PHP网站制作之转载老外编写的一个maillist源代码
聪明的你,显然已经逐渐的开悟了,慢慢的理解了编程的概念,那么祝贺你,你已经迈出了成功的第一步。源代码admin.php3
<?
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<br><br>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><br><br>
<a href=\"admin.php3?users&$adminuser1&$adminpass1\">$show_users</a><br><br>
<a href=\"admin.php3?delall&$adminuser1&$adminpass1\">$del_table</a><br><br>
<a href=\"tablecreator.php3\">$create_table</a>
";
}
else { echo"$noaccess"; }
}
else { echo"$noaccess"; }
}
else if($string2=='delall')
{
if($string2==$adminuser)
{
if($string2==$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=='users')
{
if($string2==$adminuser)
{
if($string2==$adminpass)
{
echo"
$headline_users<br><br>
<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</td><td>$data</td><td>$data</td><td><a href=\"admin.php3?deluser&$string2&$string2&$data\">$delete</td></tr>";
}
echo"
</table>
";
}
else { echo"$noaccess"; }
}
else { echo"$noaccess"; }
}
else if($string2=='deluser')
{
if($string2==$adminuser)
{
if($string2==$adminpass)
{
$query="DELETE FROM $maillist_table WHERE email='$string2'";
mysql_db_query($database_name,$query,$conn) or die("$string2 $could_not_be_deleted");
echo"$string2 has_been_deleted";
}
else { echo"$noaccess"; }
}
else { echo"$noaccess"; }
}
else if($string2=='send')
{
if($string2==$adminuser)
{
if($string2==$adminpass)
{
echo"
$send_mail:<br><br>
<form method=POST action=admin.php3?sendmail&$string2&$string2>
$topic:<br><input type=text name=subject><br>
$message:<br><textarea rows=20 cols=50 name=text wrap=physical></textarea><br>
<input type=submit value=\"$send\"><input type=reset value=\"$reset\">
";
}
else { echo"$noaccess"; }
}
else { echo"$noaccess"; }
}
else if($string2=='sendmail')
{
if($string2==$adminuser)
{
if($string2==$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","$subject","$text","From: $from\nX-Mailer: $mailer\nReply-To: $reply\n") or die("$send_error");
}
echo"
$xxx_has_been_sent:<br><br>
$topic:<br>
$subject<br>
$message:<br>
$text<br>
";
}
else { echo"$noaccess"; }
}
else { echo"$noaccess"; }
}
print_back();
print_footer();
?>
english.inc.php3
<?
$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.<br>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
<?
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
<?
/******************************************************************************/
/* */
/* Mailinglisten-Manager */
/* */
/* by: Marcel Beerta */
/* http://www.supertown.de/computer/mazen/ */
/* marcel.beerta@gmx.net */
/* */
/******************************************************************************/
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<br><br>
Name: $name<br>
$prename: $vorname<br>
E-Mail: $email<br>
$password: $pw<br><br>
$remember_pass<br>
";
}
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><br><br><br><br><br><br><br>
";
}
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<br><br>");
if($data==$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 ...<br><br>
<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><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
";
}
print_back();
print_footer();
?>
layout.inc.php3
<?
/******************************************************************************/
/* */
/* Layout Datei ... */
/* */
/* Einfach auf eigene Layout-Wuensche anpassen ... */
/* */
/* by Marcel Beerta */
/* http://www.supertown.de/computer/mazen/ */
/* */
/******************************************************************************/
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"
<br>
";
}
function print_footer ( )
{
echo"
<p align=center>
</p>
</body></html>
";
}
function print_back ( )
{
echo"<br><br><a href=\"javascript:history.go(-1)\"><strong><< back </strong></a><br><br>";
}
?>
config.inc.php3
/*****************************************************************************/
/* */
/* Datenbank-Connector */
/* Marcel Beerta */
/* http://www.supertown.de/mazen/maillist */
/*****************************************************************************/
/**************************************/
/* Just edit the following few lines: */
/**************************************/
//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='sszw@163.net';
//Reply-To-E-Mail
$reply='sszw@163.net';
//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";
?>
那么接下来,这就算学会啦?NO,NO,NO,还早呢,你至尽还没碰过OOP之类的吧?模板呢? 你很难利用原理去编写自己的代码。对于php来说,系统的学习我认为还是很重要的,当你有一定理解后,你可你针对某种效果研究,我想那时你不会只是复制代码的水平了。 作为一个合格的coder 编码的规范是必须,命名方面我推崇“驼峰法”,另外就是自己写的代码最好要带注释,不然时间长了,就算是自己的代码估计看起来都费事,更不用说别人拉。 我还是推荐用firefox ,配上firebug 插件调试js能省下不受时间。谷歌的浏览器最好也不少用,因为谷歌的大侠们实在是太天才啦,把一些原来的js代码加了一些特效。 首先声明:我是一个菜鸟,是一个初学者。学习了一段php后总是感觉自己没有提高,无奈。经过反思我认为我学习过程中存在很多问题,我改变了学习方法后自我感觉有了明显的进步。 我学习了一段时间后,我发现效果并不好(估计是我自身的问题)。因为一个人的精力总是有限的,同时学习这么多,会导致每个的学习时间都得不到保证。 这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。 最后祝愿,php会给你带来快乐的同时 你也会给他带来快乐。 Ps:以上纯属原创,如有雷同,纯属巧合 至于模板嘛,各位高人一直以来就是争论不休,我一只小菜鸟就不加入战团啦,咱们新手还是多学点东西的好。 php是动态网站开发的优秀语言,在学习的时候万万不能冒进。在系统的学习前,我认为不应该只是追求实现某种效果,因为即使你复制他人的代码调试成功,实现了你所期望的效果,你也不了解其中的原理。 使用 jquery 等js框架的时候,要随时注意浏览器的更新情况,不然很容易发生框架不能使用。 首推的搜索引擎当然是Google大神,其次我比较喜欢 百度知道。不过搜出来的结果往往都是 大家copy来copy去的,运气的的概率很大。 多看优秀程序员编写的代码,仔细理解他们解决问题的方法,对自身有很大的帮助。 要进行开发,搭建环境是首先需要做的事,windows下面我习惯把环境那个安装在C盘下面,因为我配的环境经常出现诡异事件,什么事都没做环境有的时候就不能用啦。 兴趣是最好的老师,百度是最好的词典。 开发工具也会慢慢的更专业,每个公司的可能不一样,但是zend studio是个大伙都会用的。 当然这种网站的会员费就几十块钱。 在我安装pear包的时候老是提示,缺少某某文件,才发现 那群extension 的排列是应该有一点的顺序,而我安装的版本的排序不是正常的排序。没办法我只好把那群冒号加了上去,只留下我需要使用的扩展。
页:
[1]