$Date: 2005-12-08 16:32:40 +0000 (Thu, 08 Dec 2005) $ | > $Revision: 96 $ | > $Author: bfarber $ +--------------------------------------------------------------------------- | | > Admin functions library | > Script written by Matt Mecham | > Date started: 1st march 2002 | | > DBA Checked: Tue 25th May 2004 +-------------------------------------------------------------------------- */ class admin_functions { # Global var $ipsclass; var $img_url; var $page_title = "Добро пожаловать в админцентр Invision Power Board"; var $page_detail = "Вы можете настраивать ваш форум, используя этот админцентр.

Нажатие на одну из ссылок в левом меню загрузит выбранные настройки в окне справа для администрирования. Каждая опция содержит какую-то информацию."; var $html; var $errors = ""; var $nav = array(); var $time_offset = 0; var $jump_menu = ""; var $no_jump = 0; var $master_skin = array(); var $depth_guide = '--'; var $menu_ids = array(); /*-------------------------------------------------------------------------*/ // CONSTRUCTOR /*-------------------------------------------------------------------------*/ function admin_functions() { $this->ipsclass->base_url = $this->ipsclass->base_url; $this->img_url = $this->ipsclass->skin_url; } /*-------------------------------------------------------------------------*/ // ACP PERMISSION CHECK /*-------------------------------------------------------------------------*/ function cp_permission_check( $perm) { //---------------------------------- // Got actual restrictions? //---------------------------------- if ( ! $this->ipsclass->member['row_perm_cache'] ) { return TRUE; } //------------------------------- // Get lang: NEEDS SORTIN' //------------------------------- if ( ! is_array( $this->perm_lang ) OR ! count( $this->perm_lang ) ) { require_once( ROOT_PATH."cache/lang_cache/ru/acp_lang_acpperms.php" ); $this->perm_lang = $lang; } //---------------------------------- // Got restrictions in place... // 1) Check tab root and parent //---------------------------------- list( $perm_main , $_data ) = explode( '|', $perm ); list( $perm_child, $perm_bit ) = explode( ':', $_data ); if ( ! $this->ipsclass->member['_perm_cache'][ $perm_main ] ) { $this->ipsclass->kill_menu = 1; $this->ipsclass->admin->error("Вы не имеет доступа к этой таблице: ".$this->perm_lang[ $perm_main ] ); exit(); } //---------------------------------- // Got restrictions in place... // 2) Check feature parent //---------------------------------- if ( $perm_child ) { if ( ! $this->ipsclass->member['_perm_cache'][ $perm_main .':'. $perm_child ] ) { if ( $this->perm_lang[ $perm_main .':'. $perm_child ] ) { $this->ipsclass->admin->error("Вы не имеет доступа к возможности: ".$this->perm_lang[ $perm_main .':'. $perm_child ]); } else { $this->ipsclass->admin->error("Вы не имеет доступа к этой возможности"); } exit(); } } //---------------------------------- // Got restrictions in place... // 3) Check feature parent //---------------------------------- if ( $perm_bit ) { if ( ! $this->ipsclass->member['_perm_cache'][ $perm_main .':'. $perm_child .':'. $perm_bit ] ) { $this->ipsclass->admin->error("Вы не имеет доступа к функции этой возможности"); exit(); } } return TRUE; } /*-------------------------------------------------------------------------*/ // ACP_SESSION /*-------------------------------------------------------------------------*/ function acp_session_validation( $check_ip=1 ) { if ( ! $this->ipsclass->input['adsess'] ) { //---------------------------------- // No URL adsess found, lets log in. //---------------------------------- $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Сессий администратора не найдено"; return FALSE; } else { //---------------------------------- // We have a URL adsess, lets verify... //---------------------------------- $this->ipsclass->DB->query("SELECT * FROM ibf_admin_sessions WHERE session_id='".$this->ipsclass->input['adsess']."'"); $row = $this->ipsclass->DB->fetch_row(); if ( $row['session_id'] == "" ) { //---------------------------------- // Fail-safe, no DB record found, lets log in.. //---------------------------------- $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Невозможно запросить сессию"; return FALSE; } else if ($row['session_member_id'] == "") { //---------------------------------- // No member ID is stored, log in! //---------------------------------- $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Невозможно определить правильный ID"; return FALSE; } else { //---------------------------------- // Key is good, check the member details //---------------------------------- $this->ipsclass->DB->build_query( array( 'select' => 'm.*', 'from' => array( 'members' => 'm' ), 'where' => 'm.id='.intval($row['session_member_id']), 'add_join' => array( 0 => array( 'select' => 'g.*', 'from' => array( 'groups' => 'g' ), 'where' => 'g.g_id=m.mgroup', 'type' => 'left' ), 1 => array( 'select' => 'p.*', 'from' => array( 'admin_permission_rows' => 'p' ), 'where' => 'm.id=p.row_member_id', 'type' => 'left' ) ) ) ); $this->ipsclass->DB->exec_query(); $this->ipsclass->member = $this->ipsclass->DB->fetch_row(); $this->ipsclass->member['_perm_cache'] = unserialize( $this->ipsclass->member['row_perm_cache'] ); //---------------------------------- // Get perms //---------------------------------- $this->ipsclass->sess->member = $this->ipsclass->member; $this->ipsclass->sess->build_group_permissions(); $this->ipsclass->member = $this->ipsclass->sess->member; if ($this->ipsclass->member['id'] == "") { //---------------------------------- // Ut-oh, no such member, log in! //---------------------------------- $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "ID пользователя неверно"; return FALSE; } else { //---------------------------------- // Member found, check passy //---------------------------------- if ($row['session_member_login_key'] != $this->ipsclass->member['member_login_key']) { //---------------------------------- // Passys don't match.. //---------------------------------- $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Сессия пароля не совпадает"; return FALSE; } else { //---------------------------------- // Do we have admin access? //---------------------------------- if ($this->ipsclass->member['g_access_cp'] != 1) { $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Вы не имеет доступа в админцентр"; return FALSE; } else { $this->ipsclass->admin_session = $row; $this->ipsclass->admin_session['_session_validated'] = 1; } } } } } //---------------------------------- // If we're here, we're valid... //---------------------------------- if ( $this->ipsclass->admin_session['_session_validated'] == 1 ) { if ( $this->ipsclass->admin_session['session_running_time'] < ( time() - 60*60*2) ) { $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Текущая сессия администратора истекла"; } //------------------------------ // Are we checking IP's? //------------------------------ else if ($check_ip == 1) { $first_ip = preg_replace( "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3", $this->ipsclass->admin_session['session_ip_address'] ); $second_ip = preg_replace( "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/", "\\1.\\2.\\3", $this->ipsclass->ip_address ); if ( $first_ip != $second_ip ) { $this->ipsclass->admin_session['_session_validated'] = 0; $this->ipsclass->admin_session['_session_message'] = "Ваш текущий IP не совпадает ни с одной нашей записью"; return FALSE; } } //------------------------------ // Lets update the sessions table: //------------------------------ $this->ipsclass->DB->do_update( 'admin_sessions', array( 'session_running_time' => time(), 'session_location' => $this->ipsclass->input['act'] ), 'session_member_id='.intval($this->ipsclass->member['id'])." and session_id='".$this->ipsclass->input['adsess']."'" ); return TRUE; } } /*-------------------------------------------------------------------------*/ // Get mysql version /*-------------------------------------------------------------------------*/ function get_mysql_version() { $this->ipsclass->DB->sql_get_version(); $this->ipsclass->true_version = $this->ipsclass->DB->true_version; $this->ipsclass->mysql_version = $this->ipsclass->DB->mysql_version; } /*-------------------------------------------------------------------------*/ // Get mysql version /*-------------------------------------------------------------------------*/ function get_fulltextindex_status() { if ( $this->ipsclass->DB->sql_is_currently_fulltext( 'posts' ) == TRUE ) { return 1; } else { return 0; } } /*-------------------------------------------------------------------------*/ // make template / text data safe for forms /*-------------------------------------------------------------------------*/ function text_to_form($t="") { // Use forward look up to only convert & not { //$t = preg_replace("/&(?!#[0-9]+;)/s", '&', $t ); $t = str_replace("&", "&" , $t ); $t = str_replace( "<" , "<" , $t ); $t = str_replace( ">" , ">" , $t ); $t = str_replace( '"' , """ , $t ); $t = str_replace( "'" , ''' , $t ); $t = str_replace( "\\", "\" , $t ); return $t; // A nice cup of? } /*-------------------------------------------------------------------------*/ // Converts form data back into raw text /*-------------------------------------------------------------------------*/ function form_to_text($t="") { $t = str_replace( '\\' , '\\\\', $t ); $t = str_replace( "&" , "&", $t ); $t = str_replace( "<" , "<", $t ); $t = str_replace( ">" , ">", $t ); $t = str_replace( """ , '"', $t ); $t = str_replace( "'" , "'", $t ); $t = str_replace( '\' ,'\\', $t ); return $t; } /*-------------------------------------------------------------------------*/ // Generate skin list /*-------------------------------------------------------------------------*/ function skin_get_skin_dropdown() { $skin_array = array(); foreach( $this->ipsclass->cache['skin_id_cache'] as $id => $data ) { if ( $data['set_parent'] < 1 and $id > 1 ) { $data['set_parent'] = 'root'; } $this->master_skin[ $data['set_parent'] ][ $id ] = $data; } foreach( $this->master_skin['root'] as $id => $data ) { $skin_array[] = array( $id, $data['set_name'] ); if ( is_array( $this->master_skin[ $id ] ) ) { foreach( $this->master_skin[ $id ] as $id => $data ) { $skin_array[] = array( $id, $this->depth_guide.$data['set_name'] ); $skin_array = $this->skin_get_skin_dropdown_recurse( $id, $skin_array, $this->depth_guide.$this->depth_guide ); } } } return $skin_array; } /*-------------------------------------------------------------------------*/ // Recurse /*-------------------------------------------------------------------------*/ function skin_get_skin_dropdown_recurse( $root_id, $skin_array=array(), $depth_guide='' ) { if ( is_array( $this->master_skin[ $root_id ] ) ) { foreach( $this->master_skin[ $root_id ] as $id => $data ) { $skin_array[] = array( $id, $this->depth_guide.$data['set_name'] ); $skin_array = $this->skin_get_skin_dropdown_recurse( $id, $skin_array, $this->depth_guide.$this->depth_guide ); } } return $skin_array; } /*-------------------------------------------------------------------------*/ // IMPORT FUNCTION /*-------------------------------------------------------------------------*/ function import_xml( $infilename ) { //----------------------------------------- // Allowed file-types //----------------------------------------- $allowed_files = array( 'xml', 'gz' ); //----------------------------------------- // Upload //----------------------------------------- $FILE_NAME = $_FILES['FILE_UPLOAD']['name']; $FILE_SIZE = $_FILES['FILE_UPLOAD']['size']; $FILE_TYPE = $_FILES['FILE_UPLOAD']['type']; //----------------------------------------- // Naughty Opera adds the filename on the end of the // mime type - we don't want this. //----------------------------------------- $FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE ); //----------------------------------------- // Naughty Mozilla likes to use "none" to indicate an empty upload field. // I love universal languages that aren't universal. //----------------------------------------- if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") ) { continue; } //----------------------------------------- // Not a naughty file? //----------------------------------------- $file_extension = preg_replace( "#^.*\.(.+?)$#si", "\\1", strtolower( $_FILES['FILE_UPLOAD']['name'] ) ); if ( ! in_array( $file_extension, $allowed_files ) ) { @unlink( $_FILES[ $postfield ]['tmp_name'] ); return ''; } $content = ""; if ( strstr( $FILE_NAME, $infilename ) ) { if ( move_uploaded_file( $_FILES[ 'FILE_UPLOAD' ]['tmp_name'], $this->ipsclass->vars['upload_dir']."/".$FILE_NAME) ) { if ( $FILE_NAME == $infilename.'.gz' ) { if ( $FH = @gzopen( $this->ipsclass->vars['upload_dir']."/".$FILE_NAME, 'rb' ) ) { while ( ! @gzeof( $FH ) ) { $content .= @gzread( $FH, 1024 ); } @gzclose( $FH ); } } else if ( $FILE_NAME == $infilename ) { if ( $FH = @fopen( $this->ipsclass->vars['upload_dir']."/".$FILE_NAME, 'rb' ) ) { $content = @fread( $FH, filesize($this->ipsclass->vars['upload_dir']."/".$FILE_NAME) ); @fclose( $FH ); } } @unlink( $this->ipsclass->vars['upload_dir']."/".$FILE_NAME ); } } return $content; } /*-------------------------------------------------------------------------*/ // Shows dialogue download box /*-------------------------------------------------------------------------*/ function show_download( $data, $name, $type="unknown/unknown", $compress=1 ) { if ( $compress and @function_exists('gzencode') ) { $name .= '.gz'; } else { $compress = 0; } header('Content-Type: '.$type); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Disposition: attachment; filename="' . $name . '"'); if ( ! $compress ) { @header('Content-Length: ' . strlen($data) ); } @header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); @header('Pragma: public'); if ( $compress ) { print gzencode($data); } else { print $data; } exit(); } /*-------------------------------------------------------------------------*/ // Makes good raw form text /*-------------------------------------------------------------------------*/ function make_safe($t) { $t = stripslashes($t); $t = preg_replace( "/\\\/", "\", $t ); return $t; } /*-------------------------------------------------------------------------*/ // Sets up time offset for ACP use /*-------------------------------------------------------------------------*/ function get_date($date="", $method="") { $this->time_options = array( 'JOINED' => $this->ipsclass->vars['clock_joined'], 'SHORT' => $this->ipsclass->vars['clock_short'], 'LONG' => $this->ipsclass->vars['clock_long'] ); if (!$date) { return '--'; } if (empty($method)) { $method = 'LONG'; } $this->time_offset = (($this->ipsclass->member['time_offset'] != "") ? $this->ipsclass->member['time_offset'] : $this->ipsclass->vars['time_offset']) * 3600; if ($this->ipsclass->vars['time_adjust'] != "" and $this->ipsclass->vars['time_adjust'] != 0) { $this->time_offset += ($this->ipsclass->vars['time_adjust'] * 60); } if ($this->ipsclass->member['dst_in_use']) { $this->time_offset += 3600; } return gmdate($this->time_options[$method], ($date + $this->time_offset) ); } /*-------------------------------------------------------------------------*/ // save_log /*-------------------------------------------------------------------------*/ function save_log($action="") { $this->ipsclass->DB->do_insert( 'admin_logs', array( 'act' => $this->ipsclass->input['act'], 'code' => $this->ipsclass->input['code'], 'member_id' => $this->ipsclass->member['id'], 'ctime' => time(), 'note' => $action, 'ip_address' => $this->ipsclass->input['IP_ADDRESS'], ) ); return true; } /*-------------------------------------------------------------------------*/ // get_tar_names /*-------------------------------------------------------------------------*/ function get_tar_names($start='lang-') { $files = array(); $dir = $this->ipsclass->vars['base_dir']."archive_in"; if ( is_dir($dir) ) { $handle = opendir($dir); while (($filename = readdir($handle)) !== false) { if (($filename != ".") && ($filename != "..")) { if (preg_match("/^$start.+?\.tar$/", $filename)) { $files[] = $filename; } } } closedir($handle); } return $files; } /*-------------------------------------------------------------------------*/ // copy_dir /*-------------------------------------------------------------------------*/ function copy_dir($from_path, $to_path, $mode = 0777) { // Strip off trailing slashes... $from_path = preg_replace( "#/$#", "", $from_path); $to_path = preg_replace( "#/$#", "", $to_path); if ( ! is_dir($from_path) ) { $this->errors = "Невозможно найти папку /$from_path"; return FALSE; } if ( ! is_dir($to_path) ) { if ( ! @mkdir($to_path, $mode) ) { $this->errors = "Невозможно создать папку /$to_path/! Пожалуйста, проверьте права доступа (CHMOD) и попробуйте снова."; return FALSE; } else { @chmod($to_path, $mode); } } //$this_path = getcwd(); if (is_dir($from_path)) { //chdir($from_path); $handle = opendir($from_path); while (($file = readdir($handle)) !== false) { if (($file != ".") && ($file != "..")) { if ( is_dir( $from_path."/".$file ) ) { $this->copy_dir($from_path."/".$file, $to_path."/".$file); //chdir($from_path); } if ( is_file( $from_path."/".$file ) ) { copy($from_path."/".$file, $to_path."/".$file); @chmod($to_path."/".$file, 0777); } } } closedir($handle); } if ($this->errors == "") { return TRUE; } } /*-------------------------------------------------------------------------*/ // rm_dir /*-------------------------------------------------------------------------*/ function rm_dir($file) { $errors = 0; // Remove trailing slashes.. $file = preg_replace( "#/$#", "", $file ); if ( file_exists($file) ) { // Attempt CHMOD @chmod($file, 0777); if ( is_dir($file) ) { $handle = opendir($file); while (($filename = readdir($handle)) !== false) { if (($filename != ".") && ($filename != "..")) { $this->rm_dir($file."/".$filename); } } closedir($handle); if ( ! @rmdir($file) ) { $errors++; } } else { if ( ! @unlink($file) ) { $errors++; } } } if ($errors == 0) { return TRUE; } else { return FALSE; } } /*-------------------------------------------------------------------------*/ // rebuild_config: /*-------------------------------------------------------------------------*/ function rebuild_config( $new = "" ) { //----------------------------------------- // Check to make sure this is a valid array //----------------------------------------- if (! is_array($new) ) { $ibforums->admin->error("Ошибка! Не удалось обновить конфигурационный файл форума. Действие отменено!"); } //----------------------------------------- // Do we have anything to save out? //----------------------------------------- if ( count($new) < 1 ) { return ""; } //----------------------------------------- // Get an up to date copy of the config file // (Imports $INFO) //----------------------------------------- require ROOT_PATH.'conf_global.php'; //----------------------------------------- // Rebuild the $INFO hash //----------------------------------------- foreach( $new as $k => $v ) { // Update the old... $v = preg_replace( "/'/", "\\'" , $v ); $v = preg_replace( "/\r/", "" , $v ); $INFO[ $k ] = $v; } //----------------------------------------- // Rename the old config file //----------------------------------------- @rename( ROOT_PATH.'conf_global.php', ROOT_PATH.'conf_global-bak.php' ); @chmod( ROOT_PATH.'conf_global-bak.php', 0777); //----------------------------------------- // Rebuild the old file //----------------------------------------- ksort($INFO); $file_string = " $v ) { if ($k == 'skin' or $k == 'languages') { // Protect serailized arrays.. $v = stripslashes($v); $v = addslashes($v); } $file_string .= '$INFO['."'".$k."'".']'."\t\t\t=\t'".$v."';\n"; } $file_string .= "\n".'?'.'>'; // Question mark + greater than together break syntax hi-lighting in BBEdit 6 :p if ( $fh = fopen( ROOT_PATH.'conf_global.php', 'w' ) ) { fwrite($fh, $file_string, strlen($file_string) ); fclose($fh); } else { $this->ipsclass->admin->error("Критическая ошибка! Не удалось открыть для записи файл conf_global.php - изменения не будут внесены. Необходимо изменить права доступа (CHMOD) к файлу на 0777."); } // Pass back the new $INFO array to anyone who cares... return $this->ipsclass->vars; } /*-------------------------------------------------------------------------*/ // compile_forum_perms: // // Returns the READ/REPLY/START DB strings // /*-------------------------------------------------------------------------*/ function compile_forum_perms() { $r_array = array( 'READ' => '', 'REPLY' => '', 'START' => '', 'UPLOAD' => '' ); if ($this->ipsclass->input['READ_ALL'] == 1) { $r_array['READ'] = '*'; } if ($this->ipsclass->input['REPLY_ALL'] == 1) { $r_array['REPLY'] = '*'; } if ($this->ipsclass->input['START_ALL'] == 1) { $r_array['START'] = '*'; } if ($this->ipsclass->input['UPLOAD_ALL'] == 1) { $r_array['UPLOAD'] = '*'; } if ($this->ipsclass->input['SHOW_ALL'] == 1) { $r_array['SHOW'] = '*'; } $this->ipsclass->DB->simple_construct( array( 'select' => 'perm_id, perm_name', 'from' => 'forum_perms', 'order' => "perm_id" ) ); $this->ipsclass->DB->simple_exec(); while ( $data = $this->ipsclass->DB->fetch_row() ) { if ($r_array['SHOW'] != '*') { if ($this->ipsclass->input[ 'SHOW_'.$data['perm_id'] ] == 1) { $r_array['SHOW'] .= $data['perm_id'].","; } } //----------------------------------------- if ($r_array['READ'] != '*') { if ($this->ipsclass->input[ 'READ_'.$data['perm_id'] ] == 1) { $r_array['READ'] .= $data['perm_id'].","; } } //----------------------------------------- if ($r_array['REPLY'] != '*') { if ($this->ipsclass->input[ 'REPLY_'.$data['perm_id'] ] == 1) { $r_array['REPLY'] .= $data['perm_id'].","; } } //----------------------------------------- if ($r_array['START'] != '*') { if ($this->ipsclass->input[ 'START_'.$data['perm_id'] ] == 1) { $r_array['START'] .= $data['perm_id'].","; } } //----------------------------------------- if ($r_array['UPLOAD'] != '*') { if ($this->ipsclass->input[ 'UPLOAD_'.$data['perm_id'] ] == 1) { $r_array['UPLOAD'] .= $data['perm_id'].","; } } } $r_array['START'] = preg_replace( "/,$/", "", $r_array['START'] ); $r_array['REPLY'] = preg_replace( "/,$/", "", $r_array['REPLY'] ); $r_array['READ'] = preg_replace( "/,$/", "", $r_array['READ'] ); $r_array['UPLOAD'] = preg_replace( "/,$/", "", $r_array['UPLOAD'] ); $r_array['SHOW'] = preg_replace( "/,$/", "", $r_array['SHOW'] ); return $r_array; } /*-------------------------------------------------------------------------*/ // OUTPUT FUNCTIONS /*-------------------------------------------------------------------------*/ function print_popup() { global $use_gzip; //-------------------------------------- // Message in a bottle? //-------------------------------------- if ( $this->ipsclass->main_msg ) { $html = $this->ipsclass->skin_global_acp->global_message(); } $html .= $this->ipsclass->skin_global_acp->global_popup( $this->ipsclass->html ); print $html; exit(); } /*-------------------------------------------------------------------------*/ // Multi-redirect /*-------------------------------------------------------------------------*/ function output_multiple_redirect_init( $url, $text='', $addtotext=1 ) { //$this->nav[] = array( $url, 'Redirecting...' ); if ( $this->ipsclass->can_use_fancy_js ) { $this->ipsclass->html .= "\n
Инициализация...
"; } else { $this->ipsclass->html .= ""; } $this->output(); } /*-------------------------------------------------------------------------*/ // Multi-redirect (hit) /*-------------------------------------------------------------------------*/ function output_multiple_redirect_hit( $url, $text='', $addtotext=1 ) { if ( $this->ipsclass->can_use_fancy_js ) { print "ajax_refresh( '$url', '$text', $addtotext );"; exit(); } else { print $this->ipsclass->skin_global_acp->global_redirect_hit( $url, $text ); exit(); } } /*-------------------------------------------------------------------------*/ // Multi-redirect (hit) /*-------------------------------------------------------------------------*/ function output_multiple_redirect_done($text='Готово!') { if ( $this->ipsclass->can_use_fancy_js ) { $text = str_replace( "'", "\\'", $text ); print "document.getElementById('refreshbox').innerHTML = '$text' + '
' + document.getElementById('refreshbox').innerHTML;"; exit(); } else { print $this->ipsclass->skin_global_acp->global_redirect_done( $text ); exit(); } } /*-------------------------------------------------------------------------*/ // OUTPUT /*-------------------------------------------------------------------------*/ function output() { global $use_gzip; //----------------------------------------- // Debug? //----------------------------------------- if ($this->ipsclass->DB->obj['debug']) { flush(); print "SQL Отладчик"; print "

SQL Общее время: {$this->ipsclass->DB->sql_time} для {$this->ipsclass->DB->query_cnt} запросов


".$this->ipsclass->DB->debug_html; print "
Общее время работы SQL: {$this->ipsclass->DB->sql_time}
"; exit(); } //----------------------------------------- // Start function proper //----------------------------------------- $html = str_replace( '<%CONTENT%>', $this->ipsclass->skin_global_acp->global_frame_wrapper(), $this->ipsclass->skin_global_acp->global_main_wrapper() ); $this->ipsclass->DB->close_db(); $navigation = array( "На главную" ); if ( count($this->nav) > 0 ) { foreach ( $this->nav as $idx => $links ) { if ($links[0] != "") { $navigation[] = "{$links[1]}"; } else { $navigation[] = $links[1]; } } } //-------------------------------------- // Navigation? //-------------------------------------- if ( count($navigation) > 0 ) { $html = str_replace( "<%NAV%>", $this->ipsclass->skin_global_acp->global_wrap_nav( implode( " > ", $navigation ) ), $html ); } //-------------------------------------- // Message in a bottle? //-------------------------------------- if ( $this->ipsclass->main_msg ) { $message = $this->ipsclass->skin_global_acp->global_message(); } //-------------------------------------- // Help? //-------------------------------------- $this->ipsclass->html_help_msg = $this->ipsclass->html_help_msg ? $this->ipsclass->html_help_msg : $this->page_detail; $this->ipsclass->html_help_title = $this->ipsclass->html_help_title ? $this->ipsclass->html_help_title : $this->page_title; if ( $this->ipsclass->html_help_title ) { $help = $this->ipsclass->skin_global_acp->global_help_block( $this->ipsclass->html_help_title, $this->ipsclass->html_help_msg ); } //----------------------------------------- // Quick Jump? //----------------------------------------- if ( $this->no_jump != 1 ) { $html = str_replace( "", $this->build_jump_menu(), $html ); } //----------------------------------------- // Kill menu? // For when we don't want to show the menu // during a tab error from cp_permission_check //----------------------------------------- if ( $this->ipsclass->kill_menu ) { $html .= ""; } //----------------------------------------- // Show queries //----------------------------------------- $query_html = ""; if ( IN_DEV and count( $this->ipsclass->DB->obj['cached_queries']) ) { $queries = ""; foreach( $this->ipsclass->DB->obj['cached_queries'] as $q ) { if ( strlen($q) > 300 ) { $q = substr( $q, 0, 300 ).'...'; } $queries .= htmlspecialchars($q).'
'; } $query_html .= $this->ipsclass->skin_global_acp->global_query_output($queries); } global $Debug; $query_html .= "

Время генерации страницы: ".$Debug->endTimer()."
"; //----------------------------------------- // Other tags... //----------------------------------------- $html = str_replace( "<%TITLE%>" , $this->ipsclass->html_title, $html ); $html = str_replace( "<%MENU%>" , $this->build_menu() , $html ); $html = str_replace( "<%TABS%>" , $this->build_tabs() , $html ); $html = str_replace( "<%SECTIONCONTENT%>", $this->ipsclass->html, $html ); $html = str_replace( "<%MSG%>" , $message , $html ); $html = str_replace( "<%HELP%>" , $help , $html ); $html = str_replace( "<%QUERIES%>" , $query_html , $html ); //----------------------------------------- // Got BODY EXTRA? //----------------------------------------- if ( $this->ipsclass->body_extra ) { $html = str_replace( "ipsclass->body_extra, $html ); } //----------------------------------------- // Gzip? //----------------------------------------- if ($use_gzip == 1) { $buffer = ob_get_contents(); ob_end_clean(); @ob_start('ob_gzhandler'); print $buffer; } @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @header("Cache-Control: no-cache, must-revalidate"); @header("Pragma: no-cache"); print $html; exit(); } /*-------------------------------------------------------------------------*/ // Build menu tree /*-------------------------------------------------------------------------*/ function build_tabs() { $onoff['content'] = 'taboff'; $onoff['lookandfeel'] = 'taboff'; $onoff['tools'] = 'taboff'; $onoff['components'] = 'taboff'; $onoff['admin'] = 'taboff'; $onoff[ $this->ipsclass->menu_type ] = 'tabon'; return $this->ipsclass->skin_global_acp->global_tabs( $onoff ); } /*-------------------------------------------------------------------------*/ // BUILD MENU /*-------------------------------------------------------------------------*/ function build_menu() { //-------------------------------- // Catch log in pages, etc //-------------------------------- if ( ! $this->ipsclass->menu_type ) { return; } //-------------------------------- // Import $PAGES and $CATS //-------------------------------- require_once( ROOT_PATH."sources/acp_loaders/acp_pages_".$this->ipsclass->menu_type.".php" ); $this->pages = $PAGES; $this->cats = $CATS; $this->desc = $DESC; $html = $this->build_tree(); return $html; } /*-------------------------------------------------------------------------*/ // Show in frame /*-------------------------------------------------------------------------*/ function show_inframe($url="", $html="") { if ( $url ) { $this->ipsclass->html .= ""; } else { $this->ipsclass->html .= ""; } $this->output(); } /*-------------------------------------------------------------------------*/ // Redirect: /*-------------------------------------------------------------------------*/ function redirect($url, $text, $is_popup=0, $time=2) { //-------------------------------- // Got board URL in url? //-------------------------------- if ( ! strstr( $url, $this->ipsclass->vars['board_url'] ) ) { $url = $this->ipsclass->base_url.'&'.$url; } if ( $this->ipsclass->main_msg ) { if( strlen($this->ipsclass->main_msg) > 1500 ) { $this->ipsclass->main_msg = substr( $this->ipsclass->main_msg, 0, 1500 ); } $url .= '&messageinabottleacp='.urlencode( $this->ipsclass->main_msg ); } $this->ipsclass->main_msg = ""; $this->ipsclass->html_title = "IPB: Админцентр: Переадресация..."; $html = $this->ipsclass->skin_global_acp->global_redirect( $url, $time, $text ); $this->ipsclass->html = str_replace( '<%CONTENT%>', $html, $this->ipsclass->skin_global_acp->global_main_wrapper() ); $this->ipsclass->html = str_replace( '<%TITLE%>' , $this->ipsclass->html_title, $this->ipsclass->html ); $this->ipsclass->html = str_replace( "ipsclass->html ); @header("Content-type: text/html"); print $this->ipsclass->html; exit(); } /*-------------------------------------------------------------------------*/ // No waiting redirect /*-------------------------------------------------------------------------*/ function redirect_noscreen($url) { $extra = ""; if ( $this->ipsclass->main_msg ) { $extra = '&messageinabottleacp='.urlencode( $this->ipsclass->main_msg ); } $url = str_replace( "&", "&", $url ) . $extra; if ($this->ipsclass->vars['header_redirect'] == 'refresh') { @header("Refresh: 0;url=".$url); } else if ($this->ipsclass->vars['header_redirect'] == 'html') { echo(""); exit(); } else { @header("Location: ".$url); } exit(); } /*-------------------------------------------------------------------------*/ // Error: /*-------------------------------------------------------------------------*/ function error($error="", $is_popup=0) { $this->page_title = "Сообщение админцентра"; $this->page_detail = " "; $this->ipsclass->html .= "
Сообщение админцентра
$error
"; if ($is_popup == 0) { $this->output(); } else { $this->print_popup(); } } /*-------------------------------------------------------------------------*/ // Done Screen: /*-------------------------------------------------------------------------*/ function done_screen($title, $link_text="", $link_url="", $redirect="") { if ( $redirect ) { $this->redirect( $this->ipsclass->base_url.'&'.$link_url, "$title
Перемещение к: ".$link_text ); } $this->page_title = $title; $this->page_detail = "Действие выполнено успешно"; $this->ipsclass->adskin->td_header[] = array( " " , "100%" ); $this->ipsclass->html .= $this->ipsclass->adskin->start_table("Результат"); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic( "Перейти в: $link_text", "center" ); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic( "Перейти на главную страницу админцентра", "center" ); $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); $this->output(); } /*-------------------------------------------------------------------------*/ // INFO screen /*-------------------------------------------------------------------------*/ function info_screen($text="", $title='Предупреждение Safe Mode') { $this->page_title = $title; $this->page_detail = "Пожалуйста, помните следующее:"; $this->ipsclass->adskin->td_header[] = array( " " , "100%" ); $this->ipsclass->html .= $this->ipsclass->adskin->start_table("Результат"); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic( $text ); $this->ipsclass->html .= $this->ipsclass->adskin->add_td_basic( "Перейти на: главную страницу админцентра", "center" ); $this->ipsclass->html .= $this->ipsclass->adskin->end_table(); $this->output(); } /*-------------------------------------------------------------------------*/ // Build menu tree /*-------------------------------------------------------------------------*/ function build_tree() { //---------------------------------- // INIT //---------------------------------- $html = ""; $links = ""; //---------------------------------- // Known menu stuff //---------------------------------- # Section Module CODE => Real Perm Key $menu_limits = array( 'content:mem:add' => 'content:mem:add', 'content:mem:title' => 'content:mem:title-view', ); foreach($this->cats as $cid => $data) { $name = $data[0]; $color = $data[1]; $extra = $data[2]; $this->menu_ids[] = $cid; $this->ipsclass->admin->jump_menu .= "\n"; foreach($this->pages[ $cid ] as $pid => $pdata) { if ( $pdata[2] != "" ) { if ( ! @is_dir( ROOT_PATH.$pdata[2] ) ) { continue; } } //---------------------------------- // Got actual restrictions? //---------------------------------- $no_access = 0; if ( $this->ipsclass->member['row_perm_cache'] ) { //------------------------------- // Yup.. so extract link info //------------------------------- $_tmp = str_replace( '&', '&', $pdata[1] ); $perm_child = ""; $perm_main = ""; $perm_bit = ""; foreach( explode( '&', $_tmp ) as $_urlbit ) { list( $k, $v ) = explode( '=', $_urlbit ); if ( $k == 'act' ) { $perm_child = $v; } else if ( $k == 'section' ) { $perm_main = $v; } else if ( $k == 'code' ) { $perm_bit = $v; } if ( $perm_child AND $perm_main AND $perm_bit ) { break; } } if ( $perm_child AND $perm_main AND $perm_bit AND $menu_limits[ $perm_main.':'.$perm_child.':'.$perm_bit ] ) { if ( ! $this->ipsclass->member['_perm_cache'][ $menu_limits[ $perm_main.':'.$perm_child.':'.$perm_bit ] ] ) { $no_access = 1; } } else if ( $perm_child AND $perm_main ) { if ( ! $this->ipsclass->member['_perm_cache'][ $perm_main .':'. $perm_child ] ) { $no_access = 1; } } } $links .= $this->ipsclass->adskin->menu_cat_link($pid, $cid, $pdata[1], $pdata[0], $pdata[3], $pdata[4], $no_access); } $html .= $this->ipsclass->adskin->menu_cat_wrap( $show, $name, $links, $cid, $this->desc[$cid], $color, $extra ); unset($links); $this->ipsclass->admin->jump_menu .= "\n"; } return $html; } /*-------------------------------------------------------------------------*/ // BUILDS JUMP MENU, yay! /*-------------------------------------------------------------------------*/ function build_jump_menu() { return ""; global $PAGES, $CATS, $DESC; $html = " "; $html .= "
\n \n
"; return $html; } /*-------------------------------------------------------------------------*/ // BUILD SKIN JUMP MENU /*-------------------------------------------------------------------------*/ function skin_jump_menu($set_id="") { if ( $set_id == "" ) { $set_id = $this->ipsclass->input['id']; } $set_id = intval($set_id); $r = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$set_id ) ); $html = "
"; return $html; } } ?>