Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / code-functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/28/2009 *
4  * ===================                          Last change: 02/28/2009 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : code-functions.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Functions for handling status codes              *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Funktionen zum Umgang mit Status-Funktionen      *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         die();
36 } // END - if
37
38 // Adds a code key/value pair to $GLOBALS
39 function addCode ($key, $value) {
40         $GLOBALS['status_codes'][$key] = $value;
41 }
42
43 // Gets a code from the $GLOBALS registry or triggers an error if not found
44 function getCode ($key) {
45         // Is the key set?
46         if (!isCodeSet($key)) {
47                 // Abort here
48                 reportBug(__FUNCTION__, __LINE__, sprintf('%s[%s:] Code %s is not set.',
49                         __FUNCTION__,
50                         __LINE__,
51                         $key
52                 ));
53         } // END - if
54
55         // Return it
56         return $GLOBALS['status_codes'][$key];
57 }
58
59 // Checks whether a specified status code is set
60 function isCodeSet ($key) {
61         // Simply use isset()
62         return (isset($GLOBALS['status_codes'][$key]));
63 }
64
65 // Get hex-decimal value from given error code
66 function getHexErrorCode ($errorCode) {
67         // Convert it
68         $hex = str_pad(dechex($errorCode), 3, '0', STR_PAD_LEFT);
69
70         // Return it
71         return $hex;
72 }
73
74 // [EOF]
75 ?>