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 doCrop()
 {
     $pFile = $_GET['pic'];
     $iFile = FS::fp($pFile, '+iPATH');
     $callback = $_GET['callback'];
     list($width, $height, $imagetype) = @getimagesize($iFile);
     $pw = $width > 500 ? 500 : $width;
     $tw = (int) $this->iCMS->config['thumbwidth'];
     $th = (int) $this->iCMS->config['thumbhight'];
     $rate = round($pw / $width, 2) * 100;
     $sliderMin = round($tw / $width, 2) * 100;
     include admincp::tpl();
 }
Beispiel #3
0
    function dodelpic()
    {
        $id = (int) $_GET['id'];
        $mid = (int) $_GET['mid'];
        $table = model::tbn($_GET['table']);
        $field = $_GET['field'];
        $fp = $_GET['fp'];
        if (empty($fp)) {
            return;
        }
        !$id && javascript::alert("请选择要删除图片的内容");
        $thumbfilepath = gethumb($fp, '', '', false, true, true);
        FS::del(FS::fp($fp, '+iPATH'));
        if ($thumbfilepath) {
            foreach ($thumbfilepath as $wh => $tfp) {
                FS::del(FS::fp($tfp, '+iPATH'));
            }
        }
        $filename = FS::info($fp)->filename;
        iCMS_DB::query("DELETE FROM `#iCMS@__file` WHERE `filename` = '{$filename}'");
        iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET `{$field}` = '' WHERE `id` ='{$id}'");
        echo '<script type="text/javascript">
	        parent.$("#' . $field . '2").hide();
	        parent.$("#c' . $field . '1").hide();
	        parent.$("#' . $field . '1").show();
	        parent.$("[name=' . $field . ']").val("");</script>';
    }
Beispiel #4
0
function delArticle($id, $uid = '0', $postype = '1')
{
    global $iCMS;
    $uid && ($sql = "and `userid`='{$uid}' and `postype`='{$postype}'");
    $id = (int) $id;
    $art = iCMS_DB::getRow("SELECT * FROM `#iCMS@__article` WHERE id='{$id}' {$sql} Limit 1");
    if ($art->pic) {
        $usePic = iCMS_DB::getValue("SELECT id FROM `#iCMS@__article` WHERE `pic`='{$art->pic}' and `id`<>'{$id}'");
        if (empty($usePic)) {
            $msg .= delpic($art->pic);
        } else {
            $msg .= $art->pic . '文件 其它文章正在使用,请到文件管理删除…<span style=\'color:green;\'>×</span><br />';
        }
    }
    $forum = $iCMS->getCache('system/forum.cache', $art->fid);
    $body = iCMS_DB::getValue("SELECT `body` FROM `#iCMS@__article_data` WHERE aid='{$id}' Limit 1");
    if ($forum['mode'] && strstr($forum['contentRule'], '{PHP}') === false && empty($art->url)) {
        $bArray = explode('<!--iCMS.PageBreak-->', $body);
        $total = count($bArray);
        for ($i = 1; $i <= $total; $i++) {
            $iurl = $iCMS->iurl('show', array((array) $art, $forum), $i);
            FS::del($iurl->path);
            $msg .= $iurl->path . ' 静态文件删除…<span style=\'color:green;\'>√</span><br />';
        }
    }
    $frs = iCMS_DB::getArray("SELECT `filename`,`path`,`ext` FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    for ($i = 0; $i < count($frs); $i++) {
        if (!empty($frs[$i])) {
            $path = $frs[$i]['path'] . '/' . $frs[$i]['filename'] . '.' . $frs[$i]['ext'];
            FS::del(FS::fp($frs[$i]['path'], '+iPATH'));
            $msg .= $path . ' 文件删除…<span style=\'color:green;\'>√</span><br />';
        }
    }
    if ($art->tags) {
        include_once iPATH . 'include/tag.class.php';
        $msg .= iTAG::del($art->tags);
    }
    iCMS_DB::query("DELETE FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    $msg .= '相关文件数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("DELETE FROM `#iCMS@__comment` WHERE indexId='{$id}' and mid='0'");
    $msg .= '评论数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("DELETE FROM `#iCMS@__article` WHERE id='{$id}'");
    iCMS_DB::query("DELETE FROM `#iCMS@__article_data` WHERE `id`='{$id}'");
    iCMS_DB::query("DELETE FROM `#iCMS@__vlink` WHERE indexId='{$id}' AND modelId='0'");
    $msg .= '文章数据删除…<span style=\'color:green;\'>√</span><br />';
    iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1");
    $msg .= '栏目数据更新…<span style=\'color:green;\'>√</span><br />';
    $msg .= '删除完成…<span style=\'color:green;\'>√</span><hr />';
    return $msg;
}
        <th>ID</th>
        <th>文件名</th>
        <th>内容ID</th>
        <th>文件大小</th>
        <th>上传时间</th>
        <th>管理</th>
      </tr>
    </thead>
    <?php 
for ($i = 0; $i < $_count; $i++) {
    $filename = $rs[$i]['filename'] . '.' . $rs[$i]['ext'];
    $path = $rs[$i]['path'] . '/' . $filename;
    $rs[$i]['time'] = get_date($rs[$i]['time'], 'Y-m-d H:i');
    $rs[$i]['size'] = FS::sizeUnit($rs[$i]['size']);
    $rs[$i]['icon'] = FS::icon($filename);
    $rs[$i]['path'] = FS::fp($path);
    ?>
    <tr id="fid<?php 
    echo $rs[$i]['id'];
    ?>
">
      <td><input type="checkbox" class="checkbox" name="delete[]" value="<?php 
    echo $rs[$i]['id'];
    ?>
" /></td>
      <td><?php 
    echo $total - ($i + $this->firstcount);
    ?>
</td>
      <td><a href="<?php 
    echo $rs[$i]['path'];
</td>
    <td rowspan="2" valign="top" id="tdfile"><ul class="filelist fileheader">
        <li class="name">名称</li>
        <li class="size">大小</li>
        <li class="date">修改日期</li>
        <li class="manage">管理</li>
      </ul><form action="<?php 
echo __ADMINCP__;
?>
=files" method="post" target="iCMS_FRAME" id="iDF">
    	<div id="fList">
        <?php 
$_FL = $L['FileList'];
$_fCount = count($_FL);
for ($i = 0; $i < $_fCount; $i++) {
    $href = $do == 'template' ? $iCMS->config['url'] . '/templates/' . $_FL[$i]['path'] : FS::fp($_FL[$i]['path']);
    $filepath = $from == 'editor' ? $href : $_FL[$i]['path'];
    ?>
      	<ul class="filelist">
        <li class="name n" title="<?php 
    echo $_FL[$i]['name'];
    ?>
"><input type="checkbox" class="checkbox cfiles" name="files[]" value="<?php 
    echo $href;
    ?>
" /> <a href="<?php 
    echo $href;
    ?>
" class="icon" target="_blank" title="点击查看"><?php 
    echo $_FL[$i]['icon'];
    ?>
Beispiel #7
0
function avatar($uid, $size = "24")
{
    $_dir = ceil($uid / 500);
    $avatar = 'avatar/' . $_dir . '/' . $uid . '_' . $size . '.gif';
    if (!file_exists(FS::fp($avatar, '+iPATH'))) {
        global $iCMS;
        return $iCMS->config['publicURL'] . '/common/avatar_' . $size . '.gif';
    } else {
        return FS::fp($avatar);
    }
}
Beispiel #8
0
 function insert_db_remote($content, $aid)
 {
     $content = stripslashes($content);
     preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*((http|file):\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $content, $match);
     $_array = array_unique($match[1]);
     set_time_limit(0);
     foreach ($_array as $key => $value) {
         $value = FS::fp($value, '-http');
         $filename = basename($value);
         $pic = iCMS_DB::getValue("SELECT `pic` FROM `#iCMS@__article` WHERE `id` = '{$aid}'");
         $this->autopic && $key == 0 && empty($pic) && iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '{$value}' WHERE `id` = '{$aid}'");
         $faid = iCMS_DB::getValue("SELECT `aid` FROM `#iCMS@__file` WHERE `filename` ='{$filename}'");
         empty($faid) && iCMS_DB::query("UPDATE `#iCMS@__file` SET `aid` = '{$aid}' WHERE `filename` ='{$filename}'");
     }
 }
Beispiel #9
0
 function FieldValue($mid, $field, $v)
 {
     global $iCMS;
     $FArray = $iCMS->getCache('system/models.field', $mid);
     $A = $FArray[$field];
     $option = unserialize($A['option']);
     $optStr = $option[$A['type']];
     if ($optStr) {
         $_optArray = explode("\n", $optStr);
         foreach ($_optArray as $k => $optA) {
             list($index, $choice) = explode("=", $optA);
             $optArray[trim($index)] = trim($choice);
         }
     }
     $Fval = Null;
     switch ($A['type']) {
         case "radio":
             $optArray && ($Fval = $optArray[$v]);
             break;
         case "upload":
             $v && ($Fval = FS::fp($v, '+http'));
             break;
             //		case "editor":
             //			$body	=explode('<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>',$v);
             //			$total	=count($body);
             //			$nBody	=$body[intval($page-1)];
             //			$v		=$iCMS->keywords($nBody);
             //			$rs->page=$page;
             //			if($total>1){
             //				$CLArray=array('id'=>$rs->id,'link'=>$rs->customlink,'dir'=>$rs->forumdir,'pubdate'=>$rs->pubdate);
             //				$pagebreak=($page-1>1)?'<a href="'.$this->iurl('show',$CLArray,$page-1).'" class="pagebreak" target="_self">上一页</a> ':'<a href="'.$this->iurl('show',$CLArray).'" class="pagebreak" target="_self">'.$this->language('page:prev').'</a> ';
             //				for($i=1;$i<=$total;$i++){
             //					$cls=$i==$page?"pagebreaksel":"pagebreak";
             //					$pagebreak.=$i==1?'<a href="'.$this->iurl('show',$CLArray).'" class="'.$cls.'" target="_self">'.$i.'</a>':'<a href="'.$this->iurl('show',$CLArray,$i).'" class="'.$cls.'" target="_self">'.$i.'</a>';
             //				}
             //				$np=($total-$page>0)?$page+1:$page;
             //				$pagebreak.='<a href="'.$this->iurl('show',$CLArray,$np).'" class="pagebreak" target="_self">'.$this->language('page:next').'</a>';
             //				$rs->pagebreak=$pagebreak;
             //			}
             //		break;
         //		case "editor":
         //			$body	=explode('<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>',$v);
         //			$total	=count($body);
         //			$nBody	=$body[intval($page-1)];
         //			$v		=$iCMS->keywords($nBody);
         //			$rs->page=$page;
         //			if($total>1){
         //				$CLArray=array('id'=>$rs->id,'link'=>$rs->customlink,'dir'=>$rs->forumdir,'pubdate'=>$rs->pubdate);
         //				$pagebreak=($page-1>1)?'<a href="'.$this->iurl('show',$CLArray,$page-1).'" class="pagebreak" target="_self">上一页</a> ':'<a href="'.$this->iurl('show',$CLArray).'" class="pagebreak" target="_self">'.$this->language('page:prev').'</a> ';
         //				for($i=1;$i<=$total;$i++){
         //					$cls=$i==$page?"pagebreaksel":"pagebreak";
         //					$pagebreak.=$i==1?'<a href="'.$this->iurl('show',$CLArray).'" class="'.$cls.'" target="_self">'.$i.'</a>':'<a href="'.$this->iurl('show',$CLArray,$i).'" class="'.$cls.'" target="_self">'.$i.'</a>';
         //				}
         //				$np=($total-$page>0)?$page+1:$page;
         //				$pagebreak.='<a href="'.$this->iurl('show',$CLArray,$np).'" class="pagebreak" target="_self">'.$this->language('page:next').'</a>';
         //				$rs->pagebreak=$pagebreak;
         //			}
         //		break;
         case in_array($A['type'], array('checkbox', 'select', 'multiple')):
             $vArray = explode(',', $v);
             if ($optArray) {
                 foreach ($optArray as $value => $text) {
                     $vArray = explode(',', $v);
                     in_array($value, $vArray) && ($Fval[$value] = $text);
                 }
             }
             break;
     }
     return $Fval;
 }
Beispiel #10
0
 function doviewPic()
 {
     echo '<img src="' . FS::fp($_GET['callback']) . '"/>';
 }
Beispiel #11
0
 public function Show($id, $page = 1, $tpl = true)
 {
     $rs = iCMS_DB::getRow("SELECT a.*,d.tpl,d.body,d.subtitle FROM #iCMS@__article as a LEFT JOIN #iCMS@__article_data AS d ON a.id = d.aid WHERE a.id='" . (int) $id . "' AND a.status ='1'");
     //echo iCMS_DB::$last_query;
     //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
     //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
     //var_dump($explain);
     empty($rs) && $this->error('error:page');
     $F = $this->getCache('system/forum.cache', $rs->fid);
     if ($F['status'] == 0) {
         return false;
     }
     if ($rs->url) {
         if ($this->mode == "CreateHtml") {
             return false;
         } else {
             $this->go($rs->url);
         }
     }
     if ($this->mode == "CreateHtml" && (strstr($F['contentRule'], '{PHP}') || $F['url'] || $F['mode'] == 0)) {
         return false;
     }
     $_iurlArray = array((array) $rs, $F);
     $rs->iurl = $this->iurl('show', $_iurlArray, $page);
     $rs->url = $rs->iurl->href;
     $tpl && $this->gotohtml($rs->iurl->path, $rs->iurl->href, $F['mode']);
     $this->iList($rs->fid, false);
     preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $rs->body, $picArray);
     $pA = array_unique($picArray[1]);
     foreach ($pA as $key => $pVal) {
         $ipVal = FS::fp($pVal, 'http2iPATH');
         file_exists($ipVal) && ($rs->photo[] = trim($pVal));
     }
     $body = explode('<!--iCMS.PageBreak-->', $rs->body);
     $rs->pagetotal = count($body);
     $rs->body = $this->keywords($body[intval($page - 1)]);
     $rs->pagecurrent = $page;
     if ($rs->pagetotal > 1) {
         $ppHref = $this->iurl('show', $_iurlArray, $page - 1 > 1 ? $page - 1 : 1)->href;
         $rs->pagebreak = '<a href="' . $ppHref . '" class="prevpagebreak" target="_self">' . $this->language('page:prev') . '</a> ';
         for ($i = 1; $i <= $rs->pagetotal; $i++) {
             $cls = $i == $page ? "pagebreaksel" : "pagebreak";
             $rs->pagebreak .= '<a href="' . $this->iurl('show', $_iurlArray, $i)->href . '" class="' . $cls . '" target="_self">' . $i . '</a>';
         }
         $npHref = $this->iurl('show', $_iurlArray, $rs->pagetotal - $page > 0 ? $page + 1 : $page)->href;
         $rs->pagebreak .= '<a href="' . $npHref . '" class="nextpagebreak" target="_self">' . $this->language('page:next') . '</a>';
         if ($page < $rs->pagetotal) {
             $imgA = array_unique($picArray[0]);
             foreach ($imgA as $key => $img) {
                 $rs->body = str_replace($img, '<p align="center"><a href="' . $npHref . '"><b>' . $this->language('show:PicGotoNext') . '</b></a></p>
                 <a href="' . $npHref . '" title="' . $rs->title . '">' . $img . '</a><br/>', $rs->body);
             }
         }
     }
     $rs->page = array('total' => $rs->pagetotal, 'current' => $rs->pagecurrent, 'break' => $rs->pagebreak, 'prev' => $ppHref, 'next' => $npHref);
     if ($rs->tags) {
         $tagarray = explode(',', $rs->tags);
         foreach ($tagarray as $tk => $tag) {
             $t = $this->getTag($tag);
             if ($t) {
                 $rs->tag[$tk]['name'] = $tag;
                 $rs->tag[$tk]['url'] = $t['url']->href;
                 $rs->taglink .= '<a href="' . $rs->tag[$tk]['url'] . '" class="tag" target="_self" title="' . $t['count'] . $this->language('page:list') . '">' . $rs->tag[$tk]['name'] . '</a> ';
             }
         }
     }
     $rs->rel = $rs->related;
     $rs->metadata && ($rs->metadata = unserialize($rs->metadata));
     $rs->prev = $this->language('show:first');
     $prers = iCMS_DB::getRow("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$rs->id}' AND `fid`='{$rs->fid}' AND `status`='1' order by id DESC Limit 1");
     $prers && ($rs->prev = '<a href="' . $this->iurl('show', array((array) $prers, $F))->href . '" class="prev" target="_self">' . $prers->title . '</a>');
     $rs->next = $this->language('show:last');
     $nextrs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$rs->id}'  and `fid`='{$rs->fid}' AND `status`='1' order by id ASC Limit 1");
     $nextrs && ($rs->next = '<a href="' . $this->iurl('show', array((array) $nextrs, $F))->href . '" class="next" target="_self">' . $nextrs->title . '</a>');
     $rs->comment = array('url' => $this->config['publicURL'] . "/comment.php?indexId={$rs->id}&sortId={$rs->fid}", 'count' => $rs->comments);
     $rs->link = "<a href='{$rs->url}'>{$rs->title}</a>";
     if ($F['mode']) {
         $rs->hits = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=hits&fid={$rs->fid}&id={$rs->id}&action=show\" type=\"text/javascript\"></script>";
         $rs->digg = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=digg&id={$rs->id}&action=show\" type=\"text/javascript\"></script>";
         $rs->comments = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=comment&id={$rs->id}&action=show\" type=\"text/javascript\"></script>";
     } else {
         $this->mode != 'CreateHtml' && iCMS_DB::query("UPDATE `#iCMS@__article` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1");
     }
     $rs->mid = 0;
     $rs->table = 'article';
     $this->Hook($rs);
     $this->assign('show', (array) $rs);
     if ($tpl) {
         $tpl = empty($rs->tpl) ? $F['contentTPL'] : $rs->tpl;
         return $this->iPrint($tpl, 'show');
     }
 }
Beispiel #12
0
function iCMS_list($vars, &$iCMS)
{
    if ($vars['loop'] == "rel" && empty($vars['id'])) {
        return false;
    }
    $whereSQL = " status='1'";
    $_cache = $iCMS->getCache(array('system/forum.cache', 'system/forum.hidden'));
    $_cache['system/forum.hidden'] && ($whereSQL .= getSQL($_cache['system/forum.hidden'], 'fid', 'not'));
    $maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
    $cacheTime = isset($vars['time']) ? (int) $vars['time'] : -1;
    isset($vars['userid']) && ($whereSQL .= " AND `userid`='{$vars['userid']}'");
    isset($vars['author']) && ($whereSQL .= " AND `author`='{$vars['author']}'");
    isset($vars['top']) && ($whereSQL .= " AND `top`='" . _int($vars['top']) . "'");
    $vars['call'] == 'user' && ($whereSQL .= " AND `postype`='0'");
    $vars['call'] == 'admin' && ($whereSQL .= " AND `postype`='1'");
    $forum = $_cache['system/forum.cache'];
    if (isset($vars['fid!'])) {
        $_Nfid = getfids($vars['fid!']);
        $_Nfid && ($Nfids[] = $_Nfid);
        $vars['sub'] == 'all' && ($Nfids[] = $vars['fid!']);
        $ids = $Nfids && $vars['sub'] == 'all' ? implode(',', $Nfids) : $vars['fid!'];
        $whereSQL .= getSQL($ids, 'fid', 'not');
    }
    if (isset($vars['fid'])) {
        $_fid = getfids($vars['fid']);
        $_fid && ($fids[] = $_fid);
        $vars['sub'] == 'all' && ($fids[] = $vars['fid']);
        $ids = $fids && $vars['sub'] == 'all' ? implode(',', $fids) : $vars['fid'];
        $whereSQL .= getSQL($ids, 'fid');
    }
    isset($vars['type']) && ($whereSQL .= " AND `type` ='{$vars['type']}'");
    $vars['id'] && ($whereSQL .= getSQL($vars['id'], 'id'));
    $vars['id!'] && ($whereSQL .= getSQL($vars['id!'], 'id', 'not'));
    $by = $vars['by'] == "ASC" ? "ASC" : "DESC";
    if ($vars['keywords']) {
        if (strpos($vars['keywords'], ',') === false) {
            $vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
            $whereSQL .= " AND CONCAT(title,keywords,description) like '%" . addslashes($vars['keywords']) . "%'";
        } else {
            $kw = explode(',', $vars['keywords']);
            foreach ($kw as $v) {
                $keywords .= addslashes($v) . "|";
            }
            $keywords = substr($keywords, 0, -1);
            $whereSQL .= "  And CONCAT(title,keywords,description) REGEXP '{$keywords}' ";
        }
    }
    isset($vars['pic']) && ($whereSQL .= " AND `isPic`='1'");
    switch ($vars['orderby']) {
        case "id":
            $orderSQL = " ORDER BY `id` {$by}";
            break;
        case "hot":
            $orderSQL = " ORDER BY `hits` {$by}";
            break;
        case "comment":
            $orderSQL = " ORDER BY `comments` {$by}";
            break;
        case "pubdate":
            $orderSQL = " ORDER BY `pubdate` {$by}";
            break;
        case "disorder":
            $orderSQL = " ORDER BY `orderNum` {$by}";
            break;
            //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        //        case "rand":    $orderSQL=" ORDER BY rand() $by";    break;
        case "top":
            $orderSQL = " ORDER BY `top`,`orderNum` ASC";
            break;
        default:
            $orderSQL = " ORDER BY `id` DESC";
    }
    isset($vars['date']) && (list($iCMS->date['y'], $iCMS->date['m'], $iCMS->date['d']) = explode('-', $vars['date']));
    if ($iCMS->date) {
        $day = empty($iCMS->date['d']) ? '01' : $iCMS->date['d'];
        $start = strtotime($iCMS->date['y'] . $iCMS->date['m'] . $day);
        $end = empty($iCMS->date['d']) ? $start + 86400 * $iCMS->date['total'] : $start + 86400;
        $whereSQL .= " AND `pubdate`<='{$end}' AND `pubdate`>='{$start}'";
    } else {
        isset($vars['startdate']) && ($whereSQL .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'");
        isset($vars['enddate']) && ($whereSQL .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'");
    }
    isset($vars['where']) && ($whereSQL .= $vars['where']);
    if ($vars['action'] == 'search') {
        $whereSQL .= $iCMS->actionSQL;
        //    }elseif($vars['action']=='vlink'){
        //        $this->countSQL    = 'SELECT count(#iCMS@__article.id) FROM `#iCMS@__article`,`#iCMS@__vlink` WHERE #iCMS@__article.id = `indexId` AND `fid`=\''.$vars['fid'].'\' AND';
        //        $this->selectSQL= 'SELECT #iCMS@__article.* FROM `#iCMS@__article`,`#iCMS@__vlink` WHERE #iCMS@__article.id = `indexId` AND `fid`=\''.$vars['fid'].'\' AND';
        //         $orderSQL        = " ORDER BY #iCMS@__vlink.indexId $by";
    } elseif ($vars['action'] == 'tag') {
        if (empty($vars['tag'])) {
            return false;
        }
        if (is_array($vars['tag'])) {
            $_tCache = $vars['tag'];
        } else {
            $_tCache = $iCMS->getCache($iCMS->getTagKey($vars['tag']));
        }
        if ($_tCache['id']) {
            $tidSQL = 'AND `tid`=\'' . $_tCache['id'] . '\'';
        } else {
            if ($_tCache) {
                foreach ($_tCache as $_tag) {
                    if ($_tag) {
                        $_tids[] = $_tag['id'];
                    }
                }
            }
            if (empty($_tids)) {
                return false;
            }
            $tidSQL = 'AND `tid` in (' . implode(',', $_tids) . ')';
        }
        $countSQL = 'SELECT count(#iCMS@__article.id) FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE #iCMS@__article.id = `indexId` ' . $tidSQL . ' AND';
        $selectSQL = 'SELECT #iCMS@__article.* FROM `#iCMS@__article`,`#iCMS@__taglist` WHERE #iCMS@__article.id = `indexId` ' . $tidSQL . ' AND';
        $orderSQL = " ORDER BY #iCMS@__taglist.indexId {$by}";
        $vars['indexId!'] && ($whereSQL .= getSQL($vars['indexId!'], '#iCMS@__article.id', 'not'));
    }
    $offset = 0;
    if ($vars['page']) {
        empty($countSQL) && ($countSQL = "SELECT count(*) FROM `#iCMS@__article` WHERE");
        $total = iCMS_DB::getValue($countSQL . " {$whereSQL}");
        //        echo iCMS_DB::last_query;
        $pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
        $pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
        $offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
        //        $GLOBALS['cpn'] && $iCMS->_vars['pagenav'].='<span><a class="page_more" href="more.php?fid='.$ids.'" target="_self">'.$iCMS->language('page:more').'</a></span>';
        //$iCMS->addto($pagenav,"----------------");
    }
    $iscache = true;
    if ($vars['cache'] == false || isset($vars['page'])) {
        $iscache = false;
        $rs = array();
    } else {
        $cacheName = 'list/' . md5($whereSQL . $orderSQL . $maxperpage);
        $rs = $iCMS->getCache($cacheName);
    }
    if (empty($rs)) {
        empty($selectSQL) && ($selectSQL = "SELECT id,fid,title,stitle,clink,url,source,author,editor,userid,pic,keywords,tags,description,related,pubdate,hits,good,bad,comments,top FROM `#iCMS@__article` WHERE");
        $rs = iCMS_DB::getArray($selectSQL . " {$whereSQL} {$orderSQL} LIMIT {$offset} , {$maxperpage}");
        //echo iCMS_DB::$last_query;
        //iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
        //$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
        //var_dump($explain);
        $_count = count($rs);
        for ($i = 0; $i < $_count; $i++) {
            $rs[$i]['pic'] && ($rs[$i]['pic'] = FS::fp($rs[$i]['pic'], '+http'));
            $F = $forum[$rs[$i]['fid']];
            $rs[$i]['sort']['name'] = $F['name'];
            $rs[$i]['sort']['url'] = $iCMS->iurl('forum', $F)->href;
            $rs[$i]['sort']['link'] = "<a href='{$rs[$i]['sort']['url']}'>{$rs[$i]['sort']['name']}</a>";
            $rs[$i]['url'] = $iCMS->iurl('show', array($rs[$i], $F))->href;
            $rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['title']}</a>";
            $rs[$i]['commentUrl'] = $iCMS->config['publicURL'] . "/comment.php?indexId=" . $rs[$i]['id'] . "&sortId=" . $rs[$i]['fid'];
            $rs[$i]['metadata'] && ($rs[$i]['metadata'] = unserialize($rs[$i]['metadata']));
            $rs[$i]['description'] && ($rs[$i]['description'] = str_replace("\n", "<br />", $rs[$i]['description']));
            if ($rs[$i]['tags'] && isset($vars['tag'])) {
                $tagarray = explode(',', $rs[$i]['tags']);
                foreach ($tagarray as $tk => $tag) {
                    $t = $iCMS->getTag($tag);
                    if ($t) {
                        $rs[$i]['tag'][$tk]['name'] = $tag;
                        $rs[$i]['tag'][$tk]['url'] = $t['url']->href;
                        $rs[$i]['taglink'] .= '<a href="' . $rs[$i]['tag'][$tk]['url'] . '" class="tag" target="_self">' . $tag . '</a> ';
                    }
                }
            }
        }
        $iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
    }
    return $rs;
}
Beispiel #13
0
                高:
                <input type="text" id="h" name="h" value="0"/>
                <br />
                </fieldset>
                <input type="submit" value="剪裁" class="submit"/>
              </td>
              <td ><fieldset>
                <legend>预览</legend>
                <div style="width:<?php 
echo $tw;
?>
px;height:<?php 
echo $th;
?>
px;overflow:hidden; margin:5px;"> <img src="<?php 
echo FS::fp($pFile, '+http');
?>
" id="crop_preview" width="<?php 
echo $pw;
?>
" style="border:#CCCCCC solid 1px;"/> </div>
                </fieldset></td>
            </tr>
          </form>
        </table></td>
    </tr>
  </table>
  </fieldset>
</div>
</body>
</html>
Beispiel #14
0
 function into($id)
 {
     $rs = iCMS_DB::getRow("SELECT a.title,ad.body FROM `#iCMS@__article` a LEFT JOIN `#iCMS@__article_data` ad ON a.id=ad.aid WHERE a.id='{$id}'");
     $img = array();
     $msg = false;
     preg_match_all("/<img.*?src\\s*=[\"|'|\\s]*(http:\\/\\/.*?\\.(gif|jpg|jpeg|bmp|png)).*?>/is", $rs->body, $img);
     $_array = array_unique($img[1]);
     foreach ($_array as $key => $value) {
         $value = FS::fp($value, '-http');
         $rootpf = FS::fp($value, '+iPATH');
         if (file_exists($rootpf)) {
             $pti = pathinfo($rootpf);
             $_FileSize = @filesize($rootpf);
             $filename = $pti['filename'];
             $frs = iCMS_DB::getRow("SELECT `id`,`aid` FROM `#iCMS@__file` WHERE `filename`='{$filename}'");
             if (empty($frs)) {
                 iCMS_DB::query("INSERT INTO `#iCMS@__file` (`aid`,`filename`,`ofilename`,`path`,`intro`,`ext`,`size` ,`time`,`type`) VALUES ('{$id}','" . $filename . "', '', '{$path}','{$rs->title}', '" . $pti['extension'] . "', '{$_FileSize}', '" . time() . "', '0')");
                 $msg .= "图片: " . $value . " 入库…<span style='color:green;'>√</span><br />";
             } else {
                 $msg .= "图片: " . $value . " 文件库中已有…<span style='color:green;'>×</span><br />";
             }
             if (empty($frs->aid)) {
                 iCMS_DB::query("UPDATE `#iCMS@__file` SET `aid`='{$id}' where `filename`='{$filename}'");
                 $msg .= "图片: " . $value . " 所属文章ID已更新…<span style='color:green;'>√</span><br />";
             }
         } else {
             $data = "AID: " . $id . " 路径: [" . $rootpf . "] 标题: " . $rs->title . "\n";
             FS::write(iPATH . "admin/logs/pic_exist_" . date('Y-m-d') . ".txt", $data, true, "a+");
         }
     }
     return $msg;
 }