Пример #1
0
 function do_import_rule()
 {
     iFS::$checkFileData = false;
     iFS::$config['allow_ext'] = 'txt';
     iFS::$config['yun']['enable'] = false;
     $F = iFS::upload('upfile');
     $path = $F['RootPath'];
     if ($path) {
         $data = file_get_contents($path);
         if ($data) {
             $data = base64_decode($data);
             $data = unserialize($data);
             iDB::insert("spider_rule", $data);
         }
         @unlink($path);
         iPHP::success('规则导入完成', 'js:1');
     }
 }
Пример #2
0
 function do_import()
 {
     $_POST['cid'] or iPHP::alert('请选择标签所属栏目!');
     iFS::$checkFileData = false;
     iFS::$config['allow_ext'] = 'txt';
     iFS::$config['yun']['enable'] = false;
     $F = iFS::upload('upfile');
     $path = $F['RootPath'];
     if ($path) {
         $contents = file_get_contents($path);
         $encode = mb_detect_encoding($contents, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
         if (strtoupper($encode) != 'UTF-8') {
             if (function_exists('mb_convert_encoding')) {
                 $contents = mb_convert_encoding($contents, 'UTF-8', $encode);
             } elseif (function_exists('iconv')) {
                 $contents = iconv($encode, 'UTF-8', $contents);
             } else {
                 iPHP::alert('请把文件编码转换成UTF-8!');
             }
         }
         if ($contents) {
             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');
             $cid = implode(',', (array) $_POST['cid']);
             $tcid = implode(',', (array) $_POST['tcid']);
             $pid = implode(',', (array) $_POST['pid']);
             $variable = explode("\n", $contents);
             $msg = array();
             foreach ($variable as $key => $name) {
                 $name = trim($name);
                 if (empty($name)) {
                     $msg['empty']++;
                     continue;
                 }
                 $name = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $name);
                 $name = addslashes($name);
                 if (iDB::value("SELECT `id` FROM `#iCMS@__tags` where `name` = '{$name}'")) {
                     $msg['has']++;
                     continue;
                 }
                 $tkey = strtolower(pinyin($name));
                 $uid = iMember::$userid;
                 $haspic = '0';
                 $status = '1';
                 $pubdate = time();
                 $data = compact($fields);
                 $id = iDB::insert('tags', $data);
                 map::init('prop', $this->appid);
                 $pid && map::add($pid, $id);
                 map::init('category', $this->appid);
                 $cid && map::add($cid, $id);
                 $tcid && map::add($tcid, $id);
                 $msg['success']++;
             }
         }
         @unlink($path);
         iPHP::success('标签导入完成<br />空标签:' . (int) $msg['empty'] . '个<br />已经存在标签:' . (int) $msg['has'] . '个<br />成功导入标签:' . (int) $msg['success'] . '个');
     }
 }
Пример #3
0
 private function __action_profile_avatar()
 {
     iFS::$watermark = false;
     iFS::$checkFileData = false;
     $dir = get_user_dir(user::$userid);
     $F = iFS::upload('upfile', $dir, user::$userid, 'jpg');
     if (empty($F)) {
         if ($_POST['format'] == 'json') {
             iPHP::code(0, 'user:iCMS:error', 0, 'json');
         } else {
             iPHP::js_callback(array("code" => 0));
         }
     }
     $url = iFS::fp($F['path'], '+http');
     if ($_POST['format'] == 'json') {
         iPHP::code(1, 'user:profile:avatar', $url, 'json');
     }
     $array = array("code" => $F["code"], "value" => $F["path"], "url" => $url, "fid" => $F["fid"], "fileType" => $F["ext"], "image" => in_array($F["ext"], array('gif', 'jpg', 'jpeg', 'png')) ? 1 : 0, "original" => $F["oname"], "state" => $F['code'] ? 'SUCCESS' : $F['state']);
     iPHP::js_callback($array);
 }