예제 #1
0
function recursiveCopy($filename, $initialfolder, $targetfolder)
{
    $badfiles = ['vendor', 'node_modules', '.DS_Store', 'sftp-config.json', '.git', '.gitignore', 'build.sh'];
    foreach (Folder::items($initialfolder . '/' . $filename, false, Folder::PATH_BASENAME) as $item) {
        if (!in_array($item, $badfiles)) {
            if (is_dir($initialfolder . '/' . $filename . '/' . $item)) {
                recursiveCopy($item, $initialfolder . '/' . $filename, $targetfolder . '/' . $filename);
            } else {
                File::copy($initialfolder . '/' . $filename . '/' . $item, $targetfolder . '/' . $filename . '/' . $item);
            }
        }
    }
}
예제 #2
0
/**
 * Recursively copy one directory to another.
 *
 * @param string $source The source path to copy.
 * @param string $destination The path to copy to.
 */
function recursiveCopy($source, $destination)
{
    mkdir($destination);
    $sourceDir = dir($source);
    while (false !== ($entry = $sourceDir->read())) {
        if ($entry != '.' && $entry != '..') {
            if (is_dir($source . '/' . $entry)) {
                recursiveCopy($source . '/' . $entry, $destination . '/' . $entry);
            } else {
                copy($source . '/' . $entry, $destination . '/' . $entry);
            }
        }
    }
}
예제 #3
0
파일: manager.php 프로젝트: gueff/mymvc
/**
 * copies recursively
 * @param type $src
 * @param type $dst
 */
function recursiveCopy($src, $dst)
{
    $dir = opendir($src);
    @mkdir($dst);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                recursiveCopy($src . '/' . $file, $dst . '/' . $file);
            } else {
                copy($src . '/' . $file, $dst . '/' . $file);
            }
        }
    }
    closedir($dir);
}
 /**
  * Recursive copy the directory
  * @param string $src
  * @param string $dst
  */
 protected function recursiveCopy($src, $dst)
 {
     if ($this->isZip($src)) {
         $this->extractZip($src, $this->getInstallDir());
         return;
     }
     $dir = opendir($src);
     if (!is_dir($dst)) {
         mkdir($dst);
     }
     while (false !== ($file = readdir($dir))) {
         if ($file != '.' && $file != '..') {
             if (is_dir($src . '/' . $file)) {
                 recursiveCopy($src . '/' . $file, $dst . '/' . $file);
             } else {
                 copy($src . '/' . $file, $dst . '/' . $file);
             }
         }
     }
     closedir($dir);
 }
예제 #5
0
function minecraftBackupWorld($service_id, $label)
{
    global $config;
    $label = stripAlphaNumeric($label);
    if (empty($label) || strlen($label) > 32) {
        $label = uid(5);
    }
    //get the identifier
    $id = stripAlphaNumeric(getServiceParam($service_id, "id"));
    if ($id === false) {
        return "Error: the identifier for this service is not set.";
    }
    //make sure didn't exceed limit on backups
    $backupLimit = getServiceParam($service_id, "blimit");
    if ($backupLimit === false) {
        $backupLimit = 12;
    }
    $num_backups = count(minecraftServerList($service_id, "backups"));
    if ($num_backups > $backupLimit) {
        return "You have exceeded the limit on the number of backups. Please contact support.";
    }
    //try to turn off saving and do a save of the current world state
    // don't worry if this fails; if it fails the server probably isn't running...
    $result = minecraftCommand($service_id, array("save-off", "save-all"));
    sleep(2);
    //wait for anything to finish
    //copy the world directory to temporary directory
    $jail = jailEnabled($service_id);
    if ($jail) {
        jailFileMove($service_id, "world", "world_tmp", "cp -r");
    } else {
        recursiveCopy($config['minecraft_path'] . $id . "/world", $config['minecraft_path'] . $id . "/world_tmp");
    }
    //zip the directory simply, delete the temporary directory
    if ($jail) {
        jailExecute($service_id, "cd " . escapeshellarg(jailPath($service_id)) . " && zip -r " . escapeshellarg(jailPath($service_id) . $label . ".uxbakzip") . " world_tmp");
        jailExecute($service_id, "rm -r " . escapeshellarg(jailPath($service_id) . "world_tmp"));
    } else {
        exec("cd " . escapeshellarg($config['minecraft_path'] . $id) . " && zip -r " . escapeshellarg($config['minecraft_path'] . $id . "/" . $label . ".uxbakzip") . " world_tmp");
        delete_directory($config['minecraft_path'] . $id . "/world_tmp");
    }
    minecraftCommand($service_id, "save-on");
}
예제 #6
0
function installGarena()
{
    global $config;
    if (isInstalled("garena")) {
        return;
    }
    chdir($config['root_path']);
    rexec("svn co http://gcb.googlecode.com/svn/trunk/bin gcb-bin");
    mkdir($config['garena_path']);
    chmod($config['garena_path'], 0755);
    mkdir($config['garena_path'] . "lib");
    chmod($config['garena_path'] . "lib", 0755);
    copy($config['root_path'] . "gcb-bin/gcb.jar", $config['garena_path'] . "gcb.jar");
    copy($config['root_path'] . "gcb-bin/gcbrooms.txt", $config['garena_path'] . "gcbrooms.txt");
    copy($config['root_path'] . "gcb-bin/gkey.pem", $config['garena_path'] . "gkey.pem");
    copy($config['root_path'] . "gcb-bin/gcb.cfg", $config['garena_path'] . "gcb.cfg");
    recursiveCopy($config['root_path'] . "gcb-bin/lib", $config['garena_path'] . "lib");
    installFinish("garena");
}
예제 #7
0
function recursiveCopy($path, $dest)
{
    if (is_dir($path)) {
        if (!file_exists($dest)) {
            mkdir($dest);
        }
        $objects = scandir($path);
        if (sizeof($objects) > 0) {
            foreach ($objects as $file) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                // go on
                if (is_dir($path . DIRECTORY_SEPARATOR . $file)) {
                    recursiveCopy($path . DIRECTORY_SEPARATOR . $file, $dest . DIRECTORY_SEPARATOR . $file);
                } else {
                    copy($path . DIRECTORY_SEPARATOR . $file, $dest . DIRECTORY_SEPARATOR . $file);
                }
            }
        }
        return true;
    } elseif (is_file($path)) {
        return copy($path, $dest);
    } else {
        return false;
    }
}
예제 #8
0
파일: fs.php 프로젝트: Rudi9719/lucid
 function recursiveCopy($smodule, $source, $tmodule, $target)
 {
     $sinfo = $smodule->getFileInfo($source);
     if ($sinfo['type'] == "text/directory") {
         $tmodule->createDirectory($target);
         foreach ($smodule->listPath($source) as $entry) {
             if ($entry['type'] == "text/directory") {
                 recursiveCopy($smodule, $source . '/' . $entry['name'], $tmodule, $target . '/' . $entry['name']);
                 continue;
             }
             modCopy($smodule, $entry['path'], $tmodule, $target . '/' . $entry['name']);
         }
     } else {
         modCopy($smodule, $source, $tmodule, $target);
     }
 }
예제 #9
0
 function recursiveCopy($path, $dest)
 {
     if (is_dir($path)) {
         @mkdir($dest);
         $objects = scandir($path);
         if (sizeof($objects) > 0) {
             foreach ($objects as $file) {
                 if ($file !== '.' && $file !== '..') {
                     if (is_dir($path . $file)) {
                         recursiveCopy($path . $file . DS, $dest . DS . $file . DS);
                     } else {
                         copy($path . $file, $dest . $file);
                     }
                 }
             }
         }
         return true;
     } elseif (is_file($path)) {
         return copy($path, $dest);
     } else {
         return false;
     }
 }
예제 #10
0
파일: Skin.php 프로젝트: c12g/stratos-php
 /**
  * Create a new skin using an existing one as a template.
  *
  * @param string $name The name of the new skin.
  * @param string $baseSkinName The name of the skin to base the new skin from.
  *
  * @throws Exception
  * @return Model_Skin
  */
 public static function addSkin($name, $baseSkinName)
 {
     $name = trim($name);
     $baseSkinName = trim($baseSkinName);
     /*
      * Make sure we're given good skin names.
      */
     if ($name == null) {
         throw new Exception('Please provide a skin name.');
     }
     if ($baseSkinName == null) {
         throw new Exception('Please provide a base skin name.');
     }
     /*
      * Make sure the base skin exists.
      */
     try {
         $baseSkin = new Model_Skin($baseSkinName);
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     /*
      * Make sure the new skin doesn't already exist.
      */
     try {
         $skin = new Model_Skin($name);
     } catch (Exception $e) {
         // no-op
     }
     if ($skin != null) {
         throw new Exception('The skin ' . $name . ' already exists.');
     }
     /*
      * Copy the base skin to the new skin.
      */
     recursiveCopy(SKIN_PATH . '/' . $baseSkinName, SKIN_PATH . '/' . $name);
     /*
      * Return the new skin.
      */
     return new Model_Skin($name);
 }
예제 #11
0
function recursiveCopy($dragID, $dropID)
{
    if ($dragID != $dropID) {
        $result = copyNode($dragID, $dropID, false);
        $sql = "select * from " . __racinebd__ . "arbre where supprimer=0 and pere=" . $dragID . " order by ordre";
        $link = query($sql);
        while ($ligne = fetch($link)) {
            recursiveCopy($ligne["arbre_id"], $result[1]);
        }
    }
}
예제 #12
0
 /**
  * Save the modified image output in the specified path as the first argument.
  *
  * @param $path
  * @param null $format
  * @param null $quality
  * @return $this
  */
 public function save($path, $format = null, $quality = null)
 {
     if (null !== $quality) {
         //set quality of the image
         $this->addConvertOption('quality', $quality);
     }
     $format = null === $format || $this->getForceAlpha() || $format == 'png' ? 'png32' : null;
     recursiveCopy($this->imagePath, $path);
     if (null !== $format) {
         //set the image format. see: http://www.imagemagick.org/script/formats.php
         $path = strtoupper($format) . ':' . $path;
     }
     $command = $this->getConvertCommand() . $path;
     $this->processCommand($command);
     $this->convertCommandOptions = [];
     $this->convertFilters = [];
     return $this;
 }
예제 #13
0
파일: File.php 프로젝트: solverat/pimcore
 /**
  * @param $oldPath
  * @param $newPath
  * @return bool
  */
 public static function rename($oldPath, $newPath)
 {
     if (stream_is_local($oldPath) && stream_is_local($newPath)) {
         // rename is only possible if both stream wrapper are the same
         // unfortunately it seems that there's no other alternative for stream_is_local() although it isn't
         // absolutely correct it solves the problem temporary
         $return = rename($oldPath, $newPath, self::getContext());
     } else {
         $return = recursiveCopy($oldPath, $newPath);
         recursiveDelete($oldPath);
     }
     return $return;
 }
예제 #14
0
파일: sampledrop.php 프로젝트: jcmwc/fleet
     log_phantom($dragID, "Déplacement du noeud");
 } else {
     if ($hitMode == "last") {
         //print "ici jc";
         $okDrop = moveLastNode($dragID);
         $msg = 'Tout est ok';
         log_phantom($dragID, "Déplacement du noeud");
     } else {
         if ($hitMode == "after") {
             $okDrop = moveBeforeNode($dropID, $dragID);
             $msg = 'Tout est ok';
             log_phantom($dragID, "Déplacement du noeud");
         } else {
             if ($copydrag == 1) {
                 if ($recursive == 1) {
                     recursiveCopy($dragID, $dropID);
                     $okDrop = true;
                     $msg = 'Tout est ok';
                 } else {
                     //copy du noeud
                     $result = copyNode($dragID, $dropID);
                     $okDrop = $result[0];
                     $msg = $result[1];
                     log_phantom($result[1], "Copie du noeud" . $dragID);
                 }
             } else {
                 if ($replace == 1) {
                     replaceNode($dropID, $dragID);
                     $okDrop = true;
                     $msg = 'Tout est ok';
                 } else {