예제 #1
0
function reCategorize($argv)
{
    $c = new ColorCLI();
    $where = '';
    $update = true;
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $where = ' AND groupid = ' . $argv[1];
    } else {
        if (isset($argv[1]) && preg_match('/\\([\\d, ]+\\)/', $argv[1])) {
            $where = ' AND groupid IN ' . $argv[1];
        } else {
            if (isset($argv[1]) && $argv[1] === 'misc') {
                $where = ' AND categoryid IN (1090, 2020, 3050, 4040, 5050, 6050, 7050, 8010)';
            }
        }
    }
    if (isset($argv[2]) && $argv[2] === 'test') {
        $update = false;
    }
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1]))) {
        echo $c->header("Categorizing all releases in {$argv[1]} using searchname. This can take a while, be patient.");
    } else {
        if (isset($argv[1]) && $argv[1] == "misc") {
            echo $c->header("Categorizing all releases in misc categories using searchname. This can take a while, be patient.");
        } else {
            echo $c->header("Categorizing all releases using searchname. This can take a while, be patient.");
        }
    }
    $timestart = TIME();
    if (isset($argv[1]) && (is_numeric($argv[1]) || preg_match('/\\([\\d, ]+\\)/', $argv[1])) || $argv[1] === 'misc') {
        $chgcount = categorizeRelease($update, str_replace(" AND", "WHERE", $where), true);
    } else {
        $chgcount = categorizeRelease($update, "", true);
    }
    $consoletools = new ConsoleTools();
    $time = $consoletools->convertTime(TIME() - $timestart);
    if ($update === true) {
        echo $c->header("Finished re-categorizing " . number_format($chgcount) . " releases in " . $time . " , \tusing the searchname.\n");
    } else {
        echo $c->header("Finished re-categorizing in " . $time . " , using the searchname.\n" . "This would have changed " . number_format($chgcount) . " releases but no updates were done.\n");
    }
}
예제 #2
0
function print_str($type, $str, $argv)
{
    if ($argv[1] != 'file') {
        $cli = new ColorCLI();
        if ($type == "primary") {
            echo $cli->primary($str);
        } else {
            if ($type == "alternate") {
                echo $cli->alternate($str);
            } else {
                echo $cli->header($str);
            }
        }
    } else {
        echo $str . "\n";
    }
}
예제 #3
0
    /**
     * Download new headers for a single group.
     *
     * @param array $groupMySQL Array of MySQL results for a single group.
     * @param int   $maxHeaders (Optional) How many headers to download max.
     *
     * @return void
     */
    public function updateGroup($groupMySQL, $maxHeaders = 0)
    {
        $startGroup = microtime(true);
        // Select the group on the NNTP server, gets the latest info on it.
        $groupNNTP = $this->_nntp->selectGroup($groupMySQL['name']);
        if ($this->_nntp->isError($groupNNTP)) {
            $groupNNTP = $this->_nntp->dataError($this->_nntp, $groupMySQL['name']);
            if ($groupNNTP->code == 411) {
                $this->_groups->disableIfNotExist($groupMySQL['id']);
            }
            if ($this->_nntp->isError($groupNNTP)) {
                return;
            }
        }
        if ($this->_echoCLI) {
            $this->_colorCLI->doEcho($this->_colorCLI->primary('Processing ' . $groupMySQL['name']), true);
        }
        if ($groupMySQL['regexmatchonly'] == 1) {
            $this->onlyProcessRegexBinaries = true;
            if ($this->_echoCLI) {
                $this->_colorCLI->doEcho($this->_colorCLI->primary('Note: Discarding parts that do not match a regex', true));
            }
        } else {
            $this->onlyProcessRegexBinaries = false;
        }
        // Attempt to repair any missing parts before grabbing new ones.
        if ($groupMySQL['last_record'] != 0) {
            if ($this->_partRepair) {
                if ($this->_echoCLI) {
                    $this->_colorCLI->doEcho($this->_colorCLI->primary('Part repair enabled. Checking for missing parts.'), true);
                }
                $this->partRepair($groupMySQL);
            } else {
                if ($this->_echoCLI) {
                    $this->_colorCLI->doEcho($this->_colorCLI->primary('Part repair disabled by user.'), true);
                }
            }
        }
        // Generate postdate for first record, for those that upgraded.
        if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] != 0) {
            $groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP);
            $this->_pdo->queryExec(sprintf('
					UPDATE groups
					SET first_record_postdate = %s
					WHERE id = %d', $this->_pdo->from_unixtime($groupMySQL['first_record_postdate']), $groupMySQL['id']));
        }
        // Get first article we want aka the oldest.
        if ($groupMySQL['last_record'] == 0) {
            if ($this->_newGroupScanByDays) {
                // For new newsgroups - determine here how far we want to go back using date.
                $first = $this->daytopost($this->_newGroupDaysToScan, $groupNNTP);
            } else {
                if ($groupNNTP['first'] >= $groupNNTP['last'] - ($this->_newGroupMessagesToScan + $this->messageBuffer)) {
                    // If what we want is lower than the groups first article, set the wanted first to the first.
                    $first = $groupNNTP['first'];
                } else {
                    // Or else, use the newest article minus how much we should get for new groups.
                    $first = (string) ($groupNNTP['last'] - ($this->_newGroupMessagesToScan + $this->messageBuffer));
                }
            }
            // We will use this to subtract so we leave articles for the next time (in case the server doesn't have them yet)
            $leaveOver = $this->messageBuffer;
            // If this is not a new group, go from our newest to the servers newest.
        } else {
            // Set our oldest wanted to our newest local article.
            $first = $groupMySQL['last_record'];
            // This is how many articles we will grab. (the servers newest minus our newest).
            $totalCount = (string) ($groupNNTP['last'] - $first);
            // Check if the server has more articles than our loop limit x 2.
            if ($totalCount > $this->messageBuffer * 2) {
                // Get the remainder of $totalCount / $this->message buffer
                $leaveOver = round($totalCount % $this->messageBuffer, 0, PHP_ROUND_HALF_DOWN) + $this->messageBuffer;
            } else {
                // Else get half of the available.
                $leaveOver = round($totalCount / 2, 0, PHP_ROUND_HALF_DOWN);
            }
        }
        // The last article we want, aka the newest.
        $last = $groupLast = (string) ($groupNNTP['last'] - $leaveOver);
        // If the newest we want is older than the oldest we want somehow.. set them equal.
        if ($last < $first) {
            $last = $groupLast = $first;
        }
        // This is how many articles we are going to get.
        $total = (string) ($groupLast - $first);
        // This is how many articles are available (without $leaveOver).
        $realTotal = (string) ($groupNNTP['last'] - $first);
        // Check if we should limit the amount of fetched new headers.
        if ($maxHeaders > 0) {
            if ($maxHeaders < $groupLast - $first) {
                $groupLast = $last = (string) ($maxHeaders + $first);
            }
            $total = (string) ($groupLast - $first);
        }
        // If total is bigger than 0 it means we have new parts in the newsgroup.
        if ($total > 0) {
            if ($this->_echoCLI) {
                $this->_colorCLI->doEcho($this->_colorCLI->primary(($groupMySQL['last_record'] == 0 ? 'New group ' . $groupNNTP['group'] . ' starting with ' . ($this->_newGroupScanByDays ? $this->_newGroupDaysToScan . ' days' : number_format($this->_newGroupMessagesToScan) . ' messages') . ' worth.' : 'Group ' . $groupNNTP['group'] . ' has ' . number_format($realTotal) . ' new articles.') . ' Leaving ' . number_format($leaveOver) . " for next pass.\nServer oldest: " . number_format($groupNNTP['first']) . ' Server newest: ' . number_format($groupNNTP['last']) . ' Local newest: ' . number_format($groupMySQL['last_record'])), true);
            }
            $done = false;
            // Get all the parts (in portions of $this->messageBuffer to not use too much memory).
            while ($done === false) {
                // Increment last until we reach $groupLast (group newest article).
                if ($total > $this->messageBuffer) {
                    $last = (string) ($first + $this->messageBuffer) > $groupLast ? $groupLast : (string) ($first + $this->messageBuffer);
                }
                // Increment first so we don't get an article we already had.
                $first++;
                if ($this->_echoCLI) {
                    $this->_colorCLI->doEcho($this->_colorCLI->header("\nGetting " . number_format($last - $first + 1) . ' articles (' . number_format($first) . ' to ' . number_format($last) . ') from ' . $groupMySQL['name'] . " - (" . number_format($groupLast - $last) . " articles in queue)."));
                }
                // Get article headers from newsgroup.
                $scanSummary = $this->scan($groupMySQL, $first, $last);
                // Check if we fetched headers.
                if (!empty($scanSummary)) {
                    // If new group, update first record & postdate
                    if (is_null($groupMySQL['first_record_postdate']) && $groupMySQL['first_record'] == 0) {
                        $groupMySQL['first_record'] = $scanSummary['firstArticleNumber'];
                        if (isset($scanSummary['firstArticleDate'])) {
                            $groupMySQL['first_record_postdate'] = strtotime($scanSummary['firstArticleDate']);
                        } else {
                            $groupMySQL['first_record_postdate'] = $this->postdate($groupMySQL['first_record'], $groupNNTP);
                        }
                        $this->_pdo->queryExec(sprintf('
								UPDATE groups
								SET first_record = %s, first_record_postdate = %s
								WHERE id = %d', $scanSummary['firstArticleNumber'], $this->_pdo->from_unixtime($this->_pdo->escapeString($groupMySQL['first_record_postdate'])), $groupMySQL['id']));
                    }
                    if (isset($scanSummary['lastArticleDate'])) {
                        $scanSummary['lastArticleDate'] = strtotime($scanSummary['lastArticleDate']);
                    } else {
                        $scanSummary['lastArticleDate'] = $this->postdate($scanSummary['lastArticleNumber'], $groupNNTP);
                    }
                    $this->_pdo->queryExec(sprintf('
							UPDATE groups
							SET last_record = %s, last_record_postdate = %s, last_updated = NOW()
							WHERE id = %d', $this->_pdo->escapeString($scanSummary['lastArticleNumber']), $this->_pdo->from_unixtime($scanSummary['lastArticleDate']), $groupMySQL['id']));
                } else {
                    // If we didn't fetch headers, update the record still.
                    $this->_pdo->queryExec(sprintf('
							UPDATE groups
							SET last_record = %s, last_updated = NOW()
							WHERE id = %d', $this->_pdo->escapeString($last), $groupMySQL['id']));
                }
                if ($last == $groupLast) {
                    $done = true;
                } else {
                    $first = $last;
                }
            }
            if ($this->_echoCLI) {
                $this->_colorCLI->doEcho($this->_colorCLI->primary(PHP_EOL . 'Group ' . $groupMySQL['name'] . ' processed in ' . number_format(microtime(true) - $startGroup, 2) . ' seconds.'), true);
            }
        } else {
            if ($this->_echoCLI) {
                $this->_colorCLI->doEcho($this->_colorCLI->primary('No new articles for ' . $groupMySQL['name'] . ' (first ' . number_format($first) . ', last ' . number_format($last) . ', grouplast ' . number_format($groupMySQL['last_record']) . ', total ' . number_format($total) . ")\n" . 'Server oldest: ' . number_format($groupNNTP['first']) . ' Server newest: ' . number_format($groupNNTP['last']) . ' Local newest: ' . number_format($groupMySQL['last_record'])), true);
            }
        }
    }
예제 #4
0
        } else {
            exit($c->error("\nHave you changed the path to the patches folder, or do you have the right permissions?\n"));
        }
        sort($patches);
        foreach ($patches as $patch) {
            if (preg_match('/\\.sql$/i', $patch)) {
                $filepath = $argv[1] . $patch;
                $file = fopen($filepath, "r");
                $patch = fread($file, filesize($filepath));
                if (preg_match('/UPDATE `?site`? SET `?value`? = \'?(\\d{1,})\'? WHERE `?setting`? = \'sqlpatch\'/i', $patch, $patchnumber)) {
                    if ($patchnumber['1'] > $currentversion) {
                        if ($safeupgrade == true && $backedup == false) {
                            BackupDatabase();
                            $backedup = true;
                        }
                        SplitSQL($filepath);
                        $patched++;
                    }
                }
            }
        }
    } else {
        exit($c->error("\nUnable to determine OS.\n"));
    }
}
if ($patched == 0) {
    exit($c->info("Nothing to patch, you are already on patch version " . $currentversion));
}
if ($patched > 0) {
    echo $c->header($patched . " patch(es) applied.");
}
예제 #5
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$cli = new ColorCLI();
$pdo = new Settings(['checkVersion' => true]);
$ftinnodb = $pdo->isDbVersionAtLeast('5.6');
if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "fmyisam") {
    $tbl = $argv[1];
    printf($cli->header("Converting {$tbl}"));
    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=FIXED");
} else {
    if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dmyisam") {
        $tbl = $argv[1];
        printf($cli->header("Converting {$tbl}"));
        $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=DYNAMIC");
    } else {
        if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "cinnodb") {
            $tbl = $argv[1];
            if ($ftinnodb || !$ftinnodb && $tbl !== 'releasesearch' && $tbl !== 'predbhash') {
                printf($cli->header("Converting {$tbl}"));
                $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=COMPRESSED");
            } else {
                printf($cli->header("Not converting releasesearch / predbhash as your INNODB version does not support fulltext indexes"));
            }
        } else {
            if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dinnodb") {
                $tbl = $argv[1];
                if ($ftinnodb || !$ftinnodb && $tbl !== 'releasesearch' && $tbl !== 'predbhash') {
                    printf($cli->header("Converting {$tbl}"));
                    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=DYNAMIC");
예제 #6
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use newznab\db\Settings;
$cli = new ColorCLI();
$pdo = new Settings(['checkVersion' => true]);
$ftinnodb = $pdo->isDbVersionAtLeast('5.6');
if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "fmyisam") {
    $tbl = $argv[1];
    printf($cli->header("Converting {$tbl}"));
    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=FIXED");
} else {
    if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dmyisam") {
        $tbl = $argv[1];
        printf($cli->header("Converting {$tbl}"));
        $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=MYISAM ROW_FORMAT=DYNAMIC");
    } else {
        if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "cinnodb") {
            $tbl = $argv[1];
            if ($ftinnodb || !$ftinnodb && $tbl !== 'releasesearch' && $tbl !== 'bookinfo' && $tbl !== 'consoleinfo' && $tbl !== 'musicinfo') {
                printf($cli->header("Converting {$tbl}"));
                $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=COMPRESSED");
            } else {
                printf($cli->header("Not converting bookinfo / consoleinfo / musicinfo / releasesearch as your INNODB version does not support fulltext indexes"));
            }
        } else {
            if (isset($argv[1]) && isset($argv[2]) && $argv[2] == "dinnodb") {
                $tbl = $argv[1];
                if ($ftinnodb || !$ftinnodb && $tbl !== 'releasesearch' && $tbl !== 'bookinfo' && $tbl !== 'consoleinfo' && $tbl !== 'musicinfo') {
                    printf($cli->header("Converting {$tbl}"));
                    $pdo->queryExec("ALTER TABLE {$tbl} ENGINE=INNODB ROW_FORMAT=DYNAMIC");
예제 #7
0
$path2covers = NN_COVERS . 'games' . DS;
$dirItr = new RecursiveDirectoryIterator($path2covers);
$itr = new RecursiveIteratorIterator($dirItr, RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($itr as $filePath) {
    if (is_file($filePath) && preg_match('/\\d+\\.jpg/', $filePath)) {
        preg_match('/(\\d+)\\.jpg/', basename($filePath), $match);
        if (isset($match[1])) {
            $run = $pdo->queryDirect("UPDATE gamesinfo SET cover = 1 WHERE cover = 0 AND id = " . $match[1]);
            if ($run !== false) {
                if ($run->rowCount() >= 1) {
                    $covers++;
                } else {
                    $run = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE id = " . $match[1]);
                    if ($run !== false && $run->rowCount() == 0) {
                        echo $c->info($filePath . " not found in db.");
                    }
                }
            }
        }
    }
}
$qry = $pdo->queryDirect("SELECT id FROM gamesinfo WHERE cover = 1");
foreach ($qry as $rows) {
    if (!is_file($path2covers . $rows['id'] . '.jpg')) {
        $pdo->queryDirect("UPDATE gamesinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
        echo $c->info($path2covers . $rows['id'] . ".jpg does not exist.");
        $deleted++;
    }
}
echo $c->header($covers . " covers set.");
echo $c->header($deleted . " games unset.");
예제 #8
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
exit('Needs to be rewritten');
$cli = new ColorCLI();
if (!isset($argv[1])) {
    exit($cli->error("\nThis script will set bitwise = 0 or all rename bits to unchecked or just specific bits.\n\n" . "php {$argv['0']} true           ...: To reset bitwise on all releases to 0.\n" . "php {$argv['0']} rename         ...: To reset bitwise on all releases for just rename bits (4, 8, 16, 32, 64, 128).\n" . "php {$argv['0']} 512            ...: To reset a specific bit.\n"));
}
$pdo = new Settings();
$res = false;
if ($argv[1] === 'true') {
    $res = $pdo->queryExec('UPDATE releases SET bitwise = 0, iscategorized = 0, isrenamed = 0, nzbstatus = 0, ishashed = 0, isrequestid = 0');
} else {
    if ($argv[1] === 'rename') {
        $res = $pdo->queryExec('UPDATE releases SET isrenamed = 0, bitwise = ((bitwise & ~248)|0)');
    } else {
        if (is_numeric($argv[1])) {
            $res = $pdo->queryExec('UPDATE releases SET bitwise = ((bitwise & ~' . $argv[1] . ')|0)');
        }
    }
}
if ($res !== false && is_numeric($argv[1])) {
    echo $cli->header('Succesfully reset the bitwise of ' . number_format($res->rowCount()) . ' releases to 0 for bit(s) ' . $argv[1] . '.');
} else {
    if ($res !== false) {
        echo $cli->header('Succesfully reset the bitwise of ' . number_format($res->rowCount()) . ' releases to un-renamed.');
    } else {
        echo $cli->header('No releases to be reset.');
    }
}
예제 #9
0
<?php

require_once dirname(__FILE__) . "/config.php";
$time = TIME();
$c = new ColorCLI();
if (isset($argv[1])) {
    $group = $argv[1];
    echo $c->header("Updating group {$group}");
    $g = new Groups();
    $group = $g->getByName($group);
    $bin = new Binaries();
    $bin->updateGroup($group);
} else {
    $binaries = new Binaries();
    $binaries->updateAllGroups();
}
function relativeTime($_time)
{
    $d = array();
    $d[0] = array(1, "sec");
    $d[1] = array(60, "min");
    $d[2] = array(3600, "hr");
    $d[3] = array(86400, "day");
    $d[4] = array(31104000, "yr");
    $w = array();
    $return = "";
    $now = TIME();
    $diff = $now - $_time;
    $secondsLeft = $diff;
    for ($i = 4; $i > -1; $i--) {
        $w[$i] = intval($secondsLeft / $d[$i][0]);
예제 #10
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$cli = new ColorCLI();
$rtkey = (new Settings())->getSetting('rottentomatokey');
if (isset($rtkey)) {
    $rt = new RottenTomato($rtkey);
    print_r(json_decode($rt->searchMovie("inception")));
    $url = RottenTomato::API_URL . "movies.json?apikey=" . $rt->getApiKey() . "&q=inception&page_limit=50";
    exit($cli->header("\nIf nothing was displayed above then there might be an error. If so, go to the following url: " . $url . "\n"));
} else {
    exit($cli->error("\nNo rotten tomato key.\n"));
}
예제 #11
0
<?php

require dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
$count = $groups = 0;
$cli = new ColorCLI();
echo $cli->header("This script will show all Backfill Groups.\n" . "An optional first argument of ASC/DESC is used to sort the display by first_record_postdate in ascending/descending order.\n" . "An optional second argument will limit the return to that number of groups.\n\n" . "php {$argv['0']} true 20    ...: To sort the backfill groups by first_record_postdate and display only 20 groups.\n");
$limit = "";
if (isset($argv[2]) && is_numeric($argv[2])) {
    $limit = "limit " . $argv[2];
} else {
    if (isset($argv[1]) && is_numeric($argv[1])) {
        $limit = "limit " . $argv[1];
    }
}
$mask = $cli->primary("%-50.50s %22.22s %22.22s %22.22s %22.22s");
$mask1 = $cli->header("%-50.50s %22.22s %22.22s %22.22s %22.22s");
$groups = $pdo->queryOneRow("SELECT COUNT(*) AS count FROM groups WHERE backfill = 1 AND first_record IS NOT NULL");
if ($rels = $pdo->query("SELECT last_updated, last_updated, CAST(last_record AS SIGNED)-CAST(first_record AS SIGNED) AS headers_downloaded FROM groups")) {
    foreach ($rels as $rel) {
        $count += $rel['headers_downloaded'];
    }
}
printf($mask1, "Group Name => " . $groups['count'] . "(" . number_format($count) . " downloaded)", "Backfilled Days", "Oldest Post", "Last Updated", "Headers Downloaded");
printf($mask1, "==================================================", "======================", "======================", "======================", "======================");
if (isset($argv[1]) && ($argv[1] === "desc" || $argv[1] === "DESC")) {
    if ($rels = $pdo->query(sprintf("SELECT name, backfill_target, first_record_postdate, last_updated, last_updated, " . "CAST(last_record AS SIGNED)-CAST(first_record AS SIGNED) AS headers_downloaded, " . "TIMESTAMPDIFF(DAY,first_record_postdate,NOW()) AS days FROM groups " . "WHERE backfill = 1 AND first_record_postdate IS NOT NULL AND last_updated IS NOT NULL " . "AND last_updated IS NOT NULL ORDER BY first_record_postdate DESC %s", $limit))) {
        foreach ($rels as $rel) {
            $headers = number_format($rel['headers_downloaded']);
            printf($mask, $rel['name'], $rel['backfill_target'] . "(" . $rel['days'] . ")", $rel['first_record_postdate'], $rel['last_updated'], $headers);
예제 #12
0
require_once dirname(__FILE__) . '/../../../www/config.php';
use nzedb\db\Settings;
$pdo = new Settings();
$DIR = nZEDb_MISC;
$smarty = new Smarty();
$dbname = DB_NAME;
$cli = new ColorCLI();
if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "safe")) {
    $restart = (new Tmux())->isRunning();
    system("cd {$DIR} && git pull");
    if (\nzedb\utility\Utility::hasCommand("php5")) {
        $PHP = "php5";
    } else {
        $PHP = "php";
    }
    echo $cli->header("Patching database - {$dbname}.");
    $safe = $argv[1] === "safe" ? true : false;
    system("{$PHP} " . nZEDb_ROOT . 'cli' . DS . "update_db.php true {$safe}");
    // Remove folders from smarty.
    $cleared = $smarty->clearCompiledTemplate();
    if ($cleared) {
        echo $cli->header("The smarty template cache has been cleaned for you");
    } else {
        echo $cli->header("You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c");
    }
    if ($restart) {
        echo $cli->header("Starting tmux scripts.");
        $pdo->queryExec("UPDATE tmux SET value = '1' WHERE setting = 'RUNNING'");
    }
} else {
    exit($cli->error("\nThis script will automatically do a git pull, patch the DB and delete the smarty folder contents.\n\n" . "php {$argv['0']} true   ...: To run.\n" . "php {$argv['0']} safe   ...: Tto run a backup of your database and then update.\n"));
예제 #13
0
// Test if your giantbomb key is working.
$giantbombkey = (new \nzedb\db\Settings())->getSetting('giantbombkey');
$cli = new ColorCLI();
$obj = new GiantBomb($giantbombkey, $resp = "json");
$searchgame = "South Park The Stick of Truth";
$resultsfound = 0;
$e = null;
try {
    $fields = array("deck", "description", "original_game_rating", "api_detail_url", "image", "genres", "name", "platforms", "publishers", "original_release_date", "reviews", "site_detail_url");
    $result = $obj->search($searchgame, $fields, 1);
    $result = json_decode(json_encode($result), true);
    if ($result['number_of_total_results'] != 0) {
        $resultsfound = count($result['results']);
        for ($i = 0; $i <= $resultsfound; $i++) {
            similar_text($result['results'][$i]['name'], $searchgame, $p);
            if ($p > 90) {
                $result = $result['results'][$i];
                break;
            }
        }
    }
} catch (Exception $e) {
    $result = false;
}
if ($result !== false && !empty($result)) {
    print_r($result);
    exit($cli->header("\nLooks like it is working alright."));
} else {
    print_r($e);
    exit($cli->error("\nThere was a problem attempting to query giantbomb. Maybe your key is wrong, or you are being throttled.\n"));
}
예제 #14
0
                $run = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE id = " . $match1[1]);
                if ($run->rowCount() == 0) {
                    echo $c->info($filePath . " not found in db.");
                }
            }
        }
    }
}
$qry = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE cover = 1");
if ($qry instanceof Traversable) {
    foreach ($qry as $rows) {
        if (!is_file($path2covers . $rows['id'] . '-cover.jpg')) {
            $pdo->queryDirect("UPDATE xxxinfo SET cover = 0 WHERE cover = 1 AND id = " . $rows['id']);
            echo $c->info($path2covers . $rows['id'] . "-cover.jpg does not exist.");
            $deleted++;
        }
    }
}
$qry1 = $pdo->queryDirect("SELECT id FROM xxxinfo WHERE backdrop = 1");
if ($qry1 instanceof Traversable) {
    foreach ($qry1 as $rows) {
        if (!is_file($path2covers . $rows['id'] . '-backdrop.jpg')) {
            $pdo->queryDirect("UPDATE xxxinfo SET backdrop = 0 WHERE backdrop = 1 AND id = " . $rows['id']);
            echo $c->info($path2covers . $rows['id'] . "-backdrop.jpg does not exist.");
            $deleted++;
        }
    }
}
echo $c->header($covers . " covers set.");
echo $c->header($updated . " backdrops set.");
echo $c->header($deleted . " movies unset.");