mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-02 03:08:53 +00:00
Merge pull request #218 from DariusIII/dev_games
Added PC games postprocessing and cover view
This commit is contained in:
+7
-7
@@ -8,7 +8,7 @@ require_once(dirname(__FILE__) . "/../lib/showsleep.php");
|
||||
require_once(dirname(__FILE__) . "/../lib/functions.php");
|
||||
|
||||
|
||||
$version = "0.4r2004";
|
||||
$version = "0.4r2011";
|
||||
|
||||
$db = new DB();
|
||||
$functions = new Functions();
|
||||
@@ -49,10 +49,10 @@ $proc = "SELECT
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 2000 AND 2999 AND imdbID IS NULL ) AS movies,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 3000 AND 3999 AND musicinfoID IS NULL) AS audio,
|
||||
( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status), category c WHERE c.ID = r.categoryID AND c.parentID = 6000 AND r.passwordstatus = -1 AND r.haspreview = -1 AND c.disablepreview = 0) AS xxx,
|
||||
( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status) INNER JOIN category c on c.ID = r.categoryID WHERE (r.passwordstatus = -1) OR (r.haspreview = -1 and c.disablepreview = 0)) AS pc,
|
||||
( SELECT COUNT(*) FROM releases r INNER JOIN category c ON c.ID = r.categoryID WHERE r.nzbstatus = 1 AND ((r.categoryID BETWEEN 4000 AND 4999 AND r.passwordstatus BETWEEN -6 AND -1 AND r.haspreview = -1 AND c.disablepreview = 0) OR (r.categoryID = 4050 AND r.gamesinfo_id IS NULL))) AS pc,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID BETWEEN 5000 AND 5999 AND rageID = -1) AS tv,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE categoryID = 7020 AND bookinfoID IS NULL ) AS book,
|
||||
( SELECT COUNT(*) FROM releases r USE INDEX(ix_releases_status), category c WHERE c.ID = r.categoryID AND r.passwordstatus = -1 AND r.haspreview = -1 AND c.disablepreview = 0) AS work,
|
||||
( SELECT COUNT(*) FROM releases r INNER JOIN category c ON c.ID = r.categoryID WHERE r.nzbstatus = 1 AND ((r.passwordstatus BETWEEN -6 AND -1 AND r.haspreview = -1 AND c.disablepreview = 0) OR (r.categoryID = 4050 AND r.gamesinfo_id IS NULL))) AS work,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status)) AS releases,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE releasenfoID = 0 AND nfostatus BETWEEN -6 AND -1) AS nforemains,
|
||||
( SELECT COUNT(*) FROM releases USE INDEX(ix_releases_status) WHERE nfostatus = 1 AND releasenfoID = 1) AS nfo,
|
||||
@@ -1657,12 +1657,12 @@ while ($i > 0) {
|
||||
shell_exec("tmux respawnp -t${tmux_session}:2.4 'echo \"\033[38;5;${color}m\n${panes2[4]} has been disabled/terminated by Postprocess Anime\"'");
|
||||
}
|
||||
|
||||
//Process Console releases in pane 2.5 once if needed then exits
|
||||
if (($maxload >= get_load()) && ($post_amazon == 1) && ($console_releases_proc > 0)) {
|
||||
//Process Games in pane 2.5 once if needed then exits
|
||||
if (($maxload >= get_load()) && ($post_amazon == 1) && (($console_releases_proc > 0) || ($pc_releases_proc > 0))) {
|
||||
$color = get_color($colors_start, $colors_end, $colors_exc);
|
||||
$log = writelog($panes2[5]);
|
||||
shell_exec("tmux respawnp -t${tmux_session}:2.5 'echo \"\033[38;5;\"$color\"m\" && cd $_bin && $_php postprocess_new.php games 2>&1 $log && $_sleep $post_timer_amazon && echo \" \033[1;0;33m\"' 2>&1 1> /dev/null");
|
||||
} else if (($maxload >= get_load()) && ($post_amazon == 1) && ($console_releases_proc == 0)) {
|
||||
shell_exec("tmux respawnp -t${tmux_session}:2.5 'echo \"\033[38;5;\"$color\"m\" && cd $_bin && $_php postprocess_new.php console 2>&1 $log && $_php postprocess_new.php games 2>&1 $log && $_sleep $post_timer_amazon && echo \" \033[1;0;33m\"' 2>&1 1> /dev/null");
|
||||
} else if (($maxload >= get_load()) && ($post_amazon == 1) && (($console_releases_proc == 0) || ($pc_releases_proc > 0))) {
|
||||
$color = get_color($colors_start, $colors_end, $colors_exc);
|
||||
shell_exec("tmux respawnp -t${tmux_session}:2.5 'echo \"\033[38;5;\"$color\"m\n$panes2[5] has been disabled/terminated by No Games to process\"'");
|
||||
} else if ($maxload <= get_load()) {
|
||||
|
||||
@@ -51,6 +51,8 @@ if (isset($argv[1]) && $argv[1] === "additional") {
|
||||
$thetvdb->processReleases();
|
||||
} else if (isset($argv[1]) && $argv[1] === "games") {
|
||||
$pprocess->processGames();
|
||||
} else if (isset($argv[1]) && $argv[1] === "console") {
|
||||
$pprocess->processConsoleGames();
|
||||
} else if (isset($argv[1]) && $argv[1] === "ebook") {
|
||||
$postprocess->processBooks();
|
||||
} else if (isset($argv[1]) && $argv[1] === "music") {
|
||||
|
||||
+34
-8
@@ -17,6 +17,7 @@ ADD `proc_pp` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
ADD `proc_par2` BIT NOT NULL DEFAULT 0,
|
||||
ADD `proc_nfo` BIT NOT NULL DEFAULT 0,
|
||||
ADD `proc_files` BIT NOT NULL DEFAULT 0,
|
||||
ADD `gamesinfo_id` INT AFTER consoleinfoID,
|
||||
ADD `nzbstatus` TINYINT(1) NOT NULL DEFAULT 1;
|
||||
CREATE INDEX `ix_releases_nfostatus` ON `releases` (`nfostatus` ASC) USING HASH;
|
||||
CREATE INDEX `ix_releases_reqidstatus` ON `releases` (`reqidstatus` ASC) USING HASH;
|
||||
@@ -26,8 +27,11 @@ CREATE INDEX `ix_releases_dehashstatus` ON `releases` (`dehashstatus`);
|
||||
CREATE INDEX `ix_releases_haspreview` ON `releases` (`haspreview` ASC) USING HASH;
|
||||
CREATE INDEX `ix_releases_postdate_name` ON `releases` (`postdate`, `name`);
|
||||
CREATE INDEX `ix_releases_prehashid_searchname` ON `releases` (`prehashID`, `searchname`);
|
||||
CREATE INDEX `ix_releases_gamesinfo_id` ON `releases` (`gamesinfo_id`);
|
||||
CREATE INDEX `ix_releases_status` ON `releases` (`nzbstatus`, `iscategorized`, `isrenamed`, `nfostatus`, `ishashed`, `passwordstatus`, `dehashstatus`, `releasenfoID`, `musicinfoID`, `consoleinfoID`, `bookinfoID`, `haspreview`, `categoryID`, `imdbID`, `rageID`);
|
||||
|
||||
ALTER TABLE users ADD COLUMN gameview INT AFTER consoleview;
|
||||
|
||||
DROP TABLE IF EXISTS prehash;
|
||||
CREATE TABLE prehash (
|
||||
ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
@@ -203,7 +207,7 @@ INSERT INTO tmux (setting, value) VALUES ('defrag_cache', '900'),
|
||||
('ffmpeg_duration', '5'),
|
||||
('ffmpeg_image_time', '5'),
|
||||
('processvideos', '0'),
|
||||
('sqlpatch', '50');
|
||||
('sqlpatch', '55');
|
||||
|
||||
DROP TABLE IF EXISTS releasesearch;
|
||||
CREATE TABLE releasesearch (
|
||||
@@ -476,6 +480,29 @@ INSERT INTO country (code, name) VALUES ('AF', 'Afghanistan'),
|
||||
('ZM', 'Zambia'),
|
||||
('ZW', 'Zimbabwe');
|
||||
|
||||
DROP TABLE IF EXISTS gamesinfo;
|
||||
CREATE TABLE gamesinfo (
|
||||
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
asin VARCHAR(128) DEFAULT NULL,
|
||||
url VARCHAR(1000) DEFAULT NULL,
|
||||
platform VARCHAR(255) DEFAULT NULL,
|
||||
publisher VARCHAR(255) DEFAULT NULL,
|
||||
genreid INT(10) NULL DEFAULT NULL,
|
||||
esrb VARCHAR(255) NULL DEFAULT NULL,
|
||||
releasedate DATETIME DEFAULT NULL,
|
||||
review VARCHAR(3000) DEFAULT NULL,
|
||||
cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
createddate DATETIME NOT NULL,
|
||||
updateddate DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE INDEX ix_gamesinfo_asin (asin)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8
|
||||
COLLATE = utf8_unicode_ci
|
||||
AUTO_INCREMENT = 1;
|
||||
|
||||
DROP TABLE IF EXISTS shortgroups;
|
||||
CREATE TABLE shortgroups (
|
||||
ID INT(11) NOT NULL AUTO_INCREMENT,
|
||||
@@ -701,6 +728,11 @@ INSERT INTO menu (href, title, tooltip, role, ordinal)
|
||||
VALUES ('prehash', 'Prehash',
|
||||
'Prehash', 1, 68);
|
||||
|
||||
INSERT INTO `site` (`setting`, `value`) VALUES
|
||||
('categorizeforeign', '1'),
|
||||
('catwebdl', '0'),
|
||||
('giantbombkey', '');
|
||||
|
||||
DROP TRIGGER IF EXISTS check_insert;
|
||||
DROP TRIGGER IF EXISTS check_update;
|
||||
|
||||
@@ -745,10 +777,4 @@ CREATE TRIGGER delete_search AFTER DELETE ON releases FOR EACH ROW BEGIN DELETE
|
||||
WHERE releaseID = OLD.ID;
|
||||
END;
|
||||
$$
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DELIMITER ;
|
||||
@@ -0,0 +1,24 @@
|
||||
DROP TABLE IF EXISTS gamesinfo;
|
||||
CREATE TABLE gamesinfo (
|
||||
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
asin VARCHAR(128) DEFAULT NULL,
|
||||
url VARCHAR(1000) DEFAULT NULL,
|
||||
platform VARCHAR(255) DEFAULT NULL,
|
||||
publisher VARCHAR(255) DEFAULT NULL,
|
||||
genreid INT(10) NULL DEFAULT NULL,
|
||||
esrb VARCHAR(255) NULL DEFAULT NULL,
|
||||
releasedate DATETIME DEFAULT NULL,
|
||||
review VARCHAR(3000) DEFAULT NULL,
|
||||
cover TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
|
||||
createddate DATETIME NOT NULL,
|
||||
updateddate DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE INDEX ix_gamesinfo_asin (asin)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8
|
||||
COLLATE = utf8_unicode_ci
|
||||
AUTO_INCREMENT = 1;
|
||||
|
||||
UPDATE `tmux` SET `value` = '52' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,4 @@
|
||||
INSERT INTO `site`
|
||||
(`setting`, `value`)
|
||||
VALUES ('giantbombkey', '');
|
||||
UPDATE `tmux` SET `value` = '53' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE releases ADD COLUMN gamesinfo_id INT AFTER consoleinfoID;
|
||||
CREATE INDEX ix_releases_gamesinfo_id ON releases (gamesinfo_id);
|
||||
UPDATE `tmux` SET `value` = '54' WHERE `setting` = 'sqlpatch';
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE users ADD COLUMN gameview INT AFTER consoleview;
|
||||
UPDATE `tmux` SET `value` = '55' WHERE `setting` = 'sqlpatch';
|
||||
+18
-3
@@ -16,6 +16,7 @@ require_once(WWW_DIR . "/lib/amazon.php");
|
||||
require_once(WWW_DIR . "/lib/genres.php");
|
||||
require_once(WWW_DIR . "/lib/anidb.php");
|
||||
require_once(WWW_DIR . "/lib/book.php");
|
||||
require_once(WWW_DIR . "/lib/Games.php");
|
||||
require_once("consoletools.php");
|
||||
require_once("ColorCLI.php");
|
||||
require_once("nzbcontents.php");
|
||||
@@ -131,6 +132,7 @@ class PProcess
|
||||
$this->processSharing($nntp);
|
||||
$this->processMovies();
|
||||
$this->processMusic();
|
||||
$this->processConsoleGames();
|
||||
$this->processGames();
|
||||
$this->processAnime();
|
||||
$this->processTv();
|
||||
@@ -164,6 +166,19 @@ class PProcess
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup console games if enabled.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processConsoleGames()
|
||||
{
|
||||
if ($this->site->lookupgames !== '0') {
|
||||
$console = new Konsole($this->echooutput);
|
||||
$console->processConsoleReleases();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup games if enabled.
|
||||
*
|
||||
@@ -171,9 +186,9 @@ class PProcess
|
||||
*/
|
||||
public function processGames()
|
||||
{
|
||||
if ($this->site->lookupgames !== '0') {
|
||||
$console = new Konsole($this->echooutput);
|
||||
$console->processConsoleReleases();
|
||||
if ($this->site->lookupgames !== 0) {
|
||||
$games = new Games($this->echooutput);
|
||||
$games->processGamesReleases();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
require_once("config.php");
|
||||
require_once(WWW_DIR."/lib/adminpage.php");
|
||||
require_once(WWW_DIR."/lib/users.php");
|
||||
|
||||
$page = new AdminPage();
|
||||
$users = new Users();
|
||||
$id = 0;
|
||||
|
||||
// set the current action
|
||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
|
||||
|
||||
//get the user roles
|
||||
$userroles = $users->getRoles();
|
||||
$roles = array();
|
||||
$defaultrole = Users::ROLE_USER;
|
||||
$defaultinvites = Users::DEFAULT_INVITES;
|
||||
foreach ($userroles as $r) {
|
||||
$roles[$r['ID']] = $r['name'];
|
||||
if ($r['isdefault'] == 1)
|
||||
{
|
||||
$defaultrole = $r['ID'];
|
||||
$defaultinvites = $r['defaultinvites'];
|
||||
}
|
||||
}
|
||||
|
||||
switch($action)
|
||||
{
|
||||
case 'add':
|
||||
$user = array();
|
||||
$user["role"] = $defaultrole;
|
||||
$user["notes"] = "";
|
||||
$user["invites"] = $defaultinvites;
|
||||
$user["movieview"] = "1";
|
||||
$user["musicview"] = "1";
|
||||
$user["gameview"] = "1";
|
||||
$user["consoleview"] = "1";
|
||||
$user["bookview"] = "1";
|
||||
$page->smarty->assign('user', $user);
|
||||
break;
|
||||
case 'submit':
|
||||
|
||||
if ($_POST["id"] == "")
|
||||
{
|
||||
$invites = $defaultinvites;
|
||||
foreach($userroles as $role) {
|
||||
if ($role['ID'] == $_POST['role'])
|
||||
$invites = $role['defaultinvites'];
|
||||
}
|
||||
$ret = $users->signup($_POST["username"], $_POST["password"], $_POST["email"], '', $_POST["role"], $_POST["notes"], $invites, "", true, false, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret = $users->update($_POST["id"], $_POST["username"], $_POST["email"], $_POST["grabs"], $_POST["role"], $_POST["notes"], $_POST["invites"], (isset($_POST['movieview']) ? "1" : "0"), (isset($_POST['musicview']) ? "1" : "0"), (isset($_POST['gameview']) ? "1" : "0"), (isset($_POST['consoleview']) ? "1" : "0"), (isset($_POST['bookview']) ? "1" : "0"));
|
||||
if ($_POST['password'] != "")
|
||||
$users->updatePassword($_POST["id"], $_POST['password']);
|
||||
}
|
||||
|
||||
if ($ret >= 0)
|
||||
header("Location:".WWW_TOP."/user-list.php");
|
||||
else
|
||||
{
|
||||
switch ($ret)
|
||||
{
|
||||
case Users::ERR_SIGNUP_BADUNAME:
|
||||
$page->smarty->assign('error', "Bad username. Try a better one.");
|
||||
break;
|
||||
case Users::ERR_SIGNUP_BADPASS:
|
||||
$page->smarty->assign('error', "Bad password. Try a longer one.");
|
||||
break;
|
||||
case Users::ERR_SIGNUP_BADEMAIL:
|
||||
$page->smarty->assign('error', "Bad email.");
|
||||
break;
|
||||
case Users::ERR_SIGNUP_UNAMEINUSE:
|
||||
$page->smarty->assign('error', "Username in use.");
|
||||
break;
|
||||
case Users::ERR_SIGNUP_EMAILINUSE:
|
||||
$page->smarty->assign('error', "Email in use.");
|
||||
break;
|
||||
default:
|
||||
$page->smarty->assign('error', "Unknown save error.");
|
||||
break;
|
||||
}
|
||||
$user = array();
|
||||
$user["ID"] = $_POST["id"];
|
||||
$user["username"] = $_POST["username"];
|
||||
$user["email"] = $_POST["email"];
|
||||
$user["grabs"] = (isset($_POST["grabs"]) ? $_POST["grabs"] : "0");
|
||||
$user["role"] = $_POST["role"];
|
||||
$user["notes"] = $_POST["notes"];
|
||||
$user["invites"] = (isset($_POST["invites"]) ? $_POST["invites"] : "0");
|
||||
$user["movieview"] = $_POST["movieview"];
|
||||
$user["bookview"] = $_POST["bookview"];
|
||||
$page->smarty->assign('user', $user);
|
||||
}
|
||||
break;
|
||||
case 'view':
|
||||
default:
|
||||
|
||||
if (isset($_GET["id"]))
|
||||
{
|
||||
$page->title = "User Edit";
|
||||
$id = $_GET["id"];
|
||||
$user = $users->getByID($id);
|
||||
|
||||
$page->smarty->assign('user', $user);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$page->smarty->assign('yesno_ids', array(1,0));
|
||||
$page->smarty->assign('yesno_names', array( 'Yes', 'No'));
|
||||
|
||||
$page->smarty->assign('role_ids', array_keys($roles));
|
||||
$page->smarty->assign('role_names', $roles);
|
||||
|
||||
$page->content = $page->smarty->fetch('user-edit.tpl');
|
||||
$page->render();
|
||||
|
||||
@@ -0,0 +1,889 @@
|
||||
<?php
|
||||
require_once(WWW_DIR . "/lib/framework/db.php");
|
||||
require_once(WWW_DIR . "/lib/GiantBombAPI.php");
|
||||
require_once(WWW_DIR . "/lib/Tmux.php");
|
||||
require_once(WWW_DIR . "/lib/GiantBombAPI.php");
|
||||
require_once(WWW_DIR . "/lib/category.php");
|
||||
require_once(WWW_DIR."/lib/genres.php");
|
||||
require_once(WWW_DIR."/lib/releaseimage.php");
|
||||
require_once(WWW_DIR."../misc/update_scripts/nix_scripts/tmux/lib/ColorCLI.php");
|
||||
require_once(WWW_DIR."../misc/update_scripts/nix_scripts/tmux/lib/functions.php");
|
||||
|
||||
|
||||
class Games
|
||||
{
|
||||
const REQID_NONE = -3; // The Request ID was not found locally or via web lookup.
|
||||
const REQID_ZERO = -2; // The Request ID was 0.
|
||||
const REQID_NOLL = -1; // Request ID was not found via local lookup.
|
||||
const CONS_UPROC = 0; // Release has not been processed.
|
||||
const REQID_FOUND = 1; // Request ID found and release was updated.
|
||||
|
||||
public $pdo;
|
||||
|
||||
/**
|
||||
* @param bool $echooutput
|
||||
*/
|
||||
function __construct($echooutput = false)
|
||||
{
|
||||
$this->echooutput = $echooutput;
|
||||
|
||||
$this->pdo = new DB();
|
||||
$s = new Sites();
|
||||
$this->site = $s->get();
|
||||
$t = new Tmux();
|
||||
$this->tmux = $t->get();
|
||||
$this->pubkey = $this->site->giantbombkey;
|
||||
$this->gameqty = ($this->tmux->maxgamesprocessed != '') ? $this->tmux->maxgamesprocessed : 150;
|
||||
$this->sleeptime = ($this->tmux->amazonsleep != '') ? $this->tmux->amazonsleep : 1000;
|
||||
$this->imgSavePath = WWW_DIR . 'covers/games' . '/';
|
||||
$this->renamed = '';
|
||||
if ($this->site->lookupgames == 2) {
|
||||
$this->renamed = 'AND isrenamed = 1';
|
||||
}
|
||||
//$this->cleangames = ($this->pdo->getSetting('lookupgames') == 2) ? 'AND isrenamed = 1' : '';
|
||||
$this->c = new ColorCLI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getgamesinfo($id)
|
||||
{
|
||||
return $this->pdo->queryOneRow(
|
||||
sprintf("
|
||||
SELECT gamesinfo.*, genres.title AS genres
|
||||
FROM gamesinfo
|
||||
LEFT OUTER JOIN genres ON genres.ID = gamesinfo.genreid
|
||||
WHERE gamesinfo.id = %d",
|
||||
$id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $title
|
||||
* @param $platform
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getgamesinfoByName($title, $platform)
|
||||
{
|
||||
return $this->pdo->queryOneRow(
|
||||
sprintf("
|
||||
SELECT *
|
||||
FROM gamesinfo
|
||||
WHERE title LIKE %s
|
||||
AND platform LIKE %s",
|
||||
$this->pdo->escapeString("%" . $title . "%"),
|
||||
$this->pdo->escapeString("%" . $platform . "%")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $start
|
||||
* @param $num
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRange($start, $num)
|
||||
{
|
||||
return $this->pdo->query(
|
||||
sprintf(
|
||||
"SELECT * FROM gamesinfo ORDER BY createddate DESC %s",
|
||||
($start === false ? '' : 'LIMIT ' . $num . ' OFFSET ' . $start)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
$res = $this->pdo->queryOneRow("SELECT COUNT(id) AS num FROM gamesinfo");
|
||||
return ($res === false ? 0 : $res["num"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cat
|
||||
* @param $maxage
|
||||
* @param array $excludedcats
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getgamesCount($cat, $maxage = -1, $excludedcats = array())
|
||||
{
|
||||
$catsrch = "";
|
||||
if (count($cat) > 0 && $cat[0] != -1) {
|
||||
$catsrch = " (";
|
||||
$categ = new Category();
|
||||
foreach ($cat as $category) {
|
||||
if ($category != -1) {
|
||||
if ($categ->isParent($category)) {
|
||||
$children = $categ->getChildren($category);
|
||||
$chlist = "-99";
|
||||
foreach ($children as $child) {
|
||||
$chlist .= ", " . $child["ID"];
|
||||
}
|
||||
|
||||
if ($chlist != "-99") {
|
||||
$catsrch .= " r.categoryID IN (" . $chlist . ") OR ";
|
||||
}
|
||||
} else {
|
||||
$catsrch .= sprintf(" r.categoryID = %d OR ", $category);
|
||||
}
|
||||
}
|
||||
}
|
||||
$catsrch .= "1=2 )";
|
||||
}
|
||||
|
||||
$res = $this->pdo->queryOneRow(
|
||||
sprintf("
|
||||
SELECT COUNT(DISTINCT r.gamesinfo_id) AS num
|
||||
FROM releases r
|
||||
INNER JOIN gamesinfo gam ON gam.id = r.gamesinfo_id
|
||||
WHERE r.nzbstatus = 1
|
||||
AND gam.title != ''
|
||||
AND gam.cover = 1
|
||||
AND r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease')
|
||||
AND %s %s %s %s",
|
||||
$this->getBrowseBy(),
|
||||
$catsrch,
|
||||
($maxage > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxage) : ''),
|
||||
(count($excludedcats) > 0 ? " AND r.categoryID NOT IN (" . implode(",", $excludedcats) . ")" : '')
|
||||
)
|
||||
);
|
||||
|
||||
return ($res === false ? 0 : $res["num"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cat
|
||||
* @param $start
|
||||
* @param $num
|
||||
* @param $orderby
|
||||
* @param $maxage
|
||||
* @param array $excludedcats
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getgamesRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = array())
|
||||
{
|
||||
$browseby = $this->getBrowseBy();
|
||||
|
||||
if ($start === false) {
|
||||
$limit = "";
|
||||
} else {
|
||||
$limit = " LIMIT " . $num . " OFFSET " . $start;
|
||||
}
|
||||
$catsrch = "";
|
||||
if (count($cat) > 0 && $cat[0] != -1) {
|
||||
$catsrch = " (";
|
||||
$categ = new Category();
|
||||
foreach ($cat as $category) {
|
||||
if ($category != -1) {
|
||||
if ($categ->isParent($category)) {
|
||||
$children = $categ->getChildren($category);
|
||||
$chlist = "-99";
|
||||
foreach ($children as $child) {
|
||||
$chlist .= ", " . $child["id"];
|
||||
}
|
||||
|
||||
if ($chlist != "-99") {
|
||||
$catsrch .= " r.categoryID IN (" . $chlist . ") OR ";
|
||||
}
|
||||
} else {
|
||||
$catsrch .= sprintf(" r.categoryID = %d OR ", $category);
|
||||
}
|
||||
}
|
||||
}
|
||||
$catsrch .= "1=2 )";
|
||||
}
|
||||
|
||||
if ($maxage > 0) {
|
||||
$maxage = sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxage);
|
||||
} else {
|
||||
$maxage = '';
|
||||
}
|
||||
|
||||
$exccatlist = "";
|
||||
if (count($excludedcats) > 0) {
|
||||
$exccatlist = " AND r.categoryID NOT IN (" . implode(",", $excludedcats) . ")";
|
||||
}
|
||||
|
||||
$order = $this->getgamesOrder($orderby);
|
||||
|
||||
return $this->pdo->query(
|
||||
sprintf(
|
||||
"SELECT GROUP_CONCAT(r.ID ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, "
|
||||
. "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, "
|
||||
. "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, "
|
||||
. "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, "
|
||||
. "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, "
|
||||
. "GROUP_CONCAT(rn.ID ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, "
|
||||
. "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, "
|
||||
. "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, "
|
||||
. "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, "
|
||||
. "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, "
|
||||
. "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, "
|
||||
. "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, "
|
||||
. "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, "
|
||||
. "gam.*, r.gamesinfo_id, groups.name AS group_name, rn.ID as nfoid FROM releases r "
|
||||
. "LEFT OUTER JOIN groups ON groups.ID = r.groupID "
|
||||
. "LEFT OUTER JOIN releasenfo rn ON rn.releaseID = r.ID "
|
||||
. "INNER JOIN gamesinfo gam ON gam.id = r.gamesinfo_id "
|
||||
. "WHERE r.nzbstatus = 1 AND gam.cover = 1 AND gam.title != '' AND "
|
||||
. "r.passwordstatus <= (SELECT value FROM site WHERE setting='showpasswordedrelease') AND %s %s %s %s "
|
||||
. "GROUP BY gam.id ORDER BY %s %s" . $limit,
|
||||
$browseby,
|
||||
$catsrch,
|
||||
$maxage,
|
||||
$exccatlist,
|
||||
$order[0],
|
||||
$order[1]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $orderby
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getgamesOrder($orderby)
|
||||
{
|
||||
$order = ($orderby == '') ? 'r.postdate' : $orderby;
|
||||
$orderArr = explode("_", $order);
|
||||
switch ($orderArr[0]) {
|
||||
case 'title':
|
||||
$orderfield = 'gam.title';
|
||||
break;
|
||||
case 'platform':
|
||||
$orderfield = 'gam.platform';
|
||||
break;
|
||||
case 'releasedate':
|
||||
$orderfield = 'gam.releasedate';
|
||||
break;
|
||||
case 'genre':
|
||||
$orderfield = 'gam.genreID';
|
||||
break;
|
||||
case 'size':
|
||||
$orderfield = 'r.size';
|
||||
break;
|
||||
case 'files':
|
||||
$orderfield = 'r.totalpart';
|
||||
break;
|
||||
case 'stats':
|
||||
$orderfield = 'r.grabs';
|
||||
break;
|
||||
case 'posted':
|
||||
default:
|
||||
$orderfield = 'r.postdate';
|
||||
break;
|
||||
}
|
||||
$ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc';
|
||||
|
||||
return array($orderfield, $ordersort);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getgamesOrdering()
|
||||
{
|
||||
return array(
|
||||
'title_asc', 'title_desc', 'posted_asc', 'posted_desc', 'size_asc', 'size_desc',
|
||||
'files_asc', 'files_desc', 'stats_asc', 'stats_desc', 'platform_asc', 'platform_desc',
|
||||
'releasedate_asc', 'releasedate_desc', 'genre_asc', 'genre_desc'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getBrowseByOptions()
|
||||
{
|
||||
return array('platform' => 'platform', 'title' => 'title', 'genre' => 'genreID');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBrowseBy()
|
||||
{
|
||||
$browseby = ' ';
|
||||
$browsebyArr = $this->getBrowseByOptions();
|
||||
$like = 'LIKE';
|
||||
|
||||
foreach ($browsebyArr as $bbk => $bbv) {
|
||||
if (isset($_REQUEST[$bbk]) && !empty($_REQUEST[$bbk])) {
|
||||
$bbs = stripslashes($_REQUEST[$bbk]);
|
||||
$browseby .= 'gam.' . $bbv . ' ' . $like . ' (' . $this->pdo->escapeString('%' . $bbs . '%') . ') AND ';
|
||||
}
|
||||
}
|
||||
|
||||
return $browseby;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param $field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function makeFieldLinks($data, $field)
|
||||
{
|
||||
$tmpArr = explode(', ', $data[$field]);
|
||||
$newArr = array();
|
||||
$i = 0;
|
||||
foreach ($tmpArr as $ta) {
|
||||
// Only use first 6.
|
||||
if ($i > 5) {
|
||||
break;
|
||||
}
|
||||
$newArr[] =
|
||||
'<a href="' . WWW_TOP . '/games?' . $field . '=' . urlencode($ta) . '" title="' .
|
||||
$ta . '">' . $ta . '</a>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
return implode(', ', $newArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $title
|
||||
* @param $asin
|
||||
* @param $url
|
||||
* @param $salesrank
|
||||
* @param $platform
|
||||
* @param $publisher
|
||||
* @param $releasedate
|
||||
* @param $esrb
|
||||
* @param $cover
|
||||
* @param $genreID
|
||||
*/
|
||||
public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genreID)
|
||||
{
|
||||
|
||||
$this->pdo->exec(
|
||||
sprintf("
|
||||
UPDATE gamesinfo
|
||||
SET
|
||||
title = %s, asin = %s, url = %s, salesrank = %s, platform = %s, publisher = %s,
|
||||
releasedate= %s,esrb = %s, cover = %d, genreid = %d, updateddate = NOW()
|
||||
WHERE id = %d",
|
||||
$this->pdo->escapeString($title),
|
||||
$this->pdo->escapeString($asin),
|
||||
$this->pdo->escapeString($url),
|
||||
$salesrank,
|
||||
$this->pdo->escapeString($platform),
|
||||
$this->pdo->escapeString($publisher),
|
||||
$this->pdo->escapeString($releasedate),
|
||||
$this->pdo->escapeString($esrb),
|
||||
$cover,
|
||||
$genreID,
|
||||
$id
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process each game, updating game information from Giantbomb
|
||||
*
|
||||
* @param $gameInfo
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function updategamesinfo($gameInfo)
|
||||
{
|
||||
$gen = new Genres();
|
||||
$ri = new ReleaseImage();
|
||||
|
||||
$con = array();
|
||||
$ggameid = $this->fetchgiantbombgameid($gameInfo['title']);
|
||||
$gb = $this->fetchGiantBombArray($ggameid);
|
||||
$gb = $gb['results'];
|
||||
if (!is_array($gb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load genres.
|
||||
$defaultGenres = $gen->getGenres(Genres::GAME_TYPE);
|
||||
$genreassoc = array();
|
||||
foreach ($defaultGenres as $dg) {
|
||||
$genreassoc[$dg['ID']] = strtolower($dg['title']);
|
||||
}
|
||||
|
||||
// Get game properties.
|
||||
$con['coverurl'] = (string)$gb['image']['super_url'];
|
||||
if ($con['coverurl'] != "") {
|
||||
$con['cover'] = 1;
|
||||
} else {
|
||||
$con['cover'] = 0;
|
||||
}
|
||||
|
||||
$con['title'] = (string)$gb['name'];
|
||||
if (empty($con['title'])) {
|
||||
$con['title'] = $gameInfo['title'];
|
||||
}
|
||||
if (is_array($gb['platforms'])) {
|
||||
while (list($key) = each($gb['platforms'])) {
|
||||
if ($gb['platforms'][$key]['id'] == $gameInfo['node']) {
|
||||
$con['platform'] = (string)$gb['platforms'][$key]['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($con['platform'])) {
|
||||
$con['platform'] = $gameInfo['platform'];
|
||||
}
|
||||
|
||||
// Beginning of Recheck Code.
|
||||
// This is to verify the result back from amazon was at least somewhat related to what was intended.
|
||||
// Some of the platforms don't match Amazon's exactly. This code is needed to facilitate rechecking.
|
||||
if (preg_match('/^Pc$/i', $gameInfo['platform'])) {
|
||||
$gameInfo['platform'] = str_replace('Pc', 'PC', $gameInfo['platform']);
|
||||
} // baseline single quote
|
||||
if (preg_match('/^Mac$/i', $gameInfo['platform'])) {
|
||||
$gameInfo['platform'] = str_replace('Mac', 'MAC', $gameInfo['platform']);
|
||||
} // baseline single quote
|
||||
|
||||
// Remove Online Game Code So Titles Match Properly.
|
||||
if (preg_match('/\[Online Game Code\]/i', $con['title'])) {
|
||||
$con['title'] = str_replace(' [Online Game Code]', '', $con['title']);
|
||||
} // baseline single quote
|
||||
// Basically the XBLA names contain crap, this is to reduce the title down far enough to be usable.
|
||||
|
||||
// This actual compares the two strings and outputs a percentage value.
|
||||
$titlepercent = $platformpercent = '';
|
||||
similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent);
|
||||
similar_text(strtolower($gameInfo['platform']),
|
||||
strtolower($con['platform']),
|
||||
$platformpercent);
|
||||
|
||||
// If the release is DLC matching sucks, so assume anything over 50% is legit.
|
||||
if (isset($gameInfo['dlc']) && $gameInfo['dlc'] == 1) {
|
||||
if ($titlepercent >= 50) {
|
||||
$titlepercent = 100;
|
||||
$platformpercent = 100;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
echo("Matched: Title Percentage: $titlepercent% between " . strtolower($gameInfo['title']) . " and " . strtolower($con['title']) . ".\n");
|
||||
echo("Matched: Platform Percentage: $platformpercent% \n");
|
||||
*/
|
||||
|
||||
// If the Title is less than 80% Platform must be 100% unless it is XBLA.
|
||||
if ($titlepercent < 60) {
|
||||
if ($platformpercent != 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If title is less than 80% then its most likely not a match.
|
||||
if ($titlepercent < 60) {
|
||||
similar_text(strtolower($gameInfo['title'] . ' - ' . $gameInfo['platform']),
|
||||
strtolower($con['title']),
|
||||
$titlewithplatpercent);
|
||||
if ($titlewithplatpercent < 70) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Platform must equal 100%.
|
||||
if ($platformpercent != 100) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$con['asin'] = $ggameid;
|
||||
|
||||
$con['url'] = (string)$gb['site_detail_url'];
|
||||
$con['url'] = str_replace("%26tag%3Dws", "%26tag%3Dopensourceins%2D21", $con['url']);
|
||||
|
||||
/*$con['salesrank'] = (string)$amaz->Items->Item->SalesRank;
|
||||
if ($con['salesrank'] == "") {
|
||||
$con['salesrank'] = 'null';
|
||||
}
|
||||
*/
|
||||
if (is_array($gb['publishers'])) {
|
||||
while (list($key) = each($gb['publishers'])) {
|
||||
if ($key == 0) {
|
||||
$con['publisher'] = (string)$gb['publishers'][$key]['name'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$con['publisher'] = "Unknown";
|
||||
}
|
||||
|
||||
if (is_array($gb['original_game_rating'])) {
|
||||
$con['esrb'] = (string)$gb['original_game_rating'][0]['name'];
|
||||
} else {
|
||||
$con['esrb'] = (string)$gb['original_game_rating']['name'];
|
||||
}
|
||||
$con['releasedate'] = $this->pdo->escapeString((string)$gb['original_release_date']);
|
||||
if ($con['releasedate'] == "''") {
|
||||
$con['releasedate'] = 'null';
|
||||
}
|
||||
|
||||
$con['review'] = "";
|
||||
if (isset($gb['decription'])) {
|
||||
$con['review'] = trim(strip_tags((string)$gb['description']));
|
||||
}
|
||||
|
||||
$genreKey = -1;
|
||||
$genreName = '';
|
||||
|
||||
if (empty($genreName) && isset($gb['genres'][0]['name'])) {
|
||||
$a = (string)$gb['genres'][0]['name'];
|
||||
$b = str_replace('-', ' ', $a);
|
||||
$tmpGenre = explode(',', $b);
|
||||
foreach ($tmpGenre as $tg) {
|
||||
$genreMatch = $this->matchBrowseNode(ucwords($tg));
|
||||
if ($genreMatch !== false) {
|
||||
$genreName = $genreMatch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($genreName)) {
|
||||
$genreName = 'Unknown';
|
||||
}
|
||||
if (in_array(strtolower($genreName), $genreassoc)) {
|
||||
$genreKey = array_search(strtolower($genreName), $genreassoc);
|
||||
} else {
|
||||
$genreKey = $this->pdo->queryInsert(
|
||||
sprintf("
|
||||
INSERT INTO genres (title, type)
|
||||
VALUES (%s, %d)",
|
||||
$this->pdo->escapeString($genreName),
|
||||
Genres::GAME_TYPE
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$con['gamesgenre'] = $genreName;
|
||||
$con['gamesgenreID'] = $genreKey;
|
||||
|
||||
$check = $this->pdo->queryOneRow(
|
||||
sprintf('
|
||||
SELECT id
|
||||
FROM gamesinfo
|
||||
WHERE title = %s
|
||||
AND asin = %s',
|
||||
$this->pdo->escapeString($con['title']),
|
||||
$this->pdo->escapeString($con['asin'])
|
||||
)
|
||||
);
|
||||
if ($check === false) {
|
||||
$gamesId = $this->pdo->queryInsert(
|
||||
sprintf("
|
||||
INSERT INTO gamesinfo
|
||||
(title, asin, url, platform, publisher, genreid, esrb, releasedate, review, cover, createddate, updateddate)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %d, NOW(), NOW())",
|
||||
$this->pdo->escapeString($con['title']),
|
||||
$this->pdo->escapeString($con['asin']),
|
||||
$this->pdo->escapeString($con['url']),
|
||||
$this->pdo->escapeString($con['platform']),
|
||||
$this->pdo->escapeString($con['publisher']),
|
||||
($con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID']),
|
||||
$this->pdo->escapeString($con['esrb']),
|
||||
$con['releasedate'],
|
||||
$this->pdo->escapeString(substr($con['review'], 0, 3000)),
|
||||
$con['cover']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$gamesId = $check['id'];
|
||||
$this->pdo->exec(
|
||||
sprintf('
|
||||
UPDATE gamesinfo
|
||||
SET
|
||||
title = %s, asin = %s, url = %s, platform = %s, publisher = %s, genreid = %s,
|
||||
esrb = %s, releasedate = %s, review = %s, cover = %s, updateddate = NOW()
|
||||
WHERE id = %d',
|
||||
$this->pdo->escapeString($con['title']),
|
||||
$this->pdo->escapeString($con['asin']),
|
||||
$this->pdo->escapeString($con['url']),
|
||||
$this->pdo->escapeString($con['platform']),
|
||||
$this->pdo->escapeString($con['publisher']),
|
||||
($con['gamesgenreID'] == -1 ? "null" : $con['gamesgenreID']),
|
||||
$this->pdo->escapeString($con['esrb']),
|
||||
$con['releasedate'],
|
||||
$this->pdo->escapeString(substr($con['review'], 0, 3000)),
|
||||
$con['cover'],
|
||||
$gamesId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($gamesId) {
|
||||
if ($this->echooutput) {
|
||||
$this->c->doEcho(
|
||||
$this->c->header("Added/updated game: ") .
|
||||
$this->c->alternateOver(" Title: ") .
|
||||
$this->c->primary($con['title']) .
|
||||
$this->c->alternateOver(" Platform: ") .
|
||||
$this->c->primary($con['platform'])
|
||||
);
|
||||
}
|
||||
$con['cover'] = $ri->saveImage($gamesId, $con['coverurl'], $this->imgSavePath, 250, 250);
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
$this->c->doEcho(
|
||||
$this->c->headerOver("Nothing to update: ") .
|
||||
$this->c->primary($con['title'] . " (" . $con['platform'] . ')' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $gamesId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Giantbomb search results
|
||||
*
|
||||
* @param $gameid
|
||||
*
|
||||
* @return bool|mixed Json Array if no result False
|
||||
*/
|
||||
|
||||
public function fetchGiantBombArray($gameid)
|
||||
{
|
||||
$obj = new GiantBomb($this->pubkey);
|
||||
try {
|
||||
$fields = array(
|
||||
"deck", "description", "original_game_rating", "api_detail_url", "image", "genres",
|
||||
"name", "platforms", "publishers", "original_release_date", "reviews",
|
||||
"site_detail_url"
|
||||
);
|
||||
$result = json_decode(json_encode($obj->game($gameid, $fields)), true);
|
||||
} catch (Exception $e) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Giantbomb game ID for api requests
|
||||
*
|
||||
* @param $title
|
||||
*
|
||||
* @return bool|mixed - Json Array if game was found false if nothing
|
||||
*/
|
||||
public function fetchgiantbombgameid($title)
|
||||
{
|
||||
$obj = new GiantBomb($this->pubkey);
|
||||
try {
|
||||
$result = json_decode(json_encode($obj->search($title, '', 1)), true);
|
||||
if (!is_array($result['results']) || (int) $result['number_of_total_results'] === 0) {
|
||||
$result = false;
|
||||
} else {
|
||||
$result = $result['results'][0]['id'];
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function processGamesReleases()
|
||||
{
|
||||
$res = $this->pdo->queryDirect(
|
||||
sprintf('
|
||||
SELECT searchname, ID
|
||||
FROM releases
|
||||
WHERE nzbstatus = 1 %s
|
||||
AND gamesinfo_id IS NULL
|
||||
AND categoryID = 4050
|
||||
ORDER BY postdate DESC
|
||||
LIMIT %d',
|
||||
$this->renamed,
|
||||
$this->gameqty
|
||||
)
|
||||
);
|
||||
|
||||
if ($res !== false && $res->rowCount() > 0) {
|
||||
if ($this->echooutput) {
|
||||
$this->c->doEcho($this->c->header("Processing " . $res->rowCount() . ' games release(s).'));
|
||||
}
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$startTime = microtime(true);
|
||||
$usedgb = false;
|
||||
$gameInfo = $this->parseTitle($arr['searchname']);
|
||||
if ($gameInfo !== false) {
|
||||
|
||||
if ($this->echooutput) {
|
||||
$this->c->doEcho(
|
||||
$this->c->headerOver('Looking up: ') .
|
||||
$this->c->primary($gameInfo['title'] . ' (' . $gameInfo['platform'] . ')' )
|
||||
);
|
||||
}
|
||||
|
||||
// Check for existing games entry.
|
||||
$gameCheck = $this->getgamesinfoByName($gameInfo['title'], $gameInfo['platform']);
|
||||
|
||||
if ($gameCheck === false) {
|
||||
$gameId = $this->updategamesinfo($gameInfo);
|
||||
$usedgb = true;
|
||||
if ($gameId === false) {
|
||||
$gameId = -2;
|
||||
}
|
||||
} else {
|
||||
$gameId = $gameCheck['id'];
|
||||
}
|
||||
//$gameId = null;
|
||||
// Update release.
|
||||
$this->pdo->exec(sprintf('UPDATE releases SET gamesinfo_id = %d WHERE ID = %d', $gameId, $arr['ID']));
|
||||
} else {
|
||||
// Could not parse release title.
|
||||
$this->pdo->exec(sprintf('UPDATE releases SET gamesinfo_id = %d WHERE ID = %d', -2, $arr['ID']));
|
||||
|
||||
if ($this->echooutput) {
|
||||
echo '.';
|
||||
}
|
||||
}
|
||||
|
||||
// Sleep to not flood amazon.
|
||||
$diff = floor((microtime(true) - $startTime) * 1000000);
|
||||
if ($this->sleeptime * 1000 - $diff > 0 && $usedgb === true) {
|
||||
usleep($this->sleeptime * 1000 - $diff);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($this->echooutput) {
|
||||
$this->c->doEcho($this->c->header('No games releases to process.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the game release title
|
||||
*
|
||||
* @param string $releasename
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function parseTitle($releasename)
|
||||
{
|
||||
// Get name of the game from name of release.
|
||||
if (preg_match(
|
||||
'/^(.+((EFNet|EFNet\sFULL|FULL\sabgxEFNet|abgx\sFULL|abgxbox360EFNet)\s|illuminatenboard\sorg|' .
|
||||
'Place2(hom|us)e.net|united-forums? co uk|\(\d+\)))?(?P<title>.*?)[\.\-_ \:](v\.?\d\.\d|RIP|ADDON|' .
|
||||
'EUR|USA|JP|ASIA|JAP|JPN|AUS|MULTI(\.?\d{1,2})?|PATCHED|FULLDVD|DVD5|DVD9|DVDRIP|\(GAMES\)\s*\(C\)|PROPER|REPACK|RETAIL|' .
|
||||
'DEMO|DISTRIBUTION|BETA|REGIONFREE|READ\.?NFO|NFOFIX|Update|' .
|
||||
// Group names, like Reloaded, CPY, Razor1911, etc
|
||||
'[a-z0-9]{2,}$)/i',
|
||||
preg_replace('/\sMulti\d?\s/i', '', $releasename),
|
||||
$matches)
|
||||
) {
|
||||
// Replace dots, underscores, or brackets with spaces.
|
||||
$result['title'] = str_replace(' RF ', ' ', preg_replace('/(\.|_|\%20|\[|\])/', ' ', $matches['title']));
|
||||
// Needed to add code to handle DLC Properly.
|
||||
if (stripos($result['title'], 'dlc') !== false) {
|
||||
$result['dlc'] = '1';
|
||||
if (stripos($result['title'], 'Rock Band Network') !== false) {
|
||||
$result['title'] = 'Rock Band';
|
||||
} else if (stripos($result['title'], '-') !== false) {
|
||||
$dlc = explode("-", $result['title']);
|
||||
$result['title'] = $dlc[0];
|
||||
} else if (preg_match('/(.*? .*?) /i', $result['title'], $dlc)) {
|
||||
$result['title'] = $dlc[0];
|
||||
}
|
||||
}
|
||||
|
||||
//get the platform of the release
|
||||
if (preg_match('/[\.\-_ ](?P<platform>MAC|MACOSX)/i', $releasename, $matches)) {
|
||||
$platform = $matches['platform'];
|
||||
if (preg_match('/^MAC$/i', $platform)) {
|
||||
$platform = 'MAC';
|
||||
} else {
|
||||
$platform = 'MACOSX';
|
||||
}
|
||||
} else {
|
||||
$platform = "PC";
|
||||
}
|
||||
|
||||
$browseNode = $this->getBrowseNode($platform);
|
||||
$result['platform'] = $platform;
|
||||
$result['node'] = $browseNode;
|
||||
$result['release'] = $releasename;
|
||||
|
||||
// Other option is to pass the $release->categoryID here if we don't find a platform but that would require an
|
||||
// extra lookup to determine the name. In either case we should have a title at the minimum.
|
||||
return array_map("trim", $result);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Giantbomb Category ID #
|
||||
*
|
||||
* @param $platform
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getBrowseNode($platform)
|
||||
{
|
||||
switch ($platform) {
|
||||
case 'PC':
|
||||
$nodeId = '94';
|
||||
break;
|
||||
case 'MAC':
|
||||
$nodeId = '17';
|
||||
break;
|
||||
default:
|
||||
$nodeId = '94';
|
||||
break;
|
||||
}
|
||||
|
||||
return $nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not in use for future additions.
|
||||
*
|
||||
* @param $nodeName
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
public function matchBrowseNode($nodeName)
|
||||
{
|
||||
$str = '';
|
||||
|
||||
//music nodes above mp3 download nodes
|
||||
switch ($nodeName) {
|
||||
case 'Action':
|
||||
case 'Adventure':
|
||||
case 'Arcade':
|
||||
case 'Board Games':
|
||||
case 'Cards':
|
||||
case 'Casino':
|
||||
case 'Flying':
|
||||
case 'Puzzle':
|
||||
case 'Racing':
|
||||
case 'Rhythm':
|
||||
case 'Role-Playing':
|
||||
case 'Simulation':
|
||||
case 'Sports':
|
||||
case 'Strategy':
|
||||
case 'Trivia':
|
||||
$str = $nodeName;
|
||||
break;
|
||||
}
|
||||
|
||||
return ($str !== '') ? $str : false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,435 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* GiantBomb PHP wrapper is a simple class written in PHP to
|
||||
* make interactions with GiantBomb api easier.
|
||||
*
|
||||
* @package GiantBomb api PHP wrapper
|
||||
* @version 0.4
|
||||
* @author Amal Francis
|
||||
* @author Koroban
|
||||
* @license MIT License
|
||||
*/
|
||||
class GiantBomb
|
||||
{
|
||||
|
||||
/**
|
||||
* The api key
|
||||
*
|
||||
* @access private
|
||||
* @type string
|
||||
*/
|
||||
private $api_key = "";
|
||||
|
||||
/**
|
||||
* The api response type : json/xml
|
||||
*
|
||||
* @access private
|
||||
* @type string
|
||||
*/
|
||||
private $resp_type = "json";
|
||||
|
||||
/**
|
||||
* A variable to hold the formatted result of
|
||||
* last api request
|
||||
*
|
||||
* @access public
|
||||
* @type array
|
||||
*/
|
||||
public $result = array();
|
||||
|
||||
/**
|
||||
* api endpoint
|
||||
* prefix for all API cals
|
||||
*
|
||||
* @access protected
|
||||
* @type string
|
||||
*/
|
||||
protected $endpoint = 'http://www.giantbomb.com/api/';
|
||||
|
||||
/**
|
||||
* curl instance
|
||||
*
|
||||
* @access protected
|
||||
* @type handle
|
||||
*/
|
||||
protected $ch = null;
|
||||
|
||||
/**
|
||||
* Constructor of class
|
||||
*
|
||||
* @param string $key string API key to use
|
||||
* @param string $resp type Type of respone to request
|
||||
*
|
||||
* @void
|
||||
*/
|
||||
public function __construct($key, $resp = "json")
|
||||
{
|
||||
// Set the api key
|
||||
$this->api_key = $key;
|
||||
|
||||
// Now set the api response type, Default to json
|
||||
$this->resp_type = $resp;
|
||||
|
||||
// Init new instance of curl
|
||||
$this->ch = curl_init();
|
||||
|
||||
// set default options for curl
|
||||
curl_setopt_array(
|
||||
$this->ch,
|
||||
array(
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_NOPROGRESS => true,
|
||||
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* deletes curl instance
|
||||
*
|
||||
* @void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
// Close request to clear up some resources
|
||||
if (!is_null($this->ch)) {
|
||||
curl_close($this->ch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send call to API
|
||||
*
|
||||
* @param string $module string name of url suffix
|
||||
* @param array $params array get parameters to send to API
|
||||
*
|
||||
* @return mixed|array response of API
|
||||
* @throws GiantBombException
|
||||
*/
|
||||
private function call($module, $params = array())
|
||||
{
|
||||
// set api data
|
||||
$params['api_key'] = $this->api_key;
|
||||
$params['format'] = $this->resp_type;
|
||||
|
||||
// build URL
|
||||
$url = $this->endpoint . $module . '?' . http_build_query($params);
|
||||
|
||||
// Set URL
|
||||
curl_setopt($this->ch, CURLOPT_URL, $url);
|
||||
|
||||
// Send the request & save response to $resp
|
||||
$resp["data"] = curl_exec($this->ch);
|
||||
if (curl_errno($this->ch)) {
|
||||
throw new GiantBombException('API call failed: ' . curl_error($this->ch));
|
||||
}
|
||||
|
||||
// save http response code
|
||||
$resp["httpCode"] = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (!$resp || !$resp["data"]) {
|
||||
throw new GiantBombException("Couldn't get information from API");
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format filter array to string
|
||||
*
|
||||
* @param $filters array list of filters
|
||||
*
|
||||
* @return string combined filter string
|
||||
*/
|
||||
private function format_filter($filters = array())
|
||||
{
|
||||
$filters_merged = array();
|
||||
foreach ($filters as $ky => $vl) {
|
||||
$filters_merged[] = $ky . ':' . $vl;
|
||||
}
|
||||
|
||||
return implode(',', $filters_merged);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about given object type
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $id string ID to request
|
||||
* @param array $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
* @throws GiantBombException
|
||||
*/
|
||||
public function get_object($type, $id, $field_list = array())
|
||||
{
|
||||
$resp = $this->call($type . '/' . $id . '/',
|
||||
array('field_list' => implode(',', $field_list)));
|
||||
|
||||
// No game with given game id found
|
||||
if ($resp["httpCode"] == 404) {
|
||||
throw new GiantBombException('Couldn\'t find ' . $type . ' with game id "' . $id . '"');
|
||||
}
|
||||
|
||||
return $this->parse_result($resp["data"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of objects by given filters
|
||||
*
|
||||
* @param $type
|
||||
* @param $filter array filter by given values - no "," accepted
|
||||
* @param $limit integer limit result count by given limit
|
||||
* @param $offset integer offset of results
|
||||
* @param $platform integer ID of platform to limit
|
||||
* @param $sort array list of keys to sort, format key => asc/desc,
|
||||
* @param $field_list array list of field to result
|
||||
*
|
||||
* @return mixed|array response
|
||||
*/
|
||||
public function get_objects($type, $filter = array(), $limit = 100, $offset = 0,
|
||||
$platform = null, $sort = array(), $field_list = array())
|
||||
{
|
||||
$resp = $this->call($type . '/',
|
||||
array(
|
||||
'field_list' => implode(',', $field_list),
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'platforms' => $platform,
|
||||
'sort' => $this->format_filter($sort),
|
||||
'filter' => $this->format_filter($filter)
|
||||
));
|
||||
|
||||
return $this->parse_result($resp["data"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a game
|
||||
*
|
||||
* @param $id string ID to request
|
||||
* @param $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function game($id, $field_list = array())
|
||||
{
|
||||
return $this->get_object('game', $id, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* List games by filters
|
||||
*
|
||||
* @param $filter array filter by given values - no "," accepted
|
||||
* @param $limit integer limit result count by given limit
|
||||
* @param $offset integer offset of results
|
||||
* @param $platform integer ID of platform to limit
|
||||
* @param $sort array list of keys to sort, format key => asc/desc,
|
||||
* @param $field_list array list of field to result
|
||||
*
|
||||
* @return array list of games
|
||||
*/
|
||||
public function games($filter = array(), $limit = 100, $offset = 0, $platform = null,
|
||||
$sort = array(), $field_list = array())
|
||||
{
|
||||
return $this->get_objects('games', $filter, $limit, $offset, $platform, $sort, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get review by id
|
||||
*
|
||||
* @param $review_id string ID to request
|
||||
* @param $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function review($review_id, $field_list = array())
|
||||
{
|
||||
return $this->get_object('review', $review_id, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get game_rating by id
|
||||
*
|
||||
* @param $rating_id string ID to request
|
||||
* @param $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function game_rating($rating_id, $field_list = array())
|
||||
{
|
||||
return $this->get_object('game_rating', $rating_id, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get company by id
|
||||
*
|
||||
* @param $company_id string ID to request
|
||||
* @param $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function company($company_id, $field_list = array())
|
||||
{
|
||||
return $this->get_object('company', $company_id, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get character by id
|
||||
*
|
||||
* @param $character_id string ID to request
|
||||
* @param $field_list array list of fields to response
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function character($character_id, $field_list = array())
|
||||
{
|
||||
return $this->get_object('character', $character_id, $field_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a search with given keyword
|
||||
*
|
||||
* @param $query string keyword to search
|
||||
* @param $field_list array list of fields to response
|
||||
* @param $limit integer limit result count by given limit
|
||||
* @param $page
|
||||
* @param $resources
|
||||
*
|
||||
* @return array response
|
||||
*/
|
||||
public function search($query, $field_list = array(), $limit = 100, $page = 0, $resources = array())
|
||||
{
|
||||
if (!is_array($field_list)) {
|
||||
$field_list = (array)$field_list;
|
||||
}
|
||||
if (!is_array($resources)) {
|
||||
$resources = (array)$resources;
|
||||
}
|
||||
|
||||
$resp = $this->call(
|
||||
'search/',
|
||||
array(
|
||||
'field_list' => implode(',', $field_list),
|
||||
'limit' => $limit,
|
||||
'page' => $page,
|
||||
'query' => $query,
|
||||
'resources' => implode(',', $resources)
|
||||
)
|
||||
);
|
||||
|
||||
return $this->parse_result($resp['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* List genres
|
||||
*
|
||||
* @param $field_list array list of field to result
|
||||
* @param $limit integer limit result count by given limit
|
||||
* @param $offset integer offset of results
|
||||
*
|
||||
* @return array list of games
|
||||
*/
|
||||
public function genres($field_list = array(), $limit = 100, $offset = 0)
|
||||
{
|
||||
$resp = $this->call(
|
||||
'genres/',
|
||||
array(
|
||||
'field_list' => implode(',', $field_list),
|
||||
'limit' => $limit,
|
||||
'offset' => $offset
|
||||
)
|
||||
);
|
||||
|
||||
return $this->parse_result($resp['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* List platforms by filter
|
||||
*
|
||||
* @param $field_list array list of field to result
|
||||
* @param $limit integer limit result count by given limit
|
||||
* @param $offset integer offset of results
|
||||
* @param $filter array filter by given values - no "," accepted
|
||||
* @param $sort array list of keys to sort, format key => asc/desc,
|
||||
*
|
||||
* @return array list of games
|
||||
*/
|
||||
public function platforms($field_list = array(), $limit = 100, $offset = 0, $filter = array(),
|
||||
$sort = array())
|
||||
{
|
||||
$resp = $this->call(
|
||||
'platforms/',
|
||||
array(
|
||||
'field_list' => implode(',', $field_list),
|
||||
'limit' => $limit,
|
||||
'offset' => $offset,
|
||||
'sort' => $this->format_filter($sort),
|
||||
'filter' => $this->format_filter($filter)
|
||||
)
|
||||
);
|
||||
|
||||
return $this->parse_result($resp["data"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return parsed result of api response
|
||||
*
|
||||
* @param $data string result of API
|
||||
*
|
||||
* @return mixed|SimpleXMLElement parsed version of input string(object)
|
||||
* @throws GiantBombException
|
||||
*/
|
||||
private function parse_result($data)
|
||||
{
|
||||
try {
|
||||
if ($this->resp_type == "json") {
|
||||
$result = @json_decode($data);
|
||||
} else {
|
||||
$result = @simplexml_load_string($data);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new GiantBombException("Parse error occoured", null, $e);
|
||||
}
|
||||
|
||||
if (empty($result) || !empty($result->error) && strtoupper($result->error) != "OK") {
|
||||
throw new GiantBombException("Following error encountered: " . $result->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a custom exception class for api wrapper
|
||||
*/
|
||||
class GiantBombException extends Exception
|
||||
{
|
||||
|
||||
/**
|
||||
* Redefine the exception so message isn't optional
|
||||
*
|
||||
* @param $message string message to set in exception
|
||||
* @param $code integer error code
|
||||
* @param $previous Exception previous Exception to save
|
||||
*
|
||||
* @void
|
||||
*/
|
||||
public function __construct($message, $code = 0, Exception $previous = null)
|
||||
{
|
||||
// make sure everything is assigned properly
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert exception to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -91,17 +91,15 @@ define('NET_NNTP_PROTOCOL_RESPONSECODE_READY_POSTING_PROHIBITED', 201);
|
||||
* 'Closing connection - goodbye!' (RFC977)
|
||||
*
|
||||
* @access public
|
||||
* @since ?
|
||||
*/
|
||||
//define('NET_NNTP_PROTOCOL_RESPONSECODE_DISCONNECTING_REQUESTED', 205); ///// goodbye
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_DISCONNECTING_REQUESTED', 205);
|
||||
|
||||
/**
|
||||
* 'Service discontinued' (RFC977)
|
||||
*
|
||||
* @access public
|
||||
* @since ?
|
||||
*/
|
||||
//define('NET_NNTP_PROTOCOL_RESPONSECODE_DISCONNECTING_FORCED', 400); ///// unavailable / discontinued
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_DISCONNECTING_FORCED', 400);
|
||||
|
||||
|
||||
/**
|
||||
@@ -168,6 +166,12 @@ define('NET_NNTP_PROTOCOL_RESPONSECODE_GROUP_SELECTED', 211);
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_NO_SUCH_GROUP', 411);
|
||||
|
||||
/**
|
||||
* 'Groups and descriptions unavailable'
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_XGTITLE_GROUPS_UNAVAILABLE', 481);
|
||||
|
||||
// }}}
|
||||
// {{{ Constants: Article retrieval
|
||||
@@ -249,6 +253,13 @@ define('NET_NNTP_PROTOCOL_RESPONSECODE_NO_SUCH_ARTICLE_NUMBER', 423);
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_NO_SUCH_ARTICLE_ID', 430);
|
||||
|
||||
/**
|
||||
* 'List of groups and descriptions follows' (RFC2980)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_XGTITLE_GROUPS_FOLLOW', 482);
|
||||
|
||||
|
||||
// }}}
|
||||
// {{{ Constants: Transferring
|
||||
@@ -383,6 +394,13 @@ define('NET_NNTP_PROTOCOL_RESPONSECODE_AUTHENTICATION_REQUIRED', 480);
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_AUTHENTICATION_CONTINUE', 381);
|
||||
|
||||
/**
|
||||
* 'Continue with TLS negotiation' (RFC4642)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_TLS_AUTHENTICATION_CONTINUE', 382);
|
||||
|
||||
/**
|
||||
* 'Authentication accepted' (RFC2980)
|
||||
*
|
||||
@@ -491,6 +509,14 @@ define('NET_NNTP_PROTOCOL_RESPONSECODE_INTERNAL_FAULT', 403);
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_BASE64_ENCODING_ERROR', 504);
|
||||
|
||||
/**
|
||||
* 'Can not initiate TLS negotiation' (RFC4642)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
define('NET_NNTP_PROTOCOL_RESPONSECODE_TLS_FAILED_NEGOTIATION', 580);
|
||||
|
||||
|
||||
// }}}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once(WWW_DIR."/lib/framework/db.php");
|
||||
require_once(WWW_DIR."/lib/category.php");
|
||||
|
||||
/**
|
||||
* This class handles data access for genre data.
|
||||
*/
|
||||
class Genres
|
||||
{
|
||||
const CONSOLE_TYPE = Category::CAT_PARENT_GAME;
|
||||
const MUSIC_TYPE = Category::CAT_PARENT_MUSIC;
|
||||
const BOOK_TYPE = Category::CAT_BOOK_EBOOK;
|
||||
const GAME_TYPE = Category::CAT_PARENT_PC;
|
||||
|
||||
/**
|
||||
* Get genre rows, filter by type/active.
|
||||
*/
|
||||
public function getGenres($type='', $activeonly=false, $usecache=false)
|
||||
{
|
||||
$db = new DB();
|
||||
|
||||
if (!empty($type))
|
||||
$typesql = sprintf(" and genres.type = %d", $type);
|
||||
else
|
||||
$typesql = '';
|
||||
|
||||
if ($activeonly)
|
||||
{
|
||||
$sql = sprintf("SELECT genres.* FROM genres INNER JOIN (SELECT DISTINCT genreID FROM musicinfo) X ON X.genreID = genres.ID %s
|
||||
UNION
|
||||
SELECT genres.* FROM genres INNER JOIN (SELECT DISTINCT genreID FROM consoleinfo) X ON X.genreID = genres.ID %s
|
||||
ORDER BY title", $typesql, $typesql);
|
||||
}
|
||||
else
|
||||
$sql = sprintf("select genres.* from genres where 1 %s order by title", $typesql);
|
||||
|
||||
return $db->query($sql, $usecache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new genre.
|
||||
*/
|
||||
public function getOrAddGenreKey($genreName, &$genreassoc)
|
||||
{
|
||||
if (in_array(strtolower($genreName), $genreassoc))
|
||||
{
|
||||
$genreKey = array_search(strtolower($genreName), $genreassoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$db = new DB();
|
||||
$genreKey = $db->queryInsert(sprintf("INSERT INTO genres (`title`, `type`) VALUES (%s, %d)", $db->escapeString($genreName), Genres::MUSIC_TYPE));
|
||||
$genreassoc[$genreKey] = strtolower($genreName);
|
||||
}
|
||||
|
||||
return $genreKey;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Attempt to include PEAR's nntp class if it has not already been included.
|
||||
*/
|
||||
|
||||
@@ -157,7 +157,7 @@ class Users
|
||||
return $db->queryInsert($sql);
|
||||
}
|
||||
|
||||
public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl = false, $nzbvortexApiKey = false)
|
||||
public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl = false, $nzbvortexApiKey = false)
|
||||
{
|
||||
$db = new DB();
|
||||
|
||||
@@ -190,6 +190,7 @@ class Users
|
||||
$sql[] = sprintf('invites = %d', $invites);
|
||||
$sql[] = sprintf('movieview = %d', $movieview);
|
||||
$sql[] = sprintf('musicview = %d', $musicview);
|
||||
$sql[] = sprintf('gameview = %d', $gameview);
|
||||
$sql[] = sprintf('consoleview = %d', $consoleview);
|
||||
$sql[] = sprintf('bookview = %d', $bookview);
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
require_once(WWW_DIR."/lib/releases.php");
|
||||
require_once(WWW_DIR."/lib/category.php");
|
||||
|
||||
$releases = new Releases;
|
||||
|
||||
if (!$users->isLoggedIn())
|
||||
$page->show403();
|
||||
|
||||
$category = -1;
|
||||
if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"]))
|
||||
$category = $_REQUEST["t"];
|
||||
|
||||
$grp = array();
|
||||
if (isset($_REQUEST["g"]))
|
||||
$grp = explode(",", $_REQUEST["g"]);
|
||||
|
||||
$catarray = array();
|
||||
$catarray[] = $category;
|
||||
|
||||
$page->smarty->assign('category', $category);
|
||||
$browsecount = $releases->getBrowseCount($catarray, -1, $page->userdata["categoryexclusions"], $grp);
|
||||
|
||||
$offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0;
|
||||
$ordering = $releases->getBrowseOrdering();
|
||||
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
|
||||
|
||||
$results = array();
|
||||
$results = $releases->getBrowseRange($catarray, $offset, ITEMS_PER_PAGE, $orderby, -1, $page->userdata["categoryexclusions"], $grp);
|
||||
|
||||
$page->smarty->assign('pagertotalitems',$browsecount);
|
||||
$page->smarty->assign('pageroffset',$offset);
|
||||
$page->smarty->assign('pageritemsperpage',ITEMS_PER_PAGE);
|
||||
$page->smarty->assign('pagerquerybase', WWW_TOP."/browse?t=".$category.(count($grp) > 0 ? "&g=".$grp[0] : "")."&ob=".$orderby."&offset=");
|
||||
$page->smarty->assign('pagerquerysuffix', "#results");
|
||||
|
||||
$pager = $page->smarty->fetch("pager.tpl");
|
||||
$page->smarty->assign('pager', $pager);
|
||||
|
||||
$section = '';
|
||||
if ($category == -1 && count($grp) == 0)
|
||||
$page->smarty->assign("catname","All");
|
||||
elseif ($category != -1 && count($grp) == 0)
|
||||
{
|
||||
$cat = new Category();
|
||||
$cdata = $cat->getById($category);
|
||||
|
||||
if ($cdata) {
|
||||
$page->smarty->assign('catname',$cdata["title"]);
|
||||
if ($cdata['parentID'] == Category::CAT_PARENT_GAME || $cdata['ID'] == Category::CAT_PARENT_GAME)
|
||||
$section = 'console';
|
||||
elseif ($cdata['ID'] == Category::CAT_BOOK_EBOOK)
|
||||
$section = 'books';
|
||||
elseif ($cdata['parentID'] == Category::CAT_PARENT_MOVIE || $cdata['ID'] == Category::CAT_PARENT_MOVIE)
|
||||
$section = 'movies';
|
||||
elseif ($cdata['parentid'] == Category::CAT_PARENT_PC || $cdata['ID'] == Category::CAT_PC_GAMES)
|
||||
$section = 'games';
|
||||
elseif ($cdata['parentID'] == Category::CAT_PARENT_MUSIC || $cdata['ID'] == Category::CAT_PARENT_MUSIC)
|
||||
$section = 'music';
|
||||
} else {
|
||||
$page->show404();
|
||||
}
|
||||
}
|
||||
elseif (count($grp) > 0)
|
||||
{
|
||||
$page->smarty->assign('catname',$grp[0]);
|
||||
}
|
||||
$page->smarty->assign('section',$section);
|
||||
|
||||
foreach($ordering as $ordertype)
|
||||
$page->smarty->assign('orderby'.$ordertype, WWW_TOP."/browse?t=".$category."&ob=".$ordertype."&offset=0".(count($grp) > 0 ? "&g=".$grp[0] : ""));
|
||||
|
||||
$page->smarty->assign('lastvisit',$page->userdata['lastlogin']);
|
||||
|
||||
$page->smarty->assign('results',$results);
|
||||
|
||||
$page->meta_title = "Browse Nzbs";
|
||||
$page->meta_keywords = "browse,nzb,description,details";
|
||||
$page->meta_description = "Browse for Nzbs";
|
||||
|
||||
$page->content = $page->smarty->fetch('browse.tpl');
|
||||
$page->render();
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
require_once(WWW_DIR . "/lib/category.php");
|
||||
require_once(WWW_DIR . "/lib/Games.php");
|
||||
require_once(WWW_DIR . "/lib/genres.php");
|
||||
if (!$users->isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$games = new Games();
|
||||
$cat = new Category();
|
||||
$gen = new Genres();
|
||||
|
||||
$concats = $cat->getChildren(Category::CAT_PARENT_PC);
|
||||
$ctmp = array();
|
||||
foreach ($concats as $ccat) {
|
||||
$ctmp[$ccat['ID']] = $ccat;
|
||||
}
|
||||
$category = Category::CAT_PC_GAMES;
|
||||
if (isset($_REQUEST["t"]) && array_key_exists($_REQUEST['t'], $ctmp)) {
|
||||
$category = $_REQUEST["t"] + 0;
|
||||
}
|
||||
|
||||
$catarray = array();
|
||||
$catarray[] = $category;
|
||||
|
||||
$page->smarty->assign('catlist', $ctmp);
|
||||
$page->smarty->assign('category', $category);
|
||||
|
||||
$browsecount = $games->getgamesCount($catarray, -1, $page->userdata["categoryexclusions"]);
|
||||
|
||||
$offset = (isset($_REQUEST["offset"]) && ctype_digit($_REQUEST['offset'])) ? $_REQUEST["offset"] : 0;
|
||||
$ordering = $games->getgamesOrdering();
|
||||
|
||||
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
|
||||
|
||||
$results = $games2 = array();
|
||||
$results = $games->getgamesRange($catarray, $offset, ITEMS_PER_PAGE_SMALL, $orderby, -1, $page->userdata["categoryexclusions"]);
|
||||
$maxwords = 50;
|
||||
foreach ($results as $result) {
|
||||
if (!empty($result['review'])) {
|
||||
$words = explode(' ', $result['review']);
|
||||
if (sizeof($words) > $maxwords) {
|
||||
$newwords = array_slice($words, 0, $maxwords);
|
||||
$result['review'] = implode(' ', $newwords) . '...';
|
||||
}
|
||||
}
|
||||
$games2[] = $result;
|
||||
}
|
||||
$platform = (isset($_REQUEST['platform']) && !empty($_REQUEST['platform'])) ? stripslashes($_REQUEST['platform']) : '';
|
||||
$page->smarty->assign('platform', $platform);
|
||||
|
||||
$title = (isset($_REQUEST['title']) && !empty($_REQUEST['title'])) ? stripslashes($_REQUEST['title']) : '';
|
||||
$page->smarty->assign('title', $title);
|
||||
|
||||
$genres = $gen->getGenres(Genres::GAME_TYPE, true);
|
||||
$tmpgnr = array();
|
||||
foreach ($genres as $gn) {
|
||||
$tmpgnr[$gn['ID']] = $gn['title'];
|
||||
}
|
||||
$genre = (isset($_REQUEST['genre']) && array_key_exists($_REQUEST['genre'], $tmpgnr)) ? $_REQUEST['genre'] : '';
|
||||
$page->smarty->assign('genres', $genres);
|
||||
$page->smarty->assign('genre', $genre);
|
||||
|
||||
$browseby_link = '&title=' . $title . '&platform=' . $platform;
|
||||
|
||||
$page->smarty->assign('pagertotalitems', $browsecount);
|
||||
$page->smarty->assign('pageroffset', $offset);
|
||||
$page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE_SMALL);
|
||||
$page->smarty->assign('pagerquerybase', WWW_TOP . "/games?t=" . $category . $browseby_link . "&ob=" . $orderby . "&offset=");
|
||||
$page->smarty->assign('pagerquerysuffix', "#results");
|
||||
|
||||
$pager = $page->smarty->fetch("pager.tpl");
|
||||
$page->smarty->assign('pager', $pager);
|
||||
|
||||
if ($category == -1) {
|
||||
$page->smarty->assign("catname", "All");
|
||||
} else {
|
||||
$cdata = $cat->getById($category);
|
||||
if ($cdata) {
|
||||
$page->smarty->assign('catname', $cdata["title"]);
|
||||
} else {
|
||||
$page->show404();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ordering as $ordertype) {
|
||||
$page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/games?t=" . $category . $browseby_link . "&ob=" . $ordertype . "&offset=0");
|
||||
}
|
||||
|
||||
$page->smarty->assign('results', $games2);
|
||||
|
||||
$page->meta_title = "Browse Games";
|
||||
$page->meta_keywords = "browse,nzb,games,description,details";
|
||||
$page->meta_description = "Browse for Games";
|
||||
|
||||
$page->content = $page->smarty->fetch('games.tpl');
|
||||
$page->render();
|
||||
@@ -67,6 +67,7 @@ switch ($action) {
|
||||
$data["invites"],
|
||||
(isset($_POST['movieview']) ? "1" : "0"),
|
||||
(isset($_POST['musicview']) ? "1" : "0"),
|
||||
(isset($_POST['gameview']) ? "1" : "0"),
|
||||
(isset($_POST['consoleview']) ? "1" : "0"),
|
||||
(isset($_POST['bookview']) ? "1" : "0"),
|
||||
$_POST['queuetypeids'],
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 815 B |
@@ -232,6 +232,14 @@
|
||||
<div class="hint">The amazon associate tag. Used for cover lookups.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:180px;"><label for="giantbombkey">Giant Bomb API Key:</label></td>
|
||||
<td>
|
||||
<input id="giantbombkey" class="long" name="giantbombkey" type="text" value="{$fsite->giantbombkey}"/>
|
||||
|
||||
<div class="hint">The giantbomb key. Used for game lookups.</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
@@ -981,5 +989,4 @@
|
||||
|
||||
<input type="submit" value="Save Site Settings" />
|
||||
|
||||
</form>
|
||||
|
||||
</form>
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
<h1>{$page->title}</h1>
|
||||
|
||||
{if $error != ''}
|
||||
@@ -31,7 +31,7 @@
|
||||
{if $user.ID}
|
||||
<div class="hint">Only enter a password if you want to change it.</div>
|
||||
{/if}
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
{if $user.ID}
|
||||
<tr>
|
||||
@@ -63,6 +63,13 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Game View:</td>
|
||||
<td>
|
||||
<input name="gameview" type="checkbox" value="1" {if $user.gameview=="1"}checked="checked"{/if}" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Console View:</td>
|
||||
<td>
|
||||
@@ -95,16 +102,16 @@
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" value="Save" />
|
||||
|
||||
|
||||
{if $user.ID != ""}
|
||||
<input onclick="return doDelete();" type="button" value="Delete" />
|
||||
|
||||
<input onclick="return doDelete();" type="button" value="Delete" />
|
||||
|
||||
<script type="text/javascript">
|
||||
function doDelete()
|
||||
{
|
||||
if (confirm('Are you sure?'))
|
||||
window.location='user-delete.php?id={$user.ID}&redir=user-list.php';
|
||||
else
|
||||
if (confirm('Are you sure?'))
|
||||
window.location='user-delete.php?id={$user.ID}&redir=user-list.php';
|
||||
else
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
{if $site->adbrowse}
|
||||
{$site->adbrowse}
|
||||
{/if}
|
||||
<h1>Browse Games</h1>
|
||||
|
||||
<form name="browseby" action="games">
|
||||
<table class="rndbtn" border="0" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<th class="left"><label for="title">Title</label></th>
|
||||
<th class="left"><label for="platform">Platform</label></th>
|
||||
<th class="left"><label for="genre">Genre</label></th>
|
||||
<th class="left"><label for="category">Category</label></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="title" type="text" name="title" value="{$title}" size="15"/></td>
|
||||
<td><input id="platform" type="text" name="platform" value="{$platform}" size="15"/></td>
|
||||
<td>
|
||||
<select id="genre" name="genre">
|
||||
<option class="grouping" value=""></option>
|
||||
{foreach from=$genres item=gen}
|
||||
<option {if $gen.id == $genre}selected="selected"{/if} value="{$gen.id}">{$gen.title}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="category" name="t">
|
||||
<option class="grouping" value="1000"></option>
|
||||
{foreach from=$catlist item=ct}
|
||||
<option {if $ct.id==$category}selected="selected"{/if} value="{$ct.id}">{$ct.title}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</td>
|
||||
<td><input class='rndbtn' type="submit" value="Go"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<p></p>
|
||||
|
||||
{if $results|@count > 0}
|
||||
<form id="nzb_multi_operations_form" action="get">
|
||||
|
||||
<div class="nzb_multi_operations">
|
||||
View: <b>Covers</b> | <a href="{$smarty.const.WWW_TOP}/browse?t={$category}">List</a><br/>
|
||||
<small>With Selected:</small>
|
||||
<input type="button" class="nzb_multi_operations_download" value="Download NZBs"/>
|
||||
<input type="button" class="nzb_multi_operations_cart" value="Add to Cart"/>
|
||||
{if $sabintegrated}<input type="button" class="nzb_multi_operations_sab" value="Send to my Queue"/>{/if}
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
{$pager}
|
||||
|
||||
<table style="width:100%;" class="data highlight icons" id="coverstable">
|
||||
<tr>
|
||||
<th width="130"><input type="checkbox" class="nzb_check_all"/></th>
|
||||
<th>title<br/><a title="Sort Descending" href="{$orderbytitle_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbytitle_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>platform<br/><a title="Sort Descending" href="{$orderbyplatform_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbyplatform_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>genre<br/><a title="Sort Descending" href="{$orderbygenre_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbygenre_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>release date<br/><a title="Sort Descending" href="{$orderbyreleasedate_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbyreleasedate_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>posted<br/><a title="Sort Descending" href="{$orderbyposted_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbyposted_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>size<br/><a title="Sort Descending" href="{$orderbysize_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbysize_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>files<br/><a title="Sort Descending" href="{$orderbyfiles_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbyfiles_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
<th>stats<br/><a title="Sort Descending" href="{$orderbystats_desc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif"
|
||||
alt=""/></a><a title="Sort Ascending" href="{$orderbystats_asc}"><img
|
||||
src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt=""/></a>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
{foreach from=$results item=result}
|
||||
<tr class="{cycle values=",alt"}">
|
||||
<td class="mid">
|
||||
<div class="movcover">
|
||||
<a class="title" title="View details"
|
||||
href="{$smarty.const.WWW_TOP}/details/{$result.guid}/{$result.searchname|escape:"htmlall"}">
|
||||
<img class="shadow"
|
||||
src="{$smarty.const.WWW_TOP}/covers/games/{if $result.cover == 1}{$result.gamesinfo_id}.jpg{else}no-cover.jpg{/if}"
|
||||
width="120" border="0" alt="{$result.title|escape:"htmlall"}"/>
|
||||
</a>
|
||||
|
||||
<div class="movextra">
|
||||
{if $result.nfoid > 0}<a href="{$smarty.const.WWW_TOP}/nfo/{$result.guid}"
|
||||
title="View Nfo" class="rndbtn modal_nfo" rel="nfo">
|
||||
Nfo</a>{/if}
|
||||
<a class="rndbtn" target="_blank" href="{$site->dereferrer_link}{$result.url}"
|
||||
name="amazon{$result.gamesinfo_id}" title="View amazon page">Amazon</a>
|
||||
<a class="rndbtn" target="_blank"
|
||||
href="{$site->dereferrer_link}http://ign.com/search?q={$result.title|escape:"htmlall"}&page=0&count=10&type=object&objectType=game&filter=games&"
|
||||
name="ign{$result.gamesinfo_id}" title="View ign page">IGN</a>
|
||||
<a class="rndbtn" target="_blank"
|
||||
href="{$site->dereferrer_link}http://www.gamespot.com/search/?qs={$result.title|escape:"htmlall"}/"
|
||||
name="gamespot{$result.gamesinfo_id}" title="View gamespot page">Gamespot</a>
|
||||
<a class="rndbtn" target="_blank"
|
||||
href="{$site->dereferrer_link}http://www.metacritic.com/search/game/{$result.title|escape:"htmlall"}/results"
|
||||
name="metacritic{$result.gamesinfo_id}" title="View metacritic page">Metacritic</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="8" class="left" id="guid{$result.guid}">
|
||||
<h2><a class="title" title="View details"
|
||||
href="{$smarty.const.WWW_TOP}/details/{$result.guid}/{$result.searchname|escape:"htmlall"}">{$result.title|stripslashes|escape:"htmlall"}
|
||||
- {$result.platform|escape:"htmlall"}</a></h2>
|
||||
{if $result.genre != ""}<b>Genre:</b>{$result.genre}<br/>{/if}
|
||||
{if $result.esrb != ""}<b>Rating:</b>{$result.esrb}<br/>{/if}
|
||||
{if $result.publisher != ""}<b>Publisher:</b>{$result.publisher}<br/>{/if}
|
||||
{if $result.releasedate != ""}<b>Released:</b>{$result.releasedate|date_format}<br/>{/if}
|
||||
{if $result.review != ""}<b>Review:</b>{$result.review|stripslashes|escape:'htmlall'}<br/>{/if}
|
||||
<br/>
|
||||
|
||||
<div class="movextra">
|
||||
<table>
|
||||
{assign var="msplits" value=","|explode:$result.grp_release_id}
|
||||
{assign var="mguid" value=","|explode:$result.grp_release_guid}
|
||||
{assign var="mnfo" value=","|explode:$result.grp_release_nfoid}
|
||||
{assign var="mgrp" value=","|explode:$result.grp_release_grpname}
|
||||
{assign var="mname" value="#"|explode:$result.grp_release_name}
|
||||
{assign var="mpostdate" value=","|explode:$result.grp_release_postdate}
|
||||
{assign var="msize" value=","|explode:$result.grp_release_size}
|
||||
{assign var="mtotalparts" value=","|explode:$result.grp_release_totalparts}
|
||||
{assign var="mcomments" value=","|explode:$result.grp_release_comments}
|
||||
{assign var="mgrabs" value=","|explode:$result.grp_release_grabs}
|
||||
{assign var="mpass" value=","|explode:$result.grp_release_password}
|
||||
{assign var="minnerfiles" value=","|explode:$result.grp_rarinnerfilecount}
|
||||
{assign var="mhaspreview" value=","|explode:$result.grp_haspreview}
|
||||
{foreach from=$msplits item=m}
|
||||
<tr id="guid{$mguid[$m@index]}" {if $m@index > 1}class="mlextra"{/if}>
|
||||
<td>
|
||||
<div class="icon"><input type="checkbox" class="nzb_check"
|
||||
value="{$mguid[$m@index]}"/></div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{$smarty.const.WWW_TOP}/details/{$mguid[$m@index]}/{$mname[$m@index]|escape:"htmlall"}">{$mname[$m@index]|escape:"htmlall"}</a>
|
||||
|
||||
<div>
|
||||
<i class="icon-calendar"></i> Posted {$mpostdate[$m@index]|timeago} | <i
|
||||
class="icon-hdd"></i> {$msize[$m@index]|fsize_format:"MB"} | <i
|
||||
class="icon-file"></i> <a title="View file list"
|
||||
href="{$smarty.const.WWW_TOP}/filelist/{$mguid[$m@index]}">{$mtotalparts[$m@index]}
|
||||
files</a> | <i class="icon-comments"></i> <a
|
||||
title="View comments for {$mname[$m@index]|escape:"htmlall"}"
|
||||
href="{$smarty.const.WWW_TOP}/details/{$mguid[$m@index]}/{$mname[$m@index]|escape:"htmlall"}#comments">{$mcomments[$m@index]}
|
||||
cmt{if $mcomments[$m@index] != 1}s{/if}</a> | <i
|
||||
class="icon-download"></i> {$mgrabs[$m@index]}
|
||||
grab{if $mgrabs[$m@index] != 1}s{/if} |
|
||||
{if $mnfo[$m@index] > 0}<a
|
||||
href="{$smarty.const.WWW_TOP}/nfo/{$mguid[$m@index]}"
|
||||
title="View Nfo" class="modal_nfo" rel="nfo">Nfo</a> | {/if}
|
||||
{if $mpass[$m@index] == 1}Passworded | {elseif $mpass[$m@index] == 2}Potential Password | {/if}
|
||||
<a href="{$smarty.const.WWW_TOP}/browse?g={$mgrp[$m@index]}"
|
||||
title="Browse releases in {$mgrp[$m@index]|replace:"alt.binaries":"a.b"}">Grp</a>
|
||||
{if $mhaspreview[$m@index] == 1 && $userdata.canpreview == 1} | <a
|
||||
href="{$smarty.const.WWW_TOP}/covers/preview/{$mguid[$m@index]}_thumb.jpg"
|
||||
name="name{$mguid[$m@index]}"
|
||||
title="Screenshot of {$mname[$m@index]|escape:"htmlall"}"
|
||||
class="modal_prev" rel="preview">Preview</a>{/if}
|
||||
{if $minnerfiles[$m@index] > 0} | <a href="#" onclick="return false;"
|
||||
class="mediainfo"
|
||||
title="{$mguid[$m@index]}">
|
||||
Media</a>{/if}
|
||||
</div>
|
||||
</td>
|
||||
<td class="icons">
|
||||
<div class="icon icon_nzb"><a title="Download Nzb"
|
||||
href="{$smarty.const.WWW_TOP}/getnzb/{$mguid[$m@index]}/{$mname[$m@index]|escape:"htmlall"}">
|
||||
</a></div>
|
||||
<div class="icon icon_cart" title="Add to Cart"></div>
|
||||
{if $sabintegrated}
|
||||
<div class="icon icon_sab" title="Send to my Queue"></div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{if $m@index == 1 && $m@total > 2}
|
||||
<tr>
|
||||
<td colspan="5"><a class="mlmore" href="#">{$m@total-2} more...</a></td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
{$pager}
|
||||
|
||||
<div class="nzb_multi_operations">
|
||||
<small>With Selected:</small>
|
||||
<input type="button" class="nzb_multi_operations_download" value="Download NZBs"/>
|
||||
<input type="button" class="nzb_multi_operations_cart" value="Add to Cart"/>
|
||||
{if $sabintegrated}<input type="button" class="nzb_multi_operations_sab" value="Send to my Queue"/>{/if}
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{else}
|
||||
<h4>There doesn't seem to be any releases here. Please try the <a
|
||||
href="{$smarty.const.WWW_TOP}/browse?t={$category}">list</a> view.</h4>
|
||||
{/if}
|
||||
|
||||
<br/><br/><br/>
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="menucontainer">
|
||||
<div id="menucontainer">
|
||||
<div id="menulink">
|
||||
<ul>
|
||||
{foreach from=$parentcatlist item=parentcat}
|
||||
@@ -30,6 +30,20 @@
|
||||
{/foreach}
|
||||
</ul>
|
||||
</li>
|
||||
{elseif ($parentcat.ID == 4000 && $userdata.gameview=="1")}
|
||||
<li><a title="Browse {$parentcat.title}" href="{$smarty.const.WWW_TOP}/games">{$parentcat.title}</a>
|
||||
<ul>
|
||||
{foreach from=$parentcat.subcatlist item=subcat}
|
||||
{if $subcat.ID == 4050}
|
||||
<li><a title="Browse {$subcat.title}"
|
||||
href="{$smarty.const.WWW_TOP}/games">{$subcat.title}</a></li>
|
||||
{else}
|
||||
<li><a title="Browse {$subcat.title}"
|
||||
href="{$smarty.const.WWW_TOP}/browse?t={$subcat.ID}">{$subcat.title}</a></li>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</ul>
|
||||
</li>
|
||||
{else}
|
||||
<li><a title="Browse {$parentcat.title}" href="{$smarty.const.WWW_TOP}/browse?t={$parentcat.ID}">{$parentcat.title}</a>
|
||||
<ul>
|
||||
@@ -51,7 +65,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="menusearchlink">
|
||||
<form id="headsearch_form" action="{$smarty.const.WWW_TOP}/search/" method="get">
|
||||
|
||||
@@ -69,7 +83,9 @@
|
||||
</select>
|
||||
|
||||
<label style="display:none;" for="headsearch">Search Text</label>
|
||||
<input id="headsearch" name="search" value="{if $header_menu_search == ""}Enter keywords{else}{$header_menu_search|escape:"htmlall"}{/if}" style="width:85px;" type="text" tabindex="1" />
|
||||
<input id="headsearch" name="search"
|
||||
value="{if $header_menu_search == ""}Enter keywords{else}{$header_menu_search|escape:"htmlall"}{/if}"
|
||||
style="width:85px;" type="text" tabindex="1"/>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
|
||||
<h1>Profile for {$user.username|escape:"htmlall"}</h1>
|
||||
|
||||
<table class="data">
|
||||
@@ -14,11 +14,11 @@
|
||||
<tr><th>Grabs Today:</th><td><span id="ugrtd">{$grabstoday.num}</span> {if $grabstoday.num >= $user.downloadrequests} <small>(Next DL in {($grabstoday.nextdl/3600)|intval}h {($grabstoday.nextdl/60) % 60}m)</small>{/if}{if $userdata.role==2 && $grabstoday.num > 0}<a onclick="resetapireq({$user.ID}, 'grabs'); document.getElementById('ugrtd').innerHTML='0'; return false;" href="#">Reset</a>{/if}</td></tr>
|
||||
{/if}
|
||||
<tr><th>Grabs Total:</th><td>{$user.grabs}</td></tr>
|
||||
|
||||
|
||||
{if ($user.ID==$userdata.ID || $userdata.role==2) && $site->registerstatus==1}
|
||||
<tr>
|
||||
<th title="Not public">Invites:</th>
|
||||
<td>{$user.invites}
|
||||
<td>{$user.invites}
|
||||
{if $user.invites > 0}
|
||||
[<a id="lnkSendInvite" onclick="return false;" href="#">Send Invite</a>]
|
||||
<span title="Your invites will be reduced when the invitation is claimed." class="invitesuccess" id="divInviteSuccess">Invite Sent</span>
|
||||
@@ -34,15 +34,16 @@
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
|
||||
{if $userinvitedby && $userinvitedby.username != ""}
|
||||
<tr><th>Invited By:</th><td><a title="View {$userinvitedby.username}'s profile" href="{$smarty.const.WWW_TOP}/profile?name={$userinvitedby.username}">{$userinvitedby.username}</a></td>
|
||||
{/if}
|
||||
|
||||
|
||||
<tr><th>UI Preferences:</th>
|
||||
<td>
|
||||
{if $user.movieview == "1"}View movie covers{else}View standard movie category{/if}<br/>
|
||||
{if $user.musicview == "1"}View music covers{else}View standard music category{/if}<br/>
|
||||
{if $user.gameview == "1"}View game covers{else}View standard game category{/if}<br/>
|
||||
{if $user.consoleview == "1"}View console covers{else}View standard console category{/if}<br/>
|
||||
{if $user.bookview == "1"}View book covers{else}View standard book category{/if}
|
||||
</td>
|
||||
@@ -58,7 +59,7 @@
|
||||
Storage: {if $sabsetting == ''}N/A{else}{$sabsetting}{/if}
|
||||
</td>
|
||||
{/if}
|
||||
|
||||
|
||||
{if ($user.ID==$userdata.ID)}
|
||||
<tr>
|
||||
<th>NZBVortex</th>
|
||||
@@ -74,8 +75,8 @@
|
||||
<tr><th>My TV Shows:</th><td><a href="{$smarty.const.WWW_TOP}/myshows">Manage my shows</a></td></tr>
|
||||
<tr><th>My Movies:</th><td><a href="{$smarty.const.WWW_TOP}/mymovies">Manage my movies</a></td></tr>
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
|
||||
{if $user.ID==$userdata.ID}<tr><th></th><td><a href="{$smarty.const.WWW_TOP}/profileedit">Edit</a></td></tr>{/if}
|
||||
</table>
|
||||
|
||||
@@ -91,7 +92,7 @@
|
||||
<th>hosthash</th>
|
||||
<th>release</th>
|
||||
</tr>
|
||||
|
||||
|
||||
{foreach from=$downloadlist item=download}
|
||||
{if $download@iteration == 10}
|
||||
<tr class="more"><td colspan="3"><a onclick="$('tr.extra').toggle();$('tr.more').toggle();return false;" href="#">show all...</a></td></tr>
|
||||
@@ -121,7 +122,7 @@
|
||||
<th>comment</th>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
{foreach from=$commentslist item=comment}
|
||||
<tr>
|
||||
<td width="80" title="{$comment.createddate}">{$comment.createddate|date_format}</td>
|
||||
|
||||
@@ -60,6 +60,13 @@
|
||||
<div class="hint">Browse music covers. Only shows music with known lookup info.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>View Game Page:</th>
|
||||
<td>
|
||||
<input id="gameview" name="gameview" value="1" type="checkbox" {if $user.gameview=="1"}checked="checked"{/if}>
|
||||
<div class="hint">Browse game covers. Only shows games with known lookup info.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>View Console Page:</th>
|
||||
<td>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
//This script will update all records in the gamesinfo table
|
||||
require_once(dirname(__FILE__) . "/../bin/config.php");
|
||||
require_once(WWW_DIR . "/lib/Games.php");
|
||||
require_once("ColorCLI.php");
|
||||
|
||||
|
||||
$game = new Games(true);
|
||||
$pdo = new DB();
|
||||
$c = new ColorCLI();
|
||||
|
||||
$res = $pdo->query(
|
||||
sprintf("SELECT searchname FROM releases WHERE gamesinfo_id IS NULL AND categoryID = 4050 ORDER BY ID DESC LIMIT 100")
|
||||
);
|
||||
$total = count($res);
|
||||
if ($total > 0) {
|
||||
echo $c->header("Updating game info for " . number_format($total) . " releases.");
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = microtime(true);
|
||||
$gameInfo = $game->parseTitle($arr['searchname']);
|
||||
if ($gameInfo !== false) {
|
||||
$gameData = $game->updateGamesInfo($gameInfo);
|
||||
if ($gameData === false) {
|
||||
echo $c->primary($gameInfo['release'] . ' not found');
|
||||
}
|
||||
}
|
||||
|
||||
// amazon limits are 1 per 1 sec
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
echo $c->alternate("Sleeping");
|
||||
usleep(1000000 - $diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . "/../bin/config.php");
|
||||
require_once(WWW_DIR . "/lib/framework/db.php");
|
||||
require_once("ColorCLI.php");
|
||||
|
||||
$pdo = new DB();
|
||||
$covers = $updated = $deleted = 0;
|
||||
$c = new ColorCLI();
|
||||
|
||||
if ($argc == 1 || $argv[1] != 'true') {
|
||||
exit($c->error("\nThis script will check all images in covers/games and compare to db->gamesinfo.\nTo run:\nphp $argv[0] true\n"));
|
||||
}
|
||||
$path2covers = WWW_DIR . 'covers/games' . '/';
|
||||
|
||||
$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.");
|
||||
@@ -15,7 +15,7 @@ $tmux = $t->get();
|
||||
$patch = (isset($tmux->sqlpatch)) ? $tmux->sqlpatch : 0;
|
||||
|
||||
// Check database patch version
|
||||
if ($patch < 51) {
|
||||
if ($patch < 55) {
|
||||
exit($c->error("\nYour database is not up to date. Please update.\nphp ${DIR}/lib/DB/patchDB.php\n"));
|
||||
}
|
||||
$tmux_session = (isset($tmux->tmux_session)) ? $tmux->tmux_session : 0;
|
||||
|
||||
Reference in New Issue
Block a user