예제 #1
0
 function load()
 {
     if ($this->usePHPEngine) {
         // start session
         require_once WPRO_DIR . 'conf/customSessHandlers.inc.php';
         if (!isset($_SESSION)) {
             session_start();
         }
     }
     // get IP hash
     $this->encodeIp();
     // find session id (if one exists)
     $this->sessionId = isset($_REQUEST[$this->sessionName]) ? $_REQUEST[$this->sessionName] : '';
     if (!preg_match('/^[A-Za-z0-9]+$/D', $this->sessionId) || strlen($this->sessionId) != 32) {
         return false;
     }
     // if sid is empty create new sid
     if (empty($this->sessionId)) {
         // create new sid, maybe not would be less secure?
         return false;
     } else {
         // check that sid has not expired
         if ($this->_expired()) {
             return false;
         } elseif ($this->usePHPEngine) {
             //check for valid data in session and load...
             $key = md5($this->ipHash . $this->sessionId);
             if (isset($_SESSION[$this->prefix . '_wpxTime_' . $key])) {
                 $_SESSION[$this->prefix . '_wpxTime_' . $key] = time();
                 if (isset($_SESSION[$this->prefix . '_wpxPlugins_' . $key])) {
                     $plugins = unserialize(base64_decode($_SESSION[$this->prefix . '_wpxPlugins_' . $key]));
                     $plugins = array_merge($this->corePlugins, $plugins);
                     foreach ($plugins as $plugin) {
                         if (substr($plugin, 0, 9) == 'wproCore_') {
                             $dir = WPRO_DIR . 'core/plugins/';
                         } else {
                             $dir = WPRO_DIR . 'plugins/';
                         }
                         $this->fs->includeFileOnce($plugin, $dir, '/plugin.php');
                     }
                 } else {
                     return false;
                 }
                 if (isset($_SESSION[$this->prefix . '_wpxData_' . $key])) {
                     $this->data = unserialize(base64_decode($_SESSION[$this->prefix . '_wpxData_' . $key]));
                 } else {
                     return false;
                 }
                 if (!WPRO_REDUCED_SESSION) {
                     if (isset($_SESSION[$this->prefix . '_wpxEditor_' . $key])) {
                         $editor = unserialize(base64_decode($_SESSION[$this->prefix . '_wpxEditor_' . $key]));
                     } else {
                         return false;
                     }
                 }
             } else {
                 return false;
             }
         } else {
             // check for a valid session file and load...
             if (file_exists($this->file)) {
                 // validate file
                 $data = $this->fs->getContents($this->file);
                 $match = "/^\\<\\?php\\s+if \\(!defined\\('IN_WPRO'\\)\\) exit\\(\\)\\;\n[\$]wpxPlugins = \"[^\"]+\"\\;\\s+[\$]wpxData = \"[^\"]+\"\\;\\s+[\$]wpxEditor = \"[^\"]+\"\\;\\s+\\?>\$/Di";
                 if (!preg_match($match, $data)) {
                     return false;
                 }
             } else {
                 return false;
             }
             if (@(include $this->file)) {
                 touch($this->file);
                 if (isset($wpxPlugins)) {
                     $plugins = unserialize(base64_decode($wpxPlugins));
                     $plugins = array_merge($this->corePlugins, $plugins);
                     foreach ($plugins as $plugin) {
                         if (substr($plugin, 0, 9) == 'wproCore_') {
                             $dir = WPRO_DIR . 'core/plugins/';
                         } else {
                             $dir = WPRO_DIR . 'plugins/';
                         }
                         $this->fs->includeFileOnce($plugin, $dir, '/plugin.php');
                     }
                 } else {
                     return false;
                 }
                 if (isset($wpxData)) {
                     $this->data = unserialize(base64_decode($wpxData));
                 } else {
                     return false;
                 }
                 if (!WPRO_REDUCED_SESSION) {
                     if (isset($wpxEditor)) {
                         $editor = unserialize(base64_decode($wpxEditor));
                     } else {
                         return false;
                     }
                 }
             } else {
                 return false;
             }
         }
         if (WPRO_REDUCED_SESSION) {
             $editor = new wysiwygPro();
             $editor->_makeEditor();
         }
         $this->registerShutdown();
         return $editor;
     }
 }