<?php require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\db\Settings; use nzedb\utility\Utility; $pdo = new Settings(); $covers = $updated = $deleted = 0; if ($argc == 1 || $argv[1] != 'true') { exit($pdo->log->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp {$argv['0']} true\n")); } $row = $pdo->queryOneRow("SELECT value FROM settings WHERE setting = 'coverspath'"); if ($row !== false) { Utility::setCoversConstant($row['value']); } else { die("Unable to set Covers' constant!\n"); } $path2covers = nZEDb_COVERS . 'xxx' . DS; $dirItr = new \RecursiveDirectoryIterator($path2covers); $itr = new \RecursiveIteratorIterator($dirItr, \RecursiveIteratorIterator::LEAVES_ONLY); foreach ($itr as $filePath) { if (is_file($filePath) && preg_match('/-cover\\.jpg/', $filePath)) { preg_match('/(\\d+)-cover\\.jpg/', basename($filePath), $match); if (isset($match[1])) { $run = $pdo->queryDirect("UPDATE xxxinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]); if ($run->rowCount() >= 1) { $covers++; } else { $run = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE id = " . $match[1]); if ($run->rowCount() == 0) { echo $pdo->log->info($filePath . " not found in db."); }
<?php require_once dirname(__FILE__) . '/../../../www/config.php'; use nzedb\db\Settings; $pdo = new Settings(); $covers = $updated = $deleted = 0; if ($argc == 1 || $argv[1] != 'true') { exit($pdo->log->error("\nThis script will check all images in covers/xxx and compare to db->xxxinfo.\nTo run:\nphp {$argv['0']} true\n")); } $row = $pdo->queryOneRow("SELECT value FROM settings WHERE setting = 'coverspath'"); if ($row !== false) { \nzedb\utility\Utility::setCoversConstant($row['value']); } else { die("Unable to set Covers' constant!\n"); } $path2covers = nZEDb_COVERS . 'xxx' . DS; $dirItr = new RecursiveDirectoryIterator($path2covers); $itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY); foreach ($itr as $filePath) { if (is_file($filePath) && preg_match('/-cover\\.jpg/', $filePath)) { preg_match('/(\\d+)-cover\\.jpg/', basename($filePath), $match); if (isset($match[1])) { $run = $pdo->queryDirect("UPDATE xxxinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]); if ($run->rowCount() >= 1) { $covers++; } else { $run = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE id = " . $match[1]); if ($run->rowCount() == 0) { echo $pdo->log->info($filePath . " not found in db."); } }
public function setCovers() { $path = $this->getSetting(['section' => 'site', 'subsection' => 'main', 'name' => 'coverspath', 'setting' => 'coverspath']); Utility::setCoversConstant($path); }