@@ -4,188 +4,188 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Command |
| 6 | 6 | { |
| 7 | - const SUCCESS_EXIT = 0; |
|
| 8 | - const FAILURE_EXIT = 1; |
|
| 7 | + const SUCCESS_EXIT = 0; |
|
| 8 | + const FAILURE_EXIT = 1; |
|
| 9 | 9 | |
| 10 | - protected $stats = array(); |
|
| 10 | + protected $stats = array(); |
|
| 11 | 11 | |
| 12 | - public static function main() |
|
| 13 | - { |
|
| 14 | - $command = new self; |
|
| 15 | - $command->run(); |
|
| 16 | - } |
|
| 17 | - |
|
| 18 | - public function run() |
|
| 19 | - { |
|
| 20 | - $opts = getopt( |
|
| 21 | - 'hi:o:', |
|
| 22 | - array( |
|
| 23 | - 'help', |
|
| 24 | - 'input:', |
|
| 25 | - 'output:', |
|
| 26 | - 'dry-run', |
|
| 27 | - 'keep-sourcemap', |
|
| 28 | - 'keep-sourcemap-comment', |
|
| 29 | - 'linebreak-position:', |
|
| 30 | - 'memory-limit:', |
|
| 31 | - 'pcre-backtrack-limit:', |
|
| 32 | - 'pcre-recursion-limit:', |
|
| 33 | - 'remove-important-comments' |
|
| 34 | - ) |
|
| 35 | - ); |
|
| 36 | - |
|
| 37 | - $help = $this->getOpt(array('h', 'help'), $opts); |
|
| 38 | - $input = $this->getOpt(array('i', 'input'), $opts); |
|
| 39 | - $output = $this->getOpt(array('o', 'output'), $opts); |
|
| 40 | - $dryrun = $this->getOpt('dry-run', $opts); |
|
| 41 | - $keepSourceMapComment = $this->getOpt(array('keep-sourcemap', 'keep-sourcemap-comment'), $opts); |
|
| 42 | - $linebreakPosition = $this->getOpt('linebreak-position', $opts); |
|
| 43 | - $memoryLimit = $this->getOpt('memory-limit', $opts); |
|
| 44 | - $backtrackLimit = $this->getOpt('pcre-backtrack-limit', $opts); |
|
| 45 | - $recursionLimit = $this->getOpt('pcre-recursion-limit', $opts); |
|
| 46 | - $removeImportantComments = $this->getOpt('remove-important-comments', $opts); |
|
| 47 | - |
|
| 48 | - if (!is_null($help)) { |
|
| 49 | - $this->showHelp(); |
|
| 50 | - die(self::SUCCESS_EXIT); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (is_null($input)) { |
|
| 54 | - fwrite(STDERR, '-i <file> argument is missing' . PHP_EOL); |
|
| 55 | - $this->showHelp(); |
|
| 56 | - die(self::FAILURE_EXIT); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (!is_readable($input)) { |
|
| 60 | - fwrite(STDERR, 'Input file is not readable' . PHP_EOL); |
|
| 61 | - die(self::FAILURE_EXIT); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - $css = file_get_contents($input); |
|
| 65 | - |
|
| 66 | - if ($css === false) { |
|
| 67 | - fwrite(STDERR, 'Input CSS code could not be retrieved from input file' . PHP_EOL); |
|
| 68 | - die(self::FAILURE_EXIT); |
|
| 69 | - } |
|
| 12 | + public static function main() |
|
| 13 | + { |
|
| 14 | + $command = new self; |
|
| 15 | + $command->run(); |
|
| 16 | + } |
|
| 17 | + |
|
| 18 | + public function run() |
|
| 19 | + { |
|
| 20 | + $opts = getopt( |
|
| 21 | + 'hi:o:', |
|
| 22 | + array( |
|
| 23 | + 'help', |
|
| 24 | + 'input:', |
|
| 25 | + 'output:', |
|
| 26 | + 'dry-run', |
|
| 27 | + 'keep-sourcemap', |
|
| 28 | + 'keep-sourcemap-comment', |
|
| 29 | + 'linebreak-position:', |
|
| 30 | + 'memory-limit:', |
|
| 31 | + 'pcre-backtrack-limit:', |
|
| 32 | + 'pcre-recursion-limit:', |
|
| 33 | + 'remove-important-comments' |
|
| 34 | + ) |
|
| 35 | + ); |
|
| 36 | + |
|
| 37 | + $help = $this->getOpt(array('h', 'help'), $opts); |
|
| 38 | + $input = $this->getOpt(array('i', 'input'), $opts); |
|
| 39 | + $output = $this->getOpt(array('o', 'output'), $opts); |
|
| 40 | + $dryrun = $this->getOpt('dry-run', $opts); |
|
| 41 | + $keepSourceMapComment = $this->getOpt(array('keep-sourcemap', 'keep-sourcemap-comment'), $opts); |
|
| 42 | + $linebreakPosition = $this->getOpt('linebreak-position', $opts); |
|
| 43 | + $memoryLimit = $this->getOpt('memory-limit', $opts); |
|
| 44 | + $backtrackLimit = $this->getOpt('pcre-backtrack-limit', $opts); |
|
| 45 | + $recursionLimit = $this->getOpt('pcre-recursion-limit', $opts); |
|
| 46 | + $removeImportantComments = $this->getOpt('remove-important-comments', $opts); |
|
| 47 | + |
|
| 48 | + if (!is_null($help)) { |
|
| 49 | + $this->showHelp(); |
|
| 50 | + die(self::SUCCESS_EXIT); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (is_null($input)) { |
|
| 54 | + fwrite(STDERR, '-i <file> argument is missing' . PHP_EOL); |
|
| 55 | + $this->showHelp(); |
|
| 56 | + die(self::FAILURE_EXIT); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + if (!is_readable($input)) { |
|
| 60 | + fwrite(STDERR, 'Input file is not readable' . PHP_EOL); |
|
| 61 | + die(self::FAILURE_EXIT); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + $css = file_get_contents($input); |
|
| 65 | + |
|
| 66 | + if ($css === false) { |
|
| 67 | + fwrite(STDERR, 'Input CSS code could not be retrieved from input file' . PHP_EOL); |
|
| 68 | + die(self::FAILURE_EXIT); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - $this->setStat('original-size', strlen($css)); |
|
| 71 | + $this->setStat('original-size', strlen($css)); |
|
| 72 | 72 | |
| 73 | - $cssmin = new Minifier; |
|
| 73 | + $cssmin = new Minifier; |
|
| 74 | 74 | |
| 75 | - if (!is_null($keepSourceMapComment)) { |
|
| 76 | - $cssmin->keepSourceMapComment(); |
|
| 77 | - } |
|
| 75 | + if (!is_null($keepSourceMapComment)) { |
|
| 76 | + $cssmin->keepSourceMapComment(); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - if (!is_null($removeImportantComments)) { |
|
| 80 | - $cssmin->removeImportantComments(); |
|
| 81 | - } |
|
| 79 | + if (!is_null($removeImportantComments)) { |
|
| 80 | + $cssmin->removeImportantComments(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if (!is_null($linebreakPosition)) { |
|
| 84 | - $cssmin->setLineBreakPosition($linebreakPosition); |
|
| 85 | - } |
|
| 83 | + if (!is_null($linebreakPosition)) { |
|
| 84 | + $cssmin->setLineBreakPosition($linebreakPosition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if (!is_null($memoryLimit)) { |
|
| 88 | - $cssmin->setMemoryLimit($memoryLimit); |
|
| 89 | - } |
|
| 87 | + if (!is_null($memoryLimit)) { |
|
| 88 | + $cssmin->setMemoryLimit($memoryLimit); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - if (!is_null($backtrackLimit)) { |
|
| 92 | - $cssmin->setPcreBacktrackLimit($backtrackLimit); |
|
| 93 | - } |
|
| 91 | + if (!is_null($backtrackLimit)) { |
|
| 92 | + $cssmin->setPcreBacktrackLimit($backtrackLimit); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - if (!is_null($recursionLimit)) { |
|
| 96 | - $cssmin->setPcreRecursionLimit($recursionLimit); |
|
| 97 | - } |
|
| 95 | + if (!is_null($recursionLimit)) { |
|
| 96 | + $cssmin->setPcreRecursionLimit($recursionLimit); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $this->setStat('compression-time-start', microtime(true)); |
|
| 99 | + $this->setStat('compression-time-start', microtime(true)); |
|
| 100 | 100 | |
| 101 | - $css = $cssmin->run($css); |
|
| 101 | + $css = $cssmin->run($css); |
|
| 102 | 102 | |
| 103 | - $this->setStat('compression-time-end', microtime(true)); |
|
| 104 | - $this->setStat('peak-memory-usage', memory_get_peak_usage(true)); |
|
| 105 | - $this->setStat('compressed-size', strlen($css)); |
|
| 103 | + $this->setStat('compression-time-end', microtime(true)); |
|
| 104 | + $this->setStat('peak-memory-usage', memory_get_peak_usage(true)); |
|
| 105 | + $this->setStat('compressed-size', strlen($css)); |
|
| 106 | 106 | |
| 107 | - if (!is_null($dryrun)) { |
|
| 108 | - $this->showStats(); |
|
| 109 | - die(self::SUCCESS_EXIT); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if (is_null($output)) { |
|
| 113 | - fwrite(STDOUT, $css . PHP_EOL); |
|
| 114 | - $this->showStats(); |
|
| 115 | - die(self::SUCCESS_EXIT); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if (!is_writable(dirname($output))) { |
|
| 119 | - fwrite(STDERR, 'Output file is not writable' . PHP_EOL); |
|
| 120 | - die(self::FAILURE_EXIT); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - if (file_put_contents($output, $css) === false) { |
|
| 124 | - fwrite(STDERR, 'Compressed CSS code could not be saved to output file' . PHP_EOL); |
|
| 125 | - die(self::FAILURE_EXIT); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - $this->showStats(); |
|
| 129 | - |
|
| 130 | - die(self::SUCCESS_EXIT); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - protected function getOpt($opts, $options) |
|
| 134 | - { |
|
| 135 | - $value = null; |
|
| 136 | - |
|
| 137 | - if (is_string($opts)) { |
|
| 138 | - $opts = array($opts); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - foreach ($opts as $opt) { |
|
| 142 | - if (array_key_exists($opt, $options)) { |
|
| 143 | - $value = $options[$opt]; |
|
| 144 | - break; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $value; |
|
| 149 | - } |
|
| 107 | + if (!is_null($dryrun)) { |
|
| 108 | + $this->showStats(); |
|
| 109 | + die(self::SUCCESS_EXIT); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if (is_null($output)) { |
|
| 113 | + fwrite(STDOUT, $css . PHP_EOL); |
|
| 114 | + $this->showStats(); |
|
| 115 | + die(self::SUCCESS_EXIT); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if (!is_writable(dirname($output))) { |
|
| 119 | + fwrite(STDERR, 'Output file is not writable' . PHP_EOL); |
|
| 120 | + die(self::FAILURE_EXIT); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + if (file_put_contents($output, $css) === false) { |
|
| 124 | + fwrite(STDERR, 'Compressed CSS code could not be saved to output file' . PHP_EOL); |
|
| 125 | + die(self::FAILURE_EXIT); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + $this->showStats(); |
|
| 129 | + |
|
| 130 | + die(self::SUCCESS_EXIT); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + protected function getOpt($opts, $options) |
|
| 134 | + { |
|
| 135 | + $value = null; |
|
| 136 | + |
|
| 137 | + if (is_string($opts)) { |
|
| 138 | + $opts = array($opts); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + foreach ($opts as $opt) { |
|
| 142 | + if (array_key_exists($opt, $options)) { |
|
| 143 | + $value = $options[$opt]; |
|
| 144 | + break; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $value; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - protected function setStat($statName, $statValue) |
|
| 152 | - { |
|
| 153 | - $this->stats[$statName] = $statValue; |
|
| 154 | - } |
|
| 151 | + protected function setStat($statName, $statValue) |
|
| 152 | + { |
|
| 153 | + $this->stats[$statName] = $statValue; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - protected function formatBytes($size, $precision = 2) |
|
| 157 | - { |
|
| 158 | - $base = log($size, 1024); |
|
| 159 | - $suffixes = array('B', 'K', 'M', 'G', 'T'); |
|
| 160 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
| 161 | - } |
|
| 156 | + protected function formatBytes($size, $precision = 2) |
|
| 157 | + { |
|
| 158 | + $base = log($size, 1024); |
|
| 159 | + $suffixes = array('B', 'K', 'M', 'G', 'T'); |
|
| 160 | + return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - protected function formatMicroSeconds($microSecs, $precision = 2) |
|
| 164 | - { |
|
| 165 | - // ms |
|
| 166 | - $time = round($microSecs * 1000, $precision); |
|
| 163 | + protected function formatMicroSeconds($microSecs, $precision = 2) |
|
| 164 | + { |
|
| 165 | + // ms |
|
| 166 | + $time = round($microSecs * 1000, $precision); |
|
| 167 | 167 | |
| 168 | - if ($time >= 60 * 1000) { |
|
| 169 | - $time = round($time / 60 * 1000, $precision) .' m'; // m |
|
| 170 | - } elseif ($time >= 1000) { |
|
| 171 | - $time = round($time / 1000, $precision) .' s'; // s |
|
| 172 | - } else { |
|
| 173 | - $time .= ' ms'; |
|
| 174 | - } |
|
| 168 | + if ($time >= 60 * 1000) { |
|
| 169 | + $time = round($time / 60 * 1000, $precision) .' m'; // m |
|
| 170 | + } elseif ($time >= 1000) { |
|
| 171 | + $time = round($time / 1000, $precision) .' s'; // s |
|
| 172 | + } else { |
|
| 173 | + $time .= ' ms'; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - return $time; |
|
| 177 | - } |
|
| 176 | + return $time; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - protected function showStats() |
|
| 180 | - { |
|
| 181 | - $spaceSavings = round((1 - ($this->stats['compressed-size'] / $this->stats['original-size'])) * 100, 2); |
|
| 182 | - $compressionRatio = round($this->stats['original-size'] / $this->stats['compressed-size'], 2); |
|
| 183 | - $compressionTime = $this->formatMicroSeconds( |
|
| 184 | - $this->stats['compression-time-end'] - $this->stats['compression-time-start'] |
|
| 185 | - ); |
|
| 186 | - $peakMemoryUsage = $this->formatBytes($this->stats['peak-memory-usage']); |
|
| 179 | + protected function showStats() |
|
| 180 | + { |
|
| 181 | + $spaceSavings = round((1 - ($this->stats['compressed-size'] / $this->stats['original-size'])) * 100, 2); |
|
| 182 | + $compressionRatio = round($this->stats['original-size'] / $this->stats['compressed-size'], 2); |
|
| 183 | + $compressionTime = $this->formatMicroSeconds( |
|
| 184 | + $this->stats['compression-time-end'] - $this->stats['compression-time-start'] |
|
| 185 | + ); |
|
| 186 | + $peakMemoryUsage = $this->formatBytes($this->stats['peak-memory-usage']); |
|
| 187 | 187 | |
| 188 | - print <<<EOT |
|
| 188 | + print <<<EOT |
|
| 189 | 189 | |
| 190 | 190 | ------------------------------ |
| 191 | 191 | CSSMIN STATS |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | EOT; |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - protected function showHelp() |
|
| 203 | - { |
|
| 204 | - print <<<'EOT' |
|
| 202 | + protected function showHelp() |
|
| 203 | + { |
|
| 204 | + print <<<'EOT' |
|
| 205 | 205 | Usage: cssmin [options] -i <file> [-o <file>] |
| 206 | 206 | |
| 207 | 207 | -i|--input <file> File containing uncompressed CSS code. |
@@ -219,5 +219,5 @@ discard block |
||
| 219 | 219 | --remove-important-comments Removes !important comments from output. |
| 220 | 220 | |
| 221 | 221 | EOT; |
| 222 | - } |
|
| 222 | + } |
|
| 223 | 223 | } |
@@ -45,25 +45,29 @@ discard block |
||
| 45 | 45 | $recursionLimit = $this->getOpt('pcre-recursion-limit', $opts); |
| 46 | 46 | $removeImportantComments = $this->getOpt('remove-important-comments', $opts); |
| 47 | 47 | |
| 48 | - if (!is_null($help)) { |
|
| 48 | + if (!is_null($help)) |
|
| 49 | + { |
|
| 49 | 50 | $this->showHelp(); |
| 50 | 51 | die(self::SUCCESS_EXIT); |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | - if (is_null($input)) { |
|
| 54 | + if (is_null($input)) |
|
| 55 | + { |
|
| 54 | 56 | fwrite(STDERR, '-i <file> argument is missing' . PHP_EOL); |
| 55 | 57 | $this->showHelp(); |
| 56 | 58 | die(self::FAILURE_EXIT); |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | - if (!is_readable($input)) { |
|
| 61 | + if (!is_readable($input)) |
|
| 62 | + { |
|
| 60 | 63 | fwrite(STDERR, 'Input file is not readable' . PHP_EOL); |
| 61 | 64 | die(self::FAILURE_EXIT); |
| 62 | 65 | } |
| 63 | 66 | |
| 64 | 67 | $css = file_get_contents($input); |
| 65 | 68 | |
| 66 | - if ($css === false) { |
|
| 69 | + if ($css === false) |
|
| 70 | + { |
|
| 67 | 71 | fwrite(STDERR, 'Input CSS code could not be retrieved from input file' . PHP_EOL); |
| 68 | 72 | die(self::FAILURE_EXIT); |
| 69 | 73 | } |
@@ -72,27 +76,33 @@ discard block |
||
| 72 | 76 | |
| 73 | 77 | $cssmin = new Minifier; |
| 74 | 78 | |
| 75 | - if (!is_null($keepSourceMapComment)) { |
|
| 79 | + if (!is_null($keepSourceMapComment)) |
|
| 80 | + { |
|
| 76 | 81 | $cssmin->keepSourceMapComment(); |
| 77 | 82 | } |
| 78 | 83 | |
| 79 | - if (!is_null($removeImportantComments)) { |
|
| 84 | + if (!is_null($removeImportantComments)) |
|
| 85 | + { |
|
| 80 | 86 | $cssmin->removeImportantComments(); |
| 81 | 87 | } |
| 82 | 88 | |
| 83 | - if (!is_null($linebreakPosition)) { |
|
| 89 | + if (!is_null($linebreakPosition)) |
|
| 90 | + { |
|
| 84 | 91 | $cssmin->setLineBreakPosition($linebreakPosition); |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | - if (!is_null($memoryLimit)) { |
|
| 94 | + if (!is_null($memoryLimit)) |
|
| 95 | + { |
|
| 88 | 96 | $cssmin->setMemoryLimit($memoryLimit); |
| 89 | 97 | } |
| 90 | 98 | |
| 91 | - if (!is_null($backtrackLimit)) { |
|
| 99 | + if (!is_null($backtrackLimit)) |
|
| 100 | + { |
|
| 92 | 101 | $cssmin->setPcreBacktrackLimit($backtrackLimit); |
| 93 | 102 | } |
| 94 | 103 | |
| 95 | - if (!is_null($recursionLimit)) { |
|
| 104 | + if (!is_null($recursionLimit)) |
|
| 105 | + { |
|
| 96 | 106 | $cssmin->setPcreRecursionLimit($recursionLimit); |
| 97 | 107 | } |
| 98 | 108 | |
@@ -104,23 +114,27 @@ discard block |
||
| 104 | 114 | $this->setStat('peak-memory-usage', memory_get_peak_usage(true)); |
| 105 | 115 | $this->setStat('compressed-size', strlen($css)); |
| 106 | 116 | |
| 107 | - if (!is_null($dryrun)) { |
|
| 117 | + if (!is_null($dryrun)) |
|
| 118 | + { |
|
| 108 | 119 | $this->showStats(); |
| 109 | 120 | die(self::SUCCESS_EXIT); |
| 110 | 121 | } |
| 111 | 122 | |
| 112 | - if (is_null($output)) { |
|
| 123 | + if (is_null($output)) |
|
| 124 | + { |
|
| 113 | 125 | fwrite(STDOUT, $css . PHP_EOL); |
| 114 | 126 | $this->showStats(); |
| 115 | 127 | die(self::SUCCESS_EXIT); |
| 116 | 128 | } |
| 117 | 129 | |
| 118 | - if (!is_writable(dirname($output))) { |
|
| 130 | + if (!is_writable(dirname($output))) |
|
| 131 | + { |
|
| 119 | 132 | fwrite(STDERR, 'Output file is not writable' . PHP_EOL); |
| 120 | 133 | die(self::FAILURE_EXIT); |
| 121 | 134 | } |
| 122 | 135 | |
| 123 | - if (file_put_contents($output, $css) === false) { |
|
| 136 | + if (file_put_contents($output, $css) === false) |
|
| 137 | + { |
|
| 124 | 138 | fwrite(STDERR, 'Compressed CSS code could not be saved to output file' . PHP_EOL); |
| 125 | 139 | die(self::FAILURE_EXIT); |
| 126 | 140 | } |
@@ -134,12 +148,15 @@ discard block |
||
| 134 | 148 | { |
| 135 | 149 | $value = null; |
| 136 | 150 | |
| 137 | - if (is_string($opts)) { |
|
| 151 | + if (is_string($opts)) |
|
| 152 | + { |
|
| 138 | 153 | $opts = array($opts); |
| 139 | 154 | } |
| 140 | 155 | |
| 141 | - foreach ($opts as $opt) { |
|
| 142 | - if (array_key_exists($opt, $options)) { |
|
| 156 | + foreach ($opts as $opt) |
|
| 157 | + { |
|
| 158 | + if (array_key_exists($opt, $options)) |
|
| 159 | + { |
|
| 143 | 160 | $value = $options[$opt]; |
| 144 | 161 | break; |
| 145 | 162 | } |
@@ -165,11 +182,16 @@ discard block |
||
| 165 | 182 | // ms |
| 166 | 183 | $time = round($microSecs * 1000, $precision); |
| 167 | 184 | |
| 168 | - if ($time >= 60 * 1000) { |
|
| 185 | + if ($time >= 60 * 1000) |
|
| 186 | + { |
|
| 169 | 187 | $time = round($time / 60 * 1000, $precision) .' m'; // m |
| 170 | - } elseif ($time >= 1000) { |
|
| 188 | + } |
|
| 189 | + elseif ($time >= 1000) |
|
| 190 | + { |
|
| 171 | 191 | $time = round($time / 1000, $precision) .' s'; // s |
| 172 | - } else { |
|
| 192 | + } |
|
| 193 | + else |
|
| 194 | + { |
|
| 173 | 195 | $time .= ' ms'; |
| 174 | 196 | } |
| 175 | 197 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | Peak memory usage: $peakMemoryUsage |
| 197 | 197 | |
| 198 | 198 | |
| 199 | -EOT; |
|
| 199 | +eot; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | protected function showHelp() |
@@ -218,6 +218,6 @@ discard block |
||
| 218 | 218 | --pcre-recursion-limit <limit> Sets the PCRE recursion limit for this script. |
| 219 | 219 | --remove-important-comments Removes !important comments from output. |
| 220 | 220 | |
| 221 | -EOT; |
|
| 221 | +eot; |
|
| 222 | 222 | } |
| 223 | 223 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $base = log($size, 1024); |
| 159 | 159 | $suffixes = array('B', 'K', 'M', 'G', 'T'); |
| 160 | - return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; |
|
| 160 | + return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)]; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | protected function formatMicroSeconds($microSecs, $precision = 2) |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $time = round($microSecs * 1000, $precision); |
| 167 | 167 | |
| 168 | 168 | if ($time >= 60 * 1000) { |
| 169 | - $time = round($time / 60 * 1000, $precision) .' m'; // m |
|
| 169 | + $time = round($time / 60 * 1000, $precision) . ' m'; // m |
|
| 170 | 170 | } elseif ($time >= 1000) { |
| 171 | - $time = round($time / 1000, $precision) .' s'; // s |
|
| 171 | + $time = round($time / 1000, $precision) . ' s'; // s |
|
| 172 | 172 | } else { |
| 173 | 173 | $time .= ' ms'; |
| 174 | 174 | } |
@@ -4,152 +4,152 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Colors |
| 6 | 6 | { |
| 7 | - public static function getHexToNamedMap() |
|
| 8 | - { |
|
| 9 | - // Hex colors longer than named counterpart |
|
| 10 | - return array( |
|
| 11 | - '#f0ffff' => 'azure', |
|
| 12 | - '#f5f5dc' => 'beige', |
|
| 13 | - '#ffe4c4' => 'bisque', |
|
| 14 | - '#a52a2a' => 'brown', |
|
| 15 | - '#ff7f50' => 'coral', |
|
| 16 | - '#ffd700' => 'gold', |
|
| 17 | - '#808080' => 'gray', |
|
| 18 | - '#008000' => 'green', |
|
| 19 | - '#4b0082' => 'indigo', |
|
| 20 | - '#fffff0' => 'ivory', |
|
| 21 | - '#f0e68c' => 'khaki', |
|
| 22 | - '#faf0e6' => 'linen', |
|
| 23 | - '#800000' => 'maroon', |
|
| 24 | - '#000080' => 'navy', |
|
| 25 | - '#fdf5e6' => 'oldlace', |
|
| 26 | - '#808000' => 'olive', |
|
| 27 | - '#ffa500' => 'orange', |
|
| 28 | - '#da70d6' => 'orchid', |
|
| 29 | - '#cd853f' => 'peru', |
|
| 30 | - '#ffc0cb' => 'pink', |
|
| 31 | - '#dda0dd' => 'plum', |
|
| 32 | - '#800080' => 'purple', |
|
| 33 | - '#f00' => 'red', |
|
| 34 | - '#fa8072' => 'salmon', |
|
| 35 | - '#a0522d' => 'sienna', |
|
| 36 | - '#c0c0c0' => 'silver', |
|
| 37 | - '#fffafa' => 'snow', |
|
| 38 | - '#d2b48c' => 'tan', |
|
| 39 | - '#008080' => 'teal', |
|
| 40 | - '#ff6347' => 'tomato', |
|
| 41 | - '#ee82ee' => 'violet', |
|
| 42 | - '#f5deb3' => 'wheat' |
|
| 43 | - ); |
|
| 44 | - } |
|
| 7 | + public static function getHexToNamedMap() |
|
| 8 | + { |
|
| 9 | + // Hex colors longer than named counterpart |
|
| 10 | + return array( |
|
| 11 | + '#f0ffff' => 'azure', |
|
| 12 | + '#f5f5dc' => 'beige', |
|
| 13 | + '#ffe4c4' => 'bisque', |
|
| 14 | + '#a52a2a' => 'brown', |
|
| 15 | + '#ff7f50' => 'coral', |
|
| 16 | + '#ffd700' => 'gold', |
|
| 17 | + '#808080' => 'gray', |
|
| 18 | + '#008000' => 'green', |
|
| 19 | + '#4b0082' => 'indigo', |
|
| 20 | + '#fffff0' => 'ivory', |
|
| 21 | + '#f0e68c' => 'khaki', |
|
| 22 | + '#faf0e6' => 'linen', |
|
| 23 | + '#800000' => 'maroon', |
|
| 24 | + '#000080' => 'navy', |
|
| 25 | + '#fdf5e6' => 'oldlace', |
|
| 26 | + '#808000' => 'olive', |
|
| 27 | + '#ffa500' => 'orange', |
|
| 28 | + '#da70d6' => 'orchid', |
|
| 29 | + '#cd853f' => 'peru', |
|
| 30 | + '#ffc0cb' => 'pink', |
|
| 31 | + '#dda0dd' => 'plum', |
|
| 32 | + '#800080' => 'purple', |
|
| 33 | + '#f00' => 'red', |
|
| 34 | + '#fa8072' => 'salmon', |
|
| 35 | + '#a0522d' => 'sienna', |
|
| 36 | + '#c0c0c0' => 'silver', |
|
| 37 | + '#fffafa' => 'snow', |
|
| 38 | + '#d2b48c' => 'tan', |
|
| 39 | + '#008080' => 'teal', |
|
| 40 | + '#ff6347' => 'tomato', |
|
| 41 | + '#ee82ee' => 'violet', |
|
| 42 | + '#f5deb3' => 'wheat' |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public static function getNamedToHexMap() |
|
| 47 | - { |
|
| 48 | - // Named colors longer than hex counterpart |
|
| 49 | - return array( |
|
| 50 | - 'aliceblue' => '#f0f8ff', |
|
| 51 | - 'antiquewhite' => '#faebd7', |
|
| 52 | - 'aquamarine' => '#7fffd4', |
|
| 53 | - 'black' => '#000', |
|
| 54 | - 'blanchedalmond' => '#ffebcd', |
|
| 55 | - 'blueviolet' => '#8a2be2', |
|
| 56 | - 'burlywood' => '#deb887', |
|
| 57 | - 'cadetblue' => '#5f9ea0', |
|
| 58 | - 'chartreuse' => '#7fff00', |
|
| 59 | - 'chocolate' => '#d2691e', |
|
| 60 | - 'cornflowerblue' => '#6495ed', |
|
| 61 | - 'cornsilk' => '#fff8dc', |
|
| 62 | - 'darkblue' => '#00008b', |
|
| 63 | - 'darkcyan' => '#008b8b', |
|
| 64 | - 'darkgoldenrod' => '#b8860b', |
|
| 65 | - 'darkgray' => '#a9a9a9', |
|
| 66 | - 'darkgreen' => '#006400', |
|
| 67 | - 'darkgrey' => '#a9a9a9', |
|
| 68 | - 'darkkhaki' => '#bdb76b', |
|
| 69 | - 'darkmagenta' => '#8b008b', |
|
| 70 | - 'darkolivegreen' => '#556b2f', |
|
| 71 | - 'darkorange' => '#ff8c00', |
|
| 72 | - 'darkorchid' => '#9932cc', |
|
| 73 | - 'darksalmon' => '#e9967a', |
|
| 74 | - 'darkseagreen' => '#8fbc8f', |
|
| 75 | - 'darkslateblue' => '#483d8b', |
|
| 76 | - 'darkslategray' => '#2f4f4f', |
|
| 77 | - 'darkslategrey' => '#2f4f4f', |
|
| 78 | - 'darkturquoise' => '#00ced1', |
|
| 79 | - 'darkviolet' => '#9400d3', |
|
| 80 | - 'deeppink' => '#ff1493', |
|
| 81 | - 'deepskyblue' => '#00bfff', |
|
| 82 | - 'dodgerblue' => '#1e90ff', |
|
| 83 | - 'firebrick' => '#b22222', |
|
| 84 | - 'floralwhite' => '#fffaf0', |
|
| 85 | - 'forestgreen' => '#228b22', |
|
| 86 | - 'fuchsia' => '#f0f', |
|
| 87 | - 'gainsboro' => '#dcdcdc', |
|
| 88 | - 'ghostwhite' => '#f8f8ff', |
|
| 89 | - 'goldenrod' => '#daa520', |
|
| 90 | - 'greenyellow' => '#adff2f', |
|
| 91 | - 'honeydew' => '#f0fff0', |
|
| 92 | - 'indianred' => '#cd5c5c', |
|
| 93 | - 'lavender' => '#e6e6fa', |
|
| 94 | - 'lavenderblush' => '#fff0f5', |
|
| 95 | - 'lawngreen' => '#7cfc00', |
|
| 96 | - 'lemonchiffon' => '#fffacd', |
|
| 97 | - 'lightblue' => '#add8e6', |
|
| 98 | - 'lightcoral' => '#f08080', |
|
| 99 | - 'lightcyan' => '#e0ffff', |
|
| 100 | - 'lightgoldenrodyellow' => '#fafad2', |
|
| 101 | - 'lightgray' => '#d3d3d3', |
|
| 102 | - 'lightgreen' => '#90ee90', |
|
| 103 | - 'lightgrey' => '#d3d3d3', |
|
| 104 | - 'lightpink' => '#ffb6c1', |
|
| 105 | - 'lightsalmon' => '#ffa07a', |
|
| 106 | - 'lightseagreen' => '#20b2aa', |
|
| 107 | - 'lightskyblue' => '#87cefa', |
|
| 108 | - 'lightslategray' => '#778899', |
|
| 109 | - 'lightslategrey' => '#778899', |
|
| 110 | - 'lightsteelblue' => '#b0c4de', |
|
| 111 | - 'lightyellow' => '#ffffe0', |
|
| 112 | - 'limegreen' => '#32cd32', |
|
| 113 | - 'mediumaquamarine' => '#66cdaa', |
|
| 114 | - 'mediumblue' => '#0000cd', |
|
| 115 | - 'mediumorchid' => '#ba55d3', |
|
| 116 | - 'mediumpurple' => '#9370db', |
|
| 117 | - 'mediumseagreen' => '#3cb371', |
|
| 118 | - 'mediumslateblue' => '#7b68ee', |
|
| 119 | - 'mediumspringgreen' => '#00fa9a', |
|
| 120 | - 'mediumturquoise' => '#48d1cc', |
|
| 121 | - 'mediumvioletred' => '#c71585', |
|
| 122 | - 'midnightblue' => '#191970', |
|
| 123 | - 'mintcream' => '#f5fffa', |
|
| 124 | - 'mistyrose' => '#ffe4e1', |
|
| 125 | - 'moccasin' => '#ffe4b5', |
|
| 126 | - 'navajowhite' => '#ffdead', |
|
| 127 | - 'olivedrab' => '#6b8e23', |
|
| 128 | - 'orangered' => '#ff4500', |
|
| 129 | - 'palegoldenrod' => '#eee8aa', |
|
| 130 | - 'palegreen' => '#98fb98', |
|
| 131 | - 'paleturquoise' => '#afeeee', |
|
| 132 | - 'palevioletred' => '#db7093', |
|
| 133 | - 'papayawhip' => '#ffefd5', |
|
| 134 | - 'peachpuff' => '#ffdab9', |
|
| 135 | - 'powderblue' => '#b0e0e6', |
|
| 136 | - 'rebeccapurple' => '#663399', |
|
| 137 | - 'rosybrown' => '#bc8f8f', |
|
| 138 | - 'royalblue' => '#4169e1', |
|
| 139 | - 'saddlebrown' => '#8b4513', |
|
| 140 | - 'sandybrown' => '#f4a460', |
|
| 141 | - 'seagreen' => '#2e8b57', |
|
| 142 | - 'seashell' => '#fff5ee', |
|
| 143 | - 'slateblue' => '#6a5acd', |
|
| 144 | - 'slategray' => '#708090', |
|
| 145 | - 'slategrey' => '#708090', |
|
| 146 | - 'springgreen' => '#00ff7f', |
|
| 147 | - 'steelblue' => '#4682b4', |
|
| 148 | - 'turquoise' => '#40e0d0', |
|
| 149 | - 'white' => '#fff', |
|
| 150 | - 'whitesmoke' => '#f5f5f5', |
|
| 151 | - 'yellow' => '#ff0', |
|
| 152 | - 'yellowgreen' => '#9acd32' |
|
| 153 | - ); |
|
| 154 | - } |
|
| 46 | + public static function getNamedToHexMap() |
|
| 47 | + { |
|
| 48 | + // Named colors longer than hex counterpart |
|
| 49 | + return array( |
|
| 50 | + 'aliceblue' => '#f0f8ff', |
|
| 51 | + 'antiquewhite' => '#faebd7', |
|
| 52 | + 'aquamarine' => '#7fffd4', |
|
| 53 | + 'black' => '#000', |
|
| 54 | + 'blanchedalmond' => '#ffebcd', |
|
| 55 | + 'blueviolet' => '#8a2be2', |
|
| 56 | + 'burlywood' => '#deb887', |
|
| 57 | + 'cadetblue' => '#5f9ea0', |
|
| 58 | + 'chartreuse' => '#7fff00', |
|
| 59 | + 'chocolate' => '#d2691e', |
|
| 60 | + 'cornflowerblue' => '#6495ed', |
|
| 61 | + 'cornsilk' => '#fff8dc', |
|
| 62 | + 'darkblue' => '#00008b', |
|
| 63 | + 'darkcyan' => '#008b8b', |
|
| 64 | + 'darkgoldenrod' => '#b8860b', |
|
| 65 | + 'darkgray' => '#a9a9a9', |
|
| 66 | + 'darkgreen' => '#006400', |
|
| 67 | + 'darkgrey' => '#a9a9a9', |
|
| 68 | + 'darkkhaki' => '#bdb76b', |
|
| 69 | + 'darkmagenta' => '#8b008b', |
|
| 70 | + 'darkolivegreen' => '#556b2f', |
|
| 71 | + 'darkorange' => '#ff8c00', |
|
| 72 | + 'darkorchid' => '#9932cc', |
|
| 73 | + 'darksalmon' => '#e9967a', |
|
| 74 | + 'darkseagreen' => '#8fbc8f', |
|
| 75 | + 'darkslateblue' => '#483d8b', |
|
| 76 | + 'darkslategray' => '#2f4f4f', |
|
| 77 | + 'darkslategrey' => '#2f4f4f', |
|
| 78 | + 'darkturquoise' => '#00ced1', |
|
| 79 | + 'darkviolet' => '#9400d3', |
|
| 80 | + 'deeppink' => '#ff1493', |
|
| 81 | + 'deepskyblue' => '#00bfff', |
|
| 82 | + 'dodgerblue' => '#1e90ff', |
|
| 83 | + 'firebrick' => '#b22222', |
|
| 84 | + 'floralwhite' => '#fffaf0', |
|
| 85 | + 'forestgreen' => '#228b22', |
|
| 86 | + 'fuchsia' => '#f0f', |
|
| 87 | + 'gainsboro' => '#dcdcdc', |
|
| 88 | + 'ghostwhite' => '#f8f8ff', |
|
| 89 | + 'goldenrod' => '#daa520', |
|
| 90 | + 'greenyellow' => '#adff2f', |
|
| 91 | + 'honeydew' => '#f0fff0', |
|
| 92 | + 'indianred' => '#cd5c5c', |
|
| 93 | + 'lavender' => '#e6e6fa', |
|
| 94 | + 'lavenderblush' => '#fff0f5', |
|
| 95 | + 'lawngreen' => '#7cfc00', |
|
| 96 | + 'lemonchiffon' => '#fffacd', |
|
| 97 | + 'lightblue' => '#add8e6', |
|
| 98 | + 'lightcoral' => '#f08080', |
|
| 99 | + 'lightcyan' => '#e0ffff', |
|
| 100 | + 'lightgoldenrodyellow' => '#fafad2', |
|
| 101 | + 'lightgray' => '#d3d3d3', |
|
| 102 | + 'lightgreen' => '#90ee90', |
|
| 103 | + 'lightgrey' => '#d3d3d3', |
|
| 104 | + 'lightpink' => '#ffb6c1', |
|
| 105 | + 'lightsalmon' => '#ffa07a', |
|
| 106 | + 'lightseagreen' => '#20b2aa', |
|
| 107 | + 'lightskyblue' => '#87cefa', |
|
| 108 | + 'lightslategray' => '#778899', |
|
| 109 | + 'lightslategrey' => '#778899', |
|
| 110 | + 'lightsteelblue' => '#b0c4de', |
|
| 111 | + 'lightyellow' => '#ffffe0', |
|
| 112 | + 'limegreen' => '#32cd32', |
|
| 113 | + 'mediumaquamarine' => '#66cdaa', |
|
| 114 | + 'mediumblue' => '#0000cd', |
|
| 115 | + 'mediumorchid' => '#ba55d3', |
|
| 116 | + 'mediumpurple' => '#9370db', |
|
| 117 | + 'mediumseagreen' => '#3cb371', |
|
| 118 | + 'mediumslateblue' => '#7b68ee', |
|
| 119 | + 'mediumspringgreen' => '#00fa9a', |
|
| 120 | + 'mediumturquoise' => '#48d1cc', |
|
| 121 | + 'mediumvioletred' => '#c71585', |
|
| 122 | + 'midnightblue' => '#191970', |
|
| 123 | + 'mintcream' => '#f5fffa', |
|
| 124 | + 'mistyrose' => '#ffe4e1', |
|
| 125 | + 'moccasin' => '#ffe4b5', |
|
| 126 | + 'navajowhite' => '#ffdead', |
|
| 127 | + 'olivedrab' => '#6b8e23', |
|
| 128 | + 'orangered' => '#ff4500', |
|
| 129 | + 'palegoldenrod' => '#eee8aa', |
|
| 130 | + 'palegreen' => '#98fb98', |
|
| 131 | + 'paleturquoise' => '#afeeee', |
|
| 132 | + 'palevioletred' => '#db7093', |
|
| 133 | + 'papayawhip' => '#ffefd5', |
|
| 134 | + 'peachpuff' => '#ffdab9', |
|
| 135 | + 'powderblue' => '#b0e0e6', |
|
| 136 | + 'rebeccapurple' => '#663399', |
|
| 137 | + 'rosybrown' => '#bc8f8f', |
|
| 138 | + 'royalblue' => '#4169e1', |
|
| 139 | + 'saddlebrown' => '#8b4513', |
|
| 140 | + 'sandybrown' => '#f4a460', |
|
| 141 | + 'seagreen' => '#2e8b57', |
|
| 142 | + 'seashell' => '#fff5ee', |
|
| 143 | + 'slateblue' => '#6a5acd', |
|
| 144 | + 'slategray' => '#708090', |
|
| 145 | + 'slategrey' => '#708090', |
|
| 146 | + 'springgreen' => '#00ff7f', |
|
| 147 | + 'steelblue' => '#4682b4', |
|
| 148 | + 'turquoise' => '#40e0d0', |
|
| 149 | + 'white' => '#fff', |
|
| 150 | + 'whitesmoke' => '#f5f5f5', |
|
| 151 | + 'yellow' => '#ff0', |
|
| 152 | + 'yellowgreen' => '#9acd32' |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | 155 | } |
@@ -92,9 +92,12 @@ discard block |
||
| 92 | 92 | mb_internal_encoding('ASCII'); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - try { |
|
| 95 | + try |
|
| 96 | + { |
|
| 96 | 97 | $out = _safe_serialize($value); |
| 97 | - } catch(Exception $e) { |
|
| 98 | + } |
|
| 99 | + catch(Exception $e) |
|
| 100 | + { |
|
| 98 | 101 | $out = false; |
| 99 | 102 | } |
| 100 | 103 | |
@@ -215,7 +218,8 @@ discard block |
||
| 215 | 218 | |
| 216 | 219 | // go to terminal state if we're at the end of the root array |
| 217 | 220 | array_pop($expected); |
| 218 | - if(count($expected) == 0) { |
|
| 221 | + if(count($expected) == 0) |
|
| 222 | + { |
|
| 219 | 223 | $state = 1; |
| 220 | 224 | } |
| 221 | 225 | break; |
@@ -287,9 +291,12 @@ discard block |
||
| 287 | 291 | mb_internal_encoding('ASCII'); |
| 288 | 292 | } |
| 289 | 293 | |
| 290 | - try { |
|
| 294 | + try |
|
| 295 | + { |
|
| 291 | 296 | $out = _safe_unserialize($str); |
| 292 | - } catch(Exception $e) { |
|
| 297 | + } |
|
| 298 | + catch(Exception $e) |
|
| 299 | + { |
|
| 293 | 300 | $out = ''; |
| 294 | 301 | } |
| 295 | 302 | |
@@ -31,48 +31,48 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | * @throw Exception if $value is malformed or contains unsupported types (e.g., resources, objects) |
| 33 | 33 | */ |
| 34 | -function _safe_serialize( $value ) |
|
| 34 | +function _safe_serialize($value) |
|
| 35 | 35 | { |
| 36 | - if(is_null($value)) |
|
| 36 | + if (is_null($value)) |
|
| 37 | 37 | { |
| 38 | 38 | return 'N;'; |
| 39 | 39 | } |
| 40 | - if(is_bool($value)) |
|
| 40 | + if (is_bool($value)) |
|
| 41 | 41 | { |
| 42 | - return 'b:'.(int)$value.';'; |
|
| 42 | + return 'b:' . (int) $value . ';'; |
|
| 43 | 43 | } |
| 44 | - if(is_int($value)) |
|
| 44 | + if (is_int($value)) |
|
| 45 | 45 | { |
| 46 | - return 'i:'.$value.';'; |
|
| 46 | + return 'i:' . $value . ';'; |
|
| 47 | 47 | } |
| 48 | - if(is_float($value)) |
|
| 48 | + if (is_float($value)) |
|
| 49 | 49 | { |
| 50 | - return 'd:'.$value.';'; |
|
| 50 | + return 'd:' . $value . ';'; |
|
| 51 | 51 | } |
| 52 | - if(is_string($value)) |
|
| 52 | + if (is_string($value)) |
|
| 53 | 53 | { |
| 54 | - return 's:'.strlen($value).':"'.$value.'";'; |
|
| 54 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
| 55 | 55 | } |
| 56 | - if(is_array($value)) |
|
| 56 | + if (is_array($value)) |
|
| 57 | 57 | { |
| 58 | 58 | $out = ''; |
| 59 | - foreach($value as $k => $v) |
|
| 59 | + foreach ($value as $k => $v) |
|
| 60 | 60 | { |
| 61 | 61 | $out .= _safe_serialize($k) . _safe_serialize($v); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - return 'a:'.count($value).':{'.$out.'}'; |
|
| 64 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
| 65 | 65 | } |
| 66 | - if(is_resource($value)) |
|
| 66 | + if (is_resource($value)) |
|
| 67 | 67 | { |
| 68 | 68 | // built-in returns 'i:0;' |
| 69 | 69 | throw new \Exception('safe_serialize: resources not supported'); |
| 70 | 70 | } |
| 71 | - if(is_object($value) || gettype($value) == 'object') |
|
| 71 | + if (is_object($value) || gettype($value) == 'object') |
|
| 72 | 72 | { |
| 73 | 73 | throw new \Exception('safe_serialize: objects not supported'); |
| 74 | 74 | } |
| 75 | - throw new \Exception('safe_serialize cannot serialize: '.gettype($value)); |
|
| 75 | + throw new \Exception('safe_serialize cannot serialize: ' . gettype($value)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param mixed $value |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | -function safe_serialize( $value ) |
|
| 85 | +function safe_serialize($value) |
|
| 86 | 86 | { |
| 87 | 87 | // ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() |
| 88 | 88 | if (function_exists('mb_internal_encoding') && |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | try { |
| 96 | 96 | $out = _safe_serialize($value); |
| 97 | - } catch(Exception $e) { |
|
| 97 | + } catch (Exception $e) { |
|
| 98 | 98 | $out = false; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function _safe_unserialize($str) |
| 116 | 116 | { |
| 117 | - if(strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) |
|
| 117 | + if (strlen($str) > MAX_SERIALIZED_INPUT_LENGTH) |
|
| 118 | 118 | { |
| 119 | 119 | throw new \Exception('safe_unserialize: input exceeds ' . MAX_SERIALIZED_INPUT_LENGTH); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if(empty($str) || !is_string($str)) |
|
| 122 | + if (empty($str) || !is_string($str)) |
|
| 123 | 123 | { |
| 124 | 124 | return false; |
| 125 | 125 | } |
@@ -128,59 +128,59 @@ discard block |
||
| 128 | 128 | $expected = array(); |
| 129 | 129 | $state = 0; |
| 130 | 130 | |
| 131 | - while($state != 1) |
|
| 131 | + while ($state != 1) |
|
| 132 | 132 | { |
| 133 | 133 | $type = isset($str[0]) ? $str[0] : ''; |
| 134 | 134 | |
| 135 | - if($type == '}') |
|
| 135 | + if ($type == '}') |
|
| 136 | 136 | { |
| 137 | 137 | $str = substr($str, 1); |
| 138 | 138 | } |
| 139 | - else if($type == 'N' && $str[1] == ';') |
|
| 139 | + else if ($type == 'N' && $str[1] == ';') |
|
| 140 | 140 | { |
| 141 | 141 | $value = null; |
| 142 | 142 | $str = substr($str, 2); |
| 143 | 143 | } |
| 144 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 144 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
| 145 | 145 | { |
| 146 | 146 | $value = $matches[1] == '1' ? true : false; |
| 147 | 147 | $str = substr($str, 4); |
| 148 | 148 | } |
| 149 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 149 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
| 150 | 150 | { |
| 151 | - $value = (int)$matches[1]; |
|
| 151 | + $value = (int) $matches[1]; |
|
| 152 | 152 | $str = $matches[2]; |
| 153 | 153 | } |
| 154 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 154 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
| 155 | 155 | { |
| 156 | - $value = (float)$matches[1]; |
|
| 156 | + $value = (float) $matches[1]; |
|
| 157 | 157 | $str = $matches[3]; |
| 158 | 158 | } |
| 159 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
| 159 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
| 160 | 160 | { |
| 161 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
| 162 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
| 161 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
| 162 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
| 163 | 163 | } |
| 164 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 164 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 165 | 165 | { |
| 166 | - $expectedLength = (int)$matches[1]; |
|
| 166 | + $expectedLength = (int) $matches[1]; |
|
| 167 | 167 | $str = $matches[2]; |
| 168 | 168 | } |
| 169 | - else if($type == 'O') |
|
| 169 | + else if ($type == 'O') |
|
| 170 | 170 | { |
| 171 | 171 | throw new \Exception('safe_unserialize: objects not supported'); |
| 172 | 172 | } |
| 173 | 173 | else |
| 174 | 174 | { |
| 175 | - throw new \Exception('safe_unserialize: unknown/malformed type: '.$type); |
|
| 175 | + throw new \Exception('safe_unserialize: unknown/malformed type: ' . $type); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - switch($state) |
|
| 178 | + switch ($state) |
|
| 179 | 179 | { |
| 180 | 180 | case 3: // in array, expecting value or another array |
| 181 | - if($type == 'a') |
|
| 181 | + if ($type == 'a') |
|
| 182 | 182 | { |
| 183 | - if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 183 | + if (count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 184 | 184 | { |
| 185 | 185 | throw new \Exception('safe_unserialize: array nesting exceeds ' . MAX_SERIALIZED_ARRAY_DEPTH); |
| 186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $state = 2; |
| 193 | 193 | break; |
| 194 | 194 | } |
| 195 | - if($type != '}') |
|
| 195 | + if ($type != '}') |
|
| 196 | 196 | { |
| 197 | 197 | $list[$key] = $value; |
| 198 | 198 | $state = 2; |
@@ -202,31 +202,31 @@ discard block |
||
| 202 | 202 | throw new \Exception('safe_unserialize: missing array value'); |
| 203 | 203 | |
| 204 | 204 | case 2: // in array, expecting end of array or a key |
| 205 | - if($type == '}') |
|
| 205 | + if ($type == '}') |
|
| 206 | 206 | { |
| 207 | - if(count($list) < end($expected)) |
|
| 207 | + if (count($list) < end($expected)) |
|
| 208 | 208 | { |
| 209 | 209 | throw new \Exception('safe_unserialize: array size less than expected ' . $expected[0]); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | unset($list); |
| 213 | - $list = &$stack[count($stack)-1]; |
|
| 213 | + $list = &$stack[count($stack) - 1]; |
|
| 214 | 214 | array_pop($stack); |
| 215 | 215 | |
| 216 | 216 | // go to terminal state if we're at the end of the root array |
| 217 | 217 | array_pop($expected); |
| 218 | - if(count($expected) == 0) { |
|
| 218 | + if (count($expected) == 0) { |
|
| 219 | 219 | $state = 1; |
| 220 | 220 | } |
| 221 | 221 | break; |
| 222 | 222 | } |
| 223 | - if($type == 'i' || $type == 's') |
|
| 223 | + if ($type == 'i' || $type == 's') |
|
| 224 | 224 | { |
| 225 | - if(count($list) >= MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 225 | + if (count($list) >= MAX_SERIALIZED_ARRAY_LENGTH) |
|
| 226 | 226 | { |
| 227 | 227 | throw new \Exception('safe_unserialize: array size exceeds ' . MAX_SERIALIZED_ARRAY_LENGTH); |
| 228 | 228 | } |
| 229 | - if(count($list) >= end($expected)) |
|
| 229 | + if (count($list) >= end($expected)) |
|
| 230 | 230 | { |
| 231 | 231 | throw new \Exception('safe_unserialize: array size exceeds expected length'); |
| 232 | 232 | } |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | throw new \Exception('safe_unserialize: illegal array index type'); |
| 240 | 240 | |
| 241 | 241 | case 0: // expecting array or value |
| 242 | - if($type == 'a') |
|
| 242 | + if ($type == 'a') |
|
| 243 | 243 | { |
| 244 | - if(count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 244 | + if (count($stack) >= MAX_SERIALIZED_ARRAY_DEPTH) |
|
| 245 | 245 | { |
| 246 | 246 | throw new \Exception('safe_unserialize: array nesting exceeds ' . MAX_SERIALIZED_ARRAY_DEPTH); |
| 247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $state = 2; |
| 253 | 253 | break; |
| 254 | 254 | } |
| 255 | - if($type != '}') |
|
| 255 | + if ($type != '}') |
|
| 256 | 256 | { |
| 257 | 257 | $data = $value; |
| 258 | 258 | $state = 1; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if(!empty($str)) |
|
| 266 | + if (!empty($str)) |
|
| 267 | 267 | { |
| 268 | 268 | throw new \Exception('safe_unserialize: trailing data in input'); |
| 269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @param string $str |
| 278 | 278 | * @return mixed |
| 279 | 279 | */ |
| 280 | -function safe_unserialize( $str ) |
|
| 280 | +function safe_unserialize($str) |
|
| 281 | 281 | { |
| 282 | 282 | // ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() |
| 283 | 283 | if (function_exists('mb_internal_encoding') && |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | try { |
| 291 | 291 | $out = _safe_unserialize($str); |
| 292 | - } catch(Exception $e) { |
|
| 292 | + } catch (Exception $e) { |
|
| 293 | 293 | $out = ''; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -58,7 +58,9 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | // Should we account for how much is currently being used? |
| 60 | 60 | if ($in_use) |
| 61 | - $memory_needed += memory_get_usage(); |
|
| 61 | + { |
|
| 62 | + $memory_needed += memory_get_usage(); |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | // If more is needed, request it |
| 64 | 66 | if ($memory_current < $memory_needed) |
@@ -117,7 +119,9 @@ discard block |
||
| 117 | 119 | |
| 118 | 120 | // Don't let apache close the connection |
| 119 | 121 | if ($server_reset && function_exists('apache_reset_timeout')) |
| 120 | - @apache_reset_timeout(); |
|
| 122 | + { |
|
| 123 | + @apache_reset_timeout(); |
|
| 124 | + } |
|
| 121 | 125 | |
| 122 | 126 | return ini_get('max_execution_time'); |
| 123 | 127 | } |
@@ -37,14 +37,18 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | // Secure PHPSESSIONID |
| 39 | 39 | if (parse_url($boardurl, PHP_URL_SCHEME) === 'https') |
| 40 | - @ini_set('session.cookie_secure', true); |
|
| 40 | + { |
|
| 41 | + @ini_set('session.cookie_secure', true); |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | if (!empty($modSettings['globalCookies'])) |
| 43 | 45 | { |
| 44 | 46 | $parsed_url = parse_url($boardurl); |
| 45 | 47 | |
| 46 | 48 | if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
| 47 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 49 | + { |
|
| 50 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 51 | + } |
|
| 48 | 52 | } |
| 49 | 53 | |
| 50 | 54 | // @todo Set the session cookie path? |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | { |
| 54 | 58 | // Attempt to end the already-started session. |
| 55 | 59 | if (ini_get('session.auto_start') == 1) |
| 56 | - session_write_close(); |
|
| 60 | + { |
|
| 61 | + session_write_close(); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 59 | 65 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -96,7 +102,9 @@ discard block |
||
| 96 | 102 | // APC destroys static class members before sessions can be written. To work around this we |
| 97 | 103 | // explicitly call session_write_close on script end/exit bugs.php.net/bug.php?id=60657 |
| 98 | 104 | if (extension_loaded('apc') && ini_get('apc.enabled') && !extension_loaded('apcu')) |
| 99 | - register_shutdown_function('session_write_close'); |
|
| 105 | + { |
|
| 106 | + register_shutdown_function('session_write_close'); |
|
| 107 | + } |
|
| 100 | 108 | } |
| 101 | 109 | |
| 102 | 110 | // Start the session |
@@ -104,7 +112,9 @@ discard block |
||
| 104 | 112 | |
| 105 | 113 | // Change it so the cache settings are a little looser than default. |
| 106 | 114 | if (!empty($modSettings['databaseSession_loose']) || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'search')) |
| 107 | - header('Cache-Control: private'); |
|
| 115 | + { |
|
| 116 | + header('Cache-Control: private'); |
|
| 117 | + } |
|
| 108 | 118 | } |
| 109 | 119 | |
| 110 | 120 | // Set the randomly generated code. |
@@ -133,7 +133,9 @@ |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | foreach ($vars as $key => $value) |
| 136 | - $this->js_vars[$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 136 | + { |
|
| 137 | + $this->js_vars[$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
| 138 | + } |
|
| 137 | 139 | } |
| 138 | 140 | |
| 139 | 141 | /** |
@@ -154,7 +154,9 @@ discard block |
||
| 154 | 154 | $validator->text_replacements(array('paid_email_to' => $txt['paid_email_to'])); |
| 155 | 155 | |
| 156 | 156 | if ($validator->validate($this->_req->post)) |
| 157 | - $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 157 | + { |
|
| 158 | + $this->_req->post->paid_email_to = $validator->validation_data('paid_email_to'); |
|
| 159 | + } |
|
| 158 | 160 | else |
| 159 | 161 | { |
| 160 | 162 | // That's not an email, lets set it back in the form to be fixed and let them know its wrong |
@@ -162,7 +164,9 @@ discard block |
||
| 162 | 164 | $context['error_type'] = 'minor'; |
| 163 | 165 | $context['settings_message'] = array(); |
| 164 | 166 | foreach ($validator->validation_errors() as $id => $error) |
| 165 | - $context['settings_message'][] = $error; |
|
| 167 | + { |
|
| 168 | + $context['settings_message'][] = $error; |
|
| 169 | + } |
|
| 166 | 170 | } |
| 167 | 171 | } |
| 168 | 172 | |
@@ -201,7 +205,9 @@ discard block |
||
| 201 | 205 | // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. |
| 202 | 206 | $modSettings['paid_currency'] = !empty($modSettings['paid_currency_code']) ? $modSettings['paid_currency_code'] : ''; |
| 203 | 207 | if (!empty($modSettings['paid_currency_code']) && !in_array($modSettings['paid_currency_code'], array('usd', 'eur', 'gbp'))) |
| 204 | - $modSettings['paid_currency'] = 'other'; |
|
| 208 | + { |
|
| 209 | + $modSettings['paid_currency'] = 'other'; |
|
| 210 | + } |
|
| 205 | 211 | |
| 206 | 212 | // These are all the default settings. |
| 207 | 213 | $config_vars = array( |
@@ -257,7 +263,9 @@ discard block |
||
| 257 | 263 | |
| 258 | 264 | // Not made the settings yet? |
| 259 | 265 | if (empty($modSettings['paid_currency_symbol'])) |
| 260 | - throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 266 | + { |
|
| 267 | + throw new Elk_Exception('paid_not_set_currency', false, array($scripturl . '?action=admin;area=paidsubscribe;sa=settings')); |
|
| 268 | + } |
|
| 261 | 269 | |
| 262 | 270 | // Some basic stuff. |
| 263 | 271 | $context['page_title'] = $txt['paid_subs_view']; |
@@ -460,7 +468,9 @@ discard block |
||
| 460 | 468 | |
| 461 | 469 | // There needs to be something. |
| 462 | 470 | if (empty($this->_req->post->span_value) || empty($this->_req->post->cost)) |
| 463 | - throw new Elk_Exception('paid_no_cost_value'); |
|
| 471 | + { |
|
| 472 | + throw new Elk_Exception('paid_no_cost_value'); |
|
| 473 | + } |
|
| 464 | 474 | } |
| 465 | 475 | // Flexible is harder but more fun ;) |
| 466 | 476 | else |
@@ -475,7 +485,9 @@ discard block |
||
| 475 | 485 | ); |
| 476 | 486 | |
| 477 | 487 | if (empty($this->_req->post->cost_day) && empty($this->_req->post->cost_week) && empty($this->_req->post->cost_month) && empty($this->_req->post->cost_year)) |
| 478 | - throw new Elk_Exception('paid_all_freq_blank'); |
|
| 488 | + { |
|
| 489 | + throw new Elk_Exception('paid_all_freq_blank'); |
|
| 490 | + } |
|
| 479 | 491 | } |
| 480 | 492 | |
| 481 | 493 | $cost = serialize($cost); |
@@ -485,7 +497,9 @@ discard block |
||
| 485 | 497 | if (!empty($this->_req->post->addgroup)) |
| 486 | 498 | { |
| 487 | 499 | foreach ($this->_req->post->addgroup as $id => $dummy) |
| 488 | - $addGroups[] = (int) $id; |
|
| 500 | + { |
|
| 501 | + $addGroups[] = (int) $id; |
|
| 502 | + } |
|
| 489 | 503 | } |
| 490 | 504 | $addGroups = implode(',', $addGroups); |
| 491 | 505 | |
@@ -813,16 +827,22 @@ discard block |
||
| 813 | 827 | |
| 814 | 828 | // If we haven't been passed the subscription ID get it. |
| 815 | 829 | if ($context['log_id'] && !$context['sub_id']) |
| 816 | - $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 830 | + { |
|
| 831 | + $context['sub_id'] = validateSubscriptionID($context['log_id']); |
|
| 832 | + } |
|
| 817 | 833 | |
| 818 | 834 | if (!isset($context['subscriptions'][$context['sub_id']])) |
| 819 | - throw new Elk_Exception('no_access', false); |
|
| 835 | + { |
|
| 836 | + throw new Elk_Exception('no_access', false); |
|
| 837 | + } |
|
| 820 | 838 | |
| 821 | 839 | $context['current_subscription'] = $context['subscriptions'][$context['sub_id']]; |
| 822 | 840 | |
| 823 | 841 | // Searching? |
| 824 | 842 | if (isset($this->_req->post->ssearch)) |
| 825 | - return $this->action_viewsub(); |
|
| 843 | + { |
|
| 844 | + return $this->action_viewsub(); |
|
| 845 | + } |
|
| 826 | 846 | // Saving? |
| 827 | 847 | elseif (isset($this->_req->post->save_sub)) |
| 828 | 848 | { |
@@ -843,14 +863,20 @@ discard block |
||
| 843 | 863 | $member = getMemberByName($this->_req->post->name); |
| 844 | 864 | |
| 845 | 865 | if (empty($member)) |
| 846 | - throw new Elk_Exception('error_member_not_found'); |
|
| 866 | + { |
|
| 867 | + throw new Elk_Exception('error_member_not_found'); |
|
| 868 | + } |
|
| 847 | 869 | |
| 848 | 870 | if (alreadySubscribed($context['sub_id'], $member['id_member'])) |
| 849 | - throw new Elk_Exception('member_already_subscribed'); |
|
| 871 | + { |
|
| 872 | + throw new Elk_Exception('member_already_subscribed'); |
|
| 873 | + } |
|
| 850 | 874 | |
| 851 | 875 | // Actually put the subscription in place. |
| 852 | 876 | if ($status == 1) |
| 853 | - addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 877 | + { |
|
| 878 | + addSubscription($context['sub_id'], $member['id_member'], 0, $starttime, $endtime); |
|
| 879 | + } |
|
| 854 | 880 | else |
| 855 | 881 | { |
| 856 | 882 | $details = array( |
@@ -872,10 +898,14 @@ discard block |
||
| 872 | 898 | |
| 873 | 899 | // Pick the right permission stuff depending on what the status is changing from/to. |
| 874 | 900 | if ($subscription_status['old_status'] == 1 && $status != 1) |
| 875 | - removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 901 | + { |
|
| 902 | + removeSubscription($context['sub_id'], $subscription_status['id_member']); |
|
| 903 | + } |
|
| 876 | 904 | |
| 877 | 905 | elseif ($status == 1 && $subscription_status['old_status'] != 1) |
| 878 | - addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 906 | + { |
|
| 907 | + addSubscription($context['sub_id'], $subscription_status['id_member'], 0, $starttime, $endtime); |
|
| 908 | + } |
|
| 879 | 909 | |
| 880 | 910 | else |
| 881 | 911 | { |
@@ -902,12 +932,16 @@ discard block |
||
| 902 | 932 | { |
| 903 | 933 | $toDelete = array(); |
| 904 | 934 | foreach ($this->_req->post->delsub as $id => $dummy) |
| 905 | - $toDelete[] = (int) $id; |
|
| 935 | + { |
|
| 936 | + $toDelete[] = (int) $id; |
|
| 937 | + } |
|
| 906 | 938 | |
| 907 | 939 | $deletes = prepareDeleteSubscriptions($toDelete); |
| 908 | 940 | |
| 909 | 941 | foreach ($deletes as $id_subscribe => $id_member) |
| 910 | - removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 942 | + { |
|
| 943 | + removeSubscription($id_subscribe, $id_member, isset($this->_req->post->delete)); |
|
| 944 | + } |
|
| 911 | 945 | } |
| 912 | 946 | redirectexit('action=admin;area=paidsubscribe;sa=viewsub;sid=' . $context['sub_id']); |
| 913 | 947 | } |
@@ -946,15 +980,18 @@ discard block |
||
| 946 | 980 | $result = getBasicMemberData((int) $this->_req->query->uid); |
| 947 | 981 | $context['sub']['username'] = $result['real_name']; |
| 948 | 982 | } |
| 949 | - else |
|
| 950 | - $context['sub']['username'] = ''; |
|
| 983 | + else { |
|
| 984 | + $context['sub']['username'] = ''; |
|
| 985 | + } |
|
| 951 | 986 | } |
| 952 | 987 | // Otherwise load the existing info. |
| 953 | 988 | else |
| 954 | 989 | { |
| 955 | 990 | $row = getPendingSubscriptions($context['log_id']); |
| 956 | 991 | if (empty($row)) |
| 957 | - throw new Elk_Exception('no_access', false); |
|
| 992 | + { |
|
| 993 | + throw new Elk_Exception('no_access', false); |
|
| 994 | + } |
|
| 958 | 995 | |
| 959 | 996 | // Any pending payments? |
| 960 | 997 | $context['pending_payments'] = array(); |
@@ -974,9 +1011,11 @@ discard block |
||
| 974 | 1011 | foreach ($costs as $duration => $cost) |
| 975 | 1012 | { |
| 976 | 1013 | if ($cost != 0 && $cost == $pending[1] && $duration == $pending[2]) |
| 977 | - $context['pending_payments'][$id] = array( |
|
| 1014 | + { |
|
| 1015 | + $context['pending_payments'][$id] = array( |
|
| 978 | 1016 | 'desc' => sprintf($modSettings['paid_currency_symbol'], $cost . '/' . $txt[$duration]), |
| 979 | 1017 | ); |
| 1018 | + } |
|
| 980 | 1019 | } |
| 981 | 1020 | } |
| 982 | 1021 | elseif ($costs['fixed'] == $pending[1]) |
@@ -998,7 +1037,9 @@ discard block |
||
| 998 | 1037 | { |
| 999 | 1038 | // Flexible? |
| 1000 | 1039 | if (isset($this->_req->query->accept)) |
| 1001 | - addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1040 | + { |
|
| 1041 | + addSubscription($context['current_subscription']['id'], $row['id_member'], $context['current_subscription']['real_length'] === 'F' ? strtoupper(substr($pending[2], 0, 1)) : 0); |
|
| 1042 | + } |
|
| 1002 | 1043 | unset($pending_details[$id]); |
| 1003 | 1044 | |
| 1004 | 1045 | $new_details = serialize($pending_details); |
@@ -270,13 +270,13 @@ discard block |
||
| 270 | 270 | 'items_per_page' => 20, |
| 271 | 271 | 'base_href' => $scripturl . '?action=admin;area=paidsubscribe;sa=view', |
| 272 | 272 | 'get_items' => array( |
| 273 | - 'function' => function () { |
|
| 273 | + 'function' => function() { |
|
| 274 | 274 | global $context; |
| 275 | 275 | return $context['subscriptions']; |
| 276 | 276 | }, |
| 277 | 277 | ), |
| 278 | 278 | 'get_count' => array( |
| 279 | - 'function' => function () { |
|
| 279 | + 'function' => function() { |
|
| 280 | 280 | global $context; |
| 281 | 281 | return count($context['subscriptions']); |
| 282 | 282 | }, |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | 'style' => 'width: 30%;', |
| 290 | 290 | ), |
| 291 | 291 | 'data' => array( |
| 292 | - 'function' => function ($rowData) { |
|
| 292 | + 'function' => function($rowData) { |
|
| 293 | 293 | global $scripturl; |
| 294 | 294 | |
| 295 | 295 | return sprintf('<a href="%1$s?action=admin;area=paidsubscribe;sa=viewsub;sid=%2$s">%3$s</a>', $scripturl, $rowData['id'], $rowData['name']); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | 'value' => $txt['paid_cost'], |
| 302 | 302 | ), |
| 303 | 303 | 'data' => array( |
| 304 | - 'function' => function ($rowData) { |
|
| 304 | + 'function' => function($rowData) { |
|
| 305 | 305 | global $txt; |
| 306 | 306 | |
| 307 | 307 | return $rowData['flexible'] ? '<em>' . $txt['flexible'] . '</em>' : $rowData['cost'] . ' / ' . $rowData['length']; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | 'value' => $txt['paid_is_active'], |
| 339 | 339 | ), |
| 340 | 340 | 'data' => array( |
| 341 | - 'function' => function ($rowData) { |
|
| 341 | + 'function' => function($rowData) { |
|
| 342 | 342 | global $txt; |
| 343 | 343 | |
| 344 | 344 | return '<span class="' . ($rowData['active'] ? 'success' : 'alert') . '">' . ($rowData['active'] ? $txt['yes'] : $txt['no']) . '</span>'; |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | 'value' => $txt['subscribers'], |
| 351 | 351 | ), |
| 352 | 352 | 'data' => array( |
| 353 | - 'function' => function ($rowData) { |
|
| 353 | + 'function' => function($rowData) { |
|
| 354 | 354 | global $scripturl, $txt; |
| 355 | 355 | |
| 356 | 356 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=viewsub;sid=' . $rowData['id'] . '"><i class="icon i-view" title="' . $txt['view'] . '"></i></a>'; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | 'value' => $txt['modify'], |
| 364 | 364 | ), |
| 365 | 365 | 'data' => array( |
| 366 | - 'function' => function ($rowData) { |
|
| 366 | + 'function' => function($rowData) { |
|
| 367 | 367 | global $txt, $scripturl; |
| 368 | 368 | |
| 369 | 369 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modify;sid=' . $rowData['id'] . '"><i class="icon i-modify" title="' . $txt['modify'] . '"></i></a>'; |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | 'value' => $txt['remove'] |
| 377 | 377 | ), |
| 378 | 378 | 'data' => array( |
| 379 | - 'function' => function ($rowData) { |
|
| 379 | + 'function' => function($rowData) { |
|
| 380 | 380 | global $txt, $scripturl; |
| 381 | 381 | |
| 382 | 382 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modify;delete;sid=' . $rowData['id'] . '"><i class="icon i-delete" title="' . $txt['delete'] . '"></i></a>'; |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | 'style' => 'width: 20%;', |
| 637 | 637 | ), |
| 638 | 638 | 'data' => array( |
| 639 | - 'function' => function ($rowData) { |
|
| 639 | + 'function' => function($rowData) { |
|
| 640 | 640 | global $txt, $scripturl; |
| 641 | 641 | |
| 642 | 642 | return $rowData['id_member'] == 0 ? $txt['guest'] : '<a href="' . $scripturl . '?action=profile;u=' . $rowData['id_member'] . '">' . $rowData['name'] . '</a>'; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | 'value' => $txt['edit_subscriber'], |
| 709 | 709 | ), |
| 710 | 710 | 'data' => array( |
| 711 | - 'function' => function ($rowData) { |
|
| 711 | + 'function' => function($rowData) { |
|
| 712 | 712 | global $txt, $scripturl; |
| 713 | 713 | |
| 714 | 714 | return '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $rowData['id'] . '">' . $txt['modify'] . '</a>'; |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | 'class' => 'centertext', |
| 723 | 723 | ), |
| 724 | 724 | 'data' => array( |
| 725 | - 'function' => function ($rowData) { |
|
| 725 | + 'function' => function($rowData) { |
|
| 726 | 726 | return '<input type="checkbox" name="delsub[' . $rowData['id'] . ']" class="input_check" />'; |
| 727 | 727 | }, |
| 728 | 728 | 'class' => 'centertext', |
@@ -137,8 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | // @todo move this to a filter/sanitation class |
| 139 | 139 | foreach ($this->_req->post as $key => $value) |
| 140 | - if (!is_array($value)) |
|
| 140 | + { |
|
| 141 | + if (!is_array($value)) |
|
| 141 | 142 | $this->_req->post[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $value)); |
| 143 | + } |
|
| 142 | 144 | |
| 143 | 145 | // Generate a password |
| 144 | 146 | if (empty($this->_req->post->password) || !is_string($this->_req->post->password) || trim($this->_req->post->password) === '') |
@@ -472,7 +474,9 @@ discard block |
||
| 472 | 474 | |
| 473 | 475 | // Are there some contacts missing? |
| 474 | 476 | if (!empty($this->_req->post->coppaAge) && !empty($this->_req->post->coppaType) && empty($this->_req->post->coppaPost) && empty($this->_req->post->coppaFax)) |
| 475 | - throw new Elk_Exception('admin_setting_coppa_require_contact'); |
|
| 477 | + { |
|
| 478 | + throw new Elk_Exception('admin_setting_coppa_require_contact'); |
|
| 479 | + } |
|
| 476 | 480 | |
| 477 | 481 | // Post needs to take into account line breaks. |
| 478 | 482 | $this->_req->post->coppaPost = str_replace("\n", '<br />', empty($this->_req->post->coppaPost) ? '' : $this->_req->post->coppaPost); |
@@ -81,13 +81,15 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $is_first = 0; |
| 83 | 83 | foreach ($context['report_types'] as $k => $temp) |
| 84 | - $context['report_types'][$k] = array( |
|
| 84 | + { |
|
| 85 | + $context['report_types'][$k] = array( |
|
| 85 | 86 | 'id' => $k, |
| 86 | 87 | 'title' => isset($txt['gr_type_' . $k]) ? $txt['gr_type_' . $k] : $k, |
| 87 | 88 | 'description' => isset($txt['gr_type_desc_' . $k]) ? $txt['gr_type_desc_' . $k] : null, |
| 88 | 89 | 'function' => $temp, |
| 89 | 90 | 'is_first' => $is_first++ == 0, |
| 90 | 91 | ); |
| 92 | + } |
|
| 91 | 93 | |
| 92 | 94 | $report_type = !empty($this->_req->post->rt) ? $this->_req->post->rt : (!empty($this->_req->query->rt) ? $this->_req->query->rt : null); |
| 93 | 95 | |
@@ -123,7 +125,9 @@ discard block |
||
| 123 | 125 | $template_layers = Template_Layers::instance(); |
| 124 | 126 | $template_layers->removeAll(); |
| 125 | 127 | foreach ($reportTemplates[$set_template]['layers'] as $layer) |
| 126 | - $template_layers->add($layer); |
|
| 128 | + { |
|
| 129 | + $template_layers->add($layer); |
|
| 130 | + } |
|
| 127 | 131 | } |
| 128 | 132 | } |
| 129 | 133 | |
@@ -196,7 +200,9 @@ discard block |
||
| 196 | 200 | $all_groups = getBasicMembergroupData(array('all'), array(), null, false); |
| 197 | 201 | $groups = array(-1 => $txt['guest_title'], 0 => $txt['full_member']); |
| 198 | 202 | foreach ($all_groups as $row) |
| 199 | - $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>'; |
|
| 203 | + { |
|
| 204 | + $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>'; |
|
| 205 | + } |
|
| 200 | 206 | |
| 201 | 207 | // All the fields we'll show. |
| 202 | 208 | $boardSettings = array( |
@@ -213,7 +219,9 @@ discard block |
||
| 213 | 219 | ); |
| 214 | 220 | |
| 215 | 221 | if (!empty($modSettings['deny_boards_access'])) |
| 216 | - $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 222 | + { |
|
| 223 | + $boardSettings['disallowed_groups'] = $txt['board_disallowed_groups']; |
|
| 224 | + } |
|
| 217 | 225 | |
| 218 | 226 | // Do it in columns, it's just easier. |
| 219 | 227 | setKeys('cols'); |
@@ -250,9 +258,12 @@ discard block |
||
| 250 | 258 | foreach ($allowedGroups as $key => $group) |
| 251 | 259 | { |
| 252 | 260 | if (isset($groups[$group])) |
| 253 | - $allowedGroups[$key] = $groups[$group]; |
|
| 254 | - else |
|
| 255 | - unset($allowedGroups[$key]); |
|
| 261 | + { |
|
| 262 | + $allowedGroups[$key] = $groups[$group]; |
|
| 263 | + } |
|
| 264 | + else { |
|
| 265 | + unset($allowedGroups[$key]); |
|
| 266 | + } |
|
| 256 | 267 | } |
| 257 | 268 | |
| 258 | 269 | $boardData['groups'] = implode(', ', $allowedGroups); |
@@ -263,9 +274,12 @@ discard block |
||
| 263 | 274 | foreach ($disallowedGroups as $key => $group) |
| 264 | 275 | { |
| 265 | 276 | if (isset($groups[$group])) |
| 266 | - $disallowedGroups[$key] = $groups[$group]; |
|
| 267 | - else |
|
| 268 | - unset($disallowedGroups[$key]); |
|
| 277 | + { |
|
| 278 | + $disallowedGroups[$key] = $groups[$group]; |
|
| 279 | + } |
|
| 280 | + else { |
|
| 281 | + unset($disallowedGroups[$key]); |
|
| 282 | + } |
|
| 269 | 283 | } |
| 270 | 284 | |
| 271 | 285 | $boardData['disallowed_groups'] = implode(', ', $disallowedGroups); |
@@ -302,42 +316,55 @@ discard block |
||
| 302 | 316 | if (isset($this->_req->post->boards)) |
| 303 | 317 | { |
| 304 | 318 | if (!is_array($this->_req->post->boards)) |
| 305 | - $query_boards['boards'] = array_map('intval', explode(',', $this->_req->post->boards)); |
|
| 306 | - else |
|
| 307 | - $query_boards['boards'] = array_map('intval', $this->_req->post->boards); |
|
| 319 | + { |
|
| 320 | + $query_boards['boards'] = array_map('intval', explode(',', $this->_req->post->boards)); |
|
| 321 | + } |
|
| 322 | + else { |
|
| 323 | + $query_boards['boards'] = array_map('intval', $this->_req->post->boards); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + else { |
|
| 327 | + $query_boards = 'all'; |
|
| 308 | 328 | } |
| 309 | - else |
|
| 310 | - $query_boards = 'all'; |
|
| 311 | 329 | |
| 312 | 330 | // Fetch the board names and profiles. |
| 313 | 331 | // This returns id_board, name, id_profile keys |
| 314 | 332 | $boards = fetchBoardsInfo($query_boards, array('sort_by' => 'id_board', 'selects' => 'permissions')); |
| 315 | 333 | $profiles = array(); |
| 316 | 334 | foreach ($boards as $b) |
| 317 | - $profiles[] = $b['id_profile']; |
|
| 335 | + { |
|
| 336 | + $profiles[] = $b['id_profile']; |
|
| 337 | + } |
|
| 318 | 338 | |
| 319 | 339 | // Groups, next. |
| 320 | 340 | $query_groups = array(); |
| 321 | 341 | if (isset($this->_req->post->groups)) |
| 322 | 342 | { |
| 323 | 343 | if (!is_array($this->_req->post->groups)) |
| 324 | - $query_groups = array_map('intval', explode(',', $this->_req->post->groups)); |
|
| 325 | - else |
|
| 326 | - $query_groups = array_map('intval', $this->_req->post->groups); |
|
| 344 | + { |
|
| 345 | + $query_groups = array_map('intval', explode(',', $this->_req->post->groups)); |
|
| 346 | + } |
|
| 347 | + else { |
|
| 348 | + $query_groups = array_map('intval', $this->_req->post->groups); |
|
| 349 | + } |
|
| 327 | 350 | |
| 328 | 351 | $group_clause = 'id_group IN ({array_int:groups})'; |
| 329 | 352 | } |
| 330 | - else |
|
| 331 | - $group_clause = '1=1'; |
|
| 353 | + else { |
|
| 354 | + $group_clause = '1=1'; |
|
| 355 | + } |
|
| 332 | 356 | |
| 333 | 357 | // Get all the possible membergroups, except admin! |
| 334 | 358 | require_once(SUBSDIR . '/Reports.subs.php'); |
| 335 | 359 | $all_groups = allMembergroups($group_clause, $query_groups); |
| 336 | 360 | |
| 337 | 361 | if (empty($query_groups) || in_array(-1, $query_groups) || in_array(0, $query_groups)) |
| 338 | - $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']) + $all_groups; |
|
| 339 | - else |
|
| 340 | - $member_groups = array('col' => '') + $all_groups; |
|
| 362 | + { |
|
| 363 | + $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']) + $all_groups; |
|
| 364 | + } |
|
| 365 | + else { |
|
| 366 | + $member_groups = array('col' => '') + $all_groups; |
|
| 367 | + } |
|
| 341 | 368 | |
| 342 | 369 | // Make sure that every group is represented - plus in rows! |
| 343 | 370 | setKeys('rows', $member_groups); |
@@ -350,8 +377,10 @@ discard block |
||
| 350 | 377 | foreach ($boardPermissions as $row) |
| 351 | 378 | { |
| 352 | 379 | foreach ($boards as $id => $board) |
| 353 | - if ($board['id_profile'] == $row['id_profile']) |
|
| 380 | + { |
|
| 381 | + if ($board['id_profile'] == $row['id_profile']) |
|
| 354 | 382 | $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny']; |
| 383 | + } |
|
| 355 | 384 | |
| 356 | 385 | // Make sure we get every permission. |
| 357 | 386 | if (!isset($permissions[$row['permission']])) |
@@ -386,7 +415,9 @@ discard block |
||
| 386 | 415 | { |
| 387 | 416 | // Don't overwrite the key column! |
| 388 | 417 | if ($id_group === 'col') |
| 389 | - continue; |
|
| 418 | + { |
|
| 419 | + continue; |
|
| 420 | + } |
|
| 390 | 421 | |
| 391 | 422 | $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array(); |
| 392 | 423 | |
@@ -397,16 +428,22 @@ discard block |
||
| 397 | 428 | $curData[$id_group] = $group_permissions[$ID_PERM]; |
| 398 | 429 | } |
| 399 | 430 | // Otherwise means it's set to disallow.. |
| 400 | - else |
|
| 401 | - $curData[$id_group] = 'x'; |
|
| 431 | + else { |
|
| 432 | + $curData[$id_group] = 'x'; |
|
| 433 | + } |
|
| 402 | 434 | |
| 403 | 435 | // Now actually make the data for the group look right. |
| 404 | 436 | if (empty($curData[$id_group])) |
| 405 | - $curData[$id_group] = '<span class="alert">' . $txt['board_perms_deny'] . '</span>'; |
|
| 437 | + { |
|
| 438 | + $curData[$id_group] = '<span class="alert">' . $txt['board_perms_deny'] . '</span>'; |
|
| 439 | + } |
|
| 406 | 440 | elseif ($curData[$id_group] == 1) |
| 407 | - $curData[$id_group] = '<span class="success">' . $txt['board_perms_allow'] . '</span>'; |
|
| 408 | - else |
|
| 409 | - $curData[$id_group] = 'x'; |
|
| 441 | + { |
|
| 442 | + $curData[$id_group] = '<span class="success">' . $txt['board_perms_allow'] . '</span>'; |
|
| 443 | + } |
|
| 444 | + else { |
|
| 445 | + $curData[$id_group] = 'x'; |
|
| 446 | + } |
|
| 410 | 447 | } |
| 411 | 448 | |
| 412 | 449 | // Now add the data for this permission. |
@@ -435,14 +472,20 @@ discard block |
||
| 435 | 472 | foreach ($raw_boards as $row) |
| 436 | 473 | { |
| 437 | 474 | if (trim($row['member_groups']) == '') |
| 438 | - $groups = array(1); |
|
| 439 | - else |
|
| 440 | - $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 475 | + { |
|
| 476 | + $groups = array(1); |
|
| 477 | + } |
|
| 478 | + else { |
|
| 479 | + $groups = array_merge(array(1), explode(',', $row['member_groups'])); |
|
| 480 | + } |
|
| 441 | 481 | |
| 442 | 482 | if (trim($row['deny_member_groups']) == '') |
| 443 | - $denyGroups = array(); |
|
| 444 | - else |
|
| 445 | - $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 483 | + { |
|
| 484 | + $denyGroups = array(); |
|
| 485 | + } |
|
| 486 | + else { |
|
| 487 | + $denyGroups = explode(',', $row['deny_member_groups']); |
|
| 488 | + } |
|
| 446 | 489 | |
| 447 | 490 | $boards[$row['id_board']] = array( |
| 448 | 491 | 'id' => $row['id_board'], |
@@ -466,7 +509,9 @@ discard block |
||
| 466 | 509 | |
| 467 | 510 | // Add on the boards! |
| 468 | 511 | foreach ($boards as $board) |
| 469 | - $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 512 | + { |
|
| 513 | + $mgSettings['board_' . $board['id']] = $board['name']; |
|
| 514 | + } |
|
| 470 | 515 | |
| 471 | 516 | // Add all the membergroup settings, plus we'll be adding in columns! |
| 472 | 517 | setKeys('cols', $mgSettings); |
@@ -493,7 +538,9 @@ discard block |
||
| 493 | 538 | |
| 494 | 539 | // Board permissions. |
| 495 | 540 | foreach ($boards as $board) |
| 496 | - $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="error">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 541 | + { |
|
| 542 | + $group['board_' . $board['id']] = in_array($row['id_group'], $board['groups']) ? '<span class="success">' . $txt['board_perms_allow'] . '</span>' : (!empty($modSettings['deny_boards_access']) && in_array($row['id_group'], $board['deny_groups']) ? '<span class="error">' . $txt['board_perms_deny'] . '</span>' : 'x'); |
|
| 543 | + } |
|
| 497 | 544 | |
| 498 | 545 | addData($group); |
| 499 | 546 | } |
@@ -514,7 +561,9 @@ discard block |
||
| 514 | 561 | if (isset($this->_req->post->groups)) |
| 515 | 562 | { |
| 516 | 563 | if (!is_array($this->_req->post->groups)) |
| 517 | - $this->_req->post->groups = explode(',', $this->_req->post->groups); |
|
| 564 | + { |
|
| 565 | + $this->_req->post->groups = explode(',', $this->_req->post->groups); |
|
| 566 | + } |
|
| 518 | 567 | |
| 519 | 568 | $query_groups = array_diff(array_map('intval', $this->_req->post->groups), array(3)); |
| 520 | 569 | $group_clause = 'id_group IN ({array_int:groups})'; |
@@ -530,9 +579,12 @@ discard block |
||
| 530 | 579 | $all_groups = allMembergroups($group_clause, $query_groups); |
| 531 | 580 | |
| 532 | 581 | if (!isset($this->_req->post->groups) || in_array(-1, $this->_req->post->groups) || in_array(0, $this->_req->post->groups)) |
| 533 | - $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']) + $all_groups; |
|
| 534 | - else |
|
| 535 | - $groups = array('col' => '') + $all_groups; |
|
| 582 | + { |
|
| 583 | + $groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']) + $all_groups; |
|
| 584 | + } |
|
| 585 | + else { |
|
| 586 | + $groups = array('col' => '') + $all_groups; |
|
| 587 | + } |
|
| 536 | 588 | |
| 537 | 589 | // Make sure that every group is represented! |
| 538 | 590 | setKeys('rows', $groups); |
@@ -557,7 +609,9 @@ discard block |
||
| 557 | 609 | { |
| 558 | 610 | // Send the data! |
| 559 | 611 | if ($lastPermission !== null) |
| 560 | - addData($curData); |
|
| 612 | + { |
|
| 613 | + addData($curData); |
|
| 614 | + } |
|
| 561 | 615 | |
| 562 | 616 | // Add the permission name in the left column. |
| 563 | 617 | $curData = array('col' => isset($txt['group_perms_name_' . $row['permission']]) ? $txt['group_perms_name_' . $row['permission']] : $row['permission']); |
@@ -567,9 +621,12 @@ discard block |
||
| 567 | 621 | |
| 568 | 622 | // Good stuff - add the permission to the list! |
| 569 | 623 | if ($row['add_deny']) |
| 570 | - $curData[$row['id_group']] = '<span class="success">' . $txt['board_perms_allow'] . '</span>'; |
|
| 571 | - else |
|
| 572 | - $curData[$row['id_group']] = '<span class="alert">' . $txt['board_perms_deny'] . '</span>'; |
|
| 624 | + { |
|
| 625 | + $curData[$row['id_group']] = '<span class="success">' . $txt['board_perms_allow'] . '</span>'; |
|
| 626 | + } |
|
| 627 | + else { |
|
| 628 | + $curData[$row['id_group']] = '<span class="alert">' . $txt['board_perms_deny'] . '</span>'; |
|
| 629 | + } |
|
| 573 | 630 | } |
| 574 | 631 | |
| 575 | 632 | // Flush the last data! |
@@ -599,8 +656,10 @@ discard block |
||
| 599 | 656 | $boards_moderated = array(); |
| 600 | 657 | |
| 601 | 658 | foreach ($moderators as $id_member => $rows) |
| 602 | - foreach ($rows as $row) |
|
| 659 | + { |
|
| 660 | + foreach ($rows as $row) |
|
| 603 | 661 | $boards_moderated[$id_member][] = $row['id_board']; |
| 662 | + } |
|
| 604 | 663 | |
| 605 | 664 | // Get a list of global moderators (i.e. members with moderation powers). |
| 606 | 665 | $global_mods = array_intersect(membersAllowedTo('moderate_board', 0), membersAllowedTo('approve_posts', 0), membersAllowedTo('remove_any', 0), membersAllowedTo('modify_any', 0)); |
@@ -613,13 +672,17 @@ discard block |
||
| 613 | 672 | |
| 614 | 673 | // This is a bit of a cop out - but we're protecting their forum, really! |
| 615 | 674 | if (count($allStaff) > 300) |
| 616 | - throw new Elk_Exception('report_error_too_many_staff'); |
|
| 675 | + { |
|
| 676 | + throw new Elk_Exception('report_error_too_many_staff'); |
|
| 677 | + } |
|
| 617 | 678 | |
| 618 | 679 | // Get all the possible membergroups! |
| 619 | 680 | $all_groups = getBasicMembergroupData(array('all'), array(), null, false); |
| 620 | 681 | $groups = array(0 => $txt['full_member']); |
| 621 | 682 | foreach ($all_groups as $row) |
| 622 | - $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>'; |
|
| 683 | + { |
|
| 684 | + $groups[$row['id']] = empty($row['online_color']) ? $row['name'] : '<span style="color: ' . $row['online_color'] . '">' . $row['name'] . '</span>'; |
|
| 685 | + } |
|
| 623 | 686 | |
| 624 | 687 | // All the fields we'll show. |
| 625 | 688 | $staffSettings = array( |
@@ -652,18 +715,23 @@ discard block |
||
| 652 | 715 | |
| 653 | 716 | // What do they moderate? |
| 654 | 717 | if (in_array($row['id_member'], $global_mods)) |
| 655 | - $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 718 | + { |
|
| 719 | + $staffData['moderates'] = '<em>' . $txt['report_staff_all_boards'] . '</em>'; |
|
| 720 | + } |
|
| 656 | 721 | elseif (isset($boards_moderated[$row['id_member']])) |
| 657 | 722 | { |
| 658 | 723 | // Get the names |
| 659 | 724 | foreach ($boards_moderated[$row['id_member']] as $board) |
| 660 | - if (isset($boards[$board])) |
|
| 725 | + { |
|
| 726 | + if (isset($boards[$board])) |
|
| 661 | 727 | $staffData['moderates'][] = $boards[$board]['name']; |
| 728 | + } |
|
| 662 | 729 | |
| 663 | 730 | $staffData['moderates'] = implode(', ', $staffData['moderates']); |
| 664 | 731 | } |
| 665 | - else |
|
| 666 | - $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 732 | + else { |
|
| 733 | + $staffData['moderates'] = '<em>' . $txt['report_staff_no_boards'] . '</em>'; |
|
| 734 | + } |
|
| 667 | 735 | |
| 668 | 736 | // Next add the main data. |
| 669 | 737 | addData($staffData); |
@@ -695,7 +763,9 @@ discard block |
||
| 695 | 763 | |
| 696 | 764 | // Set the table count if needed. |
| 697 | 765 | if (empty($context['table_count'])) |
| 698 | - $context['table_count'] = 0; |
|
| 766 | + { |
|
| 767 | + $context['table_count'] = 0; |
|
| 768 | + } |
|
| 699 | 769 | |
| 700 | 770 | // Create the table! |
| 701 | 771 | $context['tables'][$context['table_count']] = array( |
@@ -746,15 +816,22 @@ discard block |
||
| 746 | 816 | |
| 747 | 817 | // No tables? Create one even though we are probably already in a bad state! |
| 748 | 818 | if (empty($context['table_count'])) |
| 749 | - newTable(); |
|
| 819 | + { |
|
| 820 | + newTable(); |
|
| 821 | + } |
|
| 750 | 822 | |
| 751 | 823 | // Specific table? |
| 752 | 824 | if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
| 753 | - return false; |
|
| 825 | + { |
|
| 826 | + return false; |
|
| 827 | + } |
|
| 754 | 828 | elseif ($custom_table !== null) |
| 755 | - $table = $custom_table; |
|
| 756 | - else |
|
| 757 | - $table = $context['current_table']; |
|
| 829 | + { |
|
| 830 | + $table = $custom_table; |
|
| 831 | + } |
|
| 832 | + else { |
|
| 833 | + $table = $context['current_table']; |
|
| 834 | + } |
|
| 758 | 835 | |
| 759 | 836 | // If we have keys, sanitise the data... |
| 760 | 837 | $data = array(); |
@@ -768,7 +845,9 @@ discard block |
||
| 768 | 845 | ); |
| 769 | 846 | // Special "hack" the adding separators when doing data by column. |
| 770 | 847 | if (substr($key, 0, 5) === '#sep#') |
| 771 | - $data[$key]['separator'] = true; |
|
| 848 | + { |
|
| 849 | + $data[$key]['separator'] = true; |
|
| 850 | + } |
|
| 772 | 851 | } |
| 773 | 852 | } |
| 774 | 853 | else |
@@ -781,7 +860,9 @@ discard block |
||
| 781 | 860 | ); |
| 782 | 861 | |
| 783 | 862 | if (substr($key, 0, 5) === '#sep#') |
| 784 | - $data[$key]['separator'] = true; |
|
| 863 | + { |
|
| 864 | + $data[$key]['separator'] = true; |
|
| 865 | + } |
|
| 785 | 866 | } |
| 786 | 867 | } |
| 787 | 868 | |
@@ -795,7 +876,9 @@ discard block |
||
| 795 | 876 | else |
| 796 | 877 | { |
| 797 | 878 | foreach ($data as $key => $item) |
| 798 | - $context['tables'][$table]['data'][$key][] = $item; |
|
| 879 | + { |
|
| 880 | + $context['tables'][$table]['data'][$key][] = $item; |
|
| 881 | + } |
|
| 799 | 882 | } |
| 800 | 883 | } |
| 801 | 884 | |
@@ -813,15 +896,22 @@ discard block |
||
| 813 | 896 | |
| 814 | 897 | // No tables - return? |
| 815 | 898 | if (empty($context['table_count'])) |
| 816 | - return false; |
|
| 899 | + { |
|
| 900 | + return false; |
|
| 901 | + } |
|
| 817 | 902 | |
| 818 | 903 | // Specific table? |
| 819 | 904 | if ($custom_table !== null && !isset($context['tables'][$custom_table])) |
| 820 | - return false; |
|
| 905 | + { |
|
| 906 | + return false; |
|
| 907 | + } |
|
| 821 | 908 | elseif ($custom_table !== null) |
| 822 | - $table = $custom_table; |
|
| 823 | - else |
|
| 824 | - $table = $context['current_table']; |
|
| 909 | + { |
|
| 910 | + $table = $custom_table; |
|
| 911 | + } |
|
| 912 | + else { |
|
| 913 | + $table = $context['current_table']; |
|
| 914 | + } |
|
| 825 | 915 | |
| 826 | 916 | // Plumb in the separator |
| 827 | 917 | $context['tables'][$table]['data'][] = array( |
@@ -846,7 +936,9 @@ discard block |
||
| 846 | 936 | global $context; |
| 847 | 937 | |
| 848 | 938 | if (empty($context['tables'])) |
| 849 | - return; |
|
| 939 | + { |
|
| 940 | + return; |
|
| 941 | + } |
|
| 850 | 942 | |
| 851 | 943 | // Loop through each table counting up some basic values, to help with the templating. |
| 852 | 944 | foreach ($context['tables'] as $id => $table) |
@@ -858,11 +950,16 @@ discard block |
||
| 858 | 950 | |
| 859 | 951 | // Work out the rough width - for templates like the print template. Without this we might get funny tables. |
| 860 | 952 | if ($table['shading']['left'] && $table['width']['shaded'] !== 'auto' && $table['width']['normal'] !== 'auto') |
| 861 | - $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 953 | + { |
|
| 954 | + $context['tables'][$id]['max_width'] = $table['width']['shaded'] + ($context['tables'][$id]['column_count'] - 1) * $table['width']['normal']; |
|
| 955 | + } |
|
| 862 | 956 | elseif ($table['width']['normal'] !== 'auto') |
| 863 | - $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 864 | - else |
|
| 865 | - $context['tables'][$id]['max_width'] = 'auto'; |
|
| 957 | + { |
|
| 958 | + $context['tables'][$id]['max_width'] = $context['tables'][$id]['column_count'] * $table['width']['normal']; |
|
| 959 | + } |
|
| 960 | + else { |
|
| 961 | + $context['tables'][$id]['max_width'] = 'auto'; |
|
| 962 | + } |
|
| 866 | 963 | } |
| 867 | 964 | } |
| 868 | 965 | |
@@ -890,9 +987,12 @@ discard block |
||
| 890 | 987 | |
| 891 | 988 | // Do we want to use the keys of the keys as the keys? :P |
| 892 | 989 | if ($reverse) |
| 893 | - $context['keys'] = array_flip($keys); |
|
| 894 | - else |
|
| 895 | - $context['keys'] = $keys; |
|
| 990 | + { |
|
| 991 | + $context['keys'] = array_flip($keys); |
|
| 992 | + } |
|
| 993 | + else { |
|
| 994 | + $context['keys'] = $keys; |
|
| 995 | + } |
|
| 896 | 996 | |
| 897 | 997 | // Rows or columns? |
| 898 | 998 | $context['key_method'] = $method === 'rows' ? 'rows' : 'cols'; |