@nhadsall, Can you please disable impressions in the settings (Affiliates > Settings > General)?
Thread Starter
Nathan
(@nhadsall)
I’ve done that now. I assume that will fix it since that code won’t be run. But can we fix the code 🙂 It’s not a huge issue, but it’s clogging up the error log.
Thanks for the help!
@nhadsall, We have made some changes to the file that may fix this error on your site. Please contact us if you are interested in testing it: https://wpaffiliatemanager.com/contact/
Thread Starter
Nathan
(@nhadsall)
We deactivated that feature, but are still getting the error. I’ll send my contact info to you. Thanks!
@nhadsall, We have emailed you with an updated copy of the plugin. Please let us know if it fixes the issue.
Thread Starter
Nathan
(@nhadsall)
Sadly, it’s still there 🙁
header('Content-type: image/gif');
header('Connection: close');
// Output a 1x1 pixel transparent gif
ob_start();
echo base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
$length = ob_get_length();
header("Content-Length: $length");
It says the error is on line 21, so the ob_end_flush()
. It looks like data has already been sent out by time you are adding headers on line 10 and 11. Even it that is not true, line 18 is sending headers after an echo, which would also throw an error.
Thread Starter
Nathan
(@nhadsall)
Ah ha! I found it. The issue was different. I looked at the log file and realized it wasn’t the header! It was the gif output.
[28-Aug-2020 16:43:16 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/USER/public_html/wp-content/plugins/affiliates-manager/imp.php:15) in /home/USER/public_html/wp-content/plugins/affiliates-manager/classes/ClickTracking.php on line 40
line 40 is trying to set a cookie in the header!
if(!empty($aff_id)){
$cookie_life_time = wpam_get_cookie_life_time();
setcookie('wpam_id', $aff_id, $cookie_life_time, "/", COOKIE_DOMAIN);
}
-
This reply was modified 4 years, 7 months ago by
Nathan.
Thread Starter
Nathan
(@nhadsall)
Okay, once I realized that was the problem, I just moved the gif echo to the end:
<?php
/* Connection: close and Content-Length headers are sent, so that browsers disconnect
* early on to minimize connection time */
//The following outputs a 1x1 pixel gif. It is not really need for the functionality but nice to have.
ignore_user_abort(true);
// ob_end_clean();
$gif = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7');
$length = strlen( $gif );
header('Content-type: image/gif');
header('Connection: close');
header("Content-Length: $length");
//End of gif output.
require_once ("../../../wp-load.php");
require_once ("config.php");
require_once ("source/Tracking/RequestTracker.php");
if (isset($_GET[WPAM_PluginConfig::$RefKey])
&& get_option(WPAM_PluginConfig::$AffEnableImpressions)) {
try {
$requestTracker = new WPAM_Tracking_RequestTracker();
$request_data = array_map('strip_tags', $_GET);
$requestTracker->handleImpression($request_data);
} catch (Exception $e) {
wp_die("WPAM FAILED: " . $e->getMessage());
}
}
echo $gif;
exit;
Thread Starter
Nathan
(@nhadsall)
Just following up to see if you will be able to apply this fix or something similar so it doesn’t break again on the next update. Thanks!