示例#1
0
 public static function send($a = array("send_uid" => 0, "send_name" => NULL, "receiv_uid" => 0, "receiv_name" => NULL, "content" => NULL), $type = 1)
 {
     // $userid = (int)$a['userid'];
     // $friend = (int)$a['friend'];
     $send_uid = (int) $a['send_uid'];
     $send_name = iS::escapeStr($a['send_name']);
     $receiv_uid = (int) $a['receiv_uid'];
     $receiv_name = iS::escapeStr($a['receiv_name']);
     $content = iS::escapeStr($a['content']);
     $sendtime = time();
     if ($send_uid && $send_uid == $receiv_uid && !$a['self']) {
         return;
     }
     $fields = array('userid', 'friend', 'send_uid', 'send_name', 'receiv_uid', 'receiv_name', 'content', 'type', 'sendtime', 'readtime', 'status');
     $data = compact($fields);
     $data['userid'] = $send_uid;
     $data['friend'] = $receiv_uid;
     $data['readtime'] = "0";
     $data['status'] = "1";
     iDB::insert('message', $data);
     if ($type == "1") {
         $data['userid'] = $receiv_uid;
         $data['friend'] = $send_uid;
         iDB::insert('message', $data);
     }
 }
示例#2
0
 function do_save()
 {
     $id = (int) $_POST['id'];
     $cid = (int) $_POST['cid'];
     $pid = (int) $_POST['pid'];
     $name = iS::escapeStr($_POST['name']);
     $key = iS::escapeStr($_POST['key']);
     $data = $_POST['data'];
     $status = (int) $_POST['status'];
     $name or iPHP::alert('标记名称不能为空!');
     // $key OR iPHP::alert('标记key值不能为空!');
     $key or $key = pinyin($name);
     $fields = array('cid', 'pid', 'name', 'key', 'data', 'status');
     $data = compact($fields);
     if ($id) {
         iDB::update('marker', $data, array('id' => $id));
         $msg = "标记更新完成!";
     } else {
         iDB::value("SELECT `id` FROM `#iCMS@__marker` where `key` ='{$key}'") && iPHP::alert('该标记已经存在!请另选一个');
         $id = iDB::insert('marker', $data);
         $msg = "新标记添加完成!";
     }
     $this->cache($id);
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#3
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);
 }
示例#4
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);
 }
示例#5
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);
 }
示例#6
0
 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;
     }
 }
示例#7
0
文件: user.app.php 项目: sunhk25/iCMS
 public function ACTION_favorite()
 {
     $this->auth or iPHP::code(0, 'iCMS:!login', 0, 'json');
     $uid = user::$userid;
     $appid = (int) $_POST['appid'];
     $iid = (int) $_POST['iid'];
     $cid = (int) $_POST['cid'];
     $url = iS::escapeStr($_POST['url']);
     $title = iS::escapeStr($_POST['title']);
     $addtime = time();
     $url or iPHP::code(0, 'iCMS:favorite:url', 0, 'json');
     iDB::value("SELECT `id` FROM `#iCMS@__user_favorite` where `uid`='" . user::$userid . "' AND `url`='{$url}' limit 1") && iPHP::code(0, 'iCMS:favorite:failure', 0, 'json');
     $fields = array('uid', 'appid', 'cid', 'url', 'title', 'addtime');
     $data = compact($fields);
     $cid = iDB::insert('user_favorite', $data);
     iDB::query("UPDATE `#iCMS@__article` SET `favorite`=favorite+1 WHERE `id` ='{$aid}' limit 1");
     iPHP::code(1, 'iCMS:favorite:success', 0, '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
 /**
  * [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));
     }
 }
示例#10
0
 public function API_interface()
 {
     if (iPHP_DEBUG) {
         // ob_start();
         // iDB::$show_errors = true;
     }
     if ($_GET["api_token"] != iCMS::$config['api']['weixin']['token']) {
         throw new Exception('TOKEN is error!');
     }
     if ($_GET["echostr"] && !$_GET['msg_signature']) {
         if ($this->checkSignature()) {
             echo $_GET["echostr"];
             exit;
         }
     }
     $input = file_get_contents("php://input");
     if ($input) {
         $xml = simplexml_load_string($input, 'SimpleXMLElement', LIBXML_NOCDATA);
         $FromUserName = $xml->FromUserName;
         $ToUserName = $xml->ToUserName;
         $content = trim($xml->Content);
         $msgType = $xml->MsgType;
         $event = $xml->Event;
         $eventKey = $xml->EventKey;
         $CreateTime = time();
         $dayline = get_date('', 'Y-m-d H:i:s');
         if ($event == 'LOCATION') {
             $Latitude = $xml->Latitude;
             //地理位置纬度
             $Longitude = $xml->Longitude;
             //地理位置经度
             $Precision = $xml->Precision;
             //地理位置精度
         }
         if ($event == 'SCAN') {
             $Ticket = $xml->Ticket;
             //二维码的ticket,可用来换取二维码图片
         }
         if ($msgType == 'voice') {
             $MediaId = $xml->MediaId;
             //语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体
             $Format = $xml->Format;
             //语音格式:amr
             $Recognition = $xml->Recognition;
             //语音识别结果,UTF8编码
             $MsgID = $xml->MsgID;
             //消息id,64位整型
         }
         if ($msgType != "text") {
             $content = $event;
         }
         $fields = array('ToUserName', 'FromUserName', 'CreateTime', 'content', 'dayline');
         $data = compact($fields);
         $content && iDB::insert('weixin_api_log', $data);
         $site_name = addslashes(iCMS::$config['site']['name']);
         $site_desc = addslashes(iCMS::$config['site']['description']);
         $site_key = addslashes(iCMS::$config['site']['keywords']);
         $site_host = str_replace('http://', '', iCMS_URL);
         if (in_array($event, array('subscribe', 'unsubscribe'))) {
             if ($event == 'subscribe') {
                 $subscribe_msg = $site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息';
                 iCMS::$config['api']['weixin']['subscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['subscribe']);
                 //$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
                 $this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
             }
             if ($event == 'unsubscribe') {
                 $subscribe_msg = "非常感谢您一直以来对我们【" . iCMS::$config['api']['weixin']['name'] . "】的支持!我们会继续努力,做出更好的内容!\n";
                 iCMS::$config['api']['weixin']['unsubscribe'] && ($subscribe_msg = iCMS::$config['api']['weixin']['unsubscribe']);
                 //$subscribe_msg = str_replace(array('{site.name}'), replace, subject)
                 $this->msg_xml($subscribe_msg, $FromUserName, $ToUserName);
             }
         }
         if (in_array($content, array("1", "2", "3", "?", "?", "你好"))) {
             $this->msg_xml($site_name . ' (' . $site_host . ') ' . $site_desc . "\n\n回复:" . $site_key . ' 将会收到我们最新为您准备的信息', $FromUserName, $ToUserName);
         }
         iPHP::assign('weixin', $data);
         iPHP::view("iCMS://weixin.api.htm");
     }
     if (iPHP_DEBUG) {
         // $output = ob_get_contents();
         // ob_end_clean();
         // echo $output;
         // iFS::write('weixin.api.debug.log',$output,1,'ab+');
     }
 }
示例#11
0
 /**
  * [ACTION_create 创建新收藏夹]
  */
 public function ACTION_create()
 {
     $this->__login();
     $uid = user::$userid;
     $nickname = user::$nickname;
     $title = iS::escapeStr($_POST['title']);
     $description = iS::escapeStr($_POST['description']);
     $mode = (int) $_POST['mode'];
     empty($title) && iPHP::code(0, 'iCMS:favorite:create_empty', 0, 'json');
     $fwd = iCMS::filter($title);
     $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json');
     if ($description) {
         $fwd = iCMS::filter($description);
         $fwd && iPHP::code(0, 'iCMS:favorite:create_filter', 0, 'json');
     }
     $max = iDB::value("SELECT COUNT(id) FROM `#iCMS@__favorite` WHERE `uid`='{$uid}'");
     $max >= 10 && iPHP::code(0, 'iCMS:favorite:create_max', 0, 'json');
     $count = 0;
     $follow = 0;
     $fields = array('uid', 'nickname', 'title', 'description', 'follow', 'count', 'mode');
     $data = compact($fields);
     $cid = iDB::insert('favorite', $data);
     $cid && iPHP::code(1, 'iCMS:favorite:create_success', $cid, 'json');
     iPHP::code(0, 'iCMS:favorite:create_failure', 0, 'json');
 }
示例#12
0
文件: tags.app.php 项目: sunhk25/iCMS
 function do_save()
 {
     $id = (int) $_POST['id'];
     $uid = (int) $_POST['uid'];
     $rootid = (int) $_POST['rootid'];
     $cid = implode(',', (array) $_POST['cid']);
     $tcid = implode(',', (array) $_POST['tcid']);
     $pid = implode(',', (array) $_POST['pid']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_tcid = iS::escapeStr($_POST['_tcid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $name = iS::escapeStr($_POST['name']);
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $tkey = iS::escapeStr($_POST['tkey']);
     $seotitle = iS::escapeStr($_POST['seotitle']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $pic = iS::escapeStr($_POST['pic']);
     $bpic = iS::escapeStr($_POST['bpic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $related = iS::escapeStr($_POST['related']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $status = (int) $_POST['status'];
     $haspic = $pic ? '1' : '0';
     $pubdate = time();
     $metadata = $_POST['metadata'];
     $uid or $uid = iMember::$userid;
     if ($callback) {
         if (empty($name)) {
             echo '标签名称不能为空!';
             return false;
         }
     }
     $name or iPHP::alert('标签名称不能为空!');
     $cid or iPHP::alert('请选择标签所属栏目!');
     if ($metadata) {
         if ($metadata['key']) {
             $md = array();
             foreach ($metadata['key'] as $_mk => $_mval) {
                 !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
                 $md[$_mval] = $metadata['value'][$_mk];
             }
         } else {
             $md = $metadata;
         }
         $metadata = addslashes(json_encode($md));
     }
     if (empty($id)) {
         $hasNameId = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'");
         if ($hasNameId) {
             if (isset($_POST['spider_update'])) {
                 $id = $hasNameId;
             } else {
                 iPHP::alert('该标签已经存在!请检查是否重复');
             }
         }
     }
     if (empty($tkey) && $url) {
         $tkey = substr(md5($url), 8, 16);
         $hasTkey = iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'");
         if ($hasTkey) {
             if (isset($_POST['spider_check_tkey'])) {
                 echo '该自定义链接已经存在!请检查是否重复';
                 return false;
             } else {
                 iPHP::alert('该自定义链接已经存在!请检查是否重复');
             }
         }
     }
     $tkey or $tkey = strtolower(pinyin($name));
     iFS::$forceExt = "jpg";
     iFS::checkHttp($pic) && ($pic = iFS::http($pic));
     iFS::checkHttp($bpic) && ($bpic = iFS::http($bpic));
     iFS::checkHttp($mpic) && ($mpic = iFS::http($mpic));
     iFS::checkHttp($spic) && ($spic = iFS::http($spic));
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $fields = array('uid', 'rootid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'bpic', 'mpic', 'spic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status');
     $data = compact($fields);
     if (empty($id)) {
         $data['postime'] = $pubdate;
         $data['count'] = '0';
         $data['comments'] = '0';
         $id = iDB::insert('tags', $data);
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         $pid && map::add($pid, $id);
         map::init('category', $this->appid);
         map::add($cid, $id);
         $tcid && map::add($tcid, $id);
         $msg = '标签添加完成';
     } else {
         if (isset($_POST['spider_update'])) {
             // $data = array();
             $hasTag = iDB::row("SELECT * FROM `#iCMS@__tags` where `id` = '{$id}'", ARRAY_A);
             $this->check_spider_data($data, $hasTag, 'subtitle', $subtitle);
             $this->check_spider_data($data, $hasTag, 'description', $description);
             $this->check_spider_data($data, $hasTag, 'seotitle', $seotitle);
             $this->check_spider_data($data, $hasTag, 'keywords', $keywords);
             $this->check_spider_data($data, $hasTag, 'related', $related);
             $hasTag['cid'] && $cid && ($data['cid'] = $cid);
             $_cid = $hasTag['cid'];
             $hasTag['tcid'] && $tcid && ($data['tcid'] = $tcid);
             $_tcid = $hasTag['tcid'];
             $hasTag['pid'] && $pid && ($data['pid'] = $pid);
             $_pid = $hasTag['pid'];
         }
         unset($data['count'], $data['comments']);
         iDB::update('tags', $data, array('id' => $id));
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $id);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $id);
         map::diff($tcid, $_tcid, $id);
         $msg = '标签更新完成';
     }
     iACP::callback($id, $this);
     if ($this->callback['code']) {
         return array("code" => $this->callback['code'], 'indexid' => $id);
     }
     iPHP::success($msg, "url:" . APP_URI);
 }
示例#13
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);
 }
示例#14
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);
     }
 }
示例#15
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');
 }
示例#16
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;
     }
 }
示例#17
0
文件: user.app.php 项目: sunhk25/iCMS
 function do_save()
 {
     $uid = (int) $_POST['uid'];
     $pid = implode(',', (array) $_POST['pid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $user = $_POST['user'];
     $userdata = $_POST['userdata'];
     $username = $user['username'];
     $nickname = $user['nickname'];
     $password = $user['password'];
     unset($user['password']);
     $username or iPHP::alert('账号不能为空');
     preg_match("/^[\\w\\-\\.]+@[\\w\\-]+(\\.\\w+)+\$/i", $username) or iPHP::alert('该账号格式不对');
     $nickname or iPHP::alert('昵称不能为空');
     $user['regdate'] = iPHP::str2time($user['regdate']);
     $user['lastlogintime'] = iPHP::str2time($user['lastlogintime']);
     $user['pid'] = $pid;
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     if (empty($uid)) {
         $password or iPHP::alert('密码不能为空');
         $user['password'] = md5($password);
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `username` ='{$username}' LIMIT 1") && iPHP::alert('该账号已经存在');
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname` ='{$nickname}' LIMIT 1") && iPHP::alert('该昵称已经存在');
         $uid = iDB::insert('user', $user);
         map::init('prop', iCMS_APP_USER);
         $pid && map::add($pid, $uid);
         $msg = "账号添加完成!";
     } else {
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `username` ='{$username}' AND `uid` !='{$uid}' LIMIT 1") && iPHP::alert('该账号已经存在');
         iDB::value("SELECT `uid` FROM `#iCMS@__user` where `nickname` ='{$nickname}' AND `uid` !='{$uid}' LIMIT 1") && iPHP::alert('该昵称已经存在');
         $password && ($user['password'] = md5($password));
         iDB::update('user', $user, array('uid' => $uid));
         map::init('prop', iCMS_APP_USER);
         map::diff($pid, $_pid, $uid);
         if (iDB::value("SELECT `uid` FROM `#iCMS@__user_data` where `uid`='{$uid}' LIMIT 1")) {
             iDB::update('user_data', $userdata, array('uid' => $uid));
         } else {
             $userdata['uid'] = $uid;
             iDB::insert('user_data', $userdata);
         }
         $msg = "账号修改完成!";
     }
     iPHP::success($msg, 'url:' . APP_URI);
 }
示例#18
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');
 }
示例#19
0
 public function ACTION_add()
 {
     if (!iCMS::$config['comment']['enable']) {
         iPHP::code(0, 'iCMS:comment:close', 0, 'json');
     }
     iPHP::app('user.class', 'static');
     user::get_cookie() or iPHP::code(0, 'iCMS:!login', 0, 'json');
     $seccode = iS::escapeStr($_POST['seccode']);
     if (iCMS::$config['comment']['seccode']) {
         iPHP::seccode($seccode, true) or iPHP::code(0, 'iCMS:seccode:error', 'seccode', 'json');
     }
     iPHP::app('user.msg.class', 'static');
     $appid = (int) $_POST['appid'];
     $iid = (int) $_POST['iid'];
     $cid = (int) $_POST['cid'];
     $suid = (int) $_POST['suid'];
     $reply_id = (int) $_POST['id'];
     $reply_uid = (int) $_POST['userid'];
     $reply_name = iS::escapeStr($_POST['name']);
     $title = iS::escapeStr($_POST['title']);
     $content = iS::escapeStr($_POST['content']);
     $iid or iPHP::code(0, 'iCMS:article:empty_id', 0, 'json');
     $content or iPHP::code(0, 'iCMS:comment:empty', 0, 'json');
     $fwd = iCMS::filter($content);
     $fwd && iPHP::code(0, 'iCMS:comment:filter', 0, 'json');
     $appid or $appid = iCMS_APP_ARTICLE;
     $addtime = $_SERVER['REQUEST_TIME'];
     $ip = iPHP::getIp();
     $userid = user::$userid;
     $username = user::$nickname;
     $status = iCMS::$config['comment']['examine'] ? '0' : '1';
     $up = '0';
     $down = '0';
     $quote = '0';
     $floor = '0';
     $fields = array('appid', 'cid', 'iid', 'suid', 'title', 'userid', 'username', 'content', 'reply_id', 'reply_uid', 'reply_name', 'addtime', 'status', 'up', 'down', 'ip', 'quote', 'floor');
     $data = compact($fields);
     $id = iDB::insert('comment', $data);
     iDB::query("UPDATE `#iCMS@__article` SET comments=comments+1 WHERE `id` ='{$iid}' limit 1");
     user::update_count($userid, 1, 'comments');
     if (iCMS::$config['comment']['examine']) {
         iPHP::code(0, 'iCMS:comment:examine', $id, 'json');
     }
     iPHP::code(1, 'iCMS:comment:success', $id, 'json');
 }
示例#20
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);
 }
示例#21
0
 public static function insFileData($data, $type = 0)
 {
     if (!self::$checkFileData) {
         return;
     }
     $userid = self::$userid === false ? 0 : self::$userid;
     $data['userid'] = $userid;
     $data['time'] = time();
     $data['type'] = $type;
     iDB::insert(self::$TABLE, $data);
     return iDB::$insert_id;
 }
示例#22
0
 public static function data_insert($data)
 {
     if (iCMS_ARTICLE_DATA === "TEXT") {
         return self::put_text(self::$ID, $data);
     }
     return iDB::insert('article_data', $data);
 }
示例#23
0
文件: tags.app.php 项目: World3D/iCMS
 function do_save()
 {
     $id = (int) $_POST['id'];
     $uid = (int) $_POST['uid'];
     $cid = implode(',', (array) $_POST['cid']);
     $tcid = implode(',', (array) $_POST['tcid']);
     $pid = implode(',', (array) $_POST['pid']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_tcid = iS::escapeStr($_POST['_tcid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $name = iS::escapeStr($_POST['name']);
     $subtitle = iS::escapeStr($_POST['subtitle']);
     $tkey = iS::escapeStr($_POST['tkey']);
     $seotitle = iS::escapeStr($_POST['seotitle']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $pic = iS::escapeStr($_POST['pic']);
     $description = iS::escapeStr($_POST['description']);
     $url = iS::escapeStr($_POST['url']);
     $related = iS::escapeStr($_POST['related']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $weight = _int($_POST['weight']);
     $ordernum = _int($_POST['ordernum']);
     $status = (int) $_POST['status'];
     $haspic = $pic ? '1' : '0';
     $pubdate = time();
     $metadata = iS::escapeStr($_POST['metadata']);
     $uid or $uid = iMember::$userid;
     $name or iPHP::alert('标签名称不能为空!');
     $cid or iPHP::alert('请选择标签所属栏目!');
     if ($metadata) {
         $md = array();
         foreach ($metadata['key'] as $_mk => $_mval) {
             !preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->name_text . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
             $md[$_mval] = $metadata['value'][$_mk];
         }
         $metadata = addslashes(serialize($md));
     }
     if (empty($id)) {
         iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'") && iPHP::alert('该标签已经存在!请检查是否重复');
     }
     if (empty($tkey) && $url) {
         $tkey = substr(md5($url), 8, 16);
         iDB::value("SELECT `id` FROM `#iCMS@__tags` where `tkey` = '{$tkey}'") && iPHP::alert('该自定义链接已经存在!请检查是否重复');
     }
     $tkey or $tkey = strtolower(pinyin($name));
     strstr($pic, 'http://') && ($pic = iFS::http($pic));
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $fields = array('uid', 'cid', 'tcid', 'pid', 'tkey', 'name', 'seotitle', 'subtitle', 'keywords', 'description', 'metadata', 'haspic', 'pic', 'url', 'related', 'count', 'weight', 'tpl', 'ordernum', 'pubdate', 'status');
     $data = compact($fields);
     if (empty($id)) {
         $data['count'] = '0';
         $data['comments'] = '0';
         $id = iDB::insert('tags', $data);
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         $pid && map::add($pid, $id);
         map::init('category', $this->appid);
         map::add($cid, $id);
         $tcid && map::add($tcid, $id);
         iPHP::success('标签添加完成', "url:" . APP_URI);
     } else {
         unset($data['count'], $data['comments']);
         iDB::update('tags', $data, array('id' => $id));
         tag::cache($id, 'id');
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $id);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $id);
         map::diff($tcid, $_tcid, $id);
         iPHP::success('标签更新完成', "url:" . APP_URI);
     }
 }