<?php

require_once('copytool.php');
$max = floor(execSQL('select max(pr_id) from tblpresentation')->fetchColumn()/1000);
$min = @is_numeric($options['n'])? $max - $options['n'] : 0;
$thumbcp = array_key_exists('t', $options);

for ($i = $max; $i >= $min; $i--) {
  $stmt = execSql('select pr_id, pr_category from tblpresentation where pr_id>='.($i*1000).' and pr_id<'.(($i+1)*1000));
  while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    list($pr_id, $pr_cat) = array_values($row);
    mycopy("uploads/resources/$pr_cat/$pr_id");
    if ($thumbcp) mycopy("uploads/thumbnails/$pr_cat/$pr_id/images/Slide0.jpg");
  }
}
