Location: PHPKode > projects > php Blogger > signup.php
<?php session_start();
/* * ********************************************************************
*  Copyright notice PHP Blogger 1.1.
*
*  (c) 2011 Predrag Rukavina - admin[at]phpblogger[dot]org
*  All rights reserved
*
*  This script is part of the PHP Blogger project. 
*  The PHP Blogger project is free software; you can redistribute it and/or
*  modify it under the terms of the GNU General Public License
*  as published by the Free Software Foundation; either version 2
*  of the License, or (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
*  MA  02110-1301, USA.
*
*  This copyright notice MUST appear in all copies of the script!
* ********************************************************************** */
##############################
# signup.php     version 1.1.#
##############################
include ('settings.php');
require_once ('languages/lang_'.$language.'.php');
if(@$_SESSION['INC_USER_ID'] == true) {
	echo $lang['ERRORSIG'];
	die();
}
require_once ('classes/stopforumspam.php');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="themes/classic/styles/style.css" />
<title><?php echo $lang['ADMNEW'] ?></title>
</head>
<body>
<div id="wrapper">
<div class="headers">
<div class="headerin">
<div id="menu">
<li id="logo"><a href="<?php echo $sitepath ?>"><?php echo $sitetitle ?></a></li>
</div>
<div class="headerinfo">
<li class="float">
</li>
<li style="float:right">
</li>
</div>
</div>
<div id="announc">
</div>
</div>
<div id="main">
<div>
<script language="JavaScript">
    function validationEmail(maForm) {
        if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(maForm.email.value)){
            return (true)
        }
        alert("<?php echo $lang['INVALIDM'] ?>")
        return (false)
    }
</script>
<?php 	if(isset($_POST['Submit'])) {
	if((@$_POST['check']) == @$_SESSION['check']) {
		//do nothing
	} else {
		echo "$lang[WRONGCAP] <a href='signup.php'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	$privilege = $_POST['privilege'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$email = $_POST['email'];
	$ipse = $_SERVER['REMOTE_ADDR'];
	$keys = rand(111111111,888888888);
	if($stopspam == 1) {
		checkStopForumSpam($email,$ipse);
	}
	if(get_magic_quotes_gpc()) {
		$privilege = stripslashes($privilege);
		$username = stripslashes($username);
		$password = stripslashes($password);
		$email = stripslashes($email);
		$keys = stripslashes($keys);
	}
	$privilege = mysql_real_escape_string($privilege);
	$username = mysql_real_escape_string($username);
	$password = mysql_real_escape_string($password);
	$email = mysql_real_escape_string($email);
	$keys = mysql_real_escape_string($keys);
	if(preg_match('#[^A-Za-z0-9]#',$username)) {
		echo "$lang[ONLYLETER]: <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(preg_match('#[^A-Za-z0-9]#',$password)) {
		echo "$lang[ONLYLETER] <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	$name = array($username,$password,$email);
	foreach($name as $name) {
		if(preg_match("/%/",$name)) {
			echo "$lang[NOTVALID] '%'</div></div>";
			include ('static.php');
			die();
		}
		if(preg_match("/;/",$name)) {
			echo "$lang[NOTVALID] ';'</div></div>";
			include ('static.php');
			die();
		}
		if(preg_match("/</",$name)) {
			echo "$lang[NOTVALID] '<'</div></div>";
			include ('static.php');
			die();
		}
		if(preg_match("/\\[/",$name)) {
			echo "$lang[NOTVALID] '['</div></div>";
			include ('static.php');
			die();
		}
	}
	if(strlen($username) < 5) {
		echo "$lang[LASTFIV] <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(strlen($username) > 30) {
		echo "$lang[MAXCHAR]: 30 <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(strlen($password) < 5) {
		echo "$lang[LASTFIV] <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(strlen($password) > 30) {
		echo "$lang[MAXCHAR]: 30 <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(strlen($email) < 5) {
		echo "$lang[LASTFIV] <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(strlen($email) > 80) {
		echo "$lang[MAXCHAR]: 80 <a href='javascript:history.go(-1)'>$lang[GOBACK]</a></div></div>";
		include ('static.php');
		die();
	}
	if(preg_match("/ /",$username)) {
		echo "$lang[NOTVALID]</div></div>";
		include ('static.php');
		die();
	}
	if(preg_match("/ /",$password)) {
		echo "$lang[NOTVALID]</div></div>";
		include ('static.php');
		die();
	}
	$arecordSet = $conn->Execute("SELECT username, email FROM users WHERE username = '".
		mysql_real_escape_string($username)."' or email = '".mysql_real_escape_string($email).
		"'");
	if($arecordSet) {
		if($arecordSet->fields > 0) {
		echo "$lang[ERREXIST]</div></div>";
		include ('static.php');
                $arecordSet->MoveNext();
		die();
	}}
	if($_FILES['image']['name'] == "") {
		$new_image = "noavatar.png";
	} else {
		$current_image = $_FILES['image']['name'];
		$extension = substr(strrchr($current_image,'.'),1);
		if(($extension !== "jpg" && $extension !== "jpeg")) {
			echo $lang['ERRUPLOAD'];
			include ('static.php');
			die();
		}
		$time = date("fYhis");
		$new_image = $time.".".$extension;
		$destination = "uploads/".$new_image;
		$action = copy($_FILES['image']['tmp_name'],$destination);
		/**
		 * ccthumb()
		 * 
		 * @param mixed $imgSrc
		 * @param mixed $filename
		 * @param mixed $thumbnail_width
		 * @param mixed $thumbnail_height
		 * @return
		 */
		function ccthumb($imgSrc,$filename,$thumbnail_width,$thumbnail_height) {
			list($width_orig,$height_orig) = getimagesize($imgSrc);
			if($width_orig > 1080 || $height_orig > 1080) {
				echo 'Maximum width and height exceeded. Please upload images below  1080 x 1080 px size.';
				exit();
			}
			$tag = explode('.',$imgSrc);
			if(preg_match('/jpg|jpeg/',$tag[1])) {
				if(@$cimage = imagecreatefromjpeg($imgSrc) == true) {
					$cimage = imagecreatefromjpeg($imgSrc);
				} else {
					die("wrong file");
				}
			}
			$ratio_orig = $width_orig / $height_orig;
			if($thumbnail_width / $thumbnail_height > $ratio_orig) {
				$new_height = $thumbnail_width / $ratio_orig;
				$new_width = $thumbnail_width;
			} else {
				$new_width = $thumbnail_height * $ratio_orig;
				$new_height = $thumbnail_height;
			}
			$x_mid = $new_width / 2;
			$y_mid = $new_height / 2;
			$process = imagecreatetruecolor(round($new_width),round($new_height));
			imagecopyresampled($process,$cimage,0,0,0,0,$new_width,$new_height,$width_orig,
				$height_orig);
			$thumb = imagecreatetruecolor($thumbnail_width,$thumbnail_height);
			imagecopyresampled($thumb,$process,0,0,($x_mid - ($thumbnail_width / 2)),($y_mid -
				($thumbnail_height / 2)),$thumbnail_width,$thumbnail_height,$thumbnail_width,$thumbnail_height);
			imagejpeg($thumb,$filename,100);
			return $thumb;
		}
		ccthumb($destination,'maxthumb/'.$new_image,50,50);
		ccthumb($destination,'minthumb/'.$new_image,25,25);
	}
	$brecordSet = $conn->Execute("INSERT INTO users (privilege, username, password, email, ipos, thumbs, date, active, keysi)
    VALUES ('$privilege', '$username',(md5('$password')),'$email','$ipse','$new_image',NOW(),'0','$keys')");
	$myurl = "$sitepath/confirm.php";
	$headers = 'MIME-Version: 1.0'."\r\n";
	$headers .= 'Content-type: text/html; charset=utf-8'."\r\n";
	$headers .= "From: $sitemail"."\r\n";
	$bodys = "
<head>
<style>
#content{
align:center;
padding:4px;
margin:0px auto;
background:#fff;
border:1px dotted #f8f8f8;
width:733px;
font-family;tahoma;
color:#222;
}
</style>
</head>
<div id = 'content'>
<h4>$sitetitle</h4>$lang[MAILHEAD] \"$username\", $lang[NEWREG]<br /><br />
<a href=\"$myurl?id=$keys\">$myurl?id=$keys</a><br /><br />
$myurl?id=$keys<br /><br />
$lang[THAREG]<br /><br />$sitetitle";
	$subject = "$lang[ACTREG] $sitetitle";
	mail($email,$subject,$bodys,$headers);
	$ccsubject = $sitetitle." - $lang[ADMNEW]";
	$ccbodys = "<h4>$lang[ADMSEW]<br /><br /><a href=\"$sitepath\">$sitetitle</a></h4>";
	mail($sitemail,$ccsubject,$ccbodys,$headers);
	echo $lang['PASTHE'] . "</div>";
	unset($_SESSION['check']);
	session_destroy();
	$recordSet->Close();
	$arecordSet->Close();
	
	$conn->Close();
} else {
	$currentip = $_SERVER["REMOTE_ADDR"];
	$crecordSet = &$conn->Execute("SELECT * FROM `banip` WHERE `banipad` = '".
		mysql_real_escape_string($currentip)."'");
	if($crecordSet) {
		if($crecordSet->fields > 0) {
			echo $lang['BANNED'];
			include ('static.php');
			die();
		}
	}
    ?>
<form name="maForm" action="signup.php" id="inrform" enctype="multipart/form-data" method="post"  onSubmit="return validationEmail(this)">
<input type="hidden" name="privilege" value="<?php echo $signuprole ?>">
<div style="width:555px;height:75px;">
<h2><?php echo $lang['ADMNEW'] ?></h2>
<?php echo $lang['ALLFIELD'] ?>
</div>
<div style="width:555px;height:75px;">
<p style="float:left;width:255px;height:35px"><b><?php echo $lang['USER'] ?>:</b> <?php echo $lang['REQUI'] ?></p>
<p style="float:right;width:300px;height:35px"><input style="width:318px;" name="username" type="text"></p>
<p style="width:555px;"><font style="font-size:10px;"><?php echo $lang['ONLY'] ?></p>
<p><?php echo $lang['ENTER'] ?></font></p>
</div>
<div style="width:555px;height:75px;">
<p style="float:left;width:255px;height:35px"><b><?php echo $lang['PASS'] ?>:</b> <?php echo $lang['REQUI'] ?></p>
<p style="float:right;width:300px;height:35px"><input style="width:318px;" name="password" type="password"></p>
<p><font style="font-size:10px;"><?php echo $lang['ONLY'] ?></font></p>
</div>
<div style="width:555px;height:75px;">
<p style="float:left;width:255px;height:35px"><b><?php echo $lang['EMAIL'] ?>:</b> <?php echo $lang['REQUI'] ?></p>
<p style="float:right;width:300px;height:35px"><input style="width:318px;" name="email" type="text"></p>
<p><font style="font-size:10px;"><?php echo $lang['CMAIL'] ?></font></p>
</div>
<div style="width:555px;height:75px;">
<p style="float:left;width:255px;height:35px"><b><?php echo $lang['IMAGE'] ?>:</b></p>
<p style="float:right;width:300px;height:35px"><input type="file" name="image" type="text"></p>
<p><font style="font-size:11px;"><?php echo $lang['FILES'] ?></font></p>
</div>
<div style="width:555px;height:75px;">
<p><img src="captcha.php" id="img" border="0" style="border:1px solid #ddd;width:75px;height:28px;" title="<?php echo $lang['ENTERNUM'] ?>"></p>
<p style="float:right;width:300px;height:35px"><input style="width:318px;" size="4" name="check"></p>
<p><font style="font-size:11px;"><?php echo $lang['ENTERNUM'] ?></font></p>
</div>
<div style="width:555px;height:75px;">
<input class="cbuton" type="submit" value="<?php echo $lang['NEWACC'] ?>" name="Submit" type="button">
</div>
</form>
</div>
<?php 	
$recordSet->Close();
$crecordSet->Close();
$conn->Close();
}
?>
</div>
<?php include ('static.php'); ?>
Return current item: php Blogger