Beispiel #1
1
 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
 public function checkOut(Request $request)
 {
     $address = \StringHelper::filterString($request->input('address'));
     $name = \StringHelper::filterString($request->input('name'));
     $content = \StringHelper::filterString($request->input('comments'));
     $phone = \StringHelper::filterString($request->input('phone'));
     $count = Cart::count();
     if ($phone != "" && $name != "" && $content != "" && $count > 0) {
         $order = new Order();
         $order->order_name = $name;
         $order->status = 1;
         $order->active = 1;
         $order->order_comment = $content;
         $order->order_address = $address;
         $order->order_phone = $phone;
         $order->save();
         $cart = Cart::content();
         foreach ($cart as $item) {
             $order_detail = new OrderDetail();
             $order_detail->dish_id = $item->id;
             $order_detail->dish_number = $item->qty;
             $order_detail->order_id = $order->id;
             $order_detail->save();
         }
         Cart::destroy();
         return Redirect::to(url('menu'))->with('message', 'Order Success !. You can continue buy now !');
     } else {
         return Redirect::to(url('checkout'))->with('message', 'Order Fail !. Something Wrong !');
     }
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function bookTable(Request $request)
 {
     $email = \StringHelper::filterString($request->input('email'));
     $name = \StringHelper::filterString($request->input('name'));
     $phone = \StringHelper::filterString($request->input('phone'));
     $number = \StringHelper::filterString($request->input('number'));
     $month = \StringHelper::filterString($request->input('month'));
     $day = \StringHelper::filterString($request->input('day'));
     $hour = \StringHelper::filterString($request->input('hour'));
     $min = \StringHelper::filterString($request->input('min'));
     $a_p = \StringHelper::filterString($request->input('a-p'));
     $content = \StringHelper::filterString($request->input('comments'));
     if ($email != "" && $name != "" && $phone != "" && $number != "" && $month != "" && $day != "") {
         $book_table = new BookTable();
         $book_table->name = $name;
         $book_table->email = $email;
         $book_table->phone = $phone;
         $book_table->number = $number;
         $book_table->comments = $content;
         $book_table->active = 1;
         $book_table->status = 1;
         $book_table->date = $day . "-" . $month . " " . $hour . ":" . $min . " " . $a_p;
         $book_table->save();
     }
     return Redirect::back()->with('message', 'Success');
 }
 public function deleteOrder(Request $request)
 {
     $order_id = \StringHelper::filterString($request->input('order_id'));
     $deletedRows = Order::where('id', $order_id)->delete();
     $catRow = OrderDetail::where('order_id', $order_id)->delete();
     return Redirect::back()->with('message', 'Success');
 }
Beispiel #5
0
 public function actionchangePassword()
 {
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $old_pass = StringHelper::filterString(Yii::app()->request->getPost('old_password'));
             $pass1 = StringHelper::filterString(Yii::app()->request->getPost('password'));
             $pass2 = StringHelper::filterString(Yii::app()->request->getPost('password2'));
             $user = User::model()->findByAttributes(array('password' => md5($old_pass)));
             if ($user) {
                 if ($pass1 == $pass2) {
                     $user->password = md5($pass1);
                     $user->save(FALSE);
                     Yii::app()->user->setFlash('success', "Password changed !");
                     $this->redirect(Yii::app()->createUrl('admin/order'));
                 }
             } else {
                 $this->redirect(Yii::app()->createUrl('admin/home/login'));
             }
         } catch (exception $e) {
             echo $e->getMessage();
         }
     }
     $this->render('changePassword');
 }
 public function actionInsertPostCeleb()
 {
     $this->pageTitile = 'Thêm bài viết người nổi tiếng';
     $request = Yii::app()->request;
     try {
         $post_content = StringHelper::filterString($request->getPost('post_content'));
         $celeb_id = StringHelper::filterString($request->getPost('celeb_id'));
         $location = StringHelper::filterString($request->getPost('location'));
         $cats = $request->getPost('cats');
         if (count($_FILES['images']['tmp_name']) > 1) {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         } else {
             $url_arr = UploadHelper::getUrlUploadMultiImages($_FILES['images'], $celeb_id . 'celeb');
         }
         // $album = StringHelper::filterString($request->getPost('album'));
         $album = NULL;
         $res = Posts::model()->addPostCeleb($celeb_id, $post_content, $location, $url_arr, $album, $cats);
         if ($res != FALSE) {
             Yii::app()->user->setFlash('success', 'Thêm bài viết thành công');
         } else {
             Yii::app()->user->setFlash('error', 'Có lỗi xảy ra');
         }
         $this->redirect(Yii::app()->createUrl('celebrity/addPost'));
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #7
0
 public function actionUpdateVersion()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $app_ver = StringHelper::filterString($request->getPost('app_ver'));
             $db_ver = StringHelper::filterString($request->getPost('db_ver'));
             $model = AppDbVer::model()->findByAttributes(array('id' => 1));
             $model->app_ver = $app_ver;
             $model->db_ver = $db_ver;
             if ($model->save(FALSE)) {
                 $this->retVal->status = 1;
                 $this->retVal->message = "Success";
             } else {
                 $this->retVal->status = 0;
                 $this->retVal->message = "Fail";
             }
             $this->retVal->data = "";
         } catch (exception $e) {
             $this->retVal->message = $e->getMessage();
         }
         echo CJSON::encode($this->retVal);
         Yii::app()->end();
     }
 }
Beispiel #8
0
 public function actionGetOrderAndResult()
 {
     $request = Yii::app()->request;
     $order_id = StringHelper::filterString($request->getQuery('order_id'));
     $data = OrderMedlatec::model()->getOrderAndResult($order_id);
     ResponseHelper::JsonReturnSuccess($data, 'Success');
 }
 public function actionViewDocument()
 {
     if (isset($_GET['doc_id'])) {
         $doc_id = StringHelper::filterString($_GET['doc_id']);
         $detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id)));
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "doc_id = :doc_id";
         $spCriteria->params = array(':doc_id' => $doc_id);
         $subject_doc = SubjectDoc::model()->find($spCriteria);
         $spjCriteria = new CDbCriteria();
         $spjCriteria->select = "*";
         $spjCriteria->condition = "subject_id = :subject_id";
         $spjCriteria->params = array(':subject_id' => $subject_doc->subject_id);
         $subject = Subject::model()->find($spjCriteria);
         $related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()"));
         foreach ($detail_doc as $detail) {
             $title = $detail->doc_name . " | Bluebee - UET";
             $this->pageTitle = $title;
             if ($detail->doc_type == 3) {
                 $image = Yii::app()->getBaseUrl(true) . $detail->doc_url;
             } else {
                 $image = $detail->doc_url;
             }
             $des = $detail->doc_description;
             Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
             Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width'));
             Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height'));
             Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type'));
             Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
         }
         $this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject));
     }
 }
Beispiel #10
0
 public function actionDetail()
 {
     $request = Yii::app()->request;
     $patient_id = StringHelper::filterString($request->getQuery("patient_id"));
     $patient_info = Patient::model()->findByAttributes(array('patient_id' => $patient_id));
     // $patient_info = Patient::model()->getPatientDetailAdmin($patient_id);
     // echo CJSON::encode($patient_info);
     $this->render('detail', array('patient_info' => $patient_info));
 }
Beispiel #11
0
 public function actionEdit()
 {
     $request = Yii::app()->request;
     $this->layoutPath = Yii::getPathOfAlias('webroot') . "/themes/classic/views/layouts";
     $this->layout = 'main_modal';
     $service_id = StringHelper::filterString($request->getQuery('service_id'));
     $data = ServiceMedlatec::model()->findByPk($service_id);
     $this->render('edit', array('data' => $data));
 }
Beispiel #12
0
 public function actionEdit()
 {
     try {
         $id = StringHelper::filterString(Yii::app()->request->getQuery('id'));
         $result = Opinion::model()->findByPk($id);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
     $this->render('edit', array('model' => $result));
 }
 public function actionGetSubjectByUser()
 {
     $request = Yii::app()->request;
     try {
         $user_id = StringHelper::filterString($request->getQuery('user_id'));
         $data = Subject::model()->getSubjectByUser($user_id);
         ResponseHelper::JsonReturnSuccess($data, 'success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #14
0
 public function actionGetServices()
 {
     $request = Yii::app()->request;
     try {
         $limit = StringHelper::filterString($request->getQuery('limit'));
         $offset = StringHelper::filterString($request->getQuery('offset'));
         $data = ServiceMedlatec::model()->getServices($limit, $offset);
         ResponseHelper::JsonReturnSuccess($data, 'Success');
     } catch (Exception $ex) {
     }
 }
 public function processAdminLogin(Request $request)
 {
     $uname = \StringHelper::filterString($request->input('uname'));
     $upw = \StringHelper::filterString($request->input('upw'));
     if ($uname == 'admin' && $upw == 'admin') {
         // Session::put('admin', 'admin');
         return Redirect::to(url('admin/dish'))->with('message', 'Login success');
     } else {
         return Redirect::to(url('admin/login'))->with('message', 'Something Wrong :(');
     }
 }
Beispiel #16
0
 public function actionDetailCategory()
 {
     $request = Yii::app()->request;
     try {
         $cat_id = StringHelper::filterString($request->getQuery('cat_id'));
         $data = Posts::model()->getPostByCategoryId($cat_id);
         $this->render('categoryById', $data);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #17
0
 public function actionGetFeedbackByEvent()
 {
     $request = Yii::app()->request;
     try {
         $event_id = StringHelper::filterString($request->getQuery('event_id'));
         $data = Feedback::model()->getFeedbackByEvent($event_id);
         ResponseHelper::JsonReturnSuccess($data, 'Success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
 public function actionGetAnswersOfQuiz()
 {
     $request = Yii::app()->request;
     try {
         $quiz_id = StringHelper::filterString($request->getQuery('quiz_id'));
         $data = QuizAnswer::model()->findAllByAttributes(array('quiz_id' => $quiz_id));
         ResponseHelper::JsonReturnSuccess($data);
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage());
     }
 }
 public function actionSearch()
 {
     $no_res = "Không tìm thấy kết quả phù hợp";
     if (isset($_GET['query'])) {
         $query = StringHelper::filterString($_GET['query']);
         $subject_result = $this->searchSubject($query);
         $teacher_result = $this->searchTeacher($query);
         $doc_result = $this->searchDocument($query);
         $user_result = $this->searchUser($query);
         $this->render('Search', array('subject_result' => $subject_result, 'teacher_result' => $teacher_result, 'doc_result' => $doc_result, 'subject_count' => count($subject_result), 'teacher_count' => count($teacher_result), 'doc_count' => count($doc_result), 'user_result' => $user_result, 'user_count' => count($user_result), 'query' => $query));
     }
 }
 public function actionSendNotification()
 {
     $request = Yii::app()->request;
     try {
         $message = StringHelper::filterString($request->getPost('message'));
         $device_id = StringHelper::filterString($request->getPost('device_id'));
         $result = GcmHelper::sendNotification($device_id, $message);
         ResponseHelper::JsonReturnSuccess($result, 'success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #21
0
 public function actionGetBestGameQuizByPlayer()
 {
     $request = Yii::app()->request;
     try {
         $player_id = StringHelper::filterString($request->getQuery('player_id'));
         $quiz_id = StringHelper::filterString($request->getQuery('quiz_id'));
         $data = Game::model()->getBestScoreOfQuizByPlayer($player_id, $quiz_id);
         ResponseHelper::JsonReturnSuccess($data);
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage());
     }
 }
Beispiel #22
0
 public function actionSearchPostWeb()
 {
     $request = Yii::app()->request;
     try {
         $query = StringHelper::filterString($request->getQuery('query'));
         $data = Posts::model()->searchPost($query, Yii::app()->session['user_id']);
         //   var_dump($data); die;
         $this->render('index', $data);
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #23
0
 public function actionGetCommentByPost()
 {
     $request = Yii::app()->request;
     try {
         $post_id = StringHelper::filterString($request->getQuery('post_id'));
         $limit = StringHelper::filterString($request->getQuery('limit'));
         $offset = StringHelper::filterString($request->getQuery('offset'));
         $data = Comments::model()->getCommentByPost($post_id, $limit, $offset);
         ResponseHelper::JsonReturnSuccess($data, "Success");
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #24
0
 public function actionGetEventByUser()
 {
     $request = Yii::app()->request;
     try {
         $user_id = StringHelper::filterString($request->getQuery('user_id'));
         $limit = StringHelper::filterString($request->getQuery('limit'));
         $offset = StringHelper::filterString($request->getQuery('offset'));
         $data = Events::model()->getEventByUser($user_id, $limit, $offset);
         ResponseHelper::JsonReturnSuccess($data, 'Success');
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
 public function actionUser()
 {
     if (isset($_GET["token"])) {
         $token = StringHelper::filterString($_GET["token"]);
         $user_current_token = User::model()->find(array('select' => '*', 'condition' => 'user_token = :user_token', 'params' => array(':user_token' => $token)));
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "user_id = '" . $user_current_token->user_id . "'";
         $spjCriteria = new CDbCriteria();
         $spjCriteria->select = "*";
         $spjCriteria->condition = "doc_author = :doc_author";
         $spjCriteria->params = array(':doc_author' => $user_current_token->user_id);
         $spjCriteria->order = 'doc_id DESC';
         $count = Doc::model()->count($spjCriteria);
         $pages = new CPagination($count);
         $pages->pageSize = 12;
         $pages->applyLimit($spjCriteria);
         $user_doc_info = Doc::model()->findAll($spjCriteria);
         $user_current_id = User::model()->findByAttributes(array('user_id' => $user_current_token->user_id));
         $this->pageTitle = $user_current_token->user_real_name . " | Bluebee - UET";
         Yii::app()->clientScript->registerMetaTag($user_current_token->user_real_name . " | Bluebee - UET", null, null, array('property' => 'og:title'));
         Yii::app()->clientScript->registerMetaTag($user_current_token->user_avatar, null, null, array('property' => 'og:image'));
         if ($user_current_id) {
             $this->render('user', array('user_detail_info' => User::model()->findAll($spCriteria), 'user_doc_info' => $user_doc_info, 'pages' => $pages, 'doc_count' => $count));
         }
     }
     if (isset($_GET["id"])) {
         $id = StringHelper::filterString($_GET["id"]);
         $spCriteria = new CDbCriteria();
         $spCriteria->select = "*";
         $spCriteria->condition = "user_id = :id";
         $spCriteria->params = array(':id' => $id);
         $spjCriteria = new CDbCriteria();
         $spjCriteria->select = "*";
         $spjCriteria->condition = "doc_author = :doc_author";
         $spjCriteria->params = array(':doc_author' => $id);
         $spjCriteria->order = 'doc_id DESC';
         $count = Doc::model()->count($spjCriteria);
         $pages = new CPagination($count);
         $pages->pageSize = 12;
         $pages->applyLimit($spjCriteria);
         $user_doc_info = Doc::model()->findAll($spjCriteria);
         $user_detail_info = User::model()->findAll($spCriteria);
         foreach ($user_detail_info as $user) {
             $this->pageTitle = "Bluebee - UET | " . $user['user_real_name'];
             Yii::app()->clientScript->registerMetaTag("Bluebee - UET | " . $user['user_real_name'], null, null, array('property' => 'og:title'));
             Yii::app()->clientScript->registerMetaTag($user['user_avatar'], null, null, array('property' => 'og:image'));
         }
         $this->render('user', array('user_detail_info' => $user_detail_info, 'user_doc_info' => $user_doc_info, 'pages' => $pages, 'doc_count' => $count));
     }
 }
Beispiel #26
0
 public function actionGetEnglishEntries()
 {
     $request = Yii::app()->request;
     try {
         $begin = StringHelper::filterString($request->getQuery('beginWith'));
         $limit = StringHelper::filterString($request->getQuery('limit'));
         $offset = StringHelper::filterString($request->getQuery('offset'));
         $sql = "SELECT * FROM tbl_english_entries WHERE word LIKE '" . $begin . "%' LIMIT {$offset}, {$limit}";
         $data = Yii::app()->db->createCommand($sql)->queryAll();
         ResponseHelper::JsonReturnSuccess($data);
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage());
     }
 }
 public function actionDeleteRemind()
 {
     try {
         $request = Yii::app()->request;
         $remind_id = StringHelper::filterString($request->getPost('remind_id'));
         if (MedicineRemind::model()->deleteRemind($remind_id)) {
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnError('', 'Error !');
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function sendContact(Request $request)
 {
     $email = \StringHelper::filterString($request->input('email'));
     $name = \StringHelper::filterString($request->input('name'));
     $content = \StringHelper::filterString($request->input('comments'));
     if ($email != "" && $name != "" && $content != "") {
         $contact = new Contact();
         $contact->contact_name = $name;
         $contact->contact_email = $email;
         $contact->contact_content = $content;
         $contact->save();
     }
     return Redirect::back()->with('message', 'Success');
 }
 public function actionDeleteAllHistoryOfRemind()
 {
     try {
         $request = Yii::app()->request;
         $remind_id = StringHelper::filterString($request->getQuery('remin_id'));
         $result = HistoryRemind::model()->deleteAllHistoryOfARemind($remind_id);
         if ($result) {
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnError('', 'Error !');
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Beispiel #30
0
 public function actionProcessLogin()
 {
     $request = Yii::app()->request;
     if (isset($_POST)) {
         $email = StringHelper::filterString($request->getPost('email'));
         $password = StringHelper::filterString($request->getPost('password'));
         if ($email === '*****@*****.**' && $password === '123456') {
             Yii::app()->session['logged'] = 1;
             $this->redirect(Yii::app()->createUrl('documentary/index'));
         } else {
             Yii::app()->user->setFlash('error', 'Sai tên đăng nhập và mật khẩu');
             $this->redirect(Yii::app()->createUrl('user/login'));
         }
     }
 }