Ignore:
Timestamp:
Jan 31, 2008, 9:11:25 PM (16 years ago)
Author:
george
Message:

Opraveno: Různé chyby ve skriptech.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • system/backup/do-backup.php

    r37 r39  
    11<?php
    2 include('../html/global.php');
     2include('/a/html/global.php');
    33$Database->select_db('backup');
    44
    55function mkdirrec($path,$mode)
    66{
    7   if (!is_dir($path)) {
    8     if (!@mkdir($path,$mode)) {
     7  if (!is_dir($path))
     8  {
     9    if (!@mkdir($path,$mode))
     10    {
    911      mkdirrec(dirname($path),$mode); mkdir($path,$mode);
    1012    }
     
    1315
    1416$backup = '/tmp/backup';
    15 mkdirrec($backup,0777);
     17mkdirrec($backup, 0777);
    1618
    1719// Nacti polozky z databaze
     
    2022while($Row = $DbResult->fetch_array()) array_push($Rows,$Row);
    2123
    22 while ($Row = array_shift($Rows)) {
     24while ($Row = array_shift($Rows))
     25{
    2326  if ($Row['description']) echo('Zalohuji '.$Row['description']."\n");
    2427  // Nacteni vyjimek
    2528  $DbResult = $Database->query("SELECT * FROM items WHERE parent=".$Row['id']);
    2629  $Exceptions = array();
    27   while($Except = $DbResult->fetch_array()) $Exceptions[$Except['name']] = 1;
     30  while($Except = $DbResult->fetch_array())
     31    $Exceptions[$Except['name']] = 1;
    2832  // Prochazeni slozek
    2933  $root = $Row['name'];
    30   if ($root[0]!='/') $root = '/'.$root;
    31   if (!($recursive = (substr($root,strlen($root)-2,2)!='/*'))) $root = substr($root,0,strlen($root)-2);
     34  if ($root[0] != '/') $root = '/'.$root;
     35  if (!($recursive = (substr($root, strlen($root) - 2, 2) != '/*'))) $root = substr($root, 0, strlen($root) - 2);
    3236  $paths = array('.');
    3337  mkdirrec($backup.$root, 0700);
    34   while ($folder = array_shift($paths)) {
    35     $handle=opendir($root.'/'.$folder);
    36     if ($folder!='.') {
     38  while ($folder = array_shift($paths))
     39  {
     40    $handle = opendir($root.'/'.$folder);
     41    if ($folder != '.')
     42    {
    3743      mkdirrec($backup.$root.'/'.$folder, 0700);
    38       $folder.='/';
    39     } else $folder='';
    40     while (false!==($file = readdir($handle))) {
    41       if ($file != "." && $file != ".." && !(@$Exceptions[$folder.$file])) {
    42         if (is_dir($root.'/'.$folder.$file)) {
    43           if ($recursive) { array_push($paths,$folder.$file); }
    44         } else {
     44      $folder .= '/';
     45    } else $folder = '';
     46    while (false !== ($file = readdir($handle)))
     47    {
     48      if ($file != "." && $file != ".." && !array_key_exists($folder.$file, $Exceptions))
     49      {
     50        if (is_dir($root.'/'.$folder.$file))
     51        {
     52          if ($recursive) array_push($paths, $folder.$file);
     53        } else
     54        {
    4555          $ftype=filetype($root.'/'.$folder.$file);
    46           if (($ftype=='file')||($ftype=='link')||($ftype=='')) exec('cp -u '.addslashes($root.'/'.$folder.$file).' '.addslashes($backup.$root.'/'.$folder.$file));
     56          if (($ftype == 'file') || ($ftype == 'link') || ($ftype == ''))
     57          {
     58            //echo('Kopiruju '.addslashes($root.'/'.$folder.$file).' na '.addslashes($backup.$root.'/'.$folder.$file)."\n");
     59            exec('cp -u '.addslashes($root.'/'.$folder.$file).' '.addslashes($backup.$root.'/'.$folder.$file));
     60          }
    4761        }
    4862      }
Note: See TracChangeset for help on using the changeset viewer.