Ejemplo n.º 1
0
 /**
  * Uninstall/Delete plugin action. Called from uninstall.php file. This function removes file and options setup by plugin.
  *
  * @since 1.0.0
  * @see
  *
  * @param int UNIX timestamp from time()
  *
  * @return none
  */
 function uninstall_snapshot()
 {
     $this->load_config();
     $this->set_backup_folder();
     if (isset($this->_settings['backupBaseFolderFull']) && strlen($this->_settings['backupBaseFolderFull'])) {
         Snapshot_Helper_Utility::recursive_rmdir($this->_settings['backupBaseFolderFull']);
     }
     delete_option($this->_settings['options_key']);
 }
Ejemplo n.º 2
0
 /**
  * @param $from_dir - Source Directory
  * @param $dest_dir Destination Directory
  * @param bool $move_files (true) will move each file individually. (false) will remove destination sub-directories and move entire source sub-directory
  */
 public static function move_tree($from_dir, $dest_dir, $move_files = false)
 {
     if (!is_dir($from_dir)) {
         echo "Source Directory does not exists [" . $from_dir . "]<br />";
         die;
     }
     if (!is_dir($dest_dir)) {
         echo "Destination Directory does not exists [" . $dest_dir . "]<br />";
         die;
     }
     if ($move_files == true) {
         $from_files = Snapshot_Helper_Utility::scandir($from_dir);
         if (is_array($from_files) && count($from_files)) {
             foreach ($from_files as $from_file_full) {
                 $from_file = str_replace(trailingslashit_snapshot($from_dir), '', $from_file_full);
                 $dest_file_full = self::trailingslashit_snapshot($dest_dir) . $from_file;
                 if (!file_exists(dirname($dest_file_full))) {
                     mkdir(dirname($dest_file_full), 0777, true);
                 }
                 if (file_exists($dest_file_full)) {
                     unlink($dest_file_full);
                 }
                 $rename_ret = rename($from_file_full, $dest_file_full);
                 if ($rename_ret === false) {
                     die;
                 }
             }
         }
     } else {
         if ($from_dh = opendir($from_dir)) {
             while (($from_file = readdir($from_dh)) !== false) {
                 if ($from_file == '.' || $from_file == '..') {
                     continue;
                 }
                 $from_file_full = self::trailingslashit_snapshot($from_dir) . $from_file;
                 $dest_file_full = self::trailingslashit_snapshot($dest_dir) . $from_file;
                 if (file_exists($dest_file_full)) {
                     if (is_dir($dest_file_full)) {
                         Snapshot_Helper_Utility::recursive_rmdir($dest_file_full);
                     } else {
                         unlink($dest_file_full);
                     }
                 }
                 rename($from_file_full, $dest_file_full);
             }
             closedir($from_dh);
         }
     }
 }