headinc.php

来自「极限OA开源系统」· PHP 代码 · 共 117 行

PHP
117
字号
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
header("Cache-control: private");
$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];

define("KIN_UNION", TRUE);
set_magic_quotes_runtime(0);

if (!isset($_REQUEST)){$_REQUEST = array_merge($_GET, $_POST, $_COOKIE);}

if(getenv('HTTP_X_FORWARDED_FOR')!='') {
    $yip = (!empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $_SERVER['REMOTE_ADDR'] );
    if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip_list)) {
		$private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10..*/', '/^224..*/', '/^240..*/');
        $yip = preg_replace($private_ip, $client_ip, $ip_list[1]);
    }
}else {
    $yip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $_SERVER['REMOTE_ADDR'] );
}
$ssid = md5($_SERVER['HTTP_USER_AGENT'].$onlineip );

if(empty($referer) && isset($_SERVER['HTTP_REFERER'])) {
	$referer = $_SERVER['HTTP_REFERER'];
}

$SCRIPT_FILENAME = str_replace('\\\\', '/', ($HTTP_SERVER_VARS['PATH_TRANSLATED'] ? $HTTP_SERVER_VARS['PATH_TRANSLATED'] : $HTTP_SERVER_VARS['SCRIPT_FILENAME']));
$union_root = substr($SCRIPT_FILENAME, 0, strrpos($SCRIPT_FILENAME, '/') + 1);

require './includes/config.php';
require $union_root.'./includes/'.$database.'.php';
require $union_root.'./includes/sess.php';
require $union_root.'./includes/global.php';

$timestamp = time();
$magic_quotes_gpc = get_magic_quotes_gpc();
$register_globals = @ini_get('register_globals');

$UNION_SESSION = $UNION_CACHE = $UNION_USER = $sess_arr = array();

$tables = array('department', 'dict','employees','members','parts','sessions','setting','client','cli_note','diary','addresslist','listday','task','bulletin','folder','filetype','file','ps'); 
foreach($tables as $t) {
	${"table_".$t} = $tablepre.$t;
}

$set_onlinehold = $set_onlinehold?$set_onlinehold:600;

$currscript = basename($PHP_SELF);
$currscript = substr($currscript, 0, strpos($currscript, '.php'));

$creatsession = false;
unset($union_user,$union_user);

if(is_array($_SESSION['SESS_ET'])) {
	@extract($_SESSION['SESS_ET']);
	$union_user = union_addslashes($union_user_);
	$union_pass = union_addslashes($union_pass_);
}
if($union_user && $union_pass) {
	$UNION_USER = $db->query_fetch("SELECT uid AS union_uid, fig AS union_fig, part AS union_part, username AS union_user, password AS union_pass, employ AS union_employ FROM $table_members WHERE username='$union_user' && password='$union_pass'");
}
//echo $_COOKIE['union_user_'];

if(!$allow_cookie && $_COOKIE['union_user_'] && $_COOKIE['union_pass_'] && empty($union_user)) {
	if(empty($union_user)) {
		$UNION_USER = $db->query_fetch("SELECT uid AS union_uid, fig AS union_fig, part AS union_part, username AS union_user, password AS union_pass, employ AS union_employ FROM $table_members WHERE username='$_COOKIE[union_user_]' && password='$_COOKIE[union_pass_]'");
		if ($UNION_USER) {
			union_setcookie("union_user_", $_COOKIE['union_user_']);
			union_setcookie("union_pass_", $_COOKIE['union_pass_']);
		}else{
			clearcookies();
		}
		$creatsession = true;
	}
	@extract($UNION_USER);
}

if($union_employ) {
	$tmp = $db->query_fetch("SELECT d.name,d.id FROM $table_department d,$table_employees e WHERE d.id=e.depart && e.id='$union_employ'");
	if($tmp[name]) {
		$union_employs = $tmp[name];
		$union_departid = $tmp[id];
	}
}
$union_rights = array();
$tmp = $db->query_fetch("SELECT id,rights FROM $table_parts WHERE id='$union_part'");
if($tmp[id]) {
	$union_rights = unserialize($tmp[rights]);
}



if(!@ini_get('register_globals') || !get_magic_quotes_gpc()) {
	@extract(union_addslashes($_REQUEST));
	if(!@ini_get('register_globals')) {
		foreach($_FILES as $key => $val) {
			$$key = $val['tmp_name'];
			${$key.'_name'} = $val['name'];
			${$key.'_size'} = $val['size'];
			${$key.'_type'} = $val['type'];
		}
	}
}


register_shutdown_function('union_end');


$sess_arr = array('union_user_'=>$union_user,'union_pass_'=>$union_pass,'gid'=>$gid,'email'=>$email,
					'credit'=>$credit,'avatar'=>$avatar,'lastvisit'=>$lastvisit,'lastposttime'=>$lastposttime,'newps'=>$newps);

if($currscript != 'login' && !$union_user) {
	$surl = "cur_=$currscript&act_=$action&sact_=$sysaction";
	header("Location:login.php?$surl");
	exit;
}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?