0

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 "<!--\n";
        echo "<EurekaLogReply>Thank you for your feedback!</EurekaLogReply>\n";        
        echo "-->";
        echo '</body>';
        echo '</html>';

        SendBugReportMessage('[email protected]',
                             'A User of my program',
                             'Eurekalog Bug Report',
                             'This is a bug report from Eurekalog.',
                             '[email protected]',
                             $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

5
  • 1
    This question has nothing to do with Delphi, as it onlyl concerns PHP. I'm removing the Delphi tag. Please use tags that are actually applicable to your question; the fact that an external application is written in a language does not mean that language applies to your PHP script. If you want to ask a question about how to change your Delphi code to add the application name to a EurekaLog exception report, please do so.
    – Ken White
    Sep 30, 2014 at 2:46
  • 1
    Come on, this is highly irrational! The question does NOT imply that a possible solution could be an addition to the PHP code NOR does it assume that a possible solution could be implemented in Delphi Code. If I knew whether the solution would come from Delphi or PHP code I wouldn't ask this question here. Please think logically! And BTW, who voted my question down? This is a perfectly legitimate question, it should get points up because it is a common problem when using the "HTTP upload" option in Eurekalog. A competent answer to this question would help a lot of people with Eurekalog. Sep 30, 2014 at 20:25
  • 1
    No, that's NOT asking for a PHP ONLY solution, because a possible solution could also be derived from a Delphi implementation and could solve the problem with a PHP counterpart in PHP. That's called INTEROPERABILITY, a topic which unfortunately is underestimated in Delphi: You CANNOT make a sharp separation between two programming languages when they cooperate together, which is the case here with Eurekalog operating from Delphi code and interacting with PHP code. Again: This is a real problem with the "HTTP upload" option in Eurekalog. A solution could help a lot of users. Sep 30, 2014 at 21:38
  • 1
    A question that describes PHP, includes PHP code, and asks for a PHP solution in this case could IMPLY a Delphi solution because the two interact with each other. "IMPLY" means that an external subject can be included without being explicitly mentioned. - And BTW, I've rephrased the question, so please remove the down-vote. Sep 30, 2014 at 21:56
  • 1
    Again, I see a lot of irrationality here at work ... Sep 30, 2014 at 22:01

2 Answers 2

1

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"]

0

For this particular task you can also use OnCustomFileName event handler to alter file name used for sending. You are interested in AFileType = ftZIP (if you are going to send packed .elp report) or AFileType = ftBugReport (if you are going to send unpacked .el report).

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.