function dofpower() { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__members` WHERE `uid`='" . intval($_GET['uid']) . "'"); $forum = new forum(); $forum->allArray(); include admincp::tpl("account.fpower"); }
function checkuser($a, $p, $ajax = false) { //验证用户 账号/密码 self::$Rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__members` WHERE `username`='{$a}' AND `password`='{$p}'"); if (empty(self::$Rs)) { //记录 $a && runlog('user.login', 'username='******'&password='******'password']); if ($ajax) { return false; } self::LoginPage(); } else { self::$uId = self::$Rs->uid; self::$Rs->info && (self::$Rs->info = unserialize(self::$Rs->info)); self::$group = iCMS_DB::getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='{self::{$Rs->groupid}}'"); //用户组 self::$power = explode(',', self::merge(self::$group->power, self::$Rs->power)); $cpower = self::merge(self::$group->cpower, self::$Rs->cpower); self::$cpower = empty($cpower) ? array(0) : explode(',', $cpower); self::$nickname = empty(self::$Rs->nickname) ? self::$Rs->username : self::$Rs->nickname; if ($ajax) { return true; } } }
function doAdd() { Admin::MP(array("menu_index_forum_add", "menu_forums_add")); include_once iPATH . 'include/model.class.php'; $forum = new forum(); if ($_GET['fid']) { Admin::CP(intval($_GET['fid']), 'Permission_Denied', __SELF__ . '?mo=forums'); $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__forum` WHERE `fid`='" . intval($_GET['fid']) . "'", ARRAY_A); $rootid = $rs['rootid']; } else { $rootid = intval($_GET['rootid']); $rootid && Admin::CP($rootid, 'Permission_Denied', __SELF__ . '?mo=forums'); } if (empty($rs)) { $rs = array(); $rs['attr'] = '1'; $rs['status'] = '1'; $rs['isexamine'] = '1'; $rs['issend'] = '1'; $rs['orderNum'] = $rs['mode'] = '0'; $rs['htmlext'] = '.html'; $rs['forumRule'] = '{FDIR}/index{EXT}'; $rs['contentRule'] = '{FDIR}/{YYYY}/{MM}-{DD}/{AID}{EXT}'; if ($rootid) { $rootRs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__forum` WHERE `fid`='" . $rootid . "'", ARRAY_A); $rs['htmlext'] = $rootRs['htmlext']; $rs['forumRule'] = $rootRs['forumRule']; $rs['contentRule'] = $rootRs['contentRule']; } } include admincp::tpl("forums.add"); }
function dofpower() { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='" . intval($_GET['groupid']) . "'"); admincp::head(); $forum = new forum(); $forum->allArray(); include admincp::tpl(); }
function delCache($id) { global $iCMS; $id = implode(',', (array) $id); $rs = iCMS_DB::getRow("SELECT `name` FROM `#iCMS@__tags` WHERE `id` in ({$id}) "); $iCMS->iCache->delete($iCMS->getTagKey($rs->name)); iCMS_DB::query("DELETE FROM `#iCMS@__tags` WHERE `id` in ({$id}) "); }
function dofpower() { include_once iPATH . 'include/forum.class.php'; $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__admin` WHERE `uid`='" . intval($_GET['uid']) . "'"); $forum = new forum(); $forum->allArray(); include admincp::tpl("account.fpower"); }
function doadd() { include_once iPATH . "include/fckeditor.php"; $editor = new FCKeditor('replace'); $id = (int) $_GET['id']; $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__keywords` where `id`='{$id}'"); $editor->Value = $rs->replace; include admincp::tpl('keywords.add'); }
function data($id = 0) { if ($id) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__model` where id='{$id}'", ARRAY_A); $rs['tbn'] = self::tbn($rs['table']); } else { $rs = iCMS_DB::getArray("SELECT * FROM `#iCMS@__model`"); } return $rs; }
function table($id) { if ($id) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__model` where id='{$id}'", ARRAY_A); if (!isSysTable($rs['table'])) { $rs['table'] = $rs['table'] . '_content'; } return $rs; } else { return false; } }
function doadd() { $id = $_GET['id']; if ($id) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__model` where `id`='{$id}'", ARRAY_A); } if (empty($rs)) { $rs['position'] = 'tools'; $rs['position2'] = 'sub'; } include admincp::tpl(); }
function checkadmin($a, $p, $Ret = false) { //验证用户 账号/密码 self::$Rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__admin` WHERE `username`='{$a}' AND `password`='{$p}'"); if (empty(self::$Rs)) { //记录 $a && runlog('login', 'username='******'&password='******'password']); return $Ret ? 'Bad' : self::LoginPage(); } else { self::$uId = self::$Rs->uid; self::$Rs->info && (self::$Rs->info = unserialize(self::$Rs->info)); self::$group = iCMS_DB::getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='" . self::$Rs->groupid . "'"); //用户组 self::$power = explode(',', self::merge(self::$group->power, self::$Rs->power)); $cpower = self::merge(self::$group->cpower, self::$Rs->cpower); self::$cpower = empty($cpower) ? array(0) : explode(',', $cpower); self::$Rs->groupid == "1" && (self::$cpower = NULL); } }
function FILES($field, $intro = "", $_dir = "", $FileName = "", $type = "upload") { global $iCMS; $RootPath = FS::path_join(iPATH, $iCMS->config['uploadfiledir']) . '/'; //绝对路径 if ($_FILES[$field]['name']) { $tmp_name = $_FILES[$field]['tmp_name']; !is_uploaded_file($tmp_name) && exit("What are you doing?"); if ($_FILES[$field]['error'] > 0) { switch ((int) $_FILES[$field]['error']) { case UPLOAD_ERR_NO_FILE: @unlink($tmp_name); javascript::alert('请选择上传文件!'); return false; break; case UPLOAD_ERR_FORM_SIZE: @unlink($tmp_name); javascript::alert('上传的文件超过大小!'); return false; break; } return false; } $_FileSize = @filesize($tmp_name); //文件类型 $oFileName = $_FILES[$field]['name']; // preg_match("/\.([a-zA-Z0-9]{2,4})$/",$oFileName,$exts); $FileExt = strtolower(FS::getExt($oFileName)); //ļʽ self::CheckValidExt($oFileName); //判断文件类型 //过滤文件; strstr($FileExt, 'ph') && ($FileExt = "phpfile"); in_array($FileExt, array('cer', 'htr', 'cdx', 'asa', 'asp', 'jsp', 'aspx', 'cgi')) && ($FileExt .= "file"); $FileMd5 = md5_file($tmp_name); $rs = iCMS_DB::getRow("SELECT * FROM #iCMS@__file WHERE `filename`='{$FileMd5}' LIMIT 1"); if (empty($rs) || $type == "reupload") { empty($FileName) && ($FileName = $FileMd5 . "." . $FileExt); // 文件保存目录方式 $FileDir = ""; if (empty($_dir)) { 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']); } } else { $FileDir = $_dir; } $RootPath = $RootPath . $FileDir . '/'; //创建目录 FS::mkdir($RootPath); //文件名 $FilePath = $FileDir . '/' . $FileName; $FileRootPath = $RootPath . $FileName; self::saveUpload($tmp_name, $FileRootPath); if (in_array($FileExt, array('gif', 'jpg', 'jpeg', 'png'))) { if ($iCMS->config['isthumb'] && ($iCMS->config['thumbwidth'] || $iCMS->config['thumbhight'])) { FS::mkdir($RootPath . "thumb"); $Thumb = self::thumbnail($RootPath, $FileRootPath, $FileMd5); !empty($Thumb['src']) && $iCMS->config['thumbwatermark'] && self::watermark($Thumb['src']); } self::watermark($FileRootPath); } // 写入数据库 empty($_FileSize) && ($_FileSize = 0); if ($type == "upload") { iCMS_DB::query("INSERT INTO `#iCMS@__file` (`filename`,`ofilename`,`path`,`intro`,`ext`,`size`,`time`,`type`) VALUES ('{$FileMd5}', '{$oFileName}', '{$FileDir}','{$intro}', '{$FileExt}', '{$_FileSize}', '" . time() . "', '0') "); $fid = iCMS_DB::$insert_id; } } else { $fid = $rs->id; $FilePath = $rs->path . "/" . $rs->filename . "." . $rs->ext; $FileName = $rs->filename . "." . $rs->ext; unlink($tmp_name); } return array('fid' => $fid, 'FilePath' => $FilePath, 'OriginalFileName' => $oFileName, 'FileName' => $FileName); } else { return; } }
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 = uploadpath($value, '-http'); $rootpf = uploadpath($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; }
function create($id, $fn = false) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__advertise` WHERE `id`='{$id}'"); return adm($rs); }
function doedit() { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__members` WHERE `uid`='" . (int) $_GET['userid'] . "'"); $rs->info = unserialize($rs->info); include admincp::tpl('user.add'); }
function dovlink() { empty($_POST['id']) && javascript::alert("请选择文章"); empty($_POST['pattern']) && javascript::alert("请选择操作方式"); $vlink = empty($_POST['vlink']) ? "" : implode(',', $_POST['vlink']); foreach ($_POST['id'] as $id) { $art = iCMS_DB::getRow("SELECT vlink,fid FROM `#iCMS@__article` WHERE `id`='{$id}'"); if ($_POST['pattern'] == 'replace') { } elseif ($_POST['pattern'] == 'addto') { $vlink = $art->vlink ? $art->vlink . ',' . $vlink : $vlink; } $vlink2 = empty($vlink) ? $art->fid : $vlink . ',' . $art->fid; vlinkDiff($vlink2, $art->vlink, $id); $vlinkArray = explode(',', $vlink); $vlinkArray = array_unique($vlinkArray); $vlinkArray2 = array(); foreach ($vlinkArray as $v) { $v != $art->fid && ($vlinkArray2[] = $v); } $vlink = empty($vlinkArray2) ? "" : implode(',', $vlinkArray2); iCMS_DB::query("UPDATE `#iCMS@__article` SET `vlink` = '{$vlink}' WHERE `id`='{$id}'"); } javascript::dialog('文章虚拟链接更改完成!', "url:1"); }
function doadd() { $id = (int) $_GET['id']; $id && ($rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__search` where `id`='{$id}'")); include admincp::tpl('search.add'); }
function quote($id = 0, $i = 0) { if ($id) { $i++; $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__comment` WHERE `id`='{$id}'"); $text = '<div class="quote">'; $i < 52 && $rs->quote && ($text .= $this->quote($rs->quote, $i)); $text .= '<span class="floor">#' . ($rs->floor + 1) . '</span>'; $text .= '<span>' . $rs->username . '的原贴:</span><p>' . str_replace("\r", '<br />', $rs->contents) . '</p>'; $text .= '</div>'; return $text; } }
function doAddfield() { $mid = (int) $_GET['id']; $fid = (int) $_GET['fid']; if ($fid) { $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__field` where `id`='{$fid}'", ARRAY_A); $rs['option'] = unserialize($rs['option']); } else { $rs['show'] = 0; } include admincp::tpl(); }
function cQuote($id = 0, $i = 0) { global $iCMS; if ($id) { $i++; $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__comment` WHERE `id`='{$id}'"); $text = '<div class="quote">'; $i < 52 && $rs->quote && ($text .= cQuote($rs->quote, $i)); $text .= '<span class="floor">#' . ($rs->floor + 1) . '</span>'; // $text.='<span>----- 以下引用 <strong><em>'.$rs->username.'</em></strong> 于 '.get_date($rs->addtime,'Y-m-d H:i').' 的发言 -----</span><p>'.$rs->contents. '</p>'; // $text.='<span>'.$rs->username.'的原贴:</span><p>'.ubb($rs->contents). '</p>'; $text .= '<span>' . $rs->username . '的原贴:</span><p>' . str_replace("\r", '<br />', $rs->contents) . '</p>'; // $text.='<div class="comment-action"><span><a href=\'javascript:iCMS.digg("up",'.$rs->indexId.','.$rs->id.')\'>支持[+<span id="up_'.$rs->id.'">'.$rs->up.'</span>]</a></span><span><a href=\'javascript:iCMS.digg("down",'.$rs->indexId.','.$rs->id.')\'>反对[-<span id="down_'.$rs->id.'">'.$rs->down.'</span>]</a></span><span><a href=\'javascript:iCMS.quote('.$rs->id.','.$rs->floor.')\' id="quote'.$rs->id.'">回复</a> <a href=\'javascript:iCMS.unquote('.$rs->id.')\' id="unquote'.$rs->id.'" style="display:none;">取消回复</a></span></div>'; $text .= '</div>'; return $text; } }
function bakuptable($tabledb) { foreach ($tabledb as $table) { $creattable .= "DROP TABLE IF EXISTS {$table};\n"; $CreatTable = iCMS_DB::getRow("SHOW CREATE TABLE {$table}", ARRAY_A); $CreatTable['Create Table'] = str_replace($CreatTable['Table'], $table, $CreatTable['Create Table']); $creattable .= $CreatTable['Create Table'] . ";\n\n"; $creattable = str_replace(DB_PREFIX, 'iCMS_', $creattable); } return $creattable; }
function dopreview() { $id = (int) $_GET['id']; $mid = $_GET['mid']; $table = model::tbn($_GET['table']); $id = $_GET['id']; !$id && javascript::alert("请选择要删除的文章"); $id && ($rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` where `id`='{$id}' AND userid='" . member::$uId . "' AND postype='0'", ARRAY_A)); echo '<style type="text/css"> .preview .title { height:53px; line-height:53px; margin:0px auto 0px; text-align: center; } .preview .title h1 { font-size:24px; font-weight: bold; } .preview .content { overflow:hidden; margin:10px auto; color:#444; font-size:14px; line-height:160%; padding:5px; } .preview .content p { font-size: 14px; margin-top: 10px; margin-right: auto; margin-bottom: 0px; margin-left: auto; line-height: 25px; text-indent: 2em; padding: 0px; } .preview .content img { clear: both; display: block; margin: 0 auto; } .preview .content a { border-bottom:1px dotted #0B3B8C; color:#0B3B8C; text-decoration:none; } </style>'; echo '<div class="preview"><div class="title"><h1>' . $rs['title'] . '</h1></div>'; echo '<div class="content"><pre>'; print_r($rs); echo '</pre></div></div>'; }
function content($id, $mId, $table = NULL, $tpl = true) { $model = $this->getCache('system/models.cache', $mId); empty($table) && ($table = $model['tbn']); $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE id='" . (int) $id . "' AND `status` ='1'"); 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, $model); $rs->iurl = $this->iurl('content', $_iurlArray, $page); $rs->url = $rs->iurl->href; $tpl && $this->gotohtml($rs->iurl->path, $rs->iurl->href, $F['mode']); $this->iList($rs->fid, false); $rs->comment = array('url' => $this->config['publicURL'] . "/comment.php?indexId={$rs->id}&mId={$mId}&sortId={$rs->fid}", 'count' => $rs->comments); if ($F['mode']) { $rs->hits = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=hits&mid={$mId}&fid={$rs->fid}&id={$rs->id}&action=show\" language=\"javascript\"></script>"; $rs->digg = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=digg&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>"; $rs->comments = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=comment&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>"; } else { $this->mode != 'CreateHtml' && iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1"); } 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> '; } } } if ($fArray = explode(',', $model['field'])) { include_once iPATH . 'include/model.class.php'; foreach ($fArray as $k => $field) { if (!model::isDefField($field)) { $FV = model::FieldValue($mId, $field, $rs->{$field}); $FV !== Null && ($rs->{$field} = $FV); } } } $rs->prev = $this->language('show:first'); $prers = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE `id` < '{$rs->id}' AND `fid`='{$rs->fid}' AND `status`='1' order by id DESC Limit 1"); $prers && ($rs->prev = '<a href="' . $this->iurl('content', array((array) $prers, $F, $model))->href . '" class="prev" target="_self">' . $prers->title . '</a>'); $rs->next = $this->language('show:last'); $nextrs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE `id` > '{$rs->id}' and `fid`='{$rs->fid}' AND `status`='1' order by id ASC Limit 1"); $nextrs && ($rs->next = '<a href="' . $this->iurl('content', array((array) $nextrs, $F, $model))->href . '" class="next" target="_self">' . $nextrs->title . '</a>'); $rs->link = "<a href='{$rs->url}'>{$rs->title}</a>"; $rs->mid = $mId; $rs->table = $table; $this->Hook($rs); $this->assign('content', (array) $rs); if ($tpl) { $tpl = empty($rs->tpl) ? $F['contentTPL'] : $rs->tpl; return $this->iPrint($tpl, 'content'); } }
function dopreview() { $id = (int) $_GET['id']; !$id && javascript::alert("请选择要删除的文章"); $rs = iCMS_DB::getRow("SELECT a.*,ad.tpl,ad.body,ad.subtitle FROM `#iCMS@__article` a LEFT JOIN `#iCMS@__article_data` ad ON a.id=ad.aid WHERE a.id='{$id}' AND a.userid='" . member::$uId . "' AND a.postype='0'", ARRAY_A); echo '<style type="text/css"> .preview .title { height:53px; line-height:53px; margin:0px auto 0px; text-align: center; } .preview .title h1 { font-size:24px; font-weight: bold; } .preview .content { overflow:hidden; margin:10px auto; color:#444; font-size:14px; line-height:160%; padding:5px; } .preview .content p { font-size: 14px; margin-top: 10px; margin-right: auto; margin-bottom: 0px; margin-left: auto; line-height: 25px; text-indent: 2em; padding: 0px; } .preview .content img { clear: both; display: block; margin: 0 auto; } .preview .content a { border-bottom:1px dotted #0B3B8C; color:#0B3B8C; text-decoration:none; } </style>'; echo '<div class="preview"><div class="title"><h1>' . $rs['title'] . '</h1></div>'; echo '<div class="content">' . $rs['body'] . '</div></div>'; }
function delContent($id, $mid, $uid = '0', $postype = '1') { $uid && ($sql = "and `userid`='{$uid}' and `postype`='{$postype}'"); $model = model::data($mid); $table = $model['tbn']; $FArray = model::field($mid); $MF = explode(',', $model['field']); $rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` where `id`='{$id}' {$sql}", ARRAY_A); foreach ($MF as $field) { if ($FArray[$field]['type'] == 'upload') { $rs[$field] && ($msg .= delpic($rs[$field])); } } $rs['tags'] && ($msg .= deltag($rs['tags'])); iCMS_DB::query("DELETE FROM `#iCMS@__comment` WHERE indexId='{$id}' and mid='{$mid}'"); $msg .= '评论数据删除…<span style=\'color:green;\'>√</span><br />'; iCMS_DB::query("DELETE FROM `#iCMS@__{$table}` WHERE id='{$id}'"); iCMS_DB::query("DELETE FROM `#iCMS@__vlink` WHERE indexId='{$id}' AND modelId='{$mid}'"); $msg .= '内容数据删除…<span style=\'color:green;\'>√</span><br />'; iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='" . $rs['fid'] . "' LIMIT 1"); $msg .= '栏目数据更新…<span style=\'color:green;\'>√</span><br />'; $msg .= '删除完成…<span style=\'color:green;\'>√</span><hr />'; return $msg; }
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)); //ļʽ 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); }
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, '', '', false, true, true); FS::del(uploadpath($art->pic, '+iPATH')); $msg .= $art->pic . ' 文件删除…<span style=\'color:green;\'>√</span><br />'; if ($thumbfilepath) { foreach ($thumbfilepath as $wh => $fp) { FS::del(uploadpath($fp, '+iPATH')); $msg .= '缩略图 ' . $wh . ' 文件删除…<span style=\'color:green;\'>√</span><br />'; } } $filename = FS::info($art->pic)->filename; iCMS_DB::query("DELETE FROM `#iCMS@__file` WHERE `filename` = '{$filename}'"); $msg .= $art->pic . ' 数据删除…<span style=\'color:green;\'>√</span><br />'; } 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(uploadpath($frs[$i]['path'], '+iPATH')); $msg .= $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}'"); $iCMS->iCache->delete($iCMS->getTagKey($v)); } else { iCMS_DB::query("UPDATE `#iCMS@__tags` SET `count`=count-1 ,`updatetime`='" . time() . "' WHERE `name`='{$v}'"); } } iCMS_DB::query("DELETE FROM `#iCMS@__taglist` WHERE indexId='{$id}' AND modelId='0'"); $msg .= '标签更新…<span style=\'color:green;\'>√</span><br />'; } 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; }
function iCMS_plugins_statistics($vars, &$iCMS) { $a = iCMS_DB::getRow("SELECT count(*) AS c,SUM(hits) AS h FROM #iCMS@__article WHERE status='1'"); $c = iCMS_DB::getValue("SELECT count(*) FROM #iCMS@__comment WHERE `status`='1'"); echo "<p>日志: <b>{$a->c}</b> 篇</p><p>评论: <b>{$c}</b> 个</p><p>访问: <b>{$a->h}</b> 次</p>"; }
function doadd() { include iPATH . 'include/from.fun.php'; $mid = $_GET['mid']; $table = model::tbn($_GET['table']); $model = model::data($mid); $fArray = explode(',', $model['field']); $_count = count($fArray); $rs = array(); $id = $_GET['id']; $id && ($rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` where `id`='{$id}'", ARRAY_A)); $rs['mName'] = $_GET['table']; $rs['mid'] = $mid; $rs['fid'] = empty($rs['fid']) ? intval($_GET['fid']) : $rs['fid']; $rs['pubdate'] = empty($id) ? get_date('', "Y-m-d H:i:s") : get_date($rs['pubdate'], 'Y-m-d H:i:s'); empty($rs['editor']) && ($rs['editor'] = empty(member::$Rs->name) ? member::$Rs->username : member::$Rs->name); empty($rs['userid']) && ($rs['userid'] = member::$uId); $rs['orderNum'] = _int($rs['orderNum']); $rs['top'] = _int($rs['top']); $formArray = FormArray($mid, $fArray, $rs); $strpos = strpos(__REF__, '?'); $REFERER = $strpos === false ? '' : substr(__REF__, $strpos); include admincp::tpl(); }
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->commentInfo = array('title' => $rs->title, 'indexId' => $rs->id, 'mId' => 0, 'sortId' => $rs->fid); $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 = uploadpath($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']; $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->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->link = "<a href='{$rs->url}'>{$rs->title}</a>"; $this->result = $rs; if ($F['mode']) { $rs->hits = "<script src=\"" . $this->config['publicURL'] . "/action.php?do=hits&id={$rs->id}&action=show\" type=\"text/javascript\"></script>"; $rs->digg = "<script src=\"" . $this->config['publicURL'] . "/action.php?do=digg&id={$rs->id}&action=show\" type=\"text/javascript\"></script>"; $rs->comments = "<script src=\"" . $this->config['publicURL'] . "/action.php?do=comment&id={$rs->id}\" type=\"text/javascript\"></script>"; } else { $this->mode != 'CreateHtml' && iCMS_DB::query("UPDATE `#iCMS@__article` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1"); } $this->assign('show', (array) $rs); if ($tpl) { $tpl = empty($rs->tpl) ? $F['contentTPL'] : $rs->tpl; return $this->iPrint($tpl, 'show'); } }