diff --git a/bin/fixreleasenames.php b/bin/fixreleasenames.php index d5b472939..55aaf8376 100644 --- a/bin/fixreleasenames.php +++ b/bin/fixreleasenames.php @@ -14,7 +14,7 @@ $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(true); $pieces = explode(' ', $argv[1]); if (isset($pieces[1]) && $pieces[0] == 'nfo') { diff --git a/bin/monitor.php b/bin/monitor.php index cfd55b51a..0b411dfda 100644 --- a/bin/monitor.php +++ b/bin/monitor.php @@ -10,7 +10,7 @@ require_once(dirname(__FILE__) . "/../lib/functions.php"); $version = "0.4r2100"; -$db = new DB(); +$db = new Settings(); $s = new Sites(); $site = $s->get(); $patch = $site->dbversion; @@ -1925,7 +1925,7 @@ function run_ircscraper($tmux_session, $_php, $pane, $run_ircscraper) function run_sharing($tmux_session, $_php, $pane, $_sleep, $sharing_timer) { - $db = new DB(); + $db = new Settings(); $sharing = $db->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new Tmux(); $tmux = $t->get(); diff --git a/bin/nzb-import-new.php b/bin/nzb-import-new.php index 06f9df4c0..e88a928f8 100644 --- a/bin/nzb-import-new.php +++ b/bin/nzb-import-new.php @@ -20,7 +20,7 @@ if (!isset($argv[1])) { )); } -$db = new DB(); +$db = new Settings(); $binaries = new Binaries(); $s = new Sites(); $site = $s->get(); diff --git a/bin/requestID.php b/bin/requestID.php index fde0c9778..841b3b0ff 100644 --- a/bin/requestID.php +++ b/bin/requestID.php @@ -1,7 +1,7 @@ error("This script is not intended to be run manually, it is called from requestid_threaded.py.")); } $pieces = explode(' ', $argv[1]); -$db = new DB(); +$db = new Settings(); $n = "\n"; $category = new Categorize(); $groups = new Groups(); @@ -119,7 +119,7 @@ function getReleaseNameFromRequestID($tmux, $requestID, $groupName) function localLookup($requestID, $groupName, $oldname) { - $db = new DB(); + $db = new Settings(); $groups = new Groups(); $f = new Functions(); $groupID = $f->getIDByName($groupName); diff --git a/bin/update_groups.php b/bin/update_groups.php index a6d2c98ae..bd46d0c58 100644 --- a/bin/update_groups.php +++ b/bin/update_groups.php @@ -23,7 +23,7 @@ if ($nntp->isError($data)) { echo $c->header("Inserting new values into shortgroups table."); -$db = new DB(); +$db = new Settings(); $db->queryExec('TRUNCATE TABLE shortgroups'); // Put into an array all active groups diff --git a/bin/update_parsing.php b/bin/update_parsing.php index 356a3fb31..188629827 100644 --- a/bin/update_parsing.php +++ b/bin/update_parsing.php @@ -22,9 +22,9 @@ unset($array['']); //This script updates release names for releases in 'TV > Other', 'Movie > Other', 'XXX > Other', and 'Other > Misc' categories. //It first attempts to extract the release name from the NFO, falling back to rarset filename -- the ReleaseFiles. //If the new releasename is the same as the old name, OR the name is different but still doesnt match a new category, it will skip the release. -//Configure the script using the options below. +//Configure the script using the options below. -/// The following value either shows or hides the releases that failed to find a new name and category. +/// The following value either shows or hides the releases that failed to find a new name and category. $debug = false; /// Set this to true to see fails @@ -38,7 +38,7 @@ if ( $array['PAST_24_HOURS'] == "true" ) { } else { $limited = false; } -/// Set to true for 24 hours, false for whole db. +/// Set to true for 24 hours, false for whole db. /// WARNING!!!!!!!!The following value runs update_parsing either against "other categories", or all categories, do not use this if $echo is false. This is for testing. /// WARNING!!!!!!!!Make sure memory_limit in php has no limit ( -1 ) if you are running against all categories @@ -57,7 +57,7 @@ $notnforelchange = 0; $rescount = 0; $nopreCount = 0; $test = 0; -$db = new DB(); +$db = new Settings(); $updated = 0; @@ -68,7 +68,7 @@ if($othercats == true) //Only Other categories rn.ID as nfoID, g.name as groupname, GROUP_CONCAT(rf.name) as filenames - FROM releases r + FROM releases r LEFT JOIN releasenfo rn ON (rn.releaseID = r.ID) LEFT JOIN groups g ON (g.ID = r.groupID) LEFT JOIN releasefiles rf ON (rf.releaseID = r.ID) @@ -83,7 +83,7 @@ else //All categories rn.ID as nfoID, g.name as groupname, GROUP_CONCAT(rf.name) as filenames - FROM releases r + FROM releases r LEFT JOIN releasenfo rn ON (rn.releaseID = r.ID) LEFT JOIN groups g ON (g.ID = r.groupID) LEFT JOIN releasefiles rf ON (rf.releaseID = r.ID) @@ -143,7 +143,7 @@ function updateCategory($rel,$foundName,$methodused) } else { - $db = new DB(); + $db = new Settings(); $releases = new Releases(); $foundName = html_entity_decode($foundName); $foundName = str_replace(''', '', $foundName); @@ -189,9 +189,9 @@ if ($res) { $title = ''; $items = preg_split( "/(\.| )/", $rel['name']); - foreach ($items as $value) + foreach ($items as $value) { - if (preg_match("/^[a-z]+$/i", $value)) + if (preg_match("/^[a-z]+$/i", $value)) { $len = strlen($value); if ($len > 2) { $title.= substr($value,-2) . substr($value, 0, -2) ." "; } @@ -212,18 +212,18 @@ if ($res) } } - //Use the Nfo to try to get the proper release name using scene regex. + //Use the Nfo to try to get the proper release name using scene regex. $nfo = $db->queryOneRow(sprintf("select uncompress(nfo) as nfo from releasenfo where releaseID = %d", $rel['RID'])); if ($nfo && $foundName == "") { $nfo = $nfo['nfo']; $Nfocount ++; - + //Title.SxxEx.EpTitle.source.vcodec.group if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.SxxEx.EpTitle.source.vcodec.group"; + $methodused = "Nfo Title.SxxEx.EpTitle.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -237,7 +237,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;.\(\)]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.SxxEx.EpTitle.source.group"; + $methodused = "Nfo Title.SxxEx.EpTitle.source.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -251,7 +251,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.SxxExx.EPtitle.resolution.source.vcodec.group"; + $methodused = "Nfo Title.SxxExx.EPtitle.resolution.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -259,13 +259,13 @@ if ($res) else { $foundName = null; - } + } } //Title.SxxExx.source.vcodec.group if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.SxxExx.source.vcodec.group"; + $methodused = "Nfo Title.SxxExx.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -279,7 +279,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.SxxExx.acodec.source.resolution.vcodec.group"; + $methodused = "Nfo Title.SxxExx.acodec.source.resolution.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -293,7 +293,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.Sxx-Exx.eptitle.year.group"; + $methodused = "Nfo Title.Sxx-Exx.eptitle.year.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -307,7 +307,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.Sxx-Exx.res.src.vcod.group"; + $methodused = "Nfo Title.Sxx-Exx.res.src.vcod.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -321,7 +321,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.Sxx-Exx.eptitle.src.vcod.group"; + $methodused = "Nfo Title.Sxx-Exx.eptitle.src.vcod.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -335,7 +335,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.eptitle.res.vcod"; + $methodused = "Nfo Title.year.eptitle.res.vcod"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -349,7 +349,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(480|720|1080)(i|p)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.source.vcodec.res.grp"; + $methodused = "Nfo Title.year.source.vcodec.res.grp"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -363,7 +363,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.source.vcodec.acodec.grp"; + $methodused = "Nfo Title.year.source.vcodec.acodec.grp"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -377,7 +377,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.###(season/episode).source.group"; + $methodused = "Nfo Title.year.###(season/episode).source.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -391,7 +391,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.language.acodec.source.vcodec.group"; + $methodused = "Nfo Title.year.language.acodec.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -405,7 +405,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.resolution.source.acodec.vcodec.group"; + $methodused = "Nfo Title.year.resolution.source.acodec.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -419,7 +419,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.resolution.source.vcodec.group"; + $methodused = "Nfo Title.year.resolution.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -433,7 +433,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.source.resolution.acodec.vcodec.group"; + $methodused = "Nfo Title.year.source.resolution.acodec.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -447,7 +447,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.resolution.acodec.vcodec.group"; + $methodused = "Nfo Title.year.resolution.acodec.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -461,7 +461,7 @@ if ($res) if(preg_match('/[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.source.res.group"; + $methodused = "Nfo Title.year.source.res.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -475,7 +475,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )[\w.\-\',;& ]+(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.year.eptitle.source.vcodec.group"; + $methodused = "Nfo Title.year.eptitle.source.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -489,7 +489,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.resolution.source.acodec.vcodec.group"; + $methodused = "Nfo Title.resolution.source.acodec.vcodec.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -503,7 +503,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )((19|20)\d\d)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_",".",$matches['0']); - $methodused = "Nfo Title.resolution.acodec.eptitle.source.year.group"; + $methodused = "Nfo Title.resolution.acodec.eptitle.source.year.group"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -514,7 +514,7 @@ if ($res) } } //Title.language.year.acodec.src - if (preg_match('/\w[\w.\-\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)(\.|_|\-| )((19|20)\d\d)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+\w/i', $nfo, $matches) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)(\.|_|\-| )((19|20)\d\d)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+\w/i', $nfo, $matches) && $foundName == '') { $foundName = str_replace("_",".",$matches['0']); $methodused = "NFO Title.language.year.acodec.src"; @@ -545,7 +545,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(GC|NDS|NGC|PS3|WII|XBOX(360)?)(\.|_|\-| )(DUPLEX|iNSOMNi|OneUp|STRANGE|SWAG|SKY)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Nfo Videogames 2"; + $methodused = "Nfo Videogames 2"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -559,7 +559,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(\d{1,10}|Linux|UNIX)(\.|_|\-| )(RPM)?(\.|_|\-| )?(X64)?(\.|_|\-| )?(Incl)(\.|_|\-| )(Keygen)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Nfo Apps 1"; + $methodused = "Nfo Apps 1"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -571,10 +571,10 @@ if ($res) } // Apps 2 if(preg_match('/\w[\w.\-\',;& ]+(\d){1,8}(\.|_|\-| )(winall-freeware)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") - { + { $foundName = str_replace("WinAll-Freeware","Software.WinAll-Freeware",$matches['0']); $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Nfo Apps 2 WinALL-Freeware"; + $methodused = "Nfo Apps 2 WinALL-Freeware"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -586,9 +586,9 @@ if ($res) } // Sports 1 - year.month.day.sport.year?.text if(preg_match('/\w(19|20)\d\d(\.|_|\-| )\d{2}(\.|_|\-| )\d{2}(\.|_|\-| )(IndyCar|NBA|NCW(T|Y)S|NNS|NSCS?)((\.|_|\-| )(19|20)\d\d)?[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") - { + { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Nfo Sports 1"; + $methodused = "Nfo Sports 1"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -609,7 +609,7 @@ if ($res) { $files = array( $files ); } - + foreach( $files AS $file ) { // R&C @@ -697,7 +697,7 @@ if ($res) } } //Title.SxxEx.EpTitle.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.SxxEx.EpTitle.source.vcodec.group"; @@ -711,7 +711,7 @@ if ($res) } } //Title.SxxEx.EpTitle.source.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;.\(\)]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;.\(\)]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.SxxEx.EpTitle.source.group"; @@ -725,7 +725,7 @@ if ($res) } } //Title.SxxExx.EPtitle.resolution.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',; \[\]]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',; \[\]]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.SxxExx.EPtitle.resolution.source.vcodec.group"; @@ -739,7 +739,7 @@ if ($res) } } //Title.SxxExx.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.SxxExx.source.vcodec.group"; @@ -753,7 +753,7 @@ if ($res) } } //Title.SxxExx.acodec.source.resolution.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.SxxExx.acodec.source.resolution.vcodec.group"; @@ -767,7 +767,7 @@ if ($res) } } //Title.Sxx-Exx.eptitle.year.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.Sxx-Exx.eptitle.year.group"; @@ -781,7 +781,7 @@ if ($res) } } //Title.Sxx-Exx.res.src.vcod.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.Sxx-Exx.res.src.vcod.group"; @@ -795,7 +795,7 @@ if ($res) } } //Title.Sxx-Exx.eptitle.src.vcod.group - if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.Sxx-Exx.eptitle.src.vcod.group"; @@ -809,7 +809,7 @@ if ($res) } } //Title.year.eptitle.res.vcod - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.eptitle.res.vcod"; @@ -823,7 +823,7 @@ if ($res) } } //Title.year.source.vcodec.res.grp - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(480|720|1080)(i|p)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(480|720|1080)(i|p)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.source.vcodec.res.grp"; @@ -837,7 +837,7 @@ if ($res) } } //Title.year.source.vcodec.acodec.grp - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.source.vcodec.acodec.grp"; @@ -851,7 +851,7 @@ if ($res) } } //Title.year.###(season/episode).source.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )((s\d{1,2}(\.|_|\-| )?(b|d|e)\d{1,2})|\d{1,2}x\d{2}|ep(\.|_|\-| )?\d{2})(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.###(season/episode).source.group"; @@ -865,7 +865,7 @@ if ($res) } } //Title.year.language.acodec.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+(Brazilian|Chinese|Croatian|Danish|Deutsch|Dutch|Estonian|English|Finnish|Flemish|Francais|French|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.language.acodec.source.vcodec.group"; @@ -879,7 +879,7 @@ if ($res) } } //Title.year.resolution.source.acodec.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.resolution.source.acodec.vcodec.group"; @@ -893,7 +893,7 @@ if ($res) } } //Title.year.resolution.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)?(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)?(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.resolution.source.vcodec.group"; @@ -907,7 +907,7 @@ if ($res) } } //Title.year.source.resolution.acodec.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-|(\.|_|\-| ))?(AC3|HD)?|Dolby(\s?TrueHD)?|TrueHD|MP3)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-|(\.|_|\-| ))?(AC3|HD)?|Dolby(\s?TrueHD)?|TrueHD|MP3)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.source.resolution.acodec.vcodec.group"; @@ -921,7 +921,7 @@ if ($res) } } //Title.year.resolution.acodec.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.resolution.acodec.vcodec.group"; @@ -935,7 +935,7 @@ if ($res) } } //Title.year.source.res - if (preg_match('/[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(480|720|1080)(i|p)(\.|_|\-| )[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.source.res"; @@ -949,7 +949,7 @@ if ($res) } } //Title.year.eptitle.source.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )[\w.\-\',;& ]+(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+((19|20)\d\d)(\.|_|\-| )[\w.\-\',;& ]+(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BR(RIP)?|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.year.eptitle.source.vcodec.group"; @@ -963,7 +963,7 @@ if ($res) } } //Title.resolution.source.acodec.vcodec.group - if (preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)(\.|_|\-| )(DivX|(H|X)(\.|_|\-| )?264|MPEG2|XviD(HD)?|WMV)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.resolution.source.acodec.vcodec.group"; @@ -977,7 +977,7 @@ if ($res) } } //Title.resolution.acodec.eptitle.source.year.group - if (preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )((19|20)\d\d)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+(480|720|1080)(i|p)(\.|_|\-| )(AAC( LC)?|AC-?3|DD5((\.|_|\-| )1)?|(A_)?DTS(-)?(HD)?|Dolby(( )?TrueHD)?|MP3|TrueHD)[\w.\-\',;& ]+(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)(\.|_|\-| )((19|20)\d\d)[\w.\-\',;& ]+\w/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.resolution.acodec.eptitle.source.year.group"; @@ -991,7 +991,7 @@ if ($res) } } //Title - SxxExx - Eptitle - if (preg_match('/\S.*[\w.\-\',;]+\s\-\ss\d{2}e\d{2}\s\-\s[\w.\-\',;].+\./i', $file, $matches3) && $foundName == '') + if (preg_match('/\S.*[\w.\-\',;]+\s\-\ss\d{2}e\d{2}\s\-\s[\w.\-\',;].+\./i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title - SxxExx - Eptitle"; @@ -1005,7 +1005,7 @@ if ($res) } } //Title-SxxExx-XVID-DL.avi - if (preg_match('/\w[\w.\-\',;& ]+-S\d{1,2}E\d{1,2}-XVID-DL.avi/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+-S\d{1,2}E\d{1,2}-XVID-DL.avi/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title-SxxExx-XVID-DL.avi"; @@ -1019,7 +1019,7 @@ if ($res) } } //Title.211.hdtv-lol.extension - if (preg_match('/\w[\w.\-\',;& ]+\d{3,4}\.hdtv-lol\.(avi|mp4|mkv|ts|nfo|nzb)/i', $file, $matches3) && $foundName == '') + if (preg_match('/\w[\w.\-\',;& ]+\d{3,4}\.hdtv-lol\.(avi|mp4|mkv|ts|nfo|nzb)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename Title.211.hdtv-lol.extension"; @@ -1036,7 +1036,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(ASIA|DLC|EUR|GOTY|JPN|KOR|MULTI\d{1}|NTSCU?|PAL|RF|Region(\.|_|-|( ))?Free|USA|XBLA)(\.|_|\-| )(DLC\.Complete|FRENCH|GERMAN|MULTI\d{1}|PROPER|PSN|READ(\.|_|-|( ))?NFO|UMD)?(\.|_|\-| )?(GC|NDS|NGC|PS3|PSP|WII|XBOX(360)?)[\w.\-\',;& ]+\w/i',$file,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Filename Videogames 1"; + $methodused = "Filename Videogames 1"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1050,7 +1050,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(GC|NDS|NGC|PS3|WII|XBOX(360)?)(\.|_|\-| )(DUPLEX|iNSOMNi|STRANGE|SWAG|SKY)[\w.\-\',;& ]+\w/i',$file,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Filename Videogames 2"; + $methodused = "Filename Videogames 2"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1064,7 +1064,7 @@ if ($res) if(preg_match('/\w.+\)\.nds/i',$file,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Filename Videogames 3 ).nds"; + $methodused = "Filename Videogames 3 ).nds"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1078,7 +1078,7 @@ if ($res) if(preg_match('/\w[\w.\-\',;& ]+(\d{1,10}|Linux|UNIX)(\.|_|\-| )(RPM)?(\.|_|\-| )?(X64)?(\.|_|\-| )?(Incl)(\.|_|\-| )(Keygen)[\w.\-\',;& ]+\w/i',$file,$matches) && $foundName == "") { $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Filename Apps 1"; + $methodused = "Filename Apps 1"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1093,7 +1093,7 @@ if ($res) { $foundName = str_replace("WinAll-Freeware","Software.WinAll-Freeware",$matches['0']); $foundName = str_replace("_"," ",$matches['0']); - $methodused = "Filename Apps 2"; + $methodused = "Filename Apps 2"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1108,7 +1108,7 @@ if ($res) { $foundName = str_replace("_"," ",$matches['0']); $foundName = str_replace("OUTLAWS","PC GAME OUTLAWS",$matches['0']); - $methodused = "Filename PC Games 1 OUTLAWS"; + $methodused = "Filename PC Games 1 OUTLAWS"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1123,7 +1123,7 @@ if ($res) { $foundName = str_replace("_"," ",$matches['0']); $foundName = str_replace("ALiAS","PC GAME ALiAS",$matches['0']); - $methodused = "Filename PC Games 2 ALiAS"; + $methodused = "Filename PC Games 2 ALiAS"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -1134,7 +1134,7 @@ if ($res) } } // ReleaseGroup.Title.Format.mkv - if (preg_match('/(?<=swg_|swghd\-|lost\-|veto\-|kaka\-|abd\-|airline\-|daa\-|data\-|japhson\-|ika\-|lng\-|nrdhd\-|saimorny\-|sparks\-|ulshd\-|nscrns\-|ifpd\-|invan\-|an0\-|besthd\-|muxhd\-|s7\-).*?(1080|720|480)(i|p)(?=\.MKV)/i', $file, $matches3) && $foundName == '') + if (preg_match('/(?<=swg_|swghd\-|lost\-|veto\-|kaka\-|abd\-|airline\-|daa\-|data\-|japhson\-|ika\-|lng\-|nrdhd\-|saimorny\-|sparks\-|ulshd\-|nscrns\-|ifpd\-|invan\-|an0\-|besthd\-|muxhd\-|s7\-).*?(1080|720|480)(i|p)(?=\.MKV)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_",".",$matches3['0']); $methodused = "Filename ReleaseGroup.Title.Format"; @@ -1147,9 +1147,9 @@ if ($res) $foundName = null; } } - } + } } - + //The Big One if(preg_match_all('/([\w\d\ ]+)\.{2,}(\:|\[)(?P.*)(\s{2}|\s{1})/i',$nfo, $matches) && $foundName == "") { @@ -1197,7 +1197,7 @@ if ($res) if ( isset ($lut['title'])) { $tempname = $tempname.$del.$lut['title']; - } + } if ( isset ($lut['album']) && !isset ($lut['title'])) { $tempname = $tempname.$del.$lut['album']; @@ -1205,7 +1205,7 @@ if ($res) if ( isset ($lut['track']) && !isset ($lut['title']) && !isset ($lut['album'])) { $tempname = $tempname.$del.$lut['track']; - } + } if (!isset ($lut['source'])) { $lut['source'] = 'WEB'; @@ -1236,9 +1236,9 @@ if ($res) if (isset ($lut['ripper'])) { $tempname = $tempname.$del.$lut['ripper']; - } + } $tempname = preg_replace("/[^a-zA-Z,0-9,\-,\&,\s]/", "", $tempname); - $tempname = preg_replace("/[ ]{2,}/","",$tempname); + $tempname = preg_replace("/[ ]{2,}/","",$tempname); $methodused = "The Big One Music"; $foundName = $tempname; if (determineCategory($rel,$foundName) === true) @@ -1248,7 +1248,7 @@ if ($res) else { $foundName = null; - } + } } else if ( isset ( $lut['title'] ) ) { @@ -1262,7 +1262,7 @@ if ($res) { $tempname = $tempname.$del."S".str_pad($season,2,'0',STR_PAD_LEFT).'E'.str_pad($episode,2,'0',STR_PAD_LEFT); } - else + else { if ($season) { @@ -1301,7 +1301,7 @@ if ($res) else { $foundName = null; - } + } } } @@ -1314,7 +1314,7 @@ if ($res) { $files = array( $files ); } - + foreach( $files AS $file ) { // Scene regex @@ -1334,7 +1334,7 @@ if ($res) else { $foundName = null; - } + } } //Check to see if file is inside of a folder. Use folder name if it is @@ -1351,7 +1351,7 @@ if ($res) else { $foundName = null; - } + } } If(preg_match('/(?!UTC)([\w]+[\w\.\- \'\)\(]+(\d{4}|HDTV).*?\-[\w]+)/i',$matches1['1'],$res) && $foundName == '') { @@ -1364,7 +1364,7 @@ if ($res) else { $foundName = null; - } + } } If(preg_match('/^([\w\.\- ]+\-[\w]+)(\\\\|)$/i',$matches1['2'],$res) && $foundName == '') { @@ -1377,11 +1377,11 @@ if ($res) else { $foundName = null; - } + } } } } - + //Check rarfile contents for a scene name with different regex $sceneRegex2 = '/([\w\'\-\.\(\)\+\! ]+\.[\w\'\-\.\(\)\ ]+)(.*?\\\\.*?|)\.(?:\w{3,4})+\.([\w].*[\w])$/i'; if (preg_match($sceneRegex2, $file, $matches) && $foundName == '') @@ -1432,7 +1432,7 @@ if ($res) else { $foundName = null; - } + } } if(preg_match('/(?!UTC)([\w]+[\w\.\- \'\)\(]+(\d{4}|HDTV).*?\-[\w]+)/i',$matches1['1'],$res) && $foundName == '') { @@ -1445,7 +1445,7 @@ if ($res) else { $foundName = null; - } + } } if(preg_match('/^([\w\.\!\'(\\)\- ]+\-[\w]+)(\\\\|)$/i',$matches1['2'],$res) && $foundName == '') { @@ -1458,7 +1458,7 @@ if ($res) else { $foundName = null; - } + } } } if(preg_match('/(?!UTC)([\w]+[\w\.\- \'\)\(]+(\d{4}|HDTV).*?\-[\w]+)/i',$file,$matches2) && $foundName == '') @@ -1472,7 +1472,7 @@ if ($res) else { $foundName = null; - } + } } } // Petje Releases @@ -1500,7 +1500,7 @@ if ($res) } } } - + //3D Remux if (preg_match('/.*Remux\.mkv/', $file, $matches4)) { @@ -1514,7 +1514,7 @@ if ($res) { $foundName = null; } - } + } //QoQ Extended if (preg_match('/Q\-sbuSLN.*/i', $file, $matches4)) { @@ -1532,7 +1532,7 @@ if ($res) } } } - } + } /// This is a last ditch effort, build a ReleaseName from the Nfo if ($nfo && ($foundName == "" || $methodused == 'Scene format no folder.')) @@ -1540,7 +1540,7 @@ if ($res) //Try to look for Title (Year). if(preg_match('/(\w[\w`~!@#$%^&*()_+\-={}|"<>?\[\]\\;\',.\/ ]+\s?\((19|20)\d\d\))/i', $nfo,$matches) && $foundName == "" && !preg_match('/\.pdf|Audio\s?Book/i', $nfo)) { - $foundName = $matches[0]; + $foundName = $matches[0]; if(preg_match('/(idiomas|lang|language|langue|sprache).*?\b(Brazilian|Chinese|Croatian|Danish|DE|Deutsch|Dutch|Estonian|ES|English|Englisch|Finnish|Flemish|Francais|French|FR|German|Greek|Hebrew|Icelandic|Italian|Japenese|Japan|Japanese|Korean|Latin|Nordic|Norwegian|Polish|Portuguese|Russian|Serbian|Slovenian|Swedish|Spanisch|Spanish|Thai|Turkish)\b/i',$nfo,$matches)) { if($matches[2] == 'DE') @@ -1560,7 +1560,7 @@ if ($res) $matches[2] = 'SPANISH'; } $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/(frame size|res|resolution|video|video res).*?(272|336|480|494|528|608|640|\(640|688|704|720x480|816|820|1080|1 080|1280 @|1280|1920|1 920|1920x1080)/i',$nfo,$matches)) { if($matches[2] == '272') @@ -1610,7 +1610,7 @@ if ($res) if($matches[2] == '820') { $matches[2] = '1080p'; - } + } if($matches[2] == '1080') { $matches[2] = '1080p'; @@ -1630,11 +1630,11 @@ if ($res) if($matches[2] == '1920') { $matches[2] = '1080p'; - } + } if($matches[2] == '1 920') { $matches[2] = '1080p'; - } + } if($matches[2] == '1 080') { $matches[2] = '1080p'; @@ -1674,11 +1674,11 @@ if ($res) if($matches[2] == '1920') { $matches[2] = '1080p'; - } + } if($matches[2] == '1 920') { $matches[2] = '1080p'; - } + } if($matches[2] == '720') { $matches[2] = '480p'; @@ -1686,7 +1686,7 @@ if ($res) $foundName = $foundName.".".$matches[2]; } if(preg_match('/source.*?\b(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD\-?(5|9|(R(IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R5|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)\b/i',$nfo,$matches)) - { + { if($matches[1] == 'BD') { $matches[1] = 'Bluray.x264'; @@ -1802,7 +1802,7 @@ if ($res) else { $foundName = null; - } + } } //LastNfoAttempt (IMDB) if(preg_match('/tt(\d{7})/i',$nfo,$matches) && $foundName == "") @@ -1848,7 +1848,7 @@ if ($res) $matches[1] = 'Subbed.Chinese'; } $foundName = $foundName.".".$matches[1]; - } + } if(preg_match('/(hauteur|height|largeur|res|resolution|video|video res|width).*?(272|336|480|494|528|608|640|720x480|816|820|1080|1 080|1280 @|1280|1920|1 920|1920x1080)/i',$nfo,$matches)) { if($matches[2] == '272') @@ -1886,7 +1886,7 @@ if ($res) if($matches[2] == '820') { $matches[2] = '1080p'; - } + } if($matches[2] == '1080') { $matches[2] = '1080p'; @@ -1906,11 +1906,11 @@ if ($res) if($matches[2] == '1920') { $matches[2] = '1080p'; - } + } if($matches[2] == '1 920') { $matches[2] = '1080p'; - } + } if($matches[2] == '1 080') { $matches[2] = '1080p'; @@ -1924,9 +1924,9 @@ if ($res) $matches[2] = '720p'; } $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/source.*?\b(BD(-?(25|50|RIP))?|Blu(-)?Ray( )?(3D)?|BRRIP|CAM(RIP)?|DBrip|DTV|DVD(\-| )?(5|9|(R(1|IP)?|scr(eener)?))?|(H|P|S)D?(RIP|TV(RIP)?)?|NTSC|PAL|R\d|Retail R\d|Ripped |(S)?VCD|scr(eener)?|SAT(RIP)?|TS|VHS(RIP)?|VOD|WEB-DL)\b/i',$nfo,$matches)) - { + { if($matches[1] == 'BD') { $matches[1] = 'Bluray.x264'; @@ -2044,9 +2044,9 @@ if ($res) $matches[2] = 'DTS'; } $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/posted.*?\b(joalba)\b/i',$nfo,$matches)) - { + { if($matches[1] == 'joalba') { $matches[1] = 'XVID'; @@ -2054,7 +2054,7 @@ if ($res) $foundName = $foundName.".".$matches[1]; } $foundName = $foundName."-NoGroup"; - $methodused = "Nfo IMDB.com"; + $methodused = "Nfo IMDB.com"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -2062,7 +2062,7 @@ if ($res) else { $foundName = null; - } + } } } } @@ -2099,7 +2099,7 @@ if ($res) else { $foundName = null; - } + } } //LastNfoAttempt 4 Iguana NFO's if(preg_match('/Supplier.+?IGUANA/i', $nfo) && $foundName == "") @@ -2145,7 +2145,7 @@ if ($res) else { $foundName = null; - } + } } } //CompleteRelease @@ -2161,7 +2161,7 @@ if ($res) { $foundName = null; } - } + } //The Big One v2 if(preg_match_all('/([\w\ ]+).{2,}(\:|\[)(?P.*)(\s{1}|\s{0})/i',$nfo, $matches) && $foundName == "") { @@ -2211,7 +2211,7 @@ if ($res) if ( isset ($lut['title'])) { $tempname = $tempname.$del.$lut['title']; - } + } if ( isset ($lut['album']) && !isset ($lut['title'])) { $tempname = $tempname.$del.$lut['album']; @@ -2219,7 +2219,7 @@ if ($res) if ( isset ($lut['track']) && !isset ($lut['title']) && !isset ($lut['album'])) { $tempname = $tempname.$del.$lut['track']; - } + } if (!isset ($lut['source'])) { $lut['source'] = 'WEB'; @@ -2250,9 +2250,9 @@ if ($res) if (isset ($lut['ripper'])) { $tempname = $tempname.$del.$lut['ripper']; - } + } $tempname = preg_replace("/[^a-zA-Z,0-9,\-,\&,\s]/", "", $tempname); - $tempname = preg_replace("/[ ]{2,}/","",$tempname); + $tempname = preg_replace("/[ ]{2,}/","",$tempname); $methodused = "The Big One v2 Music"; $foundName = $tempname; if (determineCategory($rel,$foundName) === true) @@ -2262,7 +2262,7 @@ if ($res) else { $foundName = null; - } + } } else if ( isset ( $lut['title'] ) ) { @@ -2276,7 +2276,7 @@ if ($res) { $tempname = $tempname.$del."S".str_pad($season,2,'0',STR_PAD_LEFT).'E'.str_pad($episode,2,'0',STR_PAD_LEFT); } - else + else { if ($season) { @@ -2315,7 +2315,7 @@ if ($res) else { $foundName = null; - } + } } //LOUNGE releases if(preg_match('/([\w.]+\.MBLURAY)/i', $nfo, $matches)) @@ -2360,7 +2360,7 @@ if ($res) else { $foundName = null; - } + } } //Japhson releases if(preg_match('/Japhson/i', $nfo, $matches)) @@ -2380,16 +2380,16 @@ if ($res) { if(!preg_match('/English/i', $matches[1])) { - $foundName = $foundName.".".$matches[1]; - } + $foundName = $foundName.".".$matches[1]; + } } if(preg_match('/audio.*?\b(\w+)\b/i',$nfo,$matches)) { if(preg_match('/(Chinese|German|Dutch|Spanish|Hebrew|Finnish|Norwegian)/i', $matches[1])) { - $foundName = $foundName.".".$matches[1]; - } - } + $foundName = $foundName.".".$matches[1]; + } + } if(preg_match('/(video|resolution|video res).*?(1080|720|816|820|272|1280 @|528|1920)/i',$nfo,$matches)) { if($matches[2] == '1280 @') @@ -2399,9 +2399,9 @@ if ($res) if($matches[2] == '1920') { $matches[2] = '1080'; - } + } $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/source.*?\b(DVD9|DVD5|BDRIP|DVD\-?RIP|BLURAY)\b/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[1]; @@ -2409,7 +2409,7 @@ if ($res) if(preg_match('/(video|resolution|video res).*?(XVID|X264|WMV)/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/audio.*?\b(DTS|AC3)\b/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[1]; @@ -2444,9 +2444,9 @@ if ($res) { if(!preg_match('/En/i', $matches[1])) { - $foundName = $foundName.".".$matches[1]; - } - } + $foundName = $foundName.".".$matches[1]; + } + } if(preg_match('/(V).*?(1080|720|816|820|272|1280 @|528|1920)/i',$nfo,$matches)) { if($matches[2] == '1280 @') @@ -2456,9 +2456,9 @@ if ($res) if($matches[2] == '1920') { $matches[2] = '1080'; - } + } $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/V.*?\b(DVD9|DVD5|BDRIP|DVD\-?RIP|BLURAY)\b/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[1]; @@ -2466,7 +2466,7 @@ if ($res) if(preg_match('/(V).*?(XVID|X264|WMV)/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[2]; - } + } if(preg_match('/A.*?\b(DTS|AC3)\b/i',$nfo,$matches)) { $foundName = $foundName.".".$matches[1]; @@ -2517,14 +2517,14 @@ if ($res) if(preg_match('/presents.*?([\w].*?\((19|20)\d{2}\))/is',$nfo,$matches)) { $foundName = $matches[1]; - } + } if(preg_match('/language.*?\b([\w]+)\b/i',$nfo,$matches)) { if($matches[1] != "english") { - $foundName = $foundName.".".$matches[1]; - } - } + $foundName = $foundName.".".$matches[1]; + } + } if(preg_match('/resolution.*?(1080|720)/i',$nfo,$matches)) { $foundName = $foundName.".BluRay.".$matches[1]; @@ -2806,7 +2806,7 @@ if ($res) if ($title) { $tempname = $tempname."-".$title; - } + } if ($source) { $tempname = $tempname."-".$source; @@ -2814,7 +2814,7 @@ if ($res) if ($year) { $tempname = $tempname."-".$year; - } + } $tempname = preg_replace("/[^a-zA-Z,0-9,\-,\s]/", "", $tempname); $foundName = $tempname; $methodused = "Nfo Live Sets"; @@ -2852,7 +2852,7 @@ if ($res) if(preg_match('/ALiAS|BAT-TEAM|\FAiRLiGHT|Game Type|HI2U|iTWINS|JAGUAR|LARGEISO|MAZE|MEDIUMISO|nERv|PROPHET|PROFiT|PROCYON|RELOADED|REVOLVER|ROGUE|ViTALiTY/i',$nfo) && preg_match('/\w[\w.\+\&\*\/\-\(\)\',;: ]+\(c\)[\w.\-\',;& ]+\w/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("(c)","(PC GAMES) (c)",$matches['0']); - $methodused = "Nfo more games (c)"; + $methodused = "Nfo more games (c)"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); @@ -2866,7 +2866,7 @@ if ($res) if(preg_match('/ALiAS|BAT-TEAM|\FAiRLiGHT|Game Type|HI2U|iTWINS|LARGEISO|JAGUAR|MAZE|MEDIUMISO|nERv|PROPHET|PROFiT|PROCYON|RELOADED|REVOLVER|ROGUE|ViTALiTY/i',$nfo) && preg_match('/\w[\w.\+\&\*\/\-\(\)\',;: ]+\*ISO\*/i',$nfo,$matches) && $foundName == "") { $foundName = str_replace("*ISO*","*ISO* (PC GAMES)",$matches['0']); - $methodused = "Nfo more games 2 *ISO*"; + $methodused = "Nfo more games 2 *ISO*"; if (determineCategory($rel,$foundName) === true) { updateCategory($rel,$foundName,$methodused); diff --git a/lib/DB/mysqldump_tables.php b/lib/DB/mysqldump_tables.php index 5dcf8ffe8..9fa77c560 100644 --- a/lib/DB/mysqldump_tables.php +++ b/lib/DB/mysqldump_tables.php @@ -5,7 +5,7 @@ require_once(WWW_DIR . "/lib/ColorCLI.php"); // This script can dump all tables or just collections/binaries/parts/partrepair/groups. -$db = new DB(); +$db = new Settings(); $c = new ColorCLI(); if ($db->dbSystem() == "pgsql") { exit($c->error("\nThis script is only for mysql.\n")); diff --git a/lib/DB/patchDB.php b/lib/DB/patchDB.php index 38095c0f5..e3bfddafb 100644 --- a/lib/DB/patchDB.php +++ b/lib/DB/patchDB.php @@ -17,7 +17,7 @@ function SplitSQL($file, $delimiter = ';') if (is_resource($file) === true) { $query = array(); - $db = new DB(); + $db = new Settings(); $dbsys = DB_TYPE; $c = new ColorCLI(); @@ -77,7 +77,7 @@ function SplitSQL($file, $delimiter = ';') function BackupDatabase() { - $db = new DB(); + $db = new Settings(); $c = new ColorCLI(); $DIR = dirname (__FILE__); @@ -109,7 +109,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__); diff --git a/lib/Enzebe.php b/lib/Enzebe.php index f2a32066d..bfd1fba06 100644 --- a/lib/Enzebe.php +++ b/lib/Enzebe.php @@ -113,7 +113,7 @@ class Enzebe $this->site = new Sites(); $this->bname = 'binaries'; $this->pname = 'parts'; - $this->db = new DB(); + $this->db = new Settings(); $fp = gzopen($path, 'w5'); if ($fp) { $nzb_guid = ''; diff --git a/lib/Konsole.php b/lib/Konsole.php index ac2a2cfa2..3044e8036 100644 --- a/lib/Konsole.php +++ b/lib/Konsole.php @@ -30,7 +30,7 @@ class Konsole $this->asstag = $site->amazonassociatetag; $this->gameqty = (!empty($tmux->maxgamesprocessed)) ? $tmux->maxgamesprocessed : 150; $this->sleeptime = (!empty($tmux->amazonsleep)) ? $tmux->amazonsleep : 1000; - $this->db = new DB(); + $this->db = new Settings(); $this->imgSavePath = WWW_DIR . 'covers/console/'; $this->renamed = ''; $this->c = new ColorCLI(); diff --git a/lib/MiscSorter.php b/lib/MiscSorter.php index 18919a5f4..f31102a29 100644 --- a/lib/MiscSorter.php +++ b/lib/MiscSorter.php @@ -1,5 +1,5 @@ e0 = '([-_](proof|sample|thumbs?))*(\.part\d*(\.rar)?|\.rar|\.7z)?(\d{1,3}\.rev"|\.vol.+?"|\.[A-Za-z0-9]{2,4}"|")'; $this->e1 = $this->e0 . '[- ]{0,3}yEnc$/'; $this->e2 = $this->e0 . '[- ]{0,3}\d+[.,]\d+ [kKmMgG][bB][- ]{0,3}yEnc$/'; - $this->db = new DB(); + $this->db = new Settings(); } public function releaseCleaner($subject, $fromName, $groupName, $usepre = false) diff --git a/lib/ReleaseRemover.php b/lib/ReleaseRemover.php index 84c26add9..abb4c3bc9 100644 --- a/lib/ReleaseRemover.php +++ b/lib/ReleaseRemover.php @@ -1,6 +1,6 @@ db = new DB(); + $this->db = new Settings(); $this->color = new ColorCLI(); $this->consoleTools = new ConsoleTools(); $this->releases = new Releases(); diff --git a/lib/Sharing.php b/lib/Sharing.php index 0395b27ae..13fbbe46a 100644 --- a/lib/Sharing.php +++ b/lib/Sharing.php @@ -79,7 +79,7 @@ Class Sharing if (!is_null($db)) { $this->db = $db; } else { - $this->db = new DB(); + $this->db = new Settings(); } // Get all sharing info from DB. diff --git a/lib/copy_this/www/admin/ajax_sharing_settings.php b/lib/copy_this/www/admin/ajax_sharing_settings.php index b8a27f3ef..2ad0d8d0e 100644 --- a/lib/copy_this/www/admin/ajax_sharing_settings.php +++ b/lib/copy_this/www/admin/ajax_sharing_settings.php @@ -6,7 +6,7 @@ require_once(WWW_DIR."/lib/adminpage.php"); // Login check. $admin = new AdminPage; -$db = new DB(); +$db = new Settings(); if (isset($_GET['site_ID']) && isset($_GET['site_status'])) { $db->queryExec(sprintf('UPDATE sharing_sites SET enabled = %d WHERE ID = %d', $_GET['site_status'], $_GET['site_ID'])); diff --git a/lib/copy_this/www/admin/sharing.php b/lib/copy_this/www/admin/sharing.php index 462485ddd..d6b3f262f 100644 --- a/lib/copy_this/www/admin/sharing.php +++ b/lib/copy_this/www/admin/sharing.php @@ -6,7 +6,7 @@ require_once(WWW_DIR."/lib/framework/db.php"); $page = new AdminPage(); $page->title = 'Sharing Settings'; -$db = new DB(); +$db = new Settings(); $offset = (isset($_GET['offset']) ? $_GET['offset'] : 0); diff --git a/lib/copy_this/www/lib/Categorize.php b/lib/copy_this/www/lib/Categorize.php index 22821ab58..c59cba76c 100644 --- a/lib/copy_this/www/lib/Categorize.php +++ b/lib/copy_this/www/lib/Categorize.php @@ -46,7 +46,7 @@ class Categorize extends Category $site = $s->get(); $this->categorizeForeign = ($site->categorizeforeign == "0") ? false : true; $this->catWebDL = ($site->catwebdl == "0") ? false : true; - $this->db = new DB(); + $this->db = new Settings(); //parent::__construct(); } diff --git a/lib/copy_this/www/lib/Tmux.php b/lib/copy_this/www/lib/Tmux.php index 243d69ba4..6e9abb0b1 100644 --- a/lib/copy_this/www/lib/Tmux.php +++ b/lib/copy_this/www/lib/Tmux.php @@ -1,12 +1,12 @@ db = new DB(); + $this->db = new Settings(); } public function version() diff --git a/lib/copy_this/www/lib/anidb.php b/lib/copy_this/www/lib/anidb.php index 8c5b754c7..50534548c 100644 --- a/lib/copy_this/www/lib/anidb.php +++ b/lib/copy_this/www/lib/anidb.php @@ -1,6 +1,6 @@ n = "\n"; } @@ -25,17 +25,17 @@ class Backfill $n = $this->n; $groups = new Groups; $res = false; - if ($groupName != '') + if ($groupName != '') { $grp = $groups->getByName($groupName); if ($grp) $res = array($grp); - } - else + } + else { $res = $groups->getActive(); } - + if ($res) { foreach($res as $groupArr) @@ -48,14 +48,14 @@ class Backfill echo "No groups specified. Ensure groups are added to newznab's database for updating.$n"; } } - + /** * Update a group back to a specified date. - */ + */ function backfillGroup($groupArr, $backfillDate=null, $regexOnly=false) { - $db = new DB(); + $db = new Settings(); $binaries = new Binaries(); $n = $this->n; @@ -66,7 +66,7 @@ class Backfill } $this->startGroup = microtime(true); - + $nntp = new Nntp(); $nntpc = new Nntp(); //Make sure we actually have a connection going before doing anything. @@ -173,15 +173,15 @@ class Backfill $timeGroup = number_format(microtime(true) - $this->startGroup, 2); echo "Group processed in $timeGroup seconds $n"; } - else + else { echo "Failed to get NNTP connection.$n"; } } - + /** * Returns single timestamp from a local article number. - */ + */ function postdate($nntp,$post,$debug=true) { $n = $this->n; @@ -207,24 +207,24 @@ class Backfill if($debug && $attempts > 0) echo "retried $attempts time(s)".$n; $attempts++; } while($attempts <= 3 && $success == false); - + if (!$success) { return ""; } - + if($debug) echo "DEBUG: postdate for post: $post came back $date ("; $date = strtotime($date); if($debug) echo "$date seconds unixtime or ".$this->daysOld($date)." days)".$n; return $date; } - + /** * Calculates the post number for a given number of days back in a group. - */ + */ function daytopost($nntp, $group, $days, $debug=true) { $n = $this->n; $pddebug = false; //DEBUG every postdate call?!?! if ($debug) echo "INFO: daytopost finding post for $group $days days back.".$n; - + $data = $nntp->selectGroup($group); if(PEAR::isError($data)) { @@ -236,10 +236,10 @@ class Backfill $totalnumberofarticles = $data['last'] - $data['first']; $upperbound = $data['last']; $lowerbound = $data['first']; - + if ($debug) echo "Total Articles: $totalnumberofarticles $n Upper: $upperbound $n Lower: $lowerbound $n Goal: ".date("r", $goaldate)." ($goaldate) $n"; if ($data['last']==PHP_INT_MAX) { echo "ERROR: Group data is coming back as php's max value. You should not see this since we use a patched Net_NNTP that fixes this bug.$n"; die(); } - + $firstDate = $this->postdate($nntp, $data['first'], $pddebug); $lastDate = $this->postdate($nntp, $data['last'], $pddebug); if ($goaldate < $firstDate) @@ -255,17 +255,17 @@ class Backfill return ""; } if ($debug) echo "DEBUG: Searching for postdate $n Goaldate: $goaldate (".date("r", $goaldate).") $n Firstdate: $firstDate (".((is_int($firstDate))?date("r", $firstDate):'n/a').") $n Lastdate: $lastDate (".date("r", $lastDate).") $n"; - + $interval = floor(($upperbound - $lowerbound) * 0.5); $dateofnextone = ""; $templowered = ""; - + if ($debug) echo "Start: ".$data['first']." $n End: ".$data['last']." $n Interval: $interval $n"; - + $dateofnextone = $lastDate; - + while($this->daysOld($dateofnextone) < $days) //match on days not timestamp to speed things up - { + { $nskip = 1; while(($tmpDate = $this->postdate($nntp,($upperbound-$interval),$pddebug))>$goaldate) { @@ -280,23 +280,23 @@ class Backfill if($debug) echo "Set interval to $interval articles. $n"; } $dateofnextone = $this->postdate($nntp,($upperbound-1),$pddebug); - + $skip = 1; while(!$dateofnextone) - { - $upperbound = $upperbound - $skip; - $skip = $skip * 2; - if($debug) echo "Getting next article date... $upperbound\n"; + { + $upperbound = $upperbound - $skip; + $skip = $skip * 2; + if($debug) echo "Getting next article date... $upperbound\n"; $dateofnextone = $this->postdate($nntp,($upperbound-1),$pddebug); - } + } } echo "Determined to be article $upperbound which is ".$this->daysOld($dateofnextone)." days old (".date("r", $dateofnextone).") $n"; return $upperbound; } - + /** * Calculate the number of days from a timestamp. - */ + */ private function daysOld($timestamp) { return round((time()-$timestamp)/86400, 1); @@ -304,8 +304,8 @@ class Backfill /** * Calculate the number of days from a date. - */ - private function dateToDays($backfillDate) + */ + private function dateToDays($backfillDate) { return floor(-($backfillDate - time())/(60*60*24)); } diff --git a/lib/copy_this/www/lib/binaries.php b/lib/copy_this/www/lib/binaries.php index 732d5f772..12240300c 100644 --- a/lib/copy_this/www/lib/binaries.php +++ b/lib/copy_this/www/lib/binaries.php @@ -1,5 +1,5 @@ n; @@ -668,7 +668,7 @@ class Binaries */ public function search($search, $limit = 1000, $excludedcats = array()) { - $db = new DB(); + $db = new Settings(); // // if the query starts with a ^ it indicates the search is looking for items which start with the term @@ -716,7 +716,7 @@ class Binaries */ public function getForReleaseId($id) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select binaries.* from binaries where releaseID = %d order by relpart", $id)); } @@ -726,7 +726,7 @@ class Binaries */ public function getById($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select binaries.*, groups.name as groupname from binaries left outer join groups on binaries.groupID = groups.ID where binaries.ID = %d ", $id)); } @@ -736,7 +736,7 @@ class Binaries */ public function getBlacklist($activeonly = true) { - $db = new DB(); + $db = new Settings(); $where = ""; if ($activeonly) @@ -755,7 +755,7 @@ class Binaries */ public function getBlacklistByID($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from binaryblacklist where ID = %d ", $id)); } @@ -765,7 +765,7 @@ class Binaries */ public function deleteBlacklist($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from binaryblacklist where ID = %d", $id)); } @@ -775,7 +775,7 @@ class Binaries */ public function updateBlacklist($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -793,7 +793,7 @@ class Binaries */ public function addBlacklist($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -814,7 +814,7 @@ class Binaries */ public function delete($id) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from parts where binaryID = %d", $id)); $db->queryExec(sprintf("DELETE from binaries where ID = %d", $id)); } diff --git a/lib/copy_this/www/lib/book.php b/lib/copy_this/www/lib/book.php index 320c20ac4..40a534fe8 100644 --- a/lib/copy_this/www/lib/book.php +++ b/lib/copy_this/www/lib/book.php @@ -12,7 +12,7 @@ require_once(WWW_DIR."/lib/releaseimage.php"); class Book { const NUMTOPROCESSPERTIME = 100; - + /** * Default constructor. */ @@ -24,16 +24,16 @@ class Book $this->pubkey = $site->amazonpubkey; $this->privkey = $site->amazonprivkey; $this->asstag = $site->amazonassociatetag; - + $this->imgSavePath = WWW_DIR.'covers/book/'; } - + /** * Get bookinfo row for ID. */ public function getBookInfo($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT bookinfo.*, genres.title as genres FROM bookinfo left outer join genres on genres.ID = bookinfo.genreID where bookinfo.ID = %d ", $id)); } @@ -42,7 +42,7 @@ class Book */ public function getBookInfoByName($author, $title) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM bookinfo where author like %s and title like %s", $db->escapeString("%".$author."%"), $db->escapeString("%".$title."%"))); } @@ -50,73 +50,73 @@ class Book * Get bookinfo rows by limit. */ public function getRange($start, $num) - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - - return $db->query(" SELECT * FROM bookinfo ORDER BY createddate DESC".$limit); + + return $db->query(" SELECT * FROM bookinfo ORDER BY createddate DESC".$limit); } - + /** * Get count of all bookinfos. */ public function getCount() - { - $db = new DB(); - $res = $db->queryOneRow("select count(ID) as num from bookinfo"); + { + $db = new Settings(); + $res = $db->queryOneRow("select count(ID) as num from bookinfo"); return $res["num"]; } - + /** * Get count of all bookinfo rows for browse list. */ public function getBookCount($maxage=-1) { - $db = new DB(); - + $db = new Settings(); + $browseby = $this->getBrowseBy(); if ($maxage > 0) $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage); else - $maxage = ""; - + $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); - - $res = $db->queryOneRow($sql, true); - return $res["num"]; - } - + + $res = $db->queryOneRow($sql, true); + return $res["num"]; + } + /** * Get range of bookinfo rows for browse list. */ public function getBookRange($start, $num, $orderby, $maxage=-1) - { - $db = new DB(); - + { + $db = new Settings(); + $browseby = $this->getBrowseBy(); - + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - + $maxagesql = ""; if ($maxage > 0) $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]); - $rows = $db->query($sql, true); + $rows = $db->query($sql, true); // //get a copy of all the bookinfoids - // - $ids = ""; + // + $ids = ""; foreach ($rows as $row) $ids .= $row["bookinfoID"]. ", "; @@ -130,7 +130,7 @@ class Book $sql = sprintf("select r.*, releasenfo.ID as nfoID, groups.name as grpname from releases r left outer join releasenfo on releasenfo.releaseID = r.ID left outer join groups on groups.ID = r.groupID where bookinfoID in (%s) %s order by r.postdate desc", $ids, $maxagesql); $allrows = $db->query($sql, true); $arr = array(); - + // // build array indexed by bookinfoid // @@ -151,7 +151,7 @@ class Book $arr[$allrow["bookinfoID"]]["grabs"] = (isset($arr[$allrow["bookinfoID"]]["grabs"]) ? $arr[$allrow["bookinfoID"]]["grabs"] : "") . $allrow["grabs"] . ","; $arr[$allrow["bookinfoID"]]["categoryID"] = (isset($arr[$allrow["bookinfoID"]]["categoryID"]) ? $arr[$allrow["bookinfoID"]]["categoryID"] : "") . $allrow["categoryID"] . ","; } - + // // stuff back into the results set // @@ -171,11 +171,11 @@ class Book $row["grp_release_comments"] = substr($arr[$row["bookinfoID"]]["comments"], 0, -1); $row["grp_release_grabs"] = substr($arr[$row["bookinfoID"]]["grabs"], 0, -1); $row["grp_release_categoryID"] = substr($arr[$row["bookinfoID"]]["categoryID"], 0, -1); - } + } } return $rows; } - + /** * Get orderby column for book browse list. */ @@ -196,7 +196,7 @@ class Book case 'stats': $orderfield = 'r.grabs'; break; - case 'posted': + case 'posted': default: $orderfield = 'r.postdate'; break; @@ -204,7 +204,7 @@ class Book $ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc'; return array($orderfield, $ordersort); } - + /** * Get all orderable columns for book browse list. */ @@ -212,7 +212,7 @@ class Book { return array('author_asc', 'author_desc', 'posted_asc', 'posted_desc', 'size_asc', 'size_desc', 'files_asc', 'files_desc', 'stats_asc', 'stats_desc'); } - + /** * Get filter options from browse list. */ @@ -220,14 +220,14 @@ class Book { return array('author'=>'author', 'title'=>'title'); } - + /** * Get filter options from user into SQL query. */ public function getBrowseBy() { $db = new Db; - + $browseby = ' '; $browsebyArr = $this->getBrowseByOptions(); foreach ($browsebyArr as $bbk=>$bbv) { @@ -242,36 +242,36 @@ class Book } return $browseby; } - + /** * Update bookinfo row. */ public function update($id, $title, $asin, $url, $author, $publisher, $publishdate, $cover) - { - $db = new DB(); - + { + $db = new Settings(); + $db->queryExec(sprintf("update bookinfo SET title=%s, asin=%s, url=%s, author=%s, publisher=%s, publishdate='%s', cover=%d, updateddate=NOW() WHERE ID = %d", - $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $db->escapeString($author), $db->escapeString($publisher), $publishdate, $cover, $id)); + $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $db->escapeString($author), $db->escapeString($publisher), $publishdate, $cover, $id)); } - + /** - * Determine if a bookinfo can be found locally, if not query amazon, strip out it + * Determine if a bookinfo can be found locally, if not query amazon, strip out it * properties and update the database. */ public function updateBookInfo($author, $title) { - $db = new DB(); + $db = new Settings(); $ri = new ReleaseImage(); - + $mus = array(); $amaz = $this->fetchAmazonProperties($author." ".$title); - if (!$amaz) + if (!$amaz) { //echo "tried to lookup ".$author." ".$title; return false; } sleep(1); - + // // get album properties // @@ -282,7 +282,7 @@ class Book if ($item['coverurl'] != "") $item['cover'] = 1; else - $item['cover'] = 0; + $item['cover'] = 0; $item["author"] = (string) $amaz->Items->Item->ItemAttributes->Author; $item["dewey"] = (string) $amaz->Items->Item->ItemAttributes->DeweyDecimalNumber; $item["ean"] = (string) $amaz->Items->Item->ItemAttributes->EAN; @@ -294,18 +294,18 @@ class Book $item["review"] = ""; if (isset($amaz->Items->Item->EditorialReviews)) $item["review"] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); - + //This is to verify the result back from amazon was at least somewhat related to what was intended. //If you are debugging releases comment out the following code to show all info - + $match = similar_text($author, $item["author"], $authorpercent); $match = similar_text($title, $item['title'], $titlepercent); - + //If the author is less than 80% album must be 100% if ($authorpercent < '60') - { + { if ($titlepercent != '100') - { + { //echo "\nAuthor Under 80 Title Under 100 \n".$author." - ".$item['author']." - ".$authorpercent."\n"; $temptitle = $title; $tempauthor = $author; @@ -324,29 +324,29 @@ class Book } } } - + //If the title is ever under 30%, it's probably not a match. if ($titlepercent < '30') { //echo "Title Under 30 ".$title." - ".$item['title']." - ".$titlepercent; return false; } - - $bookId = $this->addUpdateBookInfo($item['title'], $item['asin'], $item['url'], - $item['author'], $item['publisher'], $item['publishdate'], $item['review'], + + $bookId = $this->addUpdateBookInfo($item['title'], $item['asin'], $item['url'], + $item['author'], $item['publisher'], $item['publishdate'], $item['review'], $item['cover'], $item['dewey'], $item['ean'], $item['isbn'], $item['pages'] ); - if ($bookId) + if ($bookId) { $item['cover'] = $ri->saveImage($bookId, $item['coverurl'], $this->imgSavePath, 250, 250); - } - + } + return $bookId; } - + /** * Query amazon for a title. - */ + */ public function fetchAmazonProperties($title) { $obj = new AmazonProductAPI($this->pubkey, $this->privkey, $this->asstag); @@ -361,24 +361,24 @@ class Book return $result; } - + /** * Process all untagged book releases for additional metadata. - */ + */ public function processBookReleases() { $ret = 0; - $db = new DB(); + $db = new Settings(); $numlookedup = 0; - + $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where bookinfoID IS NULL and categoryID = %d ORDER BY postdate DESC LIMIT 100", Category::CAT_BOOK_EBOOK)); if ($db->getNumRows($res) > 0) - { + { if ($this->echooutput) echo "BookPrc : Processing " . $db->getNumRows($res) . " book releases\n"; - + while ($arr = $db->getAssocArray($res)) - { + { if ($numlookedup > Book::NUMTOPROCESSPERTIME) return; @@ -388,10 +388,10 @@ class Book { if ($this->echooutput) echo 'BookPrc : '.$book["author"].' - '.$book["title"]."\n"; - + //check for existing book entry $bookCheck = $this->getBookInfoByName($book["author"], $book["title"]); - + if ($bookCheck === false) { // @@ -404,19 +404,19 @@ class Book $bookId = $ret; } } - else + else { $bookId = $bookCheck["ID"]; } - } + } $db->queryExec(sprintf("update releases SET bookinfoID = %d WHERE ID = %d", $bookId, $arr["ID"])); } } } - + /** * Strip out author and title name from a release name. - */ + */ public function parseAuthor($releasename) { $result = array(); @@ -426,15 +426,15 @@ class Book //only process the reasonably named items //if (!preg_match('/epub|mobi|html|lit|prc|djvu|pdf/i', $releasename)) // return false; - + //remove things in brackets and double hyphens $newName = preg_replace("%(\([\w\s-.,]*\)|\[[\w\s-.,]*\]|[0-9])%","",$newName); $newName = preg_replace("%(\-\s.*\-)%","-",$newName); $name = explode("-", $newName); $name = array_map("trim", $name); - - + + if (is_array($name) && sizeof($name) > 1) { $result['author'] = trim($name[0]); @@ -460,7 +460,7 @@ class Book //echo "author parsed - ".$result['author']."\n"; //echo "title parsed - ".$result['title']."\n"; - + // switch Cratchett, Bob to Bob Cratchett preg_match_all('/[,]/i', $result['author'], $matches); if (sizeof($matches[0]) == 1) @@ -474,17 +474,17 @@ class Book } } } - + return (!empty($result['author']) ? $result : false); } - + /** * Insert or update a bookinfo row. - */ + */ public function addUpdateBookInfo($title, $asin, $url, $author, $publisher, $publishdate, $review, $cover, $dewey, $ean, $isbn, $pages) { - $db = new DB(); - + $db = new Settings(); + if ($pages == 0) $pages = "null"; else @@ -501,15 +501,15 @@ class Book $sql = sprintf("INSERT INTO bookinfo (title, asin, url, author, publisher, publishdate, review, cover, createddate, updateddate, dewey, ean, isbn, pages) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, now(), now(), %s, %s, %s, %s) - ON DUPLICATE KEY UPDATE title = %s, asin = %s, url = %s, author = %s, publisher = %s, publishdate = %s, review = %s, cover = %d, createddate = now(), updateddate = now(), dewey = %s, ean = %s, isbn = %s, pages = %s", - $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), - $db->escapeString($author), $db->escapeString($publisher), + ON DUPLICATE KEY UPDATE title = %s, asin = %s, url = %s, author = %s, publisher = %s, publishdate = %s, review = %s, cover = %d, createddate = now(), updateddate = now(), dewey = %s, ean = %s, isbn = %s, pages = %s", + $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), + $db->escapeString($author), $db->escapeString($publisher), $publishdate, $db->escapeString($review), $cover, $db->escapeString($dewey), $db->escapeString($ean), $db->escapeString($isbn), $pages, - $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), - $db->escapeString($author), $db->escapeString($publisher), + $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), + $db->escapeString($author), $db->escapeString($publisher), $db->escapeString($publishdate), $db->escapeString($review), $cover, $db->escapeString($dewey), $db->escapeString($ean), $db->escapeString($isbn), $pages ); - + $bookId = $db->queryInsert($sql); - return $bookId; + return $bookId; } } diff --git a/lib/copy_this/www/lib/category.php b/lib/copy_this/www/lib/category.php index 8400abbbb..7f379f69c 100644 --- a/lib/copy_this/www/lib/category.php +++ b/lib/copy_this/www/lib/category.php @@ -1,5 +1,5 @@ 0) @@ -139,7 +139,7 @@ class Category */ public function isParent($cid) { - $db = new DB(); + $db = new 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; @@ -152,7 +152,7 @@ class Category */ public function getFlat($activeonly = false) { - $db = new DB(); + $db = new Settings(); $act = ""; if ($activeonly) $act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE); @@ -165,7 +165,7 @@ class Category */ public function getChildren($cid) { - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("select c.* from category c where parentID = %d", $cid), true); } @@ -177,7 +177,7 @@ class Category */ public function getEnabledParentNames() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT title FROM category WHERE parentID IS NULL AND status = 1"); } @@ -187,7 +187,7 @@ class Category */ public function getById($id) { - $db = new DB(); + $db = new 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)); } @@ -198,7 +198,7 @@ class Category */ public function getSizeRangeById($id) { - $db = new DB(); + $db = new 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 ) @@ -239,14 +239,14 @@ class Category */ public function getByIds($ids) { - $db = new DB(); + $db = new 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 DB(); + $db = new 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)); @@ -258,7 +258,7 @@ class Category */ public function update($id, $status, $desc, $disablepreview, $minsize, $maxsize) { - $db = new DB(); + $db = new 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)); } @@ -268,7 +268,7 @@ class Category */ public function getForMenu($excludedcats = array()) { - $db = new DB(); + $db = new Settings(); $ret = array(); $exccatlist = ""; diff --git a/lib/copy_this/www/lib/console.php b/lib/copy_this/www/lib/console.php index b7ab66ca5..ee4b11e62 100644 --- a/lib/copy_this/www/lib/console.php +++ b/lib/copy_this/www/lib/console.php @@ -8,13 +8,13 @@ require_once(WWW_DIR."/lib/util.php"); require_once(WWW_DIR."/lib/releaseimage.php"); /** - * This class looks up metadata about console releases and handles + * This class looks up metadata about console releases and handles * storage/retrieval from the database. */ class Console { const NUMTOPROCESSPERTIME = 100; - + /** * Default constructor */ @@ -26,62 +26,62 @@ class Console $this->pubkey = $site->amazonpubkey; $this->privkey = $site->amazonprivkey; $this->asstag = $site->amazonassociatetag; - + $this->imgSavePath = WWW_DIR.'covers/console/'; } - + /** * Get consoleinfo row by ID. - */ + */ public function getConsoleInfo($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT consoleinfo.*, genres.title as genres FROM consoleinfo left outer join genres on genres.ID = consoleinfo.genreID where consoleinfo.ID = %d ", $id)); } /** * Get consoleinfo row by name and platform. - */ + */ public function getConsoleInfoByName($title, $platform) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM consoleinfo where title like %s and platform like %s", $db->escapeString("%".$title."%"), $db->escapeString("%".$platform."%"))); } /** * Get range of consoleinfo row by limit. - */ + */ public function getRange($start, $num) - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - - return $db->query(" SELECT * FROM consoleinfo ORDER BY createddate DESC".$limit); + + return $db->query(" SELECT * FROM consoleinfo ORDER BY createddate DESC".$limit); } - + /** * Get count of all consoleinfo rows. - */ + */ public function getCount() - { - $db = new DB(); - $res = $db->queryOneRow("select count(ID) as num from consoleinfo"); + { + $db = new Settings(); + $res = $db->queryOneRow("select count(ID) as num from consoleinfo"); return $res["num"]; } - + /** * Get count of all consoleinfo rows for browse list. - */ + */ public function getConsoleCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new DB(); - + $db = new Settings(); + $browseby = $this->getBrowseBy(); - + $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -108,36 +108,36 @@ class Console } } $catsrch.= "1=2 )"; - } + } if ($maxage > 0) $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage); else - $maxage = ""; - + $maxage = ""; + $exccatlist = ""; 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); - $res = $db->queryOneRow($sql, true); - return $res["num"]; - } - + $res = $db->queryOneRow($sql, true); + return $res["num"]; + } + /** * Get range of consoleinfo rows for browse list. - */ + */ public function getConsoleRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $browseby = $this->getBrowseBy(); - + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - + $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -164,8 +164,8 @@ class Console } } $catsrch.= "1=2 )"; - } - + } + $maxagesql = ""; if ($maxage > 0) $maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage); @@ -173,15 +173,15 @@ class Console $exccatlist = ""; if (count($excludedcats) > 0) $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]); - return $db->query($sql, true); + return $db->query($sql, true); } - + /** * Get orderby column for console browse list. - */ + */ public function getConsoleOrder($orderby) { $order = ($orderby == '') ? 'r.postdate' : $orderby; @@ -208,7 +208,7 @@ class Console case 'stats': $orderfield = 'r.grabs'; break; - case 'posted': + case 'posted': default: $orderfield = 'r.postdate'; break; @@ -216,30 +216,30 @@ class Console $ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc'; return array($orderfield, $ordersort); } - + /** * Get available orderby columns for console browse list. - */ + */ public function getConsoleOrdering() { return array('title_asc', 'title_desc', 'posted_asc', 'posted_desc', 'size_asc', 'size_desc', 'files_asc', 'files_desc', 'stats_asc', 'stats_desc', 'platform_asc', 'platform_desc', 'releasedate_asc', 'releasedate_desc', 'genre_asc', 'genre_desc'); } - + /** * Get available filter columns for console browse list. - */ + */ public function getBrowseByOptions() { return array('platform'=>'platform', 'title'=>'title', 'genre'=>'genreID'); } - + /** * Get sql for selected filter columns for console browse list. - */ + */ public function getBrowseBy() { $db = new Db; - + $browseby = ' '; $browsebyArr = $this->getBrowseByOptions(); foreach ($browsebyArr as $bbk=>$bbv) { @@ -250,39 +250,39 @@ class Console } return $browseby; } - + /** * Update consoleinfo row. - */ + */ public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genreID) - { - $db = new DB(); - + { + $db = new Settings(); + $db->queryExec(sprintf("update consoleinfo SET title=%s, asin=%s, url=%s, salesrank=%s, platform=%s, publisher=%s, releasedate='%s', esrb=%s, cover=%d, genreID=%d, updateddate=NOW() WHERE ID = %d", - $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($platform), $db->escapeString($publisher), $releasedate, $db->escapeString($esrb), $cover, $genreID, $id)); + $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($platform), $db->escapeString($publisher), $releasedate, $db->escapeString($esrb), $cover, $genreID, $id)); } - + /** * Check whether a title is available at Amazon and store its metadata. - */ + */ public function updateConsoleInfo($gameInfo) { - $db = new DB(); + $db = new Settings(); $gen = new Genres(); $ri = new ReleaseImage(); - + $con = array(); $amaz = $this->fetchAmazonProperties($gameInfo['title'], $gameInfo['node']); - if (!$amaz) - return false; - + if (!$amaz) + return false; + //load genres $defaultGenres = $gen->getGenres(Genres::CONSOLE_TYPE); $genreassoc = array(); foreach($defaultGenres as $dg) { $genreassoc[$dg['ID']] = strtolower($dg['title']); } - + // // get game properties // @@ -295,19 +295,19 @@ class Console $con['title'] = (string) $amaz->Items->Item->ItemAttributes->Title; if (empty($con['title'])) $con['title'] = $gameInfo['title']; - + $con['platform'] = (string) $amaz->Items->Item->ItemAttributes->Platform; if (empty($con['platform'])) $con['platform'] = $gameInfo['platform']; - + //Beginning of Recheck Code //This is to verify the result back from amazon was at least somewhat related to what was intended. - + //Some of the Platforms don't match Amazon's exactly. This code is needed to facilitate rechecking. if (preg_match('/^X360$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('X360', 'Xbox 360', $gameInfo['platform']); // baseline single quote - } + } if (preg_match('/^XBOX360$/i', $gameInfo['platform'])) { $gameInfo['platform'] = str_replace('XBOX360', 'Xbox 360', $gameInfo['platform']); // baseline single quote @@ -347,20 +347,20 @@ class Console { $con['title'] = str_replace(' [Online Game Code]', '', $con['title']); // baseline single quote } - + //Basically the XBLA names contain crap, this is to reduce the title down far enough to be usable if (preg_match('/xbla/i', $gameInfo['platform'])) { $gameInfo['title'] = substr($gameInfo['title'],0,10); $con['substr'] = $gameInfo['title']; } - + //This actual compares the two strings and outputs a percentage value. $titlepercent =''; $platformpercent =''; similar_text(strtolower($gameInfo['title']), strtolower($con['title']), $titlepercent); similar_text(strtolower($gameInfo['platform']), strtolower($con['platform']), $platformpercent); - + //Since Wii Ware games and XBLA have inconsistent original platforms, as long as title is 50% its ok. if (preg_match('/(wiiware|xbla)/i', $gameInfo['platform'])) { @@ -369,7 +369,7 @@ class Console $platformpercent = 100; } } - + //If the release is DLC matching sucks, so assume anything over 50% is legit. if (isset($gameInfo['dlc']) && $gameInfo['dlc'] == 1) { @@ -379,47 +379,47 @@ class Console $platformpercent = 100; } } - + //Show the Percentages //echo("Matched: Title Percentage: $titlepercent%"); //echo("Matched: Platform Percentage: $platformpercent%"); - + //If the Title is less than 80% Platform must be 100% unless it is XBLA if ($titlepercent < 70) - { + { if ($platformpercent != 100) { return false; } } - + //If title is less than 80% then its most likely not a match if ($titlepercent < 70) - return false; - + return false; + //Platform must equal 100% if ($platformpercent != 100) - return false; - + return false; + $con['asin'] = (string) $amaz->Items->Item->ASIN; $con['url'] = (string) $amaz->Items->Item->DetailPageURL; - + $con['salesrank'] = (string) $amaz->Items->Item->SalesRank; if ($con['salesrank'] == "") $con['salesrank'] = 'null'; - + $con['publisher'] = (string) $amaz->Items->Item->ItemAttributes->Publisher; - + $con['esrb'] = (string) $amaz->Items->Item->ItemAttributes->ESRBAgeRating; - + $con['releasedate'] = $db->escapeString((string) $amaz->Items->Item->ItemAttributes->ReleaseDate); if ($con['releasedate'] == "''") $con['releasedate'] = 'null'; - + $con['review'] = ""; if (isset($amaz->Items->Item->EditorialReviews)) $con['review'] = trim(strip_tags((string) $amaz->Items->Item->EditorialReviews->EditorialReview->Content)); - + $genreKey = -1; $genreName = ''; if (isset($amaz->Items->Item->BrowseNodes) || isset($amaz->Items->Item->ItemAttributes->Genre)) @@ -445,7 +445,7 @@ class Console } } } - + if (empty($genreName) && isset($amaz->Items->Item->ItemAttributes->Genre)) { $tmpGenre = (string) $amaz->Items->Item->ItemAttributes->Genre; @@ -460,14 +460,14 @@ class Console break; } } - } + } } - + if (empty($genreName)) { $genreName = 'Unknown'; } - + if (in_array(strtolower($genreName), $genreassoc)) { $genreKey = array_search(strtolower($genreName), $genreassoc); } else { @@ -475,31 +475,31 @@ class Console } $con['consolegenre'] = $genreName; $con['consolegenreID'] = $genreKey; - + $query = sprintf(" INSERT INTO consoleinfo (`title`, `asin`, `url`, `salesrank`, `platform`, `publisher`, `genreID`, `esrb`, `releasedate`, `review`, `cover`, `createddate`, `updateddate`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, now(), now()) - ON DUPLICATE KEY UPDATE `title` = %s, `asin` = %s, `url` = %s, `salesrank` = %s, `platform` = %s, `publisher` = %s, `genreID` = %s, `esrb` = %s, `releasedate` = %s, `review` = %s, `cover` = %d, createddate = now(), updateddate = now()", - $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), + ON DUPLICATE KEY UPDATE `title` = %s, `asin` = %s, `url` = %s, `salesrank` = %s, `platform` = %s, `publisher` = %s, `genreID` = %s, `esrb` = %s, `releasedate` = %s, `review` = %s, `cover` = %d, createddate = now(), updateddate = now()", + $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), + $con['salesrank'], $db->escapeString($con['platform']), $db->escapeString($con['publisher']), ($con['consolegenreID']==-1?"null":$con['consolegenreID']), $db->escapeString($con['esrb']), + $con['releasedate'], $db->escapeString($con['review']), $con['cover'], + $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), $con['salesrank'], $db->escapeString($con['platform']), $db->escapeString($con['publisher']), ($con['consolegenreID']==-1?"null":$con['consolegenreID']), $db->escapeString($con['esrb']), - $con['releasedate'], $db->escapeString($con['review']), $con['cover'], - $db->escapeString($con['title']), $db->escapeString($con['asin']), $db->escapeString($con['url']), - $con['salesrank'], $db->escapeString($con['platform']), $db->escapeString($con['publisher']), ($con['consolegenreID']==-1?"null":$con['consolegenreID']), $db->escapeString($con['esrb']), $con['releasedate'], $db->escapeString($con['review']), $con['cover'] ); $consoleId = $db->queryInsert($query); - if ($consoleId) + if ($consoleId) { $con['cover'] = $ri->saveImage($consoleId, $con['coverurl'], $this->imgSavePath, 250, 250); - } + } return $consoleId; } - + /** * Retrieve properties for an item from Amazon. - */ + */ public function fetchAmazonProperties($title, $node) { $obj = new AmazonProductAPI($this->pubkey, $this->privkey, $this->asstag); @@ -513,37 +513,37 @@ class Console } return $result; } - + /** * Check all untagged console releases for their extended metadata. - */ + */ public function processConsoleReleases() { $ret = 0; - $db = new DB(); + $db = new Settings(); $numlookedup = 0; - + $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 postdate DESC LIMIT 100", Category::CAT_PARENT_GAME)); if ( $db->getNumRows($res) > 0) - { + { if ($this->echooutput) echo "ConsPrc : Processing " . $db->getNumRows($res) . " console releases\n"; - + while ($arr = $db->getAssocArray($res)) - { + { if ($numlookedup > Console::NUMTOPROCESSPERTIME) return; $gameInfo = $this->parseTitle($arr['searchname']); if ($gameInfo !== false) { - + if ($this->echooutput) echo 'ConsPrc : '.$gameInfo["title"].' ('.$gameInfo["platform"].')'."\n"; - + //check for existing console entry $gameCheck = $this->getConsoleInfoByName($gameInfo["title"], $gameInfo["platform"]); - + if ($gameCheck === false) { $numlookedup++; @@ -553,7 +553,7 @@ class Console $gameId = -2; } } - else + else { $gameId = $gameCheck["ID"]; } @@ -561,7 +561,7 @@ class Console //update release $db->queryExec(sprintf("update releases SET consoleinfoID = %d WHERE ID = %d", $gameId, $arr["ID"])); - } + } else { //could not parse release title $db->queryExec(sprintf("update releases SET consoleinfoID = %d WHERE ID = %d", -2, $arr["ID"])); @@ -569,17 +569,17 @@ class Console } } } - + /** * Strip a title from a releasename. - */ + */ function parseTitle($releasename) { $result = array(); - + //get name of the game from name of release preg_match('/^(?P.*?)[\.\-_ ](v\.?\d\.\d|PAL|NTSC|EUR|USA|JP|ASIA|JAP|JPN|AUS|MULTI\.?5|MULTI\.?4|MULTI\.?3|PATCHED|FULLDVD|DVD5|DVD9|DVDRIP|PROPER|REPACK|RETAIL|DEMO|DISTRIBUTION|REGIONFREE|READ\.?NFO|NFOFIX|PS2|PS3|PSP|WII|X\-?BOX|XBLA|X360|NDS|N64|NGC)/i', $releasename, $matches); - if (isset($matches['title'])) + if (isset($matches['title'])) { $title = $matches['title']; //replace dots or underscores with spaces @@ -604,17 +604,17 @@ class Console } } } - + //get the platform of the release preg_match('/[\.\-_ ](?P<platform>XBLA|WiiWARE|N64|SNES|NES|PS2|PS3|PS 3|PSP|WII|XBOX360|X\-?BOX|X360|NDS|NGC)/i', $releasename, $matches); - if (isset($matches['platform'])) + if (isset($matches['platform'])) { $platform = $matches['platform']; if (preg_match('/^(XBLA)$/i', $platform)) { if (preg_match('/DLC/i', $title)) { - $platform = str_replace('XBLA', 'XBOX360', $platform); // baseline single quote + $platform = str_replace('XBLA', 'XBOX360', $platform); // baseline single quote } } $browseNode = $this->getBrowseNode($platform); @@ -628,10 +628,10 @@ class Console //in either case we should have a title at the minimum return (isset($result['title']) && !empty($result['title']) && isset($result['platform'])) ? $result : false; } - + /** * Translate Amazon browse nodes for console types. - */ + */ function getBrowseNode($platform) { switch($platform) @@ -673,20 +673,20 @@ class Console $nodeId = '541022'; break; default: - $nodeId = '468642'; + $nodeId = '468642'; break; } - + return $nodeId; } - + /** * Match an Amazon browse node with internal genre types . - */ + */ public function matchBrowseNode($nodeName) { $str = ''; - + switch($nodeName) { case 'Action': diff --git a/lib/copy_this/www/lib/content.php b/lib/copy_this/www/lib/content.php index a06c1a840..cf7db2f4d 100644 --- a/lib/copy_this/www/lib/content.php +++ b/lib/copy_this/www/lib/content.php @@ -7,7 +7,7 @@ require_once(WWW_DIR."/lib/framework/db.php"); * This class looks up site content. */ class Contents -{ +{ const TYPEUSEFUL = 1; const TYPEARTICLE = 2; const TYPEINDEX = 3; @@ -21,12 +21,12 @@ class Contents { $content["url"] = "/".$content["url"]; } - + if (substr($content["url"], strlen($content["url"]) - 1) != '/') { $content["url"] = $content["url"]."/"; } - + return $content; } @@ -34,17 +34,17 @@ class Contents * Delete a content row. */ public function delete($id) - { - $db = new DB(); + { + $db = new Settings(); return $db->queryExec(sprintf("DELETE from content where id=%d", $id)); - } + } /** * Update a content row. */ 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,11 +53,11 @@ class Contents * Add a content row. */ public function add($content) - { - $db = new DB(); - + { + $db = new Settings(); + $content = $this->validate($content); - + return $db->queryInsert(sprintf("insert into content (role, title, url, body, metadescription, metakeywords, contenttype, showinmenu, status, ordinal ) values (%d, %s, %s, %s, %s, %s, %d, %d, %d, %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"] )); } @@ -65,53 +65,53 @@ class Contents * Get all active content rows. */ public function get() - { - $db = new DB(); - return $db->query(sprintf("select * from content where status = 1 order by contenttype, coalesce(ordinal, 1000000)")); - } - + { + $db = new Settings(); + return $db->query(sprintf("select * from content where status = 1 order by contenttype, coalesce(ordinal, 1000000)")); + } + /** * Get all content rows. */ public function getAll() - { - $db = new DB(); - return $db->query(sprintf("select * from content order by contenttype, coalesce(ordinal, 1000000)")); - } + { + $db = new Settings(); + return $db->query(sprintf("select * from content order by contenttype, coalesce(ordinal, 1000000)")); + } /** * Get a content row by its ID. */ public function getByID($id, $role) - { - $db = new DB(); + { + $db = new Settings(); if ($role == Users::ROLE_ADMIN) $role = ""; else $role = sprintf("and (role=%d or role=0)", $role); - - return $db->queryOneRow(sprintf("select * from content where id = %d %s", $id, $role)); - } - + + return $db->queryOneRow(sprintf("select * from content where id = %d %s", $id, $role)); + } + /** * Get the index page. */ public function getIndex() - { - $db = new DB(); - return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX), true); - } + { + $db = new Settings(); + return $db->queryOneRow(sprintf("select * from content where status=1 and contenttype = %d ", Contents::TYPEINDEX), true); + } /** * Get all content rows for a role and menu type, ie useful links. */ public function getForMenuByTypeAndRole($id, $role) - { - $db = new DB(); + { + $db = new Settings(); if ($role == Users::ROLE_ADMIN) $role = ""; else - $role = sprintf("and (role=%d or role=0)", $role); - return $db->query(sprintf("select * from content where showinmenu=1 and status=1 and contenttype = %d %s ", $id, $role)); - } + $role = sprintf("and (role=%d or role=0)", $role); + return $db->query(sprintf("select * from content where showinmenu=1 and status=1 and contenttype = %d %s ", $id, $role)); + } } \ No newline at end of file diff --git a/lib/copy_this/www/lib/episode.php b/lib/copy_this/www/lib/episode.php index f11f86dc9..7493326c5 100644 --- a/lib/copy_this/www/lib/episode.php +++ b/lib/copy_this/www/lib/episode.php @@ -5,13 +5,13 @@ require_once(WWW_DIR."/lib/framework/db.php"); * This class looks up tv episode data. */ class Episode -{ +{ /** * Get an episodeinfo row by ID. */ public function getEpisodeInfoByID($episodeinfoID) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE ID = %d', $episodeinfoID)); } @@ -20,8 +20,8 @@ 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)) $additionalSql = sprintf('AND fullep = %s', $db->escapeString($fullep)); diff --git a/lib/copy_this/www/lib/forum.php b/lib/copy_this/www/lib/forum.php index f21f8bb92..0158facb5 100644 --- a/lib/copy_this/www/lib/forum.php +++ b/lib/copy_this/www/lib/forum.php @@ -11,21 +11,21 @@ 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; - + if ($parentid != 0) { $par = $this->getParent($parentid); if ($par == false) return -1; - + $db->queryExec(sprintf("update forumpost set replies = replies + 1, updateddate = now() where ID = %d", $parentid)); } - - $db->queryInsert(sprintf("INSERT INTO `forumpost` (`forumID`,`parentID`,`userID`,`subject`,`message`, `locked`, `sticky`, `replies`, `createddate`, `updateddate`) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", + + $db->queryInsert(sprintf("INSERT INTO `forumpost` (`forumID`,`parentID`,`userID`,`subject`,`message`, `locked`, `sticky`, `replies`, `createddate`, `updateddate`) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", $parentid, $userid, $db->escapeString($subject) , $db->escapeString($message), $locked, $sticky, $replies)); } @@ -34,8 +34,8 @@ class Forum */ public function getParent($parent) { - $db = new DB(); - return $db->queryOneRow(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.ID = forumpost.userID where forumpost.ID = %d ", $parent)); + $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)); } /** @@ -43,8 +43,8 @@ class Forum */ public function getRecentPosts($limit) { - $db = new DB(); - 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)); + $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)); } @@ -53,8 +53,8 @@ class Forum */ public function getPosts($parent) { - $db = new DB(); - 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)); + $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)); } /** @@ -62,8 +62,8 @@ class Forum */ public function getPost($id) { - $db = new DB(); - return $db->queryOneRow(sprintf(" SELECT * from forumpost where ID = %d", $id)); + $db = new Settings(); + return $db->queryOneRow(sprintf(" SELECT * from forumpost where ID = %d", $id)); } /** @@ -71,8 +71,8 @@ class Forum */ public function getBrowseCount() { - $db = new DB(); - $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where parentID = 0")); + $db = new Settings(); + $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where parentID = 0")); return $res["num"]; } @@ -81,14 +81,14 @@ class Forum */ public function getBrowseRange($start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - return $db->query(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.ID = forumpost.userID where parentID = 0 order by updateddate desc".$limit )); + return $db->query(sprintf(" SELECT forumpost.*, users.username from forumpost left outer join users on users.ID = forumpost.userID where parentID = 0 order by updateddate desc".$limit )); } /** @@ -96,7 +96,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)); } @@ -105,7 +105,7 @@ class Forum */ public function deletePost($id) { - $db = new DB(); + $db = new Settings(); $post = $this->getPost($id); if ($post) { @@ -121,32 +121,32 @@ class Forum */ public function deleteUser($id) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from forumpost where userID = %d", $id)); } /** * Count of all posts for a user. - */ + */ public function getCountForUser($uid) - { - $db = new DB(); - $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where userID = %d", $uid)); + { + $db = new Settings(); + $res = $db->queryOneRow(sprintf("select count(ID) as num from forumpost where userID = %d", $uid)); return $res["num"]; } - + /** * Get forum posts for a user for paged list in profile. - */ + */ public function getForUserRange($uid, $start, $num) - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - - return $db->query(sprintf(" SELECT forumpost.*, users.username FROM forumpost LEFT OUTER JOIN users ON users.ID = forumpost.userID where userID = %d order by forumpost.createddate desc ".$limit, $uid)); + + return $db->query(sprintf(" SELECT forumpost.*, users.username FROM forumpost LEFT OUTER JOIN users ON users.ID = forumpost.userID where userID = %d order by forumpost.createddate desc ".$limit, $uid)); } } \ No newline at end of file diff --git a/lib/copy_this/www/lib/genres.php b/lib/copy_this/www/lib/genres.php index 50843c79a..7a705e6ba 100644 --- a/lib/copy_this/www/lib/genres.php +++ b/lib/copy_this/www/lib/genres.php @@ -1,6 +1,6 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/category.php"); class Genres diff --git a/lib/copy_this/www/lib/groups.php b/lib/copy_this/www/lib/groups.php index 0aa2b6596..2055425b1 100644 --- a/lib/copy_this/www/lib/groups.php +++ b/lib/copy_this/www/lib/groups.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/category.php"); require_once(WWW_DIR . "/lib/site.php"); require_once(WWW_DIR . "/lib/releases.php"); @@ -35,7 +35,7 @@ class Groups } $ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc'; $orderby = $orderfield . " " . $ordersort; - $db = new DB(); + $db = new Settings(); return $db->query(sprintf("SELECT groups.*, COALESCE(rel.num, 0) AS num_releases FROM groups @@ -51,7 +51,7 @@ class Groups */ public function getGroupsForSelect() { - $db = new DB(); + $db = new Settings(); $categories = $db->query("SELECT * FROM groups WHERE active = 1 ORDER BY name"); $temp_array = array(); @@ -68,7 +68,7 @@ class Groups */ public function getByID($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from groups where ID = %d ", $id)); } @@ -78,7 +78,7 @@ class Groups */ public function getActive() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT * FROM groups WHERE active = 1 ORDER BY name"); } @@ -88,14 +88,14 @@ class Groups */ public function getByName($grp) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from groups where name = '%s' ", $grp)); } public function getByNameByID($ID) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("select name from groups where ID = %d ", $ID)); return $res["name"]; @@ -103,7 +103,7 @@ class Groups public function getIDByName($name) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("SELECT ID FROM groups WHERE name = %s", $db->escapeString($name))); return $res["ID"]; @@ -114,7 +114,7 @@ class Groups */ public function getCount($groupname = "", $activeonly = false) { - $db = new DB(); + $db = new Settings(); $grpsql = ''; if ($groupname != "") @@ -133,7 +133,7 @@ class Groups */ public function getRange($start, $num, $groupname = "", $activeonly = false) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; else @@ -161,7 +161,7 @@ class Groups */ public function add($group) { - $db = new DB(); + $db = new Settings(); if ($group["minfilestoformrelease"] == "" || $group["minfilestoformrelease"] == "0") $minfiles = 'null'; @@ -196,7 +196,7 @@ class Groups */ public function delete($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from groups where ID = %d", $id)); } @@ -206,7 +206,7 @@ class Groups */ public function reset($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("update groups set backfill_target=0, first_record=0, first_record_postdate=null, last_record=0, last_record_postdate=null, last_updated=null where ID = %d", $id)); } @@ -218,7 +218,7 @@ class Groups { require_once(WWW_DIR . "/lib/binaries.php"); - $db = new DB(); + $db = new Settings(); $releases = new Releases(); $binaries = new Binaries(); @@ -238,7 +238,7 @@ class Groups */ public function update($group) { - $db = new DB(); + $db = new Settings(); if ($group["minfilestoformrelease"] == "" || $group["minfilestoformrelease"] == "0") $minfiles = 'null'; @@ -266,7 +266,7 @@ class Groups if ($groupList == "") { $ret[] = "No group list provided."; } else { - $db = new DB(); + $db = new Settings(); $nntp = new Nntp; if (!$nntp->doConnect()) { $ret[] = "Failed to get NNTP connection"; @@ -302,7 +302,7 @@ class Groups */ public function updateGroupStatus($id, $status = 0) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update groups SET active = %d WHERE id = %d", $status, $id)); $status = ($status == 0) ? 'deactivated' : 'activated'; diff --git a/lib/copy_this/www/lib/menu.php b/lib/copy_this/www/lib/menu.php index e58851292..73daeedef 100644 --- a/lib/copy_this/www/lib/menu.php +++ b/lib/copy_this/www/lib/menu.php @@ -6,14 +6,14 @@ require_once(WWW_DIR."/lib/users.php"); * This class looks up site menu data. */ class Menu -{ +{ /** * Get all menu rows for a role. */ public function get($role, $serverurl) - { - $db = new DB(); - + { + $db = new Settings(); + $guest = ""; if ($role != Users::ROLE_GUEST) $guest = sprintf(" and role != %d ", Users::ROLE_GUEST); @@ -23,8 +23,8 @@ class Menu $sql = sprintf("select * from menu where role <= %d %s order by ordinal", $role, $guest); - $data = $db->query($sql); - + $data = $db->query($sql); + $ret = array(); foreach ($data as $d) { @@ -39,32 +39,32 @@ class Menu } } return $ret; - } - + } + /** * Get all menu rows. */ public function getAll() - { - $db = new DB(); - return $db->query(sprintf("select * from menu order by role, ordinal")); - } - + { + $db = new Settings(); + return $db->query(sprintf("select * from menu order by role, ordinal")); + } + /** * Get a menu row by its ID. */ public function getById($id) - { - $db = new DB(); - return $db->queryOneRow(sprintf("select * from menu where ID = %d", $id)); - } - + { + $db = new Settings(); + return $db->queryOneRow(sprintf("select * from menu where ID = %d", $id)); + } + /** * Delete a menu row. */ public function delete($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from menu where ID = %d", $id)); } @@ -73,17 +73,17 @@ class Menu */ public function add($menu) { - $db = new DB(); - 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"] )); + $db = new 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"] )); } - + /** * Update a menu row. */ public function update($menu) { - $db = new DB(); + $db = new 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"] )); } } \ No newline at end of file diff --git a/lib/copy_this/www/lib/movie.php b/lib/copy_this/www/lib/movie.php index 11c14f704..5652ab26a 100644 --- a/lib/copy_this/www/lib/movie.php +++ b/lib/copy_this/www/lib/movie.php @@ -18,7 +18,7 @@ class Movie const SRC_OPENING = 3; const SRC_UPCOMING = 4; const SRC_DVD = 5; - + /** * Default constructor. */ @@ -29,36 +29,36 @@ class Movie $site = $s->get(); $this->apikey = $site->tmdbkey; $this->lookuplanguage = $site->lookuplanguage; - + $this->imgSavePath = WWW_DIR.'covers/movies/'; } - + /** * Get a movieinfo row by its imdbID. */ public function getMovieInfo($imdbId) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM movieinfo where imdbID = %d", $imdbId)); } - + /** * Get movieinfo rows by array of imdbIDs. */ public function getMovieInfoMultiImdb($imdbIds) { - $db = new DB(); + $db = new Settings(); $allids = implode(",", array_filter($imdbIds)); $sql = sprintf("SELECT DISTINCT movieinfo.*, releases.imdbID AS relimdb FROM movieinfo LEFT OUTER JOIN releases ON releases.imdbID = movieinfo.imdbID WHERE movieinfo.imdbID IN (%s)", $allids); return $db->query($sql); - } - + } + /** * Delete movieinfo row by its imdbID. */ public function delete($imdbId) { - $db = new DB(); + $db = new Settings(); @unlink($this->imgSavePath.$imdbId.'-cover.jpg'); @unlink($this->imgSavePath.$imdbId.'-backdrop.jpg'); return $db->queryOneRow(sprintf("delete FROM movieinfo where imdbID = %d", $imdbId)); @@ -79,45 +79,45 @@ class Movie * Get movieinfo rows by limit. */ public function getRange($start, $num, $moviename="") - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - + $rsql = ''; if ($moviename != "") - $rsql .= sprintf("and movieinfo.title like %s ", $db->escapeString("%".$moviename."%")); - - return $db->query(sprintf(" SELECT * FROM movieinfo where 1=1 %s ORDER BY createddate DESC".$limit, $rsql)); + $rsql .= sprintf("and movieinfo.title like %s ", $db->escapeString("%".$moviename."%")); + + return $db->query(sprintf(" SELECT * FROM movieinfo where 1=1 %s ORDER BY createddate DESC".$limit, $rsql)); } - + /** * Get count of all movieinfo rows. */ public function getCount($moviename="") - { - $db = new DB(); - + { + $db = new Settings(); + $rsql = ''; if ($moviename != "") $rsql .= sprintf("and movieinfo.title like %s ", $db->escapeString("%".$moviename."%")); - - $res = $db->queryOneRow(sprintf("select count(ID) as num from movieinfo where 1=1 %s ", $rsql)); + + $res = $db->queryOneRow(sprintf("select count(ID) as num from movieinfo where 1=1 %s ", $rsql)); return $res["num"]; } - + /** * Get count of all movieinfo rows filter by category. */ public function getMovieCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new DB(); - + $db = new Settings(); + $browseby = $this->getBrowseBy(); - + $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -145,37 +145,37 @@ class Movie } $catsrch.= "1=2 )"; } - else - $catsrch = " 1=1 "; + else + $catsrch = " 1=1 "; if ($maxage > 0) $maxage = sprintf(" and r.postdate > now() - interval %d day ", $maxage); else - $maxage = ""; - + $maxage = ""; + $exccatlist = ""; 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); - $res = $db->queryOneRow($sql, true); - return $res["num"]; - } - + $res = $db->queryOneRow($sql, true); + return $res["num"]; + } + /** * Get movieinfo rows for browse list by limit. */ public function getMovieRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $browseby = $this->getBrowseBy(); - + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - + $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -203,9 +203,9 @@ class Movie } $catsrch.= "1=2 )"; } - else + else $catsrch = " 1=1 "; - + $maxagesql = ""; if ($maxage > 0) $maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage); @@ -213,15 +213,15 @@ class Movie $exccatlist = ""; if (count($excludedcats) > 0) $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]); - $rows = $db->query($sql, true); + $rows = $db->query($sql, true); // //get a copy of all the imdbs - // - $imdbds = ""; + // + $imdbds = ""; foreach ($rows as $row) $imdbds .= $row["imdbID"]. ", "; @@ -235,7 +235,7 @@ class Movie $sql = sprintf("select r.*, releasenfo.ID as nfoID, groups.name as grpname, concat(cp.title, ' > ', c.title) as categoryName from releases r left outer join category c on c.ID = r.categoryID left outer join category cp on cp.ID = c.parentID left outer join releasenfo on releasenfo.releaseID = r.ID left outer join groups on groups.ID = r.groupID where imdbID in (%s) and %s %s %s order by r.postdate desc", $imdbds, $catsrch, $maxagesql, $exccatlist); $allrows = $db->query($sql, true); $arr = array(); - + // // build array indexed by imdbid // @@ -257,7 +257,7 @@ class Movie $arr[$allrow["imdbID"]]["categoryID"] = (isset($arr[$allrow["imdbID"]]["categoryID"]) ? $arr[$allrow["imdbID"]]["categoryID"] : "") . $allrow["categoryID"] . ","; $arr[$allrow["imdbID"]]["categoryName"] = (isset($arr[$allrow["imdbID"]]["categoryName"]) ? $arr[$allrow["imdbID"]]["categoryName"] : "") . $allrow["categoryName"] . ","; } - + // // stuff back into the results set // @@ -278,12 +278,12 @@ class Movie $row["grp_release_grabs"] = substr($arr[$row["imdbID"]]["grabs"], 0, -1); $row["grp_release_categoryID"] = substr($arr[$row["imdbID"]]["categoryID"], 0, -1); $row["grp_release_categoryName"] = substr($arr[$row["imdbID"]]["categoryName"], 0, -1); - } + } } return $rows; - + } - + /** * Get movieinfo orderby column sql. */ @@ -301,7 +301,7 @@ class Movie case 'rating': $orderfield = 'm.rating'; break; - case 'posted': + case 'posted': default: $orderfield = 'max(r.postdate)'; break; @@ -309,7 +309,7 @@ class Movie $ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc'; return array($orderfield, $ordersort); } - + /** * Get movieinfo orderby columns. */ @@ -317,7 +317,7 @@ class Movie { return array('title_asc', 'title_desc', 'year_asc', 'year_desc', 'rating_asc', 'rating_desc'); } - + /** * Get movieinfo filter columns. */ @@ -325,14 +325,14 @@ class Movie { return array('title', 'director', 'actors', 'genre', 'rating', 'year', 'imdb'); } - + /** * Get movieinfo sql column for users selected filter. */ public function getBrowseBy() { $db = new Db; - + $browseby = ' '; $browsebyArr = $this->getBrowseByOptions(); foreach ($browsebyArr as $bb) { @@ -348,7 +348,7 @@ class Movie } return $browseby; } - + /** * Create links for data like actor/director so used can requery. */ @@ -356,7 +356,7 @@ class Movie { if ($data[$field] == "") return ""; - + $tmpArr = explode(', ',$data[$field]); $newArr = array(); $i = 0; @@ -367,45 +367,45 @@ class Movie } return implode(', ', $newArr); } - + /** * Update movieinfo row. */ public function update($id, $title, $tagline, $plot, $year, $rating, $genre, $director, $actors, $language, $cover, $backdrop) - { - $db = new DB(); - + { + $db = new Settings(); + $db->queryExec(sprintf("update movieinfo SET title=%s, tagline=%s, plot=%s, year=%s, rating=%s, genre=%s, director=%s, actors=%s, language=%s, cover=%d, backdrop=%d, updateddate=NOW() WHERE imdbID = %d", - $db->escapeString($title), $db->escapeString($tagline), $db->escapeString($plot), $db->escapeString($year), $db->escapeString($rating), $db->escapeString($genre), $db->escapeString($director), $db->escapeString($actors), $db->escapeString($language), $cover, $backdrop, $id)); + $db->escapeString($title), $db->escapeString($tagline), $db->escapeString($plot), $db->escapeString($year), $db->escapeString($rating), $db->escapeString($genre), $db->escapeString($director), $db->escapeString($actors), $db->escapeString($language), $cover, $backdrop, $id)); } - + /** * Update movieinfo row by querying external sources and updating known properties/images. */ public function updateMovieInfo($imdbId) { - + if ($imdbId + 0 == 0) { return; } - + $ri = new ReleaseImage(); - + //check themoviedb for imdb info $tmdb = $this->fetchTmdbProperties($imdbId); - + //check imdb for movie info $imdb = $this->fetchImdbProperties($imdbId); - + if (!$imdb && !$tmdb) { return false; } - + $mov = array(); $mov['imdb_id'] = $imdbId; $mov['tmdb_id'] = (!isset($tmdb['tmdb_id']) || $tmdb['tmdb_id'] == '') ? "NULL" : $tmdb['tmdb_id']; - + //prefer tmdb cover over imdb cover $mov['cover'] = 0; if (isset($tmdb['cover']) && $tmdb['cover'] != '') { @@ -413,14 +413,14 @@ class Movie } elseif (isset($imdb['cover']) && $imdb['cover'] != '') { $mov['cover'] = $ri->saveImage($imdbId.'-cover', $imdb['cover'], $this->imgSavePath); } - + $mov['backdrop'] = 0; if (isset($tmdb['backdrop']) && $tmdb['backdrop'] != '') { $mov['backdrop'] = $ri->saveImage($imdbId.'-backdrop', $tmdb['backdrop'], $this->imgSavePath, 1024, 768); } - + $mov['title'] = ''; - if (isset($tmdb['title']) && $tmdb['title'] != '') { + if (isset($tmdb['title']) && $tmdb['title'] != '') { $mov['title'] = $tmdb['title']; } elseif (isset($imdb['title']) && $imdb['title'] != '') { $mov['title'] = $imdb['title']; @@ -435,13 +435,13 @@ class Movie $mov['rating'] = ''; if (isset($imdb['rating']) && $imdb['rating'] != '') { $mov['rating'] = $imdb['rating']; - } elseif (isset($tmdb['rating']) && $tmdb['rating'] != '') { + } elseif (isset($tmdb['rating']) && $tmdb['rating'] != '') { $mov['rating'] = $tmdb['rating']; } $mov['rating'] = str_replace(',','.',$mov['rating']); - + $mov['tagline'] = ''; - if (isset($tmdb['tagline']) && $tmdb['tagline'] != '') { + if (isset($tmdb['tagline']) && $tmdb['tagline'] != '') { $mov['tagline'] = $tmdb['tagline']; } elseif (isset($imdb['tagline']) && $imdb['tagline'] != '') { $mov['tagline'] = $imdb['tagline']; @@ -449,65 +449,65 @@ class Movie $mov['tagline'] = html_entity_decode($mov['tagline'], ENT_QUOTES, 'UTF-8'); $mov['plot'] = ''; - if (isset($tmdb['plot']) && $tmdb['plot'] != '') { + if (isset($tmdb['plot']) && $tmdb['plot'] != '') { $mov['plot'] = $tmdb['plot']; } elseif (isset($imdb['plot']) && $imdb['plot'] != '') { $mov['plot'] = $imdb['plot']; } $mov['plot'] = html_entity_decode($mov['plot'], ENT_QUOTES, 'UTF-8'); - + $mov['year'] = ''; if (isset($imdb['year']) && $imdb['year'] != '') { $mov['year'] = $imdb['year']; - } elseif (isset($tmdb['year']) && $tmdb['year'] != '') { + } elseif (isset($tmdb['year']) && $tmdb['year'] != '') { $mov['year'] = $tmdb['year']; } $mov['genre'] = ''; if (isset($tmdb['genre']) && $tmdb['genre'] != '') { $mov['genre'] = $tmdb['genre']; - } elseif (isset($imdb['genre']) && $imdb['genre'] != '') { + } elseif (isset($imdb['genre']) && $imdb['genre'] != '') { $mov['genre'] = $imdb['genre']; } if (is_array($mov['genre'])) { $mov['genre'] = implode(', ', array_unique($mov['genre'])); } $mov['genre'] = html_entity_decode($mov['genre'], ENT_QUOTES, 'UTF-8'); - + $mov['director'] = ''; - if (isset($imdb['director']) && $imdb['director'] != '') { + if (isset($imdb['director']) && $imdb['director'] != '') { $mov['director'] = (is_array($imdb['director'])) ? implode(', ', array_unique($imdb['director'])) : $imdb['director']; } $mov['director'] = html_entity_decode($mov['director'], ENT_QUOTES, 'UTF-8'); - + $mov['actors'] = ''; - if (isset($imdb['actors']) && $imdb['actors'] != '') { + if (isset($imdb['actors']) && $imdb['actors'] != '') { $mov['actors'] = (is_array($imdb['actors'])) ? implode(', ', array_unique($imdb['actors'])) : $imdb['actors']; } $mov['actors'] = html_entity_decode($mov['actors'], ENT_QUOTES, 'UTF-8'); - + $mov['language'] = ''; - if (isset($imdb['language']) && $imdb['language'] != '') { + if (isset($imdb['language']) && $imdb['language'] != '') { $mov['language'] = (is_array($imdb['language'])) ? implode(', ', array_unique($imdb['language'])) : $imdb['language']; } $mov['language'] = html_entity_decode($mov['language'], ENT_QUOTES, 'UTF-8'); - $db = new DB(); + $db = new Settings(); $query = sprintf(" - INSERT INTO movieinfo + INSERT INTO movieinfo (imdbID, tmdbID, title, rating, tagline, trailer, plot, year, genre, director, actors, language, cover, backdrop, createddate, updateddate) - VALUES + VALUES (%d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, NOW(), NOW()) ON DUPLICATE KEY UPDATE imdbID=%d, tmdbID=%s, title=%s, rating=%s, tagline=%s, trailer=%s, plot=%s, year=%s, genre=%s, director=%s, actors=%s, language=%s, cover=%d, backdrop=%d, updateddate=NOW()", $mov['imdb_id'], $mov['tmdb_id'], $db->escapeString($mov['title']), $db->escapeString($mov['rating']), $db->escapeString($mov['tagline']), $db->escapeString($mov['trailer']), $db->escapeString($mov['plot']), $db->escapeString($mov['year']), $db->escapeString($mov['genre']), $db->escapeString($mov['director']), $db->escapeString($mov['actors']), $db->escapeString($mov['language']), $mov['cover'], $mov['backdrop'], $mov['imdb_id'], $mov['tmdb_id'], $db->escapeString($mov['title']), $db->escapeString($mov['rating']), $db->escapeString($mov['tagline']), $db->escapeString($mov['trailer']), $db->escapeString($mov['plot']), $db->escapeString($mov['year']), $db->escapeString($mov['genre']), $db->escapeString($mov['director']), $db->escapeString($mov['actors']), $db->escapeString($mov['language']), $mov['cover'], $mov['backdrop']); - + $movieId = $db->queryInsert($query); - + return $movieId; } - + /** * Lookup a movie on tmdb by ID */ @@ -515,7 +515,7 @@ class Movie { $tmdb = new TMDb($this->apikey, $this->lookuplanguage); $lookupId = ($isImdbId) ? 'tt'.$id : $id; - + try { $movie = $tmdb->getMovie($lookupId); } catch (Exception $e) { @@ -534,10 +534,10 @@ class Movie $ret['tagline'] = $movie['tagline']; if (isset($movie['release_date'])) $ret['year'] = date("Y", strtotime($movie['release_date'])); - if (isset($movie['genres']) && sizeof($movie['genres']) > 0) + if (isset($movie['genres']) && sizeof($movie['genres']) > 0) { $genres = array(); - foreach($movie['genres'] as $genre) + foreach($movie['genres'] as $genre) { $genres[] = $genre['name']; } @@ -560,7 +560,7 @@ class Movie return $ret; } - + /** * Search for a movie on tmdb by querystring. */ @@ -573,7 +573,7 @@ class Movie return false; } if (!$movies || !isset($movies['results'])) { return false; } - + $ret = array(); $c=0; foreach($movies['results'] as $movie) @@ -581,11 +581,11 @@ class Movie $c++; if ($c >= $limit) continue; - + $m = $this->fetchTmdbProperties($movie['id'], false); if ($m !== false) $ret[] = $m; - } + } return $ret; } @@ -602,14 +602,14 @@ class Movie 'year' => '/<title>.*?\(.*?(\d{4}).*?<\/title>/iS', 'cover' => '/<a.*?href="\/media\/.*?>\s*<img[^>]*?src="(.*?)"/iS' ); - + $imdb_regex_multi = array( 'genre' => '/<span.*?itemprop=\"genre\">(.*?)<\/span>/iS', 'language' => '/<a.*?href="\/language\/.* itemprop=["\']url["\'].*?>(.*?)<\/a>/iS' ); $buffer = getUrl("http://www.imdb.com/title/tt$imdbId/", 'get', '', '', '', '', '', $this->lookuplanguage); - + // make sure we got some data if ($buffer !== false && strlen($buffer)) { @@ -644,10 +644,10 @@ class Movie if (preg_match_all('/<span.*?itemprop="name".*?>(.*?)<\/span>/is', $hit[1], $results, PREG_PATTERN_ORDER)) { $ret['director'] = $results[1]; - } + } } - - + + //actors if (preg_match('/<h4.*?Stars?:<\/h4>(.*?)<\/div>/is', $buffer, $hit)) { @@ -656,27 +656,27 @@ class Movie $ret['actors'] = $results[1]; } } - + return $ret; } - + return false; - } + } /** * Process all untagged movies to link them to a movieinfo row. */ public function processMovieReleases() { $ret = 0; - $db = new DB(); + $db = new Settings(); $nfo = new Nfo(); - + $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where imdbID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY postdate DESC LIMIT 100", Category::CAT_PARENT_MOVIE)); if ($db->getNumRows($res) > 0) - { + { if ($this->echooutput) echo "MovProc : Processing " . $db->getNumRows($res) . " movie releases\n"; - + while ($arr = $db->getAssocArray($res)) { $imdbID = false; @@ -702,7 +702,7 @@ class Movie { if ($this->echooutput) echo 'MovProc : '.$moviename.' ['.$arr['searchname'].']'."\n"; - + //$buffer = getUrl("https://www.google.com/search?source=ig&hl=en&rlz=&btnG=Google+Search&aq=f&oq=&q=".urlencode($moviename.' site:imdb.com')); $buffer = getUrl("http://www.bing.com/search?&q=".urlencode($moviename.' site:imdb.com')); @@ -710,11 +710,11 @@ class Movie if ($buffer !== false && strlen($buffer)) { $imdbId = $this->parseImdbFromNfo($buffer); - if ($imdbId !== false) + if ($imdbId !== false) { //update release with imdb id $db->queryExec(sprintf("update releases SET imdbID = %s WHERE ID = %d", $db->escapeString($imdbId), $arr["ID"])); - + //check for existing movie entry $movCheck = $this->getMovieInfo($imdbId); if ($movCheck === false || (isset($movCheck['updateddate']) && (time() - strtotime($movCheck['updateddate'])) > 2592000)) @@ -726,12 +726,12 @@ class Movie //no imdb id found, set to all zeros so we dont process again $db->queryExec(sprintf("update releases SET imdbID = %d WHERE ID = %d", 0, $arr["ID"])); } - + } else { //url fetch failed, will try next run } - - + + } else { //no valid movie name found, set to all zeros so we dont process again $db->queryExec(sprintf("update releases SET imdbID = %d WHERE ID = %d", 0, $arr["ID"])); @@ -739,20 +739,20 @@ class Movie } } } - + /** * Strip a movie name from a release. */ public function parseMovieName($releasename) { $cat = new Category; - if (!$cat->isMovieForeign($releasename)) + if (!$cat->isMovieForeign($releasename)) { preg_match('/^(?P<name>.*)[\.\-_\( ](?P<year>19\d{2}|20\d{2})/i', $releasename, $matches); - if (!isset($matches['year'])) + if (!isset($matches['year'])) preg_match('/^(?P<name>.*)[\.\-_ ](?:dvdrip|bdrip|brrip|bluray|hdtv|divx|xvid|proper|repack|real\.proper|sub\.?fix|sub\.?pack|ac3d|unrated|1080i|1080p|720p|810p)/i', $releasename, $matches); - - if (isset($matches['name'])) + + if (isset($matches['name'])) { $name = preg_replace('/\(.*?\)|\.|_/i', ' ', $matches['name']); $year = (isset($matches['year'])) ? ' ('.$matches['year'].')' : ''; @@ -761,27 +761,27 @@ class Movie } return false; } - + /** * Get rows from upcoming table by type. - */ + */ public function getUpcoming($type, $source="rottentomato") { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select * from upcoming where source = %s and typeid = %d", $db->escapeString($source), $type); return $db->queryOneRow($sql); } - + /** * Retrieve upcoming movie data from rottentomatoes API. - */ + */ public function updateUpcoming() { $s = new Sites(); $site = $s->get(); if (isset($site->rottentomatokey)) { - $rt = new RottenTomato($site->rottentomatokey); + $rt = new RottenTomato($site->rottentomatokey); $ret = $rt->getBoxOffice(); if ($ret != "") @@ -804,22 +804,22 @@ class Movie $this->updateInsUpcoming('rottentomato', Movie::SRC_DVD, $ret); } } - + /** * Add/Update upcoming row. - */ + */ public function updateInsUpcoming($source, $type, $info) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("INSERT into upcoming (source,typeID,info,updateddate) VALUES (%s, %d, %s, now()) ON DUPLICATE KEY UPDATE info = %s", $db->escapeString($source), $type, $db->escapeString($info), $db->escapeString($info)); $db->queryInsert($sql); } - + /** * Get list of standard movie genres. - */ + */ public function getGenres() { return array( diff --git a/lib/copy_this/www/lib/music.php b/lib/copy_this/www/lib/music.php index 51a4c3da5..4b78e3fef 100644 --- a/lib/copy_this/www/lib/music.php +++ b/lib/copy_this/www/lib/music.php @@ -34,7 +34,7 @@ class Music */ public function getMusicInfo($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT musicinfo.*, genres.title as genres FROM musicinfo left outer join genres on genres.ID = musicinfo.genreID where musicinfo.ID = %d ", $id)); } @@ -43,7 +43,7 @@ class Music */ public function getMusicInfoByName($artist, $album) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM musicinfo where artist like %s and title like %s", $db->escapeString("%".$artist."%"), $db->escapeString("%".$album."%"))); } @@ -52,7 +52,7 @@ class Music */ public function getRange($start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -67,7 +67,7 @@ class Music */ public function getCount() { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow("select count(ID) as num from musicinfo"); return $res["num"]; } @@ -77,7 +77,7 @@ class Music */ public function getMusicCount($cat, $maxage=-1, $excludedcats=array()) { - $db = new DB(); + $db = new Settings(); $browseby = $this->getBrowseBy(); @@ -128,7 +128,7 @@ class Music */ public function getMusicRange($cat, $start, $num, $orderby, $maxage=-1, $excludedcats=array()) { - $db = new DB(); + $db = new Settings(); $browseby = $this->getBrowseBy(); @@ -258,7 +258,7 @@ class Music */ public function update($id, $title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $year, $tracks, $cover, $genreID) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update musicinfo SET title=%s, asin=%s, url=%s, salesrank=%s, artist=%s, publisher=%s, releasedate='%s', year=%s, tracks=%s, cover=%d, genreID=%d, updateddate=NOW() WHERE ID = %d", $db->escapeString($title), $db->escapeString($asin), $db->escapeString($url), $salesrank, $db->escapeString($artist), $db->escapeString($publisher), $releasedate, $db->escapeString($year), $db->escapeString($tracks), $cover, $genreID, $id)); @@ -269,7 +269,7 @@ class Music */ public function updateMusicInfo($artist, $album, $year) { - $db = new DB(); + $db = new Settings(); $gen = new Genres(); $ri = new ReleaseImage(); @@ -435,7 +435,7 @@ class Music public function processMusicReleases() { $ret = 0; - $db = new DB(); + $db = new Settings(); $numlookedup = 0; $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where musicinfoID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY postdate DESC LIMIT 1000", Category::CAT_PARENT_MUSIC)); @@ -559,7 +559,7 @@ class Music */ public function processMusicReleaseFromMediaInfo() { - $db = new DB(); + $db = new Settings(); $res = $db->query("SELECT r.searchname, ref.releaseID, ref.mediainfo FROM releaseextrafull ref INNER JOIN releases r ON r.ID = ref.releaseID WHERE r.musicinfoID = -2"); $rescount = sizeof($res); @@ -619,7 +619,7 @@ class Music */ public function addUpdateMusicInfo($title, $asin, $url, $salesrank, $artist, $publisher, $releasedate, $review, $year, $genreID, $tracks, $cover) { - $db = new DB(); + $db = new Settings(); if (strlen($year) > 4) { if (preg_match("/\d{4}/", $year, $matches)) diff --git a/lib/copy_this/www/lib/nfo.php b/lib/copy_this/www/lib/nfo.php index 3beac6e3e..48be1c985 100644 --- a/lib/copy_this/www/lib/nfo.php +++ b/lib/copy_this/www/lib/nfo.php @@ -45,19 +45,19 @@ class Nfo * @access public * @var Defines the maximum size a single segment can be before we can rule * after a binary has matched a releaseregex - */ + */ const NFO_MAX_FILESIZE = 50000; /** * @access public * @var Database flag for no NFO found - */ + */ const FLAG_NFO_MISSING = -1; /** * @access public * @var Database flag NFO pending scan - */ + */ const FLAG_NFO_PENDING = 0; /** @@ -77,26 +77,26 @@ class Nfo // - 1 segment // - within byte size // - + // Array of all possible matches to return $nfo_idx = array(); - + // Search for all entries that have a single segment if (empty($nzbInfo->segmentfiles)) // Nothing to Return return array(); - + // Fetch Meta Information if (isset($nzbInfo->metadata['name'])) $name = $nzbInfo->metadata['name']; else $name = ""; - + $unordered_list=array(); foreach($nzbInfo->segmentfiles as $segment){ if ($segment['filesize'] > Nfo::NFO_MAX_FILESIZE) continue; - + $unordered_list[] = array( "name" => $name, "subject" => $segment['subject'], @@ -105,7 +105,7 @@ class Nfo "groups" => $segment['groups'] ); } - + // // Filter built list above based on subject line info // hence... eliminate par2, nzb ... etc files @@ -121,7 +121,7 @@ class Nfo $nfo_idx[]=$n; } } - + // Handle Releases with Obfuscation // Releases titled: f4ca0f95896da1d41254bf49791a86a2 if($this->use_obfuscated) @@ -136,7 +136,7 @@ class Nfo $nfo_idx[]=$n; } } - + // Fuzzy Parsing sees if it can identify other possible nfo's however // they are appended to the end of the list obvious nfo's are always // processed first @@ -147,7 +147,7 @@ class Nfo $nfo_idx[]=$n; } } - + // Return array of matched content in order (aprox) // from very possible to... possible... return $nfo_idx; @@ -190,7 +190,7 @@ class Nfo private function is_sfv(&$raw){ // scan a content and return true if it is detected to be // an sfv file, otherwise return false - + // First we identify acceptable sfv lines, anything that // does not match against the below causes this function to // exit gracefully and report that were not dealing with @@ -223,8 +223,8 @@ class Nfo // the release id; In the event we fetch the data and deem // 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) ". @@ -297,17 +297,17 @@ class Nfo // ... // The function strips indexes that appear invalid // and stores the most ideal match per release - + $parsed_blob = array(); $parsed_meta = array(); - + foreach($nfometa as $uid => $info){ $ideal = Null; $tossed = 0; $total = count($info); foreach($info as $idx => $entry){ // Save first 'valid' entry - + // Some simple checks right off the top... if there is // no blob or the data failed to fetch, we can rule // this entry out right away @@ -323,14 +323,14 @@ class Nfo if($this->verbose) echo '-'; continue; } - + // Eliminate detected xml (usually nzb) files if(preg_match('/xmlns[^=]*="[^"]*"/i', $nfoblob[$uid][$idx]) || preg_match("/(\<\?xml[\d\D]*\?\>)/i", $nfoblob[$uid][$idx])){ if($this->verbose) echo '-'; continue; } - + // We do not want to pick up sfv files if($this->is_sfv($nfoblob[$uid][$idx])){ if($this->verbose) echo '-'; @@ -348,7 +348,7 @@ class Nfo $ideal = $idx; break; } - + if($ideal !== Null){ // An ideal match was found $parsed_blob[(string)$uid] = $nfoblob[$uid][$ideal]; @@ -360,14 +360,14 @@ class Nfo unset($parsed_meta[(string)$uid]); } } - + // perform swap with new parsed data by elminating the array containing // the possible matches with the absolute match itself... // no longer is anyone dealing with an array of array after calling // this function $nfoblob = $parsed_blob; $nfometa = $parsed_meta; - + return count($nfoblob); } @@ -407,7 +407,7 @@ class Nfo // ... // ) $nntp = new Nntp(); - + // Connect to server (we throw an exception if we fail) which // is caught upstairs with the nfo_grab() function // no error handling is needed here @@ -419,7 +419,7 @@ class Nfo foreach($match["groups"] as $group){ // Don not try other groups if we already got it if($fetched)break; - + // Select the group and then attempt to fetch the article $blob = $nntp->getMessages($group, $match["segment"], false); if ($blob === false){ @@ -430,7 +430,7 @@ class Nfo // of the same thing $fetched = true; if($this->verbose) echo '.'; - + // Update blob with decrypted version and store if ($this->is_binary($blob)){ // Binary data is not acceptable, we only @@ -473,7 +473,7 @@ class Nfo } // Restore handler as any future errors really are... code errors :) restore_error_handler(); - + if($retries>0){ foreach ($_blobhash as $k => $v) $blobhash[(string)$k]=$v; @@ -489,14 +489,14 @@ 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; // Build NFO List $nfometa = array(); - + // Missing NFO Query (oldest first so they don't expire on us) $mnfo = "SELECT ID,guid, name FROM releases r ". "WHERE r.releasenfoID = ".Nfo::FLAG_NFO_PENDING. @@ -515,7 +515,7 @@ class Nfo $this->setNfoMissing($r["ID"]); continue; } - + $nzbInfo = new NzbInfo(); if (!$nzbInfo->loadFromFile($nzbfile)) { @@ -524,12 +524,12 @@ class Nfo $this->setNfoMissing($r["ID"]); continue; } - + $total+=1; - + $filename = basename($nzbfile); if($this->verbose) echo sprintf("NfoProc : Scanning %s - ", $r["name"]); - + $matches = $this->nfo_scan($nzbInfo); unset($nzbInfo); if(is_array($matches)){ @@ -545,10 +545,10 @@ class Nfo } if($this->verbose) echo count($matches)." possible nfo(s).\n"; $processed++; - + // Hash Matches by Release ID $nfometa[(string)$r["ID"]] = $matches; - + if(!($processed%$batch)) { $nfoblob = array(); @@ -561,7 +561,7 @@ class Nfo $this->store_blob($nfometa, $nfoblob, $removed); } if($this->verbose) echo "\n"; - + // Reset nfo list array $nfometa = array(); } @@ -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 ". @@ -620,7 +620,7 @@ class Nfo } return false; } - + /** * Process Nfo's */ diff --git a/lib/copy_this/www/lib/nzb.php b/lib/copy_this/www/lib/nzb.php index 97fb4aae3..6c64cb41f 100644 --- a/lib/copy_this/www/lib/nzb.php +++ b/lib/copy_this/www/lib/nzb.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/site.php"); require_once(WWW_DIR . "/lib/category.php"); require_once(WWW_DIR . "../misc/update_scripts/nix_scripts/tmux/lib/Enzebe.php"); @@ -15,7 +15,7 @@ class NZB */ function writeNZBforReleaseId($relid, $name, $catId, $path) { - $db = new DB(); + $db = new Settings(); $cat = new Category(); $catrow = $cat->getById($catId); $site = new Sites(); diff --git a/lib/copy_this/www/lib/parsing.php b/lib/copy_this/www/lib/parsing.php index f893e9408..014f82e8f 100644 --- a/lib/copy_this/www/lib/parsing.php +++ b/lib/copy_this/www/lib/parsing.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/site.php"); require_once(WWW_DIR . "/lib/category.php"); require_once(WWW_DIR . "/lib/movie.php"); @@ -42,7 +42,7 @@ class Parsing public function process() { - $db = new DB(); + $db = new Settings(); // Default query for both full db and last 4 hours. $sql = "SELECT r.searchname, r.name, r.fromname, r.ID as RID, r.categoryID, r.guid, r.postdate, @@ -819,7 +819,7 @@ class Parsing echo " Status: Release changed\n\n"; } if (!$this->echoonly) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releases SET name = %s, searchname = %s, categoryID = %d, imdbID = NULL, rageID = -1, bookinfoID = NULL, musicinfoID = NULL, consoleinfoID = NULL WHERE releases.ID = %d", $db->escapeString($name), $db->escapeString($searchname), $categoryID, $rel['RID'])); } $this->numupdated++; diff --git a/lib/copy_this/www/lib/predb.php b/lib/copy_this/www/lib/predb.php index cf83361fd..5cee12d65 100644 --- a/lib/copy_this/www/lib/predb.php +++ b/lib/copy_this/www/lib/predb.php @@ -21,7 +21,7 @@ class PreDB */ public function getByID($preID) { - $db = new DB(); + $db = new Settings(); $predbQuery = $db->query(sprintf("SELECT * FROM predb WHERE ID = %s LIMIT %d", $preID, 1)); return isset($predbQuery[0]) ? $predbQuery[0] : false; @@ -32,7 +32,7 @@ class PreDB */ public function getByDirname($dirname) { - $db = new DB(); + $db = new Settings(); $dirname = str_replace(' ', '_', $dirname); $predbQuery = $db->query(sprintf("SELECT * FROM predb WHERE dirname = %s LIMIT %d", $db->escapeString($dirname), 1)); @@ -57,12 +57,12 @@ class PreDB } } } - - $db = new DB(); - + + $db = new Settings(); + $dirname = empty($dirname) ? '' : sprintf("WHERE dirname LIKE %s", $db->escapeString('%'.$dirname.'%')); $category = empty($category) ? '' : sprintf((empty($dirname) ? 'WHERE' : ' AND')." category = %s", $db->escapeString($category)); - + $predbQuery = $db->queryOneRow(sprintf('SELECT COUNT(ID) AS num FROM predb %s %s', $dirname, $category), true); return $predbQuery['num']; @@ -86,9 +86,9 @@ class PreDB } } } - - $db = new DB(); - + + $db = new Settings(); + $dirname = str_replace(' ', '%', $dirname); $dirname = empty($dirname) ? '' : sprintf('WHERE dirname LIKE %s', $db->escapeString('%'.$dirname.'%')); $category = empty($category) ? '' : sprintf((empty($dirname) ? 'WHERE' : ' AND')." category = %s", $db->escapeString($category)); @@ -103,8 +103,8 @@ class PreDB */ public function processReleases($daysback = 3) { - $db = new DB(); - + $db = new Settings(); + if ($this->echooutput) echo "Predb : Updating releases with pre data\n"; @@ -116,19 +116,19 @@ class PreDB $sql = sprintf("SELECT ID FROM predb WHERE dirname = %s LIMIT 1", $db->escapeString($arr['searchname'])); $predbQuery = $db->queryOneRow($sql); - if($predbQuery) + if($predbQuery) { $db->queryExec(sprintf('UPDATE releases SET preID = %d WHERE ID = %d', $predbQuery['ID'], $arr['ID'])); - + $matched++; } } - + if($this->echooutput) echo "Predb : Matched pre data to ".$matched." releases\n"; - + } - + /** * Add/Update predb row. */ @@ -148,31 +148,31 @@ class PreDB (!empty($preArray['filecount']) ? (int) $preArray['filecount'] : 0), (!empty($preArray['nuke_filename']) ? $db->escapeString($preArray['nuke_filename']) : '""') )); - - //$newCheck = mysql_affected_rows(); + + //$newCheck = mysql_affected_rows(); //if($this->echooutput && $newCheck > 0) // echo "!PRE: [".date('Y-m-d H:i:s', $preArray['ctime']).'] - [ '.$preArray['dirname'].' ] - ['.$preArray['category']."]\n"; - + return true; } - else + else { $db->queryExec(sprintf("update predb SET nuketype=%s, nukereason=%s, nuketime=%d WHERE dirname = %s", - $db->escapeString($preArray['category']), + $db->escapeString($preArray['category']), (!empty($preArray['nuke_filename']) ? $db->escapeString($preArray['nuke_filename']) : '""'), $preArray['ctime'], $db->escapeString($preArray['dirname']) )); - + //$newCheck = mysql_affected_rows(); //if($this->echooutput && $newCheck > 0) // echo $preArray['category'].': ['.date('Y-m-d H:i:s', $preArray['ctime']).'] - [ '.$preArray['dirname'].' ] - ['.$preArray['nuke_filename']."]\n"; - + return true; } - + return false; } @@ -180,7 +180,7 @@ class PreDB * XOR decode a string with a key. */ function xorDecode($subject, $nzprekey) - { + { return ($nzprekey ^ base64_decode($subject)); } @@ -200,19 +200,19 @@ class PreDB public function nzpreUpdate() { require_once(WWW_DIR."/lib/nntp.php"); - + $s = new Sites(); $site = $s->get(); - + if(empty($site->nzpregroup) || empty($site->nzpresubject) || empty($site->nzpreposter) || empty($site->nzprefield) || empty($site->nzprekey)) return false; - - if($this->echooutput) + + if($this->echooutput) echo "Predb : Checking for new pre data "; - - $db = new DB(); + + $db = new Settings(); $nntp = new Nntp(); - + if(!$nntp->doConnect()) { echo "Failed to get NNTP connection\n"; return false; @@ -229,18 +229,18 @@ class PreDB echo "Predb : Error ".$ret->getMessage()."\n"; return false; } - + $added_updated = 0; $nzprekey = $site->nzprekey; while(strlen($nzprekey) < 1024) $nzprekey = $nzprekey.$nzprekey; - + $cnt = !empty($site->nzprearticles) ? $site->nzprearticles : 500; foreach($groupMsgs as $groupMsg) { if ($cnt%50==0 && $cnt != 0 && $this->echooutput) echo $cnt.".."; $cnt--; - + if(preg_match('/^'.$site->nzpresubject.'$/', $groupMsg['Subject']) && preg_match('/^'.$site->nzpreposter.'$/', $groupMsg['From'])) { $ret = $msgHeader = $nntp->getHeader($groupMsg['Message-ID']); if(PEAR::isError($ret)) @@ -255,7 +255,7 @@ class PreDB $added_updated++; } } - + break; } } @@ -263,8 +263,8 @@ class PreDB } $nntp->disconnect(); - - if($this->echooutput) + + if($this->echooutput) echo "\nPredb : Added/Updated ".$added_updated." records\n"; } } diff --git a/lib/copy_this/www/lib/releasecomments.php b/lib/copy_this/www/lib/releasecomments.php index 05ddb25bc..71d1ba3ab 100644 --- a/lib/copy_this/www/lib/releasecomments.php +++ b/lib/copy_this/www/lib/releasecomments.php @@ -6,40 +6,40 @@ require_once(WWW_DIR."/lib/site.php"); * This class handles storage and retrieval of release comments. */ class ReleaseComments -{ +{ /** * Get a comment by ID. */ public function getCommentById($id) - { - $db = new DB(); - return $db->queryOneRow(sprintf("SELECT * FROM releasecomment WHERE ID = %d", $id)); + { + $db = new Settings(); + return $db->queryOneRow(sprintf("SELECT * FROM releasecomment WHERE ID = %d", $id)); } /** * Get all comments for a GID. */ public function getCommentsByGid($gid) - { - $db = new DB(); - 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 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))); + { + $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 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))); } /** * Get all comments for a release.GUID. */ public function getCommentsByGuid($guid) - { - $db = new DB(); - 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))); + { + $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))); } /** * Get all count of all comments. */ 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 @@ -70,7 +70,7 @@ class ReleaseComments if(count($clause)) $q .= " WHERE ".implode(" AND ", $clause); - $res = $db->queryOneRow($q); + $res = $db->queryOneRow($q); return $res["num"]; } @@ -78,8 +78,8 @@ class ReleaseComments * Delete a comment. */ public function deleteComment($id) - { - $db = new DB(); + { + $db = new Settings(); $res = $this->getCommentById($id); if ($res) { @@ -87,13 +87,13 @@ class ReleaseComments $this->updateReleaseCommentCount($res["gid"]); } } - + /** * Delete all comments for a release.ID. */ public function deleteCommentsForRelease($id) - { - $db = new DB(); + { + $db = new Settings(); $res = $this->getCommentById($id); if ($res) { @@ -101,14 +101,14 @@ class ReleaseComments $this->updateReleaseCommentCount($res["gid"]); } } - + /** * Delete all comments for a users.ID. */ public function deleteCommentsForUser($id) - { - $db = new DB(); - + { + $db = new Settings(); + $numcomments = $this->getCommentCountForUser($id); if ($numcomments > 0) { @@ -129,67 +129,67 @@ class ReleaseComments if(strlen(trim($text)) == 0) return false; - $db = new DB(); - + $db = new Settings(); + $site = new Sites(); $s = $site->get(); if ($s->storeuserips != "1") - $host = ""; - - $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (releaseID, gid, text, userID, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $db->escapeString($gid), $db->escapeString($text), $userid, $db->escapeString($host))); - $this->updateReleaseCommentCount($gid); + $host = ""; + + $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (releaseID, gid, text, userID, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $db->escapeString($gid), $db->escapeString($text), $userid, $db->escapeString($host))); + $this->updateReleaseCommentCount($gid); return $comid; } - + /** * Get releasecomment rows by limit. */ public function getCommentsRange($start, $num) - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - + $sql = "SELECT rc.ID, userID, guid, 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 (userID IN (SELECT id FROM users) OR rc.username IS NOT NULL) ORDER BY createddate DESC ".$limit; - return $db->query($sql); + return $db->query($sql); } /** * Update the denormalised count of comments for a release. */ 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) )); + WHERE releases.gid = %s", $db->escapeString($gid) )); } - + /** * Get a count of all comments for a user. */ public function getCommentCountForUser($uid) - { - $db = new DB(); - $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releasecomment WHERE userID = %d AND isvisible = 1", $uid)); + { + $db = new Settings(); + $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releasecomment WHERE userID = %d AND isvisible = 1", $uid)); return $res["num"]; } - + /** * Get comments for a user by limit. */ public function getCommentsForUserRange($uid, $start, $num) - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - - return $db->query(sprintf("SELECT releasecomment.*, r.guid, r.searchname, users.username FROM releasecomment INNER JOIN releases r ON r.ID = releasecomment.releaseID LEFT OUTER JOIN users ON users.ID = releasecomment.userID WHERE userID = %d ORDER BY releasecomment.createddate DESC ".$limit, $uid)); + + return $db->query(sprintf("SELECT releasecomment.*, r.guid, r.searchname, users.username FROM releasecomment INNER JOIN releases r ON r.ID = releasecomment.releaseID LEFT OUTER JOIN users ON users.ID = releasecomment.userID WHERE userID = %d ORDER BY releasecomment.createddate DESC ".$limit, $uid)); } } diff --git a/lib/copy_this/www/lib/releaseextra.php b/lib/copy_this/www/lib/releaseextra.php index a8b3e9693..36d77c2b5 100644 --- a/lib/copy_this/www/lib/releaseextra.php +++ b/lib/copy_this/www/lib/releaseextra.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/util.php"); /** @@ -67,42 +67,42 @@ class ReleaseExtra public function getVideo($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releasevideo where releaseID = %d", $id)); } 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 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 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 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)); @@ -214,7 +214,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) @@ -243,7 +243,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) @@ -263,7 +263,7 @@ class ReleaseExtra public function addSubs($releaseID, $subsID, $subslanguage) { - $db = new DB(); + $db = new Settings(); $row = $this->getSubs($releaseID); if ($row) return -1; @@ -275,21 +275,21 @@ class ReleaseExtra public function getFull($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releaseextrafull where releaseID = %d", $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; diff --git a/lib/copy_this/www/lib/releasefiles.php b/lib/copy_this/www/lib/releasefiles.php index ec95fb823..ac433884e 100644 --- a/lib/copy_this/www/lib/releasefiles.php +++ b/lib/copy_this/www/lib/releasefiles.php @@ -11,7 +11,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)); } @@ -20,7 +20,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))); } @@ -29,7 +29,7 @@ class ReleaseFiles */ public function delete($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from releasefiles where releaseID = %d", $id)); } @@ -38,7 +38,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); } diff --git a/lib/copy_this/www/lib/releaseimage.php b/lib/copy_this/www/lib/releaseimage.php index 3d7e123fd..b663a04e8 100644 --- a/lib/copy_this/www/lib/releaseimage.php +++ b/lib/copy_this/www/lib/releaseimage.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/util.php"); /** diff --git a/lib/copy_this/www/lib/releaseregex.php b/lib/copy_this/www/lib/releaseregex.php index 1c25d6191..dd0c8045b 100644 --- a/lib/copy_this/www/lib/releaseregex.php +++ b/lib/copy_this/www/lib/releaseregex.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/binaries.php"); require_once(WWW_DIR . "/lib/groups.php"); require_once(WWW_DIR . "/lib/nntp.php"); @@ -25,7 +25,7 @@ class ReleaseRegex if (!empty($this->regexes)) return $this->regexes; - $db = new DB(); + $db = new Settings(); $where = ""; if ($activeonly) @@ -68,7 +68,7 @@ class ReleaseRegex public function getGroupsForSelect() { - $db = new DB(); + $db = new Settings(); $categories = $db->query("SELECT distinct coalesce(groupname,'all') as groupname from releaseregex order by groupname "); $temp_array = array(); @@ -85,7 +85,7 @@ class ReleaseRegex */ public function getByID($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from releaseregex where ID = %d ", $id)); } @@ -115,7 +115,7 @@ class ReleaseRegex */ public function delete($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE from releaseregex where ID = %d", $id)); } @@ -125,7 +125,7 @@ class ReleaseRegex */ public function update($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -150,7 +150,7 @@ class ReleaseRegex */ public function add($regex) { - $db = new DB(); + $db = new Settings(); $groupname = $regex["groupname"]; if ($groupname == "") @@ -178,7 +178,7 @@ class ReleaseRegex $outcome = @preg_match($regexArr["regex"], $binarySubject, $matches); if ($outcome === false) { echo "ERROR: " . ($regexArr["ID"] < 10000 ? "System" : "Custom") . " release regex '" . $regexArr["ID"] . "' is not a valid regex.\n"; - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releaseregex set status=0 where ID = %d and status=1", $regexArr["ID"])); return $ret; @@ -309,7 +309,7 @@ class ReleaseRegex public function fetchTestBinaries($groupname, $numarticles, $clearexistingbins) { - $db = new DB(); + $db = new Settings(); $nntp = new Nntp(); $binaries = new Binaries(); $groups = new Groups(); diff --git a/lib/copy_this/www/lib/releases.php b/lib/copy_this/www/lib/releases.php index 467026d56..1c1921860 100644 --- a/lib/copy_this/www/lib/releases.php +++ b/lib/copy_this/www/lib/releases.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/page.php"); require_once(WWW_DIR . "/lib/users.php"); require_once(WWW_DIR . "/lib/releaseregex.php"); @@ -85,7 +85,7 @@ class Releases */ public function getByNames($names) { - $db = new DB(); + $db = new Settings(); $nsql = "1=2"; if (count($names) > 0) { @@ -119,7 +119,7 @@ class Releases */ public function getCount() { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow("select count(ID) as num from releases"); return $res["num"]; @@ -130,7 +130,7 @@ class Releases */ public function getRange($start, $num) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -145,7 +145,7 @@ class Releases */ public function getPreviewCount($previewtype, $cat) { - $db = new DB(); + $db = new Settings(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -180,7 +180,7 @@ class Releases */ public function getPreviewRange($previewtype, $cat, $start, $num) { - $db = new DB(); + $db = new Settings(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -220,7 +220,7 @@ class Releases */ public function getBrowseCount($cat, $maxage = -1, $excludedcats = array(), $grp = array()) { - $db = new DB(); + $db = new Settings(); $catsrch = ""; if (count($cat) > 0 && $cat[0] != -1) { @@ -273,7 +273,7 @@ class Releases */ public function getBrowseRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = array(), $grp = array()) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -383,7 +383,7 @@ class Releases */ public function getForExport($postfrom, $postto, $group, $cat) { - $db = new DB(); + $db = new Settings(); if ($postfrom != "") { $dateparts = explode("/", $postfrom); if (count($dateparts) == 3) @@ -418,7 +418,7 @@ class Releases */ public function getEarliestUsenetPostDate() { - $db = new DB(); + $db = new Settings(); $row = $db->queryOneRow("SELECT DATE_FORMAT(min(postdate), '%d/%m/%Y') as postdate from releases"); return $row["postdate"]; @@ -429,7 +429,7 @@ class Releases */ public function getLatestUsenetPostDate() { - $db = new DB(); + $db = new Settings(); $row = $db->queryOneRow("SELECT DATE_FORMAT(max(postdate), '%d/%m/%Y') as postdate from releases"); return $row["postdate"]; @@ -440,7 +440,7 @@ class Releases */ public function getReleasedGroupsForSelect($blnIncludeAll = true) { - $db = new DB(); + $db = new Settings(); $groups = $db->query("select distinct groups.ID, groups.name from releases inner join groups on groups.ID = releases.groupID"); $temp_array = array(); @@ -458,7 +458,7 @@ class Releases */ public function getRss($cat, $num, $uid = 0, $rageid, $anidbid, $airdate = -1) { - $db = new DB(); + $db = new Settings(); $limit = " LIMIT 0," . ($num > 100 ? 100 : $num); @@ -505,7 +505,7 @@ class Releases */ public function getShowsRss($num, $uid = 0, $excludedcats = array(), $airdate = -1) { - $db = new DB(); + $db = new Settings(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -555,7 +555,7 @@ class Releases */ public function getMyMoviesRss($num, $uid = 0, $excludedcats = array()) { - $db = new DB(); + $db = new Settings(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -597,7 +597,7 @@ class Releases */ public function getShowsRange($usershows, $start, $num, $orderby, $maxage = -1, $excludedcats = array()) { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -637,7 +637,7 @@ class Releases */ public function getShowsCount($usershows, $maxage = -1, $excludedcats = array()) { - $db = new DB(); + $db = new Settings(); $exccatlist = ""; if (count($excludedcats) > 0) @@ -671,7 +671,7 @@ class Releases */ public function delete($id, $isGuid = false) { - $db = new DB(); + $db = new Settings(); $users = new Users(); $s = new Sites(); $nfo = new Nfo(); @@ -732,7 +732,7 @@ class Releases */ public function deleteSingle($guid, $id, $nzb, $releaseImage) { - $db = new DB(); + $db = new Settings(); $releaseImage = new ReleaseImage(); // Delete NZB from disk. $nzbPath = $nzb->getNZBPath($guid); @@ -776,7 +776,7 @@ class Releases */ public function update($id, $name, $searchname, $fromname, $category, $parts, $grabs, $size, $posteddate, $addeddate, $rageid, $seriesfull, $season, $episode, $imdbid, $anidbid, $tvdbid, $consoleinfoid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releases set name=%s, searchname=%s, fromname=%s, categoryID=%d, totalpart=%d, grabs=%d, size=%s, postdate=%s, adddate=%s, rageID=%d, seriesfull=%s, season=%s, episode=%s, imdbID=%d, anidbID=%d, tvdbID=%d,consoleinfoID=%d where id = %d", $db->escapeString($name), $db->escapeString($searchname), $db->escapeString($fromname), $category, $parts, $grabs, $db->escapeString($size), $db->escapeString($posteddate), $db->escapeString($addeddate), $rageid, $db->escapeString($seriesfull), $db->escapeString($season), $db->escapeString($episode), $imdbid, $anidbid, $tvdbid, $consoleinfoid, $id @@ -800,7 +800,7 @@ class Releases 'imdbID' => $imdbid ); - $db = new DB(); + $db = new Settings(); $updateSql = array(); foreach ($update as $updk => $updv) { if ($updv != '') @@ -827,7 +827,7 @@ class Releases */ public function updateHasPreview($guid, $haspreview) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releases set haspreview = %d where guid = %s", $haspreview, $db->escapeString($guid))); } @@ -858,7 +858,7 @@ class Releases // // Search using MySQL // - $db = new DB(); + $db = new Settings(); $catsrch = ""; $usecatindex = ""; @@ -972,7 +972,7 @@ class Releases return $results; } - $db = new DB(); + $db = new Settings(); if ($rageId != "-1") $rageId = sprintf(" and rageID = %d ", $rageId); @@ -1076,7 +1076,7 @@ class Releases return $results; } - $db = new DB(); + $db = new Settings(); $anidbID = ($anidbID > -1) ? sprintf(" AND anidbID = %d ", $anidbID) : ''; @@ -1142,7 +1142,7 @@ class Releases return $results; } - $db = new DB(); + $db = new Settings(); $searchsql = ""; if ($artist != "") @@ -1222,7 +1222,7 @@ class Releases return $results; } - $db = new DB(); + $db = new Settings(); $searchsql = ""; if ($author != "") @@ -1262,7 +1262,7 @@ class Releases return $results; } - $db = new DB(); + $db = new Settings(); if ($imdbId != "-1" && is_numeric($imdbId)) { //pad id with zeros just in case @@ -1383,7 +1383,7 @@ class Releases */ public function getByGuid($guid) { - $db = new DB(); + $db = new Settings(); if (is_array($guid)) { $tmpguids = array(); foreach ($guid as $g) @@ -1433,7 +1433,7 @@ class Releases */ public function removeRageIdFromReleases($rageid) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("select count(ID) as num from releases where rageID = %d", $rageid)); $ret = $res["num"]; $db->queryExec(sprintf("update releases set rageID = -1, seriesfull = null, season = null, episode = null where rageID = %d", $rageid)); @@ -1446,7 +1446,7 @@ class Releases */ public function removeThetvdbIdFromReleases($tvdbID) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releases WHERE tvdbID = %d", $tvdbID)); $ret = $res["num"]; $res = $db->queryExec(sprintf("update releases SET tvdbID = -1 where tvdbID = %d", $tvdbID)); @@ -1456,7 +1456,7 @@ class Releases public function removeAnidbIdFromReleases($anidbID) { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow(sprintf("SELECT count(ID) AS num FROM releases WHERE anidbID = %d", $anidbID)); $ret = $res["num"]; $db->queryExec(sprintf("update releases SET anidbID = -1, episode = null, tvtitle = null, tvairdate = null where anidbID = %d", $anidbID)); @@ -1466,14 +1466,14 @@ class Releases public function getById($id) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select releases.*, groups.name as group_name from releases left outer join groups on groups.ID = releases.groupID where releases.ID = %d ", $id)); } public function getReleaseNfo($id, $incnfo = true) { - $db = new DB(); + $db = new Settings(); $selnfo = ($incnfo) ? ', uncompress(nfo) as nfo' : ''; return $db->queryOneRow(sprintf("SELECT ID, releaseID" . $selnfo . " FROM releasenfo where releaseID = %d AND nfo IS NOT NULL", $id)); @@ -1481,7 +1481,7 @@ class Releases public function updateGrab($guid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update releases set grabs = grabs + 1 where guid = %s", $db->escapeString($guid))); } @@ -1872,7 +1872,7 @@ class Releases public function insertRelease($cleanRelName, $cleanedName, $parts, $group, $guid, $catId, $regexID, $date, $fromname, $reqID, $site, $nzbstatus, $isrenamed, $isReqID, $prehashID) { - $db = new DB(); + $db = new Settings(); if ($regexID == "") $regexID = " null "; @@ -1953,7 +1953,7 @@ class Releases if (preg_match('/\/\*\$Rev: (\d{3,4})/i', $regfile, $matches)) { $serverrev = intval($matches[1]); if ($serverrev > $rev) { - $db = new DB(); + $db = new Settings(); $site = new Sites; $queries = explode(";", $regfile); @@ -1980,7 +1980,7 @@ class Releases public function getTopDownloads() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT ID, searchname, guid, adddate, grabs FROM releases where grabs > 0 @@ -1991,7 +1991,7 @@ class Releases public function getTopComments() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT ID, guid, searchname, adddate, comments FROM releases where comments > 0 @@ -2002,7 +2002,7 @@ class Releases public function getRecentlyAdded() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT concat(cp.title, ' > ', category.title) as title, COUNT(*) AS count FROM category @@ -2021,7 +2021,7 @@ class Releases */ public function getNewestMovies() { - $db = new DB(); + $db = new Settings(); return $db->query( "SELECT DISTINCT (a.imdbID), @@ -2047,7 +2047,7 @@ class Releases */ public function getNewestConsole() { - $db = new DB(); + $db = new Settings(); return $db->query( "SELECT DISTINCT (a.consoleinfoID), @@ -2073,7 +2073,7 @@ class Releases */ public function getNewestGames() { - $db = new DB(); + $db = new Settings(); return $db->query( "SELECT DISTINCT (a.gamesinfo_id), @@ -2099,7 +2099,7 @@ class Releases */ public function getNewestMP3s() { - $db = new DB(); + $db = new Settings(); return $db->query( "SELECT DISTINCT (a.musicinfoID), @@ -2125,7 +2125,7 @@ class Releases */ public function getNewestBooks() { - $db = new DB(); + $db = new Settings(); return $db->query( "SELECT DISTINCT (a.bookinfoID), diff --git a/lib/copy_this/www/lib/site.php b/lib/copy_this/www/lib/site.php index 3135a5b6b..837e5e8c2 100644 --- a/lib/copy_this/www/lib/site.php +++ b/lib/copy_this/www/lib/site.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/framework/cache.php"); class Sites @@ -25,7 +25,7 @@ class Sites public function update($form) { - $db = new DB(); + $db = new Settings(); $site = $this->row2Object($form); if (substr($site->nzbpath, strlen($site->nzbpath) - 1) != '/') @@ -78,7 +78,7 @@ class Sites $cache->delete($sql); } - $db = new DB(); + $db = new Settings(); $rows = $db->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); if ($rows === false) @@ -130,7 +130,7 @@ class Sites public function updateItem($setting, $value) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("update site set value = %s where setting = %s", $db->escapeString($value), $db->escapeString($setting)); return $db->queryExec($sql); diff --git a/lib/copy_this/www/lib/sphinx.php b/lib/copy_this/www/lib/sphinx.php index 8f64c217a..ed1ebc6d0 100644 --- a/lib/copy_this/www/lib/sphinx.php +++ b/lib/copy_this/www/lib/sphinx.php @@ -35,17 +35,17 @@ class Sphinx function __construct() { $s = new Sites; - + $this->site = $s->get(); $this->nzb = new Nzb; $this->indexes = array("releases", "releasefiles", "releasenfo", "nzbs", "predb"); } - + /** * Runs a Sphinx command. This suppresses various lines of output from the * Sphinx binaries. - * + * * @param string $cmd The command to run. * @param boolean $stdout If ``true`` (default), print to stdout. * @return array An array of lines returned from the popen process. @@ -61,7 +61,7 @@ class Sphinx { continue; } - + $output[] = $line; if ($stdout) { printf("%s", $line); @@ -69,7 +69,7 @@ class Sphinx } return $output; } - + /** * Returns the next merge date as a timestamp. This value is suitable for * use as the `nextmergedate` value in the database. @@ -78,7 +78,7 @@ class Sphinx { return strtotime("tomorrow ".$this->site->sphinxmergefreq); } - + /** * Returns the next rebuild date as a timestamp. This value is suitable * for use as the `nextrebuilddate` value in the database. @@ -95,7 +95,7 @@ class Sphinx } return $rebuildDate; } - + /** * Sets the values for ``lastrebuilddate`` and ``nextrebuilddate`` in the * database for the given ``$index``. @@ -110,19 +110,19 @@ class Sphinx // This is an invalid index or isn't enabled return false; } - - $db = new DB(); - + + $db = new Settings(); + if ($lastRebuildDate == 0) { $lastRebuildDate = "NOW()"; } else { $lastRebuildDate = sprintf("FROM_UNIXTIME(%d)", $lastRebuildDate); } - + $index = $db->escapeString($index); $nextRebuildDate = sprintf("FROM_UNIXTIME(%d)", $this->getNextRebuildDate()); - + $sql = "UPDATE sphinx " . "SET lastrebuilddate = %s, " . "nextrebuilddate = %s " @@ -131,7 +131,7 @@ class Sphinx $index)); return true; } - + /** * Sets the value for ``lastmergedate`` and ``nextmergedate`` in the * database for the given ``$index``. If ``$lastMergedDate`` is supplied @@ -148,19 +148,19 @@ class Sphinx // This is an invalid index or isn't enabled return false; } - - $db = new DB(); - + + $db = new Settings(); + if ($lastMergedDate == 0) { $lastMergedDate = "NOW()"; } else { $lastMergedDate = sprintf("FROM_UNIXTIME(%d)", $lastMergedDate); } - + $index = $db->escapeString($index); $nextMergeDate = sprintf("FROM_UNIXTIME(%d)", $this->getNextMergeDate()); - + $sql = "UPDATE sphinx " . "SET lastmergedate = %s, " . "nextmergedate = %s " @@ -169,11 +169,11 @@ class Sphinx $index)); return true; } - + /** * Updates the given index $index. If $full is `true`, then the * 'main' index is updated, otherwise the 'delta' index is updated. - * + * * @param string $index * @param boolean $full * @return null @@ -185,17 +185,17 @@ class Sphinx // This is an invalid index or isn't enabled return false; } - + if (!$full) { // We're doing a delta update instead $index .= "_delta"; } - + // Path to `indexer` binary $indexer = $this->getSphinxBinPath("indexer"); $cmd = sprintf("%s --rotate %s", $indexer, $index); $this->runCmd($cmd); - + if ($full) { // Since we just updated the main index, we need to update dates. // Notice that we also update the merge dates--we do this because a @@ -206,11 +206,11 @@ class Sphinx $this->setRebuildDates($index); } } - + /** * Merges a 'delta' index with a 'main' index, but only if the index is * enabled. - * + * * @param string $index The index to merge. * @param boolean $updateDates True (default) to update merge dates. * @return null @@ -226,7 +226,7 @@ class Sphinx $cmd = sprintf("%s --rotate --merge %s %s", $indexer, $index, $index."_delta"); $this->runCmd($cmd); - + if ($updateDates) { $this->setMergeDates($index); } @@ -234,7 +234,7 @@ class Sphinx // TODO: Return false if the merge fails return true; } - + /** * Extracts all of the information about a given ``$index`` via the * ``indextool`` program provided by Sphinx. @@ -249,14 +249,14 @@ class Sphinx "field_list" => array(), "attr_list" => array() ); - + if ($this->isIndexEnabled($index)) { $details["enabled"] = true; - + if (!$main) { $index .= "_delta"; } - + $handle = fopen($this->site->sphinxconfpath, 'r'); if ($handle) { $indexPath = ""; @@ -267,7 +267,7 @@ class Sphinx $indexPath = $matches[1]; } } - + if ($indexPath) { $indexer = $this->getSphinxBinPath("indextool"); $cmd = sprintf("%s --dumpheader %s.sph", $indexer, @@ -295,7 +295,7 @@ class Sphinx } return $details; } - + /** * Updates indexes. This function does quite a lot of stuff: * @@ -309,34 +309,34 @@ class Sphinx */ public function update() { - $db = new DB(); - + $db = new Settings(); + if (!$this->site->sphinxenabled) { // Sphinx is disabled, so we don't do anything. return; } - + // Loop over the enabled indexes and see what operations are due $sql = "SELECT * FROM sphinx"; $res = $db->queryDirect($sql); while ($row = $db->getAssocArray($res)) { $index = $row["name"]; - + if (!$this->isIndexEnabled($row["name"])) { continue; } - + $indexDetails = $this->indexDetails($index); $isMergeDueDate = (strtotime($row['nextmergedate']) <= time(true)); $isMergeDueSize = (intval($indexDetails["total-documents"]) >= intval($this->site->sphinxmergefreq_count)); - + if (strtotime($row['nextrebuilddate']) <= time(true) && $this->site->sphinxrebuildfreq_day != "") { // Rebuild required printf("Index '%s' is going to be rebuilt.\n", $index); - + // TODO: Check for success or failure. $this->updateIndex($index, true); } else if ($isMergeDueDate || $isMergeDueSize) { @@ -348,7 +348,7 @@ class Sphinx "and will be merged (contains %s records).\n", $index, $indexDetails["total-documents"]); } - + if ($this->mergeIndex($index)) { printf("Merge successful.\n"); } else { @@ -357,7 +357,7 @@ class Sphinx } } } - + printf("Updating delta indexes\n"); foreach($this->getAllEnabledIndexes() as $index) { // Index `nzbs` is never updated this way because it is a RT index @@ -368,13 +368,13 @@ class Sphinx } } } - + /** * Returns the path to the Sphinx binary ``$bin``. For example, if the * path to Sphinx's "indexer" binary is desired, this function can be used * to get the full path to it. It is also desirable to use this function * as it properly sets the ``sphinx.conf`` file to use. - * + * * @param string $bin The Sphinx binary to run (indexer, searchd, etc.). * @return string The path to the binary. */ @@ -388,12 +388,12 @@ class Sphinx $path .= DIRECTORY_SEPARATOR ; } $path .= $bin; - + // The '-c' sets the config file (sphinx.conf). $path = sprintf("\"%s\" -c \"%s\"", trim($path), $conf); return $path; } - + /** * Returns ``true`` if ``$index`` is enabled, ``false`` otherwise. * @@ -406,7 +406,7 @@ class Sphinx if (!$this->site->sphinxenabled) { return false; } - + // Only check "main" index, since the delta will be enabled // if main is as well. $index = strtolower(str_replace("_delta", "", $index)); @@ -425,7 +425,7 @@ class Sphinx return false; } } - + /** * Returns an array of all the indexes that are enabled. If Sphinx support * isn't enabled, then this returns an empty array. @@ -446,12 +446,12 @@ class Sphinx } return $enabled; } - + /** * Generates and returns a string of the of ``sphinx.conf`` file. * ``$sphinxDir`` should be a string representing the directory in which to * store the indexes. - * + * * @param string $sphinxDir Path to where indexes should be stored. * @return string */ @@ -473,19 +473,19 @@ class Sphinx $map = array_map($fn, array_keys($dict)); return preg_replace($map, array_values($dict), $str); } - + $nnRoot = realpath(FS_ROOT."/../../"); - + if (!$sphinxDir) { $sphinxDir = $nnRoot."/db/sphinxdata"; } - + if (!$sphinxConf) { $sphinxConf = $sphinxDir."/sphinx.conf"; } - + $sphinxConfFile = fopen($sphinxConf, 'w'); - + $filename = $nnRoot."/misc/sphinx/sphinx.tpl"; $handle = fopen($filename, "r"); $conf = fread($handle, filesize($filename)); @@ -496,13 +496,13 @@ class Sphinx "db_name" => DB_NAME, "sphinx_dir" => $sphinxDir ); - + fwrite($sphinxConfFile, subst($conf, $vars)); fclose($sphinxConfFile); - + return $sphinxConf; } - + /** * Indexing function for NZB contents. Unlink the other indexes, 'nzbs' * can't be indexed from MySQL data directly since the data to be indexed @@ -525,28 +525,28 @@ class Sphinx */ public function indexNZBs($startingID=-1) { - + // TODO: Use batching // See: http://sphinxsearch.com/docs/2.0.1/rt-caveats.html // if (!$this->isIndexEnabled("nzbs")) { return 0; } - + $out = fopen("php://stdout", 'w'); - + // Get connection to Sphinx's MySQL interface. // Connect to Sphinx $hostport = explode (":", $this->site->sphinxserverhost); $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]); if (!$sdb) { // Couldn't connect to Sphinx. - return false; + return false; } - + // Get connection to Newznab's MySQL database $ndb = new DB; - + // Determine which release to start with if ($startingID < 0) { $sql = "SELECT id FROM nzbs ORDER BY id DESC LIMIT 1"; @@ -558,12 +558,12 @@ class Sphinx $startingID = (int)$row[0]; } } - + // Get the number of NZBs to do $sql = "SELECT COUNT(ID) as num FROM releases WHERE ID >= %d"; $row = $ndb->queryOneRow(sprintf($sql, $startingID)); $recordCount = (int)$row["num"]; - + // Start looping over the releases and build the NZB index printf("starting from ID %d\n", $startingID); $numIndexed = 0; @@ -602,7 +602,7 @@ class Sphinx } return $numIndexed; } - + /** * Query the indexer directly. Returns an array of the results, unless * there was an error in which case ``false`` is returned. However, if @@ -632,21 +632,21 @@ class Sphinx if ($ret !== false) return $ret; } - + // Connect to Sphinx $hostport = explode (":", $this->site->sphinxserverhost); $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]); if (!$sdb) { // Couldn't connect to Sphinx. - return false; + return false; } - + // Get the results from Sphinx. $lev = error_reporting(); error_reporting(0); $result = mysqli_query($sdb, $sphinxQuery); error_reporting($lev); - + $error = mysqli_error($sdb); // A 1064 error means that the query is invalid, so we don't care // about that. @@ -654,7 +654,7 @@ class Sphinx // All other errors we will considered a failure. return false; } - + // Get the query metadata. $meta = array(); $mresult = mysqli_query($sdb,"SHOW META"); @@ -664,7 +664,7 @@ class Sphinx while ($row = mysqli_fetch_row($mresult)) { $meta[$row[0]] = $row[1]; } - + $results = array(); if ($result) { @@ -677,7 +677,7 @@ class Sphinx } } } - + if ($lookupQuery && count($results) > 0) { $ndb = new DB; $sql = sprintf($lookupQuery, implode(",", $results)); @@ -690,16 +690,16 @@ class Sphinx } } } - + $count = 0; if ( count($results) > 0 && array_key_exists("total", $meta) ) { $count = (int)$meta["total_found"]; $results[0]["_totalrows"] = ($count > MAX_MATCHES) ? MAX_MATCHES : $count; } - + if ($useCache !== false && $cache->enabled) - $cache->store($sphinxQuery, $results, $useCache); - + $cache->store($sphinxQuery, $results, $useCache); + return $results; } /** @@ -726,10 +726,10 @@ class Sphinx &$lookupQuery="") { $ndb = new DB; - + $offset = intval($offset); $limit = intval($limit); - + if ($lookup) { // Since we're going to look up the data from MySQL, we don't need // to get all the fields from Sphinx. @@ -737,7 +737,7 @@ class Sphinx } else { $select = "* "; } - + // Create a comma separated string of indexes, but only of enabled // indexes $searchIndexes = array(); @@ -750,7 +750,7 @@ class Sphinx $searchIndexes = array_reverse($this->getAllEnabledIndexes(true)); } $from = implode(", ", $searchIndexes); - + // Check to see if this is an extended query. If it is, remove the // leading "!" and don't touch the rest of the query. if (count($search) > 0) { @@ -763,7 +763,7 @@ class Sphinx /* Basic Query */ - + // Check to see if the the query contains any field specifiers like: // "@(field1,field2)"--if not, add in the default search fields. foreach($search as $i => $q) { @@ -772,25 +772,25 @@ class Sphinx // turns the query for "ubuntu" into something like: // "@(name,searchname) ubuntu" $fields = str_replace(" ", "", $this->site->sphinxsearchfields); - + // Remove single "-" so that Sphinx doesn't use it as an // exclusion modifier $q = preg_replace('/([^\-])\-/', '\1 ', $q); - + // "basic" search syntax allows a "--" exclusion modifier, // but Sphinx uses "-" as a the exclusion modifier $q = str_replace("--", "-", $q); // always add on * to Season based searches $q = preg_replace('/([\. ]S\d{2})( |$)/i', '\1*\2', $q); - + // Construct the basic query $search[$i] = sprintf("@(%s) ", $fields).$q; } } } } - + // Create the actual MATCH() query. Per the Sphinx docs, each query // can only have one MATCH() statement. if (count($search) > 0) { @@ -804,11 +804,11 @@ class Sphinx // "@@relaxed" wasn't found at the beginning, $search[0] = "@@relaxed ".$search[0]; } - + $where[] = sprintf("MATCH(%s)", $ndb->escapeString(implode(' ', $search))); } } - + // Build the category query. If any of the categories are a "parent" // then we need to explicitly include their children as well. $categoryIDs = array(); @@ -818,7 +818,7 @@ class Sphinx if (!in_array($category, $categoryIDs)) { $categoryIDs[] = $category; } - + $categ = new Category(); if ($categ->isParent($category)) { // Inlcude all children @@ -837,19 +837,19 @@ class Sphinx if ($categoryIDs) { $where[] = sprintf("categoryID IN (%s)", implode(",", $categoryIDs)); } - + // Filter on postdate. if ($maxage > 0) { // TODO: This probably isn't the best way to do this... $where[] = sprintf("postdate >= %d", time()-($maxage*86400)); } - + // Categories to exclude. if (count($excludedcats) > 0) { $where[] = sprintf("categoryID NOT IN (%s)", implode(",", $excludedcats)); } - + // Usenet groups to include. if ($grp) { foreach($grp as $i => $g) { @@ -864,33 +864,33 @@ class Sphinx } $where[] = sprintf("groupID IN (%s)", implode(",", $grp)); } - + // Order the results. // TODO: implement better default ordering behavior. $orderby = ""; if (count($order) == 2) { $orderby = sprintf("ORDER BY %s %s", $order[0], $order[1]); - + // Add in the ORDER BY parameters if there is a $lookupQuery if ($lookupQuery) { $lookupQuery = $lookupQuery." ".$orderby; } } - + // Build the full query. $q = sprintf("SELECT %s FROM %s ".(!empty($where)?"WHERE ":"")." %s %s LIMIT %d,%d", $select, $from, implode(" AND ", $where), $orderby, $offset, $limit); - + // Sphinx imposes a 1000 result limit (max_matches) by default, so in // order to access results beyond this, we need to tell it to do so if ($offset >= 1000) { $q .= sprintf(" OPTION max_matches=%d", $offset+$limit); } - + return $q; } - + /** * Search ``$indexes`` for ``$search`` term(s). ``$search`` should be a * string containing a valid Sphinx query, see `query syntax`_ for @@ -922,7 +922,7 @@ class Sphinx // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; if ($lookup) { $lookupQuery .= "SELECT releases.*, " @@ -965,7 +965,7 @@ class Sphinx $indexes, $lookup, $where, $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Returns an array of all the releases matching the given query. This * presents the same interface as :php:meth:`Releases::searchbyRageId`. @@ -986,26 +986,26 @@ class Sphinx } $search[] = sprintf("@season %s", $db->escapeString($series)); } - + if ($episode != "") { if (is_numeric($episode)) { $episode = sprintf('E%02d', $episode); } $search[] = sprintf("@episode %s", $db->escapeString($episode)); } - + $where = array(); if ($rageId != "-1") { $where[] = "rageid = ".$rageId; } - + if (count($indexes) == 0) { // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; - if ($lookup) { + if ($lookup) { $lookupQuery .= "SELECT releases.*, " . "CONCAT(cp.title, ' > ', c.title) AS category_name, " . "CONCAT(cp.ID, ',', c.ID) AS category_ids, " @@ -1031,7 +1031,7 @@ class Sphinx $lookup, $where, $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Returns an array of all the releases matching the given query. This * presents the same interface as :php:meth:`Releases::searchbyImdbId`. @@ -1051,16 +1051,16 @@ class Sphinx } else { $where[] = sprintf("imdbid != 0", $imdbId); } - + if ($genre != "") { $search[] = sprintf("@movieinfo_genre %s", $db->escapeString($genre)); } - + if (count($indexes) == 0) { // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; if ($lookup) { $lookupQuery .= "SELECT releases.*, " @@ -1097,7 +1097,7 @@ class Sphinx $lookup, $where, $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Returns an array of all the releases matching the given query. This * presents the same interface as :php:meth:`Releases::searchAudio`. @@ -1114,32 +1114,32 @@ class Sphinx if ($artist != "") { $search[] = sprintf("@musicinfo_artist %s", $db->escapeString($artist)); } - + if ($album != "") { $search[] = sprintf("@musicinfo_title %s", $db->escapeString($album)); } - + if ($label != "") { $search[] = sprintf("@musicinfo_publisher %s", $db->escapeString($label)); } - + if ($track != "") { $search[] = sprintf("@musicinfo_tracks %s", $db->escapeString($track)); } - + if ($year != "") { $where[] = sprintf("musicinfo_year = %d", $year); } - + if (count($genre) > 0 && $genre[0] != -1) { $where[] = sprintf("musicinfo_genreID IN (%s)", implode(",", $genre)); } - + if (count($indexes) == 0) { // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; if ($lookup) { $lookupQuery .= "SELECT releases.*, " @@ -1175,7 +1175,7 @@ class Sphinx $lookup, $where, $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Returns an array of all the releases matching the given query. This * presents the same interface as :php:meth:`Releases::searchBook`. @@ -1189,16 +1189,16 @@ class Sphinx if ($author != "") { $search[] = sprintf("@bookinfo_author %s", $db->escapeString($author)); } - + if ($title != "") { $search[] = sprintf("@bookinfo_title %s", $db->escapeString($title)); } - + if (count($indexes) == 0) { // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; if ($lookup) { $lookupQuery .= "SELECT releases.*, " @@ -1231,13 +1231,13 @@ class Sphinx . "FROM site WHERE setting='showpasswordedrelease')" . "AND releases.ID IN (%s)"; } - + $sphinxQuery = $this->buildQuery($search, array(-1), $offset, $limit, $order, $maxage, array(), array(), $indexes, $lookup, array(), $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Returns an array of all the releases matching the given query. This * presents the same interface as :php:meth:`Releases::searchbyAnidbId`. @@ -1246,23 +1246,23 @@ class Sphinx $name='', $maxage=-1, $indexes=array(), $lookup=true) { - $db = new DB(); + $db = new Settings(); $where = array(); $search = array(); $order = array("postdate", "desc"); if ($anidbID > -1) { $where[] = sprintf("anidbID = %d", $anidbID); } - + if (is_numeric($epno)) { $search[] = sprintf("@episode %s", $db->escapeString($epno)); } - + if (count($indexes) == 0) { // Remove predb from the default list of indexes to search $indexes = $this->getAllEnabledIndexes(true, array('predb')); } - + $lookupQuery = ""; if ($lookup) { $lookupQuery .= "SELECT releases.*, " @@ -1288,14 +1288,14 @@ class Sphinx $indexes, $lookup, $where, $lookupQuery); return $this->searchDirect($sphinxQuery, $lookupQuery, 180); } - + /** * Get predb rows by limit and filter. This presents the same interface as * :php:meth:`PreDB::getPreRange`. */ public function getPreRange($start=0, $num, $dirname='', $category='') { - $db = new DB(); + $db = new Settings(); $dirname = empty($category) ? $dirname : $dirname." @category =".$category; $sphinxQuery = sprintf("SELECT id " ."FROM predb, predb_delta " @@ -1312,7 +1312,7 @@ class Sphinx . "ORDER BY predb.ctime DESC"; return $this->searchDirect($sphinxQuery, $lookupQuery, 120); } - + /** * Get count of all predb rows that match the query. This presents the * same interface as :php:meth:`PreDB::getPreCount`. If there is an issue @@ -1325,12 +1325,12 @@ class Sphinx public function getPreCount($dirname='', $category='') { $results = $this->getPreRange(0, 1, $dirname, $category); - if (is_array($results)) { + if (is_array($results)) { return $results[0]['_totalrows']; } return -1; } - + /** * Convert seconds to human readable text. From: * http://csl.sublevel3.org/php-secs-to-human-text/ diff --git a/lib/copy_this/www/lib/spotnab.php b/lib/copy_this/www/lib/spotnab.php index ba751200f..9609812b9 100644 --- a/lib/copy_this/www/lib/spotnab.php +++ b/lib/copy_this/www/lib/spotnab.php @@ -267,7 +267,7 @@ class SpotNab { // *********************************************************************** public function auto_clean($max_days=90){ - $db = new DB(); + $db = new Settings(); // automatically sweep old sources lingering that have not shown any // sort of life what-so-ever for more then 90 days $sql = "DELETE FROM spotnabsources WHERE " @@ -291,7 +291,7 @@ class SpotNab { $sql_rel = "SELECT GID FROM releases WHERE GID IN ('%s') "; $sql_del = "DELETE FROM releasecomment WHERE GID IN ('%s')"; $total_delcnt = 0; - $db = new DB(); + $db = new Settings(); while(1) { $res = $db->query(sprintf($sql, $offset, $batch)); @@ -336,7 +336,7 @@ class SpotNab { // using existing sources // - it has never posted discovery information // - it has never scanned for existing discoveries - $db = new DB(); + $db = new Settings(); // resets sources so they need to query again $sources = "UPDATE spotnabsources SET " @@ -370,7 +370,7 @@ class SpotNab { // *********************************************************************** public function fetch_discovery($reftime=Null, $retries=3){ - $db = new DB(); + $db = new Settings(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -530,7 +530,7 @@ class SpotNab { // *********************************************************************** public function auto_post_discovery($repost_sec=SpotNab::POST_BROADCAST_INTERVAL){ - $db = new DB(); + $db = new Settings(); // performs a post discovery once the time in seconds has elapsed $q = "SELECT updateddate FROM site WHERE " ."setting = 'spotnabbroadcast'"; @@ -653,7 +653,7 @@ class SpotNab { * The specified $reftime is presumed to be local *not utc* */ - $db = new DB(); + $db = new Settings(); $last = $first = Null; // Return Value; Initialize it to Okay @@ -901,7 +901,7 @@ class SpotNab { public function processGID($limit=500, $batch=5000, $delete_broken_releases=false){ // Process until someone presses cntrl-c - $db = new DB(); + $db = new Settings(); $nzb = new NZB(); $processed = 0; @@ -991,7 +991,7 @@ class SpotNab { public function keygen($print=true, $force_regen=false){ // Simply generate a Public/Private Key pair if they don't already // exist - $db = new DB(); + $db = new Settings(); // A small boolean we safely toggle after performing // a few checks first to make sure it's safe to do so @@ -1314,7 +1314,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new DB(); + $db = new Settings(); $rc = new ReleaseComments(); // Comments @@ -1535,7 +1535,7 @@ class SpotNab { // Prepare some general SQL Commands for saving later if all goes well // - $db = new DB(); + $db = new Settings(); // Auto Enable Flag (used for inserts only) $auto_enable = ($this->_auto_enable)?"1":"0"; @@ -1873,7 +1873,7 @@ class SpotNab { { $message['comments'] = $data['comments']; - $db = new DB(); + $db = new Settings(); $sql = sprintf("UPDATE releasecomment " ."SET issynced = 1 WHERE ID IN (%s)", implode(",", $data['ids'])); @@ -2220,7 +2220,7 @@ class SpotNab { * but otherwise it's expected format is string "Y-m-d H:i:s" */ - $db = new DB(); + $db = new Settings(); // Now we fetch for any new posts since reference point $sql = sprintf("SELECT r.gid, rc.ID, rc.text, u.username, " @@ -2463,22 +2463,22 @@ class SpotNab { public function getSources() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT ID, lastupdate,lastbroadcast, active, description, " ."(SELECT count(ID) from releasecomment where sourceid = s.ID)" ." AS comments FROM spotnabsources s"); } - + public function getSourceById($id) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("SELECT * FROM spotnabsources WHERE id = %d", $id); return $db->queryOneRow($sql); } public function addSource($description,$username,$usermail,$usenetgroup,$publickey) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("INSERT INTO spotnabsources " ."(description, username, useremail," ." usenetgroup, publickey, active) " @@ -2488,10 +2488,10 @@ class SpotNab { $db->escapeString($publickey)); return $db->queryInsert($sql); } - + public function updateSource($id, $description,$username,$usermail,$usenetgroup,$publickey) { - $db = new DB(); + $db = new Settings(); return $db->queryExec( sprintf("UPDATE spotnabsources SET " ."description = %s, username = %s, useremail = %s," @@ -2503,19 +2503,19 @@ class SpotNab { public function deleteSource($id) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("DELETE FROM spotnabsources WHERE id = %d", $id)); } public function toggleSource($id, $active) { - $db = new DB(); + $db = new Settings(); return $db->queryExec(sprintf("update spotnabsources SET active = %d WHERE id = %d", $active, $id)); } - + public function getDefaultValue($table,$field) { - $db = new DB(); - return $db->query(sprintf("SHOW COLUMNS FROM %s WHERE field = %s", $table, $db->escapeString($field))); + $db = new Settings(); + return $db->query(sprintf("SHOW COLUMNS FROM %s WHERE field = %s", $table, $db->escapeString($field))); } } diff --git a/lib/copy_this/www/lib/thetvdb.php b/lib/copy_this/www/lib/thetvdb.php index 3d55b3d5b..7192d2430 100644 --- a/lib/copy_this/www/lib/thetvdb.php +++ b/lib/copy_this/www/lib/thetvdb.php @@ -19,7 +19,7 @@ class TheTVDB public function addSeries($TheTVDBAPIArray) { - $db = new DB(); + $db = new Settings(); $airstime = $TheTVDBAPIArray['airstime']; if($airstime != "") @@ -51,7 +51,7 @@ class TheTVDB public function addEpisodes($TheTVDBAPIArray) { - $db = new DB(); + $db = new Settings(); for($i=0; $i < count($TheTVDBAPIArray['episodetvdbID']); $i++) { $airdate = strftime('%Y-%m-%d %H:%M:%S', strtotime($TheTVDBAPIArray['episodefirstaired'][$i].' '.$TheTVDBAPIArray['airstime'])); @@ -74,7 +74,7 @@ class TheTVDB public function updateSeries($tvdbID, $actors, $airsday, $airstime, $contentrating, $firstaired, $genre, $imdbID, $network, $overview, $rating, $ratingcount, $runtime, $seriesname, $status) { - $db = new DB(); + $db = new Settings(); if ($airstime != "") $airstime = $db->escapeString(date("H:i:s", strtotime($airstime))); else @@ -102,33 +102,33 @@ class TheTVDB public function deleteTitle($tvdbID) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE FROM thetvdb WHERE tvdbID = %d", $tvdbID)); } public function addEmptySeries($seriesname) { - $db = new DB(); + $db = new Settings(); $db->queryInsert(sprintf("INSERT INTO thetvdb (tvdbID, seriesname, createddate) VALUES (0, %s, now())", $db->escapeString($seriesname))); } public function getSeriesInfoByID($tvdbID) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM thetvdb WHERE tvdbID = %d", $tvdbID)); } public function getSeriesInfoByName($seriesname) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("SELECT * FROM thetvdb WHERE seriesname = %s", $db->escapeString($seriesname))); } public function getSeriesRange($start, $num, $seriesname='') { - $db = new DB(); + $db = new Settings(); $limit = ($start === false) ? '' : " LIMIT ".$start.",".$num; @@ -141,7 +141,7 @@ class TheTVDB public function getSeriesCount($seriesname='') { - $db = new DB(); + $db = new Settings(); $rsql = ''; if ($seriesname != '') @@ -179,13 +179,13 @@ class TheTVDB if($this->echooutput && $echooutput) echo 'TheTVDB : '.$seriesName.' '.$fullep." Not found\n"; - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf('UPDATE releases SET episodeinfoID = %d WHERE ID = %d', -2, $releaseID)); } public function processReleases() { - $db = new DB(); + $db = new Settings(); $results = $db->queryDirect(sprintf("SELECT ID, searchname, rageID, anidbID, seriesfull, season, episode, tvtitle FROM releases WHERE episodeinfoID IS NULL AND categoryID IN ( SELECT ID FROM category WHERE parentID = %d ) LIMIT 150", Category::CAT_PARENT_TV)); diff --git a/lib/copy_this/www/lib/tvrage.php b/lib/copy_this/www/lib/tvrage.php index c298a9b9d..3e4b7d343 100644 --- a/lib/copy_this/www/lib/tvrage.php +++ b/lib/copy_this/www/lib/tvrage.php @@ -6,19 +6,19 @@ require_once(WWW_DIR."/lib/framework/db.php"); require_once(WWW_DIR."/lib/framework/cache.php"); class TvRage -{ +{ const APIKEY = '7FwjZ8loweFcOhHfnU3E'; const MATCH_PROBABILITY = 75; - + function TvRage($echooutput=false) { $this->echooutput = $echooutput; - + $this->xmlFullSearchUrl = "http://services.tvrage.com/feeds/full_search.php?show="; - $this->xmlFullShowInfoUrl = "http://services.tvrage.com/feeds/full_show_info.php?sid="; + $this->xmlFullShowInfoUrl = "http://services.tvrage.com/feeds/full_show_info.php?sid="; $this->xmlEpisodeInfoUrl = "http://services.tvrage.com/myfeeds/episodeinfo.php?key=".TvRage::APIKEY; - $this->xmlFullScheduleUrl = "http://services.tvrage.com/feeds/fullschedule.php?country="; - + $this->xmlFullScheduleUrl = "http://services.tvrage.com/feeds/fullschedule.php?country="; + $this->showInfoUrl = "http://www.tvrage.com/shows/id-"; } @@ -34,117 +34,117 @@ class TvRage } public function getByID($id) - { - $db = new DB(); - return $db->queryOneRow(sprintf("select * from tvrage where ID = %d", $id )); + { + $db = new Settings(); + return $db->queryOneRow(sprintf("select * from tvrage where ID = %d", $id )); } - + public function getByRageID($id) - { - $db = new DB(); - return $db->query(sprintf("select * from tvrage where rageID = %d", $id )); + { + $db = new Settings(); + return $db->query(sprintf("select * from tvrage where rageID = %d", $id )); } - + public function getByTitle($title) { // check if we already have an entry for this show - $db = new DB(); + $db = new Settings(); $sql = sprintf("SELECT rageID from tvrage where (releasetitle = %s or releasetitle = %s)", $db->escapeString($title), $db->escapeString(str_replace(' and ', ' & ', $title))); $res = $db->queryOneRow($sql); if ($res) return $res["rageID"]; - + return false; } - + public function add($rageid, $releasename, $desc, $genre, $country, $imgbytes) - { + { $releasename = str_replace(array('.','_'), array(' ',' '), $releasename); - - $db = new DB(); - return $db->queryInsert(sprintf("insert into tvrage (rageID, releasetitle, description, genre, country, createddate, imgdata) values (%d, %s, %s, %s, %s, now(), %s)", - $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $db->escapeString($imgbytes))); + + $db = new Settings(); + return $db->queryInsert(sprintf("insert into tvrage (rageID, releasetitle, description, genre, country, createddate, imgdata) values (%d, %s, %s, %s, %s, now(), %s)", + $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $db->escapeString($imgbytes))); } public function update($id, $rageid, $releasename, $desc, $genre, $country, $imgbytes) - { - $db = new DB(); - + { + $db = new Settings(); + if ($imgbytes != "") $imgbytes = sprintf(", imgdata = %s", $db->escapeString($imgbytes)); - + $db->queryExec(sprintf("update tvrage set rageID = %d, releasetitle = %s, description = %s, genre = %s, country = %s %s where ID = %d", - $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $imgbytes, $id )); + $rageid, $db->escapeString($releasename), $db->escapeString($desc), $db->escapeString($genre), $db->escapeString($country), $imgbytes, $id )); } public function delete($id) - { - $db = new DB(); + { + $db = new Settings(); return $db->queryExec(sprintf("DELETE from tvrage where ID = %d",$id)); } public function getRange($start, $num, $ragename="") - { - $db = new DB(); - + { + $db = new Settings(); + if ($start === false) $limit = ""; else $limit = " LIMIT ".$start.",".$num; - - $rsql = ''; - if ($ragename != "") - $rsql .= sprintf("and tvrage.releasetitle like %s ", $db->escapeString("%".$ragename."%")); - - return $db->query(sprintf(" SELECT ID, rageID, releasetitle, description, createddate from tvrage where 1=1 %s order by rageID asc".$limit, $rsql)); - } - - public function getCount($ragename="") - { - $db = new DB(); - + $rsql = ''; if ($ragename != "") $rsql .= sprintf("and tvrage.releasetitle like %s ", $db->escapeString("%".$ragename."%")); - - $res = $db->queryOneRow(sprintf("select count(ID) as num from tvrage where 1=1 %s ", $rsql)); + + return $db->query(sprintf(" SELECT ID, rageID, releasetitle, description, createddate from tvrage where 1=1 %s order by rageID asc".$limit, $rsql)); + } + + public function getCount($ragename="") + { + $db = new Settings(); + + $rsql = ''; + if ($ragename != "") + $rsql .= sprintf("and tvrage.releasetitle like %s ", $db->escapeString("%".$ragename."%")); + + $res = $db->queryOneRow(sprintf("select count(ID) as num from tvrage where 1=1 %s ", $rsql)); return $res["num"]; } - + public function getCalendar($date = "") { - $db = new DB(); + $db = new Settings(); if(!preg_match('/\d{4}-\d{2}-\d{2}/',$date)) $date = date("Y-m-d"); $sql = sprintf("SELECT * FROM episodeinfo WHERE rageID > %d AND DATE(airdate) = %s order by airdate asc ", 0, $db->escapeString($date)); return $db->query($sql); } - + public function getSeriesList($uid, $letter="", $ragename="") - { - $db = new DB(); - + { + $db = new Settings(); + $rsql = ''; if ($letter != "") { if ($letter == '0-9') $letter = '[0-9]'; - + $rsql .= sprintf("and tvrage.releasetitle REGEXP %s", $db->escapeString('^'.$letter)); - } + } $tsql = ''; if ($ragename != '') { $tsql .= sprintf("and tvrage.releasetitle like %s", $db->escapeString("%".$ragename."%")); } - + $sql = sprintf(" SELECT tvrage.ID, tvrage.rageID, tvrage.releasetitle, tvrage.genre, tvrage.country, tvrage.createddate, tvrage.prevdate, tvrage.nextdate, userseries.ID as userseriesID from tvrage left outer join userseries on userseries.userID = %d and userseries.rageID = tvrage.rageID where tvrage.rageID > 0 %s %s group by tvrage.rageID order by tvrage.releasetitle asc", $uid, $rsql, $tsql); - return $db->query($sql); + return $db->query($sql); } - + public function updateSchedule() { - $db = new DB(); + $db = new Settings(); $countries = $db->query("select distinct(country) as country from tvrage where country != ''"); $showsindb = $db->query("select distinct(rageid) as rageid from tvrage"); @@ -153,7 +153,7 @@ class TvRage { $showarray[] = $show['rageid']; } - + if ($this->echooutput) echo 'TVRage : Updating schedule...'; @@ -178,13 +178,13 @@ class TvRage $yesterday = strtotime("-1 day") - $tzOffset; $xmlSchedule = array(); - foreach ($sched as $dayObj) + foreach ($sched as $dayObj) { $currDay = (string)$dayObj['attr']; - foreach ($dayObj->time as $sTime) + foreach ($dayObj->time as $sTime) { $currTime = (string) $sTime['attr']; - foreach ($sTime as $sShow) + foreach ($sTime as $sShow) { $currShowName = (string) $sShow['name']; $currShowId = (string) $sShow->sid; @@ -225,39 +225,39 @@ class TvRage } } // update series info - foreach ($xmlSchedule as $showId=>$epInfo) + foreach ($xmlSchedule as $showId=>$epInfo) { $res = $db->query(sprintf("select *, UNIX_TIMESTAMP(nextdate) as nextDateU, UNIX_TIMESTAMP(DATE(nextdate)) as nextDateDay from tvrage where rageID = %d", $showId)); - if (sizeof($res) > 0) + if (sizeof($res) > 0) { - foreach ($res as $arr) + foreach ($res as $arr) { $prev_ep = $next_ep = ""; $query = array(); - + // previous episode - if (isset($epInfo['prev']) && $epInfo['prev']['episode'] != '') + if (isset($epInfo['prev']) && $epInfo['prev']['episode'] != '') { $prev_ep = $epInfo['prev']['episode'].', "'.$epInfo['prev']['title'].'"'; $query[] = sprintf("prevdate = FROM_UNIXTIME(%s), previnfo = %s", $epInfo['prev']['day_time'], $db->escapeString($prev_ep)); } - + // next episode - if (isset($epInfo['next']) && $epInfo['next']['episode'] != '') + if (isset($epInfo['next']) && $epInfo['next']['episode'] != '') { - if ($prev_ep == "" && $arr['nextinfo'] != '' && $epInfo['next']['day_time'] > $arr['nextDateU'] && $arr['nextDateDay'] < $yesterday) + if ($prev_ep == "" && $arr['nextinfo'] != '' && $epInfo['next']['day_time'] > $arr['nextDateU'] && $arr['nextDateDay'] < $yesterday) { $db->queryExec(sprintf("update tvrage set prevdate = nextdate, previnfo = nextinfo where ID = %d", $arr['ID'])); $prev_ep = "SWAPPED with: ".$arr['nextinfo']." - ".date("r", $arr['nextDateU']); } $next_ep = $epInfo['next']['episode'].', "'.$epInfo['next']['title'].'"'; $query[] = sprintf("nextdate = FROM_UNIXTIME(%s), nextinfo = %s", $epInfo['next']['day_time'], $db->escapeString($next_ep)); - } - else + } + else { $query[] = "nextdate = null, nextinfo = null"; } - + // output /* if ($this->echooutput) @@ -267,7 +267,7 @@ class TvRage echo " -next: {$next_ep} - ".(isset($epInfo['next']['day_time']) ? date("r",$epInfo['next']['day_time']) : "")."\n"; } */ - + // update info if (count($query) > 0) { @@ -279,32 +279,32 @@ class TvRage } } // end update series info } - } // end foreach country + } // end foreach country if ($this->echooutput) echo "TVRage : Schedule complete...\n"; } - + public function getEpisodeInfo($rageid, $series, $episode) { $result = array('title'=>'', 'airdate'=>''); - + $series = str_ireplace("s", "", $series); $episode = str_ireplace("e", "", $episode); - + $lookupUrl = $this->xmlEpisodeInfoUrl."&sid=".$rageid."&ep=".$series."x".$episode; - + $xml = $this->fetchCache($lookupUrl); if ($xml === false) $xml = getUrl($lookupUrl); - + if ($xml !== false) { $this->storeCache($lookupUrl, $xml); - + if (preg_match('/no show found/i', $xml)) return false; - + $xmlObj = @simplexml_load_string($xml); $arrXml = objectsIntoArray($xmlObj); if (is_array($arrXml)) @@ -313,24 +313,24 @@ class TvRage $result['airdate'] = $arrXml['episode']['airdate']; if (isset($arrXml['episode']['title'])) $result['title'] = $arrXml['episode']['title']; - + return $result; } return false; } return false; } - + public function getRageInfoFromPage($rageid) { $result = array('desc'=>'', 'imgurl'=>''); - + $lookupUrl = $this->showInfoUrl.$rageid; - + $page = $this->fetchCache($lookupUrl); if ($page === false) $page = getUrl($lookupUrl); - + if ($page !== false) { $this->storeCache($lookupUrl, $page); @@ -358,22 +358,22 @@ class TvRage } return $result; } - + public function getRageInfoFromService($rageid) { $result = array('genres'=>'', 'country'=>'', 'showid'=>$rageid); - + $lookupUrl = $this->xmlFullShowInfoUrl.$rageid; - + $xml = $this->fetchCache($lookupUrl); if ($xml === false) $xml = getUrl($lookupUrl); - + if ($xml !== false) { $this->storeCache($lookupUrl, $xml); - - $xml = str_replace('<genre></genre>', '', $xml); + + $xml = str_replace('<genre></genre>', '', $xml); $xmlObj = @simplexml_load_string($xml); $arrXml = objectsIntoArray($xmlObj); @@ -387,7 +387,7 @@ class TvRage } return false; } - + public function updateEpInfo($show, $relid) { $db = new Db; @@ -400,17 +400,17 @@ class TvRage $db->queryExec(sprintf("update releases set seriesfull = %s, season = %s, episode = %s, tvairdate=%s where ID = %d", $db->escapeString($show['seriesfull']), $db->escapeString($show['season']), $db->escapeString($show['episode']), $tvairdate, $relid)); } - + public function refreshRageInfo($id) { $row = $this->getByID($id); $rageid = $row["rageID"]; - + $rInfo = $this->getRageInfoFromPage($rageid); $desc = ''; if (isset($rInfo['desc']) && !empty($rInfo['desc'])) $desc = $rInfo['desc']; - + $imgbytes = ''; if (isset($rInfo['imgurl']) && !empty($rInfo['imgurl'])) { @@ -421,32 +421,32 @@ class TvRage if($im !== false) $imgbytes = $img; } - } - - $db = new DB(); + } + + $db = new Settings(); $sql = sprintf("update tvrage set description = %s, imgdata = %s where id = %d", $db->escapeString($desc), $db->escapeString($imgbytes), $id); return $db->queryExec($sql); - + } - + public function updateRageInfo($rageid, $show, $tvrShow, $relid) { $db = new Db; - + $idCheck = $this->getByRageID($rageid); - + $epinfo = false; - + //check local releases to see if we already have the data if ($idCheck && sizeof($idCheck) > 0) { $epinfo = $db->queryOneRow(sprintf("select tvtitle as title, tvairdate as airdate from releases where tvairdate is not null and season = %s and episode = %s and rageID = %d", $db->escapeString($show['season']), $db->escapeString($show['episode']), $idCheck[0]['rageID'])); //check tvdb episodeinfo data - if ($epinfo == false) - $epinfo = $db->queryOneRow(sprintf("select eptitle as title, airdate as airdate from episodeinfo where airdate is not null and fullep = %s and rageID = %d", $db->escapeString(str_replace('S', '', $show['season']).'x'.str_replace('E', '', $show['episode'])), $idCheck[0]['rageID'])); + if ($epinfo == false) + $epinfo = $db->queryOneRow(sprintf("select eptitle as title, airdate as airdate from episodeinfo where airdate is not null and fullep = %s and rageID = %d", $db->escapeString(str_replace('S', '', $show['season']).'x'.str_replace('E', '', $show['episode'])), $idCheck[0]['rageID'])); } - + // try and get the episode specific info from tvrage if its not available locally if ($epinfo == false) $epinfo = $this->getEpisodeInfo($rageid, $show['season'], $show['episode']); @@ -457,12 +457,12 @@ class TvRage $tvtitle = (!empty($epinfo['title'])) ? $db->escapeString($epinfo['title']) : "null"; $db->queryExec(sprintf("update releases set tvtitle=trim(%s), tvairdate=%s, rageID = %d where ID = %d", $tvtitle, $tvairdate, $tvrShow['showid'], $relid)); - } - else + } + else { $db->queryExec(sprintf("update releases set rageID = %d where ID = %d", $tvrShow['showid'], $relid)); } - + $genre = ''; if (isset($tvrShow['genres']) && is_array($tvrShow['genres']) && !empty($tvrShow['genres'])) { @@ -471,16 +471,16 @@ class TvRage else $genre = $tvrShow['genres']['genre']; } - + $country = ''; if (isset($tvrShow['country']) && !empty($tvrShow['country'])) $country = $tvrShow['country']; - + $rInfo = $this->getRageInfoFromPage($rageid); $desc = ''; if (isset($rInfo['desc']) && !empty($rInfo['desc'])) $desc = $rInfo['desc']; - + $imgbytes = ''; if (isset($rInfo['imgurl']) && !empty($rInfo['imgurl'])) { @@ -491,17 +491,17 @@ class TvRage if($im !== false) $imgbytes = $img; } - } - + } + $this->add($rageid, $show['cleanname'], $desc, $genre, $country, $imgbytes); } - + public function processTvReleases($lookupTvRage=true, $numtoProcess=100) { $ret = 0; - $db = new DB(); + $db = new Settings(); $nfo = new Nfo(); - + // get all releases without a rageid which are in a tv category. $result = $db->queryDirect(sprintf("SELECT searchname, ID from releases where rageID = -1 and categoryID in ( select ID from category where parentID = %d ) order by postdate desc limit %d ", Category::CAT_PARENT_TV, $numtoProcess)); @@ -613,35 +613,35 @@ class TvRage } } - + return $ret; } - + public function getRageMatch($showInfo) { $title = $showInfo['cleanname']; - + $lookupUrl = $this->xmlFullSearchUrl.urlencode(strtolower($title)); - + $xml = $this->fetchCache($lookupUrl); if ($xml === false) $xml = getUrl($lookupUrl); //full search gives us the akas - + if ($xml !== false) { $this->storeCache($lookupUrl, $xml); - - $xml = str_replace('<genre></genre>', '', $xml); + + $xml = str_replace('<genre></genre>', '', $xml); $xmlObj = @simplexml_load_string($xml); $arrXml = objectsIntoArray($xmlObj); - + if (isset($arrXml['show']) && is_array($arrXml['show'])) { // we got a valid xml response $titleMatches = array(); $urlMatches = array(); $akaMatches = array(); - + if (isset($arrXml['show']['showid'])) { // we got exactly 1 match so lets convert it to an array so we can use it in the logic below @@ -650,17 +650,17 @@ class TvRage unset($arrXml); $arrXml['show'] = $newArr; } - + foreach ($arrXml['show'] as $arr) - { + { $titlepct = $urlpct = $akapct = 0; - - // get a match percentage based on our name and the name returned from tvr + + // get a match percentage based on our name and the name returned from tvr $titlepct = $this->checkMatch($title, $arr['name']); if ($titlepct !== false) $titleMatches[$titlepct][] = array('title'=>$arr['name'], 'showid'=>$arr['showid'], 'country'=>$arr['country'], 'genres'=>$arr['genres'], 'tvr'=>$arr); - - // get a match percentage based on our name and the url returned from tvr + + // get a match percentage based on our name and the url returned from tvr if (isset($arr['link']) && preg_match('/tvrage\.com\/((?!shows)[^\/]*)$/i', $arr['link'], $tvrlink)) { $urltitle = str_replace('_', ' ', $tvrlink[1]); @@ -668,7 +668,7 @@ class TvRage if ($urlpct !== false) $urlMatches[$urlpct][] = array('title'=>$urltitle, 'showid'=>$arr['showid'], 'country'=>$arr['country'], 'genres'=>$arr['genres'], 'tvr'=>$arr); } - + // check if there are any akas for this result and get a match percentage for them too if (isset($arr['akas'])) { @@ -688,14 +688,14 @@ class TvRage $akaMatches[$akapct][] = array('title'=>$arr['akas']['aka'], 'showid'=>$arr['showid'], 'country'=>$arr['country'], 'genres'=>$arr['genres'], 'tvr'=>$arr); } } - + } - + // reverse sort our matches so highest matches are first krsort($titleMatches); krsort($urlMatches); krsort($akaMatches); - + // look for 100% title matches first if (isset($titleMatches[100])) { @@ -703,7 +703,7 @@ class TvRage echo 'TVRage : Found 100% match: "'.$titleMatches[100][0]['title'].'"'."\n"; return $titleMatches[100][0]; } - + // look for 100% url matches next if (isset($urlMatches[100])) { @@ -711,7 +711,7 @@ class TvRage echo 'TVRage : Found 100% url match: "'.$urlMatches[100][0]['title'].'"'."\n"; return $urlMatches[100][0]; } - + // look for 100% aka matches next if (isset($akaMatches[100])) { @@ -719,7 +719,7 @@ class TvRage echo 'TVRage : Found 100% aka match: "'.$akaMatches[100][0]['title'].'"'."\n"; return $akaMatches[100][0]; } - + // no 100% matches, loop through what we got and if our next closest match is more than TvRage::MATCH_PROBABILITY % of the title lets take it foreach($titleMatches as $mk=>$mv) { @@ -727,56 +727,56 @@ class TvRage if (isset($showInfo['country']) && !empty($showInfo['country']) && !empty($mv[0]['country'])) if (strtolower($showInfo['country']) != strtolower($mv[0]['country'])) continue; - + if ($this->echooutput) echo 'TVRage : Found '.$mk.'% match: "'.$titleMatches[$mk][0]['title'].'"'."\n"; return $titleMatches[$mk][0]; } - + // same as above but for akas foreach($akaMatches as $ak=>$av) { if (isset($showInfo['country']) && !empty($showInfo['country']) && !empty($av[0]['country'])) if (strtolower($showInfo['country']) != strtolower($av[0]['country'])) continue; - + if ($this->echooutput) echo 'TVRage : Found '.$ak.'% aka match: "'.$akaMatches[$ak][0]['title'].'"'."\n"; return $akaMatches[$ak][0]; } - + return false; - + } else { return false; } - + } else { if ($this->echooutput) echo 'TVRage : Error connecting to tvrage'."\n"; return -1; } - + if ($this->echooutput) echo 'TVRage : No match found online'."\n"; return false; } - + public function checkMatch($ourName, $tvrName) { // clean up name ($ourName is already clean) $tvrName = $this->cleanName($tvrName); $tvrName = preg_replace('/ of /i', '', $tvrName); $ourName = preg_replace('/ of /i', '', $ourName); - + // create our arrays $ourArr = explode(' ', $ourName); $tvrArr = explode(' ', $tvrName); - + // set our match counts $numMatches = 0; $totalMatches = sizeof($ourArr)+sizeof($tvrArr); - + // loop through each array matching again the opposite value, if they match increment! foreach($ourArr as $oname) { @@ -788,23 +788,23 @@ class TvRage if (preg_match('/ '.preg_quote($tname, '/').' /i', ' '.$ourName.' ')) $numMatches++; } - + // check what we're left with if ($numMatches <= 0) return false; else $matchpct = ($numMatches/$totalMatches)*100; - + if ($matchpct >= TvRage::MATCH_PROBABILITY) return $matchpct; else return false; } - + public function cleanName($str) { $str = str_replace(array('.', '_', '-'), ' ', $str); - + $str = str_replace(array('à','á','â','ã','ä','æ','À','Á','Â','Ã','Ä'), 'a', $str); $str = str_replace(array('ç','Ç'), 'c', $str); $str = str_replace(array('Σ','è','é','ê','ë','È','É','Ê','Ë'), 'e', $str); @@ -812,16 +812,16 @@ class TvRage $str = str_replace(array('ò','ó','ô','õ','ö','Ò','Ó','Ô','Õ','Ö'), 'o', $str); $str = str_replace(array('ù','ú','û','ü','ū','Ú','Û','Ü','Ū'), 'u', $str); $str = str_replace('ß', 'ss', $str); - + $str = str_replace('&', 'and', $str); $str = preg_replace('/^(history|discovery) channel/i', '', $str); $str = str_replace(array('\'', ':', '!', '"', '#', '*', '’', ',', '(', ')', '?'), '', $str); $str = str_replace('$', 's', $str); $str = preg_replace('/\s{2,}/', ' ', $str); - + return trim($str); } - + public function fetchCache($key) { $cache = new Cache; @@ -833,16 +833,16 @@ class TvRage } return false; } - + public function storeCache($key, $data) { $cache = new Cache; if ($cache->enabled) return $cache->store($key, $data); - + return false; } - + public function parseNameEpSeason($relname) { $showInfo = array( @@ -855,7 +855,7 @@ class TvRage 'year' => '', 'cleanname' => '' ); - + //S01E01-E02 //S01E01-02 if (preg_match('/^(.*?)[\. \-]s(\d{1,2})\.?e(\d{1,3})(?:\-e?|\-?e)(\d{1,3})\./i', $relname, $matches)) { @@ -962,7 +962,7 @@ class TvRage $showInfo['season'] = intval($matches[2]); $showInfo['episode'] = 'all'; } - + if (!empty($showInfo['name'])) { //country or origin matching if (preg_match('/[\._ ](US|UK|AU|NZ|CA|NL|Canada|Australia|America)/', $showInfo['name'], $countryMatch)) @@ -976,10 +976,10 @@ class TvRage else $showInfo['country'] = strtoupper($countryMatch[1]); } - + //clean show name $showInfo['cleanname'] = $this->cleanName($showInfo['name']); - + //check for dates instead of seasons if (strlen($showInfo['season']) == 4) { $showInfo['seriesfull'] = $showInfo['season']."/".$showInfo['episode']; @@ -987,7 +987,7 @@ class TvRage //get year if present (not for releases with dates as seasons) if (preg_match('/[\._ ](19|20)(\d{2})/i', $relname, $yearMatch)) $showInfo['year'] = $yearMatch[1].$yearMatch[2]; - + $showInfo['season'] = sprintf('S%02d', $showInfo['season']); //check for multi episode release if (is_array($showInfo['episode'])) { @@ -1004,10 +1004,10 @@ class TvRage $showInfo['airdate'] = (!empty($showInfo['airdate'])) ? $showInfo['airdate'].' 00:00:00' : ''; return $showInfo; } - + return false; } - + public function getGenres() { return array( diff --git a/lib/copy_this/www/lib/usermovies.php b/lib/copy_this/www/lib/usermovies.php index 0f52d427a..48d0a120a 100644 --- a/lib/copy_this/www/lib/usermovies.php +++ b/lib/copy_this/www/lib/usermovies.php @@ -4,47 +4,47 @@ require_once(WWW_DIR."/lib/framework/db.php"); class UserMovies { public function addMovie($uid, $imdbid, $catid=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; - + $sql = sprintf("insert into usermovies (userID, imdbID, categoryID, createddate) values (%d, %d, %s, now())", $uid, $imdbid, $catid); - return $db->queryInsert($sql); - } + return $db->queryInsert($sql); + } public function getMovies($uid) - { - $db = new DB(); + { + $db = new Settings(); $sql = sprintf("select usermovies.*, movieinfo.year, movieinfo.plot, movieinfo.cover, movieinfo.title from usermovies left outer join movieinfo on movieinfo.imdbID = usermovies.imdbID where userID = %d order by movieinfo.title asc", $uid); - return $db->query($sql); - } + return $db->query($sql); + } public function delMovie($uid, $imdbid) - { - $db = new DB(); + { + $db = new Settings(); $db->queryExec(sprintf("DELETE from usermovies where userID = %d and imdbID = %d ", $uid, $imdbid)); } - + public function getMovie($uid, $imdbid) - { - $db = new DB(); + { + $db = new Settings(); $sql = sprintf("select usermovies.*, movieinfo.title from usermovies left outer join movieinfo on movieinfo.imdbID = usermovies.imdbID where usermovies.userID = %d and usermovies.imdbID = %d ", $uid, $imdbid); - return $db->queryOneRow($sql); - } + return $db->queryOneRow($sql); + } public function delMovieForUser($uid) - { - $db = new DB(); + { + $db = new Settings(); $db->queryExec(sprintf("DELETE from usermovies where userID = %d", $uid)); - } + } public function updateMovie($uid, $imdbid, $catid=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; - + $sql = sprintf("update usermovies set categoryID = %s where userID = %d and imdbID = %d", $catid, $uid, $imdbid); $db->queryExec($sql); } diff --git a/lib/copy_this/www/lib/users.php b/lib/copy_this/www/lib/users.php index e9a3dafd4..1f713872f 100644 --- a/lib/copy_this/www/lib/users.php +++ b/lib/copy_this/www/lib/users.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/site.php"); require_once(WWW_DIR . "/lib/releases.php"); require_once(WWW_DIR . "/lib/forum.php"); @@ -40,14 +40,14 @@ class Users public function get() { - $db = new DB(); + $db = new Settings(); return $db->query("select * from users"); } public function delete($id) { - $db = new DB(); + $db = new Settings(); $this->delCartForUser($id); $this->delUserCategoryExclusions($id); $this->delDownloadRequests($id); @@ -70,7 +70,7 @@ class Users public function getRange($start, $num, $orderby, $username = '', $email = '', $host = '', $role = '') { - $db = new DB(); + $db = new Settings(); if ($start === false) $limit = ""; @@ -138,7 +138,7 @@ class Users public function getCount() { - $db = new DB(); + $db = new Settings(); $res = $db->queryOneRow("select count(ID) as num from users WHERE email != 'sharing@nZEDb.com'"); return $res["num"]; @@ -146,7 +146,7 @@ class Users public function add($uname, $pass, $email, $role, $notes, $host, $invites = Users::DEFAULT_INVITES, $invitedby = 0) { - $db = new DB(); + $db = new Settings(); $site = new Sites(); $s = $site->get(); @@ -165,7 +165,7 @@ class Users public function update($id, $uname, $email, $grabs, $role, $notes, $invites, $movieview, $musicview, $gameview, $xxxview, $consoleview, $bookview, $queueType = '', $nzbgetURL = '', $nzbgetUsername = '', $nzbgetPassword = '', $saburl = '', $sabapikey = '', $sabpriority = '', $sabapikeytype = '', $nzbvortexServerUrl, $nzbvortexApiKey = false, $cp_url = false, $cp_api = false) { - $db = new DB(); + $db = new Settings(); $uname = trim($uname); $email = trim($email); @@ -245,7 +245,7 @@ class Users public function updateUserRole($uid, $role) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set role = %d where id = %d", $role, $uid)); return Users::SUCCESS; @@ -253,7 +253,7 @@ class Users public function updateUserRoleChangeDate($uid, $date) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users SET rolechangedate = '%s' WHERE ID = %d", $date, $uid)); return Users::SUCCESS; @@ -261,7 +261,7 @@ class Users public function updateExpiredRoles($uprole, $downrole, $msgsubject, $msgbody) { - $db = new DB(); + $db = new Settings(); $site = new Sites; $s = $site->get(); @@ -277,7 +277,7 @@ class Users public function updateRssKey($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set rsstoken = md5(%s) where id = %d", $db->escapeString(uniqid()), $uid)); return Users::SUCCESS; @@ -285,7 +285,7 @@ class Users public function updatePassResetGuid($id, $guid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set resetguid = %s where id = %d", $db->escapeString($guid), $id)); return Users::SUCCESS; @@ -293,7 +293,7 @@ class Users public function updatePassword($id, $password) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set password = %s, userseed=md5(%s) where id = %d", $db->escapeString($this->hashPassword($password)), $db->escapeString(generateUuid()), $id)); return Users::SUCCESS; @@ -301,34 +301,34 @@ class Users public function getByEmail($email) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from users where lower(email) = %s ", $db->escapeString(strtolower($email)))); } public function getByPassResetGuid($guid) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select * from users where resetguid = %s ", $db->escapeString($guid))); } public function getByUsername($uname) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select users.*, userroles.name as rolename, userroles.apirequests, userroles.downloadrequests from users inner join userroles on userroles.ID = users.role where username = %s ", $db->escapeString($uname))); } public function incrementGrabs($id, $num = 1) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set grabs = grabs + %d where id = %d ", $num, $id)); } public function getById($id) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select users.*, userroles.name as rolename, userroles.hideads, userroles.canpreview, userroles.canpre, userroles.apirequests, userroles.downloadrequests, NOW() as now from users inner join userroles on userroles.ID = users.role where users.id = %d ", $id); return $db->queryOneRow($sql); @@ -336,7 +336,7 @@ class Users public function getByIdAndRssToken($id, $rsstoken) { - $db = new DB(); + $db = new Settings(); $res = $this->getById($id); return ($res && $res["rsstoken"] == $rsstoken ? $res : null); @@ -344,7 +344,7 @@ class Users public function getByRssToken($rsstoken) { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow(sprintf("select users.*, userroles.apirequests, userroles.downloadrequests, NOW() as now from users inner join userroles on userroles.ID = users.role where users.rsstoken = %s ", $db->escapeString($rsstoken))); } @@ -366,7 +366,7 @@ class Users public function isDisabled($username) { - $db = new DB(); + $db = new Settings(); $role = $db->queryOneRow(sprintf("select role as role from users where username = %s ", $db->escapeString($username))); return ($role["role"] == Users::ROLE_DISABLED); @@ -544,7 +544,7 @@ class Users public function updateSiteAccessed($uid, $host = "") { - $db = new DB(); + $db = new Settings(); $hostSql = ''; if ($host != '') $hostSql = sprintf(', host = %s', $db->escapeString($host)); @@ -554,7 +554,7 @@ class Users public function updateApiAccessed($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set apiaccess = now() where id = %d ", $uid)); } @@ -568,7 +568,7 @@ class Users public function addCart($uid, $releaseid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("insert into usercart (userID, releaseID, createddate) values (%d, %d, now())", $uid, $releaseid); return $db->queryInsert($sql); @@ -576,7 +576,7 @@ class Users public function getCart($uid, $releaseid = "") { - $db = new DB(); + $db = new Settings(); if ($releaseid != "") $releaseid = " and releases.ID = " . $db->escapeString($releaseid); @@ -585,7 +585,7 @@ class Users public function delCartByGuid($guids, $uid) { - $db = new DB(); + $db = new Settings(); if (!is_array($guids)) return false; @@ -602,7 +602,7 @@ class Users public function delCartByUserAndRelease($guid, $uid) { - $db = new DB(); + $db = new Settings(); $rel = $db->queryOneRow(sprintf("select ID from releases where guid = %s", $db->escapeString($guid))); if ($rel) $db->queryExec(sprintf("DELETE FROM usercart WHERE userID = %d AND releaseID = %d", $uid, $rel["ID"])); @@ -610,19 +610,19 @@ class Users public function delCartForUser($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from usercart where userID = %d", $uid)); } public function delCartForRelease($rid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from usercart where releaseID = %d", $rid)); } public function addCategoryExclusions($uid, $catids) { - $db = new DB(); + $db = new Settings(); $this->delUserCategoryExclusions($uid); if (count($catids) > 0) { foreach ($catids as $catid) { @@ -633,7 +633,7 @@ class Users public function getCategoryExclusion($uid) { - $db = new DB(); + $db = new Settings(); $ret = array(); $data = $db->query(sprintf("select categoryID from userexcat where userID = %d union distinct select categoryID from roleexcat inner join users on users.role = roleexcat.role where users.ID = %d", $uid, $uid)); foreach ($data as $d) @@ -644,7 +644,7 @@ class Users public function getRoleCategoryExclusion($role) { - $db = new DB(); + $db = new Settings(); $ret = array(); $data = $db->query(sprintf("select categoryID from roleexcat where role = %d", $role)); foreach ($data as $d) @@ -655,7 +655,7 @@ class Users public function addRoleCategoryExclusions($role, $catids) { - $db = new DB(); + $db = new Settings(); $this->delRoleCategoryExclusions($role); if (count($catids) > 0) { foreach ($catids as $catid) { @@ -670,7 +670,7 @@ class Users $ret = array(); if ($data) { - $db = new DB(); + $db = new Settings(); $category = new Category(); $data = $category->getByIds($data); foreach ($data as $d) @@ -682,19 +682,19 @@ class Users public function delCategoryExclusion($uid, $catid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userexcat where userID = %d and categoryID = %d", $uid, $catid)); } public function delUserCategoryExclusions($uid) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userexcat where userID = %d", $uid)); } public function delRoleCategoryExclusions($role) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from roleexcat where role = %d", $role)); } @@ -714,7 +714,7 @@ class Users public function getInvite($inviteToken) { - $db = new DB(); + $db = new Settings(); // // Tidy any old invites sent greater than DEFAULT_INVITE_EXPIRY_DAYS days ago. @@ -726,13 +726,13 @@ class Users public function addInvite($uid, $inviteToken) { - $db = new DB(); + $db = new Settings(); $db->queryInsert(sprintf("insert into userinvite (guid, userID, createddate) values (%s, %d, now())", $db->escapeString($inviteToken), $uid)); } public function deleteInvite($inviteToken) { - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("DELETE from userinvite where guid = %s ", $db->escapeString($inviteToken))); } @@ -742,7 +742,7 @@ class Users if (!$invite) return -1; - $db = new DB(); + $db = new Settings(); $db->queryExec(sprintf("update users set invites = case when invites <= 0 then 0 else invites-1 end where ID = %d ", $invite["userID"])); $this->deleteInvite($invitecode); @@ -751,7 +751,7 @@ class Users public function getTopGrabbers() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT ID, username, SUM(grabs) as grabs FROM users GROUP BY ID, username @@ -763,7 +763,7 @@ class Users public function getUsersByMonth() { - $db = new DB(); + $db = new Settings(); return $db->query("SELECT DATE_FORMAT(createddate, '%M %Y') AS mth, COUNT(*) AS num FROM users @@ -775,7 +775,7 @@ class Users public function getUsersByHostHash() { - $db = new DB(); + $db = new Settings(); $site = new Sites(); $s = $site->get(); @@ -808,7 +808,7 @@ class Users public function getUsersByRole() { - $db = new DB(); + $db = new Settings(); return $db->query("select ur.name, count(u.ID) as num from users u inner join userroles ur on ur.ID = u.role @@ -819,7 +819,7 @@ class Users public function getLoginCountsByMonth() { - $db = new DB(); + $db = new Settings(); return $db->query("select 'Login' as type, sum(case when lastlogin > curdate() - INTERVAL 1 DAY then 1 else 0 end) as 1day, @@ -843,14 +843,14 @@ class Users public function getRoles() { - $db = new DB(); + $db = new Settings(); return $db->query("select * from userroles"); } public function getRoleById($id) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select * from userroles where ID = %d", $id); return $db->queryOneRow($sql); @@ -858,14 +858,14 @@ class Users public function getDefaultRole() { - $db = new DB(); + $db = new Settings(); return $db->queryOneRow("select * from userroles where isdefault = 1"); } public function addRole($name, $apirequests, $downloadrequests, $defaultinvites, $canpreview, $canpre, $hideads) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("insert into userroles (name, apirequests, downloadrequests, defaultinvites, canpreview, canpre, hideads) VALUES (%s, %d, %d, %d, %d, %d)", $db->escapeString($name), $apirequests, $downloadrequests, $defaultinvites, $canpreview, $canpre, $hideads); return $db->queryInsert($sql); @@ -873,7 +873,7 @@ class Users public function updateRole($id, $name, $apirequests, $downloadrequests, $defaultinvites, $isdefault, $canpreview, $canpre, $hideads) { - $db = new DB(); + $db = new Settings(); if ($isdefault == 1) $db->queryExec("update userroles set isdefault=0"); @@ -882,7 +882,7 @@ class Users public function deleteRole($id) { - $db = new DB(); + $db = new Settings(); $res = $db->query(sprintf("select ID from users where role = %d", $id)); if (sizeof($res) > 0) { $userids = array(); @@ -898,7 +898,7 @@ class Users public function getApiRequests($userid) { - $db = new DB(); + $db = new Settings(); //clear old requests //$db->queryExec(sprintf("DELETE FROM userrequests WHERE (userID = %d AND timestamp < DATE_SUB(NOW(), INTERVAL 1 DAY))", $userid)); $db->queryExec(sprintf("DELETE FROM userrequests WHERE timestamp < DATE_SUB(NOW(), INTERVAL 1 DAY)", $userid)); @@ -910,7 +910,7 @@ class Users public function addApiRequest($userid, $request, $hosthash) { - $db = new DB(); + $db = new Settings(); $hosthash = ($hosthash != "" ? $db->escapeString($hosthash) : "null"); $sql = sprintf("insert into userrequests (userID, request, timestamp, hosthash) VALUES (%d, %s, now(), %s)", $userid, $db->escapeString($request), $hosthash); @@ -920,7 +920,7 @@ class Users public function delApiRequests($userid) { - $db = new DB(); + $db = new Settings(); return $db->queryInsert(sprintf("delete from userrequests where userID = %d", $userid)); } @@ -933,7 +933,7 @@ class Users */ public function pruneRequestHistory($days = 0) { - $db = new DB(); + $db = new Settings(); if ($days == 0) { $days = 1; $db->queryExec("update userdownloads set releaseID = null"); @@ -945,7 +945,7 @@ class Users public function getDownloadRequests($userid, $hosthash = "", $site = "") { - $db = new DB(); + $db = new Settings(); if ($hosthash != "" && $site->userhostexclusion != '') { $ipsql = ""; @@ -965,7 +965,7 @@ class Users public function getDownloadRequestsForUserAndAllHostHashes($userid) { - $db = new DB(); + $db = new Settings(); $sql = sprintf("select distinct hosthash from userdownloads where userID = %d and hosthash is not null and hosthash != ''", $userid); $rows = $db->query($sql); @@ -982,7 +982,7 @@ class Users public function addDownloadRequest($userid, $hosthash, $relGuid) { - $db = new DB(); + $db = new Settings(); $hosthash = ($hosthash != "" ? $db->escapeString($hosthash) : "null"); $sql = sprintf("insert into userdownloads (userID, timestamp, hosthash, releaseID) VALUES (%d, now(), %s, (select ID from releases where guid = %s))", $userid, $hosthash, $db->escapeString($relGuid)); @@ -992,14 +992,14 @@ class Users public function delDownloadRequests($userid) { - $db = new DB(); + $db = new Settings(); return $db->queryInsert(sprintf("delete from userdownloads where userID = %d", $userid)); } public function delDownloadRequestsForRelease($releaseID) { - $db = new DB(); + $db = new Settings(); return $db->queryInsert(sprintf("delete from userdownloads where releaseID = %d", $releaseID)); } diff --git a/lib/copy_this/www/lib/userseries.php b/lib/copy_this/www/lib/userseries.php index fb5155fa2..5298151d9 100644 --- a/lib/copy_this/www/lib/userseries.php +++ b/lib/copy_this/www/lib/userseries.php @@ -4,53 +4,53 @@ require_once(WWW_DIR."/lib/framework/db.php"); class UserSeries { public function addShow($uid, $rageid, $catid=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; - + $sql = sprintf("insert into userseries (userID, rageID, categoryID, createddate) values (%d, %d, %s, now())", $uid, $rageid, $catid); - return $db->queryInsert($sql); - } + return $db->queryInsert($sql); + } public function getShows($uid) - { - $db = new DB(); + { + $db = new Settings(); $sql = sprintf("select userseries.*, tvrage.releasetitle from userseries inner join (SELECT ID, releasetitle, rageid FROM tvrage GROUP BY rageid) tvrage on tvrage.rageID = userseries.rageID where userID = %d order by tvrage.releasetitle asc", $uid); - return $db->query($sql); - } + return $db->query($sql); + } public function delShow($uid, $rageid) - { - $db = new DB(); + { + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where userID = %d and rageID = %d ", $uid, $rageid)); } - + public function getShow($uid, $rageid) - { - $db = new DB(); + { + $db = new Settings(); $sql = sprintf("select userseries.*, tvrage.releasetitle from userseries left outer join (SELECT ID, releasetitle, rageid FROM tvrage GROUP BY rageid) tvrage on tvrage.rageID = userseries.rageID where userseries.userID = %d and userseries.rageID = %d ", $uid, $rageid); - return $db->queryOneRow($sql); - } + return $db->queryOneRow($sql); + } public function delShowForUser($uid) - { - $db = new DB(); + { + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where userID = %d", $uid)); - } + } public function delShowForSeries($sid) - { - $db = new DB(); + { + $db = new Settings(); $db->queryExec(sprintf("DELETE from userseries where rageID = %d", $sid)); } - + public function updateShow($uid, $rageid, $catid=array()) - { - $db = new DB(); - + { + $db = new Settings(); + $catid = (!empty($catid)) ? $db->escapeString(implode('|', $catid)) : "null"; - + $sql = sprintf("update userseries set categoryID = %s where userID = %d and rageID = %d", $catid, $uid, $rageid); $db->queryExec($sql); } diff --git a/lib/copy_this/www/pages/prehashinfo.php b/lib/copy_this/www/pages/prehashinfo.php index 9e6ec8a36..1f21374f8 100644 --- a/lib/copy_this/www/pages/prehashinfo.php +++ b/lib/copy_this/www/pages/prehashinfo.php @@ -1,6 +1,6 @@ <?php require_once(WWW_DIR . "/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . '/../misc/update_scripts/nix_scripts/tmux/lib/functions.php'); /** @@ -152,7 +152,7 @@ if (isset($_GET['type'])) { case 'r': case 'requestID': if (isset($_GET['reqid']) && is_numeric($_GET['reqid']) && isset($_GET['group']) && is_string($_GET['group'])) { - $db = new DB(); + $db = new Settings(); $preData = $db->query( sprintf(' SELECT p.* @@ -178,7 +178,7 @@ if (isset($_GET['type'])) { case 't': case 'title': if (isset($_GET['title'])) { - $db = new DB(); + $db = new Settings(); $preData = $db->query( sprintf('SELECT * FROM prehash p WHERE p.title %s %s %s LIKE %s LIMIT %d OFFSET %d', $newer, @@ -196,7 +196,7 @@ if (isset($_GET['type'])) { case 'm': case 'md5': if (isset($_GET['md5']) && strlen($_GET['title']) === 32) { - $db = new DB(); + $db = new Settings(); $preData = $db->query( sprintf('SELECT * FROM prehash p INNER JOIN predbhash ph ON ph.pre_id = p.ID WHERE MATCH(hashes) AGAINST (%s) %s %s %s LIMIT %d OFFSET %d', $db->escapeString($_GET['md5']), @@ -213,7 +213,7 @@ if (isset($_GET['type'])) { case 's': case 'sha1': if (isset($_GET['sha1']) && strlen($_GET['sha1']) === 40) { - $db = new DB(); + $db = new Settings(); $preData = $db->query( sprintf('SELECT * FROM prehash p INNER JOIN predbhash ph ON ph.pre_id = p.ID WHERE MATCH(hashes) AGAINST (%s) %s %s %s LIMIT %d OFFSET %d', $db->escapeString($_GET['sha1']), @@ -229,7 +229,7 @@ if (isset($_GET['type'])) { case 'a': case 'all': - $db = new DB(); + $db = new Settings(); $preData = $db->query( sprintf('SELECT * FROM prehash p WHERE 1=1 %s %s %s ORDER BY p.predate DESC LIMIT %d OFFSET %d', $newer, diff --git a/lib/functions.php b/lib/functions.php index a69953fa9..554200189 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1,5 +1,5 @@ <?php -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/category.php"); require_once(WWW_DIR . "/lib/releases.php"); require_once(WWW_DIR . "/lib/releaseimage.php"); @@ -36,7 +36,7 @@ class Functions $this->p = new Postprocess(); $this->echooutput = $echooutput; $this->c = new ColorCLI(); - $this->db = new DB(); + $this->db = new Settings(); $this->groups = new Groups(); $this->m = new Movie(); $this->consoleTools = new ConsoleTools(); diff --git a/lib/testing/DB/reset_postprocessing.php b/lib/testing/DB/reset_postprocessing.php index 77cae2fcc..b86e820e3 100644 --- a/lib/testing/DB/reset_postprocessing.php +++ b/lib/testing/DB/reset_postprocessing.php @@ -1,10 +1,10 @@ <?php require_once(dirname(__FILE__) . "/../../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); require_once(WWW_DIR . "/lib/ConsoleTools.php"); -$pdo = new DB(); +$pdo = new Settings(); $consoletools = new ConsoleTools(); $pdo->log = new ColorCLI(); $ran = false; diff --git a/lib/testing/convert_mysql_tables.php b/lib/testing/convert_mysql_tables.php index 9111abf62..e032ed611 100644 --- a/lib/testing/convert_mysql_tables.php +++ b/lib/testing/convert_mysql_tables.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__) . "/../../bin/config.php"); require_once(WWW_DIR."lib/framework/db.php"); $sql = "SHOW tables"; -$db = new DB(); +$db = new Settings(); if (isset($argv[1]) && $argv[1] == "myisam") { diff --git a/lib/testing/getGames.php b/lib/testing/getGames.php index 4116d005d..4381e1c04 100644 --- a/lib/testing/getGames.php +++ b/lib/testing/getGames.php @@ -6,7 +6,7 @@ require_once(WWW_DIR . "/lib/ColorCLI.php"); $game = new Games(true); -$pdo = new DB(); +$pdo = new Settings(); $c = new ColorCLI(); $res = $pdo->query( diff --git a/lib/testing/getXXXCovers.php b/lib/testing/getXXXCovers.php index 8b83922fb..47f979f3a 100644 --- a/lib/testing/getXXXCovers.php +++ b/lib/testing/getXXXCovers.php @@ -5,7 +5,7 @@ require_once(WWW_DIR . "/lib/XXX.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$pdo = new DB(); +$pdo = new Settings(); $movie = new XXX(); $c = new ColorCLI(); diff --git a/lib/testing/populate_anidb.php b/lib/testing/populate_anidb.php index 9435366d4..9ddd23d95 100644 --- a/lib/testing/populate_anidb.php +++ b/lib/testing/populate_anidb.php @@ -4,7 +4,7 @@ */ require_once(dirname(__FILE__) . "/../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/util.php"); require_once(WWW_DIR . "/lib/releaseimage.php"); require_once(WWW_DIR . "/lib/Tmux.php"); @@ -14,7 +14,7 @@ class AniDBstandAlone { const CLIENTVER = 1; function __construct($echooutput=false) { - $this->pdo = new DB(); + $this->pdo = new Settings(); $t = new Tmux(); $this->tmux = $t->get(); $s = new Sites(); diff --git a/lib/testing/recategorize.php b/lib/testing/recategorize.php index 8fcb536c1..200675a76 100644 --- a/lib/testing/recategorize.php +++ b/lib/testing/recategorize.php @@ -1,6 +1,6 @@ <?php require_once(dirname(__FILE__) . "/../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/category.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); require_once(WWW_DIR . "/lib/ConsoleTools.php"); @@ -66,7 +66,7 @@ function reCategorize($argv) // Returns the quantity of categorized releases. function categorizeRelease($update = true, $where, $echooutput = false) { - $pdo = new DB(); + $pdo = new Settings(); $cat = new Categorize(); $consoletools = new consoleTools(); $relcount = $chgcount = 0; diff --git a/lib/testing/updateGamesImages.php b/lib/testing/updateGamesImages.php index 6cdc0a641..0578fcd62 100644 --- a/lib/testing/updateGamesImages.php +++ b/lib/testing/updateGamesImages.php @@ -1,9 +1,9 @@ <?php require_once(dirname(__FILE__) . "/../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$pdo = new DB(); +$pdo = new Settings(); $covers = $updated = $deleted = 0; $c = new ColorCLI(); diff --git a/lib/testing/updateXXXImages.php b/lib/testing/updateXXXImages.php index 8f13cf7b2..6affc6c2e 100644 --- a/lib/testing/updateXXXImages.php +++ b/lib/testing/updateXXXImages.php @@ -1,9 +1,9 @@ <?php require_once(dirname(__FILE__) . "/../../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$pdo = new DB(); +$pdo = new Settings(); $c = new ColorCLI(); $covers = $updated = $deleted = 0; diff --git a/nnscripts/lib/nnscripts.php b/nnscripts/lib/nnscripts.php index 23515aac5..16577684a 100644 --- a/nnscripts/lib/nnscripts.php +++ b/nnscripts/lib/nnscripts.php @@ -13,7 +13,7 @@ require_once(WWW_DIR."lib/site.php"); /** * This class contains the functions used by the other NNScripts - * + * * @author NN Scripts * @license http://opensource.org/licenses/MIT MIT License * @copyright (c) 2013 - NN Scripts @@ -30,13 +30,13 @@ abstract class NNScripts * @var string */ protected $scriptName = 'Unknown NNScript'; - + /** * The script version (needs to be set in the real script) * @var string */ protected $scriptVersion = '0.0'; - + /** * Allowed settings * @var array @@ -54,7 +54,7 @@ abstract class NNScripts * @var DB */ protected $db; - + /** * The settings read from the ini file * @var string @@ -66,7 +66,7 @@ abstract class NNScripts * @var null|Getopt */ protected $options = null; - + /** * Disable the limit option * @var bool @@ -93,7 +93,7 @@ abstract class NNScripts $this->site = $site->get(); // Initiate the database connection - $this->db = new DB(); + $this->db = new Settings(); // Read the settings from the ini file $this->readSettings(); @@ -147,7 +147,7 @@ abstract class NNScripts */ protected function setLimit() { - $limit = ( isset( $this->settings['limit'] ) ? $this->settings['limit'] : null ); + $limit = ( isset( $this->settings['limit'] ) ? $this->settings['limit'] : null ); if( null === $limit && in_array( 'limit', $this->allowedSettings ) ) { // Not set by settings.ini @@ -156,16 +156,16 @@ abstract class NNScripts // Get the limit and convert to hours $limit = (float)str_replace( ',', '.', $this->site->rawretentiondays ) * 24; } - + // Set the new limit $this->settings['limit'] = $limit; } } - + /** * Read the settings from the config.ini fille - * + * * @return void */ protected function readSettings() @@ -183,13 +183,13 @@ abstract class NNScripts // Try to read the ini file $settingsFile = "/settings.ini"; $iniArray = $this->parseIniFile( $settingsFile, true ); - + // Parse the "global" settings $this->parseIniSettings( $settings, $iniArray, 'global' ); // Parse the class settings $this->parseIniSettings( $settings, $iniArray, get_class( $this ) ); - + // Remove all the not used settings if( is_array( $this->allowedSettings ) && 0 < count( $this->allowedSettings ) ) { @@ -224,7 +224,7 @@ abstract class NNScripts { if( array_key_exists( $settingKey, $iniArray[ $key ] ) ) { - $value = $iniArray[ $key ][ $settingKey ]; + $value = $iniArray[ $key ][ $settingKey ]; if( is_numeric( $value ) ) { $value = ( preg_match('/^[0-9]+$/', $value ) ? (int)$value : (float)$value ); @@ -301,7 +301,7 @@ abstract class NNScripts $values[ $i - 1 ][ $key ] = $value; } } - + for( $j=0; $j<$i; $j++ ) { if( array_key_exists( $j, $sections ) && array_key_exists( $j, $values ) ) @@ -339,17 +339,17 @@ abstract class NNScripts if( isset( $options[ $last ][3] ) ) $options[ $last ][3] = $options[ $last ][3] . PHP_EOL; } - + // Add the quiet option if( in_array( 'display', $basics ) ) { $o1 = ( true === $this->settings['display'] ? ' (settings default)' : '' ); $options[] = array( 'd', 'display', Ulrichsg\Getopt::NO_ARGUMENT, sprintf( 'Enable output%s', $o1 ) ); - + $o2 = ( false === $this->settings['display'] ? ' (settings default)' : '' ); $options[] = array( 'q', 'quiet', Ulrichsg\Getopt::NO_ARGUMENT, sprintf( 'Disable output%s'. PHP_EOL, $o2 ) ); } - + // Add the nolimit option if( in_array( 'limit', $basics ) ) { @@ -366,7 +366,7 @@ abstract class NNScripts $o2 = ( false === $this->settings['remove'] ? ' (settings default)' : '' ); $options[] = array( 'k', 'keep', Ulrichsg\Getopt::NO_ARGUMENT, sprintf( 'Disable the removal of releases%s'. PHP_EOL, $o2 ) ); } - + // Add the debug option if( in_array( 'debug', $basics ) ) { @@ -417,14 +417,14 @@ abstract class NNScripts { throw new Exception( 'Option \'limit\' must be numeric' ); } - + $this->settings['limit'] = false; if( 0 < (float)$this->options->getOption('limit') ) { $this->settings['limit'] = (float)$this->options->getOption('limit'); } } - + // Full database if( $this->options->getOption('full') ) $this->settings['full'] = true; @@ -434,7 +434,7 @@ abstract class NNScripts $this->settings['remove'] = true; if( $this->options->getOption('keep') ) $this->settings['remove'] = false; - + // Check for display options if( $this->options->getOption('quiet') ) $this->settings['display'] = false; @@ -444,7 +444,7 @@ abstract class NNScripts // Debug? if( $this->options->getOption('debug') ) $this->settings['debug'] = true; - + // Query limit if( $this->options->getOption('querylimit') ) if( is_numeric( $this->options->getOption('querylimit') ) ) @@ -518,7 +518,7 @@ abstract class NNScripts $this->displayTitle(); $this->display( PHP_EOL ); } - + /** * Display app settings * @return void @@ -573,7 +573,7 @@ abstract class NNScripts } $this->display( PHP_EOL . sprintf( "- update: %s", $line ) ); } - + // querylimit if( isset( $this->settings['querylimit'] ) && null !== $this->settings['querylimit'] ) { diff --git a/scripts/reset_rar_check.php b/scripts/reset_rar_check.php index f36f28c4e..d1b7cef03 100755 --- a/scripts/reset_rar_check.php +++ b/scripts/reset_rar_check.php @@ -1,6 +1,6 @@ <?php require(dirname(__FILE__) . "/../bin/config.php"); -require_once(WWW_DIR . "/lib/framework/db.php"); +require_once(WWW_DIR . "/lib/framework/Settings.php"); $db = new DB; diff --git a/start.php b/start.php index c9a8d9055..fee879fa2 100644 --- a/start.php +++ b/start.php @@ -5,7 +5,7 @@ require_once (WWW_DIR.'/lib/site.php'); require_once(WWW_DIR. '/lib/Tmux.php'); require_once(WWW_DIR . "/lib/ColorCLI.php"); -$db = new DB(); +$db = new Settings(); $DIR = dirname (__FILE__); $c = new ColorCLI(); $s = new Sites(); @@ -168,7 +168,7 @@ function window_ircscraper($tmux_session) function window_sharing($tmux_session) { - $db = new DB(); + $db = new Settings(); $sharing = $db->queryOneRow('SELECT enabled, posting, fetching FROM sharing'); $t = new Tmux(); $tmux = $t->get();