@@ -12,10 +12,10 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * These constants are bitwise for checking what was changed. |
| 14 | 14 | */ |
| 15 | - const UPDATED_GIT_COMMIT = 1; |
|
| 16 | - const UPDATED_GIT_TAG = 2; |
|
| 17 | - const UPDATED_SQL_DB_PATCH = 4; |
|
| 18 | - const UPDATED_SQL_FILE_LAST = 8; |
|
| 15 | + const UPDATED_GIT_COMMIT = 1; |
|
| 16 | + const UPDATED_GIT_TAG = 2; |
|
| 17 | + const UPDATED_SQL_DB_PATCH = 4; |
|
| 18 | + const UPDATED_SQL_FILE_LAST = 8; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @var \nntmux\utility\Git instance variable. |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * |
| 28 | 28 | * @package nntmux\utility |
| 29 | 29 | */ |
| 30 | -Class Country |
|
| 30 | +class Country |
|
| 31 | 31 | { |
| 32 | 32 | /** |
| 33 | 33 | * Get a country code for a country name. |
@@ -30,164 +30,164 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class zipfile |
| 32 | 32 | { |
| 33 | - /** |
|
| 34 | - * Array to store compressed data |
|
| 35 | - * |
|
| 36 | - * @var array $datasec |
|
| 37 | - */ |
|
| 38 | - var $datasec = []; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Central directory |
|
| 42 | - * |
|
| 43 | - * @var array $ctrl_dir |
|
| 44 | - */ |
|
| 45 | - var $ctrl_dir = []; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * End of central directory record |
|
| 49 | - * |
|
| 50 | - * @var string $eof_ctrl_dir |
|
| 51 | - */ |
|
| 52 | - var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Last offset position |
|
| 56 | - * |
|
| 57 | - * @var integer $old_offset |
|
| 58 | - */ |
|
| 59 | - var $old_offset = 0; |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Converts an Unix timestamp to a four byte DOS date and time format (date |
|
| 64 | - * in high two bytes, time in low two bytes allowing magnitude comparison). |
|
| 65 | - * |
|
| 66 | - * @param integer current Unix timestamp |
|
| 67 | - * |
|
| 68 | - * @return integer current date in a four byte DOS format |
|
| 69 | - * |
|
| 70 | - * @access private |
|
| 71 | - */ |
|
| 72 | - function unix2DosTime($unixtime = 0) { |
|
| 73 | - $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); |
|
| 74 | - |
|
| 75 | - if ($timearray['year'] < 1980) { |
|
| 76 | - $timearray['year'] = 1980; |
|
| 77 | - $timearray['mon'] = 1; |
|
| 78 | - $timearray['mday'] = 1; |
|
| 79 | - $timearray['hours'] = 0; |
|
| 80 | - $timearray['minutes'] = 0; |
|
| 81 | - $timearray['seconds'] = 0; |
|
| 82 | - } // end if |
|
| 83 | - |
|
| 84 | - return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | |
|
| 85 | - ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); |
|
| 86 | - } // end of the 'unix2DosTime()' method |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Adds "file" to archive |
|
| 91 | - * |
|
| 92 | - * @param string file contents |
|
| 93 | - * @param string name of the file in the archive (may contains the path) |
|
| 94 | - * @param integer the current timestamp |
|
| 95 | - * |
|
| 96 | - * @access public |
|
| 97 | - */ |
|
| 98 | - function addFile($data, $name, $time = 0) |
|
| 99 | - { |
|
| 100 | - $name = str_replace('\\', '/', $name); |
|
| 101 | - |
|
| 102 | - $dtime = dechex($this->unix2DosTime($time)); |
|
| 103 | - $hexdtime = '\x' . $dtime[6] . $dtime[7] |
|
| 104 | - . '\x' . $dtime[4] . $dtime[5] |
|
| 105 | - . '\x' . $dtime[2] . $dtime[3] |
|
| 106 | - . '\x' . $dtime[0] . $dtime[1]; |
|
| 107 | - eval('$hexdtime = "' . $hexdtime . '";'); |
|
| 108 | - |
|
| 109 | - $fr = "\x50\x4b\x03\x04"; |
|
| 110 | - $fr .= "\x14\x00"; // ver needed to extract |
|
| 111 | - $fr .= "\x00\x00"; // gen purpose bit flag |
|
| 112 | - $fr .= "\x08\x00"; // compression method |
|
| 113 | - $fr .= $hexdtime; // last mod time and date |
|
| 114 | - |
|
| 115 | - // "local file header" segment |
|
| 116 | - $unc_len = strlen($data); |
|
| 117 | - $crc = crc32($data); |
|
| 118 | - $zdata = gzcompress($data); |
|
| 119 | - $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
|
| 120 | - $c_len = strlen($zdata); |
|
| 121 | - $fr .= pack('V', $crc); // crc32 |
|
| 122 | - $fr .= pack('V', $c_len); // compressed filesize |
|
| 123 | - $fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 124 | - $fr .= pack('v', strlen($name)); // length of filename |
|
| 125 | - $fr .= pack('v', 0); // extra field length |
|
| 126 | - $fr .= $name; |
|
| 127 | - |
|
| 128 | - // "file data" segment |
|
| 129 | - $fr .= $zdata; |
|
| 130 | - |
|
| 131 | - // "data descriptor" segment (optional but necessary if archive is not |
|
| 132 | - // served as file) |
|
| 133 | - // nijel(2004-10-19): this seems not to be needed at all and causes |
|
| 134 | - // problems in some cases (bug #1037737) |
|
| 135 | - //$fr .= pack('V', $crc); // crc32 |
|
| 136 | - //$fr .= pack('V', $c_len); // compressed filesize |
|
| 137 | - //$fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 138 | - |
|
| 139 | - // add this entry to array |
|
| 140 | - $this -> datasec[] = $fr; |
|
| 141 | - |
|
| 142 | - // now add to central directory record |
|
| 143 | - $cdrec = "\x50\x4b\x01\x02"; |
|
| 144 | - $cdrec .= "\x00\x00"; // version made by |
|
| 145 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
| 146 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 147 | - $cdrec .= "\x08\x00"; // compression method |
|
| 148 | - $cdrec .= $hexdtime; // last mod time & date |
|
| 149 | - $cdrec .= pack('V', $crc); // crc32 |
|
| 150 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 151 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 152 | - $cdrec .= pack('v', strlen($name)); // length of filename |
|
| 153 | - $cdrec .= pack('v', 0); // extra field length |
|
| 154 | - $cdrec .= pack('v', 0); // file comment length |
|
| 155 | - $cdrec .= pack('v', 0); // disk number start |
|
| 156 | - $cdrec .= pack('v', 0); // internal file attributes |
|
| 157 | - $cdrec .= pack('V', 32); // external file attributes - 'archive' bit set |
|
| 158 | - |
|
| 159 | - $cdrec .= pack('V', $this -> old_offset); // relative offset of local header |
|
| 160 | - $this -> old_offset += strlen($fr); |
|
| 161 | - |
|
| 162 | - $cdrec .= $name; |
|
| 163 | - |
|
| 164 | - // optional extra field, file comment goes here |
|
| 165 | - // save to central directory |
|
| 166 | - $this -> ctrl_dir[] = $cdrec; |
|
| 167 | - } // end of the 'addFile()' method |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Dumps out file |
|
| 172 | - * |
|
| 173 | - * @return string the zipped file |
|
| 174 | - * |
|
| 175 | - * @access public |
|
| 176 | - */ |
|
| 177 | - function file() |
|
| 178 | - { |
|
| 179 | - $data = implode('', $this -> datasec); |
|
| 180 | - $ctrldir = implode('', $this -> ctrl_dir); |
|
| 181 | - |
|
| 182 | - return |
|
| 183 | - $data . |
|
| 184 | - $ctrldir . |
|
| 185 | - $this -> eof_ctrl_dir . |
|
| 186 | - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" |
|
| 187 | - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall |
|
| 188 | - pack('V', strlen($ctrldir)) . // size of central dir |
|
| 189 | - pack('V', strlen($data)) . // offset to start of central dir |
|
| 190 | - "\x00\x00"; // .zip file comment length |
|
| 191 | - } // end of the 'file()' method |
|
| 33 | + /** |
|
| 34 | + * Array to store compressed data |
|
| 35 | + * |
|
| 36 | + * @var array $datasec |
|
| 37 | + */ |
|
| 38 | + var $datasec = []; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Central directory |
|
| 42 | + * |
|
| 43 | + * @var array $ctrl_dir |
|
| 44 | + */ |
|
| 45 | + var $ctrl_dir = []; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * End of central directory record |
|
| 49 | + * |
|
| 50 | + * @var string $eof_ctrl_dir |
|
| 51 | + */ |
|
| 52 | + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Last offset position |
|
| 56 | + * |
|
| 57 | + * @var integer $old_offset |
|
| 58 | + */ |
|
| 59 | + var $old_offset = 0; |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Converts an Unix timestamp to a four byte DOS date and time format (date |
|
| 64 | + * in high two bytes, time in low two bytes allowing magnitude comparison). |
|
| 65 | + * |
|
| 66 | + * @param integer current Unix timestamp |
|
| 67 | + * |
|
| 68 | + * @return integer current date in a four byte DOS format |
|
| 69 | + * |
|
| 70 | + * @access private |
|
| 71 | + */ |
|
| 72 | + function unix2DosTime($unixtime = 0) { |
|
| 73 | + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); |
|
| 74 | + |
|
| 75 | + if ($timearray['year'] < 1980) { |
|
| 76 | + $timearray['year'] = 1980; |
|
| 77 | + $timearray['mon'] = 1; |
|
| 78 | + $timearray['mday'] = 1; |
|
| 79 | + $timearray['hours'] = 0; |
|
| 80 | + $timearray['minutes'] = 0; |
|
| 81 | + $timearray['seconds'] = 0; |
|
| 82 | + } // end if |
|
| 83 | + |
|
| 84 | + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | |
|
| 85 | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); |
|
| 86 | + } // end of the 'unix2DosTime()' method |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Adds "file" to archive |
|
| 91 | + * |
|
| 92 | + * @param string file contents |
|
| 93 | + * @param string name of the file in the archive (may contains the path) |
|
| 94 | + * @param integer the current timestamp |
|
| 95 | + * |
|
| 96 | + * @access public |
|
| 97 | + */ |
|
| 98 | + function addFile($data, $name, $time = 0) |
|
| 99 | + { |
|
| 100 | + $name = str_replace('\\', '/', $name); |
|
| 101 | + |
|
| 102 | + $dtime = dechex($this->unix2DosTime($time)); |
|
| 103 | + $hexdtime = '\x' . $dtime[6] . $dtime[7] |
|
| 104 | + . '\x' . $dtime[4] . $dtime[5] |
|
| 105 | + . '\x' . $dtime[2] . $dtime[3] |
|
| 106 | + . '\x' . $dtime[0] . $dtime[1]; |
|
| 107 | + eval('$hexdtime = "' . $hexdtime . '";'); |
|
| 108 | + |
|
| 109 | + $fr = "\x50\x4b\x03\x04"; |
|
| 110 | + $fr .= "\x14\x00"; // ver needed to extract |
|
| 111 | + $fr .= "\x00\x00"; // gen purpose bit flag |
|
| 112 | + $fr .= "\x08\x00"; // compression method |
|
| 113 | + $fr .= $hexdtime; // last mod time and date |
|
| 114 | + |
|
| 115 | + // "local file header" segment |
|
| 116 | + $unc_len = strlen($data); |
|
| 117 | + $crc = crc32($data); |
|
| 118 | + $zdata = gzcompress($data); |
|
| 119 | + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
|
| 120 | + $c_len = strlen($zdata); |
|
| 121 | + $fr .= pack('V', $crc); // crc32 |
|
| 122 | + $fr .= pack('V', $c_len); // compressed filesize |
|
| 123 | + $fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 124 | + $fr .= pack('v', strlen($name)); // length of filename |
|
| 125 | + $fr .= pack('v', 0); // extra field length |
|
| 126 | + $fr .= $name; |
|
| 127 | + |
|
| 128 | + // "file data" segment |
|
| 129 | + $fr .= $zdata; |
|
| 130 | + |
|
| 131 | + // "data descriptor" segment (optional but necessary if archive is not |
|
| 132 | + // served as file) |
|
| 133 | + // nijel(2004-10-19): this seems not to be needed at all and causes |
|
| 134 | + // problems in some cases (bug #1037737) |
|
| 135 | + //$fr .= pack('V', $crc); // crc32 |
|
| 136 | + //$fr .= pack('V', $c_len); // compressed filesize |
|
| 137 | + //$fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 138 | + |
|
| 139 | + // add this entry to array |
|
| 140 | + $this -> datasec[] = $fr; |
|
| 141 | + |
|
| 142 | + // now add to central directory record |
|
| 143 | + $cdrec = "\x50\x4b\x01\x02"; |
|
| 144 | + $cdrec .= "\x00\x00"; // version made by |
|
| 145 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
| 146 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 147 | + $cdrec .= "\x08\x00"; // compression method |
|
| 148 | + $cdrec .= $hexdtime; // last mod time & date |
|
| 149 | + $cdrec .= pack('V', $crc); // crc32 |
|
| 150 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 151 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 152 | + $cdrec .= pack('v', strlen($name)); // length of filename |
|
| 153 | + $cdrec .= pack('v', 0); // extra field length |
|
| 154 | + $cdrec .= pack('v', 0); // file comment length |
|
| 155 | + $cdrec .= pack('v', 0); // disk number start |
|
| 156 | + $cdrec .= pack('v', 0); // internal file attributes |
|
| 157 | + $cdrec .= pack('V', 32); // external file attributes - 'archive' bit set |
|
| 158 | + |
|
| 159 | + $cdrec .= pack('V', $this -> old_offset); // relative offset of local header |
|
| 160 | + $this -> old_offset += strlen($fr); |
|
| 161 | + |
|
| 162 | + $cdrec .= $name; |
|
| 163 | + |
|
| 164 | + // optional extra field, file comment goes here |
|
| 165 | + // save to central directory |
|
| 166 | + $this -> ctrl_dir[] = $cdrec; |
|
| 167 | + } // end of the 'addFile()' method |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Dumps out file |
|
| 172 | + * |
|
| 173 | + * @return string the zipped file |
|
| 174 | + * |
|
| 175 | + * @access public |
|
| 176 | + */ |
|
| 177 | + function file() |
|
| 178 | + { |
|
| 179 | + $data = implode('', $this -> datasec); |
|
| 180 | + $ctrldir = implode('', $this -> ctrl_dir); |
|
| 181 | + |
|
| 182 | + return |
|
| 183 | + $data . |
|
| 184 | + $ctrldir . |
|
| 185 | + $this -> eof_ctrl_dir . |
|
| 186 | + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" |
|
| 187 | + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall |
|
| 188 | + pack('V', strlen($ctrldir)) . // size of central dir |
|
| 189 | + pack('V', strlen($data)) . // offset to start of central dir |
|
| 190 | + "\x00\x00"; // .zip file comment length |
|
| 191 | + } // end of the 'file()' method |
|
| 192 | 192 | |
| 193 | 193 | } |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @var array $datasec |
| 37 | 37 | */ |
| 38 | - var $datasec = []; |
|
| 38 | + var $datasec = []; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Central directory |
| 42 | 42 | * |
| 43 | 43 | * @var array $ctrl_dir |
| 44 | 44 | */ |
| 45 | - var $ctrl_dir = []; |
|
| 45 | + var $ctrl_dir = []; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * End of central directory record |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @var integer $old_offset |
| 58 | 58 | */ |
| 59 | - var $old_offset = 0; |
|
| 59 | + var $old_offset = 0; |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | . '\x' . $dtime[0] . $dtime[1]; |
| 107 | 107 | eval('$hexdtime = "' . $hexdtime . '";'); |
| 108 | 108 | |
| 109 | - $fr = "\x50\x4b\x03\x04"; |
|
| 110 | - $fr .= "\x14\x00"; // ver needed to extract |
|
| 111 | - $fr .= "\x00\x00"; // gen purpose bit flag |
|
| 112 | - $fr .= "\x08\x00"; // compression method |
|
| 113 | - $fr .= $hexdtime; // last mod time and date |
|
| 109 | + $fr = "\x50\x4b\x03\x04"; |
|
| 110 | + $fr .= "\x14\x00"; // ver needed to extract |
|
| 111 | + $fr .= "\x00\x00"; // gen purpose bit flag |
|
| 112 | + $fr .= "\x08\x00"; // compression method |
|
| 113 | + $fr .= $hexdtime; // last mod time and date |
|
| 114 | 114 | |
| 115 | 115 | // "local file header" segment |
| 116 | 116 | $unc_len = strlen($data); |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | $zdata = gzcompress($data); |
| 119 | 119 | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
| 120 | 120 | $c_len = strlen($zdata); |
| 121 | - $fr .= pack('V', $crc); // crc32 |
|
| 122 | - $fr .= pack('V', $c_len); // compressed filesize |
|
| 123 | - $fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 124 | - $fr .= pack('v', strlen($name)); // length of filename |
|
| 125 | - $fr .= pack('v', 0); // extra field length |
|
| 121 | + $fr .= pack('V', $crc); // crc32 |
|
| 122 | + $fr .= pack('V', $c_len); // compressed filesize |
|
| 123 | + $fr .= pack('V', $unc_len); // uncompressed filesize |
|
| 124 | + $fr .= pack('v', strlen($name)); // length of filename |
|
| 125 | + $fr .= pack('v', 0); // extra field length |
|
| 126 | 126 | $fr .= $name; |
| 127 | 127 | |
| 128 | 128 | // "file data" segment |
@@ -141,20 +141,20 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | // now add to central directory record |
| 143 | 143 | $cdrec = "\x50\x4b\x01\x02"; |
| 144 | - $cdrec .= "\x00\x00"; // version made by |
|
| 145 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
| 146 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 147 | - $cdrec .= "\x08\x00"; // compression method |
|
| 148 | - $cdrec .= $hexdtime; // last mod time & date |
|
| 149 | - $cdrec .= pack('V', $crc); // crc32 |
|
| 150 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 151 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 144 | + $cdrec .= "\x00\x00"; // version made by |
|
| 145 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
| 146 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 147 | + $cdrec .= "\x08\x00"; // compression method |
|
| 148 | + $cdrec .= $hexdtime; // last mod time & date |
|
| 149 | + $cdrec .= pack('V', $crc); // crc32 |
|
| 150 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 151 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 152 | 152 | $cdrec .= pack('v', strlen($name)); // length of filename |
| 153 | - $cdrec .= pack('v', 0); // extra field length |
|
| 154 | - $cdrec .= pack('v', 0); // file comment length |
|
| 155 | - $cdrec .= pack('v', 0); // disk number start |
|
| 156 | - $cdrec .= pack('v', 0); // internal file attributes |
|
| 157 | - $cdrec .= pack('V', 32); // external file attributes - 'archive' bit set |
|
| 153 | + $cdrec .= pack('v', 0); // extra field length |
|
| 154 | + $cdrec .= pack('v', 0); // file comment length |
|
| 155 | + $cdrec .= pack('v', 0); // disk number start |
|
| 156 | + $cdrec .= pack('v', 0); // internal file attributes |
|
| 157 | + $cdrec .= pack('V', 32); // external file attributes - 'archive' bit set |
|
| 158 | 158 | |
| 159 | 159 | $cdrec .= pack('V', $this -> old_offset); // relative offset of local header |
| 160 | 160 | $this -> old_offset += strlen($fr); |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | $data . |
| 184 | 184 | $ctrldir . |
| 185 | 185 | $this -> eof_ctrl_dir . |
| 186 | - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" |
|
| 187 | - pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall |
|
| 188 | - pack('V', strlen($ctrldir)) . // size of central dir |
|
| 189 | - pack('V', strlen($data)) . // offset to start of central dir |
|
| 190 | - "\x00\x00"; // .zip file comment length |
|
| 186 | + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" |
|
| 187 | + pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall |
|
| 188 | + pack('V', strlen($ctrldir)) . // size of central dir |
|
| 189 | + pack('V', strlen($data)) . // offset to start of central dir |
|
| 190 | + "\x00\x00"; // .zip file comment length |
|
| 191 | 191 | } // end of the 'file()' method |
| 192 | 192 | |
| 193 | 193 | } |
@@ -69,7 +69,8 @@ |
||
| 69 | 69 | * |
| 70 | 70 | * @access private |
| 71 | 71 | */ |
| 72 | - function unix2DosTime($unixtime = 0) { |
|
| 72 | + function unix2DosTime($unixtime = 0) |
|
| 73 | + { |
|
| 73 | 74 | $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); |
| 74 | 75 | |
| 75 | 76 | if ($timearray['year'] < 1980) { |
@@ -663,7 +663,7 @@ |
||
| 663 | 663 | |
| 664 | 664 | protected function _processConditions($key, $value, $context, $schema = null, $glue = 'AND') |
| 665 | 665 | { |
| 666 | - $constraintTypes =& $this->_constraintTypes; |
|
| 666 | + $constraintTypes = & $this->_constraintTypes; |
|
| 667 | 667 | $model = $context->model(); |
| 668 | 668 | $models = $context->models(); |
| 669 | 669 | |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | if ($fields && is_array($fields) && is_int(key($fields))) { |
| 863 | 863 | $data = array_intersect_key($data, array_combine($fields, $fields)); |
| 864 | 864 | } |
| 865 | - $method = "_{$type}Fields"; |
|
| 865 | + $method = "_{$type}fields"; |
|
| 866 | 866 | return $this->{$method}($data, $schema, $context); |
| 867 | 867 | } |
| 868 | 868 | return empty($fields) ? '*' : join(', ', $fields); |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | if ($offset = $context->offset() ?: '') { |
| 885 | 885 | $offset = " OFFSET {$offset}"; |
| 886 | 886 | } |
| 887 | - return "LIMIT {$limit}{$offset}"; |
|
| 887 | + return "limit {$limit}{$offset}"; |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
@@ -1419,7 +1419,7 @@ discard block |
||
| 1419 | 1419 | $data[$name] = $this->name($value); |
| 1420 | 1420 | break; |
| 1421 | 1421 | case 'on': |
| 1422 | - $data[$name] = "ON {$value}"; |
|
| 1422 | + $data[$name] = "on {$value}"; |
|
| 1423 | 1423 | break; |
| 1424 | 1424 | case 'expr': |
| 1425 | 1425 | if (is_array($value)) { |
@@ -1466,7 +1466,7 @@ |
||
| 1466 | 1466 | |
| 1467 | 1467 | return [ |
| 1468 | 1468 | 'first' => function($self, $params, $chain) { |
| 1469 | - $options =& $params['options']; |
|
| 1469 | + $options = & $params['options']; |
|
| 1470 | 1470 | $options['limit'] = 1; |
| 1471 | 1471 | $data = $chain->next($self, $params, $chain); |
| 1472 | 1472 | |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class Games |
| 8 | 8 | { |
| 9 | - const REQID_FOUND = 1; // Request id found and release was updated. |
|
| 10 | - const REQID_NO_LOCAL = -1; // Request id was not found via local lookup. |
|
| 9 | + const REQID_FOUND = 1; // Request id found and release was updated. |
|
| 10 | + const REQID_NO_LOCAL = -1; // Request id was not found via local lookup. |
|
| 11 | 11 | const REQID_NONE = -3; // The Request id was not found locally or via web lookup. |
| 12 | - const REQID_UNPROCESSED = 0; // Release has not been processed. |
|
| 12 | + const REQID_UNPROCESSED = 0; // Release has not been processed. |
|
| 13 | 13 | const REQID_ZERO = -2; // The Request id was 0. |
| 14 | 14 | |
| 15 | 15 | /** |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $this->_classUsed = "steam"; |
| 418 | 418 | $this->_getGame->cookie = $this->cookie; |
| 419 | 419 | $this->_getGame->searchTerm = $gameInfo['title']; |
| 420 | - if($this->_getGame->search() !== false){ |
|
| 420 | + if ($this->_getGame->search() !== false) { |
|
| 421 | 421 | $this->_gameResults = $this->_getGame->getAll(); |
| 422 | 422 | } |
| 423 | 423 | if (count($this->_gameResults) < 1) { |
@@ -444,10 +444,10 @@ discard block |
||
| 444 | 444 | return false; |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | - if(empty($this->_gameResults['title'])){ |
|
| 447 | + if (empty($this->_gameResults['title'])) { |
|
| 448 | 448 | return false; |
| 449 | 449 | } |
| 450 | - if(!is_array($this->_gameResults)){ |
|
| 450 | + if (!is_array($this->_gameResults)) { |
|
| 451 | 451 | return false; |
| 452 | 452 | } |
| 453 | 453 | if (count($this->_gameResults) > 1) { |
@@ -636,14 +636,14 @@ discard block |
||
| 636 | 636 | if (empty($con['title'])) { |
| 637 | 637 | $con['title'] = $gameInfo['title']; |
| 638 | 638 | } |
| 639 | - if(!isset($con['releasedate'])){ |
|
| 639 | + if (!isset($con['releasedate'])) { |
|
| 640 | 640 | $con['releasedate'] = ""; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | if ($con['releasedate'] == "''") { |
| 644 | 644 | $con['releasedate'] = ""; |
| 645 | 645 | } |
| 646 | - if(!isset($con['review'])){ |
|
| 646 | + if (!isset($con['review'])) { |
|
| 647 | 647 | $con['review'] = 'No Review'; |
| 648 | 648 | } |
| 649 | 649 | $con['classused'] = $this->_classUsed; |
@@ -730,17 +730,17 @@ discard block |
||
| 730 | 730 | $this->pdo->log->primary($con['title']) |
| 731 | 731 | ); |
| 732 | 732 | } |
| 733 | - if($con['cover'] === 1){ |
|
| 733 | + if ($con['cover'] === 1) { |
|
| 734 | 734 | $con['cover'] = $ri->saveImage($gamesId, $con['coverurl'], $this->imgSavePath, 250, 250); |
| 735 | 735 | } |
| 736 | - if($con['backdrop'] === 1){ |
|
| 736 | + if ($con['backdrop'] === 1) { |
|
| 737 | 737 | $con['backdrop'] = $ri->saveImage($gamesId . '-backdrop', $con['backdropurl'], $this->imgSavePath, 1920, 1024); |
| 738 | 738 | } |
| 739 | 739 | } else { |
| 740 | 740 | if ($this->echoOutput) { |
| 741 | 741 | $this->pdo->log->doEcho( |
| 742 | 742 | $this->pdo->log->headerOver("Nothing to update: ") . |
| 743 | - $this->pdo->log->primary($con['title'] . ' (PC)' ) |
|
| 743 | + $this->pdo->log->primary($con['title'] . ' (PC)') |
|
| 744 | 744 | ); |
| 745 | 745 | } |
| 746 | 746 | } |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | if ($this->echoOutput) { |
| 857 | 857 | $this->pdo->log->doEcho( |
| 858 | 858 | $this->pdo->log->headerOver('Looking up: ') . |
| 859 | - $this->pdo->log->primary($gameInfo['title'] . ' (PC)' ) |
|
| 859 | + $this->pdo->log->primary($gameInfo['title'] . ' (PC)') |
|
| 860 | 860 | ); |
| 861 | 861 | } |
| 862 | 862 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | $gameId = -2; |
| 871 | 871 | |
| 872 | 872 | // Leave gamesinfo_id 0 to parse again |
| 873 | - if($this->maxHitRequest === true){ |
|
| 873 | + if ($this->maxHitRequest === true) { |
|
| 874 | 874 | $gameId = 0; |
| 875 | 875 | } |
| 876 | 876 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | $result['title'] = $dlc[0]; |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | - if(empty($result['title'])){ |
|
| 945 | + if (empty($result['title'])) { |
|
| 946 | 946 | return false; |
| 947 | 947 | } |
| 948 | 948 | $browseNode = '94'; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | break; |
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | - if(empty($genreName)){ |
|
| 1013 | + if (empty($genreName)) { |
|
| 1014 | 1014 | $genreName = $tmpGenre[0]; |
| 1015 | 1015 | } |
| 1016 | 1016 | } else { |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $this->_classUsed = "steam"; |
| 418 | 418 | $this->_getGame->cookie = $this->cookie; |
| 419 | 419 | $this->_getGame->searchTerm = $gameInfo['title']; |
| 420 | - if($this->_getGame->search() !== false){ |
|
| 420 | + if($this->_getGame->search() !== false) { |
|
| 421 | 421 | $this->_gameResults = $this->_getGame->getAll(); |
| 422 | 422 | } |
| 423 | 423 | if (count($this->_gameResults) < 1) { |
@@ -444,10 +444,10 @@ discard block |
||
| 444 | 444 | return false; |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | - if(empty($this->_gameResults['title'])){ |
|
| 447 | + if(empty($this->_gameResults['title'])) { |
|
| 448 | 448 | return false; |
| 449 | 449 | } |
| 450 | - if(!is_array($this->_gameResults)){ |
|
| 450 | + if(!is_array($this->_gameResults)) { |
|
| 451 | 451 | return false; |
| 452 | 452 | } |
| 453 | 453 | if (count($this->_gameResults) > 1) { |
@@ -636,14 +636,14 @@ discard block |
||
| 636 | 636 | if (empty($con['title'])) { |
| 637 | 637 | $con['title'] = $gameInfo['title']; |
| 638 | 638 | } |
| 639 | - if(!isset($con['releasedate'])){ |
|
| 639 | + if(!isset($con['releasedate'])) { |
|
| 640 | 640 | $con['releasedate'] = ""; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | if ($con['releasedate'] == "''") { |
| 644 | 644 | $con['releasedate'] = ""; |
| 645 | 645 | } |
| 646 | - if(!isset($con['review'])){ |
|
| 646 | + if(!isset($con['review'])) { |
|
| 647 | 647 | $con['review'] = 'No Review'; |
| 648 | 648 | } |
| 649 | 649 | $con['classused'] = $this->_classUsed; |
@@ -730,10 +730,10 @@ discard block |
||
| 730 | 730 | $this->pdo->log->primary($con['title']) |
| 731 | 731 | ); |
| 732 | 732 | } |
| 733 | - if($con['cover'] === 1){ |
|
| 733 | + if($con['cover'] === 1) { |
|
| 734 | 734 | $con['cover'] = $ri->saveImage($gamesId, $con['coverurl'], $this->imgSavePath, 250, 250); |
| 735 | 735 | } |
| 736 | - if($con['backdrop'] === 1){ |
|
| 736 | + if($con['backdrop'] === 1) { |
|
| 737 | 737 | $con['backdrop'] = $ri->saveImage($gamesId . '-backdrop', $con['backdropurl'], $this->imgSavePath, 1920, 1024); |
| 738 | 738 | } |
| 739 | 739 | } else { |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | $gameId = -2; |
| 871 | 871 | |
| 872 | 872 | // Leave gamesinfo_id 0 to parse again |
| 873 | - if($this->maxHitRequest === true){ |
|
| 873 | + if($this->maxHitRequest === true) { |
|
| 874 | 874 | $gameId = 0; |
| 875 | 875 | } |
| 876 | 876 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | $result['title'] = $dlc[0]; |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | - if(empty($result['title'])){ |
|
| 945 | + if(empty($result['title'])) { |
|
| 946 | 946 | return false; |
| 947 | 947 | } |
| 948 | 948 | $browseNode = '94'; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | break; |
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | - if(empty($genreName)){ |
|
| 1013 | + if(empty($genreName)) { |
|
| 1014 | 1014 | $genreName = $tmpGenre[0]; |
| 1015 | 1015 | } |
| 1016 | 1016 | } else { |
@@ -222,7 +222,7 @@ |
||
| 222 | 222 | $gameIDs = $releaseIDs = false; |
| 223 | 223 | |
| 224 | 224 | if (is_array($games['result'])) { |
| 225 | - foreach ($games['result'] AS $game => $id) { |
|
| 225 | + foreach ($games['result'] as $game => $id) { |
|
| 226 | 226 | $gameIDs[] = $id['id']; |
| 227 | 227 | $releaseIDs[] = $id['grp_release_id']; |
| 228 | 228 | } |
@@ -30,14 +30,14 @@ |
||
| 30 | 30 | * |
| 31 | 31 | * @return array|bool |
| 32 | 32 | */ |
| 33 | - public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute='0') |
|
| 33 | + public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute = '0') |
|
| 34 | 34 | { |
| 35 | 35 | $db = new Settings(); |
| 36 | 36 | |
| 37 | - if($epabsolute == '0') //as string - not int. |
|
| 38 | - if(!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep)) |
|
| 37 | + if ($epabsolute == '0') //as string - not int. |
|
| 38 | + if (!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep)) |
|
| 39 | 39 | $additionalSql = sprintf('AND fullep = %s', $db->escapeString($fullep)); |
| 40 | - else $additionalSql = sprintf('AND airdate LIKE %s', $db->escapeString($fullep.' %')); |
|
| 40 | + else $additionalSql = sprintf('AND airdate LIKE %s', $db->escapeString($fullep . ' %')); |
|
| 41 | 41 | else $additionalSql = sprintf('AND epabsolute = %s', $db->escapeString($epabsolute)); |
| 42 | 42 | |
| 43 | 43 | return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE showtitle = %s %s', $db->escapeString($showtitle), $additionalSql)); |
@@ -34,11 +34,16 @@ |
||
| 34 | 34 | { |
| 35 | 35 | $db = new Settings(); |
| 36 | 36 | |
| 37 | - if($epabsolute == '0') //as string - not int. |
|
| 37 | + if($epabsolute == '0') { |
|
| 38 | + //as string - not int. |
|
| 38 | 39 | if(!preg_match('/[21]\d{3}\/\d{2}\/\d{2}/', $fullep)) |
| 39 | 40 | $additionalSql = sprintf('AND fullep = %s', $db->escapeString($fullep)); |
| 40 | - else $additionalSql = sprintf('AND airdate LIKE %s', $db->escapeString($fullep.' %')); |
|
| 41 | - else $additionalSql = sprintf('AND epabsolute = %s', $db->escapeString($epabsolute)); |
|
| 41 | + } else { |
|
| 42 | + $additionalSql = sprintf('AND airdate LIKE %s', $db->escapeString($fullep.' %')); |
|
| 43 | + } |
|
| 44 | + else { |
|
| 45 | + $additionalSql = sprintf('AND epabsolute = %s', $db->escapeString($epabsolute)); |
|
| 46 | + } |
|
| 42 | 47 | |
| 43 | 48 | return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE showtitle = %s %s', $db->escapeString($showtitle), $additionalSql)); |
| 44 | 49 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | if ($matches['req'] !== 'N/A' && preg_match('/^(?P<req>\d+):(?P<group>.+)$/i', $matches['req'], $matches2)) { |
| 211 | 211 | $this->_curPre['reqid'] = $matches2['req']; |
| 212 | - $this->_curPre['group_id'] = $this->_getGroupID($matches2['group']); |
|
| 212 | + $this->_curPre['group_id'] = $this->_getGroupID($matches2['group']); |
|
| 213 | 213 | } |
| 214 | 214 | if ($matches['size'] !== 'N/A') { |
| 215 | 215 | $this->_curPre['size'] = $matches['size']; |
@@ -275,28 +275,28 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | $query = 'INSERT INTO predb ('; |
| 277 | 277 | |
| 278 | - $query .= (!empty($this->_curPre['size']) ? 'size, ' : ''); |
|
| 279 | - $query .= (!empty($this->_curPre['category']) ? 'category, ' : ''); |
|
| 280 | - $query .= (!empty($this->_curPre['source']) ? 'source, ' : ''); |
|
| 281 | - $query .= (!empty($this->_curPre['reason']) ? 'nukereason, ' : ''); |
|
| 282 | - $query .= (!empty($this->_curPre['files']) ? 'files, ' : ''); |
|
| 283 | - $query .= (!empty($this->_curPre['reqid']) ? 'requestid, ' : ''); |
|
| 284 | - $query .= (!empty($this->_curPre['group_id']) ? 'groups_id, ' : ''); |
|
| 285 | - $query .= (!empty($this->_curPre['nuked']) ? 'nuked, ' : ''); |
|
| 286 | - $query .= (!empty($this->_curPre['filename']) ? 'filename, ' : ''); |
|
| 278 | + $query .= (!empty($this->_curPre['size']) ? 'size, ' : ''); |
|
| 279 | + $query .= (!empty($this->_curPre['category']) ? 'category, ' : ''); |
|
| 280 | + $query .= (!empty($this->_curPre['source']) ? 'source, ' : ''); |
|
| 281 | + $query .= (!empty($this->_curPre['reason']) ? 'nukereason, ' : ''); |
|
| 282 | + $query .= (!empty($this->_curPre['files']) ? 'files, ' : ''); |
|
| 283 | + $query .= (!empty($this->_curPre['reqid']) ? 'requestid, ' : ''); |
|
| 284 | + $query .= (!empty($this->_curPre['group_id']) ? 'groups_id, ' : ''); |
|
| 285 | + $query .= (!empty($this->_curPre['nuked']) ? 'nuked, ' : ''); |
|
| 286 | + $query .= (!empty($this->_curPre['filename']) ? 'filename, ' : ''); |
|
| 287 | 287 | |
| 288 | 288 | $query .= 'predate, title) VALUES ('; |
| 289 | 289 | |
| 290 | - $query .= (!empty($this->_curPre['size']) ? $this->_pdo->escapeString($this->_curPre['size']) . ', ' : ''); |
|
| 291 | - $query .= (!empty($this->_curPre['category']) ? $this->_pdo->escapeString($this->_curPre['category']) . ', ' : ''); |
|
| 292 | - $query .= (!empty($this->_curPre['source']) ? $this->_pdo->escapeString($this->_curPre['source']) . ', ' : ''); |
|
| 293 | - $query .= (!empty($this->_curPre['reason']) ? $this->_pdo->escapeString($this->_curPre['reason']) . ', ' : ''); |
|
| 294 | - $query .= (!empty($this->_curPre['files']) ? $this->_pdo->escapeString($this->_curPre['files']) . ', ' : ''); |
|
| 295 | - $query .= (!empty($this->_curPre['reqid']) ? $this->_curPre['reqid'] . ', ' : ''); |
|
| 296 | - $query .= (!empty($this->_curPre['group_id']) ? $this->_curPre['group_id'] . ', ' : ''); |
|
| 297 | - $query .= (!empty($this->_curPre['nuked']) ? $this->_curPre['nuked'] . ', ' : ''); |
|
| 298 | - $query .= (!empty($this->_curPre['filename']) ? $this->_pdo->escapeString($this->_curPre['filename']) . ', ' : ''); |
|
| 299 | - $query .= (!empty($this->_curPre['predate']) ? $this->_curPre['predate'] . ', ' : 'NOW(), '); |
|
| 290 | + $query .= (!empty($this->_curPre['size']) ? $this->_pdo->escapeString($this->_curPre['size']) . ', ' : ''); |
|
| 291 | + $query .= (!empty($this->_curPre['category']) ? $this->_pdo->escapeString($this->_curPre['category']) . ', ' : ''); |
|
| 292 | + $query .= (!empty($this->_curPre['source']) ? $this->_pdo->escapeString($this->_curPre['source']) . ', ' : ''); |
|
| 293 | + $query .= (!empty($this->_curPre['reason']) ? $this->_pdo->escapeString($this->_curPre['reason']) . ', ' : ''); |
|
| 294 | + $query .= (!empty($this->_curPre['files']) ? $this->_pdo->escapeString($this->_curPre['files']) . ', ' : ''); |
|
| 295 | + $query .= (!empty($this->_curPre['reqid']) ? $this->_curPre['reqid'] . ', ' : ''); |
|
| 296 | + $query .= (!empty($this->_curPre['group_id']) ? $this->_curPre['group_id'] . ', ' : ''); |
|
| 297 | + $query .= (!empty($this->_curPre['nuked']) ? $this->_curPre['nuked'] . ', ' : ''); |
|
| 298 | + $query .= (!empty($this->_curPre['filename']) ? $this->_pdo->escapeString($this->_curPre['filename']) . ', ' : ''); |
|
| 299 | + $query .= (!empty($this->_curPre['predate']) ? $this->_curPre['predate'] . ', ' : 'NOW(), '); |
|
| 300 | 300 | |
| 301 | 301 | $query .= '%s)'; |
| 302 | 302 | |
@@ -325,26 +325,26 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | $query = 'UPDATE predb SET '; |
| 327 | 327 | |
| 328 | - $query .= (!empty($this->_curPre['size']) ? 'size = ' . $this->_pdo->escapeString($this->_curPre['size']) . ', ' : ''); |
|
| 329 | - $query .= (!empty($this->_curPre['source']) ? 'source = ' . $this->_pdo->escapeString($this->_curPre['source']) . ', ' : ''); |
|
| 330 | - $query .= (!empty($this->_curPre['files']) ? 'files = ' . $this->_pdo->escapeString($this->_curPre['files']) . ', ' : ''); |
|
| 331 | - $query .= (!empty($this->_curPre['reason']) ? 'nukereason = ' . $this->_pdo->escapeString($this->_curPre['reason']) . ', ' : ''); |
|
| 332 | - $query .= (!empty($this->_curPre['reqid']) ? 'requestid = ' . $this->_curPre['reqid'] . ', ' : ''); |
|
| 333 | - $query .= (!empty($this->_curPre['group_id']) ? 'groups_id = ' . $this->_curPre['group_id'] . ', ' : ''); |
|
| 334 | - $query .= (!empty($this->_curPre['predate']) ? 'predate = ' . $this->_curPre['predate'] . ', ' : ''); |
|
| 335 | - $query .= (!empty($this->_curPre['nuked']) ? 'nuked = ' . $this->_curPre['nuked'] . ', ' : ''); |
|
| 336 | - $query .= (!empty($this->_curPre['filename']) ? 'filename = ' . $this->_pdo->escapeString($this->_curPre['filename']) . ', ' : ''); |
|
| 328 | + $query .= (!empty($this->_curPre['size']) ? 'size = ' . $this->_pdo->escapeString($this->_curPre['size']) . ', ' : ''); |
|
| 329 | + $query .= (!empty($this->_curPre['source']) ? 'source = ' . $this->_pdo->escapeString($this->_curPre['source']) . ', ' : ''); |
|
| 330 | + $query .= (!empty($this->_curPre['files']) ? 'files = ' . $this->_pdo->escapeString($this->_curPre['files']) . ', ' : ''); |
|
| 331 | + $query .= (!empty($this->_curPre['reason']) ? 'nukereason = ' . $this->_pdo->escapeString($this->_curPre['reason']) . ', ' : ''); |
|
| 332 | + $query .= (!empty($this->_curPre['reqid']) ? 'requestid = ' . $this->_curPre['reqid'] . ', ' : ''); |
|
| 333 | + $query .= (!empty($this->_curPre['group_id']) ? 'groups_id = ' . $this->_curPre['group_id'] . ', ' : ''); |
|
| 334 | + $query .= (!empty($this->_curPre['predate']) ? 'predate = ' . $this->_curPre['predate'] . ', ' : ''); |
|
| 335 | + $query .= (!empty($this->_curPre['nuked']) ? 'nuked = ' . $this->_curPre['nuked'] . ', ' : ''); |
|
| 336 | + $query .= (!empty($this->_curPre['filename']) ? 'filename = ' . $this->_pdo->escapeString($this->_curPre['filename']) . ', ' : ''); |
|
| 337 | 337 | $query .= ( |
| 338 | 338 | (empty($this->_oldPre['category']) && !empty($this->_curPre['category'])) |
| 339 | 339 | ? 'category = ' . $this->_pdo->escapeString($this->_curPre['category']) . ', ' |
| 340 | 340 | : '' |
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | - if ($query === 'UPDATE predb SET '){ |
|
| 343 | + if ($query === 'UPDATE predb SET ') { |
|
| 344 | 344 | return; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - $query .= 'title = ' . $this->_pdo->escapeString($this->_curPre['title']); |
|
| 347 | + $query .= 'title = ' . $this->_pdo->escapeString($this->_curPre['title']); |
|
| 348 | 348 | $query .= ' WHERE title = ' . $this->_pdo->escapeString($this->_curPre['title']); |
| 349 | 349 | |
| 350 | 350 | $this->_pdo->ping(true); |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | $nukeString = ''; |
| 369 | 369 | if ($this->_nuked !== false) { |
| 370 | - switch((int)$this->_curPre['nuked']) { |
|
| 370 | + switch ((int)$this->_curPre['nuked']) { |
|
| 371 | 371 | case PreDb::PRE_NUKED: |
| 372 | 372 | $nukeString = '[ NUKED ] '; |
| 373 | 373 | break; |
@@ -340,7 +340,7 @@ |
||
| 340 | 340 | : '' |
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | - if ($query === 'UPDATE predb SET '){ |
|
| 343 | + if ($query === 'UPDATE predb SET ') { |
|
| 344 | 344 | return; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | if($refdate !== Null){ |
| 73 | 73 | if(is_string($refdate)){ |
| 74 | - // ensure we're in the right format |
|
| 74 | + // ensure we're in the right format |
|
| 75 | 75 | $refdate=date("Y-m-d H:i:s", strtotime($refdate)); |
| 76 | 76 | }else if(is_int($refdate)){ |
| 77 | - // ensure we're in the right format |
|
| 77 | + // ensure we're in the right format |
|
| 78 | 78 | $refdate=date("Y-m-d H:i:s", $refdate); |
| 79 | 79 | }else{ |
| 80 | 80 | // leave it as null (bad content anyhow) |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | if($refdate !== Null) |
| 88 | 88 | $clause[] = "createddate >= '$refdate'"; |
| 89 | 89 | |
| 90 | - // set localOnly to Null to include both local and remote |
|
| 91 | - // set localOnly to true to only receive local comment count |
|
| 92 | - // set localOnly to false to only receive remote comment count |
|
| 90 | + // set localOnly to Null to include both local and remote |
|
| 91 | + // set localOnly to true to only receive local comment count |
|
| 92 | + // set localOnly to false to only receive remote comment count |
|
| 93 | 93 | if($localOnly === true){ |
| 94 | 94 | $clause[] = "sourceid = 0"; |
| 95 | 95 | }else if($localOnly === false){ |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return |
| 69 | 69 | */ |
| 70 | - public function getCommentCount($refdate=Null, $localOnly=Null) |
|
| 70 | + public function getCommentCount($refdate = Null, $localOnly = Null) |
|
| 71 | 71 | { |
| 72 | - if($refdate !== Null){ |
|
| 73 | - if(is_string($refdate)){ |
|
| 72 | + if ($refdate !== Null) { |
|
| 73 | + if (is_string($refdate)) { |
|
| 74 | 74 | // ensure we're in the right format |
| 75 | - $refdate=date("Y-m-d H:i:s", strtotime($refdate)); |
|
| 76 | - }else if(is_int($refdate)){ |
|
| 75 | + $refdate = date("Y-m-d H:i:s", strtotime($refdate)); |
|
| 76 | + } else if (is_int($refdate)) { |
|
| 77 | 77 | // ensure we're in the right format |
| 78 | - $refdate=date("Y-m-d H:i:s", $refdate); |
|
| 79 | - }else{ |
|
| 78 | + $refdate = date("Y-m-d H:i:s", $refdate); |
|
| 79 | + } else { |
|
| 80 | 80 | // leave it as null (bad content anyhow) |
| 81 | 81 | $refdate = Null; |
| 82 | 82 | } |
@@ -84,20 +84,20 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $q = "SELECT count(id) AS num FROM release_comments"; |
| 86 | 86 | $clause = []; |
| 87 | - if($refdate !== Null) |
|
| 87 | + if ($refdate !== Null) |
|
| 88 | 88 | $clause[] = "createddate >= '$refdate'"; |
| 89 | 89 | |
| 90 | 90 | // set localOnly to Null to include both local and remote |
| 91 | 91 | // set localOnly to true to only receive local comment count |
| 92 | 92 | // set localOnly to false to only receive remote comment count |
| 93 | - if($localOnly === true){ |
|
| 93 | + if ($localOnly === true) { |
|
| 94 | 94 | $clause[] = "sourceid = 0"; |
| 95 | - }else if($localOnly === false){ |
|
| 95 | + } else if ($localOnly === false) { |
|
| 96 | 96 | $clause[] = "sourceid != 0"; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if(count($clause)) |
|
| 100 | - $q .= " WHERE ".implode(" AND ", $clause); |
|
| 99 | + if (count($clause)) |
|
| 100 | + $q .= " WHERE " . implode(" AND ", $clause); |
|
| 101 | 101 | |
| 102 | 102 | $res = $this->pdo->queryOneRow($q); |
| 103 | 103 | return $res["num"]; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $this->pdo->queryExec(sprintf("update releases |
| 219 | 219 | SET comments = (SELECT count(id) FROM release_comments WHERE release_comments.gid = releases.gid AND isvisible = 1) |
| 220 | - WHERE releases.gid = %s", $this->pdo->escapeString($gid) )); |
|
| 220 | + WHERE releases.gid = %s", $this->pdo->escapeString($gid))); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | if ($start === false) |
| 248 | 248 | $limit = ""; |
| 249 | 249 | else |
| 250 | - $limit = " LIMIT ".$start.",".$num; |
|
| 250 | + $limit = " LIMIT " . $start . "," . $num; |
|
| 251 | 251 | |
| 252 | - return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releases_id LEFT OUTER JOIN users ON users.id = release_comments.users_id WHERE users_id = %d ORDER BY release_comments.createddate DESC ".$limit, $uid)); |
|
| 252 | + return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releases_id LEFT OUTER JOIN users ON users.id = release_comments.users_id WHERE users_id = %d ORDER BY release_comments.createddate DESC " . $limit, $uid)); |
|
| 253 | 253 | } |
| 254 | 254 | } |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function getCommentCount($refdate=Null, $localOnly=Null) |
| 71 | 71 | { |
| 72 | - if($refdate !== Null){ |
|
| 73 | - if(is_string($refdate)){ |
|
| 72 | + if($refdate !== Null) { |
|
| 73 | + if(is_string($refdate)) { |
|
| 74 | 74 | // ensure we're in the right format |
| 75 | 75 | $refdate=date("Y-m-d H:i:s", strtotime($refdate)); |
| 76 | - }else if(is_int($refdate)){ |
|
| 76 | + } else if(is_int($refdate)) { |
|
| 77 | 77 | // ensure we're in the right format |
| 78 | 78 | $refdate=date("Y-m-d H:i:s", $refdate); |
| 79 | - }else{ |
|
| 79 | + } else { |
|
| 80 | 80 | // leave it as null (bad content anyhow) |
| 81 | 81 | $refdate = Null; |
| 82 | 82 | } |
@@ -84,20 +84,22 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $q = "SELECT count(id) AS num FROM release_comments"; |
| 86 | 86 | $clause = []; |
| 87 | - if($refdate !== Null) |
|
| 88 | - $clause[] = "createddate >= '$refdate'"; |
|
| 87 | + if($refdate !== Null) { |
|
| 88 | + $clause[] = "createddate >= '$refdate'"; |
|
| 89 | + } |
|
| 89 | 90 | |
| 90 | 91 | // set localOnly to Null to include both local and remote |
| 91 | 92 | // set localOnly to true to only receive local comment count |
| 92 | 93 | // set localOnly to false to only receive remote comment count |
| 93 | - if($localOnly === true){ |
|
| 94 | + if($localOnly === true) { |
|
| 94 | 95 | $clause[] = "sourceid = 0"; |
| 95 | - }else if($localOnly === false){ |
|
| 96 | + } else if($localOnly === false) { |
|
| 96 | 97 | $clause[] = "sourceid != 0"; |
| 97 | 98 | } |
| 98 | 99 | |
| 99 | - if(count($clause)) |
|
| 100 | - $q .= " WHERE ".implode(" AND ", $clause); |
|
| 100 | + if(count($clause)) { |
|
| 101 | + $q .= " WHERE ".implode(" AND ", $clause); |
|
| 102 | + } |
|
| 101 | 103 | |
| 102 | 104 | $res = $this->pdo->queryOneRow($q); |
| 103 | 105 | return $res["num"]; |
@@ -125,8 +127,7 @@ discard block |
||
| 125 | 127 | public function deleteCommentsForRelease($id) |
| 126 | 128 | { |
| 127 | 129 | $res = $this->getCommentById($id); |
| 128 | - if ($res) |
|
| 129 | - { |
|
| 130 | + if ($res) { |
|
| 130 | 131 | $this->pdo->queryExec(sprintf("DELETE rc.* FROM release_comments rc JOIN releases r ON r.gid = rc.gid WHERE r.id = %d", $id)); |
| 131 | 132 | $this->updateReleaseCommentCount($res["gid"]); |
| 132 | 133 | } |
@@ -140,11 +141,9 @@ discard block |
||
| 140 | 141 | public function deleteCommentsForUser($id) |
| 141 | 142 | { |
| 142 | 143 | $numcomments = $this->getCommentCountForUser($id); |
| 143 | - if ($numcomments > 0) |
|
| 144 | - { |
|
| 144 | + if ($numcomments > 0) { |
|
| 145 | 145 | $comments = $this->getCommentsForUserRange($id, 0, $numcomments); |
| 146 | - foreach ($comments as $comment) |
|
| 147 | - { |
|
| 146 | + foreach ($comments as $comment) { |
|
| 148 | 147 | $this->deleteComment($comment["id"]); |
| 149 | 148 | $this->updateReleaseCommentCount($comment["gid"]); |
| 150 | 149 | } |
@@ -244,10 +243,11 @@ discard block |
||
| 244 | 243 | */ |
| 245 | 244 | public function getCommentsForUserRange($uid, $start, $num) |
| 246 | 245 | { |
| 247 | - if ($start === false) |
|
| 248 | - $limit = ""; |
|
| 249 | - else |
|
| 250 | - $limit = " LIMIT ".$start.",".$num; |
|
| 246 | + if ($start === false) { |
|
| 247 | + $limit = ""; |
|
| 248 | + } else { |
|
| 249 | + $limit = " LIMIT ".$start.",".$num; |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | 252 | return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releases_id LEFT OUTER JOIN users ON users.id = release_comments.users_id WHERE users_id = %d ORDER BY release_comments.createddate DESC ".$limit, $uid)); |
| 253 | 253 | } |