Jump to content
MakeWebGames

Seker

Members
  • Posts

    579
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Seker

  1. Your file permission isn't 777, is it? Also, you need another } right before the ?>.
  2. As you're not being too descriptive... Try this: (Untested)   <?php /*---------------------------------------------------------- -- Crystal Dealer -- Please DO NOT alter this section -- This page has been developed by David Armstead (Maniak) -- Contact me @ <a href="mailto:[email protected]">david_arm [email protected]</a> ----------------------------------------------------------*/ include_once (DIRNAME(__FILE__) .'/globals.php'); $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : 'index'; switch($_GET['action']) { case 'add': add(); break; case 'Buy': Buy(); break; default: index(); break; } if (!in_array($_GET['action'], array('index', 'add'))) { echo('Invalid Command!'); exit($h->endpage()); } function index() { global $db, $ir, $h; $q=$db->query("SELECT * FROM `crydeal`"); echo "<h3>Crystal Dealer</h3>"; if($ir['user_level'] == 2) { echo "<p align='left'><a href='dealer.php?action=add'>Add crystals to the dealer</a></p>"; } echo "<p align='left'>Welcome to the crystal Dealer. Here you can buy a set amount of crystals from the game for a set price.</p> <table width='50%' class='table'><tr> <td class='h' width='40%'>Number of Crystals</td> <td class='h' width='40%'>Cost</td> <td class='h' width='10%'></td> </tr>"; if(!$db->num_rows($q)) { echo "<tr><td colspan='3' align = 'center'>No crystals for sale here!</td></tr>"; } else { while ($r=$db->fetch_row($q)) { echo "<tr> <td width='40%'>".number_format($r['crystals'])."</td> <td width='40%'>$".number_format($r['price'])."</td> <td width='10%'><a href='dealer.php?action=Buy&id=".$r['id']."'>[buy]</td> </tr>"; } } echo "</table>"; } function add() { global $db, $ir, $h; if(isset($_POST['submit'])) { if(!isset($_POST['crystals'])) { echo "Amount of crystals cannot be empty!"; exit($h->endpage()); } if(!isset($_POST['price'])) { echo "The price cannot be empty!"; exit($h->endpage()); } else { $db->query("INSERT INTO `crydeal` VALUES(NULL, ".abs(intval($_POST['crystals'])).", ".abs(intval($_POST['price'])).")"); echo "Crystal package added. <a href='dealer.php'>[View package]</a>"; } } if($ir['user_level'] !=2) { echo "Haha, trying to fool the system?! Just get out of here!"; } else { echo "<form action='?action=add' method='post'> <table width='95%' class='table'> <tr> <td colspan='2' class='h'><center>Add a new package</td> </tr> <tr> <td>Amount of crystals</td> <td><input type='text' name='crystals' length='70'></td> </tr> <tr> <td>Cost (for the package)</td> <td><input type='text' name='price' length='70'></td> </tr> <tr> <td></td> <td align='right'><input type='submit' value='Add package' name='submit' /></td> </tr> </table> </form>"; } } function Buy() { global $h, $ir, $db; if((!isset($_GET['id'])) || !ctype_digit($_GET['id'])) { echo "Invalid use of file"; exit($h->endpage()); } else { $q=$db->query("SELECT * FROM `crydeal` WHERE `id` = ".$_GET['id'].""); if(mysql_num_rows($q) == 0) { echo "Invalid action."; exit($h->endpage()); } else { $cryd=$db->fetch_row($q); if($ir['money'] < $cryd['price']) { echo "You do not have enough Money!"; exit($h->endpage()); } $price=$cryd['price']; $crystals=$cryd['crystals']; echo "You brought ".number_format($cryd['crystals'])." for $".number_format($price).". <a href='explore.php'>Back</a>"; $db->query("UPDATE `users` SET `money` = `money` - ".$price.", `crystals` = `crystals` + ".$crystals." WHERE (`userid` = ".$_SESSION['userid'].")"); } } ?>
  3. After re-reading both posts again, twice, I realized that is exactly what you were saying. :P In any case, faster queries = faster page loads and faster page loads = happier users. So, I think the original suggestion from RoZ would be the better way to go.
  4. This seems more in the range of general good practice than it does just personal preference. Code optimization should always be done, not in general terms, but on very specific levels. On top of how you laid it out, sniko. Each time a query accesses that number, it's also accessing all 11 of those lines. As far as memory usage, I don't know if this is separate, but it seems the queries would be faster if they were limited only to what's needed. Example: INT(11) 1000 Your query would be looking for 00000000000 and changing it to 00000001000 Whereas with SMALLINT Your query would only be looking for 00000 and changing it to 01000 This make sense?
  5. http://dev.mysql.com/doc/refman/5.0/en/integer-types.html TINYINT 1 Byte SMALLINT 2 Bytes MEDIUMINT 3 Bytes INT 4 Bytes BIGINT 8 Bytes Negligible difference, but it's there.
  6. First off, I "LOL'ed" at "new [spammer/scammer/template stealer/mod distributor]." (It's like one of those workbook activities. Just insert whatever you've caught this guy doing.) My opinion on the matter? It's pretty low, and it's against the game rules of just about every single game out there. There are legitimate cross-promotion methods out there. Of course, from skooda's history, he probably cannot/will not/lacks the respect to afford them. Imagine if you ran a Burger King. The McDonald's guy is walking around in your parking lot and handing out fliers. How would you feel about that? Not very good. Not very good at all.
  7. Nice.I'm sure someone would have asked. And good going on the efficiency. Tables are just my personal preference. This was only the second mod I sat down and wrote from scratch. It works for me, so I'm pretty happy with it. But your contribution is definitely appreciated SRB.
  8. Ahh As I said, I had to strip out everything specific to my game. This isn't even called Streets for me, so nice catch.
  9. Yeah, read it wrong. My bad.
  10. On a side note, topic-related. Why pay $9 for a .co.cc when you can get your own .com for around $10..?
  11. Ah well, I'll try that order. I just thought, surely, it would go by the INSERT. Shows my freshness to the world of PHP, I suppose.
  12.   "INSERT INTO inventory (inv_itemid, inv_userid, inv_qty)   item_give($_GET['ID'],$userid,$_POST['qty']);   That doesn't match up?
  13. Yeah, actually, I took the $_NULL out and it stopped the SQL warning. However, it's still not updating the inventory. As far as security... That's my last planned step. I don't see any use in going through and securing every file while I'm still changing just about everything's layout/content on a daily basis. Not a problem until the game goes live.
  14. I found an item_give function posted here by AlabamaHit a while back. Now, using it in my streets mod doesn't give me a problem. However, when I try to replace the SQL query in itembuy.php, it doesn't update the inventory, and I get this:   Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/*******/public_html/global_func.php on line 348   Here's the item_add function as it is in global_func.php:   function item_give($userid, $itemid, $qty, $notid=0) { if($notid > 0) { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$userid} and inv_itemid={$itemid} AND inv_id != {$notid}"); } else { $q=mysql_query("SELECT * FROM inventory WHERE inv_userid={$userid} and inv_itemid={$itemid}"); } if(mysql_num_rows($q) > 0) { $r=mysql_fetch_array($q); mysql_query("UPDATE inventory SET inv_qty=inv_qty+{$qty} WHERE inv_id={$r['inv_id']}"); } else { mysql_query("INSERT INTO inventory (inv_itemid, inv_userid, inv_qty) VALUES ({$itemid}, {$userid}, {$qty})"); } }   What I have in itembuy.php:   item_give($_NULL,$_GET['ID'],$userid,$_POST['qty']);   Any ideas what I'm doing wrong? And, it's worth mentioning, when I add the { } around each of the values, it throws an "unexpected {" error.
  15. I've been asking for help a lot and I've definitely received more of it than I've earned, so I thought I should start putting out some mods. My first one is going to just be a simple revamp of a classic. I was never happy with using coordinates for searching the streets. This one simply uses mt_rand to determine outcomes is just a little cleaner and easier to edit than some floating around. As written, users get 250 steps per day and have: -- 10% chance of gaining crystals -- 16% chance of gaining money -- 11% chance of gaining experience -- 11% chance of going to the hospital -- 11% chance of going to jail -- 41% chance of nothing happening (All of this can be easily changed to your preference) SQL: ALTER TABLE `users` ADD `steps` INT( 3 ) NOT NULL DEFAULT 250;   streets.php: <?php session_start(); require "global_func.php"; if ($_SESSION['loggedin'] == 0) { header("Location: login.php"); exit; } $userid = $_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is = mysql_query( "SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid", $c) or die(mysql_error()); $ir = mysql_fetch_array($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); switch ($_GET['action']) { case 'walk': do_streets__walk(); break; default: home(); break; } function home() { global $ir,$h,$c,$userid; $q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE u.userid=$userid"); $r=mysql_fetch_array($q); $city = $r['cityname']; $trav = $ir['steps']; echo " <table width='70%' border='1'> <tr> <td align='center'> <font size='3'><b><u>The $city Streets</u></b></font> </td> </tr> <tr> <td align='center'> Take your chances with a walk through the $city streets! </td> </tr> <tr> <td align='center'> Each day, you get to travel up to <b>250</b> times! </td> </tr> <tr> <td align='center'> While traveling, you can find crystals, cash, or even gain experience! </td> </tr> <tr> <td align='center'> But, be careful! There are dangers in the streets! </td> </tr> </table> <br /><br />"; echo " <table width='70%' border='1'> <tr> <td align='center' colspan='2'> <font size='3'><b><u>What would you like to do?</u></b></font> </td> </tr> <tr> <td align='center' colspan='2'> You can travel <b>{$trav}</b> more times today! </td> </tr> <td align='center' width='50%'> <a href='streets.php?action=walk'>[Go For A Walk]</a> </td> <td align='center' width='50%'> <a href='index.php'>[Change Your Mind]</a> </td> </tr> </table> <br /><br />"; } function do_streets_walk() { global $ir,$h,$c,$userid; $q=mysql_query("SELECT u.*,c.* FROM users u LEFT JOIN cities c ON u.location=c.cityid WHERE u.userid=$userid"); $r=mysql_fetch_array($q); $chance = mt_rand(1,100); $city = $r['cityname']; $trav = $ir['steps']; if ($ir['steps'] <= 0) { echo " You have traveled enough for today! Come back tomorrow!<br /><br /> <a href='index.php'>Home</a>"; exit($h->endpage()); } if ($ir['hospital']) { echo " You cannot travel while in the hospital!<br /><br /> <a href='index.php'>Home</a>"; exit($h->endpage()); } if ($ir['jail']) { echo " You cannot travel while in jail!<br /><br /> <a href='index.php'>Home</a>"; exit($h->endpage()); } if ($ir['energy'] < 5) { echo " You are too tired to travel! You need at least 5 energy!<br /><br /> <a href='index.php'>Home</a>"; exit($h->endpage()); } echo " <table width=70% border='1'> <tr> <td align='center' width='50%'> <font size='2'>You start your journey through the $city streets!</font> </td> <td align='center' width='50%'> <font size='2'>You can travel up to <b>{$trav}</b> more times today!</font> </td> </tr> <tr>"; if ($chance <= 10) { $rewardtok = mt_rand(5,15); mysql_query("UPDATE users SET crystals=crystals+$rewardtok,steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Congratulations! You found <b>$rewardtok</b> crystals while walking through the streets! </td> </tr> <tr> <td align='center' width='50%'> <a href='streets.php?action=walk'><b>[Continue Traveling]</b></a> </td> <td align='center' width='50%'> <a href='streets.php'><b>[back]</b></a> </td> </tr> </table>"; } if (($chance >= 15) && ($chance <= 30)) { $rewardg = mt_rand(100,5000); $reward = money_formatter($rewardg); mysql_query("UPDATE users SET money=money+$rewardg,steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Congratulations! You found <b>$reward</b> while walking through the streets! </td> </tr> <tr> <td align='center' width='50%'> <a href='streets.php?action=walk'><b>[Continue Traveling]</b></a> </td> <td align='center' width='50%'> <a href='streets.php'><b>[back]</b></a> </td> </tr> </table>"; } if (($chance >= 40) && ($chance <= 50)) { $rewardexp = mt_rand(5,50); mysql_query("UPDATE users SET exp=exp+$rewardexp,steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Congratulations! You gained <b>$rewardexp<b> experience while walking through the streets! </td> </tr> <tr> <td align='center' width='50%'> <a href='streets.php?action=walk'><b>[Continue Traveling]</b></a> </td> <td align='center' width='50%'> <a href='streets.php'><b>[back]</b></a> </td> </tr> </table>"; } if (($chance >= 55) && ($chance <= 65)) { $punsb = mt_rand(3,12); mysql_query("UPDATE users SET hospital=$punsb,hospreason='Drank contaminated water',steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Oh no! You stopped for a drink, but the water was contaminated! You've gone to the hospital for <b>$punsb</b> minutes! </td> </tr> <tr> <td align='center' colspan='2'> <a href='index.php'><b>[Home]</b></a> </td> </tr> </table>"; } if (($chance >= 75) && ($chance <= 85)) { $puncage = mt_rand(3,12); mysql_query("UPDATE users SET jail=$puncage,jailreason='Suspected shoplifter',steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Oh no! You've wandered into a wealthy high-end clothing store! The store owner had you tossed in jail for <b>$puncage</b> minutes under suspicion of shoplifting! </td> </tr> <tr> <td align='center' colspan='2'> <a href='index.php'><b>[Home]</b></a> </td> </tr> </table>"; } if ((($chance > 10) && ($chance < 15)) || (($chance > 30) && ($chance < 40)) || (($chance > 50) && ($chance < 55)) || (($chance > 65) && ($chance < 75)) || ($chance > 85)) { mysql_query("UPDATE users SET steps=steps-1,energy=energy-5 WHERE userid=$userid"); echo " <td align='center' colspan='2'> Your walk has been nice, but you still haven't found anything! </td> </tr> <tr> <td align='center' width='50%'> <a href='streets.php?action=walk'><b>[Continue Traveling]</b></a> </td> <td align='center' width='50%'> <a href='streets.php'><b>[back]</b></a> </td> </tr> </table>"; } } $h->endpage();   Add to cron_day: mysql_query("UPDATE users SET steps = 250");   I did my best to take out anything specific to my game, so the wording on the hospital/jail results may be a little weird, but other than that, you shouldn't have any problems.
  16. One of the older posts on the site names CrazyT as doing some coding for goodgirl. Who knows if any of it's true. Likely, all of it. But an interesting read, none the less.
  17. Ah yes, I got confused for a second. Yeah, the forums are free. So, I don't know. Would my newspaper/staff_news/bbcode codes be needed? Or, is anyone familiar enough with how to include the code to just point me in the right direction?
  18. So, I have Cronus' secured forums (legally purchased), and with that came the bbcode engine. I'd like to enable the use of bbcode with the newspaper using that engine. Can anyone suggest what I need to include in my newspaper.php or staff_news.php?
  19. I found a pretty old post on here with an example for a Super Points postback. The problem I had, is that it was for V2, which calls a file I don't have with 1.1 (config.php). So, since I know nothing about the way the DB connections work, I kind of just started cut and pasting. I think it's working right now, except for one weird thing. When using the Admin Test, it does credit the points. The problem is, it credits the points about 8-10 separate times, and I cannot figure it out. Any pointers? I'm also trying to send an event to the user confirming the offer went through. I've tried dozens of ways, but no luck. Would appreciate any help on this. srpback.php: (I know it's probably completely wrong, so have mercy, please) <?php session_start(); require "mysql.php"; global $c; $earn = ($_GET['new']); $userid = ($_GET['uid']); $totaluser = ($_GET['total']); $offerid = ($_GET['oid']); store_lead($_GET['oid'], $_GET['uid'], $_GET['total'], $_GET['new']); echo 1; //store_lead function in classes.php// function store_lead($offerid, $userid, $totaluser, $earn){ mysql_query("SELECT * FROM `offers` WHERE `oid`='{$offerid}', `uid`='{$userid}', `total`='{$totaluser}', `new`='{$earn}'"); mysql_query("INSERT INTO `offers` (`oid`, `uid`, `total`, `new`) VALUES ('$offerid', '$userid', '$totaluser', '$earn')"); mysql_query("UPDATE `users` SET crystals = crystals+$earn WHERE userid=$userid"); //give user crystals// } //ASSIGN VARIABLES TO USER INFO $time = date("M j G:i:s Y"); $ip = getenv('REMOTE_ADDR'); $userAgent = getenv('HTTP_USER_AGENT'); $referrer = getenv('HTTP_REFERER'); $query = getenv('QUERY_STRING'); //COMBINE VARS INTO OUR LOG ENTRY $msg = "IP: " . $ip . " TIME: " . $time . " REFERRER: " . $referrer . " SEARCHSTRING: " . $query . " USERAGENT: " . $userAgent; //CALL OUR LOG FUNCTION writeToLogFile($msg); function writeToLogFile($msg) { $today = date("Y_m_d"); $logfile = $today."_log.txt"; $dir = 'postbacklogs'; $saveLocation=$dir . '/' . $logfile; if (!$handle = @fopen($saveLocation, "a")) { exit; } else { if(@fwrite($handle,"$msg\r\n")===FALSE) { exit; } @fclose($handle); } } ?>
  20. I actually got it working after like three hours of tinkering. I just tricked it a little bit. Included the top half of the menu with the header table as a <td> and added a class. Made the bottom half a second <td> as it seems you cannot stop image repeat in a <td>. At least, I couldn't figure it out. Any time I used no-repeat, the image just disappeared. I definitely will still read into !important, though. Thanks for the tip. @HauntedDawg: I've been trying to use Firebug, but I've yet to figure it out. It looks to me like it just says "Error" without telling me what the actual error is. Maybe it's because I'm using Chrome and it's considered "Firebug Lite" or maybe I'm just missing it completely. Will play around with it more, definitely.
  21. I've put my mainmenu into a table. The problem is, it will not inherit the background-image from the right class. It's still just using the default table css. Can anyone see any problems? mainmenu.php: <?php /** * MCCodes Version 1.1.1 * Copyright (C) 2005-2012 Dabomstew * All rights reserved. * * Redistribution of this code in any form is prohibited, except in * the specific cases set out in the MCCodes Customer License. * * This code license may be used to run one (1) game. * A game is defined as the set of users and other game database data, * so you are permitted to create alternative clients for your game. * * If you did not obtain this code from MCCodes.com, you are in all likelihood * using it illegally. Please contact MCCodes to discuss licensing options * in this case. * * File: mainmenu.php * Signature: 03b30e7286ced73ca9a388223ffe4caf * Date: Tue, 13 Mar 12 10:41:49 +0000 */ if (strpos($_SERVER['PHP_SELF'], "mainmenu.php") !== false) { exit; } global $c, $ir; $hc = mysql_query("SELECT * FROM users WHERE hospital > 0"); $hospitalcount = mysql_num_rows($hc); $jc = mysql_query("SELECT * FROM users WHERE jail > 0"); $jailcount = mysql_num_rows($jc); print " <table class=treemenu width=100%><td align=center> <a href='index.php'>Home</a><br /> <a href='inventory.php'>Backpack</a><br /> <a href='explore.php'>Explore</a><br /> <a href='events.php'>"; $d = mysql_query( "SELECT COUNT(*) as cnt FROM events WHERE evUSER={$ir['userid']} AND evREAD=0", $c) or die(mysql_error()); $r = mysql_fetch_array($d); if ($r['cnt'] > 0) { print "<b>Events ({$r['cnt']})</b>"; } else { print "Events (0)"; } print "</a><br /> <a href='mailbox.php'>"; $d2 = mysql_query( "SELECT COUNT(*) as cnt FROM mail WHERE mail_to={$ir['userid']} AND mail_read=0", $c) or die(mysql_error()); $r = mysql_fetch_array($d2); if ($r['cnt'] > 0) { print "<b>Mail ({$r['cnt']})</b>"; } else { print "Mail (0)"; } print "</a><br /> <a href='gym.php'>Training</a><br /> <a href='criminal.php'>Crimes</a><br /> <a href='hospital.php'>Sick Bay ({$hospitalcount})</a><br /> <a href='revenge.php'>Revenge Center</a><br /> <a href='jail.php'>Cage ({$jailcount})</a><br />"; if ($ir['gang']) { print "\n<a href='yourgang.php'>Your District</a><br />"; } print " <a href='bank.php'>Gold Storage</a><br /> <a href='job.php'>Your Job</a><br /> <a href='attladder.php'>Attack Ladder</a><br /> <a href='crystaltemple.php'>Spend Tokens</a><br /> <a href='education.php'>Learning Center</a><br /> <a href='monopaper.php'>Newspaper</a> <a href='forums.php'>Forums</a><br />"; if ($ir['donatordays']) { print "</a> <a href='donatordailycrystals.php'><b>Donator Daily Crystals</b></a><br />"; } else { print "<a href='dailycrystals.php'><b>Daily Crystals</b></a><br />"; } print " <a href='search.php'>Search</a><br /> <a href='advsearch.php'>Advanced Search</a> <br /> <br /> <br /> <br /> <br />"; if ($ir['user_level'] > 1) { print "<hr /> <b>Staff Only</b><br />\n"; if ($ir['user_level'] < 6 and $ir['user_level'] != 4) { print "<a href='new_staff.php'>Staff Panel</a><br />\n"; } } if ($ir['user_level'] > 1) { print "<hr /> <b>Staff Online:</b>"; $q = mysql_query( "SELECT * FROM users WHERE laston > " . (time() - 900) . " AND user_level>1 ORDER BY userid ASC", $c); while ($r = mysql_fetch_array($q)) { $la = time() - $r['laston']; $unit = "secs"; if ($la >= 60) { $la = (int) ($la / 60); $unit = "mins"; } if ($la >= 60) { $la = (int) ($la / 60); $unit = "hours"; if ($la >= 24) { $la = (int) ($la / 24); $unit = "days"; } } print "<a href='viewuser.php?u={$r['userid']}'>{$r['username']}</a> ($la $unit)<br />"; } } if ($ir['donatordays']) { print "<hr /> <b>Donators Only</b><br /> <a href='ddreward.php'>Daily Donator Reward</a><br /> <a href='friendslist.php'>Friends List</a><br /> <a href='blacklist.php'>Black List</a>"; } print "<hr /> <a href='preferences.php'>Preferences</a><br /> <a href='preport.php'>Player Report</a><br /> <a href='helptutorial.php'>Help Tutorial</a><br /> <a href='gamerules.php'>Game Rules</a><br /> <a href='viewuser.php?u={$ir['userid']}'>My Profile</a><br /> <a href='logout.php'>Logout</a><hr /><br /> Time is now<br /> "; echo date('F j, Y') . "<br />" . date('g:i:s a') . "</td></table>";   The CSS for a default table and the treemenu class: [CSS]table { font-family: helvetica, arial, geneva, sans-serif; font-size: 9pt; background-repeat: repeat; border-color: #FFFFFF; color: white; background-image: url(http://*****.net/images/expbg.png) }   table.treemenu { background-image: url(http://*****.net/images/tree331.png) background-repeat: no-repeat; }[/CSS]
  22. Ahh Thank you all. Will give this a shot and see how it comes out.
  23. Would I do it just like the display_pic column in users? Set it as text and insert the link?
  24. I believe the problem with this is, I would still be limited to using one image for every city. I'm trying to use separate images for each city.
  25. Google "Angry Birds." Then shoot yourself when you realize that's what our world has been whittled down to as far as entertainment.
×
×
  • Create New...