<?php

$root = "/data/violet/backup/resources";
$dbh = new PDO('mysql:host=210.211.97.53;dbname=tvtl', 'violet', '123456');
for ($cat = 0; $cat < 650; $cat++) {
  $path = "$root/$cat";
  if (!file_exists($path)) continue;
  foreach (scandir($path) as $dir) {
    if ($dir=='.' || $dir=='..' || !is_dir("$path/$dir") || !is_numeric($dir)) continue;
    $sql = "select count(*) from tblpresentation where pr_id=$dir";
    if ($dbh->query($sql)->fetchColumn() > 0) {
      echo("$path/$dir\n");
    }
  }
}
