$nbcomments = 0; //initialize nbcomments if ($del && ($admin[sary][level] >= LEVEL_DEL || $sary->uid == $USER->uid)) { $qry = $DB->query("DELETE FROM #__namana_sary_comments WHERE id='{$del}'"); $nbcomments = $DB->get_var("SELECT count(id) FROM #__namana_sary_comments WHERE saryid='{$saryid}'"); $qry = $DB->query("UPDATE #__namana_sary SET comments = {$nbcomments} WHERE saryid='{$saryid}'"); del_cache("namana|sary|comments|" . $saryid); } if ($alefa && !is_blocked($sary->user)) { // nampiditra comment if ($comment) { $daty = gmmktime(); $qry = $DB->query("INSERT INTO #__namana_sary_comments (user, saryid, comment, daty) VALUES('{$USER->username}', '{$saryid}', '{$comment}', {$daty})"); $nbcomments = $DB->get_var("SELECT count(id) FROM #__namana_sary_comments WHERE saryid='{$saryid}'"); $qry = $DB->query("UPDATE #__namana_sary SET comments = {$nbcomments} WHERE saryid='{$saryid}'"); del_cache("namana|sary|comments|" . $saryid); } } $debut = $debut ? $debut : 0; $limite = 20; $total = $nbcomments > 0 ? $nbcomments : $DB->get_var("SELECT count(id) FROM #__namana_sary_comments WHERE saryid='{$saryid}' "); $comments = get_cache("SELECT * FROM #__namana_sary_comments WHERE saryid='{$saryid}' ORDER BY id LIMIT {$debut}, {$limite}", -1, "namana|sary|comments|" . $saryid); $sary->comments = $comments; $smarty->assign("sary", $sary); if (is_blocked($sary->user)) { $smarty->assign("blocked", true); } $smarty->assign("debut", $debut); $smarty->assign("limite", $limite); $smarty->assign("total", $total); $x_body .= $smarty->fetch($CFG->moddir . "namana/templates/sary_comments.htm");
public function createAction() { global $tpl; set_time_limit(100); //删除data/chache目录 $path = DATA_DIR . 'cache/'; //缓存目录 if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //$files[] = $file; @unlink($path . $file); } } closedir($handle); } //删除首页 del_cache(); //文章 $total = Cache::getTotal(); $start = 0; $limit = 20; $start_id = 0; $i = 0; $tablename_content = Record::tableFromClass('Article'); $tablename_contentpart = Record::tableFromClass('ContentPart'); $previous = null; while ($i < $total) { $sql = "select * from {$tablename_content} where type='post' and id > {$start_id} order by id asc limit {$limit}"; Record::$__CONN__->query($sql); $articles = array(); $articles = Record::$__CONN__->last_result; if (is_array($articles) && count($articles) > 0) { foreach ($articles as $k => $data) { $article = new Article(get_object_vars($data)); //上一页 $previous = isset($previous) ? $previous : ''; $tpl->assign('previous', $previous); $previous = $article; //下一页 if (isset($articles[$k + 1])) { //$next = new Article(get_object_vars($articles[$k+1])); $next = $articles[$k + 1]; } else { $next = $article->next(); } $tpl->assign('next', $next); $content_part = ContentPart::findById($article->id); $article->content = processContent($content_part->content); $article->tags = isset($this->cahce_tags[$article->id]) ? $this->cahce_tags[$article->id] : array(); $article->category = isset($this->cahce_categories[$article->cid]) ? $this->cahce_categories[$article->cid]['name'] : '无分类'; $article->category_slug = isset($this->cahce_categories[$article->cid]) ? $this->cahce_categories[$article->cid]['slug'] : 'uncategory'; $this->createHtml($article); if ($k == $limit - 1) { $start_id = $article->id; } } } $i += $limit; } //while flush(); echo 'create cache over!'; echo '<a href="index.php">Index</a>'; }
amessage('channelmodifyfinish', axaction(6, '?entry=fchannels&action=fchanneldetail&chid=' . $chid)); } } elseif ($action == 'fchanneldel' && $chid) { if (empty($confirm)) { $message = lang('del_alert') . "<br><br>"; $message .= lang('confirmclick') . "[<a href=?entry=fchannels&action=fchanneldel&chid=" . $chid . "&confirm=1>" . lang('delete') . "</a>] "; $message .= lang('giveupclick') . "[<a href=?entry=fchannels&action=fchannelsedit>" . lang('goback') . "</a>]"; amessage($message); } if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}fcatalogs WHERE chid='{$chid}'")) { amessage('chaoutrelocdel', '?entry=fchannels&action=fchannelsedit'); } $db->query("DROP TABLE IF EXISTS {$tblprefix}farchives_{$chid}"); $db->query("DELETE FROM {$tblprefix}fchannels WHERE chid='{$chid}'"); $db->query("DELETE FROM {$tblprefix}ffields WHERE chid='{$chid}'"); del_cache('ffields', $chid); @unlink(M_ROOT . './dynamic/mguides/free_' . $chid . '.php'); adminlog(lang('delete_freeinfo_channel')); updatecache('fchannels'); amessage('frechadelfin', "?entry=fchannels&action=fchannelsedit"); } elseif ($action == 'fielddetail' && $chid && $fieldename) { !isset($fchannels[$chid]) && amessage('choosechannel', '?entry=fchannels&action=fchannelsedit'); $field = read_cache('ffield', $chid, $fieldename); empty($field) && amessage('choosefield', '?entry=fchannels&action=fchanneldetail&chid=' . $chid); if (!submitcheck('bfielddetail')) { tabheader("[" . $fchannels[$chid]['cname'] . "] " . lang('field_edit') . " [{$field['cname']}]", 'fielddetail', "?entry=fchannels&action=fielddetail&chid={$chid}&fieldename={$fieldename}", 2, 0, 1); $submitstr = ''; list($fmode, $fnew, $fsave) = array('fa', false, false); include_once M_ROOT . "./include/fields/{$field['datatype']}.php"; tabfooter('bfielddetail', lang('submit')); check_submit_func($submitstr);
public function del() { del_cache(); }
foreach ($mtagnew['setting'] as $key => $val) { if (in_array($key, $unsetvars) && empty($val)) { unset($mtagnew['setting'][$key]); } if (!empty($unsetvars1[$key]) && in_array($val, $unsetvars1[$key])) { unset($mtagnew['setting'][$key]); } } } $mtagnew['template'] = empty($mtagnew['template']) ? '' : stripslashes($mtagnew['template']); $mtagnew['disabled'] = empty($mtag['disabled']) ? 0 : 1; $mtag = array('cname' => stripslashes($mtagnew['cname']), 'ename' => $mtagnew['ename'], 'tclass' => $tclass, 'template' => $mtagnew['template'], 'setting' => $mtagnew['setting'], 'disabled' => $mtagnew['disabled']); $mtags[$mtagnew['ename']] = array('tclass' => $tclass, 'vieworder' => $mtags[$tname]['vieworder']); cache2file($mtag, cache_name($ttype, $mtagnew['ename']), $ttype, $sid); if ($mtagnew['ename'] != $tname) { del_cache($ttype, $tname, '', $sid); unset($mtags[$tname]); } mtags_order($mtags); cache2file($mtags, $ttype . 's', $ttype . 's', $sid); adminlog(lang('detamod' . $ttype)); amessage('tagmodfin', axaction(6, $forward)); } } function mtags_order(&$mtags) { if (!is_array($mtags) || empty($mtags) || !function_exists('array_multisort')) { return; } foreach ($mtags as $k => $v) { $vorder[$k] = $v['vieworder'];
function del_cache($dir, $ext_fl = '') { if ($fp = opendir($dir)) { while (($file = readdir($fp)) !== false) { if (substr($file, 0, 1) != '.' && substr($file, -9) != 'index.htm') { $fl = $dir . $file; if ($fl != $dir . $ext_fl) { is_file($fl) && @unlink($fl); } is_dir($fl) && del_cache($fl . '/', $ext_fl); } } closedir($fp); } }
$sqlstr = ""; foreach ($lines as $line) { $line = trim($line); if ($line != "") { if (!($line[0] == "#" || $line[0] . $line[1] == "--")) { $sqlstr .= $line; } } } $sqlstr = rtrim($sqlstr, ";"); $sqls = explode(";", $sqlstr); foreach ($sqls as $k => $v) { $rs = $db->dbs($v); } if ($rs) { echo 'install:error'; } else { $data['DB_HOST'] = $_POST['db_host']; $data['DB_NAME'] = $_POST['db_name']; $data['DB_USER'] = $_POST['db_user']; $data['DB_PWD'] = $_POST['db_pwd']; $data['install'] = 1; $confile = 'config.php'; $c = (require $confile); $c = array_merge($c, $data); $settingstr = '<?php ' . "\n" . 'return ' . var_export($c, true) . ';'; file_put_contents($confile, $settingstr); del_cache(); echo 'install:success'; } }
/** * 批量移动文章 * @param <type> $args */ public function batch_moveAction($args = null) { //move update cid $post_checked = isset($_POST['checked']) ? $_POST['checked'] : null; $newcid = isset($_POST['newcid']) ? $_POST['newcid'] : null; if (is_array($post_checked) && count($post_checked) > 0) { $id_arr = array(); foreach ($post_checked as $val) { $data = unserialize(base64_decode($val)); if ($data->cid != $newcid) { $id_arr[] = $data->id; //更新分类统计 // $c2 = new Category('id', $data->cid); // $c2->count--; // $c2->save(); $tablename = Record::tableFromClass('Category'); $sql = "UPDATE {$tablename} SET count=count-1 WHERE id = '{$data->cid}'"; Record::$__CONN__->query($sql); } } //sql Article::moveIds($id_arr, $newcid); } //更新文章分类统计 $c1 = new Category('id', $newcid); $c1->count = $c1->count + count($id_arr); $c1->save(); del_cache(); go_redirect('index.php?job=admin_article'); }
public function __construct() { global $tpl, $app; $app->refresh(); $this->cache = new FileCache(); $this->cache->cachePath = DATA_DIR . 'cache/'; //侧栏分类 $categories = $this->cache->get('categories'); if ($categories === false) { $categories = array(); //获得所有分类 $categories[0] = Category::findAll(); if (is_array($categories[0]) && count($categories[0]) > 0) { foreach ($categories[0] as $k => $v) { $categories[0][$k]->url = SITE_URL . 'category/' . $v->slug . '/'; //$this->categories[$v->id] = get_object_vars($v); $categories[1][$v->id] = $v; $categories[1][$v->slug] = $v; } } if (DEBUG === false) { $this->cache->set('categories', $categories, 7200); //缓存2小时 del_cache(); } } //mprint_r($categories[0], 'a'); //分别以ID, slug为键值的分类组合 $this->categories = $categories[1]; //Tags 热词 $tags_list = $this->cache->get('hot_tags'); if ($tags_list === false) { $hot_tags = Tag::findAll(20); //mprint_r($hot_tags, '$hot_tags'); if (count($hot_tags) > 0) { $first = current($hot_tags); $last = end($hot_tags); foreach ($hot_tags as $k => $v) { $tags_list[$k]['word'] = $v->name; $tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count); $tags_list[$k]['url'] = SITE_URL . 'tag/' . strtolower($v->name) . '/'; } } if (DEBUG === false) { $this->cache->set('hot_tags', $tags_list, 7200); } } //首页最近文章 $recent_post = $this->cache->get('recent_post'); if ($recent_post === false) { $recent_post = Article::getPost(5); if (is_array($recent_post) && count($recent_post) > 0) { foreach ($recent_post as $key => $val) { $recent_post[$key]->url = SITE_URL . 'post/' . $val->id . '.html'; } } if (DEBUG === false) { $this->cache->set('recent_post', $recent_post, 7200); //缓存2小时 del_cache(); } } //mprint_r($recent_post, '$recent_post'); $tpl->assign('recent_post', $recent_post); $tpl->assign('categories', $categories[0]); $tpl->assign('tag_list', $tags_list); }
if (empty($confirm)) { $message = lang('del_alert') . "<br><br>"; $message .= lang('confirmclick') . "[<a href=?entry=matypes&action=matypedel&matid=" . $matid . "&confirm=1>" . lang('delete') . "</a>] "; $message .= lang('giveupclick') . "[<a href=?entry=matypes&action=matypesedit>" . lang('goback') . "</a>]"; amessage($message); } if ($db->result_one("SELECT COUNT(*) FROM {$tblprefix}marchives_{$matid}")) { amessage('deluserasmatype', '?entry=matypes&action=matypesedit'); } $db->query("DELETE FROM {$tblprefix}mcnodes WHERE mcnvar='matid' AND mcnid='{$matid}'"); updatecache('mcnodes'); $db->query("DROP TABLE IF EXISTS {$tblprefix}marchives_{$matid}", 'SILENT'); $db->query("DELETE FROM {$tblprefix}matypes WHERE matid='{$matid}'", 'SILENT'); $db->query("DELETE FROM {$tblprefix}mafields WHERE matid='{$matid}'", 'SILENT'); //清除相关缓存 del_cache('mafields', $matid); adminlog(lang('del_matype')); updatecache('matypes'); amessage('matypedelsuccess', "?entry=matypes&action=matypesedit"); } elseif ($action == 'fielddetail' && $matid && $fieldename) { !isset($matypes[$matid]) && amessage('choosematype'); $field = read_cache('mafield', $matid, $fieldename); empty($field) && amessage('choosefield'); if (!submitcheck('bfielddetail')) { $submitstr = ''; tabheader(lang('edit_matype_field') . " - " . $matypes[$matid]['cname'] . " - {$field['cname']}", 'fielddetail', "?entry=matypes&action=fielddetail&matid={$matid}&fieldename={$fieldename}", 2, 0, 1, 1); list($fmode, $fnew, $fsave) = array('ma', false, false); include M_ROOT . "./include/fields/{$field['datatype']}.php"; tabfooter('bfielddetail'); check_submit_func($submitstr); a_guide('fielddetail');