Esempio n. 1
0
/**
 * Trigger an error.
 * @param  string $sErrNo error string defined in errors.php
 * @param  array   $aExtra optional associative array with extra error info
 * @return void
 * @author  Marc Groot Koerkamp
 * @since 1.5.1
 */
function sqm_trigger_error($sErrNo, $aExtra = array())
{
    static $aErrors;
    if (!isset($aErrors)) {
        // Include the error definition file.
        include_once SM_PATH . 'include/errors.php';
    }
    $iPhpErr = E_USER_NOTICE;
    if (is_array($aErrors) && isset($aErrors[$sErrNo]['level'])) {
        if (is_array($aExtra) && count($aExtra)) {
            $aErrors[$sErrNo]['extra'] = $aExtra;
        }
        // because trigger_error can only handle a string argument for the error description
        // we serialize the result.
        $sErrString = serialize($aErrors[$sErrNo]);
        $iPhpErr = $aErrors[$sErrNo]['level'];
    } else {
        sm_print_r($aErrors);
        $sErrString = "Error <{$sErrNo}> does not exist, fix the code or update the errors.php file";
        $iPhpErr = E_USER_ERROR;
    }
    trigger_error($sErrString, $iPhpErr);
}
/**
* Provide an easy way to dump the imap dialogue if $imap_asearch_debug_dump is TRUE
* @global bool imap_asearch_debug_dump
* @param string $var_name
* @param string $var_var
*/
function s_debug_dump($var_name, $var_var)
{
    global $imap_asearch_debug_dump;
    if ($imap_asearch_debug_dump) {
        if (function_exists('sm_print_r')) {
            //Only exists since 1.4.2
            sm_print_r($var_name, $var_var);
        } else {
            echo '<pre>';
            echo htmlentities($var_name);
            print_r($var_var);
            echo '</pre>';
        }
    }
}