douganmo1121 2014-09-29 23:24
浏览 35

Eurekalog“HTTP上传”:如何发送程序名称?

In several Delphi XE2 projects, I have set up Eurekalog to send bug reports via "HTTP upload" which works well, as I use a PHP script to catch the bug report, save it in a directory and send it to me via email:

<?php

require 'PHPMailerAutoload.php';

foreach ($_FILES as $key => $value)
{
    $uploaded_file = $_FILES[$key]['tmp_name'];
    $server_dir = 'upload/';
    $server_file = $server_dir . date("Y-m-d H-i-s ") . basename($_FILES[$key]['name']);
    $ext = strtoupper(pathinfo($server_file, PATHINFO_EXTENSION));
    if ($ext != 'EL')
    {
        continue;
    }
    if (move_uploaded_file($uploaded_file, $server_file))
    {
        echo '<html>';
        echo '<head>';
        echo '<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">';
        echo '<title>Bug submission</title>';
        echo '</head>';
        echo '<body>';
        echo 'Thank you!<br />';
        echo "<!--
";
        echo "<EurekaLogReply>Thank you for your feedback!</EurekaLogReply>
";        
        echo "-->";
        echo '</body>';
        echo '</html>';

        SendBugReportMessage('auserofmyprogram@usersofmyprogram.com',
                             'A User of my program',
                             'Eurekalog Bug Report',
                             'This is a bug report from Eurekalog.',
                             'eurekalog.bugreport@mysite.com',
                             $server_file,
                             basename($server_file)
                             );
    }    
}

function SendBugReportMessage($AFrom, $AFromName, $ASubject, $ABodyText, $ARecipient, $AFileToAttach, $ANameOfFile)
{
    $email = new PHPMailer();
    $email->From      = $AFrom;
    $email->FromName  = $AFromName;
    $email->Subject   = $ASubject;
    $email->Body      = $ABodyText;
    $email->AddAddress($ARecipient);
    $file_to_attach = $AFileToAttach;
    $email->AddAttachment($file_to_attach, $ANameOfFile);
    return $email->Send();
}

?>

Now I have several programs using this very same PHP script to upload their bug reports. However, the bug report sent to this PHP script has always the name "BugReport". So, in the PHP script how can I get the name of the program which sent the bug report, so I can save it by attaching the program name and include the program name in the mail subject? Or could there be a solution by implementing something on the side of the Delphi code? Or in Eurekalog?

Eurekalog version is 7.1.0.0

  • 写回答

2条回答 默认 最新

  • douweiluo0600 2014-10-07 14:46
    关注

    You can use web-fields for that. EurekaLog has OnCustomWebFieldsRequest event handler, which allow you to alter web-fields for any web-based send method (such as HTTP upload, bug trackers with HTTP API, etc.).

    Assign such event hanlder:

    uses
      EEvents;
    
    procedure AddApplicationName(const ACustom: Pointer; ASender: TObject { TELWebSender }; AWebFields: TStrings; var ACallNextHandler: Boolean);
    begin
      AWebFields.Values['Application'] := AnsiLowerCase(ExtractFileName(ParamStr(0)));
    end;
    
    initialization
      RegisterEventCustomWebFieldsRequest(nil, AddApplicationName);
    end.
    

    Then, you can access your new "Application" field from your script. For PHP it will be $_REQUEST["Application"] or $_POST["Application"]

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。