Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,142
  • Joined

  • Last visited

  • Days Won

    148

Everything posted by Magictallguy

  1. Re: PHP Code to send a mail when something happens Another idea for you, create a mail_add function (like stafflog_add, or event_add). Once that's done, you can just put mail_add(UserID, "Message"); Simplified for you :P And if you have a look at the check_level() function (I haven't looked at that for a while so this purely from memory) Add in there somewhere if($ir['exp'] == $ir['exp_needed']) { $newlevel = $ir['level']+1; $sql = sprintf("INSERT INTO mail VALUES ('', %u, '%s', %u, %u, '%s', '%s')", 0, "Upgrade", $r['userid'], "unix_timestamp()", "Level Upgrade", "You can upgrade your level! Click on the Upgrade link found wherever to become level $newlevel"); $db->query($sql); } Or something like that NOT tested
  2. Re: Count Backwards :D   <?php $number = "4935"; echo sprintf("%s", number_format($number)); ?>
  3. Re: Jail and hosp Probably set up the cron job wrong..
  4. Re: i cant install HELP If you are still having trouble. Feel free to contact me on MSN [email protected]
  5. Re: Free 2 - Gym Not only did I screw up, I left in an abusable bug O_o   <?php /** If you don't understand it, leave it alone **/ $macropage = "gym.php"; include "globals.php"; global $db, $h, $ir, $userid; if ($ir['hospital']) { echo " You cannot access the gym whilst in hospital</p>"; $h->endpage(); exit; } $prefs = isset($_SESSION['gymprefs']) ? $_SESSION['gymprefs'] : array('what' => "all", 'expend' => "100%"); $what = $prefs['what']; $expend = $prefs['expend']; $message = false; $sql = sprintf("SELECT us.strength, us.agility, us.guard, us.labour, u.energy, u.will, u.jail FROM users u LEFT JOIN userstats us ON (u.userid = us.userid) WHERE (u.userid = %u)", $userid); $row = $db->fetch_row($db->query($sql)); $formID = preg_replace("`^([0-9A-F]{8})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{12})$`ms", "{\\1-\\2-\\3-\\4-\\5}", strtoupper(md5(serialize(array(session_id(), "Gym", null))))); if (isset($_POST['formID']) && is_string($_POST['formID']) && ($_POST['formID'] === $formID)) { $what = isset($_POST['what']) && is_string($_POST['what']) && preg_match("`^((all)|(strength)|(agility)|(guard)|(labour))$`ims", $_POST['what']) ? strtolower($_POST['what']) : $what; $expend = isset($_POST['expend']) && is_string($_POST['expend']) && preg_match("`^((100%)|(75%)|(50%)|(25%)|(value))$`ims", $_POST['expend']) ? strtolower($_POST['expend']) : $expend; $value = isset($_POST['value']) && is_string($_POST['value']) && preg_match("`^\d+$`ims", $_POST['value']) ? @intval($_POST['value']) : 0; $sql = sprintf("SELECT energy, will FROM users WHERE (userid = %u)", $userid); $rs = $db->query($sql); $info = $db->fetch_row($rs); $energy = $row['energy']; $will = $row['will']; switch ($expend) { case "100%": $value = $row['energy']; break; case "75%": $value = $row['energy'] * 0.75; break; case "50%": $value = $row['energy'] * 0.50; break; case "25%": $value = $row['energy'] * 0.25; break; default: break; } $value = floor($value); if ($value > $row['energy']) $message = "<span style='color:#C00;'>You don't have enough energy</span>"; else { $prefs = array('what' => $what, 'expend' => $expend); $gain = 0; $will = $row['will']; for ($i = 0; $i < $value; $i++) { $gain += mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150); $will = max(0, $will - mt_rand(1, 3)); } if ($row['jail']) $gain *= 0.5; $row['will'] = floor($will); $row['energy'] -= $value; switch ($what) { case "all": $message = sprintf("<span style='color:#070;'>You gain %s in each stat</span>", number_format($gain * 0.25, 2)); $row['strength'] += $gain * 0.25; $row['agility'] += $gain * 0.25; $row['guard'] += $gain * 0.25; $row['labour'] += $gain * 0.25; break; case "strength": $message = sprintf("<span style='color:#070;'>You gain %s in strength</span>", number_format($gain, 2)); $row['strength'] += $gain; break; case "agility": $message = sprintf("<span style='color:#070;'>You gain %s in agility</span>", number_format($gain, 2)); $row['agility'] += $gain; break; case "guard": $message = sprintf("<span style='color:#070;'>You gain %s in guard</span>", number_format($gain, 2)); $row['guard'] += $gain; break; case "labour": $message = sprintf("<span style='color:#070;'>You gain %s in labour</span>", number_format($gain, 2)); $row['labour'] += $gain; break; } $sql1 = sprintf("UPDATE userstats SET strength = %.6f, agility = %.6f, guard = %.6f, labour = %.6f WHERE (userid = %u)", $row['strength'], $row['agility'], $row['guard'], $row['labour'], $userid); $sql2 = sprintf("UPDATE users SET will = %u, energy = %d WHERE (userid = %u)", $row['will'], $row['energy'], $userid); if($gain > 1) { $sql3 = sprintf("UPDATE users SET exp = exp + %u WHERE (userid = %d)", ($ir['level']), $userid); $db->query($sql3); } $db->query($sql1); $db->query($sql2); } $_SESSION['gymprefs'] = $prefs; } $row['ranks'] = array ( 'strength' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength > %.6f)", $row['strength']))) + 1, 'agility' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (agility > %.6f)", $row['agility']))) + 1, 'guard' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (guard > %.6f)", $row['guard']))) + 1, 'labour' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (labour > %.6f)", $row['labour']))) + 1, 'total' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength + agility + guard + labour > %.6f)", $row['strength'] + $row['agility'] + $row['guard'] + $row['labour']))) + 1, ); echo "<div id='gym'>"; echo sprintf("<h3>[img=imageicons/stats.png] %sGym [img=imageicons/stats.png]</h3>", $ir['jail'] ? "Jail " : ""); if ($message) echo sprintf(" %s</p>", $message); echo "<form name='train' id='train' action='gym.php' method='post' style='padding:0;margin:0;'>"; echo sprintf("<input type='hidden' name='formID' value='%s' />", $formID); echo "<table cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<td class='h' style='width:50%;'>Train</td>"; echo "<td class='h' style='width:50%;'>Expend</td>"; echo "</tr>"; echo "<tr>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='what' id='what0' value='all' %sstyle='vertical-align:middle;' /><label for='what0' style='cursor:pointer;'>All (25%% energy in each) [Rank #%s]</label> ", $what === "all" ? "checked='checked' " : "", number_format($row['ranks']['total'])); echo sprintf("<input type='radio' name='what' id='what1' value='strength' %sstyle='vertical-align:middle;' /><label for='what1' style='cursor:pointer;'>Strength (%s) [Rank #%s]</label> ", $what === "strength" ? "checked='checked' " : "", number_format($row['strength']), number_format($row['ranks']['strength'])); echo sprintf("<input type='radio' name='what' id='what2' value='agility' %sstyle='vertical-align:middle;' /><label for='what2' style='cursor:pointer;'>Agility (%s) [Rank #%s]</label> ", $what === "agility" ? "checked='checked' " : "", number_format($row['agility']), number_format($row['ranks']['agility'])); echo sprintf("<input type='radio' name='what' id='what3' value='guard' %sstyle='vertical-align:middle;' /><label for='what3' style='cursor:pointer;'>Guard (%s) [Rank #%s]</label> ", $what === "guard" ? "checked='checked' " : "", number_format($row['guard']), number_format($row['ranks']['guard'])); echo sprintf("<input type='radio' name='what' id='what4' value='labour' %sstyle='vertical-align:middle;' /><label for='what4' style='cursor:pointer;'>Labour (%s) [Rank #%s]</label> ", $what === "labour" ? "checked='checked' " : "", number_format($row['labour']), number_format($row['ranks']['labour'])); echo "</td>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='expend' id='expend0' value='100%%' %sstyle='vertical-align:middle;' /><label for='expend0' style='cursor:pointer;'>100%% Energy</label> ", $expend === "100%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend1' value='75%%' %sstyle='vertical-align:middle;' /><label for='expend1' style='cursor:pointer;'>75%% Energy</label> ", $expend === "75%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend2' value='50%%' %sstyle='vertical-align:middle;' /><label for='expend2' style='cursor:pointer;'>50%% Energy</label> ", $expend === "50%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend3' value='25%%' %sstyle='vertical-align:middle;' /><label for='expend3' style='cursor:pointer;'>25%% Energy</label> ", $expend === "25%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend4' value='value' %sstyle='vertical-align:middle;' onclick='document.train.value.focus();' /><label for='expend4' style='cursor:pointer;'><input type='text' id='value' name='value' value='{$row['energy']}' size='8' onfocus='this.select();' /> Energy</label> ", $expend === "value" ? "checked='checked' " : ""); //(C)2008,Nyna echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' style='text-align:center;padding:6px;'>"; echo "<input type='submit' name='submit' value='Work Out!' />"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</div>"; $h->endpage(); ?> Code is fixed, tested, and bugless :) Edit: Well.. Now it is! xD
  6. Re: Free 2 - Search Which are now referred to as "Enterprise Servers"
  7. Re: Free 2 - Gym     <?php $macropage = "gym.php"; include "v1.php"; global $db, $h, $ir, $userid; if ($ir['hospital']) { echo " You cannot access the gym whilst in hospital</p>"; $h->endpage(); exit; } $prefs = isset($_SESSION['gymprefs']) ? $_SESSION['gymprefs'] : array('what' => "all", 'expend' => "100%"); $what = $prefs['what']; $expend = $prefs['expend']; $message = false; $sql = sprintf("SELECT us.strength, us.agility, us.guard, us.labour, u.energy, u.will, u.jail FROM users u LEFT JOIN userstats us ON (u.userid = us.userid) WHERE (u.userid = %u)", $userid); $row = $db->fetch_row($db->query($sql)); $formID = preg_replace("`^([0-9A-F]{8})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{12})$`ms", "{\\1-\\2-\\3-\\4-\\5}", strtoupper(md5(serialize(array(session_id(), "Gym", null))))); if (isset($_POST['formID']) && is_string($_POST['formID']) && ($_POST['formID'] === $formID)) { $what = isset($_POST['what']) && is_string($_POST['what']) && preg_match("`^((all)|(strength)|(agility)|(guard)|(labour))$`ims", $_POST['what']) ? strtolower($_POST['what']) : $what; $expend = isset($_POST['expend']) && is_string($_POST['expend']) && preg_match("`^((100%)|(75%)|(50%)|(25%)|(value))$`ims", $_POST['expend']) ? strtolower($_POST['expend']) : $expend; $value = isset($_POST['value']) && is_string($_POST['value']) && preg_match("`^\d+$`ims", $_POST['value']) ? @intval($_POST['value']) : 0; $sql = sprintf("SELECT energy, will FROM users WHERE (userid = %u)", $userid); $rs = $db->query($sql); $info = $db->fetch_row($rs); $energy = $row['energy']; $will = $row['will']; switch ($expend) { case "100%": $value = $row['energy']; break; case "75%": $value = $row['energy'] * 0.75; break; case "50%": $value = $row['energy'] * 0.50; break; case "25%": $value = $row['energy'] * 0.25; break; default: break; } $value = floor($value); if ($value > $row['energy']) $message = "<span style='color:#C00;'>You don't have enough energy</span>"; else { $prefs = array('what' => $what, 'expend' => $expend); $gain = 0; $will = $row['will']; for ($i = 0; $i < $value; $i++) { $gain += mt_rand(1, 3) / mt_rand(500, 900) * mt_rand(500, 900) * (($will + 20) / 150); $will = max(0, $will - mt_rand(1, 3)); } if ($row['jail']) $gain *= 0.5; $row['will'] = floor($will); $row['energy'] -= $value; switch ($what) { case "all": $message = sprintf("<span style='color:#070;'>You gain %s in each stat</span>", number_format($gain * 0.25, 2)); $row['strength'] += $gain * 0.25; $row['agility'] += $gain * 0.25; $row['guard'] += $gain * 0.25; $row['labour'] += $gain * 0.25; break; case "strength": $message = sprintf("<span style='color:#070;'>You gain %s in strength</span>", number_format($gain, 2)); $row['strength'] += $gain; break; case "agility": $message = sprintf("<span style='color:#070;'>You gain %s in agility</span>", number_format($gain, 2)); $row['agility'] += $gain; break; case "guard": $message = sprintf("<span style='color:#070;'>You gain %s in guard</span>", number_format($gain, 2)); $row['guard'] += $gain; break; case "labour": $message = sprintf("<span style='color:#070;'>You gain %s in labour</span>", number_format($gain, 2)); $row['labour'] += $gain; break; } $sql1 = sprintf("UPDATE userstats SET strength = %.6f, agility = %.6f, guard = %.6f, labour = %.6f WHERE (userid = %u)", $row['strength'], $row['agility'], $row['guard'], $row['labour'], $userid); $sql2 = sprintf("UPDATE users SET will = %u, energy = %d WHERE (userid = %u)", $row['will'], $row['energy'], $userid); $sql3 = sprintf("UPDATE `users` SET `exp` = (%d + %d * %d / %d) WHERE (`userid` = $u)", $ir['exp'], $_POST['amnt'], $ir['maxwill'], 750); $db->query($sql1); $db->query($sql2); $db->query($sql3); } $_SESSION['gymprefs'] = $prefs; } $row['ranks'] = array ( 'strength' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength > %.6f)", $row['strength']))) + 1, 'agility' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (agility > %.6f)", $row['agility']))) + 1, 'guard' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (guard > %.6f)", $row['guard']))) + 1, 'labour' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (labour > %.6f)", $row['labour']))) + 1, 'total' => $db->fetch_single($db->query(sprintf("SELECT COUNT(userid) FROM userstats WHERE (strength + agility + guard + labour > %.6f)", $row['strength'] + $row['agility'] + $row['guard'] + $row['labour']))) + 1, ); echo "<style type='text/css'>"; echo "#gym { }"; echo "#gym h3, #gym p { }"; echo "#gym table { width:90%;border-collapse:collapse; }"; echo "#gym th { border:solid 1px #333;background:#F6F6F6 url(titlebg.gif);padding:3px;color:#333; }"; echo "#gym td { border:solid 1px #333;padding:3px;color:#333; }"; echo "#gym { }"; echo "</style>"; echo "<div id='gym'>"; echo sprintf("<h3>%sGym</h3>", $ir['jail'] ? "Jail " : ""); if ($message) echo sprintf(" %s</p>", $message); echo "<form name='train' id='train' action='gym.php' method='post' style='padding:0;margin:0;'>"; echo sprintf("<input type='hidden' name='formID' value='%s' />", $formID); echo "<table cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<th class='sub' style='width:50%;'>Train</th>"; echo "<th class='sub' style='width:50%;'>Expend</th>"; echo "</tr>"; echo "<tr>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='what' id='what0' value='all' %sstyle='vertical-align:middle;' /><label for='what0' style='cursor:pointer;'>All (25%% energy in each) [Rank #%s]</label> ", $what === "all" ? "checked='checked' " : "", number_format($row['ranks']['total'])); echo sprintf("<input type='radio' name='what' id='what1' value='strength' %sstyle='vertical-align:middle;' /><label for='what1' style='cursor:pointer;'>Strength (%s) [Rank #%s]</label> ", $what === "strength" ? "checked='checked' " : "", number_format($row['strength']), number_format($row['ranks']['strength'])); echo sprintf("<input type='radio' name='what' id='what2' value='agility' %sstyle='vertical-align:middle;' /><label for='what2' style='cursor:pointer;'>Agility (%s) [Rank #%s]</label> ", $what === "agility" ? "checked='checked' " : "", number_format($row['agility']), number_format($row['ranks']['agility'])); echo sprintf("<input type='radio' name='what' id='what3' value='guard' %sstyle='vertical-align:middle;' /><label for='what3' style='cursor:pointer;'>Guard (%s) [Rank #%s]</label> ", $what === "guard" ? "checked='checked' " : "", number_format($row['guard']), number_format($row['ranks']['guard'])); echo sprintf("<input type='radio' name='what' id='what4' value='labour' %sstyle='vertical-align:middle;' /><label for='what4' style='cursor:pointer;'>Labour (%s) [Rank #%s]</label> ", $what === "labour" ? "checked='checked' " : "", number_format($row['labour']), number_format($row['ranks']['labour'])); echo "</td>"; echo "<td style='line-height:200%;'>"; echo sprintf("<input type='radio' name='expend' id='expend0' value='100%%' %sstyle='vertical-align:middle;' /><label for='expend0' style='cursor:pointer;'>100%% Energy</label> ", $expend === "100%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend1' value='75%%' %sstyle='vertical-align:middle;' /><label for='expend1' style='cursor:pointer;'>75%% Energy</label> ", $expend === "75%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend2' value='50%%' %sstyle='vertical-align:middle;' /><label for='expend2' style='cursor:pointer;'>50%% Energy</label> ", $expend === "50%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend3' value='25%%' %sstyle='vertical-align:middle;' /><label for='expend3' style='cursor:pointer;'>25%% Energy</label> ", $expend === "25%" ? "checked='checked' " : ""); echo sprintf("<input type='radio' name='expend' id='expend4' value='value' %sstyle='vertical-align:middle;' onclick='document.train.value.focus();' /><label for='expend4' style='cursor:pointer;'><input type='text' id='value' name='value' value='{$row['energy']}' size='8' onfocus='this.select();' /> Energy</label> ", $expend === "value" ? "checked='checked' " : "");//(C)2008,Nyna echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' style='text-align:center;padding:6px;'>"; echo "<input type='submit' name='submit' value='Train' />"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</form>"; echo "</div>"; echo "<p style='color:#CCC;'>An open-source extension from [url='http://nyna.co.uk/']Nyna[/url]</p>"; $h->endpage(); ?>   There you go!
  8. Re: Free 2 - Search I forgot to mention that I've made things slightly easier.. Contents of v1.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(); ?>   'tis very simple stuff - same idea as v2's include "globals.php";
  9. Re: Free 2 - Search For v1! <?php include "v1.php"; echo "<style type='text/css'>"; echo "table.search { border-collapse:collapse;width:95%; }"; echo "table.search th { background:#F6F6F6 url(titlebg.gif);padding:0.25em;border:solid 1px #999; }"; echo "table.search td { padding:0.25em;border:solid 1px #999; }"; echo "</style>"; function time_format( $seconds, $mode = "short" ) { $names = array('long' => array("day", "hour", "minute", "second"), 'short' => array("day", "hr", "min", "sec")); $seconds = floor($seconds); $minutes = intval($seconds / 60); $seconds -= ($minutes * 60); $hours = intval($minutes / 60); $minutes -= ($hours * 60); $days = intval($hours / 24); $hours -= ($days * 24); $result = array(); if ($days) $result[] = sprintf("%s %s%s", number_format($days), $names[$mode][0], $days == 1 ? "" : "s"); if ($hours) $result[] = sprintf("%s %s%s", number_format($hours), $names[$mode][1], $hours == 1 ? "" : "s"); if (($minutes) && (count($result) < 2)) $result[] = sprintf("%s %s%s", number_format($minutes), $names[$mode][2], $minutes == 1 ? "" : "s"); if ((($seconds) && (count($result) < 2)) || !count($result)) $result[] = sprintf("%s %s%s", number_format($seconds), $names[$mode][3], $seconds == 1 ? "" : "s"); return implode(" and ", $result); } $what = ""; if (isset($_POST['what']) && is_string($_POST['what'])) { $what = trim(substr(trim($_POST['what']) . " ", 0, 50)); $what = trim(str_replace("%", "", $what)); if (strlen($what)) { if (preg_match("`\d+`ims", $what)) { $sql = sprintf ( "SELECT `userid`, `username`, `level`, `laston`, `user_level`, `donatordays` ". "FROM `users` ". "WHERE ((`userid` = %u) OR (`username` LIKE '%%%s%%'))", $what, mysql_escape($what) ); } else { $sql = sprintf ( "SELECT `userid`, `username`, `level`, `laston`, `user_level`, `donatordays` ". "FROM `users` ". "WHERE (`username` LIKE '%%%s%%') ". "ORDER BY `username` ". "LIMIT 25", mysql_escape($what) ); } $rs = mysql_query($sql); $rows = array(); $colors = array ( 'staff' => "#C00", 'member' => "#009", 'donator' => "#070", ); while ($row = mysql_fetch_array($rs)) $rows[] = array ( 'id' => intval($row['userid']), 'name' => $row['username'], 'level' => intval($row['level']), 'ping' => intval($row['laston']), 'staff' => ($row['user_level'] > 1), 'donator' => ($row['donator'] > 0), ); // comment out these 2 lines of you do NOT want to automatically // jump to the user's profile IF there is only one result. if (count($rows) == 1) header(sprintf("Location: viewuser.php?u=%u", $rows[0]['id'])); // display results echo "<h3>Search Results</h3>"; echo "<table cellpadding='0' cellspacing='0' class='search'>"; echo "<tr>"; echo "<th style='text-align:left;'>User</th>"; echo "<th style='text-align:center;'>Level</th>"; echo "<th style='text-align:left;'>Last Seen</th>"; echo "</tr>"; foreach ($rows as $user) { echo "<tr>"; echo sprintf("<td>[url='viewuser.php?u=%u']%s [%u][/url]</td>", $user['id'], $user['staff'] ? $colors['staff'] : ($user['donator'] ? $colors['donator'] : $colors['member']), htmlspecialchars($user['name']), $user['id']); echo sprintf("<td style='text-align:center;'>%u</td>", number_format($user['level'])); echo sprintf("<td>%s ago</td>", time_format(time() - $user['ping'])); echo "</tr>"; } if (!count($rows)) { echo "<tr>"; echo "<td colspan='3'>No results found</td>"; echo "</tr>"; } echo "</table>"; } } echo "<h3>Search</h3>"; echo "<form action='search.php' method='post'>"; echo sprintf("Name or ID# <input type='text' name='what' maxlength='50' value='%s' /> ", htmlspecialchars($what)); echo "<input type='submit' value='Search' />"; echo "</form>"; echo "<p style='color:#CCC;'>An open-source extension from [url='http://nyna.co.uk/']Nyna[/url]</p>"; $h->endpage(); ?> Tested and works perfectly!
  10. Re: Multiple Item Use Mod {v1} That won't work with v2 as the itemname and so on is different..
  11. Re: Tutorial: v2 - v1 Conversion Oh shush xD
  12. Re: Tutorial: v2 - v1 Conversion Right, so... include "globals.php"; becomes session_start(); require_once __DIR__.'/mysql.php'; global $c; require_once __DIR__.'/global_func.php'; if (!array_key_exists('loggedin', $_SESSION) or 0 == $_SESSION['loggedin']) { exit(header('Location: /login.php')); } $userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) && $_SESSION['userid'] > 0 ? $_SESSION['userid'] : null; $is = mysql_query('SELECT u.*, us.* FROM users AS u INNER JOIN userstats AS us ON u.userid = us.userid WHERE u.userid = '.$userid, $c) or die(mysql_error()); if (!mysql_num_rows($is)) { session_unset(); session_destroy(); exit(header('Location: /login.php')); } $ir = mysql_fetch_assoc($is); check_level(); $fm = money_formatter($ir['money']); $cm = money_formatter($ir['crystals'], ''); $lv = date('F j, Y, g:i a', $ir['laston']); require_once __DIR__.'/header.php'; $h = new headers(); $h->startheaders(); $h->userdata($ir, $lv, $fm, $cm); $h->menuarea(); include "sglobals.php"; becomes session_start(); require_once __DIR__.'/mysql.php'; global $c; require_once __DIR__.'/global_func.php'; if (!array_key_exists('loggedin', $_SESSION) or 0 == $_SESSION['loggedin']) { exit(header('Location: /login.php')); } $userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) && $_SESSION['userid'] > 0 ? $_SESSION['userid'] : null; $is = mysql_query('SELECT u.*, us.* FROM users AS u INNER JOIN userstats AS us ON u.userid = us.userid WHERE u.userid = '.$userid, $c) or die(mysql_error()); if (!mysql_num_rows($is)) { session_unset(); session_destroy(); exit(header('Location: /login.php')); } $ir = mysql_fetch_assoc($is); if(!in_array($ir['user_level'], array(2, 3, 5))) { exit(header('Location: /index.php')); } require_once __DIR__.'/header.php'; $h = new headers(); $h->startheaders(); 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->smenuarea(); $db->query becomes mysql_query $db->fetch_row becomes mysql_fetch_assoc $db->num_rows becomes mysql_num_rows $db->fetch_single becomes mysql_result
  13. Re: [FAQ] sprintf - no, it's not a phone company I feel I must agree :)
  14. Re: NEW USERS IMAGE GALLERY FREE!!!!! Well that's an interesting mod... A lot of security will need to be implemented into that. That way you're not uploading to someone else's server! A few backdoors/worms could easiy be uploaded there lol
  15. Re: Paper Ads I might add this to my update paper mod :)
  16. Re: Updated Newspaper - more than one page Staff Functions!! SQL's Add more for more pages :) ALTER TABLE `papercontent` ADD `page2_content` LONGTEXT NOT NULL , ADD `page3_content` LONGTEXT NOT NULL ;   Open: staff_special.php Add these cases case 'editnews2': newspaper_page_2_form(); break; case 'editnews3': newspaper_page_3_form(); break; Find this function newspaper_form() { global $db,$ir,$c,$h,$userid; $q=$db->query("SELECT * FROM papercontent LIMIT 1"); $news=$db->fetch_single($q); print "<h3>Editing Newspaper</h3><form action='staff_special.php?action=subnews' method='post'> <textarea rows='7' cols='35' name='newspaper'>$news</textarea> <input type='submit' value='Change' /></form>"; } function newspaper_submit() { global $db,$ir,$c,$h,$userid; $news=$_POST['newspaper']; $db->query("UPDATE papercontent SET content='$news'"); print "Newspaper updated!"; stafflog_add("Updated game newspaper"); }   And replace with   <?php function newspaper_form() { global $db; if(!isset($_POST['submit'])) { $news = $db->fetch_single($db->query("SELECT content FROM papercontent LIMIT 1")); echo "<h3>Editing Newspaper Page 1</h3> <form action='staff_special.php?action=editnews' method='post'> <textarea rows='7' cols='35' name='newspaper'>".stripslashes($news)."</textarea> <input type='submit' name='submit' value='Change' /> </form>"; } else { $db->query("UPDATE papercontent SET content = '".$db->escape($_POST['newspaper'])."'"); echo "Newspaper updated!"; stafflog_add("Updated game newspaper page 1"); } } function newspaper_page_2_form() { global $db; if(!isset($_POST['submit'])) { $news = $db->fetch_single($db->query("SELECT page2_content FROM papercontent LIMIT 1")); echo "<h3>Editing Newspaper Page 2</h3> <form action='staff_special.php?action=editnews2' method='post'> <textarea rows='7' cols='35' name='newspaper'>".stripslashes($news)."</textarea> <input type='submit' name='submit' value='Change' /> </form>"; } else { $db->query("UPDATE papercontent SET page2_content = '".$db->escape($news)."'"); echo "Newspaper updated!"; stafflog_add("Updated game newspaper page 2"); } } function newspaper_page_3_form() { global $db; if(!isset($_POST['submit'])) { $news = $db->fetch_single($db->query("SELECT page3_content FROM papercontent LIMIT 1")); echo "<h3>Editing Newspaper Page 3</h3> <form action='staff_special.php?action=editnews3' method='post'> <textarea rows='7' cols='35' name='newspaper'>".stripslashes($news)."</textarea> <input type='submit' name='submit' value='Change' /></form>"; } else { $db->query("UPDATE papercontent SET page3_content = '".$db->escape($news)."'"); echo "Newspaper updated!"; stafflog_add("Updated game newspaper page 3"); } } Remove the current newspaper link from your smenu.php and add these ones   > [url='staff_special.php?action=editnews']Edit Newspaper Page 1[/url] > [url='staff_special.php?action=editnews2']Edit Newspaper Page 2[/url] > [url='staff_special.php?action=editnews3']Edit Newspaper Page 3[/url]   You'll also have to update the newspaper - which I'll add in to my original post :)
  17. Re: Updated Newspaper - more than one page I thought the pic would be funny too so yea :P
  18. Last updated: 30/06/20 Note: This is untested and was (re)written on no sleep. Please post any bugs below and I will repair. I'm sure this has been made before, and may have even been posted (unsure as to where) but I thought I'd post my version For this, you will need to overwrite your newspaper.php, edit staff_special.php, and run an SQL command. SQL Command Use the same naming scheme to add more pages: page#_content (where # is a unique page number) ALTER TABLE papercontent CHANGE content page1_content LONGTEXT NULL, ADD page2_content LONGTEXT NULL, ADD page3_content LONGTEXT NULL; INSERT INTO settings (conf_name, conf_value) VALUES ('newspaper_page_count', 3); newspaper.php <?php /* MC Codes v2 newspaper.php Multi-page newspaper with administrative extension Original code under MCC license Edits under DBAD: https://dbad-license.org/ */ require_once __DIR__ . '/globals.php'; $_GET['page'] = array_key_exists('page', $_GET) && is_numeric($_GET['page']) ? (int)$_GET['page'] : 1; /** * @param database $db the database wrapper object * @param array $set the game's settings * @param int $page the active page number * * @return string|null */ function get_page($db, $set, $page) { if ($page > $set['newspaper_page_count']) { return null; } $col = 'page' . $page . '_content'; $result = $db->query('SELECT ' . $col . ' FROM papercontent LIMIT 1'); if (!$db->num_rows($result)) { return null; } $content = $db->fetch_single($result); if (!$content) { return null; } return stripslashes(htmlspecialchars($content)); } ?> <h3 id="newspaper-title">The Newspaper - Page <?php echo $_GET['page']; ?></h3> <table class="table" style="width:75%;border-spacing:1px;" aria-describedby="newspaper-title"> <tr> <td><a href="job.php">Your Job</a></td> <td><a href="gym.php">Local Gym</a></td> <td><a href="halloffame.php">Hall of Fame</a></td> </tr> <tr> <th scope="col"><a href="newspaper.php?page=1">Page 1</a></th> <th scope="col"><a href="newspaper.php?page=2">Page 2</a></th> <th scope="col"><a href="newspaper.php?page=3">Page 3</a></th> </tr> <tr> <td colspan="3"><?php echo get_page($db, $set, $_GET['page']); ?></td> </tr> </table> <?php $h->endpage(); Administrative update Open: staff_special.php Find this function newspaper_form() { global $db,$ir,$c,$h,$userid; $q=$db->query("SELECT * FROM papercontent LIMIT 1"); $news=$db->fetch_single($q); print "<h3>Editing Newspaper</h3><form action='staff_special.php?action=subnews' method='post'> <textarea rows='7' cols='35' name='newspaper'>$news</textarea> <input type='submit' value='Change' /></form>"; } function newspaper_submit() { global $db,$ir,$c,$h,$userid; $news=$_POST['newspaper']; $db->query("UPDATE papercontent SET content='$news'"); print "Newspaper updated!"; stafflog_add("Updated game newspaper"); } And replace with /** * @param database $db * @return array|null */ function get_pages($db) { $data = []; $result = $db->query('SELECT * FROM papercontent'); $row = $db->fetch_row($result); foreach ($row as $key => $value) { $smolKey = str_replace('_content', '', $key); $data[$smolKey] = $value; } return !empty($data) ? $data : null; } /** * @param database $db * @param array $set * @return void */ function newspaper_form($db, $set) { $pages = get_pages($db); if (array_key_exists('submit', $_POST)) { $query = ''; $updated = []; for ($i = 1; $i <= $set['newspaper_page_count']; ++$i) { $page = 'page_' . $i; $_POST[$page] = array_key_exists($page, $_POST) && is_string($_POST[$page]) ? $_POST[$page] : ''; if ($_POST[$page] !== $pages[$page]) { $query .= ', ' . $page . '_content = \'' . $db->escape($_POST[$page]) . '\''; $updated[] = $i; } } if ($query !== '') { $count = count($updated); $query = substr($query, 2); $db->query('UPDATE papercontent SET ' . $query); stafflog_add('Updated game newspaper; ' . ($count === 1 ? 'page ' . $updated[0] : 'pages ' . implode(', ', $updated))); $pages = get_pages($db); } } ?> <h3 id="newspaper-title-edit">Editing Newspaper</h3> <form action="staff_special.php?action=editnews" method="post"> <?php for ($i = 1; $i <= $set['newspaper_page_count']; ++$i) { $content = stripslashes($pages['page' . $i]); $key = 'page' . $i; ?> <div> <label for="<?php echo $key; ?>">Page <?php echo $i; ?></label> <textarea name="<?php echo $key; ?>" id="<?php echo $key; ?>" rows="5" class="w-100" style="width:100%;"><?php echo $content; ?></textarea> </div> <?php } ?> <button type="submit" name="submit"> Update </button> </form> <?php }
  19. Re: mccodes v2 i need serious help You do realise he's posted an unedited header.php xD
  20. Re: y isnt der a jail in v1 That may also enunciated as "Indeed, it is" with or without the comma. Blimmin' 'ell, tha' was 'ard to type..
  21. Re: v3 game engine Getting back to the topic's title.. [ul] v3 should be coming out sometime before this Christmas (2008) It will be coming with a licencing kit that's been encoded. All copyrights will be reserved and handled officially. It will be the most secure Game Engine created [/ul] (Nyna will have a lot of fun with this one...) It's uses the default mysql_query in some places and sprintf in others :) You've still got a little work to do but it uses advanced (AND CLEAN!!) code!
  22. Re: Arsons City Owning Mod As I've already said in one of my other posts: Since when was this a flaming forum? - You want to flame? Do it in the right place. I seriously don't care what you think about other people, you're entitled to your opinion. But who said we wanted to hear it too?!
  23. Re: i better warn all game owners here Since when was CE a flaming board? People! I have a message for you... GROW UP! I'm 16 and I can treat people with respect. Why can't you?
  24. Re: Stats hack? I'll help you - free too :)
  25. Re: MCcodes Needs Protection V3 is coming with an encoded licencing kit. Not telling you which code but 'tis a fun one. If the licence is an invalid one, it will delete all v3 files from your website. Dabomstew was feeling a little evil when he thought of that ;)
×
×
  • Create New...