@@ -5,7 +5,6 @@ |
||
5 | 5 | |
6 | 6 | // This script is simply so I can show sleep progress in bash script |
7 | 7 | $consoletools = new ConsoleTools(); |
8 | -if (isset($argv[1]) && is_numeric($argv[1])) |
|
9 | -{ |
|
8 | +if (isset($argv[1]) && is_numeric($argv[1])) { |
|
10 | 9 | $consoletools->showsleep($argv[1]); |
11 | 10 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | $namefixer->checked++; |
58 | 58 | } |
59 | - }else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
59 | + } else if (isset($pieces[1]) && $pieces[0] == 'md5') { |
|
60 | 60 | $release = $pieces[1]; |
61 | 61 | if ($res = $db->queryOneRow(sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, dehashstatus, rf.name AS filename FROM releases r LEFT JOIN release_files rf ON r.id = rf.releases_id WHERE r.id = %d', $release))) { |
62 | 62 | if (preg_match('/[a-fA-F0-9]{32,40}/i', $res['name'], $matches)) { |
@@ -29,19 +29,24 @@ discard block |
||
29 | 29 | } else { |
30 | 30 | $util = new Utility(); |
31 | 31 | $path = (!$util->endsWith($argv[1], "/") ? $argv[1] . "/" : $argv[1]); |
32 | - if (isset($argv[2])) |
|
33 | - $usefilename = strtolower($argv[2]) == 'true'; |
|
34 | - if (isset($argv[3])) |
|
35 | - $dupecheck = strtolower($argv[3]) == 'true'; |
|
36 | - if (isset($argv[4])) |
|
37 | - $movefiles = strtolower($argv[4]) == 'true'; |
|
38 | - if (isset($argv[5]) && is_numeric($argv[5])) |
|
39 | - $categoryoverride = $argv[5]; |
|
40 | -} |
|
32 | + if (isset($argv[2])) { |
|
33 | + $usefilename = strtolower($argv[2]) == 'true'; |
|
34 | + } |
|
35 | + if (isset($argv[3])) { |
|
36 | + $dupecheck = strtolower($argv[3]) == 'true'; |
|
37 | + } |
|
38 | + if (isset($argv[4])) { |
|
39 | + $movefiles = strtolower($argv[4]) == 'true'; |
|
40 | + } |
|
41 | + if (isset($argv[5]) && is_numeric($argv[5])) { |
|
42 | + $categoryoverride = $argv[5]; |
|
43 | + } |
|
44 | + } |
|
41 | 45 | |
42 | 46 | $groups = $db->query("SELECT id, name FROM groups"); |
43 | -foreach ($groups as $group) |
|
47 | +foreach ($groups as $group) { |
|
44 | 48 | $siteGroups[$group["name"]] = $group["id"]; |
49 | +} |
|
45 | 50 | |
46 | 51 | echo "\nUsage: php import.php [path(string)] [usefilename(true/false)] [dupecheck(true/false)] [movefiles(true/false)] [overridecategory(number)]\n"; |
47 | 52 | |
@@ -66,8 +71,12 @@ discard block |
||
66 | 71 | if (!$nzbInfo->loadFromFile($nzbFile, true)) { |
67 | 72 | echo "Failed to load nzb from disk " . $nzbFile . "\n"; |
68 | 73 | if ($movefiles) { |
69 | - if (!file_exists($errorpath)) mkdir($errorpath); |
|
70 | - if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile)); |
|
74 | + if (!file_exists($errorpath)) { |
|
75 | + mkdir($errorpath); |
|
76 | + } |
|
77 | + if (!file_exists($errorpath . basename($nzbFile))) { |
|
78 | + rename($nzbFile, $errorpath . basename($nzbFile)); |
|
79 | + } |
|
71 | 80 | } |
72 | 81 | } else { |
73 | 82 | if ($dupecheck) { |
@@ -75,8 +84,12 @@ discard block |
||
75 | 84 | if ($dupes['total'] > 0) { |
76 | 85 | echo sprintf("%0" . $digits . "d %.2f%% Error : Dupe %s - GID(%s)\n", $items - $num, $num / $items * 100, $nzbFile, $nzbInfo->gid); |
77 | 86 | if ($movefiles) { |
78 | - if (!file_exists($dupepath)) mkdir($dupepath); |
|
79 | - if (!file_exists($dupepath . basename($nzbFile))) rename($nzbFile, $dupepath . basename($nzbFile)); |
|
87 | + if (!file_exists($dupepath)) { |
|
88 | + mkdir($dupepath); |
|
89 | + } |
|
90 | + if (!file_exists($dupepath . basename($nzbFile))) { |
|
91 | + rename($nzbFile, $dupepath . basename($nzbFile)); |
|
92 | + } |
|
80 | 93 | } |
81 | 94 | continue; |
82 | 95 | } |
@@ -94,8 +107,12 @@ discard block |
||
94 | 107 | if ($groupID == -1) { |
95 | 108 | echo sprintf("%0" . $digits . "d %.2f%% Error : Missing group %s - Group(%s)\n", $items - $num, $num / $items * 100, $nzbFile, str_replace("alt.binaries.", "a.b.", implode(",", $nzbInfo->groups))); |
96 | 109 | if ($movefiles) { |
97 | - if (!file_exists($nogrouppath)) mkdir($nogrouppath); |
|
98 | - if (!file_exists($nogrouppath . basename($nzbFile))) rename($nzbFile, $nogrouppath . basename($nzbFile)); |
|
110 | + if (!file_exists($nogrouppath)) { |
|
111 | + mkdir($nogrouppath); |
|
112 | + } |
|
113 | + if (!file_exists($nogrouppath . basename($nzbFile))) { |
|
114 | + rename($nzbFile, $nogrouppath . basename($nzbFile)); |
|
115 | + } |
|
99 | 116 | $missinggroups = array_merge($missinggroups, $nzbInfo->groups); |
100 | 117 | } |
101 | 118 | continue; |
@@ -114,14 +131,22 @@ discard block |
||
114 | 131 | gzclose($fp); |
115 | 132 | echo sprintf("%0" . $digits . "d %.2f%% Imported %s\n", $items - $num, $num / $items * 100, $name); |
116 | 133 | if ($movefiles) { |
117 | - if (!file_exists($importedpath)) mkdir($importedpath); |
|
118 | - if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile)); |
|
134 | + if (!file_exists($importedpath)) { |
|
135 | + mkdir($importedpath); |
|
136 | + } |
|
137 | + if (!file_exists($importedpath . basename($nzbFile))) { |
|
138 | + rename($nzbFile, $importedpath . basename($nzbFile)); |
|
139 | + } |
|
119 | 140 | } |
120 | 141 | } else { |
121 | 142 | echo sprintf("%0" . $digits . "d %.2f%% Error : Failed to write file to disk %s\n", $items - $num, $num / $items * 100, $nzbfilename); |
122 | 143 | if ($movefiles) { |
123 | - if (!file_exists($errorpath)) mkdir($errorpath); |
|
124 | - if (!file_exists($errorpath . basename($nzbFile))) rename($nzbFile, $errorpath . basename($nzbFile)); |
|
144 | + if (!file_exists($errorpath)) { |
|
145 | + mkdir($errorpath); |
|
146 | + } |
|
147 | + if (!file_exists($errorpath . basename($nzbFile))) { |
|
148 | + rename($nzbFile, $errorpath . basename($nzbFile)); |
|
149 | + } |
|
125 | 150 | } |
126 | 151 | $releases->deleteSingle(['g' => $relguid, 'i' => $relid], $nzb, $releaseImage); |
127 | 152 | } |
@@ -173,14 +198,22 @@ discard block |
||
173 | 198 | if ($binaryId != 0) { |
174 | 199 | echo sprintf("%0" . $digits . "d %.2f%% Imported %s (%d:%s-%d/%d)\n", $items - $num, $num / $items * 100, basename($nzbFile), $regexMatches['regcatid'], $regexMatches['regexid'], $numbins, $numparts); |
175 | 200 | if ($movefiles) { |
176 | - if (!file_exists($importedpath)) mkdir($importedpath); |
|
177 | - if (!file_exists($importedpath . basename($nzbFile))) rename($nzbFile, $importedpath . basename($nzbFile)); |
|
201 | + if (!file_exists($importedpath)) { |
|
202 | + mkdir($importedpath); |
|
203 | + } |
|
204 | + if (!file_exists($importedpath . basename($nzbFile))) { |
|
205 | + rename($nzbFile, $importedpath . basename($nzbFile)); |
|
206 | + } |
|
178 | 207 | } |
179 | 208 | } else { |
180 | 209 | echo sprintf("%0" . $digits . "d %.2f%% Error : No Regex Match %s\n", $items - $num, $num / $items * 100, basename($nzbFile)); |
181 | 210 | if ($movefiles) { |
182 | - if (!file_exists($noregexpath)) mkdir($noregexpath); |
|
183 | - if (!file_exists($noregexpath . basename($nzbFile))) rename($nzbFile, $noregexpath . basename($nzbFile)); |
|
211 | + if (!file_exists($noregexpath)) { |
|
212 | + mkdir($noregexpath); |
|
213 | + } |
|
214 | + if (!file_exists($noregexpath . basename($nzbFile))) { |
|
215 | + rename($nzbFile, $noregexpath . basename($nzbFile)); |
|
216 | + } |
|
184 | 217 | } |
185 | 218 | } |
186 | 219 | } |
@@ -192,8 +225,9 @@ discard block |
||
192 | 225 | $missinggroups = array_unique($missinggroups); |
193 | 226 | $grpsql = "INSERT INTO groups (name, backfill_target, first_record, first_record_postdate, last_record, last_record_postdate, last_updated, minfilestoformrelease, minsizetoformrelease, active, regexmatchonly, description) VALUES ('%s', 0, 0, null, 0, null, null, null, null, 0, 1, 'Added by import');\n"; |
194 | 227 | $grpout = ""; |
195 | - foreach ($missinggroups as $mg) |
|
196 | - $grpout .= sprintf($grpsql, $mg); |
|
228 | + foreach ($missinggroups as $mg) { |
|
229 | + $grpout .= sprintf($grpsql, $mg); |
|
230 | + } |
|
197 | 231 | |
198 | 232 | @file_put_contents(sprintf("missing_groups_%s.sql", uniqid()), $grpout); |
199 | 233 | } |
@@ -25,16 +25,18 @@ |
||
25 | 25 | |
26 | 26 | $time = 0; |
27 | 27 | |
28 | -if (isset($argv[1])) |
|
28 | +if (isset($argv[1])) { |
|
29 | 29 | $time = strtotime($argv[1]); |
30 | +} |
|
30 | 31 | |
31 | 32 | if (($time > 1) && ($time < time())) { |
32 | 33 | $groupName = (isset($argv[2]) ? $argv[2] : ''); |
33 | 34 | |
34 | - if (isset($argv[3]) && $argv[3] == true) |
|
35 | - $regexOnly = true; |
|
36 | - else |
|
37 | - $regexOnly = false; |
|
35 | + if (isset($argv[3]) && $argv[3] == true) { |
|
36 | + $regexOnly = true; |
|
37 | + } else { |
|
38 | + $regexOnly = false; |
|
39 | + } |
|
38 | 40 | |
39 | 41 | $backfill = new Backfill(); |
40 | 42 | $backfill->backfillAllGroups($groupName, strtotime($argv[1]), $regexOnly); |
@@ -30,8 +30,7 @@ |
||
30 | 30 | //$movies = $db->query("SELECT imdbid from movieinfo where trailer is null and tmdbid is not null"); |
31 | 31 | |
32 | 32 | |
33 | -if (count($movies) == 0) |
|
34 | -{ |
|
33 | +if (count($movies) == 0) { |
|
35 | 34 | echo "No records selected to update - either uncomment case or no matches found.\n"; |
36 | 35 | die(); |
37 | 36 | } |
@@ -7,20 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $db = new DB(); |
9 | 9 | $res = $db->queryOneRow( sprintf("Select now()")); |
10 | -foreach($res as $time){ |
|
10 | +foreach($res as $time) { |
|
11 | 11 | echo "Mysql Time Is Now ".$time."\n";} |
12 | 12 | $res=""; |
13 | 13 | $res = date('r'); |
14 | 14 | echo "PHP Time Is Now ".$res."\n"; |
15 | 15 | $res=""; |
16 | 16 | |
17 | -if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') |
|
18 | -{ |
|
17 | +if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
19 | 18 | exec("time /t", $res); |
20 | 19 | echo "System Time is Now ".$res['0']."\n"; |
21 | -} |
|
22 | -else |
|
23 | -{ |
|
20 | +} else { |
|
24 | 21 | exec("date", $res); |
25 | 22 | echo "System Time is Now ".$res['0']."\n"; |
26 | 23 | } |
@@ -9,11 +9,9 @@ |
||
9 | 9 | $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
10 | 10 | |
11 | 11 | // Start the transaction |
12 | - if( $db->beginTransaction() ) |
|
13 | - { |
|
12 | + if( $db->beginTransaction() ) { |
|
14 | 13 | // Loop 20 times |
15 | - for($i=1 ; $i<=20 ; $i++ ) |
|
16 | - { |
|
14 | + for($i=1 ; $i<=20 ; $i++ ) { |
|
17 | 15 | // Header |
18 | 16 | echo "--[ Insert run: {$i} ]----------------------------------------". PHP_EOL; |
19 | 17 |
@@ -6,10 +6,11 @@ |
||
6 | 6 | |
7 | 7 | $memcache_enabled = extension_loaded("memcached"); |
8 | 8 | |
9 | -if ($memcache_enabled) |
|
9 | +if ($memcache_enabled) { |
|
10 | 10 | echo "extension loaded"; |
11 | -else |
|
11 | +} else { |
|
12 | 12 | echo "extension not loaded"; |
13 | +} |
|
13 | 14 | |
14 | 15 | $mc = new Memcached(); |
15 | 16 | $mc->connect("localhost", 11211) ; |
@@ -37,12 +37,11 @@ |
||
37 | 37 | $errcnt=0; |
38 | 38 | |
39 | 39 | echo "\n"; |
40 | -foreach ($res as $regexrow) |
|
41 | -{ |
|
42 | - foreach ($regs as $regex){ |
|
40 | +foreach ($res as $regexrow) { |
|
41 | + foreach ($regs as $regex) { |
|
43 | 42 | try { |
44 | 43 | $res=preg_match($regexrow["regex"], $regex); |
45 | - }catch(Exception $e){ |
|
44 | + } catch(Exception $e) { |
|
46 | 45 | $errcnt++; |
47 | 46 | $strerr=str_pad((int) $errcnt,2," ",STR_PAD_LEFT); |
48 | 47 | echo "$strerr. id=".$regexrow["id"]. |