//Não deixa fazer nada se estiver em um duelo. if ($userrow["batalha_timer2"] == 5) { global $topvar; $topvar = true; display("Você não pode fazer nenhum movimento enquanto estiver em um duelo. Clique <a href=\"users.php?do=resetarduelo\">aqui</a>, para resetar seu Duelo atual. ", "Erro", false, false, false); die; } if (isset($_GET["do"])) { $do = explode(":", $_GET["do"]); // Town functions. if ($do[0] == "inn") { include 'towns.php'; inn(); } elseif ($do[0] == "buy") { include 'towns.php'; buy(); } elseif ($do[0] == "buy2") { include 'towns.php'; buy2($do[1]); } elseif ($do[0] == "buy3") { include 'towns.php'; buy3($do[1]); } elseif ($do[0] == "sell") { include 'towns.php'; sell(); } elseif ($do[0] == "maps") { include 'towns.php'; maps(); } elseif ($do[0] == "maps2") { include 'towns.php'; maps2($do[1]);
if (!$ok[$quant]) { redirect("index.php?page=buyok&error=4"); } if ($ok[$quant][userID]) { redirect("index.php?page=buyok&error=5"); } $timenow = $ok[$quant][fromtime]; $totime = $ok[$quant][totime]; } if ($timenow < time()) { redirect("index.php?page=buyok&error=2"); } $rems = 0; $prices = array(0, 200, 300, 400, 500); $remembers = array(); if ($_POST[rem]) { foreach ($_POST[rem] as $rem) { if ($rem[on]) { $remembers[] = array(before => $rem[before] * 1, min => $rem[min] * 1); } } } if ($user[balans] >= read_setting("price") + $prices[count($remembers)]) { buy($user[userID], $nowday, $quant, $mashine); if ($remembers) { buy_sms($user[userID], $nowday, $quant, $mashine, $remembers); } redirect("index.php?page=buyok&error=6"); } else { redirect("index.php?page=buyok&error=1"); }
function buy3($id) { // Update user profile with new item & stats. if (isset($_POST["cancel"])) { header("Location: index.php"); die; } global $userrow; $townquery = doquery("SELECT name,itemslist FROM {{table}} WHERE latitude='" . $userrow["latitude"] . "' AND longitude='" . $userrow["longitude"] . "' LIMIT 1", "towns"); if (mysql_num_rows($townquery) != 1) { display("Tentativa de trapaça detectada.<br>", "Error"); } $townrow = mysql_fetch_array($townquery); $townitems = explode(",", $townrow["itemslist"]); if (!in_array($id, $townitems)) { display("Tentativa de trapaça detectada.<br>", "Error"); } $itemsquery = doquery("SELECT * FROM {{table}} WHERE id='{$id}' LIMIT 1", "items"); $itemsrow = mysql_fetch_array($itemsquery); if ($userrow["gold"] < $itemsrow["buycost"]) { global $conteudo; $conteudo = personagemgeral("Você não tem Ryou suficiente para comprar esse item.<br /><br />Você pode retornar à <a href=\"index.php\">cidade</a>, <a href=\"index.php?do=buy\">shop</a>, ou usar os botões de direção para continuar explorando.", 'personagem1', 'Anari'); buy(); die; } if ($itemsrow["type"] == 1) { // weapon // Check if they already have an item in the slot. if ($userrow["weaponid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='" . $userrow["weaponid"] . "' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($itemsquery2); } else { $itemsrow2 = array("attribute" => 0, "buycost" => 0, "special" => "X"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "X") { $special = explode(",", $itemsrow["special"]); $tochange = $special[0]; $userrow[$tochange] = $userrow[$tochange] + $special[1]; $specialchange1 = "{$tochange}='" . $userrow[$tochange] . "',"; if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "X") { $special2 = explode(",", $itemsrow2["special"]); $tochange2 = $special2[0]; $userrow[$tochange2] = $userrow[$tochange2] - $special2[1]; $specialchange2 = "{$tochange2}='" . $userrow[$tochange2] . "',"; if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; } } // New stats. $newgold = $userrow["gold"] + ceil($itemsrow2["buycost"] / 4) - $itemsrow["buycost"]; $newattack = $userrow["attackpower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $userrow["id"]; if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; } if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; } if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; } if ($userrow["currentnp"] > $userrow["maxnp"]) { $newnp = $userrow["maxnp"]; } else { $newnp = $userrow["currentnp"]; } if ($userrow["currentep"] > $userrow["maxep"]) { $newep = $userrow["maxep"]; } else { $newep = $userrow["currentep"]; } //Nova durabilidade. $durab = explode(",", $userrow['durabilidade']); $novadurab = "-,"; for ($j = 1; $j < 6; $j++) { if ($j == 1) { $novadurab .= "X,"; } else { $novadurab .= $durab[$j] . ","; } } $novadurab .= $durab[6]; // Final update. $updatequery = doquery("UPDATE {{table}} SET {$specialchange1} {$specialchange2} gold='{$newgold}', attackpower='{$newattack}', weaponid='{$newid}', weaponname='{$newname}', currenthp='{$newhp}', currentmp='{$newmp}', currenttp='{$newtp}',currentnp='{$newnp}',currentep='{$newep}',sorte='" . $userrow["sorte"] . "',agilidade='" . $userrow["agilidade"] . "',determinacao='" . $userrow["determinacao"] . "',precisao='" . $userrow["precisao"] . "',inteligencia='" . $userrow["inteligencia"] . "',droprate='" . $userrow["droprate"] . "', durabilidade='{$novadurab}' WHERE id='{$userid}' LIMIT 1", "users"); } elseif ($itemsrow["type"] == 2) { // Armor // Check if they already have an item in the slot. if ($userrow["armorid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='" . $userrow["armorid"] . "' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($itemsquery2); } else { $itemsrow2 = array("attribute" => 0, "buycost" => 0, "special" => "X"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "X") { $special = explode(",", $itemsrow["special"]); $tochange = $special[0]; $userrow[$tochange] = $userrow[$tochange] + $special[1]; $specialchange1 = "{$tochange}='" . $userrow[$tochange] . "',"; if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "X") { $special2 = explode(",", $itemsrow2["special"]); $tochange2 = $special2[0]; $userrow[$tochange2] = $userrow[$tochange2] - $special2[1]; $specialchange2 = "{$tochange2}='" . $userrow[$tochange2] . "',"; if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; } } // New stats. $newgold = $userrow["gold"] + ceil($itemsrow2["buycost"] / 4) - $itemsrow["buycost"]; $newdefense = $userrow["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $userrow["id"]; if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; } if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; } if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; } if ($userrow["currentnp"] > $userrow["maxnp"]) { $newnp = $userrow["maxnp"]; } else { $newnp = $userrow["currentnp"]; } if ($userrow["currentep"] > $userrow["maxep"]) { $newep = $userrow["maxep"]; } else { $newep = $userrow["currentep"]; } //Nova durabilidade. $durab = explode(",", $userrow['durabilidade']); $novadurab = "-,"; for ($j = 1; $j < 6; $j++) { if ($j == 2) { $novadurab .= "X,"; } else { $novadurab .= $durab[$j] . ","; } } $novadurab .= $durab[6]; // Final update. $updatequery = doquery("UPDATE {{table}} SET {$specialchange1} {$specialchange2} gold='{$newgold}', defensepower='{$newdefense}', armorid='{$newid}', armorname='{$newname}', currenthp='{$newhp}', currentmp='{$newmp}', currenttp='{$newtp}', currentnp='{$newnp}',currentep='{$newep}',sorte='" . $userrow["sorte"] . "',agilidade='" . $userrow["agilidade"] . "',determinacao='" . $userrow["determinacao"] . "',precisao='" . $userrow["precisao"] . "',inteligencia='" . $userrow["inteligencia"] . "',droprate='" . $userrow["droprate"] . "', durabilidade='{$novadurab}' WHERE id='{$userid}' LIMIT 1", "users"); } elseif ($itemsrow["type"] == 3) { // Shield // Check if they already have an item in the slot. if ($userrow["shieldid"] != 0) { $itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='" . $userrow["shieldid"] . "' LIMIT 1", "items"); $itemsrow2 = mysql_fetch_array($itemsquery2); } else { $itemsrow2 = array("attribute" => 0, "buycost" => 0, "special" => "X"); } // Special item fields. $specialchange1 = ""; $specialchange2 = ""; if ($itemsrow["special"] != "X") { $special = explode(",", $itemsrow["special"]); $tochange = $special[0]; $userrow[$tochange] = $userrow[$tochange] + $special[1]; $specialchange1 = "{$tochange}='" . $userrow[$tochange] . "',"; if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; } if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; } } if ($itemsrow2["special"] != "X") { $special2 = explode(",", $itemsrow2["special"]); $tochange2 = $special2[0]; $userrow[$tochange2] = $userrow[$tochange2] - $special2[1]; $specialchange2 = "{$tochange2}='" . $userrow[$tochange2] . "',"; if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; } if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; } } // New stats. $newgold = $userrow["gold"] + ceil($itemsrow2["buycost"] / 4) - $itemsrow["buycost"]; $newdefense = $userrow["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"]; $newid = $itemsrow["id"]; $newname = $itemsrow["name"]; $userid = $userrow["id"]; if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; } if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; } if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; } if ($userrow["currentnp"] > $userrow["maxnp"]) { $newnp = $userrow["maxnp"]; } else { $newnp = $userrow["currentnp"]; } if ($userrow["currentep"] > $userrow["maxep"]) { $newep = $userrow["maxep"]; } else { $newep = $userrow["currentep"]; } //Nova durabilidade. $durab = explode(",", $userrow['durabilidade']); $novadurab = "-,"; for ($j = 1; $j < 6; $j++) { if ($j == 3) { $novadurab .= "X,"; } else { $novadurab .= $durab[$j] . ","; } } $novadurab .= $durab[6]; // Final update. $updatequery = doquery("UPDATE {{table}} SET {$specialchange1} {$specialchange2} gold='{$newgold}', defensepower='{$newdefense}', shieldid='{$newid}', shieldname='{$newname}', currenthp='{$newhp}', currentmp='{$newmp}', currenttp='{$newtp}', currentnp='{$newnp}',currentep='{$newep}',sorte='" . $userrow["sorte"] . "',agilidade='" . $userrow["agilidade"] . "',determinacao='" . $userrow["determinacao"] . "',precisao='" . $userrow["precisao"] . "',inteligencia='" . $userrow["inteligencia"] . "',droprate='" . $userrow["droprate"] . "', durabilidade='{$novadurab}' WHERE id='{$userid}' LIMIT 1", "users"); } global $conteudo; $conteudo = personagemgeral('O negócio foi realizado com sucesso. Muito obrigado(a) por comprar esse item!', 'personagem1', 'Anari'); buy(); }
$user = $tmp[2]; $date = time(); $cmd = "SELECT * FROM `jos_users` WHERE id=" . $acc; $inf = mysql_fetch_assoc(mysql_query($cmd)); $inc = $inf['mua_' . $add] + $count; $cmd = "UPDATE `jos_users` SET mua_" . $add . '=' . $inc . ' WHERE id=' . $acc; mysql_query($cmd); $cmd = "INSERT INTO `jos_history` (userid,time,method," . $add . ",tongcong) VALUES (" . $user . "," . $date . ",'Tin nhắn SMS','" . $count . "|" . $price / $count . "'," . $price . ")"; mysql_query($cmd); response($phone, $note); } switch ($tmp[1]) { case 'NUP': apply('day tin', 1, 5000); break; case 'NDD': apply('danh dau tin', 2, 10000); break; case 'NNB': apply('noi bat tin', 3, 15000); break; case 'MUP': buy('nap quyen day tin', 1, 2, 5000); break; case 'MDD': buy('nap quyen danh dau tin', 2, 1, 10000); break; case 'MNB': buy('nap quyen noi bat tin', 3, 1, 15000); break; }
<?php $port = 12345; $addr = '192.168.7.83'; $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); socket_bind($sock, $addr, $port); socket_listen($sock); $sock = socket_accept($sock); $buf = socket_read($sock, 1024); list($user, $goods) = split('[/]', $buf); $res = buy($user, $goods); echo "res : " . $res . "\n"; socket_write($sock, $res, 1024); sleep(5); socket_close($sock); function buy($user, $goods) { // parameter setting $url = "localhost"; $admin = "root"; $passwd = "07s49power"; $db = "smc"; date_default_timezone_set('Asia/Tokyo'); $date = date('Y-m-d G:i:s'); //preparation $link = mysql_connect($url, $admin, $passwd) or die("failed\n"); mysql_select_db($db, $link) or die("Not found such a database\n"); $sql = "SET CHARACTER SET UTF8"; mysql_query($sql, $link) or die("Can't set character-set to UTF8\n"); // userのbarcodeをnameに変換するう $sql = "SELECT name FROM user WHERE barcode = \"" . $user . "\"";
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_code('ocworld'); require_code('ocworld_screens'); // Decide what functions to execute for this command $command = either_param('type', 'room'); $param = either_param('param', ''); $dest_member_id = either_param_integer('user', -1); $member_id = get_member(); if (is_guest($member_id)) { ocw_refresh_with_message(do_lang_tempcode('W_NOT_LOGGED_IN'), 'warn'); return new ocp_tempcode(); } $item = either_param('item', ''); // Create the member if they aren't already in the system $member_rows = $GLOBALS['SITE_DB']->query_select('w_members', array('*'), array('id' => $member_id), '', 1); if (!array_key_exists(0, $member_rows)) { $member_rows[0] = array('id' => $member_id, 'location_realm' => 0, 'location_x' => 0, 'location_y' => 0, 'banned' => 0, 'health' => 10, 'trolled' => 0, 'lastactive' => time()); $GLOBALS['SITE_DB']->query_insert('w_members', $member_rows[0]); } $member_row = $member_rows[0]; // Check for banning if ($member_row['banned'] == 1) { ocw_refresh_with_message(do_lang_tempcode('W_YOU_BANNED'), 'warn'); } // Check for death if ($member_row['health'] < 1) { take_items($member_id); $GLOBALS['SITE_DB']->query_update('w_members', array('location_realm' => 0, 'location_x' => 0, 'location_y' => 0, 'banned' => 0, 'health' => 10), array('id' => $member_id), '', 1); ocw_refresh_with_message(do_lang_tempcode('W_YOU_DIED'), 'warn'); } // Mark as active $GLOBALS['SITE_DB']->query_update('w_members', array('lastactive' => time()), array('id' => $member_id), '', 1); destick($member_id); // Check to see if the user is locked into answering a trolls questions if ($member_row['trolled'] != 0) { $realm = $member_row['location_realm']; // Get the questions that were asked $i = 0; $trolled = $member_row['trolled']; $q = array(); $a = array(); while (($trolled & 255 << $i * 8) != 0) { $q_num = $trolled >> $i * 8 & 255; $q[$i + 1] = $GLOBALS['SITE_DB']->query_value('w_realms', 'q' . strval($q_num), array('id' => $realm)); $a[$i + 1] = $GLOBALS['SITE_DB']->query_value('w_realms', 'a' . strval($q_num), array('id' => $realm)); $i++; } $num_questions = $i; // Are we marking or answering? if (post_param('a1', '!!') != '!!') { // Mark them $pass = 0; for ($i = 1; $i <= $num_questions; $i++) { $given = strtolower(post_param('a' . strval($i))); $stored = strtolower($a[$i]); if ($given == $stored) { $pass++; } elseif (strstr(':' . $stored . ':', ':' . $given . ':') !== false) { $pass++; } } // Regardless they have had their chance: no more questions $GLOBALS['SITE_DB']->query_update('w_members', array('trolled' => 0), array('id' => $member_id), '', 1); if ($pass == 0) { $pen_id = mt_rand(0, 2); if ($pen_id == 0) { $joke = mt_rand(1, 10); $penalty = do_lang_tempcode('W_JOKE_' . strval($joke)); hurt($member_id); } if ($pen_id == 1) { $penalty = do_lang('W_PENALTY_STOLEN'); steal($member_id, -$realm - 1); } if ($pen_id == 2) { $penalty = do_lang('W_PENALTY_SENT_LOBBY'); basic_enter_room($member_id, $realm, 0, 0); } ocw_refresh_with_message(do_lang_tempcode('W_TROLL_YOU', escape_html($penalty)), 'warn'); } else { ocw_refresh_with_message(do_lang_tempcode('W_TROLL_THANKYOU', integer_format($pass))); } } else { $troll_name = $GLOBALS['SITE_DB']->query_value('w_realms', 'troll_name', array('id' => $realm)); $title = get_page_title('W_TROLL_Q', true, array(escape_html($troll_name))); $questions = new ocp_tempcode(); for ($i = 1; $i <= $num_questions; $i++) { $questions->attach(do_template('W_TROLL_QUESTION', array('_GUID' => 'b09eb44e4264a9dca5bdf651ca9a48d4', 'Q' => $q[$i], 'I' => strval($i)))); } return do_template('W_TROLL', array('_GUID' => 'e108ccaebc5b1adfa9db6b5b23e93602', 'TITLE' => $title, 'TROLL' => $troll_name, 'QUESTIONS' => $questions)); } } // There is a chance the troll on this realm will pick this 'turn' to move if (mt_rand(0, 6) == 1) { $realm = $member_row['location_realm']; $troll_id = -$realm - 1; $troll_loc = get_loc_details($troll_id, true); if (!is_null($troll_loc)) { list(, $troll_x, $troll_y) = $troll_loc; $dx = -1; $dy = -1; do { $dx = mt_rand(-1, 1); $dy = mt_rand(-1, 1); } while (!room_exists($troll_x + $dx, $troll_y + $dy, $realm)); $GLOBALS['SITE_DB']->query_update('w_members', array('location_x' => $troll_x + $dx, 'location_y' => $troll_y + $dy), array('id' => $troll_id), '', 1); } } require_code('uploads'); // What command are we being asked to do? if ($command == 'confirm') { $url = build_url(array('page' => 'ocworld'), '_SELF'); $command2 = either_param('btype', ''); $item = either_param('item', ''); $user = either_param_integer('user', -1); $param = either_param('param', ''); return do_template('W_CONFIRM_SCREEN', array('_GUID' => '365870cb4c6cb4282ff6c7a11f4f8a5b', 'TITLE' => get_page_title('W_CONFIRM_TITLE'), 'URL' => $url, 'COMMAND' => $command2, 'ITEM' => $item, 'USER' => strval($user), 'PARAM' => $param)); } if ($command == 'reallocate') { if (!has_specific_permission(get_member(), 'administer_ocworld')) { ocw_refresh_with_message(do_lang_tempcode('W_ONLY_STAFF_REALLOC'), 'warn'); } $out = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('items', array('*'), array('copy_owner' => NULL)); foreach ($rows as $myrow) { $owner = $GLOBALS['SITE_DB']->query_value('w_itemdef', 'owner', array('name' => $myrow['name'])); if (!is_null($owner)) { $GLOBALS['SITE_DB']->query_update('w_items', array('copy_owner' => $owner), array('name' => $myrow['name'], 'copy_owner' => NULL)); $out->attach(paragraph(do_lang_tempcode('W_REALLOCATING', escape_html($myrow['name']), 'tfgdfgd4rf'))); } } return do_template('W_REALLOCATE', array('_GUID' => '8fa4b9205310d6bc2fc28348a52898d5', 'TITLE' => get_page_title('W_REALLOCATE'), 'OUT' => $out)); } if ($command == 'portal') { portal($member_id, intval($param)); } if ($command == 'realms') { realms(); return new ocp_tempcode(); } if ($command == 'up') { $tpl = try_to_enter_room($member_id, 0, -1, ''); if (!is_null($tpl)) { return $tpl; } ocw_refresh_with_message(new ocp_tempcode()); } if ($command == 'down') { $tpl = try_to_enter_room($member_id, 0, 1, ''); if (!is_null($tpl)) { return $tpl; } ocw_refresh_with_message(new ocp_tempcode()); } if ($command == 'right') { $tpl = try_to_enter_room($member_id, 1, 0, ''); if (!is_null($tpl)) { return $tpl; } ocw_refresh_with_message(new ocp_tempcode()); } if ($command == 'left') { $tpl = try_to_enter_room($member_id, -1, 0, ''); if (!is_null($tpl)) { return $tpl; } ocw_refresh_with_message(new ocp_tempcode()); } if ($command == 'answered') { $tpl = try_to_enter_room($member_id, post_param_integer('dx'), post_param_integer('dy'), $param); if (!is_null($tpl)) { return $tpl; } } if ($command == 'drop') { drop_wrap($member_id, $item); } if ($command == 'give') { give($member_id, $dest_member_id, $item); } if ($command == 'pickpocket') { pickpocket($member_id, $dest_member_id); } if ($command == 'use') { useitem($member_id, $item); } if ($command == 'take') { take($member_id, $item, $dest_member_id); } if ($command == 'buy') { buy($member_id, $item, $dest_member_id); } if ($command == 'inventory') { $tpl = output_inventory_screen($dest_member_id); return $tpl; } if ($command == 'findperson') { findperson($param == '' ? strval($dest_member_id) : $param); } if ($command == 'message') { message($member_id, post_param('post'), post_param_integer('tuser')); } if ($command == 'emergency') { basic_enter_room($member_id, 0, 0, 0); } if ($command == 'delete-message-by-person') { if (!has_specific_permission($member_id, 'administer_ocworld') && $member_id != $dest_member_id) { ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn'); } delete_message($member_id, $dest_member_id, addslashes($param)); } // Management if ($command == 'additem') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { $tpl = do_template('W_ITEM_SCREEN', array('_GUID' => '0246f7037a360996bdfb4f1dcf96bcfc', 'PRICE' => integer_format(get_price('mud_item')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ITEM_TEXT')), 'TITLE' => get_page_title('W_ADD_ITEM_TITLE'), 'PAGE_TYPE' => 'additem', 'ITEM' => '', 'DESCRIPTION' => '', 'BRIBABLE' => '0', 'HEALTHY' => '0', 'PICTURE_URL' => '', 'MAX_PER_PLAYER' => '10', 'REPLICATEABLE' => '1')); return $tpl; } $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); add_item_wrap($member_id, $name, post_param_integer('cost', 0), post_param_integer('not_infinite', 0), post_param_integer('bribable', 0), post_param_integer('healthy', 0), $urls[0], post_param_integer('max_per_player', -1), post_param_integer('replicateable', 0), post_param('description')); } if ($command == 'additemcopy') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'w_itemdef WHERE replicateable=1 OR owner=' . strval((int) get_member()) . ' ORDER BY name'); $items = ''; foreach ($rows as $myrow) { $items .= "<option value=\"" . escape_html($myrow['name']) . "\">" . escape_html($myrow['name']) . "</option>"; } if ($items == '') { ocw_refresh_with_message(do_lang_tempcode('W_NO_ITEMS_YET'), 'warn'); } if ($GLOBALS['XSS_DETECT']) { ocp_mark_as_escaped($items); } $tpl = do_template('W_ITEMCOPY_SCREEN', array('_GUID' => '15799930bca51eafdee3c0a8e197866a', 'PRICE' => integer_format(get_price('mud_item_copy')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ITEM_COPY_TEXT')), 'TITLE' => get_page_title('W_ADD_ITEM_COPY_TITLE'), 'PAGE_TYPE' => 'additemcopy', 'NOT_INFINITE' => '1', 'ITEMS' => $items, 'COST' => '')); return $tpl; } add_item_wrap_copy($member_id, $name, post_param_integer('cost'), post_param_integer('not_infinite', 0)); } if ($command == 'addroom') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { list($realm, $x, $y) = get_loc_details($member_id); $tpl = do_template('W_ROOM_SCREEN', array('_GUID' => '5357a6cf8648c952cf29c2b7234cfa6c', 'PRICE' => integer_format(get_price('mud_room')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_ROOM_TEXT')), 'ROOM_TEXT' => '', 'TITLE' => get_page_title('W_ADD_ROOM_TITLE'), 'PAGE_TYPE' => 'addroom', 'NAME' => '', 'PASSWORD_QUESTION' => '', 'PASSWORD_ANSWER' => '', 'PASSWORD_FAIL_MESSAGE' => '', 'REQUIRED_ITEM' => '', 'LOCKED_UP' => '0', 'LOCKED_DOWN' => '0', 'LOCKED_LEFT' => '0', 'LOCKED_RIGHT' => '0', 'ALLOW_PORTAL' => '1', 'PICTURE_URL' => '')); return $tpl; } $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); add_room_wrap($member_id, post_param_integer('position'), $name, post_param('text'), post_param('password_question'), post_param('password_answer'), post_param('password_fail_message'), post_param('required_item'), post_param_integer('locked_up', 0), post_param_integer('locked_down', 0), post_param_integer('locked_right', 0), post_param_integer('locked_left', 0), $urls[0], post_param_integer('allow_portal', 0)); } if ($command == 'addrealm') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { $fortnights = (time() - $GLOBALS['FORUM_DRIVER']->get_member_join_timestamp(get_member())) / (60 * 60 * 24 * 7 * 2); $made = $GLOBALS['SITE_DB']->query_value('w_realms', 'COUNT(*)', array('owner' => get_member())); $left = round($fortnights - $made); $_qa = new ocp_tempcode(); for ($i = 1; $i <= 30; $i++) { $_qa->attach(do_template('W_REALM_SCREEN_QUESTION', array('_GUID' => '5fa7725f11b0df7e58ff83f2f1751515', 'I' => strval($i), 'Q' => '', 'A' => ''))); } $tpl = do_template('W_REALM_SCREEN', array('_GUID' => '7ae26fe1766aed02233e1be84772759b', 'PRICE' => integer_format(get_price('mud_realm')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_REALM_TEXT', integer_format($left))), 'TITLE' => get_page_title('W_ADD_REALM_TITLE'), 'PAGE_TYPE' => 'addrealm', 'QA' => $_qa, 'NAME' => '', 'TROLL_NAME' => '', 'PRIVATE' => '0')); return $tpl; } $i = 1; $qa = array(); while (strlen(post_param('question' . strval($i), '')) > 0) { $qa[$i] = array(); $qa[$i]['q'] = post_param('question' . strval($i)); $qa[$i]['a'] = post_param('answer' . strval($i)); $i++; } $urls1 = get_url('jail_pic_url', 'jail_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); $urls2 = get_url('jail_house_pic_url', 'jail_house_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); $urls3 = get_url('lobby_pic_url', 'lobby_pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); add_realm_wrap($member_id, $name, post_param('troll_name'), post_param('jail_name'), post_param('jail_text'), $urls1[0], post_param('jail_house_name'), post_param('jail_house_text'), $urls2[0], post_param('lobby_name'), post_param('lobby_text'), $urls3[0], $qa, post_param_integer('private', 0)); } if ($command == 'addportal') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { $tpl = do_template('W_PORTAL_SCREEN', array('_GUID' => '69e74a964f69721d0381a920c4a25ce5', 'PRICE' => integer_format(get_price('mud_portal')), 'TEXT' => paragraph(do_lang_tempcode('W_ADD_PORTAL_TEXT')), 'TITLE' => get_page_title('W_ADD_PORTAL_TITLE'), 'PORTAL_TEXT' => '', 'PAGE_TYPE' => 'addportal', 'NAME' => '', 'END_LOCATION_REALM' => '', 'END_LOCATION_X' => '', 'END_LOCATION_Y' => '')); return $tpl; } add_portal_wrap($member_id, $name, post_param('text'), post_param_integer('end_location_realm', -1), post_param_integer('end_location_x', -1), post_param_integer('end_location_y', -1)); } if ($command == 'deleteitem') { require_code('ocworld_action'); delete_item_wrap($item); } if ($command == 'deleteroom') { require_code('ocworld_action'); delete_room_wrap($member_id); } if ($command == 'deleterealm') { require_code('ocworld_action'); delete_realm_wrap($member_id); } if ($command == 'deleteportal') { require_code('ocworld_action'); delete_portal_wrap($member_id, intval($param)); } // Admin commands if (has_specific_permission($member_id, 'administer_ocworld')) { if ($command == 'mergeitems') { merge_items($item, either_param('item2')); } if ($command == 'teleport-person') { $ast = strpos($param, ':'); $b = strpos($param, ':', $ast + 1); $realm = substr($param, 0, $ast); $x = intval(substr($param, $ast + 1, $b - $ast - 1)); $y = intval(substr($param, $b + 1)); basic_enter_room($dest_member_id, $realm, $x, $y); } if ($command == 'imprison-person') { imprison($dest_member_id); } if ($command == 'hurt-person') { hurt($dest_member_id); } if ($command == 'dehurt-person') { dehurt($dest_member_id); } if ($command == 'ban-person') { ban_member($dest_member_id); } if ($command == 'unban-person') { unban_member($dest_member_id); } if ($command == 'take-from-person') { steal($member_id, $dest_member_id); } } if ($command == 'edititem') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { $rows = $GLOBALS['SITE_DB']->query_select('w_itemdef', array('*'), array('name' => either_param('item')), '', 1); if (!array_key_exists(0, $rows)) { ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn'); } $row = $rows[0]; $tpl = do_template('W_ITEM_SCREEN', array('_GUID' => '1f581864bd2f0cbe05742e03ab6c2a53', 'TITLE' => get_page_title('W_EDIT_ITEM_TITLE'), 'PAGE_TYPE' => 'edititem', 'ITEM' => either_param('item'), 'DESCRIPTION' => $row['description'], 'BRIBABLE' => strval($row['bribable']), 'HEALTHY' => strval($row['healthy']), 'PICTURE_URL' => $row['picture_url'], 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']), 'MAX_PER_PLAYER' => strval($row['max_per_player']), 'REPLICATEABLE' => strval($row['replicateable']))); return $tpl; } $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); edit_item_wrap($member_id, $item, $name, post_param_integer('bribable', 0), post_param_integer('healthy', 0), $urls[0], grab_new_owner('new_owner'), post_param_integer('max_per_player', -1), post_param_integer('replicateable', 0), post_param('description')); } if ($command == 'edititemcopy') { require_code('ocworld_action'); $cost = post_param_integer('cost', -1); if ($cost == -1) { $user = get_param_integer('user'); list($realm, $x, $y) = get_loc_details($member_id); $cost = $GLOBALS['SITE_DB']->query_value('w_items', 'cost', array('copy_owner' => $user, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'name' => get_param('item'))); $not_infinite = $GLOBALS['SITE_DB']->query_value('w_items', 'not_infinite', array('copy_owner' => $user, 'location_x' => $x, 'location_y' => $y, 'location_realm' => $realm, 'name' => get_param('item'))); $tpl = do_template('W_ITEMCOPY_SCREEN', array('_GUID' => 'a8d28f6516408dba96a8b57ddcd7cee6', 'TITLE' => get_page_title('W_EDIT_ITEM_COPY_TITLE'), 'PAGE_TYPE' => 'edititemcopy', 'NOT_INFINITE' => strval($not_infinite), 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($realm), 'ITEM' => get_param('item'), 'OWNER' => strval($user), 'COST' => strval($cost))); return $tpl; } edit_item_wrap_copy($member_id, $item, $cost, post_param_integer('not_infinite', 0), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm'), grab_new_owner('new_owner')); } if ($command == 'editroom') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { list($location_realm, $x, $y) = get_loc_details($member_id); $rows = $GLOBALS['SITE_DB']->query_select('w_rooms', array('*'), array('location_x' => $x, 'location_y' => $y, 'location_realm' => $location_realm), '', 1); if (!array_key_exists(0, $rows)) { ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn'); } $row = $rows[0]; $tpl = do_template('W_ROOM_SCREEN', array('_GUID' => 'a4c5f8ae962cdbaa304135cf07c583a0', 'TITLE' => get_page_title('W_EDIT_ROOM_TITLE'), 'PAGE_TYPE' => 'editroom', 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($location_realm), 'NAME' => $row['name'], 'ROOM_TEXT' => $row['r_text'], 'PASSWORD_QUESTION' => $row['password_question'], 'PASSWORD_ANSWER' => $row['password_answer'], 'PASSWORD_FAIL_MESSAGE' => $row['password_fail_message'], 'REQUIRED_ITEM' => $row['required_item'], 'LOCKED_UP' => strval($row['locked_up']), 'LOCKED_DOWN' => strval($row['locked_down']), 'LOCKED_LEFT' => strval($row['locked_left']), 'LOCKED_RIGHT' => strval($row['locked_right']), 'ALLOW_PORTAL' => strval($row['allow_portal']), 'PICTURE_URL' => $row['picture_url'], 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']))); return $tpl; } $urls = get_url('url', 'pic', 'uploads/ocworld', 0, OCP_UPLOAD_IMAGE); edit_room_wrap($member_id, $name, post_param('text'), post_param('password_question'), post_param('password_answer'), post_param('password_fail_message'), post_param('required_item'), post_param_integer('locked_up', 0), post_param_integer('locked_down', 0), post_param_integer('locked_right', 0), post_param_integer('locked_left', 0), $urls[0], post_param_integer('allow_portal', 0), grab_new_owner('new_owner'), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm')); } if ($command == 'editrealm') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { list($realm, , ) = get_loc_details($member_id); $rows = $GLOBALS['SITE_DB']->query_select('w_realms', array('*'), array('id' => $realm), '', 1); if (!array_key_exists(0, $rows)) { ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn'); } $row = $rows[0]; $qatc = new ocp_tempcode(); for ($i = 1; $i <= 30; $i++) { $qatc->attach(do_template('W_REALM_SCREEN_QUESTION', array('_GUID' => '0510427a3895969dede2bd13db7d46a6', 'I' => strval($i), 'Q' => $row['q' . strval($i)], 'A' => $row['a' . strval($i)]))); } $tpl = do_template('W_REALM_SCREEN', array('_GUID' => 'f2503e0be6e45a296baa8625cafb4d72', 'TITLE' => get_page_title('W_EDIT_REALM_TITLE'), 'PAGE_TYPE' => 'editrealm', 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']), 'QA' => $qatc, 'NAME' => $row['name'], 'TROLL_NAME' => $row['troll_name'], 'PRIVATE' => strval($row['r_private']))); return $tpl; } for ($i = 1; $i <= 30; $i++) { $qa[$i]['q'] = post_param('question' . strval($i)); $qa[$i]['a'] = post_param('answer' . strval($i)); } edit_realm_wrap($member_id, $name, post_param('troll_name'), $qa, post_param_integer('private', 0), grab_new_owner('new_owner')); } if ($command == 'editportal') { require_code('ocworld_action'); $name = post_param('name', ''); if ($name == '') { list($realm, $x, $y) = get_loc_details($member_id); $end_realm = get_param_integer('param'); $rows = $GLOBALS['SITE_DB']->query_select('w_portals', array('*'), array('start_location_x' => $x, 'start_location_y' => $y, 'start_location_realm' => $realm, 'end_location_realm' => $end_realm), '', 1); if (!array_key_exists(0, $rows)) { ocw_refresh_with_message(do_lang_tempcode('MISSING_RESOURCE'), 'warn'); } $row = $rows[0]; $tpl = do_template('W_PORTAL_SCREEN', array('_GUID' => 'cad0e01c1c4c410e67b775c3ff6eeb3a', 'TITLE' => get_page_title('W_EDIT_PORTAL_TITLE'), 'PAGE_TYPE' => 'editportal', 'X' => strval($x), 'Y' => strval($y), 'REALM' => strval($realm), 'PARAM' => $param, 'NAME' => $row['name'], 'PORTAL_TEXT' => $row['p_text'], 'END_LOCATION_REALM' => strval($end_realm), 'END_LOCATION_X' => strval($row['end_location_x']), 'END_LOCATION_Y' => strval($row['end_location_y']), 'OWNER' => is_null($row['owner']) ? '' : strval($row['owner']))); return $tpl; } edit_portal_wrap($member_id, intval($param), $name, post_param('text'), post_param_integer('end_location_realm'), post_param_integer('end_location_x'), post_param_integer('end_location_y'), grab_new_owner('new_owner'), post_param_integer('new_x'), post_param_integer('new_y'), post_param_integer('new_realm')); } if ($command == 'room') { return output_room_screen($member_id); } ocw_refresh_with_message(do_lang('SUCCESS')); return new ocp_tempcode(); }
<head> <title>Transaction Details</title> </head> <body> <h1> Transaction Details</h1> <br> <?php $username = $_POST['username']; $transaction = $_POST['type']; $stockSymbol = $_POST['symbol']; $amount = $_POST['amount']; switch ($transaction) { case "buy": buy($stockSymbol, $amount, $username); break; case "sell": echo "Not Implemented"; break; default: echo "You broke the simulator!"; } function buy($stockSymbol, $amount, $username) { $msg = "Your (buy) transaction was successful."; $msg .= "</br>*Function not actually implemented!*"; echo $msg; } ?>
<?php include_once '../include/headers.php'; include_once '../include/dbutils.php'; include_once '../include/main.php'; include_once 'domain/orders.php'; db_connect(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $request_payload = file_get_contents('php://input'); //var_dump($request_payload); $json = json_decode($request_payload); if (isset($_GET['assignToOrderId'])) { $value = assignProduct($json, $_GET['assignToOrderId']); } else { $value = buy($json); } //return JSON array exit(json_encode($value)); }
$value_holding = $qty * $price; $buy_net = $value_holding; $p_avg = $price; $query_insert = "INSERT INTO `{$trader}`(`scrip_id`, `buy_qty`, `buy_price`,`holding`,`value_holding`, `buy_net`, `avg_price`) VALUES ('{$id}','{$qty}','{$price}','{$qty}','{$value_holding}','{$buy_net}','{$p_avg}')"; $query_insert_run = mysql_query($query_insert); } header('Location:myspace.php'); } } $trader = $_SESSION['user_id']; if (loggedin()) { if (isset($_POST['scrip_buy']) && isset($_POST['qty'])) { $id = $_POST['scrip_buy']; // id of the scrip for buy request $qty = $_POST['qty']; $query_price = "SELECT `current_price` FROM `ltp` WHERE `id`='{$id}'"; // price of the scrip for buy request $query_price_run = mysql_query($query_price); while ($row = mysql_fetch_assoc($query_price_run)) { $price = $row['current_price']; } // qty requested buy($price, $qty, $id, $trader); //buy function for the id } } else { echo 'You are not logged in'; } ?>
$servername = "localhost"; $username = "******"; $password = ""; $dbname = "eBay"; session_start(); if (isset($_POST['action'])) { switch ($_POST['action']) { case 'login': logIn($_POST['eMail'], $_POST['password']); break; case 'addtoCart': addToCart($_POST['id'], $_POST['quantity']); break; case 'buy': buy($_POST['id'], $_POST['quantity']); break; case 'signup': signUp($_POST['eMail'], $_POST['password'], $_POST['firstname'], $_POST['lastname']); break; case 'upload_image': uploadImage(); break; case 'add_to_cart': addToCart(); break; case 'load_products': loadProducts(); break; case 'load_cart_products': loadCartProducts();