function Action() { global $db; global $ip; global $cols; global $sites; $num = 0; foreach ($sites as $sitename => $siteid) { $dirs = array("/ts/{$sitename}", "/ts2/{$sitename}", "/home/{$sitename}"); foreach ($dirs as $dir) { $books = ListDir($dir); foreach ($books as $book) { $bookid = basename($book); $chapters = $db->get_chapters($siteid, $bookid); $files = ListDir($book); foreach ($files as $file) { $chapterid = basename($file, ".mp3"); if (array_key_exists($chapterid, $chapters)) { $chapter = $chapters[$chapterid]; $uri = $chapter[$cols[$ip]]; $server = ""; $path = "/"; $parts = explode(":", $uri); if (count($parts) == 1) { $server = "115.28.51.131"; $path = $uri; } else { $server = $parts[0]; $path = $parts[1]; } if (0 == strcmp($ip, $server)) { continue; } } $uri = "{$ip}:{$file}"; print_r("Add file[{$bookid}:{$chapterid}]: {$uri}\n"); if (0 == strcmp("175.195.249.184", $ip)) { $r = $db->set_chapter_uri($siteid, $bookid, $chapterid, $uri); } else { $r = $db->set_chapter_uri2($siteid, $bookid, $chapterid, $uri); } if (0 != $r) { print_r("db add file ({$uri}) error:" . $db->get_error() . "\n"); } ++$num; } } } } unset($chapters); unset($books); unset($files); return $num; }
function filenameFromVersion($version) { $filenames = ListDir(getcwd() . '/migrations', array('extentions' => array('php'))); foreach ($filenames as $thisFilename) { $parts = explode('_', $thisFilename); $thisVersion = str_replace('.', '_', $parts[0]); if ($version == $thisVersion) { return $thisFilename; } } trigger_error("version not found: " . $version); }
static function filenameFromVersion($version, $type) { if ($type != 'migration' && $type != 'seed') { trigger_error("invalid migration type: {$type}"); } $dirname = self::getDirName($type); $filenames = ListDir(app_dir . '/' . $dirname, array('extentions' => array('php'))); foreach ($filenames as $thisFilename) { $parts = explode('_', $thisFilename); $thisVersion = str_replace('.', '_', $parts[0]); if ($version == $thisVersion) { return $thisFilename; } } trigger_error("version not found: " . $version); }
function list_dir($dir_handle, $path) { global $listing; echo "<ul>"; while (false !== ($file = readdir($dir_handle))) { $dir = $path . $file; if (is_dir($dir) && $file != '.' && $file != '..') { $handle = @opendir($dir) or die("Unable to open file {$file}"); echo "<li>" . $dir; ListDir($handle, $dir); echo "</li>"; } elseif ($file != '.' && $file != '..' && $file != '.htaccess') { echo '<li><a href="' . $dir . '">' . $file . '</a></li>'; } } echo "</ul>"; closedir($dir_handle); }
function ListDir($dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (is_dir($dir . "/" . $file) && $file != "." && $file != "..") { ListDir($dir . "/" . $file); } if (!is_dir($dir . "/" . $file) && $file != "." && $file != "..") { $date = filemtime($dir . "/" . $file); $data = "{$dir}/{$file}|"; $data .= filesize($dir . "/" . $file); $data .= "|"; $data .= $date; $data .= "|"; $data .= date("Y/m/d H:i:s.", $date); $data .= "<br>"; echo $data; } } closedir($handle); } }
list($rep_unite, $herbier) = $unite; // Unite de sauvegarde if ($unites = ListDir($rep_unite)) { foreach ($unites as $file_unite) { if ($file_unite == $herbier) { $rep_herbier = $rep_unite . $file_unite; // Code herbier if ($herbiers = ListDir($rep_herbier)) { foreach ($herbiers as $file_herbier) { if (is_dir($rep_herbier . DIRECTORY_SEPARATOR . $file_herbier)) { $rep_classement = $rep_herbier . DIRECTORY_SEPARATOR . $file_herbier; $min = intval($file_herbier); $max = $min + 999; echo $this->Format("===" . $file_unite . " de " . $min . " à " . $max . '""<br>""' . "==="); // Scan if ($scans = ListDir($rep_classement)) { foreach ($scans as $file_scan) { if (is_file($rep_classement . DIRECTORY_SEPARATOR . $file_scan)) { $rep_scan = $rep_classement . DIRECTORY_SEPARATOR; $file_scan_tif = ereg_replace('\\.bz2', '', $file_scan); $file_scan_rep = ereg_replace('\\.tif\\.bz2', '', $file_scan); echo $this->Format('[[' . URL_SCAN . DIRECTORY_SEPARATOR . $file_scan_rep . ' ' . $file_scan_rep . ']]'); if (!file_exists($rep_unite . 'CACHE' . DIRECTORY_SEPARATOR . $file_unite . DIRECTORY_SEPARATOR . $file_herbier . DIRECTORY_SEPARATOR . $file_scan_rep . DIRECTORY_SEPARATOR . 'ImageProperties.xml')) { echo $this->Format('"" ""Zoom absent !'); } echo $this->Format('""<br>""'); } } } } }
include 'inc/common.php'; // check validity of request if ($_REQUEST['s'] === $SESSIONHASH) { require_once 'inc/zip.class.php'; $zipfile = new zipfile(); $timestamp = date('Y-m-d-Hi'); ini_set("memory_limit", "600M"); // paths and files to backup $paths = array($relative . 'data', $relative . 'theme'); //no trailing slash $files = array($relative . '.htaccess', $relative . 'index.php', $relative . 'gsconfig.php'); $zipfile->add_dir('getsimple'); // cycle thru each path and file and add to zip file foreach ($paths as $path) { $dir_handle = @opendir($path) or die("Unable to open {$path}"); ListDir($dir_handle, $path); } foreach ($files as $fl) { $filedata = file_get_contents($fl); $zipfile->add_file($filedata, substr_replace($fl, 'getsimple', 0, 2)); } // $listing is the list of all files and folders that were added to the backup //echo $listing; // create the final zip file $file = $relative . 'backups/zip/' . $timestamp . '_archive.zip'; $fh = fopen($file, 'w') or die('Could not open file for writing!'); fwrite($fh, $zipfile->file()) or die('Could not write to file'); fclose($fh); // redirect back to archive page with a success header('Location: archive.php?done'); } else {
function ListDir($dir_handle, $path) { global $zipfile; while (false !== ($file = readdir($dir_handle))) { $dir = $path . '/' . $file; $zippath = substr_replace($dir, 'getsimple', 0, 2); if (is_dir($dir) && $file != '.' && $file != '..') { $handle = @opendir($dir) or die("Unable to open file {$file}"); $zipfile->add_dir($zippath); ListDir($handle, $dir); } elseif ($file != '.' && $file != '..') { $filedata = file_get_contents($dir); $zipfile->add_file($filedata, $zippath); } } closedir($dir_handle); }