Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/02/2008, 19:23
nanoweb
 
Fecha de Ingreso: septiembre-2006
Mensajes: 10
Antigüedad: 18 años, 5 meses
Puntos: 0
Aolicación no funciona en PHP5

Hola, amigos.

Bueno, el eterno problema...

Tengo una aplicaión en Flash + PHP y funciona perfectamente en un servidor con php4.
La llevo a otro Server con PHP5 y deja de funcionar.

Les paso el código a ver si me pueden decir que variables tengo que cambiar para que PHP5 me lo haga funcionar.

Consta de 3 archivos .php que paso a continuación

configure.php
[CODE<?php
// |||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||

// Set the user name for the newletter editor
$admin_username = "myusername";

// Set the password for the newletter editor
$admin_password = "mypassword";

// |||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||

// Name of the datafile, set file permissions to 666 or 777
$file_location = "subscribers.txt";

// Your email
$your_email = "[email protected]";

// Pattern for filtering out own emails
$pattern = "yoursite.com";

// Select the type of mail to send. false for text emails, true for html emails.
$html_email = false;

// |||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||

// Sorry message for failed subscription
$sorry_subscribe_message = "Sorry, but there is already an entry for $email";

// Sorry message for blank email
$sorry_blankmail_message = "Sorry, but you will have to enter an email address.";

// Sorry message for invalid emails
$sorry_oddmail_message = "Sorry, but \"$email\" does not look like an email to me.";

// Sorry message if someone entered your own mail
$sorry_ownmail_message = "Sorry, but I don't really want to get my own newsletter!";

// Subscribe message, will be shown when someone subscribes
$subscribe_message = "Thank you for subscribing to my newsletter, a confirmation email is on its way!";

// Unsubscribe message for deletion
$unsubscribe_message = "$email was deleted. You will not recieve any more newsletters.";

// Unsubscribe message for failed deletion
$failed_unsubscribe_message = "Sorry, you cannot unsubscribe as I didn't find an entry for $email";

// |||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||

// Title of the newsletter, will be displayed in the FROM field of the mail client
$mail_from = "Yoursite Newsletter";

// Subscribe mail, the email subject that will be sent when someone subscribes
$subscribe_mail_subject = "Thank you for subscribing.";

// Subscribe mail, the message that will be sent when someone subscribes
$subscribe_mail_body = "Thank you for subscribing to my newsletter.\nYou can unsubscribe at any time by returning to http://www.yoursite.com/newsletter/.";

// Newsletter mail header, this message will be attached to the top of the newsletter
$newsletter_premail = "Hello!\n\n";

// Newsletter mail footer, this message will be attached to the bottom of the newsletter
$newsletter_postmail = "\n\nTake care,\nYour Name\n\nYou can unsubscribe at any time by returning to http://www.yoursite.com/newsletter/.";

// |||||||||||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||
?>
[/CODE]

admin.php
Código:
<?php
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

require("configure.php");

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

function render_header(){
global $PHP_SELF;
echo "<html>
<head>
<title>Newletter Admin</title>
<style type=\"text/css\">
body {background-color: #fff; margin: 10px;}
h1,h2 {font-family: verdana,sans-serif; font-size: 11px; font-weight: normal; padding: 5px}
h1 {background-color: #999;}
h2 {background-color: #ccc;}
p,a,input,textarea {font-family: verdana,sans-serif; font-size: 11px; color: #000;}
a {color: #00f; text-decoration: none;}
a:hover {text-decoration: underline;}
a:visited {color: #609;}
pre {font-size: 11px; background-color: #eee; padding: 5px;}
input.button {padding: 1px 10px 1px 10px; cursor: pointer;}
textarea {width: 500px; height: 250px; padding: 5px;}
</style>
</head>
<body>
<h1>Newletter Admin</h1>
";}

function render_footer(){
echo "</body>
</html>
";}

function render_nav(){
echo "<h2><a href=\"$PHP_SELF?cmd=logout\">Logout</a></h2>
";}

function render_login($message){
global $PHP_SELF;
echo "<h2>$message</h2>
<form action=\"$PHP_SELF\" method=\"post\">
<p>Username<br /><input type=\"text\" class=\"text\" name=\"username\" value=\"\" /></p>
<p>Password<br /><input type=\"password\" class=\"text\" name=\"password\" value=\"\" /></p>
<p><input type=\"submit\" class=\"button\" name=\"login\" value=\"Login\" /></p>
<p>(Cookies must be enabled to maintain a user session.)</p>
</form>
<script type=\"text/javascript\">document.forms[0].username.focus();</script>
</body>
</html>
";}

function render_editor(){
global $PHP_SELF, $subject, $message;
echo "<form action=\"$PHP_SELF\" method=\"post\">
<input type=\"hidden\" name=\"cmd\" value=\"send\" />
<p>Subject:<br />
<input type=\"text\" class=\"text\" name=\"subject\" value=\"$subject\" /></p>
<p>Message:<br />
<textarea cols=\"70\" rows=\"10\" name=\"message\">".stripslashes($message)."</textarea></p>
<p><input type=\"submit\" class=\"button\" name=\"submit\" value=\"send\" /> <input type=\"submit\" class=\"button\" name=\"submit\" value=\"preview\" /></p>
</form>
";}

function render_preview(){
	global $your_email;
	echo "<p>A test email has been sent to $your_email</p>";
	render_editor();
}

function logout(){
	global $PHP_SELF;
	session_destroy();
	header("Location: $PHP_SELF");
	exit;
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

session_start();
session_register("SESSION_USER");
if(empty($SESSION_USER)){
	if($username != $admin_username || $password != $admin_password){
		render_header();
		render_login((!isset($username) && !isset($password)) ? "Please Login." : "Incorrect Username or Password.");
		render_footer();
		exit;
	}else{
		$SESSION_USER = $admin_username;
	}
}
if($cmd == "logout"){
	logout();
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

render_header();
render_nav();

$fp = fopen($file_location,"r");
$file_data = fread($fp, filesize($file_location));
fclose($fp);
$file_data = stripslashes($file_data);
$rows = explode("%",$file_data);

if($cmd == "send"){
	$mail_subject = stripslashes($subject);
	$mail_body = stripslashes($newsletter_premail.$message.$newsletter_postmail);
	$mail_headers = "From: $mail_from <$your_email>";
	if($html_email){
		$mail_headers .= "\r\nContent-Type: text/html; charset=iso-8859-1";
	}
	switch($submit){
	case "send":
		$recipients = "";
		foreach($rows as $i){
			if($i != ""){
				mail($i, $mail_subject, $mail_body, $mail_headers);
				$recipients .= "$i<br />";
			}
		}
		if(!$html_email){
			$mail_body = str_replace("<", "&lt;", $mail_body);
			$mail_body = str_replace(">", "&gt;", $mail_body);
		}
echo "<p>The following email has been sent to:<br />
$recipients</p>
<pre>$mail_headers</pre>
<pre>Subject: $mail_subject</pre>
<pre>$mail_body</pre>
";
		break;
	case "preview":
		mail($your_email, $mail_subject, $mail_body, $mail_headers);
		render_preview();
	}
}else{
	render_editor();
}

render_footer();

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?>
newsletter.php
Código:
<?php
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

// Variables sent from Flash:
// $cmd ("subscribe" || "unsubscribe")
// $email

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

error_reporting(0);
require("configure.php");

function valid_email($string){
	return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i", $string);
}

$fp = fopen($file_location,"r");
$file_data = fread($fp, filesize($file_location));
fclose($fp);
$file_data = stripslashes($file_data);
$rows = explode("%",$file_data);
$subscribers = "";
$emailfound = false;
foreach($rows as $i){
	if($i != ""){
		if($i != $email){
			$subscribers .= "%$i";
		}else{
			$emailfound = true;
		}
	}
}
switch($cmd){
case "subscribe":
	if($emailfound == true){
		$message = $sorry_subscribe_message;
	}
	else if($email == ""){
		$message = $sorry_blankmail_message;
	}
	else if(!valid_email($email)){
		$message = $sorry_oddmail_message;
	}
	else if(preg_match("/".$pattern."/",$email)){
		$message = $sorry_ownmail_message;
	}
	else{
		$fp = fopen($file_location,"a");
		$add = "%".$email;
		flock($fp, 1);
		fwrite($fp, $add);
		flock($fp, 3);
		fclose($fp);
		$mail_headers = ($html_email) ? "\r\nContent-Type: text/html; charset=iso-8859-1" : "";
		mail($your_email, "New Newsletter Subscriber", "$email has subscribed to your newsletter.", "From: $mail_from <$email>".$mail_headers);
		mail($email, $subscribe_mail_subject, $subscribe_mail_body, "From: $mail_from <$your_email>".$mail_headers);
		$message = $subscribe_message;
		$email = "";
	}
	break;
case "unsubscribe":
	if($emailfound == true){
		$fp = fopen($file_location,"w");
		fwrite($fp, $subscribers);
		fclose($fp);
		$message = $unsubscribe_message;
		$email = "";
	}else{
		$message = $failed_unsubscribe_message;
	}
}

echo "email=$email&message=$message";

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?>
Les agradecería que le echaran un vistazo a ver si pueden dar con la solución

Saludos