📄 admin_functions.php
字号:
<?php
class admin_functions
{
var $img_url;
var $page_title = "欢迎使用华酷论坛管理控制面板";
var $page_detail = "你可以使用论坛管理控制面板设置和定制你的论坛参数;请通过点击左侧的管理选项菜单来显示相关的管理选项。在每个管理选项里都包含了详细的帮助和提示信息,以帮助你方便快速的管理论坛。<br><br><b>如果你在使用中遇到问题,请访问我们的官方技术支持论坛:</b><br><li><a href='http://www.ibfchina.com' target='_blank'>华酷论坛技术支持 - http://www.ibfchina.com</a></li><li><a href='http://service.ibfchina.com' target='_blank'>华酷论坛相关服务 - http://service.ibfchina.com</a></li><li><a href='http://download.ibfchina.com' target='_blank'>华酷论坛最新下载 - http://download.ibfchina.com</a></li>";
var $html;
var $errors = "";
var $nav = array( );
var $time_offset = 0;
function admin_functions( )
{
global $INFO;
global $IN;
$this->img_url = $INFO['html_url']."/sys-img";
$this->base_url = $INFO['board_url']."/admin.".$INFO['php_ext']."?adsess=".$IN['AD_SESS'];
}
function make_safe( $t )
{
$t = stripslashes( $t );
$t = preg_replace( "/\\\\/", "\", $t );
return $t;
}
function get_date( $date = "", $method = "" )
{
global $INFO;
global $IN;
global $MEMBER;
$this->time_options = array(
"JOINED" => $INFO['clock_joined'],
"SHORT" => $INFO['clock_short'],
"LONG" => $INFO['clock_long']
);
if ( !$date )
{
return "--";
}
if ( empty( $method ) )
{
$method = "LONG";
}
$this->time_offset = ( $MEMBER['time_offset'] != "" ? $MEMBER['time_offset'] : $INFO['time_offset'] ) * 3600;
if ( $INFO['time_adjust'] != "" && $INFO['time_adjust'] != 0 )
{
$this->time_offset += $INFO['time_adjust'] * 60;
}
if ( $MEMBER['dst_in_use'] )
{
$this->time_offset += 3600;
}
return gmdate( $this->time_options[$method], $date + $this->time_offset );
}
function save_log( $action = "" )
{
global $INFO;
global $DB;
global $IN;
global $MEMBER;
$str = $DB->compile_db_insert_string( array(
"act" => $IN['act'],
"code" => $IN['code'],
"member_id" => $MEMBER['id'],
"ctime" => time( ),
"note" => $action,
"ip_address" => $IN['IP_ADDRESS']
) );
$DB->query( "INSERT INTO ibf_admin_logs ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
return true;
}
function get_tar_names( $start = "lang-" )
{
global $INFO;
$files = array( );
$dir = $INFO['base_dir']."archive_in";
if ( is_dir( $dir ) )
{
$handle = opendir( $dir );
while ( ( $filename = readdir( $handle ) ) !== false )
{
if ( !( $filename != "." && $filename != ".." ) && !preg_match( "/^{$start}.+?\\.tar\$/", $filename ) )
{
$files[] = $filename;
}
}
closedir( $handle );
}
return $files;
}
function copy_dir( $from_path, $to_path, $mode = 511 )
{
global $INFO;
$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 777)后再试!";
return FALSE;
}
else
{
@chmod( $to_path, $mode );
}
}
$this_path = getcwd( );
if ( is_dir( $from_path ) )
{
chdir( $from_path );
$handle = opendir( "." );
while ( ( $file = readdir( $handle ) ) !== false )
{
if ( $file != "." && $file != ".." )
{
if ( is_dir( $file ) )
{
$this->copy_dir( $from_path."/".$file, $to_path."/".$file );
chdir( $from_path );
}
if ( is_file( $file ) )
{
copy( $from_path."/".$file, $to_path."/".$file );
@chmod( $to_path."/".$file, 511 );
}
}
}
closedir( $handle );
}
if ( $this->errors == "" )
{
return TRUE;
}
}
function rm_dir( $file )
{
global $INFO;
$errors = 0;
$file = preg_replace( "#/\$#", "", $file );
if ( file_exists( $file ) )
{
@chmod( $file, 511 );
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;
}
}
function rebuild_config( $new = "" )
{
global $IN;
global $std;
global $root_path;
if ( !is_array( $new ) )
{
$ADMIN->error( "错误:你正在尝试重新生成论坛配置文件,操作失败!" );
}
if ( count( $new ) < 1 )
{
return "";
}
require( ROOT_PATH."conf_global.php" );
foreach ( $new as $k => $v )
{
$v = preg_replace( "/'/", "\\'", $v );
$v = preg_replace( "/\r/", "", $v );
$INFO[$k] = $v;
}
@rename( ROOT_PATH."conf_global.php", ROOT_PATH."conf_global-bak.php" );
@chmod( ROOT_PATH."conf_global-bak.php", 511 );
$file_string = "<?php\n";
foreach ( $INFO as $k => $v )
{
if ( $k == "skin" || $k == "languages" )
{
$v = stripslashes( $v );
$v = addslashes( $v );
}
$file_string .= "\$INFO['".$k."'"."]"."\t\t\t=\t'".$v."';\n";
}
$file_string .= "\n?>";
if ( $fh = fopen( ROOT_PATH."conf_global.php", "w" ) )
{
fputs( $fh, $file_string, strlen( $file_string ) );
fclose( $fh );
}
else
{
$ADMIN->error( "错误警告:无法打开和写入文件 'conf_global.php' - 请检查文件属性是否正确(CHMOD 777)。" );
}
return $INFO;
}
function compile_forum_perms( )
{
global $DB;
global $IN;
$r_array = array( "READ" => "", "REPLY" => "", "START" => "", "UPLOAD" => "" );
if ( $IN['READ_ALL'] == 1 )
{
$r_array['READ'] = "*";
}
if ( $IN['REPLY_ALL'] == 1 )
{
$r_array['REPLY'] = "*";
}
if ( $IN['START_ALL'] == 1 )
{
$r_array['START'] = "*";
}
if ( $IN['UPLOAD_ALL'] == 1 )
{
$r_array['UPLOAD'] = "*";
}
$DB->query( "SELECT g_id, g_title FROM ibf_groups ORDER BY g_id" );
while ( $data = $DB->fetch_row( ) )
{
if ( $r_array['READ'] != "*" && $IN["READ_".$data['g_id']] == 1 )
{
$r_array['READ'] .= $data['g_id'].",";
}
if ( $r_array['REPLY'] != "*" && $IN["REPLY_".$data['g_id']] == 1 )
{
$r_array['REPLY'] .= $data['g_id'].",";
}
if ( $r_array['START'] != "*" && $IN["START_".$data['g_id']] == 1 )
{
$r_array['START'] .= $data['g_id'].",";
}
if ( !( $r_array['UPLOAD'] != "*" ) && !( $IN["UPLOAD_".$data['g_id']] == 1 ) )
{
$r_array['UPLOAD'] .= $data['g_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'] );
return $r_array;
}
function print_popup( )
{
global $IN;
global $INFO;
global $DB;
global $std;
global $SKIN;
global $use_gzip;
$html = "<html>\n\t\t <head>\n\t\t\t\t <meta http-equiv=\"Content-Language\" content=\"zh-cn\">\n\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n\t\t\t\t <meta name=\"author\" content=\"Powered By HuaCooL Network\">\n\t\t\t\t <meta name=\"copyright\" content=\"Copyright 2002-2003 www.ibfchina.com, HuaCooL Network\"> \n\t\t\t\t <title>华酷论坛 (Powered by HuaCooL Network)</title>\n\t\t <meta HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n\t\t\t\t <meta HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache\">\n\t\t\t\t <meta HTTP-EQUIV=\"Expires\" CONTENT=\"Mon, 06 May 1996 04:57:00 GMT\">";
$html .= $SKIN->get_css( );
$html .= "</head>\n";
$html .= "</head>\n\t\t\t\t <body marginheight='0' marginwidth='0' leftmargin='0' topmargin='0' bgcolor='#E7E7E7'>\n\t\t\t\t <table cellspacing='0' cellpadding='2' width='100%' align='center' border='0' bgcolor='#E7E7E7'>\n\t\t\t\t <tr>\n\t\t\t\t\t<td>\n\t\t\t\t\t <table cellspacing='3' cellpadding='2' width='100%' align='center' height='100%' border='0' bgcolor='#FFFFFF' style='border:thin solid black'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t <td valign='top' bgcolor='#FFFFFF'>\n\t\t\t\t\t\t <table cellspacing='0' cellpadding='2' border='0' align='center' width='100%' height='100%' bgcolor='#FFFFFF'>";
$html .= $this->html;
$html .= "</table></td></tr></table></td></tr></table></body></html>";
print $html;
exit( );
}
function output( )
{
global $IN;
global $INFO;
global $DB;
global $std;
global $SKIN;
global $use_gzip;
$html = $SKIN->print_top( $this->page_title, $this->page_detail );
$html .= $this->html;
$html .= $SKIN->print_foot( );
$DB->close_db( );
if ( 0 < count( $this->nav ) )
{
$navigation = array(
"<a href='{$this->base_url}&act=index' target='body'>论坛管理中心首页</a>"
);
foreach ( $this->nav as $idx => $links )
{
if ( $links[0] != "" )
{
$navigation[] = "<a href='{$this->base_url}&{$links[0]}' target='body'>{$links[1]}</a>";
}
else
{
$navigation[] = $links[1];
}
}
if ( 0 < count( $navigation ) )
{
$html = str_replace( "<!--NAV-->", $SKIN->wrap_nav( implode( " -> ", $navigation ) ), $html );
}
}
if ( $use_gzip == 1 )
{
$buffer = ob_get_contents( );
ob_end_clean( );
ob_start( "ob_gzhandler" );
print $buffer;
}
print $html;
exit( );
}
function error( $error = "", $is_popup = 0 )
{
global $IN;
global $INFO;
global $DB;
global $std;
global $SKIN;
global $HTTP_REFERER;
$this->page_title = "发生错误...";
$this->page_detail = "发生了下面的错误信息。";
$this->html .= "<tr><td><span style='font-size:14px'>{$error}</span><br><br><center><a href='{$HTTP_REFERER}'>返回</a></center></td></tr>";
if ( $is_popup == 0 )
{
$this->output( );
}
else
{
$this->print_popup( );
}
}
function done_screen( $title, $link_text = "", $link_url = "" )
{
global $IN;
global $INFO;
global $DB;
global $std;
global $SKIN;
$this->page_title = $title;
$this->page_detail = "你的操作已经执行成功!";
$SKIN->td_header[] = array( " ", "100%" );
$this->html .= $SKIN->start_table( "管理导航" );
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&{$link_url}' target='body'>进入:{$link_text}</a>", "center" );
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&act=index' target='body'>进入:论坛管理中心首页</a>", "center" );
$this->html .= $SKIN->end_table( );
$this->output( );
}
function info_screen( $text = "", $title = "安全模式限制警告" )
{
global $IN;
global $INFO;
global $DB;
global $std;
global $SKIN;
$this->page_title = $title;
$this->page_detail = "请注意下面的信息:";
$SKIN->td_header[] = array( " ", "100%" );
$this->html .= $SKIN->start_table( "管理导航" );
$this->html .= $SKIN->add_td_basic( $text );
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&act=index' target='body'>进入:论坛管理中心首页</a>", "center" );
$this->html .= $SKIN->end_table( );
$this->output( );
}
function menu( )
{
global $IN;
global $std;
global $PAGES;
global $CATS;
global $SKIN;
$links = $this->build_tree( );
$html = $SKIN->menu_top( ).$links.$SKIN->menu_foot( );
print $html;
exit( );
}
function build_tree( )
{
global $IN;
global $std;
global $PAGES;
global $CATS;
global $SKIN;
global $DESC;
$html = "";
$links = "";
foreach ( $CATS as $cid => $name )
{
if ( preg_match( "/(?:^|,){$cid}(?:,|\$)/", $IN['show'] ) )
{
foreach ( $PAGES[$cid] as $pid => $pdata )
{
$links .= $SKIN->menu_cat_link( $pdata[1], $pdata[0] );
}
$html .= $SKIN->menu_cat_expanded( $name, $links, $cid );
unset( $links );
}
else
{
$html .= $SKIN->menu_cat_collapsed( $name, $cid, $DESC[$cid] );
}
}
return $html;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -