<?php
	class user{
		function login($username, $password){
			$pass = sha1(md5($password));
			$r = mysql_query("SELECT * FROM `adminus` WHERE `email`='$username' AND `sifre`='$pass' LIMIT 1");
				$t = mysql_num_rows($r);
			if($t>=1){
				$my = mysql_fetch_object($r);
					$_SESSION['a_adminus'] 	= $my->aID;
					$_SESSION['ad_session']	= session_id();
					$this->updatelogin($my->aID);
				echo "Giriş Tamamdır. İyi Çalışmalar.";
			}else{
				echo "Yanlış Kullanıcı Adı ve Şifre!";
			}
		}
		function admininfo($aID){
			$r = mysql_query("SELECT * FROM `adminus` WHERE `aID`='$aID'");
				$my = mysql_fetch_object($r);
				return $my->isim;
		}
		function updatelogin($aID){
			$date=date("Y-m-d H:i:s");
			$m = mysql_query("UPDATE `adminus` SET `giris`='$date' WHERE aID='$aID'");
		}
		function giris(){
        if(isset($_SESSION['a_adminus']) && isset($_SESSION['ad_session'])){
            $login = "ok";
        }else{
            $login = "fail";
        }
        return $login;
    }
	function yeniuyeler(){
		$date = date("Y-m-d 00:00:00");
		$mysql = mysql_query("SELECT * FROM `uye` WHERE `tarih`>'$date'");
			$num = mysql_num_rows($mysql);
		return $num;
	}
	function yenimesajlar(){
		$date = date("Y-m-d 00:00:00");
		$mysql = mysql_query("SELECT * FROM `iletisim` WHERE `tarih`>'$date'");
			$num = mysql_num_rows($mysql);
		return $num;
	}
	 function uyehambilgileri($uID){
        //SELECT * FROM `uye` WHERE `uID`='$uID'
        $a = mysql_query("SELECT * FROM uye WHERE uID='$uID'");
		if(mysql_num_rows($a)<=0){
			$m="0";
		}else{
        	$m = mysql_fetch_object($a);
		}
        return $m;
    }
	
	function tarihsaat($tarih){
			$newdate[1] = substr($tarih, 0, 4);
			$newdate[2] = substr($tarih, 5, 2);
			$newdate[3] = substr($tarih, 8, 2);
			$newdate[4] = substr($tarih, 11, 2);
			$newdate[5] = substr($tarih, 14, 2);
			$newdate[6] = substr($tarih, 17, 2);
				$newdateformated = $newdate[3].".".$newdate[2].".".$newdate[1]." ".$newdate[4].":".$newdate[5];
			return $newdateformated;
	}
	function cikisyap(){
		session_destroy();
    }
	function info(){
        $t = mysql_query("SELECT * FROM site WHERE sID='1'");
            $s = mysql_fetch_object($t);
        return  $s;
    }
	function limit($vip){
        $t = mysql_query("SELECT * FROM limitler WHERE vip='$vip'");
            $s = mysql_fetch_object($t);
        return  $s;
    }
	function odemetipi($tur, $oID){
		 $n = mysql_query("SELECT * FROM `uye_odeme` WHERE `oID`='$oID'");
			$y = mysql_fetch_object($n);
		if($tur=="Havale"){ $r = $tur." / ".$y->banka; }
		elseif($tur=="Kredi"){ $r = "Kredi Kartı"; }
		elseif($tur=="Mobil"){ $r = "Mobil Ödeme"; }
		return $r;
	}
	function sehirgetir($sID){
		$array = array("34"=>"İstanbul");
		return $array[$sID];
	}
	function vipmi($uID){
        $a = mysql_query("SELECT * FROM uye WHERE uID='$uID'");
		if(mysql_num_rows($a)<=0){
			$t = "0";
		}else{
            $m = mysql_fetch_object($a);
                $t = $m->vip;
		}

        return $t;
    }
}
?>