function upexpsave() { global $db; $str = file_get_contents($_FILES['file1']['tmp_name']); $labelRule = buildregx("<(p_[\\s\\S]*?)>(.*?)</(p_[\\s\\S]*?)>", "is"); preg_match_all($labelRule, $str, $iar); $arlen = count($iar[1]); $in1 = ""; $in2 = ""; $rc = false; for ($m = 0; $m < $arlen; $m++) { if ($iar[1][$m] != "p_id") { if ($rc) { $in1 .= ","; $in2 .= ","; } $in1 .= $iar[1][$m]; $in2 .= "'" . replaceStr($iar[2][$m], "'", "\\'") . "'"; $rc = true; } } $sql = "insert into {pre}cj_art_projects (" . $in1 . ") values(" . $in2 . ")"; $status = $db->query($sql); if ($status) { showmsg("导入规则成功!", "collect_art_manage.php"); } else { alert("导入失败,请检查规则是否正确!"); } }
for ($i = 1; $i <= $pagesize; $i++) { $sql = 'SELECT d_id,d_name,d_enname,d_type,d_addtime,d_time,d_content FROM {pre}vod WHERE d_hide=0 and d_type >0 ORDER BY d_time DESC '; $sql .= 'limit ' . $num * ($i - 1) . ',' . $num; $labelRule = buildregx("{maccms:vod([\\s\\S]*?)}([\\s\\S]*?){/maccms:vod}", ""); preg_match_all($labelRule, $tpl->H, $matches1); $markhtml = ''; $n = 0; for ($j = 0; $j < count($matches1[0]); $j++) { $markval = $matches1[0][$j]; $markpar = $matches1[1][$j]; $markdes = $matches1[2][$j]; $rs = $db->query($sql); if (!$rs) { $markhtml = ''; } else { $labelRule = buildregx("\\[vod:\\s*([0-9a-zA-Z]+)([\\s]*[len|style]*)[=]??([\\da-zA-Z\\-\\\\/\\:\\s]*)\\]", ""); preg_match_all($labelRule, $markdes, $matches2); while ($row = $db->fetch_array($rs)) { $n++; $marktemp = $markdes; for ($k = 0; $k < count($matches2[0]); $k++) { $marktemp = $tpl->parse("vod", $marktemp, $matches2[0][$k], $matches2[1][$k], $matches2[3][$k], $row, $n); } $markhtml .= $marktemp; } } unset($rs); } unset($matches2); unset($matches1); if ($i > 1) {
function replaceArt() { $id = $this->D['a_id']; $name = $this->D['a_name']; $slink = $this->getLink('art', 'detail', $typearr, $this->D); $this->H = str_replace(array('[art:hits]', '[art:fav]', '[art:share]', '[art:desktop]', '[art:digg]', '[art:comment]'), array('<em id="hits">加载中</em><script>MAC.Hits("art","' . $id . '")</script>', '<a target="_self" href="javascript:void(0)" onclick=\'MAC.Fav(document.URL,document.title);return false;\'>我要收藏</a>', '<a target="_self" href="javascript:void(0)" onclick=\'MAC.Copy(document.title+" " +document.URL);return false;\'>我要分享</a>', '<a target="_self" href="javascript:void(0)" onclick=\'MAC.Desktop("' . $this->D['a_name'] . '");return false;\'>保存到桌面</a>', '<div class="digg_artup" onmouseout="this.style.backgroundPosition=\'-189px 0\'" onmouseover="this.style.backgroundPosition=\'0 0\'"><div class="digg_bar"><div id="digg_artup_img"></div></div><span id="digg_artup_num"><span id="digg_artup_sp">0%</span> (<span id="digg_artup_val">0</span>)</span></div><div class="digg_artdown" onmouseout="this.style.backgroundPosition=\'-378px 0\'" onmouseover="this.style.backgroundPosition=\'-567px 0\'"><div class="digg_bar"><div id="digg_artdown_img"></div></div><span id="digg_artdown_num"><span id="digg_artdown_sp">0%</span> (<span id="digg_artdown_val">0</span>)</span></div>', '<div id="comment" class="comment">评论加载中...</div>'), $this->H); if (strpos($this->H, "[art:textlink]")) { $this->H = str_replace("[art:textlink]", $this->getTypeText("art") . " » <a href='" . $slink . "'>" . $this->D["a_name"] . "</a>", $this->H); } if (strpos($this->H, "[art:prelink]")) { $this->H = str_replace("[art:prelink]", $this->getPreNextLink('art', $this->D["a_id"], 0), $this->H); } if (strpos($this->H, "[art:nextlink]")) { $this->H = str_replace("[art:nextlink]", $this->getPreNextLink('art', $this->D["a_id"], 1), $this->H); } $labelRule = buildregx("\\[art:\\s*([0-9a-zA-Z]+)([\\s]*[len|style]*)[=]??([\\da-zA-Z\\-\\\\/\\:\\s]*)\\]", ""); preg_match_all($labelRule, $this->H, $matches2); for ($j = 0; $j < count($matches2[0]); $j++) { $marktemp = $this->parse("art", $matches2[0][$j], $matches2[0][$j], $matches2[1][$j], $matches2[3][$j], $this->D, 0); $this->H = str_replace($matches2[0][$j], $marktemp, $this->H); } unset($matches2); }
function loadart($row, $typearr) { global $cache, $mac; //if (!is_array($this->page_typearr)){ $this->page_typearr = getValueByArray($cache[1], "t_id", $mac["arttypeid"]); } $this->page_typearr = $typearr; $mac["arttypepid"] = $this->page_typearr["t_pid"]; $cacheName = "art_" . $mac["arttypeid"]; $cachetemplatename = "template_art"; $templatepath = root . "template/" . app_templatedir . "/" . app_htmldir . "/" . $this->page_typearr["t_arttemplate"]; if (chkCache($cacheName)) { $this->html = getCache($cacheName); } else { $this->html = getFileByCache($cachetemplatename, $templatepath); setCache($cacheName, $this->html, 0); } $this->html = replaceStr($this->html, "[artinfo:page]", $mac["page"]); $this->page_type = "art"; $contentarr = explode("[artinfo:page]", $row["a_content"]); if ($mac["page"] <= count($contentarr)) { $this->page_content = $contentarr[$mac["page"] - 1]; } $this->page = $mac["page"]; $this->page_id = $row["a_id"]; $this->page_name = $row["a_title"]; $this->page_enname = $row["a_entitle"]; $this->page_size = 1; $this->data_count = count($contentarr); $this->page_count = count($contentarr); $this->pageshow(); unset($contentarr); $slink = $this->getArtLink($row["a_id"], $row["a_title"], $row["a_entitle"], $this->page_typearr["t_id"], $this->page_typearr["t_name"], $this->page_typearr["t_enname"], true); $this->html = replaceStr($this->html, "[artinfo:hits]", "<span id=\"hit\">加载中</span><script>getHit('art','" . $row["a_id"] . "')</script>"); $this->html = replaceStr($this->html, "[artinfo:fav]", "<a href=\"javascript:void(0)\" onclick=\"sitefav('http://" . app_siteurl . $slink . "','" . $row["a_title"] . "');return false;\"/>我要收藏</a>"); $this->html = replaceStr($this->html, "[artinfo:share]", "<a href=\"javascript:void(0)\" onclick=\"copyData(document.title +' ' + window.location.href);return false;\"/>我要分享</a>"); if (indexOf($this->html, "[artinfo:textlink]")) { $typeLink = $this->getArtTypeLink($this->page_typearr["t_id"], $this->page_typearr["t_name"], $this->page_typearr["t_enname"], true); $this->html = replaceStr($this->html, "[artinfo:textlink]", $this->getTypeText($mac["arttypeid"], $this->page_typearr["t_pid"], $this->page_typearr["t_name"], $typeLink, "art") . " » <a href='" . $slink . "'>" . $row["a_title"] . "</a>"); } if (indexOf($this->html, "[artinfo:prelink]")) { $this->html = replaceStr($this->html, "[artinfo:prelink]", $this->getArtPreNextLink($row["a_id"], 0)); } if (indexOf($this->html, "[artinfo:nextlink]")) { $this->html = replaceStr($this->html, "[artinfo:nextlink]", $this->getArtPreNextLink($row["a_id"], 1)); } $this->replaceComment(2, $row["a_id"]); $this->replaceMood(2, $row["a_id"]); $labelRule = buildregx("\\[artinfo:\\s*([0-9a-zA-Z]+)([\\s]*[len|style]*)[=]??([\\da-zA-Z\\-\\\\/\\:\\s]*)\\]", ""); preg_match_all($labelRule, $this->html, $matches2); for ($j = 0; $j < count($matches2[0]); $j++) { $marktemp = $this->parse("art", $matches2[0][$j], $matches2[0][$j], $matches2[1][$j], $matches2[3][$j], $row, 0); $this->html = replaceStr($this->html, $matches2[0][$j], $marktemp); } unset($matches2); $this->mark(); $this->ifEx(); $this->run(); }
if ($nums > 0) { $pagecount = ceil($nums / 20); echo "<font color=red>共" . $nums . "条数据需要同步,每次同步20个数据,正在开始同步第" . $pagecount . "页数据的的图片</font><br>"; ob_flush(); flush(); $sql = "SELECT a_id,a_content FROM {pre}art WHERE a_content LIKE '<img%src=\"http%://%' " . $where; $sql .= " limit " . ($pagecount - 1) . ",20"; $rs = $db->query($sql); $num = 0; while ($row = $db->fetch_array($rs)) { $colarr = array(); $valarr = array(); $a_id = $row['a_id']; $a_content = $row["a_content"]; $status = false; $rule = buildregx("<img[^>]*src\\s*=\\s*['" . chr(34) . "]?([\\w/\\-\\:.]*)['" . chr(34) . "]?[^>]*>", "is"); preg_match_all($rule, $a_content, $matches); $matchfieldarr = $matches[1]; $matchfieldstrarr = $matches[0]; $matchfieldvalue = ""; foreach ($matchfieldarr as $f => $matchfieldstr) { $matchfieldvalue = $matchfieldstrarr[$f]; $a_pic = trim(preg_replace("/[ \r\n\t\f]{1,}/", " ", $matchfieldstr)); $st = strrpos($a_pic, '/'); $fname = substring($a_pic, strlen($a_pic) - $st, $st + 1); $path = "upload/art/" . getSavePicPath('art') . "/"; $thumbpath = ""; $ps = savepic($a_pic, $path, $thumbpath, $fname, 'art', $msg); if ($ps) { $a_content = str_replace($a_pic, $GLOBALS['MAC']['site']['installdir'] . $path . $fname, $a_content); } else {
function getArray($strBody, $strStart, $strEnd) { $strStart = stripslashes($strStart); $strEnd = stripslashes($strEnd); if (isN($strBody)) { return false; } if (isN($strStart)) { return false; } if (isN($strEnd)) { return false; } $strStart = str_replace("(", "\\(", $strStart); $strStart = str_replace(")", "\\)", $strStart); $strStart = str_replace("'", "\\'", $strStart); $strStart = str_replace("?", "\\?", $strStart); $strEnd = str_replace("(", "\\(", $strStart); $strEnd = str_replace(")", "\\)", $strStart); $strEnd = str_replace("'", "\\'", $strStart); $strEnd = str_replace("?", "\\?", $strStart); $labelRule = $strStart . "(.*?)" . $strEnd; $labelRule = buildregx($labelRule, "is"); preg_match_all($labelRule, $strBody, $tmparr); $tmparrlen = count($tmparr[1]); $rc = false; for ($i = 0; $i < $tmparrlen; $i++) { if ($rc) { $str .= "{Array}"; } $str .= $tmparr[1][$i]; $rc = true; } if (isN($str)) { return false; } $str = str_replace($strStart, "", $str); $str = str_replace($strEnd, "", $str); $str = str_replace("\"\"", "", $str); $str = str_replace("'", "", $str); $str = str_replace(" ", "", $str); if (isN($str)) { return false; } return $str; }
$valarr = array($status, $sort, $from, $show, $des, $tip); for ($i = 0; $i < count($colarr); $i++) { $n = $colarr[$i]; $v = $valarr[$i]; $plt->set_var($n, $v); } $plt->parse('rows_' . $rn, 'list_' . $rn, true); } unset($xmlnode); unset($nodes); unset($doc); unset($colarr); unset($valarr); } elseif ($method == 'playerup') { $s = file_get_contents($_FILES['file1']['tmp_name']); $labelRule = buildregx('<([\\s\\S]+?)>([\\s\\S]+?)</\\1>', ""); preg_match_all($labelRule, $s, $iar); $arlen = count($iar[1]); for ($m = 0; $m < $arlen; $m++) { $play[$iar[1][$m]] = $iar[2][$m]; } unset($iar); if ($play['from'] != '') { $xp = '../inc/config/vodplay.xml'; $doc = new DOMDocument(); $doc->formatOutput = true; $doc->load($xp); $xmlnode = $doc->documentElement; $nodes = $xmlnode->getElementsByTagName('play'); $flag = 'add'; foreach ($nodes as $node) {
function syncartpic() { global $db; $ids = be("get", "ids"); $sql = "SELECT count(a_id) FROM {pre}art WHERE a_content LIKE '%src=\"http://%' "; if (!isN($ids)) { $where = " and a_id not in (" . $ids . ") "; } else { $ids = "0"; } $nums = $db->getOne($sql . $where); if ($nums > 0) { $page = be("get", "page"); if (isN($page)) { $page = 1; } else { $page = intval($page); } $sql = "SELECT a_id,a_content FROM {pre}art WHERE a_content LIKE '%src=\"http://%' " . $where; $pagecount = ceil($nums / 20); $sql .= " limit " . ($pagecount - 1) . ",20"; $rs = $db->query($sql); echo "<font color=red>共" . $nums . "条数据需要同步下载,每次同步20个数据,正在开始同步第" . $pagecount . "页数据的的图片</font><br>"; $num = 0; while ($row = $db->fetch_array($rs)) { $a_content = $row["a_content"]; $status = false; $rule = buildregx("<img[^>]*src\\s*=\\s*['" . chr(34) . "]?([\\w/\\-\\:.]*)['" . chr(34) . "]?[^>]*>", "is"); preg_match_all($rule, $a_content, $matches); $matchfieldarr = $matches[1]; $matchfieldstrarr = $matches[0]; $matchfieldvalue = ""; foreach ($matchfieldarr as $f => $matchfieldstr) { $matchfieldvalue = $matchfieldstrarr[$f]; $a_pic = trim(preg_replace("/[ \r\n\t\f]{1,}/", " ", $matchfieldstr)); $picname = time() . $num; if (strpos($a_pic, ".jpg") || strpos($a_pic, ".bmp") || strpos($a_pic, ".png") || strpos($a_pic, ".gif")) { $extName = substring($a_pic, 4, strlen($a_pic) - 4); } else { $extName = ".jpg"; } $picpath = "../upload/art" . "/" . getSavePicPath() . "/"; $picpath = replaceStr($picpath, "///", "/"); $picpath = replaceStr($picpath, "//", "/"); if (!is_dir($picpath)) { mkdir($picpath); } $picfile = $picname . $extName; $status = savepic($a_pic, $picpath, $picfile); if ($status) { $a_content = replaceStr($a_content, $a_pic, replaceStr($picpath . $picfile, "../", app_installdir)); } else { $a_content = replaceStr($a_content, $a_pic, ""); } } $num++; $db->query("UPDATE {pre}art set a_content='" . $a_content . "' where a_id='" . $row["a_id"] . "'"); } echo "<br><font color=red>暂停5秒后继续同步图片</font><br><script>setTimeout(\"updatenext();\",5000);function updatenext(){location.href='admin_pic.php?action=syncartpic&page=" . ($page + 1) . "&ids=" . $ids . "';}</script>"; } else { if ($ids != "0") { $des = "以下文章ID:" . substring($ids, strlen($ids) - 1, 2) . "的图片同步失败,请检查图片链接是否失效"; } else { $des = "恭喜,所有外部图片已经成功同步到本地!"; } alertUrl("{$des}", "admin_art.php"); } unset($rs); }