function copy_directory($directory, $destination)
 {
     $destination = $destination . basename($directory);
     # The directory will be created
     if (!file_exists($destination)) {
         if (!mkdir($destination)) {
             return false;
         }
     }
     $directory_list = @scandir($directory);
     # Directory scanning
     if (!$directory_list) {
         return false;
     }
     foreach ($directory_list as $item_name) {
         $item = $directory . DIRECTORY_SEPARATOR . $item_name;
         if ($item_name == '.' || $item_name == '..') {
             continue;
         }
         if (filetype($item) == 'dir') {
             copy_directory($item, $destination . DIRECTORY_SEPARATOR);
         } else {
             var_dump($item);
             var_dump($destination . DIRECTORY_SEPARATOR . $item_name);
             if (!copy($item, $destination . DIRECTORY_SEPARATOR . $item_name)) {
                 return false;
             }
         }
     }
     return true;
 }
Exemplo n.º 2
0
function copy_directory($source, $destination)
{
    global $log;
    if (is_dir($source)) {
        mkdir($destination);
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            if (is_dir($PathDir)) {
                copy_directory($PathDir, $destination . '/' . $readdirectory);
                continue;
            }
            try {
                copy($PathDir, $destination . '/' . $readdirectory);
            } catch (\ErrorException $e) {
                $log->error($e->getMessage());
            }
        }
        $directory->close();
    } else {
        try {
            copy($source, $destination);
        } catch (\ErrorException $e) {
            $log->error($e->getMessage());
        }
    }
}
function unzipFile($filename, $filenameRail, $feedDirectory)
{
    $results = unzip($filename, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
    $results2 = unzip($filenameRail, $dest_dir = false, $create_zip_name_dir = true, $overwrite = true);
    $filenameRailFolder = $feedDirectory . "/gtfs/" . basename($filenameRail, ".zip");
    $test = copy_directory($filenameRailFolder, $feedDirectory . "/" . basename($filenameRail, ".zip"));
}
Exemplo n.º 4
0
 public function generateBlog()
 {
     set_time_limit(0);
     global $app;
     $this->parser = new \Parsedown();
     $data = $this->getData();
     $layout = $data['settings']['layout'] ?: 'default';
     $layoutDir = $app->view->getData('layoutsDir') . $layout . '/';
     // first copy all contents of template to public folder
     copy_directory($layoutDir, $this->publicDir);
     // now create actual html pages
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($layoutDir), 'partials_loader' => new \Mustache_Loader_FilesystemLoader($layoutDir . '/partials')));
     $mustacheFiles = glob($layoutDir . '/*.mustache');
     $excludedFiles = array('category', 'post', 'page', 'archive', 'tag');
     foreach ($mustacheFiles as $mustacheFile) {
         $fileName = basename($mustacheFile);
         $fileName = str_replace('.mustache', '', $fileName);
         // we will generate these later
         if (true === in_array($fileName, $excludedFiles)) {
             continue;
         }
         $template = $mustache->loadTemplate($fileName);
         $html = $template->render($data);
         file_put_contents($this->publicDir . $fileName . '.html', $html);
     }
     // delete mustache particals folders from public folder
     rrmdir($this->publicDir . 'partials/');
     // delete *.mustache from public dir
     $mustacheFiles = glob($this->publicDir . '/*.mustache');
     foreach ($mustacheFiles as $mustacheFile) {
         @unlink($mustacheFile);
     }
     // generate post files
     $this->generatePostPageFiles($mustache, $data, 'post');
     // generate page files
     $this->generatePostPageFiles($mustache, $data, 'page');
     // generate category and tag files
     $this->generateCategoryTagFiles($mustache, $data, 'category');
     $this->generateCategoryTagFiles($mustache, $data, 'tag');
     // generate archive files
     $this->generateArchiveFiles($mustache, $data);
     // generate RSS file
     $this->generateRSS($data);
     // generate sitemap.xml
     $this->generateSitemap($data);
     // copy blog data file
     copy('data/blog.json', 'public/data/blog.json');
     $message = '';
     $message .= 'Blog has been generated in <strong>public</strong> folder :)<br><br>';
     $message .= '<a id="viewGenLog" class="btn btn-primary">View Log</a><br><br>';
     $message .= '<div id="genlog">' . $this->getGenerateLog($this->generateLog) . '</div>';
     echo $message;
 }
Exemplo n.º 5
0
/**
 * This procedural script copies all non-blacklisted files from the development folder to the production folder, in preparation for FTPing to the server.
 * 
 * Instructions:
 * To run, simply go to the correct address in your web browser while your local web server is running (e.g. http://localhost:8888/development/deploy.php)
 * To add new files to the blacklist, simply add a new string element to the blacklist array with the full name of the desired folder or file.
 * 
 * Notes:
 * Any new files that are added to development will be copied to production by default. The blacklist array only needs to be modified if tester files or other development-specific files are added to the development folder.
 */
function copy_directory($source, $destination)
{
    mkdir($destination);
    $directory = dir($source);
    while (FALSE !== ($readdirectory = $directory->read())) {
        if ($readdirectory == '.' || $readdirectory == '..') {
            continue;
        }
        $pathDir = $source . '/' . $readdirectory;
        if (is_dir($pathDir)) {
            copy_directory($pathDir, $destination . '/' . $readdirectory);
            continue;
        }
        if (copy($pathDir, $destination . '/' . $readdirectory)) {
            echo "Successfully copied {$pathDir}.\n";
        }
    }
    $directory->close();
}
Exemplo n.º 6
0
function copy_directory($source, $destination)
{
    if (is_dir($source)) {
        @mkdir($destination);
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            if (is_dir($PathDir)) {
                copy_directory($PathDir, $destination . '/' . $readdirectory);
                continue;
            }
            copy($PathDir, $destination . '/' . $readdirectory);
        }
        $directory->close();
    } else {
        copy($source, $destination);
    }
}
Exemplo n.º 7
0
             }
         } else {
             if ($addons['type'] == 'themes') {
                 $folder = "../plugins/{$addons['folder']}";
                 $copy = @copy_directory("../tmp/{$name_file}", "../themes/{$addons['folder']}");
             } else {
                 if ($addons['type'] == 'admin_themes') {
                     $flback = siteConfig('backend_folder');
                     $folder = "../{$flback}/themes/{$addons['folder']}";
                     $copy = @copy_directory("../tmp/{$name_file}", $folder);
                 } else {
                     if ($addons['type'] == 'updater') {
                         $copy = @copy_directory("../tmp/{$name_file}", "../");
                         $dapur = siteConfig('backend_folder');
                         if (siteConfig('backend_folder') != 'dapur') {
                             @copy_directory("../dapur", "../{$dapur}", true);
                         }
                     } else {
                         $fail = true;
                         alert('error', File_uploaded_not_valid);
                     }
                 }
             }
         }
     }
 }
 if (!isset($fail)) {
     if (isset($folder) and file_exists("{$folder}/installer.php")) {
         @unlink("{$folder}/installer.php");
     }
     if ($copy) {
Exemplo n.º 8
0
function copy_directory($source, $destination, $cut = null)
{
    $copy = false;
    if (is_dir($source)) {
        @mkdir($destination);
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            if (is_dir($PathDir)) {
                copy_directory($PathDir, $destination . '/' . $readdirectory);
                continue;
            }
            $copy = copy($PathDir, $destination . '/' . $readdirectory);
        }
        $directory->close();
    } else {
        $copy = copy($source, $destination);
    }
    if (isset($cut)) {
        delete_directory($source);
    }
    if ($copy) {
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 9
0
function copy_directory($source, $destination, $holo, $name, $check_holo = true)
{
    $log = Logger::getLogger("copy");
    $log->debug("copy directory : " . $source . " in " . $destination);
    if (is_dir($source)) {
        $directory = dir($source);
        while (FALSE !== ($readdirectory = $directory->read())) {
            if ($readdirectory == '.' || $readdirectory == '..' || $readdirectory == '.DS_Store') {
                continue;
            }
            $PathDir = $source . '/' . $readdirectory;
            $log->debug("File : " . $readdirectory . " Path : " . $PathDir . " holo=" . $check_holo);
            if (is_dir($PathDir)) {
                copy_directory($PathDir, $destination . '/' . $readdirectory, $holo, $name, $check_holo);
                continue;
            }
            if ($check_holo == false) {
                $log->debug("holo false => copy " . $PathDir . " in " . $destination . '/' . $readdirectory);
                copy($PathDir, $destination . '/' . $readdirectory);
                if (strstr($readdirectory, ".xml")) {
                    filter_file($destination . '/' . $readdirectory, $name);
                }
            } else {
                if (strpos($readdirectory, $holo)) {
                    $log->debug("holo true => copy " . $PathDir . " in " . $destination . '/' . $readdirectory);
                    copy($PathDir, $destination . '/' . $readdirectory);
                    if (strstr($readdirectory, ".xml")) {
                        filter_file($destination . '/' . $readdirectory, $name);
                    }
                }
            }
        }
        $directory->close();
    } else {
        copy($source, $destination);
    }
}
Exemplo n.º 10
0
    }
} else {
    echo 0;
}
if (isset($_POST['patching']) and $_POST['patching'] != false and $site_version != $latest_version and $xml) {
    $plink = $p['link'];
    $root = "../../..";
    $newfile = "{$root}/tmp/patch_{$p['number']}.zip";
    if (!file_exists("{$root}/tmp")) {
        mkdir("{$root}/tmp");
    }
    if (copy($plink, $newfile)) {
        if (extractZip($newfile, "{$root}/tmp")) {
            $dapur = siteConfig('backend_folder');
            if (siteConfig('backend_folder') != 'dapur') {
                copy_directory("{$root}/dapur", "{$root}/{$dapur}", true);
            }
            $db = new FQuery();
            $db->connect();
            $db->update(FDBPrefix . 'setting', array('value' => "{$p['number']}"), "name='version'");
            $sup = $p['number'];
            @unlink("{$root}/installer.php");
            ?>
				<script>		
					$(document).ready(function() {										
						$(".update-info").LoadingDot({
							"speed": 500,
							"maxDots": 4,
							"word": " <?php 
            echo Installing_patch . $p['number'];
            ?>
Exemplo n.º 11
0
                         
                         This will remove the {FUNCTION} text from
                         the functions file if no extras are needed
     */
     $functions = NULL;
     if ($has_menu) {
         $functions .= file_get_contents(BASE . '/build_parts/wp_nav_menu/_functions.php');
     }
     if ($has_widget) {
         $functions .= file_get_contents(BASE . '/build_parts/register_sidebar/_functions.php');
     }
     if ($has_custom_post_type) {
         // add the include to the functions file
         $functions .= file_get_contents(BASE . '/build_parts/custom_post_type/_functions.php');
         // Copy over the custom_post_type.php file and add edits
         copy_directory(BASE . '/build_parts/custom_post_type/files/', $new_theme . '/inc/php/');
         $custom_post_type_contents = file_get_contents($new_theme . '/inc/php/custom_post_type.php');
         $custom_post_type_name = $_POST['custom_post_type_name'];
         $custom_post_type_info = array('{SINGULAR}' => ucfirst($custom_post_type_name), '{PLURAL}' => Inflect::pluralize(ucfirst($custom_post_type_name)), '{PLURAL_LOWERCASE}' => strtolower(Inflect::pluralize($custom_post_type_name)));
         $custom_post_type_file = fopen($new_theme . '/inc/php/custom_post_type.php', "w+");
         foreach ($custom_post_type_info as $replace => $with) {
             $custom_post_type_contents = preg_replace("/{$replace}/", $with, $custom_post_type_contents);
         }
         fwrite($custom_post_type_file, $custom_post_type_contents);
         fclose($custom_post_type_file);
     }
     $contents = preg_replace("/{FUNCTIONS}/", $functions, $contents);
     break;
 case 'sidebar.php':
     $widget_area = '';
     if ($has_widget) {
Exemplo n.º 12
0
/**
 * @author Oliver Tupman <*****@*****.**>
 * Date: 08/06/2012
 * Time: 16:34
 */
echo "[deploy] Starting xBoilerplate deployment\n\n";
function copy_directory($source, $destination)
{
    $result = exec('cp -R ' . $source . ' ' . $destination);
    return $result;
}
$autogeneratedDirs = array('tmp', 'test', 'config');
if (!file_exists('vendor')) {
    die("[deploy] FAILED: Command must be run at the same level as composer.json\n");
}
if (file_exists('httpdocs')) {
    die("[deploy] FAILED: httpdocs directory already exists, remove if you wish to deploy a new xBoilerplate skeleton\n");
}
$baseDir = __DIR__ . DIRECTORY_SEPARATOR;
foreach ($autogeneratedDirs as $directory) {
    if (!file_exists($directory)) {
        mkdir($directory);
    }
}
copy_directory($baseDir . 'httpdocs', '.');
copy($baseDir . 'config' . DIRECTORY_SEPARATOR . 'config.php', 'config' . DIRECTORY_SEPARATOR . 'config.php');
copy($baseDir . "Vagrantfile", "Vagrantfile");
echo "[deploy] SUCCESS: your xBoilerplate skeleton was created\n";
echo "         You can start it by using the command: vagrant up\n";
echo "         And then accessing it via http://10.10.10.10\n";
Exemplo n.º 13
0
/**
 * Copy selected directory
 *
 * @param string $source
 * @param string $destination
 */
function copy_directory($source, $destination)
{
    $file_array = array();
    if (is_file($source)) {
        $perm = fileperms($source);
        copy($source, $destination);
        chmod($destination, 0744);
    }
    if (@is_dir($source)) {
        @mkdir($destination, 0777);
        $dir_handle = opendir($source);
        while ($files = readdir($dir_handle)) {
            if ($files != "." && $files != "..") {
                $file_array[] = $files;
            }
        }
        closedir($dir_handle);
    }
    for ($i = 0; $i < count($file_array); $i++) {
        $file = $file_array[$i];
        if ($destination != "{$source}/{$file}") {
            copy_directory("{$source}/{$file}", "{$destination}/{$file}");
        }
    }
}
Exemplo n.º 14
0
     }
 } else {
     if (file_exists($plg)) {
         extractZip($path_file, '../plugins');
         include $plg;
         alert('info', AddOns_installed);
         if (isset($plugin_info)) {
             echo "<div class='install_info'>{$plugin_info}</div>";
         }
     } else {
         if (file_exists($app)) {
             extractZip($path_file, "../{$folback}/apps");
             include $app;
             $insser_apps_data = insert_new_apps($apps_name, $apps_folder, $apps_author, $apps_type);
             if ($apps_type == 1) {
                 copy_directory($apf, "../apps/{$folder}");
                 delete_directory("../{$folback}/apps/{$folder}/{$folder}");
             }
             alert('info', AddOns_installed);
             if (isset($apps_info)) {
                 echo "<div class='install_info'>{$apps_info}</div>";
             }
         } else {
             if (file_exists($thm)) {
                 extractZip($path_file, '../themes');
                 include $thm;
                 alert('info', AddOns_installed);
                 echo "<div class='install_info'>{$theme_info}</div>";
             } else {
                 if (file_exists($atm)) {
                     extractZip($path_file, "../{$folback}/themes");
Exemplo n.º 15
0
/**
 * Copy directories
 *
 * @param string $dir
 * @param array  &$errorLog
 * @param bool   $createDest
 *
 * @return bool|void
 */
function copy_directories($dir, &$errorLog, $createDest = true)
{
    // Ensure the destination directory exists
    $exists = file_exists(MAUTIC_ROOT . $dir);
    if ($createDest && !$exists) {
        mkdir(MAUTIC_ROOT . $dir, 0755, true);
    } elseif (!$exists) {
        $errorLog[] = sprintf('%s does not exist.', MAUTIC_ROOT . $dir);
        return false;
    }
    // Copy root level files first
    copy_files($dir, $errorLog);
    $iterator = new DirectoryIterator(MAUTIC_UPGRADE_ROOT . $dir);
    /** @var DirectoryIterator $directory */
    foreach ($iterator as $directory) {
        // Sanity checks
        if (!$directory->isDot() && $directory->isDir()) {
            $src = $directory->getPath() . '/' . $directory->getFilename();
            $dest = str_replace(MAUTIC_UPGRADE_ROOT, MAUTIC_ROOT, $src);
            $result = copy_directory($src, $dest);
            if ($result !== true) {
                if (is_array($result)) {
                    $errorLog += $result;
                } else {
                    $errorLog[] = $result;
                }
            }
            $deleteDir = recursive_remove_directory($src);
            if (!$deleteDir) {
                $errorLog[] = sprintf('Failed to remove the upgrade directory %s folder', str_replace(MAUTIC_UPGRADE_ROOT, '', $src));
            }
        }
    }
}
Exemplo n.º 16
0
    $folderThumb .= $registry['query_ID'] . '_' . $_POST['full_name'] . '/';
    $folder_temp .= $_POST['full_name'] . '/';
    chmod($folder, 0777);
    chmod($folderThumb, 0777);
    // Returns array of files
    $files1 = scandir($folder);
    // Count number of files and store them to variable..
    $num_files = count($files1) - 1;
    if ($num_files > 5) {
        echo '{"status":"error"}';
        die;
    }
    function copy_directory($src, $dst)
    {
        $dir = opendir($src);
        @mkdir($dst);
        while (false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($src . '/' . $file)) {
                    recurse_copy($src . '/' . $file, $dst . '/' . $file);
                } else {
                    copy($src . '/' . $file, $dst . '/' . $file);
                }
            }
        }
        closedir($dir);
    }
    copy_directory($folder_temp, $folder);
    copy_directory($folder_temp, $folderThumb);
    die;
}
Exemplo n.º 17
0
Arquivo: debug.php Projeto: bycEEE/env
    }
}
exec("mkdir -p ~/Downloads/spot_mini_debug");
$output = "DEBUG: ";
//
// check for library update in progress
if (file_exists($w->data() . "/update_library_in_progress")) {
    $w->result('', '', "Library update in progress", "", 'fileicon:' . $w->data() . '/update_library_in_progress', 'no', null, '');
    $output = $output . "Library update in progress: " . "the file" . $w->data() . "/update_library_in_progress is present\n";
}
if (!file_exists($w->data() . "/settings.json")) {
    $output = $output . "The file " . $w->data() . "/settings.json is not present\n";
} else {
    copy($w->data() . "/settings.json", $w->home() . "/Downloads/spot_mini_debug/settings.json");
}
copy_directory($w->cache(), $w->home() . "/Downloads/spot_mini_debug/cache");
if (!file_exists($w->data() . "/fetch_artworks.db")) {
    $output = $output . "The file " . $w->data() . "/fetch_artworks.db is not present\n";
} else {
    copy($w->data() . "/fetch_artworks.db", $w->home() . "/Downloads/spot_mini_debug/fetch_artworks.db");
}
if (!file_exists($w->data() . "/library.db")) {
    $output = $output . "The file " . $w->data() . "/library.db is not present\n";
} else {
    copy($w->data() . "/library.db", $w->home() . "/Downloads/spot_mini_debug/library.db");
}
if (!file_exists($w->data() . "/library_new.db")) {
    $output = $output . "The file " . $w->data() . "/library_new.db is not present\n";
} else {
    copy($w->data() . "/library_new.db", $w->home() . "/Downloads/spot_mini_debug/library_new.db");
}