- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
<?php
class user {
var $logined=false;
var $information;
var $err_code=0;
var $err_arr;
var $cookie_time=2592000;
var $_db;
var $no_profile_photo="/assets/img/no_profile_photo.jpg";
var $friends_list=array();
var $friends_list_to=array();
var $friends_list_from=array();
//RewriteRule ^(.*)profile_photo.jpg$ assets/img/no_profile_photo.jpg [L]
function db($_db){
$this->_db=$_db;
}
function set_err_txts(){
$this->err_arr[0]="";
$this->err_arr[1]="login preg";
$this->err_arr[2]="no such login in db";
$this->err_arr[3]="wrong pass";
$this->err_arr[4]="";
}
function auth($login,$pass,$md5=false){
if(!($login)) {return false;}
////////////////////////////////////
$this->set_err_txts();
$cookie_time=time()+$this->cookie_time;
/////////////////////////////
if(!(preg_match("/^[a-z0-9_-]+$/i",$login)))
{$this->err_code=1; return false;}
////////////////////////////////////////////////////////////
$sql="select id, login, salt from users where login='".$login."'";
$res=mysql_query($sql,$this->_db);
//echo $sql; echo var_dump($this->_db); echo var_dump($res);
if(!($item=mysql_fetch_array($res)))
{$this->err_code=2; return false;}
///
$id=$item['id'];
$salt=$item['salt'];
////////////////////////////////////////////////////////////
if(!($md5)){ $pass=$this->code_pass($pass,$salt); }
////////////////////////////////////////////////////////////////
$sql="select * from users where (login='".$login."') and (pass='".$pass."')";
$res=mysql_query($sql,$this->_db);
//echo $sql; echo var_dump($this->_db); echo var_dump($res);
if(!($item=mysql_fetch_array($res)))
{$this->err_code=3; return false;}
/////////////////////////////////////////////////////////////
setcookie("login", $login, $cookie_time,"/");
setcookie("pass", $pass, $cookie_time,"/");
$sql="update users set visit_time=".time()." where id='".$id."'";
mysql_query($sql,$this->_db);
$this->information=$item;
$this->logined=true;
////////////////////////////////////////////////////////////////
$sql="
select users_params.name, users_params_values.value
from users_params, users_params_values
where
(users_params_values.user_id='".$id."')
and
(users_params_values.param_id=users_params.id)";
$res=mysql_query($sql,$this->_db);
while($item=mysql_fetch_row($res)){
$this->information[$item[0]]=$item[1];
}
$this->information["folder"]="/profiles/".substr($login,0,1)."/".$login."/";
$this->information["profile_photo"]=$this->information["folder"]."profile_photo.jpg";
$this->create_friends_list();
return true;
}
function get_info_by_id($target_user_id){
$sql="select id, login, visit_time from users where id='".$target_user_id."'";
$res=mysql_query($sql,$this->_db);
$item=mysql_fetch_array($res);
$login=$item['login'];
$this->information["login"]=$login;
$this->information["visit_time"]=$item['visit_time'];
$this->information["id"]=$item['id'];
$sql="
select users_params.name, users_params_values.value
from users_params, users_params_values
where
(users_params_values.user_id='".$target_user_id."')
and
(users_params_values.param_id=users_params.id)";
$res=mysql_query($sql,$this->_db);
while($item=mysql_fetch_row($res)){
$this->information[$item[0]]=$item[1];
}
$this->information["folder"]="/profiles/".substr($login,0,1)."/".$login."/";
$this->information["profile_photo"]=$this->information["folder"]."profile_photo.jpg";
}
.... over 9000 ....
eth0 02.08.2013 18:26 # +1
Stallman 02.08.2013 19:12 # 0
someone 02.08.2013 23:26 # +2
Лец ми спик фром май харт ин инглиш!
denis90 03.08.2013 23:25 # 0