示例#1
0
文件: prop.app.php 项目: sunhk25/iCMS
 function do_save()
 {
     $pid = (int) $_POST['pid'];
     $cid = (int) $_POST['cid'];
     $ordernum = (int) $_POST['ordernum'];
     $field = iS::escapeStr($_POST['field']);
     $name = iS::escapeStr($_POST['name']);
     $type = iS::escapeStr($_POST['type']);
     $val = iS::escapeStr($_POST['val']);
     $field == 'pid' && !is_numeric($val) && iPHP::alert('pid字段的值只能用数字');
     $field or iPHP::alert('属性字段不能为空!');
     $name or iPHP::alert('属性名称不能为空!');
     $type or iPHP::alert('类型不能为空!');
     $field == 'pid' && ($val = (int) $val);
     $fields = array('rootid', 'cid', 'field', 'type', 'ordernum', 'name', 'val');
     $data = compact($fields);
     if ($pid) {
         iDB::update('prop', $data, array('pid' => $pid));
         $msg = "属性更新完成!";
     } else {
         iDB::value("SELECT `pid` FROM `#iCMS@__prop` where `type` ='{$type}' AND `val` ='{$val}' AND `field` ='{$field}' AND `cid` ='{$cid}'") && iPHP::alert('该类型属性值已经存在!请另选一个');
         iDB::insert('prop', $data);
         $msg = "新属性添加完成!";
     }
     $this->cache();
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#2
0
 function do_update()
 {
     if ($this->id) {
         $data = iACP::fields($_GET['iDT']);
         $data && iDB::update("marker", $data, array('id' => $this->id));
         $this->cache($this->id);
         iPHP::success('操作成功!', 'js:1');
     }
 }
示例#3
0
 function do_save()
 {
     $id = (int) $_POST['id'];
     $keyword = iS::escapeStr($_POST['keyword']);
     $url = iS::escapeStr($_POST['url']);
     $times = (int) $_POST['times'];
     $keyword or iPHP::alert('关键词不能为空!');
     $url or iPHP::alert('链接不能为空!');
     $fields = array('keyword', 'url', 'times');
     $data = compact($fields);
     if (empty($id)) {
         iDB::value("SELECT `id` FROM `#iCMS@__keywords` where `keyword` ='{$keyword}'") && iPHP::alert('该关键词已经存在!');
         iDB::insert('keywords', $data);
         $this->cache();
         $msg = "关键词添加完成!";
     } else {
         iDB::value("SELECT `id` FROM `#iCMS@__keywords` where `keyword` ='{$keyword}' AND `id` !='{$id}'") && iPHP::alert('该关键词已经存在!');
         iDB::update('keywords', $data, array('id' => $id));
         $this->cache();
         $msg = "关键词编辑完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#4
0
 function do_save()
 {
     $id = (int) $_POST['id'];
     $cid = (int) $_POST['cid'];
     $name = iS::escapeStr($_POST['name']);
     $logo = iS::escapeStr($_POST['logo']);
     $url = iS::escapeStr($_POST['url']);
     $desc = iS::escapeStr($_POST['desc']);
     $ordernum = (int) $_POST['ordernum'];
     $name or iPHP::alert('网站不能为空!');
     $url or iPHP::alert('链接不能为空!');
     $fields = array('cid', 'name', 'logo', 'url', 'desc', 'ordernum');
     $data = compact($fields);
     if (empty($id)) {
         iDB::value("SELECT `id` FROM `#iCMS@__links` where `name` ='{$name}'") && iPHP::alert('该网站已经存在!');
         iDB::insert('links', $data);
         $msg = "网站添加完成!";
     } else {
         iDB::value("SELECT `id` FROM `#iCMS@__links` where `name` ='{$name}' AND `id` !='{$id}'") && iPHP::alert('该网站已经存在!');
         iDB::update('links', $data, array('id' => $id));
         $msg = "网站编辑完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#5
0
 function do_saveproject()
 {
     $id = (int) $_POST['id'];
     $name = iS::escapeStr($_POST['name']);
     $urls = iS::escapeStr($_POST['urls']);
     $list_url = $_POST['list_url'];
     $cid = iS::escapeStr($_POST['cid']);
     $rid = iS::escapeStr($_POST['rid']);
     $poid = iS::escapeStr($_POST['poid']);
     $poid = iS::escapeStr($_POST['poid']);
     $checker = iS::escapeStr($_POST['checker']);
     $self = isset($_POST['self']) ? '1' : '0';
     $sleep = (int) $_POST['sleep'];
     $auto = iS::escapeStr($_POST['auto']);
     $psleep = (int) $_POST['psleep'];
     $lastupdate = $_POST['lastupdate'] ? iPHP::str2time($_POST['lastupdate']) : '';
     empty($name) && iPHP::alert('名称不能为空!');
     empty($cid) && iPHP::alert('请选择绑定的栏目');
     empty($rid) && iPHP::alert('请选择采集规则');
     //empty($poid)	&& iPHP::alert('请选择发布规则');
     $fields = array('name', 'urls', 'list_url', 'cid', 'rid', 'poid', 'checker', 'self', 'sleep', 'auto', 'lastupdate', 'psleep');
     $data = compact($fields);
     if ($id) {
         iDB::update('spider_project', $data, array('id' => $id));
     } else {
         iDB::insert('spider_project', $data);
     }
     iPHP::success('完成', 'url:' . APP_URI . '&do=project');
 }
示例#6
0
文件: push.app.php 项目: World3D/iCMS
 function do_save()
 {
     $id = (int) $_POST['id'];
     $cid = (int) $_POST['cid'];
     $_cid = (int) $_POST['_cid'];
     $userid = (int) $_POST['userid'];
     $pid = (int) $_POST['pid'];
     $editor = iS::escapeStr($_POST['editor']);
     $ordernum = _int($_POST['ordernum']);
     $addtime = iPHP::str2time($_POST['addtime']);
     $title = iS::escapeStr($_POST['title']);
     $pic = $this->getpic($_POST['pic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $title2 = iS::escapeStr($_POST['title2']);
     $pic2 = $this->getpic($_POST['pic2']);
     $description2 = iS::escapeStr($_POST['description2']);
     $url2 = iS::escapeStr($_POST['url2']);
     $title3 = iS::escapeStr($_POST['title3']);
     $pic3 = $this->getpic($_POST['pic3']);
     $description3 = iS::escapeStr($_POST['description3']);
     $url3 = iS::escapeStr($_POST['url3']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     empty($userid) && ($userid = iMember::$userid);
     empty($title) && iPHP::alert('1.标题必填');
     empty($cid) && iPHP::alert('请选择所属栏目');
     $haspic = empty($pic) ? 0 : 1;
     $status = 1;
     $fields = array('cid', 'rootid', 'pid', 'haspic', 'editor', 'userid', 'title', 'pic', 'url', 'description', 'title2', 'pic2', 'url2', 'description2', 'title3', 'pic3', 'url3', 'description3', 'ordernum', 'metadata', 'addtime', 'hits', 'status');
     $data = compact($fields);
     if (empty($id)) {
         iDB::insert('push', $data);
         iDB::query("UPDATE `#iCMS@__category` SET `count` = count+1 WHERE `cid` ='{$cid}' LIMIT 1 ");
         iPHP::success('推送完成', 'url:' . APP_URI);
     } else {
         iDB::update('push', $data, array('id' => $id));
         if ($_cid != $cid) {
             iDB::query("UPDATE `#iCMS@__category` SET `count` = count-1 WHERE `cid` ='{$_cid}' and `count`>0 LIMIT 1 ");
             iDB::query("UPDATE `#iCMS@__category` SET `count` = count+1 WHERE `cid` ='{$cid}' LIMIT 1 ");
         }
         iPHP::success('编辑完成!', 'url:' . APP_URI);
     }
 }
示例#7
0
文件: user.app.php 项目: sunhk25/iCMS
 public function ACTION_login()
 {
     iCMS::$config['user']['login']['enable'] or iPHP::code(0, 'user:login:forbidden', 'uname', 'json');
     $uname = iS::escapeStr($_POST['uname']);
     $pass = md5(trim($_POST['pass']));
     $remember = (bool) $_POST['remember'] ? ture : false;
     $openid = iS::escapeStr($_POST['openid']);
     $platform = iS::escapeStr($_POST['platform']);
     if (iCMS::$config['user']['login']['seccode']) {
         $seccode = iS::escapeStr($_POST['seccode']);
         iPHP::seccode($seccode, true) or iPHP::code(0, 'iCMS:seccode:error', 'seccode', 'json');
     }
     $remember && (user::$cookietime = 14 * 86400);
     $user = user::login($uname, $pass, strpos($uname, '@') === false ? 'nk' : 'un');
     if ($user === true) {
         if ($openid) {
             iDB::query("\n                    INSERT INTO `#iCMS@__user_openid`\n                           (`uid`, `openid`, `platform`)\n                    VALUES ('" . user::$userid . "', '{$openid}', '{$platform}');\n                ");
         }
         iPHP::code(1, 0, $this->forward, 'json');
     } else {
         if (iCMS::$config['user']['login']['interval']) {
             $cache_name = "iCMS/error/login." . md5($uname);
             $login_error = iCache::get($cache_name);
             if ($login_error) {
                 if ($login_error[1] >= 5) {
                     $_field = strpos($uname, '@') === false ? 'nickname' : 'username';
                     iDB::update('user', array('status' => '3'), array($_field => $uname));
                     iPHP::code(0, 'user:login:interval', 'uname', 'json');
                 } else {
                     $login_error[1]++;
                 }
             } else {
                 $login_error = array($uname, 1);
             }
             iCache::set($cache_name, $login_error, iCMS::$config['user']['login']['interval']);
         }
         // $lang = 'user:login:error';
         // $user && $lang.='_status_'.$user;
         iPHP::code(0, 'user:login:error', 'uname', 'json');
     }
 }
示例#8
0
 function do_save()
 {
     $gid = intval($_POST['gid']);
     $type = intval($_POST['type']);
     $name = iS::escapeStr($_POST['name']);
     $power = $_POST['power'] ? json_encode($_POST['power']) : '';
     $cpower = $_POST['cpower'] ? json_encode($_POST['cpower']) : '';
     $name or iPHP::alert('角色名不能为空');
     $fields = array('name', 'ordernum', 'power', 'cpower', 'type');
     $data = compact($fields);
     if ($gid) {
         iDB::update('group', $data, array('gid' => $gid));
         $msg = "角色修改完成!";
     } else {
         iDB::insert('group', $data);
         $msg = "角色添加完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#9
0
文件: user.app.php 项目: sunhk25/iCMS
 function do_batch()
 {
     $idA = (array) $_POST['id'];
     $idA or iPHP::alert("请选择要操作的用户");
     $ids = implode(',', (array) $_POST['id']);
     $batch = $_POST['batch'];
     switch ($batch) {
         case 'prop':
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', iCMS_APP_USER);
             $pid = implode(',', (array) $_POST['pid']);
             foreach ((array) $_POST['id'] as $id) {
                 $_pid = iDB::value("SELECT `pid` FROM `#iCMS@__user` where `uid`='{$id}' LIMIT 1");
                 iDB::update('user', compact('pid'), array('uid' => $id));
                 map::diff($pid, $_pid, $id);
             }
             iPHP::success('用户属性设置完成!', 'js:1');
             break;
         case 'dels':
             iPHP::$break = false;
             foreach ($idA as $id) {
                 $this->do_del($id, false);
             }
             iPHP::$break = true;
             iPHP::success('用户全部删除完成!', 'js:1');
             break;
     }
 }
示例#10
0
文件: tags.app.php 项目: sunhk25/iCMS
 function do_batch()
 {
     $idArray = (array) $_POST['id'];
     $idArray or iPHP::alert("请选择要操作的标签");
     $ids = implode(',', $idArray);
     $batch = $_POST['batch'];
     switch ($batch) {
         case 'dels':
             iPHP::$break = false;
             foreach ($idArray as $id) {
                 $this->do_del($id, false);
             }
             iPHP::$break = true;
             iPHP::success('标签全部删除完成!', 'js:1');
             break;
         case 'move':
             $_POST['cid'] or iPHP::alert("请选择目标栏目!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $cid = (int) $_POST['cid'];
             foreach ($idArray as $id) {
                 $_cid = iDB::value("SELECT `cid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('cid'), compact('id'));
                 if ($_cid != $cid) {
                     map::diff($cid, $_cid, $id);
                     $this->categoryApp->update_count_one($_cid, '-');
                     $this->categoryApp->update_count_one($cid);
                 }
             }
             iPHP::success('成功移动到目标栏目!', 'js:1');
             break;
         case 'mvtcid':
             $_POST['tcid'] or iPHP::alert("请选择目标分类!");
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('category', $this->appid);
             $tcid = (int) $_POST['tcid'];
             foreach ($idArray as $id) {
                 $_tcid = iDB::value("SELECT `tcid` FROM `#iCMS@__tags` where `id` ='{$id}'");
                 iDB::update("tags", compact('tcid'), compact('id'));
                 if ($_tcid != $tcid) {
                     map::diff($tcid, $_tcid, $id);
                     $this->categoryApp->update_count_one($_tcid, '-');
                     $this->categoryApp->update_count_one($tcid);
                 }
             }
             iPHP::success('成功移动到目标分类!', 'js:1');
             break;
         case 'prop':
             iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
             map::init('prop', $this->appid);
             $pid = implode(',', (array) $_POST['pid']);
             foreach ((array) $_POST['id'] as $id) {
                 $_pid = iDB::value("SELECT pid FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                 iDB::update("tags", compact('pid'), compact('id'));
                 map::diff($pid, $_pid, $id);
             }
             iPHP::success('属性设置完成!', 'js:1');
             break;
         case 'weight':
             $weight = _int($_POST['mweight']);
             $sql = "`weight` = '{$weight}'";
             break;
         case 'tpl':
             $tpl = iS::escapeStr($_POST['mtpl']);
             $sql = "`tpl` = '{$tpl}'";
             break;
         case 'keyword':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`keywords` = '" . iS::escapeStr($_POST['mkeyword']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT keywords FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`keywords` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mkeyword']) : iS::escapeStr($_POST['mkeyword'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('关键字更改完成!', 'js:1');
             }
             break;
         case 'tag':
             if ($_POST['pattern'] == 'replace') {
                 $sql = "`related` = '" . iS::escapeStr($_POST['mtag']) . "'";
             } elseif ($_POST['pattern'] == 'addto') {
                 foreach ($idArray as $id) {
                     $keywords = iDB::value("SELECT related FROM `#iCMS@__tags` WHERE `id`='{$id}'");
                     $sql = "`related` = '" . ($keywords ? $keywords . ',' . iS::escapeStr($_POST['mtag']) : iS::escapeStr($_POST['mtag'])) . "'";
                     iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id`='{$id}'");
                 }
                 iPHP::success('相关标签更改完成!', 'js:1');
             }
             break;
         default:
             if (strpos($batch, ':')) {
                 $data = iACP::fields($batch);
                 foreach ($idArray as $id) {
                     $data && iDB::update("tags", $data, array('id' => $id));
                 }
                 iPHP::success('操作成功!', 'js:1');
             } else {
                 iPHP::alert('请选择要操作项!', 'js:1');
             }
     }
     $sql && iDB::query("UPDATE `#iCMS@__tags` SET {$sql} WHERE `id` IN ({$ids})");
     iPHP::success('操作成功!', 'js:1');
 }
示例#11
0
 public static function update_spider_url_ids($indexid = 0)
 {
     foreach ((array) spider::$spider_url_ids as $key => $suid) {
         if ($indexid) {
             $data = array('indexid' => $indexid);
         } else {
             $data = array('pid' => spider::$pid, 'publish' => '1', 'status' => '1', 'pubdate' => time());
         }
         iDB::update('spider_url', $data, array('id' => $suid));
     }
 }
示例#12
0
文件: menu.app.php 项目: sunhk25/iCMS
 function do_save()
 {
     $id = $_POST['id'];
     $rootid = $_POST['rootid'];
     $app = $_POST['app'];
     $name = $_POST['name'];
     $title = $_POST['title'];
     $href = $_POST['href'];
     $a_class = $_POST['a_class'];
     $icon = $_POST['icon'];
     $target = $_POST['target'];
     $data_toggle = $_POST['data-toggle'];
     $ordernum = $_POST['ordernum'];
     $class = '';
     $caret = '';
     $data_meta = $_POST['data-meta'];
     $data_target = '';
     if ($data_toggle == "dropdown") {
         $class = 'dropdown';
         $a_class = 'dropdown-toggle';
         $caret = '<b class="caret"></b>';
     } else {
         if ($data_toggle == "modal") {
             $data_meta or $data_meta = '{"width":"800px","height":"600px"}';
             $data_target = '#iCMS-MODAL';
         }
     }
     $fields = array('rootid', 'ordernum', 'app', 'name', 'title', 'href', 'icon', 'class', 'a_class', 'target', 'caret', 'data-toggle', 'data-meta', 'data-target');
     $data = compact($fields);
     $data['data-toggle'] = $data_toggle;
     $data['data-meta'] = $data_meta;
     $data['data-target'] = $data_target;
     if ($id) {
         iDB::update('menu', $data, array('id' => $id));
         $msg = "编辑完成!";
     } else {
         iDB::insert('menu', $data);
         $msg = "添加完成!";
     }
     iACP::$menu->cache();
     iPHP::success($msg, 'url:' . APP_URI . '&do=manage');
 }
示例#13
0
 public static function crawl($work = NULL, $pid = NULL, $_rid = NULL, $_urls = null, $callback = null)
 {
     $pid === NULL && ($pid = spider::$pid);
     if ($pid) {
         $project = spider::project($pid);
         $cid = $project['cid'];
         $rid = $project['rid'];
         $prule_list_url = $project['list_url'];
         $lastupdate = $project['lastupdate'];
     } else {
         $cid = spider::$cid;
         $rid = spider::$rid;
     }
     if (empty($rid) && $_rid !== NULL) {
         $rid = $_rid;
     }
     if ($work == 'shell') {
         $lastupdate = $project['lastupdate'];
         if ($project['psleep']) {
             if (time() - $lastupdate < $project['psleep']) {
                 echo '采集方案[' . $pid . "]:" . format_date($lastupdate) . "刚采集过了,请" . $project['psleep'] / 3600 . "小时后在继续采集\n";
                 return;
             }
         }
         echo "开始采集方案[" . $pid . "] 采集规则[" . $rid . "]\n";
     }
     $ruleA = spider::rule($rid);
     $rule = $ruleA['rule'];
     $urls = $rule['list_urls'];
     $project['urls'] && ($urls = $project['urls']);
     spiderUrls::$urls && ($urls = spiderUrls::$urls);
     $_urls && ($urls = $_urls);
     $urlsArray = explode("\n", $urls);
     $urlsArray = array_filter($urlsArray);
     $_urlsArray = $urlsArray;
     $urlsList = array();
     if ($work == 'shell') {
         // echo "$urls\n";
         print_r($urlsArray);
     }
     foreach ($_urlsArray as $_key => $_url) {
         $_url = htmlspecialchars_decode($_url);
         $_urlsList = array();
         /**
          * RULE@rid@url
          * url使用[rid]规则采集并返回列表结果
          */
         if (strpos($_url, 'RULE@') !== false) {
             list($___s, $_rid, $_urls) = explode('@', $_url);
             if (spider::$ruleTest) {
                 print_r('<b>使用[rid:' . $_rid . ']规则抓取列表</b>:' . $_urls);
                 echo "<hr />";
             }
             $_urlsList = spiderUrls::crawl($work, false, $_rid, $_urls, 'CALLBACK@URL');
             $urlsList = array_merge($urlsList, $_urlsList);
             unset($urlsArray[$_key]);
         } else {
             preg_match('|.*<(.*)>.*|is', $_url, $_matches);
             if ($_matches) {
                 list($format, $begin, $num, $step, $zeroize, $reverse) = explode(',', $_matches[1]);
                 $url = str_replace($_matches[1], '*', trim($_matches[0]));
                 $_urlsList = spiderTools::mkurls($url, $format, $begin, $num, $step, $zeroize, $reverse);
                 unset($urlsArray[$_key]);
                 $urlsList = array_merge($urlsList, $_urlsList);
             }
         }
     }
     $urlsList && ($urlsArray = array_merge($urlsArray, $urlsList));
     unset($_urlsArray, $_key, $_url, $_matches, $_urlsList, $urlsList);
     $urlsArray = array_unique($urlsArray);
     // spider::$useragent = $rule['user_agent'];
     // spider::$encoding  = $rule['curl']['encoding'];
     // spider::$referer   = $rule['curl']['referer'];
     // spider::$charset   = $rule['charset'];
     if (empty($urlsArray)) {
         if ($work == 'shell') {
             echo "采集列表为空!请填写!\n";
             return false;
         }
         iPHP::alert('采集列表为空!请填写!', 'js:parent.window.iCMS_MODAL.destroy();');
     }
     //      if(spider::$ruleTest){
     //          echo "<pre>";
     //          print_r(iS::escapeStr($project));
     //          print_r(iS::escapeStr($rule));
     //          echo "</pre>";
     //          echo "<hr />";
     //      }
     if ($rule['mode'] == "2") {
         iPHP::import(iPHP_LIB . '/phpQuery.php');
         spider::$ruleTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
     }
     $pubArray = array();
     $pubCount = array();
     $pubAllCount = array();
     spider::$curl_proxy = $rule['proxy'];
     spider::$urlslast = null;
     foreach ($urlsArray as $key => $url) {
         $url = trim($url);
         spider::$urlslast = $url;
         if ($work == 'shell') {
             echo '开始采集列表:' . $url . "\n";
         }
         if (spider::$ruleTest) {
             echo '<b>抓取列表:</b>' . $url . "<br />";
         }
         $html = spiderTools::remote($url);
         if (empty($html)) {
             continue;
         }
         if ($rule['mode'] == "2") {
             $doc = phpQuery::newDocumentHTML($html, 'UTF-8');
             $list_area = $doc[trim($rule['list_area_rule'])];
             // if(strpos($rule['list_area_format'], 'DOM::')!==false){
             //     $list_area = spiderTools::dataClean($rule['list_area_format'], $list_area);
             // }
             if ($rule['list_area_format']) {
                 $list_area_format = trim($rule['list_area_format']);
                 if (strpos($list_area_format, 'ARRAY::') !== false) {
                     $list_area_format = str_replace('ARRAY::', '', $list_area_format);
                     $lists = array();
                     foreach ($list_area as $la_key => $la) {
                         $lists[] = phpQuery::pq($list_area_format, $la);
                     }
                 } else {
                     $lists = phpQuery::pq($list_area_format, $list_area);
                 }
             } else {
                 $lists = $list_area;
             }
             // $lists = $list_area;
             //echo 'list:getDocumentID:'.$lists->getDocumentID()."\n";
         } else {
             $list_area_rule = spiderTools::pregTag($rule['list_area_rule']);
             if ($list_area_rule) {
                 preg_match('|' . $list_area_rule . '|is', $html, $matches, $PREG_SET_ORDER);
                 $list_area = $matches['content'];
             } else {
                 $list_area = $html;
             }
             $html = null;
             unset($html);
             if (spider::$ruleTest) {
                 echo iS::escapeStr($rule['list_area_rule']);
                 //              echo iS::escapeStr($list_area);
                 echo "<hr />";
             }
             if ($rule['list_area_format']) {
                 $list_area = spiderTools::dataClean($rule['list_area_format'], $list_area);
             }
             preg_match_all('|' . spiderTools::pregTag($rule['list_url_rule']) . '|is', $list_area, $lists, PREG_SET_ORDER);
             $list_area = null;
             unset($list_area);
             if ($rule['sort'] == "1") {
                 //arsort($lists);
             } elseif ($rule['sort'] == "2") {
                 asort($lists);
             } elseif ($rule['sort'] == "3") {
                 shuffle($lists);
             }
         }
         if (spider::$ruleTest) {
             echo '<b>列表区域规则:</b>' . iS::escapeStr($rule['list_area_rule']);
             echo "<hr />";
             echo '<b>列表区域抓取结果:</b>' . iS::escapeStr($list_area);
             echo "<hr />";
             echo '<b>列表链接规则:</b>' . iS::escapeStr($rule['list_url_rule']);
             echo "<hr />";
             echo '<b>网址合成规则:</b>' . iS::escapeStr($rule['list_url']);
             echo "<hr />";
         }
         if ($prule_list_url) {
             $rule['list_url'] = $prule_list_url;
         }
         //PID@xx 返回URL列表
         if ($callback == 'CALLBACK@URL') {
             $cbListUrl = array();
             foreach ($lists as $lkey => $row) {
                 list(spider::$title, spider::$url) = spiderTools::title_url($row, $rule, $url);
                 if (spider::$url === false) {
                     continue;
                 }
                 // if(spider::checker($work)===true){
                 $cbListUrl[] = spider::$url;
                 // }
             }
             return $cbListUrl;
         }
         if ($work == "shell") {
             $pubCount[$url]['count'] = count($lists);
             $pubAllCount['count'] += $pubCount[$url]['count'];
             echo "开始采集:" . $url . " 列表 " . $pubCount[$url]['count'] . "条记录\n";
             foreach ($lists as $lkey => $row) {
                 list(spider::$title, spider::$url) = spiderTools::title_url($row, $rule, $url);
                 if (spider::$url === false) {
                     continue;
                 }
                 $hash = md5(spider::$url);
                 echo "title:" . spider::$title . "\n";
                 echo "url:" . spider::$url . "\n";
                 spider::$rid = $rid;
                 $checker = spider::checker($work);
                 if ($checker === true) {
                     echo "开始采集....";
                     $callback = spider::publish("shell");
                     if ($callback['code'] == "1001") {
                         $pubCount[$url]['success']++;
                         $pubAllCount['success']++;
                         echo "....√\n";
                         if ($project['sleep']) {
                             echo "sleep:" . $project['sleep'] . "s\n";
                             if ($rule['mode'] != "2") {
                                 unset($lists[$lkey]);
                             }
                             gc_collect_cycles();
                             sleep($project['sleep']);
                         } else {
                             //sleep(1);
                         }
                     } else {
                         $pubCount[$url]['error']++;
                         $pubAllCount['error']++;
                         echo "error\n\n";
                         continue;
                     }
                 }
                 $pubCount[$url]['published']++;
                 $pubAllCount['published']++;
             }
             if ($rule['mode'] == "2") {
                 phpQuery::unloadDocuments($doc->getDocumentID());
             } else {
                 unset($lists);
             }
         }
         if ($work == "WEB@MANUAL") {
             $listsArray[$url] = $lists;
         }
         if ($work == "WEB@AUTO" || $work == 'DATA@RULE') {
             foreach ($lists as $lkey => $row) {
                 list(spider::$title, spider::$url) = spiderTools::title_url($row, $rule, $url);
                 if (spider::$url === false) {
                     continue;
                 }
                 $hash = md5(spider::$url);
                 if (spider::$ruleTest) {
                     echo '<b>列表抓取结果:</b>' . $lkey . '<br />';
                     echo spider::$title . ' (<a href="' . APP_URI . '&do=testdata' . '&url=' . urlencode(spider::$url) . '&rid=' . $rid . '&pid=' . $pid . '&title=' . urlencode(spider::$title) . '" target="_blank">测试内容规则</a>) <br />';
                     echo spider::$url . "<br />";
                     echo $hash . "<br /><hr />";
                 } else {
                     if (spider::checker($work) === true || spider::$dataTest) {
                         $suData = array('sid' => 0, 'url' => spider::$url, 'title' => spider::$title, 'cid' => $cid, 'rid' => $rid, 'pid' => $pid, 'hash' => $hash);
                         switch ($work) {
                             case 'DATA@RULE':
                                 $contentArray[$lkey] = spiderData::crawl();
                                 // $contentArray[$lkey] = spiderUrls::crawl($work,$_pid);
                                 unset($suData['sid']);
                                 $suData['title'] = addslashes($suData['title']);
                                 $suData += array('addtime' => time(), 'status' => '2', 'publish' => '2', 'indexid' => '0', 'pubdate' => '0');
                                 spider::$dataTest or $suid = iDB::insert('spider_url', $suData);
                                 $contentArray[$lkey]['spider_url'] = $suid;
                                 break;
                             case 'WEB@AUTO':
                                 $pubArray[] = $suData;
                                 break;
                         }
                     }
                 }
             }
         }
     }
     $lists = null;
     unset($lists);
     gc_collect_cycles();
     switch ($work) {
         case 'WEB@AUTO':
             return $pubArray;
             break;
         case 'DATA@RULE':
             return $contentArray;
             break;
         case 'WEB@MANUAL':
             return array('cid' => $cid, 'rid' => $rid, 'pid' => $pid, 'sid' => $sid, 'work' => $work, 'rule' => $rule, 'listsArray' => $listsArray);
             break;
         case "shell":
             echo "采集数据统结果:\n";
             print_r($pubCount);
             print_r($pubAllCount);
             echo "全部采集完成....\n";
             iDB::update('spider_project', array('lastupdate' => time()), array('id' => $pid));
             break;
     }
 }
示例#14
0
 public static function update_spider_url_publish($suid)
 {
     iDB::update('spider_url', array('publish' => '1', 'pubdate' => time()), array('id' => $suid));
 }
示例#15
0
 function do_save()
 {
     $appid = $this->appid;
     $cid = (int) $_POST['cid'];
     $rootid = (int) $_POST['rootid'];
     $status = (int) $_POST['status'];
     $isucshow = (int) $_POST['isucshow'];
     $issend = (int) $_POST['issend'];
     $isexamine = (int) $_POST['isexamine'];
     $ordernum = (int) $_POST['ordernum'];
     $mode = (int) $_POST['mode'];
     $pid = implode(',', (array) $_POST['pid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_rootid_hash = iS::escapeStr($_POST['_rootid_hash']);
     $name = iS::escapeStr($_POST['name']);
     $subname = iS::escapeStr($_POST['subname']);
     $domain = iS::escapeStr($_POST['domain']);
     $htmlext = iS::escapeStr($_POST['htmlext']);
     $url = iS::escapeStr($_POST['url']);
     $password = iS::escapeStr($_POST['password']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $dir = iS::escapeStr($_POST['dir']);
     $title = iS::escapeStr($_POST['title']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $description = iS::escapeStr($_POST['description']);
     $categoryURI = iS::escapeStr($_POST['categoryURI']);
     $categoryRule = iS::escapeStr($_POST['categoryRule']);
     $contentRule = iS::escapeStr($_POST['contentRule']);
     $urlRule = iS::escapeStr($_POST['urlRule']);
     $indexTPL = iS::escapeStr($_POST['indexTPL']);
     $listTPL = iS::escapeStr($_POST['listTPL']);
     $contentTPL = iS::escapeStr($_POST['contentTPL']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $contentprop = iS::escapeStr($_POST['contentprop']);
     $body = $_POST['body'];
     $hasbody = (int) $_POST['hasbody'];
     $hasbody or $hasbody = $body ? 1 : 0;
     if ($_rootid_hash) {
         $_rootid = authcode($_rootid_hash);
         if ($rootid != $_rootid) {
             iPHP::alert('非法数据提交!');
         } else {
             iACP::CP($_rootid, 'a', 'alert');
             exit;
         }
     }
     $cid && $cid == $rootid && iPHP::alert('不能以自身做为上级' . $this->category_name);
     empty($name) && iPHP::alert($this->category_name . '名称不能为空!');
     if ($metadata) {
         $md = array();
         foreach ($metadata['key'] as $_mk => $_mval) {
             !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->category_name . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
             $md[$_mval] = $metadata['value'][$_mk];
         }
         $metadata = addslashes(serialize($md));
     }
     if ($contentprop) {
         $ca = array();
         foreach ($contentprop['key'] as $_cak => $_caval) {
             $_caval or $_caval = strtolower(pinyin($contentprop['name'][$_cak]));
             !preg_match("/[a-zA-Z0-9_\\-]/", $_caval) && iPHP::alert('内容附加属性字段只能由英文字母、数字或_-组成(不支持中文)');
             $ca[$_caval] = $contentprop['name'][$_cak];
         }
         $contentprop = addslashes(serialize($ca));
     }
     if ($mode == "2") {
         if (strpos($categoryRule, '{CDIR}') === FALSE && strpos($categoryRule, '{CID}') === FALSE && strpos($categoryRule, '{0xCID}') === FALSE) {
             iPHP::alert('伪静态模式下版块URL规则<hr />必需要有<br />{CDIR}版块目录<br />或者<br />{CID},{0xCID}版块ID');
         }
         if (strpos($contentRule, '{ID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) {
             iPHP::alert('伪静态模式下内容URL规则<hr />必需要有<br />{ID}' . $this->_app_name . 'ID <br />或者<br />{0xID}' . $this->_app_name . 'ID补零<br />或者<br />{LINK}' . $this->_app_name . '自定义链接');
         }
     }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     map::init('prop', iCMS_APP_CATEGORY);
     $fields = array('rootid', 'appid', 'ordernum', 'name', 'subname', 'password', 'title', 'keywords', 'description', 'dir', 'mode', 'domain', 'url', 'pic', 'mpic', 'spic', 'htmlext', 'categoryURI', 'categoryRule', 'contentRule', 'urlRule', 'indexTPL', 'listTPL', 'contentTPL', 'metadata', 'contentprop', 'hasbody', 'pid', 'isexamine', 'issend', 'isucshow', 'status');
     $data = compact($fields);
     if (empty($cid)) {
         iACP::CP($rootid, 'a', 'alert');
         $nameArray = explode("\n", $name);
         $_count = count($nameArray);
         foreach ($nameArray as $nkey => $_name) {
             $_name = trim($_name);
             if (empty($_name)) {
                 continue;
             }
             if ($_count == "1") {
                 if (empty($dir) && empty($url)) {
                     $dir = strtolower(pinyin($_name));
                 }
             } else {
                 empty($url) && ($dir = strtolower(pinyin($_name)));
             }
             $this->check_dir($dir, $appid, $url);
             $data['name'] = $_name;
             $data['dir'] = $dir;
             $data['userid'] = iMember::$userid;
             $data['creator'] = iMember::$nickname;
             $data['createtime'] = time();
             $data['count'] = '0';
             $data['comments'] = '0';
             $cid = iDB::insert('category', $data);
             $pid && map::add($pid, $cid);
             $this->cache(false, $this->appid);
             $this->cahce_one($cid);
         }
         $msg = $this->category_name . "添加完成!";
     } else {
         if (empty($dir) && empty($url)) {
             $dir = strtolower(pinyin($name));
         }
         iACP::CP($cid, 'e', 'alert');
         $this->check_dir($dir, $appid, $url, $cid);
         $data['dir'] = $dir;
         iDB::update('category', $data, array('cid' => $cid));
         map::diff($pid, $_pid, $cid);
         $this->cahce_one($cid);
         $msg = $this->category_name . "编辑完成!";
     }
     $hasbody && iCache::set('iCMS/category/' . $cid . '.body', $body, 0);
     iPHP::success($msg, 'url:' . $this->category_uri);
 }
示例#16
0
 function do_save()
 {
     $uid = (int) $_POST['uid'];
     $gender = (int) $_POST['gender'];
     $type = $_POST['type'];
     $username = iS::escapeStr($_POST['uname']);
     $nickname = iS::escapeStr($_POST['nickname']);
     $realname = iS::escapeStr($_POST['realname']);
     $power = $_POST['power'] ? json_encode($_POST['power']) : '';
     $cpower = $_POST['cpower'] ? json_encode($_POST['cpower']) : '';
     $gid = 0;
     $info = array();
     $info['icq'] = iS::escapeStr($_POST['icq']);
     $info['home'] = iS::escapeStr($_POST['home']);
     $info['year'] = intval($_POST['year']);
     $info['month'] = intval($_POST['month']);
     $info['day'] = intval($_POST['day']);
     $info['from'] = iS::escapeStr($_POST['from']);
     $info['signature'] = iS::escapeStr($_POST['signature']);
     $info = addslashes(serialize($info));
     $_POST['pwd'] && ($password = md5($_POST['pwd']));
     $username or iPHP::alert('账号不能为空');
     if (iACP::is_superadmin()) {
         $gid = (int) $_POST['gid'];
     } else {
         isset($_POST['gid']) && iPHP::alert('您没有权限更改角色');
     }
     $fields = array('gid', 'gender', 'username', 'nickname', 'realname', 'power', 'cpower', 'info');
     $data = compact($fields);
     if (empty($uid)) {
         iDB::value("SELECT `uid` FROM `#iCMS@__members` where `username` ='{$username}' LIMIT 1") && iPHP::alert('该账号已经存在');
         $_data = compact(array('password', 'regtime', 'lastip', 'lastlogintime', 'logintimes', 'post', 'type', 'status'));
         $_data['regtime'] = time();
         $_data['lastip'] = iPHP::getIp();
         $_data['lastlogintime'] = time();
         $_data['status'] = '1';
         $data = array_merge($data, $_data);
         iDB::insert('members', $data);
         $msg = "账号添加完成!";
     } else {
         iDB::value("SELECT `uid` FROM `#iCMS@__members` where `username` ='{$username}' AND `uid` !='{$uid}' LIMIT 1") && iPHP::alert('该账号已经存在');
         iDB::update('members', $data, array('uid' => $uid));
         $password && iDB::query("UPDATE `#iCMS@__members` SET `password`='{$password}' WHERE `uid` ='" . $uid . "'");
         $msg = "账号修改完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#17
0
 public static function upFileData($data, $fid = 0)
 {
     if (empty($fid)) {
         return;
     }
     $userid = self::$userid === false ? 0 : self::$userid;
     $data['userid'] = $userid;
     $data['time'] = time();
     iDB::update(self::$TABLE, $data, array('id' => $fid));
 }
示例#18
0
 public static function data_update($data, $where)
 {
     if (iCMS_ARTICLE_DATA === "TEXT") {
         return self::put_text(self::$ID, $data);
     }
     return iDB::update('article_data', $data, $where);
 }
示例#19
0
 /**
  * [set 更新配置]
  * @param [type]  $v     [description]
  * @param [type]  $n     [description]
  * @param [type]  $appid   [description]
  * @param boolean $cache [description]
  */
 function set($value, $name, $appid, $cache = false)
 {
     $cache && iCache::set('iCMS/config/' . $name, $value, 0);
     is_array($value) && ($value = addslashes(serialize($value)));
     $check = iDB::value("SELECT `name` FROM `#iCMS@__config` WHERE `appid` ='{$appid}' AND `name` ='{$name}'");
     $fields = array('appid', 'name', 'value');
     $data = compact($fields);
     if ($check === null) {
         iDB::insert('config', $data);
     } else {
         iDB::update('config', $data, array('appid' => $appid, 'name' => $name));
     }
 }