Example #1
0
 private static function _loadOldConfig(&$config, $old_config_file)
 {
     set_time_limit(0);
     $old_config = new USVN_Config_Ini($old_config_file['tmp_name'], USVN_CONFIG_SECTION, array('create' => false));
     // Import subversion configuration
     foreach ($old_config->subversion as $key => $value) {
         if ($config->subversion->{$key} != $value && $key != 'url') {
             if (!file_exists($value) || USVN_DirectoryUtils::copyr($value, $config->subversion->{$key}) === false) {
                 throw new USVN_Exception(T_("Can't copy the old configuration.\n"));
             }
         }
     }
     // Import database configuration
     if ($old_config->database->adapterName == 'PDO_SQLITE') {
         if (strpos($old_config->database->options->dbname, $old_config->subversion->path) === 0) {
             $old_config->database->options->dbname = $config->subversion->path . substr($old_config->database->options->dbname, strlen($old_config->subversion->path));
         }
     }
     $config->database = $old_config->database;
 }
Example #2
0
 /**
  * Copy a file, or recursively copy a folder and its contents
  *
  * @author      Aidan Lister <*****@*****.**>
  * @version     1.0.1
  * @link        http://aidanlister.com/repos/v/function.copyr.php
  * @param       string   $source    Source path
  * @param       string   $dest      Destination path
  * @return      bool     Returns TRUE on success, FALSE on failure
  */
 public static function copyr($source, $dest)
 {
     // Check for symlinks
     if (is_link($source)) {
         return symlink(readlink($source), $dest);
     }
     // Simple copy for a file
     if (is_file($source)) {
         return copy($source, $dest);
     }
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         USVN_DirectoryUtils::copyr("{$source}/{$entry}", "{$dest}/{$entry}");
     }
     // Clean up
     $dir->close();
     return true;
 }