function AddIncludePath($s_dir = ".")
{
    global $sSavePath, $bPathSaved;
    $s_path = ini_get('include_path');
    $i_path_len = strlen($s_path);
    $s_sep = IsServerWindows() ? ";" : ":";
    // get path separator
    //
    // look for it in the include_path
    //
    $b_found = false;
    $i_pos = 0;
    $i_len = strlen($s_dir);
    while (!$b_found && ($i_pos = strpos($s_path, $s_dir, $i_pos)) !== false) {
        if ($i_pos == 0) {
            if ($i_len == $i_path_len) {
                $b_found = true;
            } elseif ($s_path[$i_len] == $s_sep) {
                $b_found = true;
            }
        } elseif ($s_path[$i_pos - 1] == $s_sep && ($i_pos + $i_len == $i_path_len || $s_path[$i_pos + $i_len] == $s_sep)) {
            $b_found = true;
        }
        if (!$b_found) {
            $i_pos++;
        }
    }
    if (!$b_found) {
        //
        // allow multiple calls, but only store the original path once
        //
        if (!$bPathSaved) {
            $sSavePath = $s_path;
        }
        if (empty($s_path)) {
            $s_path = $s_dir;
        } else {
            //
            // prepend the directory
            //
            $s_path = $s_dir . $s_sep . $s_path;
        }
        ini_set('include_path', $s_path);
        $bPathSaved = true;
    }
}
Example #2
0
function LoadLanguageFile()
{
    global $aMessages, $sLangID;
    //
    // look for '.' in the include_path
    //
    $s_path = ini_get('include_path');
    $b_reset = false;
    if ($s_path != ".") {
        if (IsServerWindows()) {
            ini_set('include_path', $s_path . ";.");
        } else {
            ini_set('include_path', $s_path . ":.");
        }
        $b_reset = true;
    }
    include "language.inc";
    if ($b_reset) {
        ini_set('include_path', $s_path);
    }
}