dpq59734 2015-12-13 22:45
浏览 145
已采纳

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

I am working on API for DHRU CMS.

Unfortunately there are NO API setting to modify API CALLs, I can only provide domain: www.mydomain.com and Press SYNC. Then it will make a call to www.mydomain.com/api/index.php

Content of /api/index.php below:

   <?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.
");
    }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
    n42bVdO8Xx4gEGoUd5OI3lCEqfl2ojsJVJ5rHz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k8ZK5UXs4cnZMTTBph5iTtdg+y
    eKukLtvt6xH2ymHsQdpaERn1ZQehrhjlnl0YGuVHJqq840A+bKqUVcbyJ3PdT8QuhWpYS5H1oBT8
    UcB3I15HN3KcKAATZJX6u9nV4iAlxKN3iZxqMfCAVpv9gAi99fXIEcvhkeoEi4ux4nYCDKVvJXnV
    8tznbh8FbfIGw7WVAcT49uzkgurX/UVACSYSMdn6wpTRTE==

I cant figure out what this contents means, but but the contents above is answer to API call. Now I am trying to figure out what it is asking for and how to reply. Here I have made a simple script to read values and dump them to TXT file. But file is empty.. No result so far with this code:

<?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);
?>

I have also tried $_POST, $_GET and $_REQUEST but no result.

Is there any other way I can dump result from a API call?

Thanks for helping me out.

  • 写回答

1条回答 默认 最新

  • douduoting8408 2015-12-13 23:35
    关注

    Example of fetching both $_GET and $_POST and write it to some logfile:

    <?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')."
    ");
    fwrite($fh, "
    RAW POST: =\t ".$rawpost."
    ");
    fwrite($fh, "
    RAW GET: =\t ".$rawget."
    ");
    fwrite($fh, "-------------------------------------------------------
    ");
    fclose($fh);
    ?>
    

    With the above if someone posts data with the GET and POST method it will write it to the logfile. Your log file will need the proper write permissions if you are on a Linux system.

    btw: The content of that index.php file is encoded with ionCube.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python题,根本不会啊
  • ¥15 Python题,不会啦
  • ¥15 LD衰减结果文件dist的单位?
  • ¥15 Python题,回答一下下啦
  • ¥15 利用Java语言结合数据库实现-个信息管理系统(如学生管理系统、图书管理系统(可以加上借书还书等功能等)或者小游戏
  • ¥15 会会信号与系统和python的来
  • ¥15 关于#python#的问题
  • ¥20 oracle RAC 怎么配置啊,配置
  • ¥15 excel 日常使用中出现问题
  • ¥20 pdusession建立失败