diff --git a/Changelog b/Changelog index ad277ef8f..42eadc018 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-11-24 DariusIII + * Chg: Use bootstrap/autoload.php instead the bootstrap.php in root of install * Chg: Update whoops library 2017-11-23 DariusIII * Chg: Update Nfo class diff --git a/_install/install_nntmux.php b/_install/install_nntmux.php index a904295fb..e4aa00724 100644 --- a/_install/install_nntmux.php +++ b/_install/install_nntmux.php @@ -3,7 +3,7 @@ if (! defined('NN_INSTALLER')) { define('NN_INSTALLER', true); } -require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; include_once dirname(__DIR__).DIRECTORY_SEPARATOR.'nntmux'.DIRECTORY_SEPARATOR.'constants.php'; use nntmux\db\DB; diff --git a/app/Providers/YencServiceProvider.php b/app/Providers/YencServiceProvider.php index ff13cb026..b20d2e2d9 100644 --- a/app/Providers/YencServiceProvider.php +++ b/app/Providers/YencServiceProvider.php @@ -34,11 +34,11 @@ class YencServiceProvider extends ServiceProvider public static function config(array $options = []) { $defaults = [ - ['name' => [ - 'default' => 'Php', - ], - ], - ]; + ['name' => [ + 'default' => 'Php', + ], + ], + ]; $options += $defaults; diff --git a/build/NewPatches.php b/build/NewPatches.php index 264764a03..d83c786ee 100644 --- a/build/NewPatches.php +++ b/build/NewPatches.php @@ -18,7 +18,7 @@ * @author niel * @copyright 2015 nZEDb */ -require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DbUpdate; use nntmux\utility\Git; diff --git a/build/git-hooks/runHooks.php b/build/git-hooks/runHooks.php index 21fefb359..f8ea9a1d9 100755 --- a/build/git-hooks/runHooks.php +++ b/build/git-hooks/runHooks.php @@ -20,7 +20,7 @@ */ define('GIT_PRE_COMMIT', true); -require_once realpath(dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR.'bootstrap.php'); +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\utility\Git; use App\Extensions\util\Versions; diff --git a/build/postInstall.php b/build/postInstall.php index e847c1d52..fb5af3aff 100644 --- a/build/postInstall.php +++ b/build/postInstall.php @@ -16,7 +16,7 @@ * @author niel * @copyright 2016 nZEDb */ -require_once '..'.DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once '..'.DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; $updates = NN_CONFIGS.'updates.json'; if (! file_exists($updates)) { diff --git a/cli/data/populate_anidb.php b/cli/data/populate_anidb.php index ef9cc989f..53d524646 100755 --- a/cli/data/populate_anidb.php +++ b/cli/data/populate_anidb.php @@ -2,7 +2,7 @@ /* This script is designed to gather all show data from anidb and add it to the anidb table for nntmux, as part of this process we need the number of PI queries that can be executed max and whether or not we want debuging the first argument if unset will try to do the entire list (a good way to get banned), the second option can be blank or true for debugging. * IF you are using this script then then you also want to edit anidb.php in www/lib and locate "604800" and replace it with 1204400, this will make sure it never tries to connect to anidb as this will fail */ -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\ColorCLI; @@ -21,11 +21,14 @@ if ($argc > 1 && $argv[1] === 'true' && isset($argv[2])) { } } } else { - ColorCLI::doEcho(PHP_EOL.ColorCLI::error( - 'To execute this script you must provide a boolean argument.'.PHP_EOL. - 'Argument1: true|false to run this script or not'.PHP_EOL. - 'Argument2: full|info for what type of data to populate.'.PHP_EOL. - 'Argument3 (optional) anidbid to fetch info for'.PHP_EOL. - 'WARNING: Argument "info" without third argument will get you banned from AniDB almost instantly'), true - ); + ColorCLI::doEcho( + PHP_EOL.ColorCLI::error( + 'To execute this script you must provide a boolean argument.'.PHP_EOL. + 'Argument1: true|false to run this script or not'.PHP_EOL. + 'Argument2: full|info for what type of data to populate.'.PHP_EOL. + 'Argument3 (optional) anidbid to fetch info for'.PHP_EOL. + 'WARNING: Argument "info" without third argument will get you banned from AniDB almost instantly' + ), + true + ); } diff --git a/cli/data/populate_steam_apps.php b/cli/data/populate_steam_apps.php index 1057fcfb3..54bf74f52 100644 --- a/cli/data/populate_steam_apps.php +++ b/cli/data/populate_steam_apps.php @@ -1,6 +1,6 @@ 0 ? $argv[2] : 10000)); } @@ -27,28 +27,28 @@ function populate_rt($table, $max) $pdo = new DB(); switch ($table) { - case 'releases_rt': - $pdo->queryDirect('SET SESSION group_concat_max_len=8192'); - $query = ( - 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename + case 'releases_rt': + $pdo->queryDirect('SET SESSION group_concat_max_len=8192'); + $query = ( + 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename FROM releases r LEFT JOIN release_files rf ON(r.id=rf.releases_id) WHERE r.id > %d GROUP BY r.id ORDER BY r.id ASC LIMIT %d' - ); - $rtvalues = '(id, name, searchname, fromname, filename)'; - $totals = $pdo->queryOneRow('SELECT COUNT(id) AS c, MIN(id) AS min FROM releases'); - if (! $totals) { - exit("Could not get database information for releases table.\n"); - } - $total = $totals['c']; - $minId = $totals['min']; - break; - default: - exit(); - } + ); + $rtvalues = '(id, name, searchname, fromname, filename)'; + $totals = $pdo->queryOneRow('SELECT COUNT(id) AS c, MIN(id) AS min FROM releases'); + if (! $totals) { + exit("Could not get database information for releases table.\n"); + } + $total = $totals['c']; + $minId = $totals['min']; + break; + default: + exit(); + } $sphinx = new SphinxSearch(); $string = sprintf('REPLACE INTO %s %s VALUES ', $table, $rtvalues); @@ -67,17 +67,17 @@ function populate_rt($table, $max) $lastId = $row['id']; } switch ($table) { - case 'releases_rt': - $tempString .= sprintf( - '(%d,%s,%s,%s,%s),', - $row['id'], - $sphinx->sphinxQL->escapeString($row['name']), - $sphinx->sphinxQL->escapeString($row['searchname']), - $sphinx->sphinxQL->escapeString($row['fromname']), - $sphinx->sphinxQL->escapeString($row['filename']) - ); - break; - } + case 'releases_rt': + $tempString .= sprintf( + '(%d,%s,%s,%s,%s),', + $row['id'], + $sphinx->sphinxQL->escapeString($row['name']), + $sphinx->sphinxQL->escapeString($row['searchname']), + $sphinx->sphinxQL->escapeString($row['fromname']), + $sphinx->sphinxQL->escapeString($row['filename']) + ); + break; + } } if (! $tempString) { continue; diff --git a/misc/sphinxsearch/toggle_search_type.php b/misc/sphinxsearch/toggle_search_type.php index 82a405ec6..06a0356f6 100644 --- a/misc/sphinxsearch/toggle_search_type.php +++ b/misc/sphinxsearch/toggle_search_type.php @@ -1,28 +1,28 @@ log->error('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX to optimize for Sphinx!'.PHP_EOL); - } - break; - case 'standard': - revertToStandard(new DB()); - break; + case 'sphinx': + if (NN_RELEASE_SEARCH_TYPE == ReleaseSearch::SPHINX) { + optimizeForSphinx(new DB()); + } else { + echo PHP_EOL.$pdo->log->error('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX to optimize for Sphinx!'.PHP_EOL); + } + break; + case 'standard': + revertToStandard(new DB()); + break; } // Optimize database usage for Sphinx full-text @@ -44,25 +44,26 @@ function revertToStandard($pdo) if (isset($argv[2]) && in_array($argv[2], ['cinnodb', 'dinnodb', 'cmyisam', 'dmyisam'])) { switch ($argv[2]) { - case 'cinnnodb': - $engFormat = 'ENGINE = InnoDB ROW_FORMAT = Compressed'; - break; - case 'dinnodb': - $engFormat = 'ENGINE = InnoDB ROW_FORMAT = Dynamic'; - break; - case 'cmyisam': - $engFormat = 'ENGINE = MyISAM ROW_FORMAT = Compressed'; - break; - case 'dmyisam': - $engFormat = 'ENGINE = MyISAM ROW_FORMAT = Dynamic'; - break; - } + case 'cinnnodb': + $engFormat = 'ENGINE = InnoDB ROW_FORMAT = Compressed'; + break; + case 'dinnodb': + $engFormat = 'ENGINE = InnoDB ROW_FORMAT = Dynamic'; + break; + case 'cmyisam': + $engFormat = 'ENGINE = MyISAM ROW_FORMAT = Compressed'; + break; + case 'dmyisam': + $engFormat = 'ENGINE = MyISAM ROW_FORMAT = Dynamic'; + break; + } } echo PHP_EOL.$pdo->log->info('Dropping old table data and recreating fresh from schema. (Quick)'.PHP_EOL); $pdo->queryExec('DROP TABLE IF EXISTS release_search_data'); $pdo->queryExec( - sprintf(" + sprintf( + " CREATE TABLE release_search_data ( id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, releases_id INT(11) UNSIGNED NOT NULL, @@ -81,9 +82,9 @@ function revertToStandard($pdo) DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci AUTO_INCREMENT = 1", - $engFormat - ) - ); + $engFormat + ) + ); echo $pdo->log->info('Populating the releasearch table with initial data. (Slow)'.PHP_EOL); $pdo->queryInsert('INSERT INTO release_search_data (releases_id, guid, name, searchname, fromname) @@ -93,7 +94,8 @@ function revertToStandard($pdo) dropSearchTriggers($pdo); - $pdo->exec(' + $pdo->exec( + ' CREATE TRIGGER insert_search AFTER INSERT ON releases FOR EACH ROW BEGIN INSERT INTO release_search_data (releases_id, guid, name, searchname, fromname) @@ -124,7 +126,7 @@ function revertToStandard($pdo) DELETE FROM release_search_data WHERE releases_id = OLD.id; END;' - ); + ); echo $pdo->log->header('Standard search should once again be available.'.PHP_EOL); } diff --git a/misc/testing/DB/change_USP_provider.php b/misc/testing/DB/change_USP_provider.php index f634ef141..d5b7d3a86 100644 --- a/misc/testing/DB/change_USP_provider.php +++ b/misc/testing/DB/change_USP_provider.php @@ -1,6 +1,6 @@ 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 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 releasenfo 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 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 releasenfo 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 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 will not be converted as fulltext indexes are not supported.\n" - )); + "\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 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 releasenfo 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 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 releasenfo 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 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 will not be converted as fulltext indexes are not supported.\n" + )); } diff --git a/misc/testing/DB/convert_to_tpg.php b/misc/testing/DB/convert_to_tpg.php index 44c88d2a0..c6c3c62e3 100644 --- a/misc/testing/DB/convert_to_tpg.php +++ b/misc/testing/DB/convert_to_tpg.php @@ -1,6 +1,6 @@ log->error("\nThis script will move all collections, binaries, parts into tables per group.\n\n" - ."php $argv[0] true ...: To process all parts and leave the parts/binaries/collections tables intact.\n" - ."php $argv[0] true truncate ...: To process all parts and truncate parts/binaries/collections tables after completed.\n")); + ."php $argv[0] true ...: To process all parts and leave the parts/binaries/collections tables intact.\n" + ."php $argv[0] true truncate ...: To process all parts and truncate parts/binaries/collections tables after completed.\n")); } $start = time(); @@ -43,26 +43,26 @@ if ($collections_rows instanceof \Traversable) { echo $pdo->log->header("Processing ${groupName}"); //collection $pdo->queryExec('INSERT IGNORE INTO collections_'.$row['groups_id'].' (subject, fromname, date, xref, totalfiles, groups_id, collectionhash, dateadded, filecheck, filesize, releaseid) ' - ."SELECT subject, fromname, date, xref, totalfiles, groups_id, collectionhash, dateadded, filecheck, filesize, releaseid FROM collections WHERE groups_id = ${row['groups_id']}"); + ."SELECT subject, fromname, date, xref, totalfiles, groups_id, collectionhash, dateadded, filecheck, filesize, releaseid FROM collections WHERE groups_id = ${row['groups_id']}"); $collections = $pdo->queryOneRow('SELECT COUNT(*) AS cnt FROM collections where groups_id = '.$row['groups_id']); $ncollections = $pdo->queryOneRow('SELECT COUNT(*) AS cnt FROM collections_'.$row['groups_id']); echo $pdo->log->primary("Group ${groupName}, Collections = ${collections['cnt']} [${ncollections['cnt']}]"); //binaries $pdo->queryExec("INSERT IGNORE INTO binaries_${row['groups_id']} (name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, collections_id) " - .'SELECT name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, n.id FROM binaries b ' - .'INNER JOIN collections c ON b.collections_id = c.id ' - ."INNER JOIN collections_${row['groups_id']} n ON c.collectionhash = n.collectionhash AND c.groups_id = ${row['groups_id']}"); + .'SELECT name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, n.id FROM binaries b ' + .'INNER JOIN collections c ON b.collections_id = c.id ' + ."INNER JOIN collections_${row['groups_id']} n ON c.collectionhash = n.collectionhash AND c.groups_id = ${row['groups_id']}"); $binaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries b INNER JOIN collections c ON b.collections_id = c.id where c.groups_id = ${row['groups_id']}"); $nbinaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries_${row['groups_id']}"); echo $pdo->log->primary("Group ${groupName}, Binaries = ${binaries['cnt']} [${nbinaries['cnt']}]"); //parts $pdo->queryExec("INSERT IGNORE INTO parts_${row['groups_id']} (messageid, number, partnumber, size, binaries_id, collections_id) " - .'SELECT messageid, number, partnumber, size, n.id, c.id FROM parts p ' - .'INNER JOIN binaries b ON p.binaries_id = b.id ' - ."INNER JOIN binaries_${row['groups_id']} n ON b.binaryhash = n.binaryhash " - ."INNER JOIN collections_${row['groups_id']} c on c.id = n.collections_id AND c.groups_id = ${row['groups_id']}"); + .'SELECT messageid, number, partnumber, size, n.id, c.id FROM parts p ' + .'INNER JOIN binaries b ON p.binaries_id = b.id ' + ."INNER JOIN binaries_${row['groups_id']} n ON b.binaryhash = n.binaryhash " + ."INNER JOIN collections_${row['groups_id']} c on c.id = n.collections_id AND c.groups_id = ${row['groups_id']}"); $parts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts p INNER JOIN binaries b ON p.binaries_id = b.id INNER JOIN collections c ON b.collections_id = c.id WHERE c.groups_id = ${row['groups_id']}"); $nparts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts_${row['groups_id']}"); echo $pdo->log->primary("Group ${groupName}, Parts = ${parts['cnt']} [${nparts['cnt']}]\n"); diff --git a/misc/testing/DB/mysqldump_tables.php b/misc/testing/DB/mysqldump_tables.php index 4582b35aa..94dfcb249 100644 --- a/misc/testing/DB/mysqldump_tables.php +++ b/misc/testing/DB/mysqldump_tables.php @@ -1,6 +1,6 @@ log->error("\nThis script can dump/restore all tables, compressed or OUTFILE/INFILE, or just collections/binaries/parts.\n\n" - ."**Single File\n" - ."php $argv[0] db dump /path/to/save/to ...: To dump the database.\n" - ."php $argv[0] db restore /path/to/restore/from ...: To restore the database.\n\n" - ."**Individual Table Files\n" - ."php $argv[0] all dump /path/to/save/to ...: To dump all tables.\n" - ."php $argv[0] all restore /path/to/restore/from ...: To restore all tables.\n\n" - ."**Three Tables (collections, binaries, parts)\n" - ."php $argv[0] test dump /path/to/save/to ...: To dump binaries and parts tables.\n" - ."php $argv[0] test restore /path/to/restore/from ...: To restore binaries and parts tables.\n\n" - ."**Individal Files - OUTFILE/INFILE - No schema\n" - ."**MySQL MUST have write permissions to this path\n" - ."php $argv[0] all outfile /path/to/save/to ...: To dump all tables, using OUTFILE.\n" - ."php $argv[0] all infile /path/to/restore/from ...: To restore all tables, using INFILE.\n\n"); + ."**Single File\n" + ."php $argv[0] db dump /path/to/save/to ...: To dump the database.\n" + ."php $argv[0] db restore /path/to/restore/from ...: To restore the database.\n\n" + ."**Individual Table Files\n" + ."php $argv[0] all dump /path/to/save/to ...: To dump all tables.\n" + ."php $argv[0] all restore /path/to/restore/from ...: To restore all tables.\n\n" + ."**Three Tables (collections, binaries, parts)\n" + ."php $argv[0] test dump /path/to/save/to ...: To dump binaries and parts tables.\n" + ."php $argv[0] test restore /path/to/restore/from ...: To restore binaries and parts tables.\n\n" + ."**Individal Files - OUTFILE/INFILE - No schema\n" + ."**MySQL MUST have write permissions to this path\n" + ."php $argv[0] all outfile /path/to/save/to ...: To dump all tables, using OUTFILE.\n" + ."php $argv[0] all infile /path/to/restore/from ...: To restore all tables, using INFILE.\n\n"); } if (file_exists('mysql-defaults.txt')) { diff --git a/misc/testing/DB/populate_nzb_guid.php b/misc/testing/DB/populate_nzb_guid.php index 95b4061ad..8fec6221c 100644 --- a/misc/testing/DB/populate_nzb_guid.php +++ b/misc/testing/DB/populate_nzb_guid.php @@ -1,6 +1,6 @@ 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")); + ."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) diff --git a/misc/testing/DB/rename_to_lower.php b/misc/testing/DB/rename_to_lower.php index 802d71153..d45534cfe 100644 --- a/misc/testing/DB/rename_to_lower.php +++ b/misc/testing/DB/rename_to_lower.php @@ -1,6 +1,6 @@ log->error("\nThis script renames all table columns to lowercase, it can be dangerous. Please BACKUP your database before running this script.\n" - ."php rename_to_lower.php true ...: To rename all table columns to lowercase.\n")); + ."php rename_to_lower.php true ...: To rename all table columns to lowercase.\n")); } echo $pdo->log->warning('This script renames all table colums to lowercase.'); diff --git a/misc/testing/DB/reset_postprocessing.php b/misc/testing/DB/reset_postprocessing.php index f9db7b68d..e5f54bd46 100755 --- a/misc/testing/DB/reset_postprocessing.php +++ b/misc/testing/DB/reset_postprocessing.php @@ -1,6 +1,6 @@ rowCount(); foreach ($qry as $releases) { $pdo->queryExec( - sprintf(' + sprintf( + ' UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, tv_episodes_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %d', - $releases['id'] - ) - ); + $releases['id'] + ) + ); $consoletools->overWritePrimary('Resetting Releases: '.$consoletools->percentString(++$affected, $total)); } } @@ -290,8 +291,10 @@ if (isset($argv[1]) && ($argv[1] === 'xxx' || $argv[1] === 'all')) { $total = $qry->rowCount(); foreach ($qry as $releases) { $pdo->queryExec('UPDATE releases SET xxxinfo_id = 0 WHERE id = '.$releases['id']); - $consoletools->overWritePrimary('Resetting XXX Releases: '.$consoletools->percentString(++$concount, - $total)); + $consoletools->overWritePrimary('Resetting XXX Releases: '.$consoletools->percentString( + ++$concount, + $total + )); } } echo ColorCLI::header(PHP_EOL.number_format($concount).' xxxinfo_IDs reset.'); @@ -323,25 +326,25 @@ if (isset($argv[1]) && ($argv[1] === 'nfos' || $argv[1] === 'all')) { if ($ran === false) { exit( - ColorCLI::error( - '\nThis script will reset postprocessing per category. It can also truncate the associated tables.' - .'\nTo reset only those that have previously failed, those without covers, samples, previews, etc. use the ' - .'second argument false.\n' - .'To reset even those previously post processed, use the second argument true.\n' - .'To truncate the associated table, use the third argument truncate.\n\n' - .'php reset_postprocessing.php consoles true ...: To reset all consoles.\n' - .'php reset_postprocessing.php games true ...: To reset all games.\n' - .'php reset_postprocessing.php movies true ...: To reset all movies.\n' - .'php reset_postprocessing.php music true ...: To reset all music.\n' - .'php reset_postprocessing.php misc true ...: To reset all misc.\n' - .'php reset_postprocessing.php tv true ...: To reset all tv.\n' - .'php reset_postprocessing.php anime true ...: To reset all anime.\n' - .'php reset_postprocessing.php books true ...: To reset all books.\n' - .'php reset_postprocessing.php xxx true ...: To reset all xxx.\n' - .'php reset_postprocessing.php nfos true ...: To reset all nfos.\n' - .'php reset_postprocessing.php all true ...: To reset everything.\n' - ) - ); + ColorCLI::error( + '\nThis script will reset postprocessing per category. It can also truncate the associated tables.' + .'\nTo reset only those that have previously failed, those without covers, samples, previews, etc. use the ' + .'second argument false.\n' + .'To reset even those previously post processed, use the second argument true.\n' + .'To truncate the associated table, use the third argument truncate.\n\n' + .'php reset_postprocessing.php consoles true ...: To reset all consoles.\n' + .'php reset_postprocessing.php games true ...: To reset all games.\n' + .'php reset_postprocessing.php movies true ...: To reset all movies.\n' + .'php reset_postprocessing.php music true ...: To reset all music.\n' + .'php reset_postprocessing.php misc true ...: To reset all misc.\n' + .'php reset_postprocessing.php tv true ...: To reset all tv.\n' + .'php reset_postprocessing.php anime true ...: To reset all anime.\n' + .'php reset_postprocessing.php books true ...: To reset all books.\n' + .'php reset_postprocessing.php xxx true ...: To reset all xxx.\n' + .'php reset_postprocessing.php nfos true ...: To reset all nfos.\n' + .'php reset_postprocessing.php all true ...: To reset everything.\n' + ) + ); } else { echo PHP_EOL; } diff --git a/misc/testing/DB/reset_truncate.php b/misc/testing/DB/reset_truncate.php index 71d614d88..4ee09fe82 100644 --- a/misc/testing/DB/reset_truncate.php +++ b/misc/testing/DB/reset_truncate.php @@ -1,6 +1,6 @@ queryDirect('DELETE FROM releases WHERE nzbstatus = 0'); echo $pdo->log->primary($delcount->rowCount().' releases had no nzb, deleted.'); } else { - exit($pdo->log->error("\nThis script removes releases with no NZBs, resets all groups, truncates or drops(tpg) \n" - ."article tables. All other releases are left alone.\n" - ."php $argv[0] [true, drop] ...: To reset all groups and truncate/drop the tables.\n" - ) - ); + exit($pdo->log->error( + "\nThis script removes releases with no NZBs, resets all groups, truncates or drops(tpg) \n" + ."article tables. All other releases are left alone.\n" + ."php $argv[0] [true, drop] ...: To reset all groups and truncate/drop the tables.\n" + ) + ); } diff --git a/misc/testing/DB/resetdb.php b/misc/testing/DB/resetdb.php index 257ea73c5..7726f0f69 100644 --- a/misc/testing/DB/resetdb.php +++ b/misc/testing/DB/resetdb.php @@ -1,6 +1,6 @@ . */ -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Users; diff --git a/misc/testing/DB/show_table_sizes.php b/misc/testing/DB/show_table_sizes.php index 0a93af47c..ed9735b91 100644 --- a/misc/testing/DB/show_table_sizes.php +++ b/misc/testing/DB/show_table_sizes.php @@ -1,6 +1,6 @@ log->error("\nThis script will show table data, index and free space used. The argument needed is numeric.\n\n" - ."php $argv[0] 1 ...: To show all tables with data + index space used greater than 1MB or free space greater than 1MB.\n" - ."php $argv[0] .01 ...: To show all tables with data + index space used greater than .01MB or free space greater than .01MB.\n")); + ."php $argv[0] 1 ...: To show all tables with data + index space used greater than 1MB or free space greater than 1MB.\n" + ."php $argv[0] .01 ...: To show all tables with data + index space used greater than .01MB or free space greater than .01MB.\n")); } passthru('clear'); $data = $index = $total = $free = 0; $table_data = "SELECT TABLE_NAME AS 'Table', TABLE_ROWS AS 'Rows', " - ."ENGINE AS 'engine', " - ."CREATE_OPTIONS AS 'format', " - ."((DATA_LENGTH) / POWER(1024,2)) AS 'data', " - ."((INDEX_LENGTH) / POWER(1024,2)) AS 'index', " - ."((DATA_FREE) / POWER(1024,2)) AS 'free', " - ."((DATA_LENGTH + INDEX_LENGTH) / POWER(1024,2)) AS 'total' " - ."FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '".env('DB_NAME')."' " - .'ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC'; + ."ENGINE AS 'engine', " + ."CREATE_OPTIONS AS 'format', " + ."((DATA_LENGTH) / POWER(1024,2)) AS 'data', " + ."((INDEX_LENGTH) / POWER(1024,2)) AS 'index', " + ."((DATA_FREE) / POWER(1024,2)) AS 'free', " + ."((DATA_LENGTH + INDEX_LENGTH) / POWER(1024,2)) AS 'total' " + ."FROM information_schema.TABLES WHERE information_schema.TABLES.table_schema = '".env('DB_NAME')."' " + .'ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC'; $run = $pdo->queryDirect($table_data); @@ -45,16 +45,16 @@ printf($mask, 'Table Name', 'Engine', 'Row_Format', 'Data Size', 'Index Size', ' printf($mask, '', '', '', number_format($data, 2).' MB', number_format($index, 2).' MB', number_format($free, 2).' MB', number_format($total, 2).' MB'); $myisam = $pdo->queryOneRow('SELECT CONCAT(ROUND(KBS/POWER(1024,IF(pw<0,0,IF(pw>3,0,pw)))+0.49999), ' - ."SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_key_buffer_size " - .'FROM (SELECT SUM(index_length) KBS ' - .'FROM information_schema.tables ' - ."WHERE engine='MyISAM' AND table_schema NOT IN ('information_schema','mysql')) A, (SELECT 3 pw) B;", false); + ."SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_key_buffer_size " + .'FROM (SELECT SUM(index_length) KBS ' + .'FROM information_schema.tables ' + ."WHERE engine='MyISAM' AND table_schema NOT IN ('information_schema','mysql')) A, (SELECT 3 pw) B;", false); $innodb = $pdo->queryOneRow('SELECT CONCAT(ROUND(KBS/POWER(1024,IF(pw<0,0,IF(pw>3,0,pw)))+0.49999), ' - ."SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_innodb_buffer_pool_size " - .'FROM (SELECT SUM(index_length) KBS ' - .'FROM information_schema.tables ' - ."WHERE engine='InnoDB') A,(SELECT 3 pw) B;", false); + ."SUBSTR(' KMG',IF(pw<0,0,IF(pw>3,0,pw))+1,1)) recommended_innodb_buffer_pool_size " + .'FROM (SELECT SUM(index_length) KBS ' + .'FROM information_schema.tables ' + ."WHERE engine='InnoDB') A,(SELECT 3 pw) B;", false); $a = $myisam['recommended_key_buffer_size']; if ($myisam['recommended_key_buffer_size'] === null) { diff --git a/misc/testing/Dev/clean_nzbs.php b/misc/testing/Dev/clean_nzbs.php index 9eba73194..5c7f8a38d 100644 --- a/misc/testing/Dev/clean_nzbs.php +++ b/misc/testing/Dev/clean_nzbs.php @@ -1,6 +1,6 @@ $nzbFile) { continue; } - $newFileName = $nzb->getNZBPath(str_replace('.nzb.gz', '', $nzbFile->getBasename()), - $newLevel, - true); + $newFileName = $nzb->getNZBPath( + str_replace('.nzb.gz', '', $nzbFile->getBasename()), + $newLevel, + true + ); if ($newFileName != $nzbFile) { rename($nzbFile, $newFileName); chmod($newFileName, 0777); diff --git a/misc/testing/PostProc/check_covers.php b/misc/testing/PostProc/check_covers.php index 86cdf7494..afb489d5f 100644 --- a/misc/testing/PostProc/check_covers.php +++ b/misc/testing/PostProc/check_covers.php @@ -3,7 +3,7 @@ // -------------------------------------------------------------- // Scan for releases missing previews on disk // -------------------------------------------------------------- -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Movie; @@ -55,9 +55,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { echo ColorCLI::header('Total releases missing covers that '.$couldbe.'their covers fixed = '.number_format($counterfixed)); } else { exit(ColorCLI::header("\nThis script checks if release covers actually exist on disk.\n\n" - ."Releases without covers may be reset for post-processing, thus regenerating them and related meta data.\n\n" - ."Useful for recovery after filesystem corruption, or as an alternative re-postprocessing tool.\n\n" - ."Optional LIMIT parameter restricts number of releases to be reset.\n\n" - ."php $argv[0] check [LIMIT] ...: Dry run, displays missing covers.\n" - ."php $argv[0] true [LIMIT] ...: Re-process releases missing covers.\n")); + ."Releases without covers may be reset for post-processing, thus regenerating them and related meta data.\n\n" + ."Useful for recovery after filesystem corruption, or as an alternative re-postprocessing tool.\n\n" + ."Optional LIMIT parameter restricts number of releases to be reset.\n\n" + ."php $argv[0] check [LIMIT] ...: Dry run, displays missing covers.\n" + ."php $argv[0] true [LIMIT] ...: Re-process releases missing covers.\n")); } diff --git a/misc/testing/PostProc/check_previews.php b/misc/testing/PostProc/check_previews.php index bf3f4ae6d..26380fc05 100644 --- a/misc/testing/PostProc/check_previews.php +++ b/misc/testing/PostProc/check_previews.php @@ -3,7 +3,7 @@ // -------------------------------------------------------------- // Scan for releases missing previews on disk // -------------------------------------------------------------- -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NZB; use nntmux\db\DB; @@ -43,7 +43,8 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { echo $pdo->log->warning('Missing preview '.$nzbpath); if ($argv[1] === 'true') { $pdo->queryExec( - sprintf('UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %s', $row['id'])); + sprintf('UPDATE releases SET consoleinfo_id = NULL, gamesinfo_id = 0, imdbid = NULL, musicinfo_id = NULL, bookinfo_id = NULL, videos_id = 0, xxxinfo_id = 0, passwordstatus = -1, haspreview = -1, jpgstatus = 0, videostatus = 0, audiostatus = 0, nfostatus = -1 WHERE id = %s', $row['id']) + ); } } @@ -55,9 +56,9 @@ if (isset($argv[1]) && ($argv[1] === 'true' || $argv[1] === 'check')) { echo $pdo->log->header('Total releases missing previews that '.$couldbe.'reset for reprocessing= '.number_format($counterfixed)); } else { exit($pdo->log->header("\nThis script checks if release previews actually exist on disk.\n\n" - ."Releases without previews may be reset for post-processing, thus regenerating them and related meta data.\n\n" - ."Useful for recovery after filesystem corruption, or as an alternative re-postprocessing tool.\n\n" - ."Optional LIMIT parameter restricts number of releases to be reset.\n\n" - ."php $argv[0] check [LIMIT] ...: Dry run, displays missing previews.\n" - ."php $argv[0] true [LIMIT] ...: Re-process releases missing previews.\n")); + ."Releases without previews may be reset for post-processing, thus regenerating them and related meta data.\n\n" + ."Useful for recovery after filesystem corruption, or as an alternative re-postprocessing tool.\n\n" + ."Optional LIMIT parameter restricts number of releases to be reset.\n\n" + ."php $argv[0] check [LIMIT] ...: Dry run, displays missing previews.\n" + ."php $argv[0] true [LIMIT] ...: Re-process releases missing previews.\n")); } diff --git a/misc/testing/PostProc/getConsole.php b/misc/testing/PostProc/getConsole.php index b2af8bdfa..54a37e60d 100644 --- a/misc/testing/PostProc/getConsole.php +++ b/misc/testing/PostProc/getConsole.php @@ -2,7 +2,7 @@ //This script will update all records in the consoleinfo table -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Console; @@ -13,12 +13,13 @@ $pdo = new DB(); $console = new Console(['Echo' => true, 'Settings' => $pdo]); $res = $pdo->queryDirect( - sprintf( - 'SELECT searchname, id FROM releases WHERE consoleinfo_id IS NULL AND categories_id + sprintf( + 'SELECT searchname, id FROM releases WHERE consoleinfo_id IS NULL AND categories_id BETWEEN %s AND %s ORDER BY id DESC', - Category::GAME_ROOT, - Category::GAME_OTHER - )); + Category::GAME_ROOT, + Category::GAME_OTHER + ) +); if ($res instanceof \Traversable) { echo $pdo->log->header('Updating console info for '.number_format($res->rowCount()).' releases.'); diff --git a/misc/testing/PostProc/getGameCovers.php b/misc/testing/PostProc/getGameCovers.php index 9d3ecf7b2..808181b1d 100644 --- a/misc/testing/PostProc/getGameCovers.php +++ b/misc/testing/PostProc/getGameCovers.php @@ -2,7 +2,7 @@ //This script will update all records in the gamesinfo table -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Games; diff --git a/misc/testing/PostProc/getImdb.php b/misc/testing/PostProc/getImdb.php index 14478819f..a1a97f2bf 100644 --- a/misc/testing/PostProc/getImdb.php +++ b/misc/testing/PostProc/getImdb.php @@ -1,7 +1,7 @@ log->header('Total releases missing samples that '.$couldbe.'their samples updated = '.number_format($counterfixed)); } else { exit($pdo->log->header("\nThis script checks if XXX release samples actually exist on disk.\n\n" - ."php $argv[0] check ...: Dry run, displays missing samples.\n" - ."php $argv[0] true ...: Update XXX releases missing samples.\n")); + ."php $argv[0] check ...: Dry run, displays missing samples.\n" + ."php $argv[0] true ...: Update XXX releases missing samples.\n")); } diff --git a/misc/testing/PostProc/updateBookImages.php b/misc/testing/PostProc/updateBookImages.php index 0f0cc986e..e37d046cb 100644 --- a/misc/testing/PostProc/updateBookImages.php +++ b/misc/testing/PostProc/updateBookImages.php @@ -1,6 +1,6 @@ queryExec('TRUNCATE TABLE predb_imports'); } else { exit($pdo->log->error("\nThis script can export or import a predb dump file. You may use the full path, or a relative path.\n" - ."For importing, the script insert new rows and update existing matched rows. For databases not on the local system, use remote, else use local.\n" - ."For exporting, the path must be writeable by mysql, any existing file[predb_dump.csv] will be + ."For importing, the script insert new rows and update existing matched rows. For databases not on the local system, use remote, else use local.\n" + ."For exporting, the path must be writeable by mysql, any existing file[predb_dump.csv] will be overwritten.\n\n" - ."php dump_predb.php export /path/to/write/to ...: To export.\n" - ."php dump_predb.php [remote | local] /path/to/filename ...: To import.\n")); + ."php dump_predb.php export /path/to/write/to ...: To export.\n" + ."php dump_predb.php [remote | local] /path/to/filename ...: To import.\n")); } diff --git a/misc/testing/Releases/delete_releases.php b/misc/testing/Releases/delete_releases.php index f4f5b2ad4..3c50091c4 100644 --- a/misc/testing/Releases/delete_releases.php +++ b/misc/testing/Releases/delete_releases.php @@ -1,6 +1,6 @@ queryExec( - sprintf(' + sprintf( + ' UPDATE releases SET iscategorized = 1, videos_id = 0, @@ -97,10 +98,10 @@ function categorizeRelease($where, $update = true, $echooutput = false) xxxinfo_id = 0, categories_id = %d WHERE id = %d', - $catId, - $rowrel['id'] - ) - ); + $catId, + $rowrel['id'] + ) + ); } $chgcount++; } diff --git a/misc/testing/Releases/removeCrapReleases.php b/misc/testing/Releases/removeCrapReleases.php index 6cd3a870b..7ad7f19ee 100755 --- a/misc/testing/Releases/removeCrapReleases.php +++ b/misc/testing/Releases/removeCrapReleases.php @@ -1,7 +1,7 @@ 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." - ) - ); + $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 | nzb | 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. - ' huge = Remove releases with single file with size of over 200 megabytes.'.$n. - ' nzb = Remove releases having 1 file that is an nzb file.'.$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 - ); + "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 | nzb | 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. + ' huge = Remove releases with single file with size of over 200 megabytes.'.$n. + ' nzb = Remove releases having 1 file that is an nzb file.'.$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")); } diff --git a/misc/testing/Tests/regexverify.php b/misc/testing/Tests/regexverify.php index d45e5d5ff..229cc9431 100644 --- a/misc/testing/Tests/regexverify.php +++ b/misc/testing/Tests/regexverify.php @@ -6,7 +6,7 @@ // // by l2g // -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Releases; diff --git a/misc/testing/Tests/test_amazon_API.php b/misc/testing/Tests/test_amazon_API.php index 09f6dd3db..37358e4d2 100644 --- a/misc/testing/Tests/test_amazon_API.php +++ b/misc/testing/Tests/test_amazon_API.php @@ -1,6 +1,6 @@ getMovieFanart((string) $argv[1]); diff --git a/misc/testing/Tests/test_giantbomb_API.php b/misc/testing/Tests/test_giantbomb_API.php index 83962f75f..46565a52a 100755 --- a/misc/testing/Tests/test_giantbomb_API.php +++ b/misc/testing/Tests/test_giantbomb_API.php @@ -1,6 +1,6 @@ search($searchgame, $fields, 1); $result = json_decode(json_encode($result), true); if ($result['number_of_total_results'] != 0) { diff --git a/misc/testing/Tests/test_nntp_server.php b/misc/testing/Tests/test_nntp_server.php index b5c9b57ed..d7303c9af 100755 --- a/misc/testing/Tests/test_nntp_server.php +++ b/misc/testing/Tests/test_nntp_server.php @@ -1,7 +1,7 @@ 0) { $seriesAppends = [ - 'networks' => $tmdb->client->getTvApi()->getTvshow($series['results'][0]['id'])['networks'], - 'alternative_titles' => $tmdb->client->getTvApi()->getAlternativeTitles($series['results'][0]['id']), - 'external_ids' => $tmdb->client->getTvApi()->getExternalIds($series['results'][0]['id']), - ]; + 'networks' => $tmdb->client->getTvApi()->getTvshow($series['results'][0]['id'])['networks'], + 'alternative_titles' => $tmdb->client->getTvApi()->getAlternativeTitles($series['results'][0]['id']), + 'external_ids' => $tmdb->client->getTvApi()->getExternalIds($series['results'][0]['id']), + ]; print_r($seriesAppends); if ($seriesAppends) { $series['results'][0]['networks'] = $seriesAppends['networks']; diff --git a/misc/testing/Tests/test_trakt_API.php b/misc/testing/Tests/test_trakt_API.php index e0844bc0e..4a56cb732 100755 --- a/misc/testing/Tests/test_trakt_API.php +++ b/misc/testing/Tests/test_trakt_API.php @@ -1,6 +1,6 @@ error('Invalid arguments. This script requires a text string (show name) followed by a season and episode number.'.PHP_EOL. - 'You can also optionally supply "YYYY" "MM" "DD" arguments instead of season/episode for an airdate lookup.') - ); + 'You can also optionally supply "YYYY" "MM" "DD" arguments instead of season/episode for an airdate lookup.') + ); } diff --git a/misc/testing/Tests/test_tvmaze_API.php b/misc/testing/Tests/test_tvmaze_API.php index 6a251b480..495c58f07 100755 --- a/misc/testing/Tests/test_tvmaze_API.php +++ b/misc/testing/Tests/test_tvmaze_API.php @@ -1,6 +1,6 @@ getPDO()); // Insert some data - $sql = sprintf(" + $sql = sprintf( + " INSERT INTO `testdata` (`id` ,`field1` ,`field2` ,`field3` ,`field4`) VALUES - ('%s', '%s', '%s', '%s', '%s')", $i, $i, $i, $i, $i + ('%s', '%s', '%s', '%s', '%s')", + $i, + $i, + $i, + $i, + $i ); $newDb->exec($sql); diff --git a/misc/testing/Various/renametopre.php b/misc/testing/Various/renametopre.php index 509affda4..647cc39cb 100644 --- a/misc/testing/Various/renametopre.php +++ b/misc/testing/Various/renametopre.php @@ -1,7 +1,7 @@ log->error( - "\nThis script will attempt to rename releases using regexes first from ReleaseCleaning.php and then from this file.\n" - ."An optional last argument, show, will display the release name changes.\n\n" - ."php $argv[0] full ...: To process all releases not previously renamed.\n" - ."php $argv[0] 2 ...: To process all releases added in the previous 2 hours not previously renamed.\n" - ."php $argv[0] all ...: To process all releases.\n" - ."php $argv[0] full 155 ...: To process all releases in groupid 155 not previously renamed.\n" - ."php $argv[0] all 155 ...: To process all releases in groupid 155.\n" - ."php $argv[0] all '(155, 140)' ...: To process all releases in group_ids 155 and 140.\n" - ."php $argv[0] predb_id ...: To process all releases where not matched to predb.\n" - )); + "\nThis script will attempt to rename releases using regexes first from ReleaseCleaning.php and then from this file.\n" + ."An optional last argument, show, will display the release name changes.\n\n" + ."php $argv[0] full ...: To process all releases not previously renamed.\n" + ."php $argv[0] 2 ...: To process all releases added in the previous 2 hours not previously renamed.\n" + ."php $argv[0] all ...: To process all releases.\n" + ."php $argv[0] full 155 ...: To process all releases in groupid 155 not previously renamed.\n" + ."php $argv[0] all 155 ...: To process all releases in groupid 155.\n" + ."php $argv[0] all '(155, 140)' ...: To process all releases in group_ids 155 and 140.\n" + ."php $argv[0] predb_id ...: To process all releases where not matched to predb.\n" + )); } preName($argv, $argc); @@ -95,9 +95,9 @@ function preName($argv, $argc) } resetSearchnames(); echo $pdo->log->header( - 'SELECT id, name, searchname, fromname, size, groups_id, categories_id FROM releases'.$why.$what. - $where.";\n" - ); + 'SELECT id, name, searchname, fromname, size, groups_id, categories_id FROM releases'.$why.$what. + $where.";\n" + ); $res = $pdo->queryDirect('SELECT id, name, searchname, fromname, size, groups_id, categories_id FROM releases'.$why.$what.$where); $total = $res->rowCount(); if ($total > 0) { @@ -135,10 +135,11 @@ function preName($argv, $argc) $files = $rf->get($row['id']); foreach ($files as $f) { if (preg_match( - '/^(?P.+?)(\\[\w\[\]\(\). -]+)?\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', $f['name'], - $match - ) - ) { + '/^(?P<title>.+?)(\\[\w\[\]\(\). -]+)?\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', + $f['name'], + $match + ) + ) { $cleanName = $match['title']; break; } @@ -159,18 +160,24 @@ function preName($argv, $argc) $determinedcat = $category->determineCategory($row['groups_id'], $cleanName); if ($propername == true) { $pdo->queryExec( - sprintf( - 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' - .'iscategorized = 1, isrenamed = 1, searchname = %s, categories_id = %d, predb_id = '.$preid.' WHERE id = %d', $pdo->escapeString($cleanName), $determinedcat, $row['id'] - ) - ); + sprintf( + 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' + .'iscategorized = 1, isrenamed = 1, searchname = %s, categories_id = %d, predb_id = '.$preid.' WHERE id = %d', + $pdo->escapeString($cleanName), + $determinedcat, + $row['id'] + ) + ); } else { $pdo->queryExec( - sprintf( - 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' - .'iscategorized = 1, searchname = %s, categories_id = %d, predb_id = '.$preid.' WHERE id = %d', $pdo->escapeString($cleanName), $determinedcat, $row['id'] - ) - ); + sprintf( + 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' + .'iscategorized = 1, searchname = %s, categories_id = %d, predb_id = '.$preid.' WHERE id = %d', + $pdo->escapeString($cleanName), + $determinedcat, + $row['id'] + ) + ); } if ($increment === true) { $internal++; @@ -185,16 +192,17 @@ function preName($argv, $argc) $oldcatname = $category->getNameByID($row['categories_id']); $newcatname = $category->getNameByID($determinedcat); - NameFixer::echoChangedReleaseName([ - 'new_name' => $cleanName, - 'old_name' => $row['searchname'], - 'new_category' => $newcatname, - 'old_category' => $oldcatname, - 'group' => $groupname, - 'releases_id' => $row['id'], - 'method' => 'misc/testing/Various/renametopre.php', - ] - ); + NameFixer::echoChangedReleaseName( + [ + 'new_name' => $cleanName, + 'old_name' => $row['searchname'], + 'new_category' => $newcatname, + 'old_category' => $oldcatname, + 'group' => $groupname, + 'releases_id' => $row['id'], + 'method' => 'misc/testing/Various/renametopre.php', + ] + ); } } } elseif ($show === 3 && preg_match('/^\[?\d*\].+?yEnc/i', $row['name'])) { @@ -252,18 +260,18 @@ function resetSearchnames() global $pdo; echo $pdo->log->header('Resetting blank searchnames.'); $bad = $pdo->queryDirect( - 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' - ."predb_id = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''" - ); + 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' + ."predb_id = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''" + ); $tot = $bad->rowCount(); if ($tot > 0) { echo $pdo->log->primary(number_format($tot).' Releases had no searchname.'); } echo $pdo->log->header('Resetting searchnames that are 8 characters or less.'); $run = $pdo->queryDirect( - 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' - .'predb_id = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8' - ); + 'UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, bookinfo_id = NULL, anidbid = NULL, ' + .'predb_id = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8' + ); $total = $run->rowCount(); if ($total > 0) { echo $pdo->log->primary(number_format($total).' Releases had searchnames that were 8 characters or less.'); diff --git a/misc/testing/_run_once/tpg_delete_triggers_2015-08-14.php b/misc/testing/_run_once/tpg_delete_triggers_2015-08-14.php index 55dc232b9..412ce14a5 100644 --- a/misc/testing/_run_once/tpg_delete_triggers_2015-08-14.php +++ b/misc/testing/_run_once/tpg_delete_triggers_2015-08-14.php @@ -18,7 +18,7 @@ * @author niel * @copyright 2014 nZEDb */ -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use App\Models\Settings; diff --git a/misc/testing/_run_once/tpg_fixes.php b/misc/testing/_run_once/tpg_fixes.php index ab676020e..c8452d605 100644 --- a/misc/testing/_run_once/tpg_fixes.php +++ b/misc/testing/_run_once/tpg_fixes.php @@ -20,11 +20,11 @@ */ if (! isset($argv[1]) || ! in_array($argv[1], ['1'])) { exit( - 'Options: (enter a number, it\'s not recommended to rerun the same fix)'.PHP_EOL. - '1: 2014-07-28: Add unique key to binaryhash to be able to do multiple updates in 1 statement.'.PHP_EOL - ); + 'Options: (enter a number, it\'s not recommended to rerun the same fix)'.PHP_EOL. + '1: 2014-07-28: Add unique key to binaryhash to be able to do multiple updates in 1 statement.'.PHP_EOL + ); } -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use App\Models\Settings; @@ -43,15 +43,15 @@ if ($groups === false) { $queries = []; switch ($argv[1]) { - case 1: - // Drop this index, as we will recreate it as a unique. - $queries[] = ['t' => 1, 'q' => 'ALTER TABLE binaries_%d DROP INDEX ix_binary_binaryhash']; - // Recreate the index as unique so we can use on duplicate key update, saving select / update query. - $queries[] = ['t' => 1, 'q' => 'ALTER IGNORE TABLE binaries_%d ADD UNIQUE INDEX ix_binary_binaryhash(binaryhash)']; - break; - default: - exit(); - } + case 1: + // Drop this index, as we will recreate it as a unique. + $queries[] = ['t' => 1, 'q' => 'ALTER TABLE binaries_%d DROP INDEX ix_binary_binaryhash']; + // Recreate the index as unique so we can use on duplicate key update, saving select / update query. + $queries[] = ['t' => 1, 'q' => 'ALTER IGNORE TABLE binaries_%d ADD UNIQUE INDEX ix_binary_binaryhash(binaryhash)']; + break; + default: + exit(); + } $groupCount = $groups->rowCount(); if ($groups instanceof \Traversable && count($queries) && $groupCount) { @@ -59,19 +59,19 @@ if ($groups === false) { echo 'Fixing group '.$group['id'].PHP_EOL; foreach ($queries as $query) { switch ($query['t']) { - // Queries needing 1 group id. - case 1: - $pdo->queryExec(sprintf($query['q'], $group['id']), true); - break; - // Queries needing 2 group IDs. - case 2: - $pdo->queryExec(sprintf($query['q'], $group['id'], $group['id']), true); - break; - // Queries needing 3 group IDs. - case 3: - $pdo->queryExec(sprintf($query['q'], $group['id'], $group['id'], $group['id']), true); - break; - } + // Queries needing 1 group id. + case 1: + $pdo->queryExec(sprintf($query['q'], $group['id']), true); + break; + // Queries needing 2 group IDs. + case 2: + $pdo->queryExec(sprintf($query['q'], $group['id'], $group['id']), true); + break; + // Queries needing 3 group IDs. + case 3: + $pdo->queryExec(sprintf($query['q'], $group['id'], $group['id'], $group['id']), true); + break; + } } echo 'Finished fixing group '.$group['id'].', '.(--$groupCount).' to go!'.PHP_EOL; } diff --git a/misc/testing/_run_once/tpg_update_triggers_2014-09-25.php b/misc/testing/_run_once/tpg_update_triggers_2014-09-25.php index af1059b5f..f12536891 100644 --- a/misc/testing/_run_once/tpg_update_triggers_2014-09-25.php +++ b/misc/testing/_run_once/tpg_update_triggers_2014-09-25.php @@ -18,7 +18,7 @@ * @author niel * @copyright 2014 nZEDb */ -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use App\Models\Settings; @@ -42,12 +42,16 @@ if ($tables instanceof \Traversable) { echo "Updating table binaries{$table['suffix']}".PHP_EOL; $pdo->queryExec(sprintf($query1, $table['suffix']), true); $pdo->queryExec(sprintf($query2, $table['suffix']), true); - $pdo->queryExec(sprintf($query3, - $table['suffix'], - $table['suffix'], - $table['suffix'], - $table['suffix']), - true); + $pdo->queryExec( + sprintf( + $query3, + $table['suffix'], + $table['suffix'], + $table['suffix'], + $table['suffix'] + ), + true + ); $pdo->queryExec(sprintf($query4, $table['suffix']), true); } echo 'All done!'.PHP_EOL; diff --git a/misc/testing/dumpnfo.php b/misc/testing/dumpnfo.php index bf2df47b7..e00445ae1 100644 --- a/misc/testing/dumpnfo.php +++ b/misc/testing/dumpnfo.php @@ -5,7 +5,7 @@ // Its not very efficient to pull them all out, should really work out which day you need and go from there. // -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\utility\Utility; diff --git a/misc/testing/fix_filesize.php b/misc/testing/fix_filesize.php index 4cda0a43f..543001b53 100644 --- a/misc/testing/fix_filesize.php +++ b/misc/testing/fix_filesize.php @@ -6,7 +6,7 @@ If after import you have a bunch of zero sized releases run this Author: lordgnu <lordgnu@me.com> */ -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NZB; use nntmux\db\DB; diff --git a/misc/testing/nzb-export.php b/misc/testing/nzb-export.php index b4113be38..ea37895d6 100644 --- a/misc/testing/nzb-export.php +++ b/misc/testing/nzb-export.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NZBExport; @@ -9,32 +9,32 @@ $n = PHP_EOL; // Print usage. if (count($argv) !== 6) { exit( - 'This will export NZB files(to .nzb or .nzb.gz) into sub folders (using group name) of the specified folder.'.$n.$n. - 'Usage: '.$n. - $_SERVER['_'].' '.__FILE__.' arg1 arg2 arg3 arg4 arg5'.$n.$n. - 'arg1 : Path to folder where NZB files are to be stored. | a folder path'.$n. - 'arg2 : The start date in this format: 01/01/2008 or false | date/false'.$n. - 'arg3 : The end date in this format: 01/01/2008 or false | date/false'.$n. - 'arg4 : Group ID for the group or false | number/false'.$n. - 'arg5 : Gzip the NZB files (recommended, faster/takes less space) | true/false'.$n.$n. - 'Examples: '.$n. - $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' 01/01/2012 01/01/2014 false true'.$n. - $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' false 01/01/2014 12 false'.$n - ); + 'This will export NZB files(to .nzb or .nzb.gz) into sub folders (using group name) of the specified folder.'.$n.$n. + 'Usage: '.$n. + $_SERVER['_'].' '.__FILE__.' arg1 arg2 arg3 arg4 arg5'.$n.$n. + 'arg1 : Path to folder where NZB files are to be stored. | a folder path'.$n. + 'arg2 : The start date in this format: 01/01/2008 or false | date/false'.$n. + 'arg3 : The end date in this format: 01/01/2008 or false | date/false'.$n. + 'arg4 : Group ID for the group or false | number/false'.$n. + 'arg5 : Gzip the NZB files (recommended, faster/takes less space) | true/false'.$n.$n. + 'Examples: '.$n. + $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' 01/01/2012 01/01/2014 false true'.$n. + $_SERVER['_'].' '.$argv[0].' '.NN_ROOT.'exportFolder'.DS.' false 01/01/2014 12 false'.$n + ); } $NE = new NZBExport(); $NE->beginExport( - [ - // Path. - $argv[1], - // Start time. - (strtolower($argv[2]) === 'false' ? '' : $argv[2]), - // End time. - (strtolower($argv[3]) === 'false' ? '' : $argv[3]), - // Group ID. - (strtolower($argv[4]) === 'false' ? 0 : (int) $argv[4]), - // Gzip. - (strtolower($argv[5]) === 'true' ? true : false), - ] + [ + // Path. + $argv[1], + // Start time. + (strtolower($argv[2]) === 'false' ? '' : $argv[2]), + // End time. + (strtolower($argv[3]) === 'false' ? '' : $argv[3]), + // Group ID. + (strtolower($argv[4]) === 'false' ? 0 : (int) $argv[4]), + // Gzip. + (strtolower($argv[5]) === 'true' ? true : false), + ] ); diff --git a/misc/testing/nzb-import.php b/misc/testing/nzb-import.php index 96960771d..7c5d79d51 100644 --- a/misc/testing/nzb-import.php +++ b/misc/testing/nzb-import.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NZBImport; diff --git a/misc/testing/refreshMovie.php b/misc/testing/refreshMovie.php index 1d7c71a28..2b7cad32f 100644 --- a/misc/testing/refreshMovie.php +++ b/misc/testing/refreshMovie.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Movie; diff --git a/misc/testing/spotnab.php b/misc/testing/spotnab.php index fac4de677..bc3e5b316 100644 --- a/misc/testing/spotnab.php +++ b/misc/testing/spotnab.php @@ -107,73 +107,73 @@ Both posting and fetching will 'NOT' work unless you've generated Global Release ID values for all of your current releases... this is done by running the command: - #> php spotnab.php -g + #> php spotnab.php -g POSTING - 1. To run all of the SQL statements identifed above + 1. To run all of the SQL statements identifed above - 2. You 'must' have all Global Release ID's defined for each - release or the comments associated with it will not be - included in the post. + 2. You 'must' have all Global Release ID's defined for each + release or the comments associated with it will not be + included in the post. - 3. Generate yourself your own set of SSL keys: - #> php spotnab.php -k + 3. Generate yourself your own set of SSL keys: + #> php spotnab.php -k - 4. At this point your ready to post... If you run the following SQL - statement, you'll mark all your existing comments: + 4. At this point your ready to post... If you run the following SQL + statement, you'll mark all your existing comments: - -- Ensure spotnab posting is enabled: - UPDATE `site` set `value` = '1' WHERE `setting` = 'spotnabpost'; + -- Ensure spotnab posting is enabled: + UPDATE `site` set `value` = '1' WHERE `setting` = 'spotnabpost'; - -- Posting actually uses this date as a reference to when - -- it last posted. So set it to a date so far back in time - -- that all your existing comments become declared as unposted. + -- Posting actually uses this date as a reference to when + -- it last posted. So set it to a date so far back in time + -- that all your existing comments become declared as unposted. - UPDATE `site` set `updateddate` = '1980-01-01 00:00:00' - WHERE `setting` = 'spotnabpost' AND `value` = '1'; + UPDATE `site` set `updateddate` = '1980-01-01 00:00:00' + WHERE `setting` = 'spotnabpost' AND `value` = '1'; FETCHING - 1. You need to acquire and enable sources. A source is as simple - as someone providing you their public key they generated using - the --keygen (-k) switch. + 1. You need to acquire and enable sources. A source is as simple + as someone providing you their public key they generated using + the --keygen (-k) switch. - 2. Fetch releases: - #> php spotnab.php -f + 2. Fetch releases: + #> php spotnab.php -f - 3. Consider fetching your own posts back just to test things out...: + 3. Consider fetching your own posts back just to test things out...: - SET @key := (SELECT value FROM settings WHERE setting = 'spotnabsitepubkey'); - INSERT INTO `spotnabsources` (`ID` , `username`, `useremail` , - `usenetgroup`, `publickey` , `active` , - `description` , `lastupdate` ) - VALUES ( NULL , 'nntp', 'spot@nntp.com', 'alt.binaries.backup', @key, - '1', '1', 'My Key Fetch Test', NULL); + SET @key := (SELECT value FROM settings WHERE setting = 'spotnabsitepubkey'); + INSERT INTO `spotnabsources` (`ID` , `username`, `useremail` , + `usenetgroup`, `publickey` , `active` , + `description` , `lastupdate` ) + VALUES ( NULL , 'nntp', 'spot@nntp.com', 'alt.binaries.backup', @key, + '1', '1', 'My Key Fetch Test', NULL); - Then you can run the fetch release command again to poll for - stuff you posted already (if you did). + Then you can run the fetch release command again to poll for + stuff you posted already (if you did). - #> php spotnab.php -f + #> php spotnab.php -f SHARING - 1. Use the -k switch on the tool to retrieve your public key... - share it... let people use the comments posted on your site - get them to do the same to you. Eliminating crappy content - couldn't be more easy. + 1. Use the -k switch on the tool to retrieve your public key... + share it... let people use the comments posted on your site + get them to do the same to you. Eliminating crappy content + couldn't be more easy. - Spotnab now has a built in feature to post a discovery message - for others to grab automatically. Just call: - #> php spotnab.php -b + Spotnab now has a built in feature to post a discovery message + for others to grab automatically. Just call: + #> php spotnab.php -b - You can also fetch messages from those who have already - posted their own discovery message by calling: - #> php spotnab.php -d + You can also fetch messages from those who have already + posted their own discovery message by calling: + #> php spotnab.php -d - Just note that anything auto-discovered is disabled by default - so you need to go into your options and 'enable' it if you - recognize or want to test out the source. + Just note that anything auto-discovered is disabled by default + so you need to go into your options and 'enable' it if you + recognize or want to test out the source. */ -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\SpotNab; @@ -197,18 +197,18 @@ $shortopts .= 'b'; $shortopts .= 'F::'; $longopts = [ - 'post', - 'fetch', - 'fetch-backfill::', - 'discover', - 'broadcast', - 'test', - 'populate-gid', - 'populate-fix-gid', - 'soft-reset', - 'keygen', - 'force-keygen', - 'clean-orphan-comments', + 'post', + 'fetch', + 'fetch-backfill::', + 'discover', + 'broadcast', + 'test', + 'populate-gid', + 'populate-fix-gid', + 'soft-reset', + 'keygen', + 'force-keygen', + 'clean-orphan-comments', ]; $options = getopt($shortopts, $longopts); @@ -221,39 +221,39 @@ function display_help() echo "\n"; echo "Actions:\n"; echo ' -g, --populate-gid This could be considered phase one of ' - ."this project.\n"; + ."this project.\n"; echo ' requiring that your releases database' - ." table is up to date\n"; + ." table is up to date\n"; echo ' with all GID (Global Identifiers) so' - ." it can correctly\n"; + ." it can correctly\n"; echo ' communicate with other servers that ' - ."share the same content\n"; + ."share the same content\n"; echo " from the servers configured.\n"; echo ' -G, --populate-fix-gid Same as -g except broken nzb files are ' - ."also broken releases.\n"; + ."also broken releases.\n"; echo ' Specifying this switch will remove ' - ."these dead releses.\n"; + ."these dead releses.\n"; echo ' -f, --fetch Get latest spotnab comments from ' - ."usenet using the information\n"; + ."usenet using the information\n"; echo "\n"; echo " -F=DAYS\n"; echo ' --fetch-backfill=DAYS Get latest spotnab comments as far back' - ." as the days specified.\n"; + ." as the days specified.\n"; echo "\n"; echo ' -p, --post Post latest updates from local system ' - ."to usenet.\n"; + ."to usenet.\n"; echo "\n"; echo ' -k, --keygen Generate a new SSL Public/Private Key ' - ."pair only if one isn't\n"; + ."pair only if one isn't\n"; echo " already generated.\n"; echo ' -K, --force-keygen Generate a new SSL Public/Private Key ' - ."pair\n"; + ."pair\n"; echo "\n"; echo " -d, --discover Attempt to discovery all sources available.\n"; echo "\n"; echo " -o, --clean-orphan-comments\n"; echo ' Eliminate all fetched comments that you do not have a' - ." release\n"; + ." release\n"; echo " associated with.\n"; echo "\n"; echo " -b, --broadcast Broadast information for others so they can discover.\n"; @@ -262,7 +262,7 @@ function display_help() echo " just added. This is ideal to do if you\n"; echo " change usenet servers.\n"; echo ' -t, --test Produces a whole lot of garbage, but ' - ."is used for testing\n"; + ."is used for testing\n"; echo " the internals of the class...\n"; echo "\n"; } @@ -278,7 +278,7 @@ if (! count($options)) { $delete_broken_releases = false; if (array_key_exists('G', $options) || - array_key_exists('populate-fix-gid', $options)) { + array_key_exists('populate-fix-gid', $options)) { echo 'Updating GID in releases table + fix ...'; $spotnab = new SpotNab(); $spotnab->processGID(0, 5000, true); @@ -286,7 +286,7 @@ if (array_key_exists('G', $options) || } if (array_key_exists('g', $options) || - array_key_exists('populate-gid', $options)) { + array_key_exists('populate-gid', $options)) { echo 'Updating GID in releases table ...'; $spotnab = new SpotNab(); $spotnab->processGID(); @@ -294,7 +294,7 @@ if (array_key_exists('g', $options) || } if (array_key_exists('r', $options) || - array_key_exists('soft-reset', $options)) { + array_key_exists('soft-reset', $options)) { echo 'Soft Reseting Spotnab... '; $spotnab = new SpotNab(); $spotnab->soft_reset(); @@ -303,17 +303,17 @@ if (array_key_exists('r', $options) || $force_keygen_save = false; if (array_key_exists('K', $options) || - array_key_exists('force-keygen', $options)) { + array_key_exists('force-keygen', $options)) { $spotnab = new SpotNab(); $spotnab->keygen(true, true); } elseif (array_key_exists('k', $options) || - array_key_exists('keygen', $options)) { + array_key_exists('keygen', $options)) { $spotnab = new SpotNab(); $spotnab->keygen(true); } if (array_key_exists('p', $options) || - array_key_exists('post', $options)) { + array_key_exists('post', $options)) { echo 'Posting... '; $spotnab = new SpotNab(); $spotnab->post(); @@ -321,7 +321,7 @@ if (array_key_exists('p', $options) || } if (array_key_exists('d', $options) || - array_key_exists('discover', $options)) { + array_key_exists('discover', $options)) { echo 'Discovering... '; $spotnab = new SpotNab(); $spotnab->fetch_discovery(); @@ -329,7 +329,7 @@ if (array_key_exists('d', $options) || } if (array_key_exists('F', $options) || - array_key_exists('fetch-backfill', $options)) { + array_key_exists('fetch-backfill', $options)) { $days = array_key_exists('F', $options) ? $options['F'] : $options['fetch-backfill']; try { $days = abs(intval($days)); @@ -347,7 +347,7 @@ if (array_key_exists('F', $options) || $spotnab->fetch(time() - ($days * 86400)); echo "Done\n"; } elseif (array_key_exists('f', $options) || - array_key_exists('fetch', $options)) { + array_key_exists('fetch', $options)) { echo 'Fetching... '; $spotnab = new SpotNab(); $spotnab->fetch(); @@ -355,7 +355,7 @@ if (array_key_exists('F', $options) || } if (array_key_exists('b', $options) || - array_key_exists('broadcast', $options)) { + array_key_exists('broadcast', $options)) { echo 'Broadcasting... '; $spotnab = new SpotNab(); $spotnab->post_discovery(); @@ -363,16 +363,18 @@ if (array_key_exists('b', $options) || } if (array_key_exists('t', $options) || - array_key_exists('test', $options)) { + array_key_exists('test', $options)) { $spotnab = new SpotNab(); if ($spotnab->has_openssl()) { - printf('%s INFO - Testing SSL Key Generator ...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing SSL Key Generator ...', + date('Y-m-d H:i:s') + ); $keys = $spotnab->keygen(false); if (is_array($keys) && - array_key_exists('pubkey', $keys) && - array_key_exists('prvkey', $keys)) { + array_key_exists('pubkey', $keys) && + array_key_exists('prvkey', $keys)) { $prvkey = $spotnab->decompstr($keys['prvkey']); $pubkey = $spotnab->decompstr($keys['pubkey']); $refc = $spotnab->getRandomStr(80); @@ -382,8 +384,10 @@ if (array_key_exists('t', $options) || echo "Failed!\n"; } - printf('%s INFO - Testing SSL encryption/decryption ...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing SSL encryption/decryption ...', + date('Y-m-d H:i:s') + ); $preMsg = $spotnab->getRandomStr(800); $postMsg = $spotnab->decrypt($spotnab->encrypt($preMsg)); if ($postMsg === false) { @@ -394,33 +398,35 @@ if (array_key_exists('t', $options) || echo "Failed!\n"; } - printf('%s INFO - Testing small message encode/decode ...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing small message encode/decode ...', + date('Y-m-d H:i:s') + ); $before = [ - 'server' => [ - 'code' => 'l2g', - 'title' => 'l2g newznab', - ], - 'postdate_utc' => $spotnab->local2utc(), - 'comments' => [ - [ - 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'comment' => 'testing comment 1', - 'username' => 'l2g', - 'is_visible' => 1, - 'postdate_utc' => $spotnab->local2utc(time() - 86400), - ], - [ - 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'username' => 'l2g-hater', - 'is_visible' => 1, - 'comment' => 'testing comment 2', - 'postdate_utc' => $spotnab->local2utc(time() - 86000), - ], - ], - ]; + 'server' => [ + 'code' => 'l2g', + 'title' => 'l2g newznab', + ], + 'postdate_utc' => $spotnab->local2utc(), + 'comments' => [ + [ + 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'comment' => 'testing comment 1', + 'username' => 'l2g', + 'is_visible' => 1, + 'postdate_utc' => $spotnab->local2utc(time() - 86400), + ], + [ + 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'username' => 'l2g-hater', + 'is_visible' => 1, + 'comment' => 'testing comment 2', + 'postdate_utc' => $spotnab->local2utc(time() - 86000), + ], + ], + ]; $article = $spotnab->encodePost($before, null, true); if ($article !== false) { $after = $spotnab->decodePost($article[1]); @@ -432,26 +438,28 @@ if (array_key_exists('t', $options) || } else { echo "Failed!\n"; } - printf('%s INFO - Testing big message encode/decode ...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing big message encode/decode ...', + date('Y-m-d H:i:s') + ); $before = [ - 'server' => [ - 'code' => 'l2g', - 'title' => 'l2g newznab', - ], - 'postdate_utc' => $spotnab->local2utc(), - 'comments' => [], - ]; + 'server' => [ + 'code' => 'l2g', + 'title' => 'l2g newznab', + ], + 'postdate_utc' => $spotnab->local2utc(), + 'comments' => [], + ]; for ($i = 0; $i < 3000; $i++) { // Build large post $before['comments'][] = [ - 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', - 'comment' => $refc = $spotnab->getRandomStr(rand(15, 200)), - 'username' => 'bb', - 'is_visible' => 1, - 'postdate_utc' => $spotnab->local2utc(time() - 86400), - ]; + 'gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', + 'comment' => $refc = $spotnab->getRandomStr(rand(15, 200)), + 'username' => 'bb', + 'is_visible' => 1, + 'postdate_utc' => $spotnab->local2utc(time() - 86400), + ]; } $article = $spotnab->encodePost($before, null, true); if ($article !== false) { @@ -465,19 +473,21 @@ if (array_key_exists('t', $options) || echo "Failed!\n"; } - printf('%s INFO - Testing fake usenet parse ...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing fake usenet parse ...', + date('Y-m-d H:i:s') + ); // Fake group hash table $hash = [[ - 'ID' => 0, - 'key' => $spotnab->decompstr($keys['pubkey']), - 'user' => 'nntp', - 'email' => 'spot@nntp.com', - // We want to find new content, so to make our header - // new, we need to take our ref time and back down - // one second so it can be processed.. - 'ref' => $article[2]['Epoch'] - 1, - ]]; + 'ID' => 0, + 'key' => $spotnab->decompstr($keys['pubkey']), + 'user' => 'nntp', + 'email' => 'spot@nntp.com', + // We want to find new content, so to make our header + // new, we need to take our ref time and back down + // one second so it can be processed.. + 'ref' => $article[2]['Epoch'] - 1, + ]]; // Fake headers (use debug information from encodePost) $headers = [$article[2]]; @@ -491,44 +501,58 @@ if (array_key_exists('t', $options) || echo "Failed\n"; } } else { - printf("%s WARNING - openssl is not correctly installed; broadcasts and posts will be disabled.\n", - date('Y-m-d H:i:s')); + printf( + "%s WARNING - openssl is not correctly installed; broadcasts and posts will be disabled.\n", + date('Y-m-d H:i:s') + ); } - printf('%s INFO - Testing UTC/Local conversions [1/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [1/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->utc2local(); $refb = $spotnab->utc2local($spotnab->local2utc($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; - printf('%s INFO - Testing UTC/Local conversions [2/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [2/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->local2utc(); $refb = $spotnab->local2utc($spotnab->utc2local($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; - printf('%s INFO - Testing UTC/Local conversions [3/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [3/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->local2utc(date('Y-m-d H:i:s')); $refb = $spotnab->local2utc($spotnab->utc2local($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; - printf('%s INFO - Testing UTC/Local conversions [4/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [4/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->utc2local(time()); $refb = $spotnab->utc2local($spotnab->local2utc($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; - printf('%s INFO - Testing UTC/Local conversions [5/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [5/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->local2utc(time()); $refb = $spotnab->local2utc($spotnab->utc2local($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; - printf('%s INFO - Testing UTC/Local conversions [6/6]...', - date('Y-m-d H:i:s')); + printf( + '%s INFO - Testing UTC/Local conversions [6/6]...', + date('Y-m-d H:i:s') + ); $refa = $spotnab->utc2local(gmdate('Y-m-d H:i:s')); $refb = $spotnab->utc2local($spotnab->local2utc($refa)); echo ($refa == $refb) ? "Successful!\n" : "Failed!\n"; } if (array_key_exists('o', $options) || - array_key_exists('clean-orphan-comments', $options)) { + array_key_exists('clean-orphan-comments', $options)) { echo 'Removing orphan comments...'; $spotnab = new SpotNab(); printf("%d record(s) removed.\n", $spotnab->orphan_comment_clean()); diff --git a/misc/testing/tidynzbfolder.php b/misc/testing/tidynzbfolder.php index 5808fe8e9..a88136269 100644 --- a/misc/testing/tidynzbfolder.php +++ b/misc/testing/tidynzbfolder.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\Releases; diff --git a/misc/update/backfill.php b/misc/update/backfill.php index e8ac92b08..21e745c71 100644 --- a/misc/update/backfill.php +++ b/misc/update/backfill.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NNTP; use nntmux\db\DB; @@ -34,11 +34,11 @@ if (isset($argv[1]) && $argv[1] === 'all' && ! isset($argv[2])) { $backfill->safeBackfill($argv[2]); } else { exit(\nntmux\ColorCLI::error("\nWrong set of arguments.\n" - .'php backfill.php safe 200000 ...: Backfill an active group alphabetically, x articles, the script stops,'."\n" - .' ...: if the group has reached reached 2012-06-24, the next group will backfill.'."\n" - .'php backfill.php alph 200000 ...: Backfills all groups (sorted alphabetically) by number of articles'."\n" - .'php backfill.php date 200000 ...: Backfills all groups (sorted by least backfilled in time) by number of articles'."\n" - .'php backfill.php alt.binaries.ath 200000 ...: Backfills a group by name by number of articles'."\n" - .'php backfill.php all ...: Backfills all groups 1 at a time, by date (set in admin-view groups)'."\n" - .'php backfill.php alt.binaries.ath ...: Backfills a group by name, by date (set in admin-view groups)'."\n")); + .'php backfill.php safe 200000 ...: Backfill an active group alphabetically, x articles, the script stops,'."\n" + .' ...: if the group has reached reached 2012-06-24, the next group will backfill.'."\n" + .'php backfill.php alph 200000 ...: Backfills all groups (sorted alphabetically) by number of articles'."\n" + .'php backfill.php date 200000 ...: Backfills all groups (sorted by least backfilled in time) by number of articles'."\n" + .'php backfill.php alt.binaries.ath 200000 ...: Backfills a group by name by number of articles'."\n" + .'php backfill.php all ...: Backfills all groups 1 at a time, by date (set in admin-view groups)'."\n" + .'php backfill.php alt.binaries.ath ...: Backfills a group by name, by date (set in admin-view groups)'."\n")); } diff --git a/misc/update/decrypt_hashes.php b/misc/update/decrypt_hashes.php index a4094ead1..a50aa54c9 100755 --- a/misc/update/decrypt_hashes.php +++ b/misc/update/decrypt_hashes.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\db\DB; use nntmux\NameFixer; @@ -10,12 +10,12 @@ $pdo = new DB(); if (! isset($argv[1]) || ($argv[1] != 'all' && $argv[1] != 'full' && ! is_numeric($argv[1]))) { exit($pdo->log->error( - "\nThis script tries to match hashes of the releases.name or releases.searchname to predb hashes.\n" - ."To display the changes, use 'show' as the second argument.\n\n" - ."php decrypt_hashes.php 1000 ...: to limit to 1000 sorted by newest postdate.\n" - ."php decrypt_hashes.php full ...: to run on full database.\n" - ."php decrypt_hashes.php all ...: to run on all hashed releases(including previously renamed).\n" - )); + "\nThis script tries to match hashes of the releases.name or releases.searchname to predb hashes.\n" + ."To display the changes, use 'show' as the second argument.\n\n" + ."php decrypt_hashes.php 1000 ...: to limit to 1000 sorted by newest postdate.\n" + ."php decrypt_hashes.php full ...: to run on full database.\n" + ."php decrypt_hashes.php all ...: to run on all hashed releases(including previously renamed).\n" + )); } echo $pdo->log->header("\nDecrypt Hashes (${argv[1]}) Started at ".date('g:i:s')); diff --git a/misc/update/match_prefiles.php b/misc/update/match_prefiles.php index 201f5c413..7b9988474 100755 --- a/misc/update/match_prefiles.php +++ b/misc/update/match_prefiles.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\ColorCLI; use nntmux\NameFixer; diff --git a/misc/update/multiprocessing/backfill.php b/misc/update/multiprocessing/backfill.php index ba9d42fdb..71d8264e7 100644 --- a/misc/update/multiprocessing/backfill.php +++ b/misc/update/multiprocessing/backfill.php @@ -1,7 +1,7 @@ <?php declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; // Check if argument 1 is numeric, which is to limit article count. diff --git a/misc/update/multiprocessing/binaries.php b/misc/update/multiprocessing/binaries.php index 280abfd10..131c8928c 100644 --- a/misc/update/multiprocessing/binaries.php +++ b/misc/update/multiprocessing/binaries.php @@ -6,7 +6,7 @@ if (! isset($argv[1]) || ! is_numeric($argv[1])) { ); } declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; (new Forking())->processWorkType('binaries', [0 => $argv[1]]); diff --git a/misc/update/multiprocessing/fixrelnames.php b/misc/update/multiprocessing/fixrelnames.php index 00729f37c..0e39bde8e 100644 --- a/misc/update/multiprocessing/fixrelnames.php +++ b/misc/update/multiprocessing/fixrelnames.php @@ -8,7 +8,7 @@ if (! isset($argv[1]) || ! in_array($argv[1], ['standard', 'predbft'])) { ); } -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/multiprocessing/import.php b/misc/update/multiprocessing/import.php index 500d31ae9..99d81a8a8 100644 --- a/misc/update/multiprocessing/import.php +++ b/misc/update/multiprocessing/import.php @@ -1,7 +1,7 @@ <?php declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\ForkingImportNZB; diff --git a/misc/update/multiprocessing/postprocess.php b/misc/update/multiprocessing/postprocess.php index dc18442ec..739abe2e4 100644 --- a/misc/update/multiprocessing/postprocess.php +++ b/misc/update/multiprocessing/postprocess.php @@ -15,7 +15,7 @@ if (! isset($argv[1]) || ! in_array($argv[1], ['ama', 'add', 'mov', 'nfo', 'sha' } declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/multiprocessing/releases.php b/misc/update/multiprocessing/releases.php index 513f431c4..df4b4fe8f 100644 --- a/misc/update/multiprocessing/releases.php +++ b/misc/update/multiprocessing/releases.php @@ -1,7 +1,7 @@ <?php declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/multiprocessing/requestid.php b/misc/update/multiprocessing/requestid.php index e694e9835..b554989dd 100644 --- a/misc/update/multiprocessing/requestid.php +++ b/misc/update/multiprocessing/requestid.php @@ -1,7 +1,7 @@ <?php declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/multiprocessing/safe.php b/misc/update/multiprocessing/safe.php index 3e511050c..531197272 100644 --- a/misc/update/multiprocessing/safe.php +++ b/misc/update/multiprocessing/safe.php @@ -9,7 +9,7 @@ if (! isset($argv[1]) || ! in_array($argv[1], ['backfill', 'binaries'])) { } declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/multiprocessing/update_per_group.php b/misc/update/multiprocessing/update_per_group.php index 09585a72d..47a272990 100644 --- a/misc/update/multiprocessing/update_per_group.php +++ b/misc/update/multiprocessing/update_per_group.php @@ -1,7 +1,7 @@ <?php declare(ticks=1); -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\libraries\Forking; diff --git a/misc/update/postprocess.php b/misc/update/postprocess.php index b31233066..7434a3c1d 100644 --- a/misc/update/postprocess.php +++ b/misc/update/postprocess.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NNTP; use nntmux\db\DB; diff --git a/misc/update/requestid.php b/misc/update/requestid.php index 8ed0c40e3..6a431d682 100755 --- a/misc/update/requestid.php +++ b/misc/update/requestid.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\ColorCLI; use nntmux\RequestIDWeb; @@ -10,26 +10,26 @@ $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 - ) - ); + 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)] - ); + ['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)] - ); + ['limit' => $argv[1], 'show' => $argv[2], 'time' => (isset($argv[3]) && is_numeric($argv[3]) && $argv[3] > 0 ? $argv[3] : 0)] + ); } diff --git a/misc/update/tmux/bin/groupfixrelnames.php b/misc/update/tmux/bin/groupfixrelnames.php index 5e3e0bb1e..6cb378ce5 100644 --- a/misc/update/tmux/bin/groupfixrelnames.php +++ b/misc/update/tmux/bin/groupfixrelnames.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\Nfo; use nntmux\NZB; diff --git a/misc/update/tmux/bin/postprocess_pre.php b/misc/update/tmux/bin/postprocess_pre.php index 4b116a3a9..6cfc15ec4 100755 --- a/misc/update/tmux/bin/postprocess_pre.php +++ b/misc/update/tmux/bin/postprocess_pre.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\PreDb; diff --git a/misc/update/tmux/bin/postprocess_threaded.php b/misc/update/tmux/bin/postprocess_threaded.php index 7a1b0e1ac..58cd80704 100644 --- a/misc/update/tmux/bin/postprocess_threaded.php +++ b/misc/update/tmux/bin/postprocess_threaded.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NNTP; use nntmux\Tmux; diff --git a/misc/update/tmux/bin/showsleep.php b/misc/update/tmux/bin/showsleep.php index 38d06201f..156b39535 100644 --- a/misc/update/tmux/bin/showsleep.php +++ b/misc/update/tmux/bin/showsleep.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\ConsoleTools; diff --git a/misc/update/tmux/bin/update_groups.php b/misc/update/tmux/bin/update_groups.php index e39e81dba..8addbc32c 100644 --- a/misc/update/tmux/bin/update_groups.php +++ b/misc/update/tmux/bin/update_groups.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 4).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NNTP; use nntmux\db\DB; diff --git a/misc/update/tmux/monitor.php b/misc/update/tmux/monitor.php index 813cc97cf..054918435 100644 --- a/misc/update/tmux/monitor.php +++ b/misc/update/tmux/monitor.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\Tmux; use nntmux\db\DB; diff --git a/misc/update/tmux/run.php b/misc/update/tmux/run.php index e0972f4c1..beb78d0a3 100644 --- a/misc/update/tmux/run.php +++ b/misc/update/tmux/run.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\Tmux; use nntmux\db\DB; diff --git a/misc/update/tmux/start.php b/misc/update/tmux/start.php index bc4cd74ae..11babe740 100644 --- a/misc/update/tmux/start.php +++ b/misc/update/tmux/start.php @@ -6,7 +6,7 @@ * * It will start the tmux server and monitoring scripts if needed. */ -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\Tmux; use nntmux\ColorCLI; diff --git a/misc/update/tmux/stop.php b/misc/update/tmux/stop.php index 3d7620777..d3ed8aeeb 100644 --- a/misc/update/tmux/stop.php +++ b/misc/update/tmux/stop.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\Tmux; diff --git a/misc/update/update_binaries.php b/misc/update/update_binaries.php index 25d873676..97a8d1e79 100644 --- a/misc/update/update_binaries.php +++ b/misc/update/update_binaries.php @@ -1,6 +1,6 @@ <?php -require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap.php'; +require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use nntmux\NNTP; use nntmux\db\DB; @@ -27,10 +27,12 @@ if (isset($argv[1]) && ! is_numeric($argv[1])) { $grp = new Groups(['Settings' => $pdo]); $group = $grp->getByName($groupName); if (is_array($group)) { - $binaries->updateGroup($group, - (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : $maxHeaders)); + $binaries->updateGroup( + $group, + (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : $maxHeaders) + ); } } else { $binaries->updateAllGroups((isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? $argv[1] : - $maxHeaders)); + $maxHeaders)); }