当前位置:首页> PHP教程> PHP代码
关键字
文章内容
PHP编写的一个邮件列表源代码
 
 
修改时间:[2012/07/03 09:28]    阅读次数:[1854]    发表者:[起缘]
 

admin.php3

<? php
INCLUDE("layout.inc.php3");
INCLUDE("config.inc.php3");
INCLUDE("./lang/$language.inc.php3");
print_header("$admin_name");
print_navbar();
$string = implode($argv, " ");
$string2 = explode("&", $string);
if($string == ’’)
{
    echo"
    <p align=center>$program_name Version: $ver
    Administration:</p>
    <form method=POST action="admin.php3 ? admin">
    <table border=0 width=50%>
    <tr><td>$admin_username:</td><td><input type=text name=adminuser1></td></tr>
    <tr><td>$admin_password:</td><td><input type=password name=adminpass1></td></tr>
    <tr><td></td><td><input type=submit value="$send"><input type=reset value=$reset></td></tr>
    </table>
    </form>
    ";
}
else if($string == ’admin’)
{
    if($adminuser1 == $adminuser)
    {
        if($adminpass1 == $adminpass)
        {
            echo"
            <p align=center>$admin_name:</p>
            <a href="admin.php3 ? send&$adminuser1&$adminpass1">$send_mail</a>
            <a href="admin.php3 ? users&$adminuser1&$adminpass1">$show_users</a>
            <a href="admin.php3 ? delall&$adminuser1&$adminpass1">$del_table</a>
            <a href="tablecreator.php3">$create_table</a>
            ";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
else if($string2[0] == ’delall’)
{
    if($string2[1] == $adminuser)
    {
        if($string2[2] == $adminpass)
        {
            $query = "DROP TABLE $maillist_table";
            mysql_db_query($database_name, $query, $conn) or die("$cant_del_table");
            echo"$table_deleted";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
else if($string2[0] == ’users’)
{
    if($string2[1] == $adminuser)
    {
        if($string2[2] == $adminpass)
        {
            echo"
            $headline_users
            <table border=0 width=100% cellspacing=1><tr bgcolor="#000084"><td
            width=25%>Name:</td><td width=25%>$prename:</td><td width=25%>E-Mail</td><td
            width=25%>?/td></tr>
            ";
            $query = "SELECT * from $maillist_table";
            $result = mysql_db_query($database_name, $query, $conn) or die("$database_error");
            while($data = mysql_fetch_row($result))
            {
                echo"<tr bgcolor="#0000A0"><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td><a
                href="admin.php3 ? deluser&$string2[1]&$string2[2]&$data[2]">$delete</td></tr>";
            }
            echo"
            </table>
            ";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
else if($string2[0] == ’deluser’)
{
    if($string2[1] == $adminuser)
    {
        if($string2[2] == $adminpass)
        {
            $query = "DELETE FROM $maillist_table WHERE email=’$string2[3]’";
            mysql_db_query($database_name, $query, $conn) or die("$string2[3] $could_not_be_deleted");
            echo"$string2[3] has_been_deleted";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
else if($string2[0] == ’send’)
{
    if($string2[1] == $adminuser)
    {
        if($string2[2] == $adminpass)
        {
            echo"
            $send_mail:
            <form method=POST action=admin.php3?sendmail&$string2[1]&$string2[2]>
            $topic:
            <input type=text name=subject>
            $message:
            <textarea rows=20 cols=50 name=text wrap=physical></textarea>
            <input type=submit value="$send"><input type=reset value="$reset">
            ";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
else if($string2[0] == ’sendmail’)
{
    if($string2[1] == $adminuser)
    {
        if($string2[2] == $adminpass)
        {
            $query = "SELECT * FROM $maillist_table";
            $result = mysql_db_query($database_name, $query, $conn) or die("$database_error");
            while($data = mysql_fetch_row($result))
            {
                mail("$data[2]", "$subject", "$text", "From: $fromnX-Mailer: $mailernReply-To: $replyn") or
                die("$send_error");
            }
            echo"
            $xxx_has_been_sent:
            $topic:
            $subject
            $message:
            $text
            ";
        }
        else
        {
            echo"$noaccess";
        }
    }
    else
    {
        echo"$noaccess";
    }
}
print_back();
print_footer();
? >

english.inc.php3

<? php
$mailadd_text = "If you are in our Newsletter, you get an E-Mail with Informations about our Homepage every month. Just fill in the following Form. to unsubscribe click";
$remember_pass = "Please remember your Password, otherwise, you can’t delete your mailadress from the list";
$wrong_mail = "You’ve entered a bad E-Mail adress";
$admin_name = "Newsletter Administration";
$program_name = "Newsletter-Manager";
$admin_username = "Admin-Username";
$admin_password = "Admin-Password";
$send = "submit";
$reset = "reset";
$noaccess = "access denied";
$send_mail = "Send a Mail to the list";
$show_users = "Show/delete members";
$del_table = "Delete Table $maillist_table";
$create_table = "Create Table $maillist_table";
$cant_del_table = "Can’t delete Table $maillist_table";
$table_deleted = "Table $maillist_table has been deleted";
$headline_users = "Every user on one place:";
$prename = "Prename";
$database_error = "Error on Database: $database_name";
$delete = "delete";
$could_not_be_deleted = "could not be deleted";
$has_been_deleted = "has been deleted";
$topic = "Topic";
$message = "Message";
$send_error = "send error";
$xxx_has_been_sent = "The following has been sent";
$already_there = "You are already in the list!!!";
$xxx_has_been_entered = "The following has been entered";
$password = "Password";
$cant_find_entry = "Can’t find entry!";
$isnt_in_db = "$email is not entered in the Database";
$error_del = "Error while trying to delete";
$entry_del = "Entry has been deleted";
$here = "HERE";
$click = "";
$all_fields_must_be_edited = "ERROR! All Fields have to be filled in completely!";
? >

tablecreator.php3

<? php
INCLUDE"layout.inc.php3";
INCLUDE"config.inc.php3";
print_header("Create table $maillist_table");
print_navbar();
$query = "CREATE TABLE $maillist_table (name CHAR (50) not null , vorname CHAR (50) not null , email CHAR (255) not null , pass CHAR (10) not null , PRIMARY KEY (email), INDEX (email), UNIQUE (email))";
mysql_db_query($database_name, $query, $conn) or die("Could not create table");
echo"Table "$maillist_table" has been created";
print_back();
print_footer();
? >

index.php3

<? php
INCLUDE "config.inc.php3";
INCLUDE "./lang/$language.inc.php3";
INCLUDE "layout.inc.php3";
print_header("$program_name");
print_navbar();
$string = implode($argv, " ");
if ($string == ’add’)
{
    if($name && $prename && $email && $pw)
    {
        $query = "INSERT INTO $maillist_table(name,vorname,email,pass) VALUES(’$name’,’$vorname’,’$email’,’$pw’)";
        mysql_db_query($database_name, $query, $conn) or die("$already_there");
        echo"
        $xxx_has_been_entered
        Name: $name
        $prename: $vorname
        E-Mail: $email
        $password: $pw
        $remember_pass
        ";
    }
    else
    {
        echo"$all_fields_must_be_edited";
    }
}
else if($string == ’delete’)
{
    echo"
    <form method=POST action="index.php3 ? delme">
    <table border=0 align=left cellspacing=0 width=50%>
    <tr><td>E-Mail:</td><td><input type=text name=email></td></tr>
    <tr><td>$password:</td><td><input type=text name=pw></td></tr>
    <tr><td><input type=submit value="$send"></td><td></td></tr>
    </table>
    </form>
    ";
}
else if($string == ’delme’)
{
    $query1 = "SELECT * FROM $maillist_table WHERE $maillist_table.email LIKE ’$email’";
    $result = mysql_db_query($database_name, $query1, $conn) or die("$cant_find_entry");
    $data = mysql_fetch_row($result) or die("$isnt_in_db
                                            ");
    if($data[3] == $pw)
    {
        $query = "DELETE FROM $maillist_table WHERE email=’$email’";
        mysql_db_query($database_name, $query, $conn) or die("$error_del");
        echo"$entry_del";
    }
    else
    {
        echo"$noaccess";
    }
}
else
{
    echo"$mailadd_text
    <a href="index.php3 ? delete">$here</a> $click ...
    <form method=POST action=index.php3?add>
    <table border=0 align=left cellspacing=0 width=50%>
    <tr><td>Name:</td><td><input type=text name=name></td></tr>
    <tr><td>$prename:</td><td> <input type=text name=vorname></td></tr>
    <tr><td>E-Mail:</td><td> <input type=text name=email></td></tr>
    <tr><td>$password:</td><td> <input type=text name=pw></td></tr>
    <tr><td><input type=submit value="$send"></td></tr>
    </table>
    </form>
    ";
}
print_back();
print_footer();
? >

layout.inc.php3

<? php
function print_header ($title)
{
    echo"<html><head>
    <meta http-equiv="Content - Type" content="text / html;
    charset = ISO - 8859 - 1">
              <meta NAME="description"
              content="">
              <meta NAME="keywords"
              content="">
              <meta name="distribution" content="global">
              <meta NAME="robots" content="index">
              <meta NAME="robots" content="follow">
              <meta NAME="revisit - after" CONTENT="1 days">
              <meta NAME="language" content="">
              <meta NAME="author" content="">
              <meta NAME="copyright" content="">
              <meta name="programmer" content="Marcel Beerta (www.game - center.de)">
              <title>$title</title>
              </head>
              <body topmargin="0" leftmargin="0" bgColor=#040732 link=#ffc600 text=#ffffff vLink=#ffc600
          style="font - family:
              Verdana;
color:
#FFFFFF">";
}
function print_navbar ( )
{
    echo"
    ";
}
function print_footer ( )
{
    echo"
    <p align=center>
    </p>
    </body></html>
    ";
}
function print_back ( )
{
    echo"
<a href="javascript:
    history.go(-1)"><strong><< back </strong></a>
    ";
}
 
<? php
function print_header ($title)
{
    echo"<html><head>
    <meta http-equiv="Content - Type" content="text / html;
    charset = ISO - 8859 - 1">
              <meta NAME="description"
              content="">
              <meta NAME="keywords"
              content="">
              <meta name="distribution" content="global">
              <meta NAME="robots" content="index">
              <meta NAME="robots" content="follow">
              <meta NAME="revisit - after" CONTENT="1 days">
              <meta NAME="language" content="">
              <meta NAME="author" content="">
              <meta NAME="copyright" content="">
              <meta name="programmer" content="Marcel Beerta (www.game - center.de)">
              <title>$title</title>
              </head>
              <body topmargin="0" leftmargin="0" bgColor=#040732 link=#ffc600 text=#ffffff vLink=#ffc600
          style="font - family:
              Verdana;
color:
#FFFFFF">";
}
function print_navbar ( )
{
    echo"
    ";
}
function print_footer ( )
{
    echo"
    <p align=center>
    </p>
    </body></html>
    ";
}
function print_back ( )
{
    echo"
<a href="javascript:
    history.go(-1)"><strong><< back </strong></a>
    ";
}
? >

config.inc.php3

<? php
//Admin-username:
$adminuser = ’szw’;
//Admin-password:
$adminpass = ’szw’;
//language
$language = ’english’; //other Languages: ’german’,’english’
//The Hostname of the MySQL-Server
$hostname = ’localhost’;
//MySQL-Server username
$user = ’root’;
//MySQL-Server password
$pass = ’’;
//Database-Name
$database_name = ’maillist’;
//Maillinglist-Table
$maillist_table = ’marcel_maillist’;
//From-E-Mail
$from = ’[email protected]’;
//Reply-To-E-Mail
$reply = ’[email protected]’;
//X-Mailer
$mailer = ’PHP - Maillist by Mazen’;
/************************************************/
/* Don’t edit this, if you don’t know, what you */
/* do... */
/************************************************/
$conn = mysql_pconnect ($hostname, $user, $pass);
$ver = "1.0.0";
? >