Location: PHPKode > projects > PHP Enter > signup.php
<?php session_start();
/* * ********************************************************************
*  Copyright notice PHP Enter 4.1.6.
*
*  (c) 2011 Predrag Rukavina - admin[at]phpenter[dot]net
*  All rights reserved
*
*  This script is part of the PHP Enter project. 
*  The PHP Enter 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!
* ********************************************************************** */
include ('settings.php');
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$arecordSet =&$conn->Execute('SELECT * FROM categori ORDER BY name ASC');
if (!$arecordSet)
    print $conn->ErrorMsg();
else
    while (!$arecordSet->EOF) {
        if ($arecordSet->fields['cord'] == 0) {
            $aval[] = $arecordSet->fields;
        } else {
            $nval[] = $arecordSet->fields;
        }
        $arecordSet->MoveNext();
    }
$smarty->assign('categori',$aval);
$smarty->assign('subcat', $nval);
$smarty->display('blank.php');
require_once ('languages/lang_'.$langs.'.php');
if(@$_SESSION['INC_USER_ID'] == true) {
	echo "<div id='error'>" . $lang['ERRORSIG'] . "</div></div>";
	                $smarty->display('footer.php');
			die();
}
?>
<script language="JavaScript">
function validationEmail(maForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(maForm.email.value)){
return (true)
}
alert("<?php echo $lang['WRONGEM'] ?>")
return (false)
}
</script>
<?php if(isset($_POST['Submit'])) {
	if($stopspam == 2) {
                if((@$_POST['check']) <> @$_SESSION['check']) {
		echo "<div id='error'>$lang[WRONGCAP] <a href='signup.php'>$lang[GOBACK]</a></div></div>";
		$smarty->display('footer.php');
		die();
	        }		
	}
	$privilege = $_POST['privilege'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$email = $_POST['email'];
	$ipse = $_SERVER['REMOTE_ADDR'];
	$keys = rand(111111111,888888888);
	if(get_magic_quotes_gpc()) {
		$privilege = stripslashes($privilege);
		$username = stripslashes($username);
		$password = stripslashes($password);
		$email = stripslashes($email);
		$keys = stripslashes($keys);
	}
	if(preg_match('#[^A-Za-z0-9]#',$username)) {
		echo "<div id='error'>$lang[ONLY] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(preg_match('#[^A-Za-z0-9]#',$password)) {
		echo "<div id='error'>$lang[ONLY] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	$name = array($username,$password,$email);
	foreach($name as $name) {
		if(preg_match("/%/",$name)) {
			echo "<div id='error'>$lang[INVALIDCHAR]  '%' </div></div>";
	                $smarty->display('footer.php');
			die();
		}
		if(preg_match("/;/",$name)) {
			echo "<div id='error'>$lang[INVALIDCHAR] ';' </div></div>";
	                $smarty->display('footer.php');
			die();
		}
		if(preg_match("/</",$name)) {
			echo "<div id='error'>$lang[INVALIDCHAR] '<' </div></div>";
	                $smarty->display('footer.php');
			die();
		}
		if(preg_match("/\\[/",$name)) {
			echo "<div id='error'>$lang[INVALIDCHAR] '[' </div></div>";
	                $smarty->display('footer.php');
			die();
		}
	}
	if(strlen($name) < 5) {
		echo "$lang[POSTERR1] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(strlen($name) > 80) {
		echo "$lang[SEAERR7] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(strlen($email) < 5) {
		echo "$lang[POSTERR1] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(strlen($email) > 80) {
		echo "$lang[SEAERR7] <a href='javascript:history.go(-1)'>$lang[BOOKBACK] </a></div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(preg_match("/ /",$username)) {
		echo "<div id='error'>$lang[INVALIDCHAR] '%' </div></div>";
	                $smarty->display('footer.php');
		die();
	}
	if(preg_match("/ /",$password)) {
		echo "<div id='error'>$lang[INVALIDCHAR] ';' </div></div>";
	                $smarty->display('footer.php');
		die();
	}
	$brecordSet = &$conn->Execute('SELECT username, email FROM users WHERE username = ? or email = ?', array($username, $email));
        if($brecordSet) {
		if($brecordSet->fields > 0) {
		echo "<div id='error'>$lang[ERREXIST]</div></div>";
		$smarty->display('footer.php');
                $brecordSet->MoveNext();
		die();
	}}
	$current_image = $_FILES['image']['name'];
	$extension = substr(strrchr($current_image,'.'),1);
	if(($extension !== "jpg" && $extension !== "jpeg")) {
		echo "<div id='error'>" . $lang['POSTERR6'] . "</div></div>";
	                $smarty->display('footer.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 > 980 || $height_orig > 980) {
			echo "<div id='error'>$lang[POSTERR7]</div></div>";
	                $smarty->display('footer.php');
			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,80);
		return $thumb;
	}
	ccthumb($destination,'maxthumb/'.$new_image,50,50);
	ccthumb($destination,'minthumb/'.$new_image,25,25);
        $time = date("Y-m-d H:i:s");
        $sql = $conn->Prepare('INSERT INTO users (privilege, username, password, email, ipos, thumbs, date, active, keysi) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
        if($conn->Execute($sql,array($privilege,$username,(md5($password)),$email,$ipse,$new_image,$time,0,$keys)) === false) {
		print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
	}
	$realmessage = $username." ".$lang['NEWMEM'];
        $sql2 = $conn->Prepare('INSERT INTO publictime (texty,imgs,date,amess) VALUES (?, ?, ?, ?)');
        if($conn->Execute($sql2,array($username,$new_image,$time,$realmessage)) === false) {
		print '<br /><div id="error">error inserting[1]: '.$conn->ErrorMsg().'</div><br />';
	}
	$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=\"http://$urlh/$urls\">$sitetitle</a></h4>";
	mail($sitemail,$ccsubject,$ccbodys,$headers);
	echo "<div id='info'>$lang[PASTHE]</div>";
    $brecordSet->Close();
    $conn->Close();
    unset($_SESSION['check']);
    session_destroy();
} else { ?>
<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> 
<h1><?php echo $lang['ADMNEW'] ?></h1>
</div>
<div>
<div><?php echo $lang['USER'] ?>: <?php echo $lang['REQUI'] ?></div>
<div><input name="username" id="cinput" type="text"></div>
<div></div>
<div><span class="small"><p><?php echo $lang['ONLY'] ?></p><p><?php echo $lang['ENTER'] ?></p></span></div>
</div>
<div> 
<div><?php echo $lang['PASS'] ?>: <?php echo $lang['REQUI'] ?></div>
<div><input name="password" id="cinput" type="password"></div>
<div></div>
<div><span class="small"><p><?php echo $lang['ONLY'] ?></p></span></div>
</div>
<div> 
<div><?php echo $lang['EMAIL'] ?>: <?php echo $lang['REQUI'] ?></div>
<div><input name="email" id="cinput" type="text"></div>
<div></div>
<div><span class="small"><p><?php echo $lang['CMAIL'] ?></p></span></div>
</div>
<div> 
<div><?php echo $lang['IMAGE'] ?>: <?php echo $lang['REQUI'] ?></div>
<div><input type="file" id="cinput" name="image" type="text"><p><?php echo $lang['FILES'] ?></p>
</div>
</div>
<?php if($stopspam == 2) { ?>
<div> 
<div><img src="captcha.php" id="img" border="0" style="border:1px solid #ddd;width:75px;height:28px;margin-bottom:5px;" title="<?php echo $lang['ENTERNUM'] ?>"></div>
<div><input id="cinput" size="4" name="check"></div>
<div><?php echo $lang['ENTERNUM'] ?></font></div>
</div>
<?php } ?>
<div> 
<div>
<div><input class="buton" type="submit" value="<?php echo $lang['NEWACC'] ?>" name="Submit" type="button"></div>
</div>
</form>
</div>
<?php } ?>
</div>
<?php
$smarty->display('footer.php');
$arecordSet->Close();
$conn->Close();
######################################
##signup.php                  4.1.4.##
######################################
?>
Return current item: PHP Enter