Example #1
0
 public function dispatch($path)
 {
     $path = rtrim($path, "/") . "/";
     $route = $this->getRouter()->match($path);
     foreach ($route['param'] as $k => $v) {
         Daq_Request::getInstance()->addParam("GET", $k, $v);
     }
     $index = $route['module'] . "/" . $route['action'];
     $ctrl = rtrim($this->_controller, "*") . ucfirst($route['module']);
     $action = $route['action'] . "Action";
     if (!class_exists($ctrl)) {
         throw new Exception("Module [{$ctrl}] does not exist");
     }
     $controller = new $ctrl();
     if (Wpjb_Utility_Seal::check()) {
         Wpjb_Upgrade_Manager::upgrade();
     }
     $info = wp_get_current_user();
     $isAdmin = true;
     if (!isset($info->wp_capabilities) || !$info->wp_capabilities['administrator']) {
         $isAdmin = false;
     }
     $this->_view->slot("is_admin", $isAdmin);
     if (!method_exists($controller, $action)) {
         throw new Exception("Method [{$action}] does not exist for controller [{$ctrl}]");
     }
     $controller->setView($this->_view);
     $controller->init();
     $controller->{$action}();
     $controller->view->render($index . ".php");
 }
Example #2
0
 private static function _exists()
 {
     if (self::$_seal) {
         return true;
     }
     $file = Wpjb_List_Path::getPath("seal_file");
     if (file_exists($file)) {
         $contents = file_get_contents($file);
         self::$_seal = unserialize(base64_decode($contents));
     }
     if (is_array(self::$_seal) && count(self::$_seal) >= 4) {
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Checks latest version data
  *
  * @return stdClass {version, date, }
  */
 public static function check($force = false)
 {
     $upgrade = Wpjb_Project::getInstance()->conf("upgrade");
     if (time() - $upgrade->lastcheck < self::CHECK && !$force) {
         return $upgrade;
     }
     $id = Wpjb_Utility_Seal::id();
     $ck = Wpjb_Utility_Seal::checksum();
     $version = Wpjb_Project::getInstance()->conf("version");
     $url = self::URL . "release/id/" . $id . "/checksum/" . $ck;
     if (!function_exists("curl_init")) {
         return new stdClass();
     }
     $json = json_decode(self::_download($url));
     if (isset($json->error)) {
         // fail silently
         return new stdClass();
     }
     if (!is_array($json)) {
         // fail silently
         return new stdClass();
     }
     $available = array();
     $key = null;
     foreach ($json as $k => $ver) {
         if (version_compare($ver->version, $version) == 1) {
             $version = $ver->version;
             $key = $k;
         }
     }
     if ($key !== null) {
         $available = $json[$key];
     }
     $upgrade = new stdClass();
     $upgrade->lastcheck = time();
     $upgrade->available = $available;
     $instance = Wpjb_Project::getInstance();
     $instance->setConfigParam("upgrade", $upgrade);
     $instance->saveConfig();
     return $upgrade;
 }