@@ -35,7 +35,6 @@ |
||
| 35 | 35 | * |
| 36 | 36 | * Quick Start: |
| 37 | 37 | * @code |
| 38 | - |
|
| 39 | 38 | * @endcode |
| 40 | 39 | * |
| 41 | 40 | * Minimum requirements: PHP 5.3.x, cURL. |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | private function cookie($cookie_file) |
| 47 | 47 | { |
| 48 | 48 | if (file_exists($cookie_file)) { |
| 49 | - $this->cookie_file = $cookie_file; |
|
| 49 | + $this->cookie_file = $cookie_file; |
|
| 50 | 50 | } else { |
| 51 | 51 | fopen($cookie_file, 'w') or $this->error('The cookie file could not be opened. Make sure this directory has the correct permissions'); |
| 52 | 52 | $this->cookie_file = $cookie_file; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $data = array("status" => 'R'); |
| 122 | 122 | curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($data)); |
| 123 | 123 | $response = curl_exec($process); |
| 124 | - if ( false === $response ) { |
|
| 124 | + if (false === $response) { |
|
| 125 | 125 | $info = curl_getinfo($process); |
| 126 | 126 | curl_close($process); |
| 127 | 127 | die('error occured during curl exec. Additioanl info: ' . var_export($info)); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | curl_setopt($process, CURLOPT_CUSTOMREQUEST, "DELETE"); |
| 145 | 145 | curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($service_url)); |
| 146 | 146 | $curl_response = curl_exec($process); |
| 147 | - if ( false === $curl_response) { |
|
| 147 | + if (false === $curl_response) { |
|
| 148 | 148 | $info = curl_getinfo($process); |
| 149 | 149 | curl_close($process); |
| 150 | 150 | die('error occured during curl exec. Additioanl info: ' . var_export($info)); |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | $this->compression = $compression; |
| 40 | 40 | $this->proxy = $proxy; |
| 41 | 41 | $this->cookies = $cookies; |
| 42 | - if ($this->cookies == true) $this->cookie($cookie); |
|
| 42 | + if ($this->cookies == true) { |
|
| 43 | + $this->cookie($cookie); |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | } |
| 45 | 47 | |
@@ -60,11 +62,17 @@ discard block |
||
| 60 | 62 | curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers); |
| 61 | 63 | curl_setopt($process, CURLOPT_HEADER, 0); |
| 62 | 64 | curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent); |
| 63 | - if ($this->cookies == true) curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file); |
|
| 64 | - if ($this->cookies == true) curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file); |
|
| 65 | + if ($this->cookies == true) { |
|
| 66 | + curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file); |
|
| 67 | + } |
|
| 68 | + if ($this->cookies == true) { |
|
| 69 | + curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file); |
|
| 70 | + } |
|
| 65 | 71 | curl_setopt($process, CURLOPT_ENCODING, $this->compression); |
| 66 | 72 | curl_setopt($process, CURLOPT_TIMEOUT, 30); |
| 67 | - if ($this->proxy) curl_setopt($process, CURLOPT_PROXY, $this->proxy); |
|
| 73 | + if ($this->proxy) { |
|
| 74 | + curl_setopt($process, CURLOPT_PROXY, $this->proxy); |
|
| 75 | + } |
|
| 68 | 76 | curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); |
| 69 | 77 | curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); |
| 70 | 78 | $return = curl_exec($process); |
@@ -95,11 +103,17 @@ discard block |
||
| 95 | 103 | // curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers); |
| 96 | 104 | curl_setopt($process, CURLOPT_HEADER, 1); |
| 97 | 105 | curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent); |
| 98 | - if ($this->cookies == true) curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file); |
|
| 99 | - if ($this->cookies == true) curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file); |
|
| 106 | + if ($this->cookies == true) { |
|
| 107 | + curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file); |
|
| 108 | + } |
|
| 109 | + if ($this->cookies == true) { |
|
| 110 | + curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file); |
|
| 111 | + } |
|
| 100 | 112 | curl_setopt($process, CURLOPT_ENCODING, $this->compression); |
| 101 | 113 | curl_setopt($process, CURLOPT_TIMEOUT, 30); |
| 102 | - if ($this->proxy) curl_setopt($process, CURLOPT_PROXY, $this->proxy); |
|
| 114 | + if ($this->proxy) { |
|
| 115 | + curl_setopt($process, CURLOPT_PROXY, $this->proxy); |
|
| 116 | + } |
|
| 103 | 117 | curl_setopt($process, CURLOPT_POST, 1); |
| 104 | 118 | curl_setopt($process, CURLOPT_POSTFIELDS, $data); |
| 105 | 119 | curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | namespace Ballybran\Core\Http; |
| 20 | 20 | |
| 21 | - class RestUtilities |
|
| 21 | + class RestUtilities |
|
| 22 | 22 | { |
| 23 | 23 | private static $httpVersion = 'HTTP/1.1'; |
| 24 | 24 | |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | $ob = ini_get('output_buffering'); |
| 66 | 66 | |
| 67 | 67 | // Abort the method if headers have already been sent, except when output buffering has been enabled |
| 68 | - if (headers_sent() && false === (bool)$ob || 'off' == strtolower($ob) ) { |
|
| 68 | + if (headers_sent() && false === (bool)$ob || 'off' == strtolower($ob)) { |
|
| 69 | 69 | return new self(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | namespace Ballybran\Library; |
| 4 | 4 | |
| 5 | 5 | $CSS_FILES = array( |
| 6 | - $css, |
|
| 6 | + $css, |
|
| 7 | 7 | ); |
| 8 | 8 | |
| 9 | 9 | $css_cache = new CSSCache($CSS_FILES); |
@@ -14,49 +14,49 @@ discard block |
||
| 14 | 14 | // |
| 15 | 15 | |
| 16 | 16 | class CSSCache { |
| 17 | - private $filenames = array(); |
|
| 18 | - private $cwd; |
|
| 17 | + private $filenames = array(); |
|
| 18 | + private $cwd; |
|
| 19 | 19 | |
| 20 | - public function __construct(array $i_filename_arr) { |
|
| 20 | + public function __construct(array $i_filename_arr) { |
|
| 21 | 21 | if (!is_array($i_filename_arr)) |
| 22 | - $i_filename_arr = array($i_filename_arr); |
|
| 22 | + $i_filename_arr = array($i_filename_arr); |
|
| 23 | 23 | |
| 24 | 24 | $this->filenames = $i_filename_arr; |
| 25 | 25 | $this->cwd = getcwd() . DIRECTORY_SEPARATOR; |
| 26 | 26 | |
| 27 | 27 | if ($this->style_changed()) |
| 28 | - $expire = -72000; |
|
| 28 | + $expire = -72000; |
|
| 29 | 29 | else |
| 30 | - $expire = 3200; |
|
| 30 | + $expire = 3200; |
|
| 31 | 31 | |
| 32 | 32 | header('Content-Type: text/css; charset: UTF-8'); |
| 33 | 33 | header('Cache-Control: must-revalidate'); |
| 34 | 34 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT'); |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function dump_style() { |
|
| 37 | + public function dump_style() { |
|
| 38 | 38 | ob_start('ob_gzhandler'); |
| 39 | 39 | |
| 40 | 40 | foreach ($this->filenames as $filename) |
| 41 | - $this->dump_cache_contents($filename); |
|
| 41 | + $this->dump_cache_contents($filename); |
|
| 42 | 42 | |
| 43 | 43 | ob_end_flush(); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | private function get_cache_name($filename, $wildcard = FALSE) { |
| 47 | 47 | $stat = stat($filename); |
| 48 | 48 | return $this->cwd . '.' . $filename . '.' . |
| 49 | - ($wildcard ? '*' : ($stat['size'] . '-' . $stat['mtime'])) . '.cache'; |
|
| 50 | - } |
|
| 49 | + ($wildcard ? '*' : ($stat['size'] . '-' . $stat['mtime'])) . '.cache'; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - private function style_changed() { |
|
| 52 | + private function style_changed() { |
|
| 53 | 53 | foreach ($this->filenames as $filename) |
| 54 | - if (!is_file($this->get_cache_name($filename))) |
|
| 54 | + if (!is_file($this->get_cache_name($filename))) |
|
| 55 | 55 | return TRUE; |
| 56 | 56 | return FALSE; |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - private function compress($buffer) { |
|
| 59 | + private function compress($buffer) { |
|
| 60 | 60 | $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); |
| 61 | 61 | $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' '), '', $buffer); |
| 62 | 62 | $buffer = str_replace('{ ', '{', $buffer); |
@@ -69,27 +69,27 @@ discard block |
||
| 69 | 69 | $buffer = str_replace(',', ',', $buffer); |
| 70 | 70 | $buffer = str_replace(' ;', ';', $buffer); |
| 71 | 71 | return $buffer; |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - private function dump_cache_contents($filename) { |
|
| 74 | + private function dump_cache_contents($filename) { |
|
| 75 | 75 | $current_cache = $this->get_cache_name($filename); |
| 76 | 76 | |
| 77 | 77 | // the cache exists - just dump it |
| 78 | 78 | if (is_file($current_cache)) { |
| 79 | - include($current_cache); |
|
| 80 | - return; |
|
| 79 | + include($current_cache); |
|
| 80 | + return; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // remove any old, lingering caches for this file |
| 84 | 84 | if ($dead_files = glob($this->get_cache_name($filename, TRUE), GLOB_NOESCAPE)) |
| 85 | - foreach ($dead_files as $dead_file) |
|
| 85 | + foreach ($dead_files as $dead_file) |
|
| 86 | 86 | unlink($dead_file); |
| 87 | 87 | |
| 88 | 88 | $compressed = $this->compress(file_get_contents($filename)); |
| 89 | 89 | file_put_contents($current_cache, $compressed); |
| 90 | 90 | |
| 91 | 91 | echo $compressed; |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -18,16 +18,18 @@ discard block |
||
| 18 | 18 | private $cwd; |
| 19 | 19 | |
| 20 | 20 | public function __construct(array $i_filename_arr) { |
| 21 | - if (!is_array($i_filename_arr)) |
|
| 22 | - $i_filename_arr = array($i_filename_arr); |
|
| 21 | + if (!is_array($i_filename_arr)) { |
|
| 22 | + $i_filename_arr = array($i_filename_arr); |
|
| 23 | + } |
|
| 23 | 24 | |
| 24 | 25 | $this->filenames = $i_filename_arr; |
| 25 | 26 | $this->cwd = getcwd() . DIRECTORY_SEPARATOR; |
| 26 | 27 | |
| 27 | - if ($this->style_changed()) |
|
| 28 | - $expire = -72000; |
|
| 29 | - else |
|
| 30 | - $expire = 3200; |
|
| 28 | + if ($this->style_changed()) { |
|
| 29 | + $expire = -72000; |
|
| 30 | + } else { |
|
| 31 | + $expire = 3200; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | header('Content-Type: text/css; charset: UTF-8'); |
| 33 | 35 | header('Cache-Control: must-revalidate'); |
@@ -37,8 +39,9 @@ discard block |
||
| 37 | 39 | public function dump_style() { |
| 38 | 40 | ob_start('ob_gzhandler'); |
| 39 | 41 | |
| 40 | - foreach ($this->filenames as $filename) |
|
| 41 | - $this->dump_cache_contents($filename); |
|
| 42 | + foreach ($this->filenames as $filename) { |
|
| 43 | + $this->dump_cache_contents($filename); |
|
| 44 | + } |
|
| 42 | 45 | |
| 43 | 46 | ob_end_flush(); |
| 44 | 47 | } |
@@ -50,9 +53,10 @@ discard block |
||
| 50 | 53 | } |
| 51 | 54 | |
| 52 | 55 | private function style_changed() { |
| 53 | - foreach ($this->filenames as $filename) |
|
| 54 | - if (!is_file($this->get_cache_name($filename))) |
|
| 56 | + foreach ($this->filenames as $filename) { |
|
| 57 | + if (!is_file($this->get_cache_name($filename))) |
|
| 55 | 58 | return TRUE; |
| 59 | + } |
|
| 56 | 60 | return FALSE; |
| 57 | 61 | } |
| 58 | 62 | |
@@ -81,9 +85,10 @@ discard block |
||
| 81 | 85 | } |
| 82 | 86 | |
| 83 | 87 | // remove any old, lingering caches for this file |
| 84 | - if ($dead_files = glob($this->get_cache_name($filename, TRUE), GLOB_NOESCAPE)) |
|
| 85 | - foreach ($dead_files as $dead_file) |
|
| 88 | + if ($dead_files = glob($this->get_cache_name($filename, TRUE), GLOB_NOESCAPE)) { |
|
| 89 | + foreach ($dead_files as $dead_file) |
|
| 86 | 90 | unlink($dead_file); |
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | $compressed = $this->compress(file_get_contents($filename)); |
| 89 | 94 | file_put_contents($current_cache, $compressed); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | public function setupXAxis($percent = '', $color = '') |
| 9 | 9 | { |
| 10 | 10 | $this->bool_x_axis_setup = true; |
| 11 | - if ( false === $percent ) { |
|
| 11 | + if (false === $percent) { |
|
| 12 | 12 | $this->bool_x_axis = false; |
| 13 | 13 | } else { |
| 14 | 14 | $this->bool_x_axis = true; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | public function setupYAxis($percent = '', $color = '') |
| 29 | 29 | { |
| 30 | 30 | $this->bool_y_axis_setup = true; |
| 31 | - if ( false === $percent ) { |
|
| 31 | + if (false === $percent) { |
|
| 32 | 32 | $this->bool_y_axis = false; |
| 33 | 33 | } else { |
| 34 | 34 | $this->bool_y_axis = true; |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | protected function returnColorArray($color) |
| 61 | 61 | { |
| 62 | 62 | //check to see if color passed through in form '128,128,128' or hex format |
| 63 | - if ( false !== strpos($color, ',') ) { |
|
| 63 | + if (false !== strpos($color, ',')) { |
|
| 64 | 64 | return explode(',', $color); |
| 65 | - } elseif ( '#' == substr($color, 0, 1) ) { |
|
| 65 | + } elseif ('#' == substr($color, 0, 1)) { |
|
| 66 | 66 | if (strlen($color) == 7) { |
| 67 | 67 | $hex1 = hexdec(substr($color, 1, 2)); |
| 68 | 68 | $hex2 = hexdec(substr($color, 3, 2)); |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | // Read file lines |
| 26 | 26 | $lines = file($file); |
| 27 | 27 | $data = array(); |
| 28 | - foreach ($lines as $line) |
|
| 29 | - $data[] = explode(';', trim($line));
|
|
| 28 | + foreach ($lines as $line) { |
|
| 29 | + $data[] = explode(';', trim($line)); |
|
| 30 | + } |
|
| 30 | 31 | return $data; |
| 31 | 32 | } |
| 32 | 33 | |
@@ -34,13 +35,15 @@ discard block |
||
| 34 | 35 | function BasicTable($header, $data) |
| 35 | 36 | {
|
| 36 | 37 | // Header |
| 37 | - foreach ($header as $col) |
|
| 38 | - $this->Cell(40, 7, $col, 1); |
|
| 38 | + foreach ($header as $col) { |
|
| 39 | + $this->Cell(40, 7, $col, 1); |
|
| 40 | + } |
|
| 39 | 41 | $this->Ln(); |
| 40 | 42 | // Data |
| 41 | 43 | foreach ($data as $row) {
|
| 42 | - foreach ($row as $col) |
|
| 43 | - $this->Cell(40, 6, $col, 1); |
|
| 44 | + foreach ($row as $col) { |
|
| 45 | + $this->Cell(40, 6, $col, 1); |
|
| 46 | + } |
|
| 44 | 47 | $this->Ln(); |
| 45 | 48 | } |
| 46 | 49 | } |
@@ -51,8 +54,9 @@ discard block |
||
| 51 | 54 | // Column widths |
| 52 | 55 | $w = array(40, 35, 40, 45); |
| 53 | 56 | // Header |
| 54 | - for ($i = 0; $i < count($header); $i++) |
|
| 55 | - $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); |
|
| 57 | + for ($i = 0; $i < count($header); $i++) { |
|
| 58 | + $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); |
|
| 59 | + } |
|
| 56 | 60 | $this->Ln(); |
| 57 | 61 | // Data |
| 58 | 62 | foreach ($data as $row) {
|
@@ -77,8 +81,9 @@ discard block |
||
| 77 | 81 | $this->SetFont('', 'B');
|
| 78 | 82 | // Header |
| 79 | 83 | $w = array(40, 35, 40, 45); |
| 80 | - for ($i = 0; $i < count($header); $i++) |
|
| 81 | - $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); |
|
| 84 | + for ($i = 0; $i < count($header); $i++) { |
|
| 85 | + $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); |
|
| 86 | + } |
|
| 82 | 87 | $this->Ln(); |
| 83 | 88 | // Color and font restoration |
| 84 | 89 | $this->SetFillColor(224, 235, 255); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | {
|
| 21 | 21 | |
| 22 | 22 | protected $col = 0; // Current column |
| 23 | - protected $y0; // Ordinate of column start |
|
| 23 | + protected $y0; // Ordinate of column start |
|
| 24 | 24 | |
| 25 | 25 | function Header() |
| 26 | 26 | {
|
@@ -52,7 +52,8 @@ |
||
| 52 | 52 | $pdf->AliasNbPages(); |
| 53 | 53 | $pdf->AddPage(); |
| 54 | 54 | $pdf->SetFont('Times', '', 12);
|
| 55 | -for ($i = 1; $i <= 40; $i++) |
|
| 56 | - $pdf->Cell(0, 10, 'Printing line number ' . $i, 0, 1); |
|
| 55 | +for ($i = 1; $i <= 40; $i++) { |
|
| 56 | + $pdf->Cell(0, 10, 'Printing line number ' . $i, 0, 1); |
|
| 57 | +} |
|
| 57 | 58 | $pdf->Output(); |
| 58 | 59 | ?> |
@@ -32,8 +32,9 @@ discard block |
||
| 32 | 32 | // Read file lines |
| 33 | 33 | $lines = file($file); |
| 34 | 34 | $data = array(); |
| 35 | - foreach ($lines as $line) |
|
| 36 | - $data[] = explode(';', trim($line)); |
|
| 35 | + foreach ($lines as $line) { |
|
| 36 | + $data[] = explode(';', trim($line)); |
|
| 37 | + } |
|
| 37 | 38 | return $data; |
| 38 | 39 | } |
| 39 | 40 | |
@@ -41,13 +42,15 @@ discard block |
||
| 41 | 42 | function BasicTable($header, $data) |
| 42 | 43 | { |
| 43 | 44 | // Header |
| 44 | - foreach ($data as $col) |
|
| 45 | - $this->Cell(72, 7, $col, 1); |
|
| 45 | + foreach ($data as $col) { |
|
| 46 | + $this->Cell(72, 7, $col, 1); |
|
| 47 | + } |
|
| 46 | 48 | $this->Ln(); |
| 47 | 49 | // Data |
| 48 | 50 | foreach ($header as $row) { |
| 49 | - foreach ($row as $col) |
|
| 50 | - $this->Cell(72, 6, $col, 1); |
|
| 51 | + foreach ($row as $col) { |
|
| 52 | + $this->Cell(72, 6, $col, 1); |
|
| 53 | + } |
|
| 51 | 54 | $this->Ln(); |
| 52 | 55 | } |
| 53 | 56 | } |