Exemplo n.º 1
0
 public function show($email)
 {
     $passwordReset = R::getRow('SELECT `users`.`id` AS `userId`, `passwordResets`.`id`, `passwordResets`.`token`, `passwordResets`.`created`
         	FROM ( `users` )
         LEFT JOIN `passwordResets`
         	ON ( `passwordResets`.`userId` = `users`.`id` )
         WHERE `users`.`email` = :email', [':email' => $email]);
     return !empty($passwordReset) ? $passwordReset : false;
 }
Exemplo n.º 2
0
 public static function login($username, $password)
 {
     $row = R::getRow("SELECT * FROM `user` WHERE username = ? ", array($username));
     if ($row != null && password_verify($password, $row["password"])) {
         $_SESSION["username"] = $username;
         $_SESSION["password"] = $password;
         return true;
     } else {
         unset($_SESSION["username"]);
         unset($_SESSION["password"]);
         return false;
     }
 }
Exemplo n.º 3
0
 public function index()
 {
     $perPage = 10;
     $page = @$_GET['page'] ? $_GET['page'] : 1;
     $start = ($page - 1) * $perPage;
     $items = R::find('contactdealer', 'LIMIT ?,?', [$start, $perPage]);
     $count = R::count('contactdealer');
     foreach ($items as &$item) {
         $item->ownProvince = R::getRow('SELECT * FROM provinces WHERE province_id=?', [$item->province_id]);
         $item->ownGeography = R::getRow('SELECT * FROM geography WHERE geo_id=?', [$item->geo_id]);
         // var_dump($item); exit();
     }
     $maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
     $this->slim->render("contactdealer/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage]);
 }
Exemplo n.º 4
0
 public function save()
 {
     if (!$this->emptyAttr('id')) {
         $contactDealer = R::findOne('contactdealer', 'id=?', [$this->getAttr('id')]);
         $contactDealer->updated_at = date('Y-m-d H:i:s');
     } else {
         $contactDealer = R::dispense('contactdealer');
         $contactDealer->created_at = date('Y-m-d H:i:s');
         $contactDealer->updated_at = date('Y-m-d H:i:s');
     }
     $contactDealer->name = $this->getAttr('name');
     $contactDealer->address = $this->getAttr('address', '');
     $contactDealer->phone = $this->getAttr('phone', '');
     $contactDealer->province_id = $this->getAttr('province_id', '');
     $contactDealer->geo_id = $this->getAttr('geo_id', '');
     $contactDealer->lat = $this->getAttr('lat', '');
     $contactDealer->lng = $this->getAttr('lng', '');
     $province = R::getRow('SELECT * FROM provinces WHERE province_id = ?', [$contactDealer->province_id]);
     if ($province) {
         $contactDealer->geo_id = $province['geo_id'];
     }
     $success = R::store($contactDealer);
     return $success;
 }
Exemplo n.º 5
0
 public function addRoomUse()
 {
     $productId = $this->slim->request->post()['product_id'];
     $roomName = $this->slim->request->post()['room_name'];
     $item = R::findOne('product', 'id=?', [$productId]);
     if (!$item) {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'NOT_FOUND_PRODUCT'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         exit;
     }
     $dateStr = date('Y-m-d');
     $productView = R::getRow('SELECT * FROM product_room WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
     if (!$productView) {
         R::exec('INSERT INTO product_room SET product_id=?, room_name=? , view_date=?', [$productId, $roomName, $dateStr]);
     }
     R::exec('UPDATE product_room SET view_count = view_count+1 WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
     header('Content-Type: application/json');
     echo json_encode(['successs' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
Exemplo n.º 6
0
 public function productAddStat($productId)
 {
     $dateStr = date('Y-m-d');
     $productView = R::getRow('SELECT * FROM product_add WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
     if (!$productView) {
         R::exec('INSERT INTO product_add SET product_id=?, add_date=?', [$productId, $dateStr]);
     }
     R::exec('UPDATE product_add SET add_count = add_count+1 WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
     header('Content-Type: application/json');
     echo json_encode(['success' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
Exemplo n.º 7
0
 public function build(&$item)
 {
     $item['province'] = R::getRow('SELECT * FROM provinces WHERE province_id=?', [$item['province_id']]);
     $item['geography'] = R::getRow('SELECT * FROM geography WHERE geo_id=?', [$item['geo_id']]);
 }