<?php
-/**\r
+/**
* functions.php
- * Additional functions for iserv-moderror-reporter\r
- * @author Roland Hieber (roland.hieber@wilhelm-gym.net)\r
- * @date 20.10.2007\r
- * \r
- * Copyright © 2007 Roland Hieber\r
- * \r
- * Permission is hereby granted, free of charge, to any person obtaining\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- * \r
- * The above copyright notice and this permission notice shall be included in\r
- * all copies or substantial portions of the Software.\r
- * \r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
- * THE SOFTWARE.\r
+ * Additional functions for iserv-moderror-reporter
+ * @author Roland Hieber (roland.hieber@wilhelm-gym.net)
+ * @date 20.10.2007
+ *
+ * Copyright © 2007 Roland Hieber
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
*/
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 */
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"]; }
* @return void
*/
function printLastError() {
- echo sprintf("<p class='err'>%s %s</p>", _c("error-reporter:An error occured:"), getLastError());
+ echo sprintf("<p class='err'>%s %s</p>", _c("error-reporter:An error ".
+ "occured:"), getLastError());
}
/**
* @throws Exception
*/
function erIsAct($strAct) {
- $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct);\r
- if(!is_resource($hQuery)) {\r
+ $hQuery = db_query("SELECT * FROM users WHERE act = $1;", $strAct);
+ if(!is_resource($hQuery)) {
throw new Exception(ER_ERROR_SQL);
- return null;\r
- }\r
+ 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 <tt>null</tt>.
+ * @return (string) The real name of the user. If the function fails, it
+ * returns <tt>null</tt>.
* @throws Exception
*/
function erGetRealUserName($strAct) {
- $hQuery = db_query("SELECT firstname, lastname FROM users WHERE act = $1;", $strAct);\r
- if(!is_resource($hQuery)) {\r
- throw new Exception(ER_ERROR_SQL);\r
- return null;\r
+ $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
- }\r
+ }
$arResult = pg_fetch_array($hQuery);
return user_join_name($arResult);
}
* @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;
/**
* 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 <tt>null</tt>.
+ * @return (string) The name of the group. If the function fails, it returns
+ * <tt>null</tt>.
* @throws Exception
*/
function erGetGroupName($strAct) {
- $hQuery = db_query(sprintf("SELECT * FROM groups WHERE act=%s;", qdb($strAct)));\r
- if(!is_resource($hQuery)) {\r
- throw new Exception(ER_ERROR_SQL);\r
- return null;\r
- }\r
+ $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
}
/**
* 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
*/
* @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");
-}\r
-?>
\ No newline at end of file
+}
+?>