コード例 #1
0
ファイル: upgrade.php プロジェクト: kiirti/Ushahidi_MHI
 /**
  * 
  * Downloads the latest ushahidi file.
  * Extracts the compressed folder.
  * Delete the folders that needs to be preserved.
  * Delete the downloaded ushahidi file.
  * Delete the extracted ushahidi file.
  * 
  */
 private function _do_upgrade()
 {
     $upgrade = new Upgrade();
     $url = "http://download.ushahidi.com/ushahidi.zip";
     $working_dir = "media/uploads/";
     $zip_file = "media/uploads/ushahidi.zip";
     //download the latest ushahidi
     $latest_ushahidi = $upgrade->download_ushahidi($url);
     //download went successful
     if ($upgrade->success) {
         $upgrade->write_to_file($latest_ushahidi, $zip_file);
     }
     //extract compressed file
     if ($upgrade->success) {
         $upgrade->unzip_ushahidi($zip_file, $working_dir);
     }
     if ($upgrade->success) {
         //remove delete database.php and config.php files. we don't want to overwrite them.
         unlink($working_dir . "ushahidi/application/config/database.php");
         unlink($working_dir . "ushahidi/application/config/config.php");
         $upgrade->remove_recursively($working_dir . "ushahidi/application/cache");
         $upgrade->remove_recursively($working_dir . "ushahidi/application/logs");
         $upgrade->remove_recursively($working_dir . "ushahidi/media/uploads");
     }
     if ($upgrade->success) {
         $upgrade->log[] = sprintf("Copying files...");
         $upgrade->copy_recursively($working_dir . "ushahidi", ".");
         $upgrade->log[] = sprintf("Successfully copied files");
     }
     if ($upgrade->success) {
         $upgrade->log[] = sprintf("Upgrading tables...");
         if ($this->_upgrade_tables()) {
             $upgrade->log[] = sprintf("Tables upgrade went successful");
         } else {
             $upgrade->errors[] = sprintf("Tables upgrade failed");
         }
     }
     if ($upgrade->success) {
         $upgrade->remove_recursively($working_dir . "ushahidi");
         unlink($zip_file);
         $upgrade->log[] = sprintf("Upgrade went successful.");
     }
     return $upgrade;
 }