Unsubscrib.php

Rich

New Member
My website host (earthlink) has changed their PHP from 5.3 to 5.6 and now my unsubscribe script does not work. Is there any change that can be made in the following (original) maxprog script:


<?php
/***************************************************************************
* unsubscribe.php
* -------------------
* begin : Monday, Jan 30, 2006
* copyright : (C) 2006 MaxProgramming, LLC
* email : [email protected]
*
***************************************************************************/

import_request_variables('GPC'); // In case register_globals = OFF in php.ini

// or
// $admin = $_GET['admin'];
// $email = $_GET['email'];

//--SETTINGS--------------------------------------------------------------------

$filename = 'unsubscribe.txt'; // Data file path
$password = 'admin'; // Admin panel password

// Set a page URL for the response
$success_url = "";

// Set a text for the response
$success_text = "<html>\n";
$success_text .= "<head><title>Address removed successfully</title></head>\n";
$success_text .= "<body bgcolor=#ADDFFF>\n";
$success_text .= "The address <a href=mailto:$email>$email</a> has been successfully removed from our database.<br>\n";
$success_text .= "You will no longer receive messages from us.<br>\n";
$success_text .= "Thank you for the service you give in behalf of Catholic Education.";
$success_text .= "</body>\n";
$success_text .= "</html>\n";

//--SCRIPT----------------------------------------------------------------------

$handle = fopen($filename, "a+"); // Open the file, create it if necessary and place pointer to end
$fcontents = file($filename);

if ($admin == $password) {

while (list ($line_num, $line) = each ($fcontents)) { // while there are elements in the array
$line = str_replace("\n", "", $line);
$line = str_replace($line, "<a href=mailto:$line>$line</a><br>\n", $line);
$page .= $line;
}
echo $page;

} else {
if ($email <> "") {
$exists = False;
$count = 0;
while (list ($line_num, $line) = each ($fcontents)) { // while there are elements in the array
$line = str_replace("\n", "", $line);
if (strcmp($email, $line) == 0) {
$exists = True;
}
$count++;
}

if (!$exists) {
if ($count > 0) { $newemail .="\n"; }
$newemail .= $email;
if (flock($handle, LOCK_EX)) {
fputs($handle, $newemail);
flock($handle, LOCK_UN);
}
}

fclose($handle);

if ($success_url <> "") {
header("Location: $success_url");
} else {
echo $success_text;
}
}
}

?>
 

stanbusk

Administrator
Staff member
Just replace this:

import_request_variables('GPC'); // In case register_globals = OFF in php.ini

Code:
// or
// $admin = $_GET['admin'];
// $email = $_GET['email'];

by this:

//import_request_variables('GPC'); // In case register_globals = OFF in php.ini

Code:
// or
$admin = $_GET['admin'];
$email = $_GET['email'];

--
Follow maxprog.com on Facebook | Google+ | Linkedin | Twitter | YouTube
and keep up-to-date with the latest Max Programming updates!
 
Top