function copyOldVersion() { if (!is_dir(PATH)) { echo 'Creating new oldVersion dir...<br>'; mkdir(PATH); } $source = "../"; $dest = PATH; // Set a stream context timeout for file reading $context = stream_context_create(array('http' => array('timeout' => 60))); echo 'Moving current ICEcoder files...<br>'; foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) { if (strpos($source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), "oldVersion") == false) { // Don't move backups, plugins or .git away $testPath = $source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(); $testPath = str_replace("\\", "/", $testPath); if (strpos($testPath, "/backups/") == false && strpos($testPath, "/plugins/") == false && strpos($testPath, "/.git/") == false) { if ($item->isDir()) { mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0755); } else { rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } } } } $icv_url = "https://icecoder.net/latest-version.txt"; echo 'Detecting current version of ICEcoder...<br>'; $icvInfo = getData($icv_url, 'curl', 'Sorry, couldn\'t figure out latest version.'); echo 'Latest version of ICEcoder is ' . $icvInfo . '<br>'; openZipNew($icvInfo); }
function copyOldVersion() { if (!is_dir(PATH)) { echo 'Creating new oldVersion dir...<br>'; mkdir(PATH); } $source = "../"; $dest = PATH; // Set a stream context timeout for file reading $context = stream_context_create(array('http' => array('timeout' => 60))); echo 'Moving current ICEcoder files...<br>'; foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST) as $item) { if (strpos($source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), "oldVersion") == false) { // Don't move plugins away $testPath = $source . DIRECTORY_SEPARATOR . $iterator->getSubPathName(); $testPath = str_replace("\\", "/", $testPath); if (strpos($testPath, "/plugins/") == false) { if ($item->isDir()) { mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), 0705); } else { rename($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); } } } } $icv_url = "https://icecoder.net/latest-version.txt"; echo 'Detecting current version of ICEcoder...<br>'; if (ini_get('allow_url_fopen')) { $icvInfo = @file_get_contents($icv_url, false, $context); if (!$icvInfo) { $icvInfo = file_get_contents(str_replace("https:", "http:", $icv_url), false, $context); } } elseif (function_exists('curl_init')) { $ch = curl_init($icv_url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $icvInfo = curl_exec($ch); } else { die('Sorry, couldn\'t figure out latest version.'); } echo 'Latest version of ICEcoder is ' . $icvInfo . '<br>'; openZipNew($icvInfo); }