PX : code

Flexphpsite by anna
Download this code


<?php

/*

http://www.china-on-site.com/flexphpsite/

This function can return the date of Chinese lunar calendar which is corresponding to the Gregorian calendar. Range from Jan  1st,1901 to Feb 11th,2021.

How to use:

Array getchinesedate(int year,int month,int day); year,month,day are the year, month, day of the Gregorian calendar.

Returns an array with 6 elements. Index 0 contains the year of the Chinese lunar calendar, index 1 contains the month of it. index 2 is the day of it, index 3 contains 1( if the month is a leap month ) and 0 ( if not ), index 4 is the Heavenly Stems of the Chinese lunar calendar, and index 5 contains the Earthly Branches of it.

The Chinese Lunar Calendar is a yearly one, with the start of the lunar year being based on the cycles of the moon. Therefore, because of this cyclical dating, the beginning of the year can fall anywhere between late January and the middle of February. A complete cycle takes 60 years and is made up of five cycles of 12 years each. 

A cycle of Twelve Terrestrial Branches5 (Zi, Chou, Yin, Mao, Chen, Si, Wu, Wei, Shen, You, Xu, Hai), correlated with Ten Celestial Trunks6 (Jia, Yi, Bing, Ding, Wu, Ji, Geng, Xin, Ren, Gui), forms sixty units to mark the year, month, day and hour. And each unit has its own name, for example, General Jinbian of the Supreme Year Jiazi, General Chencai of the Supreme Year Yichou, etc.

We also offer customization service. If you want to add new functions to your program, or want to give your program a new look and feel, please let us know your need.The most important, we charge you the incredible low price--only $5/h. (flexcustom@china-on-site.com) Meanwhile,if you have other project like website design,translation(English--Chinese) and programming, you can also outsource it to us.We offer the best service and the lowest price. ( outsource@china-on-site.com)

*/

//settings

$logwriter_logformat "combined"// log format,combined or common
$logwriter_logdir "C:/apache/htdocs/logwriter/"// physical path where your log file located
$logwriter_logfilename "access.log"// your log file's filename
$logwriter_timezone "+0800"// your server's time zone. +0800 means GMT+8



function logwriter_writelog($logstring){
    
    global 
$logwriter_logdir,$logwriter_logfilename;
    
$fullpathfilename $logwriter_logdir.$logwriter_logfilename;
    
    if (!
is_file($fullpathfilename)) {
        print 
"Log file doesn't exist or file is corrupt.";
        return;
    }
    
    if (!
is_writeable($fullpathfilename)) {
        print 
"Log file is not writable,please change its permission.";
        return;
    }
    
    if(
$fp = @fopen($fullpathfilename"a")) {
           
flock($fp2);
               
fputs($fp$logstring);               
               
fclose($fp);               
     }
}

function 
logwriter_handlevar($varname,$defaultvalue) {
    
$tempvar getenv($varname);
    if(!empty(
$tempvar)) {
    return 
$tempvar;
    } else {
    return 
$defaultvalue;
    }
}

if (!empty(
$REMOTE_HOST)) {
$logwriter_remote_vistor $REMOTE_HOST;
}else{
$logwriter_remote_vistor logwriter_handlevar("REMOTE_ADDR","-");
}

$logwriter_remote_ident logwriter_handlevar("REMOTE_IDENT","-");
$logwriter_remote_user logwriter_handlevar("REMOTE_USER","-");
$logwriter_date date("d/M/Y:H:i:s");

$logwriter_server_port logwriter_handlevar("SERVER_PORT","80");
if(
$logwriter_server_port!="80") {
$logwriter_server_port =  ":".$logwriter_server_port;
}else{
$logwriter_server_port =  "";
}

$logwriter_request_method logwriter_handlevar("REQUEST_METHOD","GET");
$logwriter_request_uri logwriter_handlevar("REQUEST_URI","");
$logwriter_server_protocol logwriter_handlevar("SERVER_PROTOCOL","HTTP/1.1");

if (
$logwriter_logformat=="common") {
$logwriter_logstring "$logwriter_remote_vistor $logwriter_remote_ident $logwriter_remote_user [$logwriter_date $logwriter_timezone] \"$logwriter_request_method $logwriter_request_uri $logwriter_server_protocol\" 200 -\n";
}else{

$logwriter_http_referer logwriter_handlevar("HTTP_REFERER","-");
$logwriter_http_user_agent logwriter_handlevar("HTTP_USER_AGENT","");

$logwriter_logstring "$logwriter_remote_vistor $logwriter_remote_ident $logwriter_remote_user [$logwriter_date $logwriter_timezone] \"$logwriter_request_method $logwriter_request_uri $logwriter_server_protocol\" 200 - \"$logwriter_http_referer\" \"$logwriter_http_user_agent\"\n";

}

logwriter_writelog($logwriter_logstring);

?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.