X-Git-Url: https://git.rohieb.name/iserv-mod-error-reporter.git/blobdiff_plain/ae87133905d183987eb75369fe94bb739a2b1cb9..7b8d765e89d6faa813a1c0762852c33c768ce4d4:/inc/functions.inc diff --git a/inc/functions.inc b/inc/functions.inc index 363ce5a..1293099 100644 --- a/inc/functions.inc +++ b/inc/functions.inc @@ -1,29 +1,29 @@ %s %s
", _c("error-reporter:An error occured:"), getLastError()); + echo sprintf("%s %s
", _c("error-reporter:An error ". + "occured:"), getLastError()); } /** @@ -77,29 +83,31 @@ function printLastError() { * @throws Exception */ function erIsAct($strAct) { - $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct); - if(!is_resource($hQuery)) { + $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct); + if(!is_resource($hQuery)) { throw new Exception(ER_ERROR_SQL); - return null; - } + return null; + } return (pg_num_rows($hQuery) > 0); } /** * 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); - if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; + $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", + $strAct); + if(!is_resource($hQuery)) { + throw new Exception(ER_ERROR_SQL); + return null; } if(pg_num_rows($hQuery) == 0) { return $strAct; // User not found in database, return account name - } + } $arResult = pg_fetch_array($hQuery); return user_join_name($arResult); } @@ -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,15 +131,17 @@ 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))); - if(!is_resource($hQuery)) { - throw new Exception(ER_ERROR_SQL); - return null; - } + $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", + qdb($strAct))); + if(!is_resource($hQuery)) { + 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 +} +?>