本文整理汇总了PHP中page::error方法的典型用法代码示例。如果您正苦于以下问题:PHP page::error方法的具体用法?PHP page::error怎么用?PHP page::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类page
的用法示例。
在下文中一共展示了page::error方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load($request)
{
global $settings, $SITE;
require_once 'classes/player.php';
// Parse page request
if ($request) {
// Split off ? args
$request_args = explode('?', $request);
if ($request_args[1]) {
$args = explode('&', $request_args[1]);
foreach ($args as $arg) {
$bits = explode('=', $arg);
$params[$bits[0]] = $bits[1];
}
}
$request_bits = explode('/', $request_args[0]);
$view = array_shift($request_bits);
for ($x = 0; $x < count($request_bits); $x++) {
$params[$x] = $request_bits[$x];
}
} else {
$view = 'index';
}
global $view_rewrite;
if (array_key_exists($view, $view_rewrite)) {
$view = $view_rewrite[$view];
}
if (file_exists('views/' . $view . '.view.php')) {
include 'views/' . $view . '.view.php';
}
$view .= '_view';
if (!class_exists($view)) {
@(include 'views/404.view.php');
if (!class_exists('404_view')) {
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
page::error("Now where'd I put that...", "It seems everything needed to draw any kind of page\r\n\t\t\t\thas gone missing. We suspect spies, but rumor is Heavy has been looking for some new sandvich\r\n\t\t\t\tbuilding materials.");
}
}
$v = new $view($params);
$v->prepare();
$SITE['head'] .= $v->additional_head();
global $user;
if ($params['creeper']) {
$SITE['head'] .= '
<script src="/static/js/af/proto.js"></script>
<script src="/static/js/af/box2d.js"></script>
<script src="/static/js/af/common.js"></script>
';
//$SITE['af'] = '';
}
//if(($user && in_array($user->id(), array(1)))) $SITE['head'] = '';
$SITE['title'] = sprintf("%s - TF2Stats.net", $v->get_title());
$v->render();
}
示例2: prepare
public function prepare()
{
global $db;
$this->template = "server_search";
$this->tab = 'server';
require_once 'classes/server.php';
if ($this->request['search']) {
$req = $this->request['search'];
if (strpos($req, ':')) {
list($ip, $port) = explode(":", $req);
$wheres[] = '(ip = %s AND port = %s)';
$whargs[] = $ip;
$whargs[] = $port;
} else {
$wheres[] = 'ip LIKE %s';
$whargs[] = '%' . $req . '%';
}
// name search
$wheres[] = 's.name LIKE %s';
$whargs[] = '%' . $req . '%';
// tag search
$wheres[] = 'tags LIKE %s';
$whargs[] = '%' . $req . '%';
$where = implode(' OR ', $wheres);
$q = $this->request['search'];
$db->query("SELECT ip, port FROM tf2_servers s WHERE " . $where, $whargs);
//echo mysql_error();
if ($db->num_rows() == 1) {
$row = $db->fetch_array();
header(sprintf('Location: /server/%s:%s', $row['ip'], $row['port']));
exit;
}
if (!$db->num_rows()) {
page::error("Spy sappin my search results", "Sorry to <i>pop in</i> unannounced, but that server you were looking for?\r\n\t\t\t\tIt's nowhere to be found. I'm not saying one of my sappers didn't have anything to do with it, but mind the charred\r\n\t\t\t\tbits of computer on the floor.", array('image' => "spy"));
}
//$db->debug=true;
foreach ($whargs as $wh) {
$cleanargs[] = "'" . mysql_real_escape_string($wh) . "'";
}
$query = vsprintf('SELECT s.ip, s.port, s.name, s.map_id, m.name AS map_name, s.players, s.max_players, bots FROM tf2_servers s LEFT JOIN tf2_maps m ON s.map_id=m.id WHERE ' . $where . ' LIMIT 50', $cleanargs);
$this->params['list'] = server::get_server_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label'), 'player_label' => array('func' => 'player_label', 'param' => '%d/%d')), 'query' => $query));
$this->title = sprintf("Search: %s", htmlspecialchars($this->request[0]));
}
}
示例3: prepare
public function prepare()
{
global $db;
$this->template = "map_search";
require_once 'classes/map.php';
$q = $this->request['search'];
//$db->debug=true;
$db->query("SELECT name FROM tf2_maps WHERE name LIKE %s", array(sprintf("%%%%%s%%%%", $q)));
//echo mysql_error();
if ($db->num_rows() == 1) {
$row = $db->fetch_array();
//die();
header('Location: /map/' . $row['name']);
exit;
}
if (!$db->num_rows()) {
page::error("We searched and searched", "But we just couldn't find the map you were looking for.\r\n\t\t\t\tRest assured Heavy is on the job. He won't rest until he knows who's been tampering with his gun.\r\n\t\t\t\t<br/><br/>That's what you were searching for, right?", array('image' => "heavy_yell"));
}
//$db->debug=true;
$this->params['list'] = map::get_map_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label')), 'query' => sprintf('SELECT m.id, m.name, m.official, m.score, plays, servers, first_seen FROM tf2_maps m WHERE name LIKE \'%%%s%%\' ORDER BY score DESC LIMIT 50', $q)));
$this->title = sprintf("Search: %s", htmlspecialchars($this->request[0]));
}
示例4: prepare
public function prepare()
{
global $db, $user, $settings;
// auth check
$auth = $db->query_first("SELECT mp.type FROM tf2stats_map_to_player mp LEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tWHERE mp.player_id = %s AND m.name = %s", array($user->id(), $this->request[0]));
if (!in_array($auth['type'], array('M', 'A', 'C'))) {
page::error("Little man", "You are no match for me!");
}
// handle file removals
if ($this->request[1] == 'delimg') {
$db->query("DELETE FROM tf2stats_map_images WHERE image = %s", array($this->request[2]));
$this->params['success'] = "Deleted " . $this->request[2];
}
// update
if ($_REQUEST['update']) {
if ($_REQUEST['filesize'] && !is_numeric($_REQUEST['filesize'])) {
$this->params['error'] = 'Filesize must be numeric. Do not append "MB".';
} elseif ($_REQUEST['url'] && !filter_var($_REQUEST['url'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
$this->params['error'] = 'Download URL is not valid.';
} else {
$i = $db->query_first("SELECT m.id, m.official FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
if (IsUserAdmin()) {
$Official = (int) (isset($_REQUEST['official']) && $_REQUEST['official'] == 'official');
cache::log("Changing official status for " . $i['id'] . " - old: " . $i['official'] . " - new: " . $Official);
if ($i['official'] != $Official) {
$db->query("UPDATE tf2_maps SET official = %s WHERE id = %s", array($Official, $i['id']));
}
}
$db->query("INSERT INTO tf2stats_managed_maps (player_id, map_id, edit_time, description, file_size, download_url) VALUES(%s, %s, %s, %s, %s, %s)\r\n\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE edit_time=%s, description=%s, file_size=%s, download_url = %s", array($user->id(), $i['id'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url']));
}
}
// map info
$map_info = $db->query_first("SELECT m.name, m.id, m.official, mp.description, mp.file_size, mp.download_url, mp.edit_time, p.name as player_name FROM tf2stats_managed_maps mp \r\n\t\t\t\t\t\tLEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tLEFT JOIN tf2_players p on mp.player_id = p.id\r\n\t\t\t\t\t\tWHERE m.name = %s\r\n\t\t\t\t\t\tORDER BY edit_time DESC\r\n\t\t\t\t\t\tLIMIT 1", array($this->request[0]));
if ($map_info) {
$this->params['old'] = true;
} else {
$map_info = $db->query_first("SELECT m.name, m.id FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
}
$this->params['map_info'] = $map_info;
// handle adding authors.
if ($this->request[1] == 'addauthor') {
if ($this->request['search']) {
$player_id = $this->request['search'];
if (!is_id64($player_id)) {
$player_id = get_id64($this->request['search']);
}
$player = new player($player_id);
if ($player->id()) {
$db->query("INSERT INTO tf2stats_map_to_player(player_id, map_id, type) VALUES(%s, %s, %s)", array($player->id(), $map_info['id'], 'A'));
$this->params['success'] = $player_id . ' has been added to the author list.';
} else {
$this->params['error'] = "Could not find a player by '" . $_REQUEST['search'] . "'. Please refine your search.";
}
} else {
$this->template = "manage_map_author";
$this->title = sprintf("Adding author for %s", htmlspecialchars($map_info['name']));
return;
}
}
if ($this->request[1] == 'delauthor') {
$id = $this->request[2];
$db->query("DELETE FROM tf2stats_map_to_player WHERE player_id=%s AND map_id = %s", array($id, $map_info['id']));
$this->params['success'] = "Deleted author";
}
// handle file uploads.
if ($this->request[1] == 'upload') {
$this->template = "manage_map_upload";
$this->title = sprintf("Upload image for %s", htmlspecialchars($map_info['name']));
$this->params['allowed_images'] = implode(', ', $settings['upload']['allowed_images']);
if ($_FILES['image']) {
if (!$_FILES['image']['tmp_name']) {
$this->params['error'] = 'Upload failed. (This usually happens when you try to upload a file larger than 1MB!)';
return;
}
// check extension.
$ext = end(explode(".", strtolower($_FILES['image']['name'])));
if (!in_array($ext, $settings['upload']['allowed_images'])) {
$this->params['error'] = 'Unsupported file extension ' . $ext . '. Please convert your image to one of these formats: ' . implode(', ', $settings['upload']['allowed_images']);
return;
}
// rename if already exists
$filename = sprintf("%s_%s", $map_info['id'], str_replace(array('(', ')', ' '), '_', basename($_FILES['image']['name'])));
$target_path = $settings['upload']['folder']['maps'] . $filename;
while (file_exists($target_path)) {
$filename = md5(time() . rand()) . '.' . $ext;
$target_path = $settings['upload']['folder']['maps'] . $filename;
}
//var_dump($target_path);
if (filesize($_FILES['image']['tmp_name']) > 2097152) {
$this->params['error'] = 'Uploaded file cannot exceed 1MB.';
return;
}
if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
$db->query("INSERT INTO tf2stats_map_images (map_id, player_id, image) VALUES(%s, %s, %s)", array($map_info['id'], $user->id(), $filename));
$this->params['success'] = basename($_FILES['image']['name']) . ' uploaded successfully.';
} else {
echo $_FILES['image']['tmp_name'];
echo $target_path;
$this->params['error'] = 'Unknown error. Please nag FireSlash until he fixes it.';
}
//.........这里部分代码省略.........
示例5: multi_stats
function multi_stats($json)
{
try {
$rgResult = json_decode($json, true);
//var_dump($rgResult);
//die();
} catch (Exception $e) {
page::error("Steam community error", "Steam appears to be having some trouble at the moment. Heavy is not pleased. Try again in a few minutes.", array('image' => 'heavy_yell'));
}
$stats = array();
if (!empty($rgResult['playerstats']['stats'])) {
foreach ($rgResult['playerstats']['stats'] as $item) {
//var_dump($item);
//printf("API: %s Value: %s <br />",$item['name'], $item['value']);
$keys = explode('.', $item['name']);
$a =& $stats;
foreach ($keys as $k) {
$a =& $a[strtolower($k)];
}
$a = intval($item['value']);
}
}
$this->stats = $stats;
}
示例6: prepare
public function prepare()
{
page::error("SERVER IS DEAD", "YOU NO PRESS F5. <br /><br />YOU WAIT NOW.<br /><br />GOOD.\r\n\t\t<br /> <br /><br /><br />\r\n\t\t<a href=\"#\" id=\"refresh\">How about now?</a> \r\n\t\t<audio src=\"/static/sound/heavy_no02.mp3\" id=\"no\" ></audio>\r\n\t\t<script type=\"text/javascript\">\r\n\t\t\$(document).ready(function() {\r\n\t\t\t\r\n\t\t\tvar refresh = \$('#refresh');\r\n\t\t\trefresh.click(function() { var no = \$('#no')[0]; no.play(); return false; });\r\n\t\t});\r\n\t\t</script>\r\n\t\t", array('image' => "heavy_yell"));
}
示例7: prepare
public function prepare()
{
global $METRICS, $CLASS_METRICS, $CLASSES, $CLASS_SLOTS, $VALVE_EMPLOYEES;
$this->template = "player_stats";
$this->tab = "player";
//backpack::update_schema();
if (is_id64($this->request[0])) {
$player_id = $this->request[0];
} else {
$player_id = get_id64($this->request[0]);
if (!$player_id) {
page::error("I will eat your search results, I'll eat them up!", "Thats right nancy boy, I've got better things\r\n\t\t\t\tto do than look for some sissy boy stats page, there's a war going on! The only path to victory is through\r\n\t\t\t\tpain and bloodshed. So man up girly boy, and put the right thing in the box next time.", array('image' => "soldier"));
}
}
$player = new player($player_id, true);
$player->preload_stats(true);
$backpack = new backpack($player, true);
cache::multi_run();
$stats = $player->get_stats();
if ($player->info['custom_url']) {
$this->canonical = sprintf('http://tf2stats.net/player/%s/', $player->info['custom_url']);
} else {
$this->canonical = sprintf('http://tf2stats.net/player/%s/', $player->id64());
}
//if($player_id != "76561198003273729")
$player->log_view();
foreach ($CLASSES as $c) {
// Build sorted class array
$classes[$stats[$c]['accum']['iplaytime']] = $c;
foreach ($METRICS as $m => $l) {
// Determine peak class values
if ($stats[$c]['max'][$m] > $stats['all']['max'][$m]['value']) {
$stats['all']['max'][$m] = array('value' => $stats[$c]['max'][$m], 'class' => $c);
}
if ($stats[$c]['accum'][$m] > $stats['all']['best'][$m]) {
$stats['all']['best'][$m] = $stats[$c]['accum'][$m];
}
$stats['all']['accum'][$m] += $stats[$c]['accum'][$m];
}
}
krsort($classes);
$this->params['classes'] = $classes;
$this->params['metrics'] = $METRICS;
$this->params['class_metrics'] = $CLASS_METRICS;
$this->params['backpack'] = $backpack;
$this->params['equipped'] = $backpack->equipped;
$this->params['player'] = $player;
$this->params['stats'] = $stats;
$this->params['slots'] = $CLASS_SLOTS;
//var_dump($backpack->equipped['soldier']['primary']);
//var_dump($backpack->equipped);
//var_dump($backpack->items);
//echo decbin(1082130432);
//$up = unpack('f',1082130432);
//var_dump($up);
for ($x = 1; $x <= 1050; $x++) {
$fullbp[$x] = false;
}
$invalids = array_slice($fullbp, 1000, 50);
$ix = 0;
$maxpage = 300;
if (is_array($backpack->items)) {
foreach ($backpack->items as $i) {
unset($tail);
if ($fullbp[$i['position']] || !$i['position']) {
$invalids[$ix++] = $i;
} else {
$fullbp[$i['position']] = $i;
}
if ($i['position'] > $maxpage) {
$maxpage = $i['position'];
}
}
}
for ($x = 0; $x < $maxpage; $x += 50) {
$bpp[] = array('items' => array_slice($fullbp, $x, 50));
}
if ($ix > 0) {
$bpp[] = array('items' => $invalids);
}
$this->params['bpp'] = $bpp;
$this->title = htmlspecialchars($player->info['name']);
$this->params['player_name'] = $this->title;
if ($player_id === '76561197972495328') {
$this->params['player_name'] .= ' — <span style="color:#4d8bd0">TF2Stats Creator</span>';
} else {
if ($player_id === '76561197972494985') {
$this->params['player_name'] = '<a href="//xpaw.ru" target="_blank" style="text-decoration:none">' . $this->title . '</a> — <span style="color:#d0514d">TF2Stats Maintainer</span>';
}
}
$this->params['valve_employee'] = in_array($player_id, $VALVE_EMPLOYEES);
}
示例8: getPropertyList
/**
* @return HTML
* @param string $field_name - Системное имя поля для которого будет выводится список значений справочника
* @param int $obj_id - ID объекта для которого формируется список
* @param string $templ_name - Шаблон оформления списка, структура шаблона аналогична структуре макроса %structure.objList()%
* @desc МАКРОС: Выводит список значений справочника, соотвествующих указанному объекту
*/
public function getPropertyList($field_name, $obj_id, $templ_name = 'default')
{
$list = '';
// подгружаем файл шаблона
$templ_file = '/structure/objects/' . $templ_name . '.tpl';
$TEMPLATE = page::getTemplate($templ_file);
if (!is_array($TEMPLATE)) {
return page::errorNotFound('structure.getPropertyList', $templ_file);
}
if ($page = ormPages::get($obj_id)) {
if ($field = $page->getClass()->getField($field_name)) {
if ($field->getType() == 95 || $field->getType() == 100) {
if ($curClass = ormClasses::get($field->getListId())) {
$class_name = $curClass->getSName();
} else {
$class_name = '';
}
$sel = new ormSelect($class_name);
if ($field->getType() == 100 || $curClass->isPage()) {
$sel->findInPages();
}
$sel->depends($obj_id, $field->id());
$class_list = $sel->getClassesList();
if (empty($class_list)) {
$class_list[] = '1';
}
//if (!empty($class_list)) {
// Узнаем какие поля объектов будут участвовать в выборке
$uri = false;
$fields_str = '';
$fields = page::getFields('obj', $TEMPLATE, $class_list);
if (isset($fields['obj'])) {
while (list($key, $val) = each($fields['obj'])) {
if ($val != 'url' && $val != 'class' && $val != 'num') {
$fields_str .= empty($fields_str) ? $val : ', ' . $val;
}
}
}
$sel->fields($fields_str);
// echo $fields_str;
// Перебираем объекты
while ($obj = $sel->getObject()) {
// Парсим поля страницы
if (isset($fields['obj_all'])) {
reset($fields['obj_all']);
while (list($num, $name) = each($fields['obj_all'])) {
page::assign('obj.' . $name, $obj->__get($name));
}
}
$num = $sel->getObjectNum() + 1;
if ($field->getType() == 100 || $curClass->isPage()) {
$target = $obj->in_new_window ? ' target="_blank"' : '';
page::assign('obj.target', $target);
page::assign('obj.url', $obj->_url);
}
page::assign('obj.num', $num);
page::assign('obj.class', $class_name);
page::assign('class-first', $num == 1 ? 'first' : '');
page::assign('class-last', $num == $sel->getObjectCount() ? 'last' : '');
page::assign('class-odd', $num % 2 == 0 ? 'odd' : '');
page::assign('class-even', $num % 2 != 0 ? 'even' : '');
page::assign('class-third', $num % 3 == 0 ? 'third' : '');
if ($num === 1) {
page::assign('first_children_id', $obj->id);
}
page::assign('last_children_id', $obj->id);
if (isset($TEMPLATE['list_' . $class_name])) {
$templ = 'list_' . $class_name;
} else {
if (isset($TEMPLATE['list'])) {
$templ = 'list';
} else {
$templ = '';
}
}
$act = '';
//(isset($TEMPLATE[$templ.'_active']) && $obj->id == $act) ? '_active' : '';
if (isset($TEMPLATE[$templ . $act])) {
if ($num > 1 && isset($TEMPLATE['separator'])) {
$list .= $TEMPLATE['separator'];
}
$list .= page::parse($TEMPLATE[$templ . $act]);
}
}
//}
if (!empty($list)) {
page::assign('list', $list);
$list = page::parse($TEMPLATE['frame_list']);
} else {
if (isset($TEMPLATE['empty'])) {
$list = page::parse($TEMPLATE['empty']);
}
}
//.........这里部分代码省略.........