public function runRules() { $AC = new anyC(); $AC->setCollectionOf("IncomingPrettify"); $AC->addAssocV3("IncomingPrettifyIsActive", "=", "1"); $I = new mIncoming(); $files = $I->getNewFiles(); echo "<div style=\"max-height:400px;overflow:auto;font-size:10px;padding:5px;\">"; $run = mUserdata::getUDValueS("trinityDBPrettifyExecute", "0") == "1"; if (!$run) { echo "<p style=\"color:red;margin-bottom:10px;\">The following operations are NOT executed, this is only a preview!<br />To execute the operations, you'll have to enable it in the options.</p>"; } foreach ($files as $path) { $newName = basename($path); if (strpos(strtolower($newName), ".part") == strlen($newName) - 5) { continue; } if (strpos(strtolower($newName), ".mkv") != strlen($newName) - 4 and strpos(strtolower($newName), ".mp4") != strlen($newName) - 4) { continue; } while ($P = $AC->getNextEntry()) { $newName = preg_replace("/" . str_replace(".", "\\.", $P->A("IncomingPrettifyFind")) . "/e" . ($P->A("IncomingPrettifyCaseSensitive") == "1" ? "" : "i"), str_replace(array("//", "."), array("\\", "\\."), $P->A("IncomingPrettifyReplace")), $newName); } $newName = str_replace("\\", "", $newName); $AC->resetPointer(); if ($newName != basename($path)) { $color = ""; if ($run) { $renamed = str_replace(basename($path), $newName, $path); if (file_exists($renamed)) { $color = "color:red;"; } else { if (rename($path, $renamed)) { $color = "color:green;"; } else { $color = "color:red;"; } } } echo "<span style=\"{$color}\">" . basename($path) . " -><br />" . basename($newName) . "</span><br /><br />"; } } echo "</div>"; }