Help debugging code for PHP5

Hi all,

I have zero coding knowledge of PHP, however an application requires a PHP script reside on our server (PHP5). After testing, the script is returning a generic error (from the developer). I have a feeling the code may not be compatible with PHP5. Could someone please take a quick look and advise if the code is PHP5 compatible?

[php]<?php

$SenderAddress = "[email protected]";

define(‘OCU_RELEASE’, ‘1.1’);
define(‘OCU_ERR’, !empty($_GET[‘err’]));

if (OCU_ERR) {
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘On’);
}
else {
error_reporting(0);
}

if (basename(FILE) == ‘1cu.php’) {
die(‘For your safety: you should really change the name of this file’);
}

if (!empty($_GET[‘test’])) {
die("OK: ".OCU_RELEASE);
}

if (empty($_GET[‘l’]) && empty($_GET[‘e’])) {
die(“OK”);
}

$l = isset($_GET[‘l’]) ? $_GET[‘l’] : ‘’;
$e = isset($_GET[‘e’]) ? $_GET[‘e’] : ‘’;
$m = isset($_GET[‘m’]) ? $_GET[‘m’] : ‘’;

$l = OCU_Unencode($l);
$e = OCU_Unencode($e);

$to = $l;
$subject = “Unsubscribe”;
$message = “Unsubscribe $e”;
$from = $e;
if ($SenderAddress != ‘test’.’@’.‘test’.‘com’) {
$from = $SenderAddress;
}

switch ($mode) {
case “1”:
$headers = “X-UserMail: $e”;
break;
case “2”:
$headers = “From: $from”;
break;
default:
$headers = “From: $from” . “\r\n” . “X-UserMail: $e”;
}

if (mail($to, $subject, $message, $headers)) {
Header(“Location: removal.htm”);
} else {
die(“There was an error processing your request; please manually send an email to $l with Unsubscribe as its subject”);
}

exit;

function OCU_Unencode($data) {
return base64_decode(strtr($data, ‘-_’, ‘+/’));
}
?>[/php]

It is PHP 5 compatible. It appears to be the 1-Click-Unsubscriber. You cannot run it all buy itself. It is expecting a query string in the url.

Hi benanamen,

Yes that is correct. 1-Click-Unsubscriber.

The string is included when clicking the “Unsubscribe” link in a mailing. It returns the error regardless of the string being included in the hyperlink unfortunately. The error returned is the error in the PHP code.

“There was an error processing your request; please manually send an email to $l with Unsubscribe as its subject”

EDIT: Solved - My host requires that I supply authentication info within the PHP script. Added and now working correctly.

Sponsor our Newsletter | Privacy Policy | Terms of Service