public function getPrize($array) { $configs = Configs::readCfg("plugin_mmovote", tbuild); $q = ""; $contis = 0; $ai = new ArrayIterator($array); foreach ($ai as $ar) { if (!empty($ar) && isset($ar["vote"]) && isset($ar["acc"]) && isset($ar["date"]) && strlen(trim($ar["acc"])) <= 10) { $ar["vote"] = str_replace("\n", "", trim($ar["vote"])); $credist = str_replace(array("(votes)", "(account)"), array("{$ar["vote"]}", "'{$ar["acc"]}'"), $configs["mmo_price"]); $ar["date"] = date_::intransDate($ar["date"], true); $q .= "IF EXISTS (SELECT * FROM [MWC_MMO_TOP] WHERE col_memb_id = '{$ar["acc"]}')\r\nBEGIN\r\n IF EXISTS (SELECT * FROM [MWC_MMO_TOP] WHERE col_memb_id = '{$ar["acc"]}' AND DATEDIFF(HOUR,col_LastVote,'" . $ar["date"] . "')>=1)\r\n BEGIN\r\n UPDATE [MWC_MMO_TOP] SET col_votes = col_votes + {$ar["vote"]},col_LastVote='" . $ar["date"] . "' WHERE col_memb_id = '{$ar["acc"]}';\r\n INSERT INTO MWC_logs(col_ErrNum,col_msg,col_mname,col_createTime) VALUES(42,'Account {$ar["acc"]} add 1 vote from mmo top','vote',GETDATE());\r\n {$credist};\r\n END\r\nEND\r\nELSE\r\nBEGIN\r\n INSERT INTO [MWC_MMO_TOP] (col_memb_id, col_LastVote,col_votes) VALUES('{$ar["acc"]}','" . $ar["date"] . "',{$ar["vote"]});\r\n INSERT INTO mwce_settings.dbo.MWC_logs(col_ErrNum,col_msg,col_mname,col_createTime,tbuild) VALUES(15,'Account {$ar["acc"]} add {$ar["vote"]} vote from mmo top ','vote',GETDATE(),'" . tbuild . "');\r\n {$credist};\r\nEND "; $contis++; if ($contis > 99) { $this->db->query($q); $q = ""; $contis = 0; } } } if ($contis > 0) { $this->db->query($q); } $this->db->SQLog("Check mmo top complete... ", "mmovote", 42); }
/** * контент логов из базы */ public function action_getlist() { $top = !empty($_POST["topst"]) ? (int) $_POST["topst"] : 100; $event = !empty($_POST["eventnum"]) ? (int) $_POST["eventnum"] : NULL; $file = !empty($_POST["lilesc"]) && $_POST["lilesc"] != "-1" ? $_POST["lilesc"] : 0; $msg = !empty($_POST["inevmsg"]) ? $_POST["inevmsg"] : NULL; if (!empty($_POST["dbegin"]) && !empty($_POST["dend"])) { $begin = date_::intransDate($_POST["dbegin"]); $end = date_::intransDate($_POST["dend"]); if ($begin == "-/-" || $end == "-/-") { return; } } else { return; } $logs = $this->model->showLogsArr($top, $event, $file, $begin, $end, $msg); $ai = new ArrayIterator($logs); foreach ($ai as $id => $val) { $val["col_createTime"] = date_::transDate($val["col_createTime"], true); $this->view->add_dict($val)->set("id", $id + 1)->out("center", "logs"); } }
/** * приведение типов по парамету * @param number|string $param * @param string $type * @return bool|float|int|string */ protected function paramsControl($param, $type) { switch ($type) { case "double": case "float": $param = floatval($param); break; case "int": case "integer": $param = intval($param); break; case "str": case "string": $param = htmlspecialchars(self::checkText($param), ENT_QUOTES); break; case "bool": case "boolean": $param = boolval($param); break; case "array": break; case "date": $param = date_::intransDate($param); break; case "datetime": $param = date_::intransDate($param, true); break; default: $param = htmlspecialchars(self::checkText($param), ENT_QUOTES); break; } return $param; }