function getlog()
{
    global $timestamp, $onlineip, $action, $sax_user;
    if ($action) {
        writefile(SABLOG_ROOT . 'data/log/adminlog.php', "<?PHP exit('Access Denied'); ?>\t{$timestamp}\t{$sax_user}\t{$onlineip}\t" . htmlspecialchars(trim($action)) . "\twap\n", 'a');
    }
}
Exemple #2
0
 function add($key, $val, $exp = 0)
 {
     $this->_file = $this->get_file($key, 'add');
     $value = array("Time" => time(), "Expires" => $exp, "Data" => $val);
     $data = serialize($value);
     $this->_cache_sock = '<?php exit;?>';
     if ($this->_have_zlib && $this->_compress_enable) {
         $this->_cache_sock .= gzcompress($data, 9);
     } else {
         $this->_cache_sock .= $data;
     }
     return writefile($this->_file, $this->_cache_sock);
 }
 public function export_db_go()
 {
     require COMMON_PATH . "tp_common.php";
     //引入自定义的类
     import("Think.Db.Db");
     //D('');也可以
     $db = DB::getInstance();
     $tables = $db->getTables();
     foreach ($tables as $tbname) {
         $coumt = $db->getFields($tbname);
         $modelname = str_replace(C('DB_PREFIX'), '', $tbname);
         //msg($modelname);
         $row = D($modelname);
         $row = $row->findAll();
         if ($_GET[dbform]) {
             //同时备份表结构
             msg('正在备份表结构......<br>', 0);
             $sql = "DROP TABLE `{$tbname}`;\n";
             $field = $db->query("show create table {$tbname}");
             $sql .= $field[0]['Create Table'] . ";\n\n";
             $dbdatasql .= $sql;
             unset($sql);
             msg('表:' . $tbname . '备份表结构信息成功!<br>');
         }
         if ($_GET[dbdata]) {
             //只备份表数据
             msg('正在备份表数据......<br>', 0);
             $sql = "TRUNCATE `{$tbname}`;\n";
             //写入清空表信息
             msg('表:' . $tbname . '写入清空表信息成功!<br>');
             $values = array();
             foreach ($row as $value) {
                 $sql = "INSERT INTO `{$tbname}` VALUES (";
                 foreach ($value as $v) {
                     $sql_tmp[] = "'" . mysql_real_escape_string($v) . "'";
                 }
                 $sql .= join(',', $sql_tmp);
                 $sql .= ");\n";
                 $dbdatasql .= $sql;
                 unset($sql);
                 unset($sql_tmp);
             }
             msg('分析表:' . $tbname . '成功!<br>');
         }
     }
     $sqlbody = $dbdatasql . "\n" . $dbdatasql . "\n\n\n";
     writefile('./Backup/SQL/tpmaker_' . date('Ymd-His') . '.sql', $sqlbody);
     msg('备份表数据成功.<br>', 0);
 }
function parse_template($tplfile, $objfile)
{
    global $options;
    $nest = 5;
    if (!($template = loadfile($tplfile))) {
        exit('Current template file not found or have no access!');
    }
    /*
    elseif (!include_once lang('templates')) {
    	exit("Current template pack do not have a necessary language file 'templates.php' or have syntax error!");
    }
    */
    $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("/\\{(\\\$[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('SABLOG_ROOT')) 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('\n<? \\1; ?>\n','')", $template);
    $template = preg_replace("/[\n\r\t]*\\{elseif\\s+(.+?)\\}[\n\r\t]*/ies", "stripvtags('\n<? } elseif(\\1) { ?>\n','')", $template);
    $template = preg_replace("/[\n\r\t]*\\{else\\}[\n\r\t]*/is", "\n<? } else { ?>\n", $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('\n<? if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\n\\3\n<? } } ?>\n')", $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('\n<? if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\n\\4\n<? } } ?>\n')", $template);
        $template = preg_replace("/[\n\r\t]*\\{if\\s+(.+?)\\}[\n\r]*(.+?)[\n\r]*\\{\\/if\\}[\n\r\t]*/ies", "stripvtags('\n<? if(\\1) { ?>','\n\\2\n<? } ?>\n')", $template);
    }
    $template = preg_replace("/\\{{$const_regexp}\\}/s", "<?=\\1?>", $template);
    $template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template);
    $template = preg_replace("/\"(http)?[\\w\\.\\/:]+\\?[^\"]+?&[^\"]+?\"/e", "transamp('\\0')", $template);
    $template = str_replace('<?=', '<?php echo ', $template);
    $template = str_replace('<? ', '<?php ', $template);
    if (!writefile($objfile, $template)) {
        exit('Directory \'./data/template/\' not found or have no access!');
    }
}
Exemple #5
0
function all_doconfig_modify($whereis){
	global $dbhost2, $dbuser2, $dbpw2, $dbname2, $tablepre2,$dbcharset2;
	if($whereis == 'is_dz') {
		//  /\$dbhost.+;/i
		if(file_exists('./uc_server/data/config.inc.php')) {
			$config = file_get_contents('./uc_server/data/config.inc.php');
			writefile('./uc_server/data/config.bak.php.'.time(),$config);
			$config = uc_doconfig_modify($config);
			writefile('./uc_server/data/config.inc.php',$config);
		}
		$config = file_get_contents('./config.inc.php');
		writefile('./forumdata/config.bak.php.'.date(ymd,time()),$config);
		$config = preg_replace('/\$dbhost.+;/i','$dbhost = \''.$dbhost2.'\';',$config);
		$config = preg_replace('/\$dbuser.+;/i','$dbuser = \''.$dbuser2.'\';',$config);
		$config = preg_replace('/\$dbpw.+;/i','$dbpw = \''.$dbpw2.'\';',$config);
		$config = preg_replace('/\$dbname.+;/i','$dbname = \''.$dbname2.'\';',$config);
		$config = preg_replace('/\$tablepre.+;/i','$tablepre = \''.$tablepre2.'\';',$config);
		$config = preg_replace('/\$dbcharset.+;/i','$dbcharset = \''.$dbcharset2.'\';',$config);
		$config = uc_doconfig_modify($config);
		if(writefile('./config.inc.php',$config)) {
			show_tools_message('配置文件已经成功修改,原配置文件已经备份到forumdata目录下。','tools.php?action=all_config');
		}
	} elseif($whereis == 'is_uch' || $whereis == 'is_ss') {
		$config = file_get_contents('./config.php');
		writefile('./data/config.bak.php.'.date(ymd,time()),$config);
		$config = preg_replace('/\$_SC\[\'dbhost\'\].+;/i','$_SC[\'dbhost\'] = \''.$dbhost2.'\';',$config);
		$config = preg_replace('/\$_SC\[\'dbuser\'\].+;/i','$_SC[\'dbuser\'] = \''.$dbuser2.'\';',$config);
		$config = preg_replace('/\$_SC\[\'dbpw\'\].+;/i','$_SC[\'dbpw\'] = \''.$dbpw2.'\';',$config);
		$config = preg_replace('/\$_SC\[\'dbname\'\].+;/i','$_SC[\'dbname\'] = \''.$dbname2.'\';',$config);
		$config = preg_replace('/\$_SC\[\'tablepre\'\].+;/i','$_SC[\'tablepre\'] = \''.$tablepre2.'\';',$config);
		$config = preg_replace('/\$_SC\[\'dbcharset\'\].+;/i','$_SC[\'dbcharset\'] = \''.$dbcharset2.'\';',$config);
		$config = uc_doconfig_modify($config);
		if(writefile('./config.php',$config)) {
			show_tools_message('配置文件已经成功修改,原配置文件已经备份到data目录下。','tools.php?action=all_config');
		}
	} elseif($whereis == 'is_uc') {
		$config = file_get_contents('./data/config.inc.php');
		writefile('./data/config.bak.php.'.date(ymd,time()),$config);
		$config = uc_doconfig_modify($config);
		if(writefile('./data/config.inc.php',$config)) {
			show_tools_message('配置文件已经成功修改,原配置文件已经备份到data目录下。','tools.php?action=all_config');
		}
	}
}
Exemple #6
0
/**
 * 写配置文件
 * @param string $path
 * @param string $content
 * @param int $isappend 是否追加
 */
function writeconf($path, $content)
{
    $o_content = (include $path);
    $new_conf = $content;
    if ($o_content) {
        $new_conf = array_merge($content, $o_content);
    }
    $str = "<?php \r\n return " . var_export($new_conf, true) . "; \r\n?>";
    return writefile($path, $str);
}
Exemple #7
0
        $max_uploads = (int) $max_uploads;
        // please keep this formatted like this
        $sSQL = "Update " . $pho_main . " set\n                    name='{$name}',\n                    description='{$description}',\n                    config_suffix='{$config_suffix}',\n                    parent={$parent},\n                    display={$display},\n                    moderation='{$moderation}',\n                    email_list='{$email_list}',\n                    email_return='{$email_return}',\n                    email_tag='{$email_tag}',\n                    check_dup={$check_dup},\n                    multi_level={$multi_level},\n                    collapse={$collapsed},\n                    flat={$rflat},\n                    lang='{$language_file}',\n                    html='{$allow_html}',\n                    table_width='{$table_width}',\n                    table_header_color='{$table_header_color}',\n                    table_header_font_color='{$table_header_font_color}',\n                    table_body_color_1='{$table_body_color_1}',\n                    table_body_color_2='{$table_body_color_2}',\n                    table_body_font_color_1='{$table_body_font_color_1}',\n                    table_body_font_color_2='{$table_body_font_color_2}',\n                    nav_color='{$nav_color}',\n                    nav_font_color='{$nav_font_color}',\n                    allow_uploads='{$allow_uploads}',\n                    upload_types='{$upload_types}',\n                    upload_size='{$upload_size}',\n                    max_uploads='{$max_uploads}',\n                    security='{$security}',\n                    showip='{$showip}',\n                    emailnotification={$emailnotification},\n                    body_color='{$body_color}',\n                    body_link_color='{$body_link_color}',\n                    body_alink_color='{$body_alink_color}',\n                    body_vlink_color='{$body_vlink_color}'\n               where\n                 id={$num}";
    } else {
        $sSQL = "Update " . $pho_main . " set name='{$name}', description='{$description}', config_suffix='{$config_suffix}', lang='{$language_file}', parent={$parent}, table_width='{$table_width}', table_header_color='{$table_header_color}', table_header_font_color='{$table_header_font_color}', table_body_color_1='{$table_body_color_1}', table_body_font_color_1='{$table_body_font_color_1}', nav_color='{$nav_color}', nav_font_color='{$nav_font_color}', body_color='{$body_color}', body_link_color='{$body_link_color}', body_alink_color='{$body_alink_color}', body_vlink_color='{$body_vlink_color}' where id={$num}";
    }
    $q->query($DB, $sSQL);
    $err = $q->error();
    if ($err == "") {
        if (!$folder && $AllowAttachments && $allow_uploads == 'Y') {
            if (!file_exists("{$AttachmentDir}/{$table}") && !@mkdir("{$AttachmentDir}/{$table}", 0777)) {
                QueMessage("The directory ({$AttachmentDir}/{$table}) for attachments could not be created.");
            } else {
                chmod("{$AttachmentDir}/{$table}", 0777);
            }
            if ($err = create_table($DB, "attachments", $table . "_attachments")) {
                QueMessage("Could not create attachments table.  Database server said \"{$err}\"");
            }
        }
        $ForumName = stripslashes($name);
        writefile($num);
        include "{$PHORUM['settings_dir']}/{$num}.php";
        QueMessage("{$ForumName} has been updated.");
    } else {
        QueMessage($err);
        $page = $frompage;
    }
} else {
    QueMessage("You must provide a name for the forum.");
    $option == "edit_prop";
}
Exemple #8
0
 function makeprotpl($id)
 {
     //生成基本Action
     $app_path = $this->getapppath();
     //获取生成程序的根目录
     $tpl_path = $this->gettplpath();
     //获取程序模板的根目录
     $data = $this->gettables($id);
     $tablename = uplower($data['title']);
     //第一个字母变成大写,其它变成小写
     $caption = $data['caption'];
     $fields = $this->getfieldsbytbid($id);
     tpmk_dir($app_path . '/Tpl/default/' . $tablename . '/');
     //生成目录
     $islist = $data['list'] == 1 ? true : false;
     //是否列表
     $issearch = $data['search'] == 1 ? true : false;
     //issearch
     $isadd = $data['add'] == 1 ? true : false;
     //是否增加
     $isedit = $data['edit'] == 1 ? true : false;
     //是否允许编辑
     $isview = $data['view'] == 1 ? true : false;
     //是否允许查看详细
     $isdel = $data['del'] == 1 ? true : false;
     //是否允许删除数据
     //生成INDEX.HMTL包括LIST及SEARCH的
     if ($islist) {
         $filename = $app_path . '/Tpl/default/' . $tablename . '/index.html';
         //生成的模板文件名
         $tpl = new tpl($tpl_path . '/Html_tpl/index.html');
         //源模板文件名
         $tpl->tplsign('tablecaption', $caption);
         //替换
         $tpl->tplsign('tablelist', $tablename);
         //替换表名
         $filecontent = $tpl->tplreturn();
         writefile($filename, $filecontent);
     }
     //生成ajaxlist.HMTL
     if ($islist || $issearch) {
         $filename = $app_path . '/Tpl/default/' . $tablename . '/ajaxlist.html';
         //生成的模板文件名
         $tpl = new tpl($tpl_path . '/Html_tpl/ajaxlist.html');
         //源模板文件名
         $listshowsort = $this->makerowslistsort($fields, 'islist');
         $listshowtd = $this->makerowslisttd($fields, 'islist');
         $tpl->tplblocksign('listshowsort', $listshowsort);
         //替换
         $tpl->tplblocksign('listshowtd', $listshowtd);
         //替换
         $tpl->tplissign('issearch', $issearch);
         //替换是否搜索
         $tpl->tplissign('isadd', $isadd);
         //替换是否增加
         $tpl->tplissign('isedit', $isedit);
         //替换是否编辑
         $tpl->tplissign('isview', $isview);
         //替换查看详细
         $tpl->tplissign('isdel', $isdel);
         //替换删除数据
         $tpl->tplsign('tablecaption', $caption);
         //替换
         $tpl->tplsign('tablelist', $tablename);
         //替换表名
         $filecontent = $tpl->tplreturn();
         writefile($filename, $filecontent);
     }
     //生成Add.HMTL
     if ($isadd) {
         $filename = $app_path . '/Tpl/default/' . $tablename . '/add.html';
         //生成的模板文件名
         $tpl = new tpl($tpl_path . '/Html_tpl/add.html');
         //源模板文件名
         if (count($fields) > 0) {
             foreach ($fields as $field) {
                 $vartype = $field['addtype'];
                 $varname = $this->maketags($field['addtype'], 'addtype', $field['name'], $field['indexvar'], $field['outkey'], $field['outkeyid'], $field['outkeyf'], $field['outkeywhere']);
                 $varcaption = $field['caption'];
                 $rows_contents[] = array("rows_type" => $vartype, "rows_name" => $varname, "rows_caption" => $varcaption);
                 //替换方式
             }
         }
         $tpl->tplblocksign('rows_contents', $rows_contents);
         $tpl->tplissign('issearch', $issearch);
         //替换是否搜索
         $tpl->tplissign('isadd', $isadd);
         //替换是否增加
         $tpl->tplissign('isedit', $isedit);
         //替换是否编辑
         $tpl->tplissign('isview', $isview);
         //替换查看详细
         $tpl->tplissign('isdel', $isdel);
         //替换删除数据
         $tpl->tplsign('tablecaption', $caption);
         //替换
         $tpl->tplsign('tablename', $tablename);
         //替换表名
         $filecontent = $tpl->tplreturn();
         writefile($filename, $filecontent);
         unset($rows_contents);
     }
     //生成Edit.HMTL
     if ($isedit) {
         $filename = $app_path . '/Tpl/default/' . $tablename . '/edit.html';
         //生成的模板文件名
         $tpl = new tpl($tpl_path . '/Html_tpl/edit.html');
         //源模板文件名
         if (count($fields) > 0) {
             foreach ($fields as $field) {
                 $vartype = $field['edittype'];
                 $varname = $this->maketags($field['edittype'], 'edittype', $field['name'], $field['indexvar'], $field['outkey'], $field['outkeyid'], $field['outkeyf'], $field['outkeywhere']);
                 $varcaption = $field['caption'];
                 $rows_contents[] = array("rows_type" => $vartype, "rows_name" => $varname, "rows_caption" => $varcaption);
                 //替换方式
             }
         }
         $tpl->tplblocksign('rows_contents', $rows_contents);
         $tpl->tplissign('issearch', $issearch);
         //替换是否搜索
         $tpl->tplissign('isadd', $isadd);
         //替换是否增加
         $tpl->tplissign('isedit', $isedit);
         //替换是否编辑
         $tpl->tplissign('isview', $isview);
         //替换查看详细
         $tpl->tplissign('isdel', $isdel);
         //替换删除数据
         $tpl->tplsign('tablecaption', $caption);
         //替换
         $tpl->tplsign('tablename', $tablename);
         //替换表名
         $filecontent = $tpl->tplreturn();
         writefile($filename, $filecontent);
         unset($rows_contents);
     }
     //生成Veiw.HMTL
     if ($isview) {
         $filename = $app_path . '/Tpl/default/' . $tablename . '/view.html';
         //生成的模板文件名
         $tpl = new tpl($tpl_path . '/Html_tpl/view.html');
         //源模板文件名
         if (count($fields) > 0) {
             foreach ($fields as $field) {
                 $vartype = $field['viewtype'];
                 $varname = $this->maketags($field['viewtype'], 'viewtype', $field['name'], $field['indexvar'], $field['outkey'], $field['outkeyid'], $field['outkeyf'], $field['outkeywhere']);
                 $varcaption = $field['caption'];
                 $rows_contents[] = array("rows_type" => $vartype, "rows_name" => $varname, "rows_caption" => $varcaption);
                 //替换方式
             }
         }
         $tpl->tplblocksign('rows_contents', $rows_contents);
         $tpl->tplissign('issearch', $issearch);
         //替换是否搜索
         $tpl->tplissign('isadd', $isadd);
         //替换是否增加
         $tpl->tplissign('isedit', $isedit);
         //替换是否编辑
         $tpl->tplissign('isview', $isview);
         //替换查看详细
         $tpl->tplissign('isdel', $isdel);
         //替换删除数据
         $tpl->tplsign('tablecaption', $caption);
         //替换
         $tpl->tplsign('tablename', $tablename);
         //替换表名
         $filecontent = $tpl->tplreturn();
         writefile($filename, $filecontent);
         unset($rows_contents);
     }
     unset($data);
 }
                            // "on" -> boolean
                            // XXX we assume there is no string called "on"
                            $config .= "gp_{$key}\t{$key}\tboolean\ttrue\n";
                            $typedef .= "\tboolean gp_{$key}=false\n";
                        } else {
                            // string otherwise
                            $config .= "gp_{$key}\t{$key}\tString\t{$val}\n";
                            $typedef .= "\tString gp_{$key}=\"{$val}\"\n";
                        }
                    }
                }
            }
        }
    }
    #echo $typedef;
    writefile($config, $uid . ".appconfig");
}
writeattributefile($gamedata, $uid . ".game");
if ($clearform) {
    header("Location: fillgameform.php#form");
} else {
    if ($badinput) {
        header("Location: fillgameform.php?error=badinput#form");
    } else {
        if ($undefinput) {
            header("Location: fillgameform.php?error=undefinput#form");
        } else {
            if ($counterror) {
                header("Location: fillgameform.php?error=counterror#form");
            } else {
                header("Location: playgame.php");
 function dumpsql_action()
 {
     global $db;
     $dump = $this->dump;
     /* 设置最长执行时间为5分钟 */
     @set_time_limit(300);
     $run_log = $this->path . '/run.log';
     /* 初始化输入变量 */
     if (empty($_REQUEST['sql_file_name'])) {
         $sql_file_name = $dump->get_random_name();
     } else {
         $sql_file_name = str_replace("0xa", '', trim($_REQUEST['sql_file_name']));
         // 过滤 0xa 非法字符
         $pos = strpos($sql_file_name, '.sql');
         if ($pos !== false) {
             $sql_file_name = substr($sql_file_name, 0, $pos);
         }
     }
     $max_size = empty($_REQUEST['vol_size']) ? 0 : intval($_REQUEST['vol_size']);
     $vol = empty($_REQUEST['vol']) ? 1 : intval($_REQUEST['vol']);
     $is_short = empty($_REQUEST['ext_insert']) ? false : true;
     $dump->is_short = $is_short;
     /* 变量验证 */
     $allow_max_size = intval(@ini_get('upload_max_filesize'));
     //单位M
     if ($allow_max_size > 0 && $max_size > $allow_max_size * 1024) {
         $max_size = $allow_max_size * 1024;
         //单位K
     }
     if ($max_size > 0) {
         $dump->max_size = $max_size * 1024;
     }
     /* 获取要备份数据列表 */
     $type = empty($_POST['type']) ? '' : trim($_POST['type']);
     $tables = array();
     switch ($type) {
         case 'full':
             $query = $db->query("SHOW TABLES LIKE '" . $GLOBALS['table_prefix'] . "%'");
             while ($t = $db->fetch_array($query)) {
                 $table = array_values($t);
                 $tables[$table[0]] = -1;
             }
             $dump->put_tables_list($run_log, $tables);
             break;
         case 'stand':
             $temp = array('site', 'user', 'groups ', 'score');
             foreach ($temp as $table) {
                 $tables[$GLOBALS['table_prefix'] . $table] = -1;
             }
             $dump->put_tables_list($run_log, $tables);
             break;
         case 'min':
             $temp = array('site');
             foreach ($temp as $table) {
                 $tables[$GLOBALS['table_prefix'] . $table] = -1;
             }
             $dump->put_tables_list($run_log, $tables);
             break;
         case 'custom':
             foreach ($_POST['customtables'] as $table) {
                 $tables[$table] = -1;
             }
             $dump->put_tables_list($run_log, $tables);
             break;
     }
     /* 开始备份 */
     $tables = $dump->dump_table($run_log, $vol);
     if ($tables === false) {
         die($dump->errorMsg());
     }
     if (empty($tables)) {
         /* 备份结束 */
         if ($vol > 1) {
             /* 有多个文件 */
             if (!@writefile(ROOT_PATH . 'data/sqlbackup/' . $sql_file_name . '_' . $vol . '.sql', $dump->dump_sql)) {
                 sheader('index.php?con=database&act=backup', 3, $sql_file_name . '_' . $vol . '.sql文件写入失败', 'redirect', true);
             }
             $list = array();
             for ($i = 1; $i <= $vol; $i++) {
                 $list[] = array('name' => $sql_file_name . '_' . $i . '.sql', 'href' => 'data/sqlbackup/' . $sql_file_name . '_' . $i . '.sql');
             }
             sheader('index.php?con=database&act=restore', 3, '文件备份完成', 'redirect', true);
         } else {
             /* 只有一个文件 */
             if (!@writefile(ROOT_PATH . 'data/sqlbackup/' . $sql_file_name . '.sql', $dump->dump_sql)) {
                 sheader('index.php?con=database&act=backup', 3, $sql_file_name . '_' . $vol . '.sql文件写入失败', 'redirect', true);
             }
             $list = array(array('name' => $sql_file_name . '.sql', 'href' => 'data/sqlbackup/' . $sql_file_name . '.sql'));
             sheader('index.php?con=database&act=restore', 3, '文件备份完成', 'redirect', true);
         }
     } else {
         /* 下一个页面处理 */
         if (!@writefile(ROOT_PATH . 'data/sqlbackup/' . $sql_file_name . '_' . $vol . '.sql', $dump->dump_sql)) {
             sheader('index.php?con=database&act=backup', 3, $sql_file_name . '_' . $vol . '.sql文件写入失败', 'redirect', true);
         }
         $lnk = 'index.php?con=database&act=dumpsql&sql_file_name=' . $sql_file_name . '&vol_size=' . $max_size . '&vol=' . ($vol + 1);
         sheader($lnk, 3, $sql_file_name . '_' . $vol . '.sql文件写入成功,进入下一个文件', 'redirect', true);
     }
 }
if (!defined('IN_BRAND')) {
    exit('Access Denied');
}
$goodcronfile = B_ROOT . './data/system/updategoodgrade.cache.php';
if (!file_exists($goodcronfile)) {
    $goodcrontext = '$crongoodid=0';
    writefile($goodcronfile, $goodcrontext, 'php');
}
@(include $goodcronfile);
$pernum = 1000;
$resultarr = array();
$wheresql = 'itemid>' . $crongoodid . ' AND';
$goodnum = DB::result_first('SELECT COUNT(itemid) FROM ' . tname('gooditems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC');
$query = DB::query('SELECT itemid, validity_end FROM ' . tname('gooditems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC LIMIT ' . $pernum);
while ($value = DB::fetch($query)) {
    if (!empty($value['validity_end']) && $value['validity_end'] < $_G['timestamp']) {
        DB::query('UPDATE ' . tname('gooditems') . ' SET grade=2 WHERE itemid=' . $value['itemid'], 'UNBUFFERED');
    }
    $resultarr[] = $value;
}
if ($goodnum > $pernum) {
    $cronlastgood = array_pop($resultarr);
    $crongoodid = $cronlastgood['itemid'];
    $goodcrontext = '$crongoodid=' . $crongoodid;
    writefile($goodcronfile, $goodcrontext, 'php');
    runcron($cron['cronid']);
} else {
    $goodcrontext = '$crongoodid=0';
    writefile($goodcronfile, $goodcrontext, 'php');
    cronnextrun(array($cron['cronid']));
}
Exemple #12
0
<?php

check_security();
?>

<?php 
// activate the current forum
$sSQL = "Update " . $pho_main . " set active=1 where id={$num}";
$q->query($DB, $sSQL);
$ForumActive = 1;
writefile($num, true);
Exemple #13
0
 unset($resultmodels['mid']);
 $resultcolumns = array();
 $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('modelcolumns') . ' WHERE mid = \'' . $_GET['mid'] . '\' ORDER BY displayorder, id');
 while ($value = $_SGLOBAL['db']->fetch_array($query)) {
     unset($value['id']);
     unset($value['mid']);
     if (!empty($value['upid']) && $value['formtype'] == 'linkage') {
         $value['upid'] = $cacheinfo['columnids'][$value['upid']];
     }
     $resultcolumns[] = $value;
 }
 $resultmodels['tpl'] = '';
 $tarr = array('info' => array('version' => S_VER, 'charset' => $_SCONFIG['charset']), 'models' => $resultmodels, 'columns' => $resultcolumns, 'categories' => $cacheinfo['categoryarr']);
 $modelsql = "/** SupeSite Dump\r\n" . " * Version: SupeSite " . S_VER . "\r\n" . " * Charset: " . $_SCONFIG['charset'] . "\r\n" . " * Time: {$time}\r\n" . " * From: {$_SCONFIG['sitename']} (" . S_URL . ")\r\n" . " * \r\n" . " * SupeSite: http://www.supesite.com\r\n" . " * Please visit our website for latest news about SupeSite\r\n" . " * --------------------------------------------------------*/\r\n\r\n\r\n";
 $modelsql .= '$cacheinfo = ' . arrayeval($tarr) . ';';
 if (!writefile($modelsqlfile, $modelsql, 'php')) {
     fclose($fp);
     deltree($datadir . '/' . $backupdir . '/');
     showmessage('file_write_error');
 } else {
     fclose($fp);
     $zipfilearr[] = $modelsqlfile;
 }
 $dberrorarr = array();
 $createtable = $tabledump = '';
 $_SGLOBAL['db']->query('SET SQL_QUOTE_SHOW_CREATE=0', 'SILENT');
 //ÎÞ±¨´íÖ´ÐйرÕÎҵĴ´½¨±íºÍÁÐʱ²»¼ÓÒýºÅ
 foreach ($modeldbarr as $tmpvalue) {
     $createtable = $_SGLOBAL['db']->query('SHOW CREATE TABLE ' . tname($resultmodels['modelname'] . $tmpvalue), 'SILENT');
     if (!$_SGLOBAL['db']->errno()) {
         $tabledump .= 'DROP TABLE IF EXISTS ' . tname($resultmodels['modelname'] . $tmpvalue) . ";\n";
Exemple #14
0
function ehtml($type, $updatetime = 0)
{
    global $_SGLOBAL, $_SGET, $_SHTML, $_SCONFIG, $lang;
    if ($type == 'get') {
        $_SGLOBAL['htmlfile']['updatetime'] = $updatetime;
        //if(empty($_SGET['php']) && !empty($_SGLOBAL['htmlfile']['path']) && file_exists($_SGLOBAL['htmlfile']['path'])) {
        //	sheader($_SGLOBAL['htmlfile']['url']);
        //}
        if (empty($_SGET['php']) && !empty($_SGLOBAL['htmlfile']['path']) && file_exists($_SGLOBAL['htmlfile']['path'])) {
            if ($_SGLOBAL['htmlfile']['path'] == './html/index.html') {
                include S_ROOT . './html/index.html';
                exit;
            } else {
                sheader($_SGLOBAL['htmlfile']['url']);
            }
        }
    } else {
        if (empty($_SHTML['maxpage']) && !empty($_SGLOBAL['htmlfile']['path'])) {
            $content = $_SGLOBAL['content'];
            $theurl = S_URL_ALL . '/index.php?' . arraytostring($_SHTML);
            $codearr = array('url' => rawurlencode($theurl), 'maketime' => $_SGLOBAL['timestamp'], 'updatetime' => $_SGLOBAL['htmlfile']['updatetime'], 'uid' => empty($_SHTML['uid']) ? 0 : $_SHTML['uid'], 'itemid' => empty($_SHTML['itemid']) ? 0 : $_SHTML['itemid'], 'action' => $_SHTML['action']);
            $code = rawurlencode(implode('/', $codearr));
            $content .= '
			<script language="javascript">
			<!--
			var Modified = new Date(document.lastModified);
			var copyright = document.getElementById("xspace-copyright");
			if(copyright) {
				copyright.innerHTML += "Last update: <a href=\\"' . $theurl . '/php/1\\" title=\\"' . $lang['the_page_can_be_updated_immediately_hits'] . '\\">"+(Modified.getYear()<200?(Modified.getYear()+1900):Modified.getYear())+"-"+(Modified.getMonth()+1)+"-"+Modified.getDate()+" "+Modified.getHours()+":"+Modified.getMinutes()+":"+Modified.getSeconds() + "</a><br>";
			}
			document.write(\'<script src="' . S_URL . '/batch.html.php?code=' . $code . '&amp;lastmodified=\' + Modified.getTime() + \'" type="text\\/javascript" language="javascript"><\\/script>\');
			//-->
			</script>';
            writefile($_SGLOBAL['htmlfile']['path'], $content);
        }
    }
}
Exemple #15
0
     }
 } else {
     showmessage('bbs_db_error', CPURL . '?action=bbs&error=db');
 }
 $_SC['bbsurl'] = trim($_POST['bbsurl']);
 $txt = sreadfile($_SC['bbsurl'] . '/index.php', 'r', 1);
 if (strlen($txt) < 100) {
     showmessage('bbs_url_error', CPURL . '?action=bbs&error=bbsurl');
 }
 //ÐÞ¸Äconfig.php
 $file = S_ROOT . './config.php';
 $configfile = sreadfile($file, 'r');
 foreach (array('dbhost_bbs', 'dbuser_bbs', 'dbpw_bbs', 'dbname_bbs', 'tablepre_bbs', 'pconnect_bbs', 'dbcharset_bbs', 'bbsurl', 'bbsattachurl', 'bbsver') as $value) {
     $configfile = preg_replace("/[\$]\\_SC\\[\\'" . $value . "\\'\\](\\s*)\\=\\s*[\"'].*?[\"']/is", "\$_SC['" . $value . "']\\1= '" . $_SC[$value] . "'", $configfile);
 }
 if (!writefile($file, $configfile)) {
     showmessage('error: config.php have no access to write', $theurl);
 }
 $bbschenelarr = array('nameid' => 'bbs', 'name' => $alang['bbs'], 'type' => 'system', 'status' => 1);
 inserttable('channels', $bbschenelarr, 0, true);
 include_once S_ROOT . './function/cache.func.php';
 dbconnect(1);
 //Éý¼¶ÂÛ̳×Ö¶Î
 updatebbstables();
 //»º´æÂÛ̳ÉèÖÃ
 updatebbssetting();
 //»º´æÂÛ̳·ç¸ñÉèÖÃ
 updatebbsstyle();
 //»º´æÂÛ̳bbcode/smiles
 updatebbsbbcode();
 updatebbsstyle();
Exemple #16
0
         $aaa = num_rand(10);
         $start = 0;
         $bakuptable = bakuptable($tabledb);
     }
     $f_num = ceil($step / 2);
     $filename = 'iCMS_' . get_date('', "md") . '_' . $aaa . '_' . $f_num . '.sql';
     $step++;
     $writedata = $bakuptable ? $bakuptable . $bakupdata : $bakupdata;
     $t_name = $tabledb[$tableid - 1];
     $c_n = $startfrom;
     if ($stop == 1) {
         $files = $step - 1;
         trim($writedata) && writefile(iPATH . 'admin/data/' . $filename, $bak . $writedata, true, 'ab');
         redirect("正在备份数据库表{$t_name}: 共{$rows}条记录<br>已经备份至{$c_n}条记录,已生成{$f_num}个备份文件,<br>程序将自动备份余下部分", __SELF__ . "?do=database&operation=savebackup&start={$startfrom}&tableid={$tableid}&sizelimit={$sizelimit}&step={$step}&aaa={$aaa}&tablesel={$tablesel}&rows={$rows}", 3);
     } else {
         trim($writedata) && writefile(iPATH . 'admin/data/' . $filename, $bak . $writedata, true, 'ab');
         if ($step > 1) {
             for ($i = 1; $i <= $f_num; $i++) {
                 $temp = substr($filename, 0, 19) . $i . ".sql";
                 if (file_exists("data/{$temp}")) {
                     $bakfile .= '<a href="' . "data/{$temp}" . '">' . $temp . '</a><br>';
                 }
             }
         }
         redirect("已全部备份完成,备份文件保存在data目录下", __SELF__ . "?do=database&operation=recover");
     }
     break;
 case 'recover':
     $Admin->MP("menu_database_recover");
     include iPATH . 'admin/table.array.php';
     $filedb = array();
Exemple #17
0
function saveremotefile($url, $thumbarr = array(100, 100), $mkthumb = 1, $maxsize = 0)
{
    global $_SCONFIG, $_SGLOBAL;
    $patharr = $blank = array('file' => '', 'thumb' => '', 'name' => '', 'type' => '', 'size' => 0);
    $ext = fileext($url);
    $patharr['type'] = $ext;
    if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) {
        $isimage = 1;
    } else {
        $isimage = 0;
        $ext = 'attach';
    }
    //debug 文件名
    if (empty($_SGLOBAL['_num'])) {
        $_SGLOBAL['_num'] = 0;
    }
    $_SGLOBAL['_num'] = intval($_SGLOBAL['_num']);
    $_SGLOBAL['_num']++;
    $filemain = $_SGLOBAL['supe_uid'] . '_' . sgmdate($_SGLOBAL['timestamp'], 'YmdHis') . $_SGLOBAL['_num'] . random(4);
    $patharr['name'] = $filemain . '.' . $ext;
    //debug 得到存储目录
    $dirpath = getattachdir();
    if (!empty($dirpath)) {
        $dirpath .= '/';
    }
    $patharr['file'] = $dirpath . $filemain . '.' . $ext;
    //debug 上传
    $content = sreadfile($url, 'rb', 1, $maxsize);
    if (empty($content)) {
        return $blank;
    }
    writefile(A_DIR . '/' . $patharr['file'], $content, 'text', 'wb', 0);
    if (!file_exists(A_DIR . '/' . $patharr['file'])) {
        return $blank;
    }
    $imageinfo = @getimagesize(A_DIR . '/' . $patharr['file']);
    list($width, $height, $type) = !empty($imageinfo) ? $imageinfo : array('', '', '');
    if (!in_array($type, array(1, 2, 3, 6, 13))) {
        @unlink(A_DIR . '/' . $patharr['file']);
        return $blank;
    }
    $patharr['size'] = filesize(A_DIR . '/' . $patharr['file']);
    //debug 缩略图水印
    if ($isimage) {
        if ($mkthumb && $ext != 'gif') {
            //debug 缩略图
            $patharr['thumb'] = makethumb($patharr['file'], $thumbarr);
            //debug 加水印
            if (!empty($patharr['thumb'])) {
                makewatermark($patharr['file']);
            }
        }
        if (empty($patharr['thumb'])) {
            $patharr['thumb'] = $patharr['file'];
        }
    }
    return $patharr;
}
if (!defined('IN_BRAND')) {
    exit('Access Denied');
}
$noticecronfile = B_ROOT . './data/system/updatenoticegrade.cache.php';
if (!file_exists($noticecronfile)) {
    $noticecrontext = '$cronnoticeid=0';
    writefile($noticecronfile, $noticecrontext, 'php');
}
@(include $noticecronfile);
$pernum = 1000;
$resultarr = array();
$wheresql = 'itemid>' . $cronnoticeid . ' AND';
$noticenum = DB::result_first('SELECT COUNT(itemid) FROM ' . tname('noticeitems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC');
$query = DB::query('SELECT itemid, validity_end FROM ' . tname('noticeitems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC LIMIT ' . $pernum);
while ($value = DB::fetch($query)) {
    if (!empty($value['validity_end']) && $value['validity_end'] < $_G['timestamp']) {
        DB::query('UPDATE ' . tname('noticeitems') . ' SET grade=2 WHERE itemid=' . $value['itemid'], 'UNBUFFERED');
    }
    $resultarr[] = $value;
}
if ($noticenum > $pernum) {
    $cronlastnotice = array_pop($resultarr);
    $cronnoticeid = $cronlastnotice['itemid'];
    $noticecrontext = '$cronnoticeid=' . $cronnoticeid;
    writefile($noticecronfile, $noticecrontext, 'php');
    runcron($cron['cronid']);
} else {
    $noticecrontext = '$cronnoticeid=0';
    writefile($noticecronfile, $noticecrontext, 'php');
    cronnextrun(array($cron['cronid']));
}
if (!defined('IN_BRAND')) {
    exit('Access Denied');
}
$groupbuycronfile = B_ROOT . './data/system/updategroupbuygrade.cache.php';
if (!file_exists($groupbuycronfile)) {
    $groupbuycrontext = '$crongroupbuyid=0';
    writefile($groupbuycronfile, $groupbuycrontext, 'php');
}
@(include $groupbuycronfile);
$pernum = 1000;
$resultarr = array();
$wheresql = 'itemid>' . $crongroupbuyid . ' AND';
$groupbuynum = DB::result_first('SELECT COUNT(itemid) FROM ' . tname('groupbuyitems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC');
$query = DB::query('SELECT itemid, validity_end FROM ' . tname('groupbuyitems') . ' WHERE ' . $wheresql . ' grade>2 ORDER BY itemid ASC LIMIT ' . $pernum);
while ($value = DB::fetch($query)) {
    if (!empty($value['validity_end']) && $value['validity_end'] < $_G['timestamp']) {
        DB::query('UPDATE ' . tname('groupbuyitems') . ' SET grade=2 WHERE itemid=' . $value['itemid'], 'UNBUFFERED');
    }
    $resultarr[] = $value;
}
if ($groupbuynum > $pernum) {
    $cronlastgroupbuy = array_pop($resultarr);
    $crongroupbuyid = $cronlastgroupbuy['itemid'];
    $groupbuycrontext = '$crongroupbuyid=' . $crongroupbuyid;
    writefile($groupbuycronfile, $groupbuycrontext, 'php');
    runcron($cron['cronid']);
} else {
    $groupbuycrontext = '$crongroupbuyid=0';
    writefile($groupbuycronfile, $groupbuycrontext, 'php');
    cronnextrun(array($cron['cronid']));
}
Exemple #20
0
/**
 * 更新用户后台模型id
 */
function updateuserspacemid()
{
    global $_SGLOBAL;
    dbconnect();
    $midarr = array();
    $query = $_SGLOBAL['db']->query('SELECT m.*, c.status FROM ' . tname('models') . ' m LEFT JOIN ' . tname('channels') . ' c ON (m.modelname = c.nameid) WHERE c.status > -1');
    while ($result = $_SGLOBAL['db']->fetch_array($query)) {
        $midarr[] = $result;
    }
    $cachefile = S_ROOT . './cache/model/model.cache.php';
    $text = '$cacheinfo = ' . arrayeval($midarr) . ';';
    writefile($cachefile, $text, 'php');
    return $midarr;
}
Exemple #21
0
 function dealdata($data)
 {
     global $current_size, $tablearr, $writefile_data, $_POST;
     $current_size += strlen($data);
     $writefile_data .= $data;
     if ($current_size >= intval($_POST["filesize"]) * 1024) {
         $current_size = 0;
         $writefile_data .= "\r\n?" . ">";
         writefile($writefile_data, "w");
         $_POST[page] = intval($_POST[page]) + 1;
         fheader();
         echo tablestart("正在从数据库'{$_POST['db_dbname']}'中导出数据……", 500);
         $str1 = "<br>-= 以下数据表处理完成 =- <div class='borderdiv' style='width:150px;height:100px;overflow:auto;' align=left>";
         $finishByte = 0;
         for (reset($tablearr); list($key, $val) = each($tablearr);) {
             if ($key < $_POST[tabledumping]) {
                 $str1 .= "√ {$val}<BR>\r\n";
                 $finishByte += $_POST[fsqltable][$val];
             } else {
                 if ($key == $_POST[tabledumping]) {
                     $str1 .= "<a href='#' id='finisheditem'> </a></div>\n\t\t\t\t\t\t<br>-= 以下数据表正待处理 =-\n\t\t\t\t\t\t<div class='borderdiv' style='width:150px;height:100px;overflow:auto;' align=left>\n\t\t\t\t\t\t<font style='color:#FF0000'>→ {$val}</font><br>\r\n";
                     $finishByte += $_POST[lastinsert] * substr(strstr($_POST[fsqltable][$val], ','), 1);
                     $finish = intval($finishByte / $_POST[totalsize] * 100);
                 } else {
                     $str1 .= "・ {$val}<br>\r\n";
                 }
             }
         }
         $str1 .= "</div><BR>";
         $str2 = tablestart("导出状态", 300);
         $str2 .= tabledata("共有数据:|" . num_bitunit($_POST[totalsize]) . "", "100|200");
         $str2 .= tabledata("现已导出:|" . num_bitunit($finishByte) . "");
         $str2 .= tabledata("每页导出:|" . num_bitunit(intval($finishByte / $_POST[page])) . "");
         $str2 .= tabledata("导出时间间隔:|{$_POST['nextpgtimeout']} 秒");
         $str2 .= tabledata("每页生成数据文件|≥ " . num_bitunit($_POST["filesize"] * 1024) . "");
         $str2 .= tabledata("已生成数据文件:|" . ($_POST[page] - 1) . " 个");
         $str2 .= tabledata("正在自动进入:|<a href='javascript:myform.submit();'>第 {$_POST['page']} 页</a>");
         $str2 .= tabledata("已用时:|" . timeformat(time() - $_POST["StartTime"]) . "");
         $str2 .= tabledata("已完成:|{$finish}% ");
         $str2 .= tabledata("完成进度:|<table width=100% height=12  border=0 cellspacing=1 cellpadding=0 class='tabletitle' align=center><tr><td width='{$finish}%'><div></div></td><td width='" . (100 - $finish) . "%'  class='tabledata'><div></div></td></tr></table>");
         $str2 .= tableend();
         $str2 .= "<B><div id='postingTag'></div></B>";
         echo tabledata("{$str1}|{$str2}");
         echo tableend();
         ffooter();
         eval(auto_submit_script());
         exit;
     }
 }
Exemple #22
0
function updateattrext($force = true, $cachetime = '53200')
{
    global $_G, $_SGLOBAL;
    $cachefile = B_ROOT . './data/system/attr_ext.cache.php';
    if ($force == false) {
        $cachemtime = file_exists($cachefile) ? filemtime($cachefile) : 0;
        if ($_G['timestamp'] - $cachemtime < $cachetime) {
            @(include $cachefile);
            return false;
        }
    }
    $_SGLOBAL['brandlinks'] = $link = array();
    $query = DB::query('SELECT * FROM ' . tname('modelcolumns') . ' WHERE mid = 2 and available = 1 order by displayorder');
    while ($value = DB::fetch($query)) {
        if (!preg_match('/^ext_/', $value['fieldname'])) {
            continue;
        }
        $_SGLOBAL['attr_ext'][] = $value;
    }
    $cachetext = '$_SGLOBAL[\'attr_ext\']=' . arrayeval($_SGLOBAL['attr_ext']);
    writefile($cachefile, $cachetext, 'php');
    @(include $cachefile);
}
Exemple #23
0
function writemodelvalidate($type, $value)
{
    global $alang;
    $validatearr = array();
    $validatestr = '';
    $cacheinfo = getmodelinfoall($type, $value);
    if (!empty($cacheinfo['fielddefault']['subject'])) {
        $alang['model_validate_subject'] = $cacheinfo['fielddefault']['subject'];
    }
    if (!empty($cacheinfo['fielddefault']['subjectimage'])) {
        $alang['model_validate_subjectimage'] = $cacheinfo['fielddefault']['subjectimage'];
    }
    if (!empty($cacheinfo['fielddefault']['catid'])) {
        $alang['model_validate_categories'] = $cacheinfo['fielddefault']['catid'];
    }
    $validatearr['fieldinfo'] = array('new Array(\'subject\', \'' . $alang['model_validate_subject'] . '\', \'text\', \'80\', \'1\', \'CHAR\')', 'new Array(\'catid\', \'' . $alang['model_validate_categories'] . '\', \'select\', \'6\', \'1\', \'SMALLINT\')', 'new Array(\'subjectimage\', \'' . $alang['model_validate_subjectimage'] . '\', \'img\', \'80\', \'0\', \'CHAR\')');
    if (!empty($cacheinfo['columns'])) {
        foreach ($cacheinfo['columns'] as $tmpvalue) {
            $issign = false;
            if ($tmpvalue['formtype'] == 'checkbox' && $tmpvalue['isrequired'] == 1) {
                $issign = true;
            } else {
                if (preg_match("/^(select|linkage|radio|timestamp|file)\$/i", $tmpvalue['formtype'])) {
                    if ($tmpvalue['isrequired'] == 1) {
                        $issign = true;
                    }
                } else {
                    $issign = true;
                }
            }
            if ($issign) {
                $validatearr['fieldinfo'][] = "new Array('{$tmpvalue['fieldname']}', '{$tmpvalue['fieldcomment']}', '{$tmpvalue['formtype']}', '{$tmpvalue['fieldlength']}', '{$tmpvalue['isrequired']}', '{$tmpvalue['fieldtype']}')";
            }
            if ($tmpvalue['formtype'] == 'linkage') {
                $tmpfielddata = strim(explode("\r\n", $tmpvalue['fielddata']));
                if (!empty($tmpfielddata)) {
                    foreach ($tmpfielddata as $skey => $svalue) {
                        if (!empty($svalue)) {
                            $svalue = trim(substr($svalue, strpos($svalue, '=') + 1));
                            $validatearr[$tmpvalue['fieldname'] . 'arr'][] = 'new Array(\'' . trim(substr($tmpfielddata[$skey], 0, strpos($tmpfielddata[$skey], '='))) . '\', \'' . $svalue . '\')';
                        }
                    }
                }
            }
        }
    }
    $validatestr = <<<EOF
var imageext = new Array('jpg', 'jpeg', 'gif', 'png');
var flashext = new Array('swf');

function strLen(str) {
\tvar charset = is_ie ? document.charset : document.characterSet;
\tvar len = 0;
\tfor(var i = 0; i < str.length; i++) {
\t\tlen += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset.toLowerCase() == "utf-8" ? 3 : 2) : 1;
\t}
\treturn len;
}

function fileext(filename) {
\tif(filename == null || filename == '') {
\t\treturn '';
\t}
\tvar ext = null;
\tvar num = filename.lastIndexOf(".");
\tif(num != -1) {
\t\text = filename.substring(num + 1);
\t} else {
\t\text = '';
\t}
\treturn ext;
}

function isfileext(filename, extarr) {
\tvar ext = fileext(filename).toLowerCase();
\tfor(var i = 0; i < extarr.length; i++) {
\t\tif(extarr[i] == ext){
\t\t\treturn true;
\t\t}
\t}
\treturn false;
}

function fill(setid, parentid, arr, value) {
\tsetid = document.getElementById(setid);
\tif(setid != null) {
\t\tsetid.options[0]=new Option('{$alang['model_validate_choose']}','');
\t\topt = 0;
\t\tif(parentid == '') {
\t\t\tfor(i=0;i<arr.length;i++) {
\t\t\t\tsetid.options[i+1]=new Option(arr[i][1],arr[i][0]);
\t\t\t\tif(arr[i][1] == value) {
\t\t\t\t\topt = i+1;
\t\t\t\t}
\t\t\t}
\t\t\tsetid.options[opt].selected=true;
\t\t\tsetid.length=i+1;
\t\t} else {
\t\t\tparentcode = document.getElementById(parentid).value;
\t\t\tcount=1;
\t\t\tif(parentcode != '') {
\t\t\t\tfor(i=0;i<arr.length;i++) {
\t\t\t\t\tif(arr[i][0].toString().substring(0,parentcode.length)==parentcode.substring(0, parentcode.length)) {
\t\t\t\t\t\tsetid.options[count]=new Option(arr[i][1],arr[i][0]);
\t\t\t\t\t\tif(value != null && arr[i][1] == value) {
\t\t\t\t\t\t\topt = count;
\t\t\t\t\t\t}
\t\t\t\t\t\tcount=count+1;
\t\t\t\t\t}
\t\t\t\t}
\t\t\t}
\t\t\tsetid.options[opt].selected=true;
\t\t\tsetid.length=count;
\t\t}
\t}
}

function validate(theform) {
\tif(fieldinfo.length > 0) {
\t\tfor(i = 0; i < fieldinfo.length; i++) {
\t\t\tobj = null;
\t\t\tif(fieldinfo[i][2] == 'checkbox' && fieldinfo[i][4] == '1') {
\t\t\t\tischoose = false;
\t\t\t\tvar nodes = document.getElementsByTagName('input');
\t\t\t\tif(nodes) {
\t\t\t\t\tfor(j = 0; j < nodes.length; j++) {
\t\t\t\t\t\tvar node = nodes[j];
\t\t\t\t\t\tif (node.name == fieldinfo[i][0]+'[]') {
\t\t\t\t\t\t\tif(obj == null) obj = node;
\t\t\t\t\t\t\tif(node.checked == true) {
\t\t\t\t\t\t\t\tischoose = true;
\t\t\t\t\t\t\t\tbreak;
\t\t\t\t\t\t\t}

\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t\tif(!ischoose) {
\t\t\t\t\t\talert('{$alang['model_validate_choose_2']}'+fieldinfo[i][1]);
\t\t\t\t\t\tobj.focus();
\t\t\t\t\t\treturn false;
\t\t\t\t\t}
\t\t\t\t}
\t\t\t} else {
\t\t\t\tischoose = true;
\t\t\t\tobj = document.getElementById(fieldinfo[i][0]);
\t\t\t\tif(fieldinfo[i][4] == '1' && obj && strLen(obj.value) < 1) {
\t\t\t\t\tischoose = false;
\t\t\t\t\tif(fieldinfo[i][2] == 'text' || fieldinfo[i][2] == 'textarea') {
\t\t\t\t\t\talert('{$alang['model_validate_input_1']}'+fieldinfo[i][1]);
\t\t\t\t\t} else if(fieldinfo[i][2] == 'img' || fieldinfo[i][2] == 'flash' || fieldinfo[i][2] == 'file' || fieldinfo[i][2] == 'timestamp') {
\t\t\t\t\t\tobjvalue = document.getElementById(fieldinfo[i][0]+'_value');
\t\t\t\t\t\tif(obj && strLen(objvalue.value) < 1) {
\t\t\t\t\t\t\talert('{$alang['model_validate_noset']}'+fieldinfo[i][1]+',{$alang['model_validate_affirm']}');
\t\t\t\t\t\t} else {
\t\t\t\t\t\t\tischoose = true;
\t\t\t\t\t\t}
\t\t\t\t\t} else {
\t\t\t\t\t\talert("{$alang['model_validate_choose_2']}"+fieldinfo[i][1]);
\t\t\t\t\t}
\t\t\t\t}
\t\t\t\tif(obj && obj.value != '') {
\t\t\t\t\tif(fieldinfo[i][2] == 'text' || (fieldinfo[i][2] == 'textarea' && fieldinfo[i][3] != 0)) {
\t\t\t\t\t\tif(fieldinfo[i][5] != 'TEXT' && fieldinfo[i][5] != 'MEDIUMTEXT' && fieldinfo[i][5] != 'LONGTEXT' && fieldinfo[i][5] != 'FLOAT' && fieldinfo[i][5] != 'DOUBLE') {
\t\t\t\t\t\t\tif (strLen(obj.value) > fieldinfo[i][3]) {
\t\t\t\t\t\t\t\tischoose = false;
\t\t\t\t\t\t\t\talert('{$alang['model_validate_input_2']}'+fieldinfo[i][1]+'{$alang['model_validate_input_3']}'+strLen(obj.value)+'{$alang['model_validate_input_4']}'+fieldinfo[i][3]+'{$alang['model_validate_input_5']}');
\t\t\t\t\t\t\t}
\t\t\t\t\t\t}
\t\t\t\t\t} else if(fieldinfo[i][2] == 'img' || fieldinfo[i][2] == 'flash') {
\t\t\t\t\t\tif (!isfileext(obj.value, (fieldinfo[i][2] == 'img' ? imageext : flashext))) {
\t\t\t\t\t\t\tischoose = false;
\t\t\t\t\t\t\talert('{$alang['model_validate_input_2']}'+fieldinfo[i][1]+'{$alang['model_validate_input_6']}');
\t\t\t\t\t\t}
\t\t\t\t\t}
\t\t\t\t}
\t\t\t\tif(!ischoose) {
\t\t\t\t\tobj.focus();
\t\t\t\t\treturn false;
\t\t\t\t}
\t\t\t}
\t\t}
\t}

\treturn true;
}

EOF;
    foreach ($validatearr as $tmpkey => $tmpvalue) {
        $validatestr .= "\nvar " . $tmpkey . " = new Array(\n";
        $validatestr .= implode(",\n", $tmpvalue);
        $validatestr .= "\n);\n";
    }
    $cachefile = S_ROOT . './model/data/' . $cacheinfo['models']['modelname'] . '/images/validate.js';
    writefile($cachefile, $validatestr);
}
Exemple #24
0
function sethtmlupdatemode($newmode)
{
    $cachefile = S_ROOT . './data/system/html.cache.php';
    @(include_once $cachefile);
    $text = '';
    if (!empty($htmltime)) {
        $text .= '$htmltime=\'' . $htmltime . '\';' . "\n";
    }
    $text .= '$htmlupdatemode=\'' . $newmode . '\';' . "\n";
    writefile($cachefile, $text, 'php', 'w', 0);
}
Exemple #25
0
function CreateConfigFile()
{
    global $DreamCMS;
    $tmp = $DreamCMS->db->get_results("SELECT * FROM `#DC@__config`");
    $config_data = "<?php\n\t\$config=array(\n";
    for ($i = 0; $i < count($tmp); $i++) {
        if ($tmp[$i]['name'] == 'rewrite' || $tmp[$i]['name'] == 'bbs' || $tmp[$i]['name'] == 'email') {
            //zhaoyanmin 加email
            $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . addslashes($tmp[$i]['value']) . "\",\n";
        } else {
            $_config .= "\t\t\"" . $tmp[$i]['name'] . "\"=>\"" . $tmp[$i]['value'] . "\",\n";
        }
    }
    $config_data .= substr($_config, 0, -2);
    $config_data .= "\t\n);?>";
    writefile(DCPATH . 'include/site.config.php', $config_data);
}
Exemple #26
0
    $filename = './shutdown.txt';
    $str = 'shutdown ok';
    writefile($filename, $str);
    echo "<script>alert('操作成功');location='member.php';</script>";
}
//重启操作
if ($_GET["PS"] == "r") {
    function writefile($fname, $str)
    {
        $fp = fopen($fname, "w");
        fputs($fp, $str);
        fclose($fp);
    }
    $filename = './restartnow.txt';
    $str = 'restart ok';
    writefile($filename, $str);
    echo "<script>alert('操作成功');location='member.php';</script>";
}
//显示用户
$sql = "select * from member where member_user='******'member'] . "',member_img='" . $_POST['member_img'] . "'";
$rs = mysql_fetch_array(mysql_query($sql));
if ($_SESSION['member']) {
    ?>
<table width="350" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3">
  <tr>
    <td width="327" align="center" bgcolor="#EBEBEB" class="font">控制者控制面板
  </tr>
</table>
<table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="3"></td>
        ++$page;
        $nexturl = CPURL . '?action=makehtml&op=makecathtml&perlisthtml=' . $perlisthtml . '&catid=' . $catid . '&total=' . $countnum . '&page=' . $page;
        echo '<table style="width:98%;padding:0.2em;border: 1px solid #698CC3;font-size:14px;font-weight:bold;font-family: Trebuchet MS, Lucida Console, Lucida Sans, sans-serif;" align="center"><tr><td><a href=' . $nexturl . '>' . $alang['making_page_info_0'] . $total . $alang['making_page_info_1'] . $start . ' / ' . ($start + $perlisthtml) . $alang['making_page_info_2'] . '</a></td><td width="35%"><a href="' . $theurl . '&op=make">' . $alang['making_page_info_3'] . '</a></td></tr></table>';
        jumpurl($nexturl, 1);
    } else {
        if ($_GET['jump'] == 'yes') {
            include_once S_ROOT . '/data/temp/catid.cache.php';
            //取出其中一个catid生成html
            $catid = array_pop($tcatidarr);
            $jump = 'no';
            if (!empty($tcatidarr)) {
                //保存到临时文件下,用于跳转
                $jump = 'yes';
                $cachefile = S_ROOT . './data/temp/catid.cache.php';
                $text = '$tcatidarr = ' . arrayeval($tcatidarr) . ';';
                writefile($cachefile, $text, 'php');
            }
            updatehtmlpathcache();
            $_SGLOBAL['db']->query("DELETE FROM " . tname('spacepages') . " WHERE catid='{$catid}'");
            $query = $_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('spaceitems') . " WHERE catid='{$catid}'");
            $countnum = $_SGLOBAL['db']->result($query, 0);
            $nexturl = CPURL . '?action=makehtml&op=makecathtml&perlisthtml=' . $perlisthtml . '&catid=' . $catid . '&total=' . $countnum . '&jump=' . $jump;
            echo '<table style="width:98%;padding:0.2em;border: 1px solid #698CC3;font-size:14px;font-weight:bold;font-family: Trebuchet MS, Lucida Console, Lucida Sans, sans-serif;" align="center"><tr><td><a href=' . $nexturl . '>' . $alang['making_page_info_0'] . $batch_makehtml_count . $alang['making_page_info_1'] . '0 / ' . $perlisthtml . $alang['making_page_info_2'] . '</a></td><td width="35%"><a href="' . $theurl . '&op=make">' . $alang['making_page_info_3'] . '</a></td></tr></table>';
            jumpurl($nexturl, 1);
            exit;
        }
        showmessage('make_html_success', $theurl);
    }
} elseif ($op == 'updatehtml') {
    include_once S_ROOT . '/data/temp/catidarr.cache.php';
    //处理对应的分类block内容
Exemple #28
0
     if (!file_exists($src)) {
         showmessage('channel_php_src_error');
     }
     if (!@copy($src, $obj)) {
         $data = implode('', file($src));
         writefile($obj, $data);
     }
     //复制模板
     $src = S_ROOT . './templates/' . $_SCONFIG['template'] . '/channel_sample.html.php';
     $obj = S_ROOT . './templates/' . $_SCONFIG['template'] . '/channel_' . $nameid . '.html.php';
     if (!file_exists($src)) {
         showmessage('channel_tpl_src_error');
     }
     if (!@copy($src, $obj)) {
         $data = implode('', file($src));
         writefile($obj, $data);
     }
 } elseif ($_POST['type'] == 'news') {
     $_POST['category'] = trim($_POST['category']);
     $datas = array();
     if (empty($_POST['category'])) {
         $datas = array("'{$alang['channel_category_1']}', '{$nameid}'", "'{$alang['channel_category_2']}', '{$nameid}'", "'{$alang['channel_category_3']}', '{$nameid}'", "'{$alang['channel_category_4']}', '{$nameid}'", "'{$alang['channel_category_5']}', '{$nameid}'", "'{$alang['channel_category_6']}', '{$nameid}'", "'{$alang['channel_category_7']}', '{$nameid}'", "'{$alang['channel_category_8']}', '{$nameid}'", "'{$alang['channel_category_9']}', '{$nameid}'");
     } else {
         $_POST['category'] = explode("\n", $_POST['category']);
         foreach ($_POST['category'] as $value) {
             $value = saddslashes(shtmlspecialchars(trim($value)));
             if ($value) {
                 $datas[] = "'{$value}', '{$nameid}'";
             }
         }
     }
Exemple #29
0
check_security();
/* Plugin Managment */
if (@$do == "props" && !empty($plugin)) {
    $plugindirname = $plugin;
    $pluginprops = TRUE;
    include "./plugin/{$plugin}/admin.php";
} else {
    if (isset($action) && isset($plugin)) {
        if ($action == "activate_plugin") {
            $PHORUM["plugins"][$plugin] = true;
            QueMessage("Plugin Activated.");
        } elseif ($action == "deactivate_plugin") {
            $PHORUM["plugins"][$plugin] = false;
            QueMessage("Plugin Deactivated.");
        }
        writefile();
    }
    ?>
<p>
<table border="0" cellspacing="0" cellpadding="3" class="box-table">
<tr>
<td colspan="2" align="center" valign="middle" class="table-header">Manage Plugins</td>
</tr>
<tr>
<?php 
    $dir = opendir("./plugin/");
    $num = 0;
    while ($plugindirname = readdir($dir)) {
        if ($plugindirname[0] != ".") {
            if (@file_exists("./plugin/{$plugindirname}/plugin.php")) {
                unset($pluginname);
function updatebbsforumset()
{
    global $_SGLOBAL;
    $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('forums') . ' ORDER BY displayorder');
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $value['pushsetting'] = unserialize($value['pushsetting']);
        $_SGLOBAL['bbsforumarr'][$value['fid']] = $value;
    }
    $cachefile = S_ROOT . './data/system/bbsforums.cache.php';
    $cachetext = '$_SGLOBAL[\'bbsforumarr\']=' . arrayeval($_SGLOBAL['bbsforumarr']);
    writefile($cachefile, $cachetext, 'php');
}