Esempio n. 1
0
 public static function isAdmin()
 {
     $admin = \Lib\Session::get('admin');
     if ($admin) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public static function intended($default = null)
 {
     if (\Lib\Session::get('intended')) {
         $to = \Lib\Session::get('intended');
         \Lib\Session::delete('intended');
         header("Location: {$to}");
         exit;
     }
     header("Location: {$default}");
     exit;
 }
Esempio n. 3
0
 private function check()
 {
     $admin = \Lib\Session::get('admin');
     $id = \Lib\Session::get('id');
     $login = \Lib\Session::get('login');
     $admin_mode = $this->http->post('admin');
     if (!$admin) {
         if ($this->http->isActive('login') && $admin_mode) {
             $login = $this->http->post('login');
             $password = $this->http->post('password');
             if ($login == ADMIN_LOGIN && $password == ADMIN_PASSWORD) {
                 \Lib\Session::set('admin', true);
                 Location::To(URL . 'admin');
             } else {
                 $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Nieprawidłowa nazwa użytkownika lub hasło.'));
             }
         }
     } else {
         Location::To(URL . 'admin');
     }
     if (empty($id) || empty($login)) {
         if ($this->http->isActive('login') && !$admin_mode) {
             $this->m_login = new \Models\Login();
             if ($this->m_login->login($this->http->post('login'), $this->http->post('password'))) {
                 if ($this->m_login->isActivated($this->http->post('login'))) {
                     \Lib\Session::set('id', $this->m_login->getId());
                     \Lib\Session::set('login', $this->m_login->getLogin());
                     Location::intended(URL . 'user');
                 } else {
                     $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Konto jest nieaktywne.'));
                 }
             } else {
                 $this->render('Login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids, 'error' => 'Nieprawidłowa nazwa użytkownika lub hasło.'));
             }
         } else {
             $this->render('login', array('categories' => $this->categories, 'd_product' => $this->d_product, 'ids' => $this->category_ids));
         }
     } else {
         Location::To(URL . 'user');
     }
 }
Esempio n. 4
0
 private function finalize()
 {
     $user = new User(\Lib\Session::get('id'));
     $name = $user->getFirstName();
     $surname = $user->getSurname();
     $country = $user->getCountry();
     $zipcode = $user->getZipCode();
     $city = $user->getCity();
     $street = $user->getStreet();
     $house = $user->getHousNr();
     $appartment = $user->getAppartmentNr();
     $order_details = new Order_details();
     $order_details->setAddress('Imie: ' . $user->getFirstName() . ' Nazwisko: ' . $user->getSurname() . ' Kraj: ' . $user->getCountry() . ' Kod-Pocztowy: ' . $user->getZipCode() . ' Miasto: ' . $user->getCity() . ' Ulica : ' . $user->getStreet() . ' Nr domu: ' . $user->getHousNr() . ' Nr mieszkania: ' . $user->getAppartmentNr());
     $time = time();
     $id = \Lib\Session::get('id');
     $rand = rand(1, 100);
     $nr = $id . $time . $rand;
     $order_details->setOrderNr($nr);
     $order_details->setDisplaySeller(true);
     $order_details->setDisplayUser(true);
     $sm = $this->http->get('shipping_method');
     if (empty($sm)) {
         Location::To(URL . 'cart/show');
     }
     $order_details->setShippingMethodId($sm);
     $order_details->setDate();
     $order_details->setStatus(1);
     $cart = \Lib\Session::get('cart');
     if (!empty($cart)) {
         $db = Register::get('db');
         $db->query('START TRANSACTION');
         $id = $order_details->writeData();
         foreach ($cart as $product) {
             $order = new Order($product['order_id']);
             $order->setActive(1);
             $order->setOrderDetailsId($id);
             $order->writeData(true);
             if (!$order->writeData(true)) {
                 $db->query('ROLLBACK');
                 return false;
             }
         }
         if ($id) {
             $db->query('COMMIT');
         } else {
             $db->query('ROLLBACK');
             return false;
         }
         $mess = $this->http->get('message');
         if (!empty($mess)) {
             $mesage = new Message();
             $mesage->setUserId(\lib\Register::get('id'));
             $mesage->setReaded(false);
             $mesage->setSeller(false);
             $mesage->setMessage($order_details->getOrderNr() . ': ' . $this->http->get('message'));
             $mesage->setDate();
             $mesage->setDisplayUser(true);
             $mesage->setDisplaySeller(true);
             $mesage->writeData();
         }
         \Lib\Session::delete('cart');
         $this->ActNumberOfProducts();
         return true;
     }
 }
Esempio n. 5
0
 public static function getNumberOfProducts()
 {
     $p = \lib\Session::get('cart_num_of_products');
     return $p;
 }
Esempio n. 6
0
 public static function getCurrentUser()
 {
     $user = Lib\Session::get('user');
     return $user;
 }
Esempio n. 7
0
 /**
  * şifremi unuttum
  *
  * @return mixed
  */
 public function SifremiUnuttum()
 {
     if (\Lib\Session::get('loggedin')) {
         \Lib\Url::redirect('hesapim');
     }
     // if (isset ( $_POST ['submit'] )) {
     if (Request::isPost()) {
         $email = $this->request->get('email');
         if ($email == '') {
             $error[] = 'email alanı boş bırakılamaz';
         }
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $error[] = 'lütfen geçerli bir email adresi yazınız ';
         }
         if (!$error) {
             $total = $this->_model->getEmail_Varmi($email);
             if ($total > 0) {
                 $user = $this->_model->getKullaniciBilgileri($email);
                 // print_r($user);die;
                 $email_adresi = $user['email'];
                 $ad_soyad = \Lib\Strings::adSoyadParcala($bilgiler['unvan']);
                 $adi_soyadi = $ad_soyad['adi'] . ' ' . $ad_soyad['soyadi'];
                 $user_id = $user['id'];
                 $subject = 'İdeal.com.tr Şifre Yenileme';
                 $tokenkey = \Lib\Tools::token_key_olustur();
                 $toplam_token_adet = $this->_model->getBoyle_bir_token_varmi($tokenkey);
                 // aynı isimde token key olabilir onu engellemek gerek
                 if ($toplam_token_adet > 0) {
                     $tokenkey = $tokenkey . 'st_n_ck_ey';
                 }
                 $postdata = array('token_key' => $tokenkey);
                 $where = array('id' => $user_id);
                 $this->_model->update_tokenKey_user($postdata, $where);
                 $message = '<a href="' . DIR . 'uyelik?action=uye_sifremiunuttum_degisiklik&token=' . $tokenkey . '">Şifre değiştirmek için tıklyayınız</a>';
                 $mail = new \Helpers\Mailler_Helper();
                 $sonuc = $mail->sendmail("*****@*****.**", $email_adresi, $adi_soyadi, $subject, $message);
                 if (!$sonuc) {
                     $hata = \Lib\Tools::message_ver('hata', $sonuc);
                     \Lib\Session::set('message', $hata);
                     // \Lib\Url::redirect('uyelik?action=sifremi_unuttum');
                 } else {
                     $basarili = \Lib\Tools::message_ver('ok', 'Şifre değiştirme linki mail adresinize gönderilmiştir');
                     \Lib\Session::set('message', $basarili);
                     // \Lib\Url::redirect('uyelik?action=uye_sifremiunuttum_degisiklik');
                 }
             } else {
                 $err = 'Böyle bir e-mail adresi bulunamadi';
                 $hata = \Lib\Tools::message_ver('hata', $err);
                 \Lib\Session::set('message', $hata);
                 // \Lib\Url::redirect('uyelik?action=sifremi_unuttum');
             }
         }
     }
     return $error;
 }
    public static function YeniSiparisBildirimi($data, $mailYazisi)
    {
        $kullanici_bilgileri = \Lib\Session::get('kullanici_bilgileri');
        $ad_soyad = \Lib\Strings::strtoTrUcFirst($kullanici_bilgileri['adi']) . ' ' . \Lib\Strings::strtoTrUcFirst($kullanici_bilgileri['soyadi']);
        // echo '<pre>';
        extract($data);
        $file = self::TableStyle() . '<body bgcolor="#f6f6f6">
            
           <strong>  ' . $mailYazisi . '   </strong>' . $data['sepet'] . '
							<table class="body-wrap">
								<tbody>
									<tr class="price2">
										<td class="right"><b>Toplam:</b></td>
										<td class="right"><a class="toplamfiyat" href="' . $data['sepet_fiyat_toplami'] . '"></a>
		                                      <span class="toplamfiyatspan">' . $data['sepet_fiyat_toplami'] . ' TL</span>
										</td>
									</tr>
								</tbody>
							</table>
	
		

								  <strong>Bilgileriniz  </strong>
								<table class="body-wrap" border="1" cellspacing="0" cellpadding="0">
									<tbody>
										<tr>
											<th>Sipariş No:</th>
											<td>' . $siparis_no . '</td>
										</tr>
										<tr>
											<th>Siparişi Oluşturan:</th>
											<td>' . $ad_soyad . '</td>
										</tr>
											<tr>
											<th>Telefon Numarası</th>
											<td>' . $telefon . '</td>
										</tr>
											    
										<tr>
											<th>Email Adresi</th>
											<td>' . $email . '</td>
										</tr>
											  
											    
										<tr>
											<th>Oluşturma Zamanı:</th>
											<td>' . $olusturma_zamani . '</td>
										</tr>
										<tr>
											<th>Sipariş Durumu:</th>
											<td>' . $siparis_durumu . '</td>
										</tr>
										<tr>
											<th>Sipariş Tutarı</th>
											<td>' . $siparis_tutari . ' TL</td>
										</tr>
        
										<tr>
											<th>Ödeme Türü</th>
											<td>' . $odeme_tipi . '</td>
										</tr>
        
        
											<tr>
											<th>Mağaza</th>
											<td>' . $magaza_adi . '</td>
										</tr>
        
        
									</tbody>
								</table>
							</div>
        

								  <strong>Teslimat Bilgileri  </strong>
								<table class="body-wrap" border="1" cellspacing="0" cellpadding="0">
									<tbody>
        
										<tr>
											<th>Teslimat Saati:</th>
											<td>' . $teslimat_saati . '</td>
										</tr>
        
										<tr>
											<th>Teslimat Tarihi:</th>
											<td>' . $teslimat_tarihi . '</td>
										</tr>
        
										<tr>
											<th>İsim Soyisim:</th>
											<td>' . $ad_soyad . '</td>
										</tr>
        
										<tr>
											<th>Adres:</th>
											<td>' . $alici_adres . ' </td>
										</tr>
        
										<tr>
											<th>Şehir ,İlçe, Semt/Mahalle</th>
											<td>' . $alici_il . ' , ' . $alici_ilce . ' , ' . $alici_semt . '</td>
										</tr>
        
									</tbody>
								</table>
							</div>
				
								  <strong>Fatura Bilgileri  </strong>
								<table class="body-wrap" border="1" cellspacing="0" cellpadding="0">
									<tbody>
        
										<tr>
											<th>İsim Soyisim:</th>
											<td>' . $ad_soyad . '</td>
										</tr>
										<tr>
											<th>Adres:</th>
											<td>' . $fatura_adres . '  </td>
										</tr>
        
										<tr>
											<th>Şehir ,İlçe, Semt/Mahalle</th>
											<td>' . $fatura_il . ' , ' . $fatura_ilce . ' , ' . $fatura_semt . '</td>
										</tr>
									</tbody>
								</table>
							</div></body></html>';
        $file = self::replaceSpace($file);
        return $file;
    }