@@ -119,7 +119,7 @@ |
||
| 119 | 119 | * |
| 120 | 120 | * @return $this |
| 121 | 121 | */ |
| 122 | - public function switch(string $dbname) |
|
| 122 | + public function switch (string $dbname) |
|
| 123 | 123 | { |
| 124 | 124 | $this->query('USE ' . $dbname)->exec(); |
| 125 | 125 | |
@@ -297,14 +297,16 @@ |
||
| 297 | 297 | $str = ''; |
| 298 | 298 | foreach ($trace as $caller) { |
| 299 | 299 | $str .= " -- Called by {$caller['function']}"; |
| 300 | - if (isset($caller['class'])) |
|
| 301 | - $str .= " From Class {$caller['class']}"; |
|
| 300 | + if (isset($caller['class'])) { |
|
| 301 | + $str .= " From Class {$caller['class']}"; |
|
| 302 | + } |
|
| 302 | 303 | } |
| 303 | 304 | } else { |
| 304 | 305 | $caller = $trace[2]; |
| 305 | 306 | $str = "Called by {$caller['function']}"; |
| 306 | - if (isset($caller['class'])) |
|
| 307 | - $str .= " From Class {$caller['class']}"; |
|
| 307 | + if (isset($caller['class'])) { |
|
| 308 | + $str .= " From Class {$caller['class']}"; |
|
| 309 | + } |
|
| 308 | 310 | } |
| 309 | 311 | return $str; |
| 310 | 312 | } |
@@ -64,7 +64,9 @@ |
||
| 64 | 64 | //return call_user_func($callback, true); |
| 65 | 65 | } |
| 66 | 66 | if (!isset($_POST['g-recaptcha-response'])) { |
| 67 | - if (ob_get_level()) ob_end_clean(); |
|
| 67 | + if (ob_get_level()) { |
|
| 68 | + ob_end_clean(); |
|
| 69 | + } |
|
| 68 | 70 | \JSON\json::json(['error' => true, 'message' => 'Recaptcha token required']); |
| 69 | 71 | exit; |
| 70 | 72 | } |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | * |
| 97 | 97 | * @return string domain or default |
| 98 | 98 | */ |
| 99 | - $savedname = function () { |
|
| 99 | + $savedname = function() { |
|
| 100 | 100 | global $url; |
| 101 | 101 | $savedname = \MVC\helper::url2host($url); |
| 102 | 102 | if (!$savedname) { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); |
| 271 | 271 | $headerSent = curl_getinfo($ch, CURLINFO_HEADER_OUT); |
| 272 | 272 | $headerSent = explode("\n", $headerSent); |
| 273 | - $headerSent = array_map(function ($v) { |
|
| 273 | + $headerSent = array_map(function($v) { |
|
| 274 | 274 | return preg_replace("/\r$/m", '', $v); |
| 275 | 275 | }, $headerSent); |
| 276 | 276 | $result['request']['raw'] = $headerSent; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $header = explode("\n", $header); |
| 284 | - $header = array_map(function ($v) { |
|
| 284 | + $header = array_map(function($v) { |
|
| 285 | 285 | return preg_replace("/\r$/m", '', $v); |
| 286 | 286 | }, $header); |
| 287 | 287 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function sort_iterable(array $arrayObj) |
| 19 | 19 | { |
| 20 | - $arrayObj = array_map(function ($object) { |
|
| 20 | + $arrayObj = array_map(function($object) { |
|
| 21 | 21 | if (\ArrayHelper\helper::is_iterable($object)) { |
| 22 | 22 | $object = sort_iterable($object); |
| 23 | 23 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @var string|null $get |
| 41 | 41 | */ |
| 42 | - $get = function (string $location) { |
|
| 42 | + $get = function(string $location) { |
|
| 43 | 43 | if (file_exists($location)) { |
| 44 | 44 | return \MVC\helper::get_url_path($location, true); |
| 45 | 45 | } |
@@ -37,83 +37,83 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | class JSLikeHTMLElement extends DOMElement |
| 39 | 39 | { |
| 40 | - /** |
|
| 41 | - * Used for setting innerHTML like it's done in JavaScript:. |
|
| 42 | - * |
|
| 43 | - * @code |
|
| 44 | - * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>'; |
|
| 45 | - * @endcode |
|
| 46 | - */ |
|
| 47 | - public function __set($name, $value) |
|
| 48 | - { |
|
| 49 | - if ('innerHTML' == $name) { |
|
| 50 | - // first, empty the element |
|
| 51 | - for ($x = $this->childNodes->length - 1; $x >= 0; --$x) { |
|
| 52 | - $this->removeChild($this->childNodes->item($x)); |
|
| 53 | - } |
|
| 54 | - // $value holds our new inner HTML |
|
| 55 | - if ('' != $value) { |
|
| 56 | - $f = $this->ownerDocument->createDocumentFragment(); |
|
| 57 | - // appendXML() expects well-formed markup (XHTML) |
|
| 58 | - $result = @$f->appendXML($value); // @ to suppress PHP warnings |
|
| 59 | - if ($result) { |
|
| 60 | - if ($f->hasChildNodes()) { |
|
| 61 | - $this->appendChild($f); |
|
| 62 | - } |
|
| 63 | - } else { |
|
| 64 | - // $value is probably ill-formed |
|
| 65 | - $f = new DOMDocument(); |
|
| 66 | - $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); |
|
| 67 | - // Using <htmlfragment> will generate a warning, but so will bad HTML |
|
| 68 | - // (and by this point, bad HTML is what we've got). |
|
| 69 | - // We use it (and suppress the warning) because an HTML fragment will |
|
| 70 | - // be wrapped around <html><body> tags which we don't really want to keep. |
|
| 71 | - // Note: despite the warning, if loadHTML succeeds it will return true. |
|
| 72 | - $result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>'); |
|
| 73 | - if ($result) { |
|
| 74 | - $import = $f->getElementsByTagName('htmlfragment')->item(0); |
|
| 75 | - foreach ($import->childNodes as $child) { |
|
| 76 | - $importedNode = $this->ownerDocument->importNode($child, true); |
|
| 77 | - $this->appendChild($importedNode); |
|
| 78 | - } |
|
| 79 | - } else { |
|
| 80 | - // oh well, we tried, we really did. :( |
|
| 81 | - // this element is now empty |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - } else { |
|
| 86 | - $trace = debug_backtrace(); |
|
| 87 | - trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
| 88 | - } |
|
| 89 | - } |
|
| 40 | + /** |
|
| 41 | + * Used for setting innerHTML like it's done in JavaScript:. |
|
| 42 | + * |
|
| 43 | + * @code |
|
| 44 | + * $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>'; |
|
| 45 | + * @endcode |
|
| 46 | + */ |
|
| 47 | + public function __set($name, $value) |
|
| 48 | + { |
|
| 49 | + if ('innerHTML' == $name) { |
|
| 50 | + // first, empty the element |
|
| 51 | + for ($x = $this->childNodes->length - 1; $x >= 0; --$x) { |
|
| 52 | + $this->removeChild($this->childNodes->item($x)); |
|
| 53 | + } |
|
| 54 | + // $value holds our new inner HTML |
|
| 55 | + if ('' != $value) { |
|
| 56 | + $f = $this->ownerDocument->createDocumentFragment(); |
|
| 57 | + // appendXML() expects well-formed markup (XHTML) |
|
| 58 | + $result = @$f->appendXML($value); // @ to suppress PHP warnings |
|
| 59 | + if ($result) { |
|
| 60 | + if ($f->hasChildNodes()) { |
|
| 61 | + $this->appendChild($f); |
|
| 62 | + } |
|
| 63 | + } else { |
|
| 64 | + // $value is probably ill-formed |
|
| 65 | + $f = new DOMDocument(); |
|
| 66 | + $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); |
|
| 67 | + // Using <htmlfragment> will generate a warning, but so will bad HTML |
|
| 68 | + // (and by this point, bad HTML is what we've got). |
|
| 69 | + // We use it (and suppress the warning) because an HTML fragment will |
|
| 70 | + // be wrapped around <html><body> tags which we don't really want to keep. |
|
| 71 | + // Note: despite the warning, if loadHTML succeeds it will return true. |
|
| 72 | + $result = @$f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>'); |
|
| 73 | + if ($result) { |
|
| 74 | + $import = $f->getElementsByTagName('htmlfragment')->item(0); |
|
| 75 | + foreach ($import->childNodes as $child) { |
|
| 76 | + $importedNode = $this->ownerDocument->importNode($child, true); |
|
| 77 | + $this->appendChild($importedNode); |
|
| 78 | + } |
|
| 79 | + } else { |
|
| 80 | + // oh well, we tried, we really did. :( |
|
| 81 | + // this element is now empty |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + } else { |
|
| 86 | + $trace = debug_backtrace(); |
|
| 87 | + trigger_error('Undefined property via __set(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Used for getting innerHTML like it's done in JavaScript:. |
|
| 93 | - * |
|
| 94 | - * @code |
|
| 95 | - * $string = $div->innerHTML; |
|
| 96 | - * @endcode |
|
| 97 | - */ |
|
| 98 | - public function __get($name) |
|
| 99 | - { |
|
| 100 | - if ('innerHTML' == $name) { |
|
| 101 | - $inner = ''; |
|
| 102 | - foreach ($this->childNodes as $child) { |
|
| 103 | - $inner .= $this->ownerDocument->saveXML($child); |
|
| 104 | - } |
|
| 91 | + /** |
|
| 92 | + * Used for getting innerHTML like it's done in JavaScript:. |
|
| 93 | + * |
|
| 94 | + * @code |
|
| 95 | + * $string = $div->innerHTML; |
|
| 96 | + * @endcode |
|
| 97 | + */ |
|
| 98 | + public function __get($name) |
|
| 99 | + { |
|
| 100 | + if ('innerHTML' == $name) { |
|
| 101 | + $inner = ''; |
|
| 102 | + foreach ($this->childNodes as $child) { |
|
| 103 | + $inner .= $this->ownerDocument->saveXML($child); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - return $inner; |
|
| 107 | - } |
|
| 106 | + return $inner; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - $trace = debug_backtrace(); |
|
| 110 | - trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
| 109 | + $trace = debug_backtrace(); |
|
| 110 | + trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); |
|
| 111 | 111 | |
| 112 | - return null; |
|
| 113 | - } |
|
| 112 | + return null; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - public function __toString() |
|
| 116 | - { |
|
| 117 | - return '[' . $this->tagName . ']'; |
|
| 118 | - } |
|
| 115 | + public function __toString() |
|
| 116 | + { |
|
| 117 | + return '[' . $this->tagName . ']'; |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -79,13 +79,13 @@ |
||
| 79 | 79 | |
| 80 | 80 | // Extract the data |
| 81 | 81 | $cookie['domain'] = $tokens[0]; // The domain that created AND can read the variable. |
| 82 | - $cookie['flag'] = $tokens[1]; // A TRUE/FALSE value indicating if all machines within a given domain can access the variable. |
|
| 83 | - $cookie['path'] = $tokens[2]; // The path within the domain that the variable is valid for. |
|
| 82 | + $cookie['flag'] = $tokens[1]; // A TRUE/FALSE value indicating if all machines within a given domain can access the variable. |
|
| 83 | + $cookie['path'] = $tokens[2]; // The path within the domain that the variable is valid for. |
|
| 84 | 84 | $cookie['secure'] = $tokens[3]; // A TRUE/FALSE value indicating if a secure connection with the domain is needed to access the variable. |
| 85 | 85 | |
| 86 | - $cookie['expiration-epoch'] = $tokens[4]; // The UNIX time that the variable will expire on. |
|
| 87 | - $cookie['name'] = urldecode($tokens[5]); // The name of the variable. |
|
| 88 | - $cookie['value'] = urldecode($tokens[6]); // The value of the variable. |
|
| 86 | + $cookie['expiration-epoch'] = $tokens[4]; // The UNIX time that the variable will expire on. |
|
| 87 | + $cookie['name'] = urldecode($tokens[5]); // The name of the variable. |
|
| 88 | + $cookie['value'] = urldecode($tokens[6]); // The value of the variable. |
|
| 89 | 89 | |
| 90 | 90 | // Convert date to a readable format |
| 91 | 91 | $cookie['expiration'] = date('Y-m-d h:i:s', $tokens[4]); |
@@ -338,7 +338,7 @@ |
||
| 338 | 338 | public function render($variables = [], $print = true) |
| 339 | 339 | { |
| 340 | 340 | //exit('xxx'); |
| 341 | - \MVC\helper::trycatch(function () use ($variables, $print) { |
|
| 341 | + \MVC\helper::trycatch(function() use ($variables, $print) { |
|
| 342 | 342 | $this->load_render($variables, $print); |
| 343 | 343 | }); |
| 344 | 344 | |