Example #1
0
function gethumb($sfp, $w = '', $h = '', $scale = false, $callback = false)
{
    global $iCMS;
    if (strpos($sfp, 'thumb/') !== false || strpos($sfp, 'http://') !== false) {
        return $sfp;
    }
    $sfn = substr($sfp, 0, strrpos($sfp, '.'));
    $sfn = substr($sfn, strrpos($sfn, '/'));
    $tpf = substr($sfp, 0, strrpos($sfp, '/')) . '/thumb' . $sfn . '_';
    $rootpf = getfilepath($tpf, iPATH, '+');
    if ($callback) {
        $tfArray = glob($rootpf . "*");
        if ($tfArray) {
            foreach ($tfArray as $filename) {
                if (file_exists($filename)) {
                    $fn = substr($filename, 0, strrpos($filename, '.'));
                    $per = substr($fn, strrpos($fn, '_') + 1);
                    $tfpList[$per] = $filename;
                }
            }
        }
        return $tfpList;
    } else {
        $srfp = getfilepath($sfp, iPATH, '+');
        if (file_exists($srfp)) {
            empty($w) && ($w = $iCMS->config['thumbwidth']);
            empty($h) && ($h = $iCMS->config['thumbhight']);
            $twh = $rootpf . $w . 'x' . $h . '.' . getext($sfp);
            if (!file_exists($twh)) {
                $Thumb = MakeThumbnail(substr($srfp, 0, strrpos($srfp, '/')) . '/', $srfp, substr($sfn, strrpos($sfn, '/') + 1), $w, $h, $scale);
                $twh = $Thumb['src'];
            }
            $src = $iCMS->dir . getfilepath($twh, iPATH, '-');
        } else {
            $src = $iCMS->dir . 'include/nopic.gif';
        }
        return $src;
    }
}
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name='', $title='', $delsize=0, $from = false) {
	global $_SGLOBAL, $space, $_SCONFIG, $_SC;

	if($albumid<0) $albumid = 0;
	
	$setarr = array();
	$filepath = getfilepath($fileext, true);
	$newfilename = $_SC['attachdir'].'./'.$filepath;

	if($handle = fopen($newfilename, 'wb')) {
		if(fwrite($handle, $strdata) !== FALSE) {
			fclose($handle);
			$size = filesize($newfilename);
			//检查空间大小

			if(empty($space)) {
				$space = getspace($_SGLOBAL['supe_uid']);
				$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('space')." WHERE uid='$_SGLOBAL[supe_uid]'");
				$space = $_SGLOBAL['db']->fetch_array($query);
				$_SGLOBAL['supe_username'] = addslashes($space['username']);
			}
			$_SGLOBAL['member'] = $space;

			$maxattachsize = checkperm('maxattachsize');//单位MB
			if($maxattachsize) {//0为不限制
				if($space['attachsize'] + $size - $delsize > $maxattachsize + $space['addsize']) {
					@unlink($newfilename);
					return -1;
				}
			}
			
			//检查是否图片
			if(function_exists('getimagesize')) {	
				$tmp_imagesize = @getimagesize($newfilename);
				list($tmp_width, $tmp_height, $tmp_type) = (array)$tmp_imagesize;
				$tmp_size = $tmp_width * $tmp_height;
				if($tmp_size > 16777216 || $tmp_size < 4 || empty($tmp_type) || strpos($tmp_imagesize['mime'], 'flash') > 0) {
					@unlink($newfilename);
					return -2;
				}
			}

			//缩略图
			include_once(S_ROOT.'./source/function_image.php');
			$thumbpath = makethumb($newfilename);
			$thumb = empty($thumbpath)?0:1;

			//大头帖不添加水印
			if($_SCONFIG['allowwatermark']) {
				makewatermark($newfilename);
			}

			//入库
			$filename = addslashes(($name ? $name : substr(strrchr($filepath, '/'), 1)));
			$title = getstr($title, 200, 1, 1, 1);
			
			if($albumid) {
				preg_match("/^new\:(.+)$/i", $albumid, $matchs);
				if(!empty($matchs[1])) {
					$albumname = shtmlspecialchars(trim($matchs[1]));
					if(empty($albumname)) $albumname = sgmdate('Ymd');
					$albumid = album_creat(array('albumname' => $albumname));
				} else {
					$albumid = intval($albumid);
					if($albumid) {
						$query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM ".tname('album')." WHERE albumid='$albumid' AND uid='$_SGLOBAL[supe_uid]'");
						if($value = $_SGLOBAL['db']->fetch_array($query)) {
							$albumname = addslashes($value['albumname']);
							$albumfriend = $value['friend'];
						} else {
							$albumname = sgmdate('Ymd');
							$albumid = album_creat(array('albumname' => $albumname));
						}
					}
				}
			} else {
				$albumid = 0;
			}

			$setarr = array(
				'albumid' => $albumid,
				'uid' => $_SGLOBAL['supe_uid'],
				'username' => $_SGLOBAL['supe_username'],
				'dateline' => $_SGLOBAL['timestamp'],
				'filename' => $filename,
				'postip' => getonlineip(),
				'title' => $title,
				'type' => $fileext,
				'size' => $size,
				'filepath' => $filepath,
				'thumb' => $thumb
			);
			$setarr['picid'] = inserttable('pic', $setarr, 1);

			//更新附件大小
			//积分
			$setsql = '';
			if($from) {
				$reward = getreward($from, 0);
				if($reward['credit']) {
					$setsql = ",credit=credit+$reward[credit]";
				}
				if($reward['experience']) {
					$setsql .= ",experience=experience+$reward[experience]";
				}
			}
			$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET attachsize=attachsize+'$size', updatetime='$_SGLOBAL[timestamp]' $setsql WHERE uid='$_SGLOBAL[supe_uid]'");

			//相册更新
			if($albumid) {
				$file = $filepath.($thumb?'.thumb.jpg':'');
				$_SGLOBAL['db']->query("UPDATE ".tname('album')."
					SET picnum=picnum+1, updatetime='$_SGLOBAL[timestamp]', pic='$file', picflag='1'
					WHERE albumid='$albumid'");
			}

			//最后进行ftp上传,防止垃圾产生
			if($_SCONFIG['allowftp']) {
				include_once(S_ROOT.'./source/function_ftp.php');
				if(ftpupload($newfilename, $filepath)) {
					$setarr['remote'] = 1;
					updatetable('pic', array('remote'=>$setarr['remote']), array('picid'=>$setarr['picid']));
					if($albumid) updatetable('album', array('picflag'=>2), array('albumid'=>$albumid));
				} else {
					return -4;
				}
			}
			
			//统计
			updatestat('pic');

			return $setarr;
    	} else {
    		fclose($handle);
    	}
	}
	return -3;
}
Example #3
0
         $iCMS->db->query("UPDATE `#iCMS@__{$__TABLE__}` SET `vlink` = CONCAT(vlink,'," . $vlink . "') WHERE `id` IN ({$ids})");
     }
     alert('内容虚拟链接更改完成!', "url:1");
     break;
 case 'thumb':
     empty($_POST['id']) && alert("请选择要提取缩略图的内容");
     if (is_array($_POST['id'])) {
         $UploadDir = $iCMS->config['uploadfiledir'] . "/";
         foreach ($_POST['id'] as $id) {
             $content = $iCMS->db->getValue("SELECT ad.body FROM `#iCMS@__{$__TABLE__}` a, `#iCMS@__{$__TABLE__data}` ad WHERE a.id=ad.aid and a.id='{$id}'");
             $img = array();
             preg_match_all("/src=[\"|'| ]{0,}(\\/(.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $content, $img);
             $_array = array_unique($img[1]);
             foreach ($_array as $key => $value) {
                 $value = getfilepath(trim($value), '', '-');
                 if (file_exists(getfilepath($value, iPATH, '+'))) {
                     $iCMS->db->query("UPDATE `#iCMS@__{$__TABLE__}` SET `pic` = '{$value}' WHERE `id` = '{$id}'");
                     break;
                 }
             }
         }
     }
     alert('成功提取缩略图', "url:1");
     break;
 case 'move':
     empty($_POST['id']) && alert("请选择要移动的内容");
     !$_POST['cataid'] && alert("请选择目标栏目");
     $cid = intval($_POST['cataid']);
     if (is_array($_POST['id'])) {
         foreach ($_POST['id'] as $id) {
             $id = intval($id);
Example #4
0
function stream_save($strdata, $albumid = 0, $fileext = 'jpg', $name = '', $title = '', $delsize = 0)
{
    global $_SGLOBAL, $space, $_SCONFIG, $_SC;
    $setarr = array();
    $filepath = getfilepath($fileext, true);
    $newfilename = $_SC['attachdir'] . './' . $filepath;
    if ($handle = fopen($newfilename, 'wb')) {
        if (fwrite($handle, $strdata) !== FALSE) {
            fclose($handle);
            $size = filesize($newfilename);
            //检查空间大小
            if (empty($space)) {
                $query = $_SGLOBAL['db']->query("SELECT username, credit, groupid, attachsize, addsize FROM " . tname('space') . " WHERE uid='{$_SGLOBAL['supe_uid']}'");
                $space = $_SGLOBAL['db']->fetch_array($query);
                $_SGLOBAL['supe_username'] = addslashes($space['username']);
            }
            $_SGLOBAL['member'] = $space;
            $maxattachsize = intval(checkperm('maxattachsize'));
            //单位MB
            if ($maxattachsize) {
                //0为不限制
                if ($space['attachsize'] + $size - $delsize > $maxattachsize + $space['addsize']) {
                    @unlink($newfilename);
                    return -1;
                }
            }
            //检查是否图片
            if (function_exists('getimagesize') && !@getimagesize($newfilename)) {
                @unlink($newfilename);
                return -2;
            }
            //缩略图
            include_once S_ROOT . './source/function_image.php';
            $thumbpath = makethumb($newfilename);
            $thumb = empty($thumbpath) ? 0 : 1;
            //大头帖不添加水印
            if ($_SCONFIG['allowwatermark']) {
                makewatermark($newfilename);
            }
            //入库
            $filename = addslashes($name ? $name : substr(strrchr($filepath, '/'), 1));
            $title = $title;
            if ($albumid) {
                preg_match("/^new\\:(.+)\$/i", $albumid, $matchs);
                if (!empty($matchs[1])) {
                    $albumname = shtmlspecialchars(trim($matchs[1]));
                    if (empty($albumname)) {
                        $albumname = sgmdate('Ymd');
                    }
                    $albumid = album_creat(array('albumname' => $albumname));
                } else {
                    $albumid = intval($albumid);
                    if ($albumid) {
                        $query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM " . tname('album') . " WHERE albumid='{$albumid}' AND uid='{$_SGLOBAL['supe_uid']}'");
                        if ($value = $_SGLOBAL['db']->fetch_array($query)) {
                            $albumname = addslashes($value['albumname']);
                            $albumfriend = $value['friend'];
                        } else {
                            $albumname = sgmdate('Ymd');
                            $albumid = album_creat(array('albumname' => $albumname));
                        }
                    }
                }
            } else {
                $albumname = sgmdate('Ymd');
                $albumid = album_creat(array('albumname' => $albumname));
            }
            $setarr = array('albumid' => $albumid, 'uid' => $_SGLOBAL['supe_uid'], 'dateline' => $_SGLOBAL['timestamp'], 'filename' => $filename, 'postip' => getonlineip(), 'title' => $title, 'type' => $fileext, 'size' => $size, 'filepath' => $filepath, 'thumb' => $thumb);
            $setarr['picid'] = inserttable('pic', $setarr, 1);
            //更新附件大小
            //积分
            $setsql = '';
            if ($pic_credit = creditrule('get', 'pic')) {
                $setsql = ",credit=credit+{$pic_credit}";
            }
            $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize+'{$size}', updatetime='{$_SGLOBAL['timestamp']}' {$setsql} WHERE uid='{$_SGLOBAL['supe_uid']}'");
            //相册更新
            if ($albumid) {
                $file = $filepath . ($thumb ? '.thumb.jpg' : '');
                $_SGLOBAL['db']->query("UPDATE " . tname('album') . "\r\n\t\t\t\t\tSET picnum=picnum+1, updatetime='{$_SGLOBAL['timestamp']}', pic='{$file}', picflag='1'\r\n\t\t\t\t\tWHERE albumid='{$albumid}'");
            }
            //最后进行ftp上传,防止垃圾产生
            if ($_SCONFIG['allowftp']) {
                include_once S_ROOT . './source/function_ftp.php';
                if (ftpupload($newfilename, $filepath)) {
                    $setarr['remote'] = 1;
                    updatetable('pic', array('remote' => $setarr['remote']), array('picid' => $setarr['picid']));
                    if ($albumid) {
                        updatetable('album', array('picflag' => 2), array('albumid' => $albumid));
                    }
                }
            }
            $siteurl = '';
            if (empty($setarr['remote'])) {
                $uri = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
                $siteurl = 'http://' . $_SERVER['HTTP_HOST'] . substr($uri, 0, strexists($uri, '/api') ? strrpos($uri, '/') - 3 : strrpos($uri, '/') + 1);
            }
            $setarr['filepathall'] = $siteurl . mkpicurl($setarr, 0);
            return $setarr;
        } else {
            fclose($handle);
        }
    }
    return -3;
}
Example #5
0
 function Show($argv, $page = 1, $tpl = true)
 {
     $catalog = $this->cache('catalog.cache', 'include/syscache', 0, true);
     $sql = $this->linkmodeSQL('a.id', 'a.customlink', $argv);
     //$this->mode=="CreateHtml" && $sql.=" and a.url=''";
     $rs = $this->db->getRow("SELECT a.*,d.tpl,d.body,d.subtitle FROM #iCMS@__article as a LEFT JOIN #iCMS@__articledata AS d ON a.id = d.aid WHERE {$sql} AND a.visible ='1'");
     empty($rs) && $this->error('error:page');
     if ($catalog[$rs->cid]['ishidden']) {
         return false;
     }
     if ($rs->url) {
         if ($this->mode == "CreateHtml") {
             return;
         } else {
             _header($rs->url);
         }
     }
     $rs->catalogdir = $this->cdir($catalog[$rs->cid]);
     $_urlArray = array('id' => $rs->id, 'cid' => $rs->cid, 'link' => $rs->customlink, 'url' => $rs->url, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $rs->pubdate);
     $_iurlArray = array('id' => $rs->id, 'link' => $rs->customlink, 'url' => $rs->url, 'dir' => $rs->catalogdir, 'pubdate' => $rs->pubdate);
     $iHtml = $this->iurl('show', $_iurlArray, $page - 1, iPATH);
     $rs->url = $this->iurl('show', $_urlArray);
     $tpl && $this->jumptohtml($iHtml, $rs->url);
     $this->get['id'] = $rs->id;
     $this->get['title'] = $rs->title;
     if ($this->config['linkmode'] == 'id') {
         $this->iList($rs->cid, false);
     } elseif ($this->config['linkmode'] == 'title') {
         $this->iList($rs->catalogdir, false);
     }
     if ($this->config['ishtm']) {
         $rs->hits = "<script src=\"" . $this->config['url'] . "/action.php?do=hits&id={$rs->id}&action=show\" language=\"javascript\"></script>";
         $rs->digg = "<script src=\"" . $this->config['url'] . "/action.php?do=digg&id={$rs->id}&action=show\" language=\"javascript\"></script>";
         $rs->comments = "<script src=\"" . $this->config['url'] . "/action.php?do=comment&id={$rs->id}\" language=\"javascript\"></script>";
     }
     $picArray = array();
     preg_match_all("/src=[\"|'| ]+((.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $rs->body, $picArray);
     $pA = array_unique($picArray[1]);
     foreach ($pA as $key => $value) {
         $iValue = getfilepath(trim($value), iPATH, '+');
         file_exists($iValue) && ($rs->photo[] = trim($value));
     }
     $body = explode('<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>', $rs->body);
     $rs->pagetotal = count($body);
     $nBody = $body[intval($page - 1)];
     $rs->body = $this->keywords($nBody);
     $rs->pagecurrent = $page;
     if ($rs->pagetotal > 1) {
         $rs->pagebreak = $page - 1 > 1 ? '<a href="' . $this->iurl('show', $_urlArray, $page - 1) . '" class="pagebreak" target="_self">上一页</a> ' : '<a href="' . $this->iurl('show', $_urlArray) . '" class="pagebreak" target="_self">' . $this->language('page:prev') . '</a> ';
         for ($i = 1; $i <= $rs->pagetotal; $i++) {
             $cls = $i == $page ? "pagebreaksel" : "pagebreak";
             $rs->pagebreak .= $i == 1 ? '<a href="' . $this->iurl('show', $_urlArray) . '" class="' . $cls . '" target="_self">' . $i . '</a>' : '<a href="' . $this->iurl('show', $_urlArray, $i) . '" class="' . $cls . '" target="_self">' . $i . '</a>';
         }
         $np = $rs->pagetotal - $page > 0 ? $page + 1 : $page;
         $rs->pagebreak .= '<a href="' . $this->iurl('show', $_urlArray, $np) . '" class="pagebreak" target="_self">' . $this->language('page:next') . '</a>';
     }
     $rs->page = array('total' => $rs->pagetotal, 'current' => $rs->pagecurrent, 'break' => $rs->pagebreak);
     if ($rs->tags) {
         $tagarray = explode(',', $rs->tags);
         if (count($tagarray) > 1) {
             foreach ($tagarray as $tk => $tag) {
                 if ($this->chkTagVisible($tag)) {
                     $rs->tag[$tk]['name'] = $tag;
                     $rs->tag[$tk]['url'] = $this->config['url'] . '/tag.php?t=' . rawurlencode($tag);
                     $rs->taglink .= '<a href="' . $rs->tag[$tk]['url'] . '" class="tag" target="_self">' . $rs->tagname[$tk]['name'] . '</a> ';
                 }
             }
         } else {
             if ($this->chkTagVisible($tagarray[0])) {
                 $rs->tag[0]['name'] = $tagarray[0];
                 $rs->tag[0]['url'] = $this->config['url'] . '/tag.php?t=' . rawurlencode($tagarray[0]);
                 $rs->taglink = '<a href="' . $this->config['url'] . '/tag.php?t=' . $rs->tag[0]['url'] . '" class="tag" target="_self">' . $tagarray[0] . '</a>';
             }
         }
     }
     if ($rs->related) {
         $relatedArray = explode("~#~", $rs->related);
         if ($relatedArray) {
             foreach ($relatedArray as $idtitle) {
                 list($reid, $retitle) = explode("#|\$", $idtitle);
                 $reid && $retitle && ($rel[] = $reid);
             }
         }
         if ($rel) {
             $rs->rel = implode(',', $rel);
             $this->assign('rel', $rs->rel);
         }
     }
     $prers = $this->db->getRow("SELECT * FROM `#iCMS@__article` WHERE `id` < '{$rs->id}' AND `cid`='{$rs->cid}' AND `visible`='1' order by id DESC Limit 1");
     $rs->prev = $prers ? '<a href="' . $this->iurl('show', array('id' => $prers->id, 'cid' => $prers->cid, 'link' => $prers->customlink, 'url' => $prers->url, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $prers->pubdate)) . '" class="prev" target="_self">' . $prers->title . '</a>' : $this->language('show:first');
     $nextrs = $this->db->getRow("SELECT * FROM `#iCMS@__article` WHERE `id` > '{$rs->id}'  and `cid`='{$rs->cid}' AND `visible`='1' order by id ASC Limit 1");
     $rs->next = $nextrs ? '<a href="' . $this->iurl('show', array('id' => $nextrs->id, 'cid' => $nextrs->cid, 'link' => $nextrs->customlink, 'url' => $nextrs->url, 'dir' => $rs->catalogdir, 'domain' => $catalog[$rs->cid]['domain'], 'pubdate' => $nextrs->pubdate)) . '" class="next" target="_self">' . $nextrs->title . '</a>' : $this->language('show:last');
     $this->mode != 'CreateHtml' && $this->db->query("UPDATE `#iCMS@__article` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1");
     $rs->link = "<a href='{$rs->url}'>{$rs->title}</a>";
     $this->result = $rs;
     $this->assign(array('id' => $rs->id, 'pic' => $rs->pic, 'url' => $rs->url, 'link' => $rs->link, 'title' => $rs->title, 'keywords' => $rs->keywords, 'description' => $rs->description, 'source' => $rs->source, 'author' => $rs->author, 'userid' => $rs->userid, 'postype' => $rs->postype, 'pubdate' => $rs->pubdate, 'subtitle' => $rs->subtitle, 'body' => $rs->body, 'pagetotal' => $rs->pagetotal, 'pagecurrent' => $rs->pagecurrent, 'pagebreak' => $rs->pagebreak, 'hits' => $rs->hits, 'digg' => $rs->digg, 'comments' => $rs->comments, 'tag' => $rs->tag, 'taglink' => $rs->taglink, 'prev' => $rs->prev, 'next' => $rs->next));
     $this->assign('show', (array) $rs);
     //3.1 所有内容
     if ($tpl) {
         $tpl = empty($rs->tpl) ? $catalog[$rs->cid]['tpl_contents'] : $rs->tpl;
         return $this->iPrint($tpl, 'show');
     }
 }
Example #6
0
    <th>文件大小</th>
    <th>最后修改时间</th>
    </tr>
  <?php 
for ($i = 0; $i < count($L['FileList']); $i++) {
    //$operation=='template'?'templates':$iCMS->config['uploadfiledir']
    if ($operation == 'template') {
        $filepath = $L['FileList'][$i]['path'];
    } elseif ($operation == 'file') {
        $filepath = $iCMS->config['uploadfiledir'] . "/" . $L['FileList'][$i]['path'];
        if (in_array($L['FileList'][$i]['ext'], array('jpg', 'gif', 'png', 'bmp', 'jpeg'))) {
            $thumbfilepath = gethumb($filepath, '', '', false, true);
            $li = '';
            if ($thumbfilepath) {
                foreach ($thumbfilepath as $wh => $tfp) {
                    $tfp = $iCMS->dir . getfilepath($tfp, iPATH, '-');
                    $li .= '<li><a href="javascript:void(0)" onclick="insert(\'' . $tfp . '\',\'' . $in . '\');" title="插入缩略图">' . $wh . '</a></li>';
                }
            }
        }
        $filepath = $iCMS->dir . $filepath;
    }
    ?>
  <tr>
    <td><a href="<?php 
    echo $Folder . "/" . $L['FileList'][$i]['path'];
    ?>
" class="viewpic" target="_blank"><?php 
    echo $L['FileList'][$i]['icon'];
    ?>
</a> <?php 
Example #7
0
function delArticle($id, $uid = '-1', $postype = '1')
{
    global $iCMS;
    $sql = $uid != "-1" ? "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)) {
            $thumbfilepath = gethumb($art->pic, '', '', true, true);
            delfile(iPATH . $art->pic);
            echo $art->pic . ' 文件删除…<span style="color:green;">√</span><br />';
            if ($thumbfilepath) {
                foreach ($thumbfilepath as $wh => $fp) {
                    delfile($fp);
                    echo '缩略图 ' . $wh . ' 文件删除…<span style="color:green;">√</span><br />';
                }
            }
            $iCMS->db->query("DELETE FROM `#iCMS@__file` WHERE `path` = '{$art->pic}'");
            echo $art->pic . ' 数据删除…<span style="color:green;">√</span><br />';
        } else {
            echo $art->pic . '文件 其它文章正在使用,请到文件管理删除…<span style="color:green;">×</span><br />';
        }
    }
    $catalog = $iCMS->cache('catalog.cache', 'include/syscache', 0, true);
    $art->catalogdir = $iCMS->cdir($catalog[$art->cid]);
    $_urlArray = array('id' => $art->id, 'link' => $art->customlink, 'url' => $art->url, 'dir' => $art->catalogdir, 'pubdate' => $art->pubdate);
    $body = $iCMS->db->getValue("SELECT `body` FROM `#iCMS@__articledata` WHERE aid='{$id}' Limit 1");
    if ($iCMS->config['ishtm'] && empty($art->url)) {
        $bArray = explode('<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>', $body);
        $total = count($bArray);
        if ($total > 1) {
            for ($i = 0; $i <= $total; $i++) {
                $filename = $iCMS->iurl('show', $_urlArray, $i, iPATH);
                echo getfilepath($filename, iPATH, '-') . ' 静态文件删除…<span style="color:green;">√</span><br />';
                delfile($filename, false);
            }
        }
    }
    $frs = $iCMS->db->getArray("SELECT `path` FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    for ($i = 0; $i < count($frs); $i++) {
        if (!empty($frs[$i])) {
            $frs[$i]['path'] && delfile(iPATH . $frs[$i]['path']);
            echo $frs[$i]['path'] . ' 文件删除…<span style="color:green;">√</span><br />';
        }
    }
    if ($art->tags) {
        $tagArray = explode(",", $art->tags);
        foreach ($tagArray as $k => $v) {
            if ($iCMS->db->getValue("SELECT `count` FROM `#iCMS@__tags` WHERE `name`='{$v}'") == "1") {
                $iCMS->db->query("DELETE FROM `#iCMS@__tags`  WHERE `name`='{$v}'");
            } else {
                $iCMS->db->query("UPDATE `#iCMS@__tags` SET  `count`=count-1  WHERE `name`='{$v}'");
            }
        }
        echo ' 标签更新…<span style="color:green;">√</span><br />';
    }
    $iCMS->db->query("DELETE FROM `#iCMS@__file` WHERE `aid`='{$id}'");
    echo ' 相关文件数据删除…<span style="color:green;">√</span><br />';
    $iCMS->db->query("DELETE FROM `#iCMS@__comment` WHERE aid='{$id}'");
    echo ' 评论数据删除…<span style="color:green;">√</span><br />';
    $iCMS->db->query("DELETE FROM `#iCMS@__article` WHERE id='{$id}'");
    $iCMS->db->query("DELETE FROM `#iCMS@__articledata` WHERE `id`='{$id}'");
    echo ' 文章数据删除…<span style="color:green;">√</span><br />';
    $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `count` = count-1 WHERE `id` ='{$art->cid}' LIMIT 1");
    echo ' 栏目数据更新…<span style="color:green;">√</span><br />';
    echo ' 删除完成…<span style="color:green;">√</span><br />';
    return true;
}
Example #8
0
        if ($width == $_width && $height == $_height) {
            //不对源图缩放
            $_img = icf($tMap[$type], $iPic);
            $_Type = $_img['type'];
        } else {
            $img = icf($tMap[$type], $iPic);
            $_Type = $img['type'];
            if ($img['res']) {
                $thumb = imagecreatetruecolor($_width, $_height);
                imagecopyresampled($thumb, $img['res'], 0, 0, 0, 0, $_width, $_height, $width, $height);
                $_tmpfile = $iCMS->config['uploadfiledir'] . '/crop_tmp_' . time() . rand(1, 999999);
                __image($thumb, $_Type, getfilepath($_tmpfile, iPATH, '+'));
                $_tmpfile .= '.' . $_Type;
                $_img = icf($tMap[$type], $_tmpfile);
                delfile($_tmpfile);
            }
        }
        if ($_img['res']) {
            $_thumb = imagecreatetruecolor($w, $h);
            imagecopyresampled($_thumb, $_img['res'], 0, 0, $x, $y, $w, $h, $w, $h);
            $thumbpath = substr($iPic, 0, strrpos($iPic, '/')) . "/thumb";
            $picName = substr($iPic, 0, strrpos($iPic, '.'));
            $picName = substr($picName, strrpos($picName, '/'));
            $fileName = $thumbpath . $picName . '_' . $w . 'x' . $h;
            createdir($thumbpath);
            __image($_thumb, $_img['type'], $fileName);
            $fileName .= '.' . $_Type;
            alert($pic . ' 剪裁成功!', 'javascript:insert("' . $iCMS->dir . getfilepath($fileName, iPATH, '-') . '","' . $_POST['in'] . '");');
        }
        break;
}
Example #9
0
function insert_db_remote($content, $aid)
{
    global $iCMS, $autopic;
    $UploadDir = $iCMS->config['uploadfiledir'] . "/";
    $content = stripslashes($content);
    $img = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(\\/(.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $content, $img);
    $_array = array_unique($img[2]);
    set_time_limit(0);
    foreach ($_array as $key => $value) {
        $value = getfilepath(trim($value), '', '-');
        $filename = substr($value, strrpos($value, '/') + 1);
        $pic = $iCMS->db->getValue("SELECT `pic` FROM `#iCMS@__article` WHERE `id` = '{$aid}'");
        $autopic && $key == 0 && empty($pic) && $iCMS->db->query("UPDATE `#iCMS@__article` SET `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}'");
    }
}
Example #10
0
function into($id)
{
    global $iCMS;
    $UploadDir = $iCMS->config['uploadfiledir'] . "/";
    $rs = $iCMS->db->getRow("SELECT a.title,ad.body FROM `#iCMS@__article` a, `#iCMS@__articledata` ad WHERE a.id=ad.aid and a.id='{$id}'");
    $img = array();
    preg_match_all("/src=[\"|'| ]{0,}(\\/(.*)\\.(gif|jpg|jpeg|bmp|png))/isU", $rs->body, $img);
    $_array = array_unique($img[1]);
    foreach ($_array as $key => $value) {
        $value = getfilepath(trim($value), '', '-');
        $rootpf = getfilepath($value, iPATH, '+');
        if (file_exists($rootpf)) {
            $filename = substr(strrchr($value, "/"), 1);
            $FileExt = substr(strrchr($filename, "."), 1);
            $_FileSize = @filesize($rootpf);
            if ($iCMS->db->getValue("SELECT `id` FROM `#iCMS@__file` WHERE `path`='{$value}'")) {
                echo "库中已有…<span style='color:green;'>×</span><br />";
                flush();
            } else {
                $iCMS->db->query("INSERT INTO `#iCMS@__file` (`aid`,`filename`,`ofilename`,`path`,`intro`,`ext`,`size` ,`time`,`type`) VALUES ('{$id}','{$filename}', '', '{$value}','{$rs->title}', '{$FileExt}', '{$_FileSize}', '" . time() . "', 'upload')");
                echo "图片: " . $value . " 入库…<span style='color:green;'>√</span><br />";
                flush();
            }
        } else {
            $data = "AID: " . $id . " 路径: " . $value . " 标题: " . $rs->title . "\n";
            writefile(iPATH . "admin/logs/pic_exist.txt", $data, true, "a+");
        }
    }
}
Example #11
0
function video_save($FILE, $title, $desc, $tovideoid = 0, $albumid)
{
    global $_SGLOBAL, $_SCONFIG, $space, $_SC;
    //允许上传类型
    $allowpictype = array('flv');
    //检查
    $FILE['size'] = intval($FILE['size']);
    if (empty($FILE['size']) || empty($FILE['tmp_name']) || !empty($FILE['error'])) {
        return cplang('lack_of_access_to_upload_file_size');
    }
    //判断后缀
    $fileext = fileext($FILE['name']);
    if (!in_array($fileext, $allowpictype)) {
        return cplang('only_allows_upload_file_types');
    }
    //获取目录
    if (!($filepath = getfilepath($fileext, true))) {
        return cplang('unable_to_create_upload_directory_server');
    }
    //检查空间大小
    if (empty($space)) {
        $space = getspace($_SGLOBAL['supe_uid']);
    }
    //用户组
    if (!checkperm('allowupload')) {
        ckspacelog();
        return cplang('inadequate_capacity_space');
    }
    //实名认证
    if (!ckrealname('album', 1)) {
        return cplang('inadequate_capacity_space');
    }
    //视频认证
    if (!ckvideophoto('album', array(), 1)) {
        return cplang('inadequate_capacity_space');
    }
    //新用户见习
    if (!cknewuser(1)) {
        return cplang('inadequate_capacity_space');
    }
    $maxattachsize = checkperm('maxattachsize');
    //单位MB
    if ($maxattachsize) {
        //0为不限制
        if ($space['attachsize'] + $FILE['size'] > $maxattachsize + $space['addsize']) {
            return cplang('inadequate_capacity_space');
        }
    }
    if ($albumid < 0) {
        $albumid = 0;
    }
    $showtip = true;
    $albumfriend = 0;
    if ($albumid) {
        preg_match("/^new\\:(.+)\$/i", $albumid, $matchs);
        if (!empty($matchs[1])) {
            $albumname = shtmlspecialchars(trim($matchs[1]));
            if (empty($albumname)) {
                $albumname = sgmdate('Ymd');
            }
            $albumid = album_creat(array('albumname' => $albumname));
        } else {
            $albumid = intval($albumid);
            if ($albumid) {
                $query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM " . tname('album') . " WHERE albumid='{$albumid}' AND uid='{$_SGLOBAL['supe_uid']}'");
                if ($value = $_SGLOBAL['db']->fetch_array($query)) {
                    $albumname = addslashes($value['albumname']);
                    $albumfriend = $value['friend'];
                } else {
                    $albumname = sgmdate('Ymd');
                    $albumid = album_creat(array('albumname' => $albumname));
                }
            }
        }
    } else {
        $albumid = 0;
        $showtip = false;
    }
    //本地上传
    $new_name = $_SC['attachdir'] . './' . $filepath;
    $tmp_name = $FILE['tmp_name'];
    if (@copy($tmp_name, $new_name)) {
        @unlink($tmp_name);
    } elseif (function_exists('move_uploaded_file') && @move_uploaded_file($tmp_name, $new_name)) {
    } elseif (@rename($tmp_name, $new_name)) {
    } else {
        return cplang('mobile_picture_temporary_failure');
    }
    //入库
    $setarr = array('albumid' => $albumid, 'uid' => $_SGLOBAL['supe_uid'], 'username' => $_SGLOBAL['supe_username'], 'dateline' => $_SGLOBAL['timestamp'], 'postip' => getonlineip(), 'filename' => addslashes($FILE['name']), 'title' => $title, 'desc' => $desc, 'size' => $FILE['size'], 'filepath' => $filepath);
    $setarr['id'] = inserttable('video', $setarr, 1);
    $setsql = '';
    if ($showtip) {
        $reward = getreward('uploadimage', 0);
        if ($reward['credit']) {
            $setsql = ",credit=credit+{$reward['credit']}";
        }
        if ($reward['experience']) {
            $setsql .= ",experience=experience+{$reward['experience']}";
        }
    }
    $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize+'{$FILE['size']}', updatetime='{$_SGLOBAL['timestamp']}' {$setsql} WHERE uid='{$_SGLOBAL['supe_uid']}'");
    updatestat('video');
    return $setarr;
}
Example #12
0
if (submitcheck("upload")) {
    //允许上传类型
    $FILE = $_FILES['file'];
    $allowsheettype = array('xls', 'xlsx');
    //检查
    $FILE['size'] = intval($FILE['size']);
    if (empty($FILE['size']) || empty($FILE['tmp_name']) || !empty($FILE['error'])) {
        showmessage('对不起,无法获取上传文件大小');
    }
    //判断后缀	fileext为全局变量
    $fileext = fileext($FILE['name']);
    if (!in_array($fileext, $allowsheettype)) {
        showmessage('上传文件不合法...');
    }
    //获取目录	getfilepath为全局变量
    if (!($filepath = getfilepath($fileext, true))) {
        showmessage('服务器无法创建上传目录');
    }
    //本地上传
    $new_name = $_SC['attachdir'] . './' . $filepath;
    $tmp_name = $FILE['tmp_name'];
    if (@copy($tmp_name, $new_name)) {
        //移动文件
        @unlink($tmp_name);
        //删除POST的临时文件
    } elseif (function_exists('move_uploaded_file') && @move_uploaded_file($tmp_name, $new_name)) {
    } elseif (@rename($tmp_name, $new_name)) {
    } else {
        showmessage('对不起,无法转移临时文件到服务器指定目录。~~~~(>_<)~~~~ ');
    }
    $filedownload = '';
Example #13
0
                $sql .= " AND ( cid ='{$cid}'";
            }
            $sql .= " OR `vlink` REGEXP '[[:<:]]" . preg_quote($cid, '/') . "[[:>:]]')";
        } else {
            $Admin->cpower && ($sql .= " AND cid IN(" . implode(',', $Admin->cpower) . ")");
        }
        isset($_GET['keyword']) && ($uri .= '&keyword=' . $_GET['keyword']);
        $maxperpage = 20;
        $total = $iCMS->db->getValue("SELECT count(*) FROM `#iCMS@__article` {$sql} order by id DESC");
        page($total, $maxperpage, "篇文章");
        $rs = $iCMS->db->getArray("SELECT * FROM `#iCMS@__article`{$sql} order by id DESC LIMIT {$firstcount} , {$maxperpage}");
        $_count = count($rs);
        //	echo $iCMS->db->func_call;
        include iCMS_admincp_tpl('dialog.article');
        break;
    case 'showpic':
        include iCMS_admincp_tpl('dialog.showpic');
        break;
    case 'cutpic':
        $pFile = $_GET['pic'];
        $iFile = getfilepath($pFile, iPATH, '+');
        $in = $_GET['in'];
        list($width, $height, $imagetype) = @getimagesize($iFile);
        $pw = $width > 500 ? 500 : $width;
        $tw = (int) $iCMS->config['thumbwidth'];
        $th = (int) $iCMS->config['thumbhight'];
        $rate = round($pw / $width, 2) * 100;
        $sliderMin = round($tw / $width, 2) * 100;
        include iCMS_admincp_tpl('dialog.cutpic');
        break;
}