function cpmsg($message, $url_forward = '', $msgtype = 'message', $extra = '', $cancelurl = '') { extract($GLOBALS, EXTR_SKIP); eval("\$message = \"".(isset($msglang[$message]) ? $msglang[$message] : $message)."\";"); if($msgtype == 'form') { $message = "<form method=\"post\" action=\"$url_forward\"><input type=\"hidden\" name=\"formhash\" value=\"".FORMHASH."\">". "<br /><br /><br />$message$extra<br /><br /><br /><br />\n". "<input class=\"button\" type=\"submit\" name=\"confirmed\" value=\"$lang[ok]\"> \n". "<input class=\"button\" type=\"button\" value=\"$lang[cancel]\" onClick=\"". ($cancelurl == '' ? 'history.go(-1)' : 'location.href=\''.$cancelurl.'\''). ";\"></form><br />"; } else { if($url_forward) { $message .= "<br /><br /><br /><a href=\"$url_forward\">$lang[message_redirect]</a>"; $url_forward = transsid($url_forward); $message .= "<script>setTimeout(\"redirect('$url_forward');\", 2000);</script>"; } elseif(strpos($message, $lang['return'])) { $message .= "<br /><br /><br /><a href=\"javascript:history.go(-1);\" class=\"mediumtxt\">$lang[message_return]</a>"; } $message = "<br /><br /><br />$message$extra<br /><br />"; } ?> <br /><br /><br /><br /><br /><br /> <table width="500" border="0" cellpadding="0" cellspacing="0" align="center" class="tableborder"> <tr class="header"><td><?=$lang['discuz_message']?></td></tr><tr><td class="altbg2"><div align="center"> <?=$message?></div><br /><br /> </td></tr></table> <br /><br /><br /> <? cpfooter(); dexit(); }
function dsu_paulissue_msg($msg, $treferer = '') { global $_G; $vars = explode(':', $msg); $msg = lang('plugin/' . $vars[0], $vars[1]); include template('dsu_paulissue:float'); dexit(); }
function sign_msg($msg, $treferer = '') { global $_G; if (defined('IN_MOBILE')) { include template('dsu_paulsign:float'); dexit(); } else { include template('dsu_paulsign:float'); dexit(); } }
function parse_template($file, $templateid, $tpldir) { global $language; $nest = 5; $tplfile = DISCUZ_ROOT . "./{$tpldir}/{$file}.htm"; $objfile = DISCUZ_ROOT . "./forumdata/templates/{$templateid}_{$file}.tpl.php"; if (!@($fp = fopen($tplfile, 'r'))) { dexit("Current template file './{$tpldir}/{$file}.htm' not found or have no access!"); } elseif ($language['discuz_lang'] != 'templates' && !(include language('templates', $templateid, $tpldir))) { dexit("<br />Current template pack do not have a necessary language file 'templates.lang.php' or have syntax error!"); } $template = @fread($fp, filesize($tplfile)); fclose($fp); $var_regexp = "((\\\$[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)(\\[[a-zA-Z0-9_\\-\\.\"\\'\\[\\]\$-ÿ]+\\])*)"; $const_regexp = "([a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)"; //$template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template); $template = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $template); $template = preg_replace("/\\{lang\\s+(.+?)\\}/ies", "languagevar('\\1')", $template); $template = preg_replace("/\\{faq\\s+(.+?)\\}/ies", "faqvar('\\1')", $template); $template = str_replace("{LF}", "<?=\"\\n\"?>", $template); $template = preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$\\.-ÿ]+)\\}/s", "<?=\\1?>", $template); $template = preg_replace("/{$var_regexp}/es", "addquote('<?=\\1?>')", $template); $template = preg_replace("/\\<\\?\\=\\<\\?\\={$var_regexp}\\?\\>\\?\\>/es", "addquote('<?=\\1?>')", $template); $template = "<? if(!defined('IN_DISCUZ')) exit('Access Denied'); ?>\n{$template}"; $template = preg_replace("/[\n\r\t]*\\{template\\s+([a-z0-9_]+)\\}[\n\r\t]*/is", "\n<? include template('\\1'); ?>\n", $template); $template = preg_replace("/[\n\r\t]*\\{template\\s+(.+?)\\}[\n\r\t]*/is", "\n<? include template(\\1); ?>\n", $template); $template = preg_replace("/[\n\r\t]*\\{eval\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? \\1 ?>','')", $template); $template = preg_replace("/[\n\r\t]*\\{echo\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? echo \\1; ?>','')", $template); $template = preg_replace("/([\n\r\t]*)\\{elseif\\s+(.+?)\\}([\n\r\t]*)/ies", "stripvtags('\\1<? } elseif(\\2) { ?>\\3','')", $template); $template = preg_replace("/([\n\r\t]*)\\{else\\}([\n\r\t]*)/is", "\\1<? } else { ?>\\2", $template); for ($i = 0; $i < $nest; $i++) { $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\}[\n\r]*(.+?)[\n\r]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<? } } ?>')", $template); $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}[\n\r\t]*(.+?)[\n\r\t]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<? } } ?>')", $template); $template = preg_replace("/([\n\r\t]*)\\{if\\s+(.+?)\\}([\n\r]*)(.+?)([\n\r]*)\\{\\/if\\}([\n\r\t]*)/ies", "stripvtags('\\1<? if(\\2) { ?>\\3','\\4\\5<? } ?>\\6')", $template); } $template = preg_replace("/\\{{$const_regexp}\\}/s", "<?=\\1?>", $template); $template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template); if (!@($fp = fopen($objfile, 'w'))) { dexit("Directory './forumdata/templates/' not found or have no access!"); } $template = preg_replace("/\"(http)?[\\w\\.\\/:]+\\?[^\"]+?&[^\"]+?\"/e", "transamp('\\0')", $template); $template = preg_replace("/\\<script[^\\>]*?src=\"(.+?)\".*?\\>\\s*\\<\\/script\\>/ise", "stripscriptamp('\\1')", $template); $template = preg_replace("/[\n\r\t]*\\{block\\s+([a-zA-Z0-9_]+)\\}(.+?)\\{\\/block\\}/ies", "stripblock('\\1', '\\2')", $template); flock($fp, 2); fwrite($fp, $template); fclose($fp); }
public function step3Action() { function dexit($msg) { echo '<script>alert("' . $msg . '");window.history.back();</script>'; exit; } extract($this->post('data')); if (!preg_match('/^[a-z0-9]+$/i', $admin_pass) || strlen($admin_pass) < 5) { dexit('请填写正确的后台帐号' . $admin_pass); } if (strlen($admin_pass) < 5) { dexit('后台密码最少5位'); } @($link = mysql_connect($host, $username, $password)) or dexit('无法连接到数据库,请检查数据库配置信息'); $dbname or dexit('连接正常\\n\\n不过您没有填写数据库名'); if (!mysql_select_db($dbname)) { if (!mysql_query("CREATE DATABASE " . $dbname)) { dexit('无权限创建数据库\\n\\n请通过其他方式建立数据库'); } } mysql_query('SET NAMES utf8'); mysql_query("SET sql_mode=''"); $arr = explode(':', $host); $host = $arr['0']; $port = isset($arr['1']) ? $arr['1'] : '3306'; $dbconfig = array('host' => $host, 'username' => $username, 'password' => $password, 'dbname' => $dbname, 'prefix' => $prefix, 'port' => $port, 'charset' => 'utf8'); $dbconfig_arr = var_export($dbconfig, true); $dbconfig_txt = "<?php" . PHP_EOL . "if (!defined('IN_XIAOCMS')) exit();" . PHP_EOL . "return " . $dbconfig_arr . ";"; if (!file_put_contents(DATA_DIR . 'config' . DIRECTORY_SEPARATOR . 'database.ini.php', $dbconfig_txt)) { dexit('数据库配置文件保存失败,请检查文件权限!'); } $sql = file_get_contents(DATA_DIR . 'install/xiaocms.sql'); $sql = str_replace(array('xiao_', 'admin_name', 'admin_pass'), array($prefix, $admin_name, md5(md5($admin_pass))), $sql); $this->install_sql_execute($sql); if ($import) { $sql = file_get_contents(DATA_DIR . 'install/xiaocms_data.sql'); $sql = str_replace('xiao_', $prefix, $sql); $this->install_sql_execute($sql); } $adminurl = $this->get_http_host() . $this->get_base_url(); include $this->install_tpl('3'); }
function loginmsg($message, $url_forward = '', $msgtype = 'message') { extract($GLOBALS, EXTR_SKIP); $action = dhtmlspecialchars($action); $message = isset($msglang[$message]) ? $msglang[$message] : $message; if ($msgtype == 'message') { $message = '<tr><td> </td><td align="center" colspan="3" >' . $message; if ($url_forward) { $message .= "<br /><br /><a href=\"{$url_forward}\">{$lang['message_redirect']}</a>"; $url_forward = transsid($url_forward); $message .= "<script>setTimeout(\"redirect('{$url_forward}');\", 1250);</script><br /><br /><br /></td><td> </td></tr>"; } else { $message .= '<br /><br /><br />'; } } else { $extra = isset($action) && empty($frames) && $action != 'logout' ? '?frames=yes&' . $_SERVER['QUERY_STRING'] : (in_array($action, array('header', 'menu', 'logout')) ? '' : '?' . $_SERVER['QUERY_STRING']); $message = '<form method="post" name="login" action="admincp.php' . $extra . '">' . '<input type="hidden" name="sid" value="' . $sid . '">' . '<input type="hidden" name="frames" value="yes>' . '<input type="hidden" name="url_forward" value="' . $url_forward . '">' . '<tr><td> </td><td align="right">' . $lang['username'] . ':</td>' . '<td>' . $discuz_user . '</td><td><a href="' . $link_logout . '&referer=' . $indexname . '" target="_blank">' . $lang['menu_logout'] . '</a></td>' . '<td> </td></tr>' . '<tr><td> </td><td align="right">' . $lang['password'] . ':</td><td><input type="password" name="admin_password" size="25"></td>' . '<td> </td><td> </td></tr>' . '<tr><td> </td><td class="line1"> </td>' . '<td class="line1" align="center"><input type="submit" class="button" value="' . $lang['submit'] . '" /></form><script language="JavaScript">document.login.admin_password.focus();</script></td>' . '<td class="line1"> </td><td> </td></tr>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Discuz! Administrator's Control Panel</title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?> "> <link href="./images/admincp/login.css" rel="stylesheet" type="text/css" /> </head> <script language="JavaScript"> if(self.parent.frames.length != 0) { self.parent.location=document.location; } function redirect(url) { window.location.replace(url); } </script> <br /><br /><br /><br /> <table width="600" border="0" cellpadding="8" cellspacing="0" class="logintable"> <tr class="loginheader"><td width="80"></td><td width="100"></td><td></td><td width="120"></td><td width="80"></td></tr> <tr style="height:40px"><td> </td> <td class="line1"><span style="color:#ffff66;font-size:14px;font-weight: bold;"><?php echo $lang['admin_page']; ?> </span></td> <td class="line1"> </td> <td class="line1"> </td> <td> </td></tr> <tr><td> </td><td class="line2"> </td><td class="line2"> </td><td class="line2"> </td><td> </td></tr> <?php echo $message; ?> <tr><td> </td><td class="line2"> </td><td class="line2"> </td><td class="line2"> </td><td> </td></tr> <tr><td colspan="5" align="center">Powered by <a href="http://www.discuz.net" target="_blank" style="color: #fff"><b>Discuz!</b></a> © 2001-2007 <a href="http://www.comsenz.com" target="_blank" style="color: #fff">Comsenz Inc.</a></td></tr> <tr><td> </td><td> </td><td> </td><td> </td><td> </td></tr></table> </html> <?php dexit(); }
function showmessage($message, $url_forward = '', $values = array(), $extraparam = array(), $custom = 0) { global $_G; $param = array('header' => false, 'timeout' => null, 'refreshtime' => null, 'closetime' => null, 'locationtime' => null, 'alert' => null, 'return' => false, 'redirectmsg' => 0, 'msgtype' => 1, 'showmsg' => true, 'showdialog' => false, 'login' => false, 'handle' => false); if ($custom) { $alerttype = 'alert_info'; $show_message = $message; include template('common/showmessage'); dexit(); } define('CACHE_FORBIDDEN', TRUE); $_G['setting']['msgforward'] = @unserialize($_G['setting']['msgforward']); $handlekey = ''; if (empty($_G['inajax']) && (!empty($_G['gp_quickforward']) || $_G['setting']['msgforward']['quick'] && $_G['setting']['msgforward']['messages'] && @in_array($message, $_G['setting']['msgforward']['messages']))) { $param['header'] = true; } if (!empty($_G['inajax'])) { $handlekey = $_G['gp_handlekey'] = !empty($_G['gp_handlekey']) ? htmlspecialchars($_G['gp_handlekey']) : ''; $param['handle'] = true; } if (!empty($_G['inajax'])) { $param['msgtype'] = empty($_G['gp_ajaxmenu']) && (empty($_POST) || !empty($_G['gp_nopost'])) ? 2 : 3; } if ($url_forward) { $param['timeout'] = true; if ($param['handle'] && !empty($_G['inajax'])) { $param['showmsg'] = false; } } foreach ($extraparam as $k => $v) { $param[$k] = $v; } if (array_key_exists('set', $extraparam)) { $setdata = array('1' => array('msgtype' => 3)); if ($setdata[$extraparam['set']]) { foreach ($setdata[$extraparam['set']] as $k => $v) { $param[$k] = $v; } } } if ($param['timeout'] !== null) { $refreshtime = intval($param['refreshtime'] === null ? $_G['setting']['msgforward']['refreshtime'] : $param['refreshtime']); $refreshsecond = !empty($refreshtime) ? $refreshtime : 3; $refreshtime = $refreshsecond * 1000; } else { $refreshtime = $refreshsecond = 0; } if ($param['login'] && $_G['uid'] || $url_forward) { $param['login'] = false; } $param['header'] = $url_forward && $param['header'] ? true : false; if ($param['header']) { header("HTTP/1.1 301 Moved Permanently"); dheader("location: " . str_replace('&', '&', $url_forward)); } $_G['hookscriptmessage'] = $message; $_G['hookscriptvalues'] = $values; $vars = explode(':', $message); if (count($vars) == 2) { $show_message = lang('plugin/' . $vars[0], $vars[1], $values); } else { $show_message = lang('message', $message, $values); } $show_jsmessage = str_replace("'", "\\\\'", $show_message); if (!$param['showmsg']) { $show_message = ''; } if ($param['msgtype'] == 3) { $show_message = str_replace(lang('message', 'return_search'), lang('message', 'return_replace'), $show_message); } $allowreturn = !$param['timeout'] && stristr($show_message, lang('message', 'return')) || $param['return'] ? true : false; if ($param['alert'] === null) { $alerttype = $url_forward ? preg_match('/\\_(succeed|success)$/', $message) ? 'alert_right' : 'alert_info' : ($allowreturn ? 'alert_error' : 'alert_info'); } else { $alerttype = 'alert_' . $param['alert']; } $extra = ''; if ($param['handle']) { $valuesjs = $comma = $subjs = ''; foreach ($values as $k => $v) { if (is_array($v)) { $subcomma = ''; foreach ($v as $subk => $subv) { $subjs .= $subcomma . '\'' . $subk . '\':\'' . $subv . '\''; $subcomma = ','; } $valuesjs .= $comma . '\'' . $k . '\':{' . $subjs . '}'; } else { $valuesjs .= $comma . '\'' . $k . '\':\'' . $v . '\''; } $comma = ','; } $valuesjs = '{' . $valuesjs . '}'; if ($url_forward) { $extra .= 'if($(\'return_' . $handlekey . '\')) $(\'return_' . $handlekey . '\').className=\'onright\';if(typeof succeedhandle_' . $handlekey . '==\'function\') {succeedhandle_' . $handlekey . '(\'' . $url_forward . '\', \'' . $show_jsmessage . '\', ' . $valuesjs . ');}'; } else { $extra .= 'if(typeof errorhandle_' . $handlekey . '==\'function\') {errorhandle_' . $handlekey . '(\'' . $show_jsmessage . '\', ' . $valuesjs . ');}'; } } if ($handlekey) { if ($param['showdialog']) { $st = $param['closetime'] !== null ? 'setTimeout("hideMenu(\'fwin_dialog\', \'dialog\')", ' . $param['closetime'] * 1000 . ');' : ''; $st .= $param['locationtime'] !== null ? 'setTimeout("window.location.href =\'' . $url_forward . '\';", ' . $param['locationtime'] * 1000 . ');' : ''; $extra .= 'hideWindow(\'' . $handlekey . '\');showDialog(\'' . $show_jsmessage . '\', \'notice\', null, ' . ($param['locationtime'] !== null ? 'function () { window.location.href =\'' . $url_forward . '\'; }' : 'null') . ', 0);' . $st . ''; $param['closetime'] = null; } if ($param['closetime'] !== null) { $extra .= 'setTimeout("hideWindow(\'' . $handlekey . '\')", ' . $param['closetime'] * 1000 . ');'; } } if (!$extra && $param['timeout']) { $extra .= 'setTimeout("window.location.href =\'' . $url_forward . '\';", ' . $refreshtime . ');'; } $show_message .= $extra ? '<script type="text/javascript" reload="1">' . $extra . '</script>' : ''; include template('common/showmessage'); dexit(); }
function insenz_cpmsg($message, $extra = '') { extract($GLOBALS, EXTR_SKIP); eval("\$message = \"" . (isset($msglang[$message]) ? $msglang[$message] : $message) . "\";"); $url_forward = 'admincp.php?action=insenz' . $extra; $message .= "<br /><br /><br /><a href=\"{$url_forward}\">{$lang['message_redirect']}</a>"; $url_forward = transsid($url_forward); echo '<script type="text/javascript">parent.setTimeout("redirect(\'' . $url_forward . '\');", 2000);parent.$("insenz_body").innerHTML = \'<br /><br /><br /><br /><br /><br /><table width="500" border="0" cellpadding="0" cellspacing="0" align="center" class="tableborder"><tr class="header"><td>' . $lang['discuz_message'] . '</td></tr><tr><td class="altbg2"><br /><br /><div align="center">' . $message . '</div><br /><br /></td></tr></table><br /><br /><br />\';</script>'; dexit(); }
public function indexAction() { $step = $this->post('step') ? $this->post('step') : 1; switch ($step) { case '1': //说明 $this->view->assign('percent', '0%'); $this->view->display('../install/' . $step); break; case '2': //环境 $pass = true; $PHP_VERSION = PHP_VERSION; if (version_compare($PHP_VERSION, '5.2.0', '<')) { $php_pass = $pass = false; } else { $php_pass = true; } $mysqli = $PHP_MYSQL = ''; if (extension_loaded('mysql')) { $PHP_MYSQL = '支持'; $mysql_pass = true; } elseif (function_exists('mysqli_init')) { $PHP_MYSQL = 'mysqli'; $mysqli = mysqli_init(); $mysql_pass = true; } else { $PHP_MYSQL = '不支持'; $mysql_pass = $pass = false; } $PHP_GD = ''; if (function_exists('imagejpeg')) { $PHP_GD .= 'jpg'; } if (function_exists('imagegif')) { $PHP_GD .= ' gif'; } if (function_exists('imagepng')) { $PHP_GD .= ' png'; } $gd_pass = $PHP_GD ? true : false; $is_json = false; $json = '["ok","t2","t3"]'; if (function_exists('json_decode')) { $json_data = json_decode($json); if ($json_data) { $is_json = true; } else { $pass = false; } } else { $json_data = null; $pass = false; } $this->view->assign(array('php_pass' => $php_pass, 'PHP_MYSQL' => $PHP_MYSQL, 'mysql_pass' => $mysql_pass, 'PHP_GD' => $PHP_GD, 'gd_pass' => $gd_pass, 'pass' => $pass, 'percent' => '20%', 'urlopen' => fn_check_url(), 'is_json' => $is_json, 'json_data' => $json_data)); $this->view->display('../install/' . $step); break; case '3': //属性 $ISWIN = strpos(strtoupper(PHP_OS), 'WIN') === false ? false : true; $files = array('cache/', 'config/', 'models/', 'uploadfiles/'); $FILES = array(); $pass = true; foreach ($files as $k => $v) { $FILES[$k]['name'] = $v; if (is_writable(APP_ROOT . $v)) { $FILES[$k]['write'] = true; } else { $FILES[$k]['write'] = $pass = false; } } $this->view->assign(array('ISWIN' => $ISWIN, 'files' => $files, 'FILES' => $FILES, 'pass' => $pass, 'percent' => '40%')); $this->view->display('../install/' . $step); break; case '4': //数据库 $this->view->assign('percent', '60%'); $this->view->display('../install/' . $step); break; case '5': //安装进度 $tdb_host = $this->post('db_host'); $tdb_user = $this->post('db_user'); $tdb_pass = $this->post('db_pass'); $tdb_name = $this->post('db_name'); $ttb_pre = $this->post('tb_pre'); $import = $this->post('import'); $username = $this->post('username'); $password = $this->post('password'); $email = $this->post('email'); function dexit($msg) { echo '<script>alert("' . $msg . '");window.history.back();</script>'; exit; } if (!preg_match('/^[a-z0-9]+$/i', $username) || strlen($username) < 4) { dexit('请填写正确的超级管理员户名'); } if (strlen($password) < 4) { dexit('超级管理员密码最少4位'); } if ($this->mysqli) { if (!@mysqli_real_connect($this->mysqli, $tdb_host, $tdb_user, $tdb_pass)) { dexit('无法连接到数据库服务器,请检查配置'); } $tdb_name or dexit('请填写数据库名'); if (!@mysqli_select_db($this->mysqli, $tdb_name)) { if (!@mysqli_query('CREATE DATABASE ' . $tdb_name)) { dexit('指定的数据库不存在\\n\\n系统尝试创建失败,请通过其他方式建立数据库'); } @mysqli_select_db($this->mysqli, $tdb_name); } @mysqli_query($this->mysqli, 'SET NAMES utf8'); } else { if (!@mysql_connect($tdb_host, $tdb_user, $tdb_pass)) { dexit('无法连接到数据库服务器,请检查配置'); } $tdb_name or dexit('请填写数据库名'); if (!@mysql_select_db($tdb_name)) { if (!@mysql_query('CREATE DATABASE $tdb_name')) { dexit('指定的数据库不存在\\n\\n系统尝试创建失败,请通过其他方式建立数据库'); } } @mysql_query('SET NAMES utf8'); } //保存配置文件 $content = "<?php" . PHP_EOL . "if (!defined('IN_FINECMS')) exit();" . PHP_EOL . PHP_EOL . "/**" . PHP_EOL . " * 数据库配置信息" . PHP_EOL . " */" . PHP_EOL . "return array(" . PHP_EOL . PHP_EOL; $content .= "\t'host' => '" . $tdb_host . "', " . PHP_EOL; $content .= "\t'username' => '" . $tdb_user . "', " . PHP_EOL; $content .= "\t'password' => '" . $tdb_pass . "', " . PHP_EOL; $content .= "\t'dbname' => '" . $tdb_name . "', " . PHP_EOL; $content .= "\t'prefix' => '" . $ttb_pre . "', " . PHP_EOL; $content .= "\t'charset' => 'utf8', " . PHP_EOL; $content .= "\t'port' => '', " . PHP_EOL; $content .= PHP_EOL . ");"; if (!file_put_contents(CONFIG_DIR . 'database.ini.php', $content)) { dexit('数据库配置文件保存失败,请检查文件权限!'); } //保存站点域名配置文件 $site = "<?php" . PHP_EOL . "if (!defined('IN_FINECMS')) exit();" . PHP_EOL . PHP_EOL . "/**" . PHP_EOL . " * 数据库配置信息" . PHP_EOL . " */" . PHP_EOL . "return array(" . PHP_EOL . PHP_EOL; $site .= "\t'1' => '" . strtolower($_SERVER['HTTP_HOST']) . "', " . PHP_EOL; $site .= PHP_EOL . ");"; if (!file_put_contents(CONFIG_DIR . 'site.ini.php', $site)) { dexit('站点配置文件保存失败,请检查文件权限!'); } //导入表结构 $salt = substr(md5(time()), 0, 10); $sql = file_get_contents(APP_ROOT . './cache/install/table.sql'); $sql = str_replace(array('{username}', '{password}', '{salt}', '{pre}'), array($username, md5(md5($password) . $salt . md5($password)), $salt, $ttb_pre), $sql); $this->installsql($sql); //导入演示数据 if ($import) { $sql = file_get_contents(APP_ROOT . './cache/install/data.sql'); $sql = str_replace('{pre}', $ttb_pre, $sql); $this->installsql($sql); } $this->view->assign(array('percent' => '80%', 'username' => $username, 'password' => $password, 'msgs' => array('保存系统配置..................', '数据库连接....................', '创建数据库....................', '创建数据表....................', '设置管理员....................', '安装系统模型..................', '更新模型缓存..................', '更新插件缓存..................', '更新会员模型..................'))); $this->view->display('../install/' . $step); break; case '6': //安装成功 $cache = new cache_file(); $cache->set('install', 1); file_put_contents(APP_ROOT . './cache/install.lock', time()); $this->view->assign(array('percent' => '100%', 'username' => $this->post('username'), 'password' => $this->post('password'))); $this->view->display('../install/' . $step); break; case 'db_test': $tdb_host = $this->post('tdb_host'); $tdb_user = $this->post('tdb_user'); $tdb_pass = $this->post('tdb_pass'); $tdb_name = $this->post('tdb_name'); $ttb_pre = $this->post('ttb_pre'); $ttb_test = $this->post('ttb_test'); if ($this->mysqli) { if (!@mysqli_real_connect($this->mysqli, $tdb_host, $tdb_user, $tdb_pass)) { exit("<script>alert('无法连接到数据库服务器,请检查配置');</script>"); } if (!@mysqli_select_db($this->mysqli, $tdb_name)) { if (!@mysqli_query('CREATE DATABASE ' . $tdb_name)) { exit("<script>alert('指定的数据库(" . $tdb_name . ")不存在,系统尝试创建失败,请通过其他方式建立数据库');</script>"); } @mysqli_select_db($this->mysqli, $tdb_name); } @mysqli_query($this->mysqli, 'SET NAMES utf8'); } else { if (!mysql_connect($tdb_host, $tdb_user, $tdb_pass)) { exit("<script>alert('无法连接到数据库服务器,请检查配置');</script>"); } if (!mysql_select_db($tdb_name)) { if (!mysql_query("CREATE DATABASE " . $tdb_name)) { exit("<script>alert('指定的数据库(" . $tdb_name . ")不存在,系统尝试创建失败,请通过其他方式建立数据库');</script>"); } mysql_select_db($tdb_name); } } $tables = array(); $query = mysql_list_tables($tdb_name); while ($r = mysql_fetch_row($query)) { $tables[] = $r[0]; } if (is_array($tables) && in_array($ttb_pre . 'user', $tables)) { if ($ttb_test) { exit('<script>alert("数据库设置正确,连接正常\\n\\n注意:系统检测到您已经安装过' . CMS_NAME . ',如果继续安装将会清空现有数据\\n\\n如果需要保留现有数据,请修改数据表前缀");</script>'); } else { exit('<script>alert("警告:系统检测到您已经安装过' . CMS_NAME . ',如果继续安装将会清空现有数据\\n\\n如果需要保留现有数据,请修改数据表前缀");</script>'); } } if ($ttb_test) { exit('<script>alert("数据库设置正确,连接正常");</script>'); } break; } }
function parse_template($tplfile, $templateid, $tpldir) { global $language, $subtemplates, $timestamp; $nest = 6; $basefile = $file = basename($tplfile, '.htm'); $file == 'header' && CURSCRIPT && ($file = 'header_' . CURSCRIPT); $objfile = ROOT_PATH . './data/' . COMPILEDIR . '/' . STYLEID . '_' . $templateid . '_' . $file . '.tpl.php'; if (!@($fp = fopen($tplfile, 'r'))) { dexit("Current template file './{$tpldir}/{$file}.htm' not found or have no access!"); } $template = @fread($fp, filesize($tplfile)); fclose($fp); $var_regexp = "((\\\$[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)(\\[[a-zA-Z0-9_\\-\\.\"\\'\\[\\]\$-ÿ]+\\])*)"; $const_regexp = "([a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)"; $headerexists = preg_match("/{(sub)?template\\s+header\\}/", $template) || $basefile == 'header_ajax'; $subtemplates = array(); for ($i = 1; $i <= 3; $i++) { if (strexists($template, '{subtemplate')) { $template = preg_replace("/[\n\r\t]*\\{subtemplate\\s+([a-z0-9_:]+)\\}[\n\r\t]*/ies", "stripvtemplate('\\1', 1)", $template); } } $template = preg_replace("/[\n\r\t]*\\{csstemplate\\}[\n\r\t]*/ies", "loadcsstemplate('\\1')", $template); $template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template); $template = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $template); $template = preg_replace("/\\{lang\\s+(.+?)\\}/ies", "languagevar('\\1')", $template); $template = preg_replace("/\\{faq\\s+(.+?)\\}/ies", "faqvar('\\1')", $template); $template = str_replace("{LF}", "<?=\"\\n\"?>", $template); $template = preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$\\.-ÿ]+)\\}/s", "<?=\\1?>", $template); $template = preg_replace("/{$var_regexp}/es", "addquote('<?=\\1?>')", $template); $template = preg_replace("/\\<\\?\\=\\<\\?\\={$var_regexp}\\?\\>\\?\\>/es", "addquote('<?=\\1?>')", $template); $headeradd = ''; if (!empty($subtemplates)) { $headeradd .= "\n0\n"; foreach ($subtemplates as $fname) { $headeradd .= "|| checktplrefresh('{$tplfile}', '{$fname}', {$timestamp}, '{$templateid}', '{$tpldir}')\n"; } $headeradd .= ';'; } $template = "<? if(!defined('IN_PHPUP')) exit('Access Denied'); {$headeradd}?>\n{$template}"; $template = preg_replace("/[\n\r\t]*\\{template\\s+([a-z0-9_:]+)\\}[\n\r\t]*/ies", "stripvtemplate('\\1', 0)", $template); $template = preg_replace("/[\n\r\t]*\\{template\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtemplate('\\1', 0)", $template); $template = preg_replace("/[\n\r\t]*\\{eval\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? \\1 ?>','')", $template); $template = preg_replace("/[\n\r\t]*\\{echo\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('<? echo \\1; ?>','')", $template); $template = preg_replace("/([\n\r\t]*)\\{elseif\\s+(.+?)\\}([\n\r\t]*)/ies", "stripvtags('\\1<? } elseif(\\2) { ?>\\3','')", $template); $template = preg_replace("/([\n\r\t]*)\\{else\\}([\n\r\t]*)/is", "\\1<? } else { ?>\\2", $template); for ($i = 0; $i < $nest; $i++) { $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\}[\n\r]*(.+?)[\n\r]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<? } } ?>')", $template); $template = preg_replace("/[\n\r\t]*\\{loop\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}[\n\r\t]*(.+?)[\n\r\t]*\\{\\/loop\\}[\n\r\t]*/ies", "stripvtags('<? if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<? } } ?>')", $template); $template = preg_replace("/([\n\r\t]*)\\{if\\s+(.+?)\\}([\n\r]*)(.+?)([\n\r]*)\\{\\/if\\}([\n\r\t]*)/ies", "stripvtags('\\1<? if(\\2) { ?>\\3','\\4\\5<? } ?>\\6')", $template); } $template = preg_replace("/\\{{$const_regexp}\\}/s", "<?=\\1?>", $template); $template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template); if (!@($fp = fopen($objfile, 'w'))) { dexit("Directory './data/compile/' not found or have no access!"); } $template = preg_replace("/\"(http)?[\\w\\.\\/:]+\\?[^\"]+?&[^\"]+?\"/e", "transamp('\\0')", $template); $template = preg_replace("/\\<script[^\\>]*?src=\"(.+?)\"(.*?)\\>\\s*\\<\\/script\\>/ise", "stripscriptamp('\\1', '\\2')", $template); $template = preg_replace("/[\n\r\t]*\\{block\\s+([a-zA-Z0-9_]+)\\}(.+?)\\{\\/block\\}/ies", "stripblock('\\1', '\\2')", $template); $template = str_replace('<div id="phpup_version"></div>', '<div id="phpup_version"><A HREF="http://www.kaka101.com/">Www.KaKa101.Com</A> Powered by ' . VERSION . '© 2010-2011 One plus One E-commerce Co.,Ltd.</div>', $template); flock($fp, 2); fwrite($fp, $template); fclose($fp); }
function dshowmessage($message, $url_forward = '', $values = array(), $extraparam = array(), $custom = 0) { global $_G, $show_message; $_G['messageparam'] = func_get_args(); if (empty($_G['inhookscript']) && defined('CURMODULE')) { hookscript(CURMODULE, $_G['basescript'], 'messagefuncs', array('param' => $_G['messageparam'])); } if ($extraparam['break']) { return; } $_G['inshowmessage'] = true; $param = array('header' => false, 'timeout' => null, 'refreshtime' => null, 'closetime' => null, 'locationtime' => null, 'alert' => null, 'return' => false, 'redirectmsg' => 0, 'msgtype' => 1, 'showmsg' => true, 'showdialog' => false, 'login' => false, 'handle' => false, 'extrajs' => '', 'striptags' => true); $navtitle = lang('core', 'title_board_message'); if ($custom) { $alerttype = 'alert_info'; $show_message = $message; include template('common/showmessage'); dexit(); } define('CACHE_FORBIDDEN', TRUE); $_G['setting']['msgforward'] = @dunserialize($_G['setting']['msgforward']); $handlekey = $leftmsg = ''; if (defined('IN_MOBILE')) { unset($extraparam['showdialog']); unset($extraparam['closetime']); unset($extraparam['extrajs']); if (!$url_forward && dreferer() && IN_MOBILE == 1) { $url_forward = $referer = dreferer(); } if (!empty($url_forward) && strpos($url_forward, 'mobile') === false) { $url_forward_arr = explode("#", $url_forward); if (strpos($url_forward_arr[0], '?') !== false) { $url_forward_arr[0] = $url_forward_arr[0] . '&mobile=' . IN_MOBILE; } else { $url_forward_arr[0] = $url_forward_arr[0] . '?mobile=' . IN_MOBILE; } $url_forward = implode("#", $url_forward_arr); } } if (empty($_G['inajax']) && (!empty($_GET['quickforward']) || $_G['setting']['msgforward']['quick'] && empty($extraparam['clean_msgforward']) && $_G['setting']['msgforward']['messages'] && @in_array($message, $_G['setting']['msgforward']['messages']))) { $param['header'] = true; } $_GET['handlekey'] = !empty($_GET['handlekey']) && preg_match('/^\\w+$/', $_GET['handlekey']) ? $_GET['handlekey'] : ''; if (!empty($_G['inajax'])) { $handlekey = $_GET['handlekey'] = !empty($_GET['handlekey']) ? dhtmlspecialchars($_GET['handlekey']) : ''; $param['handle'] = true; } if (!empty($_G['inajax'])) { $param['msgtype'] = empty($_GET['ajaxmenu']) && (empty($_POST) || !empty($_GET['nopost'])) ? 2 : 3; } if ($url_forward) { $param['timeout'] = true; if ($param['handle'] && !empty($_G['inajax'])) { $param['showmsg'] = false; } } foreach ($extraparam as $k => $v) { $param[$k] = $v; } if (array_key_exists('set', $extraparam)) { $setdata = array('1' => array('msgtype' => 3)); if ($setdata[$extraparam['set']]) { foreach ($setdata[$extraparam['set']] as $k => $v) { $param[$k] = $v; } } } $timedefault = intval($param['refreshtime'] === null ? $_G['setting']['msgforward']['refreshtime'] : $param['refreshtime']); if ($param['timeout'] !== null) { $refreshsecond = !empty($timedefault) ? $timedefault : 3; $refreshtime = $refreshsecond * 1000; } else { $refreshtime = $refreshsecond = 0; } if ($param['login'] && $_G['uid'] || $url_forward) { $param['login'] = false; } $param['header'] = $url_forward && $param['header'] ? true : false; if ($_GET['ajaxdata'] === 'json') { $param['header'] = ''; } if ($param['header']) { header("HTTP/1.1 301 Moved Permanently"); dheader("location: " . str_replace('&', '&', $url_forward)); } $url_forward_js = addslashes(str_replace('\\', '%27', $url_forward)); if ($param['location'] && !empty($_G['inajax'])) { include template('common/header_ajax'); echo '<script type="text/javascript" reload="1">window.location.href=\'' . $url_forward_js . '\';</script>'; include template('common/footer_ajax'); dexit(); } $_G['hookscriptmessage'] = $message; $_G['hookscriptvalues'] = $values; $vars = explode(':', $message); if (count($vars) == 2) { $show_message = lang('plugin/' . $vars[0], $vars[1], $values); } else { $show_message = lang('message', $message, $values); } if (isset($_GET['ajaxdata'])) { if ($_GET['ajaxdata'] === 'json') { helper_output::json(array('message' => $show_message, 'data' => $values)); } else { if ($_GET['ajaxdata'] === 'html') { helper_output::html($show_message); } } } if ($_G['connectguest']) { $param['login'] = false; $param['alert'] = 'info'; if (defined('IN_MOBILE')) { if ($message == 'postperm_login_nopermission_mobile') { $show_message = lang('plugin/qqconnect', 'connect_register_mobile_bind_error'); } $show_message = str_replace(lang('forum/misc', 'connectguest_message_mobile_search'), lang('forum/misc', 'connectguest_message_mobile_replace'), $show_message); } else { $show_message = str_replace(lang('forum/misc', 'connectguest_message_search'), lang('forum/misc', 'connectguest_message_replace'), $show_message); } if ($message == 'group_nopermission') { $show_message = lang('plugin/qqconnect', 'connectguest_message_complete_or_bind'); } } if ($param['msgtype'] == 2 && $param['login']) { dheader('location: member.php?mod=logging&action=login&handlekey=' . $handlekey . '&infloat=yes&inajax=yes&guestmessage=yes'); } $show_jsmessage = str_replace("'", "\\'", $param['striptags'] ? strip_tags($show_message) : $show_message); if ((!$param['showmsg'] || $param['showid']) && !defined('IN_MOBILE')) { $show_message = ''; } $allowreturn = !$param['timeout'] && !$url_forward && !$param['login'] || $param['return'] ? true : false; if ($param['alert'] === null) { $alerttype = $url_forward ? preg_match('/\\_(succeed|success)$/', $message) ? 'alert_right' : 'alert_info' : ($allowreturn ? 'alert_error' : 'alert_info'); } else { $alerttype = 'alert_' . $param['alert']; } $extra = ''; if ($param['showid']) { $extra .= 'if($(\'' . $param['showid'] . '\')) {$(\'' . $param['showid'] . '\').innerHTML = \'' . $show_jsmessage . '\';}'; } if ($param['handle']) { $valuesjs = $comma = $subjs = ''; foreach ($values as $k => $v) { $v = daddslashes($v); if (is_array($v)) { $subcomma = ''; foreach ($v as $subk => $subv) { $subjs .= $subcomma . '\'' . $subk . '\':\'' . $subv . '\''; $subcomma = ','; } $valuesjs .= $comma . '\'' . $k . '\':{' . $subjs . '}'; } else { $valuesjs .= $comma . '\'' . $k . '\':\'' . $v . '\''; } $comma = ','; } $valuesjs = '{' . $valuesjs . '}'; if ($url_forward) { $extra .= 'if(typeof succeedhandle_' . $handlekey . '==\'function\') {succeedhandle_' . $handlekey . '(\'' . $url_forward_js . '\', \'' . $show_jsmessage . '\', ' . $valuesjs . ');}'; } else { $extra .= 'if(typeof errorhandle_' . $handlekey . '==\'function\') {errorhandle_' . $handlekey . '(\'' . $show_jsmessage . '\', ' . $valuesjs . ');}'; } } if ($param['closetime'] !== null) { $param['closetime'] = $param['closetime'] === true ? $timedefault : $param['closetime']; } if ($param['locationtime'] !== null) { $param['locationtime'] = $param['locationtime'] === true ? $timedefault : $param['locationtime']; } if ($handlekey) { if ($param['showdialog']) { $modes = array('alert_error' => 'alert', 'alert_right' => 'right', 'alert_info' => 'notice'); $extra .= 'hideWindow(\'' . $handlekey . '\');showDialog(\'' . $show_jsmessage . '\', \'' . $modes[$alerttype] . '\', null, ' . ($param['locationtime'] !== null ? 'function () { window.location.href =\'' . $url_forward_js . '\'; }' : 'null') . ', 0, null, null, null, null, ' . ($param['closetime'] ? $param['closetime'] : 'null') . ', ' . ($param['locationtime'] ? $param['locationtime'] : 'null') . ');'; $param['closetime'] = null; $st = ''; if ($param['showmsg']) { $show_message = ''; } } if ($param['closetime'] !== null) { $extra .= 'setTimeout("hideWindow(\'' . $handlekey . '\')", ' . $param['closetime'] * 1000 . ');'; } } else { $st = $param['locationtime'] !== null ? 'setTimeout("window.location.href =\'' . $url_forward_js . '\';", ' . $param['locationtime'] * 1000 . ');' : ''; } if (!$extra && $param['timeout'] && !defined('IN_MOBILE')) { $extra .= 'setTimeout("window.location.href =\'' . $url_forward_js . '\';", ' . $refreshtime . ');'; } $show_message .= $extra ? '<script type="text/javascript" reload="1">' . $extra . $st . '</script>' : ''; $show_message .= $param['extrajs'] ? $param['extrajs'] : ''; include template('common/showmessage'); dexit(); }
function showmessage($message, $url_forward = '', $extra = '', $forwardtype = 0) { extract($GLOBALS, EXTR_SKIP); global $extrahead, $discuz_uid, $discuz_action, $debuginfo, $seccode, $seccodestatus, $fid, $tid, $charset, $show_message, $inajax, $_DCACHE, $advlist; define('CACHE_FORBIDDEN', TRUE); $show_message = $message; $messagehandle = 0; $msgforward = unserialize($_DCACHE['settings']['msgforward']); $refreshtime = intval($msgforward['refreshtime']); $refreshtime = empty($forwardtype) ? $refreshtime : ($refreshtime ? $refreshtime : 3); $msgforward['refreshtime'] = $refreshtime * 1000; $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid($url_forward) : $url_forward); $seccodecheck = $seccodestatus & 2; if ($url_forward && (!empty($quickforward) || empty($inajax) && $msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages']))) { updatesession(); dheader("location: " . str_replace('&', '&', $url_forward)); } if (!empty($infloat)) { if ($extra) { $messagehandle = $extra; } $extra = ''; } if (in_array($extra, array('HALTED', 'NOPERM'))) { $fid = $tid = 0; $discuz_action = 254; } else { $discuz_action = 255; } include language('messages'); if (isset($language[$message])) { $pre = $inajax ? 'ajax_' : ''; eval("\$show_message = \"" . (isset($language[$pre . $message]) ? $language[$pre . $message] : $language[$message]) . "\";"); unset($pre); } if (empty($infloat)) { $show_message .= $url_forward && empty($inajax) ? '<script>setTimeout("window.location.href =\'' . $url_forward . '\';", ' . $msgforward['refreshtime'] . ');</script>' : ''; } elseif ($handlekey) { $show_message = str_replace("'", "\\'", $show_message); if ($url_forward) { $show_message = "<script type=\"text/javascript\" reload=\"1\">\nif(\$('return_{$handlekey}')) \$('return_{$handlekey}').className = 'onright';\nif(typeof submithandle_{$handlekey} =='function') {submithandle_{$handlekey}('{$url_forward}', '{$show_message}');} else {location.href='{$url_forward}'}\n</script>"; } else { $show_message .= "<script type=\"text/javascript\" reload=\"1\">\nif(typeof messagehandle_{$handlekey} =='function') {messagehandle_{$handlekey}('{$messagehandle}', '{$show_message}');}\n</script>"; } } if ($advlist = array_merge($globaladvs ? $globaladvs['type'] : array(), $redirectadvs ? $redirectadvs['type'] : array())) { $advitems = ($globaladvs ? $globaladvs['items'] : array()) + ($redirectadvs ? $redirectadvs['items'] : array()); foreach ($advlist as $type => $redirectadvs) { $advlist[$type] = $advitems[$redirectadvs[array_rand($redirectadvs)]]; } } if ($extra == 'NOPERM') { include template('nopermission'); } else { include template('showmessage'); } dexit(); }
function showmessage($message, $url_forward = '', $extra = '') { extract($GLOBALS, EXTR_SKIP); global $extrahead, $discuz_action, $debuginfo, $seccode, $fid, $tid, $supe_fromsupesite, $supe_jumpurl, $supe, $charset, $show_message, $inajax, $_DCACHE, $advlist; define('CACHE_FORBIDDEN', TRUE); $supe_messagetpl = $supe_error = ''; $show_message = $message; $msgforward = unserialize($_DCACHE['settings']['msgforward']); $msgforward['refreshtime'] = intval($msgforward['refreshtime']); $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid($url_forward) : $url_forward); if ($supe_fromsupesite && $supe['status']) { $supe_messagetpl = 'supesite_'; $extra = ''; $supe_error = $url_forward ? false : true; $url_forward = !empty($supe_jumpurl) && !$supe_error ? urldecode($supe_jumpurl) : $url_forward; } elseif ($url_forward && empty($inajax) && $msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages'])) { updatesession(); dheader("location: " . str_replace('&', '&', $url_forward)); } if (in_array($extra, array('HALTED', 'NOPERM'))) { $fid = $tid = 0; $discuz_action = 254; } else { $discuz_action = 255; } include language('messages'); if (isset($language[$message])) { $pre = $supe_fromsupesite ? 'supe_' : ($inajax ? 'ajax_' : ''); eval("\$show_message = \"" . (isset($language[$pre . $message]) ? $language[$pre . $message] : $language[$message]) . "\";"); unset($pre); } $extrahead .= $url_forward ? '<meta http-equiv="refresh" content="' . $msgforward['refreshtime'] . ' url=' . $url_forward . '">' : ''; if ($advlist = array_merge($globaladvs ? $globaladvs['type'] : array(), $redirectadvs ? $redirectadvs['type'] : array())) { $advitems = ($globaladvs ? $globaladvs['items'] : array()) + ($redirectadvs ? $redirectadvs['items'] : array()); foreach ($advlist as $type => $redirectadvs) { $advlist[$type] = $advitems[$redirectadvs[array_rand($redirectadvs)]]; } } if ($extra == 'NOPERM' && !$passport_status) { //get secure code checking status (pos. -2) if ($seccodecheck = substr(sprintf('%05b', $seccodestatus), -2, 1)) { $seccode = random(6, 1) + $seccode[0] * 1000000; } include template('nopermission'); } else { include template($supe_messagetpl . 'showmessage'); } dexit(); }
$from_cookie_num = count($from_cookie_array); $from_cookie_start = $from_cookie_num - 10; $from_cookie_start = $from_cookie_start > 0 ? $from_cookie_start : 0; $from_cookie_array = array_slice($from_cookie_array, $from_cookie_start, $from_cookie_num); $from_cookie = implode("\t", $from_cookie_array); dsetcookie('from_cookie', $from_cookie); } dsetcookie('clearUserdata', 'home'); $op = 'add_success'; $article_add_url = 'portal.php?mod=portalcp&ac=article&catid='.$catid; $article = C::t('portal_article_title')->fetch($aid); $viewarticleurl = $_POST['url'] ? "portal.php?mod=list&catid=$_POST[catid]" : fetch_article_url($article); include_once template("portal/portalcp_article");dexit(); } elseif(submitcheck('pushplussubmit')) { if($aid) { check_articleperm($article['catid'], $aid, $article); } else { showmessage('no_article_specified_for_pushplus', dreferer()); } $tourl = !empty($_POST['toedit']) ? 'portal.php?mod=portalcp&ac=article&op=edit&aid='.$aid : dreferer(); $pids = (array)$_POST['pushpluspids']; $posts = array(); $tid = intval($_GET['tid']); if($tid && $pids) { foreach(C::t('forum_post')->fetch_all('tid:'.$tid, $pids) as $value) {
function insenz_cpmsg($message, $url, $type = '') { extract($GLOBALS, EXTR_SKIP); include language('admincp.msg'); eval("\$message = \"" . (isset($msglang[$message]) ? $msglang[$message] : $message) . "\";"); switch ($type) { case 'succeed': $classname = 'infotitle2'; break; case 'error': $classname = 'infotitle3'; break; case 'loading': $classname = 'infotitle1'; break; default: $classname = 'marginbot normal'; break; } $message = '<h4 class="' . $classname . '">' . $message . '</h4><p class="marginbot"><a href="' . $url . '" class="lightlink">' . lang('message_redirect') . '</a></p>'; $url = transsid($url); echo '<script type="text/JavaScript">parent.setTimeout("redirect(\'' . $url . '\');", 2000);parent.$("cpcontainer").innerHTML = \'<h3>' . $lang['discuz_message'] . '</h3><div class="infobox">' . $message . '</div>\';</script>'; dexit(); }
if (!preg_match("/^[a-z0-9]+\$/i", $username) || strlen($username) < 4) { dexit('请填写正确的超级管理员户名'); } if (strlen($password) < 6) { dexit('超级管理员密码最少6位'); } if (strlen($email) < 6 || !preg_match("/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+\$/", $email)) { dexit('请填写正确的超级管理员Email'); } if (!mysql_connect($db_host, $db_user, $db_pass)) { dexit('无法连接到数据库服务器,请检查配置'); } $db_name or dexit('请填写数据库名'); if (!mysql_select_db($db_name)) { if (!mysql_query("CREATE DATABASE {$db_name}")) { dexit('指定的数据库不存在\\n\\n系统尝试创建失败,请通过其他方式建立数据库'); } } $config = array(); $config['db_host'] = $CFG['db_host'] = $db_host; $config['db_user'] = $CFG['db_user'] = $db_user; $config['db_pass'] = $CFG['db_pass'] = $db_pass; $config['db_name'] = $CFG['db_name'] = $db_name; $config['tb_pre'] = $CFG['tb_pre'] = $DT_PRE = $tb_pre; $config['url'] = $CFG['url'] = $url; $config['cache_pre'] = $CFG['cache_pre'] = 'c' . strtolower(random(2)) . '_'; $config['cookie_pre'] = $CFG['cookie_pre'] = 'c' . strtolower(random(2)) . '_'; $config['authkey'] = $CFG['authkey'] = random(15); //保存配置文件 $tmp = file_get_contents(DT_ROOT . '/config.inc.php'); foreach ($config as $k => $v) {
function cpmsg($message, $url = '', $type = '', $extra = '', $halt = TRUE) { extract($GLOBALS, EXTR_SKIP); include language('admincp.msg'); eval("\$message = \"" . (isset($msglang[$message]) ? $msglang[$message] : $message) . "\";"); switch ($type) { case 'succeed': $classname = 'infotitle2'; break; case 'error': $classname = 'infotitle3'; break; case 'loading': $classname = 'infotitle1'; break; default: $classname = 'marginbot normal'; break; } $message = "<h4 class=\"{$classname}\">{$message}</h4>"; if ($type == 'form') { $message = "<form method=\"post\" action=\"{$url}\"><input type=\"hidden\" name=\"formhash\" value=\"" . FORMHASH . "\">" . "<br />{$message}{$extra}<br />" . "<p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"confirmed\" value=\"{$lang['ok']}\"> \n" . "<input type=\"button\" class=\"btn\" value=\"{$lang['cancel']}\" onClick=\"history.go(-1);\"></p></form><br />"; } elseif ($type == 'loadingform') { $message = "<form method=\"post\" action=\"{$url}\" id=\"loadingform\"><input type=\"hidden\" name=\"formhash\" value=\"" . FORMHASH . "\"><br />{$message}{$extra}<img src=\"images/admincp/ajax_loader.gif\" class=\"marginbot\" /><br />" . '<p class="marginbot"><a href="###" onclick="$(\'loadingform\').submit();" class="lightlink">' . lang('message_redirect') . '</a></p></form><br /><script type="text/JavaScript">setTimeout("$(\'loadingform\').submit();", 2000);</script>'; } else { $message .= $extra . ($type == 'loading' ? '<img src="images/admincp/ajax_loader.gif" class="marginbot" />' : ''); if ($url) { if ($type == 'button') { $message = "<br />{$message}<br /><p class=\"margintop\"><input type=\"submit\" class=\"btn\" name=\"submit\" value=\"{$lang['start']}\" onclick=\"location.href='{$url}'\" />"; } else { $message .= '<p class="marginbot"><a href="' . $url . '" class="lightlink">' . lang('message_redirect') . '</a></p>'; $url = transsid($url); $message .= "<script type=\"text/JavaScript\">setTimeout(\"redirect('{$url}');\", 2000);</script>"; } } elseif (strpos($message, $lang['return'])) { $message .= '<p class="marginbot"><a href="javascript:history.go(-1);" class="lightlink">' . lang('message_return') . '</a></p>'; } } if ($halt) { echo '<h3>' . lang('discuz_message') . '</h3><div class="infobox">' . $message . '</div>'; cpfooter(); dexit(); } else { echo '<div class="infobox">' . $message . '</div>'; } }
function showmessage($message, $url_forward = '', $extra = '', $forwardtype = 0) { extract($GLOBALS, EXTR_SKIP); global $hookscriptmessage, $extrahead, $discuz_uid, $discuz_action, $debuginfo, $seccode, $seccodestatus, $fid, $tid, $charset, $show_message, $inajax, $_DCACHE, $advlist; define('CACHE_FORBIDDEN', TRUE); $hookscriptmessage = $show_message = $message; $messagehandle = 0; $msgforward = unserialize($_DCACHE['settings']['msgforward']); $refreshtime = intval($msgforward['refreshtime']); $refreshtime = empty($forwardtype) ? $refreshtime : ($refreshtime ? $refreshtime : 3); $msgforward['refreshtime'] = $refreshtime * 1000; $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid($url_forward) : $url_forward); $seccodecheck = $seccodestatus & 2; if ($_DCACHE['settings']['funcsiteid'] && $_DCACHE['settings']['funckey'] && $funcstatinfo && !IS_ROBOT) { $statlogfile = DISCUZ_ROOT . './forumdata/funcstat.log'; if ($fp = @fopen($statlogfile, 'a')) { @flock($fp, 2); if (is_array($funcstatinfo)) { $funcstatinfo = array_unique($funcstatinfo); foreach ($funcstatinfo as $funcinfo) { fwrite($fp, funcstat_query($funcinfo, $message) . "\n"); } } else { fwrite($fp, funcstat_query($funcstatinfo, $message) . "\n"); } fclose($fp); $funcstatinfo = $GLOBALS['funcstatinfo'] = ''; } } if (!defined('STAT_DISABLED') && STAT_ID > 0 && !IS_ROBOT) { write_statlog($message); } if ($url_forward && (!empty($quickforward) || empty($inajax) && $msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages']))) { updatesession(); dheader("location: " . str_replace('&', '&', $url_forward)); } if (!empty($infloat)) { if ($extra) { $messagehandle = $extra; } $extra = ''; } if (in_array($extra, array('HALTED', 'NOPERM'))) { $discuz_action = 254; } else { $discuz_action = 255; } include language('messages'); $vars = explode(':', $message); if (count($vars) == 2 && isset($scriptlang[$vars[0]][$vars[1]])) { eval("\$show_message = \"" . str_replace('"', '\\"', $scriptlang[$vars[0]][$vars[1]]) . "\";"); } elseif (isset($language[$message])) { $pre = $inajax ? 'ajax_' : ''; eval("\$show_message = \"" . (isset($language[$pre . $message]) ? $language[$pre . $message] : $language[$message]) . "\";"); unset($pre); } if (empty($infloat)) { $show_message .= $url_forward && empty($inajax) ? '<script>setTimeout("window.location.href =\'' . $url_forward . '\';", ' . $msgforward['refreshtime'] . ');</script>' : ''; } elseif ($handlekey) { $show_message = str_replace("'", "\\'", $show_message); if ($url_forward) { $show_message = "<script type=\"text/javascript\" reload=\"1\">\nif(\$('return_{$handlekey}')) \$('return_{$handlekey}').className = 'onright';\nif(typeof submithandle_{$handlekey} =='function') {submithandle_{$handlekey}('{$url_forward}', '{$show_message}');} else {location.href='{$url_forward}'}\n</script>"; } else { $show_message .= "<script type=\"text/javascript\" reload=\"1\">\nif(typeof messagehandle_{$handlekey} =='function') {messagehandle_{$handlekey}('{$messagehandle}', '{$show_message}');}\n</script>"; } } if ($advlist = array_merge($globaladvs ? $globaladvs['type'] : array(), $redirectadvs ? $redirectadvs['type'] : array())) { $advitems = ($globaladvs ? $globaladvs['items'] : array()) + ($redirectadvs ? $redirectadvs['items'] : array()); foreach ($advlist as $type => $redirectadvs) { $advlist[$type] = $advitems[$redirectadvs[array_rand($redirectadvs)]]; } } if ($extra == 'NOPERM') { include template('nopermission'); } else { include template('showmessage'); } dexit(); }
function errorlog($type, $message, $halt = 1) { global $timestamp, $cyask_user; @($fp = fopen(CYASK_ROOT . './askdata/errorlog.php', 'a')); @fwrite($fp, "{$timestamp}\t{$type}\t{$cyask_user}\t" . str_replace(array("\r", "\n"), array(' ', ' '), trim(dhtmlspecialchars($message))) . "\n"); @fclose($fp); if ($halt) { dexit(); } }
function showmessage($message, $url_forward = '', $values = array(), $ext = array()) { showmessage($message, $url_forward, $values, $ext); dexit(); }
<?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: admincp_index.php 23425 2011-07-14 06:38:11Z liulanbo $ * English by Valery Votintsev at sources.ru */ if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) { exit('Access Denied'); } if (@file_exists(DISCUZ_ROOT . './install/index.php') && !DISCUZ_DEBUG) { @unlink(DISCUZ_ROOT . './install/index.php'); if (@file_exists(DISCUZ_ROOT . './install/index.php')) { dexit('Please delete install/index.php via FTP!'); } } @(include_once DISCUZ_ROOT . './source/discuz_version.php'); require_once libfile('function/attachment'); $isfounder = isfounder(); $siteuniqueid = DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='siteuniqueid'"); if (empty($siteuniqueid) || strlen($siteuniqueid) < 16) { $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; $siteuniqueid = 'DX' . $chars[date('y') % 60] . $chars[date('n')] . $chars[date('j')] . $chars[date('G')] . $chars[date('i')] . $chars[date('s')] . substr(md5($_G['clientip'] . $_G['username'] . TIMESTAMP), 0, 4) . random(4); $temp = array('skey' => 'siteuniqueid', 'svalue' => $siteuniqueid); DB::insert('common_setting', $temp, false, true); } if (submitcheck('notesubmit', 1)) { if (!empty($_G['gp_noteid']) && is_numeric($_G['gp_noteid'])) { DB::query("DELETE FROM " . DB::table('common_adminnote') . " WHERE id='{$_G['gp_noteid']}'" . ($isfounder ? '' : " AND admin='{$_G['username']}'"));
<?php if (!defined('IN_ET')) { exit('Access Denied'); } $timestamp = time(); $errmsg = ''; $dberror = $this->error(); $dberrno = $this->errno(); if ($dberrno == 1114) { function_exists('dexit') ? dexit() : exit; } else { if ($message) { $errmsg = "<b>EasyTalk info</b>: {$message}\n\n"; } if (isset($GLOBALS['_DSESSION']['discuz_user'])) { $errmsg .= "<b>User</b>: " . htmlspecialchars($GLOBALS['_DSESSION']['discuz_user']) . "\n"; } $errmsg .= "<b>Time</b>: " . gmdate("Y-n-j g:ia", $timestamp + $GLOBALS['timeoffset'] * 3600) . "\n"; $errmsg .= "<b>Script</b>: " . $GLOBALS['PHP_SELF'] . "\n\n"; if ($sql) { $errmsg .= "<b>SQL</b>: " . htmlspecialchars($sql) . "\n"; } $errmsg .= "<b>Error</b>: {$dberror}\n"; $errmsg .= "<b>Errno.</b>: {$dberrno}"; echo "<p style=\"font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;\">"; echo nl2br(str_replace($GLOBALS['tablepre'], '[Table]', $errmsg)); echo '</p>'; function_exists('dexit') ? dexit() : exit; }
} $query = $db->query("SELECT * FROM {$tablepre}usergroups WHERE type!='system' ORDER BY type, creditshigher"); while ($group = $db->fetch_array($query)) { $grouplist[$group['type']][] = $group; } include template('memcp_usergroups'); } else { if ($type == 'main' && $switchmaingroup) { $edit = intval($edit); $group = $db->fetch_first("SELECT groupid, type, system, grouptitle, allowmultigroups FROM {$tablepre}usergroups WHERE groupid='{$edit}' AND (" . ($extgroupids ? 'groupid IN (' . str_replace("\t", ',', $extgroupids) . ') OR ' : '') . "(type='special' AND system='0\t0' AND radminid='0') OR (type='member' AND '{$credits}'>=creditshigher AND '{$credits}'<creditslower))"); if (!$group) { showmessage('undefined_action', NULL, 'HALTED'); } if (!submitcheck('groupsubmit')) { include template('memcp_usergroups_misc'); dexit(); } $extgroupidsnew = $groupid; foreach (explode("\t", $extgroupids) as $extgroupid) { if ($extgroupid && $extgroupid != $edit) { $extgroupidsnew .= "\t" . $extgroupid; } } $adminidnew = in_array($adminid, array(1, 2, 3)) ? $adminid : ($group['type'] == 'special' ? -1 : 0); $db->query("UPDATE {$tablepre}members SET groupid='{$edit}', adminid='{$adminidnew}', extgroupids='{$extgroupidsnew}' WHERE uid='{$discuz_uid}'"); showmessage('usergroups_update_succeed', 'memcp.php?action=usergroups'); } elseif ($type == 'extended') { $group = $db->fetch_first("SELECT groupid, type, system, grouptitle FROM {$tablepre}usergroups WHERE groupid='{$edit}' AND (" . ($extgroupids ? 'groupid IN (' . str_replace("\t", ',', $extgroupids) . ') OR ' : '') . "(type='special' AND system<>'private' AND radminid='0'))"); if (!$group) { showmessage('undefined_action', NULL, 'HALTED'); }
function lovecache() { global $db, $tablepre, $lovecache, $smileyoff, $maxsmilies, $page, $lovepage, $dateformat, $timeformat, $timeoffset; $tpp = $lovepage ? $lovepage : 800; $start_limit = ($page - 1) * $tpp; $query = $db->query("select * FROM `" . $tablepre . "lovewall` ORDER BY `id` asc \r\n\t\tlimit {$start_limit},{$tpp}"); while ($rowlove = $db->fetch_array($query)) { $temptime = $rowlove['lovetime']; $rowlove['lovetime'] = gmdate("{$dateformat} {$timeformat}", $temptime + 3600 * $timeoffset); $rowlove['lovesay'] = dhtmlspecialchars($rowlove['lovesay']); $rowlove['lovesay'] = str_replace(array("'", '"'), array("\\'", "\""), $rowlove['lovesay']); $rowlove['lovesay'] = nl2br(str_replace(array("\t", ' ', ' ', "\r\n"), array(' ', ' ', ' ', '<br>'), $rowlove['lovesay'])); $rowlove['colorid'] = $rowlove['colorid'] ? $rowlove['colorid'] : mt_rand(0, 5); $rowlove['moodid'] = $rowlove['moodid'] ? $rowlove['moodid'] : mt_rand(0, 15); if ($rowlove['mysign'] == "匿名" or $rowlove['mysign'] == "") { $rowlove['mysign'] = str_replace(array("'", '"'), array("\\'", "\""), dhtmlspecialchars($rowlove['uname'])); } else { $rowlove['mysign'] = str_replace(array("'", '"'), array("\\'", "\""), dhtmlspecialchars($rowlove['mysign'])); } $rowlove['nickname'] = str_replace(array("'", '"'), array("\\'", "\""), dhtmlspecialchars($rowlove['nickname'])); if (!$smileyoff && !empty($GLOBALS['_DCACHE']['smilies']) && is_array($GLOBALS['_DCACHE']['smilies'])) { $rowlove['lovesay'] = preg_replace($GLOBALS['_DCACHE']['smilies']['searcharray'], $GLOBALS['_DCACHE']['smilies']['replacearray'], $rowlove['lovesay'], $maxsmilies); } $rowlove['lovesay'] = str_replace('\\"', '"', $rowlove['lovesay']); unset($rowlove['uid']); unset($rowlove['uname']); $lovewall[$rowlove[id]] = $rowlove; } if ($lovecache == 1) { $filepath = DISCUZ_ROOT . "./extend/lovewall/cache/cache_lovewall_{$page}.php"; $love_data = $lovewall ? "\$love_cache = " . arrayeval($lovewall) . ";\n\n" : ""; if (@($fp = fopen($filepath, 'w'))) { fwrite($fp, "<?php\n//Discuz! cache file, DO NOT modify me!\n" . "//Created on " . date("M j, Y, G:i") . "\n\n{$love_data}?>"); fclose($fp); } else { dexit('Can not write to cache files, please check directory ./extend/lovewall/cache/ .'); } } return $lovewall; }