EXTREMESOFT TEAM
Bine ati venit.Pe acest forum gasiti sisteme de operare,tutoriale,hackuri,yahoo hack,muzica,muzica populara,muzica disco,muzica house,filme,filme de groaza,filme de comedie,filme actiune,filme aventura,jocuri,jocuri pc,jocuri xbox,din viata de zi cu zi moda,politica si multe altele.Resusrse pentru SA:MP,Counter-Strike,Metin2. WWW.EXTREMSOFT.3XFORUM.RO WWW.EXTREMSOFT.3XFORUM.RO
|
Nou pe simpatie: Cenusareasa
 | Femeie 24 ani Bucuresti cauta Barbat 28 - 61 ani |
|
|
EXTREMESOFT TEAMReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
|
| #1 |
BillAdministrator
Postari: 71
|
|
Un mic script pt inregistrare, securizat cat de cat, Object Oriented, facut de mine daca sunt intrebari nu ezitati
in config.php:
<?php $cfg['host'] = "localhost"; $cfg['db_user'] = "root"; $cfg['db_pass'] = ""; $cfg['db'] = "db";
mysql_connect($cfg['host'], $cfg['db_user'], $cfg['db_pass']) or die(mysql_error()); mysql_select_db($cfg['db']) or die(mysql_error()); ?>
register.php
<?php include("class.register.php" ; $register = new Register();
$captcha = mt_rand(1000,9999); ?> <center> <fieldset script_blocat'width: 350px;'> <legend>Register</legend> <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='POST'> <table> <tr> <td> Full name: </td> <td> <script_blocat='text' name='name' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> E-Mail: </td> <td> <script_blocat='text' name='email' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> Username: </td> <td> <script_blocat='text' name='username' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> Password: </td> <td> <script_blocat='password' name='password' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> Retype-Password: </td> <td> <script_blocat='password' name='password2' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> Country: </td> <td> <script_blocat='text' name='country' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> City: </td> <td> <script_blocat='text' name='city' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> </td> </tr> <tr> <td> Birthday: </td> <td> <select name='d'> <option value=''>Day</option> <?php $i = 1; while($i <= 31){ echo "<option value='".$i."'>".$i."</option>"; $i++; } ?> </select> <select name='m'> <option value=''>Month</option> <?php $i = 1; while($i <= 12){ echo "<option value='".$i."'>".$i."</option>"; $i++; } ?> </select> <select name='y'> <option value=''>Year</option> <?php $i = 1960; $year = date('Y'); while($year >= $i){ echo "<option value='".$year."'>".$year."</option>"; $year = $year - 1; } ?> </select> </td> </tr> <tr> <td> Captcha(<?php echo $captcha; ?> : </td> <td> <script_blocat='text' name='insertcap' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;"> <script_blocat='hidden' name='hiddencap' value='<?php echo $captcha; ?>'> </td> </tr> </table> <script_blocat='submit' name='submit' class="input-wait ui-widget ui-widget-content ui-corner-all defaultText" script_blocat"padding: 3px; width: 180px;" value='Register'> </form> </fieldset> </center>
<?php if(isset($_POST['submit'])){
if($register->messages()){
}else{ $register->showerrors(); }
}
?>
class.register.php:
<?php error_reporting(E_ALL); include("config.php" ;
class Register { private $username; private $password; private $password2; private $passmd5; private $bd; private $city; private $country; private $name; private $email; private $errors; private $insertcap; private $hiddencap;
public function __construct() { $this->submit = isset($_POST['submit'])? 1 : 0;
if ($this->submit) { $this->username = $this->filter($_POST['username']); $this->password = $this->filter($_POST['password']); $this->password2 = $this->filter($_POST['password2']); $this->passmd5 = md5($this->password); $this->email = $this->filter($_POST['email']); $this->city = $this->filter($_POST['city']); $this->country = $this->filter($_POST['country']); $this->bd = $_POST['d'] . "-" . $_POST['m'] . "-" . $_POST['y']; $this->name = $this->filter($_POST['name']); $this->insertcap = $this->filter($_POST['insertcap']); $this->hiddencap = $this->filter($_POST['hiddencap']); } $this->errors = array(); }
public function messages() { echo $this->dataLength(); try { if (!$this->allfields()) throw new Exception("<div class='ui-widget'><div class='ui-state-error ui-corner-all' script_blocat'padding: 0 .7em;'><p><span class='ui-icon ui-icon-alert' script_blocat'float: left; margin-right: .3em;'></span><strong>Error:</strong> Please fill in all fields!</p></div></div>" ; if (!$this->passwordMatch()) throw new Exception("<div class='ui-widget'><div class='ui-state-error ui-corner-all' script_blocat'padding: 0 .7em;'><p><span class='ui-icon ui-icon-alert' script_blocat'float: left; margin-right: .3em;'></span><strong>Error:</strong> The passwords do not match!</p></div></div>" ;
if (!$this->userCheck()) throw new Exception("<div class='ui-widget'><div class='ui-state-error ui-corner-all' script_blocat'padding: 0 .7em;'><p><span class='ui-icon ui-icon-alert' script_blocat'float: left; margin-right: .3em;'></span><strong>Error:</strong> That user is already in use!</p></div></div>" ;
if (!$this->dataLength()) throw new Exception("<div class='ui-widget'><div class='ui-state-error ui-corner-all' script_blocat'padding: 0 .7em;'><p><span class='ui-icon ui-icon-alert' script_blocat'float: left; margin-right: .3em;'></span><strong>Error:</strong> The username must be between 5 and 22 characters and must contain only numbers, letters and _ !</p></div></div>" ;
if (!$this->captchamatch()) throw new Exception("<div class='ui-widget'><div class='ui-state-error ui-corner-all' script_blocat'padding: 0 .7em;'><p><span class='ui-icon ui-icon-alert' script_blocat'float: left; margin-right: .3em;'></span><strong>Error:</strong> Invalid captcha code!</p></div></div>" ;
//Aici vin liniile care insereaza datele in baza de date!
echo "success!"; }
catch(Exception $e) { $this->errors[] = $e->getMessage(); } }
public function filter($var) { return preg_replace('/[^a-zA-Z0-9-.-@-_]/', ' ', $var); }
public function userCheck() { $query = mysql_query("SELECT * FROM users WHERE username = '{$this->username}' " ; $r = mysql_num_rows($query); return ($r == 0)? 1 : 0; }
public function dataLength() { return preg_match('/^([a-zA-Z0-9._]){5,12}+$/', $this->username)? 1 : 0; }
public function passwordMatch() { return($this->password == $this->password2)? 1 : 0; }
public function captchamatch() { return($this->insertcap == $this->hiddencap)? 1 : 0; }
public function allfields() { return(!empty($this->username) && !empty($this->password) && !empty($this->password2) && !empty($this->email) && !empty($this->bd) && !empty($this->city) && !empty($this->country) && !empty($this->name) && !empty($this->insertcap))? 1 : 0; }
public function success() {
}
public function showerrors() { foreach($this->errors as $k => $v) { echo "<br /><center><fieldset script_blocat'width: 350px;'><legend>Error</legend>" . $v . "</fieldset></center>"; } } }
?>
|
|
| |
|