function nextLocationIdFromRange($location_type, $file = __FILE__, $line = __LINE__) { switch ($location_type) { case 'arena_fighting_location': $min = 90001; $max = 95001; break; case 'item_storage_location': $min = 95001; $max = 100001; break; default: die("Invalid location range({$location_type}:{$min}-{$max}) requested in call to " . __FUNCTION__ . "() by " . $file . "#" . $line); } $query = "select max(id) from phaos_locations where id>={$min} and id<{$max}"; $id = fetch_value($query); if (!$id) { //die("No id found(bad sql?) in location range($location_type) requested in call to ".__FUNCTION__."() by ".$file."#".$line); $query = "insert into phaos_locations\n (id, name, image_path, special, buildings, pass, explore)\n values\n ({$min}, 'BEGIN location range({$location_type}:{$min}-{$max})','images/special.gif',1,0,1,0)\n "; $req = mysql_query($query); if (!$req) { showError(__FILE__, __LINE__, __FUNCTION__); exit; } $id = $min; } ++$id; if ($id >= $max) { die("No ids left in location range({$location_type}:{$min}-{$max}) requested in call to " . __FUNCTION__ . "() by " . $file . "#" . $line . "<br> SQL:" . $query); } defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = "issued id {$id} as {$location_type}"; return $id; }
function item_drop($location, $item) { $query = "select number from phaos_ground where location='{$location}' and item_id='{$item['id']}' and item_type='{$item['type']}'"; $here = fetch_value($query, __FILE__, __LINE__, __FUNCTION__); $number = $item['number']; if ($here) { $number += $here; } $query = "REPLACE INTO phaos_ground (location,item_id,item_type,number)\n VALUES ('{$location}','{$item['id']}','{$item['type']}','{$number}')"; $req = mysql_query($query); if (!$req) { showError(__FILE__, __LINE__, __FUNCTION__); exit; } defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = "Dropped item:" . print_r($item, true); }
function remove_item($item_id, $item_type) { $query = "select id FROM phaos_char_inventory\n\t\t\t\tWHERE username='******'\n AND item_id='{$item_id}'\n AND type='{$item_type}'"; $id = fetch_value($query, __FILE__, __LINE__, __FUNCTION__); if ($id) { $req = mysql_query("delete from phaos_char_inventory where id={$id}"); if (!$req) { showError(__FILE__, __LINE__, __FUNCTION__); exit; } return 1; } else { return 0; } }
$newEmail = $emailPswd = ""; $newEmail = test_input($_POST["newEmail"]); $emailPswd = test_input($_POST["emailPswd"]); $emailPswd = md5($emailPswd); if (empty($newEmail) || empty($emailPswd)) { $action['result'] = 'error'; array_push($updateErr, "Aizpildiet visus epasta maiņas laukus"); } else { if (!filter_var($newEmail, FILTER_VALIDATE_EMAIL)) { $action['result'] = 'error'; array_push($updateErr, "Nederīgs epasts"); } if (email_exists($newEmail, $conn)) { $action['result'] = 'error'; array_push($updateErr, "Epasts ir aizņemts"); } if ($emailPswd != fetch_value('password', 'users', 'username', $_SESSION['user_username'], $conn)) { $action['result'] = 'error'; array_push($updateErr, "Nepareiza parole"); } } if ($action['result'] != 'error') { $update_email = update_email($newEmail, $_SESSION['user_id'], $conn); if ($update_email) { $_SESSION['user_email'] = $newEmail; exit; } else { array_push($updateErr, "Neizdevās atjaunināt epastu"); } } output_errors($updateErr);
/* Thanks to all who contribute(d) to this */ /* * This files codes a blacksmith in a style that can be used to code any shop * this blacksmith can sell other stuff too */ include "header.php"; include_once "items.php"; include_once "shop_functions.php"; include_once "class_character.php"; $refresh = 0; //determine if the SideBar has to be refreshed $character = new character($PHP_PHAOS_CHARID); // shop_valid($character->location, 'blacksmith'); shop_valid($character->location, $shop_id); // auto-generate refills if the shop does not exist yet $refills = fetch_value("SELECT count(*) FROM phaos_shop_refill WHERE shop_id='{$shop_id}'", __FILE__, __LINE__); if (!$refills) { //blacksmith refills v1.0 //insert_shop_refill($shop_id, 'armor', $item_value_min, $item_value_growth, $item_value_growth_probability, $item_count_min); insert_shop_refill($shop_id, 'weapon', rand(1, 400), 1.5, 0.83, 5); insert_shop_refill($shop_id, 'armor', rand(1, 3000), 1.5, 0.7, 1); insert_shop_refill($shop_id, 'boots', rand(1, 500), 2.0, 0.7, 1); insert_shop_refill($shop_id, 'gloves', rand(1, 500), 2.0, 0.5, 1); insert_shop_refill($shop_id, 'helm', rand(1, 700), 2.0, 0.5, 1); insert_shop_refill($shop_id, 'shield', rand(1, 160), 1.5, 0.5, 1); } //generic processing for a shop include_once "shop_include.php"; ?> <table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">
<?php include "header.php"; include_once "class_character.php"; $refsidebar = false; $character = new character($PHP_PHAOS_CHARID); $char_loc = $character->location; $location_name = fetch_value("SELECT name FROM phaos_locations WHERE id = '{$char_loc}'"); include_once "location_actions.php"; $pickedup = pickup_actions($character); if ($pickedup > 0) { $refsidebar = true; ?> <div align="center"><?php echo $pickedup . " " . $lang_char['itemspickedup']; ?> </div><?php } if ($refsidebar) { refsidebar(); $refsidebar = false; } ?> <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="center" valign="top"> <table border="0" cellspacing="5" cellpadding="0" width="100%"> <tr> <td align="center" colspan="2"> <img src="lang/<?php
$basicsquery = "SELECT phaos_shop_basics.*, phaos_buildings.name, phaos_buildings.location FROM phaos_buildings LEFT JOIN phaos_shop_basics USING(shop_id) WHERE location = '" . $character->location . "' AND phaos_shop_basics.shop_id='{$shop_id}'"; $shop_basics = fetch_first($basicsquery, __FILE__, __LINE__); @$shop_basics['shop_id'] or die("shop({$shop_id}), {$shop_basics['name']} at({$shop_basics['location']}) has no shop_basics entry"); //FIXME: // auto-generate the location the shop stores its items at if (!$shop_basics['item_location_id']) { $new_item_location_id = nextLocationIdFromRange('item_storage_location', __FILE__, __LINE__); $storage_name = "Store of Shop at {$shop_basics['location']}"; $query = "insert into phaos_locations (id,name,special) values ({$new_item_location_id},'{$storage_name}',1)"; $req = mysql_query($query); if (!$req) { showError(__FILE__, __LINE__, __FUNCTION__, $query); exit; } //check $new_item_location_id = fetch_value("select id from phaos_locations where name='{$storage_name}' LIMIT 1", __FILE__, __LINE__); if ($new_item_location_id) { $query = "update phaos_shop_basics set item_location_id={$new_item_location_id} where shop_id='{$shop_id}'"; $req = mysql_query($query); if (!$req) { showError(__FILE__, __LINE__, __FUNCTION__, $query); exit; } //rerun query $shop_basics = fetch_first($basicsquery, __FILE__, __LINE__); } else { die("Failed allocate a location for {$storage_name}"); } } defined('DEBUG') and DEBUG and $GLOBALS['debugmsgs'][] = "shop({$shop_id}) storing items at {$shop_basics['item_location_id']}"; $current_time = time();
<?php include "../init.php"; $loginError = ""; $username = $password = ""; $username = test_input($_POST["username"]); $password = test_input($_POST["password"]); if (empty($username) === true || empty($password) === true) { $loginError = 'Ievadiet lietotājvārdu un paroli'; } else { if (username_exists($username, $conn) === false) { $loginError = 'Lietotājvārds netika atrasts'; } else { if (user_active($username, $conn) === false) { $loginError = 'Apstipriniet savu e-pasu'; } else { $login = login($username, $password, $conn); if ($login === false) { $loginError = 'Nepareiza parole'; } else { $_SESSION['user_id'] = $login; if (logged_in() === true) { $_SESSION['user_username'] = fetch_value('username', 'users', 'user_id', $_SESSION['user_id'], $conn); $_SESSION['user_email'] = fetch_value('email', 'users', 'user_id', $_SESSION['user_id'], $conn); } exit; } } } } echo $loginError;