如何在PHP中将DUMP API请求信息发送到TXT文件?

时间:2015-12-13 22:45:50

标签: php api

我正在为DHRU CMS开发API。

不幸的是,没有API设置来修改API CALL,我只能提供域:www.mydomain.com和按SYNC。然后它会打电话给www.mydomain.com/api/index.php

下面的/ api / index.php 的内容:

   <?php
    if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));
    $__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');
    if(function_exists('dl')){@dl($__ln);}if(function_exists('_il_exec')){return _il_exec();
    }
    $__ln='/ioncube/'.$__ln;
    $__oid=$__id=realpath(ini_get('extension_dir'));
    $__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));
    $__here=str_replace('\\','/',substr($__here,2));
    }$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';
    $__i=strlen($__rd);
    while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;
    break;
    }}}if(function_exists('dl')){@dl($__ln);
    }}else{die('The file '.__FILE__." is corrupted.\n");
    }if(function_exists('_il_exec')){return _il_exec();
    }echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the website operator. If you are the website operator please use the <a href="http://www.ioncube.com/lw/">ionCube Loader Wizard</a> to assist with installation.');
    exit(199);
    ?>
    HR+cP/ElGN2OERf73MJKKmN0O3NzOb4pGJD4uAtGY1PaUwYj7l+JHDMBep4pqmahy4Kl4sfAGrTZ
    aL2G93Ks855rHFW7zCB0T54xRH9H3qrSrF0bW8cu82ephdXnKG7gU+xqeIGYrhCDtjkrnbjxfTW6
    SPgO1ywEMkU6IXNYZ/qD4SE3xzccXKU68rw9qYO6SWnfNL48ek9+x1+AhB1etCJY5QRNVub/Y7XI
    n42bVdO8Xx4gEGoUd5OI3lCEqfl2ojsJVJ5rHz8glJ798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5UXs4cnZMTTBph5iTtdg+y
    eKukLtvt6xH2ymHsQdpaERn1ZQehrhjlnl0YGuVHJqq840A+bKqUVcbyJ3PdT8QuhWpYS5H1oBT8
    UcB3I15HN3KcKAATZJX6u9nV4iAlxKN3iZxqMfCAVpv9gAi99fXIEcvhkeoEi4ux4nYCDKVvJXnV
    8tznbh8FbfIGw7WVAcT49uzkgurX/UVACSYSMdn6wpTRTE==

我无法弄清楚这些内容的含义,但上面的内容是API调用的答案。现在我想弄清楚它的要求以及如何回复。 在这里,我创建了一个简单的脚本来读取值并将它们转储到TXT文件中。 但是文件是空的。到目前为止这个代码没有结果:

<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$text = var_dump($__oc);
fwrite($myfile, $text);
$text = var_dump($__ln);
fwrite($myfile, $text);
$text = var_dump($__oid);
fwrite($myfile, $text);
$text = var_dump($__id);
fwrite($myfile, $text);
$text = var_dump($__here);
fwrite($myfile, $text);
$text = var_dump($__id);
fwrite($myfile, $text);
$text = var_dump($__rd);
fwrite($myfile, $text);
$text = var_dump($__i);
fwrite($myfile, $text);
$text = var_dump($__lp);
fwrite($myfile, $text);
fclose($myfile);
?>

我也尝试了$ _POST,$ _GET和$ _REQUEST,但没有结果。

我可以通过API调用转储结果吗?

感谢您帮助我。

1 个答案:

答案 0 :(得分:1)

获取$ _GET和$ _POST并将其写入某个日志文件的示例:

<?php
$rawpost = print_r($_POST, true);
$rawget = print_r($_GET, true);

$logfile = "/full/path/to/log/file/logfilename.log";
$fh = fopen($logfile,'a') or die("can't open the file");
fwrite($fh, "DATE: ".date('l jS \of F Y h:i:s A')."\r\n");
fwrite($fh, "\r\nRAW POST: =\t ".$rawpost."\r\n");
fwrite($fh, "\r\nRAW GET: =\t ".$rawget."\r\n");
fwrite($fh, "-------------------------------------------------------\r\n");
fclose($fh);
?>

如果有人使用GET和POST方法发布数据,它会将其写入日志文件。如果您使用的是Linux系统,则您的日志文件将需要正确的写入权限。

顺便说一句:index.php文件的内容是用ionCube编码的。