php数据接收转文件工具

本文是php中间件工具,作用是接收数据参数形成文件,文件作用给大家任意发挥.

提醒大家,这个文件需要做web工具访问的,配置也给大家弄好了.

<?php
error_reporting(0);
ini_set('magic_quotes_gpc', 0);
if(PHP_VERSION > '5.1') @date_default_timezone_set('PRC');

$mtime      = explode(' ', microtime());
$starttime  = $mtime[1] + $mtime[0];

define('APP_DEBUG', FALSE);
define('IN_APP', TRUE);
define('APP_ROOT', dirname(__FILE__).'/');
define('APP_DATADIR', dirname(dirname(__FILE__)).'/data/');
define('MAGIC_QUOTES_GPC', ini_get('magic_quotes_gpc'));

unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);

$_GET           = daddslashes($_GET, 1, TRUE);
$_POST          = daddslashes($_POST, 1, TRUE);
$_COOKIE        = daddslashes($_COOKIE, 1, TRUE);
$_SERVER        = daddslashes($_SERVER);
$_FILES         = daddslashes($_FILES);
$_REQUEST       = daddslashes($_REQUEST, 1, TRUE);

$game_id                = getgpc('game_id');
$host_name              = getgpc('host_name');
$time                   = getgpc('time');
$file_core              = getgpc('file_core');

//$game_id_int = intval($game_id);

$game_id = $game_id == NULL ? '' : $game_id;
$host_name = $host_name == NULL ? '' : $host_name;
$time = $time == NULL ? '' : $time;
$file_core = $file_core == NULL ? '' : $file_core;

$log_string = '{'.$game_id . ' | ' . $host_name . ' | ' . $time .' | '.$file_core.'}, ';
file_put_contents("/data/mail/log_file/run_log.txt", $log_string."\n", FILE_APPEND);
$date_string=date("y_m_d",time());
$report_file_name='/data/mail/log_file/'.$game_id.'_alarm.txt';
file_put_contents($report_file_name, $log_string."\n", FILE_APPEND);
exit;
$mtime = explode(' ', microtime());
$endtime = $mtime[1] + $mtime[0];
if(APP_DEBUG && !getgpc('inajax'))
{
        echo '<script>document.getElementById(\'debug_time\').innerHTML = \''.number_format($endtime - $starttime, 5).'\'</script>'."\n";
}

function daddslashes($string, $force = 0, $strip = FALSE) 
{
        if(!MAGIC_QUOTES_GPC || $force) 
        {
                if(is_array($string)) 
                {
                        foreach($string as $key => $val) 
                        {
                                $string[$key] = daddslashes($val, $force, $strip);
                        }
                } 
                else 
                {
                        $string = addslashes($strip ? stripslashes($string) : $string);
                }
        }
        return $string;
}

function getgpc($k, $t='R') 
{
        switch($t) 
        {
                case 'P': $var = &$_POST; break;
                case 'G': $var = &$_GET; break;
                case 'C': $var = &$_COOKIE; break;
                case 'R': $var = &$_REQUEST; break;
        }
        return isset($var[$k]) ? (is_array($var[$k]) ? $var[$k] : trim($var[$k])) : NULL;
}

function debuglog($action, $extra = '') 
{
    $time = time();
        $logfile = APP_DATADIR.'/logs/'.$action.'.php';
        if(@filesize($logfile) > 2048000) 
        {
                PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
                $hash = '';
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
                for($i = 0; $i < 4; $i++) 
                {
                        $hash .= $chars[mt_rand(0, 61)];
                }
                @rename($logfile, SITE_ROOT.'./logs/'.$action.'_'.$hash.'.php');
        }
        if($fp = @fopen($logfile, 'a')) 
        {
                @flock($fp, 2);
                $timestamp=date("y-m-d H:i:s",time());
                @fwrite($fp,$timestamp.str_replace(array('', '', ''), '', var_export($extra, TRUE))."\n");
                @fclose($fp);
        }
}
?>
web配置工具
server
{
    listen 端口;
    root  路径;
    index *.php index.html index.htm;
    
    location ~ .*.php$ 
    {
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
       #fastcgi_index  index.php;
       fastcgi_read_timeout 300;
       #include        fastcgi.conf;
       include        fastcgi_params;
    }
     
    error_page 404 /40x.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html 
    {
       root /usr/share/nginx/html;
    }
    location = /40x.html 
    {
       root /usr/share/nginx/html;
    }
    access_log ...._access.log  main;
    error_log  ...._error.log  error;
}