public static function uninstall() { global $db, $setting, $admin_cat; $info = self::info(); $db->delete($setting['db']['pre'] . "ticket"); $db->exec("drop", "table", $setting['db']['pre'] . "ticket"); $db->delete($setting['db']['pre'] . "admin_cat", array("file", "=", "ticket.php")); $db->delete($setting['db']['pre'] . "plugin", array("idx", "=", $info['idx'])); deleteCache("admin_cat"); deleteCache("plugin"); $content = "<?PHP\r\n\$ticket_list = array();\t\t\t\r\n?>"; WriteFile(dirname(__FILE__) . "/list.php", $content, "wb"); $err = array(); if ($db->GetError($err)) { showInfo($setting['language']['plugin_err_uninstall'] . "\r\n\t\t\t<br />\r\n\t\t\t<pre>\r\n\t\t\t" . join("\n------------------------\n", $err) . "\r\n\t\t\t</pre>\r\n\t\t\t"); } else { includeCache("admin_cat"); $admin_cat = toJson($admin_cat, $setting['gen']['charset']); echo <<<mystep <script language="javascript"> parent.admin_cat = {$admin_cat}; parent.setNav(); </script> mystep; buildParaList("plugin"); echo showInfo($setting['language']['plugin_uninstall_done'], false); } }
if (count($_POST) == 0) { $goto_url = $setting['info']['self']; } else { if (!preg_match("/^(select|show).+/i", $_POST['sql']) || preg_match("/ into /i", $_POST['sql'])) { showInfo($setting['language']['plugin_custom_sql_error_sql']); } else { unset($_POST['id']); if ($method == "add_ok") { $log_info = $setting['language']['plugin_custom_sql_add']; $sql_list[] = $_POST; } else { $log_info = $setting['language']['plugin_custom_sql_edit']; $sql_list[$id] = $_POST; } $content = "<?PHP\r\n\$sql_list = " . var_export($sql_list, true) . ";\t\t\t\r\n?>"; WriteFile("sql.php", $content, "wb"); } $goto_url = $setting['info']['self']; } break; case "export": $log_info = $setting['language']['plugin_custom_sql_export']; $xls = new MyXls(); $xls->init($sql_list[$id]['name'], $sql_list[$id]['name']); $xls->addRow(); $xls->addCells(explode(",", $sql_list[$id]['fields'])); $db->Query($sql_list[$id]['sql']); while ($record = $db->GetRS()) { $xls->addRow(); $xls->addCells($record); }
$update_info['content'][$i] = "."; } else { $update_info['content'][$i] = GetFile($the_file); $path_parts = pathinfo($update_info['file'][$i]); if (!empty($cs) && strpos(".php,.tpl,.html,.htm,.sql", $path_parts["extension"]) !== false) { $update_info['content'][$i] = str_ireplace(strtolower($setting['gen']['charset']), strtolower($cs), $update_info['content'][$i]); $update_info['content'][$i] = str_ireplace(strtoupper($setting['gen']['charset']), strtoupper($cs), $update_info['content'][$i]); $update_info['content'][$i] = chg_charset($update_info['content'][$i], $setting['gen']['charset'], $cs); } } } else { $update_info['content'][$i] = ""; } } $update = base64_encode(serialize($update_info)); WriteFile($cache_file, $update, "wb"); } echo $update; } else { $fso = new MyFSO(); $dir_list = $fso->Get_List($plugin_path); $plugin_list = array(); for ($i = 0, $m = count($dir_list['dir']); $i < $m; $i++) { if (file_exists($dir_list['dir'][$i] . "/ignore")) { continue; } if (is_file($dir_list['dir'][$i] . "/info.php")) { include $dir_list['dir'][$i] . "/info.php"; $plugin_list[$info['idx']] = array('name' => $info['name'], 'ver' => $info['ver'], 'intro' => $info['intro']); } }
function RecordLog($type=false) { if($type == "RANK") { $file = LOG_BATTLE_RANK; $log = @glob(LOG_BATTLE_RANK."*"); $logAmount = MAX_BATTLE_LOG_RANK; } else if($type == "UNION") { $file = LOG_BATTLE_UNION; $log = @glob(LOG_BATTLE_UNION."*"); $logAmount = MAX_BATTLE_LOG_UNION; } else { $file = LOG_BATTLE_NORMAL; $log = @glob(LOG_BATTLE_NORMAL."*"); $logAmount = MAX_BATTLE_LOG; } // 古いログを消す $i = 0; while($logAmount <= count($log) ) { unlink($log["$i"]); unset($log["$i"]); $i++; } // 新しいログを作る $time = time().substr(microtime(),2,6); $file .= $time.".dat"; $head = $time."\n";//開始時間(1行目) $head .= $this->team0_name."<>".$this->team1_name."\n";//参加チーム(2行目) $head .= count($this->team0)."<>".count($this->team1)."\n";//参加人数(3行目) $head .= $this->team0_ave_lv."<>".$this->team1_ave_lv."\n";//平均レベル(4行目) $head .= $this->result."\n";//勝利チーム(5行目) $head .= $this->actions."\n";//総ターン数(6行目) $head .= "\n";// 改行(7行目) WriteFile($file,$head.ob_get_contents()); }
function SaveLog() { if ($this->AuctionType == "item") { if (!$this->AuctionLog) { return false; } // 30行以下に収める while (100 < count($this->AuctionLog)) { array_pop($this->AuctionLog); } foreach ($this->AuctionLog as $log) { $string .= $log . "\n"; } WriteFile(AUCTION_ITEM_LOG, $string); } }
} } elseif ($method == "export") { $log_info = $setting['language']['admin_func_backup_export']; $dir = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/"; if ($table_name == "all") { require ROOT_PATH . "/source/class/myzip.class.php"; $zipfile = $dir . date("Ymd") . "_db_all.zip"; $dir = $dir . date("Ymd") . "_db_all/"; $tbl_list = $db->GetTabs($setting['db']['name']); $max_count = count($tbl_list); $files = array(); for ($i = 0; $i < $max_count; $i++) { $content = "DROP TABLE IF EXISTS `{$tbl_list[$i]}`;\n\n"; $content .= $db->GetTabSetting($tbl_list[$i], $setting_sub['db']['name']) . "\n" . $db->GetTabData($setting_sub['db']['name'] . "." . $tbl_list[$i]); $files[$i] = $dir . $setting_sub['db']['name'] . "_" . $tbl_list[$i] . ".sql"; WriteFile($files[$i], $content); } zip($files, $zipfile, $dir); header("Content-type: application/zip"); header("Accept-Ranges: bytes"); header("Accept-Length: " . filesize($zipfile)); header("Content-Disposition: attachment; filename=" . basename($zipfile)); $content = GetFile($zipfile); MultiDel($dir); unlink($zipfile); } else { $content = "DROP TABLE IF EXISTS `{$table_name}`;\n\n"; $content .= $db->GetTabSetting($table_name) . "\n" . $db->GetTabData($table_name); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Accept-Length: " . strlen($content));
public function DoIt($type = "pack", $separator = "|") { $this->pack_result = array(); if ($type == "pack") { $this->pack_fp = fopen($this->pack_file, "wb"); if (!$this->pack_fp) { die("Error Occurs In Creating Output File !"); } $time = $_SERVER['REQUEST_TIME']; if (count($this->file_list) > 0) { $this->PackFileList($separator); } else { $this->PackFile($this->pack_dir, $separator); } fclose($this->pack_fp); if ($_SERVER['REQUEST_TIME'] - $time <= 1) { sleep(1); } WriteFile($this->pack_file, gzcompress(GetFile($this->pack_file), 9)); } else { WriteFile($this->pack_file, gzuncompress(GetFile($this->pack_file))); $this->pack_fp = fopen($this->pack_file, "rb"); if (!$this->pack_fp) { die("Error Occurs In Reading Pack File !"); } $this->UnpackFile($this->pack_dir, $separator); fclose($this->pack_fp); unlink($this->pack_file); } $filename = $this->pack_file; $filesize = GetFileSize($filename); array_push($this->pack_result, "<br />File Count: {$this->file_count} File(s)"); return $filename; }
} else { $content = $_POST['content']; if (!preg_match("/^[\r\n\\s]*<\\?php(.+)\\?>[\r\n\\s]*\$/is", $content)) { $content = "<?php\n" . $content . "\n?>"; } unset($_POST['content']); if ($method == "add_ok") { $_POST['idx'] = $_SERVER['REQUEST_TIME']; $log_info = $setting['language']['plugin_xcode_add']; $mydb->insertDate($_POST, 1); } else { $log_info = $setting['language']['plugin_xcode_edit']; $record = $mydb->queryDate("idx=" . $idx, true, &$fp_pos, &$row_pos); $mydb->updateDate($_POST, $row_pos, 1); } WriteFile(dirname(__FILE__) . "/code/" . $_POST['idx'] . ".php", $content, "wb"); } break; default: break; } if (!empty($log_info)) { write_log($log_info, "idx={$idx}"); $goto_url = $setting['info']['self']; } $mydb->closeTBL(); unset($mydb); $mystep->pageEnd(false); function build_page($method) { global $mystep, $req, $db, $setting, $idx, $mydb;
} $link = ""; $m = count($list); if ($m > 0) { require ROOT_PATH . "/source/class/myzip.class.php"; $dir = ROOT_PATH . "/" . $setting['path']['upload'] . "/tmp/"; $zipfile = $dir . "update_" . date("Ymd") . ".zip"; @unlink($zipfile); $dir = $dir . "update/" . date("Ymd/"); $files = array(); for ($i = 0; $i < $m; $i++) { if ($update_info['content'][$list[$i]] == ".") { continue; } $files[$i] = $dir . $update_info['file'][$list[$i]]; WriteFile($files[$i], $update_info['content'][$list[$i]], "wb"); } if (zip($files, $zipfile, $dir)) { $link = $setting['web']['url'] . "/" . $setting['path']['upload'] . "/tmp/" . basename($zipfile); } MultiDel($dir); } } echo $link; break; default: $header = array(); $header['Referer'] = "http://" . $req->GetServer("HTTP_HOST"); $header['ms_sign'] = $setting['web']['sign']; $check_info = GetRemoteContent($setting['gen']['update'] . "?m=check&v=" . $ms_version['ver'] . "&cs=" . $setting['gen']['charset'], $header); $check_info = chg_charset($check_info, "utf-8", $setting['gen']['charset']);
function SaveRanking() { foreach($this->Ranking as $rank => $val) { $ranking .= $val["id"]."\n"; } WriteFile(RANKING,$ranking); }
@unlink($target_file); MultiDel($result_dir); sleep(1); mkdir($result_dir); $mypack = new MyPack($pack_dir, $pack_file); $mypack->AddIgnore(basename(dirname(__FILE__)), ".svn", "web.config", "aspnet_client", "include/install.lock", "Thumbs.db", "bak", "xcache", "_test", "config_test.php", "config-bak.php", "cfna_mis"); if (!empty($cs)) { $mypack->setCharset("gbk", $cs, $lng_type, ".php,.tpl,.html,.htm,.sql"); } $mypack->DoIt(); //echo $mypack->GetResult(); $result = ""; $result .= GetFile("mypack.class.php"); $result .= "\n"; $result .= GetFile("setup.php"); $result = str_replace("?>\n<?php", "", $result); WriteFile($target_file, $result, "wb"); unset($result); copy("intro.txt", $result_dir . "/readme.txt"); require "../source/class/myzip.class.php"; rename($result_dir, "upload"); zip("upload", "build/" . $result_dir . ".zip"); MultiDel("upload"); } ?> <script language="JavaScript"> location.href = "build/<?php echo $result_dir; ?> .zip"; </script>
function SaveData() { $dir = USER . $this->id; $file = USER . $this->id . "/" . DATA; if (file_exists($this->file) && $this->fp) { //print("BBB"); //ftruncate($this->fp,0); //rewind($this->fp); //$fp = fopen($file,"w+"); //flock($fp,LOCK_EX); //fputs($this->fp,$this->DataSavingFormat()); WriteFileFP($this->fp, $this->DataSavingFormat()); fclose($this->fp); unset($this->fp); //WriteFile("./user/1234/data2.dat",$this->DataSavingFormat()); //WriteFile($file,$this->DataSavingFormat()); //WriteFileFP($this->fp,$this->DataSavingFormat()); //fclose($this->fp); } else { if (file_exists($file)) { WriteFile($file, $this->DataSavingFormat()); } } }
mysql_close($link); $new_setting = arrayMerge($setting, $_POST['setting']); unset($new_setting['web']['s_user'], $new_setting['web']['s_pass'], $new_setting['web']['cache_mode'], $new_setting['db']['host'], $new_setting['db']['user'], $new_setting['db']['pass'], $new_setting['db']['pconnect'], $new_setting['db']['charset'], $new_setting['gen']['charset'], $new_setting['gen']['gzip_level'], $new_setting['gen']['cache'], $new_setting['gen']['cache_ext'], $new_setting['gen']['timezone'], $new_setting['gen']['update'], $new_setting['gen']['minify'], $new_setting['gen']['etag'], $new_setting['cookie']['path'], $new_setting['cookie']['prefix'], $new_setting['watermark']['position'], $new_setting['watermark']['img_rate'], $new_setting['watermark']['txt_font'], $new_setting['watermark']['txt_fontsize'], $new_setting['watermark']['txt_fontcolor'], $new_setting['watermark']['txt_bgcolor'], $new_setting['watermark']['alpha'], $new_setting['watermark']['credit'], $new_setting['rewrite'], $new_setting['email'], $new_setting['js'], $new_setting['list'], $new_setting['session'], $new_setting['path'], $new_setting['content'], $new_setting['memcache']); $result = <<<mystep <?php \$setting_sub = array(); /*--settings--*/ ?> mystep; $result = str_replace("/*--settings--*/", makeVarsCode($new_setting, '$setting_sub'), $result); WriteFile(ROOT_PATH . "/include/config_main.php", $result, "w"); } break; case 4: WriteFile("../include/install.lock", date("Y-m-d H:i:s")); $header = array(); $header['Referer'] = "http://" . $req->GetServer("HTTP_HOST"); $header['ms_sign'] = $setting['web']['sign']; $code = GetRemoteContent($setting['gen']['update'] . "/install.php?v=" . $ms_version['ver'] . "&cs=" . $setting['gen']['charset'] . "&email=" . urlencode($setting['web']['email']) . "&title=" . urlencode($setting['web']['title']), $header); break; default: break; } echo <<<mystep <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml"> <HEAD> \t<TITLE>MyStep 安装向导</TITLE> \t<META content="text/html; charset=gbk" http-equiv=Content-Type> \t<LINK rel=stylesheet type=text/css href="style.css" media=all>
$ip_list = explode("\n", $_POST['ip']); unset($_POST['ip'], $_POST['idx_org'], $_POST['keyword']); for ($i = 0, $m = count($ip_list); $i < $m; $i++) { if (strlen($ip_list[$i]) < 5) { continue; } $_POST['ip'] = $ip_list[$i]; $_POST['ip'] = str_replace("\n", "", $_POST['ip']); $_POST['count'] = 0; if (isset($ip_info[$_POST['ip']])) { $_POST['count'] = $ip_info[$_POST['ip']]; } $db->replace($setting['db']['pre'] . "se_detect", $_POST); } $content = "<?PHP\r\n\$agent = " . var_export($agent, true) . ";\t\t\t\r\n?>"; WriteFile("agent.php", $content, "wb"); } break; default: $goto_url = $setting['info']['self']; } if (!empty($log_info)) { write_log($log_info, "idx=" . $idx); $goto_url = $setting['info']['self']; } $mystep->pageEnd(false); function build_page($method) { global $mystep, $req, $db, $setting, $idx, $agent; $tpl_info = array("idx" => "main", "style" => "../plugin/" . basename(realpath(dirname(__FILE__))) . "/tpl/", "path" => ROOT_PATH . "/" . $setting['path']['template']); $tpl = $mystep->getInstance("MyTpl", $tpl_info);
$para_new["rewrite"][] = array($_POST['rule'][$i], $_POST['jump'][$i]); } changeSetting($setting_new, $para_new); if (!empty($_POST['rule_new'])) { if ($_POST['write_type'] == "IIS7") { if (is_file(ROOT_PATH . "/web.config")) { $iis_setting = GetFile(ROOT_PATH . "/web.config"); if (preg_match("/<rewrite>.+<\\/rewrite>/ism", $iis_setting, $match)) { $iis_setting = str_replace($match[0], $_POST['rule_new'], $iis_setting); } else { $iis_setting = str_replace("</system.webServer>", $_POST['rule_new'] . "</system.webServer>", $iis_setting); } WriteFile(ROOT_PATH . "/web.config", $iis_setting, "wb"); } } else { WriteFile(ROOT_PATH . "/.htaccess", $_POST['rule_new'], "wb"); } } } else { $tpl_info['idx'] = "web_rewrite"; $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info); $tpl_tmp->allow_script = true; $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_rewrite_title']); for ($i = 0, $m = count($rewrite_list); $i < $m; $i++) { $tpl_tmp->Set_Loop("rewrite", array("idx" => $i + 1, "rule" => $rewrite_list[$i][0], "jump" => $rewrite_list[$i][1])); } $tpl_tmp->Set_Variable('rewrite_1', $setting['rewrite']['enable'] ? "checked" : ""); $tpl_tmp->Set_Variable('rewrite_2', $setting['rewrite']['enable'] ? "" : "checked"); $tpl_tmp->Set_Variable('rewrite_read', $setting['rewrite']['read']); $tpl_tmp->Set_Variable('rewrite_list', $setting['rewrite']['list']); $tpl_tmp->Set_Variable('rewrite_tag', $setting['rewrite']['tag']);
function Save($strPage, $strWikiContent) { global $k_strExtension, $k_aConfig, $ChuOpen, $ChuWrite, $ChuClose; // Création du répertoire des pages $strPagePath = GetPagePath(); CreateDir($strPagePath); // Création du répertoire de la page $strPageDir = ComputePageDir($strPagePath, $strPage); CreateDir($strPageDir); if (file_exists($strPageDir . '/lock.txt')) { // Cette page est protégée ErrorUnableToWrite(); } // On enregistre le contenu du fichier $strDate = date('YmdHis'); $strSavePath = $strPageDir . '/' . $strDate . '.' . $k_strExtension; $file = $ChuOpen($strSavePath, 'w9'); if ($file === FALSE) { // Impossible d'ouvrir le fichier en écriture ErrorUnableToWrite(); } $ChuWrite($file, $strWikiContent); $ChuClose($file); @chmod($strSavePath, 0777); // On enregistre le fichier indiquant le dernier changement WriteFile(GetLatestDateFilePath($strPageDir), $strDate); }
CheckLogin(); $mydir = dir(dirname(__FILE__).'/journal/'); //开始把所有markdown生成HTML while($file = $mydir->read()) { //提取后缀名 $filearr = explode(".",$file); //注意,file是路径 $filetype = end($filearr); //删掉之前生成的 if($filetype==='htm') {@unlink(dirname(__FILE__).'/journal/'.$file);} //操作后缀名是md的 if($filetype==='md') {WriteFile(dirname(__FILE__).'/journal/'.$file,dirname(__FILE__).'/journal/'.$filearr[0].'.htm');} //把md文件对应的htm生成出来 } $mydir->close(); $mydir = dir(dirname(__FILE__).'/journal/'); //下面开始主页生成部分 @unlink(dirname(__FILE__).'/index.htm'); $index=""; while($file = $mydir->read()) { global $index; //提取后缀名 $filearr = explode(".",$file); //注意,file是路径 $filetype = end($filearr); //操作后缀名是htm的 if($filetype==='htm') {
function SaveCharData($id=false) { // モンスターは保存しない。 //if($this->monster) return false; if($id) { $dir = USER.$id; } else { if(!$this->user) return false; $dir = USER.$this->user; } // ユーザーが存在しない場合保存しない if(!file_exists($dir)) return false; if(isset($this->file)) $file = $this->file; else $file = $dir."/".$this->birth.".dat"; if(file_exists($file) && $this->fp) { //sleep(10);//ファイルロック確認用 WriteFileFP($this->fp,$this->DataSavingFormat()); $this->fpclose(); } else { WriteFile($file,$this->DataSavingFormat()); } }
public function setPlugin() { includeCache("plugin"); global $plugin_setting, $setting, $op_mode; $web_id = $setting['info']['web']['web_id']; $plugins = array(); if ($op_mode == true) { $plugins = $GLOBALS['plugin']; } else { $plugin_idx = ROOT_PATH . "/cache/plugin/" . $setting['info']['web']['idx'] . ".php"; if (file_exists($plugin_idx)) { include $plugin_idx; } else { $max_count = count($GLOBALS['plugin']); for ($i = 0; $i < $max_count; $i++) { if ($GLOBALS['plugin'][$i]['subweb'] == "" || strpos($GLOBALS['plugin'][$i]['subweb'], "," . $web_id . ",") !== false) { $plugins[] = $GLOBALS['plugin'][$i]; } } $result = var_export($plugins, true); $result = <<<mystep <?php \$plugins = {$result}; ?> mystep; WriteFile($plugin_idx, $result, "w"); } } $mystep = $this; $plugin_setting = array(); $max_count = count($plugins); for ($i = 0; $i < $max_count; $i++) { if ($plugins[$i]['active'] == '1') { $curPlugin = ROOT_PATH . "/plugin/" . $plugins[$i]['idx'] . "/config.php"; if (is_file($curPlugin)) { include $curPlugin; } $curPlugin = ROOT_PATH . "/plugin/" . $plugins[$i]['idx'] . "/index.php"; if (is_file($curPlugin)) { include $curPlugin; } } } return; }
<?php $id = $req->getGet("id"); $agent = strtolower($req->getServer('HTTP_USER_AGENT')); if (is_numeric($id) && strpos($agent, "spider") === false && strpos($agent, "bot") === false) { $goto_url = $db->result($setting['db']['pre'] . "ad_show", "ad_url", array("id", "n=", $id)); if (!empty($goto_url)) { $if_click = $req->getCookie("img_click_" . $id); if (!empty($if_click)) { $new_ip = 0; } else { $req->setCookie("img_click_" . $id, "Y", 3600 * 24); WriteFile(dirname(__FILE__) . "/ipdata/{$id}.csv", "click," . GetIp() . "," . date("Y-m-d H:i:s") . "\n", "ab"); $new_ip = 1; } $db->update($setting['db']['pre'] . "ad_show", array("click" => "+1", "ip_click" => "+" . $new_ip), array("id", "n=", $id)); } else { $goto_url = "/"; } } else { $goto_url = "/"; } $mystep->pageEnd();
function checkFile($dir = "", $layer = 0, $check = "") { global $file_list, $file_list_md5; if ($layer == 0) { $file_list = array(); $file_list_md5 = array(); } $the_file = ROOT_PATH . "/cache/checkfile.php"; if (empty($dir)) { $dir = ROOT_PATH; } if (($handle = opendir($dir)) === false) { return false; } $ignore = array(); if (is_file($dir . "/ignore")) { $ignore = file_get_contents($dir . "/ignore"); if (strlen($ignore) == 0) { return; } $ignore = str_replace("\r", "", $ignore); $ignore = explode("\n", $ignore); } if ($check != "") { if (file_exists(ROOT_PATH . "/update/")) { $cs_list = array("GBK", "UTF-8", "BIG5"); $charset = $GLOBALS['setting']['gen']['charset']; global $file_list_md5_ext; if ($layer == 0) { $file_list_md5_ext = array(); foreach ($cs_list as $item) { $item = strtoupper($item); $file_list_md5_ext[$item] = array(); } } } while (false !== ($file = readdir($handle))) { if (trim($file, ".") == "" || $file == "ignore" || array_search($file, $ignore) !== false) { continue; } $the_name = $dir . "/" . $file; if ($the_name == $the_file) { continue; } if (is_dir($the_name)) { checkFile($the_name, $layer + 1, "y"); } else { $file_list[] = str_replace(ROOT_PATH, "", $the_name); $file_list_md5[] = md5_file($the_name); if (isset($cs_list, $file_list_md5_ext)) { foreach ($cs_list as $item) { $item = strtoupper($item); $file_list_md5_ext[$item][] = md5_file_cs($the_name, $item, $charset); } } } } if ($layer == 0) { $content = '<?php $file_list = ' . var_export($file_list, true) . '; $file_list_md5 = ' . var_export($file_list_md5, true) . '; ' . (isset($file_list_md5_ext) ? '$file_list_md5_ext = ' . var_export($file_list_md5_ext, true) : '') . ' ?>'; WriteFile($the_file, $content, "wb"); } $result = true; } else { if ($layer == 0) { if (!is_file($the_file)) { return false; } include $the_file; } $result = array("new" => array(), "mod" => array(), "miss" => array()); while (false !== ($file = readdir($handle))) { if (trim($file, ".") == "" || $file == "ignore" || array_search($file, $ignore) !== false) { continue; } $the_name = $dir . "/" . $file; if ($the_name == $the_file || $the_name == $the_file . ".bak") { continue; } if (is_dir($the_name)) { $result_new = checkFile($the_name, $layer + 1); if ($result_new == null) { continue; } $result['new'] = array_merge($result['new'], $result_new['new']); $result['mod'] = array_merge($result['mod'], $result_new['mod']); $result['miss'] = array_merge($result['miss'], $result_new['miss']); } else { $the_name = str_replace(ROOT_PATH, "", $the_name); if (strpos($the_name, "/config.php") !== false) { continue; } if (strpos($the_name, "/template") === 0 && stripos($the_name, ".php") === false) { continue; } if (strpos($the_name, "/images") === 0 && stripos($the_name, ".php") === false) { continue; } if (strpos($the_name, "/plugin/") === 0) { if (strpos(str_replace("/plugin/", "", $the_name), "/") !== false && strpos($the_name, "/plugin/offical/") !== 0) { continue; } } if (false !== ($key = array_search($the_name, $file_list))) { if (md5_file(ROOT_PATH . $the_name) != $file_list_md5[$key]) { $result['mod'][] = $the_name; } unset($file_list[$key]); } else { $result['new'][] = $the_name; } } } if ($layer == 0) { foreach ($file_list as $the_name) { if (strpos($the_name, "/config.php") !== false) { continue; } if (strpos($the_name, "/template") === 0 && stripos($the_name, ".php") === false) { continue; } if (strpos($the_name, "/images") === 0 && stripos($the_name, ".php") === false) { continue; } if (strpos($the_name, "/plugin/") === 0) { if (strpos(str_replace("/plugin/", "", $the_name), "/") !== false && strpos($the_name, "/plugin/offical/") !== 0) { continue; } } $result['miss'][] = $the_name; } } } closedir($handle); return $result; }
public static function page_start() { if (checkSign(255)) { return; } global $db, $setting; $plugin_setting = self::setting(); include dirname(__FILE__) . "/agent.php"; $agent_cur = strtolower($_SERVER['HTTP_USER_AGENT']); $ip = getIp(); if (strpos($ip, ",") > 0) { $ip = substr($ip, 0, strrpos($ip, ",")); } $ip2 = substr($ip, 0, strrpos($ip, ".")) . ".*"; $GLOBALS['se_bot'] = ""; foreach ($agent as $key => $value) { if (strpos($agent_cur, strtolower($value)) !== false) { if ($record = $db->record($setting['db']['pre'] . "se_detect", "*", array(array("ip", "=", $ip), array("ip", "=", $ip2, "or")))) { $record['count'] += 1; } else { $record = array(); $record['idx'] = $key; $record['ip'] = $ip; $record['count'] = 1; } $db->replace($setting['db']['pre'] . "se_detect", $record); $theDate = date("Y-m-d"); if ($record = $db->record($setting['db']['pre'] . "se_count", "*", array("date", "=", $theDate))) { $record[$key] += 1; } else { $record = array(); $record['date'] = $theDate; $record[$key] = 1; } $db->replace($setting['db']['pre'] . "se_count", $record); if (strpos($plugin_setting['ban'], $key) !== false) { header("HTTP/1.1 404 Not Found"); exit; } $GLOBALS['se_bot'] = $key; break; } } if (empty($GLOBALS['se_bot']) && (strpos($agent_cur, "spider") !== false || strpos($agent_cur, "bot") !== false)) { $theDate = date("Y-m-d"); if ($record = $db->record($setting['db']['pre'] . "se_count", "*", array("date", "=", $theDate))) { if (isset($record[$setting['language']['etc']])) { $record[$setting['language']['etc']] += 1; } } else { $record = array(); $record['date'] = $theDate; $record[$setting['language']['etc']] = 1; } $db->replace($setting['db']['pre'] . "se_count", $record); WriteFile(dirname(__FILE__) . "/agent.txt", $agent_cur . "\n"); } return; }
function bbs01() { if (!BBS_BOTTOM_TOGGLE) { return false; } $file = BBS_BOTTOM; ?> <div style="margin:15px"> <h4>one line bbs</h4> 错误报告或意见,对这里的开发建议 <form action="?bbs" method="post"> <input type="text" maxlength="60" name="message" class="text" style="width:300px"/> <input type="submit" value="post" class="btn" style="width:100px" /> </form> <?php if (!file_exists($file)) { return false; } $log = file($file); if ($_POST["message"] && strlen($_POST["message"]) < 121) { $_POST["message"] = htmlspecialchars($_POST["message"], ENT_QUOTES); $_POST["message"] = stripslashes($_POST["message"]); $name = $this->name ? "<span class=\"bold\">{$this->name}</span>" : "无名"; $message = $name . " > " . $_POST["message"]; if ($this->UserColor) { $message = "<span style=\"color:{$this->UserColor}\">" . $message . "</span>"; } $message .= " <span class=\"light\">(" . date("Mj G:i") . ")</span>\n"; array_unshift($log, $message); while (150 < count($log)) { // ログ保存行数あ array_pop($log); } WriteFile($file, implode(null, $log)); } foreach ($log as $mes) { print nl2br($mes); } print '</div>'; }
break; case "add_ok": case "edit_ok": if (count($_POST) > 0) { $log_info = $setting['language']['admin_web_template_edit']; if ($_POST['file_name'] == "style.css") { $the_file = ROOT_PATH . "/images/" . $idx . "/style.css"; } else { $ext = GetFileExt($_POST['file_name']); if ($ext != "tpl") { $_POST['file_name'] .= ".tpl"; } $the_file = $tpl_path . $idx . "/" . $_POST['file_name']; } $_POST['file_content'] = str_replace(" ", "\t", $_POST['file_content']); WriteFile($the_file, $_POST['file_content'], "wb"); } break; default: build_page("show"); } if (!empty($log_info)) { write_log($log_info, "idx={$idx}"); $goto_url = $setting['info']['self']; if (!empty($idx)) { $goto_url .= "?idx=" . $idx; } } $mystep->pageEnd(false); function build_page($method = "") {
$_POST['topic_cat'] = str_replace("£¬", ",", $_POST['topic_cat']); $tpl_content = $_POST['topic_tpl']; unset($_POST['topic_tpl']); $tpl_content = str_replace(" ", " ", $tpl_content); if ($method == "add_ok") { $log_info = $setting['language']['plugin_topic_add']; $_POST['add_date'] = "now()"; $db->insert($setting['db']['pre'] . "topic", $_POST, true); $top_id = $db->GetInsertId(); } else { $log_info = $setting['language']['plugin_topic_edit']; $top_id = $_POST['topic_id']; unset($_POST['topic_id']); $db->update($setting['db']['pre'] . "topic", $_POST, array("topic_id", "n=", $topic_id)); } WriteFile("topic/" . $top_id . ".tpl", $tpl_content, "wb"); break; default: break; } if (!empty($log_info)) { write_log($log_info, "topic_id=" . $topic_id); if (empty($goto_url)) { $goto_url = $setting['info']['self']; } } $mystep->pageEnd(false); function build_page($method) { global $mystep, $req, $db, $mydb, $setting, $topic_id; $tpl_info = array("idx" => "main", "style" => "../plugin/" . basename(realpath(dirname(__FILE__))) . "/tpl/", "path" => ROOT_PATH . "/" . $setting['path']['template']);
$header = array('js' => 'Content-Type: application/x-javascript', 'css' => 'Content-Type: text/css', 'jpg' => 'Content-Type: image/jpg', 'gif' => 'Content-Type: image/gif', 'png' => 'Content-Type: image/png', 'jpeg' => 'Content-Type: image/jpeg', 'swf' => 'Content-Type: application/x-shockwave-flash'); if (isset($header[$type])) { header($header[$type]); } if (file_exists($cache_file) && filemtime($cache_file) + $etag_expires > $setting['info']['time_start'] / 1000) { $result = GetFile($cache_file); } else { switch ($type) { case "css": $css = $mystep->getCSS(); for ($i = 0, $m = count($css); $i < $m; $i++) { $result .= CSSMin::minify(GetFile($css[$i])); } break; case "js": $js = $mystep->getJS(); for ($i = 0, $m = count($js); $i < $m; $i++) { $result .= JSMin::minify(GetFile($js[$i])); } break; default: break; } if (!empty($result)) { WriteFile($cache_file, $result, "wb"); } } header("Accept-Ranges: bytes"); header("Accept-Length: " . strlen($result)); echo $result; $mystep->pageEnd(false);
public static function sess_write($sid, $sess_data) { global $setting; return WriteFile($setting['session']['path'] . "/sess_" . $sid, $sess_data, "w"); }
unset($_POST['setting']); $result = <<<mystep <?php \$setting_sub = array(); /*--settings--*/ ?> mystep; $result = str_replace("/*--settings--*/", makeVarsCode($new_setting, '$setting_sub'), $result); if ($method == "add_ok" && ($setting['db']['name'] != $new_setting['db']['name'] || $setting['db']['pre'] != $new_setting['db']['pre'])) { $strFind = array("{db_name}", "{pre}", "{charset}", "{host}", "{idx}"); $strReplace = array($new_setting['db']['name'], $new_setting['db']['pre'], $setting['db']['charset'], $_POST['host'], $_POST['idx']); $info = $db->ExeSqlFile("subweb.sql", $strFind, $strReplace); } $db->SelectDB($setting['db']['name']); WriteFile(ROOT_PATH . "/include/config_" . $_POST['idx'] . ".php", $result, "w"); $db->replace($setting['db']['pre'] . "website", $_POST); deleteCache("website"); } break; default: build_page("list"); } if (!empty($log_info)) { write_log($log_info, "web_id={$web_id}"); $goto_url = $setting['info']['self']; } $mystep->pageEnd(false); function build_page($method) { global $mystep, $req, $db, $tpl, $web_id, $tpl_info, $website, $setting;
if (!empty($record['url'])) { if (strpos($record['url'], $setting['web']['url']) !== false && !is_numeric($q_str)) { $record['url'] .= (strpos($record['url'], "?") ? "&" : "?") . $q_str; } if ($fp = @fopen($record['url'], "r")) { $buffer = fgets($fp, 4096); fclose($fp); } } unset($record); } $db->Free(); sleep($interval); } if ($flag) { WriteFile($file_log, "Mission Stop at " . date("Y-m-d H:i:s") . "\n", "ab"); } echo "Mission Stop at " . date("Y-m-d H:i:s") . "<br />\n"; file_put_contents($file_status, ""); sleep($interval); if (!empty($goto_url)) { if ($fp = @fopen($goto_url, "r")) { $buffer = fgets($fp, 4096); $buffer .= fgets($fp, 4096); fclose($fp); } } $goto_url = ""; $mystep->pageEnd(false); function getNextTime($mode, $schedule) {
} } } } } } } } } } } } //echo $output; //echo CreateOpfFile($manifest_pages); WriteFile('epub/content.opf', CreateOpfFile($manifest_pages)); WriteFile('epub/toc.ncx', CreateTocFile($navmap, $spine)); function tag($tag, $array) { if (is_array($array)) { return array_map(function ($item) use($tag) { return '<' . $tag . '>' . $item . '</' . $tag . '>'; }, $array); } else { return "<{$tag}>\n{$array}\n</{$tag}>"; } } function CreateOpfFile($manifest_pages) { $opf = <<<OPF <?xml version='1.0' encoding='utf-8'?> <package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id" version="2.0">