array_push($colarr, 'd_area'); array_push($valarr, $d_area); } if (strpos(',' . $uprule, 'i')) { array_push($colarr, 'd_lang'); array_push($valarr, $d_lang); } if (strpos(',' . $uprule, 'j')) { if ($MAC['collect']['vod']['pic'] == 1) { $ext = @substr($d_pic, strlen($d_pic) - 3); if ($ext != 'jpg' || $ext != 'bmp' || $ext != 'gif') { $ext = 'jpg'; } $fname = time() . $i . '.' . $ext; $path = "upload/vod/" . getSavePicPath('') . "/"; $thumbpath = "upload/vodthumb/" . getSavePicPath('vodthumb') . "/"; $ps = savepic($d_pic, $path, $thumbpath, $fname, 'vod', $msg); if ($ps) { $d_pic = $path . $fname; $d_picthumb = $thumbpath . $fname; array_push($colarr, 'd_pic'); array_push($valarr, $d_pic); array_push($colarr, 'd_picthumb'); array_push($valarr, $d_picthumb); } } } if (strpos(',' . $uprule, 'k')) { array_push($colarr, 'd_content'); array_push($valarr, $d_content); }
function cjView($strlink, $num) { global $starringarr, $titlearr, $picarr, $strListUrl, $p_playspecialtype, $p_playtype, $p_videocodeType, $p_videocodeApiUrl, $p_id, $p_videocodeApiUrlParamstart, $p_videocodeApiUrlParamend, $p_videourlstart, $p_videourlend, $playcodeApiUrl, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend, $playcodeApiUrltype, $db, $strListUrl, $p_titletype, $starringarr, $titlearr, $picarr, $p_id, $p_titlestart, $p_titleend, $p_lzstart, $p_lzend, $p_hitsstart, $p_hitsend, $p_starringtype, $p_starringstart, $p_starringend, $p_picstart, $p_picend, $p_typestart, $p_typeend, $p_pictype, $p_classtype, $p_collect_type, $p_timestart, $p_timeend, $p_areastart, $p_areaend, $p_contentstart, $p_contentend, $p_playcodestart, $p_playcodeend, $p_playlinkstart, $p_playlinkend, $p_playurlstart, $p_playurlend, $p_playcodetype, $p_playlinktype, $p_playtype, $p_coding, $p_lzstart, $p_lzend, $p_lzcodetype, $p_lzcodestart, $p_lzcodeend, $p_languagestart, $p_languageend, $p_remarksstart, $p_remarksend, $p_script, $p_showtype, $p_savefiles, $strdstate, $p_server, $p_setnametype, $p_setnamestart, $p_setnameend, $p_directedstart, $p_directedend, $cache; $androidUrl = ""; //var_dump($strlink);var_dump($strListUrl); try { $pos = strpos($strlink, "href=\""); if ($pos !== false) { $strlink = substr($strlink, $pos + 6); } $pos = strpos($strlink, "\""); if ($pos !== false) { $strlink = substr($strlink, 0, $pos); } } catch (Exception $e) { } $strlink = definiteUrl($strlink, $strListUrl); writetofile("crawel_auto_info.log", $p_id . '{=====}' . $strlink . "{=====}View===start"); $strViewCode = getPage($strlink, $p_coding); if ($strViewCode == false) { $strdstate = "true"; writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl); $sb = $sb + 1; return; } else { //节目名称,来自列表或者来自内容页 if ($p_titletype == 1) { $titlecode = $titlearr[$num]; } else { $titlecode = getBody($strViewCode, $p_titlestart, $p_titleend); } // var_dump($titlearr[$num]); $titlecode = filterScript($titlecode, $p_script); $titlecode = replaceFilters($titlecode, $p_id, 1, 0); $titlecode = replaceStr(replaceStr(replaceStr($titlecode, ",", " "), "'", ""), "\"\"", ""); $titlecode = trim($titlecode); // $sql="select count(*) as cc from {pre}cj_vod where m_name='".$titlecode."' and m_playfrom='".$p_playtype."'"; // $row=$db->getOne($sql); // //var_dump($row);var_dump($titlecode); // $rowcount = $row; //先缩小范围 if ($p_lzcodetype == 1) { //连载范围 $lzfwcode = getBody($strViewCode, $p_lzcodestart, $p_lzcodeend); //连载编码 $lzcode = getBody($lzfwcode, $p_lzstart, $p_lzend); $lzcode = replaceStr($lzcode, "false", "0"); $lzcode = trim($lzcode); $lzcode = intval($lzcode); } else { $lzcode = getBody($strViewCode, $p_lzstart, $p_lzend); $lzcode = replaceStr($lzcode, "false", "0"); $lzcode = trim($lzcode); $lzcode = intval($lzcode); } // if ($p_playcodetype !=2 &&($lzcode == 0) && ($rowcount>0)) { // $strdstate = "true"; // echo "<tr><td colspan=\"2\">遇到重复电影数据跳过采集!</TD></TR>"; // return; // } if (isN($p_hitsstart) || !isnum($p_hitsstart)) { $p_hitsstart = 0; } if (isN($p_hitsend) || !isnum($p_hitsend)) { $p_hitsend = 0; } if ($p_hitsstart == 0 && $p_hitsend == 0) { $m_hits = 0; } else { $m_hits = rand($p_hitsend, $p_hitsstart); } if ($p_starringtype == 1) { $starringcode = $starringarr[$num]; } else { $starringcode = getBody($strViewCode, $p_starringstart, $p_starringend); } //演员 $starringcode = filterScriptStar($starringcode, $p_script); $starringcode = replaceStr(replaceStr(replaceStr($starringcode, ",", " "), "'", ""), "\"\"", ""); $starringcode = trim($starringcode); if ($p_pictype == 1) { $piccode = $picarr[$num]; } else { $piccode = getBody($strViewCode, $p_picstart, $p_picend); } //图片 $piccode = trim($piccode); $piccode = getHrefFromImg(definiteUrl($piccode, $strListUrl)); //栏目设置 if ($p_classtype == 1) { $typecode = filterScript(getBody($strViewCode, $p_typestart, $p_typeend), $p_script); $typecode = trim($typecode); $m_typeid = changeId($typecode, $p_id, 0, 0); } else { $typecode = $p_collect_type; $typecode = trim($typecode); $m_typeid = $p_collect_type; $typearr = getValueByArray($cache[0], "t_id", $typecode); $typecode = $typearr["t_name"]; } if ($m_typeid == 0) { $m_typeid = $p_collect_type; } $typecode = filterScript($typecode, $p_script); //导演 $directedcode = filterScriptStar(getBody($strViewCode, $p_directedstart, $p_directedend), $p_script); $directedcode = replaceStr($directedcode, "false", ""); $directedcode = replaceStr($directedcode, "'", ""); $directedcode = trim($directedcode); //备注 $remarkscode = filterScript(getBody($strViewCode, $p_remarksstart, $p_remarksend), $p_script); $remarkscode = replaceStr($remarkscode, "false", ""); $remarkscode = trim($remarkscode); //语音 $languagecode = filterScript(getBody($strViewCode, $p_languagestart, $p_languageend), $p_script); $languagecode = replaceStr($languagecode, "false", "未知"); $languagecode = trim($languagecode); //时间 $timecode = filterScript(getBody($strViewCode, $p_timestart, $p_timeend), $p_script); if ($timecode == false) { $timecode == "未知"; } $timecode = trim($timecode); //地区 $areacode = filterScript(getBody($strViewCode, $p_areastart, $p_areaend), $p_script); if ($areacode == false) { $areacode = "未知"; } $areacode = trim($areacode); //内容 $contentcode = filterScript(getBody($strViewCode, $p_contentstart, $p_contentend), $p_script); if ($contentcode == false) { $contentcode = "未知"; } $contentcode = filterScript(replaceFilters($contentcode, $p_id, 2, 0), $p_script); $contentcode = replaceStr(replaceStr(replaceStr($contentcode, ",", " "), "'", ""), "\"\"", ""); $contentcode = trim($contentcode); $m_area = $areacode; $m_languageid = $languagecode; //播放列表,缩小 if ($p_playcodetype == 1) { $playcode = getBody($strViewCode, $p_playcodestart, $p_playcodeend); //获取地址设置 if ($p_playlinktype > 0) { //播放链接 $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend); } else { //内容页直接获取地址, 地址开始 $weburl = getArray($playcode, $p_playurlstart, $p_playurlend); } if ($p_setnametype == 3) { $setnames = getArray($playcode, $p_setnamestart, $p_setnameend); } } else { if ($p_playcodetype == 2) { //from api // writetofile("d:\\s.txt",$linkcode) ; // echo $p_playcodeApiUrlParamend .'=='.$playcodeApiUrlParamstart; // echo $playcodeApiUrlParamstart .'\n' .$p_playcodeApiUrlParamend .' = '.$playcodeApiUrltype; if ($playcodeApiUrltype == 0) { $paracode = getBody($strViewCode, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend); } else { $paracode = getBody($UrlTestMoive, $playcodeApiUrlParamstart, $p_playcodeApiUrlParamend); } // echo $paracode; $p_apibatchurl = replaceStr($playcodeApiUrl, "{PROD_ID}", $paracode); $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", 1); $playcode = getFormatPage($p_apibatchurls, $p_coding); $weburl = getArray($playcode, $p_playlinkstart, $p_playlinkend); $page_num = 2; // echo "page 1 :".$weburl .'\n'; $flag = true; while ($flag && $page_num < 15 && strpos($playcodeApiUrl, "{PAGE_NO}") !== false) { $p_apibatchurls = replaceStr($p_apibatchurl, "{PAGE_NO}", $page_num); // echo $p_apibatchurls .'\n'; $playcode = getFormatPage($p_apibatchurls, $p_coding); $weburls = getArray($playcode, $p_playlinkstart, $p_playlinkend); // echo "page ".$page_num." :".$weburls .'\n'; if ($weburls) { $weburl = $weburl . "{Array}" . $weburls; $page_num = $page_num + 1; } else { $flag = false; } } // var_dump($weburl); // if ($p_playlinktype >0) { // $weburl = getArray($playcode,$p_playlinkstart,$p_playlinkend); // } // else{ // $weburl = getArray($playcode,$p_playurlstart,$p_playurlend); // // var_dump($playcode); // } // if ($p_setnametype == 3) { // $setnames = getArray($playcode,$p_setnamestart,$p_setnameend); // } } else { if ($p_playlinktype > 0) { $weburl = getArray($strViewCode, $p_playlinkstart, $p_playlinkend); // var_dump($weburl); } else { $weburl = getArray($strViewCode, $p_playurlstart, $p_playurlend); $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($strViewCode, $p_coding, $p_script); $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($strViewCode, $p_coding, $p_script); writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl); } if ($p_setnametype == 3) { $setnames = getArray($strViewCode, $p_setnamestart, $p_setnameend); } } } if ($p_showtype == 1) { if ($p_savefiles == 1) { $filename = time() . $num; if (strpos($piccode, ".jpg") || strpos($piccode, ".bmp") || strpos($piccode, ".png") || strpos($piccode, ".gif")) { $extName = substring($piccode, 4, strlen($piccode) - 4); } else { $extName = ".jpg"; } $picpath = "upload/vod/" . getSavePicPath() . "/"; $picfile = $filename . $extName; //echo "<tr><td width=\"20%\" >自动下载图片:</td><td><iframe border=\"0\" valign=\"bottom\" vspace=\"0\" hspace=\"0\" marginwidth=\"0\" marginheight=\"0\" framespacing=\"0\" frameborder=\"0\" scrolling=\"no\" width=\"400\" height=\"15\" src=\"../admin_pic.php?action=downpic&wjs=1&path=../".$picpath."&file=".$picfile."&url=".$piccode."\"></iframe></td></tr>"; $piccode = $picpath . $picfile; } } else { // echo "<tr><td colspan=\"2\" align=\"center\">第".($num+1)."条数据采集结果</td></tr><tr><td width=\"20%\" >来源:</td><td >".$strlink."</td></tr><tr><td width=\"20%\" >名称:</td><td >".$titlecode." 连载:".$lzcode." 备注:".$remarkscode."</td></tr>"; } if ($weburl == false) { // echo "<tr><td colspan=\"2\">在获取播放列表链接时出错 ".$strlink." / '.$strListUrl.'</TD></TR>"; writetofile("crawel_auto_error.log", $p_id . '{=====}' . $strlink . '{=====}' . $strListUrl); // $sb=$sb+1; return; } else { $sql = "select m_id,m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_addtime,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state from {pre}cj_vod where m_pid='" . $p_id . "' and m_name='" . $titlecode . "' order by m_id desc"; $rowvod = $db->getRow($sql); if ($rowvod) { $cg = $cg + 1; $movieid = $rowvod["m_id"]; if (isN($titlecode)) { $titlecode = $rowvod["m_name"]; } if (isN($starringcode)) { $starringcode = $rowvod["m_starring"]; } if (isN($piccode)) { $piccode = $rowvod["m_pic"]; } $sql = "update {pre}cj_vod set m_pic='" . $piccode . "', m_type='" . $typecode . "',m_area='" . $areacode . "',m_urltest='" . $strlink . "',m_name='" . $titlecode . "',m_starring='" . $starringcode . "',m_directed='" . $directedcode . "',m_year='" . $timecode . "',m_playfrom='" . $p_playtype . "',m_content='" . $contentcode . "',m_addtime='" . date('Y-m-d H:i:s', time()) . "',m_zt='0',m_pid='" . $p_id . "',m_typeid='" . $m_typeid . "',m_playserver='" . $p_server . "',m_state='" . $lzcode . "',m_language='" . $languagecode . "',m_remarks='" . $remarkscode . "' where m_id=" . $rowvod["m_id"]; writetofile("sql.txt", $sql); $db->query($sql); // $sql="delete from {pre}cj_vod_url where u_movieid=".$rowvod["m_id"]; // writetofile("sql.txt", $sql); // $db->query($sql); } else { $cg = $cg + 1; $sql = "insert {pre}cj_vod (m_name,m_type,m_area,m_playfrom,m_starring,m_directed,m_pic,m_content,m_year,m_urltest,m_zt,m_pid,m_typeid,m_hits,m_playserver,m_state,m_addtime,m_language,m_remarks) values('" . $titlecode . "','" . $typecode . "','" . $areacode . "','" . $p_playtype . "','" . $starringcode . "','" . $directedcode . "','" . $piccode . "','" . $contentcode . "','" . $timecode . "','" . $strlink . "','0','" . $p_id . "','" . $m_typeid . "','" . $m_hits . "','" . $p_server . "','" . $lzcode . "','" . date('Y-m-d H:i:s', time()) . "','" . $languagecode . "','" . $remarkscode . "')"; writetofile("sql.txt", $sql); $db->query($sql); $movieid = $db->insert_id(); } $webArray = explode("{Array}", $weburl); $setnamesArray = explode("{Array}", $setnames); $webArraTemp = array(); $index = 0; $webUrls = ''; for ($i = 0; $i < count($webArray); $i++) { $UrlTemp = $webArray[$i]; if (strpos($webUrls, $UrlTemp . '<array>') === false) { $webArraTemp[$index] = $UrlTemp; $webUrls = $webUrls . $UrlTemp . '<array>'; $index++; } } // writetofile("d:\\ssssss.txt","p_videocodeType:".$p_videocodeType); $webArray = $webArraTemp; //http://www.youku.com/show_episode/id_zc16d0492e81411e196ac.html?dt=json&divid=reload_1&__rt=1&__ro=reload_1 for ($i = 0; $i < count($webArray); $i++) { $WebTestx = $webArray[$i]; if ($p_playspecialtype == 1 && strpos("," . $p_playspecialrrul, "[变量]")) { $Keyurl = explode("[变量]", $p_playspecialrrul); $urli = getBody($UrlTest, $Keyurl[0], $Keyurl[1]); if ($urli == false) { break; } $WebTestx = replaceStr($p_playspecialrerul, "[变量]", $urli); } if ($p_playspecialtype == 2) { $urArray = explode("/", $strlink); $ur = ""; for ($k = 0; $k < count($urArray) - 1; $k++) { $ur = $ur . $urArray[$k] . "/"; } $WebTestx = $ur . $WebTestx . ".html"; } writetofile("crawel_auto_info.log", $p_id . '{=====}' . $WebTestx . "{=====}ViewList===start"); if ($p_playlinktype == 1) { //播放页获取地址 $WebTestx = getHrefFromLink($WebTestx); $WebTestx = definiteUrl($WebTestx, $strListUrl); $playCode = getPage($WebTestx, $p_coding); $androidUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseAndroidVideoUrlByContent($playCode, $p_coding, $p_script); $videoAddressUrl = ContentProviderFactory::getContentProvider($p_playtype)->parseIOSVideoUrlByContent($playCode, $p_coding, $p_script); writetofile("android_log.txt", $strlink . '{===}' . $androidUrl . '{===}' . $videoAddressUrl); $url = getBody($playCode, $p_playurlstart, $p_playurlend); $url = replaceLine($url); } else { if ($p_playlinktype == 2) { //播放链接中获取地址 $WebTestx = getHrefFromLink($WebTestx); if (isN($p_playurlend)) { $tmpA = strpos($WebTestx, $p_playurlstart); $url = substr($WebTestx, strlen($WebTestx) - $tmpA - strlen($p_playurlstart) + 1); } else { $url = getBody($WebTestx, $p_playurlstart, $p_playurlend); } } else { if ($p_playlinktype == 3) { //单播放页获取所有播放地址 $WebTestx = getHrefFromLink($WebTestx); $playCode = getPage($WebTestx, $p_coding); $tmpB = getArray($webCode, $p_playurlstart, $p_playurlend); $tmpC = explode("{$Array}\$", $tmpB); foreach ($tmpC as $tmpD) { $sql = "SELECT {pre}vod_url.u_url FROM ({pre}vod_url INNER JOIN {pre}vod ON {pre}vod_url.u_movieid = {pre}vod.m_id) where {pre}vod_url.u_url='" . $tmpD . "' and {pre}vod.m_pid=" . $p_id; $row = $db->getRow($sql); if (!$row) { $strTempUrl = $strTempUrl . $tmpD . "<br>"; $db->query("insert into {pre}vod_url(u_url,u_movieid) values('" . $tmpD . "','" . $movieid . "')"); } } break; } else { $url = $WebTestx; $url = replaceLine($url); } } } $url = replaceFilters($url, $p_id, 3, 0); if ($p_setnametype == 1) { $setname = getBody($url, $p_setnamestart, $p_setnameend); // $url = $setname . "$" . $url; } else { if ($p_setnametype == 2 && $p_playlinktype == 1) { $setname = getBody($playCode, $p_setnamestart, $p_setnameend); // $url = $setname ."$" .$url; } else { if ($p_setnametype == 3) { $setname = $setnamesArray[$i]; } } } $sql = "SELECT {pre}cj_vod_url.u_url FROM ({pre}cj_vod_url INNER JOIN {pre}cj_vod ON {pre}cj_vod_url.u_movieid = {pre}cj_vod.m_id) where {pre}cj_vod_url.u_url='" . $url . "' and {pre}cj_vod.m_pid=" . $p_id . " and {pre}cj_vod.m_id=" . $movieid; $rowurl = $db->getRow($sql); // writetofile("d:\\sql.txt",$rowurl); if (!$rowurl) { if ($p_playlinktype == 1) { $strTempUrl .= $url . "<br>"; $url = replaceStr($url, "'", "''"); writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )"); $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,u_weburl,iso_video_url,name,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($WebTestx) . "','" . getHrefFromLink($videoAddressUrl) . "','" . filterScriptStar($setname, $p_script) . "' ,'" . $androidUrl . "' )"); } else { $strTempUrl .= $url . "<br>"; writetofile("sql.txt", "insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')"); $db->query("insert into {pre}cj_vod_url(u_url,u_movieid,iso_video_url,u_weburl,android_vedio_url) values('" . $url . "','" . $movieid . "','" . getHrefFromLink($videoAddressUrl) . "','" . getHrefFromLink($strlink) . "', '" . $androidUrl . "')"); } } } } } $cg = $cg + 1; }
$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 { $a_content = str_replace($a_pic, "", $a_content); } echo $msg . "<br>"; ob_flush(); flush(); } $num++; $db->query("UPDATE {pre}art set a_content='" . $a_content . "' where a_id='" . $a_id . "'"); } unset($rs);
function cj() { global $MAC, $bindcache, $backurl, $typearr, $ac2, $apiurl, $flag, $xt, $ct, $group, $wd, $type, $pg, $hour, $db; switch ($ac2) { case 'sel': $ids = be("arr", "ids"); if (empty($ids)) { errMsg("采集提示", "请选择采集数据"); } switch ($xt) { case '1': $url = "?ac=videolist&rid=" . $group . "&ids=" . $ids; break; case '2': $url = "-action-ids-vodids-" . $ids . "-cid--play--inputer--wd--h-0-p-1"; break; } break; case 'day': switch ($xt) { case '1': $url = "?ac=videolist&rid=" . $group . "&h=" . $hour . "&pg=" . $pg; break; case '2': $url = "-action-day-vodids--cid--play--inputer--wd--h-" . $hour . "-p-" . $pg; break; } break; case 'type': if (empty($type)) { errMsg("请先进入分类,否则无法使用采集分类!"); } switch ($xt) { case '1': $url = "?ac=videolist&rid=" . $group . "&pg=" . $pg . "&t=" . $type; break; case '2': $url = "-action-all-vodids--cid-" . $type . "-play--inputer--wd--h-0-p-" . $pg; break; } break; case 'all': switch ($xt) { case '1': $url = "?ac=videolist&rid=" . $group . "&pg=" . $pg; break; case '2': $url = "-action-all-vodids--cid--play--inputer--wd--h-0-p-" . $pg; break; } break; } $url = $apiurl . $url; if ($xt == "0") { $xn_list = '/<pagecount>([0-9]+)<\\/pagecount>/'; $xn_pagesize = 1; $xn_pagecount = 1; $xn_recordcount = 1; $xn_d = '/<vod><id>([0-9]+)<\\/id><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><state>([\\s\\S]*?)<\\/state><type>([\\s\\S]*?)<\\/type><starring><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/starring><directed><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/directed><pic>([\\s\\S]*?)<\\/pic><time>([\\s\\S]*?)<\\/time><year>([\\s\\S]*?)<\\/year><area><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/area><language><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/language><urls>([\\s\\S]*?)<\\/urls><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des><\\/vod>/'; $xn_url = '/<url from="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/url>/'; $xn_d_id = 1; $xn_d_name = 2; $xn_d_remarks = 3; $xn_d_state = 4; $xn_d_type = 5; $xn_d_starring = 6; $xn_d_directed = 7; $xn_d_pic = 8; $xn_d_time = 9; $xn_d_year = 10; $xn_d_area = 11; $xn_d_lang = 12; $xn_d_des = 14; $xn_d_urls = 13; } elseif ($xt == "1") { $xn_list = '<list page="([\\s\\S]*?)" pagecount="([0-9]+)" pagesize="([0-9]+)" recordcount="([0-9]+)">'; $xn_pagesize = 3; $xn_pagecount = 2; $xn_recordcount = 4; $xn_d = '/<video><last>([\\s\\S]*?)<\\/last><id>([0-9]+)<\\/id><tid>([0-9]+)<\\/tid><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><type>([\\s\\S]*?)<\\/type><pic>([\\s\\S]*?)<\\/pic><lang>([\\s\\S]*?)<\\/lang><area>([\\s\\S]*?)<\\/area><year>([\\s\\S]*?)<\\/year><state>([\\s\\S]*?)<\\/state><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><actor><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/actor><director><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/director><dl>([\\s\\S]*?)<\\/dl><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des>([\\s\\S]*?)<\\/video>/'; $xn_url = '/<dd flag="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/dd>/'; $xn_d_time = 1; $xn_d_id = 2; $xn_d_type = 3; $xn_d_name = 4; $xn_d_pic = 6; $xn_d_lang = 7; $xn_d_area = 8; $xn_d_year = 9; $xn_d_state = 10; $xn_d_remarks = 11; $xn_d_starring = 12; $xn_d_directed = 13; $xn_d_urls = 14; $xn_d_content = 15; } elseif ($xt == "2") { $url = str_replace('|', '-', $url); $xn_list = '<list page="([\\s\\S]*?)" pagecount="([0-9]+)" pagesize="([0-9]+)" recordcount="([0-9]+)">'; $xn_pagesize = 3; $xn_pagecount = 2; $xn_recordcount = 4; $xn_d = '/<video><last>([\\s\\S]*?)<\\/last><id>([0-9]+)<\\/id><tid>([0-9]+)<\\/tid><name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name><type>([\\s\\S]*?)<\\/type><pic>([\\s\\S]*?)<\\/pic><lang>([\\s\\S]*?)<\\/lang><area>([\\s\\S]*?)<\\/area><year>([\\s\\S]*?)<\\/year><state>([\\s\\S]*?)<\\/state><note><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/note><actor><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/actor><director><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/director><dl>([\\s\\S]*?)<\\/dl><des><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/des>([\\s\\S]*?)<\\/video>/'; $xn_url = '/<dd flag="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/dd>/'; $xn_d_time = 1; $xn_d_id = 2; $xn_d_type = 3; $xn_d_name = 4; $xn_d_pic = 6; $xn_d_lang = 7; $xn_d_area = 8; $xn_d_year = 9; $xn_d_state = 10; $xn_d_remarks = 11; $xn_d_starring = 12; $xn_d_directed = 13; $xn_d_urls = 14; $xn_d_content = 15; } $html = getPage($url, "utf-8"); preg_match($xn_list, $html, $array1); $pgsize = $array1[$xn_pagesize]; $pgcount = $array1[$xn_pagecount]; $recordcount = $array1[$xn_recordcount]; unset($array1); if (count($recordcount) == 0) { echo '没有任何可用数据' . jump('?m=collect-list-xt-' . $xt . "-ct-" . $ct . '-group-' . $group . '-flag-' . $flag . '-apiurl-' . $apiurl, 1); return; } echo '当前采集任务<strong class="green">' . $pg . '</strong>/<span class="green">' . $pgcount . '</span>页 采集地址 ' . $url; ob_flush(); flush(); $inrule = $MAC['collect']['vod']['inrule']; $uprule = $MAC['collect']['vod']['uprule']; $filter = $MAC['collect']['vod']['filter']; preg_match_all($xn_d, $html, $array3); $i = 0; foreach ($array3[1] as $key => $value) { $i++; $rc = false; $d_id = $array3[$xn_d_id][$key]; $d_name = format_vodname($array3[$xn_d_name][$key]); $d_remarks = $array3[$xn_d_remarks][$key]; $d_state = intval($array3[$xn_d_state][$key]); $d_type = intval($bindcache[$flag . $array3[$xn_d_type][$key]]); $d_starring = htmlspecialchars_decode($array3[$xn_d_starring][$key]); $d_directed = htmlspecialchars_decode($array3[$xn_d_directed][$key]); $d_pic = $array3[$xn_d_pic][$key]; $d_time = $array3[$xn_d_time][$key]; $d_year = intval($array3[$xn_d_year][$key]); $d_area = $array3[$xn_d_area][$key]; $d_lang = $array3[$xn_d_lang][$key]; $d_content = htmlspecialchars_decode($array3[$xn_d_content][$key]); $d_playurls = htmlspecialchars_decode($array3[$xn_d_urls][$key]); $d_playurls = str_replace("'", "''", $d_playurls); preg_match_all($xn_url, $d_playurls, $array4); $d_enname = Hanzi2PinYin($d_name); $d_letter = strtoupper(substring($d_enname, 1)); $d_addtime = time(); $d_time = $d_addtime; $d_hitstime = ""; $d_hits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']); $d_dayhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']); $d_weekhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']); $d_monthhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']); $d_score = 0; $d_scoreall = 0; $d_scorenum = 0; if ($MAC['collect']['vod']['score'] == 1) { $d_scorenum = rand(1, 500); $d_scoreall = $d_scorenum * rand(1, 10); $d_score = round($d_scoreall / $d_scorenum, 1); } $d_hide = $MAC['collect']['vod']['hide']; if ($MAC['collect']['vod']['psernd'] == 1) { $d_content = repPseRnd('vod', $d_content, $i); } if ($MAC['collect']['vod']['psesyn'] == 1) { $d_content = repPseSyn('vod', $d_content); } $d_downfrom = ''; $d_downserver = ''; $d_downnote = ''; $d_downurl = ''; $d_playfrom = ''; $d_playserver = ''; $d_playnote = ''; $d_playurl = ''; $d_tag = ''; $color = 'red'; $msg = ''; if ($d_type < 1) { $des = "分类未绑定,系统跳过采集。"; } elseif (empty($d_name)) { $des = "数据不完整,不进行处理。"; } elseif (strpos(',' . $filter, $d_name)) { $des = "数据在过滤单中,系统跳过采集。"; } else { $sql = "SELECT * FROM {pre}vod WHERE d_name ='" . $d_name . "' "; if (strpos($inrule, 'b')) { $sql .= ' and d_type=' . $d_type; } if (strpos($inrule, 'c')) { $sql .= ' and d_year=' . $d_year; } if (strpos($inrule, 'd')) { $sql .= ' and d_area=\'' . $d_area . '\''; } if (strpos($inrule, 'e')) { $sql .= ' and d_lang=\'' . $d_lang . '\''; } if (strpos($inrule, 'f')) { $sql .= ' and d_starring=\'' . $d_starring . '\''; } if (strpos($inrule, 'g')) { $sql .= ' and d_directed=\'' . $d_directed . '\''; } if ($MAC['collect']['vod']['tag'] == 1) { $d_tag = getTag($d_name, $d_content); } $row = $db->getRow($sql); if (!$row) { foreach ($array4[1] as $key => $value) { if ($rc) { $d_playfrom .= "\$\$\$"; $d_playserver .= "\$\$\$"; $d_playnote .= "\$\$\$"; $d_playurl .= "\$\$\$"; } $d_playfrom .= getFrom($value); if ($xt == "1") { $d_playurl .= getVUrl($array4[2][$key]); } else { $d_playurl .= $array4[2][$key]; } $d_playserver .= '0'; $d_playnote .= ''; $rc = true; } if ($MAC['collect']['vod']['pic'] == 1) { $st = strrpos($d_pic, '/'); $fname = substring($d_pic, strlen($d_pic) - $st, $st + 1); $path = "upload/vod/" . getSavePicPath('') . "/"; $thumbpath = "upload/vodthumb/" . getSavePicPath('vodthumb') . "/"; $ps = savepic($d_pic, $path, $thumbpath, $fname, 'vod', $msg); if ($ps) { $d_pic = $path . $fname; $d_picthumb = $thumbpath . $fname; } } if ($ct == "1") { $d_downfrom = $d_playfrom; $d_downserver = ""; $d_downnote = ""; $d_downurl = $d_playurl; $d_playfrom = ""; $d_playserver = ""; $d_playnote = ""; $d_playurl = ""; } else { $d_playserver = ""; $d_downfrom = ""; $d_downserver = ""; $d_downnote = ""; $d_downurl = ""; } $db->Add("{pre}vod", array("d_type", "d_name", "d_enname", "d_letter", "d_state", "d_remarks", "d_tag", "d_pic", 'd_picthumb', "d_hits", "d_dayhits", "d_weekhits", "d_monthhits", "d_score", "d_scoreall", "d_scorenum", "d_starring", "d_directed", "d_year", "d_area", "d_lang", "d_addtime", "d_time", "d_hide", "d_content", "d_playfrom", "d_playserver", "d_playnote", "d_playurl", "d_downfrom", "d_downserver", "d_downnote", "d_downurl"), array($d_type, $d_name, $d_enname, $d_letter, $d_state, $d_remarks, $d_tag, $d_pic, $d_picthumb, $d_hits, $d_dayhits, $d_weekhits, $d_monthhits, $d_score, $d_scoreall, $d_scorenum, $d_starring, $d_directed, $d_year, $d_area, $d_lang, $d_addtime, $d_time, $d_hide, $d_content, $d_playfrom, $d_playserver, $d_playnote, $d_playurl, $d_downfrom, $d_downserver, $d_downnote, $d_downurl)); $color = 'green'; $des = "无重名,新加入库成功。"; } else { if ($row['d_lock'] == 1) { $des = "数据已经锁定,系统跳过采集更新。"; } else { if ($ct == "1") { $n_from = $row["d_downfrom"]; $n_server = $row["d_downserver"]; $n_note = $row['d_downnote']; $n_url = $row["d_downurl"]; } else { $n_from = $row["d_playfrom"]; $n_server = $row["d_playserver"]; $n_note = $row['d_playnote']; $n_url = $row["d_playurl"]; } $color = 'red'; foreach ($array4[1] as $key => $value) { $d_playfrom = getFrom($value); $d_playserver = '0'; if ($xt == "1") { $d_playurl = getVUrl($array4[2][$key]); } else { $d_playurl = $array4[2][$key]; } $rc = false; if ($n_url == $d_playurl) { $des = "数据相同,暂不更新数据"; continue; } elseif (isN($d_playfrom)) { $des = "播放器类型为空,跳过组合播放地址"; continue; } elseif (strpos("," . $n_from, $d_playfrom) <= 0) { $rc = true; $color = 'green'; $des = "数据发生改变,新增播放组。"; $n_url .= "\$\$\$" . $d_playurl; $n_from .= "\$\$\$" . $d_playfrom; $n_server .= "\$\$\$" . $d_playserver; $n_note .= "\$\$\$" . $d_playnote; } else { $color = 'green'; $des = "数据发生改变,更新播放组。"; $arr1 = explode("\$\$\$", $n_url); $arr2 = explode("\$\$\$", $n_from); $n_url = ""; for ($k = 0; $k < count($arr2); $k++) { if ($rc) { $n_url .= "\$\$\$"; } if (count($arr1) >= $k) { if ($arr2[$k] == $d_playfrom) { $arr1[$k] = $d_playurl; } $n_url .= $arr1[$k]; } else { $n_url .= $d_playurl; } $rc = true; } } } if ($rc) { $colarr = array(); $valarr = array(); array_push($colarr, 'd_time'); array_push($valarr, time()); if (strpos(',' . $uprule, 'a') && $ct != 1) { array_push($colarr, 'd_playfrom', 'd_playserver', 'd_playnote', 'd_playurl'); array_push($valarr, $n_from, $n_server, $n_note, $n_url); } if (strpos(',' . $uprule, 'b') && $ct == 1) { array_push($colarr, 'd_downfrom', 'd_downserver', 'd_downnote', 'd_downurl'); array_push($valarr, $n_from, $n_server, $n_note, $n_url); } if (strpos(',' . $uprule, 'c')) { array_push($colarr, 'd_state'); array_push($valarr, $d_state); } if (strpos(',' . $uprule, 'd')) { array_push($colarr, 'd_remarks'); array_push($valarr, $d_remarks); } if (strpos(',' . $uprule, 'e')) { array_push($colarr, 'd_directed'); array_push($valarr, $d_directed); } if (strpos(',' . $uprule, 'f')) { array_push($colarr, 'd_starring'); array_push($valarr, $d_starring); } if (strpos(',' . $uprule, 'g')) { array_push($colarr, 'd_year'); array_push($valarr, $d_year); } if (strpos(',' . $uprule, 'h')) { array_push($colarr, 'd_area'); array_push($valarr, $d_area); } if (strpos(',' . $uprule, 'i')) { array_push($colarr, 'd_lang'); array_push($valarr, $d_lang); } if (strpos(',' . $uprule, 'j')) { if ($MAC['collect']['vod']['pic'] == 1) { $st = strrpos($d_pic, '/'); $fname = substring($d_pic, strlen($d_pic) - $st, $st + 1); $path = "upload/vod/" . getSavePicPath('') . "/"; $thumbpath = "upload/vodthumb/" . getSavePicPath('vodthumb') . "/"; $ps = savepic($d_pic, $path, $thumbpath, $fname, 'vod', $msg); if ($ps) { $d_pic = $path . $fname; $d_picthumb = $thumbpath . $fname; array_push($colarr, 'd_pic'); array_push($valarr, $d_pic); array_push($colarr, 'd_picthumb'); array_push($valarr, $d_picthumb); } } } if (strpos(',' . $uprule, 'k')) { array_push($colarr, 'd_content'); array_push($valarr, $d_content); } if (strpos(',' . $uprule, 'l')) { array_push($colarr, 'd_tag'); array_push($valarr, $d_tag); } if (count($colarr) > 0) { $db->Update("{pre}vod", $colarr, $valarr, "d_id=" . $row["d_id"]); } } } } unset($row); unset($array4); } //echo <<<EOT //<div>$i. $d_name <font color="$color"> $des</font> $msg </div> //EOT; ob_flush(); flush(); } unset($array3); //unset($pinyins); if ($pg < $pgcount) { $pg = $pg + 1; cj(); } else { echo '<br>采集完毕...'; } }
$upfileDir = "../" . $_SESSION["upfolder"] . "/" . getSavePicPath() . "/"; $maxSize = 1000; if (!file_exists($upfileDir)) { mkdir($upfileDir); } foreach ($_FILES as $FILEa) { if (!in_array(substr($FILEa['name'], -3, 3), $ftypes)) { $errm = "文件格式不正确1 [ <a href=# onclick=history.go(-1)>重新上传</a> ]"; } if ($FILEa['size'] > $maxSize * 1024) { $errm = "文件大小超过了限制 [ <a onclick=history.go(-1)>重新上传</a> ]"; } if ($FILEa['error'] != 0) { $errm = "未知错误"; } $targetDir = "../" . $_SESSION["upfolder"] . "/" . getSavePicPath() . "/"; $targetFile = date('Ymd') . time() . substr($FILEa['name'], -4, 4); $realFile = $targetDir . $targetFile; if (function_exists('move_uploaded_file')) { move_uploaded_file($FILEa['tmp_name'], $realFile); if (app_watermark == 1) { imageWaterMark($targetDir . $targetFile, getcwd(), app_waterlocation, app_waterfont); } if (app_ftp == 1) { uploadftp($targetDir, $targetFile); } if ($action == "xht") { echo "{'err':'" . $errm . "','msg':'" . app_installdir . replaceStr($upfileDir, "../../", "") . $targetFile . "'}"; } else { die("<script>parent.document.getElementById('pic').value='" . "http://" . $_SERVER["HTTP_HOST"] . '/' . "cms" . '/' . replaceStr($upfileDir, "../../", "") . $targetFile . "'</script>上传成功!"); }
if (@$_REQUEST['SESSION_ID'] && ($session_id = $_REQUEST['SESSION_ID']) != session_id()) { session_destroy(); session_id($session_id); @session_start(); } chkLogin(); $action = be("get", "action"); $id = be("get", "id"); $path = be("get", "path"); if (isN($id)) { $id = "pic"; } $exts = explode(';', $MAC['upload']['filter']); //array('jpg','gif','bmp','png',"jpeg","rar","txt","zip","torrent"); $showdir = "upload/" . $path . "/" . getSavePicPath($path) . "/"; $thumbdir = "upload/" . $path . "thumb/" . getSavePicPath($path . 'thumb') . "/"; $updir = "../../" . $showdir; $maxSize = 2048; if (!file_exists($updir)) { mkdir($updir); } if ($path == 'vod') { if (!file_exists("../../" . $thumbdir)) { mkdir("../../" . $thumbdir); } } foreach ($_FILES as $FILEa) { if (empty($FILEa['name'])) { continue; } $ext = end(explode('.', $FILEa['name']));
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); }