'mac-xwhep',
'134.158.89.155' => 'lodygensky',
'134.158.90.77' => 'urbah' );
$b_db_selectable = TRUE;
/*--------------------------------------------------------------------------*/
$remoteAddr = $_SERVER['REMOTE_ADDR'];
$serverName = $_SERVER['SERVER_NAME'];
$scriptName = $_SERVER['PHP_SELF'];
$scriptFolder = substr($scriptName, 0,
strrpos($scriptName, DIRECTORY_SEPARATOR) + 1);
$b_verbose = ( strpos($scriptName, 'verbose') !== FALSE );
$b_maintainer = array_key_exists($remoteAddr, $maintenanceAddrs);
/*
echo "\$maintenance = '", $maintenance, "'
\n";
echo "(\$maintenance === 'ALL') = '", ($maintenance === 'ALL'), "'
\n";
echo "\$b_maintainer = '", $b_maintainer, "'
\n";
*/
if ( ($maintenance === 'ALL') or ($maintenance and ! $b_maintainer) )
{
if ( $maintenance === 'ALL' )
{ header($_SERVER['SERVER_PROTOCOL'].' 503 Service Unavailable'); }
echo '
', $serverName. ' : ', $scriptName,
' : Server maintenance';
?>
2015/01/12
This server is under maintenance.
Services would be available soon.
Sorry for inconveniences.
Oleg Lodygensky
\n",
" \n",
" ", $serverName, " : ", $scriptName, "\n",
' ',
"\n",
' \n",
" \n",
" \n";
if ( $b_verbose )
{
echo " $scriptName : $serverName called from $remoteAddr
\n",
" $scriptName : Server Protocol : '$server_protocol'
\n",
" $scriptName : Request method : '$request_method'
\n",
" $scriptName : Path Info : '$path_info'
\n",
" $scriptName : Query string : '$query_string'
\n",
" $scriptName : Arguments : ", count($arguments), " : '",
implode("' '", $arguments), "'
\n",
" $scriptName : "; var_dump($arg_vars); echo "
\n",
"
\n",
" $scriptName : HTTPS : '$https'
\n",
" $scriptName : Forw. Protocol : '$forw_protocol'
\n",
" $scriptName : Forw. SSL : '$forw_ssl'
\n",
" $scriptName : SSL Protocol : '$ssl_protocol'
\n",
" $scriptName : Request Protocol : HTTP",
($is_HTTPS ? 'S' : ''), "
\n";
}
if ( ! $is_HTTPS )
{
echo " $scriptName : NOT called using HTTPS
\n";
return;
}
/*--------------------------------------------------------------------------
Analyse X509 certificate of the Client
--------------------------------------------------------------------------*/
$ssl_client_cert = $_SERVER['SSL_CLIENT_CERT'];
$x509_issuer = $_SERVER['SSL_CLIENT_I_DN'];
$x509_subject = $_SERVER['SSL_CLIENT_S_DN'];
$x509_verified = $_SERVER['SSL_CLIENT_VERIFY'];
if ( $b_verbose )
{
echo "
\n",
" $scriptName : SSL Client Cert : ",
(empty($ssl_client_cert) ? 'Absent' : 'Present '), "
\n",
" $scriptName : X509 Issuer : '$x509_issuer'
\n",
" $scriptName : X509 Subject : '$x509_subject'
\n",
" $scriptName : X509 verified : '$x509_verified'
\n";
}
if ( ($x509_verified === 'NONE') or empty($x509_issuer)
or empty($x509_subject) )
{
echo " $scriptName : NO verified X509 certificate
\n";
return;
}
if ( isset($ssl_client_cert) )
{
$cert_data = openssl_x509_parse($ssl_client_cert);
$common_name = ( is_array($cert_data['subject']['CN']) ?
$cert_data['subject']['CN'][0] :
$cert_data['subject']['CN']);
if ( $b_verbose )
{ echo " $scriptName : Common Name : '$common_name'
\n"; }
}
echo ' ', "\n",
' XtremWeb-HEP Billing : ', $view,
"
\n
\n";
/*--------------------------------------------------------------------------
Verify that the PHP function permitting to connect to MySQL is available.
When using 'yum', this function is provided by the 'php-mysql' package.
--------------------------------------------------------------------------*/
$mysql = 'mysqli';
$mysql_connect = $mysql.'_connect';
$mysql_connect_available = function_exists($mysql_connect);
if ( ! $mysql_connect_available )
{
echo " $scriptName : Function '", $mysql_connect,
"' is NOT available
\n";
return;
}
elseif ( $b_verbose )
{ echo " $scriptName : Function '", $mysql_connect,
"' is available
\n"; }
/*--------------------------------------------------------------------------
Database server, database user and schema
--------------------------------------------------------------------------*/
$variableNames = array('dbserver', 'dbuser', 'dbschema');
if ( $b_db_selectable )
{
foreach ( $variableNames as $variableName )
{ ${$variableName} = $arg_vars[$variableName]; }
if ( $b_verbose )
{ echo " $scriptName : dbserver='$dbserver', ",
"dbuser='$dbuser', dbschema='$dbschema'
\n"; }
}
$b_database_specified = TRUE;
foreach ( $variableNames as $variableName )
{
if ( empty(${$variableName}) )
{ $b_database_specified = FALSE; }
}
/*--------------------------------------------------------------------------
If necessary, read database configuration file
--------------------------------------------------------------------------*/
if ( ! $b_database_specified )
{
$configFileName = 'database.conf';
$configFilePath = /* $scriptFolder. */ $configFileName;
if ( $b_verbose )
{ echo " $scriptName : File '$configFilePath'
\n"; }
$lines = file($configFilePath, FILE_IGNORE_NEW_LINES);
if ( $lines === FALSE )
{
echo " $scriptName : File '$configFilePath' : Read ERROR
\n";
return;
}
if ( $b_verbose )
{ echo " $scriptName : File '$configFilePath' has ", count($lines),
" lines
\n"; }
foreach ( $lines as $myLine )
{
$myLine = ltrim($myLine);
if ( $myLine[0] === '#' )
{ continue; }
$tokens = explode('=', $myLine);
$token0 = trim($tokens[0]);
foreach ( $variableNames as $variableName )
{
if ( ($variableName === $token0) and (empty(${$variableName})) )
{ ${$variableName} = trim($tokens[1]); }
}
}
unset($lines);
$b_database_specified = TRUE;
}
/*--------------------------------------------------------------------------
Create a form for begin date, end date and view names
--------------------------------------------------------------------------*/
echo ' \n"; }
}
mysqli_free_result($resultSet);
$b_list_views = FALSE;
/*------------------------------------------------------------------------
If the user has selected a view, build the associated query string
------------------------------------------------------------------------*/
if ( empty($query_view) or $b_bad_date )
{ unset($sql_query); }
else
{
$sql_query = "select * from ".$query_view;
/*------------------------------------------------------------------
Restrict to records belonging to the current user
------------------------------------------------------------------*/
if ( $userRightId < $userRightId_SuperUser )
{
unset($customer_title);
if ( strpos($query_view, 'View_Customer') === 0 )
{ $customer_title = 'CustomerAccount'; }
elseif ( strpos($query_view, 'View_Billing_') === 0 )
{ $customer_title =
( strpos($query_view, '_With_Long_Titles') ?
'CustomerAccount' :
'Cust' ); }
if ( isset($customer_title) )
{
$sql_query .=
" where ( (".$customer_title." = '".$login."')";
$sql_query .= ( strpos($dbschema, "test") !== FALSE ?
" or (".$customer_title." = 'oleg') )" :
" )" );
}
}
/*------------------------------------------------------------------
Restrict to records between begin and end dates
------------------------------------------------------------------*/
if ( $query_view === 'View_Billing_By_Day' )
{ $sql_query .= " and (Day >= '".$begin_date."')".
" and (Day <= '".$end_date ."')"; }
elseif ( $query_view === 'View_Billing_By_Day_With_Long_Titles' )
{ $sql_query .= " and (BillingDay >= '".$begin_date."')".
" and (BillingDay <= '".$end_date ."')"; }
elseif ( $query_view === 'View_Billing_By_Hour' )
{ $sql_query .=
" and (left(Hour, 10) >= '".$begin_date."')".
" and (left(Hour, 10) <= '".$end_date ."')"; }
elseif ( $query_view === 'View_Billing_By_Hour_With_Long_Titles' )
{ $sql_query .=
" and (left(BillingHour, 10) >= '".$begin_date."')".
" and (left(BillingHour, 10) <= '".$end_date ."')"; }
elseif ( $query_view === 'View_Billing_By_Month' )
{ $sql_query .=
" and (Month >= '".substr($begin_date, 0, 7)."')".
" and (Month <= '".substr($end_date , 0, 7)."')"; }
elseif ( $query_view === 'View_Billing_By_Month_With_Long_Titles' )
{ $sql_query .=
" and (BillingMonth >= '".substr($begin_date, 0, 7)."')".
" and (BillingMonth <= '".substr($end_date , 0, 7)."')"; }
elseif ( strpos($query_view, 'View_Billing_Details') === 0 )
{ $sql_query .=
" and (left(completedDate, 10) >= '".$begin_date."')".
" and (left(completedDate, 10) <= '".$end_date ."')"; }
}
}
mysqli_close($connection);
echo " \n";
echo "\n";
?>