Exemple #1
0
function add_resource($id_resource)
{
    global $user_id, $char, $_SESSION;
    if ($id_resource > 0) {
        $res = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$id_resource}"));
        $Res = new Res($res);
        $check = $Res->add_user(0, $user_id);
        if ($check == 1) {
            setCraftTimes($user_id, 6, 1, 1);
            echo 'Ты добыл: ' . $res['name'];
            myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$id_resource}, 0, 1, " . time() . ", {$user_id}, 'z')");
            if (isset($_SESSION['cur_get_mining'])) {
                $dob = explode('###', $_SESSION['cur_get_mining']);
                $find = 0;
                for ($i = 0; $i < sizeof($dob); $i++) {
                    $cur_dob = explode("&&&", $dob[$i]);
                    if ($cur_dob[0] == $res['name']) {
                        $find = 1;
                        $col = (int) $cur_dob[1] + 1;
                        $dob[$i] = $res['name'] . '&&&' . $col;
                    }
                }
                if ($find == 0) {
                    $dob[] = $res['name'] . '&&&1';
                }
                $_SESSION['cur_get_mining'] = implode("###", $dob);
            } else {
                $str = $res['name'] . '&&&1';
                $_SESSION['cur_get_mining'] = $str;
            }
        } else {
            echo 'У Вас недостаточно свободного места в инвентаре!';
        }
    }
}
function forgotPwd()
{
    global $req;
    global $connection;
    global $module;
    $req->hasParams("email");
    $email = $req->getParam("email");
    $POST = array('email' => $email);
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('email', 'email', true, 2, 100, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $connection->close();
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Error: " . $errors);
    } else {
        $POST = $val->sanitized;
        $email = $module->escape($POST['email']);
        $output = $module->forgotPwd($email);
        if (is_bool($output)) {
            Res::sendInvalid($module->message);
        } else {
            $res = new Res();
            $res->send();
        }
    }
}
Exemple #3
0
 public function authorize(Req $req, Res $res, $args)
 {
     $grant_type = $req->getInput('grant_type');
     $client_id = $req->getServerParam('PHP_AUTH_USER');
     $client_secret = $req->getServerParam('PHP_AUTH_PW');
     $oauth = new Oauth();
     $result = $oauth->get_token($client_id, $client_secret, $grant_type);
     return $res->authorize_output($result);
 }
Exemple #4
0
 public function photo_urls(Req $req, Res $res, $args)
 {
     $params = $req->getQueryParams();
     $jd_id = $args['jd_id'] ?? '0';
     $params['jd_id'] = $jd_id;
     $m_p = new \App\Model\Photo();
     $result = $m_p->get_urls($params);
     return $res->output($result);
 }
Exemple #5
0
 /**
  * Funkcja sprawdzająca czy zadane hasło jest wystarczająco silne - ma minimum 8 znaków, wielką i małą literę, cyfrę oraz znak specjalny.
  *
  * @param  string     $_value sprawdzane haslo
  * @return null|array NULL w przypadku wystarczająco silnego hasla, tablica błędów w przeciwnym przypadku
  * @see Res::call("validate_password_error_length")
  * @see Res::call("validate_password_error_noNumber")
  * @see Res::call("validate_password_error_noUppercase")
  * @see Res::call("validate_password_error_noLowercase")
  * @see Res::call("validate_password_error_noSpecial")
  */
 public static function password($_value)
 {
     $min_length = 8;
     $uppercase = '/[A-Z]/';
     //Uppercase
     $lowercase = '/[a-z]/';
     //lowercase
     $special_chars = '!@#$%^&*()_=+{};:,<.>';
     $special = "/[{$special_chars}]/";
     // whatever you mean by 'special char'
     $number = '/[0-9]/';
     //numbers
     $return = array();
     if (strlen($_value) < $min_length) {
         $return[] = \Res::call("validate_password_error_length", $min_length);
     }
     if (preg_match($number, $_value) < 1) {
         $return[] = \Res::call("validate_password_error_noNumber");
     }
     if (preg_match($uppercase, $_value) < 1) {
         $return[] = \Res::call("validate_password_error_noUppercase");
     }
     if (preg_match($lowercase, $_value) < 1) {
         $return[] = \Res::call("validate_password_error_noLowercase");
     }
     if (preg_match($special, $_value) < 1) {
         $return[] = \Res::call("validate_password_error_noSpecial", $special_chars);
     }
     return $return ? $return : null;
 }
Exemple #6
0
 /**
  * MAKE A RESERVATION
  * @param int id(user id) :int pid : int amount: int status;
  */
 public function makeRes($pid, $amount, $status = 0)
 {
     $res = new Res();
     $res->id = Yii::app()->user->id;
     $res->pid = $pid;
     $res->amount = $amount;
     $res->status = $status;
     $res->save();
 }
function addUsers()
{
    global $req;
    global $connection;
    $req->hasParams("adminUName", "adminFName", "adminGender", "adminEMail", "adminPassword", "adminPhone");
    $adminUName = $req->getParam("adminUName");
    $adminFName = $req->getParam("adminFName");
    $adminGender = $req->getParam("adminGender");
    $adminEMail = $req->getParam("adminEMail");
    $adminPassword = $req->getParam("adminPassword");
    $adminPhone = $req->getParam("adminPhone");
    $POST = array('adminUName' => $adminUName, 'adminFName' => $adminFName, 'adminGender' => $adminGender, 'adminEMail' => $adminEMail, 'adminPassword' => $adminPassword, 'adminPhone' => $adminPhone);
    $genderValues = array('m', 'f', 'u');
    $val = new validation();
    $val->addSource($POST);
    $val->addRule('adminUName', 'string', true, 2, 50, true)->addRule('adminFName', 'string', true, 2, 50, true)->addRule('adminGender', 'string', true, 1, 1, true)->addRule('adminEMail', 'email', true, 5, 100, true)->addRule('adminPassword', 'string', true, 4, 35, true)->addRule('adminPhone', 'string', true, 4, 20, true);
    $val->run();
    if (sizeof($val->errors) > 0) {
        $errors = implode(" <br/> ", $val->errors);
        Res::sendInvalid("Errors:" . $errors);
    } else {
        $POST = $val->sanitized;
        $adminTable = new adminTable($connection);
        $adminUName = $adminTable->escape($POST['adminUName']);
        $adminFName = $adminTable->escape($POST['adminFName']);
        $adminGender = $adminTable->escape($POST['adminGender']);
        $adminEMail = $adminTable->escape($POST['adminEMail']);
        $adminPassword = $adminTable->escape($POST['adminPassword']);
        $adminPhone = $adminTable->escape($POST['adminPhone']);
        $adminId = $adminTable->insertUsers($adminUName, $adminFName, $adminGender, $adminEMail, $adminPassword, $adminPhone);
        if (is_bool($adminId)) {
            Res::sendInvalid("Errors:" . $adminTable->message);
        } else {
            $res = new Res();
            $res->addData("adminId", $adminId);
            $res->send();
        }
    }
}
 public function hasParams()
 {
     if (!isset($this->req['param'])) {
         Res::sendInvalid("noParam");
     }
     $params = func_get_arg(0);
     $numArgs = func_num_args();
     for ($i = 0; $i < $numArgs; $i++) {
         if (!isset($this->req['param'][func_get_arg($i)])) {
             Res::sendInvalid("missingParam:" . func_get_arg($i));
         }
     }
 }
 $check_res = 0;
 for ($i = 0; $i < $ress_num; $i++) {
     //для каждого реса
     $rid_index = 'rid' . $i;
     $col_index = 'col' . $i;
     $res_id = (int) $_POST[$rid_index];
     if (!is_numeric($_POST[$col_index])) {
         $res_col = 0;
     } else {
         $res_col = max(0, $_POST[$col_index]);
     }
     if ($res_col > 0) {
         $res_need = mysql_result(myquery("SELECT res_num FROM dungeon_users_progress WHERE user_id=" . $user_id . " AND quest_id = " . $id . " AND res_id=" . $res_id . ""), 0, 0);
         $res_col = min($res_need, $res_col);
         $res_result = $res_need - $res_col;
         $Res = new Res(0, $res_id);
         $check = $Res->add_user(0, $user_id, -$res_col);
         if ($check == 1) {
             myquery("UPDATE dungeon_users_progress SET res_num=" . $res_result . " WHERE user_id=" . $user_id . " AND res_id =" . $res_id . " AND quest_id=" . $id . " ");
             $check_res = 1;
         } else {
             echo $Res->message;
         }
     }
 }
 //проверим, не выполнен ли квест
 echo '<table cellpadding="0" cellspacing="0" width="80%" border="0"><tr><td><p align=justify><br><center>';
 $done_check = myquery("SELECT max(res_num) FROM dungeon_users_progress WHERE user_id=" . $user_id . " and quest_id = " . $id . " ");
 list($res_num) = mysql_fetch_array($done_check);
 $done = 1;
 if ($res_num > 0) {
Exemple #10
0
     } else {
         echo '<tr><td align=center><font size=2 face=verdana><b>В твоем инвентаре нет предметов.</td></tr>';
     }
     echo '<tr align=center><td colspan=4>';
     $href = '?sell&sellitem=0&';
     if (isset($_POST['in_id'])) {
         $href .= 'in_id=' . $_POST['in_id'] . '&';
     }
     echo '<center>Страница: ';
     show_page($page, $allpage, $href);
     $all = $pg;
     echo '<br>(Всего предметов в инвентаре: ' . $all . ')</td></tr></table>';
 } elseif (isset($_GET['sellres']) and is_numeric($_GET['sellres'])) {
     if ($_GET['sellres'] > 0 and isset($_POST['sellcount']) and is_numeric($_POST['sellcount'])) {
         $sellcount = (int) $_POST['sellcount'];
         $Res = new Res(0, $_GET['sellres']);
         $Res->sell($sellcount);
         echo '<center>' . $Res->message . '</center>';
     }
     if ($_GET['sellres'] > 0 and !isset($_POST['sellcount'])) {
         $result_items = myquery("SELECT craft_resource.id AS res_id, craft_resource.name, craft_resource.img1, craft_resource_user.col, craft_resource.incost cena FROM craft_resource, craft_resource_user WHERE craft_resource_user.user_id=" . $user_id . " AND craft_resource.id=craft_resource_user.res_id AND craft_resource.id=" . $_GET['sellres'] . "");
         if (mysql_num_rows($result_items)) {
             $items = mysql_fetch_array($result_items);
             echo '<center><br /><br />За 1 единицу ресурса - ' . $items['cena'] . ' ' . pluralForm($items['cena'], 'монета', 'монеты', 'монет') . '<br /><br /><br /><br /><form action="?sell&sellres=' . $_GET['sellres'] . '" method="post">';
             QuoteTable('open');
             echo '<br />&nbsp;<br /><img align="middle" src="http://' . img_domain . '/item/resources/' . $items["img1"] . '.gif">&nbsp;&nbsp;&nbsp;&nbsp;' . $items['name'] . '&nbsp;&nbsp;&nbsp;&nbsp;Продать: <input type="text" name="sellcount" value="0" size="4" maxlength="4">&nbsp;&nbsp;из&nbsp;&nbsp;' . $items['col'] . ' ед. <br />&nbsp;<br />';
             echo '<center><input type="submit" value="Продать"></form><br/><br>';
             QuoteTable('close');
             echo '<br><br><a href="shop.php?sell&sellres=0">Вернуться</a>';
         }
     } else {
        echo '</table></td>';
        echo '<td>';
        echo $b->bauzeit . " Ticks";
        echo '</td>';
        echo '<td>';
        for ($i = 0; $i < sizeof($b->untergrund); $i++) {
            echo '<img src="images/buildings/' . $b->untergrund[$i]->bild . '" border="0" />';
        }
        echo '</td></tr>';
    }
    echo '</table>';
}
if ($_GET["kategorie"] == "rohstoffe") {
    echo '<h3>Rohstoffe</h3>';
    echo '<table class="liste"><tr><th>id</th><th>Name</th><th>Bild</th></tr>';
    $list = Res::getList();
    for ($i = 0; $i < sizeof($list); $i++) {
        echo '<tr><td>' . $list[$i]->id . '<td>' . $list[$i]->name . '</td><td><img src="images/misc/' . $list[$i]->bild . '" border="0" /></td></tr>';
    }
    echo '</table><br />';
}
if ($_GET["kategorie"] == "weltraum") {
    echo '<h3>Weltraumfelder</h3>';
    echo '<table class="liste">';
    $list = Weltraumfelder::getList();
    echo '<table>';
    for ($i = 0; $i < sizeof($list); $i++) {
        if ($i % 3 == 0 || $i == 0) {
            echo '<tr>';
        }
        echo '<td><table class="liste">';
                }
            }
            if ($check == 0) {
                echo "<span style=\"font-family:Tahoma,Verdana,helvetica;font-size:11px;color:#80FF80;\">{$build['name']} - тебе не удалось собрать этот ресурс</span>";
                myquery("INSERT INTO craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) VALUES ({$build_id}, '0', '" . $b[0] . "', '0', '0', " . time() . ", {$user_id}, 'n')");
            }
            echo '<br>';
        } else {
            echo 'Владелец не смог с тобой расплатиться ресурсом: ' . $build['name'] . '!<br>';
        }
    }
    echo '</b>';
    //выплата владельцу
    $select1 = myquery("select * from craft_build where id={$build_type}");
    $re = mysql_fetch_array($select1);
    $dohod1 = $re['res_dob'];
    $aa = explode("|", $dohod1);
    for ($i = 0; $i < count($aa); $i++) {
        $bb = explode("-", $aa[$i]);
        if (sizeof($bb) != 2) {
            continue;
        }
        $select2 = myquery("select * from craft_resource where id={$bb['0']}");
        $build = mysql_fetch_array($select2);
        $Res = new Res($build);
        $check = $Res->add_user(0, $build_vladel);
        if ($check == 1 and $admin_build != 1) {
            myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values ({$build_id}, '', {$bb['0']}, {$bb['1']}, '', " . time() . ", {$build_vladel}, 'p')");
        }
    }
}
Exemple #13
0
    if (!isset($_POST['submit'])) {
        $selres = myquery("SELECT * FROM craft_resource_user WHERE user_id={$user_id} AND res_id={$resid}");
        if ($selres != false and mysql_num_rows($selres) > 0) {
            $res = mysql_fetch_array($selres);
            QuoteTable('open');
            echo 'Укажи кол-во ресурса, которые ты хочешь выбросить:<br>';
            echo '<form action="act.php?func=inv&dropres=' . $resid . '" method="POST">';
            echo '<img src=http://' . img_domain . '/item/resources/' . $ress['img3'] . '.gif border=0 width=50 height=50> ' . $ress['name'] . ' - есть ' . $res['col'] . ' ед.<br><br>';
            echo 'Выбросить: <input type="text" name="kol" value="1" size=5 maxsize=5> ед.    ';
            echo '<input type="submit" name="submit" value="Выбросить">';
            echo '</form>';
            QuoteTable('close');
        }
    } elseif (isset($_POST['kol']) and $_POST['kol'] > 0 and is_numeric($_POST['kol'])) {
        $kol = (int) $_POST['kol'];
        $Res = new Res($ress, 0);
        $Res->drop($kol);
        QuoteTable('open');
        echo $Res->message;
        QuoteTable('close');
    }
}
$sel_used_items = myquery("SELECT id,item_id,used FROM game_items WHERE user_id={$user_id} AND priznak=0 AND used>0");
$used_items = array();
while ($it = mysql_fetch_array($sel_used_items)) {
    $used_items[$it['used']]['id'] = $it['id'];
    $used_items[$it['used']]['item_id'] = $it['item_id'];
}
PrintInv($user_id, 0);
$check = myquery("SELECT * FROM game_users_complects WHERE user_id='" . $user_id . "'");
$kol = mysql_num_rows($check);
Exemple #14
0
 public function paginate($num)
 {
     //
     // count data
     $sql = "select count(*) as nbRows from " . $this->table;
     $var = Database::read($sql);
     $nbRows = $var[0]['nbRows'];
     $nbPages = ceil($nbRows / $num);
     //
     //if isset get
     $page = 1;
     if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) {
         if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $nbPages) {
             $page = Res::get(Config::get('view.pagination_param'));
         }
     }
     //
     $r = array();
     //
     $sql = "select * from " . $this->table . " Limit " . ($page - 1) * $num . ",{$num}";
     $var = Database::read($sql);
     foreach ($var as $key => $value) {
         //echo $value[0];
         $o = new self($value[0], $this->table);
         //print_r(get_object_vars($o));
         array_push($r, $o);
     }
     //
     // call the data array
     $g = new DataArray($r, true, $nbRows, $num, $page);
     return $g;
 }
Exemple #15
0
 public static function run()
 {
     $currentUrl = self::CheckUrl();
     //
     if (self::CheckMaintenance($currentUrl)) {
         self::ReplaceParams();
         self::Replace();
         //
         $ok = false;
         //
         foreach (self::$requests as $value) {
             $requestsUrl = $value["url"];
             //var_dump($value);
             //
             if (preg_match("#^{$requestsUrl}\$#", $currentUrl, $params)) {
                 if (!is_null($value["subdomain"])) {
                     if (Table::contains($value["subdomain"], self::getDomain())) {
                         if ($value["methode"] == "post" && Res::isPost()) {
                             $ok = self::exec($params, $value);
                             break;
                         } else {
                             if ($value["methode"] == "post" && !Res::isPost()) {
                                 $ok = 0;
                             } else {
                                 if ($value["methode"] == "get") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "resource") {
                                         $ok = self::exec($params, $value);
                                         break;
                                     } else {
                                         if ($value["methode"] == "object") {
                                             $ok = self::exec($params, $value);
                                             //var_dump($value);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         $ok = 0;
                     }
                 } else {
                     if ($value["methode"] == "post" && Res::isPost()) {
                         $ok = self::exec($params, $value);
                         break;
                     } else {
                         if ($value["methode"] == "post" && !Res::isPost()) {
                             $ok = 0;
                         } else {
                             if ($value["methode"] == "get") {
                                 $ok = self::exec($params, $value);
                                 break;
                             } else {
                                 if ($value["methode"] == "resource") {
                                     $ok = self::exec($params, $value);
                                     break;
                                 } else {
                                     if ($value["methode"] == "object") {
                                         $ok = self::exec($params, $value);
                                         //var_dump($value);
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($ok == 0) {
             if (Config::get('app.unrouted')) {
                 throw new invalidArgumentException("There is no route call's " . $currentUrl . " in your route file");
             } else {
                 Errors::r_404();
             }
         }
     } else {
         self::showMaintenance();
     }
 }
        $free += $weight;
        $char['CC'] -= $weight;
    } else {
        $hransel = myquery("SELECT craft_resource_market.col,craft_resource.img3 AS img,craft_resource.name,craft_resource.weight,craft_resource.id AS res_id FROM craft_resource_market,craft_resource WHERE craft_resource_market.user_id={$user_id} AND craft_resource_market.town={$town} AND craft_resource_market.res_id=craft_resource.id AND craft_resource_market.id=" . $_GET['get'] . " AND craft_resource_market.priznak=1");
        if ($hransel != false and mysql_num_rows($hransel) > 0) {
            $hran = mysql_fetch_array($hransel);
            echo '<center>Взять из хранилища <input size="5" type="text" id="hran_col" value="0"> ед из ' . $hran['col'] . ' ед. ресурса <img src="http://' . img_domain . '/item/resources/' . $hran["img"] . '.gif" border="0"></a> ' . $hran['name'] . '<br /><i>1 единица ресурса ' . $hran['name'] . ' весит ' . $hran['weight'] . ' кг.</i>';
            echo '<br /><br /><input type="button" value="Взять ресурс из хранилища" onclick="location.replace(\'town.php?option=' . $option . '&part4&add=' . $build_id . '&get=' . $_GET['get'] . '&getnow=\'+document.getElementById(\'hran_col\').value+\'\')"><br/><br><br>';
        }
    }
} elseif (isset($_GET['hran'])) {
    if ($free > 0) {
        if (isset($_GET['hrannow']) and $_GET['hrannow'] > 0) {
            $it = (int) $_GET['hran'];
            $col = (int) $_GET['hrannow'];
            $Res = new Res();
            $weight = $Res->put_house($it, $col, $town, $free);
            echo $Res->message . '<br><br>';
            $free -= $weight;
            $char['CC'] += $weight;
        } else {
            $hransel = myquery("SELECT craft_resource_user.col,craft_resource.img3 AS img,craft_resource.name,craft_resource.weight,craft_resource.id AS res_id FROM craft_resource_user,craft_resource WHERE craft_resource_user.user_id={$user_id} AND craft_resource_user.col>0 AND craft_resource_user.res_id=craft_resource.id AND craft_resource_user.id=" . $_GET['hran'] . "");
            if ($hransel != false and mysql_num_rows($hransel) > 0) {
                $hran = mysql_fetch_array($hransel);
                echo '<center><br />Положить в хранилище <input size="5" type="text" id="hran_col" value="0"> ед. из ' . $hran['col'] . ' ед. ресурса <img src="http://' . img_domain . '/item/resources/' . $hran["img"] . '.gif" border="0"></a> ' . $hran['name'] . '<br /><i>1 единица ресурса ' . $hran['name'] . ' весит ' . $hran['weight'] . ' кг.</i>';
                echo '<br /><br /><input type="button" value="Положить ресурс в хранилище" onclick="location.replace(\'town.php?option=' . $option . '&part4&add=' . $build_id . '&hran=' . $_GET['hran'] . '&hrannow=\'+document.getElementById(\'hran_col\').value+\'\')"><br />';
            }
        }
    }
}
//хранилище
Exemple #17
0
 public function index(Req $req, Res $res, $args)
 {
     $body = $res->getBody();
     $body->write('Hello world');
     return $res;
 }
Exemple #18
0
<?php

App::before(function () {
    //echo "<br>start<br>";
});
App::after(function () {
    //echo "<br>end<br>";
});
Route::filter('auth', function () {
    if (Auth::guest()) {
        Url::redirect("@login");
        return false;
    } else {
        return true;
    }
});
Route::filter('guest', function () {
    if (Auth::guest()) {
        Url::redirect('/');
    }
});
Route::filter('csrf', function () {
    if (Session::token() != Res::post('_token')) {
        return false;
    } else {
        return true;
    }
});
        $res_id_in = $id_resource_kopye;
        $res_id_out = $id_resource_doska;
        break;
    default:
        exit;
        break;
}
//Забираем расходник
$res_out = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$res_id_out}"));
$Res = new Res($res_out);
$Res->add_user(0, $user_id, -1);
$mes = 'Израсходован ресурс: <i>' . $res_out['name'] . '</i> в количестве 1 ед. <br/>';
myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_out}, 0, -1, " . time() . ", {$user_id}, 'z')");
$char['CW'] = $char['CW'] - $res_out['weight'];
$res_in = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id={$res_id_in}"));
$Res1 = new Res($res_in);
$check = $Res1->add_user(0, $user_id, $kol_res_in);
if ($check == 1) {
    add_exp_for_craft($user_id, 7);
    myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_in}, 0, 1, " . time() . ", {$user_id}, 'z')");
    setCraftTimes($user_id, 7, 1, 1);
    $mes .= 'Получен ресурс: <i>' . $res_in['name'] . '</i> в количестве ' . $kol_res_in . ' ед.';
} else {
    $mes .= '<b>У Вас недостаточно свободного места в инвентаре!</b>';
}
//Поломаем предмет
mt_srand(make_seed());
myquery("UPDATE game_items SET item_uselife=item_uselife-" . mt_rand(100, 250) / 100 . " WHERE user_id={$user_id} AND used=21 AND priznak=0");
list($id, $uselife) = mysql_fetch_array(myquery("SELECT id,item_uselife FROM game_items WHERE user_id={$user_id} AND used=21 AND priznak=0"));
if ($uselife <= 0) {
    $Item = new Item($id);
Exemple #20
0
 public function paginate($RowsPerPage)
 {
     // count data
     $sql = "select count(*) as nbRows from " . $this->name;
     $var = Database::read($sql);
     $this->RowsPerPage = $RowsPerPage;
     $this->nbRows = $var[0]['nbRows'];
     $this->nbPages = ceil($this->nbRows / $RowsPerPage);
     //if isset get
     $this->CurrentPage = 1;
     if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) {
         if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $this->nbPages) {
             $this->CurrentPage = Res::get(Config::get('view.pagination_param'));
         }
     }
     //get Data
     $r = array();
     $sql = "select * from " . $this->name . " Limit " . ($this->CurrentPage - 1) * $this->RowsPerPage . ",{$this->RowsPerPage}";
     $this->data = Database::read($sql);
     //
     return $this;
 }
Exemple #21
0
     $Item = new Item();
     $Item->kleymo_return($_GET['id']);
     break;
 case 'use':
     $Item = new Item();
     $Item->use_item($_GET['id']);
     break;
 case 'drop':
     $Item = new Item();
     $Item->drop($_GET['id']);
     break;
 case 'takeres':
     if (!isset($_GET['id']) or !is_numeric($_GET['id']) or !isset($_GET['col']) or $_GET['col'] <= 0 or !is_numeric($_GET['col'])) {
         break;
     }
     $Res = new Res();
     $Res->take(0, (int) $_GET['id'], (int) $_GET['col']);
     break;
 case 'take':
     list($maze) = mysql_fetch_array(myquery("SELECT maze FROM game_maps WHERE id=" . $char['map_name'] . ""));
     if ($maze == 1 and !isset($_GET['id'])) {
         $result_items = myquery("SELECT type,effekt FROM game_maze WHERE map_name='" . $char['map_name'] . "' AND xpos=" . $char['map_xpos'] . " AND ypos=" . $char['map_ypos'] . " LIMIT 1");
         $usl = mysql_num_rows($result_items);
         if ($usl > 0) {
             list($type, $effekt) = mysql_fetch_array($result_items);
             if ($type >= 3 and $type <= 10) {
                 switch ($type) {
                     case 3:
                         $update_users = myquery("UPDATE game_users SET GP=GP + {$effekt} WHERE user_id={$user_id} LIMIT 1");
                         setGP($user_id, $effekt, 5);
                         break;
             }
         }
         if ($result['out_id'] > 0) {
             //Выдаём игроку предметы
             $check = myquery("SELECT item_id, kol*'" . $result['out_kol'] . "' as kol FROM game_exchange_groups WHERE group_id = '" . $result['out_id'] . "' and item_type = 0");
             if (mysql_num_rows($check) > 0) {
                 while ($item = mysql_fetch_array($check)) {
                     $Item = new Item();
                     $Item->add_user($item['item_id'], $char['user_id'], 0, 0, 0, $item['kol']);
                 }
             }
             //Выдаём игроку ресурсы
             $check = myquery("SELECT item_id, kol*'" . $result['out_kol'] . "' as kol FROM game_exchange_groups WHERE group_id = '" . $result['out_id'] . "' and item_type = 1");
             if (mysql_num_rows($check) > 0) {
                 while ($item = mysql_fetch_array($check)) {
                     $Res = new Res(0, $item['item_id']);
                     $Res->add_user(0, $char['user_id'], $item['kol']);
                 }
             }
         }
         //Выдаём игроку деньги
         if ($result['out_gp'] > 0) {
             save_gp($char['user_id'], $result['out_gp'], 110, 1);
         }
         echo '<b>Обмен успешно произведён!<b/><br>';
         //Занесём в лог использование шатра
         myquery("INSERT INTO game_exchange_log (user_id, exchange_id) VALUES ('" . $user_id . "', '" . $result['id'] . "') ON DUPLICATE KEY UPDATE times=times+1 ");
     }
     echo '<br><br>';
 } else {
     echo '<b>К сожалению, выбранного предолжения не существует!</b><br><br>';
Exemple #23
0
 public static function setDefault()
 {
     Cookie::create(self::getName(), Config::get('lang.default'), 60 * 24 * 7);
     Res::stsession("Fiesta_lang", Config::get('lang.default'));
 }
Exemple #24
0
 public static function __constructStatic()
 {
     static $isInitialized = false;
     if ($isInitialized) {
         return;
     }
     $isInitialized = true;
     static::$checks = array("isEmail" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli check jest ustawiony ale nieaktywny - wartosc zawsze jest poprawna wzgledem tego checka
         if (!$_rule) {
             return true;
         }
         return preg_match("/^[\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7}\$/", $_value);
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_isEmail_error", $_rule);
     }), "isInt" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli check jest ustawiony ale nieaktywny - wartosc zawsze jest poprawna wzgledem tego checka
         if (!$_rule) {
             return true;
         }
         return preg_match("/^[-+]?\\d+\$/", $_value);
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_isInt_error", $_rule);
     }), "isFloat" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli check jest ustawiony ale nieaktywny - wartosc zawsze jest poprawna wzgledem tego checka
         if (!$_rule) {
             return true;
         }
         return preg_match("/^[-+]?\\d+(?:[.,]\\d+)?\$/", $_value);
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_isFloat_error", $_rule);
     }), "isHttpUrl" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli check jest ustawiony ale nieaktywny - wartosc zawsze jest poprawna wzgledem tego checka
         if (!$_rule) {
             return true;
         }
         return preg_match('/^((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))$/', $_value);
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_isHttpUrl_error", $_rule);
     }), "max" => array("check" => function (&$_value, $_rule, FormType $_type) {
         if ($_type->isStringType()) {
             return strlen($_value) <= $_rule;
         }
         if ($_type->equals(FormType::checkbox)) {
             return count($_value) <= $_rule;
         }
         if ($_type->equals(FormType::radio)) {
             throw new \LogicException("Radio form could has only one value, max check is illogical.");
         }
         if ($_type->equals(FormType::select)) {
             throw new \LogicException("Select form must has only one value, max check is illogical.");
         }
     }, "error" => function ($_rule, FormType $_type) {
         if ($_type->isStringType()) {
             return Res::call("validate_max_string_error", $_rule);
         }
         return Res::call("validate_max_selection_error", $_rule);
     }), "maxNumber" => array("check" => function (&$_value, $_rule, FormType $_type) {
         return $_value <= $_rule;
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_maxNumber_error", $_rule);
     }), "min" => array("check" => function (&$_value, $_rule, FormType $_type) {
         if ($_type->isStringType()) {
             return strlen($_value) >= $_rule;
         }
         if ($_type->equals(FormType::checkbox)) {
             return count($_value) >= $_rule;
         }
         if ($_type->equals(FormType::radio)) {
             return isset($_value);
         }
         if ($_type->equals(FormType::select)) {
             throw new \LogicException("Select form must has only one value, min check is illogical.");
         }
         if ($_type->equals(FormType::file)) {
             return \Ker\Utils\File::fileWasSent($_value);
         }
     }, "error" => function ($_rule, FormType $_type) {
         if ($_type->isStringType()) {
             if ($_rule === 1) {
                 return Res::call("validate_empty_string_error");
             }
             return Res::call("validate_min_string_error", $_rule);
         }
         if ($_type->equals(FormType::radio)) {
             return Res::call("validate_empty_radio_error");
         }
         // TASK: #149 - wyniesc do zasobow
         if ($_type->equals(FormType::file)) {
             return "Brak pliku!";
         }
         return Res::call("validate_min_selection_error", $_rule);
     }), "minNumber" => array("check" => function (&$_value, $_rule, FormType $_type) {
         return $_value >= $_rule;
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_minNumber_error", $_rule);
     }), "re" => array("check" => function (&$_value, $_rule, FormType $_type) {
         return preg_match($_rule, $_value);
     }, "error" => function ($_rule, FormType $_type) {
         return Res::call("validate_re_error");
     }), "fileReceived" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli nie przeslano pliku - nie sprawdzamy
         if (!\Ker\Utils\File::fileWasSent($_value)) {
             return true;
         }
         return \Ker\Utils\File::fileWasReceived($_value);
     }, "error" => function ($_rule, FormType $_type) {
         return "Błąd przesyłania pliku!";
     }), "fileTypes" => array("check" => function (&$_value, $_rule, FormType $_type) {
         // jesli nie przeslano pliku - nie sprawdzamy
         if (!\Ker\Utils\File::fileWasSent($_value)) {
             return true;
         }
         $types = explode(" ", $_rule);
         return \Ker\Utils\File::typeIsAcceptable($_value, $types);
     }, "error" => function ($_rule, FormType $_type) {
         $types = explode(" ", $_rule);
         return "Niewłaściwy format pliku! Możliwe formaty: " . implode(", ", $types);
     }));
     static::$hooksPredefined = array("htmlCleaner" => function (&$_items) {
         foreach ($_items as &$item) {
             if ($item["type"]->isTextType() && (!isset($item["allowHtml"]) || !$item["allowHtml"])) {
                 $item["value"] = strip_tags($item["value"]);
             }
         }
     }, "textTrim" => function (&$_items) {
         foreach ($_items as &$item) {
             if ($item["type"]->isTextType()) {
                 $item["value"] = trim($item["value"]);
             }
         }
     }, "normalizeEmail" => function (&$_items) {
         foreach ($_items as &$item) {
             if (isset($item["check"]) && isset($item["check"]["isEmail"]) && $item["check"]["isEmail"]) {
                 $item["value"] = strtolower($item["value"]);
             }
         }
     }, "normalizeFloat" => function (&$_items) {
         foreach ($_items as &$item) {
             if (isset($item["check"]) && isset($item["check"]["isFloat"]) && $item["check"]["isFloat"]) {
                 $item["value"] = str_replace(",", ".", $item["value"]);
             }
         }
     });
 }
Exemple #25
0
 public static function run()
 {
     //
     $url = isset($_GET['url']) ? '/' . $_GET['url'] : '/';
     //echo $url;
     if (!Config::get("maintenance.activate") || in_array($url, Config::get("maintenance.outRoutes"))) {
         for ($i = 0; $i < count(self::$_uri); $i++) {
             if (strpos(self::$_uri[$i], '{}') !== false) {
                 self::$_uri[$i] = str_replace('{}', '(.*)?', self::$_uri[$i]);
             }
         }
         //
         $ok = 0;
         foreach (self::$_uri as $key => $value) {
             if (preg_match("#^{$value}\$#", $url, $params)) {
                 if (self::$_type[$key] == "post" && Res::isPost()) {
                     array_shift($params);
                     //
                     //before filter
                     //
                     call_user_func(App::$Callbacks['before']);
                     //
                     //new filter
                     //
                     $ok = true;
                     $falseok = null;
                     $oks = array();
                     //
                     if (is_string(self::$_request[$key])) {
                         if (!empty(self::$_request[$key])) {
                             $call = self::$_filters[self::$_request[$key]];
                             $ok = call_user_func($call);
                             if (!$ok) {
                                 $falseok = self::$_request[$key];
                             }
                         }
                     } else {
                         if (is_array(self::$_request[$key])) {
                             if (!empty(self::$_request[$key])) {
                                 foreach (self::$_request[$key] as $key2 => $value2) {
                                     $call = self::$_filters[$value2];
                                     $ok = call_user_func($call);
                                     if (!$ok) {
                                         $falseok = $value2;
                                         break;
                                     }
                                 }
                             }
                         }
                     }
                     // run the route callback
                     if ($ok) {
                         self::$current = $value;
                         call_user_func_array(self::$_callback[$key], $params);
                     } else {
                         if (isset(self::$_falsecall[$falseok]) && !empty(self::$_falsecall[$falseok])) {
                             $call = self::$_falsecall[$falseok];
                             $ok = call_user_func($call);
                         }
                     }
                     //
                     //after filter
                     //
                     call_user_func(App::$Callbacks['after']);
                     $ok = 1;
                     break;
                     //
                     // old
                     // array_shift($params);
                     // call_user_func_array(self::$_callback[$key], $params);
                     // $ok=1;
                 } else {
                     if (self::$_type[$key] == "post" && !Res::isPost()) {
                         $ok = 0;
                     } else {
                         if (self::$_type[$key] == "get") {
                             array_shift($params);
                             //
                             //before filter
                             //
                             call_user_func(App::$Callbacks['before']);
                             //
                             //new filter
                             //
                             $ok = true;
                             $falseok = null;
                             $oks = array();
                             //
                             if (is_string(self::$_request[$key])) {
                                 if (!empty(self::$_request[$key])) {
                                     $call = self::$_filters[self::$_request[$key]];
                                     $ok = call_user_func($call);
                                     if (!$ok) {
                                         $falseok = self::$_request[$key];
                                     }
                                 }
                             } else {
                                 if (is_array(self::$_request[$key])) {
                                     if (!empty(self::$_request[$key])) {
                                         foreach (self::$_request[$key] as $key2 => $value2) {
                                             $call = self::$_filters[$value2];
                                             $ok = call_user_func($call);
                                             if (!$ok) {
                                                 $falseok = $value2;
                                                 break;
                                             }
                                         }
                                     }
                                 }
                             }
                             // run the route callback
                             if ($ok) {
                                 self::$current = $value;
                                 call_user_func_array(self::$_callback[$key], $params);
                             } else {
                                 if (isset(self::$_falsecall[$falseok]) && !empty(self::$_falsecall[$falseok])) {
                                     $call = self::$_falsecall[$falseok];
                                     $ok = call_user_func($call);
                                 }
                             }
                             //
                             //after filter
                             //
                             call_user_func(App::$Callbacks['after']);
                             $ok = 1;
                             break;
                         }
                     }
                 }
             }
         }
         if ($ok == 0) {
             Errors::r_404();
         }
     } else {
         if (Config::get("maintenance.maintenanceEvent") == "string") {
             echo Config::get("maintenance.maintenanceResponse");
         } else {
             if (Config::get("maintenance.maintenanceEvent") == "link") {
                 Url::redirect(Config::get("maintenance.maintenanceResponse"));
             }
         }
     }
 }
Exemple #26
0
 /**
  * Load Controller
  */
 private function loadController()
 {
     $param = explode('/', $this->param());
     // Set Deafult Controller
     if ('' === $param[0]) {
         $param[0] = $this->set['controller/default'];
     }
     $controller_param_temp = $param;
     $controller_name_temp = ucfirst($this->set['name']) . '\\Controller';
     $controller_path_temp = $this->set['controller'];
     $controller_is_found = false;
     $controller_param = $controller_param_temp;
     $controller_name = $controller_name_temp;
     $controller_path = $controller_path_temp;
     // Search Controller
     while ($param) {
         $file_name = ucfirst($param[0]);
         if (file_exists("{$controller_path_temp}/{$file_name}Controller.php")) {
             array_shift($param);
             $controller_param_temp = $param;
             $controller_name_temp = "{$controller_name_temp}\\{$file_name}";
             $controller_path_temp = "{$controller_path_temp}/{$file_name}";
             $controller_is_found = true;
             $controller_param = $controller_param_temp;
             $controller_name = $controller_name_temp;
             $controller_path = $controller_path_temp;
         } elseif (file_exists("{$controller_path_temp}/{$file_name}")) {
             array_shift($param);
             $controller_param_temp = $param;
             $controller_name_temp = "{$controller_name_temp}\\{$file_name}";
             $controller_path_temp = "{$controller_path_temp}/{$file_name}";
         } else {
             break;
         }
     }
     // Response HTTP Status Code 404
     if (!$controller_is_found) {
         http_response_code(404);
         return false;
     }
     // Require Controller
     require $controller_path . 'Controller.php';
     // New Controller Instance
     $controller_name .= 'Controller';
     $controller = new $controller_name();
     if (method_exists($controller, $this->method() . 'Action')) {
         // Initialize Request Module
         Req::init(['method' => $this->method(), 'param' => $controller_param]);
         // Initialize Response Module
         Res::init(['path' => $this->set['view']]);
         // Call Function: up -> xxxAction -> down
         if (false !== $controller->up()) {
             $method = $this->method() . 'Action';
             $controller->{$method}();
         }
         $controller->down();
         return true;
     }
     http_response_code(501);
     return false;
 }
Exemple #27
0
         break;
     case $id_resource_copper_ore:
         $res_id_bullion = $id_resource_copper_bullion;
         break;
     case $id_resource_silver_nugget:
         $res_id_bullion = $id_resource_silver_bullion;
         break;
     case $id_resource_mithril_ore:
         $res_id_bullion = $id_resource_mithril_bullion;
         break;
     case $id_resource_gold_nugget:
         $res_id_bullion = $id_resource_gold_bullion;
         break;
 }
 $res_in = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id='" . $res_id_bullion . "' "));
 $Res = new Res($res_in);
 $check = $Res->add_user(0, $user_id);
 if ($check == 1) {
     myquery("UPDATE game_items SET item_uselife=item_uselife-" . mt_rand(400, 600) / 100 . " WHERE user_id={$user_id} AND used=21 AND priznak=0");
     list($id_item, $cur_uselife) = mysql_fetch_array(myquery("SELECT id,item_uselife FROM game_items WHERE priznak=0 AND user_id={$user_id} AND used=21"));
     if ($cur_uselife <= 0) {
         $Item = new Item($id_item);
         $Item->down();
     }
     $mes = 'Получен ресурс: <i>' . $res_in['name'] . '</i> в количестве 1 ед.';
     setCraftTimes($user_id, 10, 3, 1);
     myquery("insert into craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, {$res_id_bullion}, 0, 1, " . time() . ", {$user_id}, 'z')");
 } else {
     $mes = 'Неудачная попытка работы на плавильне. Проверь, хватает ли у тебя места для новых ресурсов в инвентаре!';
 }
 myquery("DELETE FROM craft_build_founder WHERE user_id={$user_id}");
     }
     if ($dostup_clan == 2) {
         $str_query = "SELECT DISTINCT game_items_factsheet.type FROM game_items,game_items_factsheet where game_items.user_id={$user_id} and game_items.priznak=1 and game_items.town='{$town}' and game_items_factsheet.type<=97 and game_items.sell_time>'{$time_for_check}' AND game_items.post_to=0 AND game_items.item_id = game_items_factsheet.id and game_items_factsheet.type=" . $Item->fact['type'] . "";
     } else {
         $str_query = "SELECT DISTINCT game_items_factsheet.type FROM game_items,game_items_factsheet where game_items.priznak=1 and game_items.town='{$town}' and game_items_factsheet.type<=97 and game_items.sell_time>'{$time_for_check}' AND game_items.post_to=0 AND game_items.item_id = game_items_factsheet.id and game_items_factsheet.type=" . $Item->fact['type'] . "";
     }
     $test = myquery($str_query);
     if (mysql_num_rows($test) > 0) {
         echo '<meta http-equiv="refresh" content="1;url=town.php?option=' . $option . '&do=viewtype&type=' . $Item->fact['type'] . '">';
     } else {
         echo '<meta http-equiv="refresh" content="1;url=town.php?option=' . $option . '">';
     }
     break;
 case 'purchase_res':
     $it = (int) $_GET['it'];
     $Res = new Res();
     $Res->buy_market(0, $it, $dostup_clan);
     echo $Res->message;
     if ($dostup_clan == 2) {
         $sct = "select * from craft_resource_market where priznak=0 AND town='{$town}' and user_id={$user_id}";
     } else {
         $sct = "select * from craft_resource_market where priznak=0 AND town='{$town}'";
     }
     $test = myquery($sct);
     if (mysql_num_rows($test) > 0) {
         $url = '<meta http-equiv="refresh" content="1;url=town.php?option=' . $option . '&do=res">';
     } else {
         $url = '<meta http-equiv="refresh" content="1;url=town.php?option=' . $option . '">';
     }
     echo $url;
     break;
Exemple #29
0
 public function drop_loot($user_id)
 {
     if ($this->error == 1) {
         return;
     }
     if ($this->npc['dropable'] == 1) {
         $seldrop = myquery("SELECT * FROM game_npc_drop WHERE npc_id=" . $this->templ['npc_id'] . ";");
         if ($seldrop != false and mysql_num_rows($seldrop)) {
             $sum_chance = 0;
             $massiv = array(0);
             $m_last = 1;
             $mes = "";
             $lcm = array();
             $str = "";
             $r = 0;
             $no_loot = 0;
             //Обработаем профессию "Охотник"
             if ($this->templ['npc_id'] == npc_id_olen) {
                 if (checkCraftTrain($user_id, 8)) {
                     $r = $r + 2 * getCraftLevel($user_id, 8);
                 } else {
                     $no_loot = 1;
                 }
             }
             while ($chance = mysql_fetch_array($seldrop)) {
                 $lcm[] = $chance['random_max'];
             }
             mysql_data_seek($seldrop, 0);
             $lcm = lcm_arr($lcm);
             while ($chance = mysql_fetch_array($seldrop)) {
                 $this_chance = ($chance['random'] + $r) * $lcm / gcd($lcm, $chance['random_max']);
                 $massiv = array_merge($massiv, array_fill($m_last, $this_chance, $chance));
                 $m_last += $this_chance;
             }
             if ($m_last < $lcm + 1) {
                 $massiv = array_merge($massiv, array_fill($m_last, $lcm + 1 - $m_last, array('items_id' => 0)));
             }
             $drop = $massiv[mt_rand(1, $lcm)];
             if ($drop['items_id'] != 0 and $no_loot == 0) {
                 $it_user_id = 0;
                 $priznak = 2;
                 $kol_predmetov = mt_rand($drop['mincount'], $drop['maxcount']);
                 $map_name = 0;
                 $map_xpos = 0;
                 $map_ypos = 0;
                 for ($cikl = 1; $cikl <= $kol_predmetov; $cikl++) {
                     $add_result = array(0);
                     if ($drop['kuda'] == 1) {
                         $it_user_id = $user_id;
                         $priznak = 0;
                         //проверим вес
                         if ($drop['drop_type'] == 1) {
                             $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . ""));
                         } elseif ($drop['drop_type'] == 2) {
                             $item = mysql_fetch_array(myquery("SELECT * FROM craft_resource WHERE id=" . $drop['items_id'] . ""));
                         }
                         list($CW, $CC) = mysql_fetch_array(myquery("SELECT CW,CC FROM view_active_users WHERE user_id={$it_user_id}"));
                         $prov = mysqlresult(myquery("SELECT COUNT(*) FROM game_wm WHERE user_id={$it_user_id} AND type=1"), 0, 0);
                         if ($CC - $CW < $item['weight'] and $prov == 0) {
                             //инвентарь заполнен. На землю его!
                             $it_user_id = 0;
                             $priznak = 2;
                             list($map_name, $map_xpos, $map_ypos) = mysql_fetch_array(myquery("SELECT map_name,map_xpos,map_ypos FROM game_users_map WHERE user_id={$it_user_id}"));
                             $drop['kuda'] = 0;
                         }
                     }
                     //если предмет
                     if ($drop['drop_type'] == 1) {
                         if ($priznak == 0) {
                             $Item = new Item();
                             $add_result = $Item->add_user($drop['items_id'], $it_user_id, 0, 0, 1);
                             // не получилось добавить один - не выйдет и остальные.
                             if ($add_result[0] == 0) {
                                 break;
                             }
                         } else {
                             if (!isset($item)) {
                                 $item = mysql_fetch_array(myquery("SELECT * FROM game_items_factsheet WHERE id=" . $drop['items_id'] . ""));
                             }
                             myquery("INSERT INTO game_items (user_id,item_id,priznak,ref_id,item_uselife,item_uselife_max,item_cost,map_name,map_xpos,map_ypos) VALUES ('{$it_user_id}','" . $drop['items_id'] . "','{$priznak}',0,'" . $item['item_uselife'] . "','" . $item['item_uselife_max'] . "','" . $item['item_cost'] . "','{$map_name}','{$map_xpos}','{$map_ypos}')");
                         }
                     } elseif ($drop['drop_type'] == 2) {
                         if ($drop['kuda'] == 1) {
                             $Res = new Res($item, 0);
                             $Res->add_user(0, $it_user_id, 1);
                             if ($this->templ['npc_id'] == npc_id_olen) {
                                 myquery("INSERT INTO craft_stat (build_id, gp, res_id, dob, vip, dat, user, type) values (0, 0, " . $drop['items_id'] . ", 0, 1, " . time() . ", {$it_user_id}, 'z')");
                                 setCraftTimes($it_user_id, 8, 1, 1);
                                 add_exp_for_craft($it_user_id, 8);
                             }
                         } elseif ($drop['kuda'] == 0) {
                             $Res = new Res(0, $drop['items_id']);
                             $Res->add_map(0, 0, 1, 0, $map_name, $map_xpos, $map_ypos);
                             myquery("INSERT INTO craft_resource_market (user_id,town,col,price,res_id,opis,map_name,map_xpos,map_ypos) VALUES (0,0,1,0," . $drop['items_id'] . ",'','" . $map_name . "','" . $map_xpos . "','" . $map_ypos . "')");
                         }
                     }
                     if ($it_user_id > 0) {
                         if ($drop['drop_type'] == 1) {
                             $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('увидел', 'увидела') . ' оставшийся от него предмет: <b>' . $item['name'] . '</b>.Ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший предмет и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>';
                         } elseif ($drop['drop_type'] == 2) {
                             $mes = '<font color=\\"#eeeeee\\">После убийства монстра ты ' . echo_sex('заметил', 'заметила') . ', как он выронил из рук: <b>' . $item['name'] . '<b/>. Не мешкая ты быстро ' . echo_sex('подобрал', 'подобрала') . ' выпавший ресурс и ' . echo_sex('положил', 'положила') . ' его в свой инвентарь!</font>';
                         }
                         $result = myquery("INSERT game_battles SET attacker_id=" . $user_id . ", target_id=0, map_name=" . $map_name . ", map_xpos=" . $map_xpos . ", map_ypos=" . $map_ypos . ", contents='" . $mes . "', post_time=" . time() . "");
                     }
                 }
             }
         }
     }
 }
 function delete_house($user_id, $build_id = 0, $town = 0)
 {
     //Если $build_id=0 - удаляем все постройки из-за налогов и удаляем саму землю
     //Иначе удаляем конкретное $build_id здание из houses_users из-за ремонта
     //При удалении дома - из-за ремонта - остальные здания не удаляем.
     //возвращаем предметы из хранилищ в его инвентарь (кроме эликсиров)
     $weight = 0;
     // Если сломан основной дом, то уничтожаем все здания в городе
     if ($build_id >= 1 and $build_id <= 4) {
         $build_id = 0;
     }
     if ($build_id == 0) {
         $selitems = myquery("SELECT SUM(game_items_factsheet.weight) AS weight FROM game_items,game_items_factsheet WHERE game_items.priznak=4 AND game_items.item_id=game_items_factsheet.id AND game_items.user_id=" . $user_id . " AND game_items_factsheet.type<>13 AND (game_items.town=" . $town . " OR " . $town . "=0) GROUP BY game_items.user_id");
         myquery("UPDATE game_items SET priznak=0 WHERE priznak=4 AND user_id=" . $user_id . " AND (game_items.town=" . $town . " OR " . $town . "=0) ");
         $weight = 0;
         if (mysql_num_rows($selitems)) {
             $weight += mysql_result($selitems, 0, 0);
         }
     }
     //возвращаем эликсиры из хранилищ в его инвентарь
     if ($build_id == 0 or $build_id >= 13 and $build_id <= 16) {
         $selitems = myquery("SELECT SUM(game_items_factsheet.weight) AS weight FROM game_items,game_items_factsheet WHERE game_items.priznak=4 AND game_items.item_id=game_items_factsheet.id AND game_items.user_id={$user_id} AND game_items_factsheet.type=13 AND (game_items.town=" . $town . " OR " . $town . "=0) GROUP BY game_items.user_id");
         myquery("UPDATE game_items SET priznak=0 WHERE priznak=4 AND user_id={$user_id} AND (game_items.town=" . $town . " OR " . $town . "=0) ");
         $weight = 0;
         if (mysql_num_rows($selitems)) {
             $weight += mysql_result($selitems, 0, 0);
         }
     }
     //возвращаем ресурсы из хранилища
     if ($build_id == 0 or $build_id >= 9 and $build_id <= 12) {
         $hransel = myquery("SELECT crm.id, crm.col FROM craft_resource_market crm WHERE crm.user_id=" . $user_id . " AND crm.priznak=1 AND (crm.town=" . $town . " OR " . $town . "=0)");
         $weight = 0;
         if ($hransel != false and mysql_num_rows($hransel) > 0) {
             while ($hran = mysql_fetch_array($hransel)) {
                 $Res = new Res(0, 0, $user_id);
                 $Res->take_house(0, $hran['id'], (int) $hran['col']);
             }
         }
     }
     //удаляем и снимаем коня
     if ($build_id == 0 or $build_id >= 6 and $build_id <= 8) {
         myquery("DELETE FROM game_users_horses WHERE user_id=" . $user_id . " AND used=0 AND (town=" . $town . " OR " . $town . "=0) ");
     }
     // Обновим инвентарь игрока
     if ($weight > 0) {
         myquery("UPDATE game_users SET CW=CW+" . $weight . " WHERE user_id=" . $user_id . "");
         myquery("UPDATE game_users_archive SET CW=CW+" . $weight . " WHERE user_id=" . $user_id . "");
     }
     // Удаляем дома/постройки игрока за задолженность
     if ($build_id == 0) {
         //Удаляем все постройки+дом
         myquery("DELETE FROM houses_market WHERE user_id=" . $user_id . " AND (town_id=" . $town . " OR " . $town . "=0)");
         myquery("DELETE FROM houses_users WHERE user_id=" . $user_id . " AND (town_id=" . $town . " OR " . $town . "=0)");
         if (mysql_num_rows(myquery("SELECT * FROM houses_users WHERE user_id=" . $user_id . "")) == 0) {
             myquery("DELETE FROM houses_nalog WHERE user_id=" . $user_id . "");
         }
     } else {
         //Удаляем конкретное здание/постройку
         myquery("DELETE FROM houses_market WHERE user_id={$user_id} AND build_id={$build_id} AND (town_id=" . $town . " OR " . $town . "=0) ");
         myquery("DELETE FROM houses_users WHERE user_id={$user_id} AND build_id={$build_id} AND (town_id=" . $town . " OR " . $town . "=0) ");
     }
     //Вышлем игроку уведомление
     if ($build_id == 0) {
         $theme = 'Все Ваши постройки были уничтожены!';
         $post = 'В связи с длительным отсутствием ремонта все Ваши постройки были уничтожены!';
     } else {
         list($name) = mysql_fetch_array(myquery("SELECT name FROM houses_templates WHERE id = " . $build_id . " "));
         $theme = 'Ваша постройка <b>' . $name . '</b> была уничтожена!';
         $post = 'В связи с длительным отсутствием ремонта Ваша постройка <b>' . $name . '</b> была уничтожена!';
     }
     myquery("INSERT INTO game_pm (komu, otkogo, theme, post, view, time, folder) VALUES ('" . $user_id . "', '0', '" . $theme . "', '" . $post . "','0','" . time() . "',1)");
 }