public function prepare() { $this->template = "usercp"; $this->title = "User control panel"; $admin = IsUserAdmin(); if ($admin) { global $db; if ($this->request[0] == 'update_schema') { require_once 'classes/backpack.php'; backpack::update_schema(); $this->params['success'] = 'Schema updated! Have a nice day <3'; } else { if ($this->request[0] == 'purge_cache') { require_once 'classes/cache.php'; cache::clean(); $this->params['success'] = 'Memcached cache purged! Have a nice day <3'; } } /*else if($this->request[0] == 'valve_maps') { global $list; $maps = explode("\n",$list); foreach($maps as $map) { list($m, $ext) = explode(".",trim($map)); //echo $m; $db->query("UPDATE tf2_maps SET official=1 where name=%s",array($m)); } $this->params['success'] = 'Maps valveified!'; }*/ } $this->params['admin'] = $admin; }
public function prepare() { if (IsUserAdmin()) { $this->template = "ref_report"; $this->tab = "more"; global $db; $db->query("SELECT * FROM tf2stats_ref ORDER BY count DESC"); while ($row = $db->fetch_array()) { $row['source_display'] = strlen($row['source']) > 62 ? substr($row['source'], 0, 62) . "..." : $row['source']; $row['dest_display'] = urldecode($row['dest']); $rows[] = $row; } $this->params['refs'] = $rows; } }
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.'; } } return; } // tinyMCE setup $this->head .= '<script type="text/javascript" src="/static/js/tiny_mce/jquery.tinymce.js"></script> <script type="text/javascript"> $().ready(function() { $(\'textarea.tinymce\').tinymce({ // Location of TinyMCE script script_url : "/static/js/tiny_mce/tiny_mce.js", theme : "advanced", mode : "none", plugins : "bbcode", theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle", content_css : "css/bbcode.css", entity_encoding : "raw", add_unload_trigger : false, remove_linebreaks : false, inline_styles : false, convert_fonts_to_spans : false, apply_source_formatting : false }); }); </script> '; // map info $this->template = "manage_map"; require_once 'classes/map.php'; $m = new map($this->request[0]); $this->params['images'] = $m->get_images('xy165'); $this->params['has_images'] = $this->params['images']; $this->params['can_set_official'] = IsUserAdmin(); // associated peoples $db->query("SELECT p.id, p.name, mp.type from tf2stats_map_to_player mp LEFT JOIN tf2_players p ON mp.player_id = p.id WHERE mp.map_id = %s", array($map_info['id'])); while ($row = $db->fetch_array()) { $row['del_link'] = sprintf('/manage_map/%s/delauthor/%s/', $this->request[0], $row['id']); $p[] = $row; } $this->title = sprintf("Managing %s", htmlspecialchars($this->request[0])); $this->params['people'] = $p; }
public static function error($title, $message, $args = array('image' => 'heavy_shotgun')) { global $settings; $images = array('heavy_shoot' => array('img_width' => 351, 'img' => $settings['images_folder'] . 'heavy render.png', 'img_alt' => "CRY SOME MORE!"), 'heavy_yell' => array('img_width' => 375, 'img' => $settings['images_folder'] . 'heavy_whotouched.png', 'img_alt' => 'WHO TOUCHED MY GUN!?'), 'heavy_shotgun' => array('img_width' => 343, 'img' => $settings['images_folder'] . 'Heavy_with_shotty.png', 'img_alt' => 'ALL OF YOU ARE DEAD!'), 'sentry' => array('img_width' => 300, 'img' => $settings['images_folder'] . 'Sentry-lvl-1.png', 'img_alt' => 'BEEP! BEEP! BEEP!'), 'spy' => array('img_width' => 319, 'img' => $settings['images_folder'] . 'tf2_spy1s.png', 'img_alt' => 'Ahem. Gentlemen.'), 'soldier' => array('img_width' => 261, 'img' => $settings['images_folder'] . 'tf2soldier.png', 'img_alt' => 'MAGGOTS!')); $params = array('title' => $title, 'message' => $message); page::draw('error', array_merge($params, $images[$args['image']])); if (IsUserAdmin()) { global $CACHE_LOG, $runtime; printf("<pre>%s\nTotal run time: %s</pre>", $CACHE_LOG, number_format(microtime(true) - $runtime, 3)); } exit; }
exit; } /*if(date('m/d/y') == '1/18/12') { header('Location: http://sopablackout.org/learnmore/'); die(); }*/ if (false && $_SERVER['REMOTE_ADDR'] == '::ffff:75.179.179.209') { ini_set('display_errors', 1); ini_set('error_reporting', E_ALL ^ E_NOTICE); } else { ini_set('display_errors', 0); } // image check $b = explode('/', $_REQUEST['page']); if ($b[0] == 'i') { require_once 'i.php'; exit; } libxml_use_internal_errors(true); require_once 'includes/common.php'; //echo $_REQUEST['page']; //if($_REQUEST['page'] != 'dead') // header('Location: http://tf2stats.net/dead'); page::load($_REQUEST['page']); //page::load("dead"); //$page->error("ERROR l4ZY","Programmer is lazy."); //printf("<!-- %s -->", $user->id()); if (IsUserAdmin()) { printf("<pre>%s\nTotal run time: %s</pre>", $CACHE_LOG, number_format(microtime(true) - $runtime, 3)); }