示例#1
0
文件: index.php 项目: laiello/bz-owl
function update_activity($teamid = false)
{
    global $maintenance;
    if (!isset($maintenance)) {
        require_once dirname(dirname(__FILE__)) . '/add-ons/maintenance/maintenance.php';
        $maintenance = new maintenance();
    }
    // old code does call this function directly with a teamid
    // just pass the call to the new add-on
    $maintenance->updateTeamActivity();
}
示例#2
0
function mt_register_settings()
{
    global $maintenance;
    if (!empty($_POST['lib_options']) && check_admin_referer('maintenance_edit_post', 'maintenance_nonce')) {
        if (!isset($_POST['lib_options']['state'])) {
            $_POST['lib_options']['state'] = 0;
        } else {
            $_POST['lib_options']['state'] = 1;
        }
        if (isset($_POST['lib_options']['htmlcss'])) {
            $_POST['lib_options']['htmlcss'] = wp_kses_stripslashes($_POST['lib_options']['htmlcss']);
        }
        if (isset($_POST['lib_options'])) {
            update_option('maintenance_options', $_POST['lib_options']);
            maintenance::mt_clear_cache();
        }
    }
}
示例#3
0
 public function action_info()
 {
     maintenance::delete_inactive_visitors();
     $messages = 0;
     if (user::logged()) {
         $user = user::get();
         $messages += $user->messages->where('read', '=', '0')->count_all();
         $roles = $user->roles->find_all();
         $roleids = array();
         if ((bool) $roles->count()) {
             foreach ($roles as $role) {
                 $roleids[] = $role->id;
             }
         }
         if ((bool) count($roleids)) {
             $messages += ORM::factory('Message')->where('role_id', 'in', $roleids)->where('read', '=', '0')->where('user_id', '!=', $user->id)->count_all();
         }
     }
     ajax::success('', array('current_visitors' => $visitors = ORM::factory('Visitor')->count_all(), 'unread_messages' => $messages));
 }
示例#4
0
 /**
  * The maintenance routines ensure that all relevant user data is accumulated
  * properly.
  */
 private function do_maintenance($sqlite3)
 {
     /**
      * Search for new aliases if $autolinknicks is enabled.
      */
     if ($this->autolinknicks) {
         $this->link_nicks($sqlite3);
     }
     $maintenance = new maintenance($this->settings);
     $maintenance->do_maintenance($sqlite3);
 }
示例#5
0
 /**
  * Site routes
  */
 public static function find($route, $params, $request)
 {
     visitor::save_update_current();
     maintenance::delete_inactive_visitors();
     extract($params);
     if (!isset($controller)) {
         $controller = 'content';
     }
     $controller = strtolower($controller);
     $guid = $controller . '/' . $action;
     if ($action == 'index') {
         $guid = $controller;
     }
     $controllerfile = ucfirst($controller);
     $action = isset($params['action']) ? $params['action'] : 'index';
     //$action = ucfirst($action);
     $slug = isset($params['slug']) ? $params['slug'] : '';
     $slug2 = isset($params['slug2']) ? $params['slug2'] : '';
     $slug3 = isset($params['slug3']) ? $params['slug3'] : '';
     $slug4 = isset($params['slug4']) ? $params['slug4'] : '';
     $slug5 = isset($params['slug5']) ? $params['slug5'] : '';
     // Homepage
     if ($guid == 'content') {
         return array('controller' => 'Site', 'action' => 'index');
     }
     // Page alias
     if ($controller == 'test') {
         return array('controller' => 'Page', 'action' => 'test');
     }
     if ($controller == 'contact') {
         return array('controller' => 'Page', 'action' => 'contact');
     }
     if ($controller == 'challenge') {
         if ($action == 'wall-of-fame') {
             return array('controller' => 'Games', 'action' => 'walloffame');
         } elseif ($action == 'index') {
             return array('controller' => 'Games', 'action' => 'challenge');
         }
     }
     if ($controller == 'leaderboard') {
         return array('controller' => 'Games', 'action' => 'leaderboard');
     }
     if ($controller == 'write') {
         $todayslug = site::day_slug();
         if (user::logged()) {
             $todayslug = user::get()->today_slug();
         }
         if (empty($action) || $action == 'index') {
             $action = $todayslug;
         }
         $page = false;
         if (user::logged()) {
             $page = ORM::factory('Page')->where('user_id', '=', user::get()->id)->where('type', '=', 'page')->where('day', '=', $action)->find();
             if (!$page->loaded() && $action == $todayslug) {
                 $page = ORM::factory('Page')->where('user_id', '=', user::get()->id)->where('type', '=', 'autosave')->where('day', '=', $action)->find();
                 // It's today, but todays page doesn't exist yet. Create it
                 if (!$page->loaded()) {
                     $page->type = 'autosave';
                     $page->save();
                 }
             }
         }
         if (user::logged() && ($page && $page->loaded()) && $slug == 'stats') {
             return array('controller' => 'Write', 'action' => 'pagestats', 'page' => $page);
         }
         if (user::logged() && ($page && $page->loaded()) || !user::logged()) {
             return array('controller' => 'Write', 'action' => 'write', 'page' => $page, 'daystamp' => $action);
         } else {
             return array('controller' => 'Write', 'action' => 'daynotfound');
         }
     }
     if ($controller == 'read') {
         return array('controller' => 'Page', 'action' => 'read', 'id' => $action);
     }
     if ($controller == 'user') {
         if ($action != '') {
             if ($action == 'password') {
                 return array('controller' => 'User', 'action' => 'password', 'token' => $slug);
             }
             if (in_array($action, user::reservednames())) {
                 return array('controller' => 'User', 'action' => $action);
             }
             // We're either looking at a user's public profile or 404'd
             $user = ORM::factory('User')->where('slug', '=', $action)->find();
             if ($user->loaded()) {
                 if ((bool) $user->option('public') || user::logged('admin')) {
                     return array('controller' => 'Me', 'action' => 'profile', 'user' => $user);
                 } else {
                     return array('controller' => 'Me', 'action' => 'notpublic');
                 }
             } else {
                 return array('controller' => 'Errors', 'action' => '404', 'params' => $params);
             }
         } else {
             return array('controller' => 'User', 'action' => 'options');
         }
     }
     // Pages/Content
     $content = ORM::factory('Content');
     if (!user::logged('admin')) {
         $content = $content->where('status', '=', 'active');
     }
     $content = $content->where('guid', '=', $guid)->find();
     if ($content->loaded()) {
         // Specific content
         $class = 'Content';
         if (class_exists('Controller_' . ucfirst($content->contenttype->type))) {
             $class = ucfirst($content->contenttype->type);
         }
         $action = 'default';
         if ($content->contenttypetype_id != 0) {
             if (method_exists('Controller_' . $class, 'action_' . $content->contenttypetype->key)) {
                 $action = $content->contenttypetype->key;
             }
         }
         $content->hit();
         return array('controller' => $class, 'action' => $action, 'content' => $content);
     } else {
         // Index page for contenttype
         if ($action == 'index') {
             $contenttype = $controller;
             if (class_exists('Controller_' . ucfirst($contenttype))) {
                 $class = ucfirst($contenttype);
                 return array('controller' => $class, 'action' => 'index');
             }
         }
     }
     // "Static" controllers
     $file = 'application/classes/Controller/' . $controllerfile . '.php';
     if (file_exists($file) && method_exists('Controller_' . ucfirst($controllerfile), 'action_' . $action)) {
         $return = array();
         $return['controller'] = $controllerfile;
         $return['action'] = isset($action) ? $action : 'index';
         $return['id'] = isset($slug) ? $slug : '';
         $return['params'] = $params;
         return $return;
     }
     // No matches. 404
     return array('controller' => 'Errors', 'action' => '404', 'params' => $params);
 }