Salve ragazzi,
ho un sistemino per una mailing list protetto da utente e password, vorrei eliminare il sistema di autenticazione e avrei bisogno di aiuto :-)
sono 2 file:
1) File mailadmin.php
Codice PHP:
<?
if (!$PHP_AUTH_USER || !$PHP_AUTH_PW)
{
// If empty, send header causing dialog box to appear
header('WWW-Authenticate: Basic realm="Mailing List admin"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
else
{
$tu = strtolower($PHP_AUTH_USER);
$pu = strtolower($PHP_AUTH_PW);
include("config.php");
if ($tu == strtolower($adminusername) && $pu == strtolower($adminpassword))
{
$fd = fopen ($listfile, "r");
$contents = fread ($fd, filesize ($listfile));
fclose ($fd);
$entries = explode(",",$contents);
for($i=0;$i<count($entries);$i++)
{
if ($entries[$i] != "")
$choices .= "<OPTION VALUE=\"$entries[$i]\"> ".$entries[$i]."\n";
}
if ($cmd != "send")
{
$output = "
<form action=\"?cmd=send\" method=\"post\">
<table align=\"left\">
<tr>
<td>
<SELECT MULTIPLE SIZE=5 NAME=sendto[]>
<OPTION VALUE=\"All\" selected>Invia a tutti
$choices
</select>
</td>
</tr>
</table>
<table align=\"center\">
<tr>
<td nowrap>Oggetto</td><td><input type=\"text\" size=\"30\" name=\"subject\"></td>
</tr>
<tr>
<td nowrap valign=\"top\">Messaggio</td><td><textarea name=\"body\" rows=\"8\" cols=\"50\"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type=\"checkbox\" name=\"useheader\" value=\"yes\"> Includi Header <input type=\"checkbox\" name=\"usefooter\" value=\"yes\"> Includi Footer</td>
</tr>
<tr>
<td></td>
<td><input type=\"submit\" value=\"Invia Mail\"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
";
}else
{
for ($i=0;$i<count($sendto);$i++)
{
echo "".$sendto[$i]."
";
}
$footerd = fopen ($footerfile, "r");
$thefooter = fread ($footerd, filesize ($footerfile));
fclose ($footerd);
$headerd = fopen ($headerfile, "r");
$theheader = fread ($headerd, filesize ($headerfile));
fclose ($headerd);
if ($useheader == "yes")
$message .= "".$theheader."\n\n";
$message .= "".$body."\n\n";
if ($usefooter == "yes")
$message .= "".$thefooter."";
if ($sendto[0] == "All")
{
for($i=0;$i<count($entries);$i++)
{
mail($entries[$i], $subject, $message,
"From: ".$fromemail."");
}
}
else
{
for($i=0;$i<count($sendto);$i++)
{
mail($sendto[$i], $subject, $message,
"From: ".$fromemail."");
}
}
$output = "sent";
}
echo $output;
}
else // Does output if username/password is incorrect
{
echo " <html><body>Invalid Login/Password</body></html> ";
}
}
2) File config.php
Codice PHP:
<?
error_reporting(0);
$listfile = "list.txt";
$headerfile = "header.txt"; // The header for an email message (when in admin you can choose not to include it)
$footerfile = "footer.txt"; // The footer for an email message (when in admin you can choose not to include it)
$adminusername = "nomeutente"; // Username for logging in to mailadmin.php
$adminpassword = "password"; // password for logging in to mailadmin.php
$fromemail = "Newsletter@assitcons.it"; // Email address the emails will be sent from.
$welcome = "welcome.html"; // file it redirects to after signing up
$goodbye = "goodbye.html"; // file it redirects to after removing yourself from the list
$error = "error.html"; // file it redirects to if its in invalid email etc
?>
Grazie a tutti
Gianluca