- Joined
- Jul 4, 2009
- Messages
- 6
- Reaction score
- 2
Това се въвежда в phpmyadmin:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `users` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(10) COLLATE cp1251_bin NOT NULL,
`password` varchar(50) COLLATE cp1251_bin NOT NULL,
`email` varchar(50) COLLATE cp1251_bin NOT NULL,
`fullname` varchar(50) COLLATE cp1251_bin DEFAULT NULL,
`site` varchar(105) COLLATE cp1251_bin NOT NULL,
`country` varchar(50) COLLATE cp1251_bin NOT NULL,
`city` varchar(50) COLLATE cp1251_bin NOT NULL,
`tel` varchar(50) CHARACTER SET latin1 NOT NULL,
`profile` text COLLATE cp1251_bin NOT NULL,
`regdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ipaddress` varchar(50) CHARACTER SET latin1 NOT NULL,
`lastlogin` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`isactive` tinyint(1) NOT NULL DEFAULT '0',
`code` varchar(10) CHARACTER SET latin1 NOT NULL,
`sesion` int(50) NOT NULL,
PRIMARY KEY (`userid`),
KEY `userid` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_bin AUTO_INCREMENT=115 ;
Index.php
<?php
if($_GET['do'] == "login")
{
login_form();
}
if($_GET['do'] == "do_login")
{
do_login();
}
if($_GET['do'] == "register")
{
register_form();
}
if($_GET['do'] == "register")
{
do_register();
}
if(empty($_SESSION['do']))
{
echo("<a href="index.php">Home</a>|<a href="index.php?do=login">Login</a>|<a href="index.php?do=register">Register</a>");
}
?>
Functions.php
<?php
//тук се свързваме с базата с данни в случая mysql
//mysql_connect("localhost", "Потребител", "парола");
mysql_connect("localhost", "root", "");
mysql_select_db("test1");
function login_form(){
echo ("<center><font class="title">"._PLEASE_ENTER_YOUR_USER."</font></center>n");
echo ("
<center>
<form method="POST" action="index.php?do=do_login" name="loginform">
<table border="0" cellspacing="2" cellpadding="4">
<tr>
<td bgcolor="#E2E2E2">"._USERNAME." : </td>
<td bgcolor="#E2E2E2"><input type="text" name="username" size="11"> $user_err</td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSWORD." : </td>
<td bgcolor="#E2E2E2"><input type="password" name="password" size="11"> $pass_err</td>
</tr>
<tr>
<td colspan=2>"._REMEBER_ME." <input type="checkbox" name="remember" value="ON"></td>
</tr>
<tr>
<td> </td>
<td> <input type="hidden" name="do" value="do_login">
<input type="submit" value=""._LOGIN.""></p>
</td>
</tr>
</table>
</form>");
}
function do_login() {
$postname = $_POST['username'];
$postpass = $_POST['password'];
$md5_postpass = md5($postpass);
if((empty($postname)) | ((empty($postpass)))){
echo(_FORM_ERR);
if(empty($postname)){
echo(_USERNAME_LOGIN_REQ);
}
if(empty($postpass)){
echo(_LOGIN_PASS_REQ);
}
exit();
}
$remember = $_POST['remember'];
$sql_check_user = mysql_query("SELECT * FROM users WHERE username = '".$postname."'");
$check_user = mysql_fetch_array($sql_check_user);
$uid = $check_user['userid'];
$realname = $check_user['fullname'];
if(($check_user['username'] != $postname) | ($check_user['password'] != $md5_postpass)){
echo("<center>"._FORM_ERR."</center>");
if($check_user['username'] != $postname){
echo("<p><center>"._USERNAME_NOT_MATCH."</center></p>");
}
if($check_user['password'] != $md5_postpass){
echo("<center>"._PASS_ERR."</center>");
}
login_form();
exit();
}else{
if(($check_user['username'] = $postname) || ($check_user['password'] = $md5_postpass)){
if($remember){
$hour = time() + 360000000;
setcookie("siteid", "esolleeu", $hour);
setcookie("uid", $uid, $hour);
setcookie("pass", $md5_postpass, $hour);
if($realname != NULL){
setcookie("name", $relaname, $hour);
}
}else{
$hour = time() + 3600;
setcookie("siteid", "esolleeu", $hour);
setcookie("uid", $uid, $hour);
setcookie("pass", $md5_postpass, $hour);
if($realname != NULL){
setcookie("name", $relaname, $hour);
}
}
}
}
}
function register_form() {
echo("<center>
<form name="LoginForm" method="post" action="index.php?do=do_register">
<table cellspacing="0" collspacing="0" border="1">
<tr>
<td bgcolor="#E2E2E2">"._USERNAME.":</a>
<td bgcolor="#E2E2E2"><input name="username" type="text" id=username"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSOWRD."</td>
<td bgcolor="#E2E2E2"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSWORD2."</td>
<td bgcolor="#E2E2E2"><input name="password2" type="password" id="password2"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._EMAIL.":</td>
<td bgcolor="#E2E2E2"><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._FULLNAME.":</td>
<td bgcolor="#E2E2E2"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._SITE.":</td>
<td bgcolor="#E2E2E2"><input name="site" type="text" id="site"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._COUNTRY.":</td>
<td bgcolor="#E2E2E2"><select name="country" class="sb">
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua And Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia And Herzegowina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG" selected>Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote D'Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="FX">France, Metropolitan</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard And Mc Donald Islands</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">North Korea (People's Republic Of Korea)</option>
<option value="KR">South Korea (Republic Of Korea)</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People's Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libyan Arab Jamahiriya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia</option>
<option value="MD">Moldova</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="KN">Saint Kitts And Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="VC">Saint Vincent And The Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome And Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia And The South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SH">St Helena</option>
<option value="PM">St Pierre and Miquelon</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard And Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad And Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks And Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VA">Vatican City State</option>
<option value="VE">Venezuela</option>
<option value="VN">Viet Nam</option>
<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (U.S.)</option>
<option value="WF">Wallis And Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZR">Zaire</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
<option value="ZZ">Other Not Shown</option>
</select>
</td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._CITY.":</td>
<td bgcolor="#E2E2E2"><select id='city' name="city">
<option value='0' selected>--</option>
<option value='4230' >_ASENOVGRAD</option><option value='2700' >_BLAGOEVGRAD</option><option value='8000' >_BURGAS</option><option value='5000' >_V_TARNOVO</option><option value='9000' >_VARNA</option><option value='3700' >_VIDIN</option><option value='3000' >_VRACA</option><option value='5300' >_GABROVO</option><option value='6400' >_DIMITROVGRAD</option><option value='9300' >_DOBRICH</option><option value='6100' >_KAZANLAK</option><option value='6600' >_KARDJALI</option><option value='2500' >_KIUSTENDIL</option><option value='5500' >_LOVECH</option><option value='3400' >_MONTANA</option><option value='4400' >_PAZARDJIK</option><option value='2300' >_PERNIK</option><option value='5800' >_PLEVEN</option><option value='4000' >_PLOVDIV</option><option value='7200' >_RAZGRAD</option><option value='7000' >_RUSE</option><option value='2800' >_SANDANSKI</option><option value='7500' >_SILISTRA</option><option value='8800' >_SLIVEN</option><option value='1000' >_SOFIA</option><option value='6000' >_STARA_ZAGORA</option><option value='7700' >_TARGOVISHTE</option><option value='6300' >_HASKOVO</option><option value='9700' >_SHUMEN</option><option value='8600' >_YAMBOL</option> <option value='1' >_OTHER</option> </select></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._TEL.":</td>
<td bgcolor="#E2E2E2"><input name="tel" type="text" id="tel"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PROFILE_DESCRIPTION.":</td>
<td bgcolor="#E2E2E2"><input name="profile" type="text" id="profiler"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2"><input type="hidden" name="submit" value="submit"></td>
<td bgcolor="#E2E2E2"><input type="submit" value=""._REGISTER.""></td>
</tr>
</table>
</form></center>");
}
function do_register(){
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$fullname = $_POST['name'];
$site = $_POST['site'];
$country = $_POST['country'];
$city = $_POST['city'];
$tel = $_POST['tel'];
$profile = $_POST['profile'];
$md5_pass = md5($password);
$regtime = date("y-m-d h:i:s");
if((empty($username)) || (empty($password)) || (empty($password2)) || (empty($email)) || (empty($fullname)) || (empty($site)) || (empty($tel))){
echo(_FORM_ERR);
if(empty($username)){
echo(_USERNAME_LOGIN_REQ);
}
if(empty($password)){
echo(_LOGIN_PASS_REQ);
}
if(empty($password2)){
echo(_LOGIN_PASS_REQ2);
}
if(empty($email)){
echo(_EMAIL_REQ);
}
if(empty($fullname)){
echo(_FULLNAME_REQ);
}
if(empty($site)){
echo(_SITE_REQ);
}
if(empty($tel)){
echo(_TEL_REQ);
}
register_form();
exit();
}
$sql_user_check = mysql_query("SELECT username FROM users WHERE username = '".$username."'");
$user_check = mysql_fetch_row($sql_user_check);
$sql_email_check = mysql_query("SELECT email FROM users WHERE email = '".$email."'");
$email_check = mysql_fetch_row($sql_email_check);
if(($user_check != 0) || ($email_check != 0)){
if($user_check != 0){
echo(_USERNAME_ALREADY_TAKEN);
}
if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email)){
echo(_INVALID_EMAIL);
}
if($email_check != 0){
echo(_EMAIL_AREADY_TAKEN);
}
if($password != $password2){
echo(_PASSWORD_DOESNT_MATCH);
}
register_form();
exit();
}
$insert = "INSERT INTO users (username, password, email, fullname, site, country, city, tel, profile, regdate)
VALUES ('".$username."', '".$md5_pass."', '".$email."', '".$fullname."', '".$site."', '".$country."', '".$city."', '".$tel."', '".$profile."', '".$regtime."')";
mysql_query($insert);
echo(_REGISTER_DONE);
echo(_10X_TO_REGISER);
}
//Тази функция я използваме за да скрием информация от външни потребители
function is_logged_in($user) {
if(isset($_COOKIE['esolleeu'])){
$userid = $_COOKIE['uid'];
$passwd = $_COOKIE['pass'];
$userid = intval($userid);
if(($userid != "") || ($passwd != "")){
$sql_check = mysql_query("SELECT * FROM esolle_users WHERE userid = '$userid'");
$info = mysql_fetch_array($sql_check);
if(($info['userid'] = $iserid) || ($info['password'] = $passwd)){
return 1;
}else{
return 0;
}
}
}
}
//Пример
// if(is_logged_in($user)){
// echo(_WELCOME_REGISTERED_USER);
// }else{
// echo(_PLEASE_LOGIN_FIRST);
// }
?>
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `users` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(10) COLLATE cp1251_bin NOT NULL,
`password` varchar(50) COLLATE cp1251_bin NOT NULL,
`email` varchar(50) COLLATE cp1251_bin NOT NULL,
`fullname` varchar(50) COLLATE cp1251_bin DEFAULT NULL,
`site` varchar(105) COLLATE cp1251_bin NOT NULL,
`country` varchar(50) COLLATE cp1251_bin NOT NULL,
`city` varchar(50) COLLATE cp1251_bin NOT NULL,
`tel` varchar(50) CHARACTER SET latin1 NOT NULL,
`profile` text COLLATE cp1251_bin NOT NULL,
`regdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ipaddress` varchar(50) CHARACTER SET latin1 NOT NULL,
`lastlogin` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`isactive` tinyint(1) NOT NULL DEFAULT '0',
`code` varchar(10) CHARACTER SET latin1 NOT NULL,
`sesion` int(50) NOT NULL,
PRIMARY KEY (`userid`),
KEY `userid` (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 COLLATE=cp1251_bin AUTO_INCREMENT=115 ;
Index.php
<?php
if($_GET['do'] == "login")
{
login_form();
}
if($_GET['do'] == "do_login")
{
do_login();
}
if($_GET['do'] == "register")
{
register_form();
}
if($_GET['do'] == "register")
{
do_register();
}
if(empty($_SESSION['do']))
{
echo("<a href="index.php">Home</a>|<a href="index.php?do=login">Login</a>|<a href="index.php?do=register">Register</a>");
}
?>
Functions.php
<?php
//тук се свързваме с базата с данни в случая mysql
//mysql_connect("localhost", "Потребител", "парола");
mysql_connect("localhost", "root", "");
mysql_select_db("test1");
function login_form(){
echo ("<center><font class="title">"._PLEASE_ENTER_YOUR_USER."</font></center>n");
echo ("
<center>
<form method="POST" action="index.php?do=do_login" name="loginform">
<table border="0" cellspacing="2" cellpadding="4">
<tr>
<td bgcolor="#E2E2E2">"._USERNAME." : </td>
<td bgcolor="#E2E2E2"><input type="text" name="username" size="11"> $user_err</td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSWORD." : </td>
<td bgcolor="#E2E2E2"><input type="password" name="password" size="11"> $pass_err</td>
</tr>
<tr>
<td colspan=2>"._REMEBER_ME." <input type="checkbox" name="remember" value="ON"></td>
</tr>
<tr>
<td> </td>
<td> <input type="hidden" name="do" value="do_login">
<input type="submit" value=""._LOGIN.""></p>
</td>
</tr>
</table>
</form>");
}
function do_login() {
$postname = $_POST['username'];
$postpass = $_POST['password'];
$md5_postpass = md5($postpass);
if((empty($postname)) | ((empty($postpass)))){
echo(_FORM_ERR);
if(empty($postname)){
echo(_USERNAME_LOGIN_REQ);
}
if(empty($postpass)){
echo(_LOGIN_PASS_REQ);
}
exit();
}
$remember = $_POST['remember'];
$sql_check_user = mysql_query("SELECT * FROM users WHERE username = '".$postname."'");
$check_user = mysql_fetch_array($sql_check_user);
$uid = $check_user['userid'];
$realname = $check_user['fullname'];
if(($check_user['username'] != $postname) | ($check_user['password'] != $md5_postpass)){
echo("<center>"._FORM_ERR."</center>");
if($check_user['username'] != $postname){
echo("<p><center>"._USERNAME_NOT_MATCH."</center></p>");
}
if($check_user['password'] != $md5_postpass){
echo("<center>"._PASS_ERR."</center>");
}
login_form();
exit();
}else{
if(($check_user['username'] = $postname) || ($check_user['password'] = $md5_postpass)){
if($remember){
$hour = time() + 360000000;
setcookie("siteid", "esolleeu", $hour);
setcookie("uid", $uid, $hour);
setcookie("pass", $md5_postpass, $hour);
if($realname != NULL){
setcookie("name", $relaname, $hour);
}
}else{
$hour = time() + 3600;
setcookie("siteid", "esolleeu", $hour);
setcookie("uid", $uid, $hour);
setcookie("pass", $md5_postpass, $hour);
if($realname != NULL){
setcookie("name", $relaname, $hour);
}
}
}
}
}
function register_form() {
echo("<center>
<form name="LoginForm" method="post" action="index.php?do=do_register">
<table cellspacing="0" collspacing="0" border="1">
<tr>
<td bgcolor="#E2E2E2">"._USERNAME.":</a>
<td bgcolor="#E2E2E2"><input name="username" type="text" id=username"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSOWRD."</td>
<td bgcolor="#E2E2E2"><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PASSWORD2."</td>
<td bgcolor="#E2E2E2"><input name="password2" type="password" id="password2"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._EMAIL.":</td>
<td bgcolor="#E2E2E2"><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._FULLNAME.":</td>
<td bgcolor="#E2E2E2"><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._SITE.":</td>
<td bgcolor="#E2E2E2"><input name="site" type="text" id="site"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._COUNTRY.":</td>
<td bgcolor="#E2E2E2"><select name="country" class="sb">
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua And Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia And Herzegowina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG" selected>Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote D'Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="FX">France, Metropolitan</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard And Mc Donald Islands</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">North Korea (People's Republic Of Korea)</option>
<option value="KR">South Korea (Republic Of Korea)</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Lao People's Republic</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libyan Arab Jamahiriya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia</option>
<option value="MD">Moldova</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="KN">Saint Kitts And Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="VC">Saint Vincent And The Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome And Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia And The South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SH">St Helena</option>
<option value="PM">St Pierre and Miquelon</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard And Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad And Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks And Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States</option>
<option value="UY">Uruguay</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VA">Vatican City State</option>
<option value="VE">Venezuela</option>
<option value="VN">Viet Nam</option>
<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (U.S.)</option>
<option value="WF">Wallis And Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZR">Zaire</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
<option value="ZZ">Other Not Shown</option>
</select>
</td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._CITY.":</td>
<td bgcolor="#E2E2E2"><select id='city' name="city">
<option value='0' selected>--</option>
<option value='4230' >_ASENOVGRAD</option><option value='2700' >_BLAGOEVGRAD</option><option value='8000' >_BURGAS</option><option value='5000' >_V_TARNOVO</option><option value='9000' >_VARNA</option><option value='3700' >_VIDIN</option><option value='3000' >_VRACA</option><option value='5300' >_GABROVO</option><option value='6400' >_DIMITROVGRAD</option><option value='9300' >_DOBRICH</option><option value='6100' >_KAZANLAK</option><option value='6600' >_KARDJALI</option><option value='2500' >_KIUSTENDIL</option><option value='5500' >_LOVECH</option><option value='3400' >_MONTANA</option><option value='4400' >_PAZARDJIK</option><option value='2300' >_PERNIK</option><option value='5800' >_PLEVEN</option><option value='4000' >_PLOVDIV</option><option value='7200' >_RAZGRAD</option><option value='7000' >_RUSE</option><option value='2800' >_SANDANSKI</option><option value='7500' >_SILISTRA</option><option value='8800' >_SLIVEN</option><option value='1000' >_SOFIA</option><option value='6000' >_STARA_ZAGORA</option><option value='7700' >_TARGOVISHTE</option><option value='6300' >_HASKOVO</option><option value='9700' >_SHUMEN</option><option value='8600' >_YAMBOL</option> <option value='1' >_OTHER</option> </select></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._TEL.":</td>
<td bgcolor="#E2E2E2"><input name="tel" type="text" id="tel"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2">"._PROFILE_DESCRIPTION.":</td>
<td bgcolor="#E2E2E2"><input name="profile" type="text" id="profiler"></td>
</tr>
<tr>
<td bgcolor="#E2E2E2"><input type="hidden" name="submit" value="submit"></td>
<td bgcolor="#E2E2E2"><input type="submit" value=""._REGISTER.""></td>
</tr>
</table>
</form></center>");
}
function do_register(){
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$fullname = $_POST['name'];
$site = $_POST['site'];
$country = $_POST['country'];
$city = $_POST['city'];
$tel = $_POST['tel'];
$profile = $_POST['profile'];
$md5_pass = md5($password);
$regtime = date("y-m-d h:i:s");
if((empty($username)) || (empty($password)) || (empty($password2)) || (empty($email)) || (empty($fullname)) || (empty($site)) || (empty($tel))){
echo(_FORM_ERR);
if(empty($username)){
echo(_USERNAME_LOGIN_REQ);
}
if(empty($password)){
echo(_LOGIN_PASS_REQ);
}
if(empty($password2)){
echo(_LOGIN_PASS_REQ2);
}
if(empty($email)){
echo(_EMAIL_REQ);
}
if(empty($fullname)){
echo(_FULLNAME_REQ);
}
if(empty($site)){
echo(_SITE_REQ);
}
if(empty($tel)){
echo(_TEL_REQ);
}
register_form();
exit();
}
$sql_user_check = mysql_query("SELECT username FROM users WHERE username = '".$username."'");
$user_check = mysql_fetch_row($sql_user_check);
$sql_email_check = mysql_query("SELECT email FROM users WHERE email = '".$email."'");
$email_check = mysql_fetch_row($sql_email_check);
if(($user_check != 0) || ($email_check != 0)){
if($user_check != 0){
echo(_USERNAME_ALREADY_TAKEN);
}
if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email)){
echo(_INVALID_EMAIL);
}
if($email_check != 0){
echo(_EMAIL_AREADY_TAKEN);
}
if($password != $password2){
echo(_PASSWORD_DOESNT_MATCH);
}
register_form();
exit();
}
$insert = "INSERT INTO users (username, password, email, fullname, site, country, city, tel, profile, regdate)
VALUES ('".$username."', '".$md5_pass."', '".$email."', '".$fullname."', '".$site."', '".$country."', '".$city."', '".$tel."', '".$profile."', '".$regtime."')";
mysql_query($insert);
echo(_REGISTER_DONE);
echo(_10X_TO_REGISER);
}
//Тази функция я използваме за да скрием информация от външни потребители
function is_logged_in($user) {
if(isset($_COOKIE['esolleeu'])){
$userid = $_COOKIE['uid'];
$passwd = $_COOKIE['pass'];
$userid = intval($userid);
if(($userid != "") || ($passwd != "")){
$sql_check = mysql_query("SELECT * FROM esolle_users WHERE userid = '$userid'");
$info = mysql_fetch_array($sql_check);
if(($info['userid'] = $iserid) || ($info['password'] = $passwd)){
return 1;
}else{
return 0;
}
}
}
}
//Пример
// if(is_logged_in($user)){
// echo(_WELCOME_REGISTERED_USER);
// }else{
// echo(_PLEASE_LOGIN_FIRST);
// }
?>