Exemple #1
0
 /**
  * @note Disable group that does not exist on USP server
  * @param $id
  *
  */
 public function disableIfNotExist($id)
 {
     $this->pdo->queryExec(sprintf("UPDATE groups SET active = 0 WHERE id = %d", $id));
     $this->colorCLI->doEcho($this->colorCLI->error('Group does not exist on server, disabling'));
 }
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\RottenTomato;
use nzedb\db\Settings;
$cli = new ColorCLI();
$rtkey = (new Settings())->getSetting('rottentomatokey');
if (isset($rtkey)) {
    $rt = new RottenTomato($rtkey);
    print_r(json_decode($rt->searchMovie("inception")));
    $url = RottenTomato::API_URL . "movies.json?apikey=" . $rt->getApiKey() . "&q=inception&page_limit=50";
    exit($cli->header("\nIf nothing was displayed above then there might be an error. If so, go to the following url: {$url}\n"));
} else {
    exit($cli->error("\nNo rotten tomato key.\n"));
}
                                                    $sql = "ALTER TABLE {$tbl} ENGINE=TokuDB Compression=tokudb_lzma";
                                                    $pdo->queryExec($sql);
                                                    $pdo->queryExec("OPTIMIZE TABLE {$tbl}");
                                                }
                                            }
                                        } else {
                                            if (isset($argv[1]) && $argv[1] == "tokudb") {
                                                $tables = $pdo->query('SHOW TABLE STATUS WHERE (Engine != "TokuDB" OR ROW_FORMAT="tokudb_lzma" OR Create_options != "`COMPRESSION`=tokudb_lzma") AND Engine != "SPHINX"');
                                                foreach ($tables as $row) {
                                                    $tbl = $row['name'];
                                                    if ($tbl !== 'release_search_data') {
                                                        printf($cli->header("Converting {$tbl}"));
                                                        $sql = "ALTER TABLE {$tbl} ENGINE=TokuDB row_format=tokudb_lzma";
                                                        $pdo->queryExec($sql);
                                                        $pdo->queryExec("OPTIMIZE TABLE {$tbl}");
                                                    }
                                                }
                                            } else {
                                                exit($cli->error("\nThis script will convert your tables to a new engine/format. Only tables not meeting the new engine/format will be converted.\n" . "A comparison of these, excluding TokuDB, https://github.com/nZEDb/nZEDb/wiki/MySQL-Storage-Engine-Comparison\n\n" . "php convert_mysql_tables.php dmyisam                                        ...: Converts all the tables to Myisam Dynamic. This is the default and is recommended where ram is limited.\n" . "php convert_mysql_tables.php fmyisam                                        ...: Converts all the tables to Myisam Fixed. This can be faster, but to fully convert all tables requires changing varchar columns to char.\n" . "                                                                                 This will use much more space than dynamic.\n" . "php convert_mysql_tables.php dinnodb                                        ...: Converts all the tables to InnoDB Dynamic. This is recommended when the total data and indexes can fit into the innodb_buffer_pool.\n" . "                                                                                 NB if your innodb version < 5.6 bookinfo / consoleinfo / musicinfo / release_search_data / predb_hashes will not be converted as fulltext indexes are not supported.\n" . "php convert_mysql_tables.php cinnodb                                        ...: Converts all the tables to InnoDB Compressed. All tables except release_nfos will be converted to Compressed row format.\n" . "                                                                                 This is recommended when the total data and indexes can not fit into the innodb_buffer_pool using DYNAMIC row format.\n" . "                                                                                 NB if your innodb version < 5.6 bookinfo / consoleinfo / musicinfo / release_search_data / predb_hashes will not be converted as fulltext indexes are not supported.\n" . "php convert_mysql_tables.php cinnodb-noparts                                ...: Converts all the tables to InnoDB Compressed. All tables except parts and release_nfos will be converted to Compressed row format.\n" . "                                                                                 Alls parts* will be converted to MyISAM Dynamic. This is recommended when using Table Per Group.\n" . "                                                                                 NB if your innodb version < 5.6 bookinfo / consoleinfo / musicinfo / release_search_data / predb_hashes will not be converted as fulltext indexes are not supported.\n" . "php convert_mysql_tables.php collections                                    ...: Converts collections, binaries, parts to MyIsam.\n" . "php convert_mysql_tables.php mariadb-tokudb                                 ...: Converts all the tables to MariaDB Tokutek DB. Use this is you installed mariadb-tokudb-engine. \n" . "                                                                                 The TokuDB engine needs to be activated first.\n" . "                                                                                 https://mariadb.com/kb/en/how-to-enable-tokudb-in-mariadb/\n" . "                                                                                 NB release_search_data will not be converted as tokudb does not support fulltext indexes.\n" . "php convert_mysql_tables.php tokudb                                         ...: Converts all the tables to Tokutek DB. Use this if you downloaded and installed the TokuDB binaries.\n" . "                                                                                 http://www.tokutek.com/resources/support/gadownloads/\n" . "                                                                                 NB release_search_data will not be converted as tokudb does not support fulltext indexes.\n" . "php convert_mysql_tables.php table [ fmyisam, dmyisam, dinnodb, cinnodb ]   ...: Converts 1 table to Engine, row_format specified.\n" . "                                                                                 NB if converting to innodb and your innodb version < 5.6 release_search_data / predb_hashes will not be converted as fulltext indexes are not supported.\n"));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Exemple #4
0
<?php

// To troubleshoot what's actually on usenet.
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\Binaries;
use nzedb\ColorCLI;
use nzedb\NNTP;
$cli = new ColorCLI();
if (!isset($argv[2]) || !is_numeric($argv[2])) {
    exit($cli->error("\nTest your nntp connection, get group information and postdate for specific article.\n\n" . "php {$argv['0']} alt.binaries.teevee 595751142    ...: To test nntp on alt.binaries.teevee with artivle 595751142.\n"));
}
$nntp = new NNTP();
if ($nntp->doConnect() !== true) {
    exit;
}
$first = $argv[2];
$group = $argv[1];
// Select a group.
$groupArr = $nntp->selectGroup($group);
print_r($groupArr);
// Insert actual local part numbers here.
$msg = $nntp->getXOVER($first . '-' . $first);
// Print out the array of headers.
print_r($msg);
// get postdate for an article
$binaries = new Binaries(['NNTP' => $nntp]);
$newdate = $binaries->postdate($first, $groupArr);
echo $cli->primary("The posted date for " . $group . ", article " . $first . " is " . date('Y-m-d H:i:s', $newdate));
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\Users;
use nzedb\db\Settings;
$colorCLI = new ColorCLI();
$warning = <<<WARNING
This script will (re)set the password hashes for older hashes (pre Db patch
158, others are ignored), with the user's email as the new password.
  It is intended for use ONLY if you have a *lot* of users, as this is not
secure (a user's email addresses may be known to other users). If you only have
a few users then run setUsersPasswordHash.php for each of them instead.
WARNING;
$usage = "\nUsage: php {$argv[0]} <IUnderStandTheRisks>";
echo $colorCLI->warning($warning);
if ($argc != 2) {
    exit($colorCLI->error("\nWrong number of parameters{$usage}"));
} else {
    if ($argv[1] !== 1 && $argv[1] != '<IUnderStandTheRisks>' && $argv[1] != 'IUnderStandTheRisks' && $argv[1] != 'true') {
        exit($colorCLI->error("\nInvalid parameter(s){$usage}"));
    }
}
$pdo = new Settings();
$users = $pdo->query("SELECT id, username, email, password FROM users");
$update = $pdo->Prepare('UPDATE users SET password = :password WHERE id = :id');
$Users = new Users(['Settings' => $pdo]);
foreach ($users as $user) {
    if (needUpdate($user)) {
        $hash = $Users->hashPassword($user['email']);
        if ($hash !== false) {
            $update->execute([':password' => $hash, ':id' => $user['id']]);
            echo $colorCLI->primary('Updating hash for user:'******'username'];
Exemple #6
0
use nzedb\utility\Misc;
$pdo = new Settings();
$DIR = nZEDb_MISC;
$smarty = new Smarty();
$dbname = DB_NAME;
$cli = new ColorCLI();
if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "safe")) {
    $restart = (new Tmux())->stopIfRunning();
    system("cd {$DIR} && git pull");
    if (Misc::hasCommand("php5")) {
        $PHP = "php5";
    } else {
        $PHP = "php";
    }
    echo $cli->header("Patching database - {$dbname}.");
    $safe = $argv[1] === "safe" ? true : false;
    system("{$PHP} " . nZEDb_ROOT . 'cli' . DS . "update_db.php true {$safe}");
    // Remove folders from smarty.
    $cleared = $smarty->clearCompiledTemplate();
    if ($cleared) {
        echo $cli->header("The smarty template cache has been cleaned for you");
    } else {
        echo $cli->header("You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c");
    }
    if ($restart) {
        echo $cli->header("Starting tmux scripts.");
        $pdo->queryExec("UPDATE tmux SET value = '1' WHERE setting = 'RUNNING'");
    }
} else {
    exit($cli->error("\nThis script will automatically do a git pull, patch the DB and delete the smarty folder contents.\n\n" . "php {$argv['0']} true   ...: To run.\n" . "php {$argv['0']} safe   ...: Tto run a backup of your database and then update.\n"));
}
Exemple #7
0
use nzedb\ColorCLI;
use nzedb\ConsoleTools;
use nzedb\NZB;
use nzedb\ReleaseImage;
use nzedb\Releases;
use nzedb\db\Settings;
use nzedb\utility\Utility;
$cli = new ColorCLI();
if (isset($argv[1])) {
    $del = false;
    if (isset($argv[2])) {
        $del = $argv[2];
    }
    create_guids($argv[1], $del);
} else {
    exit($cli->error("\nThis script updates all releases with the guid (md5 hash of the first message-id) from the nzb file.\n\n" . "php {$argv['0']} true         ...: To create missing nzb_guids.\n" . "php {$argv['0']} true delete  ...: To create missing nzb_guids and delete invalid nzbs and releases.\n"));
}
function create_guids($live, $delete = false)
{
    $pdo = new Settings();
    $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]);
    $timestart = TIME();
    $relcount = $deleted = $total = 0;
    $relrecs = false;
    if ($live == "true") {
        $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC"));
    } else {
        if ($live == "limited") {
            $relrecs = $pdo->queryDirect(sprintf("SELECT id, guid FROM releases WHERE nzbstatus = 1 AND nzb_guid IS NULL ORDER BY id DESC LIMIT 10000"));
        }
    }
Exemple #8
0
<?php

require_once realpath(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\NameFixer;
$cli = new ColorCLI();
if (!isset($argv[1]) && ($argv[1] !== 'full' || !is_numeric($argv[1]))) {
    exit($cli->error(PHP_EOL . "This script tries to match release filenames to PreDB filenames." . PHP_EOL . "To display the changes, use 'show' as the second argument. The optional third argument will limit the amount of filenames to attempt to match." . PHP_EOL . PHP_EOL . "php match_prefiles.php full show\t...: to run on full database and show renames." . PHP_EOL . "php match_prefiles.php 2000 show\t...: to run against 2000 distinct releases and show renames." . PHP_EOL));
}
$nameFixer = new NameFixer();
$nameFixer->getPreFileNames($argv);
echo $output->primary("Checking for files in the renamed directories.");
$status = 0;
$dirs = [['old' => 'misc/testing/DB_scripts', 'newpath' => 'misc/testing/DB'], ['old' => 'misc/testing/Dev_testing/Subject_testing', 'newpath' => 'misc/testing/Developers/Subject'], ['old' => 'misc/testing/Dev_testing', 'newpath' => 'misc/testing/Developers'], ['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!");
            }
        }
    }
}
exit((int) $status);
Exemple #10
0
<?php

/* This script deletes releases that match certain criteria, type php removeCrapReleases.php false for details. */
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\ReleaseRemover;
$cli = new ColorCLI();
$n = PHP_EOL;
$argCnt = count($argv);
if ($argCnt === 1) {
    exit($cli->error($n . 'Run fixReleaseNames.php first to attempt to fix release names.' . $n . 'This will miss some releases if you have not set fixReleaseNames to set the release as checked.' . $n . $n . "php {$argv['0']} false Display full usage of this script." . $n . "php {$argv['0']} true full Run this script with all options."));
}
if ($argCnt === 2) {
    if ($argv[1] === 'false') {
        exit("php {$argv['0']} arg1 arg2 arg3 arg4" . $n . $n . 'arg1 (Required) = true/false' . $n . '                  true   = Run this script and delete releases.' . $n . '                  false  = Run this script and show what could be deleted.' . $n . $n . 'arg2 (Required) = full/number' . $n . '                  full   = Run without a time limit.' . $n . '                  number = Run on releases up to this old.' . $n . $n . 'arg3 (Optional) = blacklist | blfiles | codec | executable | gibberish | hashed | huge | installbin | passworded | passwordurl | sample | scr | short | size | wmv_all' . $n . '                  blfiles     = Remove releases using the enabled blacklists in admin section of site against filenames.' . $n . '                  codec       = Remove releases where the release contains AVI or WMV file and is in x264 category (the spammer).' . $n . '                  executable  = Remove releases containing an exe file.' . $n . '                  gibberish   = Remove releases where the name is letters/numbers only and 15 characters or longer.' . $n . '                  hashed      = Remove releases where the name is letters/numbers only and 25 characters or longer.' . $n . '                  installbin  = Remove releases which contain an install.bin file.' . $n . '                  passworded  = Remove releases which contain the word password in the title.' . $n . '                  passwordurl = Remove releases which contain a password.url file.' . $n . '                  sample      = Remove releases that are smaller than 40MB more than 1 file and have sample in the title' . $n . '                  scr         = Remove releases where .scr extension is found in the files or subject.' . $n . '                  short       = Remove releases where the name is only numbers or letters and is 5 characters or less.' . $n . '                  wmv_all     = Remove releases where the release contains WMV file in any group!!.' . $n . '                  size        = Remove releases smaller than 1MB and have only 1 file and not in books or mp3 section.' . $n . $n . 'examples:' . $n . "php {$argv['0']} true 12 blacklist     = Remove releases up to 12 hours old using site blacklists." . $n . "php {$argv['0']} false full            = Show what releases could have been removed." . $n . "php {$argv['0']} true full installbin  = Remove releases which containing an install.bin file." . $n . "php {$argv['0']} true full blacklist 1 = Remove releases matching blacklist id 1." . $n);
    } else {
        exit($cli->error("Wrong usage! Type php {$argv['0']} false"));
    }
}
if ($argCnt < 3) {
    exit($cli->error("Wrong usage! Type php {$argv['0']} false"));
}
if (isset($argv[3]) && $argv[3] === 'blacklist' && isset($argv[4])) {
    $blacklistID = $argv[4];
}
$RR = new ReleaseRemover();
$RR->removeCrap($argv[1] === 'true' ? true : false, $argv[2], isset($argv[3]) ? $argv[3] : '', isset($blacklistID) ? $argv[4] : '');
Exemple #11
0
<?php

require_once dirname(__FILE__) . '/config.php';
use nzedb\ColorCLI;
use nzedb\RequestIDLocal;
use nzedb\RequestIDWeb;
$cli = new ColorCLI();
if (!isset($argv[1]) || $argv[1] != "all" && $argv[1] != "full" && $argv[1] != "web" && !is_numeric($argv[1]) || !isset($argv[2]) || !in_array($argv[2], ['true', 'false'])) {
    exit($cli->error(PHP_EOL . "This script tries to match a release request ID by group to a PreDB request ID by group doing local lookup only." . PHP_EOL . "In addition an optional final argument is time, in minutes, to check releases that have previously been checked." . PHP_EOL . PHP_EOL . "Argument 1: full|all|number|web => (mandatory)" . PHP_EOL . "all does only requestid releases, full does full database, number limits to x amount of releases, web does web requestID's" . PHP_EOL . "Argument 2: true|false          => (mandatory) Display full info on how the release was renamed or not." . PHP_EOL . "Argument 3: number             => (optional)  This is to limit how old the releases to work on (in hours)." . PHP_EOL . "php requestid.php 1000 true    => to limit to 1000 sorted by newest postdate and show renaming." . PHP_EOL . PHP_EOL . "php requestid.php full true    => to run on full database and show renaming." . PHP_EOL . "php requestid.php all true     => to run on all requestid releases (including previously renamed) and show renaming." . PHP_EOL));
}
if ($argv[1] === 'web') {
    (new RequestIDWeb())->lookupRequestIDs(['limit' => 1000, 'show' => $argv[2], 'time' => isset($argv[3]) && is_numeric($argv[3]) && $argv[3] > 0 ? $argv[3] : 0]);
} else {
    (new RequestIDLocal())->lookupRequestIDs(['limit' => $argv[1], 'show' => $argv[2], 'time' => isset($argv[3]) && is_numeric($argv[3]) && $argv[3] > 0 ? $argv[3] : 0]);
}
Exemple #12
0
use nzedb\db\Settings;
$giantbombkey = (new Settings())->getSetting('giantbombkey');
$cli = new ColorCLI();
$obj = new GiantBomb($giantbombkey, $resp = "json");
$searchgame = "South Park The Stick of Truth";
$resultsfound = 0;
$e = null;
try {
    $fields = array("deck", "description", "original_game_rating", "api_detail_url", "image", "genres", "name", "platforms", "publishers", "original_release_date", "reviews", "site_detail_url");
    $result = $obj->search($searchgame, $fields, 1);
    $result = json_decode(json_encode($result), true);
    if ($result['number_of_total_results'] != 0) {
        $resultsfound = count($result['results']);
        for ($i = 0; $i <= $resultsfound; $i++) {
            similar_text($result['results'][$i]['name'], $searchgame, $p);
            if ($p > 90) {
                $result = $result['results'][$i];
                break;
            }
        }
    }
} catch (\Exception $e) {
    $result = false;
}
if ($result !== false && !empty($result)) {
    print_r($result);
    exit($cli->header("\nLooks like it is working alright."));
} else {
    print_r($e);
    exit($cli->error("\nThere was a problem attempting to query giantbomb. Maybe your key is wrong, or you are being throttled.\n"));
}
Exemple #13
0
         case 'update version info':
         case 'run hooks':
             $hook = '/usr/bin/php ' . nZEDb_LIB . 'build/git-hooks/runHooks.php';
             if ($hook != $file[$index]) {
                 if (VERBOSE) {
                     echo $out->primary('Replace: "' . $file[$index] . '" with "' . $hook . '"');
                 }
                 $file[$index] = $hook;
                 $changed = true;
             } else {
                 echo $out->primary("Skipped: " . $file[$index]);
             }
             break;
         default:
             $index--;
             echo $out->error('Invalid hook placeholder!!');
             break;
     }
 } else {
     if (preg_match('#^PROJECT=(?P<path>.*)$#', $file[$index], $match)) {
         if ($match['path'] != nZEDb_ROOT) {
             $file[$index] = 'PROJECT=' . nZEDb_ROOT;
             $changed = true;
         }
     } else {
         if (VERBOSE) {
             echo $out->primary("Skipped: " . $file[$index]);
         }
     }
 }
 $index++;