Example #1
0
 /**
  * Restore from full file backup zip
  *  
  * @access public      
  * @return boolean
  */
 public static function fullFileRestore($version)
 {
     $ext = '.zip';
     $restore_file = $version . $ext;
     if (file_exists(DIR_FS_WORK . 'updates/' . $restore_file)) {
         // remove old zip extraction  if any
         $parent_dir = explode('/', DIR_FS_CATALOG);
         if (is_dir(DIR_FS_WORK . 'updates/' . $parent_dir[1])) {
             self::rmdir_r(DIR_FS_WORK . 'updates/' . $parent_dir[1]);
         }
         // restore full file backup
         if (utility::execEnabled() === true && utility::isLinux() === true) {
             try {
                 // unzip the archive into work/updates/
                 exec(CFG_APP_UNZIP . ' ' . DIR_FS_WORK . 'updates/' . $restore_file . ' -d ' . DIR_FS_WORK . 'updates/');
                 //copy the files
                 exec('\\cp -fr ' . DIR_FS_WORK . 'updates' . DIR_FS_CATALOG . '* ' . DIR_FS_CATALOG);
                 // cleanup
                 if (is_dir(DIR_FS_WORK . 'updates/' . $parent_dir[1])) {
                     self::rmdir_r(DIR_FS_WORK . 'updates/' . $parent_dir[1]);
                 }
                 return array('rpcStatus' => 1);
             } catch (Exception $e) {
                 return array('rpcStatus' => 0);
             }
         } else {
             if (extension_loaded('zip')) {
                 try {
                     self::_extractZip(DIR_FS_WORK . 'updates/' . $restore_file, dirname(DIR_FS_CATALOG));
                     if (is_dir(DIR_FS_WORK . 'updates/' . $parent_dir[1])) {
                         self::rmdir_r(DIR_FS_WORK . 'updates/' . $parent_dir[1]);
                     }
                     return array('rpcStatus' => 1);
                 } catch (Exception $e) {
                     return array('rpcStatus' => 0);
                 }
             } else {
                 return array('rpcStatus' => -1);
             }
         }
     } else {
         return array('rpcStatus' => -2);
     }
 }