new pisilinux web sites
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Created By : Erkan IŞIK
|
||||
* Created Date: 2017-09-27
|
||||
* Update Date : 2018-11-24
|
||||
*/
|
||||
class User_model extends Model{
|
||||
|
||||
function logincheck($data){
|
||||
$url = isset($_GET['return_url']) ? $_GET['return_url'] : null;
|
||||
|
||||
$user = DB::where('mail',$data['email'], 'and')
|
||||
->where('status','1')
|
||||
->get('user')
|
||||
->row();
|
||||
|
||||
if (!$user) {
|
||||
redirect(URL::base().'member');
|
||||
return;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
if (password_verify($data['pass'], $user->password)) {
|
||||
$valid = true;
|
||||
} elseif (md5($data['pass']) === $user->password) {
|
||||
$valid = true;
|
||||
$newHash = password_hash($data['pass'], PASSWORD_DEFAULT);
|
||||
DB::where('user_id', $user->user_id)->update('user',['password' => $newHash]);
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
DB::where('user_id', $user->user_id)->update('user',['login_date' => $data['currentDate']]);
|
||||
Session::insert('login','true');
|
||||
Session::insert('userid',$user->user_id);
|
||||
Session::insert('username',$user->username);
|
||||
Session::insert('avatar',$user->avatar);
|
||||
Session::insert('yetki',$user->authority);
|
||||
Cookie::time(60 * 60 * 24)->insert('username',$user->username);
|
||||
|
||||
if(isset($data['remember']) == '1'){
|
||||
Cookie::time(60 * 60 * 24)->insert('userlogin','true');
|
||||
Cookie::time(60 * 60 * 24)->insert('userid',$user->user_id);
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
redirect(URL::base($url));
|
||||
}else{
|
||||
redirect(URL::base());
|
||||
}
|
||||
}else{redirect(URL::base().'member');}
|
||||
}
|
||||
|
||||
function emailcontrol($post){
|
||||
$mailCheck = DB::select('mail')->where('mail', $post['email1'])->userResult();
|
||||
if ($mailCheck) {
|
||||
echo '1';
|
||||
}
|
||||
}
|
||||
|
||||
function yeniuye($post){
|
||||
$password = password_hash($post['password'], PASSWORD_DEFAULT);
|
||||
$rnd = md5(date('Ymd His'));
|
||||
$username = mb_convert_case($post['username'], MB_CASE_TITLE, "UTF-8").' '.mb_convert_case($post['surname'], MB_CASE_TITLE, "UTF-8");
|
||||
|
||||
$new_user = DB::insert('user',[
|
||||
'username' => $username,
|
||||
'mail' => $post['email'],
|
||||
'password' => $password,
|
||||
'avatar' => '',
|
||||
'status' => '0',
|
||||
'authority' => '2',
|
||||
'aktivizasyon' => $rnd,
|
||||
'egitim' => $post['egitim'],
|
||||
'meslek' => $post['meslek'],
|
||||
'beceri' => $post['beceri'],
|
||||
'nickname' => ''
|
||||
]);
|
||||
|
||||
if ($new_user){
|
||||
echo '1';
|
||||
|
||||
$mesaj = emailActivationTemplate($username, $rnd);
|
||||
|
||||
Email::from('info@pisilinux.org', 'Pisi Linux','info@pisilinux.org')
|
||||
->receiver($post['email'])
|
||||
->subject('Üyelik onayı')
|
||||
->message($mesaj)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
function sifremiunuttum_model($post){
|
||||
$user = DB::where('mail',$post['email'])->get('user')->row();
|
||||
if (!$user) {
|
||||
echo "<script>
|
||||
swal({
|
||||
title: 'Hata!',
|
||||
text: 'Böyle Bir mail adresi kayıtlı değil...',
|
||||
icon: 'error',
|
||||
button: 'Tamam'
|
||||
}).then(function() {
|
||||
window.location.href = '/member/sifremiunuttum';
|
||||
});
|
||||
</script>";
|
||||
return;
|
||||
}
|
||||
|
||||
$rnd = md5(date('Ymd His'));
|
||||
DB::where('mail',$post['email'])->update('user',['aktivizasyon' => $rnd,'status' => '0']);
|
||||
|
||||
if (DB::affectedRows()) {
|
||||
$mesaj = emailPasswordResetTemplate($rnd);
|
||||
|
||||
if (DB::affectedRows()){
|
||||
Email::from('info@pisilinux.org', 'Pisi Linux','info@pisilinux.org')
|
||||
->receiver($post['email'])
|
||||
->subject('Yeni Şifre belirleme')
|
||||
->message($mesaj)
|
||||
->send();
|
||||
|
||||
echo "<script>
|
||||
swal({
|
||||
title: 'Başarılı!',
|
||||
text: 'Kurtarma maili Gönderildi. Yeni Şifre Belirleyebilmeniz için lütfen mail adresinizi kontrol edin...',
|
||||
icon: 'success',
|
||||
button: 'Tamam'
|
||||
}).then(function() {
|
||||
window.location.href = '/';
|
||||
});
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
}//sifremiunuttum_model
|
||||
|
||||
function yenisifre($post){
|
||||
$password = password_hash($post['password'], PASSWORD_DEFAULT);
|
||||
DB::where('aktivizasyon',$post['act'])->update('user',['aktivizasyon' => '']);
|
||||
DB::where('user_id',$post['id'])->update('user',['password' => $password,'status' => '1']);
|
||||
jalert('Şifreniz Başarıyla Güncellendi. Üye giriş sayfasına yönlendiriliyorsunuz...');
|
||||
git('uye');
|
||||
}//yenisifre
|
||||
}//class sonu
|
||||
Reference in New Issue
Block a user