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'] . '个'); } }
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'); } }
function do_uploadscrawl() { if ($_GET["action"] == "tmpImg") { // 背景上传 iFS::$callback = false; $F = iFS::upload('upfile', 'scrawl/tmp'); $F === false && exit; $F['path'] && ($url = iFS::fp($F['path'], '+http')); echo "<script>parent.ue_callback('" . $url . "','SUCCESS')</script>"; } else { iFS::$callback = true; $F = iFS::base64ToFile($_POST['upfile'], 'scrawl/' . get_date(0, 'Y/md')); $F === false && exit(iFS::$ERROR); $F['path'] && ($url = iFS::fp($F['path'], '+http')); $tmp = iFS::get_dir() . "scrawl/tmp/"; iFS::rmdir($tmp); iPHP::json(array("url" => $url, "state" => 'SUCCESS')); } }
public function API_mobileUp() { $this->auth or iPHP::code(0, 'iCMS:!login', 0, 'json'); $F = iFS::upload('upfile'); $F['path'] && ($url = iFS::fp($F['path'], '+http')); iPHP::js_callback(array('url' => $url, 'code' => $F['code'])); }
function do_upload() { iACP::MP('FILE.UPLOAD', 'alert'); //iFS::$checkFileData = true; $_POST['watermark'] or iFS::$watermark = false; iFS::$callback = true; if ($this->id) { iFS::$FileData = iFS::getFileData('id', $this->id); $F = iFS::upload('upfile'); if ($F && $F['size'] != iFS::$FileData->size) { iDB::query("update `#iCMS@__filedata` SET `size`='" . $F['size'] . "' WHERE `id` = '{$this->id}'"); } } else { $udir = ltrim($_POST['udir'], '/'); $F = iFS::upload('upfile', $udir); } $array = $F === false ? iFS::$ERROR : array("value" => $F["path"], "url" => iFS::fp($F['path'], '+http'), "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']); if ($this->format == 'json') { iPHP::json($array); } else { iPHP::js_callback($array); } }