public static function publish($work = null) { $_POST = spiderData::crawl(); if (spider::$work == 'shell') { if (empty($_POST['title'])) { echo "标题不能为空\n"; return false; } if (empty($_POST['body'])) { echo "内容不能为空\n"; return false; } } $checker = spider::checker($work, spider::$pid, $_POST['reurl'], $_POST['title']); if ($checker !== true) { return $checker; } $project = spider::project(spider::$pid); if (!isset($_POST['cid'])) { $_POST['cid'] = $project['cid']; } $postArgs = spider::postArgs($project['poid']); if ($_GET['indexid']) { $aid = (int) $_GET['indexid']; $_POST['aid'] = $aid; $_POST['adid'] = iDB::value("SELECT `id` FROM `#iCMS@__article_data` WHERE aid='{$aid}'"); } $title = iS::escapeStr($_POST['title']); $url = iS::escapeStr($_POST['reurl']); $hash = md5($url); if (empty(spider::$sid)) { $spider_url = iDB::row("SELECT `id`,`publish`,`indexid` FROM `#iCMS@__spider_url` where `url`='{$url}'", ARRAY_A); if (empty($spider_url)) { $spider_url_data = array('cid' => $project['cid'], 'rid' => spider::$rid, 'pid' => spider::$pid, 'title' => addslashes($title), 'url' => $url, 'hash' => $hash, 'status' => '1', 'addtime' => time(), 'publish' => '0', 'indexid' => '0', 'pubdate' => ''); $suid = iDB::insert('spider_url', $spider_url_data); } else { if ($spider_url['indexid']) { $_POST['aid'] = $spider_url['indexid']; $_POST['adid'] = iDB::value("SELECT `id` FROM `#iCMS@__article_data` WHERE aid='" . $spider_url['indexid'] . "'"); } $suid = $spider_url['id']; } } else { $suid = spider::$sid; } if (spider::$callback['post'] && is_callable(spider::$callback['post'])) { $_POST = call_user_func_array(spider::$callback['post'], array($_POST)); } iS::slashes($_POST); $app = iACP::app($postArgs->app); $fun = $postArgs->fun; $app->callback['code'] = '1001'; /** * 主表 回调 更新关联ID */ $app->callback['primary'] = array(array('spider', 'update_spider_url_indexid'), array('suid' => $suid)); /** * 数据表 回调 成功发布 */ $app->callback['data'] = array(array('spider', 'update_spider_url_publish'), array('suid' => $suid)); $callback = $app->{$fun}(); if ($callback['code'] == $app->callback['code']) { if (spider::$sid) { $work === NULL && iPHP::success("发布成功!", 'js:1'); } else { $work === NULL && iPHP::success("发布成功!", 'js:parent.$("#' . $hash . '").remove();'); } } if ($work == "shell" || $work == "WEB@AUTO") { $callback['work'] = $work; return $callback; } }