function snatchGetList($record, &$info) { global $db, $setting, $req; $idx = $req->getCookie("ns_idx"); if (empty($idx)) { $idx = 0; } for ($i = $idx, $m = count($info['newList']); $i < $m; $i++) { if (isset($info['para']['pre_max']) && $i - $idx >= $info['para']['pre_max']) { break; } $record['subject'] = $info['newList'][$i][1]; $record['original'] = "搜狐网"; $record['url'] = $info['newList'][$i][2]; $record['add_date'] = date("Y") . "/" . $info['newList'][$i][3]; $record['item_2'] = $info['newList'][$i][4]; if (strpos($record['url'], ".sohu.com") === false) { continue; } if ($content = GetRemoteContent($record['url'], $info['header'])) { if (preg_match("/来源:<span.+?>(.+?)<\\/span>/i", $content, $matches)) { $record['original'] = strip_tags($matches[1]); unset($matches); } if (preg_match("/<meta name=\"keywords\" content=\"(.+?)\">/i", $content, $matches)) { $record['item_3'] = str_replace(" ", ",", $matches[1]); unset($matches); } if (preg_match("/<meta name=\"description\" content=\"(.+?)\">/i", $content, $matches)) { $record['item_4'] = str_replace(" ", ",", $matches[1]); $record['item_4'] = substrPro($record['item_4'], 0, 230); unset($matches); } $flag = false; if (preg_match("/<\\!\\-\\- 正文 st \\-\\->[\r\n\\s]+<div.+?>(.+?)<\\/div>[\r\n\\s]+<\\!\\-\\- 正文 end \\-\\->/is", $content, $matches)) { $record['content'] = $matches[1]; $record['content'] = preg_replace("/<div class\\=\"tagIntg.+?<\\/div>/is", "", $record['content']); $record['content'] = preg_replace("/<div class\\=\"tagHotg.+?<\\/div>/is", "", $record['content']); $record['content'] = preg_replace("/<div class\\=\"editer.+?<\\/div>/is", "", $record['content']); unset($matches); $flag = true; } elseif (preg_match("/<div class\\=\"textcont\" id\\=\"textcont\">(.+?)<\\/div>/is", $content, $matches)) { $cur_content = array(); $cur_content[0] = $matches[1]; $cur_content[0] = preg_replace("/<p class\\=\"editUsr.+?<\\/p>/is", "", $cur_content[0]); $cur_content[0] = preg_replace("/<p>.+?<p>/is", "<p>", $cur_content[0]); $cur_content[0] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $cur_content[0]); $cur_content[0] = preg_replace("/^[\r\n\\s]+/is", "", $cur_content[0]); $cur_content[0] = preg_replace("/[\r\n\\s]+\$/is", "", $cur_content[0]); unset($matches); if (preg_match("/<img id\\=\"slide_pic\" src\\=\"(.+?)\" alt\\=\"(.+?)\".*?>/is", $content, $matches)) { $cur_content[0] = "<p>" . $matches[0] . "</p>\n" . $cur_content[0]; } unset($matches); if (preg_match("/<span id\\=\"pageNum\">1\\/(\\d+)<\\/span>/is", $content, $matches)) { $pages = $matches[1]; unset($matches); for ($n = 1; $n < $pages; $n++) { $cur_url = preg_replace("/(\\.\\w+)\$/i", "_" . $n . "\\1", $record['url']); if ($page_content = GetRemoteContent($cur_url, $info['header'])) { if (preg_match("/<div class\\=\"textcont\" id\\=\"textcont\">(.+?)<\\/div>/is", $page_content, $matches)) { $cur_content[$n] = $matches[1]; $cur_content[$n] = preg_replace("/<p class\\=\"editUsr.+?<\\/p>/is", "", $cur_content[$n]); $cur_content[$n] = preg_replace("/<p>.+?<p>/is", "<p>", $cur_content[$n]); $cur_content[$n] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $cur_content[$n]); $cur_content[$n] = preg_replace("/^[\r\n\\s]+/is", "", $cur_content[$n]); $cur_content[$n] = preg_replace("/[\r\n\\s]+\$/is", "", $cur_content[$n]); } unset($matches); if (preg_match("/<img id\\=\"slide_pic\" src\\=\"(.+?)\" alt\\=\"(.+?)\".*?>/is", $page_content, $matches)) { $cur_content[$n] = "<p>" . $matches[0] . "</p>\n" . $cur_content[$n]; } unset($matches); } } } $record['content'] = implode("<!-- pagebreak -->", $cur_content); $flag = true; } elseif (preg_match("/<div.+?id\\=\"contentText\">(.+?)<\\/div>/is", $content, $matches)) { $record['content'] = $matches[1]; $record['content'] = preg_replace("/<div class\\=\"editer.+?<\\/div>/is", "", $record['content']); $record['content'] = preg_replace("/<p>.+?<p>/is", "<p>", $record['content']); $record['content'] = preg_replace("/<\\/p>[\\s\r\n]+?<\\/p>/is", "</p>", $record['content']); $record['content'] = preg_replace("/^[\r\n\\s]+/is", "", $record['content']); $record['content'] = preg_replace("/[\r\n\\s]+\$/is", "", $record['content']); unset($matches); $flag = true; } elseif (preg_match("/<div id\\=\"news_c\".+?>(.+?)<div id\\=\"news_s\"/is", $content, $matches)) { $record['content'] = $matches[1]; unset($matches); $flag = true; } else { snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="failed" style="color:red;">失败!</span></div>'); } if ($flag) { if ($db->record($setting['db']['pre'] . "news_snatch", "id", array("url", "=", $record['url'])) === false) { $record['content'] = preg_replace("/<script.+?<\\/script>/is", "", $record['content']); $record['content'] = preg_replace("/<style.+?<\\/style>/is", "", $record['content']); $record['content'] = preg_replace("/<form.+?<\\/form>/is", "", $record['content']); $record['content'] = preg_replace("/<iframe.+?<\\/iframe>/is", "", $record['content']); $record['content'] = preg_replace("/^[\r\n\\s]+/is", "", $record['content']); $record['content'] = preg_replace("/[\r\n\\s]+\$/is", "", $record['content']); $record['content'] = preg_replace("/延伸阅读.+\$/", "", $record['content']); $record['content'] = preg_replace("/<DIV class\\=\"tvsubject.+\$/", "", $record['content']); $record['content'] = str_replace("微博推荐", "", $record['content']); $record['content'] = str_replace("我来纠错", "", $record['content']); $record['content'] = str_replace('<div class="line"></div>', "", $record['content']); $record['content'] = preg_replace("/<div class\\=\"stockTrends.+?<\\/div>/s", "", $record['content']); $record['content'] = preg_replace("/<div class\\=\"shareIn.+?<\\/div>/s", "", $record['content']); $record['content'] = preg_replace("/[\r\n]+<div class\\=\"muLink.+?<\\/div>[\r\n]+/", "", $record['content']); $record['content'] = preg_replace("/<DIV class\\=\"tvsubject.+\$/s", "", $record['content']); if (preg_match("/<img.+?src=(.?)(http.+?)\\1.+?>/is", $record['content'], $matches)) { $record['item_5'] = $matches[2]; } else { $record['item_5'] = ""; } if ($record['item_5'] == "http://images.sohu.com/ccc.gif" || $record['item_5'] == "http://photo.sohu.com/20040809/Img221437781.gif" || $record["item_5"] == "http://photocdn.sohu.com/20090828/dot.gif") { $record['item_5'] = ""; } snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="succeed" style="color:green;">成功!</span></div>'); $db->insert($setting['db']['pre'] . "news_snatch", $record); } else { snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> <span class="duplicate" style="color:black;">已存在!</span></div>'); } } } else { snatch_log('<div class="item">' . $info['counter']++ . ' - <a href="' . $record['url'] . '" target="_blank">' . $record['subject'] . '</a> 获取<span class="failed" style="color:red;">失败!</span></div>'); } $req->setCookie("ns_idx", $i, 86400); } if ($i >= $m) { $req->setCookie("ns_idx"); } return true; }
function GetFileUrl($url, $filename, $dir) { //chmod($dir, 777); $zip = GetRemoteContent($url . '&d=dd'); if ($zip == '') { return false; } $fp = @fopen($dir . '/' . $filename, 'w'); fwrite($fp, $zip); fclose($fp); return true; }
<?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> \t<META name=Copyright content="*****@*****.**"> \t<script language="JavaScript" src="../script/jquery.js"></script> \t<script language="JavaScript" src="../script/global.js"></script> \t<script language="JavaScript" src="../script/checkForm.js"></script>
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']); echo $check_info; break; } $mystep->pageEnd(false);
function build_page($method) { global $mystep, $req, $tpl, $tpl_info, $plugin, $setting, $idx, $plugin_path, $website; $tpl_info['idx'] = "web_plugin_" . $method; $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info); $tpl_tmp->allow_script = true; if ($method == "list") { if ($plugin_info = json_decode(GetRemoteContent($setting['gen']['update'] . "/plugin.php?l=" . $setting['gen']['language']))) { foreach ($plugin_info as $key => $value) { $update_info[$key] = array(); $update_info[$key]['idx'] = $key; $update_info[$key]['name'] = getString($value->name); $update_info[$key]['ver'] = $value->ver; $update_info[$key]['intro'] = getString($value->intro); } unset($plugin_info); } else { $update_info = array(); } $fso = $mystep->getInstance("MyFSO"); $plugin_list = $fso->Get_List($plugin_path); $max_count = count($plugin_list['dir']); $n = 0; for ($i = 0; $i < $max_count; $i++) { if (is_file($plugin_list['dir'][$i] . "/info.php")) { $info = array(); include $plugin_list['dir'][$i] . "/info.php"; $update_info_hash = array(); if (isset($info['update_url'])) { if (isset($update_info_hash[md5($info['update_url'])])) { $plugin_info_remote = $update_info_hash[md5($info['update_url'])]; } else { if ($plugin_info_remote = json_decode(GetRemoteContent($info['update_url'] . "/plugin.php?l=" . $setting['gen']['language']))) { $update_info_hash[md5($info['update_url'])] = $plugin_info_remote; } else { $plugin_info_remote = new stdClass(); } } if (isset($plugin_info_remote->{$info}['idx'])) { $update_info[$info['idx']] = array(); $update_info[$info['idx']]['idx'] = $info['idx']; $update_info[$info['idx']]['name'] = getString($plugin_info_remote->{$info}['idx']->name); $update_info[$info['idx']]['ver'] = $plugin_info_remote->{$info}['idx']->ver; $update_info[$info['idx']]['intro'] = getString($plugin_info_remote->{$info}['idx']->intro); } } if (isset($update_info[$info['idx']]) && $info['ver'] < $update_info[$info['idx']]['ver']) { $info['ver_new'] = $update_info[$info['idx']]['ver']; $info['update'] = ""; } else { $info['ver_new'] = ""; $info['update'] = "none"; } if ($plugin_info = getParaInfo("plugin", "idx", $info['idx'])) { $info['order'] = $plugin_info['order']; $info['active'] = $plugin_info['active'] ? $setting['language']['close'] : $setting['language']['open']; $tpl_tmp->Set_Loop("plugin_list_1", $info); } else { $n++; $tpl_tmp->Set_Loop("plugin_list_2", $info); } unset($update_info[$info['idx']]); } } foreach ($update_info as $key => $value) { $tpl_tmp->Set_Loop("plugin_list_3", $value); } $tpl_tmp->Set_If('empty_2', $n == 0); $tpl_tmp->Set_If('empty_3', count($update_info) == 0); $tpl_tmp->Set_Variable('self', $setting['info']['self']); $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_plugin_title']); global $db; $db->select($setting['db']['pre'] . "admin_cat", "file, count(*) as counter", array("file", "!=", "###"), array("group" => "file", "having" => array("counter", "n>", 1))); $dp_list = ""; while ($cur = $db->getRS()) { $dp_list .= $cur['file'] . " (" . $cur['counter'] . ")\\n"; } $tpl_tmp->Set_Variable('dp_list', $dp_list); } elseif ($method == "setting") { $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_plugin_setup']); $plugin_info = getParaInfo("plugin", "idx", $idx); include $plugin_path . $idx . "/info.php"; if ($plugin_info === false) { $tpl->Set_Variable('main', showInfo($setting['language']['admin_web_plugin_err'], 0)); $mystep->show($tpl); $mystep->pageEnd(false); } $max_count = count($website); for ($i = 0; $i < $max_count; $i++) { $tpl_tmp->Set_Loop('subweb', array("web_id" => $website[$i]['web_id'], "name" => $website[$i]['name'], "checked" => strpos($plugin_info['subweb'], "," . $website[$i]['web_id'] . ",") !== false ? "checked" : "")); } $info['description'] = nl2br($info['description']); $tpl_tmp->Set_Variable('idx', $plugin_info['idx']); $tpl_tmp->Set_Variable('name', $plugin_info['name']); $tpl_tmp->Set_Variable('subweb', $plugin_info['subweb']); $tpl_tmp->Set_Variable('description', $info['description']); $tpl_tmp->Set_Variable('back_url', $req->getServer("HTTP_REFERER")); } elseif ($method == "upload") { global $script; $tpl_tmp->Set_Variable('script', $script); $tpl_tmp->Set_Variable('self', $setting['info']['self']); $Max_size = ini_get('upload_max_filesize'); $tpl_tmp->Set_Variable('Max_size', $Max_size); $tpl_tmp->Set_Variable('MaxSize', GetFileSize($Max_size)); } else { $tpl_tmp->Set_Variable('title', $setting['language']['admin_web_plugin_install']); include $plugin_path . $idx . "/info.php"; $info['description'] = nl2br($info['description']); $tpl_tmp->Set_Variables($info); $tpl_tmp->Set_Variable('back_url', $req->getServer("HTTP_REFERER")); $max_count = count($website); for ($i = 0; $i < $max_count; $i++) { $tpl_tmp->Set_Loop('subweb', array("web_id" => $website[$i]['web_id'], "name" => $website[$i]['name'], "checked" => "")); } include $plugin_path . $idx . "/class.php"; $check_info = call_user_func(array($info['class'], "check")); $color = "black"; $info = $check_info; if (empty($check_info)) { $color = "green"; $info = $setting['language']['admin_web_plugin_check_ok']; } $check_info = '<span style="color:' . $color . '">' . $info . '</span>'; $tpl_tmp->Set_Variable('check', $check_info); $tpl_tmp->Set_Variable('subweb', ""); } $tpl->Set_Variable('main', $tpl_tmp->Get_Content('$db, $setting, $idx')); unset($tpl_tmp); $mystep->show($tpl); return; }