<?php

$local_root = "/srv/www/tvtl/web/uploads/previews";
require_once("ftp.php");
$ftp = new PHP_FTP("115.84.178.137", "baigiang", "baigiang");

echo "Start backup thumbnails at ".date("Y-m-d H:i:s")."\n";
if (@$argv[1] == NULL) exit();
if (@$argv[2] == NULL) $argv[2] = $argv[1];
$numFile = $numCopy = 0;
umask(0);
for ($cat = $argv[1]; $cat <= $argv[2]; $cat++) {
  $path = "$local_root/$cat/thumbnails2";
  echo date("H:i:s")." backup directory $cat\n";
  list($nf, $nc) = $ftp->dget($cat."/thumbnails2", $path, TRUE, NULL, TRUE);
  $numFile += $nf;
  $numCopy += $nc;
}
echo "\n$numFile file(s) scanned and $numCopy file(s) copied!\n";
echo "\nBackup finish at ".date("H:i:s")."\n\n";
