Change site table to settings table, move files around and adjust to new settings table. patchDB needs to be fixed for the final patch is is used for.

This commit is contained in:
Darko
2015-05-26 16:05:42 +02:00
parent 53293bea16
commit c8022ee1be
321 changed files with 4154 additions and 829 deletions
+2 -2
View File
@@ -2,14 +2,14 @@
require_once(dirname(__FILE__)."/config.php");
use newznab\db\DB;
use newznab\db\Settings;
use newznab\processing\PProcess;
$c = new ColorCLI();
if (!isset($argv[1])) {
exit($c->error("This script is not intended to be run manually, it is called from fixreleasenames_threaded.py."));
} else if (isset($argv[1])) {
$db = new DB();
$db = new Settings();
$namefixer = new \NameFixer(['Settings' => $pdo]);
$pieces = explode(' ', $argv[1]);
if (isset($pieces[1]) && $pieces[0] == 'nfo') {
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
require_once(dirname(__FILE__) . "/config.php");
use newznab\db\DB;
use newznab\db\Settings;
use newznab\processing\PProcess;
$pdo = new DB();
$pdo = new Settings();
$s = new Sites();
$site = $s->get();
+2 -2
View File
@@ -2,10 +2,10 @@
require_once(dirname(__FILE__) . '/config.php');
use newznab\db\DB;
use newznab\db\Settings;
use newznab\processing\PProcess;
$pdo = new DB();
$pdo = new Settings();
$s = new Sites();
$site = $s->get();
/**
+2 -2
View File
@@ -2,11 +2,11 @@
require_once(dirname(__FILE__).'/config.php');
use newznab\db\DB;
use newznab\db\Settings;
$start = TIME();
$pdo = new DB();
$pdo = new Settings();
$consoleTools = new \ConsoleTools(['ColorCLI' => $pdo->log]);
// Create the connection here and pass
+2 -2
View File
@@ -1,12 +1,12 @@
<?php
require_once(dirname(__FILE__) . "/config.php");
use newznab\db\DB;
use newznab\db\Settings;
use newznab\processing\ProcessReleases;
$s = new \Sites();
$site = $s->get();
$pdo = new DB();
$pdo = new Settings();
if (isset($argv[2]) && $argv[2] === 'true') {
// Create the connection here and pass
+2 -2
View File
@@ -1,12 +1,12 @@
<?php
require_once(dirname(__FILE__)."/../../bin/config.php");
use newznab\db\DB;
use newznab\db\Settings;
// This script can dump all tables or just binaries/parts/partrepair/groups.
$pdo = new DB();
$pdo = new Settings();
$exportopts = "";
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
require_once(dirname(__FILE__)."/../../bin/config.php");
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
// Function inspired by : http://stackoverflow.com/questions/1883079/best-practice-import-mysql-file-in-php-split-queries/2011454#2011454
@@ -14,7 +14,7 @@ function SplitSQL($file, $delimiter = ';')
if (is_resource($file) === true) {
$query = array();
$db = new DB();
$db = new Settings();
$dbsys = DB_TYPE;
$c = new ColorCLI();
@@ -74,7 +74,7 @@ function SplitSQL($file, $delimiter = ';')
function BackupDatabase()
{
$db = new DB();
$db = new Settings();
$c = new ColorCLI();
$DIR = dirname (__FILE__);
@@ -106,7 +106,7 @@ if (isset($os) && $os == "unix") {
$currentversion = $tmux->sqlpatch;
$patched = 0;
$patches = array();
$db = new DB();
$db = new Settings();
$backedup = false;
$c = new ColorCLI();
$DIR = dirname (__FILE__);
+50
View File
@@ -0,0 +1,50 @@
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see LICENSE.txt in the base directory. If
* not, see:
*
* @link <http://www.gnu.org/licenses/>.
* @author niel
* @copyright 2014 nZEDb
*/
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR . 'config.php';
use newznab\db\DbUpdate;
use newznab\utility\Utility;
if (!Utility::isCLI()) {
exit;
}
if (isset($argc) && $argc > 1 && isset($argv[1]) && $argv[1] == true) {
$backup = (isset($argv[2]) && $argv[2] == 'safe') ? true : false;
$updater = new DbUpdate(['backup' => $backup]);
echo $updater->log->header("Db updater starting ...");
$patched = $updater->processPatches(['safe' => $backup]);
if ($patched > 0) {
echo $updater->log->info("$patched patch(es) applied.");
$smarty = new Smarty();
$cleared = $smarty->clearCompiledTemplate();
if ($cleared) {
$msg = "The smarty template cache has been cleaned for you\n";
} else {
$msg = "You should clear your smarty template cache at: " . SMARTY_DIR . "templates_c\n";
}
$updater->log->info($msg);
}
} else {
echo "Usage: php update_db.php true";
}
+131
View File
@@ -0,0 +1,131 @@
<?php
if (!isset($argv[1]) || $argv[1] !== 'yes') {
exit(
'This will verify path permissions for crucial locations in nZEDb for the current user running the script.' . PHP_EOL .
'If a wrong permission is encountered, you will be alerted.' . PHP_EOL .
'IT IS STRONGLY RECOMMENDED you run this against your apache/nginx user, in addition to your normal CLI user.' . PHP_EOL .
'On linux you can run it against the apache/nginx user this way: sudo -u www-data php verify_permissions.php yes' . PHP_EOL .
'See this page for a quick guide on setting up your permissions in linux: https://github.com/nZEDb/nZEDb/wiki/Setting-permissions-on-linux' . PHP_EOL .
'If you are ready to run this script, pass yes as the first argument.' . PHP_EOL
);
}
$www_path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR;
if (is_file($www_path . 'config.php')) {
require($www_path . 'config.php');
} else {
require($www_path . 'automated.config.php');
}
define('R', 1);
define('W', 2);
define('E', 4);
// Check All folders up to NN root folder.
$string = DS;
foreach (explode(DS, NN_ROOT) as $folder) {
if ($folder) {
$string .= $folder . DS;
readable($string);
executable($string);
}
}
// List of folders to check with required permissions.
$folders = [
NN_LIBS => [R],
NN_LIBS . 'smarty' => [R],
NN_LIBS . 'smarty' . DS . 'templates_c' => [R, W],
NN_RES => [R, W, E],
NN_RES . 'db' => [R, E],
NN_RES . 'db' . DS . 'patches' => [R, E],
NN_RES . 'db' . DS . 'schema' => [R, E],
NN_RES . 'db' . DS . 'schema' . DS . 'data' => [R, E],
NN_RES . 'nzb' => [R],
NN_LOGS => [R, W],
NN_TMP => [R, W],
NN_TMP . DS . 'unrar' => [R, W, E],
NN_TMP . DS . 'yEnc' => [R, W, E],
NN_VERSIONS => [R],
];
// Add nzb folders.
foreach ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'] as $identifier) {
$nzbFolder = NN_RES . 'nzb' . DS . $identifier . DS;
$folders[$nzbFolder] = [R, W];
}
// Add covers paths.
foreach (['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', 'music', 'preview', 'sample', 'tvrage', 'video', 'xxx'] as $identifier) {
$nzbFolder = NN_RES . 'covers' . DS . $identifier . DS;
$folders[$nzbFolder] = [R, W];
}
// Set up covers paths.
if (defined('DB_PASSWORD') && DB_PASSWORD != '') {
$ri = new ReleaseImage();
$folders[$ri->audSavePath] = [R, W];
$folders[$ri->imgSavePath] = [R, W];
$folders[$ri->jpgSavePath] = [R, W];
$folders[$ri->movieImgSavePath] = [R, W];
$folders[$ri->vidSavePath] = [R, W];
} else {
echo 'Skipping cover folders check, as you have not set up a database yet. You can rerun this script after running install.' . PHP_EOL;
}
// Check folders.
foreach ($folders as $folder => $check) {
exists($folder);
foreach ($check as $type) {
switch ($type) {
case R:
readable($folder);
break;
case W:
writable($folder);
break;
case E:
executable($folder);
break;
}
}
}
echo 'Your permissions seem right for this user. Note, this script does not verify all paths, only the most important ones.' . PHP_EOL;
if (!newznab\utility\Utility::isWin()) {
$user = posix_getpwuid(posix_geteuid());
if ($user['name'] !== 'www-data') {
echo 'If you have not already done so, please rerun this script using the www-data user: sudo -u www-data php verify_permissions.php yes' . PHP_EOL;
}
}
function readable($folder)
{
if (!is_readable($folder)) {
exit('Error: This path is not readable: (' . $folder . ') resolve this and rerun the script.' . PHP_EOL);
}
}
function writable($folder)
{
if (!is_writable($folder)) {
exit('Error: This path is not writable: (' . $folder . ') resolve this and rerun the script.' . PHP_EOL);
}
}
function executable($folder)
{
if (!is_executable($folder)) {
exit('Error: This path is not executable: (' . $folder . ') resolve this and rerun the script.' . PHP_EOL);
}
}
function exists($folder)
{
if (!file_exists($folder)) {
exit('Error: This path (' . $folder . ') does not exist or is not readable. Create it or make it readable.' . PHP_EOL);
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see LICENSE.txt in the base directory. If
* not, see:
*
* @link <http://www.gnu.org/licenses/>.
* @author niel
* @copyright 2014 nZEDb
*/
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'www' . DIRECTORY_SEPARATOR . 'config.php';
use newznab\utility\Utility;
use newznab\utility\Versions;
if (!Utility::isCLI()) {
exit;
}
$vers = new Versions();
if (isset($argc) && $argc > 1 && isset($argv[1]) && $argv[1] == true) {
echo $vers->out->header("Checking versions...");
if ($vers->checkAll()) {
$vers->save();
} else {
echo "No changes detected.\n";
output($vers);
}
} else {
$vers->checkAll(false);
echo "Version info in file:\n";
output($vers);
}
function output($vers)
{
echo " Commit: " . $vers->out->primary($vers->getCommit());
echo "SQL DB: " . $vers->out->primary($vers->getSQLPatchFromDb());
echo "SQL File: " . $vers->out->primary($vers->getSQLPatchFromFiles());
echo " Tag: " . $vers->out->primary($vers->getTagVersion());
}
+684
View File
@@ -0,0 +1,684 @@
<?php
/*
* Git.php
*
* A PHP git library
*
* @package Git.php
* @version 0.1.4
* @author James Brumond
* @copyright Copyright 2013 James Brumond
* @repo http://github.com/kbjr/Git.php
*/
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) die('Bad load order');
// ------------------------------------------------------------------------
/**
* Git Interface Class
*
* This class enables the creating, reading, and manipulation
* of git repositories.
*
* @class Git
*/
class Git {
/**
* Git executable location
*
* @var string
*/
protected static $bin = null;
public function __construct($binPath = null)
{
self::check_bin($binPath);
}
/**
* Sets git executable path
*
* @param string $path executable location
*/
public static function set_bin($path) {
self::$bin = $path;
}
/**
* Gets git executable path
*/
public static function get_bin() {
return empty(self::$bin) ? self::check_bin() : self::$bin;
}
/**
* Sets up library for use in a default Windows environment
*/
public static function windows_mode() {
self::set_bin('git');
}
/**
* Create a new git repository
*
* Accepts a creation path, and, optionally, a source path
*
* @access public
* @param string repository path
* @param string directory to source
* @return GitRepo
*/
public static function &create($repo_path, $source = null) {
return GitRepo::create_new($repo_path, $source);
}
/**
* Open an existing git repository
*
* Accepts a repository path
*
* @access public
* @param string repository path
* @return GitRepo
*/
public static function open($repo_path) {
return new GitRepo($repo_path);
}
/**
* Clones a remote repo into a directory and then returns a GitRepo object
* for the newly created local repo
*
* Accepts a creation path and a remote to clone from
*
* @access public
* @param string repository path
* @param string remote source
* @return GitRepo
**/
public static function &clone_remote($repo_path, $remote) {
return GitRepo::create_new($repo_path, $remote, true);
}
/**
* Checks if a variable is an instance of GitRepo
*
* Accepts a variable
*
* @access public
* @param mixed variable
* @return bool
*/
public static function is_repo($var) {
return (get_class($var) == 'GitRepo');
}
private static function check_bin($binPath = '')
{
$binPath = $binPath ?: '/usr/bin/git';
$resource = proc_open('which git', [1 => ['pipe', 'w']], $pipes);
$stdout = stream_get_contents($pipes[1]);
foreach ($pipes as $pipe) {
fclose($pipe);
}
$status = trim(proc_close($resource));
if (!$status) {
$binPath = trim($stdout);
}
if (strpos($binPath, ' ') !== false) {
$binPath = newznab\utility\Utility::isWin() ? '"' . $binPath . '"'
: str_replace(' ', '\ ', $binPath);
}
self::set_bin($binPath);
return $binPath;
}
}
// ------------------------------------------------------------------------
/**
* Git Repository Interface Class
*
* This class enables the creating, reading, and manipulation
* of a git repository
*
* @class GitRepo
*/
class GitRepo {
protected $repo_path = null;
protected $bare = false;
protected $envopts = array();
/**
* Create a new git repository
*
* Accepts a creation path, and, optionally, a source path
*
* @access public
* @param string repository path
* @param string directory to source
* @return GitRepo
*/
public static function &create_new($repo_path, $source = null, $remote_source = false) {
if (is_dir($repo_path) && file_exists($repo_path."/.git") && is_dir($repo_path."/.git")) {
throw new Exception('"'.$repo_path.'" is already a git repository');
} else {
$repo = new self($repo_path, true, false);
if (is_string($source)) {
if ($remote_source) {
$repo->clone_remote($source);
} else {
$repo->clone_from($source);
}
} else {
$repo->run('init');
}
return $repo;
}
}
/**
* Constructor
*
* Accepts a repository path
*
* @access public
* @param string repository path
* @param bool create if not exists?
* @return void
*/
public function __construct($path = null, $create_new = false, $_init = true) {
if (is_string($path)) {
$this->set_repo_path($path, $create_new, $_init);
}
}
/**
* Set the repository's path
*
* Accepts the repository path
*
* @access public
* @param string repository path
* @param bool create if not exists?
* @param bool initialize new Git repo if not exists?
* @return void
*/
public function set_repo_path($repo_path, $create_new = false, $_init = true) {
if (is_string($repo_path)) {
if ($new_path = realpath($repo_path)) {
$repo_path = $new_path;
if (is_dir($repo_path)) {
// Is this a work tree?
if (file_exists($repo_path."/.git") && is_dir($repo_path."/.git")) {
$this->repo_path = $repo_path;
$this->bare = false;
// Is this a bare repo?
} else if (is_file($repo_path."/config")) {
$parse_ini = parse_ini_file($repo_path."/config");
if ($parse_ini['bare']) {
$this->repo_path = $repo_path;
$this->bare = true;
}
} else {
if ($create_new) {
$this->repo_path = $repo_path;
if ($_init) {
$this->run('init');
}
} else {
throw new Exception('"'.$repo_path.'" is not a git repository');
}
}
} else {
throw new Exception('"'.$repo_path.'" is not a directory');
}
} else {
if ($create_new) {
if ($parent = realpath(dirname($repo_path))) {
mkdir($repo_path);
$this->repo_path = $repo_path;
if ($_init) $this->run('init');
} else {
throw new Exception('cannot create repository in non-existent directory');
}
} else {
throw new Exception('"'.$repo_path.'" does not exist');
}
}
}
}
/**
* Tests if git is installed
*
* @access public
* @return bool
*/
public function test_git() {
$descriptorspec = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$pipes = array();
$resource = proc_open(Git::get_bin(), $descriptorspec, $pipes);
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
foreach ($pipes as $pipe) {
fclose($pipe);
}
$status = trim(proc_close($resource));
return ($status != 127);
}
/**
* Run a command in the git repository
*
* Accepts a shell command to run
*
* @access protected
* @param string command to run
* @return string
*/
protected function run_command($command) {
$descriptorspec = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$pipes = array();
/* Depending on the value of variables_order, $_ENV may be empty.
* In that case, we have to explicitly set the new variables with
* putenv, and call proc_open with env=null to inherit the reset
* of the system.
*
* This is kind of crappy because we cannot easily restore just those
* variables afterwards.
*
* If $_ENV is not empty, then we can just copy it and be done with it.
*/
if(count($_ENV) === 0) {
$env = NULL;
foreach($this->envopts as $k => $v) {
putenv(sprintf("%s=%s",$k,$v));
}
} else {
$env = array_merge($_ENV, $this->envopts);
}
$cwd = $this->repo_path;
$resource = proc_open($command, $descriptorspec, $pipes, $cwd, $env);
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
foreach ($pipes as $pipe) {
fclose($pipe);
}
$status = trim(proc_close($resource));
if ($status) throw new Exception($stderr . PHP_EOL . $command);
return $stdout;
}
/**
* Run a git command in the git repository
*
* Accepts a git command to run
*
* @access public
* @param string command to run
* @return string
*/
public function run($command) {
// If git.exe is in C:/Program Files, the space between Program and Files causes an error.
return $this->run_command(Git::get_bin() . " " . $command);
}
/**
* Runs a 'git status' call
*
* Accept a convert to HTML bool
*
* @access public
* @param bool return string with <br />
* @return string
*/
public function status($html = false) {
$msg = $this->run("status");
if ($html == true) {
$msg = str_replace("\n", "<br />", $msg);
}
return $msg;
}
/**
* Runs a `git add` call
*
* Accepts a list of files to add
*
* @access public
* @param mixed files to add
* @return string
*/
public function add($files = "*") {
if (is_array($files)) {
$files = '"'.implode('" "', $files).'"';
}
return $this->run("add $files -v");
}
/**
* Runs a `git rm` call
*
* Accepts a list of files to remove
*
* @access public
* @param mixed files to remove
* @param Boolean use the --cached flag?
* @return string
*/
public function rm($files = "*", $cached = false) {
if (is_array($files)) {
$files = '"'.implode('" "', $files).'"';
}
return $this->run("rm ".($cached ? '--cached ' : '').$files);
}
/**
* Runs a `git commit` call
*
* Accepts a commit message string
*
* @access public
* @param string commit message
* @return string
*/
public function commit($message = "") {
return $this->run("commit -av -m ".escapeshellarg($message));
}
/**
* Runs a `git clone` call to clone the current repository
* into a different directory
*
* Accepts a target directory
*
* @access public
* @param string target directory
* @return string
*/
public function clone_to($target) {
return $this->run("clone --local ".$this->repo_path." $target");
}
/**
* Runs a `git clone` call to clone a different repository
* into the current repository
*
* Accepts a source directory
*
* @access public
* @param string source directory
* @return string
*/
public function clone_from($source) {
return $this->run("clone --local $source ".$this->repo_path);
}
/**
* Runs a `git clone` call to clone a remote repository
* into the current repository
*
* Accepts a source url
*
* @access public
* @param string source url
* @return string
*/
public function clone_remote($source) {
return $this->run("clone $source ".$this->repo_path);
}
/**
* Runs a `git clean` call
*
* Accepts a remove directories flag
*
* @access public
* @param bool delete directories?
* @param bool force clean?
* @return string
*/
public function clean($dirs = false, $force = false) {
return $this->run("clean".(($force) ? " -f" : "").(($dirs) ? " -d" : ""));
}
/**
* Runs a `git branch` call
*
* Accepts a name for the branch
*
* @access public
* @param string branch name
* @return string
*/
public function create_branch($branch) {
return $this->run("branch $branch");
}
/**
* Runs a `git branch -[d|D]` call
*
* Accepts a name for the branch
*
* @access public
* @param string branch name
* @return string
*/
public function delete_branch($branch, $force = false) {
return $this->run("branch ".(($force) ? '-D' : '-d')." $branch");
}
/**
* Runs a `git branch` call
*
* @access public
* @param bool keep asterisk mark on active branch
* @return array
*/
public function list_branches($keep_asterisk = false) {
$branchArray = explode("\n", $this->run("branch"));
foreach($branchArray as $i => &$branch) {
$branch = trim($branch);
if (! $keep_asterisk) {
$branch = str_replace("* ", "", $branch);
}
if ($branch == "") {
unset($branchArray[$i]);
}
}
return $branchArray;
}
/**
* Lists remote branches (using `git branch -r`).
*
* Also strips out the HEAD reference (e.g. "origin/HEAD -> origin/master").
*
* @access public
* @return array
*/
public function list_remote_branches() {
$branchArray = explode("\n", $this->run("branch -r"));
foreach($branchArray as $i => &$branch) {
$branch = trim($branch);
if ($branch == "" || strpos($branch, 'HEAD -> ') !== false) {
unset($branchArray[$i]);
}
}
return $branchArray;
}
/**
* Returns name of active branch
*
* @access public
* @param bool keep asterisk mark on branch name
* @return string
*/
public function active_branch($keep_asterisk = false) {
$branchArray = $this->list_branches(true);
$active_branch = preg_grep("/^\*/", $branchArray);
reset($active_branch);
if ($keep_asterisk) {
return current($active_branch);
} else {
return str_replace("* ", "", current($active_branch));
}
}
/**
* Runs a `git checkout` call
*
* Accepts a name for the branch
*
* @access public
* @param string branch name
* @return string
*/
public function checkout($branch) {
return $this->run("checkout $branch");
}
/**
* Runs a `git merge` call
*
* Accepts a name for the branch to be merged
*
* @access public
* @param string $branch
* @return string
*/
public function merge($branch) {
return $this->run("merge $branch --no-ff");
}
/**
* Runs a git fetch on the current branch
*
* @access public
* @return string
*/
public function fetch() {
return $this->run("fetch");
}
/**
* Add a new tag on the current position
*
* Accepts the name for the tag and the message
*
* @param string $tag
* @param string $message
* @return string
*/
public function add_tag($tag, $message = null) {
if ($message === null) {
$message = $tag;
}
return $this->run("tag -a $tag -m $message");
}
/**
* List all the available repository tags.
*
* Optionally, accept a shell wildcard pattern and return only tags matching it.
*
* @access public
* @param string $pattern Shell wildcard pattern to match tags against.
* @return array Available repository tags.
*/
public function list_tags($pattern = null) {
$tagArray = explode("\n", $this->run("tag -l $pattern"));
foreach ($tagArray as $i => &$tag) {
$tag = trim($tag);
if ($tag == '') {
unset($tagArray[$i]);
}
}
return $tagArray;
}
/**
* Push specific branch to a remote
*
* Accepts the name of the remote and local branch
*
* @param string $remote
* @param string $branch
* @return string
*/
public function push($remote, $branch) {
return $this->run("push --tags $remote $branch");
}
/**
* Pull specific branch from remote
*
* Accepts the name of the remote and local branch
*
* @param string $remote
* @param string $branch
* @return string
*/
public function pull($remote, $branch) {
return $this->run("pull $remote $branch");
}
/**
* Sets the project description.
*
* @param string $new
*/
public function set_description($new) {
file_put_contents($this->repo_path."/.git/description", $new);
}
/**
* Gets the project description.
*
* @return string
*/
public function get_description() {
return file_get_contents($this->repo_path."/.git/description");
}
/**
* Sets custom environment options for calling Git
*
* @param string key
* @param string value
*/
public function setenv($key, $value) {
$this->envopts[$key] = $value;
}
}
/* End of file */
+6
View File
@@ -0,0 +1,6 @@
{
"name": "kbjr/Git.php",
"autoload": {
"classmap": ["Git.php"]
}
}
+708
View File
@@ -0,0 +1,708 @@
Copyright (c) 2010 James Brumond
This software is dual licensed under the MIT and GNU General Public Licenses.
This means that you may use this software under either of these licenses (at
your option).
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
MIT LICENSE
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+21
View File
@@ -0,0 +1,21 @@
# Git.php
## Description
A PHP git repository control library. Allows the running of any git command from a PHP class. Runs git commands using `proc_open`, not `exec` or the type, therefore it can run in PHP safe mode.
## Requirements
A system with [git](http://git-scm.com/) installed
## Basic Use
```php
require_once('Git.php');
$repo = Git::open('/path/to/repo'); // -or- Git::create('/path/to/repo')
$repo->add('.');
$repo->commit('Some commit message');
$repo->push('origin', 'master');
```
@@ -0,0 +1,170 @@
<?php
/*
* test-suite.php
*
* The Git.php test suite
*
* @package Git.php
* @version 0.1.1-a
* @author James Brumond
* @copyright Copyright 2010 James Brumond
* @license http://github.com/kbjr/Git.php
* @link http://code.kbjrweb.com/project/gitphp
*/
define("DIR", dirname(__FILE__));
// include the git library
require DIR."/../Git.php";
$Git_Tests = array(
'Git' => function() {
$return = null;
$repo = new GitRepo();
$found = $repo->test_git();
if ($found) {
$return = array(0, "Git was located and tested successfully");
} else {
$return = array(1, "Git could not be found at the default location");
}
return $return;
},
'Git::create()' => function() {
$return = null;
$repo = Git::create(DIR."/create");
if (! Git::is_repo($repo)) {
$return = array(2, "Git::create() failed to produce expected output.");
} else {
$return = array(0, "Git::create() executed successfully");
}
return $return;
},
'Git::create([ $source ])' => function() {
$return = null;
$repo = Git::create(DIR."/createfrom", DIR."/test.git");
if (! Git::is_repo($repo)) {
$return = array(2, "Git::create([ \$source ]) failed to produce expected output.");
} else {
$return = array(0, "Git::create([ \$source ]) executed successfully");
}
return $return;
},
'Git::open()' => function() {
$return = null;
$repo = Git::open(DIR."/test.git");
if (! Git::is_repo($repo)) {
$return = array(2, "Git::open() failed to produce expected output.");
} else {
$return = array(0, "Git::open() executed successfully");
}
return $return;
}
);
class Git_TestSuiteControl {
protected $warnings = 0;
protected $errors = 0;
public static function rm($dir) {
if (! file_exists($dir)) return true;
if (! is_dir($dir)) return unlink($dir);
$items = scandir($dir);
closedir(opendir($dir));
foreach ($items as $item) {
if ($item == '.' || $item == '..') continue;
if (! self::rm("$dir/$item")) return false;
}
return rmdir($dir);
}
public function __construct() {
$this->output("Starting Git.php Test Suite.");
}
public function output($msg) {
echo "$msg\n";
}
public function warning($msg) {
$this->warnings++;
$this->output("Warning: $msg");
}
public function error($msg) {
$this->errors++;
$this->output("Error: $msg");
}
public function finish() {
$this->cleanup();
$this->output("\n\n".str_repeat('-', 30));
$this->output("Tests Complete. Results:");
$this->output("Errors: ".$this->errors." Warnings: ".$this->warnings);
}
public function cleanup() {
self::rm(DIR."/create");
self::rm(DIR."/createfrom");
}
public function run_test($name, $callback) {
$this->output("\nTesting $name.");
$this->cleanup();
try {
$oldReport = error_reporting(0);
set_error_handler(function($n, $str) {
throw new Exception($str);
});
$result = $callback();
error_reporting($oldReport);
restore_error_handler();
} catch (Exception $e) {
$this->error("Test case threw an exception:\n ".implode("\n ", explode("\n", $e->getMessage())));
return;
}
switch ($result[0]) {
case 0:
$this->output($result[1]);
break;
case 1:
$this->warning($result[1]);
break;
case 2:
$this->error($result[1]);
break;
}
}
}
// define the test class
class Git_TestSuite {
public static function run() {
$test = new Git_TestSuiteControl();
foreach ($GLOBALS['Git_Tests'] as $name => $callback) {
$test->run_test($name, $callback);
}
$test->finish();
unset($test);
}
}
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) {
header("Content-Type: text/plain");
Git_TestSuite::run();
}
/* End Of File */
@@ -1,7 +1,7 @@
<?php
require dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
if (NN_RELEASE_SEARCH_TYPE != \ReleaseSearch::SPHINX) {
@@ -12,7 +12,7 @@ if (!isset($argv[1]) || !isset($argv[2]) || !is_numeric($argv[2])) {
exit('Argument 1 must the hostname or IP to the Sphinx searchd server, Argument 2 must be the port to the Sphinx searchd server.' . PHP_EOL);
}
$pdo = new DB();
$pdo = new Settings();
$sphinxConnection = sprintf('%s:%d', $argv[1], $argv[2]);
@@ -1,7 +1,7 @@
<?php
require dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
if (NN_RELEASE_SEARCH_TYPE != \ReleaseSearch::SPHINX) {
exit('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX!' . PHP_EOL);
@@ -22,7 +22,7 @@ switch ($argv[1]) {
// Bulk insert releases into sphinx RT index.
function releases_rt()
{
$pdo = new DB();
$pdo = new Settings();
$rows = $pdo->queryExec('SELECT id, guid, name, searchname, fromname FROM releases');
if ($rows !== false && $rows->rowCount()) {
@@ -1,7 +1,7 @@
<?php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
if (!isset($argv[1]) || !in_array($argv[1], ['sphinx', 'standard'])) {
@@ -14,13 +14,13 @@ if (!isset($argv[1]) || !in_array($argv[1], ['sphinx', 'standard'])) {
switch ($argv[1]) {
case 'sphinx':
if (NN_RELEASE_SEARCH_TYPE == \ReleaseSearch::SPHINX) {
optimizeForSphinx(new DB());
optimizeForSphinx(new Settings());
} else {
echo PHP_EOL . $pdo->log->error('Error, NN_RELEASE_SEARCH_TYPE in www/settings.php must be set to SPHINX to optimize for Sphinx!' . PHP_EOL);
}
break;
case 'standard':
revertToStandard(new DB());
revertToStandard(new Settings());
break;
}
@@ -1,10 +1,10 @@
<?php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$db = new DB();
$db = new Settings();
$n = new NZB();
$s = New Sites;
$site = $s->get();
@@ -4,10 +4,10 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$releases = new Releases();
$db = new DB;
$db = new Settings;
//
// delete all previews over a year old
@@ -5,10 +5,10 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$releases = new Releases();
$db = new DB();
$db = new Settings();
//
// [1] delete all releases for a group which only has x number of files
+1 -1
View File
@@ -1 +1 @@
<?php
<?php
+1 -1
View File
@@ -3,7 +3,7 @@
require_once dirname(__FILE__) . '/../../www/config.php';
$db = new \newznab\db\DB();
$db = new \newznab\db\Settings();
$sql = "select distinct rageid from tvrage where rageid in (select rageid from tvrage where rageid != -2 group by rageid having count(*) > 1)";
$rows = $db->query($sql);
+2 -2
View File
@@ -8,9 +8,9 @@ Author: lordgnu <lordgnu@me.com>
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$db = new DB;
$db = new Settings;
$s = New Sites;
$nzb = new NZB;
@@ -2,7 +2,7 @@
require_once dirname(__FILE__) . '/../../www/config.php';
$db = new \newznab\db\DB();
$db = new \newznab\db\Settings();
//query to find rough matches
$rows = $db->query("SELECT ID, searchname from releases where searchname like '%QWERTY%'");
+2 -2
View File
@@ -3,11 +3,11 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$console = new Console(true);
$db = new DB();
$db = new Settings();
$res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where consoleinfoID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY id DESC LIMIT %d", Category::CAT_PARENT_GAME, Console::NUMTOPROCESSPERTIME));
+2 -2
View File
@@ -3,11 +3,11 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$movie = new Movie(true);
$db = new DB();
$db = new Settings();
$movies = $db->query("SELECT imdbID from movieinfo where cover = 0");
+2 -2
View File
@@ -1,11 +1,11 @@
<?php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$t = new TvRage;
$db = new DB();
$db = new Settings();
$shows = $db->query("select name from releases where categoryID IN (select ID from category where parentID = 5000) limit 0, 50");
+2 -2
View File
@@ -4,10 +4,10 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$releases = new Releases();
$db = new DB();
$db = new Settings();
//
// [1] move mp3 files from other misc into audio mp3
+2 -2
View File
@@ -2,12 +2,12 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$s = new Sites();
$site = $s->get();
$releases = new Releases();
$db = new DB();
$db = new Settings();
$nzb = new NZB();
$nntp = new NNTP;
+2 -2
View File
@@ -2,10 +2,10 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$movie = new Movie(true);
$db = new DB();
$db = new Settings();
$movies = array();
$counter = 1;
$sleepsecsbetweenscrape = 1;
+1 -1
View File
@@ -26,7 +26,7 @@ $regs = array(
);
$releases = new Releases();
$db = new DB();
$db = new Settings();
# fetch enabled regular expression
$catsql = "select ID,groupname,regex from releaseregex where status = 1";
$res = $db->query($catsql);
@@ -10,7 +10,7 @@
//
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
# If satisfied with what is matched, set this to true and have
@@ -200,11 +200,11 @@ function get_block($offset, $batch)
$catsql = "SELECT releases.*,groups.name as groupname FROM "
."releases LEFT JOIN groups on releases.groupID = groups.ID ";
$db = new DB();
$db = new Settings();
return $db->query($catsql.sprintf(' LIMIT %d,%d', $offset, $batch));
}
$db = new DB();
$db = new Settings();
$errcnt=0;
$total=0;
+2 -2
View File
@@ -7,7 +7,7 @@
//
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
function handleError($errno, $errstr, $errfile, $errline, array $errcontext)
{
@@ -26,7 +26,7 @@ $regs = array(
"simple" => '"data.mp3',
);
$db = new DB();
$db = new Settings();
# fetch enabled regular expression
$catsql = "select ID,groupname,regex from releaseregex where status = 1";
$res = $db->query($catsql);
+2 -2
View File
@@ -1,11 +1,11 @@
<?php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$s = new Sites();
$site = $s->get();
$db = new DB();
$db = new Settings();
$r = new Releases();
//
+2 -2
View File
@@ -2,10 +2,10 @@
//This Script Verifies your System Time vs Myself Time vs PHP Time
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$res="";
$db = new DB();
$db = new Settings();
$res = $db->queryonerow( sprintf("Select now()"));
foreach($res as $time){
echo "Mysql Time Is Now ".$time."\n";}
@@ -3,7 +3,7 @@
try {
// Create the first database class instance (which will initialize the PDO connection)
$db = new DB();
$db = new Settings();
// For debug set the error mode
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -18,7 +18,7 @@ try {
echo "--[ Insert run: {$i} ]----------------------------------------". PHP_EOL;
// Create a new db class instance (multiple can exist)
$newDb = new DB();
$newDb = new Settings();
// Check that there is a new db class instance, but no new PDO instance
var_dump( $newDb, $newDb->getPDO() );
@@ -2,9 +2,9 @@
//This script will rerun all releases against Category.php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$db = new DB();
$db = new Settings();
$category = new Categorize();
$changedcount = 0;
$rescount = 0;
+2 -2
View File
@@ -1,9 +1,9 @@
<?php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
$db = new DB();
$db = new Settings();
$t = new TvRage();
//
+1 -1
View File
@@ -1 +1 @@
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\DB; $r = new Releases(); $rv = new ReleaseExtra(); $db = new DB(); $rels = $db->query("select releaseID, videowidth, videoheight from releasevideo where definition is null"); foreach($rels as $rel) { $sql = sprintf("update releasevideo set definition = %d where releaseID = %d", $rv->determineVideoResolution($rel["videowidth"], $rel["videoheight"]), $rel["releaseID"]); $db->exec($sql); } ?>
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $r = new Releases(); $rv = new ReleaseExtra(); $db = new Settings(); $rels = $db->query("select releaseID, videowidth, videoheight from releasevideo where definition is null"); foreach($rels as $rel) { $sql = sprintf("update releasevideo set definition = %d where releaseID = %d", $rv->determineVideoResolution($rel["videowidth"], $rel["videoheight"]), $rel["releaseID"]); $db->exec($sql); } ?>
@@ -1,9 +1,9 @@
<?php
require_once("config.php");
use newznab\db\DB;
use newznab\db\Settings;
$pdo = new DB();
$pdo = new Settings();
// Create the connection here and pass
$nntp = new \NNTP(['Settings' => $pdo]);
+2 -2
View File
@@ -2,11 +2,11 @@
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
$releases = new Releases();
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$cat = new Category();
$releaseRegex = new ReleaseRegex();
$nzb = new NZB();
@@ -6,7 +6,7 @@ if (!isset($argv[1])) {
require_once dirname(__FILE__) . '/../../../../../www/config.php';
use \newznab\db\DB;
use \newznab\db\Settings;
use \newznab\processing\PProcess;
use \newznab\processing\ProcessReleases;
use \newznab\processing\post\ProcessAdditional;
@@ -22,7 +22,7 @@ switch ($options[1]) {
// $options[3] => (int) backfill type from tmux settings. 1 = Backfill interval , 2 = Bakfill all
case 'backfill':
if (in_array((int)$options[3], [1, 2])) {
$pdo = new DB();
$pdo = new Settings();
$value = $pdo->queryOneRow("SELECT value FROM tmux WHERE setting = 'backfill_qty'");
if ($value !== false) {
$nntp = nntp($pdo);
@@ -37,7 +37,7 @@ switch ($options[1]) {
* $options[3] => (int) Quantity of articles to download.
*/
case 'backfill_all_quantity':
$pdo = new DB();
$pdo = new Settings();
$nntp = nntp($pdo);
(new \Backfill())->backfillAllGroups($options[2], $options[3]);
break;
@@ -45,7 +45,7 @@ switch ($options[1]) {
// BackFill a single group, 10000 parts.
// $options[2] => (string)group name, Name of group to work on.
case 'backfill_all_quick':
$pdo = new DB();
$pdo = new Settings();
$nntp = nntp($pdo);
(new \Backfill())->backfillAllGroups($options[2], 10000, 'normal');
break;
@@ -59,7 +59,7 @@ switch ($options[1]) {
* $options[6] => (int) Number of threads.
*/
case 'get_range':
$pdo = new DB();
$pdo = new Settings();
$nntp = nntp($pdo);
$groups = new \Groups();
$s = new Sites();
@@ -126,7 +126,7 @@ switch ($options[1]) {
* $options[2] => (string) Group name.
*/
case 'part_repair':
$pdo = new DB();
$pdo = new Settings();
$groups = new \Groups(['Settings' => $pdo]);
$groupMySQL = $groups->getByName($options[2]);
$nntp = nntp($pdo);
@@ -143,7 +143,7 @@ switch ($options[1]) {
// Process releases.
// $options[2] => (string)groupCount, number of groups terminated by _ | (int)groupid, group to work on
case 'releases':
$pdo = new DB();
$pdo = new Settings();
$s = new Sites();
$site = $s->get();
$releases = new ProcessReleases(['Settings' => $pdo]);
@@ -185,7 +185,7 @@ switch ($options[1]) {
* $options[2] => (string) Group name.
*/
case 'update_group_headers':
$pdo = new DB();
$pdo = new Settings();
$nntp = nntp($pdo);
$groups = new \Groups();
$groupMySQL = $groups->getByName($options[2]);
@@ -198,7 +198,7 @@ switch ($options[1]) {
case 'update_per_group':
if (is_numeric($options[2])) {
$pdo = new DB();
$pdo = new Settings();
// Get the group info from MySQL.
$groupMySQL = $pdo->queryOneRow(sprintf('SELECT * FROM groups WHERE id = %d', $options[2]));
@@ -232,7 +232,7 @@ switch ($options[1]) {
case 'pp_additional':
case 'pp_nfo':
if (charCheck($options[2])) {
$pdo = new DB();
$pdo = new Settings();
// Create the connection here and pass, this is for post processing, so check for alternate.
$nntp = nntp($pdo, true);
@@ -252,7 +252,7 @@ switch ($options[1]) {
*/
case 'pp_movie':
if (charCheck($options[2])) {
$pdo = new DB();
$pdo = new Settings();
(new PProcess(['Settings' => $pdo]))->processMovies('', $options[2], (isset($options[3]) ? $options[3] : ''));
}
break;
@@ -264,7 +264,7 @@ switch ($options[1]) {
*/
case 'pp_tv':
if (charCheck($options[2])) {
$pdo = new DB();
$pdo = new Settings();
(new PProcess(['Settings' => $pdo]))->processTv('', $options[2], (isset($options[3]) ? $options[3] : ''));
}
break;
@@ -313,7 +313,7 @@ function charCheck($char)
/**
* Check if the group should be processed.
*
* @param \newznab\db\DB $pdo
* @param \newznab\db\Settings $pdo
* @param int $groupID
*/
function collectionCheck(&$pdo, $groupID)
@@ -326,7 +326,7 @@ function collectionCheck(&$pdo, $groupID)
/**
* Connect to usenet, return NNTP object.
*
* @param \newznab\db\DB $pdo
* @param \newznab\db\Settings $pdo
* @param bool $alternate Use alternate NNTP provider.
*
* @return NNTP
@@ -1,12 +1,12 @@
<?php
require_once("config.php");
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
Utility::clearScreen();
$pdo = new DB();
$pdo = new Settings();
$t = new \Tmux();
$tmux = $t->get();
$powerline = (isset($tmux->powerline)) ? $tmux->powerline : 0;
@@ -2,11 +2,11 @@
require_once("config.php");
use newznab\db\DB;
use newznab\db\Settings;
$force = ((isset($argv[1]) && ($argv[1] == "true")));
$db = new DB;
$db = new Settings;
$ret = $db->optimise($force);
if (count($ret) > 0)
@@ -2,9 +2,9 @@
require_once("config.php");
use newznab\db\DB;
use newznab\db\Settings;
$pdo = new DB();
$pdo = new Settings();
// Create the connection here and pass
$nntp = new \NNTP(['Settings' => $pdo]);
@@ -2,7 +2,7 @@
require_once("config.php");
use newznab\db\DB;
use newznab\db\Settings;
$s = new Sites();
$site = $s->get();
@@ -18,8 +18,8 @@ else
{
echo "Patchn : Executing patch ".basename($patch)."\n";
$db = new DB();
$rows = $db->query("select * from site");
$db = new Settings();
$rows = $db->query("select * from settings");
$dbData = file_get_contents($patch);
//fix to remove BOM in UTF8 files
+109
View File
@@ -0,0 +1,109 @@
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see LICENSE.txt in the base directory. If
* not, see:
*
* @link <http://www.gnu.org/licenses/>.
* @author niel
* @copyright 2014 nZEDb
*/
require_once realpath(dirname(__DIR__) . '/../www/automated.config.php');
use ColorCLI;
define('NN_GIT', NN_ROOT . '.git' . DS);
define('NN_HOOKS', NN_GIT . 'hooks' . DS);
define('PRE_COMMIT_HOOK', 'pre-commit');
define('GIT_HOOK_VERSION', 2);
$current = 1;
if ($argc > 1 && $argv[1]) {
define('VERBOSE', true);
} else {
define('VERBOSE', false);
}
$changed = false;
$source = __DIR__ . DS . 'git-hooks' . DS . PRE_COMMIT_HOOK;
$target = NN_HOOKS . DS . PRE_COMMIT_HOOK;
if (!file_exists(NN_HOOKS . PRE_COMMIT_HOOK)) {
copy($source, $target);
}
$file = file($target, FILE_IGNORE_NEW_LINES);
if (preg_match('/^(?P<key>#version=)(?P<value>.*)$/', $file[1], $match)) {
$current = $match['value'];
}
$out = new ColorCLI();
$versions = new \newznab\utility\Versions();
$version = $versions->getGitHookPrecommit();
if ($version > $current) {
copy($source, $target);
echo $out->info("Updated pre-commit hook to version $version");
$file = file($target, FILE_IGNORE_NEW_LINES);
}
chmod($target, 0774);
$count = count($file);
$index = 0;
while ($index < $count) {
if (preg_match('/^#newznab hook\s*-\s*(.+)$/', $file[$index], $match)) {
if (VERBOSE) {
echo $out->primary("Matched: " . $file[$index]);
}
$index++;
$file[$index] = trim($file[$index]);
switch ($match[1]) {
case 'update version info':
case 'run hooks':
$hook = '/usr/bin/php ' . NN_LIB . 'build/git-hooks/runHooks.php';
if ($hook != $file[$index]) {
if (VERBOSE) {
echo $out->primary('Replace: "' . $file[$index] . '" with "' . $hook . '"');
}
$file[$index] = $hook;
$changed = true;
} else {
echo $out->primary("Skipped: " . $file[$index]);
}
break;
default:
$index--;
echo $out->error('Invalid hook placeholder!!');
break;
}
} else if (preg_match('#^PROJECT=(?P<path>.*)$#', $file[$index], $match)) {
if ($match['path'] != NN_ROOT) {
$file[$index] = 'PROJECT=' . NN_ROOT;
$changed = true;
}
} else {
if (VERBOSE) {
echo $out->primary("Skipped: " . $file[$index]);
}
}
$index++;
}
if ($changed === false) {
echo $out->warning('Unable to find any hooks needing updates!');
} else {
if (file_put_contents($target, implode("\n", $file)) === false) {
echo $out->error("Error writing file to disc!!");
}
}
@@ -0,0 +1,52 @@
#!/bin/sh
#version=9
#
# The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
AGAINST=HEAD
else
# Initial commit: diff against an empty tree object
AGAINST=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
#####################################################################################################
EXIT_STATUS=0
PROJECT=/path/to/newznab/
HOOKS=${PROJECT}newznab/build/git-hooks
FILE_LIST=${HOOKS}/git_hook_list.txt
if [ -e ${FILE_LIST} ]
then
rm ${FILE_LIST}
fi
touch ${FILE_LIST}
for FILE in `git diff-index --cached --name-only --diff-filter=AM ${AGAINST}`
do
echo ${PROJECT}/${FILE} >> ${FILE_LIST}
done
#nZEDb hook - run hooks
# placeholder for script to add command with correct path ;-)
EXIT_STATUS=$?
if [ -e ${FILE_LIST} ]
then
rm ${FILE_LIST}
fi
if [ ${EXIT_STATUS} -gt 0 ]
then
exit ${EXIT_STATUS}
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached ${AGAINST} --
@@ -0,0 +1,75 @@
<?php
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see LICENSE.txt in the base directory. If
* not, see:
*
* @link <http://www.gnu.org/licenses/>.
* @author niel
* @copyright 2014 nZEDb
*/
define('GIT_PRE_COMMIT', true);
require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'www' .
DIRECTORY_SEPARATOR . 'automated.config.php');
use newznab\db\DbUpdate;
use newznab\utility\Git;
use newznab\utility\Versions;
echo "Running pre-commit hooks\n";
$error = false;
// TODO Add code here to check permissions on staged files.
//$files = file(nZEDb_ROOT . 'nzedb/build/git-hooks'), FILE_IGNORE_NEW_LINES);
//foreach ($files as $file) {
// echo "Filename: $file\n";
//}
/**
* Add all hooks BEFORE the versions are updated so they can be skipped on any errors
*/
if ($error === false) {
$git = new Git();
$branch = $git->active_branch();
if (in_array($branch, $git->mainBranches())) {
// Only update versions, patches, etc. on specific branches to lessen conflicts
try {
// Run DbUpdates to make sure we're up to date.
$DbUpdater = new DbUpdate(['git' => $git]);
$DbUpdater->newPatches(['safe' => false]);
} catch (\Exception $e) {
$error = 1;
echo "Error while checking patches!\n";
echo $e->getMessage() . "\n";
}
if ($error === false) {
try {
$vers = new Versions();
$vers->checkAll();
$vers->save();
$git->add(NN_VERSIONS);
} catch (\Exception $e) {
$error = 1;
echo "Error while checking versions!\n";
}
}
} else {
echo "not 'dev', 'next-master', or 'master' branch, skipping version/patch updates\n";
}
} else {
echo "Error in pre-commit hooks!!\n";
}
exit($error);
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<newznab>
<versions>
<sql>
<db>149</db>
<file>149</file>
</sql>
<git>
<tag>0.0.0</tag>
<!-- commit count removed Dec 2014 -->
<hooks>
<precommit>9</precommit>
<!-- this is the version of the pre-commit file in githooks NOT the files it calls -->
</hooks>
</git>
</versions>
</newznab>
@@ -14,8 +14,8 @@ class AdminPage extends BasePage
parent::__construct();
$tplpaths = [];
if ($this->site->style != "default")
$tplpaths["style_admin"] = WWW_DIR.'templates/'.$this->site->style.'/views/admin';
if ($this->pdo->getSetting('style') != "default")
$tplpaths["style_admin"] = WWW_DIR.'templates/'.$this->pdo->getSetting('style').'/views/admin';
$tplpaths["admin"] = WWW_DIR.'templates/default/views/admin';
$tplpaths["frontend"] = WWW_DIR.'templates/default/views/frontend';
$this->smarty->setTemplateDir($tplpaths);
+5 -4
View File
@@ -1,11 +1,11 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
class AniDB
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -20,7 +20,7 @@ class AniDB
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
}
/**
@@ -28,6 +28,7 @@ class AniDB
*
* @param int $anidbID
* @param string $type
* @param string $title
* @param string $startdate
* @param string $enddate
* @param string $related
@@ -38,7 +39,7 @@ class AniDB
* @param string $categories
* @param string $characters
*/
public function updateTitle($anidbID, $type, $startdate, $enddate, $related, $similar, $creators, $description, $rating, $categories, $characters)
public function updateTitle($anidbID, $title, $type, $startdate, $enddate, $related, $similar, $creators, $description, $rating, $categories, $characters, $epnos, $airdates, $episodetitles)
{
// FIXME fix the missing variables for this query
$this->pdo->queryExec(
@@ -1,13 +1,13 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
class Backfill
{
/**
* Instance of class Settings
*
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -95,7 +95,7 @@ class Backfill
$this->_echoCLI = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->pdo]));
$this->_nntp = ($options['NNTP'] instanceof \NNTP
? $options['NNTP'] : new \NNTP(['Settings' => $this->pdo])
@@ -112,10 +112,10 @@ class Backfill
}
}
$this->_compressedHeaders = ($this->site->compressedheaders == 1 ? true : false);
$this->_safeBackFillDate = ($this->site->safebackfilldate != '') ? (string)$this->site->safebackfilldate : '2008-08-14';
$this->_safePartRepair = ($this->site->safepartrepair == 1 ? 'update' : 'backfill');
$this->_tablePerGroup = ($this->site->tablepergroup == 1 ? true : false);
$this->_compressedHeaders = ($this->pdo->getSetting('compressedheaders') == 1 ? true : false);
$this->_safeBackFillDate = ($this->pdo->getSetting('safebackfilldate') != '') ? (string)$this->pdo->getSetting('safebackfilldate') : '2008-08-14';
$this->_safePartRepair = ($this->pdo->getSetting('safepartrepair') == 1 ? 'update' : 'backfill');
$this->_tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 1 ? true : false);
}
/**
+11 -9
View File
@@ -3,11 +3,12 @@ require_once SMARTY_DIR . 'Smarty.class.php';
require_once NN_LIB . 'utility' . DS . 'SmartyUtils.php';
use newznab\controllers\Captcha;
use newznab\db\Settings;
class BasePage
{
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
*/
public $settings = null;
@@ -60,15 +61,16 @@ class BasePage
// set site variable
$s = new Sites();
$this->site = $s->get();
$this->pdo = new Settings();
// Buffer settings/DB connection.
$this->settings = new newznab\db\DB();
$this->settings = new newznab\db\Settings();
$this->smarty = new Smarty();
$this->captcha = new Captcha(['Settings' => $this->settings]);
$this->smarty->setTemplateDir(
array(
'user_frontend' => NN_WWW . 'templates/' . $this->site->style . '/views/frontend',
'user_frontend' => NN_WWW . 'templates/' . $this->pdo->getSetting('style') . '/views/frontend',
'frontend' => NN_WWW . 'templates/default/views/frontend'
)
);
@@ -78,8 +80,8 @@ class BasePage
$this->smarty->error_reporting = ((NN_DEBUG ? E_ALL : E_ALL - E_NOTICE));
$this->secure_connection = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ;
if (file_exists(WWW_DIR.'templates/'.$this->site->style.'/theme.php'))
require_once(WWW_DIR.'templates/'.$this->site->style.'/theme.php');
if (file_exists(WWW_DIR.'templates/'.$this->pdo->getSetting('style').'/theme.php'))
require_once(WWW_DIR.'templates/'.$this->pdo->getSetting('style').'/theme.php');
$this->smarty->assign('themevars', (isset($themevars) ? $themevars : null));
$servername = null;
@@ -113,7 +115,7 @@ class BasePage
$this->userdata["categoryexclusions"] = $this->users->getCategoryExclusion($this->users->currentUserId());
// Change the theme to user's selected theme if they selected one, else use the admin one.
if ($this->site->userselstyle == 1) {
if ($this->pdo->getSetting('userselstyle') == 1) {
if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') {
$this->smarty->setTemplateDir(
array(
@@ -144,9 +146,9 @@ class BasePage
if ($this->userdata["hideads"] == "1")
{
$this->site->adheader="";
$this->site->adbrowse="";
$this->site->addetail="";
$this->pdo->setSetting(['adheader', '']);
$this->pdo->setSetting(['adbrowse', '']);
$this->pdo->setSetting(['addetail', '']);
}
$this->floodCheck($this->userdata["role"]);
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* Class Binaries
@@ -77,7 +77,7 @@ class Binaries
protected $_partRepair;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
protected $_pdo;
@@ -163,7 +163,7 @@ class Binaries
$s = new Sites();
$this->_site = $s->get();
$this->_pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->_pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->_groups = ($options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->_pdo]));
$this->_colorCLI = ($options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI());
$this->_nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_colorCLI, 'Settings' => $this->_pdo, 'ColorCLI' => $this->_colorCLI]));
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
@@ -11,7 +11,7 @@ class Book
const NUMTOPROCESSPERTIME = 100;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -33,7 +33,7 @@ class Book
$this->pubkey = $site->amazonpubkey;
$this->privkey = $site->amazonprivkey;
$this->asstag = $site->amazonassociatetag;
$this->pdo = new DB();
$this->pdo = new Settings();
$this->imgSavePath = WWW_DIR.'covers/book/';
}
@@ -92,7 +92,7 @@ class Book
else
$maxage = "";
$sql = sprintf("select count(distinct r.bookinfoid) as num from releases r inner join bookinfo b on b.id = r.bookinfoid and b.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') %s %s", $browseby, $maxage);
$sql = sprintf("select count(distinct r.bookinfoid) as num from releases r inner join bookinfo b on b.id = r.bookinfoid and b.title != '' where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') %s %s", $browseby, $maxage);
$res = $this->pdo->queryOneRow($sql, true);
return $res["num"];
@@ -115,7 +115,7 @@ class Book
$maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage);
$order = $this->getBrowseOrder($orderby);
$sql = sprintf(" SELECT r.bookinfoid, max(postdate), b.* from releases r inner join bookinfo b on b.id = r.bookinfoid and b.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') %s %s group by r.bookinfoid order by %s %s".$limit, $browseby, $maxagesql, $order[0], $order[1]);
$sql = sprintf(" SELECT r.bookinfoid, max(postdate), b.* from releases r inner join bookinfo b on b.id = r.bookinfoid and b.title != '' where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') %s %s group by r.bookinfoid order by %s %s".$limit, $browseby, $maxagesql, $order[0], $order[1]);
$rows = $this->pdo->query($sql, true);
//
+10 -10
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
use newznab\libraries\ApaiIO\Operations\Search;
use newznab\libraries\ApaiIO\ApaiIO;
@@ -11,7 +11,7 @@ use newznab\libraries\ApaiIO\ApaiIO;
class Books
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -72,19 +72,19 @@ class Books
$options += $defaults;
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$s = new Sites();
$this->site = $s->get();
$this->pubkey = $this->site->amazonpubkey;
$this->privkey = $this->site->amazonprivkey;
$this->asstag = $this->site->amazonassociatetag;
$this->bookqty = ($this->site->maxbooksprocessed != '') ? $this->site->maxbooksprocessed : 300;
$this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000;
$this->pubkey = $this->pdo->getSetting('amazonpubkey');
$this->privkey = $this->pdo->getSetting('amazonprivkey');
$this->asstag = $this->pdo->getSetting('amazonassociatetag');
$this->bookqty = ($this->pdo->getSetting('maxbooksprocessed') != '') ? $this->pdo->getSetting('maxbooksprocessed') : 300;
$this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000;
$this->imgSavePath = NN_COVERS . 'book' . DS;
$this->bookreqids = ($this->site->book_reqids == null || $this->site->book_reqids == "") ? 7010 : $this->site->book_reqids;
$this->bookreqids = ($this->pdo->getSetting('book_reqids') == null || $this->pdo->getSetting('book_reqids') == "") ? 7010 : $this->pdo->getSetting('book_reqids');
$this->renamed = '';
if ($this->site->lookupbooks == 2) {
if ($this->pdo->getSetting('lookupbooks') == 2) {
$this->renamed = 'AND isrenamed = 1';
}
}
@@ -1,13 +1,13 @@
<?php
namespace newznab\controllers;
use newznab\db\DB;
use newznab\db\Settings;
use ReCaptcha\ReCaptcha;
class Captcha {
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
*/
private $pdo;
@@ -86,7 +86,7 @@ class Captcha {
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$s = new \Sites();
$this->site = $s->get();
}
@@ -194,8 +194,8 @@ class Captcha {
return true;
}
$this->sitekey = $this->site->recaptchapublickey;
$this->secretkey = $this->site->recaptchaprivatekey;
$this->sitekey = $this->pdo->getSetting('recaptchapublickey');
$this->secretkey = $this->pdo->getSetting('recaptchaprivatekey');
if ($this->sitekey != false && $this->sitekey != '') {
if ($this->secretkey != false && $this->secretkey != '') {
@@ -50,9 +50,9 @@ class Categorize extends Category
//parent::__construct($options);
$s = new Sites();
$this->site = $s->get();
$this->pdo = new newznab\db\DB();
$this->categorizeForeign = ($this->site->categorizeforeign == "0") ? false : true;
$this->catWebDL = ($this->site->catwebdl == "0") ? false : true;
$this->pdo = new newznab\db\Settings();
$this->categorizeForeign = ($this->pdo->getSetting('categorizeforeign') == "0") ? false : true;
$this->catWebDL = ($this->pdo->getSetting('catwebdl') == "0") ? false : true;
$this->regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'category_regexes']);
}
+15 -15
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class manages the site wide categories.
@@ -85,7 +85,7 @@ class Category
private $tmpCat = 0;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -101,7 +101,7 @@ class Category
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
}
/**
@@ -143,7 +143,7 @@ class Category
*/
public function isParent($cid)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$ret = $db->queryOneRow(sprintf("select count(*) as count from category where id = %d and parentid is null", $cid), true);
if ($ret['count'])
return true;
@@ -156,7 +156,7 @@ class Category
*/
public function getChildren($cid)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->query(sprintf("select c.* from category c where parentid = %d", $cid), true);
}
@@ -166,7 +166,7 @@ class Category
*/
public function getFlat($activeonly = false)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$act = "";
if ($activeonly)
$act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE);
@@ -181,7 +181,7 @@ class Category
*/
public function getEnabledParentNames()
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->query("SELECT title FROM category WHERE parentid IS NULL AND status = 1");
}
@@ -193,7 +193,7 @@ class Category
*/
public function getDisabledIDs()
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->query("SELECT id FROM category WHERE status = 2 OR parentid IN (SELECT id FROM category WHERE status = 2 AND parentid IS NULL)");
}
@@ -202,14 +202,14 @@ class Category
*/
public function getById($id)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryOneRow(sprintf("SELECT c.disablepreview, c.id, c.description, c.minsizetoformrelease, c.maxsizetoformrelease, CONCAT(COALESCE(cp.title,'') , CASE WHEN cp.title IS NULL THEN '' ELSE ' > ' END , c.title) as title, c.status, c.parentid from category c left outer join category cp on cp.id = c.parentid where c.id = %d", $id));
}
public function getSizeRangeById($id)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$res = $db->queryOneRow(sprintf("SELECT c.minsizetoformrelease, c.maxsizetoformrelease, cp.minsizetoformrelease as p_minsizetoformrelease, cp.maxsizetoformrelease as p_maxsizetoformrelease" .
" from category c left outer join category cp on cp.id = c.parentid where c.id = %d", $id
)
@@ -255,14 +255,14 @@ class Category
*/
public function getByIds($ids)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->query(sprintf("SELECT concat(cp.title, ' > ',c.title) as title from category c inner join category cp on cp.id = c.parentid where c.id in (%s)", implode(',', $ids)));
}
public function getNameByID($ID)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$parent = $db->queryOneRow(sprintf("SELECT title FROM category WHERE id = %d", substr($ID, 0, 1) . "000"));
$cat = $db->queryOneRow(sprintf("SELECT title FROM category WHERE id = %d", $ID));
@@ -274,7 +274,7 @@ class Category
*/
public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryExec(sprintf("update category set disablepreview = %d, status = %d, minsizetoformrelease = %d, maxsizetoformrelease = %d, description = %s where id = %d", $disablepreview, $status, $minsize, $maxsize, $db->escapeString($desc), $id));
}
@@ -284,7 +284,7 @@ class Category
*/
public function getForMenu($excludedcats = array())
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$ret = array();
$exccatlist = "";
@@ -340,7 +340,7 @@ class Category
*/
public function get($activeonly = false, $excludedcats = array())
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
$exccatlist = "";
if (count($excludedcats) > 0)
@@ -55,7 +55,7 @@ class CollectionsCleaning
public $subject = '';
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
*/
public $pdo;
@@ -79,7 +79,7 @@ class CollectionsCleaning
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof newznab\db\DB ? $options['Settings'] : new newznab\db\DB());
$this->pdo = ($options['Settings'] instanceof newznab\db\Settings ? $options['Settings'] : new newznab\db\Settings());
$this->_regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'collection_regexes']);
}
@@ -1,7 +1,7 @@
<?php
require_once NN_LIBS . 'AmazonProductAPI.php';
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class looks up metadata about console releases and handles
@@ -12,7 +12,7 @@ class Console
const NUMTOPROCESSPERTIME = 100;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -34,7 +34,7 @@ class Console
$this->pubkey = $site->amazonpubkey;
$this->privkey = $site->amazonprivkey;
$this->asstag = $site->amazonassociatetag;
$this->pdo = new newznab\db\DB();
$this->pdo = new newznab\db\Settings();
$this->imgSavePath = WWW_DIR.'covers/console/';
}
@@ -122,7 +122,7 @@ class Console
if (count($excludedcats) > 0)
$exccatlist = " and r.categoryid not in (".implode(",", $excludedcats).")";
$sql = sprintf("select count(r.id) as num from releases r inner join consoleinfo con on con.id = r.consoleinfoid and con.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist);
$sql = sprintf("select count(r.id) as num from releases r inner join consoleinfo con on con.id = r.consoleinfoid and con.title != '' where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist);
$res = $this->pdo->queryOneRow($sql, true);
return $res["num"];
}
@@ -177,7 +177,7 @@ class Console
$exccatlist = " and r.categoryid not in (".implode(",", $excludedcats).")";
$order = $this->getConsoleOrder($orderby);
$sql = sprintf(" SELECT r.*, r.id as releaseid, con.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join consoleinfo con on con.id = r.consoleinfoid left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = con.genreID where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s order by %s %s".$limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
$sql = sprintf(" SELECT r.*, r.id as releaseid, con.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join consoleinfo con on con.id = r.consoleinfoid left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = con.genreID where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s order by %s %s".$limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
return $this->pdo->query($sql, true);
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class looks up site content.
@@ -34,7 +34,7 @@ class Contents
*/
public function delete($id)
{
$db = new DB();
$db = new Settings();
return $db->queryExec(sprintf("DELETE from content where id=%d", $id));
}
@@ -43,7 +43,7 @@ class Contents
*/
public function update($content)
{
$db = new DB();
$db = new Settings();
$content = $this->validate($content);
$db->queryExec(sprintf("update content set role=%d, title = %s , url = %s , body = %s , metadescription = %s , metakeywords = %s , contenttype = %d , showinmenu = %d , status = %d , ordinal = %d where id = %d ", $content["role"], $db->escapeString($content["title"]), $db->escapeString($content["url"]), $db->escapeString($content["body"]), $db->escapeString($content["metadescription"]), $db->escapeString($content["metakeywords"]), $content["contenttype"], $content["showinmenu"], $content["status"], $content["ordinal"], $content["id"] ));
}
@@ -53,7 +53,7 @@ class Contents
*/
public function add($content)
{
$db = new DB();
$db = new Settings();
$content = $this->validate($content);
@@ -65,7 +65,7 @@ class Contents
*/
public function get()
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select * from content where status = 1 order by contenttype, coalesce(ordinal, 1000000)"));
}
@@ -74,7 +74,7 @@ class Contents
*/
public function getAll()
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select * from content order by contenttype, coalesce(ordinal, 1000000)"));
}
@@ -83,7 +83,7 @@ class Contents
*/
public function getByID($id, $role)
{
$db = new DB();
$db = new Settings();
if ($role == Users::ROLE_ADMIN)
$role = "";
else
@@ -97,7 +97,7 @@ class Contents
*/
public function getIndex()
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX), true);
}
@@ -106,7 +106,7 @@ class Contents
*/
public function getForMenuByTypeAndRole($id, $role)
{
$db = new DB();
$db = new Settings();
if ($role == Users::ROLE_ADMIN)
$role = "";
else
+7 -9
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* Class for reading and writing NZB files on the hard disk,
@@ -36,7 +36,7 @@ class Enzebe
/**
* Instance of class db.
* @var \newznab\db\DB
* @var \newznab\db\Settings
* @access public
*/
public $pdo;
@@ -75,20 +75,18 @@ class Enzebe
/**
* Default constructor.
*
* @param \DB $pdo
* @param \Settings $pdo
*
* @access public
*/
public function __construct(&$pdo = null)
{
$this->pdo = ($pdo instanceof DB ? $pdo : new DB());
$s = new Sites();
$this->site = $s->get();
$this->pdo = ($pdo instanceof Settings ? $pdo : new Settings());
$this->tablePerGroup = ($this->site->tablepergroup == 0 ? false : true);
$nzbSplitLevel = $this->site->nzbsplitlevel;
$this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 0 ? false : true);
$nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel');
$this->nzbSplitLevel = (empty($nzbSplitLevel) ? 1 : $nzbSplitLevel);
$this->siteNzbPath = (string)$this->site->nzbpath;
$this->siteNzbPath = (string)$this->pdo->getSetting('nzbpath');
if (substr($this->siteNzbPath, -1) !== DS) {
$this->siteNzbPath .= DS;
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class looks up tv episode data.
@@ -12,7 +12,7 @@ class Episode
*/
public function getEpisodeInfoByID($episodeinfoID)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE id = %d', $episodeinfoID));
}
@@ -21,7 +21,7 @@ class Episode
*/
public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute='0')
{
$db = new DB();
$db = new Settings();
if($epabsolute == '0') //as string - not int.
if(!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep))
+10 -10
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
use newznab\libraries\Tmdb\TMDB;
@@ -144,18 +144,18 @@ class Film
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$s = new Sites();
$this->site = $s->get();
$this->releaseImage = ($options['ReleaseImage'] instanceof \ReleaseImage ? $options['ReleaseImage'] : new \ReleaseImage($this->pdo));
$this->lookuplanguage = ($this->site->lookuplanguage != '') ? (string)$this->site->lookuplanguage : 'en';
$this->lookuplanguage = ($this->pdo->getSetting('lookuplanguage') != '') ? (string)$this->pdo->getSetting('lookuplanguage') : 'en';
$this->fanartapikey = $this->site->fanarttvkey;
$this->imdburl = ($this->site->imdburl == 0 ? false : true);
$this->movieqty = ($this->site->maximdbprocessed != '') ? $this->site->maximdbprocessed : 100;
$this->fanartapikey = $this->pdo->getSetting('fanarttvkey');
$this->imdburl = ($this->pdo->getSetting('imdburl') == 0 ? false : true);
$this->movieqty = ($this->pdo->getSetting('maximdbprocessed') != '') ? $this->pdo->getSetting('maximdbprocessed') : 100;
$this->searchEngines = true;
$this->showPasswords = ($this->site->showpasswordedrelease != '') ? $this->site->showpasswordedrelease : 0;
$this->showPasswords = ($this->pdo->getSetting('showpasswordedrelease') != '') ? $this->pdo->getSetting('showpasswordedrelease') : 0;
$this->debug = NN_DEBUG;
$this->echooutput = ($options['Echo'] && NN_ECHOCLI && $this->pdo->cli);
@@ -719,7 +719,7 @@ class Film
public function fetchTMDBProperties($imdbId, $text = false)
{
$lookupId = ($text === false ? 'tt' . $imdbId : $imdbId);
$tmdb = new TMDB($this->site->tmdbkey);
$tmdb = new TMDB($this->pdo->getSetting('tmdbkey'));
try {
$tmdbLookup = $tmdb->getMovie($lookupId);
@@ -821,7 +821,7 @@ class Film
$buffer =
Utility::getUrl([
'url' => 'http://' . ($this->imdburl === false ? 'www' : 'akas') . '.imdb.com/title/tt' . $imdbId . '/',
'language' => (($this->site->lookuplanguage != '') ? $this->site->lookuplanguage : 'en'),
'language' => (($this->pdo->getSetting('lookuplanguage') != '') ? $this->pdo->getSetting('lookuplanguage') : 'en'),
'useragent' => 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) ' .
'Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10', 'foo=bar'
]
@@ -1333,7 +1333,7 @@ class Film
$this->pdo->log->doEcho($this->pdo->log->header('Updating movie schedule using rotten tomatoes.'));
}
$rt = new \RottenTomato($this->site->rottentomatokey);
$rt = new \RottenTomato($this->pdo->getSetting('rottentomatokey'));
if ($rt instanceof \RottenTomato) {
+13 -13
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class handles data access for forum and post data.
@@ -12,7 +12,7 @@ class Forum
*/
public function add($parentid, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0)
{
$db = new DB();
$db = new Settings();
if ($message == "")
return -1;
@@ -35,7 +35,7 @@ class Forum
*/
public function getParent($parent)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.id = forumpost.userid where forumpost.id = %d ", $parent));
}
@@ -44,7 +44,7 @@ class Forum
*/
public function getRecentPosts($limit)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select forumpost.*, users.username from forumpost join (select case when parentid = 0 then id else parentid end as id, max(createddate) from forumpost group by case when parentid = 0 then id else parentid end order by max(createddate) desc) x on x.id = forumpost.id inner join users on userid = users.id limit %d", $limit));
}
@@ -54,7 +54,7 @@ class Forum
*/
public function getPosts($parent)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf(" SELECT forumpost.*, CASE WHEN role=%d THEN 1 ELSE 0 END AS 'isadmin', users.username from forumpost left outer join users on users.id = forumpost.userid where forumpost.id = %d or parentid = %d order by createddate asc limit 250", Users::ROLE_ADMIN, $parent, $parent));
}
@@ -63,7 +63,7 @@ class Forum
*/
public function getPost($id)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf(" SELECT * from forumpost where id = %d", $id));
}
@@ -72,7 +72,7 @@ class Forum
*/
public function getBrowseCount()
{
$db = new DB();
$db = new Settings();
$res = $db->queryOneRow(sprintf("select count(id) as num from forumpost where parentid = 0"));
return $res["num"];
}
@@ -82,7 +82,7 @@ class Forum
*/
public function getBrowseRange($start, $num)
{
$db = new DB();
$db = new Settings();
if ($start === false)
$limit = "";
@@ -97,7 +97,7 @@ class Forum
*/
public function deleteParent($parent)
{
$db = new DB();
$db = new Settings();
$db->queryExec(sprintf("DELETE from forumpost where id = %d or parentid = %d", $parent, $parent));
}
@@ -106,7 +106,7 @@ class Forum
*/
public function deletePost($id)
{
$db = new DB();
$db = new Settings();
$post = $this->getPost($id);
if ($post)
{
@@ -122,7 +122,7 @@ class Forum
*/
public function deleteUser($id)
{
$db = new DB();
$db = new Settings();
$db->queryExec(sprintf("DELETE from forumpost where userid = %d", $id));
}
@@ -131,7 +131,7 @@ class Forum
*/
public function getCountForUser($uid)
{
$db = new DB();
$db = new Settings();
$res = $db->queryOneRow(sprintf("select count(id) as num from forumpost where userid = %d", $uid));
return $res["num"];
}
@@ -141,7 +141,7 @@ class Forum
*/
public function getForUserRange($uid, $start, $num)
{
$db = new DB();
$db = new Settings();
if ($start === false)
$limit = "";
+8 -8
View File
@@ -1,7 +1,7 @@
<?php
require_once NN_LIBS . 'GiantBombAPI.php';
use newznab\db\DB;
use newznab\db\Settings;
class Games
@@ -43,7 +43,7 @@ class Games
public $maxHitRequest;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -103,20 +103,20 @@ class Games
$this->site = $s->get();
$this->echoOutput = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->publicKey = $this->site->giantbombkey;
$this->gameQty = ($this->site->maxgamesprocessed != '') ? $this->site->maxgamesprocessed : 150;
$this->sleepTime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000;
$this->publicKey = $this->pdo->getSetting('giantbombkey');
$this->gameQty = ($this->pdo->getSetting('maxgamesprocessed') != '') ? $this->pdo->getSetting('maxgamesprocessed') : 150;
$this->sleepTime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000;
$this->imgSavePath = NN_COVERS . 'games' . DS;
$this->renamed = '';
$this->matchPercentage = 60;
$this->maxHitRequest = false;
$this->cookie = NN_TMP . 'xxx.cookie';
if ($this->site->lookupgames == 2) {
if ($this->pdo->getSetting('lookupgames') == 2) {
$this->renamed = 'AND isrenamed = 1';
}
//$this->cleangames = ($this->site->('lookupgames') == 2) ? 'AND isrenamed = 1' : '';
//$this->cleangames = ($this->pdo->getSetting('('lookupgames') == 2) ? 'AND isrenamed = 1' : '';
}
public function getGamesInfo($id)
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
class Genres
{
@@ -12,7 +12,7 @@ class Genres
const STATUS_DISABLED = 1;
/**
* @var newznab\db\DB;
* @var newznab\db\Settings;
*/
public $pdo;
@@ -26,7 +26,7 @@ class Genres
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
}
public function getGenres($type = '', $activeonly = false)
+3 -3
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class handles data access for groups.
@@ -9,7 +9,7 @@ class Groups
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -25,7 +25,7 @@ class Groups
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
}
/**
* Get all group rows.
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* Class IRCScraper
@@ -48,7 +48,7 @@ class IRCScraper extends IRCClient
protected $_oldPre;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
* @access protected
*/
protected $_pdo;
@@ -118,7 +118,7 @@ class IRCScraper extends IRCClient
$this->_titleIgnoreRegex = SCRAPE_IRC_TITLE_IGNORE;
}
$this->_pdo = new DB();
$this->_pdo = new Settings();
$this->_groupList = array();
$this->_silent = $silent;
$this->_debug = $debug;
+10 -10
View File
@@ -1,5 +1,5 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use \newznab\processing\PProcess;
use newznab\utility\Utility;
@@ -15,7 +15,7 @@ class Info
{
/**
* Instance of class DB
* @var newznab\db\DB
* @var newznab\db\Settings
* @access private
*/
public $pdo;
@@ -85,17 +85,17 @@ class Info
$this->site = $s->get();
$this->echo = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$s = new Sites();
$this->site = $s->get();
$this->nzbs = ($this->site->maxnfoprocessed != '') ? (int)$this->site->maxnfoprocessed : 100;
$this->maxsize = ($this->site->maxsizetoprocessnfo != '') ? (int)$this->site->maxsizetoprocessnfo : 100;
$this->nzbs = ($this->pdo->getSetting('maxnfoprocessed') != '') ? (int)$this->pdo->getSetting('maxnfoprocessed') : 100;
$this->maxsize = ($this->pdo->getSetting('maxsizetoprocessnfo') != '') ? (int)$this->pdo->getSetting('maxsizetoprocessnfo') : 100;
$this->maxsize = ($this->maxsize > 0 ? ('AND size < ' . ($this->maxsize * 1073741824)) : '');
$this->minsize = ($this->site->minsizetoprocessnfo != '') ? (int)$this->site->minsizetoprocessnfo : 100;
$this->minsize = ($this->pdo->getSetting('minsizetoprocessnfo') != '') ? (int)$this->pdo->getSetting('minsizetoprocessnfo') : 100;
$this->minsize = ($this->minsize > 0 ? ('AND size > ' . ($this->minsize * 1048576)) : '');
$this->maxRetries = (int)($this->site->maxnforetries >= 0 ? -((int)$this->site->maxnforetries + 1) : self::NFO_UNPROC);
$this->maxRetries = (int)($this->pdo->getSetting('maxnforetries') >= 0 ? -((int)$this->pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC);
$this->maxRetries = ($this->maxRetries < -8 ? -8 : $this->maxRetries);
$this->tmpPath = (string)$this->site->tmpunrarpath;
$this->tmpPath = (string)$this->pdo->getSetting('tmpunrarpath');
if (!preg_match('/[\/\\\\]$/', $this->tmpPath)) {
$this->tmpPath .= DS;
}
@@ -240,13 +240,13 @@ class Info
* "AND r.nzbstatus = 1 AND r.nfostatus BETWEEN -8 AND -1 AND r.size < 1073741824 AND r.size > 1048576"
* To use in a query.
*
* @param DB $pdo
* @param Settings $pdo
*
* @return string
* @access public
* @static
*/
static public function NfoQueryString(DB &$pdo)
static public function NfoQueryString(Settings &$pdo)
{
$s = new Sites();
$site = $s->get();
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
use newznab\libraries\ApaiIO\Operations\Search;
use newznab\libraries\ApaiIO\ApaiIO;
@@ -12,7 +12,7 @@ class Konsole
const CONS_NTFND = -2;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -68,18 +68,18 @@ class Konsole
$options += $defaults;
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$s = new Sites();
$this->site = $s->get();
$this->pubkey = $this->site->amazonpubkey;
$this->privkey = $this->site->amazonprivkey;
$this->asstag = $this->site->amazonassociatetag;
$this->gameqty = ($this->site->maxgamesprocessed != '') ? $this->site->maxgamesprocessed : 150;
$this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000;
$this->pubkey = $this->pdo->getSetting('amazonpubkey');
$this->privkey = $this->pdo->getSetting('amazonprivkey');
$this->asstag = $this->pdo->getSetting('amazonassociatetag');
$this->gameqty = ($this->pdo->getSetting('maxgamesprocessed') != '') ? $this->pdo->getSetting('maxgamesprocessed') : 150;
$this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000;
$this->imgSavePath = NN_COVERS . 'console' . DS;
$this->renamed = '';
if ($this->site->lookupgames == 2) {
if ($this->pdo->getSetting('lookupgames') == 2) {
$this->renamed = 'AND isrenamed = 1';
}
//$this->cleanconsole = ($this->pdo->getSetting('lookupgames') == 2) ? 'AND isrenamed = 1' : '';
+7 -7
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class looks up site menu data.
@@ -12,7 +12,7 @@ class Menu
*/
public function get($role, $serverurl)
{
$db = new DB();
$db = new Settings();
$guest = "";
if ($role != Users::ROLE_GUEST)
@@ -46,7 +46,7 @@ class Menu
*/
public function getAll()
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->query(sprintf("select * from menu order by role, ordinal"));
}
@@ -55,7 +55,7 @@ class Menu
*/
public function getById($id)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryOneRow(sprintf("select * from menu where id = %d", $id));
}
@@ -64,7 +64,7 @@ class Menu
*/
public function delete($id)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryExec(sprintf("DELETE from menu where id = %d", $id));
}
@@ -73,7 +73,7 @@ class Menu
*/
public function add($menu)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryInsert(sprintf("INSERT INTO menu (href, title, tooltip, role, ordinal, menueval, newwindow )
VALUES (%s, %s, %s, %d, %d, %s, %d) ", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"] , $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["newwindow"] ));
}
@@ -83,7 +83,7 @@ class Menu
*/
public function update($menu)
{
$db = new newznab\db\DB();
$db = new newznab\db\Settings();
return $db->queryExec(sprintf("update menu set href = %s, title = %s, tooltip = %s, role = %d, ordinal = %d, menueval = %s, newwindow=%d where id = %d ", $db->escapeString($menu["href"]), $db->escapeString($menu["title"]), $db->escapeString($menu["tooltip"]), $menu["role"] , $menu["ordinal"], $db->escapeString($menu["menueval"]), $menu["newwindow"], $menu["id"] ));
}
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
use newznab\libraries\ApaiIO\ApaiIO;
use newznab\libraries\ApaiIO\Operations\Lookup;
@@ -47,15 +47,15 @@ class MiscSorter
$this->qty = 100;
$this->DEBUGGING = NN_DEBUG;
$this->pdo = ($pdo instanceof DB ? $pdo : new DB());
$this->pdo = ($pdo instanceof Settings ? $pdo : new Settings());
$this->category = new Categorize(['Settings' => $this->pdo]);
$this->movie = new Film(['Echo' => $this->echooutput, 'Settings' => $this->pdo]);
$s = new Sites();
$this->site = $s->get();
$this->pubkey = $this->site->amazonpubkey;
$this->privkey = $this->site->amazonprivkey;
$this->asstag = $this->site->amazonassociatetag;
$this->pubkey = $this->pdo->getSetting('amazonpubkey');
$this->privkey = $this->pdo->getSetting('amazonprivkey');
$this->asstag = $this->pdo->getSetting('amazonassociatetag');
}
// Main function that determines which operation(s) should be run based on the releases NFO file
@@ -378,7 +378,7 @@ class MiscSorter
echo $e->getMessage();
}
//$amazon = new AmazonProductAPI($this->site->amazonpubkey, $this->site->amazonprivkey, $this->site->amazonassociatetag);
//$amazon = new AmazonProductAPI($this->pdo->getSetting('amazonpubkey, $this->pdo->getSetting('amazonprivkey, $this->pdo->getSetting('amazonassociatetag);
$amalookup = new Lookup();
$apaiIo = new ApaiIO($conf);
+6 -6
View File
@@ -1,7 +1,7 @@
<?php
require_once NN_LIBS . 'TMDb.php';
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -16,7 +16,7 @@ class Movie
const SRC_DVD = 5;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -53,7 +53,7 @@ class Movie
$site = $s->get();
$this->apikey = $site->tmdbkey;
$this->lookuplanguage = $site->lookuplanguage;
$this->pdo = new DB();
$this->pdo = new Settings();
$this->imgSavePath = NN_COVERS . 'movies' . DS;
}
@@ -175,7 +175,7 @@ class Movie
if (count($excludedcats) > 0)
$exccatlist = " and r.categoryid not in (".implode(",", $excludedcats).")";
$sql = sprintf("select count(distinct r.imdbid) as num from releases r inner join movieinfo m on m.imdbid = r.imdbid and m.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s ", $browseby, $catsrch, $maxage, $exccatlist);
$sql = sprintf("select count(distinct r.imdbid) as num from releases r inner join movieinfo m on m.imdbid = r.imdbid and m.title != '' where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s ", $browseby, $catsrch, $maxage, $exccatlist);
$res = $this->pdo->queryOneRow($sql, true);
return $res["num"];
}
@@ -232,7 +232,7 @@ class Movie
$exccatlist = " and r.categoryid not in (".implode(",", $excludedcats).")";
$order = $this->getMovieOrder($orderby);
$sql = sprintf(" SELECT r.imdbid, max(r.postdate) as postdate, m.* from releases r inner join movieinfo m on m.imdbid = r.imdbid where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and m.title != '' and r.imdbid != 0000000 and %s %s %s %s group by r.imdbid order by %s %s".$limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
$sql = sprintf(" SELECT r.imdbid, max(r.postdate) as postdate, m.* from releases r inner join movieinfo m on m.imdbid = r.imdbid where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and m.title != '' and r.imdbid != 0000000 and %s %s %s %s group by r.imdbid order by %s %s".$limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
$rows = $this->pdo->query($sql, true);
//
@@ -348,7 +348,7 @@ class Movie
*/
public function getBrowseBy()
{
$this->pdo = new newznab\db\DB;
$this->pdo = new newznab\db\Settings;
$browseby = ' ';
$browsebyArr = $this->getBrowseByOptions();
+6 -6
View File
@@ -1,7 +1,7 @@
<?php
require_once NN_LIBS . 'AmazonProductAPI.php';
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -12,7 +12,7 @@ class Music
const NUMTOPROCESSPERTIME = 100;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -34,7 +34,7 @@ class Music
$this->pubkey = $site->amazonpubkey;
$this->privkey = $site->amazonprivkey;
$this->asstag = $site->amazonassociatetag;
$this->pdo = new newznab\db\DB();
$this->pdo = new newznab\db\Settings();
$this->imgSavePath = WWW_DIR.'covers/music/';
}
@@ -122,7 +122,7 @@ class Music
if (count($excludedcats) > 0)
$exccatlist = " and r.categoryid not in (".implode(",", $excludedcats).")";
$sql = sprintf("select count(r.id) as num from releases r inner join musicinfo m on m.id = r.musicinfoid and m.title != '' where r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist);
$sql = sprintf("select count(r.id) as num from releases r inner join musicinfo m on m.id = r.musicinfoid and m.title != '' where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s", $browseby, $catsrch, $maxage, $exccatlist);
$res = $this->pdo->queryOneRow($sql, true);
return $res["num"];
}
@@ -178,7 +178,7 @@ class Music
$order = $this->getMusicOrder($orderby);
// query modified to join to musicinfo after limiting releases as performance issue prevented sane sql.
$sql = sprintf(" SELECT r.*, r.id as releaseid, m.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join musicinfo m on m.id = r.musicinfoid and m.title != '' left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = m.genreID inner join (select r.id from releases r inner join musicinfo m ON m.id = r.musicinfoid and m.title != '' where r.musicinfoid > 0 and r.passwordstatus <= (select value from site where setting='showpasswordedrelease') and %s %s %s %s order by %s %s %s) x on x.id = r.id order by %s %s", $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1], $limit, $order[0], $order[1]);
$sql = sprintf(" SELECT r.*, r.id as releaseid, m.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join musicinfo m on m.id = r.musicinfoid and m.title != '' left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = m.genreID inner join (select r.id from releases r inner join musicinfo m ON m.id = r.musicinfoid and m.title != '' where r.musicinfoid > 0 and r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s order by %s %s %s) x on x.id = r.id order by %s %s", $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1], $limit, $order[0], $order[1]);
return $this->pdo->query($sql, true);
}
@@ -238,7 +238,7 @@ class Music
*/
public function getBrowseBy()
{
$this->pdo = new newznab\db\DB;
$this->pdo = new newznab\db\Settings;
$browseby = ' ';
$browsebyArr = $this->getBrowseByOptions();
+9 -9
View File
@@ -1,5 +1,5 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
use newznab\libraries\ApaiIO\Operations\Search;
use newznab\libraries\ApaiIO\ApaiIO;
@@ -10,7 +10,7 @@ use newznab\libraries\ApaiIO\ApaiIO;
class Musik
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -69,15 +69,15 @@ class Musik
$s = new Sites();
$this->site = $s->get();
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pubkey = $this->site->amazonpubkey;
$this->privkey = $this->site->amazonprivkey;
$this->asstag = $this->site->amazonassociatetag;
$this->musicqty = ($this->site->maxmusicprocessed != '') ? $this->site->maxmusicprocessed : 150;
$this->sleeptime = ($this->site->amazonsleep != '') ? $this->site->amazonsleep : 1000;
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->pubkey = $this->pdo->getSetting('amazonpubkey');
$this->privkey = $this->pdo->getSetting('amazonprivkey');
$this->asstag = $this->pdo->getSetting('amazonassociatetag');
$this->musicqty = ($this->pdo->getSetting('maxmusicprocessed') != '') ? $this->pdo->getSetting('maxmusicprocessed') : 150;
$this->sleeptime = ($this->pdo->getSetting('amazonsleep') != '') ? $this->pdo->getSetting('amazonsleep') : 1000;
$this->imgSavePath = NN_COVERS . 'music' . DS;
$this->renamed = '';
if ($this->site->lookupmusic == 2) {
if ($this->pdo->getSetting('lookupmusic') == 2) {
$this->renamed = 'AND isrenamed = 1';
}
}
+5 -5
View File
@@ -107,7 +107,7 @@ class NNTP extends Net_NNTP_Client
$this->_echo = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof \newznab\db\DB ? $options['Settings'] : new \newznab\db\DB());
$this->pdo = ($options['Settings'] instanceof \newznab\db\Settings ? $options['Settings'] : new \newznab\db\Settings());
$s = new Sites();
$this->site = $s->get();
@@ -120,7 +120,7 @@ class NNTP extends Net_NNTP_Client
}
}
$this->_nntpRetries = ($this->site->nntpretries != '') ? (int)$this->site->nntpretries : 0 + 1;
$this->_nntpRetries = ($this->pdo->getSetting('nntpretries') != '') ? (int)$this->pdo->getSetting('nntpretries') : 0 + 1;
$this->_initiateYEncSettings();
}
@@ -274,7 +274,7 @@ class NNTP extends Net_NNTP_Client
// If we are connected and authenticated, try enabling compression if we have it enabled.
if ($connected === true && $authenticated === true) {
// Check if we should use compression on the connection.
if ($compression === false || $this->site->compressedheaders == 0) {
if ($compression === false || $this->pdo->getSetting('compressedheaders') == 0) {
$this->_compressionSupported = false;
}
if ($this->_debugBool) {
@@ -347,7 +347,7 @@ class NNTP extends Net_NNTP_Client
*/
public function enableCompression()
{
if (!$this->site->compressedheaders == 1) {
if (!$this->pdo->getSetting('compressedheaders') == 1) {
return;
}
$this->_enableCompression();
@@ -1220,7 +1220,7 @@ class NNTP extends Net_NNTP_Client
protected function _initiateYEncSettings()
{
// Check if the user wants to use yyDecode or the simple_php_yenc_decode extension.
$this->_yyDecoderPath = ($this->site->yydecoderpath != '') ? (string)$this->site->yydecoderpath : false;
$this->_yyDecoderPath = ($this->pdo->getSetting('yydecoderpath') != '') ? (string)$this->pdo->getSetting('yydecoderpath') : false;
if (strpos((string)$this->_yyDecoderPath, 'simple_php_yenc_decode') !== false) {
if (extension_loaded('simple_php_yenc_decode')) {
$this->_yEncExtension = true;
+7 -7
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* Class for reading and writing NZB files on the hard disk,
@@ -39,7 +39,7 @@ class NZB
/**
* Instance of class db.
* @var \newznab\db\DB
* @var \newznab\db\Settings
* @access public
*/
public $pdo;
@@ -89,20 +89,20 @@ class NZB
/**
* Default constructor.
*
* @param \newznab\db\DB $pdo
* @param \newznab\db\Settings $pdo
*
* @access public
*/
public function __construct(&$pdo = null)
{
$this->pdo = ($pdo instanceof DB ? $pdo : new DB());
$this->pdo = ($pdo instanceof Settings ? $pdo : new Settings());
$s = new Sites();
$this->site = $s->get();
$this->tablePerGroup = ($this->site->tablepergroup == 0 ? false : true);
$nzbSplitLevel = $this->site->nzbsplitlevel;
$this->tablePerGroup = ($this->pdo->getSetting('tablepergroup') == 0 ? false : true);
$nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel');
$this->nzbSplitLevel = (empty($nzbSplitLevel) ? 1 : $nzbSplitLevel);
$this->siteNzbPath = (string)$this->site->nzbpath;
$this->siteNzbPath = (string)$this->pdo->getSetting('nzbpath');
if (substr($this->siteNzbPath, -1) !== DS) {
$this->siteNzbPath .= DS;
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use \newznab\processing\PProcess;
use newznab\utility\Utility;
@@ -12,7 +12,7 @@ use newznab\utility\Utility;
Class NZBContents
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
* @access protected
*/
public $pdo;
@@ -68,7 +68,7 @@ Class NZBContents
* 'NNTP' => NNTP ; Class NNTP.
* 'Nfo' => Nfo ; Class Info.
* 'NZB' => NZB ; Class NZB.
* 'Settings' => DB ; Class newznab\db\DB.
* 'Settings' => DB ; Class newznab\db\Settings.
* 'PostProcess' => PProcess ; Class PProcess.
* )
*
@@ -87,7 +87,7 @@ Class NZBContents
$options += $defaults;
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->nntp = ($options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->echooutput, 'Settings' => $this->pdo]));
$this->nfo = ($options['Nfo'] instanceof \Info ? $options['Nfo'] : new \Info(['Echo' => $this->echooutput, 'Settings' => $this->pdo]));
$this->pp = (
@@ -101,7 +101,7 @@ Class NZBContents
$s = new Sites();
$this->site = $s->get();
$this->lookuppar2 = ($this->tmux->lookuppar2 == 1 ? true : false);
$this->alternateNNTP = ($this->site->alternate_nntp == 1 ? true : false);
$this->alternateNNTP = ($this->pdo->getSetting('alternate_nntp') == 1 ? true : false);
}
/**
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -23,7 +23,7 @@ class NZBExport
protected $retVal;
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
* @access protected
*/
protected $pdo;
@@ -64,7 +64,7 @@ class NZBExport
$this->browser = $options['Browser'];
$this->echoCLI = (!$this->browser && NN_ECHOCLI && $options['Echo']);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Setting'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Setting'] : new Settings());
$this->releases = ($options['Releases'] instanceof \Releases ? $options['Releases'] : new \Releases(['Settings' => $this->pdo]));
$this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo));
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -10,7 +10,7 @@ use newznab\utility\Utility;
class NZBImport
{
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
* @access protected
*/
protected $pdo;
@@ -107,7 +107,7 @@ class NZBImport
$s = new Sites();
$this->site = $s->get();
$this->echoCLI = (!$this->browser && NN_ECHOCLI && $options['Echo']);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->binaries = ($options['Binaries'] instanceof \Binaries ? $options['Binaries'] : new \Binaries(['Settings' => $this->pdo, 'Echo' => $this->echoCLI]));
$this->category = ($options['Categorize'] instanceof \Categorize ? $options['Categorize'] : new \Categorize(['Settings' => $this->pdo]));
$this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo));
@@ -116,7 +116,7 @@ class NZBImport
$s = new Sites();
$this->site = $s->get();
$this->crossPostt = ($this->site->crossposttime != '') ? $this->site->crossposttime : 2;
$this->crossPostt = ($this->pdo->getSetting('crossposttime') != '') ? $this->pdo->getSetting('crossposttime') : 2;
$this->browser = $options['Browser'];
$this->retVal = '';
}
@@ -403,7 +403,7 @@ class NZBImport
'postdate' => $this->pdo->escapeString($nzbDetails['postDate']),
'fromname' => $escapedFromName,
'reqid' => NULL,
'passwordstatus' => ($this->site->checkpasswordedrar > 0 ? -1 : 0),
'passwordstatus' => ($this->pdo->getSetting('checkpasswordedrar') > 0 ? -1 : 0),
'size' => $this->pdo->escapeString($nzbDetails['totalSize']),
'categoryid' => $this->category->determineCategory($nzbDetails['groupid'], $cleanName),
'isrenamed' => $renamed,
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use \newznab\processing\PProcess;
use newznab\utility\Utility;
@@ -94,7 +94,7 @@ class NameFixer
protected $fullall;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -141,7 +141,7 @@ class NameFixer
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
$this->relid = $this->fixed = $this->checked = 0;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->timeother = ' AND rel.adddate > (NOW() - INTERVAL 0 HOUR) AND rel.categoryid IN (1090, 2020, 3050, 6050, 5050, 7050, 8010, 8020) GROUP BY rel.id ORDER BY postdate DESC';
$this->timeall = ' AND rel.adddate > (NOW() - INTERVAL 6 HOUR) GROUP BY rel.id ORDER BY postdate DESC';
$this->fullother = ' AND rel.categoryid IN (1090, 2020, 3050, 6050, 5050, 7050, 8010, 8020) GROUP BY rel.id';
+6 -6
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
// Silent Error Handler (used to shut up noisy XML exceptions)
function nfoHandleError($errno, $errstr, $errfile, $errline, array $errcontext){
@@ -224,7 +224,7 @@ class Nfo
// it no good, we need to add it to the skipped array which
// must be passed into the function.
$db = new DB();
$db = new Settings();
foreach($blobhash as $uid => $blob){
$query = sprintf(
"REPLACE INTO releasenfo (id, releaseid, binaryID, nfo) ".
@@ -489,7 +489,7 @@ class Nfo
// nzb files are further parsed for nfo segments that can
// be extracted and applied to the release
$nzb = new NZB();
$db = new DB();
$db = new Settings();
// How many releases to handle at a time
$batch=Nfo::NNTP_BATCH_COUNT;
@@ -587,7 +587,7 @@ class Nfo
*/
public function deleteReleaseNfo($relid)
{
$db = new DB();
$db = new Settings();
return $db->queryExec(sprintf("DELETE from releasenfo where releaseid = %d", $relid));
}
@@ -596,7 +596,7 @@ class Nfo
*/
private function setNfoMissing($relid)
{
$db = new DB();
$db = new Settings();
$q = sprintf("UPDATE releases SET releasenfoid = %d ".
"WHERE id = %d", Nfo::FLAG_NFO_MISSING, $relid);
return $db->queryExec($q);
@@ -607,7 +607,7 @@ class Nfo
*/
public function getNfo($relid, &$nfoout)
{
$db = new DB();
$db = new Settings();
// Has NFO Query
$mnfo = "SELECT uncompress(rn.nfo) as nfo FROM releases r ".
"INNER JOIN releasenfo rn ON rn.releaseid = r.id AND rn.id = r.releasenfoid ".
+1 -1
View File
@@ -23,7 +23,7 @@ class Page extends BasePage
$this->smarty->assign('usefulcontentlist',$content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
$this->smarty->assign('articlecontentlist',$content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
if ($this->userdata != null)
$this->smarty->assign('recentforumpostslist',$f->getRecentPosts($this->site->showrecentforumposts));
$this->smarty->assign('recentforumpostslist',$f->getRecentPosts($this->pdo->getSetting('showrecentforumposts')));
$this->smarty->assign('main_menu',$this->smarty->fetch('mainmenu.tpl'));
$this->smarty->assign('useful_menu',$this->smarty->fetch('usefullinksmenu.tpl'));
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class handles parsing misc>other releases into real names.
@@ -8,7 +8,7 @@ use newznab\db\DB;
class Parsing
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -35,7 +35,7 @@ class Parsing
$this->cleanup = ['nuke' => [], 'misc' => []];
$s = new Sites();
$this->site = $s->get();
$this->pdo = new newznab\db\DB();
$this->pdo = new newznab\db\Settings();
}
/**
@@ -661,7 +661,7 @@ class Parsing
//Lookup name via reqid (filename)
if (preg_match('/\.(avi|mkv|mp4|mov|wmv|iso|img|gcm|ps3|wad|ac3|nds|bin|cue|mdf)/i', $rarFile))
{
$this->site->reqidurl;
$this->pdo->getSetting('reqidurl;
$lookupUrl = 'http://allfilled/query.php?t=alt.binaries.srrdb&reqid='.urlencode(basename($rarFile));
echo '-lookup: '.$lookupUrl."\n";
$xml = Utility::getUrl(['url' => $lookupUrl]);
@@ -685,7 +685,7 @@ class Parsing
}
// do par check if user has elected for downloading extra stuff
if ($this->site->unrarpath != '' && $foundName == "") {
if ($this->pdo->getSetting('unrarpath') != '' && $foundName == "") {
$nzb = new NZB();
$nzbfile = $nzb->NZBPath($rel['guid']);
$nzbInfo = new nzbInfo;
@@ -1485,12 +1485,12 @@ class Parsing
/**
* update a release name
*
* @param DB $pdo
* @param Settings $pdo
* @param $id
* @param $oldname
* @param $newname
*/
private function updateName(DB $pdo, $id, $oldname, $newname)
private function updateName(Settings $pdo, $id, $oldname, $newname)
{
if ($this->verbose)
echo sprintf("OLD : %s\nNEW : %s\n\n", $oldname, $newname);
@@ -2,7 +2,7 @@
require_once NN_LIBS . 'rarinfo/par2info.php';
require_once NN_LIBS . 'rarinfo/archiveinfo.php';
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -12,7 +12,7 @@ class PostProcess
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -31,7 +31,7 @@ class PostProcess
$this->echooutput = (NN_ECHOCLI && $echooutput);;
$s = new \Sites();
$this->site = $s->get();
$this->pdo = new DB();
$this->pdo = new Settings();
$this->mediafileregex = 'AVI|VOB|MKV|MP4|TS|WMV|MOV|M4V|F4V|MPG|MPEG|M2TS';
$this->audiofileregex = 'MP3|AAC|OGG';
$this->mp3SavePath = WWW_DIR.'covers/audio/';
@@ -64,7 +64,7 @@ class PostProcess
//
// Delete any passworded releases
//
if($this->site->deletepasswordedrelease == 1)
if($this->pdo->getSetting('deletepasswordedrelease') == 1)
{
echo "PostPrc : Removing unwanted releases\n";
$result = $this->pdo->query("select id from releases where passwordstatus > 0");
@@ -75,11 +75,11 @@ class PostProcess
//
// Delete any releases which are older than site's release retention days
//
if($this->site->releaseretentiondays != 0)
if($this->pdo->getSetting('releaseretentiondays') != 0)
{
echo "PostPrc : Deleting releases older than ".$this->site->releaseretentiondays." days\n";
echo "PostPrc : Deleting releases older than ".$this->pdo->getSetting('releaseretentiondays')." days\n";
$result = $this->pdo->query(sprintf("select id from releases where postdate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->site->releaseretentiondays));
$result = $this->pdo->query(sprintf("select id from releases where postdate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('releaseretentiondays')));
foreach ($result as $row)
$r->delete($row["id"]);
}
@@ -87,13 +87,13 @@ class PostProcess
//
// Delete any audiopreviews older than site->audiopreviewprune days
//
if($this->site->audiopreviewprune > 0)
if($this->pdo->getSetting('audiopreviewprune') > 0)
{
$result = $this->pdo->query(sprintf("select guid from releases where categoryid in (select id from category where parentid = ".Category::CAT_PARENT_MUSIC.") and haspreview = 2 and adddate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->site->audiopreviewprune));
$result = $this->pdo->query(sprintf("select guid from releases where categoryid in (select id from category where parentid = ".Category::CAT_PARENT_MUSIC.") and haspreview = 2 and adddate < %s - interval %d day", $this->pdo->escapeString($currTime_ori["now"]), $this->pdo->getSetting('audiopreviewprune')));
if (sizeof($result) > 0)
{
echo "PostPrc : Deleting ".count($result)." audio previews older than ".$this->site->audiopreviewprune." days\n";
echo "PostPrc : Deleting ".count($result)." audio previews older than ".$this->pdo->getSetting('audiopreviewprune')." days\n";
foreach ($result as $row)
{
$r->updateHasPreview($row["guid"], 0);
@@ -105,7 +105,7 @@ class PostProcess
//
// Delete any releases suspected of being spam/virus
//
if($this->site->removespam != 0)
if($this->pdo->getSetting('removespam') != 0)
{
$spamIDs = array();
@@ -119,9 +119,9 @@ class PostProcess
//
// all releases containing exe not in permitted categories
//
if ($this->site->exepermittedcategories != '')
if ($this->pdo->getSetting('exepermittedcategories') != '')
{
$sql = sprintf("select releasefiles.releaseid as id from releasefiles inner join releases on releases.id = releasefiles.releaseid left join releasenfo on releasenfo.releaseid = releases.id where releasefiles.name like '%%.exe' and releases.categoryid not in (%s) group by releasefiles.releaseid", $this->site->exepermittedcategories);
$sql = sprintf("select releasefiles.releaseid as id from releasefiles inner join releases on releases.id = releasefiles.releaseid left join releasenfo on releasenfo.releaseid = releases.id where releasefiles.name like '%%.exe' and releases.categoryid not in (%s) group by releasefiles.releaseid", $this->pdo->getSetting('exepermittedcategories'));
$result = $this->pdo->query($sql);
$spamIDs = array_merge($result, $spamIDs);
}
@@ -161,7 +161,7 @@ class PostProcess
*/
public function processNfos()
{
if ($this->site->lookupnfo == 1)
if ($this->pdo->getSetting('lookupnfo') == 1)
{
$nfo = new Nfo($this->echooutput);
$nfo->processNfoFiles(500);
@@ -189,7 +189,7 @@ class PostProcess
*/
public function processMovies()
{
if ($this->site->lookupimdb == 1)
if ($this->pdo->getSetting('lookupimdb') == 1)
{
$movie = new Movie($this->echooutput);
$movie->processMovieReleases();
@@ -201,7 +201,7 @@ class PostProcess
*/
public function processMusic()
{
if ($this->site->lookupmusic == 1)
if ($this->pdo->getSetting('lookupmusic') == 1)
{
$music = new Music($this->echooutput);
$music->processMusicReleases();
@@ -213,7 +213,7 @@ class PostProcess
*/
public function processBooks()
{
if ($this->site->lookupbooks == 1)
if ($this->pdo->getSetting('lookupbooks') == 1)
{
$book = new Book($this->echooutput);
$book->processBookReleases();
@@ -225,7 +225,7 @@ class PostProcess
*/
public function processGames()
{
if ($this->site->lookupgames == 1)
if ($this->pdo->getSetting('lookupgames') == 1)
{
$console = new Console($this->echooutput);
$console->processConsoleReleases();
@@ -261,20 +261,20 @@ class PostProcess
*/
public function processTv()
{
if ($this->site->lookupanidb == 1)
if ($this->pdo->getSetting('lookupanidb') == 1)
{
$anidb = new AniDB($this->echooutput);
$anidb->animetitlesUpdate();
$anidb->processAnimeReleases();
}
if ($this->site->lookuptvrage == 1)
if ($this->pdo->getSetting('lookuptvrage') == 1)
{
$tvrage = new TVRage($this->echooutput);
$tvrage->processTvReleases(($this->site->lookuptvrage==1));
$tvrage->processTvReleases(($this->pdo->getSetting('lookuptvrage') ==1));
}
if ($this->site->lookupthetvdb == 1)
if ($this->pdo->getSetting('lookupthetvdb') == 1)
{
$thetvdb = new TheTVDB($this->echooutput);
$thetvdb->processReleases();
@@ -287,20 +287,20 @@ class PostProcess
public function processOtherMiscCategory()
{
$p = null;
if($this->site->updatecleanup == 1)
if($this->pdo->getSetting('updatecleanup') == 1)
{
$p = new Parsing(false, true, false);
$p->cleanup();
}
if($this->site->updateparsing == 1)
if($this->pdo->getSetting('updateparsing') == 1)
{
if ($p == null)
$p = new Parsing(false, true, false);
$p->process();
}
if($this->site->removespecial == 1)
if($this->pdo->getSetting('removespecial') == 1)
{
if ($p == null)
$p = new Parsing(false, true, false);
@@ -315,12 +315,12 @@ class PostProcess
{
$maxattemptstocheckpassworded = 5;
$processVideoSample = ($this->site->ffmpegpath != '') ? true : false;
$processMediainfo = ($this->site->mediainfopath != '') ? true : false;
$processPasswords = ($this->site->unrarpath != '') ? true : false;
$processAudioSample = ($this->site->saveaudiopreview == 1) ? true : false;
$processVideoSample = ($this->pdo->getSetting('ffmpegpath') != '') ? true : false;
$processMediainfo = ($this->pdo->getSetting('mediainfopath') != '') ? true : false;
$processPasswords = ($this->pdo->getSetting('unrarpath') != '') ? true : false;
$processAudioSample = ($this->pdo->getSetting('saveaudiopreview') == 1) ? true : false;
$tmpPath = $this->site->tmpunrarpath;
$tmpPath = $this->pdo->getSetting('tmpunrarpath');
if (substr($tmpPath, -strlen( '/' ) ) != '/')
{
$tmpPath = $tmpPath.'/';
@@ -368,7 +368,7 @@ class PostProcess
// only load nzbs and check for rar files if we are doing something with them.
if ($processVideoSample || $processMediainfo || $processPasswords || $processAudioSample)
{
$nzbfile = $nzb->NZBPath($rel['guid'], $this->site->nzbpath);
$nzbfile = $nzb->NZBPath($rel['guid'], $this->pdo->getSetting('nzbpath'));
if (!$nzbInfo->loadFromFile($nzbfile))
{
continue;
@@ -401,7 +401,7 @@ class PostProcess
file_put_contents($samplefile, $sampleBinary);
$blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']);
$blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']);
if ($blnTookSample)
$this->updateReleaseHasPreview($rel['guid']);
@@ -432,13 +432,13 @@ class PostProcess
if ($processVideoSample && $blnTookSample === false)
{
$blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']);
$blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']);
if ($blnTookSample)
$this->updateReleaseHasPreview($rel['guid']);
}
if ($processMediainfo)
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']);
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']);
unlink($mediafile);
}
@@ -470,23 +470,23 @@ class PostProcess
$this->updateReleaseHasPreview($rel['guid'], 2);
if ($processMediainfo)
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']);
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']);
if ($this->site->lamepath != "")
$this->lameAudioSample($this->site->lamepath, $rel['guid']);
if ($this->pdo->getSetting('lamepath') != "")
$this->lameAudioSample($this->pdo->getSetting('lamepath'), $rel['guid']);
unlink($audiofile);
}
unset($audioBinary);
}
if (!empty($nzbInfo->rarfiles) && ($this->site->checkpasswordedrar > 0 || (($processVideoSample || $processAudioSample) && $blnTookSample === false) || $processMediainfo))
if (!empty($nzbInfo->rarfiles) && ($this->pdo->getSetting('checkpasswordedrar') > 0 || (($processVideoSample || $processAudioSample) && $blnTookSample === false) || $processMediainfo))
{
$mysqlkeepalive = 0;
foreach($nzbInfo->rarfiles as $rarFile)
{
//dont process any more rars if a passworded rar has been detected and the site is set to automatically delete them
if ($this->site->deletepasswordedrelease == 1 && max($passStatus) == Releases::PASSWD_RAR)
if ($this->pdo->getSetting('deletepasswordedrelease') == 1 && max($passStatus) == Releases::PASSWD_RAR)
{
echo "-Skipping processing of rar {$rarFile['subject']} as this release has already been marked as passworded.\n";
continue;
@@ -510,24 +510,24 @@ class PostProcess
{
$relFiles = $this->processReleaseFiles($fetchedBinary, $rel['id']);
if ($this->site->checkpasswordedrar > 0 && $processPasswords)
if ($this->pdo->getSetting('checkpasswordedrar') > 0 && $processPasswords)
{
$passStatus[] = $this->processReleasePasswords($fetchedBinary, $tmpPath, $this->site->unrarpath, $this->site->checkpasswordedrar);
$passStatus[] = $this->processReleasePasswords($fetchedBinary, $tmpPath, $this->pdo->getSetting('unrarpath'), $this->pdo->getSetting('checkpasswordedrar'));
}
// we need to unrar the fetched binary if checkpasswordedrar wasnt 2
if ($this->site->checkpasswordedrar < 2 && $processPasswords)
if ($this->pdo->getSetting('checkpasswordedrar') < 2 && $processPasswords)
{
$rarfile = $tmpPath.'rarfile.rar';
file_put_contents($rarfile, $fetchedBinary);
$execstring = '"'.$this->site->unrarpath.'" e -ai -ep -c- -id -r -kb -p- -y -inul "'.$rarfile.'" "'.$tmpPath.'"';
$execstring = '"'.$this->pdo->getSetting('unrarpath').'" e -ai -ep -c- -id -r -kb -p- -y -inul "'.$rarfile.'" "'.$tmpPath.'"';
$output = Utility::runCmd($execstring, false, true);
unlink($rarfile);
}
if ($processVideoSample && $blnTookSample === false)
{
$blnTookSample = $this->getSample($tmpPath, $this->site->ffmpegpath, $rel['guid']);
$blnTookSample = $this->getSample($tmpPath, $this->pdo->getSetting('ffmpegpath'), $rel['guid']);
if ($blnTookSample)
$this->updateReleaseHasPreview($rel['guid']);
}
@@ -545,14 +545,14 @@ class PostProcess
if ($processMediainfo && $blnTookMediainfo === false)
{
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->site->mediainfopath, $rel['id']);
$blnTookMediainfo = $this->getMediainfo($tmpPath, $this->pdo->getSetting('mediainfopath'), $rel['id']);
}
//
// Has to be done after mediainfo
//
if ($blnTookAudioSample && $this->site->lamepath != "")
$this->lameAudioSample($this->site->lamepath, $rel['guid']);
if ($blnTookAudioSample && $this->pdo->getSetting('lamepath') != "")
$this->lameAudioSample($this->pdo->getSetting('lamepath'), $rel['guid']);
if ($mysqlkeepalive % 25 == 0)
$this->pdo->query("select 1");
@@ -886,7 +886,7 @@ class PostProcess
$minacceptableencodefilesize = 10000;
$samplefile = $this->mp3SavePath.$releaseguid.'.mp3';
$samplefileogg = $this->mp3SavePath.$releaseguid.'.ogg';
$ffmpeginfo = $this->site->ffmpegpath;
$ffmpeginfo = $this->pdo->getSetting('ffmpegpath');
if (file_exists($samplefile))
{
@@ -987,9 +987,9 @@ class PostProcess
*/
public function processMusicFromMediaInfo()
{
$processMediainfo = ($this->site->mediainfopath != '') ? true : false;
$processAudioSample = ($this->site->saveaudiopreview == 1) ? true : false;
$processMusic = ($this->site->lookupmusic == 1) ? true : false;
$processMediainfo = ($this->pdo->getSetting('mediainfopath') != '') ? true : false;
$processAudioSample = ($this->pdo->getSetting('saveaudiopreview') == 1) ? true : false;
$processMusic = ($this->pdo->getSetting('lookupmusic') == 1) ? true : false;
if ($processMusic && $processMediainfo && $processAudioSample)
{
+5 -5
View File
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
@@ -9,7 +9,7 @@ use newznab\db\DB;
class PreDB
{
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -26,7 +26,7 @@ class PreDB
public function __construct($echooutput = true)
{
$this->echooutput = (NN_ECHOCLI && $echooutput);
$this->pdo = new DB();
$this->pdo = new Settings();
}
/**
@@ -138,11 +138,11 @@ class PreDB
/**
* Add/Update predb row.
*
* @param newznab\db\DB $pdo
* @param newznab\db\Settings $pdo
* @param $preArray
* @return bool
*/
public function updatePreDB(DB $pdo, $preArray)
public function updatePreDB(Settings $pdo, $preArray)
{
if(!preg_match('/^(UN)?((MOD)?NUKED?|DELPRE)$/', $preArray['category']))
{
@@ -1,7 +1,7 @@
<?php
require_once NN_LIBS . 'simple_html_dom.php';
use newznab\db\DB;
use newznab\db\Settings;
/**
* Class for inserting names/categories etc from PreDB sources into the DB,
@@ -30,7 +30,7 @@ Class PreHash
protected $echooutput;
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
protected $pdo;
@@ -48,7 +48,7 @@ Class PreHash
$options += $defaults;
$this->echooutput = ($options['Echo'] && NN_ECHOCLI);
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
}
/**
@@ -1,11 +1,11 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
class Regexes
{
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
*/
public $pdo;
@@ -35,7 +35,7 @@ class Regexes
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->tableName = $options['Table_Name'];
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/*
* Cleans names for releases/imports/namefixer.
@@ -57,7 +57,7 @@ class ReleaseCleaning
public $groupName = '';
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -86,7 +86,7 @@ class ReleaseCleaning
$this->e1 = \CollectionsCleaning::REGEX_FILE_EXTENSIONS . \CollectionsCleaning::REGEX_END;
$this->e2 = \CollectionsCleaning::REGEX_FILE_EXTENSIONS .
\CollectionsCleaning::REGEX_SUBJECT_SIZE . \CollectionsCleaning::REGEX_END;
$this->pdo = ($settings instanceof newznab\db\DB ? $settings : new newznab\db\DB());
$this->pdo = ($settings instanceof newznab\db\Settings ? $settings : new newznab\db\Settings());
$this->_regexes = new Regexes(['Settings' => $this->pdo, 'Table_Name' => 'release_naming_regexes']);
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
@@ -13,7 +13,7 @@ class ReleaseComments
*/
public function getCommentById($id)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("SELECT * FROM releasecomment WHERE id = %d", $id));
}
@@ -22,7 +22,7 @@ class ReleaseComments
*/
public function getCommentsByGid($gid)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("SELECT rc.id, text, createddate, sourceid, CASE WHEN sourceid = 0 THEN (SELECT username FROM users WHERE id = userid) ELSE username END AS username, CASE WHEN sourceid = 0 THEN (SELECT role FROM users WHERE id = userid) ELSE '-1' END AS role, CASE WHEN sourceid =0 THEN (SELECT r.name AS rolename FROM users AS u LEFT JOIN userroles AS r ON r.id = u.role WHERE u.id = userid) ELSE (SELECT description AS rolename FROM spotnabsources WHERE id = sourceid) END AS rolename FROM releasecomment rc WHERE isvisible = 1 AND gid = %s AND (userid IN (SELECT id FROM users) OR rc.username IS NOT NULL) ORDER BY createddate DESC LIMIT 100", $db->escapeString($gid)));
}
@@ -31,7 +31,7 @@ class ReleaseComments
*/
public function getCommentsByGuid($guid)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("SELECT rc.id, text, createddate, sourceid, CASE WHEN sourceid = 0 THEN (SELECT username FROM users WHERE id = userid) ELSE username END AS username FROM releasecomment rc LEFT JOIN releases r ON r.gid = rc.gid WHERE isvisible = 1 AND guid = %s AND (userid IN (SELECT id FROM users) OR rc.username IS NOT NULL) ORDER BY createddate DESC LIMIT 100", $db->escapeString($guid)));
}
@@ -40,7 +40,7 @@ class ReleaseComments
*/
public function getCommentCount($refdate=Null, $localOnly=Null)
{
$db = new DB();
$db = new Settings();
if($refdate !== Null){
if(is_string($refdate)){
// ensure we're in the right format
@@ -80,7 +80,7 @@ class ReleaseComments
*/
public function deleteComment($id)
{
$db = new DB();
$db = new Settings();
$res = $this->getCommentById($id);
if ($res)
{
@@ -94,7 +94,7 @@ class ReleaseComments
*/
public function deleteCommentsForRelease($id)
{
$db = new DB();
$db = new Settings();
$res = $this->getCommentById($id);
if ($res)
{
@@ -108,7 +108,7 @@ class ReleaseComments
*/
public function deleteCommentsForUser($id)
{
$db = new DB();
$db = new Settings();
$numcomments = $this->getCommentCountForUser($id);
if ($numcomments > 0)
@@ -130,7 +130,7 @@ class ReleaseComments
if(strlen(trim($text)) == 0)
return false;
$db = new DB();
$db = new Settings();
$site = new Sites();
$s = $site->get();
@@ -147,7 +147,7 @@ class ReleaseComments
*/
public function getCommentsRange($start, $num)
{
$db = new DB();
$db = new Settings();
if ($start === false)
$limit = "";
@@ -163,7 +163,7 @@ class ReleaseComments
*/
public function updateReleaseCommentCount($gid)
{
$db = new DB();
$db = new Settings();
$db->queryExec(sprintf("update releases
SET comments = (SELECT count(id) FROM releasecomment WHERE releasecomment.gid = releases.gid AND isvisible = 1)
WHERE releases.gid = %s", $db->escapeString($gid) ));
@@ -174,7 +174,7 @@ class ReleaseComments
*/
public function getCommentCountForUser($uid)
{
$db = new DB();
$db = new Settings();
$res = $db->queryOneRow(sprintf("SELECT count(id) AS num FROM releasecomment WHERE userid = %d AND isvisible = 1", $uid));
return $res["num"];
}
@@ -184,7 +184,7 @@ class ReleaseComments
*/
public function getCommentsForUserRange($uid, $start, $num)
{
$db = new DB();
$db = new Settings();
if ($start === false)
$limit = "";
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class handles storage and retrieval of releaseextrafull/releasevideo/audio/subs data.
@@ -40,21 +40,21 @@ class ReleaseExtra
public function getAudio($id)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select * from releaseaudio where releaseid = %d order by audioID ASC", $id));
}
public function getBriefByGuid($guid)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("select containerformat,videocodec,videoduration,videoaspect, concat(releasevideo.videowidth,'x',releasevideo.videoheight,' @',format(videoframerate,0),'fps') as size, group_concat(distinct releaseaudio.audiolanguage SEPARATOR ', ') as audio, group_concat(distinct releaseaudio.audiobitrate SEPARATOR ', ') as audiobitrate, group_concat(distinct releaseaudio.audioformat SEPARATOR ', ') as audioformat, group_concat(distinct releaseaudio.audiomode SEPARATOR ', ') as audiomode, group_concat(distinct releaseaudio.audiobitratemode SEPARATOR ', ') as audiobitratemode, group_concat(distinct releasesubs.subslanguage SEPARATOR ', ') as subs from releaseaudio left outer join releasesubs on releaseaudio.releaseid = releasesubs.releaseid left outer join releasevideo on releasevideo.releaseid = releaseaudio.releaseid inner join releases r on r.id = releaseaudio.releaseid where r.guid = %s group by r.id", $db->escapeString($guid)));
}
public function delete($id)
{
$db = new DB();
$db = new Settings();
$db->queryExec(sprintf("DELETE from releaseaudio where releaseid = %d", $id));
$db->queryExec(sprintf("DELETE from releasesubs where releaseid = %d", $id));
$db->queryExec(sprintf("DELETE from releaseextrafull where releaseid = %d", $id));
@@ -165,7 +165,7 @@ class ReleaseExtra
*/
public function addVideo($releaseID, $containerformat, $overallbitrate, $videoduration, $videoformat, $videocodec, $videowidth, $videoheight, $videoaspect, $videoframerate, $videolibrary)
{
$db = new DB();
$db = new Settings();
$row = $this->getVideo($releaseID);
if ($row)
@@ -191,7 +191,7 @@ class ReleaseExtra
public function getVideo($id)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("select * from releasevideo where releaseid = %d", $id));
}
@@ -239,7 +239,7 @@ class ReleaseExtra
*/
public function addAudio($releaseID, $audioID, $audioformat, $audiomode, $audiobitratemode, $audiobitrate, $audiochannels, $audiosamplerate, $audiolibrary, $audiolanguage, $audiotitle)
{
$db = new DB();
$db = new Settings();
$row = $this->getAudioAndChannel($releaseID, $audioID);
if ($row)
@@ -259,14 +259,14 @@ class ReleaseExtra
public function getAudioAndChannel($rid, $aid)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("select * from releaseaudio where releaseid = %d and audioID = %d", $rid, $aid));
}
public function addSubs($releaseID, $subsID, $subslanguage)
{
$db = new DB();
$db = new Settings();
$row = $this->getSubs($releaseID);
if ($row)
return -1;
@@ -278,21 +278,21 @@ class ReleaseExtra
public function getSubs($id)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("SELECT group_concat(subslanguage SEPARATOR ', ') as subs FROM `releasesubs` WHERE `releaseid` = %d ORDER BY `subsID` ASC", $id));
}
public function deleteFull($id)
{
$db = new DB();
$db = new Settings();
return $db->queryExec(sprintf("DELETE from releaseextrafull where releaseid = %d", $id));
}
public function addFull($id, $xml)
{
$db = new DB();
$db = new Settings();
$row = $this->getFull($id);
if ($row)
return -1;
@@ -302,7 +302,7 @@ class ReleaseExtra
public function getFull($id)
{
$db = new DB();
$db = new Settings();
return $db->queryOneRow(sprintf("select * from releaseextrafull where releaseid = %d", $id));
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
* This class handles storage and retrieval of releasefiles.
@@ -12,7 +12,7 @@ class ReleaseFiles
*/
public function get($id)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select * from releasefiles where releaseid = %d order by releasefiles.name ", $id));
}
@@ -21,7 +21,7 @@ class ReleaseFiles
*/
public function getByGuid($guid)
{
$db = new DB();
$db = new Settings();
return $db->query(sprintf("select releasefiles.* from releasefiles inner join releases r on r.id = releasefiles.releaseid where r.guid = %s order by releasefiles.name ", $db->escapeString($guid)));
}
@@ -30,7 +30,7 @@ class ReleaseFiles
*/
public function delete($id)
{
$db = new DB();
$db = new Settings();
return $db->queryExec(sprintf("DELETE from releasefiles where releaseid = %d", $id));
}
@@ -39,7 +39,7 @@ class ReleaseFiles
*/
public function add($id, $name, $size, $createddate, $passworded)
{
$db = new DB();
$db = new Settings();
$sql = sprintf("INSERT INTO releasefiles (releaseid, name, size, createddate, passworded) VALUES (%d, %s, %s, from_unixtime(%d), %d)", $id, $db->escapeString($name), $db->escapeString($size), $createddate, $passworded );
return $db->queryInsert($sql);
}
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
use newznab\utility\Utility;
/**
@@ -53,7 +53,7 @@ class ReleaseImage
{
// Creates the NN_COVERS constant
if ($pdo === null) {
$pdo = new DB();
$pdo = new Settings();
}
// Table | Column
$this->audSavePath = NN_COVERS . 'audiosample' . DS; // releases guid
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
@@ -16,7 +16,7 @@ class ReleaseRegex
private $tablePerGroup;
/**
* @var \newznab\db\DB
* @var \newznab\db\Settings
*/
public $pdo;
@@ -28,10 +28,10 @@ class ReleaseRegex
public function __construct()
{
$this->regexes = [];
$this->pdo = new DB();
$this->pdo = new Settings();
$s = new Sites();
$this->site = $s->get();
$this->tablePerGroup = $this->site->tablepergroup;
$this->tablePerGroup = $this->pdo->getSetting('tablepergroup');
}
/**
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
/**
@@ -72,7 +72,7 @@ class ReleaseRemover
protected $method = '';
/**
* @var newznab\db\DB
* @var newznab\db\Settings
*/
protected $pdo;
@@ -125,7 +125,7 @@ class ReleaseRemover
];
$options += $defaults;
$this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB());
$this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings());
$this->consoleTools = ($options['ConsoleTools'] instanceof \ConsoleTools ? $options['ConsoleTools'] : new \ConsoleTools(['ColorCLI' => $this->pdo->log]));
$this->releases = ($options['Releases'] instanceof \Releases ? $options['Releases'] : new \Releases(['Settings' => $this->pdo]));
$this->nzb = ($options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo));
@@ -1,6 +1,6 @@
<?php
use newznab\db\DB;
use newznab\db\Settings;
class ReleaseSearch
{
@@ -9,7 +9,7 @@ class ReleaseSearch
const SPHINX = 2;
/***
* @var newznab\db\DB
* @var newznab\db\Settings
*/
public $pdo;
@@ -26,9 +26,9 @@ class ReleaseSearch
private $fullTextJoinString;
/**
* @param DB $settings
* @param Settings $settings
*/
public function __construct(DB $settings)
public function __construct(Settings $settings)
{
switch (NN_RELEASE_SEARCH_TYPE) {
case self::LIKE:
@@ -43,7 +43,7 @@ class ReleaseSearch
break;
}
$this->pdo = ($settings instanceof newznab\db\DB ? $settings : new newznab\db\DB());
$this->pdo = ($settings instanceof newznab\db\Settings ? $settings : new newznab\db\Settings());
}
/**

Some files were not shown because too many files have changed in this diff Show More