diff --git a/MySqlClass.php b/MySqlClass.php index fa1fd18..6df9784 100644 --- a/MySqlClass.php +++ b/MySqlClass.php @@ -5,85 +5,82 @@ class MysqlClass private $nomehost = "localhost"; private $nomeuser = "root"; private $password = "root"; - - /* - private $nomehost = "sql.gruppolapastamadre.it"; - private $nomeuser = "w18092_ricuser"; - private $password = "RTvg0o6IESoqQyx8CCJn"; - */ - private $mydb = "w18092_ricettario"; - // controllo sulle connessioni attive - private $attiva = false; - private $connessione = null; - - // funzione per la connessione a MySQL - public function connetti() - { - if(!$this->attiva) - { - $this->connessione = mysql_connect($this->nomehost,$this->nomeuser,$this->password); - if ($this->connessione == FALSE) - die(mysql_error()); - mysql_select_db($this->mydb, $this->connessione) or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php"); - $this->attiva = true; - } - else{ - return true; - } - - } - - public function executeQuery($queryStr) - { - $this->connetti(); - - if (!$res = mysql_query($queryStr, $this->connessione)) die(mysql_error()); - return true; - return false; - } - - public function insertRecord($queryStr) - { - $this->connetti(); - - if (!$res = mysql_query($queryStr, $this->connessione)) die(mysql_error()); - return mysql_insert_id(); - } - - public function queryToObject($queryStr) - { - $this->connetti(); - - $sth = mysql_query($queryStr, $this->connessione) or die(mysql_error()); - - $rows = array(); - while($r = mysql_fetch_assoc($sth)) { - array_push($rows,array_map('utf8_encode', $r)); - } - mysql_free_result($sth); - return $rows; - } - - // funzione per la chiusura della connessione - public function disconnetti() - { - if($this->attiva) - { - if(mysql_close($this->connessione)) - { - $this->attiva = false; - return true; - } - else - { - return false; - } - } - } - - public function __destruct() - { - $this->disconnetti(); - } - } + private $mydb = "w18092_ricettario"; + /* + private $nomehost = "sql.gruppolapastamadre.it"; + private $nomeuser = "w18092_ricuser"; + private $password = "RTvg0o6IESoqQyx8CCJn"; + private $mydb = "w18092_ricettario"; + */ + // controllo sulle connessioni attive + private $attiva = false; + private $connessione = null; + + // funzione per la connessione a MySQL + public function connetti() { + if (!$this->attiva) { + $this->connessione = mysqli_connect($this->nomehost, $this->nomeuser, $this->password); + if ($this->connessione == FALSE) + die(mysqli_error()); + mysqli_select_db($this->connessione, $this->mydb) or die("Errore nella selezione del database. Verificare i parametri nel file config.inc.php"); + $this->attiva = true; + } + else { + return true; + } + } + + public function executeQuery($queryStr) { + $this->connetti(); + + if (!$res = mysqli_query($this->connessione, $queryStr)) + die(mysqli_error()); + return true; + } + + public function insertRecord($queryStr) { + $this->connetti(); + + if (!$res = mysqli_query($this->connessione, $queryStr)) + die(mysqli_error()); + return mysqli_insert_id($this->connessione); + } + + public function queryToObject($queryStr, $encode = true) { + $this->connetti(); + + $sth = mysqli_query($this->connessione, $queryStr) or die(mysqli_error()); + + if($encode){ + $rows = array(); + while ($r = mysqli_fetch_assoc($sth)) { + array_push($rows, array_map('utf8_encode', $r)); + } + mysqli_free_result($sth); + return $rows; + } + else + { + return mysqli_fetch_array($sth); + } + } + + // funzione per la chiusura della connessione + public function disconnetti() { + if ($this->attiva) { + if (mysqli_close($this->connessione)) { + $this->attiva = false; + return true; + } else { + return false; + } + } + } + + public function __destruct() { + $this->disconnetti(); + } + +} + ?> \ No newline at end of file diff --git a/Slim/Environment.php b/Slim/Environment.php index a15e1e4..3459783 100644 --- a/Slim/Environment.php +++ b/Slim/Environment.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -140,7 +140,10 @@ class Environment implements \ArrayAccess, \IteratorAggregate $env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes // Virtual path - $env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path + $env['PATH_INFO'] = $requestUri; + if (substr($requestUri, 0, strlen($physicalPath)) == $physicalPath) { + $env['PATH_INFO'] = substr($requestUri, strlen($physicalPath)); // <-- Remove physical path + } $env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string $env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash @@ -151,7 +154,8 @@ class Environment implements \ArrayAccess, \IteratorAggregate $env['SERVER_NAME'] = $_SERVER['SERVER_NAME']; //Number of server port that is running the script - $env['SERVER_PORT'] = $_SERVER['SERVER_PORT']; + //Fixes: https://github.com/slimphp/Slim/issues/962 + $env['SERVER_PORT'] = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; //HTTP request headers (retains HTTP_ prefix to match $_SERVER) $headers = \Slim\Http\Headers::extract($_SERVER); @@ -191,9 +195,9 @@ class Environment implements \ArrayAccess, \IteratorAggregate { if (isset($this->properties[$offset])) { return $this->properties[$offset]; - } else { - return null; } + + return null; } /** diff --git a/Slim/Exception/Pass.php b/Slim/Exception/Pass.php index 99d95c2..30a3a1d 100644 --- a/Slim/Exception/Pass.php +++ b/Slim/Exception/Pass.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Exception/Stop.php b/Slim/Exception/Stop.php index a251851..28aba78 100644 --- a/Slim/Exception/Stop.php +++ b/Slim/Exception/Stop.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Helper/Set.php b/Slim/Helper/Set.php index 9538b69..bf6e895 100644 --- a/Slim/Helper/Set.php +++ b/Slim/Helper/Set.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -160,7 +160,7 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate public function __unset($key) { - return $this->remove($key); + $this->remove($key); } /** @@ -215,8 +215,8 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate /** * Ensure a value or object will remain globally unique - * @param string $key The value or object name - * @param Closure The closure that defines the object + * @param string $key The value or object name + * @param \Closure $value The closure that defines the object * @return mixed */ public function singleton($key, $value) @@ -234,8 +234,8 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate /** * Protect closure from being directly invoked - * @param Closure $callable A closure to keep from being invoked and evaluated - * @return Closure + * @param \Closure $callable A closure to keep from being invoked and evaluated + * @return \Closure */ public function protect(\Closure $callable) { diff --git a/Slim/Http/Cookies.php b/Slim/Http/Cookies.php index cf13801..3b2e11e 100644 --- a/Slim/Http/Cookies.php +++ b/Slim/Http/Cookies.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Http/Headers.php b/Slim/Http/Headers.php index 1704b80..c5e08f2 100644 --- a/Slim/Http/Headers.php +++ b/Slim/Http/Headers.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Http/Request.php b/Slim/Http/Request.php index 735484b..2cd88b4 100644 --- a/Slim/Http/Request.php +++ b/Slim/Http/Request.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -169,9 +169,9 @@ class Request return true; } elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') { return true; - } else { - return false; } + + return false; } /** diff --git a/Slim/Http/Response.php b/Slim/Http/Response.php index c55d647..48c76d8 100644 --- a/Slim/Http/Response.php +++ b/Slim/Http/Response.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -85,6 +85,7 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate 204 => '204 No Content', 205 => '205 Reset Content', 206 => '206 Partial Content', + 226 => '226 IM Used', //Redirection 3xx 300 => '300 Multiple Choices', 301 => '301 Moved Permanently', @@ -116,13 +117,20 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate 418 => '418 I\'m a teapot', 422 => '422 Unprocessable Entity', 423 => '423 Locked', + 426 => '426 Upgrade Required', + 428 => '428 Precondition Required', + 429 => '429 Too Many Requests', + 431 => '431 Request Header Fields Too Large', //Server Error 5xx 500 => '500 Internal Server Error', 501 => '501 Not Implemented', 502 => '502 Bad Gateway', 503 => '503 Service Unavailable', 504 => '504 Gateway Timeout', - 505 => '505 HTTP Version Not Supported' + 505 => '505 HTTP Version Not Supported', + 506 => '506 Variant Also Negotiates', + 510 => '510 Not Extended', + 511 => '511 Network Authentication Required' ); /** diff --git a/Slim/Http/Util.php b/Slim/Http/Util.php index dafedb3..00cac0e 100644 --- a/Slim/Http/Util.php +++ b/Slim/Http/Util.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -60,9 +60,9 @@ class Util $strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes; if ($strip) { return self::stripSlashes($rawData); - } else { - return $rawData; } + + return $rawData; } /** diff --git a/Slim/Log.php b/Slim/Log.php index d872e87..13cb825 100644 --- a/Slim/Log.php +++ b/Slim/Log.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -306,7 +306,12 @@ class Log if (!isset(self::$levels[$level])) { throw new \InvalidArgumentException('Invalid log level supplied to function'); } else if ($this->enabled && $this->writer && $level <= $this->level) { - $message = (string)$object; + if (is_array($object) || (is_object($object) && !method_exists($object, "__toString"))) { + $message = print_r($object, true); + } else { + $message = (string) $object; + } + if (count($context) > 0) { if (isset($context['exception']) && $context['exception'] instanceof \Exception) { $message .= ' - ' . $context['exception']; diff --git a/Slim/LogWriter.php b/Slim/LogWriter.php index 5e44e2f..afa3ae9 100644 --- a/Slim/LogWriter.php +++ b/Slim/LogWriter.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Middleware.php b/Slim/Middleware.php index be23100..79fbb1e 100644 --- a/Slim/Middleware.php +++ b/Slim/Middleware.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Middleware/ContentTypes.php b/Slim/Middleware/ContentTypes.php index 08049db..fcc2242 100644 --- a/Slim/Middleware/ContentTypes.php +++ b/Slim/Middleware/ContentTypes.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -116,7 +116,7 @@ class ContentTypes extends \Slim\Middleware { if (function_exists('json_decode')) { $result = json_decode($input, true); - if ($result) { + if(json_last_error() === JSON_ERROR_NONE) { return $result; } } diff --git a/Slim/Middleware/Flash.php b/Slim/Middleware/Flash.php index 96f685e..593082f 100644 --- a/Slim/Middleware/Flash.php +++ b/Slim/Middleware/Flash.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Middleware/MethodOverride.php b/Slim/Middleware/MethodOverride.php index 7fa3bb0..1298767 100644 --- a/Slim/Middleware/MethodOverride.php +++ b/Slim/Middleware/MethodOverride.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE diff --git a/Slim/Middleware/PrettyExceptions.php b/Slim/Middleware/PrettyExceptions.php index 8a56442..aafda0f 100644 --- a/Slim/Middleware/PrettyExceptions.php +++ b/Slim/Middleware/PrettyExceptions.php @@ -6,7 +6,7 @@ * @copyright 2011 Josh Lockhart * @link http://www.slimframework.com * @license http://www.slimframework.com/license - * @version 2.4.2 + * @version 2.6.1 * @package Slim * * MIT LICENSE @@ -89,7 +89,7 @@ class PrettyExceptions extends \Slim\Middleware $message = $exception->getMessage(); $file = $exception->getFile(); $line = $exception->getLine(); - $trace = str_replace(array('#', '\n'), array('
The application could not run because of the following error:
'; $html .= '