Support Incident Tracker GIT4.x
base.inc.php File Reference

Go to the source code of this file.

Functions

 stripslashes_array ($data)
 cleanvar ($vars, $striphtml=TRUE, $transentities=FALSE, $mysqlescape=TRUE, $disallowedchars=array(), $replacechars=array(), $intval=FALSE)
 clean_int ($vars)
 clean_float ($vars)
 clean_dbstring ($string)
 clean_fixed_list ($string, $list, $strict=FALSE)
 available_languages ($test=FALSE)

Variables

if(realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) $application_version = '3.90'
 $application_revision = 'git'
 $siterrors = 0
 $now = time()
 $today = $now + (16 * 3600)
 $lastweek = $now - (7 * 86400)
 $todayrecent = $now - (16 * 3600)
 $startofsession = $now - ini_get("session.gc_maxlifetime")
 $CONFIG ['upload_max_filesize'] = return_bytes($CONFIG['upload_max_filesize'])
 $iconset = $CONFIG['default_iconset']
 $application_version_string = trim("v{$application_version} {$application_revision}")
 $ldap_conn = ""
 $_SERVER ['PHP_SELF']
 $oldeh = set_error_handler("sit_error_handler")

Function Documentation

available_languages ( test = FALSE)

Return an array of available languages codes by looking at the files in the i18n directory

Author:
Ivan Lucas
Parameters:
bool$test- (optional) Include test language (zz) in results
Return values:
arrayLanguage codes

Definition at line 288 of file base.inc.php.

References elseif, and i18n_code_to_name().

Referenced by cfgVarInput().

{
    $i18nfiles = list_dir('.'.DIRECTORY_SEPARATOR.'i18n');
    $i18nfiles = array_filter($i18nfiles, 'filter_i18n_filenames');
    array_walk($i18nfiles, 'i18n_filename_to_code');
    asort($i18nfiles);
    foreach ($i18nfiles AS $code)
    {
        if ($code != 'zz')
        {
            $available[$code] = i18n_code_to_name($code);
        }
        elseif ($code == 'zz' AND $test === TRUE)
        {
            $available[$code] = 'Test Language (zz)';
        }
    }

    return $available;
}
clean_dbstring ( string)

Make an external variable safe for use in a database query

Author:
Ivan Lucas
Parameters:
mixed$stringvariable to make safe
Returns:
string - DB safe variable
Note:
Strips HTML

Definition at line 234 of file base.inc.php.

Referenced by Contact::add(), cmi_create_table(), process_new_contact(), and sla_target_content().

{
    $string = strip_tags($string);

    if (get_magic_quotes_gpc() == 1)
    {
        stripslashes($string);
    }

    $string = mysql_real_escape_string($string);

    return $string;
}
clean_fixed_list ( string,
list,
strict = FALSE 
)

Make an external variable safe by ensuring the value is one of a list of predetermined values

Author:
Ivan Lucas
Parameters:
mixed$stringvariable to make safe
array$listlist of safe values
bool$strict,alsocheck the types of the values in the list
Returns:
mixed - DB safe variable
Note:
If the input string isn't found in the list, the first option is used

Definition at line 259 of file base.inc.php.

References E_USER_ERROR, and E_USER_WARNING.

{
    if (is_array($list))
    {
        if (!in_array($string, $list, $strict))
        {
            if ($string != NULL AND $string != '')
            {
                trigger_error("Unexpected input", E_USER_WARNING);
            }
            $string = $list[0];
        }
    }
    else
    {
        trigger_error("Could not understand list of predetermined values for fixed_list()", E_USER_ERROR);
        return false;
    }
    return $string;
}
clean_float ( vars)

Make an external variable safe. Force it to be a float.

Author:
Ivan Lucas
Parameters:
mixed$stringvariable to make safe
Returns:
int - safe variable

Definition at line 205 of file base.inc.php.

References E_USER_WARNING, and elseif.

{
    if (is_array($vars))
    {
        foreach ($vars as $key => $singlevar)
        {
            $var[$key] = clean_float($singlevar);
        }
    }
    elseif (!is_null($vars) AND $vars != '' AND !is_numeric($vars))
    {
        trigger_error("Input was expected to be numeric but received string instead", E_USER_WARNING);
    }
    else
    {
        $var = floatval($vars);
    }

    return $var;
}
clean_int ( vars)

Make an external variable safe. Force it to be an integer.

Author:
Ivan Lucas
Parameters:
mixed$stringvariable to make safe
Returns:
int - safe variable

Definition at line 177 of file base.inc.php.

References E_USER_WARNING, and elseif.

Referenced by Contact::add(), dashboard_watch_incidents_edit(), process_new_contact(), sla_target_content(), and transactions_report().

{
    if (is_array($vars))
    {
        foreach ($vars as $key => $singlevar)
        {
            $var[$key] = clean_int($singlevar);
        }
    }
    elseif (!is_null($vars) AND $vars != '' AND !is_numeric($vars))
    {
        trigger_error("Input was expected to be numeric but received string instead", E_USER_WARNING);
    }
    else
    {
        $var = intval($vars);
    }

    return $var;
}
cleanvar ( vars,
striphtml = TRUE,
transentities = FALSE,
mysqlescape = TRUE,
disallowedchars = array(),
replacechars = array(),
intval = FALSE 
)

Make an external variable safe for database and HTML display

Author:
Ivan Lucas, Kieran Hogg
Parameters:
mixed$varvariable to replace
bool$striphtmlwhether to strip html
bool$transentitieswhether to translate all aplicable chars (true) or just special chars (false) into html entites
bool$mysqlescapewhether to mysql_escape()
array$disallowedcharsarray of chars to remove
array$replacecharsarray of chars to replace as $orig => $replace
bool$intvalwhether to get the integer value of the variable
Todo:
TODO this function could use a bit of tidy-up
Returns:
variable

Definition at line 113 of file base.inc.php.

Referenced by Trigger::__construct(), User::add(), dashboard_rss_edit(), display_update_page(), draw_file_row(), is_kb_article(), new_update(), process_new_contact(), Form::run(), show_new_contact(), template_description(), TriggerEvent::TriggerEvent(), triggers_to_html(), and valid_username().

{
    if (is_array($vars))
    {
        foreach ($vars as $key => $singlevar)
        {
            $var[$key] = cleanvar($singlevar, $striphtml, $transentities, $mysqlescape,
                    $disallowedchars, $replacechars);
        }
    }
    else
    {
        $var = $vars;
        if ($striphtml === TRUE)
        {
            $var = strip_tags($var);
        }

        if (!empty($disallowedchars))
        {
            $var = str_replace($disallowedchars, '', $var);
        }

        if (!empty($replacechars))
        {
            foreach ($replacechars as $orig => $replace)
            {
                $var = str_replace($orig, $replace, $var);
            }
        }

        if ($transentities)
        {
            $var = htmlentities($var, ENT_COMPAT, $GLOBALS['i18ncharset']);
        }
        else
        {
            $var = htmlspecialchars($var, ENT_COMPAT, $GLOBALS['i18ncharset']);
        }

        if ($mysqlescape)
        {
            $var = mysql_real_escape_string($var);
        }

        if ($intval)
        {
            $var = intval($val);
        }

        $var = trim($var);
    }
    return $var;
}
stripslashes_array ( data)

Strip slashes from an array

Parameters:
$dataan array
Returns:
An array with slashes stripped

Definition at line 83 of file base.inc.php.

References $data.

{
    if (is_array($data))
    {
        foreach ($data as $key => $value)
        {
            $data[$key] = stripslashes_array($value);
        }
        return $data;
    }
    else
    {
        return stripslashes($data);
    }
}

Variable Documentation

$_SERVER['PHP_SELF']
$application_revision = 'git'

Definition at line 26 of file base.inc.php.

if (realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) $application_version = '3.90'

Begin global variable definitions

Definition at line 23 of file base.inc.php.

Referenced by setup_exec_sql(), trigger_replace_specials(), and upgrade_schema().

$application_version_string = trim("v{$application_version} {$application_revision}")
$CONFIG['upload_max_filesize'] = return_bytes($CONFIG['upload_max_filesize'])

Definition at line 39 of file base.inc.php.

$lastweek = $now - (7 * 86400)

Definition at line 35 of file base.inc.php.

$now = time()

Definition at line 32 of file base.inc.php.

$oldeh = set_error_handler("sit_error_handler")

Definition at line 59 of file base.inc.php.

$siterrors = 0

Definition at line 29 of file base.inc.php.

Referenced by html_redirect(), and sit_error_handler().

$startofsession = $now - ini_get("session.gc_maxlifetime")

Definition at line 37 of file base.inc.php.

Referenced by draw_chart(), suggest_reassign_userid(), user_online(), and user_online_icon().

$today = $now + (16 * 3600)

Definition at line 34 of file base.inc.php.

$todayrecent = $now - (16 * 3600)

Definition at line 36 of file base.inc.php.

Referenced by dashboard_statistics_display(), and give_overview().