/** * @todo optimize db query: use a prepared statement */ public function checkFiles($doDelete = false, $returnData = false) { $violations = array(); $dir = $this->clusterizeDir(eZSys::storageDirectory() . '/original'); if (!is_dir($dir)) { return $violations; } $dir = realpath($dir); foreach (glob($dir . '/*', GLOB_ONLYDIR) as $storageDir) { if (in_array(basename($storageDir), array('.', '..'))) { continue; } foreach (glob($storageDir . '/*') as $storageFile) { if (!is_file($storageFile)) { continue; } $fileName = basename($storageFile); $dirName = basename($storageDir); $sql1 = "SELECT COUNT(*) AS found FROM ezbinaryfile " . "WHERE filename = '" . $this->db->escapeString($fileName) . "' AND mime_type LIKE '" . $this->db->escapeString($dirName) . "/%'"; $sql2 = "SELECT COUNT(*) AS found FROM ezmedia " . "WHERE filename = '" . $this->db->escapeString($fileName) . "' AND mime_type LIKE '" . $this->db->escapeString($dirName) . "/%'"; $results1 = $this->db->arrayQuery($sql1); $results2 = $this->db->arrayQuery($sql2); if ($results1[0]['found'] == 0 && $results2[0]['found'] == 0) { if (isset($violations['violatingFileCount'])) { $violations['violatingFileCount']++; } else { $violations['violatingFileCount'] = 1; } if ($returnData) { $violations['violatingFiles'][] = $storageFile; } if ($doDelete) { unlink($storageFile); } } /*else { echo "OK: $storageFile\n"; }*/ } } return $violations; }
/** * Sets application localized url to NULL and sets its visibility as private * @param int $appId Id of application to be hidden * @param string $clusterIdentifier Identifier of cluster * @param eZDBInterface $db db to be used * @param eZCLI $cli command line to be used * @param boolean $dryRun Decides whether queries should be outputed to CLI or be used to update the DB */ function hideFromApplicationLocalized( $appId, $clusterIdentifier, eZDBInterface $db, eZCLI $cli, $dryRun = false ) { global $appId, $clusterIdentifier, $db, $eZDB, $cli, $dryRun; $update = sprintf( "UPDATE mm_application_localized SET url = NULL, restriction_level = 'private' WHERE application_id='%s' AND cluster_identifier='%s'", $db->escapeString($appId), $db->escapeString($clusterIdentifier) ); if ( !$dryRun ) { $db->query( $update ); } else { $cli->output( $update ); } }