// Copyright 2001 - 2007 SQLFusion LLC, Author: Philippe Lewicki info@sqlfusion.com // For licensing, reuse, modification and distribution see license.txt /** * Event Mydb.loadParamsFromSession * * This restore to the event controler the varibles of events stored * in the session. * <br>- param string fields_{fieldsnames} * * @package RadriaEvents * @author Philippe Lewicki <*****@*****.**> * @copyright SQLFusion LLC 2001-2004 * @version 3.0 */ use RadriaCore\Radria\Display; $disperr = new Display($this->getMessagePage()); $mydb_paramkeys = $_SESSION["mydb_paramkeys"]; $mydb_eventkey = $_REQUEST["mydb_eventkey"]; $logrun = $this->getLogRun(); if (defined("RADRIA_LOG_RUN_MYDB_EVENTS")) { $this->setLogRun(RADRIA_LOG_RUN_MYDB_EVENTS); } $this->setLog("\n Event Key: " . $mydb_eventkey); if (isset($GLOBALS['cfg_event_param_garbage_time_out'])) { $cfg_event_param_garbage_time_out = $GLOBALS['cfg_event_param_garbage_time_out']; } else { $cfg_event_param_garbage_time_out = 600; } if (isset($GLOBALS['cfg_event_param_garbage_interval'])) { $cfg_event_param_garbage_interval = $GLOBALS['cfg_event_param_garbage_interval']; } else {
/** * Process to the next page based on the $urlNext * @access public */ function doForward() { global $globalevents; if (strlen($this->getUrlNext()) == 0) { if (strlen($this->getParam("event_referer") > 0)) { $this->setUrlNext($this->getParam("event_referer")); } elseif (strlen($_SERVER['HTTP_REFERER']) > 0) { $this->setUrlNext($_SERVER['HTTP_REFERER']); } else { $disp = new Display($this->getMessagePage()); $disp->addParam("message", "No redirection set for this event. Please click back and try again"); } } if ($this->getUniqueUrl()) { if (ereg("uniqid", $this->getUrlNext())) { $this->urlNext = ereg_replace("uniqid=.*", "uniqid=" . uniqid(rand()), $this->getUrlNext()); } elseif (ereg("\\?", $this->getUrlNext())) { $this->urlNext .= "&uniqid=" . uniqid(rand()); } else { $this->urlNext .= "?uniqid=" . uniqid(rand()); } } $this->setLog("\n Forward to URL:" . $this->getUrlNext()); header("Location: " . $this->getUrlNext()); exit; }
function eventCheckUsernamePassword(EventControler $evctl) { /** Event CheckUsernamePassword * * To test if passwords matches and there is not already a login and password * To work the uniq id of the table must be named as id<table name>. * If its a new record the uniqid must be an empty string else a integer.. * If not it sets the doSave param at "no" to block the save and * Call the message page. * @package RadriaEvents * @author Philippe Lewicki <*****@*****.**> * @param array accessfield array with the name of the password and login fields * Option : * @param string errorpage page to display the errors * @copyright SQLFusion */ /* $strMissingField = "Vous devez avoir 1 login et 1 mot de passe" ; $strErrorPasswordNotMatch = "Les mots de passe saisie ne correspondent pas "; $strErrorLoginAlreadyUsed = "Loggin deja utilise, Vous devez choisir un autre login"; */ global $strMissingField, $strErrorPasswordNotMatch, $strErrorLoginAlreadyUsed; if (!isset($strMissingField)) { $strMissingField = "You need a login and password in the form"; } if (!isset($strErrorPasswordNotMatch)) { $strErrorPasswordNotMatch = "The password entries do not match"; } if (!isset($strErrorLoginAlreadyUsed)) { $strErrorLoginAlreadyUsed = "The username is already in use"; } $accessfield = $evctl->accessfield; $fields = $evctl->fields; $fieldrepeatpass = $evctl->fieldrepeatpass; $errorpage = $evctl->errorpage; $this->setLog("\n Check login & password:"******"\n Repeat pass:"******"Cancel") { if (strlen($errorpage) > 0) { $dispError = new Display($errorpage); } else { $dispError = new Display($evctl->getMessagePage()); } $dispError->addParam("message", ""); if (is_array($accessfield)) { if (!isset($table)) { $table = "users"; } $nbraccess = count($accessfield); if ($nbraccess != 2) { $dispError->editParam("message", $strMissingField); } $passwordfield = $accessfield["password"]; $loginfield = $accessfield["login"]; $this->setLog("\n Verify pass:"******"message", $strErrorPasswordNotMatch); } if (get_magic_quotes_gpc()) { $primarykey = stripslashes($primarykey); } if (strlen($primarykey) > 0) { $queryverif = "select * from " . $table . " where " . $loginfield . "='" . $fields[$loginfield] . "' AND NOT(" . $primarykey . ")"; } else { $queryverif = "select * from " . $table . " where " . $loginfield . "='" . $fields[$loginfield] . "'"; } $qVerif = new SqlQuery($evctl->getDbCon()); $rverif = $qVerif->query($queryverif); if ($qVerif->getNumRows()) { $dispError->editParam("message", $strErrorLoginAlreadyUsed); } } $error = $dispError->getParam("message"); if (strlen($error) > 0) { $_SESSION["in_page_message"] = $error; $evctl->setDisplayNext($dispError); $evctl->updateParam("doSave", "no"); // echo "supposed to be no from here " ; } } }
/** * Constructor, create the event object with name and action * parameters. * The goto param is preset to the location where the event is created. * The goto param is used in the events to define the url to call * after executing the event. * The event key is set in the constructor so a valid event key can be displayed even * if the event is manualy set to not secure * * @param String $name name of the event * @param String $action action for this event * @global $PHP_SELF, $QUERY_STRING * @constant RADRIA_EVENT_SECURE to set the event to secure or none secure mode * @access public */ function __construct($name = "", $action = "") { global $PHP_SELF, $QUERY_STRING; parent::__construct(); if (defined("RADRIA_LOG_RUN_EVENT")) { $this->setLogRun(RADRIA_LOG_RUN_EVENT); } $this->setName($name); $this->setAction($action); $this->setLevel(100); if (defined("RADRIA_EVENT_SECURE")) { $this->setSecure(RADRIA_EVENT_SECURE); } else { define("RADRIA_EVENT_SECURE", true); $this->setSecure(true); } if (defined("RADRIA_EVENT_CONTROLER")) { $this->setEventControler(RADRIA_EVENT_CONTROLER); } if (!defined("RADRIA_EVENT_ABSOLUTE_PATH")) { define("RADRIA_EVENT_ABSOLUTE_PATH", false); } if (RADRIA_EVENT_ABSOLUTE_PATH) { $this->base_web_path = "/"; } else { $this->base_web_path = ""; } if (RADRIA_EVENT_SECURE) { if ($_SERVER["HTTPS"] == "on") { $http = "https://"; } else { $http = "http://"; } $this->addParam("event_referer", $http . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } }
/** Event FieldType::eventCheckUnique * * Check that all the field set as required are field in. * If not it sets the doSave param at "no" to block the save and * call the message page. * <br>- param array fields that contains the content of the fields to check * <br>- param array required indexed on fields name and contains value "yes" * <br>Option: * <br>- param string errorpage page to display the error message */ function eventCheckUnique(EventControler $evctl) { $this->setLog("\n Check Unique , table:" . $this->unique_table_name . " message:" . $this->unique_message); if (strlen($this->unique_message) > 0) { $validate_message = $this->unique_message; } elseif (strlen($this->label) > 0) { $validate_message = $this->label . _(" must be unique"); } if ($evctl->submitbutton != _("Cancel") && strlen($this->unique_table_name) > 0) { $field_name = $this->getFieldName(); if ($evctl->unique[$field_name] == "yes") { $q_check = new SqlQuery($this->getDbCon()); $q_check->query("select {$field_name} from " . $this->unique_table_name . " where {$field_name} = '" . $q_check->quote($evctl->fields[$field_name]) . "'"); if ($q_check->getNumRows() > 0) { if (strlen($evctl->errorpage) > 0) { $urlerror = $evctl->errorpage; } else { $urlerror = $evctl->getMessagePage(); } $disp = new Display($urlerror); $disp->addParam("message", $validate_message); $_SESSION['in_page_message'] = $validate_message; $this->setLog("\n Validate message:" . $_SESSION['in_page_message']); $evctl->setDisplayNext($disp); $evctl->updateParam("doSave", "no"); } } } }