function str($url = '', $code = 'utf-8') { $neir = htmlall($url); if (!empty($neir)) { if ($code != 'utf-8') { $neir = get_bm($neir); } } return $neir; }
public function get_url($url) { $arr = htmlall($url); if (empty($arr)) { admin_msg(L('curl_err'), @$_SERVER['HTTP_REFERER'], 'no'); //获取远程失败 } else { $arr = json_decode($arr, true); $arr = get_bm($arr); if ($arr['status'] == 0) { admin_msg($arr['msg'], @$_SERVER['HTTP_REFERER'], 'no'); //错误状态 } else { return $arr['msg']; } } }
public function downpic() { $page = intval($this->input->get('page')); $pagejs = intval($this->input->get('pagejs')); $sql_string = "SELECT id,pic FROM " . CS_SqlPrefix . "vod where hid=0 and yid=0 and Lower(Left(pic,7))='http://' order by addtime desc"; $query = $this->db->query($sql_string); $total = $query->num_rows(); if ($page > $pagejs || $total == 0) { admin_msg('恭喜您,所有远程图片全部同步完成~!', site_url('vod/admin/vod'), 'ok'); //操作完成 } if ($page == 0) { $page = 1; } $per_page = 20; $totalPages = ceil($total / $per_page); // 总页数 if ($total < $per_page) { $per_page = $total; } if ($pagejs == 0) { $pagejs = $totalPages; } $sql_string .= ' limit 20'; $query = $this->db->query($sql_string); //保存目录 if (UP_Mode == 1 && UP_Pan != '') { $pathpic = UP_Pan . '/attachment/vod/' . date('Ym') . '/' . date('d') . '/'; $pathpic = str_replace("//", "/", $pathpic); } else { $pathpic = FCPATH . 'attachment/vod/' . date('Ym') . '/' . date('d') . '/'; } if (!is_dir($pathpic)) { mkdirss($pathpic); } $this->load->library('watermark'); $this->load->library('csup'); echo '<LINK href="' . Web_Path . 'packs/admin/css/style.css" type="text/css" rel="stylesheet"><br>'; echo "<div style='font-size:14px;'> <b>正在开始同步第<font style='color:red; font-size:12px; font-style:italic'>" . $page . "</font>页,共<font style='color:red; font-size:12px; font-style:italic'>" . $pagejs . "</font>页,剩<font style='color:red; font-size:12px; font-style:italic'>" . $totalPages . "</font>页</b><br><br>"; foreach ($query->result() as $row) { $up = 'no'; if (!empty($row->pic)) { $picdata = htmlall($row->pic); $file_ext = strtolower(trim(substr(strrchr($row->pic, '.'), 1))); if ($file_ext != 'jpg' && $file_ext != 'png' && $file_ext != 'gif') { $file_ext = 'jpg'; } //新文件名 $file_name = date("YmdHis") . rand(10000, 99999) . '.' . $file_ext; $file_path = $pathpic . $file_name; if (!empty($picdata)) { //保存图片 if (write_file($file_path, $picdata)) { $up = 'ok'; //判断水印 if (CS_WaterMark == 1) { $this->watermark->imagewatermark($file_path); } //判断上传方式 $res = $this->csup->up($file_path, $file_name); if (!$res) { $up = 'no'; } } } } //成功 if ($up == 'ok') { //修改数据库 $this->db->query("update " . CS_SqlPrefix . "vod set pic='/" . date('Ym') . "/" . date('d') . "/" . $file_name . "' where id=" . $row->id . ""); echo " 同步<font color=red>" . $row->pic . "</font> 图片成功! 新图片名:<a href=\"" . piclink('vod', '/' . date('Ym') . '/' . date('d') . '/' . $file_name) . "\" target=_blank>" . $file_name . "</a></br>"; } else { //修改数据库 $this->db->query("update " . CS_SqlPrefix . "vod set pic='' where id=" . $row->id . ""); echo " <font color=red>" . $row->pic . "</font>远程图片不存在!</br>"; } ob_flush(); flush(); } echo " 第" . $page . "页图片同步完毕,暂停3秒后继续同步......<script language='javascript'>setTimeout('ReadGo();'," . 3000 . ");function ReadGo(){location.href='" . site_url('vod/admin/opt/downpic') . "?page=" . ($page + 1) . "&pagejs=" . $pagejs . "';}</script></div>"; }
public function checkfile() { if (!empty($_GET['ok'])) { $data['diff'] = array(); $data['lostfile'] = array(); $data['unknowfile'] = array(); $this->filemd5('.'); //读取cscms接口 $cscms_md5 = htmlall($this->_upgrade . 'ajax/filemd5?charset=' . CS_Charset . '&update=' . CS_Uptime); $cscms_md5_arr = json_decode($cscms_md5, 1); if (!empty($cscms_md5_arr)) { //计算数组差集 $diff = array_diff($cscms_md5_arr, $this->md5_arr); //丢失文件列表 $lostfile = array(); foreach ($cscms_md5_arr as $k => $v) { if (!in_array($k, array_keys($this->md5_arr))) { $lostfile[] = $k; unset($diff[$k]); } } $data['diff'] = $diff; $data['lostfile'] = $lostfile; //未知文件列表 $data['unknowfile'] = array_diff(array_keys($this->md5_arr), array_keys($cscms_md5_arr)); } $this->load->view('upgrade_md5.html', $data); } else { admin_msg(L('plub_15'), site_url('upgrade/checkfile') . '?ok=1', 'ok'); //操作成功 } }
function keys($data, $mx = 'plub') { $url = CS_YPTURL . $mx . '/key?param=' . cs_base64_encode(arraystring(array('site' => Web_Url, 'url' => 'http://' . Web_Url . Web_Path, 'data' => $data, 'admin' => SELF, 'encry' => CS_Encryption_Key))); return htmlall($url); }
function caiji($spurl = '', $sid = 0) { $str['error'] = 'no'; if (!empty($spurl) && substr($spurl, 0, 7) == 'http://') { if (strpos($spurl, 'ku6.com') !== FALSE) { $neir = htmlall($spurl); if (!empty($neir)) { $str['name'] = str_substr('<title>', ' 在线观看', $neir); $str['pic'] = str_substr('cover: "', '"', $neir); $str['url'] = str_substr("snyu_page_params='vid=", '&category=', $neir); $str['laiy'] = "ku6"; } } elseif (strpos($spurl, '56.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr('<title>', '-', $neir); $str['pic'] = str_substr('img":"', '",', $neir); $str['pic'] = str_replace("\\", "", $str['pic']); $str['url'] = str_substr(',"EnId":"', '"', $neir); $str['laiy'] = "56"; } } elseif (strpos($spurl, 'youku.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr('<span id="subtitle">', '</span>', $neir); $str['pic'] = str_substr('&pics=', '&site=优酷', $neir); preg_match('/http:\\/\\/v.youku.com\\/v_show\\/id_\\s*([0-9a-zA-Z]+).html/', $spurl, $vid); if (!empty($vid) && !empty($vid[1])) { $str['url'] = $vid[1]; } $str['laiy'] = "youku"; } } elseif (strpos($spurl, 'tudou.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr(",kw: '", "'", $neir); $str['pic'] = str_substr(",pic: '", "'", $neir); $str['url'] = str_substr(",icode: '", "'", $neir); $str['url'] = trim($str['url']); $str['laiy'] = "tudou"; } } elseif (strpos($spurl, 'sohu.com') !== FALSE) { $neir = HtmlUp($spurl); if (!empty($neir)) { $str['name'] = str_substr('<title>', ' -', $neir); $str['pic'] = str_substr('var cover="', '";', $neir); $str['url'] = str_substr('var vid="', '";', $neir); $str['laiy'] = "sohu"; } } elseif (strpos($spurl, 'sina.com.cn') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr("\t\ttitle:'", "',", $neir); $str['pic'] = str_substr("pic:'", "'", $neir); $str['url'] = str_substr("\t\tvid:'", "'", $neir); $str['laiy'] = "sina"; } } elseif (strpos($spurl, 'qq.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr('title : "', '"', $neir); $str['pic'] = str_substr('pic :"', '",', $neir); $str['url'] = str_substr('vid:"', '"', $neir); $str['laiy'] = "qq"; } } elseif (strpos($spurl, 'pps.tv') !== FALSE) { $neir = HtmlUp($spurl); if (!empty($neir)) { $str['name'] = str_substr("<meta name='description' content=", '">', $neir); $str['name'] = substr($str['name'], 1); $str['pic'] = str_substr('"sharepic":"', '",', $neir); $str['pic'] = str_replace("\\", "", $str['pic']); $str['url'] = str_substr('"url_key":"', '",', $neir); $str['laiy'] = "pps"; } } elseif (strpos($spurl, 'letv.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr('title:"', '",', $neir); $str['pic'] = str_substr('{pic:"', '",url', $neir); $str['url'] = str_substr('vid:', ',', $neir); $str['laiy'] = "letv"; } } elseif (strpos($spurl, 'yinyuetai.com') !== FALSE) { $neir = htmlall($spurl, 'utf-8'); if (!empty($neir)) { $str['name'] = str_substr('title : "', '",', $neir); $str['pic'] = str_substr('<meta property="og:image" content="', '"/>', $neir); preg_match('/http:\\/\\/v.yinyuetai.com\\/video\\/\\s*([0-9]+)/', $spurl, $vid); $str['url'] = @$vid[1]; $str['laiy'] = "yyt"; } } } if (empty($str['url'])) { $str['error'] = 'no'; } else { $str['error'] = 'ok'; } if (!empty($str['name'])) { $str['name'] = get_bm($str['name'], 'gbk', 'utf-8'); } if ($sid == 0) { $str = json_encode($str); } return $str; }
public function index() { $ac = $this->input->get('ac', true); $op = $this->input->get('op', true); $do = $this->input->get('do', true); $rid = intval($this->input->get('rid')); if ($do == 'caiji') { //入库 $api = $this->input->get('api', TRUE); $page = intval($this->input->get('page')); $cid = intval($this->input->get('cid')); $ac = $this->input->get('ac', TRUE); $ops = $this->input->get('op', TRUE); $key = $keys = $this->input->get('key', TRUE); $ids = $this->input->get('ids', TRUE); if ($page == 0) { $page = 1; } if ($ops == '24') { $ops = 'day'; } if ($ops == 'day') { $op = 24; } elseif ($ops == 'week') { $op = 98; } else { $op = 0; } //绑定分类数组 $LIST = (require_once APPPATH . 'config/bind.php'); $api_url = '?api=' . $api . '&rid=' . $rid . '&op=' . $op . '&ac=' . $ac . '&do=caiji&key=' . $key . '&cid=' . $cid; if ($api) { $API_URL = cs_base64_decode($api) . '?ac=videolist&rid=' . $rid . '&wd=' . $key . '&t=' . $cid . '&h=' . $op . '&ids=' . $ids . '&pg=' . $page; $strs = htmlall($API_URL, 'gbk'); if (empty($strs)) { admin_msg('<font color=red>采集失败,请多试几次,如一直出现该错误,通常为网络不稳定或禁用了采集!</font>', 'javascript:history.go(-1);'); } //组合分页信息 preg_match('<list page="([0-9]+)" pagecount="([0-9]+)" pagesize="([0-9]+)" recordcount="([0-9]+)">', $strs, $page_array); if (!empty($page_array)) { $recordcount = $page_array[4]; $pagecount = $page_array[2]; $pagesize = $page_array[3]; $pageindex = $page_array[1]; } else { $recordcount = 0; $pagecount = 0; $pagesize = 0; $pageindex = 0; } echo '<LINK href="' . base_url() . 'packs/admin/css/style.css" type="text/css" rel="stylesheet"><br>'; echo '<div id="loading" style="display:none;position: absolute;left:40%;top:300px;z-index:10;"><span style="width:100px;height:40px;line-height:40px;background-color:#ccc;"> <img align="absmiddle" src="' . Web_Path . 'packs/admin/images/loading.gif">数据加载中</span></div>'; echo " <b><font color=#0000ff>当前页共有" . $recordcount . "个数据,需要采集" . $pagecount . "次,每一次采集" . $pagesize . "个,正在执行第" . $pageindex . "次采集任务</font></b><br/>"; //组合列表 $vod = ''; preg_match_all('/<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>/', $strs, $vod_array); $s = 1; foreach ($vod_array[1] as $key => $value) { $p = ($pageindex - 1) * $pagesize + $s; $add['name'] = str_replace("'", "", htmlspecialchars_decode($vod_array[4][$key])); $add['pic'] = $vod_array[6][$key]; $add['uid'] = 1; $add['daoyan'] = str_replace(" ", "/", str_replace("'", "", htmlspecialchars_decode($vod_array[13][$key]))); $add['zhuyan'] = str_replace(" ", "/", str_replace("'", "", htmlspecialchars_decode($vod_array[12][$key]))); $add['year'] = $vod_array[9][$key]; $add['diqu'] = $vod_array[8][$key]; $add['yuyan'] = $vod_array[7][$key]; $add['remark'] = empty($vod_array[10][$key]) ? '完结' : $vod_array[10][$key]; $add['text'] = str_replace("'", "", htmlspecialchars_decode($vod_array[15][$key])); $add['addtime'] = time(); $add['daoyan'] = str_replace("//", "/", $add['daoyan']); $add['zhuyan'] = str_replace("//", "/", $add['zhuyan']); preg_match_all('/<dd flag="([\\s\\S]*?)"><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/dd>/', $vod_array[14][$key], $url_arr); $laiy = $url_arr[1]; $purl = implode('#cscms#', $url_arr[2]); $purl = htmlspecialchars_decode($purl); $purl = str_replace("xigua", "xgvod", $purl); $purl = str_replace("xfplay", "yyxf", $purl); $purl = str_replace("yyxf://", "xfplay://", $purl); $purl = str_replace("百度影音", "bdhd", $purl); $purl = str_replace("#", "\n", $purl); $purl = str_replace("\ncscms\n", "#cscms#", $purl); $purl = str_replace("\r", "", $purl); $add['purl'] = $purl; //判断绑定 $val = arr_key_value($LIST, $ac . '_' . $vod_array[3][$key]); if (!$val) { echo " 第" . $p . "个影片 <font color=red>" . $vod_array[4][$key] . "</font> 数据没有绑定分类,不进行入库处理!<br/>"; //判断数据完整性 } elseif (empty($vod_array[4][$key]) || empty($purl)) { echo " 第" . $p . "个影片 <font color=red>" . $vod_array[4][$key] . "</font> 数据不完整,不进行入库处理!<br/>"; } else { $add['cid'] = $val; //判断数据是否存在 $sql = "SELECT id,purl,remark FROM " . CS_SqlPrefix . "vod where name='" . $add['name'] . "'"; $row = $this->db->query($sql)->row(); if (!$row) { $this->CsdjDB->get_insert('vod', $add); echo " 第" . $p . "个影片 <font color=#ff00ff>" . $vod_array[4][$key] . "</font>数据库中没有记录,已入库完成!<br/>"; } else { //判断更新状态 if ($row->remark == $add['remark'] && strpos($row->purl, '$' . $ac) !== FALSE) { echo " 第" . $p . "个影片 <font color=#ff6600>" . $vod_array[4][$key] . "</font> 数据相同,暂无不需要更新<br/>"; } else { //判断来源 $lyid = 0; $lyarr = explode("#cscms#", $row->purl); for ($i = 0; $i < count($lyarr); $i++) { $ly = explode("\$", $lyarr[$i]); if (in_array($ly[2], $laiy)) { $lyid = 1; $laiyname = $ly[2]; break; } } if ($lyid == 0) { //来源不存在 $edit['purl'] = $row->purl . '#cscms#' . $purl; echo " 第" . $p . "个影片 <font color=#ff00ff>" . $vod_array[4][$key] . "</font> 数据存在,增加一组来源数据成功~!<br/>"; } else { $url_all = explode("#cscms#", $row->purl); $CS_PlayUrl = ''; for ($j = 0; $j < count($url_all); $j++) { $url_aa = explode("\n", $url_all[$j]); $url_ss = explode("\$", $url_aa[0]); if ($url_ss[2] == $laiyname) { $ji = count($url_aa); $CS_PlayUrl = $url_all[$j]; break; } } $edit['remark'] = $add['remark']; $edit['purl'] = str_replace($CS_PlayUrl, $purl, $row->purl); echo " 第" . $p . "个影片 <font color=#ff00ff>" . $vod_array[4][$key] . "</font> 数据存在,数据更新成功~!<br/>"; } //更新数据 $edit['addtime'] = time(); $this->CsdjDB->get_update('vod', $row->id, $edit); } } } $s++; } if ($pageindex < $pagecount) { //缓存断点续采 $jumpurl = site_url('vod/admin/apiku') . $api_url . '&page=' . ($page + 1); write_file(APPPATH . "config/jumpurl.txt", $jumpurl); //跳转到下一页 echo "</br> <a href='" . site_url('vod/admin/apiku') . "?api=" . $api . "&op=" . $ops . "&ac=" . $ac . "&key=" . $keys . "&cid=" . $cid . "'>紧急停止</a> <b> 第<font color=red>" . $page . "</font>页入库完毕,暂停<font color=red>3</font>秒继续。。。。。</b><script>setTimeout('updatenext();',3000);\r\n\t\t\t\t\t\t\t\tfunction updatenext(){\r\n\t\t\t\t\t\t\t\t\tdocument.getElementById('loading').style.display = 'block';\r\n\t\t\t\t\t\t\t\t\tlocation.href='" . $api_url . "&page=" . ($page + 1) . "';\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t</script></br></br>"; } else { //清除断点续采 write_file(APPPATH . "config/jumpurl.txt", "0"); echo "</br> <b>恭喜您,全部入库完成啦。。。。。</b><script>\r\n\t\t\t\t\t\t\t\tsetTimeout('updatenext();',3000);\r\n\t\t\t\t\t\t\t\tfunction updatenext(){\r\n\t\t\t\t\t\t\t\t\tdocument.getElementById('loading').style.display = 'block';\r\n\t\t\t\t\t\t\t\t\tlocation.href='" . site_url('vod/admin/apiku') . str_replace("&do=caiji", "", $api_url) . "';\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t</script>"; } } else { admin_msg('<font color=red>API错误!</font>', 'javascript:history.go(-1);'); } } elseif (!empty($ac)) { //资源库查看 $api = $this->input->get('api', TRUE); $page = intval($this->input->get('page')); $cid = intval($this->input->get('cid')); $ac = $this->input->get('ac', TRUE); $op = $this->input->get('op', TRUE); $key = $this->input->get('key', TRUE); if ($page == 0) { $page = 1; } if ($op == 'all') { $op = 0; } $data['api_url'] = '?api=' . $api . '&rid=' . $rid . '&op=' . $op . '&ac=' . $ac . '&key=' . $key . '&cid=' . $cid; $data['key'] = $key; $data['op'] = $op; $data['cid'] = $cid; $data['rid'] = $rid; $data['api'] = $api; if ($api) { $API_URL = cs_base64_decode($api) . '?ac=list&rid=' . $rid . '&wd=' . $key . '&t=' . $cid . '&h=0&ids=&pg=' . $page; $strs = htmlall($API_URL, 'gbk'); if (empty($strs)) { admin_msg('<font color=red>获取列表失败,请多试几次,如一直出现该错误,通常为网络不稳定或禁用了采集!</font>', 'javascript:history.go(-1);'); } //组合分页信息 preg_match('<list page="([0-9]+)" pagecount="([0-9]+)" pagesize="([0-9]+)" recordcount="([0-9]+)">', $strs, $page_array); $data['recordcount'] = $page_array[4]; $data['pagecount'] = $page_array[2]; $data['pagesize'] = $page_array[3]; $data['pageindex'] = $page_array[1]; $path = site_url('vod/admin/apiku') . $data['api_url'] . '&key=' . $key . '&cid=' . $cid . '&'; $data['pages'] = get_admin_page($data['api_url'], $data['pagecount'], $page, 10); //组合列表 $vod = ''; preg_match_all('/<video>([\\s\\S]*?)<\\/video>/', $strs, $vod_array); foreach ($vod_array[1] as $key => $value) { preg_match_all('/<last>([\\s\\S]*?)<\\/last>/', $value, $times); preg_match_all('/<id>([0-9]+)<\\/id>/', $value, $ids); preg_match_all('/<tid>([0-9]+)<\\/tid>/', $value, $cids); preg_match_all('/<name><\\!\\[CDATA\\[([\\s\\S]*?)\\]\\]><\\/name>/', $value, $names); preg_match_all('/<type>([\\s\\S]*?)<\\/type>/', $value, $cnames); preg_match_all('/<dt>([\\s\\S]*?)<\\/dt>/', $value, $dts); $vod[$key]['addtime'] = $times[1][0]; $vod[$key]['id'] = $ids[1][0]; $vod[$key]['cid'] = intval($cids[1][0]); $vod[$key]['name'] = $names[1][0]; $vod[$key]['laiy'] = !empty($dts[1][0]) ? Laiyuan($dts[1][0]) : $ac; $vod[$key]['cname'] = $cnames[1][0]; } $data['vod'] = $vod; //组合分类 preg_match_all('/<ty id="([0-9]+)">([\\s\\S]*?)<\\/ty>/', $strs, $list_array); foreach ($list_array[1] as $key => $value) { $vod_list[$key]['id'] = $value; $vod_list[$key]['name'] = $list_array[2][$key]; } $data['vod_list'] = $vod_list; $data['ac'] = $ac; $data['page'] = $page; $data['LIST'] = (require_once APPPATH . 'config/bind.php'); $this->load->view('apiku_list.html', $data); } else { admin_msg('<font color=red>API错误!</font>', 'javascript:history.go(-1);'); } } elseif (empty($do)) { //资源库首页 $data['jumpurl'] = @file_get_contents(APPPATH . "config/jumpurl.txt"); $data['api'] = 'http://vod.chshcms.com/api/cscms_zy_4.x_utf8.js?' . rand(1000, 9999); $this->load->view('apiku.html', $data); } }