git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@41 0f545695-f87b-41b6-9a03-7f16563b5454

This commit is contained in:
2016-01-10 22:18:54 +00:00
parent 50c0032f02
commit 4e871bdbd3
25 changed files with 255 additions and 144 deletions
+42 -45
View File
@@ -5,85 +5,82 @@ class MysqlClass
private $nomehost = "localhost"; private $nomehost = "localhost";
private $nomeuser = "root"; private $nomeuser = "root";
private $password = "root"; private $password = "root";
private $mydb = "w18092_ricettario";
/* /*
private $nomehost = "sql.gruppolapastamadre.it"; private $nomehost = "sql.gruppolapastamadre.it";
private $nomeuser = "w18092_ricuser"; private $nomeuser = "w18092_ricuser";
private $password = "RTvg0o6IESoqQyx8CCJn"; private $password = "RTvg0o6IESoqQyx8CCJn";
*/
private $mydb = "w18092_ricettario"; private $mydb = "w18092_ricettario";
*/
// controllo sulle connessioni attive // controllo sulle connessioni attive
private $attiva = false; private $attiva = false;
private $connessione = null; private $connessione = null;
// funzione per la connessione a MySQL // funzione per la connessione a MySQL
public function connetti() public function connetti() {
{ if (!$this->attiva) {
if(!$this->attiva) $this->connessione = mysqli_connect($this->nomehost, $this->nomeuser, $this->password);
{
$this->connessione = mysql_connect($this->nomehost,$this->nomeuser,$this->password);
if ($this->connessione == FALSE) if ($this->connessione == FALSE)
die(mysql_error()); die(mysqli_error());
mysql_select_db($this->mydb, $this->connessione) or die ("Errore nella selezione del database. Verificare i parametri nel file config.inc.php"); 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; $this->attiva = true;
} }
else{ else {
return true;
}
}
public function executeQuery($queryStr) {
$this->connetti();
if (!$res = mysqli_query($this->connessione, $queryStr))
die(mysqli_error());
return true; return true;
} }
} public function insertRecord($queryStr) {
public function executeQuery($queryStr)
{
$this->connetti(); $this->connetti();
if (!$res = mysql_query($queryStr, $this->connessione)) die(mysql_error()); if (!$res = mysqli_query($this->connessione, $queryStr))
return true; die(mysqli_error());
return false; return mysqli_insert_id($this->connessione);
} }
public function insertRecord($queryStr) public function queryToObject($queryStr, $encode = true) {
{
$this->connetti(); $this->connetti();
if (!$res = mysql_query($queryStr, $this->connessione)) die(mysql_error()); $sth = mysqli_query($this->connessione, $queryStr) or die(mysqli_error());
return mysql_insert_id();
}
public function queryToObject($queryStr)
{
$this->connetti();
$sth = mysql_query($queryStr, $this->connessione) or die(mysql_error());
if($encode){
$rows = array(); $rows = array();
while($r = mysql_fetch_assoc($sth)) { while ($r = mysqli_fetch_assoc($sth)) {
array_push($rows,array_map('utf8_encode', $r)); array_push($rows, array_map('utf8_encode', $r));
} }
mysql_free_result($sth); mysqli_free_result($sth);
return $rows; 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 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; return false;
} }
} }
} }
public function __destruct() public function __destruct() {
{
$this->disconnetti(); $this->disconnetti();
} }
}
}
?> ?>
+9 -5
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -140,7 +140,10 @@ class Environment implements \ArrayAccess, \IteratorAggregate
$env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes $env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes
// Virtual path // 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'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string
$env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash $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']; $env['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
//Number of server port that is running the script //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) //HTTP request headers (retains HTTP_ prefix to match $_SERVER)
$headers = \Slim\Http\Headers::extract($_SERVER); $headers = \Slim\Http\Headers::extract($_SERVER);
@@ -191,9 +195,9 @@ class Environment implements \ArrayAccess, \IteratorAggregate
{ {
if (isset($this->properties[$offset])) { if (isset($this->properties[$offset])) {
return $this->properties[$offset]; return $this->properties[$offset];
} else {
return null;
} }
return null;
} }
/** /**
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+5 -5
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -160,7 +160,7 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
public function __unset($key) public function __unset($key)
{ {
return $this->remove($key); $this->remove($key);
} }
/** /**
@@ -216,7 +216,7 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
/** /**
* Ensure a value or object will remain globally unique * Ensure a value or object will remain globally unique
* @param string $key The value or object name * @param string $key The value or object name
* @param Closure The closure that defines the object * @param \Closure $value The closure that defines the object
* @return mixed * @return mixed
*/ */
public function singleton($key, $value) public function singleton($key, $value)
@@ -234,8 +234,8 @@ class Set implements \ArrayAccess, \Countable, \IteratorAggregate
/** /**
* Protect closure from being directly invoked * Protect closure from being directly invoked
* @param Closure $callable A closure to keep from being invoked and evaluated * @param \Closure $callable A closure to keep from being invoked and evaluated
* @return Closure * @return \Closure
*/ */
public function protect(\Closure $callable) public function protect(\Closure $callable)
{ {
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+3 -3
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -169,9 +169,9 @@ class Request
return true; return true;
} elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') { } elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') {
return true; return true;
} else {
return false;
} }
return false;
} }
/** /**
+10 -2
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -85,6 +85,7 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate
204 => '204 No Content', 204 => '204 No Content',
205 => '205 Reset Content', 205 => '205 Reset Content',
206 => '206 Partial Content', 206 => '206 Partial Content',
226 => '226 IM Used',
//Redirection 3xx //Redirection 3xx
300 => '300 Multiple Choices', 300 => '300 Multiple Choices',
301 => '301 Moved Permanently', 301 => '301 Moved Permanently',
@@ -116,13 +117,20 @@ class Response implements \ArrayAccess, \Countable, \IteratorAggregate
418 => '418 I\'m a teapot', 418 => '418 I\'m a teapot',
422 => '422 Unprocessable Entity', 422 => '422 Unprocessable Entity',
423 => '423 Locked', 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 //Server Error 5xx
500 => '500 Internal Server Error', 500 => '500 Internal Server Error',
501 => '501 Not Implemented', 501 => '501 Not Implemented',
502 => '502 Bad Gateway', 502 => '502 Bad Gateway',
503 => '503 Service Unavailable', 503 => '503 Service Unavailable',
504 => '504 Gateway Timeout', 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'
); );
/** /**
+3 -3
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -60,9 +60,9 @@ class Util
$strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes; $strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes;
if ($strip) { if ($strip) {
return self::stripSlashes($rawData); return self::stripSlashes($rawData);
} else {
return $rawData;
} }
return $rawData;
} }
/** /**
+7 -2
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -306,7 +306,12 @@ class Log
if (!isset(self::$levels[$level])) { if (!isset(self::$levels[$level])) {
throw new \InvalidArgumentException('Invalid log level supplied to function'); throw new \InvalidArgumentException('Invalid log level supplied to function');
} else if ($this->enabled && $this->writer && $level <= $this->level) { } 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 (count($context) > 0) {
if (isset($context['exception']) && $context['exception'] instanceof \Exception) { if (isset($context['exception']) && $context['exception'] instanceof \Exception) {
$message .= ' - ' . $context['exception']; $message .= ' - ' . $context['exception'];
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+2 -2
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -116,7 +116,7 @@ class ContentTypes extends \Slim\Middleware
{ {
if (function_exists('json_decode')) { if (function_exists('json_decode')) {
$result = json_decode($input, true); $result = json_decode($input, true);
if ($result) { if(json_last_error() === JSON_ERROR_NONE) {
return $result; return $result;
} }
} }
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+1 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
+2 -2
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -89,7 +89,7 @@ class PrettyExceptions extends \Slim\Middleware
$message = $exception->getMessage(); $message = $exception->getMessage();
$file = $exception->getFile(); $file = $exception->getFile();
$line = $exception->getLine(); $line = $exception->getLine();
$trace = str_replace(array('#', '\n'), array('<div>#', '</div>'), $exception->getTraceAsString()); $trace = str_replace(array('#', "\n"), array('<div>#', '</div>'), $exception->getTraceAsString());
$html = sprintf('<h1>%s</h1>', $title); $html = sprintf('<h1>%s</h1>', $title);
$html .= '<p>The application could not run because of the following error:</p>'; $html .= '<p>The application could not run because of the following error:</p>';
$html .= '<h2>Details</h2>'; $html .= '<h2>Details</h2>';
+4 -9
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -119,15 +119,10 @@ class SessionCookie extends \Slim\Middleware
if (session_id() === '') { if (session_id() === '') {
session_start(); session_start();
} }
$value = $this->app->getCookie($this->settings['name']); $value = $this->app->getCookie($this->settings['name']);
if ($value) { if ($value) {
try { $value = json_decode($value, true);
$_SESSION = unserialize($value); $_SESSION = is_array($value) ? $value : array();
} catch (\Exception $e) {
$this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage());
}
} else { } else {
$_SESSION = array(); $_SESSION = array();
} }
@@ -138,7 +133,7 @@ class SessionCookie extends \Slim\Middleware
*/ */
protected function saveSession() protected function saveSession()
{ {
$value = serialize($_SESSION); $value = json_encode($_SESSION);
if (strlen($value) > 4096) { if (strlen($value) > 4096) {
$this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.'); $this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.');
+7 -1
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -288,6 +288,9 @@ class Route
public function appendHttpMethods() public function appendHttpMethods()
{ {
$args = func_get_args(); $args = func_get_args();
if(count($args) && is_array($args[0])){
$args = $args[0];
}
$this->methods = array_merge($this->methods, $args); $this->methods = array_merge($this->methods, $args);
} }
@@ -298,6 +301,9 @@ class Route
public function via() public function via()
{ {
$args = func_get_args(); $args = func_get_args();
if(count($args) && is_array($args[0])){
$args = $args[0];
}
$this->methods = array_merge($this->methods, $args); $this->methods = array_merge($this->methods, $args);
return $this; return $this;
+3 -3
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -232,9 +232,9 @@ class Router
$this->getNamedRoutes(); $this->getNamedRoutes();
if ($this->hasNamedRoute($name)) { if ($this->hasNamedRoute($name)) {
return $this->namedRoutes[(string) $name]; return $this->namedRoutes[(string) $name];
} else {
return null;
} }
return null;
} }
/** /**
+42 -10
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -54,7 +54,7 @@ class Slim
/** /**
* @const string * @const string
*/ */
const VERSION = '2.4.2'; const VERSION = '2.6.1';
/** /**
* @var \Slim\Helper\Set * @var \Slim\Helper\Set
@@ -231,22 +231,22 @@ class Slim
public function __get($name) public function __get($name)
{ {
return $this->container[$name]; return $this->container->get($name);
} }
public function __set($name, $value) public function __set($name, $value)
{ {
$this->container[$name] = $value; $this->container->set($name, $value);
} }
public function __isset($name) public function __isset($name)
{ {
return isset($this->container[$name]); return $this->container->has($name);
} }
public function __unset($name) public function __unset($name)
{ {
unset($this->container[$name]); $this->container->remove($name);
} }
/** /**
@@ -906,7 +906,12 @@ class Slim
} }
} }
return $value; /*
* transform $value to @return doc requirement.
* \Slim\Http\Util::decodeSecureCookie - is able
* to return false and we have to cast it to null.
*/
return $value === false ? null : $value;
} }
/** /**
@@ -1100,6 +1105,18 @@ class Slim
$this->halt($status); $this->halt($status);
} }
/**
* RedirectTo
*
* Redirects to a specific named route
*
* @param string $route The route name
* @param array $params Associative array of URL parameters and replacement values
*/
public function redirectTo($route, $params = array(), $status = 302){
$this->redirect($this->urlFor($route, $params), $status);
}
/******************************************************************************** /********************************************************************************
* Flash Messages * Flash Messages
*******************************************************************************/ *******************************************************************************/
@@ -1138,6 +1155,16 @@ class Slim
} }
} }
/**
* Get all flash messages
*/
public function flashData()
{
if (isset($this->environment['slim.flash'])) {
return $this->environment['slim.flash']->getMessages();
}
}
/******************************************************************************** /********************************************************************************
* Hooks * Hooks
*******************************************************************************/ *******************************************************************************/
@@ -1161,9 +1188,9 @@ class Slim
/** /**
* Invoke hook * Invoke hook
* @param string $name The hook name * @param string $name The hook name
* @param mixed $hookArg (Optional) Argument for hooked functions * @param mixed ... (Optional) Argument(s) for hooked functions, can specify multiple arguments
*/ */
public function applyHook($name, $hookArg = null) public function applyHook($name)
{ {
if (!isset($this->hooks[$name])) { if (!isset($this->hooks[$name])) {
$this->hooks[$name] = array(array()); $this->hooks[$name] = array(array());
@@ -1173,10 +1200,14 @@ class Slim
if (count($this->hooks[$name]) > 1) { if (count($this->hooks[$name]) > 1) {
ksort($this->hooks[$name]); ksort($this->hooks[$name]);
} }
$args = func_get_args();
array_shift($args);
foreach ($this->hooks[$name] as $priority) { foreach ($this->hooks[$name] as $priority) {
if (!empty($priority)) { if (!empty($priority)) {
foreach ($priority as $callable) { foreach ($priority as $callable) {
call_user_func($callable, $hookArg); call_user_func_array($callable, $args);
} }
} }
} }
@@ -1344,6 +1375,7 @@ class Slim
throw $e; throw $e;
} else { } else {
try { try {
$this->response()->write(ob_get_clean());
$this->error($e); $this->error($e);
} catch (\Slim\Exception\Stop $e) { } catch (\Slim\Exception\Stop $e) {
// Do nothing // Do nothing
+4 -4
View File
@@ -6,7 +6,7 @@
* @copyright 2011 Josh Lockhart * @copyright 2011 Josh Lockhart
* @link http://www.slimframework.com * @link http://www.slimframework.com
* @license http://www.slimframework.com/license * @license http://www.slimframework.com/license
* @version 2.4.2 * @version 2.6.1
* @package Slim * @package Slim
* *
* MIT LICENSE * MIT LICENSE
@@ -108,7 +108,7 @@ class View
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
public function keep($key, Closure $value) public function keep($key, \Closure $value)
{ {
$this->data->keep($key, $value); $this->data->keep($key, $value);
} }
@@ -152,9 +152,9 @@ class View
{ {
if (!is_null($key)) { if (!is_null($key)) {
return isset($this->data[$key]) ? $this->data[$key] : null; return isset($this->data[$key]) ? $this->data[$key] : null;
} else {
return $this->data->all();
} }
return $this->data->all();
} }
/** /**
+1
View File
@@ -2,6 +2,7 @@
$allowedHost = array( $allowedHost = array(
"localhost", "localhost",
"denisnotebook",
"app.gruppolapastamadre.it", "app.gruppolapastamadre.it",
"dev.gruppolapastamadre.it", "dev.gruppolapastamadre.it",
"management.gruppolapastamadre.it" "management.gruppolapastamadre.it"
+36
View File
@@ -167,3 +167,39 @@ $app->get('/ricetta/:itemID/photos', function ($itemID) use ($app) {
$mysqlconnetion->disconnetti(); $mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj); returnJson($app, $callbackFn, $retObj);
}); });
$app->get('/statistics/gender', function () use ($app) {
$callbackFn = $app->request()->get('callback');
$query = "SELECT 'Gender' as Type, IF(Gender='', 'Sconosciuto', Gender) as Serie, COUNT(gender) as CountSerie from profilo GROUP BY gender";
$mysqlconnetion = new MysqlClass;
//$mysqlconnetion->connetti();
$retObj = $mysqlconnetion->queryToObject($query);
$mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj);
});
$app->get('/statistics/typeAccess', function () use ($app) {
$callbackFn = $app->request()->get('callback');
$query = "SELECT 'TipoAccesso' as Type, TipoAccesso as Serie, COUNT(TipoAccesso) as CountSerie from profilo GROUP BY TipoAccesso";
$mysqlconnetion = new MysqlClass;
//$mysqlconnetion->connetti();
$retObj = $mysqlconnetion->queryToObject($query);
$mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj);
});
$app->get('/statistics/themesUsage', function () use ($app) {
$callbackFn = $app->request()->get('callback');
$query = "SELECT 'TemaUI' as Type, TemaUI as Serie, COUNT(TemaUI) as CountSerie from profilo GROUP BY TemaUI";
$mysqlconnetion = new MysqlClass;
//$mysqlconnetion->connetti();
$retObj = $mysqlconnetion->queryToObject($query);
$mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj);
});
+29 -2
View File
@@ -81,7 +81,7 @@ $app->get('/profile/:keyStore/ricette', function ($keyStore) use ($app) {
$app->get('/profile/:keyStore', function ($keyStore) use ($app) { $app->get('/profile/:keyStore', function ($keyStore) use ($app) {
$callbackFn = $app->request()->get('callback'); $callbackFn = $app->request()->get('callback');
$mysqlconnetion = new MysqlClass; $mysqlconnetion = new MysqlClass;
$query = "select ProfiloID, TipoAccesso, RisultatiRicerca, TemaUI, Name, Gender, 0 as NumRicette, BloccoNoteUpdated from profilo" . $query = "SELECT ProfiloID,TipoAccesso,RisultatiRicerca,TemaUI,Name,Gender,0 AS NumRicette,BloccoNoteUpdated,Email,bSpacciatore,bPrivacy,Cap,Comune,Provincia,TipoPM, Latitudine, Longitudine from profilo" .
" where ProfiloID = '" . $keyStore . "'"; " where ProfiloID = '" . $keyStore . "'";
$retObj = $mysqlconnetion->queryToObject($query); $retObj = $mysqlconnetion->queryToObject($query);
@@ -100,11 +100,38 @@ $app->get('/profile/:keyStore', function ($keyStore) use ($app) {
returnJson($app, $callbackFn, $retObj); returnJson($app, $callbackFn, $retObj);
}); });
$app->get('/profile/province(/:iniz)', function ($iniz = "") use ($app) {
$callbackFn = $app->request()->get('callback');
$mysqlconnetion = new MysqlClass;
$where= "";
if($iniz!="")
$where = "WHERE Provincia like '" . $iniz . "%' ";
$query = "select DISTINCT Provincia from comuni " . $where . "ORDER BY Provincia";
$retObj = $mysqlconnetion->queryToObject($query);
$mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj);
});
$app->get('/profile/comuni/:prov(/:iniz)', function ($prov ,$iniz = "") use ($app) {
$callbackFn = $app->request()->get('callback');
$mysqlconnetion = new MysqlClass;
$where= "";
if($iniz!="")
$where = "AND Comune like '" . $iniz . "%' ";
$query = "select Comune, CAP from comuni where Provincia = '" . $prov . "' " . $where . "ORDER BY Comune";
$retObj = $mysqlconnetion->queryToObject($query);
$mysqlconnetion->disconnetti();
returnJson($app, $callbackFn, $retObj);
});
$app->post('/profile', function () use ($app) { $app->post('/profile', function () use ($app) {
$callbackFn = $app->request()->get('callback'); $callbackFn = $app->request()->get('callback');
$json_data_body = json_decode($app->request()->post('dataPair')); $json_data_body = json_decode($app->request()->post('dataPair'));
$mysqlconnetion = new MysqlClass; $mysqlconnetion = new MysqlClass;
$query = "insert into profilo(ProfiloID, Name, Email, Gender, TipoAccesso, RisultatiRicerca, TemaUI, UltimoAccesso, CreatoIl) values ('" . $json_data_body->keyStore . "', '" . str_replace("'", "''",$json_data_body->name) . "', '" . $json_data_body->email . "', '" . $json_data_body->gender . "', '" . $json_data_body->type . "', '" . $json_data_body->risRic . "', '" . $json_data_body->tema . "', NOW(), NOW())"; $query = "insert into profilo(ProfiloID, Name, Email, Gender, TipoAccesso, RisultatiRicerca, TemaUI, UltimoAccesso, CreatoIl) values ('" . $json_data_body->keyStore . "', '" . str_replace("'", "''", htmlentities($json_data_body->name, null, "UTF-8")) . "', '" . $json_data_body->email . "', '" . $json_data_body->gender . "', '" . $json_data_body->type . "', '" . $json_data_body->risRic . "', '" . $json_data_body->tema . "', NOW(), NOW())";
$retNewID = $mysqlconnetion->insertRecord($query); $retNewID = $mysqlconnetion->insertRecord($query);
$mysqlconnetion->disconnetti(); $mysqlconnetion->disconnetti();