コード例 #1
0
ファイル: admin.php プロジェクト: horrabin/opendb
/**
	Taken from phpMyAdmin libraries/defines.lib.php

	Determines platform (OS)
	Based on a phpBuilder article:
		see http://www.phpbuilder.net/columns/tim20000821.php
*/
function get_user_browser_os()
{
    $http_user_agent = get_http_env('HTTP_USER_AGENT');
    // 1. Platform
    if (strstr($http_user_agent, 'Win')) {
        return 'Win';
    } else {
        if (strstr($http_user_agent, 'Mac')) {
            return 'Mac';
        } else {
            if (strstr($http_user_agent, 'Linux')) {
                return 'Linux';
            } else {
                if (strstr($http_user_agent, 'Unix')) {
                    return 'Unix';
                } else {
                    if (strstr($http_user_agent, 'OS/2')) {
                        return 'OS/2';
                    } else {
                        return 'Other';
                    }
                }
            }
        }
    }
}
コード例 #2
0
ファイル: secretimage.php プロジェクト: horrabin/opendb
/**
 * TODO - note that date is used as part of the generated code, so if someone tries to
 * register just before a date change, the registration may fail - but its a fairly
 * unlikely occurence.
 *
 * @param unknown_type $random_num
 * @return unknown
 */
function get_secret_image_code($random_num)
{
    $security_hash = get_opendb_config_var('site', 'security_hash');
    $datekey = date("F j");
    $rcode = hexdec(md5(get_http_env('HTTP_USER_AGENT') . $security_hash . $random_num . $datekey));
    $code = substr($rcode, 2, 6);
    return $code;
}
コード例 #3
0
ファイル: begin.inc.php プロジェクト: horrabin/opendb
include_once "./lib/utils.php";
include_once "./lib/auth.php";
include_once "./lib/session.php";
include_once "./lib/database.php";
include_once "./lib/theme.php";
include_once "./lib/language.php";
include_once "./lib/menu.php";
include_once "./lib/OpenDbBrowserSniffer.class.php";
// OpenDb will not work with this on!!!
if (get_magic_quotes_runtime()) {
    set_magic_quotes_runtime(false);
}
// Only if $PHP_SELF is not already defined.
if (!isset($PHP_SELF)) {
    // get_http_env is a OpenDb function!
    $PHP_SELF = get_http_env('PHP_SELF');
}
// We want all the HTTP variables into the $HTTP_VARS array, so
// we can reference everything from the one place.
// any upload files will be in new post php 4.1 $_FILES array
if (!empty($_GET)) {
    // fixes for XSS vulnerabilities reported in OpenDb 1.0.6
    // http://secunia.com/advisories/31719
    $HTTP_VARS = strip_tags_array($_GET);
} else {
    if (!empty($_POST)) {
        $HTTP_VARS = $_POST;
    }
}
// Strip all slashes from this array.
if (get_magic_quotes_gpc()) {
コード例 #4
0
ファイル: http.php プロジェクト: horrabin/opendb
function get_site_path()
{
    $path = get_opendb_config_var('site.url', 'path');
    if (strlen($path)) {
        return $path;
    } else {
        // It seems that Win32 uses PATH_INFO instead of SCRIPT_NAME
        $path = ifempty(get_http_env("PATH_INFO"), ifempty(get_http_env("PHP_SELF"), get_http_env("SCRIPT_NAME")));
        // Now process path to get rid of anything after last /
        $index = strrpos($path, "/");
        if ($index !== FALSE) {
            $path = substr($path, 0, $index + 1);
        }
        //include last slash!
        // if path does not end in /, at this character.
        if (substr($path, -1, 1) != '/') {
            $path .= '/';
        }
        return $path;
    }
}
コード例 #5
0
ファイル: logging.php プロジェクト: horrabin/opendb
/**
	Appends the given text to the logfile

	This function does some checking to make sure the entry does not
	go over 4000 characters, so as not to confuse the logfile.php
	script.
*/
function opendb_logger($msgtype, $file, $function, $message = NULL, $params_r = NULL)
{
    if (get_opendb_config_var('logging', 'enable') !== FALSE) {
        $entry['datetime'] = date("d/m/y H:i:s");
        // get time and date
        $entry['ip'] = ifempty(get_http_env("REMOTE_ADDR"), "0.0.0.0");
        $entry['user_id'] = get_opendb_session_var('user_id');
        $entry['admin_user_id'] = get_opendb_session_var('admin_user_id');
        if (strlen($entry['admin_user_id']) == 0) {
            $entry['admin_user_id'] = '-';
        }
        $msgtype = strtoupper($msgtype);
        if (!in_array($msgtype, array('E', 'I', 'W'))) {
            $msgtype = 'E';
        }
        // temp bit here!
        switch ($msgtype) {
            case 'E':
                $entry['type'] = 'ERROR';
                break;
            case 'W':
                $entry['type'] = 'WARN';
                break;
            case 'I':
                $entry['type'] = 'INFO';
                break;
        }
        $entry['parameters'] = expand_opendb_logger_params($params_r);
        if (strlen($entry['parameters']) == 0) {
            $entry['parameters'] = '-';
        }
        if (strlen($file) > 0) {
            $entry['file'] = str_replace('\\', '/', $file);
        } else {
            $entry['file'] = '-';
        }
        if (strlen($function) > 0 && $function != 'unknown') {
            $entry['function'] = $function;
        } else {
            $entry['function'] = '-';
        }
        if (strlen($message) > 0) {
            $entry['message'] = $message;
        } else {
            $entry['message'] = '-';
        }
        $fileptr = @fopen(get_opendb_config_var('logging', 'file'), 'a');
        if ($fileptr) {
            $entry['datetime'] = '[' . $entry['datetime'] . ']';
            if ($entry['parameters'] != '-') {
                $entry['parameters'] = '"' . addslashes(replace_newlines($entry['parameters'])) . '"';
            }
            if ($entry['message'] != '-') {
                $entry['message'] = '"' . addslashes(replace_newlines($entry['message'])) . '"';
            }
            $line = $entry['datetime'] . ' ' . $entry['type'] . ' ' . $entry['ip'] . ' ' . $entry['user_id'] . ' ' . $entry['admin_user_id'] . ' ' . $entry['file'] . ' ' . $entry['function'] . ' ' . $entry['parameters'] . ' ' . $entry['message'];
            fwrite($fileptr, $line . "\n");
            fclose($fileptr);
        }
    }
}
コード例 #6
0
ファイル: freedb.class.php プロジェクト: horrabin/opendb
function get_hello_param()
{
    return "opendb+" . get_http_env('HTTP_HOST') . "+" . urlencode(get_opendb_config_var('site', 'title')) . "+" . get_opendb_version();
}
コード例 #7
0
 function OpenDbBrowserSniffer()
 {
     $this->phpSniffer = new phpSniff(get_http_env('HTTP_USER_AGENT'));
     $this->__initIsSupported();
 }