Beispiel #1
0
 function domanage()
 {
     if ($_FILES['Filedata']) {
         require_once iPATH . 'include/upload.class.php';
         $this->iCMS->config['iswatermark'] = false;
         $this->iCMS->config['isthumb'] = false;
         $ext = FS::getExt($_FILES['Filedata']['name']);
         $F = iUpload::FILES("Filedata", 0, '', 'avatar', 'tmp_' . member::$uId . '.' . strtolower($ext), 'avatar');
         //            echo FS::fp($F["FilePath"],'+http');
         echo '../' . $this->iCMS->config['uploadfiledir'] . '/' . $F["FilePath"];
     } else {
         $_dir = ceil(member::$uId / 500);
         $data = file_get_contents("php://input");
         $length = strlen($data);
         $lastIndex = 0;
         $sizeIndex = 0;
         $sizeArray = array(120, 48, 24);
         //同时上传3个尺寸的头像。 分割数据
         while ($lastIndex < $length) {
             $a = unpack('L', $data[$lastIndex + 3] . $data[$lastIndex + 2] . $data[$lastIndex + 1] . $data[$lastIndex]);
             $lastIndex += 4;
             $avatarData = substr($data, $lastIndex, $a[1]);
             $lastIndex += $a[1];
             $avatar = 'avatar/' . $_dir . '/' . member::$uId . '_' . $sizeArray[$sizeIndex] . '.gif';
             $fp = FS::fp($avatar, '+iPATH');
             @FS::mkdir(dirname($fp));
             @FS::write($fp, $avatarData);
             $sizeIndex++;
         }
         $rootpf = FS::fp('avatar/tmp_' . member::$uId, '+iPATH');
         foreach (glob($rootpf . "*") as $_fp) {
             file_exists($_fp) && FS::del($_fp);
         }
     }
 }
Beispiel #2
0
function gethumb($sfp, $w = '', $h = '', $tdir = false, $scale = true, $callback = false)
{
    global $iCMS;
    if (strpos($sfp, 'thumb/') !== false) {
        return $sfp;
    }
    $info = pathinfo($sfp);
    $tpf = $info['dirname'] . '/thumb/' . $info['filename'] . '_';
    if ($callback) {
        $rootpf = uploadpath($tpf, '+iPATH');
        $tfArray = glob($rootpf . "*");
        if ($tfArray) {
            foreach ($tfArray as $_tfp) {
                if (file_exists($_tfp)) {
                    $fn = substr($_tfp, 0, strrpos($_tfp, '.'));
                    $per = substr($fn, strrpos($fn, '_') + 1);
                    $tfpList[$per] = uploadpath($_tfp, '-iPATH');
                }
            }
        }
        return $tfpList;
    } else {
        $srfp = uploadpath($sfp, 'http2iPATH');
        $tdir && ($tpf = $tdir . '/' . $info['filename'] . '_');
        $rootpf = uploadpath($tpf, 'http2iPATH');
        if (file_exists($srfp)) {
            empty($w) && ($w = $iCMS->config['thumbwidth']);
            empty($h) && ($h = $iCMS->config['thumbhight']);
            $twh = $rootpf . $w . 'x' . $h . '.' . FS::getext($sfp);
            if (file_exists($twh)) {
                return uploadpath($twh, 'iPATH2http');
            } else {
                if ($iCMS->config['issmall']) {
                    require_once iPATH . 'include/upload.class.php';
                    $Thumb = iUpload::thumbnail(dirname($tdir ? $rootpf : $srfp) . '/', $srfp, $info['filename'], $w, $h, $scale, $tdir ? '' : 'thumb');
                    return uploadpath($Thumb['src'], 'iPATH2http');
                } else {
                    return $sfp;
                }
            }
        } else {
            return $iCMS->config['uploadURL'] . '/nopic.gif';
        }
    }
}
 function remotepic(&$content, $intro = '', $autopic = false)
 {
     global $iCMS;
     $content = stripslashes($content);
     $img = array();
     preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*((http|file):\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $content, $match);
     $_array = (array) array_unique($match[1]);
     $uri = parse_url($iCMS->config['uploadURL']);
     foreach ($_array as $_k => $imgurl) {
         if (strstr(strtolower($imgurl), $uri['host'])) {
             unset($_array[$_k]);
         }
     }
     if (empty($_array)) {
         $content = addslashes($content);
         return;
     }
     set_time_limit(0);
     $RootPath = self::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/';
     //绝对路径
     $FileDir = "";
     if ($iCMS->config['savedir']) {
         $FileDir = str_replace(array('Y', 'y', 'm', 'n', 'd', 'j', 'H', 'EXT'), array(get_date('', 'Y'), get_date('', 'y'), get_date('', 'm'), get_date('', 'n'), get_date('', 'd'), get_date('', 'j'), get_date('', 'H'), $FileExt), $iCMS->config['savedir']);
     }
     $RootPath = $RootPath . $FileDir . "/";
     $milliSecond = 'remote_' . get_date('', "YmdHis") . rand(1, 99999);
     self::mkdir($RootPath);
     require_once iPATH . 'include/snoopy.class.php';
     require_once iPATH . 'include/upload.class.php';
     $Snoopy = new Snoopy();
     $Snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5";
     $Snoopy->accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
     foreach ($_array as $key => $value) {
         $FileExt = strtolower(FS::getExt($value));
         //&#316;&#701;
         iUpload::CheckValidExt($value);
         //判断文件类型
         //过滤文件;
         strstr($FileExt, 'ph') && ($FileExt = "phpfile");
         in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && ($FileExt .= "file");
         $FileRootPathTmp = $RootPath . $milliSecond . $key . "." . $FileExt;
         $Snoopy->fetch($value);
         if ($Snoopy->results) {
             self::write($FileRootPathTmp, $Snoopy->results);
             $FileMd5 = md5_file($FileRootPathTmp);
             $rs = iCMS_DB::getRow("SELECT * FROM #iCMS@__file WHERE `filename`='{$FileMd5}' LIMIT 1");
             if (empty($rs)) {
                 $FileName = $FileMd5 . "." . $FileExt;
                 $FilePath = $FileDir . "/" . $FileName;
                 $FileRootPath = $RootPath . $FileName;
                 rename($FileRootPathTmp, $FileRootPath);
                 if (in_array($FileExt, array('gif', 'jpg', 'jpeg', 'png'))) {
                     if ($iCMS->config['isthumb'] && ($iCMS->config['thumbwidth'] || $iCMS->config['thumbhight'])) {
                         list($width, $height, $imagetype) = getimagesize($FileRootPath);
                         if ($width > $iCMS->config['thumbwidth'] || $height > $iCMS->config['thumbhight']) {
                             self::mkdir($RootPath . "thumb");
                         }
                         $Thumbnail = iUpload::thumbnail($RootPath, $FileRootPath, $FileMd5);
                         !empty($Thumbnail['filepath']) && $iCMS->config['thumbwatermark'] && iUpload::watermark($Thumbnail['filepath']);
                     }
                     iUpload::watermark($FileRootPath);
                 }
                 $_FileSize = @filesize($FileRootPath);
                 empty($_FileSize) && ($_FileSize = 0);
                 iCMS_DB::query("INSERT INTO `#iCMS@__file` (`filename`,`ofilename`,`path`,`intro`,`ext`,`size` ,`time`,`type`) VALUES ('{$FileMd5}', '{$value}', '{$FileDir}','{$intro}', '{$FileExt}', '{$_FileSize}', '" . time() . "', '1') ");
             } else {
                 $FilePath = $rs->path . "/" . $rs->filename . "." . $rs->ext;
                 self::del($FileRootPathTmp);
             }
             $content = str_replace($value, self::fp($FilePath, '+http'), $content);
             if ($autopic && $key == 0) {
                 break;
             }
         }
     }
     $content = addslashes($content);
 }
Beispiel #4
0
 function upload($table, $aid = 0, $title = '')
 {
     require_once iPATH . 'include/upload.class.php';
     if ($_FILES) {
         foreach ($_FILES as $name => $_FILE) {
             $field = str_replace('content_upload_', '', $name);
             $F = iUpload::FILES($name, $aid, $title);
             $_sql[] = "`{$field}` = '" . $F["FilePath"] . "'";
         }
         $sql = implode(',', $_sql);
         $sql && iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET {$sql} WHERE `id` = '{$aid}'");
     }
 }
Beispiel #5
0
 function doSave()
 {
     include_once iPATH . 'include/tag.class.php';
     //    	print_r($_POST);
     //    	exit;
     set_time_limit(0);
     $aid = (int) $_POST['aid'];
     $fid = (int) $_POST['fid'];
     $title = dhtmlspecialchars($_POST['title']);
     $source = dhtmlspecialchars($_POST['source']);
     $author = dhtmlspecialchars($_POST['author']);
     $description = dhtmlspecialchars($_POST['description']);
     $keywords = dhtmlspecialchars($_POST['keywords']);
     $tags = dhtmlspecialchars($_POST['tags']);
     $pic = dhtmlspecialchars($_POST['pic']);
     $metadata = dhtmlspecialchars($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     $userid = member::$uId;
     $pubdate = _strtotime();
     $type = 0;
     $orderNum = 0;
     $subtitle = '';
     $stitle = '';
     $editor = '';
     $clink = '';
     $url = '';
     $tpl = '';
     $top = 0;
     $vlink = "";
     $related = "";
     $postype = 0;
     $body = str_replace(array("\n", "\r", "\t"), "", $_POST['body']);
     empty($title) && javascript::alert('标题不能为空!');
     empty($fid) && javascript::alert('请选择所属栏目');
     empty($body) && javascript::alert('文章内容不能为空!');
     WordFilter($title) && javascript::alert('标题包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($source) && javascript::alert('出处包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($author) && javascript::alert('作者包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($description) && javascript::alert('摘要包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($keywords) && javascript::alert('关键字包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($tags) && javascript::alert('标签包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($metadata) && javascript::alert('自定义内容包含被系统屏蔽的字符,请返回重新填写。');
     WordFilter($body) && javascript::alert('文章内容包含被系统屏蔽的字符,请返回重新填写。');
     if ($this->iCMS->config['AutoPage']) {
         if ($this->iCMS->config['AutoPageLen'] && !preg_match('/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is', $body)) {
             $html = autoformat($body, false);
             AutoPageBreak::page($html, $this->iCMS->config['AutoPageLen']);
             $body = implode('<!--iCMS.PageBreak-->', AutoPageBreak::$Rs);
             AutoPageBreak::$Rs = '';
             unset($html);
             $this->iCMS->config['autoformat'] = false;
         }
     }
     $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is', '/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is'), array('', '', '<!--iCMS.PageBreak-->'), $body);
     $this->iCMS->config['autoformat'] && ($body = autoformat($body));
     if ($this->iCMS->config['autodesc'] == "1" && !empty($this->iCMS->config['descLen']) && empty($description)) {
         $_body = preg_replace(array('/<p[^>]*>/is', '/<[\\/\\!]*?[^<>]*?>/is', "/\n+/", "/ +/", "/^\n/"), array("\n\n", '', "\n", '', ''), $this->iCMS->config['autoformat'] ? $body : autoformat($body));
         $description = csubstr($_body, $this->iCMS->config['descLen']);
     }
     $tags = iTAG::split($tags, true);
     include iPATH . 'include/cn.class.php';
     $clink = CN::pinyin($title, $this->iCMS->config['CLsplit']);
     $isPic = empty($pic) ? 0 : 1;
     $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=article&do=manage' : $_POST['REFERER']);
     $forum = new forum();
     $status = $forum->forum[$fid]['isexamine'] ? '0' : '1';
     //审核投稿
     if (empty($aid)) {
         $hits = $good = $bad = $comments = 0;
         iCMS_DB::insert('article', compact('fid', 'title', 'stitle', 'clink', 'orderNum', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'hits', 'good', 'bad', 'comments', 'type', 'vlink', 'top', 'status'));
         $aid = iCMS_DB::$insert_id;
         iCMS_DB::insert('article_data', compact('aid', 'subtitle', 'tpl', 'body'));
         if ($_FILES['picfile']) {
             require_once iPATH . 'include/upload.class.php';
             $F = iUpload::FILES("picfile", $aid, $title);
             iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'");
         }
         //$this->insert_db_remote($body,$aid);
         iTAG::add($tags, $userid, $aid, $forum->rootid($fid));
         vlinkDiff($fid, '', $aid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($status) {
             iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
             $moreaction = array(array("text" => "查看该文章", "url" => $this->iCMS->iurl('show', array(array('id' => $aid, 'link' => $clink, 'url' => $url, 'fid' => $fid, 'pubdate' => $pubdate), $forum->forum[$fid]))->href, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => __SELF__ . "?mo=article&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => __SELF__ . "?mo=article&do=add&fid=" . $fid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => "../index.php", "o" => 'target="_blank"'));
             javascript::dialog('文章发布成功!<br />10秒后返回文章列表', 'url:' . $SELFURL, $moreaction, 10);
         } else {
             javascript::dialog('您的投稿文章发布成功!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10);
         }
     } else {
         $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__article` where `id` ='{$aid}'");
         iTAG::diff($tags, $art->tags, member::$uId, $aid, $forum->rootid($fid));
         iCMS_DB::update('article', compact('fid', 'title', 'stitle', 'orderNum', 'clink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'type', 'vlink', 'top', 'status'), array('id' => $aid));
         vlinkDiff($fid, $art->vlink, $aid);
         iCMS_DB::update('article_data', compact('tpl', 'subtitle', 'body'), compact('aid'));
         if ($_FILES['picfile']) {
             require_once iPATH . 'include/upload.class.php';
             $F = iUpload::FILES("picfile", $aid, $title);
             iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'");
         }
         //$this->insert_db_remote($body,$aid);
         if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) {
             include iPATH . 'include/iHtml.class.php';
             iHtml::Article($aid);
             iHtml::forum($fid, 1, 0, 1);
         }
         if ($status) {
             if ($art->fid != $fid) {
                 iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 ");
                 iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 ");
             }
             javascript::dialog('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
         } else {
             javascript::dialog('您的文章编辑完成!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10);
         }
     }
 }
Beispiel #6
0
 function doswfupload($param = false)
 {
     $F = iUpload::FILES("Filedata");
     if ($param) {
         echo '<li id="fid' . $F['fid'] . '"><span><a href="' . __ADMINCP__ . '=files&do=del2&fid=' . $F['fid'] . '" target="sub_iCMS_FRAME">删除</a></span><input name="files[]" type="checkbox" class="checkbox" value="' . uploadpath($F["FilePath"], '+http') . '" /> ' . $F["OriginalFileName"] . ' </li>';
     } else {
         echo '<div><ul><li>文件:' . $F["OriginalFileName"] . ' 上传成功!<span style="color:green;">√</span></li><li>路径:' . $F["FilePath"] . '</ul></div>';
     }
 }