📄 commons.inc.php
字号:
<?php
##
# Project: PHPDisk
# This is NOT a freeware, use is subject to license terms.
#
# Site: http://www.phpdisk.com
#
# $Id: commons.inc.php 253 2009-03-11 03:05:27Z along $
#
# Copyright (C) 2008-2009 PHPDisk Team. All Rights Reserved.
#
##
error_reporting(E_ERROR|E_WARNING|E_PARSE);
header("Content-Type: text/html; charset=UTF-8");
@date_default_timezone_set('Asia/Shanghai');
$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
define('LF',"\r\n");
} else {
define('LF',"\n");
}
define('NOW_YEAR','2009');
define('XCODE','pd');
$lang_id = 'zh-cn';
$timestamp = time();
define('PHPDISK_ROOT', substr(dirname(__FILE__), 0, -8));
define('IN_PHPDISK',TRUE);
define('SERVER_NAME',$_SERVER['SERVER_NAME']);
@set_magic_quotes_runtime(0);
$install_file = PHPDISK_ROOT.'./install/install.lock';
if(!file_exists($install_file)){
header("Location: install.php");
}else{
if(file_exists(PHPDISK_ROOT.'./install.php')){
echo "Please DELETE install.php file, if you have already installed your system.<br> ";
echo "<a href='install.php'>Now, I want install system.</a>";
exit();
}
}
$config_file = PHPDISK_ROOT.'./system/configs.inc.php';
file_exists($config_file) ? require_once $config_file : exit('System not install, please read ./docs/install.html .');
$setting_file = PHPDISK_ROOT.'./system/settings.inc.php';
file_exists($setting_file) ? require_once $setting_file : exit('System not install, please read ./docs/install.html .');
require_once PHPDISK_ROOT.'./includes/mysql.class.php';
require_once PHPDISK_ROOT.'./includes/global.func.php';
require_once PHPDISK_ROOT.'./includes/file.func.php';
require_once PHPDISK_ROOT.'./includes/rewrite.func.php';
require_once PHPDISK_ROOT.'./phpdisk_version.php';
$db = new cls_mysql;
$db->connect($configs['dbhost'],$configs['dbuser'],$configs['dbpasswd'],$configs['dbname'],$configs['pconnect']);
unset($configs['dbhost'],$configs['dbuser'],$configs['dbpasswd'],$configs['pconnect']);
$group_settings_file = PHPDISK_ROOT.'./system/group_settings.inc.php';
file_exists($group_settings_file) ? require_once $group_settings_file : write_cache('settings');
$stats_file = PHPDISK_ROOT.'./system/stats.inc.php';
file_exists($stats_file) ? require_once $stats_file : write_cache('stats');
if (@get_magic_quotes_gpc()) {
$_GET = stripslashes_array($_GET);
$_POST = stripslashes_array($_POST);
$_COOKIE = stripslashes_array($_COOKIE);
}
$timestamp = time();
define('PHPDISK_URL',$settings['phpdisk_url']);
define('TPL_NAME','default');
define('ADMIN_TPL_NAME','admin');
define('LANG_DIR',PHPDISK_ROOT.'./languages/'.$lang_id.'/');
$tpl_dir = 'templates/'.TPL_NAME;
$admin_tpl_dir = 'templates/'.ADMIN_TPL_NAME;
if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
$onlineip = getenv('REMOTE_ADDR');
} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
$onlineip = $_SERVER['REMOTE_ADDR'];
}
$onlineip = addslashes($onlineip);
@preg_match("/[\d\.]{7,15}/", $onlineip, $onlineipmatches);
$onlineip = $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
unset($onlineipmatches);
$pg = (int)gpc('pg','G',0);
if(!$pg){
$pg = 1;
}
$perpage = $settings['perpage'];
if ($settings['gzipcompress'] && function_exists('ob_gzhandler')) {
@ob_start('ob_gzhandler');
$gzip_info = 'Enabled';
} else {
ob_start();
$gzip_info = 'Disabled';
}
require_once lang('common');
$sysmsg = array();
$error = false;
$item = trim(gpc('item','GP',''));
$action = trim(gpc('action','GP',''));
$task = trim(gpc('task','GP',''));
$p_formhash = gpc('formhash','P','');
list($pd_uid,$pd_gid,$pd_username,$pd_pwd,$pd_email) = gpc('phpdisk_info','C','') ? explode("\t", pd_encode(gpc('phpdisk_info','C',''), 'DECODE')) : array('', '', '','','');
$pd_uid = (int)$pd_uid;
$pd_pwd = addslashes($pd_pwd);
if (!$pd_uid || !$pd_pwd) {
$pd_uid = 0;
} else {
$userinfo = $db->fetch_one_array("SELECT userid,u.gid,username,password,email,group_name FROM pd_users u,pd_groups g WHERE userid='$pd_uid' and password='$pd_pwd' and u.gid=g.gid limit 1");
if ($userinfo) {
$pd_username = $userinfo['username'];
$pd_email = $userinfo['email'];
$pd_gid = $userinfo['gid'];
$pd_group_name = $userinfo['group_name'];
} else {
$pd_uid = 0;
$pd_pwd = '';
pd_setcookie('phpdisk_info', '');
}
}
unset($userinfo);
$formhash = formhash();
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -