省实附中吧吧务应征系统3.0 源代码开放·注册与登陆处理

<?php
error_reporting(0);
session_start();
require(“header.php”);?>

<?php

include(“config.php”);
if($_POST[“SI”]==”登录”){
if(empty($_POST[“username”])){
echo (“<script type=’text/javascript’>location.href=’index.php?msg=emtuser’;</script>”);
}
if(empty($_POST[“passwd”])){
echo (“<script type=’text/javascript’>location.href=’index.php?msg=emtpass’;</script>”);}
$username= $_POST[“username”]; //用户名已经记录了
$passwd=md5($_POST[“passwd”]); //密码已经记录了
$db=mysql_connect($ucenterhostname,$ucentersqlname,$ucentersqlpass);
mysql_select_db($ucenterdbname,$db);
mysql_query(“set names ‘utf8′”);
$sql=”select * from $ucenterdbtable where username=’$username’ and passwd=’$passwd'”;
$result=mysql_fetch_array(mysql_query($sql));
if(!$result){
echo (“<script type=’text/javascript’>location.href=’index.php?msg=upwrong’;</script>”);
mysql_close();

exit;
}
$_SESSION[“username”]=”$username”;
echo “<script>location.href=’main.php’;</script>”;

exit;
}else{
if(empty($_POST[“username”])){
echo (“<script type=’text/javascript’> location.href=’erro.php?content=用户名不能是空的’;</script>”);
exit;}
if(empty($_POST[“passwd”])){
echo (“<script type=’text/javascript’>location.href=’erro.php?content=密码不能是空的’;;</script>”);}
if($_POST[“passwd”]!=$_POST[“repasswd”]){
echo (“<script type=’text/javascript’> location.href=’erro.php?content=两次密码不同!’;</script>”);
}
if(empty($_POST[“mail”])){
echo (“<script type=’text/javascript’> location.href=’erro.php?content=邮箱不能是空的’;</script>”);}
if(empty($_POST[“mobile”])){
echo (“<script type=’text/javascript’> location.href=’erro.php?content=手机号码不能是空的’;</script>”);
}
if(!is_numeric($_POST[“mobile”])){
echo (“<script type=’text/javascript’> location.href=’erro.php?content=手机号码格式不正确’;</script>”);
exit;
}
date_default_timezone_set(“PRC”);
$username=$_POST[“username”];
$passwd=md5($_POST[“passwd”]);
$mobile=$_POST[“mobile”];
$mail=$_POST[“mail”];
$time=date(‘Y-m-d H:i:s’);
$to=$_POST[“mail”];
$db=mysql_connect($ucenterhostname,$ucentersqlname,$ucentersqlpass);
mysql_select_db($ucenterdbname,$db);
mysql_query(“set names ‘utf8′”);
$sql=”select * from $ucenterdbtable where username=’$username'”;
$result=mysql_fetch_row(mysql_query($sql));
if($result){
echo (“<script type=’text/javascript’> alert(‘用户名已存在,你就不能注册这个名字’);history.go(-1);</script>”);
}else{
function request_by_curl($remote_server,$post_string){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$remote_server);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function randomFileName(){
$len=32;
$chars=’ABCDEFGHIJKFGHIJKLMNOPQLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789′;
// characters to build the password from
mt_srand((double)microtime()*1000000*getmypid());
// seed the random number generater (must be done)
while(strlen($filename)<$len)
$filename.=substr($chars,(mt_rand()%strlen($chars)),1);
return $filename;
}
$reg_token = randomFileName();
$sql=”insert into $ucenterdbtable(username,passwd,mobile,mail,time,reg_token,pass) values (‘$username’,’$passwd’,’$mobile’,’$mail’,now(),’$reg_token’,’no’)”;
mysql_query($sql);
mysql_close();
$db=mysql_connect($hostname,$sqlname,$sqlpass);
mysql_select_db($dbname,$db);
mysql_query(“set names ‘utf8′”);
$sql=”insert into $dbtable(username) values (‘$username’)”;
mysql_query($sql);
mysql_close();
$title = “【省实附中吧吧务应征系统】账户激活邮件(翰墨网络技术支持部门)”;
$url = “http://bawu.stop.sf-er.com/”;
$url.= “activate.php?username=$username”.”&”.”signup_token=$reg_token”;
$time = date(“Y 年 n 月 j 日 H 时 i 分”);
$content = “亲爱的 $username :
<br>
您于 $time 在<b>省实附中吧吧务应征系统</b>注册了账户 $username 。
<br><br>
请立即点击以下<b>一次性</b>链接激活你的账户,请不要将其转发给任何人。
<br><br>  (如果不能点击,请将其复制到浏览器地址栏打开)
<br>
———————————————————————————————————-
<br>
<br>
$url
<br>
<br>
———————————————————————————————————-
<br><br>
如果你没有注册过账户,请您删除这封邮件。
<br><br>
省实附中吧吧务应征系统 http://bawu.stop.sf-er.com
<br><br>
$time”;
$content=urlencode($content);
$post = “to=$to&title=$title&content=$content”;
request_by_curl(‘http://www.qiu-lnt.com/api/opensend.php’,$post);
echo (“<script type=’text/javascript’> location.href=’erro.php?content=省·附·人一站通注册成功,注册站点:省实附中吧吧务应征系统。请立即到你的邮箱点击激活链接激活账户。’;</script>”);}
}
?>

未经允许不得转载:Lyndon's Studio » 省实附中吧吧务应征系统3.0 源代码开放·注册与登陆处理