@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $this->_tpl = $tpl; |
| 57 | 57 | } elseif (Tools::isInstanceOf($tpl, new Route)) { |
| 58 | 58 | $this->_route = $tpl; |
| 59 | - $this->_tpl = $this->_route->controller . "/" . $this->_route->controller . "_" . $this->_route->action; |
|
| 59 | + $this->_tpl = $this->_route->controller."/".$this->_route->controller."_".$this->_route->action; |
|
| 60 | 60 | } else { |
| 61 | 61 | throw new \Exception("Invalid view template"); |
| 62 | 62 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | throw new \Exception("View object was not initialized with template"); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - require_once($path . $this->_tpl . $suffix); |
|
| 73 | + require_once($path.$this->_tpl.$suffix); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | public function setTpl($_tpl) { |
@@ -50,6 +50,9 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | private $_errors = []; |
| 52 | 52 | |
| 53 | + /** |
|
| 54 | + * @param null|Route $tpl |
|
| 55 | + */ |
|
| 53 | 56 | public function __construct($tpl) { |
| 54 | 57 | if (!empty($tpl)) { |
| 55 | 58 | if (is_string($tpl)) { |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | $time = time(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $query = "INSERT INTO " . self::TABLE_NAME . " (type, message, count, last_seen) VALUES (?, ?, 1, ?) |
|
| 41 | + $query = "INSERT INTO ".self::TABLE_NAME." (type, message, count, last_seen) VALUES (?, ?, 1, ?) |
|
| 42 | 42 | ON DUPLICATE KEY UPDATE count = count + 1, last_seen = ?"; |
| 43 | 43 | try { |
| 44 | 44 | return DBCore::doUpdateQuery($query, "ssss", [ |
@@ -27,16 +27,16 @@ discard block |
||
| 27 | 27 | public static function http_redirect($url, $params = [], $session = false) { |
| 28 | 28 | $paramsString = ""; |
| 29 | 29 | foreach ($params as $key => $value) { |
| 30 | - $paramsString.= "&" . $key . "=" . $value; |
|
| 30 | + $paramsString .= "&".$key."=".$value; |
|
| 31 | 31 | } |
| 32 | 32 | if ($session) { |
| 33 | - $paramsString.= "&" . session_name() . "=" . session_id(); |
|
| 33 | + $paramsString .= "&".session_name()."=".session_id(); |
|
| 34 | 34 | } |
| 35 | 35 | $paramsString = substr($paramsString, 1); |
| 36 | 36 | if ($paramsString) { |
| 37 | - $paramsString = "?" . $paramsString; |
|
| 37 | + $paramsString = "?".$paramsString; |
|
| 38 | 38 | } |
| 39 | - header("Location: " . $url . $paramsString); |
|
| 39 | + header("Location: ".$url.$paramsString); |
|
| 40 | 40 | exit(); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | if (function_exists("http_redirect")) { |
| 71 | - http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url); |
|
| 71 | + http_redirect("http://".$_SERVER['SERVER_NAME']."/".$url); |
|
| 72 | 72 | } else { |
| 73 | - self::http_redirect("http://" . $_SERVER['SERVER_NAME'] . "/" . $url); |
|
| 73 | + self::http_redirect("http://".$_SERVER['SERVER_NAME']."/".$url); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | $urlParts['path'] = '/'; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $sock = fsockopen($urlParts['host'], (isset($urlParts['port']) ? (int) $urlParts['port'] : 80), $errno, $errstr, 30); |
|
| 134 | + $sock = fsockopen($urlParts['host'], (isset($urlParts['port']) ? (int)$urlParts['port'] : 80), $errno, $errstr, 30); |
|
| 135 | 135 | if (!$sock) { |
| 136 | 136 | throw new HttpException("$errstr ($errno)"); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $request = "HEAD " . $urlParts['path'] . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '') . " HTTP/1.1\r\n"; |
|
| 140 | - $request.= 'Host: ' . $urlParts['host'] . "\r\n"; |
|
| 141 | - $request.= "Connection: Close\r\n\r\n"; |
|
| 139 | + $request = "HEAD ".$urlParts['path'].(isset($urlParts['query']) ? '?'.$urlParts['query'] : '')." HTTP/1.1\r\n"; |
|
| 140 | + $request .= 'Host: '.$urlParts['host']."\r\n"; |
|
| 141 | + $request .= "Connection: Close\r\n\r\n"; |
|
| 142 | 142 | fwrite($sock, $request); |
| 143 | 143 | $response = ''; |
| 144 | 144 | while (!feof($sock)) { |
| 145 | - $response.= fread($sock, 8192); |
|
| 145 | + $response .= fread($sock, 8192); |
|
| 146 | 146 | } |
| 147 | 147 | fclose($sock); |
| 148 | 148 | |
| 149 | 149 | if (preg_match('/^Location: (.+?)$/m', $response, $matches)) { |
| 150 | 150 | if (substr($matches[1], 0, 1) == "/") { |
| 151 | - return $urlParts['scheme'] . "://" . $urlParts['host'] . trim($matches[1]); |
|
| 151 | + return $urlParts['scheme']."://".$urlParts['host'].trim($matches[1]); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | return trim($matches[1]); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | if (is_array($val)) { |
| 209 | 209 | $val = implode(',', $val); |
| 210 | 210 | } |
| 211 | - $postParams[] = $key . '=' . urlencode($val); |
|
| 211 | + $postParams[] = $key.'='.urlencode($val); |
|
| 212 | 212 | } |
| 213 | 213 | $postString = implode('&', $postParams); |
| 214 | 214 | |
@@ -220,29 +220,29 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | // Data goes in the path for a GET request |
| 222 | 222 | if ($type == self::GET) { |
| 223 | - $parts['path'].= '?' . $postString; |
|
| 223 | + $parts['path'] .= '?'.$postString; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - $request = "$type " . $parts['path'] . " HTTP/1.1\r\n"; |
|
| 227 | - $request.= "Host: " . $parts['host'] . "\r\n"; |
|
| 226 | + $request = "$type ".$parts['path']." HTTP/1.1\r\n"; |
|
| 227 | + $request .= "Host: ".$parts['host']."\r\n"; |
|
| 228 | 228 | |
| 229 | 229 | if ($type == self::POST) { |
| 230 | - $request.= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
| 231 | - $request.= "Content-Length: " . strlen($postString) . "\r\n"; |
|
| 230 | + $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
|
| 231 | + $request .= "Content-Length: ".strlen($postString)."\r\n"; |
|
| 232 | 232 | } |
| 233 | - $request.= "Connection: Close\r\n"; |
|
| 234 | - $request.= "\r\n"; |
|
| 233 | + $request .= "Connection: Close\r\n"; |
|
| 234 | + $request .= "\r\n"; |
|
| 235 | 235 | |
| 236 | 236 | // Data goes in the request body for a POST request |
| 237 | 237 | if ($type == self::POST && isset($postString)) { |
| 238 | - $request.= $postString; |
|
| 238 | + $request .= $postString; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | fwrite($sock, $request); |
| 242 | 242 | |
| 243 | 243 | $response = ""; |
| 244 | 244 | while (!feof($sock) && $result = fgets($sock)) { |
| 245 | - $response.= $result; |
|
| 245 | + $response .= $result; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | fclose($sock); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | header('HTTP/1.0 404 Not Found', true, 404); |
| 283 | 283 | break; |
| 284 | 284 | default: |
| 285 | - throw new HttpException("Invalid HTTP status code '" . $code . "'"); |
|
| 285 | + throw new HttpException("Invalid HTTP status code '".$code."'"); |
|
| 286 | 286 | } |
| 287 | 287 | if (!is_null($path)) { |
| 288 | 288 | include($path); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | return self::forceHttpStatus($code, $path); |
| 310 | 310 | } |
| 311 | - throw new HttpException("Invalid HTTP class method '" . $name . "'"); |
|
| 311 | + throw new HttpException("Invalid HTTP class method '".$name."'"); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | } |
@@ -112,7 +112,7 @@ |
||
| 112 | 112 | * Detect browser version number |
| 113 | 113 | */ |
| 114 | 114 | $identifiers[] = $browserShortName; |
| 115 | - self::$pattern = '#(?<browser>' . implode('|', $identifiers) . |
|
| 115 | + self::$pattern = '#(?<browser>'.implode('|', $identifiers). |
|
| 116 | 116 | ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; |
| 117 | 117 | if (!preg_match_all(self::$pattern, $userAgent, $matches)) { |
| 118 | 118 | // we have no matching number just continue |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | if (isset($_FIELDS[$fieldName])) { |
| 211 | 211 | $_FIELDS[$fieldName] = $fieldValue; |
| 212 | 212 | } else { |
| 213 | - throw new \Exception("No field '" . $fieldName . "' in global fields list."); |
|
| 213 | + throw new \Exception("No field '".$fieldName."' in global fields list."); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $_FIELDS[$fieldName] = (bool)$_FIELDS[$fieldName]; |
| 249 | 249 | } |
| 250 | 250 | } else { |
| 251 | - throw new \Exception("No field '" . $fieldName . "' in global fields list."); |
|
| 251 | + throw new \Exception("No field '".$fieldName."' in global fields list."); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | $type = strtoupper($chunks[0]); |
| 64 | 64 | |
| 65 | 65 | if (!self::isValidQueryType($type)) { |
| 66 | - throw new DBQueryTypeException("Invalid SQL query type '" . $type . "'"); |
|
| 66 | + throw new DBQueryTypeException("Invalid SQL query type '".$type."'"); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return $type; |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | $this->changeUpdateTime(); |
| 67 | 67 | |
| 68 | 68 | return DBCore::doUpdateQuery( |
| 69 | - "UPDATE " . static::TABLE_NAME . " |
|
| 69 | + "UPDATE ".static::TABLE_NAME." |
|
| 70 | 70 | SET activation = ?, |
| 71 | 71 | update_time = ?, |
| 72 | 72 | update_user_id = ? |
| 73 | - WHERE " . static::ID_FIELD_NAME . " = ? |
|
| 73 | + WHERE " . static::ID_FIELD_NAME." = ? |
|
| 74 | 74 | LIMIT 1", |
| 75 | 75 | "isii", |
| 76 | 76 | [$this->activation, $this->updateTime, $this->updateUserId, $this->id] |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | $this->changeUpdateTime(); |
| 88 | 88 | |
| 89 | 89 | return DBCore::doUpdateQuery( |
| 90 | - "UPDATE " . static::TABLE_NAME . " |
|
| 90 | + "UPDATE ".static::TABLE_NAME." |
|
| 91 | 91 | SET removed = ?, |
| 92 | 92 | update_time = ?, |
| 93 | 93 | update_user_id = ? |
| 94 | - WHERE " . static::ID_FIELD_NAME . " = ? |
|
| 94 | + WHERE " . static::ID_FIELD_NAME." = ? |
|
| 95 | 95 | LIMIT 1", |
| 96 | 96 | "isii", |
| 97 | 97 | [$this->removed, $this->updateTime, $this->updateUserId, $this->id] |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function __construct($type = "", $name = "", $value = null) { |
| 47 | 47 | if (!(bool)preg_match("#^[a-zA-Z][a-zA-Z0-9_]*$#", $name)) { |
| 48 | - throw new DBFieldException("Can't create DBField object: invalid field name '" . $name . "'"); |
|
| 48 | + throw new DBFieldException("Can't create DBField object: invalid field name '".$name."'"); |
|
| 49 | 49 | } |
| 50 | 50 | $this->name = $name; |
| 51 | 51 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return "s"; |
| 134 | 134 | } else { |
| 135 | 135 | throw new DBFieldTypeException( |
| 136 | - "Can't detect field value type for value '" . (string)$fieldValue . "'" |
|
| 136 | + "Can't detect field value type for value '".(string)$fieldValue."'" |
|
| 137 | 137 | ); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | return $value; |
| 181 | 181 | case ("s"): |
| 182 | 182 | if (!in_array($value, ['NOW()'])) { |
| 183 | - return "'" . $value . "'"; |
|
| 183 | + return "'".$value."'"; |
|
| 184 | 184 | } else { |
| 185 | 185 | return $value; |
| 186 | 186 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | case ("!="): |
| 86 | 86 | $this->value = DBField::castValue($this->field->type, $value); |
| 87 | 87 | |
| 88 | - $this->sqlCondition = "`" . $field->name . "` " |
|
| 89 | - . $this->type . " " |
|
| 88 | + $this->sqlCondition = "`".$field->name."` " |
|
| 89 | + . $this->type." " |
|
| 90 | 90 | . DBField::sqlValue($this->field->type, $value); |
| 91 | 91 | |
| 92 | - $this->preparedCondition = "`" . $field->name . "` " . $this->type . " ?"; |
|
| 92 | + $this->preparedCondition = "`".$field->name."` ".$this->type." ?"; |
|
| 93 | 93 | $this->preparedTypes = $this->field->type; |
| 94 | 94 | $this->preparedData = [DBField::sqlValue($this->field->type, $value)]; |
| 95 | 95 | break; |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | if ($this->field->type != "s") { |
| 101 | 101 | throw new DBQueryConditionException("Field type is not a string"); |
| 102 | 102 | } |
| 103 | - $this->sqlCondition = "`" . $field->name . "` " |
|
| 104 | - . $this->type . " " |
|
| 103 | + $this->sqlCondition = "`".$field->name."` " |
|
| 104 | + . $this->type." " |
|
| 105 | 105 | . DBField::sqlValue($this->field->type, $value); |
| 106 | 106 | |
| 107 | - $this->preparedCondition = "`" . $field->name . "` " . $this->type . " ?"; |
|
| 107 | + $this->preparedCondition = "`".$field->name."` ".$this->type." ?"; |
|
| 108 | 108 | $this->preparedTypes = $this->field->type; |
| 109 | 109 | $this->preparedData = [DBField::sqlValue($this->field->type, $value)]; |
| 110 | 110 | break; |
| 111 | 111 | case ("IN"): |
| 112 | 112 | case ("NOT IN"): |
| 113 | - if (is_array($value) && !empty($value)) { |
|
| 113 | + if (is_array($value) && !empty($value)) { |
|
| 114 | 114 | $dataList = []; |
| 115 | 115 | foreach ($value as $dataItem) { |
| 116 | 116 | $dataList[] = DBField::sqlValue($this->field->type, $dataItem); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | if ($count > 0) { |
| 121 | 121 | $qmStr = "?"; |
| 122 | 122 | $tStr = $this->field->type; |
| 123 | - for ($i = 1; $i < $count; $i ++) { |
|
| 123 | + for ($i = 1; $i < $count; $i++) { |
|
| 124 | 124 | $qmStr .= ", ?"; |
| 125 | 125 | $tStr .= $this->field->type; |
| 126 | 126 | } |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $this->sqlCondition = "`" . $field->name . "` " |
|
| 133 | + $this->sqlCondition = "`".$field->name."` " |
|
| 134 | 134 | . $this->type |
| 135 | - . " (" . implode(", ", $dataList) . ")"; |
|
| 135 | + . " (".implode(", ", $dataList).")"; |
|
| 136 | 136 | |
| 137 | - $this->preparedCondition = "`" . $field->name . "` " . $this->type . " (" . $qmStr . ")"; |
|
| 137 | + $this->preparedCondition = "`".$field->name."` ".$this->type." (".$qmStr.")"; |
|
| 138 | 138 | $this->preparedTypes = $tStr; |
| 139 | 139 | $this->preparedData = $dataList; |
| 140 | 140 | } else { |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | if (is_array($value) && count($value) == 2 && isset($value[0]) && isset($value[1])) { |
| 146 | 146 | $from = DBField::sqlValue($this->field->type, $value[0]); |
| 147 | 147 | $to = DBField::sqlValue($this->field->type, $value[1]); |
| 148 | - $this->sqlCondition = "`" . $field->name . "` BETWEEN " . $from . " AND " . $to; |
|
| 148 | + $this->sqlCondition = "`".$field->name."` BETWEEN ".$from." AND ".$to; |
|
| 149 | 149 | |
| 150 | - $this->preparedCondition = "`" . $field->name . "` BETWEEN ? AND ?"; |
|
| 151 | - $this->preparedTypes = $this->field->type . $this->field->type; |
|
| 150 | + $this->preparedCondition = "`".$field->name."` BETWEEN ? AND ?"; |
|
| 151 | + $this->preparedTypes = $this->field->type.$this->field->type; |
|
| 152 | 152 | $this->preparedData = [$from, $to]; |
| 153 | 153 | } else { |
| 154 | 154 | throw new DBQueryConditionException("Invalid data for 'BETWEEN' condition"); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | case ("!="): |
| 167 | 167 | case ("LIKE"): |
| 168 | 168 | case ("NOT LIKE"): |
| 169 | - $this->sqlCondition = "`" . $field1->name . "` " . $this->type . " `" . $field2->name . "`"; |
|
| 169 | + $this->sqlCondition = "`".$field1->name."` ".$this->type." `".$field2->name."`"; |
|
| 170 | 170 | break; |
| 171 | 171 | case ("IN"): |
| 172 | 172 | case ("NOT IN"): |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | foreach ($queryCondition as $operation => $conditions) { |
| 202 | - $cond .= " " . $operator . self::getSQLCondition($conditions, $operation); |
|
| 202 | + $cond .= " ".$operator.self::getSQLCondition($conditions, $operation); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $cond .= ")"; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | ); |
| 217 | 217 | } |
| 218 | 218 | } elseif (Tools::isInstanceOf($queryCondition, "\Asymptix\db\DBQueryCondition")) { |
| 219 | - return (" " . $queryCondition->sqlCondition); |
|
| 219 | + return (" ".$queryCondition->sqlCondition); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | return ""; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | if (isset($conditionTypes[$conditionType])) { |
| 280 | 280 | return $conditionTypes[$conditionType]; |
| 281 | 281 | } |
| 282 | - throw new DBQueryConditionException("Invalid SQL condition type '" . $conditionType . "'"); |
|
| 282 | + throw new DBQueryConditionException("Invalid SQL condition type '".$conditionType."'"); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |