diff --git a/src/contact.php b/src/contact.php index d73a5aa..adaaecb 100644 --- a/src/contact.php +++ b/src/contact.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/contactdelete.php b/src/contactdelete.php index 369cc52..ceb5596 100644 --- a/src/contactdelete.php +++ b/src/contactdelete.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/contactnew.php b/src/contactnew.php index 0da1756..edf930a 100644 --- a/src/contactnew.php +++ b/src/contactnew.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/contacts.php b/src/contacts.php index 7f91fac..0353e89 100644 --- a/src/contacts.php +++ b/src/contacts.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/contactsexport.php b/src/contactsexport.php index 6f0507a..0192cec 100644 --- a/src/contactsexport.php +++ b/src/contactsexport.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/day.php b/src/day.php index 3440a33..d1989df 100644 --- a/src/day.php +++ b/src/day.php @@ -39,7 +39,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/dayprint.php b/src/dayprint.php index b4fc424..71436fd 100644 --- a/src/dayprint.php +++ b/src/dayprint.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/includes-install/cnewuser.php b/src/includes-install/cnewuser.php new file mode 100644 index 0000000..60ac0e4 --- /dev/null +++ b/src/includes-install/cnewuser.php @@ -0,0 +1,269 @@ +m_sUsername,ENT_COMPAT,'UTF-8'):$this->m_sUsername);} + + /** + * function: SetUsername + * description: set username value + * parameter: STRING|sValue - username + * return: none + * author: Olivier JULLIEN - 2010-02-04 + */ + public function SetUsername( $sValue ) + { + $this->m_sUsername=$this->Sanitize($sValue,GetRegExPatternName()); + } + + /** + * function: GetPassword + * description: return the password value + * parameter: none + * return: STRING + * author: Olivier JULLIEN - 2010-02-04 + */ + public function GetPassword(){return $this->m_sPassword1;} + + /** + * function: SetPassword1 + * description: set password1 value + * parameter: STRING|sValue - password + * return: none + * author: Olivier JULLIEN - 2010-02-04 + */ + public function SetPassword1($sValue){$this->m_sPassword1=$this->Sanitize($sValue);} + + /** + * function: SetPassword2 + * description: set password2 value + * parameter: STRING|sValue - password + * return: none + * author: Olivier JULLIEN - 2010-02-04 + */ + public function SetPassword2($sValue){$this->m_sPassword2=$this->Sanitize($sValue);} + + /** + * function: IsValidNew + * description: return true if username and password are set + * parameter: + * return: TRUE or FALSE + * author: Olivier JULLIEN - 2010-02-04 + */ + public function IsValidNew() + { + return ( !is_null($this->m_sUsername) && (strlen($this->m_sUsername)>0) + && !is_null($this->m_sPassword1) && (strlen($this->m_sPassword1)>0) + && !is_null($this->m_sPassword2) && (strlen($this->m_sPassword2)>0) + && ($this->m_sPassword1===$this->m_sPassword2) ); + } + + /** + * function: ReadInput + * description: Read GET or POST input new user values + * parameters: INTEGER|$iFilter - Filter to apply + * return: BOOLEAN| TRUE or FALSE if no input value + * author: Olivier JULLIEN - 2010-02-04 + */ + public function ReadInput($iFilter) + { + $bReturn = FALSE; + if( $iFilter===INPUT_POST ) + { + // Get user name (only POST) + if( filter_has_var(INPUT_POST,'usr') ) + { + $this->SetUsername(filter_input(INPUT_POST,'usr',FILTER_UNSAFE_RAW)); + }//if( filter_has_var(INPUT_POST,'usi') ) + + // Get Password1 (only POST) + if( filter_has_var(INPUT_POST,'pwd1') ) + { + $sBuffer=trim(filter_input(INPUT_POST,'pwd1',FILTER_UNSAFE_RAW)); + if( strlen($sBuffer)>0 ) + { + $this->SetPassword1(sha1($sBuffer)); + } + else + { + $this->m_sPassword1=NULL; + }//if( strlen($sBuffer)>0 ) + }//if( filter_has_var(INPUT_POST,'pwd1') ) + + // Get Password2 (only POST) + if( filter_has_var(INPUT_POST,'pwd2') ) + { + $sBuffer=trim(filter_input(INPUT_POST,'pwd2',FILTER_UNSAFE_RAW)); + if( strlen($sBuffer)>0 ) + { + $this->SetPassword2(sha1($sBuffer)); + } + else + { + $this->m_sPassword2=NULL; + }//if( strlen($sBuffer)>0 ) + }//if( filter_has_var(INPUT_POST,'pwd2') ) + + $bReturn = TRUE; + + }//if( $iFilter===INPUT_POST ) + + return $bReturn; + } + +} +define('PBR_NEWUSER_LOADED',1); +?> diff --git a/src/includes-install/database/data-config.sql b/src/includes-install/database/data-config.sql index 115c1b8..ad07972 100644 --- a/src/includes-install/database/data-config.sql +++ b/src/includes-install/database/data-config.sql @@ -35,7 +35,7 @@ SET AUTOCOMMIT=0; INSERT INTO `config` (`name`,`value`,`role`) VALUES ('data_version','1.0 - 2010-02-04',10), ('cookie_time_expire','36000',10), -('session_time_expire','7200',10), +('session_time_expire','36000',10), ('timezone','+1:00',10), ('max_rent_1','300',10), ('max_rent_2','300',10), diff --git a/src/includes-install/database/sp_configget.sql b/src/includes-install/database/sp_configget.sql deleted file mode 100644 index f1b52ca..0000000 --- a/src/includes-install/database/sp_configget.sql +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ConfigGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Returns autoload config values. * - * ASSUME: The columns of the tables are case insentive. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sName: name. May be empty or NULL. * - * * - * Returns: * - * none or one record (config_name, config_value) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ConfigGet` $$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ConfigGet`( IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sName VARCHAR(45) ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle VARCHAR(255) DEFAULT ' IN sp_ConfigGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sName,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sName=TRIM(sName); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Session is valid -- - SET sErrorDescription = 'Select'; - IF( (sName IS NOT NULL) AND (LENGTH(sName)>0) ) THEN - BEGIN - -- Looking for an unique config value -- - SELECT c.`name` AS 'config_name', c.`value` AS 'config_value' FROM `_PBR_DB_DBN_`.`config` AS c - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON c.`role` <= u.`role` AND u.`state` = 1 - WHERE u.`login` = sLogin AND c.`name`=sName; - END; - ELSE - BEGIN - -- Looking for a list of config value -- - SELECT c.`name` AS 'config_name', c.`value` AS 'config_value' FROM `_PBR_DB_DBN_`.`config` AS c - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON c.`role` <= u.`role` AND u.`state` = 1 - WHERE u.`login` = sLogin ORDER BY c.`name` ASC; - END; - END IF; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_configupdate.sql b/src/includes-install/database/sp_configupdate.sql deleted file mode 100644 index 6e39e4e..0000000 --- a/src/includes-install/database/sp_configupdate.sql +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 JOT - PBRAIDERS.COM * - * Tous droits rservs - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ConfigUpdate * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Update a config value. * - * COPYRIGHT : JOT, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sName: parameter's name. * - * sValue: parameter's value. * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ConfigUpdate`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ConfigUpdate`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sName VARCHAR(45), IN sValue VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ConfigUpdate'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sName,'NULL'),',',IFNULL(sValue,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sName = TRIM(sName); - SET sValue = TRIM(sValue); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (sName IS NOT NULL) AND (LENGTH(sName)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Update -- - SET sErrorDescription = 'Update'; - UPDATE `_PBR_DB_DBN_`.`config` SET `value`=sValue WHERE `name`=sName; - SELECT ROW_COUNT() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactdel.sql b/src/includes-install/database/sp_contactdel.sql deleted file mode 100644 index dfb7bae..0000000 --- a/src/includes-install/database/sp_contactdel.sql +++ /dev/null @@ -1,167 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactDel * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Delete a contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iContact: contact identifier * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row deleted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactDel`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactDel`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactDel'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE bInTransaction TINYINT(1) DEFAULT 0; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An SQLEXCEPTION occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -1; - SELECT iErrorCode AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iContact IS NOT NULL) AND (iContact>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Start transaction -- - SET sErrorDescription = 'Start transaction'; - START TRANSACTION; - SET bInTransaction = 1; - -- Delete rents -- - SET sErrorDescription = 'Delete rents'; - DELETE FROM `_PBR_DB_DBN_`.`reservation` WHERE `idcontact`=iContact; - -- Delete rents -- - SET sErrorDescription = 'Delete rents'; - DELETE FROM `_PBR_DB_DBN_`.`contact` WHERE `idcontact`=iContact; - SELECT ROW_COUNT() INTO iErrorCode; - -- Stop transaction -- - IF iErrorCode>0 THEN - BEGIN - -- No error -- - SET sErrorDescription = 'COMMIT transaction'; - COMMIT; - END; - ELSE - BEGIN - -- Error -- - SET sErrorDescription = 'ROLLBACK transaction'; - ROLLBACK; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('TRANSACTION',sErrorTitle), CONCAT('An error occures while processing "','deleting contact and rent','" step. Exit'),USER(),CURRENT_USER() ); - END; - END IF; - SET bInTransaction = 0; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactget.sql b/src/includes-install/database/sp_contactget.sql deleted file mode 100644 index 09a6ddb..0000000 --- a/src/includes-install/database/sp_contactget.sql +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iContact: contact identifier * - * * - * Returns: * - * none or one record (contact_id,contact_lastname, * - * contact_firstname,contact_tel,contact_email,contact_address * - * contact_addressmore,contact_addresscity,contact_addresszip * - * contact_comment,creation_date,creation_username,update_date * - * update_username) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (iContact IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'request'; - SELECT c.`idcontact` AS 'contact_id',c.`lastname` AS 'contact_lastname' - ,c.`firstname` AS 'contact_firstname',c.`tel` AS 'contact_tel' - ,c.`email` AS 'contact_email',c.`address` AS 'contact_address' - ,c.`address_more` AS 'contact_addressmore',c.`city` AS 'contact_addresscity' - ,c.`zip` AS 'contact_addresszip',c.`comment` AS 'contact_comment' - ,c.`create_date` AS 'creation_date',u.`login` AS 'creation_username' - ,c.`update_date` AS 'update_date',v.`login` AS 'update_username' - FROM `_PBR_DB_DBN_`.`contact` AS c - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON c.`create_iduser`=u.`iduser` - LEFT JOIN `_PBR_DB_DBN_`.`user` AS v ON c.`update_iduser`=v.`iduser` - WHERE c.`idcontact` = iContact; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactrentsget.sql b/src/includes-install/database/sp_contactrentsget.sql deleted file mode 100644 index 781c365..0000000 --- a/src/includes-install/database/sp_contactrentsget.sql +++ /dev/null @@ -1,161 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactRentsGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get rent(s) contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iContact: contact identifier * - * iOffset: offset of the first row to return * - * iLimit: maximum number of rows to return * - * * - * NOTE: In MYSQL 5.x the LIMIT clause do not accept variables. * - * So we use a less performant request to simulate it. * - * This procedure should be updated for MYSQL > 6.0. * - * * - * Returns: * - * none or one record (reservation_id, reservation_year, * - * reservation_month, reservation_day, reservation_real, * - * reservation_planned, reservation_canceled, reservation_arrhes,* - * reservation_age, reservation_comment, reservation_max) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactRentsGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactRentsGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED, IN iOffset MEDIUMINT UNSIGNED, IN iLimit MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactRentsGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),',',IFNULL(iOffset,'NULL'),',',IFNULL(iLimit,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iContact IS NOT NULL) AND (iContact>0) AND (iOffset IS NOT NULL) AND (LENGTH(iOffset)>=0) AND (iLimit IS NOT NULL) AND (LENGTH(iLimit)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET @iRowNum:=0; - SET sErrorDescription = 'Select'; - SELECT t.`reservation_id` - , t.`reservation_year` - , t.`reservation_month` - , t.`reservation_day` - , t.`reservation_real` - , t.`reservation_planned` - , t.`reservation_canceled` - , t.`reservation_age` - , t.`reservation_arrhes` - , t.`reservation_comment` - , t.`reservation_max` - FROM ( SELECT (@iRowNum:=@iRowNum+1) AS RowNumber - , r.`idreservation` AS 'reservation_id' - , r.`year` AS 'reservation_year' - , r.`month` AS 'reservation_month' - , r.`day` AS 'reservation_day' - , r.`rent_real` AS 'reservation_real' - , r.`rent_planned` AS 'reservation_planned' - , r.`rent_canceled` AS 'reservation_canceled' - , r.`age` AS 'reservation_age' - , r.`arrhe` AS 'reservation_arrhes' - , r.`comment` AS 'reservation_comment' - , r.`rent_max` AS 'reservation_max' - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`idcontact`=iContact - ORDER BY r.`year` DESC, r.`month` DESC, r.`day` DESC) AS t - WHERE t.RowNumber > iOffset - AND t.RowNumber <= (iOffset + iLimit); - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactrentsgetcount.sql b/src/includes-install/database/sp_contactrentsgetcount.sql deleted file mode 100644 index 9e1b02d..0000000 --- a/src/includes-install/database/sp_contactrentsgetcount.sql +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactRentsGetCount * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get rent count for a contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iContact: contact identifier * - * * - * Returns: * - * ErrorCode: >=0 is OK. Number of row. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactRentsGetCount`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactRentsGetCount`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactRentsGetCount'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iContact IS NOT NULL) AND (iContact>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT COUNT(r.`idreservation`) INTO iErrorCode - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`idcontact`=iContact; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactset.sql b/src/includes-install/database/sp_contactset.sql deleted file mode 100644 index 98ddc7c..0000000 --- a/src/includes-install/database/sp_contactset.sql +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactSet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Create a contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sLastName: contact last name * - * sFirstName: contact first name * - * sTel: contact telephone * - * sEmail: contact email * - * sAddress: contact address * - * sAddressMore: contact address more * - * sCity: contact address city * - * sZip: contact address zip code * - * sComment: comment * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactSet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactSet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sLastName VARCHAR(40), IN sFirstName VARCHAR(40), IN sTel VARCHAR(40), IN sEmail VARCHAR(255), IN sAddress VARCHAR(255), IN sAddressMore VARCHAR(255), IN sCity VARCHAR(255), IN sZip VARCHAR(8), IN sComment TEXT) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactSet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sLastName,'NULL'),',',IFNULL(sFirstName,'NULL'),',',IFNULL(sTel,'NULL'),',...)'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sLastName=TRIM(sLastName); - SET sFirstName=TRIM(sFirstName); - SET sTel=TRIM(sTel); - SET sEmail=TRIM(sEmail); - SET sAddress=TRIM(sAddress); - SET sAddressMore=TRIM(sAddressMore); - SET sCity=TRIM(sCity); - SET sZip=TRIM(sZip); - SET sComment=TRIM(sComment); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (sLastName IS NOT NULL) AND (LENGTH(sLastName)>0) AND (sFirstName IS NOT NULL) AND (LENGTH(sFirstName)>0) AND (sTel IS NOT NULL) AND (LENGTH(sTel)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Insert -- - SET sErrorDescription = 'Insert'; - INSERT INTO `_PBR_DB_DBN_`.`contact`(`lastname`, `firstname`, `tel`, `email`, `address`, `address_more`, `city`, `zip`, `comment`, `create_date`, `create_iduser`, `update_date`, `update_iduser`) - VALUES (sLastName, sFirstName, sTel, sEmail, sAddress, sAddressMore, sCity, sZip, sComment, SYSDATE(), iUser, NULL, NULL); - SELECT LAST_INSERT_ID() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactsget.sql b/src/includes-install/database/sp_contactsget.sql deleted file mode 100644 index b734c54..0000000 --- a/src/includes-install/database/sp_contactsget.sql +++ /dev/null @@ -1,187 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactsGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get contact(s) * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sSearch: contact last name * - * iOffset: offset of the first row to return * - * iLimit: maximum number of rows to return * - * * - * NOTE: In MYSQL 5.x the LIMIT clause do not accept variables. * - * So we use a less performant request to simulate it. * - * This procedure should be updated for MYSQL > 6.0. * - * * - * Returns: * - * none, one or more records (contact_id,contact_lastname, * - * contact_firstname,contact_tel,contact_email,contact_address * - * contact_addressmore,contact_addresscity,contact_addresszip * - * contact_comment,creation_date,creation_username,update_date * - * update_username) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactsGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactsGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sSearch VARCHAR(40), IN iOffset MEDIUMINT UNSIGNED, IN iLimit MEDIUMINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactsGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sSearch,'NULL'),',',IFNULL(iOffset,'NULL'),',',IFNULL(iLimit,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sSearch=TRIM(sSearch); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iOffset IS NOT NULL) AND (LENGTH(iOffset)>=0) AND (iLimit IS NOT NULL) AND (LENGTH(iLimit)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - SET @iRowNum:=0; - IF (sSearch IS NOT NULL) AND (LENGTH(sSearch)>0) THEN - BEGIN - -- Looking for -- - SET sErrorDescription = 'Looking for'; - SELECT t.`contact_id`,t.`contact_lastname` - ,t.`contact_firstname`,t.`contact_tel` - ,t.`contact_email`,t.`contact_address` - ,t.`contact_addressmore`,t.`contact_addresscity` - ,t.`contact_addresszip`,t.`contact_comment` - ,t.`creation_date`,t.`creation_username` - ,t.`update_date`,t.`update_username` - FROM ( SELECT (@iRowNum:=@iRowNum+1) AS RowNumber - ,c.`idcontact` AS 'contact_id',c.`lastname` AS 'contact_lastname' - ,c.`firstname` AS 'contact_firstname',c.`tel` AS 'contact_tel' - ,c.`email` AS 'contact_email',c.`address` AS 'contact_address' - ,c.`address_more` AS 'contact_addressmore',c.`city` AS 'contact_addresscity' - ,c.`zip` AS 'contact_addresszip',c.`comment` AS 'contact_comment' - ,c.`create_date` AS 'creation_date',u.`login` AS 'creation_username' - ,c.`update_date` AS 'update_date',v.`login` AS 'update_username' - FROM `_PBR_DB_DBN_`.`contact` AS c - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON c.`create_iduser`=u.`iduser` - LEFT JOIN `_PBR_DB_DBN_`.`user` AS v ON c.`update_iduser`=v.`iduser` - WHERE c.`lastname` LIKE sSearch - ORDER BY c.`lastname`) AS t - WHERE t.RowNumber > iOffset - AND t.RowNumber <= (iOffset + iLimit); - END; - ELSE - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT t.`contact_id`,t.`contact_lastname` - ,t.`contact_firstname`,t.`contact_tel` - ,t.`contact_email`,t.`contact_address` - ,t.`contact_addressmore`,t.`contact_addresscity` - ,t.`contact_addresszip`,t.`contact_comment` - ,t.`creation_date`,t.`creation_username` - ,t.`update_date`,t.`update_username` - FROM ( SELECT (@iRowNum:=@iRowNum+1) AS RowNumber - ,c.`idcontact` AS 'contact_id',c.`lastname` AS 'contact_lastname' - ,c.`firstname` AS 'contact_firstname',c.`tel` AS 'contact_tel' - ,c.`email` AS 'contact_email',c.`address` AS 'contact_address' - ,c.`address_more` AS 'contact_addressmore',c.`city` AS 'contact_addresscity' - ,c.`zip` AS 'contact_addresszip',c.`comment` AS 'contact_comment' - ,c.`create_date` AS 'creation_date',u.`login` AS 'creation_username' - ,c.`update_date` AS 'update_date',v.`login` AS 'update_username' - FROM `_PBR_DB_DBN_`.`contact` AS c - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON c.`create_iduser`=u.`iduser` - LEFT JOIN `_PBR_DB_DBN_`.`user` AS v ON c.`update_iduser`=v.`iduser` - ORDER BY c.`lastname`) AS t - WHERE t.RowNumber > iOffset - AND t.RowNumber <= (iOffset + iLimit); - END; - END IF; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactsgetcount.sql b/src/includes-install/database/sp_contactsgetcount.sql deleted file mode 100644 index b62d5d2..0000000 --- a/src/includes-install/database/sp_contactsgetcount.sql +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactsGetCount * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get contacts count. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sSearch: contact last name * - * * - * Returns: * - * ErrorCode: >=0 is OK. Number of row. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactsGetCount`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactsGetCount`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sSearch VARCHAR(40) ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactsGetCount'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sSearch,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sSearch=TRIM(sSearch); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - IF (sSearch IS NOT NULL) AND (LENGTH(sSearch)>0) THEN - BEGIN - -- Looking for -- - SET sErrorDescription = 'Looking for'; - SELECT COUNT(c.`idcontact`) INTO iErrorCode FROM `_PBR_DB_DBN_`.`contact` AS c WHERE c.`lastname` LIKE sSearch; - END; - ELSE - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT COUNT(c.`idcontact`) INTO iErrorCode FROM `_PBR_DB_DBN_`.`contact` AS c; - END; - END IF; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_contactupdate.sql b/src/includes-install/database/sp_contactupdate.sql deleted file mode 100644 index 478e9be..0000000 --- a/src/includes-install/database/sp_contactupdate.sql +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ContactUpdate * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Create a contact * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iIdentifier: contact identifier * - * sLastName: contact last name * - * sFirstName: contact first name * - * sTel: contact telephone * - * sEmail: contact email * - * sAddress: contact address * - * sAddressMore: contact address more * - * sCity: contact address city * - * sZip: contact address zip code * - * sComment: comment * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row updated. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ContactUpdate`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ContactUpdate`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED, IN sLastName VARCHAR(40), IN sFirstName VARCHAR(40), IN sTel VARCHAR(40), IN sEmail VARCHAR(255), IN sAddress VARCHAR(255), IN sAddressMore VARCHAR(255), IN sCity VARCHAR(255), IN sZip VARCHAR(8), IN sComment TEXT) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_ContactUpdate'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),',',IFNULL(sLastName,'NULL'),',',IFNULL(sFirstName,'NULL'),',',IFNULL(sTel,'NULL'),',...)'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sLastName=TRIM(sLastName); - SET sFirstName=TRIM(sFirstName); - SET sTel=TRIM(sTel); - SET sEmail=TRIM(sEmail); - SET sAddress=TRIM(sAddress); - SET sAddressMore=TRIM(sAddressMore); - SET sCity=TRIM(sCity); - SET sZip=TRIM(sZip); - SET sComment=TRIM(sComment); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iContact IS NOT NULL) AND (iContact>0) AND (sLastName IS NOT NULL) AND (LENGTH(sLastName)>0) AND (sFirstName IS NOT NULL) AND (LENGTH(sFirstName)>0) AND (sTel IS NOT NULL) AND (LENGTH(sTel)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Update -- - SET sErrorDescription = 'Update'; - UPDATE `_PBR_DB_DBN_`.`contact` SET `lastname`=sLastName, `firstname`=sFirstName, `tel`=sTel, `email`=sEmail, - `address`=sAddress, `address_more`=sAddressMore, `city`=sCity, `zip`=sZip, `comment`=sComment, `update_date`=SYSDATE(), `update_iduser`=iUser - WHERE `idcontact`=iContact; - SELECT ROW_COUNT() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_logsdel.sql b/src/includes-install/database/sp_logsdel.sql deleted file mode 100644 index 990a822..0000000 --- a/src/includes-install/database/sp_logsdel.sql +++ /dev/null @@ -1,127 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_LogsDel * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Delete logs * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row deleted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_LogsDel`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_LogsDel`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_LogsDel'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Delete -- - SET sErrorDescription = 'Delete'; - DELETE FROM `_PBR_DB_DBN_`.`log`; - SELECT ROW_COUNT() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_logsget.sql b/src/includes-install/database/sp_logsget.sql deleted file mode 100644 index 5d3fbf5..0000000 --- a/src/includes-install/database/sp_logsget.sql +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_LogsGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get log(s) * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iOffset: offset of the first row to return * - * iLimit: maximum number of rows to return * - * * - * NOTE: In MYSQL 5.x the LIMIT clause do not accept variables. * - * So we use a less performant request to simulate it. * - * This procedure should be updated for MYSQL > 6.0. * - * * - * Returns: * - * none, one or more records (log_date, log_user, log_type, * - * log_title, log_description, log_mysqluser, * - * log_mysqlcurrentuser) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_LogsGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_LogsGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iOffset MEDIUMINT UNSIGNED, IN iLimit MEDIUMINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_LogsGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iOffset,'NULL'),',',IFNULL(iLimit,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iOffset IS NOT NULL) AND (LENGTH(iOffset)>=0) AND (iLimit IS NOT NULL) AND (LENGTH(iLimit)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - SET @iRowNum:=0; - -- Select -- - SET sErrorDescription = 'Select'; - SELECT t.`logged` AS "log_date" - ,t.`username` AS "log_user" - ,t.`type` AS "log_type" - ,t.`title` AS "log_title" - ,t.`description` AS "log_description" - ,t.`mysqluser` AS "log_mysqluser" - ,t.`mysqlcurrentuser` AS "log_mysqlcurrentuser" - FROM ( SELECT (@iRowNum:=@iRowNum+1) AS RowNumber - ,l.`logged` - ,l.`username` - ,l.`type` - ,l.`title` - ,l.`description` - ,l.`mysqluser` - ,l.`mysqlcurrentuser` - FROM `log` l - ORDER BY l.`logged` DESC) AS t - WHERE t.RowNumber > iOffset - AND t.RowNumber <= (iOffset + iLimit); - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_logsgetcount.sql b/src/includes-install/database/sp_logsgetcount.sql deleted file mode 100644 index bed9167..0000000 --- a/src/includes-install/database/sp_logsgetcount.sql +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_LogsGetCount * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get logs count. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * ErrorCode: >=0 is OK. Number of row. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_LogsGetCount`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_LogsGetCount`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_LogsGetCount'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT COUNT(l.`idlog`) INTO iErrorCode FROM `_PBR_DB_DBN_`.`log` AS l; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_maxget.sql b/src/includes-install/database/sp_maxget.sql deleted file mode 100644 index 69b0bb0..0000000 --- a/src/includes-install/database/sp_maxget.sql +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_MaxGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get rent max per month * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * none, one or more records (month, max) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_MaxGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_MaxGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_MaxGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT c.`name` AS "month", c.`value` AS "max" FROM `_PBR_DB_DBN_`.`config` AS c WHERE c.`name` LIKE 'max_rent_%'; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_parameterget.sql b/src/includes-install/database/sp_parameterget.sql deleted file mode 100644 index 47ce238..0000000 --- a/src/includes-install/database/sp_parameterget.sql +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2009 JOT - PBRAIDERS.COM * - * Tous droits rservs - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_ParameterGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Return the max size group * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sMonth: rent month * - * * - * OUT iMax: max of the month * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_ParameterGet` $$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_ParameterGet`(IN sMonth VARCHAR(2), OUT iMax INTEGER) -BEGIN - SELECT IFNULL(c.`value`,0) INTO iMax - FROM `_PBR_DB_DBN_`.`config` AS c - WHERE c.`name` LIKE CONCAT_WS('_','max_rent',sMonth); -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentcontactset.sql b/src/includes-install/database/sp_rentcontactset.sql deleted file mode 100644 index 425d7d8..0000000 --- a/src/includes-install/database/sp_rentcontactset.sql +++ /dev/null @@ -1,213 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentContactSet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Create a contact and a rent * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sLastName: contact last name * - * sFirstName: contact first name * - * sTel: contact telephone * - * sEmail: contact email * - * sAddress: contact address * - * sAddressMore: contact address more * - * sCity: contact address city * - * sZip: contact address zip code * - * iReal: group real count * - * iPlanned: group planned count * - * iCanceled: group canceled count * - * iAge: group age * - * iArrhes: rent arrhes * - * iDay: rent day * - * iMonth: rent month * - * iYear: rent year * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentContactSet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentContactSet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sLastName VARCHAR(40), IN sFirstName VARCHAR(40), IN sTel VARCHAR(40), IN sEmail VARCHAR(255), IN sAddress VARCHAR(255), IN sAddressMore VARCHAR(255), IN sCity VARCHAR(255), IN sZip VARCHAR(8), IN iReal SMALLINT UNSIGNED,IN iPlanned SMALLINT UNSIGNED,IN iCanceled SMALLINT UNSIGNED,IN iAge TINYINT UNSIGNED,IN iArrhes TINYINT UNSIGNED,IN iDay TINYINT UNSIGNED, IN iMonth TINYINT UNSIGNED,IN iYear SMALLINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentContactSet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - DECLARE iContact MEDIUMINT UNSIGNED DEFAULT 0; - DECLARE bInTransaction TINYINT(1) DEFAULT 0; - DECLARE iMaxRent INTEGER UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An SQLEXCEPTION occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -1; - SELECT iErrorCode AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sLastName,'NULL'),',',IFNULL(sFirstName,'NULL'),',',IFNULL(sTel,'NULL'),',',IFNULL(iDay,'NULL'),',',IFNULL(iMonth,'NULL'),',',IFNULL(iYear,'NULL'),',...)'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sLastName=TRIM(sLastName); - SET sFirstName=TRIM(sFirstName); - SET sTel=TRIM(sTel); - SET sEmail=TRIM(sEmail); - SET sAddress=TRIM(sAddress); - SET sAddressMore=TRIM(sAddressMore); - SET sCity=TRIM(sCity); - SET sZip=TRIM(sZip); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (sLastName IS NOT NULL) AND (LENGTH(sLastName)>0) AND (sFirstName IS NOT NULL) AND (LENGTH(sFirstName)>0) AND (sTel IS NOT NULL) AND (LENGTH(sTel)>0) AND (iReal IS NOT NULL) AND (iPlanned IS NOT NULL) AND (iCanceled IS NOT NULL) AND (iDay IS NOT NULL) AND (iDay>0) AND (iDay<32) AND (iMonth IS NOT NULL) AND (iMonth>0) AND (iMonth<13) AND (iYear IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select default max rent -- - SET sErrorDescription = 'Select max rent'; - SELECT IFNULL(MAX(r.`rent_max`),0) INTO iMaxRent - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`year`=iYear - AND r.`month`=iMonth - AND r.`day`=iDay; - IF iMaxRent<=0 THEN - BEGIN - -- Select default max rent -- - SET sErrorDescription = 'Select default max rent'; - CALL sp_ParameterGet(iMonth,iMaxRent); - END; - END IF; - -- Start transaction -- - SET sErrorDescription = 'Start transaction'; - START TRANSACTION; - SET bInTransaction = 1; - -- Insert Contact -- - SET sErrorDescription = 'Insert contact'; - INSERT INTO `_PBR_DB_DBN_`.`contact`(`lastname`, `firstname`, `tel`, `email`, `address`, `address_more`, `city`, `zip`, `create_date`, `create_iduser`, `update_date`, `update_iduser`) - VALUES (sLastName, sFirstName, sTel, sEmail, sAddress, sAddressMore, sCity, sZip, SYSDATE(), iUser, NULL, NULL); - SELECT LAST_INSERT_ID() INTO iContact; - -- Insert Rent -- - IF iContact>0 THEN - BEGIN - SET sErrorDescription = 'Insert rent'; - INSERT INTO `_PBR_DB_DBN_`.`reservation` (`idcontact`,`year`,`month`,`day`,`rent_real`,`rent_planned`,`rent_canceled`,`rent_max`,`age`,`arrhe`,`create_date`,`create_iduser`,`update_date`,`update_iduser`) - VALUES (iContact, iYear, iMonth, iDay, iReal, iPlanned, iCanceled, iMaxRent, iAge, iArrhes, SYSDATE(), iUser, NULL, NULL); - SELECT LAST_INSERT_ID() INTO iErrorCode; - END; - END IF; - -- Stop transaction -- - IF iErrorCode>0 THEN - BEGIN - -- No error -- - SET sErrorDescription = 'COMMIT transaction'; - COMMIT; - END; - ELSE - BEGIN - -- Error -- - SET sErrorDescription = 'ROLLBACK transaction'; - ROLLBACK; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('TRANSACTION',sErrorTitle), CONCAT('An error occures while processing "','adding contact and rent','" step. Exit'),USER(),CURRENT_USER() ); - END; - END IF; - SET bInTransaction = 0; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentdel.sql b/src/includes-install/database/sp_rentdel.sql deleted file mode 100644 index bfd735c..0000000 --- a/src/includes-install/database/sp_rentdel.sql +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentDel * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Delete a rent * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iRent: rent identifier * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row deleted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentDel`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentDel`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iRent MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentDel'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iRent,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iRent IS NOT NULL) AND (iRent>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Delete -- - SET sErrorDescription = 'Delete'; - DELETE FROM `_PBR_DB_DBN_`.`reservation` WHERE `idreservation`=iRent; - SELECT ROW_COUNT() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentget.sql b/src/includes-install/database/sp_rentget.sql deleted file mode 100644 index a0e61a0..0000000 --- a/src/includes-install/database/sp_rentget.sql +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get a rent * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iRent: rent identifier * - * * - * Returns: * - * none or one record (reservation_year, reservation_month, * - * reservation_day, reservation_real, reservation_planned, * - * reservation_canceled, reservation_max, reservation_age, * - * reservation_arrhes, reservation_comment, creation_date, * - * creation_username, update_date, update_username, * - * contact_lastname, contact_firstname, contact_tel, * - * contact_email,contact_address, contact_addressmore, * - * contact_addresscity, contact_addresszip, contact_id, * - * reservation_id) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iRent MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iRent,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iRent IS NOT NULL) AND (iRent>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Request'; - SELECT r.`idreservation` AS 'reservation_id' - , r.`year` AS 'reservation_year' - , r.`month` AS 'reservation_month' - , r.`day` AS 'reservation_day' - , r.`rent_real` AS 'reservation_real' - , r.`rent_planned` AS 'reservation_planned' - , r.`rent_canceled` AS 'reservation_canceled' - , r.`rent_max` AS 'reservation_max' - , r.`age` AS 'reservation_age' - , r.`arrhe` AS 'reservation_arrhes' - , r.`comment` AS 'reservation_comment' - , r.`create_date` AS 'creation_date' - , u.`login` AS 'creation_username' - , r.`update_date` AS 'update_date' - , v.`login` AS 'update_username' - , c.`lastname` AS 'contact_lastname' - , c.`firstname` AS 'contact_firstname' - , c.`tel` AS 'contact_tel' - , c.`email` AS 'contact_email' - , c.`address` AS 'contact_address' - , c.`address_more` AS 'contact_addressmore' - , c.`city` AS 'contact_addresscity' - , c.`zip` AS 'contact_addresszip' - , c.`idcontact` AS 'contact_id' - FROM `_PBR_DB_DBN_`.`reservation` AS r - INNER JOIN `_PBR_DB_DBN_`.`contact` AS c ON r.`idcontact`=c.`idcontact` - INNER JOIN `_PBR_DB_DBN_`.`user` AS u ON r.`create_iduser`=u.`iduser` - LEFT JOIN `_PBR_DB_DBN_`.`user` AS v ON r.`update_iduser`=v.`iduser` - WHERE r.`idreservation`=iRent; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentsdel.sql b/src/includes-install/database/sp_rentsdel.sql deleted file mode 100644 index 267d551..0000000 --- a/src/includes-install/database/sp_rentsdel.sql +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentsDel * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Delete old rents * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iYear: year * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row deleted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentsDel`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentsDel`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iYear SMALLINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentsDel'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iYear,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iYear IS NOT NULL) AND (iYear>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Delete -- - SET sErrorDescription = 'Delete'; - DELETE FROM `_PBR_DB_DBN_`.`reservation` WHERE `year`0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentSet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentSet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iContact MEDIUMINT UNSIGNED, IN iReal SMALLINT UNSIGNED,IN iPlanned SMALLINT UNSIGNED,IN iCanceled SMALLINT UNSIGNED,IN iAge TINYINT UNSIGNED,IN iArrhes TINYINT UNSIGNED,IN iDay TINYINT UNSIGNED, IN iMonth TINYINT UNSIGNED,IN iYear SMALLINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentSet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - DECLARE iMaxRent INTEGER UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iContact,'NULL'),',',IFNULL(iDay,'NULL'),',',IFNULL(iMonth,'NULL'),',',IFNULL(iYear,'NULL'),',...)'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iContact IS NOT NULL) AND (iContact>0) AND (iReal IS NOT NULL) AND (iPlanned IS NOT NULL) AND (iCanceled IS NOT NULL) AND (iDay IS NOT NULL) AND (iDay>0) AND (iDay<32) AND (iMonth IS NOT NULL) AND (iMonth>0) AND (iMonth<13) AND (iYear IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select max rent -- - SET sErrorDescription = 'Select max rent'; - SELECT IFNULL(MAX(r.`rent_max`),0) INTO iMaxRent - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`year`=iYear - AND r.`month`=iMonth - AND r.`day`=iDay; - IF iMaxRent<=0 THEN - BEGIN - -- Select default max rent -- - SET sErrorDescription = 'Select default max rent'; - CALL sp_ParameterGet(iMonth,iMaxRent); - END; - END IF; - -- Insert Rent -- - SET sErrorDescription = 'Insert rent'; - INSERT INTO `_PBR_DB_DBN_`.`reservation` (`idcontact`,`year`,`month`,`day`,`rent_real`,`rent_planned`,`rent_canceled`,`rent_max`,`age`,`arrhe`,`create_date`,`create_iduser`,`update_date`,`update_iduser`) - VALUES (iContact, iYear, iMonth, iDay, iReal, iPlanned, iCanceled, iMaxRent, iAge, iArrhes, SYSDATE(), iUser, NULL, NULL); - SELECT LAST_INSERT_ID() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentsget.sql b/src/includes-install/database/sp_rentsget.sql deleted file mode 100644 index 3d65b2b..0000000 --- a/src/includes-install/database/sp_rentsget.sql +++ /dev/null @@ -1,183 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentsGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get rent(s) for a specific date * - * the first line (reservation_id=0) is the sum of real * - * planned and canceled rents + max of rents allowed * - * ( reservation_id=0 * - * reservation_real= * - * reservation_planned= * - * reservation_planned= * - * reservation_arrhes= ) * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iDay: requested day * - * iMonth: requested month * - * iYear: requested year * - * iOffset: offset of the first row to return * - * iLimit: maximum number of rows to return * - * * - * NOTE: In MYSQL 5.x the LIMIT clause do not accept variables. * - * So we use a less performant request to simulate it. * - * This procedure should be updated for MYSQL > 6.0. * - * * - * Returns: * - * none, one or more records (reservation_id,reservation_real * - * reservation_planned,reservation_canceled,reservation_arrhes, * - * contact_lastname,contact_firstname,contact_phone, * - * reservation_comment) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentsGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentsGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iDay TINYINT UNSIGNED, IN iMonth TINYINT UNSIGNED, IN iYear SMALLINT UNSIGNED, IN iOffset MEDIUMINT UNSIGNED, IN iLimit MEDIUMINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentsGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iDay,'NULL'),',',IFNULL(iMonth,'NULL'),',',IFNULL(iYear,'NULL'),',',IFNULL(iOffset,'NULL'),',',IFNULL(iLimit,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iDay IS NOT NULL) AND (iDay>0) AND (iDay<32) AND (iMonth IS NOT NULL) AND (iMonth>0) AND (iMonth<13) AND (iYear IS NOT NULL) AND (iOffset IS NOT NULL) AND (LENGTH(iOffset)>=0) AND (iLimit IS NOT NULL) AND (LENGTH(iLimit)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET @iRowNum:=0; - SET sErrorDescription = 'Select'; - SELECT 0 AS 'reservation_id' - , IFNULL(SUM(r.`rent_real`),0) AS 'reservation_real' - , IFNULL(SUM(r.`rent_planned`),0) AS 'reservation_planned' - , IFNULL(SUM(r.`rent_canceled`),0) AS 'reservation_canceled' - , IFNULL(MAX(r.`rent_max`),0) AS 'reservation_arrhes' - , NULL AS 'contact_lastname' - , NULL AS 'contact_firstname' - , NULL AS 'contact_phone' - , NULL AS 'reservation_comment' - FROM `_PBR_DB_DBN_`.`reservation` AS r - INNER JOIN `_PBR_DB_DBN_`.`contact` AS c ON r.`idcontact`=c.`idcontact` - WHERE r.`year`=iYear - AND r.`month`=iMonth - AND r.`day`=iDay - UNION - SELECT t.`reservation_id` - , t.`reservation_real` - , t.`reservation_planned` - , t.`reservation_canceled` - , t.`reservation_arrhes` - , t.`contact_lastname` - , t.`contact_firstname` - , t.`contact_phone` - , t.`reservation_comment` - FROM ( SELECT (@iRowNum:=@iRowNum+1) AS RowNumber - , r.`idreservation` AS 'reservation_id' - , r.`rent_real` AS 'reservation_real' - , r.`rent_planned` AS 'reservation_planned' - , r.`rent_canceled` AS 'reservation_canceled' - , r.`arrhe` AS 'reservation_arrhes' - , c.`lastname` AS 'contact_lastname' - , c.`firstname` AS 'contact_firstname' - , c.`tel` AS 'contact_phone' - , r.`comment` AS 'reservation_comment' - FROM `_PBR_DB_DBN_`.`reservation` AS r - INNER JOIN `_PBR_DB_DBN_`.`contact` AS c ON r.`idcontact`=c.`idcontact` - WHERE r.`year`=iYear - AND r.`month`=iMonth - AND r.`day`=iDay) AS t - WHERE t.RowNumber > iOffset - AND t.RowNumber <= (iOffset + iLimit); - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentsgetcount.sql b/src/includes-install/database/sp_rentsgetcount.sql deleted file mode 100644 index 2220b70..0000000 --- a/src/includes-install/database/sp_rentsgetcount.sql +++ /dev/null @@ -1,133 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentsGetCount * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get rents count for a specific date * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iDay: requested day * - * iMonth: requested month * - * iYear: requested year * - * * - * Returns: * - * ErrorCode: >=0 is OK. Number of row. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentsGetCount`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentsGetCount`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iDay TINYINT UNSIGNED, IN iMonth TINYINT UNSIGNED, IN iYear SMALLINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentsGetCount'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iDay,'NULL'),',',IFNULL(iMonth,'NULL'),',',IFNULL(iYear,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iDay IS NOT NULL) AND (iDay>0) AND (iDay<32) AND (iMonth IS NOT NULL) AND (iMonth>0) AND (iMonth<13) AND (iYear IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT COUNT(r.`idreservation`) INTO iErrorCode - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`year`=iYear - AND r.`month`=iMonth - AND r.`day`=iDay; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentsmonthget.sql b/src/includes-install/database/sp_rentsmonthget.sql deleted file mode 100644 index ad109f4..0000000 --- a/src/includes-install/database/sp_rentsmonthget.sql +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentsMonthGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get real, planned, canceled sum rents and maximum rents * - * for a specific year and month. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iMonth: requested month * - * iYear: requested year * - * * - * Returns: * - * none, one or more records (day,real,planned,canceled,max) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentsMonthGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentsMonthGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iMonth TINYINT UNSIGNED, IN iYear SMALLINT UNSIGNED ) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentsMonthGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iMonth,'NULL'),',',IFNULL(iYear,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iMonth IS NOT NULL) AND (iMonth>0) AND (iMonth<13) AND (iYear IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT r.`day` AS 'day' - , IFNULL(SUM(r.`rent_real`),0) AS 'real' - , IFNULL(SUM(r.`rent_planned`),0) AS 'planned' - , IFNULL(SUM(r.`rent_canceled`),0) AS 'canceled' - , IFNULL(MAX(r.`rent_max`),0) AS 'max' - FROM `_PBR_DB_DBN_`.`reservation` AS r - WHERE r.`year`=iYear - AND r.`month`=iMonth - GROUP BY r.`day`; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_rentupdate.sql b/src/includes-install/database/sp_rentupdate.sql deleted file mode 100644 index 4565900..0000000 --- a/src/includes-install/database/sp_rentupdate.sql +++ /dev/null @@ -1,176 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_RentUpdate * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Update a rent * -* COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iIdentifier: rent identifier * - * iReal: real count * - * iPlanned: planned count * - * iCanceled: canceled count * - * iMax: max count for the day * - * iAge: group age * - * iArrhes: rent arrhes * - * sComment: comment * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row updated. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_RentUpdate`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_RentUpdate`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iRent MEDIUMINT UNSIGNED, IN iReal SMALLINT UNSIGNED,IN iPlanned SMALLINT UNSIGNED,IN iCanceled SMALLINT UNSIGNED,IN iMax SMALLINT UNSIGNED,IN iAge TINYINT UNSIGNED,IN iArrhes TINYINT UNSIGNED, IN sComment TEXT) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_RentUpdate'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - DECLARE bInTransaction TINYINT(1) DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - IF 1=bInTransaction THEN - ROLLBACK; - END IF; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An SQLEXCEPTION occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -1; - SELECT iErrorCode AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iRent,'NULL'),',',IFNULL(iReal,'NULL'),',',IFNULL(iPlanned,'NULL'),',',IFNULL(iCanceled,'NULL'),',',IFNULL(iMax,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sComment=TRIM(sComment); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iRent IS NOT NULL) AND (iRent>0) AND (iReal IS NOT NULL) AND (iPlanned IS NOT NULL) AND (iCanceled IS NOT NULL) AND (iMax IS NOT NULL) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 1, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Start transaction -- - SET sErrorDescription = 'Start transaction'; - START TRANSACTION; - SET bInTransaction = 1; - -- Update max -- - SET sErrorDescription = 'Update max'; - UPDATE `_PBR_DB_DBN_`.`reservation` AS r INNER JOIN `_PBR_DB_DBN_`.`reservation` AS s USING(`year`,`month`,`day`) SET r.`rent_max`=iMax WHERE s.`idreservation`=iRent; - -- Update rent -- - SET sErrorDescription = 'Update rent'; - UPDATE `_PBR_DB_DBN_`.`reservation` SET `rent_real`=iReal, `rent_planned`=iPlanned, `rent_canceled`=iCanceled, `age`=iAge, `arrhe`=iArrhes, `comment`=sComment, `update_date`=SYSDATE(), `update_iduser`=iUser - WHERE `idreservation`=iRent; - SELECT ROW_COUNT() INTO iErrorCode; - -- Stop transaction -- - IF iErrorCode>0 THEN - BEGIN - -- No error -- - SET sErrorDescription = 'COMMIT transaction'; - COMMIT; - END; - ELSE - BEGIN - -- Error -- - SET sErrorDescription = 'ROLLBACK transaction'; - ROLLBACK; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('TRANSACTION',sErrorTitle), CONCAT('An error occures while processing "','updating rent','" step. Exit'),USER(),CURRENT_USER() ); - END; - END IF; - SET bInTransaction = 0; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_sessiondelete.sql b/src/includes-install/database/sp_sessiondelete.sql deleted file mode 100644 index 68003ec..0000000 --- a/src/includes-install/database/sp_sessiondelete.sql +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_SessionDelete * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Mark as delete or really delete all expired sessions. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row deleted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_SessionDelete` $$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_SessionDelete`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iCount TINYINT(1) DEFAULT 0; - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_SessionDelete'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -4; - SELECT iErrorCode AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -3; - SELECT iErrorCode AS 'ErrorCode'; - END; - DECLARE CONTINUE HANDLER FOR NOT FOUND - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('NOTFOUND',sErrorTitle), CONCAT('A not found warning occures while processing "',sErrorDescription,'" step. Continue.'),USER(),CURRENT_USER() ); - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - -- ------------------- -- - -- Delete old sessions -- - -- ------------------- -- - SET sErrorDescription = 'Delete old sessions'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - DELETE FROM `_PBR_DB_DBN_`.`session` WHERE `logoff`>0; - SELECT ROW_COUNT() INTO iCount; - END; - END IF; - -- ----------------------- -- - -- Delete expired sessions -- - -- ----------------------- -- - SET sErrorDescription = 'Delete expired sessions'; - UPDATE `_PBR_DB_DBN_`.`session` AS s SET s.`logoff`=1 WHERE s.`expire_date` < UNIX_TIMESTAMP(); - SELECT ROW_COUNT() INTO iErrorCode; - SET iErrorCode=iErrorCode+iCount; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_sessionlogoff.sql b/src/includes-install/database/sp_sessionlogoff.sql deleted file mode 100644 index 5b12e76..0000000 --- a/src/includes-install/database/sp_sessionlogoff.sql +++ /dev/null @@ -1,117 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_SessionLogOff * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Close a session. * - * ASSUME: The columns of the tables are case insentive. * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row updated. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_SessionLogOff` $$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_SessionLogOff`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_SessionLogOff'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -4; - SELECT iErrorCode AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -3; - SELECT iErrorCode AS 'ErrorCode'; - END; - DECLARE CONTINUE HANDLER FOR NOT FOUND - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('NOTFOUND',sErrorTitle), CONCAT('A not found warning occures while processing "',sErrorDescription,'" step. Continue.'),USER(),CURRENT_USER() ); - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - -- ----------------------- -- - -- Delete expired sessions -- - -- ----------------------- -- - CALL sp_SessionValid(sLogin, sSession, 0, sInet, iUser); - IF (iUser>0) THEN - BEGIN - SET sErrorDescription = 'Close the session'; - UPDATE `_PBR_DB_DBN_`.`session` AS s SET s.`logoff`=1 WHERE s.`login` = sLogin; - SELECT ROW_COUNT() INTO iErrorCode; - END; - ELSE - BEGIN - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed or already disconnected.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_sessionset.sql b/src/includes-install/database/sp_sessionset.sql deleted file mode 100644 index 44815d3..0000000 --- a/src/includes-install/database/sp_sessionset.sql +++ /dev/null @@ -1,142 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_SessionSet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Create a session if the login and password are * - * valid. * - * ASSUME: The columns of the tables are case insentive. * - * Except user.password * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sPassword: password * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_SessionSet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_SessionSet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sPassword VARCHAR(40), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode TINYINT(1) DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_SessionSet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iSessionTimeExpire INTEGER UNSIGNED DEFAULT 3600; - DECLARE iUnixTimestamp INTEGER UNSIGNED DEFAULT 0; - DECLARE iUserId INTEGER UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -4; - SELECT iErrorCode AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iErrorCode = -3; - SELECT iErrorCode AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sPassword,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check user'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sPassword = TRIM(sPassword); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sPassword IS NOT NULL) AND (LENGTH(sPassword)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Check user -- - SELECT u.`iduser` INTO iUserId FROM `_PBR_DB_DBN_`.`user`AS u WHERE u.`login` = sLogin AND u.`state`=1 AND u.`password`=sPassword; - IF (iUserId IS NOT NULL) AND (iUserId>0) THEN - BEGIN - -- Get config values -- - SET sErrorDescription = 'Get config values'; - SELECT CONVERT(c.`value`, UNSIGNED INTEGER) INTO iSessionTimeExpire FROM `_PBR_DB_DBN_`.`config` AS c WHERE c.`name` LIKE 'session_time_expire'; - SELECT CONVERT( UNIX_TIMESTAMP(), UNSIGNED INTEGER) INTO iUnixTimestamp; - -- Insert session -- - SET sErrorDescription = 'Insert session'; - REPLACE INTO `_PBR_DB_DBN_`.`session` (`login`,`session`,`create_date`,`expire_date`,`logoff`,`inet`) - VALUES ( sLogin, sSession, iUnixTimestamp, iUnixTimestamp+iSessionTimeExpire, 0, CRC32(sInet) ); - SELECT ROW_COUNT() INTO iErrorCode; - -- Update user -- - SET sErrorDescription = 'Update user'; - UPDATE `_PBR_DB_DBN_`.`user` SET `last_visit`=SYSDATE() WHERE `iduser`=iUserId; - SELECT ROW_COUNT()+iErrorCode INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode = -2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('USER CHECK',sErrorTitle), 'Unknown or not active user.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_sessionvalid.sql b/src/includes-install/database/sp_sessionvalid.sql deleted file mode 100644 index 598a533..0000000 --- a/src/includes-install/database/sp_sessionvalid.sql +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2009 JOT - PBRAIDERS.COM * - * Tous droits rservs - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_SessionValid * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Check if the session is valid and return user * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * iRole: minimum role level * - * sInet: concatenation of IP and USER_AGENT * - * * - * OUT iUser: >0 if the session is valid * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_SessionValid` $$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_SessionValid`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN iRole TINYINT(1) UNSIGNED, IN sInet VARCHAR(255), OUT iUser SMALLINT(5) UNSIGNED) -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_SessionValid'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUnixTimestamp INTEGER UNSIGNED DEFAULT 0; - DECLARE iCRC32 INTEGER UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iUser=0; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SET iUser=0; - END; - DECLARE CONTINUE HANDLER FOR NOT FOUND - BEGIN - SET iUser=0; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SELECT CONVERT( UNIX_TIMESTAMP(), UNSIGNED INTEGER) INTO iUnixTimestamp; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET iUser=0; - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (iRole IS NOT NULL) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- CRC32 -- - SET sErrorDescription = 'CRC32'; - SELECT CRC32(sInet) INTO iCRC32; - -- Request -- - SET sErrorDescription = 'SELECT'; - SELECT IFNULL(u.`iduser`,0) INTO iUser - FROM `_PBR_DB_DBN_`.`user` AS u - INNER JOIN `_PBR_DB_DBN_`.`session` AS s ON u.`login` = s.`login` AND s.`logoff`=0 AND s.`session`=sSession AND s.`inet`=iCRC32 - WHERE u.`login`=sLogin - AND s.`expire_date` >= iUnixTimestamp - AND u.`role`>=iRole - AND u.`state` = 1; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_userget.sql b/src/includes-install/database/sp_userget.sql deleted file mode 100644 index e9d8881..0000000 --- a/src/includes-install/database/sp_userget.sql +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_UserGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get an user * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iIdentifier: user identifier * - * * - * Returns: * - * none or one record (user_id, user_name, user_state) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_UserGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_UserGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iIdentifier SMALLINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_UserGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iIdentifier,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iIdentifier IS NOT NULL) AND (iIdentifier>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT u.`iduser` AS "user_id", u.`login` AS "user_name", u.`state` AS "user_state" FROM `_PBR_DB_DBN_`.`user` AS u WHERE u.`iduser`=iIdentifier; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_userset.sql b/src/includes-install/database/sp_userset.sql deleted file mode 100644 index 16e491e..0000000 --- a/src/includes-install/database/sp_userset.sql +++ /dev/null @@ -1,131 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 JOT - PBRAIDERS.COM * - * Tous droits rservs - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_UserSet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Add an user. * - * COPYRIGHT : JOT, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * sNewLogin: user login * - * sNewPassword: user password * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_UserSet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_UserSet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN sNewLogin VARCHAR(45), IN sNewPassword VARCHAR(40)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_UserSet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(sNewLogin,'NULL'),',',IFNULL(sNewPassword,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sNewLogin = TRIM(sNewLogin); - SET sNewPassword = TRIM(sNewPassword); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (sNewLogin IS NOT NULL) AND (LENGTH(sNewLogin)>0) AND (sNewPassword IS NOT NULL) AND (LENGTH(sNewPassword)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Insert user -- - SET sErrorDescription = 'Insert user'; - INSERT INTO `_PBR_DB_DBN_`.`user` (`login`, `password`, `registered`, `role`, `last_visit`, `state`) VALUES ( sNewLogin, sNewPassword, SYSDATE(), 1, NULL, 1); - SELECT LAST_INSERT_ID() INTO iErrorCode; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_usersget.sql b/src/includes-install/database/sp_usersget.sql deleted file mode 100644 index 1202b80..0000000 --- a/src/includes-install/database/sp_usersget.sql +++ /dev/null @@ -1,124 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 Olivier JULLIEN - PBRAIDERS.COM * - * Tous droits reserves - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_UsersGet * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Get User(s) * - * COPYRIGHT : Olivier JULLIEN, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * * - * Returns: * - * none, one or more records (user_id, user_name, user_lastvisit,* - * user_state) * - * or * - * ErrorCode: -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_UsersGet`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_UsersGet`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255)) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_UsersGet'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Select -- - SET sErrorDescription = 'Select'; - SELECT u.`iduser` AS "user_id", u.`login` AS "user_name", u.`last_visit` AS "user_lastvisit", u.`state` AS "user_state" FROM `_PBR_DB_DBN_`.`user` AS u ORDER BY u.`login`; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - SELECT -2 AS 'ErrorCode'; - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - SELECT -1 AS 'ErrorCode'; - END; - END IF; -END $$ - -DELIMITER ; diff --git a/src/includes-install/database/sp_userupdate.sql b/src/includes-install/database/sp_userupdate.sql deleted file mode 100644 index c782a2c..0000000 --- a/src/includes-install/database/sp_userupdate.sql +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************************* - * * - * Copyright (C) 2010 JOT - PBRAIDERS.COM * - * Tous droits rservs - All rights reserved * - * * - ************************************************************************* - * * - * Except if expressly provided in a dedicated License Agreement, you * - * are not authorized to: * - * * - * 1. Use, copy, modify or transfer this software component, module or * - * product, including any accompanying electronic or paper documentation * - * (together, the "Software"),. * - * * - * 2. Remove any product identification, copyright, proprietary notices * - * or labels from the Software. * - * * - * 3. Modify, reverse engineer, decompile, disassemble or otherwise * - * attempt to reconstruct or discover the source code, or any parts of * - * it, from the binaries of the Software. * - * * - * 4. Create derivative works based on the Software (e.g. incorporating * - * the Software in another software or commercial product or service * - * without a proper license). * - * * - * By installing or using the "Software", you confirm your acceptance * - * of the hereabove terms and conditions. * - * * - *************************************************************************/ - -USE `_PBR_DB_DBN_`; -DELIMITER $$ - -/************************************************************************* - * PBRAIDERS.COM * - * TITLE : sp_UserUpdate * - * AUTHOR : O.JULLIEN * - * CREATION : 04/02/2010 * - * DESCRIPTION: Update an user. * - * COPYRIGHT : JOT, All rights reserved * - ************************************************************************* - * Parameters: * - * IN sLogin: login identifier * - * sSession: session identifier * - * sInet: concatenation of IP and USER_AGENT * - * iIdentifier: user identifier * - * sNewPassword: user password * - * iState: user enable * - * * - * Returns: * - * ErrorCode: >0 is OK. Number of row inserted. * - * -1 when a private error occures * - * -2 when an authentication error occures * - * -3 when an access denied error occures * - * -4 when a duplicate error occures * - ************************************************************************* - * Date * Author * Changes * - ************************************************************************* - * 04/02/2010 * O.JULLIEN * Creation * - *************************************************************************/ -DROP PROCEDURE IF EXISTS `_PBR_DB_DBN_`.`sp_UserUpdate`$$ -CREATE PROCEDURE `_PBR_DB_DBN_`.`sp_UserUpdate`(IN sLogin VARCHAR(45), IN sSession VARCHAR(200), IN sInet VARCHAR(255), IN iIdentifier SMALLINT UNSIGNED, IN sNewPassword VARCHAR(40), IN iState TINYINT UNSIGNED) - SQL SECURITY INVOKER -BEGIN - -- ------ -- - -- Define -- - -- ------ -- - DECLARE iErrorCode INTEGER DEFAULT -1; - DECLARE sErrorUsername VARCHAR(25) DEFAULT 'UNKNOWN'; - DECLARE sErrorTitle TEXT DEFAULT ' IN sp_UserUpdate'; - DECLARE sErrorDescription TEXT DEFAULT ''; - DECLARE iUser SMALLINT UNSIGNED DEFAULT 0; - -- --------------------- -- - -- Define Error Handlers -- - -- --------------------- -- - DECLARE EXIT HANDLER FOR 1061, 1062 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ER_DUP_ occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -4 AS 'ErrorCode'; - END; - DECLARE EXIT HANDLER FOR 1141, 1142, 1143, 1370 - BEGIN - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('SQLEXCEPTION',sErrorTitle), CONCAT('An ACCESS_DENIED occures while processing "',sErrorDescription,'" step. Exit'),USER(),CURRENT_USER() ); - SELECT -3 AS 'ErrorCode'; - END; - -- ---------- -- - -- Initialize -- - -- ---------- -- - SET sErrorUsername = IFNULL(sLogin,'NULL'); - SET sErrorTitle = CONCAT(sErrorTitle,'(',IFNULL(sLogin,'NULL'),',',IFNULL(sSession,'NULL'),',',IFNULL(sInet,'NULL'),',',IFNULL(iIdentifier,'NULL'),',',IFNULL(sNewPassword,'NULL'),',',IFNULL(iState,'NULL'),')'); - SET sErrorDescription = 'Check parameters'; - SET sLogin = TRIM(sLogin); - SET sSession = TRIM(sSession); - SET sInet=TRIM(sInet); - SET sNewPassword = TRIM(sNewPassword); - -- ------- -- - -- Request -- - -- ------- -- - IF (sLogin IS NOT NULL) AND (LENGTH(sLogin)>0) AND (sSession IS NOT NULL) AND (LENGTH(sSession)>0) AND (sInet IS NOT NULL) AND (LENGTH(sInet)>0) AND (iIdentifier IS NOT NULL) AND (iIdentifier>0) THEN - BEGIN - -- Authentication -- - SET sErrorDescription = 'Check authentication'; - CALL sp_SessionValid(sLogin, sSession, 10, sInet, iUser); - IF (iUser>0) THEN - BEGIN - -- Update password -- - IF (sNewPassword IS NOT NULL) AND (LENGTH(sNewPassword)>0) THEN - BEGIN - SET sErrorDescription = 'Update password'; - UPDATE `_PBR_DB_DBN_`.`user` SET `password`=sNewPassword WHERE `iduser`=iIdentifier; - SELECT ROW_COUNT() INTO iErrorCode; - END; - END IF; - -- Update state -- - IF (iState IS NOT NULL) AND (iState>=0) AND (iState<2) THEN - BEGIN - SET sErrorDescription = 'Update stat'; - UPDATE `_PBR_DB_DBN_`.`user` SET `state`=iState WHERE `iduser`=iIdentifier; - SELECT ROW_COUNT()+iErrorCode INTO iErrorCode; - END; - END IF; - END; - ELSE - BEGIN - -- User, session and/or inet is/are not valid -- - SET iErrorCode=-2; - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'WARNING', CONCAT('SESSION CHECK',sErrorTitle), 'Not allowed.',USER(),CURRENT_USER() ); - END; - END IF; - END; - ELSE - BEGIN - -- Parameters are not valid -- - INSERT INTO `_PBR_DB_DBN_`.`log`(`logged`,`username`,`type`,`title`,`description`,`mysqluser`,`mysqlcurrentuser`) VALUES (SYSDATE(), sErrorUsername, 'ERROR', CONCAT('PARAMETER CHECK',sErrorTitle), 'Bad parameters.',USER(),CURRENT_USER() ); - END; - END IF; - -- ------ -- - -- Return -- - -- ------ -- - SELECT iErrorCode AS 'ErrorCode'; -END $$ - -DELIMITER ; diff --git a/src/includes-install/displayinstall.php b/src/includes-install/displayinstall.php index 7668e46..7be042a 100644 --- a/src/includes-install/displayinstall.php +++ b/src/includes-install/displayinstall.php @@ -57,7 +57,7 @@ function BuildMessage($iCode) } elseif($iCode===2) { - $sBuffer.='

PBRaiders est déjà installée. Si vous souhaitez la re-installer, vous devez d’abord la détruire.

'; + $sBuffer.='

L'application PBRaiders est déjà installée. Si vous souhaitez la re-installer, vous devez d’abord détruire la base de données, effacer le dossier qui contient l'application puis suivre les instructions du fichier lisezmoi.txt.

'; } elseif($iCode===3) { @@ -65,7 +65,7 @@ function BuildMessage($iCode) } elseif($iCode===4) { - $sBuffer.='

Le nom d'utilisateur ou le mot de passe que vous avez saisi est incorrect.

'; + $sBuffer.='

Le nom d'utilisateur ou les mots de passe que vous avez saisis sont incorrects.

'; } elseif($iCode===0) { @@ -102,7 +102,9 @@ function BuildMessage($iCode)
  • Nom
  • Mot de passe
  • -
  • +
  • +
  • Confirmer
  • +
  • diff --git a/src/includes-install/init.php b/src/includes-install/init.php new file mode 100644 index 0000000..8718310 --- /dev/null +++ b/src/includes-install/init.php @@ -0,0 +1,121 @@ +0) && ($sBuffer!='0') ) + { + // register globals is ON + // Variables that shouldn't be unset + $tNoUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'); + // Merge All + $tAll = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES + , isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); + // Parse All + foreach( $tAll as $sKey=>$sValue ) + { + // Unset duplicate GLOBALS param + if( !in_array($sKey, $tNoUnset) && isset($GLOBALS[$sKey]) ) + { + $GLOBALS[$sKey] = NULL; + unset($GLOBALS[$sKey]); + // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP <4.4.3 and <5.1.4 + unset($GLOBALS[$sKey]); + }//if( !in_array($sKey, $tNoUnset) && isset($GLOBALS[$sKey]) ) + }// foreach( $tAll as $sKey=>$sValue ) + }// if( isset($sBuffer) && ($sBuffer!=FALSE) && (strlen($sBuffer)>0) && ($sBuffer!='0') ) + unset($sBuffer); + unset($tNoUnset); + + /** Disable magic quotes + ***********************/ + $sPHPVersion=phpversion(); + $sPHPVersionRequired='5.3'; + if( (version_compare( $sPHPVersion, $sPHPVersionRequired, '<')) && (get_magic_quotes_runtime()==1) ) + { + set_magic_quotes_runtime(0); + }//if( (version_compare( $sPHPVersion, $sPHPVersionRequired, '<')) && (get_magic_quotes_runtime()==1) ) + @ini_set('magic_quotes_sybase', 0); + + // Strip slashes from GET/POST + if ( get_magic_quotes_gpc() ) + { + $_GET = stripslashes_deep($_GET ); + $_POST = stripslashes_deep($_POST ); + }// if ( get_magic_quotes_gpc() ) + + /** Set error level + ******************/ + error_reporting(E_ALL); + + /** Error managment + ******************/ + define('PBR_LOG_DIR', 'log'); + require(PBR_PATH.'/includes/class/clog.php'); + require(PBR_PATH.'/includes/class/cerrorlist.php'); + require(PBR_PATH.'/includes/function/errors.php'); + + /** Validate user + *****************/ + require(PBR_PATH.'/includes/class/cuser.php'); + // Set username + CUser::GetInstance()->SetUsername('install'); + // Set session + CUser::GetInstance()->SetSession('2010'); + +?> diff --git a/src/includes-install/initdb.php b/src/includes-install/initdb.php index 50773b6..cdfb0bc 100644 --- a/src/includes-install/initdb.php +++ b/src/includes-install/initdb.php @@ -31,9 +31,9 @@ /************************************************************************* * file encoding: UTF-8 * description: validate initialize database connection - * author: Olivier JULLIEN - 2010-02-04 + * author: Olivier JULLIEN - 2010-05-24 *************************************************************************/ -if( !defined('PBR_VERSION') || !defined('PBR_PATH') || !defined('PBR_URL') || !defined('PBR_DB_DSN') || !defined('PBR_DB_USR') || !defined('PBR_DB_PWD') ) +if( !defined('PBR_VERSION') || !defined('PBR_PATH') || !defined('PBR_DB_DSN') || !defined('PBR_DB_USR') || !defined('PBR_DB_PWD') ) die('-1'); // Open database @@ -42,6 +42,8 @@ { // Error $iMessageCode=1; + $sTitle='fichier: '.basename(__FILE__).', ligne:'.__LINE__; + ErrorLog( 'install', $sTitle, 'impossible d\'ouvrir la base de données', E_USER_ERROR, FALSE); } else { @@ -66,6 +68,8 @@ } catch(PDOException $e) { +// $sTitle='fichier: '.basename(__FILE__).', ligne:'.__LINE__; +// ErrorLog( 'install', $sTitle, $e->getMessage(), E_USER_NOTICE, FALSE); $iMessageCode=0; }//try diff --git a/src/includes-install/installdb.php b/src/includes-install/installdb.php index 07bd34f..5b77714 100644 --- a/src/includes-install/installdb.php +++ b/src/includes-install/installdb.php @@ -191,77 +191,6 @@ function LoadData() return $bReturn; } -/** - * function: CreateStoredProc - * description: Create stored procedure - * parameters: none - * return: BOOLEAN - * author: Olivier JULLIEN - 2010-02-04 - */ -function CreateStoredProc() -{ - $bReturn=FALSE; - $sSQL=$sText=''; - $tFiles=array( - 'sp_parameterget' - ,'sp_sessionvalid' - ,'sp_configget' - ,'sp_configupdate' - ,'sp_contactdel' - ,'sp_contactget' - ,'sp_contactrentsget' - ,'sp_contactrentsgetcount' - ,'sp_contactset' - ,'sp_contactsget' - ,'sp_contactsgetcount' - ,'sp_contactupdate' - ,'sp_logsdel' - ,'sp_logsget' - ,'sp_logsgetcount' - ,'sp_maxget' - ,'sp_rentcontactset' - ,'sp_rentdel' - ,'sp_rentget' - ,'sp_rentsdel' - ,'sp_rentset' - ,'sp_rentsget' - ,'sp_rentsgetcount' - ,'sp_rentsmonthget' - ,'sp_rentupdate' - ,'sp_sessiondelete' - ,'sp_sessionlogoff' - ,'sp_sessionset' - ,'sp_userget' - ,'sp_userset' - ,'sp_usersget' - ,'sp_userupdate' - ); - // Read files - foreach( $tFiles as $sFile ) - { - // Read file - if( ReadSQLFile($sFile, $sText)==TRUE ) - { - // Sanitise text - $sSQL=str_replace('_PBR_DB_DBN_',PBR_DB_DBN,$sText); - $sSQL=str_replace('DELIMITER $$','',$sSQL); - $sSQL=str_replace('$$',';',$sSQL); - // Execute sql - $bReturn=ExecuteSQL($sSQL); - if( $bReturn===FALSE ) - { - break; - }// if( ExecuteSQL($sSQL)===FALSE ) - } - else - { - $bReturn=FALSE; - break; - }//if( ReadSQLFile('schema', $sSQL) ) - }//foreach( $tFiles as $sFile ) - return $bReturn; -} - ?> Suppression réussi.

    '; + $sBuffer.='

    Suppression réussie.

    '; } elseif($iCode===3) { @@ -136,7 +137,7 @@ function BuildMessage($iCode)
    Purge -

    Supprimer les réservations antérieures à:  

    +

    Supprimer les réservations antérieures à l'année:  

    diff --git a/src/includes/display/displayusers.php b/src/includes/display/displayusers.php index acedb9a..5f0c18f 100644 --- a/src/includes/display/displayusers.php +++ b/src/includes/display/displayusers.php @@ -35,6 +35,7 @@ * - $tRecordset * - CNewUser * author: Olivier JULLIEN - 2010-02-04 + * update: Olivier JULLIEN - 2010-06-11 - add password check *************************************************************************/ if ( !defined('PBR_VERSION') || !defined('PBR_URL') || !defined('PBR_NEWUSER_LOADED') ) die('-1'); @@ -53,7 +54,7 @@ function BuildMessage($iCode) $sBuffer='
    '; if( $iCode===1 ) { - $sBuffer.='

    Le nom d'utilisateur ou le mot de passe que vous avez saisi est incorrect.

    '; + $sBuffer.='

    Le nom d'utilisateur ou les mots de passe que vous avez saisis sont incorrects.

    '; } elseif($iCode===2) { @@ -116,7 +117,9 @@ function BuildUser(&$tRecord) $sFormHidden=''; $sFormHidden.=''; $sFormHidden.=''; - $sDisable='disabled="disabled"'; + // Build name label + $sDisable='disabled="disabled"'; + $sLabelName='Nom'; $sHelp=''; // Build state control $sState='
  • Actif
  • '; @@ -135,8 +138,11 @@ function BuildUser(&$tRecord) $sFormLegend='Nouvel utilisateur'; // Build hidden control $sFormHidden=''; + // Build name label $sDisable=''; - $sHelp='
  • Seuls les caractères alphanumériques, "@",".","-" et "_" sont autorisés.
  • '; + $sLabelName='Nom*'; + $sHelp='
  • * Seuls les caractères alphanumériques, "@",".","-" et "_" sont autorisés.
  • '; + // Build state control $sState=''; }//if( $sAction=='select' ) @@ -164,11 +170,13 @@ function BuildUser(&$tRecord)
      -
    • Nom
    • +
    • />
    • Mot de passe
    • +
    • Confirmez
    • +
    diff --git a/src/includes/function/functions.php b/src/includes/function/functions.php index cee2231..d26e797 100644 --- a/src/includes/function/functions.php +++ b/src/includes/function/functions.php @@ -35,6 +35,7 @@ * update: Olivier JULLIEN - 2010-05-24 - remove function: WriteTrace * remove function: TraceWarning * add new function: stripslashes_deep + * add new function: GetRegExPatternName *************************************************************************/ if( !defined('PBR_VERSION') ) die('-1'); @@ -193,4 +194,16 @@ function stripslashes_deep($value) return $value; } +/** + * function: GetRegExPatternName + * description: Return regex filter for input name + * parameters: none + * return: STRING + * author: Olivier JULLIEN - 2010-06-11 + */ +function GetRegExPatternName() +{ + return '/^[^\s'.preg_quote('!"#$%&()*+,/:;<=>?[\]^`{|}~','/').']+$/'; +} + ?> diff --git a/src/index.php b/src/index.php index 2d83a0e..b6cf2e7 100644 --- a/src/index.php +++ b/src/index.php @@ -39,7 +39,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/install.php b/src/install.php index 1ccf396..f3dd3a1 100644 --- a/src/install.php +++ b/src/install.php @@ -36,7 +36,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config @@ -49,16 +49,17 @@ /** Initialize *************/ - error_reporting(E_ALL); // Disable error reporting for uninitialized variables - @set_time_limit(0); // Turn off PHP time limit - $iMessageCode=0; + require(PBR_PATH.'/includes-install/init.php'); $sAction=NULL; - require(PBR_PATH.'/includes/class/cerrorlist.php'); - require(PBR_PATH.'/includes-install/initdb.php'); + $iMessageCode=0; /** Include main object(s) *************************/ - require(PBR_PATH.'/includes/class/cnewuser.php'); + require(PBR_PATH.'/includes-install/cnewuser.php'); + + /** Initialize database + **********************/ + require(PBR_PATH.'/includes-install/initdb.php'); /** Prerequiste test ******************/ @@ -69,6 +70,8 @@ if( !version_compare( $sPHPVersion, $sPHPVersionRequired, '>=') && !version_compare( $sMYSQLVersion, $sMYSQLVersionRequired, '>=') ) { + $sTitle='fichier: '.basename(__FILE__).', ligne:'.__LINE__; + ErrorLog( 'install', $sTitle, 'les versions ne sont pas valides', E_USER_ERROR, FALSE); $iMessageCode=3; }//if( !version_compare( $sPHPVersion, $sPHPVersionRequired, '>=') ) @@ -76,7 +79,8 @@ ************************/ if( filter_has_var(INPUT_POST, 'act') && filter_has_var(INPUT_POST, 'usr') - && filter_has_var(INPUT_POST, 'pwd') ) + && filter_has_var(INPUT_POST, 'pwd1') + && filter_has_var(INPUT_POST, 'pwd2') ) { // Get action $sAction = trim(filter_input( INPUT_POST, 'act', FILTER_SANITIZE_SPECIAL_CHARS)); @@ -86,6 +90,8 @@ if( ($sAction!='install') || (CNewUser::GetInstance()->IsValidNew()==FALSE) ) { // Parameters are not valid + $sTitle='fichier: '.basename(__FILE__).', ligne:'.__LINE__; + ErrorLog( 'install', $sTitle, 'les paramètres ne sont pas valides', E_USER_ERROR, FALSE); $iMessageCode=4; $sAction=NULL; }//if( ($sAction=='login') && ($sToken==CSession::GetToken()) ) @@ -95,8 +101,8 @@ ***************/ require(PBR_PATH.'/includes/class/cheader.php'); CHeader::GetInstance()->SetNoCache(); - CHeader::GetInstance()->SetTitle('Installation'); - CHeader::GetInstance()->SetDescription('Installation de PBRaiders'); + CHeader::GetInstance()->SetTitle('Installation de PBRaiders '.PBR_VERSION); + CHeader::GetInstance()->SetDescription('Installation de PBRaiders '.PBR_VERSION); CHeader::GetInstance()->SetKeywords('install,installation,installer'); /** Display or install @@ -119,5 +125,6 @@ CHeader::DeleteInstance(); if(defined('PBR_DB_LOADED')) CDb::DeleteInstance(); if(defined('PBR_NEWUSER_LOADED') ) CNewUser::DeleteInstance(); - + if(defined('PBR_LOG_LOADED')) CLog::DeleteInstance(); + CErrorList::DeleteInstance(); ?> diff --git a/src/login.php b/src/login.php index 7071646..876eaba 100644 --- a/src/login.php +++ b/src/login.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION',' '); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/logout.php b/src/logout.php index 85020e7..0ddcbbd 100644 --- a/src/logout.php +++ b/src/logout.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION',' '); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/logs.php b/src/logs.php index 69d12bd..2991218 100644 --- a/src/logs.php +++ b/src/logs.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/logsdelete.php b/src/logsdelete.php index dd3b647..cfd7b38 100644 --- a/src/logsdelete.php +++ b/src/logsdelete.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/parameters.php b/src/parameters.php index df765c5..47b35f6 100644 --- a/src/parameters.php +++ b/src/parameters.php @@ -39,7 +39,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/rent.php b/src/rent.php index d2bb9dd..03f562b 100644 --- a/src/rent.php +++ b/src/rent.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/rentdelete.php b/src/rentdelete.php index 52fb57a..5e28660 100644 --- a/src/rentdelete.php +++ b/src/rentdelete.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/rentsdelete.php b/src/rentsdelete.php index 14e97ca..41e3905 100644 --- a/src/rentsdelete.php +++ b/src/rentsdelete.php @@ -38,7 +38,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/select.php b/src/select.php index 030de20..89376c4 100644 --- a/src/select.php +++ b/src/select.php @@ -37,7 +37,7 @@ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config diff --git a/src/users.php b/src/users.php index 9e46a8a..d957d86 100644 --- a/src/users.php +++ b/src/users.php @@ -34,13 +34,15 @@ * GET: act=show * GET: act=select, usi * POST: act=new, usr=, pwd= - * POST: act=update, usi, pwd=, sta= + * POST: act=update, usi, pwd=, pwdc=, sta= * author: Olivier JULLIEN - 2010-02-04 + * update: Olivier JULLIEN - 2010-06-11 - add password check + * - fixed minor bug *************************************************************************/ /** Defines **********/ - define('PBR_VERSION','1.0.1'); + define('PBR_VERSION','1.1.0'); define('PBR_PATH',dirname(__FILE__)); /** Include config @@ -119,8 +121,14 @@ ****************/ if( $sAction=='update' ) { - $iReturn=-2; - if( CNewUser::GetInstance()->IsValidUpdate()==TRUE ) + if( CNewUser::GetInstance()->IsValidUpdate()==FALSE ) + { + $iMessageCode=1; + $sAction='select'; + CNewUser::GetInstance()->SetPassword(null); + CNewUser::GetInstance()->SetPasswordCheck(null); + } + else { require(PBR_PATH.'/includes/db/'.PBR_DB_DIR.'/userupdate.php'); $iReturn = UserUpdate( CUser::GetInstance()->GetUsername() @@ -133,17 +141,14 @@ $iMessageCode=2; $sAction='show'; CNewUser::DeleteInstance(); - }//if( $iReturn>0 ) - }//if( (CNewUser::GetInstance()->IsValidUpdate()==TRUE) ) - - //Error - if( $iReturn<0 ) - { - // Failed - RedirectError( $iReturn, __FILE__, __LINE__ ); - exit; - }//if( $iReturn<1 ) - + } + else + { + // Failed + RedirectError( $iReturn, __FILE__, __LINE__ ); + exit; + }//if( $iReturn>=0 ) + }//if( (CNewUser::GetInstance()->IsValidUpdate()==FALSE) ) }//if( $sAction=='update' ) /** Action=new @@ -153,7 +158,9 @@ if( CNewUser::GetInstance()->IsValidNew()==FALSE ) { $iMessageCode=1; - $sAction=='show'; + $sAction='show'; + CNewUser::GetInstance()->SetPassword(null); + CNewUser::GetInstance()->SetPasswordCheck(null); } else {