Witam. Potrzebuje pomocy odno¶nie jednego skryptu (newsletter-a). Otó¿ brakuje w nim blokady tego samego e-maila, tzn ¿e mo¿na dodaæ kilka razy ten sam e-mail, jak równie¿ skrypt pozwala na dodanie pustego pola (pustka). St±d moje skromne ;-) pytanko : co nale¿a³o by dodac, wstawiæ aby za³ataæ t± luke
link do skryptu:
Mailinglista napisana w php i oparta o pliki tekstowea teraz pliki:
subscribe.php<?
/* PASTE THIS CODE SOMEWHERE IN YOUR PAGE, CHANGE FORMATTING AT YOUR PLEASURE */
// Displays the form to add emails to list;
$filelist = \"emails.txt\";
addEntry($email);
}
function displayAddEntryForm() {
echo \"Subscribe:\"; echo \"<form name=addEntry action=subscribe.php method=post>\"; echo \"<input type=text name=email>\"; echo \"<input type=submit name=submit value=subscribe>\"; }
// Adds emails to list;
function addEntry($email) {
$fp = fopen($GLOBALS[\"filelist\"], \"a\"); $emailsize = strlen($email . \"n\"); $fw = fwrite($fp, $email . \"n\", $emailsize); if ($fw)
echo \"<h2><div align=center>You have subscribed successfully!</div></h2>\"; else
}
displayAddEntryForm();
?>
oraz
admin_mailing.php<?
// Some variables;
// Your emails list file;
$filelist = \"emails.txt\";
// Email headers that subscribed users see
// when you send them an email;
$adminmail = \"webmaster@php.inc.ru\";
$emailheaders = \"From: \" . $adminmail . \"nReply-To: \" . $adminmail;
// By default we display entries;
$mode = \"unknown\";
// Since all administration is in one file,
// we choose what to to do now;
switch ($mode) {
case \"create\": createList(); break;
case \"display\": displayEntries($filelist); break;
case \"add\": addEntry($email); break;
case \"edit\": displayEditForm($id); break;
case \"doEdit\": editEntry($email, $oldvalue); break;
case \"delete\": deleteEntry($id); break;
case \"send\": sendNews($subject, $message); break;
default:
displayEntries(); displayAddEntryForm();
}
}
/* THIS IS THE PART WHERE WE CREATE A MAILING LIST FILE AUTOMATICALLY */
/* IGNORE IT IF YOU HAVE CREATED IT MANUALLY (NOTHING WILL BE DISPLAYED */
echo \"<h2>Please, make sure you have 777 permissions for current directory to create the mailing list
file and click the button or
create it manually and set 666 permissions on it</h2>\";
echo \"<form name=createFile action=admin_mailing.php method=post>\"; echo \"<input type=submit name=mode value=create mailing list file>\"; }
function createList() {
$fp = fopen($GLOBALS[\"filelist\"], \"w\"); if ($fp) {
echo \"<h2>Mailing list file created successfully!</h2>\"; echo \"<b>\" . $GLOBALS[\"filelist\"] . \"</b>\"; echo \"<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>\"; }
else
}
/**************************************************************************/
// Sends news to subscribers;
function sendNews($subject, $message) {
$filecontents = file($GLOBALS[\"filelist\"]); for ($i=0;$i<sizeof($filecontents);$i++) {
$a = mail($filecontents[$i], $subject, stripslashes($message), $GLOBALS[\"emailheaders\"]); if (!$a)
}
echo \"Spam sent!;)\"; echo \"<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>\"; }
// Displays the form to add emails to list;
function displayAddEntryForm() {
echo \"<h1>Add email to list:</h1>\"; echo \"<form name=addEntry action=admin_mailing.php method=get>\"; echo \"<input type=text name=email>\"; echo \"<input type=hidden name=mode value=add>\"; echo \"<input type=submit name=submit value=add>\"; }
// Adds emails to list;
function addEntry($email) {
$fp = fopen($GLOBALS[\"filelist\"], \"a\"); $emailsize = strlen($email . \"n\"); $fw = fwrite($fp, $email . \"n\", $emailsize); if ($fw) {
echo \"<h2><div align=center>Entry added successfully!</div></h2>\"; echo \"<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>\"; }
else
}
// Displays emails from list;
// by default it display last 10 emails;
function displayEntries() {
echo \"Show last <a href=admin_mailing.php?limit=10>10 emails</a> || <a href=admin_mailing.php?limit=20>20 emails</a> ||
<a href=admin_mailing.php?limit=50>50 emails</a> ||
<a href=admin_mailing.php?showall=>Show all</a><p>\";
$filecontents = file($GLOBALS[\"filelist\"]); if (isset($GLOBALS[\"limit\"])) $limit = $GLOBALS[\"limit\"];
if ((!isset($GLOBALS[\"limit\"])) and (!isset($GLOBALS[\"showall\"]))) $limit=10;
if (isset($GLOBALS[\"showall\"])) { for ($i=sizeof($filecontents)-1;$i>=0;$i--) { echo $filecontents[$i] . \" <a href=admin_mailing.php?mode=edit&id=\" . $filecontents[$i] . \">Edit</a> || <a href=admin_mailing.php?mode=delete&id=\" .
$filecontents[$i] . \">Delete</a><br>\";
}
}
$count = 1;
for ($i=sizeof($filecontents)-1;$count<=$limit;$i--) { echo $filecontents[$i] . \" <a href=admin_mailing.php?mode=edit&id=\" . $filecontents[$i] . \">Edit</a> || <a href=admin_mailing.php?mode=delete&id=\" .
$filecontents[$i] . \">Delete</a><br>\";
$count++;
}
}
}
// Displays the form to edit an email;
function displayEditForm($id) {
echo \"<h1>Edit email:</h1>\"; echo \"<form name=editForm action=admin_mailing.php method=get>\"; echo \"<input type=text name=email value=\" . $id . \">\"; echo \"<input type=hidden name=oldvalue value=\" . $id . \">\"; echo \"<input type=hidden name=mode value=doEdit>\"; echo \"<input type=submit name=submit value=update>\"; }
// Edits an email and writes the updated file;
function editEntry($email, $oldvalue) {
$filecontents = file($GLOBALS[\"filelist\"]); for ($i=0;$i<sizeof($filecontents);$i++) {
if (chop($filecontents[$i]) == $oldvalue) { $filecontents[$i] = $email . \"n\";
$fp = fopen($GLOBALS[\"filelist\"], \"w+\"); for ($a=0;$a<sizeof($filecontents);$a++) {
$emailsize = strlen($filecontents[$a] . \"n\"); $fw = fwrite($fp, $filecontents[$a], $emailsize); }
echo \"<h2><div align=center>Entry changed!</div></h2>\"; echo \"<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>\"; }
}
}
// Deletes an email and writes an updated file;
function deleteEntry($id) {
$filecontents = file($GLOBALS[\"filelist\"]); for ($i=0;$i<sizeof($filecontents);$i++) {
if (chop($filecontents[$i]) == $id) { $filecontents[$i] = \"\";
$fp = fopen($GLOBALS[\"filelist\"], \"w+\"); for ($a=0;$a<sizeof($filecontents);$a++) {
$emailsize = strlen($filecontents[$a]); $fw = fwrite($fp, $filecontents[$a], $emailsize); }
echo \"<h2><div align=center>Entry deleted!</div></h2>\"; echo \"<meta http-equiv='Refresh' content='1; URL=admin_mailing.php'>\";
}
}
}
?>
<h2>Enter any text here that you want to send to all your subscribers:</h2>
<form name=sendEmail action=admin_mailing.php method=post>
Subject:<br><input type=text name=subject><br>
Message body:<br><textarea name=message rows=10 cols=50></textarea><br>
<input type=submit name=mode value=send>
</form>
w sk³ad wchodzi jeszcze plik
emails.txt Bede wdzieczny za pomoc.