Exemple #1
0
 function del($formid)
 {
     $formid = intval($formid);
     $formname = $this->where('formid', $formid)->getOne('formname');
     $formname = $formname['formname'];
     if (model('admin_menu')->where('action', 'Form/manage')->where('menuname', $formname)->delete()) {
         if ($this->where('formid', $formid)->delete()) {
             model('form_content')->where('formid', $formid)->delete();
         }
     }
     cache::flush('admin/admin_menu');
     return true;
 }
Exemple #2
0
 /**
  * Update the page with a new set of data
  *
  * @param array $data
  */
 public function update($data = array(), $lang = null)
 {
     $data = array_merge($this->content()->toArray(), $data);
     if (!data::write($this->textfile(null, $lang), $data, 'kd')) {
         throw new Exception('The page could not be updated');
     }
     cache::flush();
     $this->reset();
     $this->touch();
     return true;
 }
Exemple #3
0
 }
 if (init('action') == 'getRestoreLog') {
     ajax::success(log::get('restore', 0, 3000));
 }
 if (init('action') == 'removeBackup') {
     jeedom::removeBackup(init('backup'));
     ajax::success();
 }
 if (init('action') == 'listBackup') {
     ajax::success(jeedom::listBackup());
 }
 if (init('action') == 'getConfiguration') {
     ajax::success(jeedom::getConfiguration(init('key'), init('default')));
 }
 if (init('action') == 'flushcache') {
     cache::flush();
     ajax::success();
 }
 if (init('action') == 'resetHwKey') {
     config::save('jeedom::installKey', '');
     ajax::success();
 }
 if (init('action') == 'backupupload') {
     $uploaddir = dirname(__FILE__) . '/../../backup';
     if (!file_exists($uploaddir)) {
         mkdir($uploaddir);
     }
     if (!file_exists($uploaddir)) {
         throw new Exception(__('Répertoire d\'upload non trouvé : ', __FILE__) . $uploaddir);
     }
     if (!isset($_FILES['file'])) {
<?php

include_once "util/top_foot_inc.php";
include "includes/caching.php";
connetti();
$cache = new cache();
$cache->flush();
dumpa($cache, 1);
top2();
$html = <<<EOD
<div
\tclass="centrale"
\talign="center"
>

Cache Scaricata

EOD;
echo $html;
foot();
 public function delete()
 {
     // delete the meta file
     f::remove($this->textfile());
     if (!f::remove($this->root())) {
         throw new Exception('The file could not be deleted');
     }
     cache::flush();
     return true;
 }
Exemple #6
0
         $body = '<form action="" method="post">';
         $body .= '<table><tr><th>' . _('IP address') . '</th><th>' . _('Reason') . '</th><th>' . _('Board') . '</th><th>' . _('Set') . '</th><th>' . _('Expires') . '</th><th>' . _('Staff') . '</th></tr>';
         while ($ban = $query->fetch()) {
             $body .= '<tr' . ($config['mod']['view_banexpired'] && $ban['expires'] != 0 && $ban['expires'] < time() ? ' style="text-decoration:line-through"' : '') . '>' . '<td style="white-space: nowrap">' . '<input type="checkbox" name="ban_' . $ban['id'] . '" id="ban_' . $ban['id'] . '" /> ' . (preg_match('/^(\\d+\\.\\d+\\.\\d+\\.\\d+|' . $config['ipv6_regex'] . ')$/', $ban['ip']) ? '<a href="?/IP/' . $ban['ip'] . '">' . $ban['ip'] . '</a>' : utf8tohtml($ban['ip'])) . '</td>' . '<td>' . ($ban['reason'] ? $ban['reason'] : '<em>-</em>') . '</td>' . '<td style="white-space: nowrap">' . (isset($ban['board']) ? sprintf($config['board_abbreviation'], $ban['board']) : '<em>' . _('all boards') . '</em>') . '</td>' . '<td style="white-space: nowrap">' . strftime($config['post_date'], $ban['set']) . '</td>' . '<td style="white-space: nowrap">' . ($ban['expires'] == 0 ? '<em>Never</em>' : strftime($config['post_date'], $ban['expires'])) . '</td>' . '<td>' . (isset($ban['username']) ? !hasPermission($config['mod']['view_banstaff']) ? $config['mod']['view_banquestionmark'] ? '?' : ($ban['type'] == JANITOR ? 'Janitor' : ($ban['type'] == MOD ? 'Mod' : ($ban['type'] == ADMIN ? 'Admin' : '?'))) : utf8tohtml($ban['username']) : '<em>deleted?</em>') . '</td>' . '</tr>';
         }
         $body .= '</table>' . (hasPermission($config['mod']['unban']) ? '<p style="text-align:center"><input name="unban" type="submit" value="Unban selected" /></p>' : '') . '</form>';
     }
     echo Element('page.html', array('config' => $config, 'title' => _('Ban list'), 'body' => $body, 'mod' => true));
 } elseif (preg_match('/^\\/flush$/', $query)) {
     if (!hasPermission($config['mod']['rebuild'])) {
         error($config['error']['noaccess']);
     }
     if (!$config['cache']['enabled']) {
         error(_('Cache is not enabled.'));
     }
     if (cache::flush()) {
         $body = 'Successfully invalidated all items in cache.';
         modLog('Cleared cache');
     } else {
         $body = 'An error occured while trying to flush cache.';
     }
     echo Element('page.html', array('config' => $config, 'title' => 'Flushed', 'body' => '<p style="text-align:center">' . $body . '</p>', 'mod' => true));
 } elseif (preg_match('/^\\/rebuild$/', $query)) {
     if (!hasPermission($config['mod']['rebuild'])) {
         error($config['error']['noaccess']);
     }
     set_time_limit($config['mod']['rebuild_timelimit']);
     $body = '<div class="ban"><h2>Rebuilding&hellip;</h2><p>';
     $body .= 'Clearing template cache&hellip;<br/>';
     load_twig();
     $twig->clearCacheFiles();
Exemple #7
0
 /**
  * Deletes the page
  *
  * @param boolean $force Forces the page to be deleted even if there are subpages
  */
 public function delete($force = false)
 {
     if (!$this->isDeletable()) {
         throw new Exception('The page cannot be deleted');
     }
     if ($force === false and $this->children()->count()) {
         throw new Exception('This page has subpages');
     }
     $parent = $this->parent();
     if (!dir::remove($this->root())) {
         throw new Exception('The page could not be deleted');
     }
     cache::flush();
     $parent->reset();
     return true;
 }
 /**
  * @param $type 要清理的缓存存放的空间
  */
 public function flush_cache($type)
 {
     //可以以后再加
     $cachetype = array('db', 'view_c', 'admin', 'cms');
     if ($type == 'db') {
         echo '正在清理数据库缓存。。。。。。<br>';
         ob_flush();
         flush();
         echo (cache::flush(Config::database('cache_dir')) ? '后台数据库缓存清理完成。' : '后台数据库缓存清理失败!') . '<br>';
         ob_flush();
         flush();
     } else {
         if ($type == 'view_c') {
             echo '正在清理后台模板缓存。。。。。。<br>';
             ob_flush();
             flush();
             echo (cache::flush(Config::template('view_c_dir')) ? '后台数据库缓存清理完成。' : '后台数据库缓存清理失败!') . '<br>';
             ob_flush();
             flush();
             echo '正在清理前台缓存。。。。。。<br/>';
             ob_flush();
             flush();
             echo (cache::flush(Config::cms('cms_app_name')) ? '前台缓存清理完成。' : '前台缓存清理失败!') . '<br>';
             ob_flush();
             flush();
         } else {
             if ($type == 'admin') {
                 echo '正在清理后台缓存。。。。。。<br>';
                 ob_flush();
                 flush();
                 echo (cache::flush('admin') ? '后台缓存清理完成。' : '后台缓存清理失败!') . '<br>';
                 ob_flush();
                 flush();
             } else {
                 if ($type == 'all') {
                     foreach ($cachetype as $type) {
                         $this->flush_cache($type);
                     }
                     echo '缓存清理完毕!';
                 }
             }
         }
     }
 }
 static function clearCache()
 {
     if (CACHE_DEFAULT_TTL === 0) {
         cache::flush();
     }
 }
 function translations_delete($input_id)
 {
     // don't delete translations
     if (isset($this->flag_delete) && $this->flag_delete) {
         return 0;
     }
     $res_lang = mysql_list_tables($_SESSION['common_db']);
     while ($arr_lang = mysql_fetch_array($res_lang)) {
         if ($lang_now = stristr($arr_lang[0], $this->table . '_')) {
             $lang_now = substr($lang_now, -2);
             $table = $arr_lang[0];
             $cache = new cache();
             $cache->flush($table, $this->id);
             $query = "SELECT * FROM `{$table}` WHERE `table_id`={$input_id}";
             if ($this->db == 'common') {
                 $res = common_query($query, __FILE__, __LINE__);
             } else {
                 $res = accounting_query($query, __FILE__, __LINE__);
             }
             if (!$res) {
                 return ERR_MYSQL;
             }
             if ($arr = mysql_fetch_array($res)) {
                 $query = "DELETE FROM `{$table}` WHERE `id`='" . $arr['id'] . "'";
                 if ($this->db == 'common') {
                     $res = common_query($query, __FILE__, __LINE__);
                 } else {
                     $res = accounting_query($query, __FILE__, __LINE__);
                 }
                 if (!$res) {
                     return ERR_MYSQL;
                 }
             }
         }
     }
     return 0;
 }
Exemple #11
0
 public function update($data = array(), $lang = null)
 {
     $data = array_merge((array) $this->meta()->toArray(), $data);
     foreach ($data as $k => $v) {
         if (is_null($v)) {
             unset($data[$k]);
         }
     }
     if (!data::write($this->textfile($lang), $data, 'kd')) {
         throw new Exception('The file data could not be saved');
     }
     // reset the page cache
     $this->page->reset();
     // reset the file cache
     $this->cache = array();
     cache::flush();
     return true;
 }
Exemple #12
0
 /**
  * Renames the file and also its meta info txt
  *  
  * @param string $filename
  * @param boolean $safeName
  */
 public function rename($name, $safeName = true)
 {
     $filename = $this->createNewFilename($name, $safeName);
     $root = $this->dir() . DS . $filename;
     if ($root == $this->root()) {
         return $filename;
     }
     if (file_exists($root)) {
         throw new Exception('A file with that name already exists');
     }
     if (!f::move($this->root(), $root)) {
         throw new Exception('The file could not be renamed');
     }
     foreach ($this->site->languages() as $lang) {
         // rename all meta files
         $meta = $this->textfile($lang->code());
         if (file_exists($meta)) {
             f::move($meta, $this->page->textfile($filename, $lang->code()));
         }
     }
     // reset the page cache
     $this->page->reset();
     // reset the basics
     $this->root = $root;
     $this->filename = $filename;
     $this->name = $name;
     $this->cache = array();
     cache::flush();
     return $filename;
 }
 public function role($action = false)
 {
     if ($action == false) {
         $data['role'] = model('admin_role')->select()->query();
         view('Index/role', $data);
     } elseif ($action == 'edit') {
         $status = array('status' => true, 'msg' => '修改成功!');
         if (isset($_POST['roleid']) && isset($_POST['rolename']) && isset($_POST['description'])) {
             $role = array('roleid' => $_POST['roleid'], 'rolename' => $_POST['rolename'], 'description' => $_POST['description']);
             if (model('admin_role')->edit($role) === false) {
                 $status = array('status' => false, 'msg' => '出现错误!');
             }
             echo json_encode($status);
             exit;
         } else {
             $status = array('status' => false, 'msg' => '参数错误!');
             echo json_encode($status);
             exit;
         }
     } elseif ($action == 'add') {
         $status = array('status' => true, 'msg' => '添加成功!');
         if (isset($_POST['rolename']) && isset($_POST['description'])) {
             $role = array('rolename' => $_POST['rolename'], 'description' => $_POST['description']);
             if (model('admin_role')->add($role) === false) {
                 $status = array('status' => false, 'msg' => '添加失败!');
             }
             echo json_encode($status);
             exit;
         }
     } elseif ($action == 'del') {
         $status = array('status' => false, 'msg' => '删除失败!');
         if (isset($_POST['roleid'])) {
             if (model('admin_role')->del($_POST['roleid']) !== false) {
                 $status = array('status' => true, 'msg' => '删除成功!');
             }
             if ($_POST['roleid'] == 1) {
                 $status = array('status' => false, 'msg' => '超级管理员不允许删除!');
             }
             echo json_encode($status);
             exit;
         }
     } elseif ($action == 'editrole') {
         if (isset($_POST['roleid']) && !empty($_POST['roleid'])) {
             if (intval($_POST['roleid']) == 1) {
                 $var = array('error', '修改失败', '超级管理员权限不准修改!', array('Index/role' => '返回角色修改'));
                 redirect(Router::url('Index/role'), 2);
                 controller('Admin', 'show_message', $var);
                 exit;
             }
             if (model('admin_role')->editrole($_POST['roleid'], $_POST['menuid']) !== false) {
                 $var = array('ok', '修改成功', '角色权限修改成功!', array('Index/role' => '返回角色修改'));
                 cache::flush('admin/admin_menu');
                 //修改角色权限后更新后台菜单缓存
                 cache::flush('admin/admin_menu');
                 //修改角色权限后更新后台菜单缓存
                 redirect(Router::url('Index/role'), 2);
                 controller('Admin', 'show_message', $var);
                 exit;
             }
         }
     }
 }