Example #1
0
<?php

// New line for CLI.
$n = PHP_EOL;
// Include config.php
require_once dirname(__FILE__) . '/../../../www/config.php';
// ColorCLI class.
$cli = new ColorCLI();
// Print arguments/usage.
$totalArgs = count($argv);
if ($totalArgs < 2) {
    exit($cli->info($n . 'This deletes releases based on a list of criteria you pass.' . $n . 'Usage:' . $n . $n . 'List of supported criteria:' . $n . 'fromname   : Look for names of people who posted releases (the poster name). (modifiers: equals, like)' . $n . 'groupname  : Look in groups. (modifiers: equals, like)' . $n . 'guid       : Look for a specific guid. (modifiers: equals)' . $n . 'name       : Look for a name (the usenet name). (modifiers: equals, like)' . $n . 'searchname : Look for a name (the search name). (modifiers: equals, like)' . $n . 'size       : Release must be (bigger than |smaller than |exactly) this size.(bytes) (modifiers: equals,bigger,smaller)' . $n . 'adddate    : Look for releases added to our DB (older than|newer than) x hours. (modifiers: bigger,smaller)' . $n . 'postdate   : Look for posted to usenet (older than|newer than) x hours. (modifiers: bigger,smaller)' . $n . 'completion : Look for completion (less than) (modifiers: smaller)' . $n . $n . 'List of Modifiers:' . $n . 'equals     : Match must be exactly this. (fromname=equals="john" will only look for "john", not "johndoe")' . $n . 'like       : Match can be similar to this. Separate words using spaces(ie:"cars hdtv x264").' . $n . '             (fromname=like="john" will look for any posters with john in it (ie:john@smith.com)' . $n . 'bigger     : Match must be bigger than this. (postdate=bigger="3" means older than 3 hours ago)' . $n . 'smaller    : Match must be smaller than this (postdate=smaller="3" means between now and 3 hours ago.' . $n . $n . 'Extra:' . $n . 'ignore     : Ignore the user check. (before running we ask you if you want to run the query to delete)' . $n . $n . 'Examples:' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' groupname=equals="alt.binaries.teevee" searchname=like="olympics 2014" postdate=bigger="5"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' guid=equals="8fb5956bae3de4fb94edcc69da44d6883d586fd0"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' size=smaller="104857600" size=bigger="2048" groupname=like="movies"' . $n . $_SERVER['_'] . ' ' . $argv[0] . ' fromname=like="@XviD.net" groupname=equals="alt.binaries.movies.divx" ignore'));
}
$RR = new ReleaseRemover();
// Remove argv[0] and send the array.
$RR->removeByCriteria(array_slice($argv, 1, $totalArgs - 1));
Example #2
0
        } else {
            exit($c->error("\nHave you changed the path to the patches folder, or do you have the right permissions?\n"));
        }
        sort($patches);
        foreach ($patches as $patch) {
            if (preg_match('/\\.sql$/i', $patch)) {
                $filepath = $argv[1] . $patch;
                $file = fopen($filepath, "r");
                $patch = fread($file, filesize($filepath));
                if (preg_match('/UPDATE `?site`? SET `?value`? = \'?(\\d{1,})\'? WHERE `?setting`? = \'sqlpatch\'/i', $patch, $patchnumber)) {
                    if ($patchnumber['1'] > $currentversion) {
                        if ($safeupgrade == true && $backedup == false) {
                            BackupDatabase();
                            $backedup = true;
                        }
                        SplitSQL($filepath);
                        $patched++;
                    }
                }
            }
        }
    } else {
        exit($c->error("\nUnable to determine OS.\n"));
    }
}
if ($patched == 0) {
    exit($c->info("Nothing to patch, you are already on patch version " . $currentversion));
}
if ($patched > 0) {
    echo $c->header($patched . " patch(es) applied.");
}
<?php

require_once dirname(__FILE__) . '/../www/config.php';
$output = new \ColorCLI();
echo $output->primary("Checking for files in the renamed directories.");
$status = 0;
$dirs = array(['old' => 'misc/testing/DB_scripts', 'newpath' => 'misc/testing/DB'], ['old' => 'misc/testing/Dev_testing/Subject_testing', 'newpath' => 'misc/testing/Dev/Subject'], ['old' => 'misc/testing/Dev_testing', 'newpath' => 'misc/testing/Dev'], ['old' => 'misc/testing/PostProc_testing', 'newpath' => 'misc/testing/PostProc'], ['old' => 'misc/testing/Regex_testing', 'newpath' => 'misc/testing/Regex'], ['old' => 'misc/testing/Release_scripts', 'newpath' => 'misc/testing/Release'], ['old' => 'misc/update_scripts/nix_scripts/tmux/powerline/themes', 'newpath' => 'misc/update/nix/tmux/powerline/themes'], ['old' => 'misc/update_scripts/nix_scripts/tmux/powerline', 'newpath' => 'misc/update/nix/tmux/powerline'], ['old' => 'misc/update_scripts/nix_scripts/screen/sequential', 'newpath' => 'misc/update/nix/screen/sequential'], ['old' => 'misc/update_scripts/nix_scripts/tmux/', 'newpath' => 'misc/update/nix/tmux'], ['old' => 'misc/update_scripts/nix_scripts', 'newpath' => 'misc/update/nix'], ['old' => 'misc/update_scripts/python_scripts/lib', 'newpath' => 'misc/update/python/lib'], ['old' => 'misc/update_scripts/python_scripts', 'newpath' => 'misc/update/python'], ['old' => 'misc/update_scripts/win_scripts', 'newpath' => 'misc/update/win'], ['old' => 'misc/update_scripts', 'newpath' => 'misc/update']);
$tatus = 0;
foreach ($dirs as $dir) {
    if (isset($dir['old'])) {
        $pathOld = nZEDb_ROOT . $dir['old'];
        if (file_exists($pathOld)) {
            $pathNew = nZEDb_ROOT . $dir['newpath'];
            echo $output->info("Moving contents of '{$pathOld}' to '{$pathNew}'");
            $dirIt = new \DirectoryIterator($pathOld);
            foreach ($dirIt as $item) {
                if ($item->isDot()) {
                    continue;
                }
                echo $output->info("  Moving {$item->getPathname()}");
                if (rename($item->getPathname(), $pathNew . DIRECTORY_SEPARATOR . $item->getFilename()) === false) {
                    echo $output->error("   FAILED!");
                    $status = 1;
                }
            }
            $d = dir($pathOld);
            if ($d->read() === false) {
                @unlink($pathOld);
            } else {
                echo $output->error("Could not move all files. Check your permissions!");
            }
Example #4
0
$changed = false;
$source = __DIR__ . DS . 'git-hooks' . DS . PRE_COMMIT_HOOK;
$target = NN_HOOKS . DS . PRE_COMMIT_HOOK;
if (!file_exists(NN_HOOKS . PRE_COMMIT_HOOK)) {
    copy($source, $target);
}
$file = file($target, FILE_IGNORE_NEW_LINES);
if (preg_match('/^(?P<key>#version=)(?P<value>.*)$/', $file[1], $match)) {
    $current = $match['value'];
}
$out = new ColorCLI();
$versions = new \newznab\utility\Versions();
$version = $versions->getGitHookPrecommit();
if ($version > $current) {
    copy($source, $target);
    echo $out->info("Updated pre-commit hook to version {$version}");
    $file = file($target, FILE_IGNORE_NEW_LINES);
}
chmod($target, 0774);
$count = count($file);
$index = 0;
while ($index < $count) {
    if (preg_match('/^#newznab hook\\s*-\\s*(.+)$/', $file[$index], $match)) {
        if (VERBOSE) {
            echo $out->primary("Matched: " . $file[$index]);
        }
        $index++;
        $file[$index] = trim($file[$index]);
        switch ($match[1]) {
            case 'update version info':
            case 'run hooks':
}
$path2covers = NN_COVERS . 'games' . DS;
$dirItr = new RecursiveDirectoryIterator($path2covers);
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
    if (is_file($filePath) && preg_match('/\\d+\\.jpg/', $filePath)) {
        preg_match('/(\\d+)\\.jpg/', basename($filePath), $match);
        if (isset($match[1])) {
            $run = $pdo->queryDirect("UPDATE gamesinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
            if ($run !== false) {
                if ($run->rowCount() >= 1) {
                    $covers++;
                } else {
                    $run = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE id = " . $match[1]);
                    if ($run !== false && $run->rowCount() == 0) {
                        echo $c->info($filePath . " not found in db.");
                    }
                }
            }
        }
    }
}
$qry = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE cover = 1");
foreach ($qry as $rows) {
    if (!is_file($path2covers . $rows['id'] . '.jpg')) {
        $pdo->queryDirect("UPDATE gamesinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
        echo $c->info($path2covers . $rows['id'] . ".jpg does not exist.");
        $deleted++;
    }
}
echo $c->header($covers . " covers set.");
Example #6
0
 /**
  * @param string $message
  *
  * @return void
  */
 public function info($message)
 {
     if (PEAR_LOG_DEBUG) {
         echo $this->color->info($message);
     }
 }