Posted by | Posted in CakePHP, php | Posted on 02-06-2010
2
Hoy he necesitado aumentar el tiempo que permanecía un usuario logueado sin que le sacara la aplicación considerándole usuario sin credenciales. Para modificar dicho tiempo es necesario acceder al siguiente código que se encuentra en el fichero: APP->CONFIG->core.php
/**
* Session time out time (in seconds).
* Actual value depends on 'Security.level' setting.
* 120 son 2 minutos -> si session.timeout es high 2x10 => 20 minutos
* 360 son 6 minutos -> si session.timeout es high 6x10 => 1 hora
* 8640 son 144 minutos -> si session.timeout es high 24 horas
*/
Configure::write('Session.timeout', '120'); //3600 seconds
y
/**
* The level of CakePHP security. The session timeout time defined
* in 'Session.timeout' is multiplied according to the settings here.
* Valid values:
*
* 'high' Session timeout in 'Session.timeout' x 10
* 'medium' Session timeout in 'Session.timeout' x 100
* 'low' Session timeout in 'Session.timeout' x 300
*
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'.
*/
Configure::write('Security.level', 'high');
Si tenéis el timeout a 120 y el nivel de seguridad a high, el tiempo que os permitirá estar logueados sin ninguna actividad en la aplicación es de 120*10/60 = 20 minutos.
Si quisiérais mantener el logueo durante 24 horas con un nivel de seguridad high tendréis que poner el timeout a 8640 (8640*10/(60*24) = 1).
Espero que os haya sido de utilidad!!
Posted by | Posted in CakePHP, php | Posted on 16-02-2010
2
Pues hoy he necesitado crear unos radiobuttons dentro de un formulario. Este formulario se llama una y otra vez porque su objetivo es el hacer que el usuario conteste una pregunta y si acierta, que conteste otra.
En un principio mi código era el siguiente:
<?php
$contents = '';
$contents .= $question;
$contents .= $form->create('User', array('action' => 'index/'.$id));
$contents .= $form->radio('Respuesta', array('1'=>$answer1, '2'=>$answer2, '3'=>$answer3));
$contents .= $form->end('Enviar info');
echo $contents;
?>
Pero esto me generó un problema: por alguna extraña razón me mantenía el valor de la pregunta anterior en el formulario. Es decir, si había marcado la 3ª respuesta como válida en la primera pregunta, pulsaba el botón de enviar la información y en la segunda pregunta me mapeaba esa 3ª respuesta.
Buscando por foros encontré una solución que no me valió, la de añadir un default (quizás hay alguien que lo haya podido desentrañar)
En mi caso, y como lo resolví fue agregando array(‘value’=>’0′) en la creación del radiobutton. De esta forma el código queda así:
<?php
$contents = '';
$contents .= $question;
$contents .= $form->create('User', array('action' => 'index/'.$id));
$contents .= $form->radio('Respuesta', array('1'=>$answer1, '2'=>$answer2, '3'=>$answer3), array('value'=>'0'));
$contents .= $form->end('Enviar info');
echo $contents;
?>
Posted by | Posted in Dominios, php | Posted on 10-02-2010
0
Hoy me he encontrado ante el problema siguiente: el navegador me daba error al probar una aplicación en remoto que funcionaba perfectamente en local. Esto es debido a que no había modificado el archivo index situado en la carpeta www (public_html) del host. Ese archivo index tiene que ser el siguiente:
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.app.webroot
* @since CakePHP(tm) v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* When using custom settings be sure to use the DS and do not add a trailing DS.
*/
/**
* The full path to the directory which holds "app", WITHOUT a trailing DS.
*
*/
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'USUARIO'); // TODO Usuario
}
/**
* The actual directory name for the "app".
*
*/
if (!defined('APP_DIR')) {
define('APP_DIR','NOMBREdelaCARPETA'); // TODO Nombre Carpeta
}
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH',
DS.'home'.DS.'USUARIO');} // TODO Usuario
/**
* Editing below this line should NOT be necessary.
* Change at your own risk.
*
*/
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CORE_PATH')) {
if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
define('APP_PATH', null);
define('CORE_PATH', null);
} else {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
return;
} else {
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch($url);
}
if (Configure::read() > 0) {
echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
}
Notas:
- La carpeta de la aplicación y la carpeta del cake tienen que ir en el directorio raiz de nuestro hosting, y la carpeta public_html debe contener lo que en local poseíamos en la carpeta webroot, y que contenía todos los css, javascript,…. (y en el que se encontraba también el index que había que modificar).
- Recordar que el archivo database.php es necesario modificarlo con los datos adecuados para enlazar la aplicación creada con la base de datos (esto es una nota para que no se me olvide).