示例#1
0
 /**
  * Validates any data provided to the stage.
  *
  * @access  public
  * @return  bool|Jaws_Error  Returns either true on success, or a Jaws_Error
  *                          containing the reason for failure.
  */
 function Validate()
 {
     if ($_SESSION['install']['predefined']) {
         return true;
     }
     $request = Jaws_Request::getInstance();
     $postReq = $request->fetch(array('secure', 'customize'), 'post');
     $_SESSION['secure'] = !empty($postReq['secure']);
     $_SESSION['customize'] = !empty($postReq['customize']);
     // try to entering to secure transformation mode
     if ($_SESSION['secure'] && (!isset($_SESSION['pub_key']) || empty($_SESSION['pub_key']))) {
         require_once JAWS_PATH . 'include/Jaws/Crypt.php';
         $pkey = Jaws_Crypt::Generate_RSA_KeyPair(512);
         if (!Jaws_Error::isError($pkey)) {
             $_SESSION['pub_key'] = $pkey['pub_key'];
             $_SESSION['pvt_key'] = $pkey['pvt_key'];
         } else {
             return new Jaws_Error(_t('INSTALL_AUTH_ERROR_RSA_KEY_GENERATION'), 0, JAWS_ERROR_WARNING);
         }
     }
     $key_file = INSTALL_PATH . 'key.txt';
     if (file_exists($key_file)) {
         $key = trim(file_get_contents($key_file));
         if ($key === $_SESSION['install']['Authentication']['key']) {
             _log(JAWS_LOG_DEBUG, "Input log and session key match");
             return true;
         }
         _log(JAWS_LOG_DEBUG, "The key found doesn't match the one below, please check that you entered the key correctly");
         return new Jaws_Error(_t('INSTALL_AUTH_ERROR_KEY_MATCH', 'key.txt'), 0, JAWS_ERROR_WARNING);
     }
     _log(JAWS_LOG_DEBUG, "Your key file was not found, please make sure you created it, and the web server is able to read it.");
     return new Jaws_Error(_t('INSTALL_AUTH_ERROR_KEY_FILE', 'key.txt'), 0, JAWS_ERROR_WARNING);
 }