📄 polerio.class.php
字号:
<?php
/*apr-04-2004 [] pythoning [] the student should have its own accessionid like identifier so that it can be deleted anytime. without any id relationship [] include the DOST copy and QChall manual in the distribution for reference [] done
[] configure
extension=php_pgsql.dll
extension=php_sqlite.dll
*/
Class Polerio
{
function Polerio()
{
}
function Linux_Server()
{
if((ereg("Linux",getenv("SERVER_SOFTWARE"))) || (ereg("Unix",getenv("SERVER_SOFTWARE"))) ) return true;
}
function PostNuke()
{
global $op, $name;
if($op && $name) return true;
else return false;
}
function GetBaseURI()
{
/** * get base URI * @returns string * @return base URI */ global $HTTP_SERVER_VARS;
// Get the name of this URI
// Start of with REQUEST_URI
if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) {
$path = $HTTP_SERVER_VARS['REQUEST_URI'];
} else {
$path = getenv('REQUEST_URI');
}
if ((empty($path)) || (substr($path, -1, 1) == '/')) {
// REQUEST_URI was empty or pointed to a path
// Try looking at PATH_INFO
$path = getenv('PATH_INFO');
if (empty($path)) {
// No luck there either
// Try SCRIPT_NAME
if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) {
$path = $HTTP_SERVER_VARS['SCRIPT_NAME'];
} else {
$path = getenv('SCRIPT_NAME');
}
}
}
$path = preg_replace('/[#\?].*/', '', $path);
$path = dirname($path);
if (preg_match('!^[/\\\]*$!', $path)) {
$path = '';
}
return $path;
}
function GetBaseURL()
{
global $HTTP_SERVER_VARS;
if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) {
$server = getenv('HTTP_HOST');
} else {
$server = $HTTP_SERVER_VARS['HTTP_HOST'];
}
$path = Polerio::GetBaseURI();
if(Polerio::PostNuke()) return "http://$server$path/";
return "http://$server$path/";
}
function GetRoot()
{
/** * private function * @returns string */ global $HTTP_SERVER_VARS;
if (empty($HTTP_SERVER_VARS['DOCUMENT_ROOT'])) {
$root= getenv('DOCUMENT_ROOT');
} else {
$root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
}
return $root;
}
function GetPolerioURI()
{
/** * generate c:/htodcs/modulename/polerio/ * generate /var/www/html/ . . . * @returns string */
$PolerioModuleRoot = './polerio/';
if(PostNuke()) $PolerioModuleRoot = './modules/PhpMyLibrary/polerio/';
return $PolerioModuleRoot;
}
function GetPolerioURL()
{
global $name; // For postnuke
if(Polerio::PostNuke()) $PolerioModuleRoot = Polerio::GetBaseURL().'modules/'.$name.'/polerio/';
else $PolerioModuleRoot = Polerio::GetBaseURL().'/polerio/';
return $PolerioModuleRoot;
}
function GetModuleURI()
{
/** * generate c:/htodocs/modulename/polerio/module/ . . . * generate /var/www/html/ . . . * @returns string */
return Polerio::GetPolerioURI().'phpmylibrary/';
}
function GetModuleURL()
{
/** * generate http://modulename/polerio/module/index.php * @returns string */ global $op, $name, $file; // For postnuke compatibility
if(Polerio::PostNuke()) $link = 'modules.php?op=modload&name='.$name.'&file=index'; else $link = 'index.php';
return Polerio::GetBaseURL().$link;
}
function useColora()
{ /** * to generate static color * @returns static color */ global $pmlconfig;
if($pmlconfig['PnThOver']!=0) {
$bcolor2 = $pmlconfig['bgcolor1'];
$bcolor1 = $pmlconfig['bgcolor3'];
} else
{
global $bgcolor1,$bgcolor2,$bgcolor3;
$bcolor2 = $bgcolor1;
$bcolor1 = $bgcolor3;
}
static $ColorValue;
if($ColorValue==$bcolor2) $ColorValue=$bcolor1;
else $ColorValue=$bcolor2;
return($ColorValue);
}
function pnLocalReferer()
{ /** * check to see if this is a local referral * @returns bool * @return true if locally referred, false if not */
global $HTTP_SERVER_VARS;
if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) {
$server = getenv('HTTP_HOST');
} else {
$server = $HTTP_SERVER_VARS['HTTP_HOST'];
}
if (empty($HTTP_SERVER_VARS['HTTP_REFERER'])) {
$referer = getenv('HTTP_REFERER');
} else {
$referer = $HTTP_SERVER_VARS['HTTP_REFERER'];
}
if (preg_match("!^http://$server/!", $referer)) {
return true;
} else {
return false;
}
}
function Med()
{
$Med = "?";
if(Polerio::PostNuke()) $Med = "&";
return $Med;
}
function Init($dbconfig=array())
{
// Proper error reporting Commented out for release.
//error_reporting(E_ALL);
//phpinfo();
// Hack for some weird PHP systems that should have the
// LC_* constants defined, but don't
if (!defined('LC_TIME')) {
define('LC_TIME', 'LC_TIME');
}
// ADODB configuration
define('POLERIO_ADODB_DIR',Polerio::GetPolerioURI());
include POLERIO_ADODB_DIR.'adodb/adodb.inc.php';
include POLERIO_ADODB_DIR.'adodb/tohtml.inc.php';
// Initialise and load configuration
#global $dbconfig;
#$dbconfig = array();
#include Polerio::GetPolerioURI().'config/conf.php';
// Initialise and load tables
global $table;
$table = array();
include Polerio::GetPolerioURI().'lib/tables.php';
// Connect to database
if (!Polerio::DBInit()) { die('Database initialisation failed'); }
// Start Session to non-post-nuked site
if(!Polerio::PostNuke()) {
include Polerio::GetPolerioURI().'lib/session.inc.php';
if (!SessionSetup()) {
die('Session setup failed');
}
if (!SessionInit()) {
die('Session initialisation failed');
}
}
return true;
}
function DBInit() { //Get database parameters global $dbconfig; $dbtype = $dbconfig['dbtype']; $dbhost = $dbconfig['dbhost']; $dbname = $dbconfig['dbname']; $dbuname = $dbconfig['dbuname']; $dbpass = $dbconfig['dbpass'];
$dbfile = $dbconfig['dbfile']; // Database connection is a global (for now) global $dbconn; // Start connection
$dbconn = ADONewConnection($dbtype); if (strcmp($dbtype, 'sqlite') == 0)
{
$dbh = $dbconn->PConnect($dbfile);
}
elseif (strcmp($dbtype, 'postgres') == 0)
{
$dbh = $dbconn->Connect($dbhost, $dbuname, $dbpass, $dbname);
}
if (!$dbh) { $dbpass = ""; die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg()); }
global $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_NUM; // force oracle to a consistent date format for comparison methods later on if (strcmp($dbtype, 'oci8') == 0) { $dbconn->Execute("alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); }
return $dbconn; } function DBGetConn() {
return array(Polerio::DBInit());
}
function DBGetTables()
{
global $table;
return $table;
}
function PhpMyLibrary()
{
global $site_footer;
$some = "<small><a href=\"http://phpmylibrary.sourceforge.net\" target=\"_blank\">@</a> PhpMyLibrary</small>";
return $site_footer[1]."<br><br>".$some;
}
function Mail($recipient="", $subject="", $body="", $headers="")
{
mail($recipient, $subject, $body, $headers);
}
function GetBrowser()
{
/* Get the Browser data */
if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold", getenv("HTTP_USER_AGENT"))) || (ereg("X11", getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT"))) AND (!ereg("MSIE", getenv("HTTP_USER_AGENT"))) AND (!ereg("Konqueror", getenv("HTTP_USER_AGENT")))) $browser = "Netscape";
// Opera needs to be above MSIE as it pretends to be an MSIE clone
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -