X-Git-Url: https://git.rohieb.name/iserv-mod-error-reporter.git/blobdiff_plain/3e05075cf3aeff4d23dc9eba7af236ea47cb919d..056421b7ab5be6252dfabb671d4c2dae6588aecc:/inc/functions.inc diff --git a/inc/functions.inc b/inc/functions.inc index bd1efbf..1293099 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -33,8 +33,12 @@ require_once("share.inc"); */ /** Access denied. This can be due to missing access rights. */ define("ER_ERROR_ACCESS_DENIED", _c("error-reporter:Access denied")); -/** Error while querying the database, maybe due to a lost connection to the server */ -define("ER_ERROR_SQL", _c("error-reporter:Error while trying to query the database")); +/** + * Error while querying the database, maybe due to a lost connection to the + * server + */ +define("ER_ERROR_SQL", _c("error-reporter:Error while trying to query the ". + "database")); /** Error while trying to open a file */ define("ER_ERROR_OPEN_FILE", _c("error-reporter:Could not open file")); /** Error while trying to write a file */ @@ -58,7 +62,8 @@ static $ercLastError = null; function setLastError($cError) { $GLOBALS["ercLastError"] = $cError; } /** * Get the error that occured last. - * @return (constant) Error code, see @ref error-reporter_errorcodes for a list of constants. + * @return (constant) Error code, see @ref error-reporter_errorcodes for a list + * of constants. */ function getLastError() { return $GLOBALS["ercLastError"]; } @@ -67,7 +72,8 @@ function getLastError() { return $GLOBALS["ercLastError"]; } * @return void */ function printLastError() { - echo sprintf("

%s %s

", _c("error-reporter:An error occured:"), getLastError()); + echo sprintf("

%s %s

", _c("error-reporter:An error ". + "occured:"), getLastError()); } /** @@ -88,14 +94,16 @@ function erIsAct($strAct) { /** * Get the real user name for an account name * @param $strAct (string) Account name of the user to look up - * @return (string) The real name of the user. If the function fails, it returns null. + * @return (string) The real name of the user. If the function fails, it + * returns null. * @throws Exception */ function erGetRealUserName($strAct) { - $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct); + $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", + $strAct); if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; + throw new Exception(ER_ERROR_SQL); + return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // User not found in database, return account name @@ -111,7 +119,8 @@ function erGetRealUserName($strAct) { * @throws Exception */ function erIsGroup($strAct) { - $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", + qdb($strAct))); if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); return null; @@ -122,14 +131,16 @@ function erIsGroup($strAct) { /** * Look up the name of a group * @param $strAct (string) Account name of the group - * @return (string) The name of the group. If the function fails, it returns null. + * @return (string) The name of the group. If the function fails, it returns + * null. * @throws Exception */ function erGetGroupName($strAct) { - $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct))); + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", + qdb($strAct))); if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; + throw new Exception(ER_ERROR_SQL); + return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // Group not found in database, return account name @@ -140,8 +151,8 @@ function erGetGroupName($strAct) { /** * Create a link to write a mail to the specified account name. - * This function returns a link if the specified account exists, otherwise it returns the - * account name. + * This function returns a link if the specified account exists, otherwise it + * returns the account name. * @param $strAct (string) Account name * @return string */ @@ -159,11 +170,11 @@ function erMailToUserLink($strAct) { * @return string */ function erIsMailAddress($strAddr) { - return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", $strAddr) > 0) - and (preg_match("/(\s*,\s*)$/", $strAddr) == 0)); + return ((preg_match("/([a-zA-Z0-9_\-\.]*(@[a-zA-Z0-9\-\.]*)?(\s*,\s*)?)+/", + $strAddr) > 0) and (preg_match("/(\s*,\s*)$/", $strAddr) == 0)); } function erInsertLog($sMsg) { log_insert($sMsg, null, "Error Report Wizard"); } -?> \ No newline at end of file +?>