/** * @param string $path * @return bool|string */ private static function fileExists($path) { $fileUtils = eZClusterFileHandler::instance($path); if ($fileUtils->requiresClusterizing()) { if (!self::$dfsBackend) { self::$dfsBackend = new eZDFSFileHandlerDFSBackend(); } $mountPoint = self::$dfsBackend->getMountPoint(); $path = eZDir::path(array($mountPoint, $path)); if (file_exists($path)) { return $path; } } else { if (file_exists($path)) { return $path; } } return false; }
$limit[0] += $limit[1]; } else { $loopRun = false; } unset($files); } $cli->output('Done'); } if ($checkDFS) { if ($delete) { $cli->output('Deleting the files on the DFS share that are not registered in the database...'); } else { $cli->output('Checking files on the DFS share...'); } $dfsBackend = new eZDFSFileHandlerDFSBackend(); $base = realpath($dfsBackend->getMountPoint()); $cleanPregExpr = preg_quote(fixWinPath($base), '@'); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base . '/' . $checkPath)) as $filename => $current) { if ($current->isFile()) { $relativePath = trim(preg_replace('@^' . $cleanPregExpr . '@', '', fixWinPath($filename)), '/'); if (!$fileHandler->fileExists($relativePath)) { $cli->output(' - ' . $relativePath); if ($delete) { unlink($filename); } } usleep($pause); } } $cli->output('Done'); }
$cli->cli->output( "Found ".count($visits)." visits:"); $visitAnswer = $cli->askQuestion( "Which date?", array_map( function($value){ return date('Y-m-d H:i:s', $value); }, $visits )); $visitDate = $visits[$visitAnswer]; // 2 - get xmls $hash = md5( serialize( array( 'type' => $nlType, 'frequency' => $nlFrequency, 'customer_type' => false, 'specialty' => false, 'publisher_folder' => false, ) ).$clusterIdentifier ); $dfsBackend = new eZDFSFileHandlerDFSBackend(); $mountPoint = $dfsBackend->getMountPoint(); $lastFile = false; foreach( glob( $mountPoint.eZSys::varDirectory()."/rssCache/".$hash.'.xml.2*') as $file ) { preg_match( '#\.(?P<rssYear>[0-9]{4})(?P<rssMonth>[0-9]{2})(?P<rssDay>[0-9]{2})_(?P<rssHour>[0-9]{2})(?P<rssMinutes>[0-9]{2})\.log$#', $file, $m ); $rssDate = mktime( $m['rssHour'], $m['rssMinutes'], 0, $m['rssMonth'], $m['rssDay'], $m['rssYear'] ); if ( $rssDate > $visitDate ) break; $lastFile = $file; } $cli->cli->output( "\nLast generated file before Creator Mail's visit:" ); $cli->cli->output( $lastFile );
/** * Checks that the NFS share is still available. * * Does so by verifying that $path does exist within the NFS mount point path + $rootPath * @return true */ function checkNFS($rootPath) { static $path = false; if (!$path) { $dfsBackend = new eZDFSFileHandlerDFSBackend(); $path = realpath($dfsBackend->getMountPoint()) . '/' . $rootPath; } if (!file_exists($path) || !is_dir($path)) { abort("DFS mount seems to be gone, aborting"); } }