Example #1
0
 public function launchAction()
 {
     if (!$this->session->has("current_user")) {
         $this->response->redirect("login/login?_redirecturl=" . urlencode('actvt/launch'));
         $this->view->disable();
         return;
     }
     if ($this->request->isPost()) {
         $uploads_dir = getcwd() . "\\user_images\\actvt";
         $img_name = '';
         if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
             $o_name = $_FILES["img"]["name"];
             $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
             $name = $uploads_dir . "\\" . $name_without_path;
             $img_name = '/user_images/actvt/' . $name_without_path;
             move_uploaded_file($_FILES["img"]["tmp_name"], $name);
             $image = new \Phalcon\Image\Adapter\Imagick($name);
             $width = $image->getWidth();
             $height = $image->getHeight();
             $final_width = 640;
             $final_height = 0;
             if ($width > $final_width) {
                 $final_height = $height * ($final_width / $width);
             } else {
                 $final_width = $width;
                 $final_height = $height;
             }
             $image->resize($final_width, $final_height);
             if ($image->save()) {
             }
         } else {
             return false;
         }
         $name = $_POST["name"];
         $place = $_POST["place"];
         $start_time = $_POST["start_time"];
         $end_time = $_POST["end_time"];
         $expected_people_count = $_POST["expected_people_count"];
         $round_money = $_POST["round_money"];
         $remark = $_POST["remark"];
         $pic_name = $img_name;
         $user = unserialize($this->session->get("current_user"));
         $common = new model\common();
         $sql = "call p_insert_single_actvt(?,?,?,?,?,?,?,?,?,?)";
         $query = $common->getReadConnection()->query($sql, array($name, $place, $start_time, $end_time, $expected_people_count, $round_money, $remark, $pic_name, $user->id, $user->name));
         $result = $query->fetchAll();
         $this->response->redirect("actvt/single/" . $result[0]["id"]);
         $this->view->disable();
         return;
     } else {
         if ($this->settings["is_mobile"] == "true") {
             $this->view->pick("actvt/mb-launch");
         }
     }
 }
Example #2
0
 public function commentImgAction()
 {
     if (!$this->session->has("current_user")) {
         $this->response->redirect("login/login");
         $this->view->disable();
         return;
     }
     $uploads_dir = getcwd() . "\\user_images\\common";
     $img_name = '';
     if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
         $o_name = $_FILES["img"]["name"];
         $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
         $name = $uploads_dir . "\\" . $name_without_path;
         $img_name = '/user_images/common/' . $name_without_path;
         move_uploaded_file($_FILES["img"]["tmp_name"], $name);
         $image = new \Phalcon\Image\Adapter\Imagick($name);
         $width = $image->getWidth();
         $height = $image->getHeight();
         $final_width = 640;
         $final_height = 0;
         if ($width > $final_width) {
             $final_height = $height * ($final_width / $width);
         } else {
             $final_width = $width;
             $final_height = $height;
         }
         $image->resize($final_width, $final_height);
         if ($image->save()) {
         }
     }
     $page_object_id = $_POST["page_object_id"];
     $page_object_name = $_POST["page_object_name"];
     $body = htmlspecialchars($_POST["body"]);
     $user = unserialize($this->session->get("current_user"));
     $user_id = $user->id;
     $common = new model\common();
     $sql = "call p_comment_" . $page_object_name . '(?,?,?,?)';
     $query = $common->getReadConnection()->query($sql, array($body, $img_name, $user_id, $page_object_id));
     return $this->response->redirect($_SERVER["HTTP_REFERER"]);
 }
Example #3
0
 public function mealAction()
 {
     if (!$this->session->has("current_user")) {
         $this->response->redirect("login/login?_redirecturl=" . urlencode('dofavor/meal'));
         $this->view->disable();
         return;
     }
     if ($this->request->isPost()) {
         $seller = $_POST["seller"];
         $qtt = $_POST["qtt"];
         $price = 0;
         $exchange_rate = 0;
         $remark = $_POST["remark"];
         $email = $_POST["email"];
         $phone = $_POST["phone"];
         $hotel_info = $_POST["hotel_info"];
         $total_fee_jpy = 0;
         $total_fee_rmb = 0;
         $uploads_dir = getcwd() . "\\user_images\\dofavor";
         $img_name = '';
         if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
             $o_name = $_FILES["img"]["name"];
             $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
             $name = $uploads_dir . "\\" . $name_without_path;
             $img_name = '/user_images/dofavor/' . $name_without_path;
             move_uploaded_file($_FILES["img"]["tmp_name"], $name);
             $image = new \Phalcon\Image\Adapter\Imagick($name);
             $width = $image->getWidth();
             $height = $image->getHeight();
             $final_width = 640;
             $final_height = 0;
             if ($width > $final_width) {
                 $final_height = $height * ($final_width / $width);
             } else {
                 $final_width = $width;
                 $final_height = $height;
             }
             $image->resize($final_width, $final_height);
             if ($image->save()) {
             }
         }
         $deadline = $_POST["deadline"];
         $user = unserialize($this->session->get("current_user"));
         $common = new model\common();
         $sql = "call p_insert_single_book_meal(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
         $query = $common->getReadConnection()->query($sql, array($seller, $qtt, $price, $deadline, $remark, $total_fee_jpy, $total_fee_rmb, $exchange_rate, $email, $phone, $hotel_info, $img_name, $user->id, $user->name));
         $result = $query->fetchAll();
         $this->response->redirect("dofavor/singleMeal/" . $result[0]["id"]);
         $this->view->disable();
         return;
     } else {
         if ($this->settings["is_mobile"] == "true") {
             $user_detail = model\userDetail::findFirstByUser_id(unserialize($this->session->get("current_user"))->id);
             if ($user_detail) {
                 $this->view->user_detail = $user_detail;
             }
             $this->view->pick("dofavor/mb-meal");
         }
     }
 }
Example #4
0
 public function registryAction()
 {
     if ($this->request->isPost() == true) {
         if (!$this->security->checkToken()) {
             $this->view->errorMsg = "检查到跨域攻击";
             return;
         }
         $headimg_name = "default.png";
         if ($this->validatePost()) {
             //验证相关信息
             $email = $_POST["email"];
             $user_name = $_POST["name"];
             $password = $_POST["password"];
             $img_type = $_POST["img_type"];
             $db_user = model\userOriginal::findFirstByEmail($email);
             if ($db_user) {
                 $this->view->errorMsg = "邮箱已注册<br/>";
                 return;
             }
             $uploads_dir = getcwd() . "\\user_images\\head_pic";
             $img_name = '';
             if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
                 $o_name = $_FILES["img"]["name"];
                 $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
                 $name = $uploads_dir . "\\" . $name_without_path;
                 $img_name = '/user_images/head_pic/' . $name_without_path;
                 move_uploaded_file($_FILES["img"]["tmp_name"], $name);
                 $image = new \Phalcon\Image\Adapter\Imagick($name);
                 $width = $image->getWidth();
                 $height = $image->getHeight();
                 $crop_width = 0;
                 $crop_height = 0;
                 $offset_x = 0;
                 $offset_y = 0;
                 if ($width > $height) {
                     $offset_x = ($width - $height) / 2;
                     $offset_y = 0;
                     $crop_width = $height;
                     $crop_height = $height;
                 } else {
                     $offset_x = 0;
                     $offset_y = ($height - $width) / 2;
                     $crop_width = $width;
                     $crop_height = $width;
                 }
                 $image->crop($crop_width, $crop_height, $offset_x, $offset_y);
                 $image->resize(200, 200);
                 if ($image->save()) {
                 }
             }
             $password = password_hash($password, PASSWORD_DEFAULT);
             $common = new model\common();
             $sql = "call p_insert_user_original(?,?,?,?)";
             $result = $common->getReadConnection()->query($sql, array($user_name, $img_name, $email, $password))->fetchAll();
             if (count($result) == 1) {
                 $user = (object) $result[0];
                 $this->session->set("current_user", serialize($user));
                 session_write_close();
                 $this->response->redirect("index/index");
                 $this->view->disable();
             } else {
                 $this->view->errorMsg = "服务器繁忙,请稍候再试<br/>";
             }
             return;
         } else {
             return;
         }
     }
     if ($this->settings["is_mobile"] == "true") {
         $this->view->pick("login/mb-registry");
     }
 }
Example #5
0
 public function addCommentAction()
 {
     $question_id = $_POST["question_id"];
     $body = $_POST["body"];
     $uploads_dir = getcwd() . "\\user_images\\common";
     $img_name = '';
     if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
         $o_name = $_FILES["img"]["name"];
         $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
         $name = $uploads_dir . "\\" . $name_without_path;
         $img_name = '/user_images/question/' . $name_without_path;
         move_uploaded_file($_FILES["img"]["tmp_name"], $name);
         $image = new \Phalcon\Image\Adapter\Imagick($name);
         $width = $image->getWidth();
         $height = $image->getHeight();
         $final_width = 640;
         $final_height = 0;
         if ($width > $final_width) {
             $final_height = $height * ($final_width / $width);
         } else {
             $final_width = $width;
             $final_height = $height;
         }
         $image->resize($final_width, $final_height);
         if ($image->save()) {
         }
     }
     $page_object_id = $question_id;
     $page_object_name = 'question';
     $body = htmlspecialchars($body);
     $user_id = $_POST["user_id"];
     $common = new model\common();
     $sql = "call p_comment_" . $page_object_name . '(?,?,?,?)';
     $query = $common->getReadConnection()->query($sql, array($body, $img_name, $user_id, $page_object_id));
     $this->flag(TRUE, '√');
 }
Example #6
0
 public function askAction()
 {
     if (!$this->session->has("current_user")) {
         $this->response->redirect("login/login?_redirecturl=" . urlencode('question/ask'));
         $this->view->disable();
         return;
     }
     if ($this->request->isPost()) {
         if (!$this->security->checkToken()) {
             return;
         }
         $uploads_dir = getcwd() . "\\user_images\\question";
         $img_name = '';
         if (isset($_FILES["img"]) && $_FILES["img"]["error"] == UPLOAD_ERR_OK) {
             $o_name = $_FILES["img"]["name"];
             $name_without_path = uniqid() . substr($o_name, strrpos($o_name, '.') - 1);
             $name = $uploads_dir . "\\" . $name_without_path;
             $img_name = '/user_images/question/' . $name_without_path;
             move_uploaded_file($_FILES["img"]["tmp_name"], $name);
             $image = new \Phalcon\Image\Adapter\Imagick($name);
             $width = $image->getWidth();
             $height = $image->getHeight();
             $final_width = 640;
             $final_height = 0;
             if ($width > $final_width) {
                 $final_height = $height * ($final_width / $width);
             } else {
                 $final_width = $width;
                 $final_height = $height;
             }
             $image->resize($final_width, $final_height);
             if ($image->save()) {
             }
         }
         $body = htmlspecialchars($_POST["body"]);
         $other_info = htmlspecialchars($_POST["other_info"]);
         $is_secret = $_POST["is_secret"];
         $tag_names = "";
         foreach ($_POST as $key => $value) {
             if (strpos($key, "t") === 0) {
                 $tag_names = $tag_names . $value . ",";
             }
         }
         $current_user = unserialize($this->session->get("current_user"));
         $common = new model\common();
         $sql = "call p_ask(?,?,?,?,?,?,?)";
         $result = $common->getReadConnection()->query($sql, array($body, $other_info, $tag_names, $img_name, $current_user->id, $current_user->name, $is_secret))->fetchAll();
         return $this->response->redirect("question/single/" . $result[0][0]);
         //			if (isset($_POST["img"])) {
         //				$data =base64_decode($_POST["data"]);
         //				$img_name=uniqid().$_POST["i"].".png";
         //				if (!$this->session->has("img_names")) {
         //					$this->session->set("img_names",$img_name);
         //				}else{
         //					$this->session->set("img_names",$this->session->get("img_names").",".$img_name);
         //				}
         //				file_put_contents(getcwd()."\\user_images\\question\\".$img_name, $data);
         //			}else{
         //				if(!$this->security->checkToken()){
         //				   return;
         //				}
         //				$body=htmlspecialchars($_POST["body"]);
         //				$other_info=htmlspecialchars($_POST["other_info"]);
         //				$is_secret=$_POST["is_secret"];
         //				$tag_names="";
         //				$pics="";
         //				foreach ($_POST as $key => $value) {
         //					if(strpos($key, "t")===0){
         //						$tag_names=$tag_names.$value.",";
         //					}
         //				}
         //				if ($this->session->has("img_names")) {
         //					$pics=$this->session->get("img_names");
         //					$this->session->remove("img_names");
         //				}else{
         //					$pics="";
         //				}
         //				$current_user=unserialize($this->session->get("current_user"));
         //				$common=new model\common();
         //				$sql="call p_ask(?,?,?,?,?,?,?)";
         //				$result=$common->getReadConnection()->query($sql,array($body,$other_info,$tag_names,$pics,$current_user->id,$current_user->name))->fetchAll();
         //
         //				$this->response->redirect("question/single/".$result[0][0]);
         //			}
         //			$this->view->disable();
         //			return;
     } else {
         if ($this->settings["is_mobile"] == "true") {
             $this->view->pick("question/mb-ask");
         }
     }
 }
Example #7
0
 /**
  * @medium
  */
 public function testImagick()
 {
     if (!class_exists('imagick')) {
         $this->markTestSkipped("Skipped");
         return;
     }
     @unlink('unit-tests/assets/production/imagick-new.jpg');
     @unlink('unit-tests/assets/production/imagick-resize.jpg');
     @unlink('unit-tests/assets/production/imagick-liquidRescale.jpg');
     @unlink('unit-tests/assets/production/imagick-crop.jpg');
     @unlink('unit-tests/assets/production/imagick-rotate.jpg');
     @unlink('unit-tests/assets/production/imagick-flip.jpg');
     @unlink('unit-tests/assets/production/imagick-sharpen.jpg');
     @unlink('unit-tests/assets/production/imagick-reflection.jpg');
     @unlink('unit-tests/assets/production/imagick-watermark.jpg');
     @unlink('unit-tests/assets/production/imagick-mask.jpg');
     @unlink('unit-tests/assets/production/imagick-background.jpg');
     // Create new image
     $image = new Phalcon\Image\Adapter\Imagick('unit-tests/assets/production/imagick-new.jpg', 100, 100);
     $image->setResourceLimit(6, 1);
     $image->save();
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-new.jpg'));
     $image = new Phalcon\Image\Adapter\Imagick('unit-tests/assets/phalconphp.jpg');
     $image->setResourceLimit(6, 1);
     // Resize to 200 pixels on the shortest side
     $image->resize(200, 200)->save('unit-tests/assets/production/imagick-resize.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-resize.jpg'));
     $this->assertTrue($image->getWidth() <= 200);
     $this->assertTrue($image->getHeight() <= 200);
     // Resize to 200x200 pixels, keeping aspect ratio
     //$image->resize(200, 200, Phalcon\Image::INVERSE);
     // Resize to 500 pixel width, keeping aspect ratio
     //$image->resize(500, NULL);
     // Resize to 500 pixel height, keeping aspect ratio
     //$image->resize(NULL, 500);
     // Resize to 200x500 pixels, ignoring aspect ratio
     //$image->resize(200, 500, Phalcon\Image::NONE);
     // The images using liquid rescaling resize to 200x200
     $image->liquidRescale(200, 200)->save('unit-tests/assets/production/imagick-liquidRescale.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-liquidRescale.jpg'));
     $this->assertTrue($image->getWidth() == 200);
     $this->assertTrue($image->getHeight() == 200);
     // The images using liquid rescaling resize to 500x500
     //$image->liquidRescale(500, 500, 3, 25);
     // Crop the image to 200x200 pixels, from the center
     $image = new Phalcon\Image\Adapter\Imagick('unit-tests/assets/phalconphp.jpg');
     $image->setResourceLimit(6, 1);
     $image->crop(200, 200)->save('unit-tests/assets/production/imagick-crop.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-crop.jpg'));
     $this->assertTrue($image->getWidth() == 200);
     $this->assertTrue($image->getHeight() == 200);
     // Rotate 45 degrees clockwise
     $image->rotate(45)->save('unit-tests/assets/production/imagick-rotate.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-rotate.jpg'));
     $this->assertTrue($image->getWidth() > 200);
     $this->assertTrue($image->getHeight() > 200);
     // Rotate 90% counter-clockwise
     //$image->rotate(-90);
     // Flip the image from top to bottom
     $image->flip(Phalcon\Image::HORIZONTAL)->save('unit-tests/assets/production/imagick-flip.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-flip.jpg'));
     // Flip the image from left to right
     //$image->flip(Phalcon\Image::VERTICAL);
     // Sharpen the image by 20%
     $image->sharpen(20)->save('unit-tests/assets/production/imagick-sharpen.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-sharpen.jpg'));
     // Create a 50 pixel reflection that fades from 0-100% opacity
     $image->reflection(50)->save('unit-tests/assets/production/imagick-reflection.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-reflection.jpg'));
     // Create a 50 pixel reflection that fades from 100-0% opacity
     //$image->reflection(50, 100, TRUE)->save('reflection.jpg');
     // Create a 50 pixel reflection that fades from 0-60% opacity
     //$image->reflection(50, 60, TRUE);
     // Add a watermark to the bottom right of the image
     $mark = new Phalcon\Image\Adapter\Imagick('unit-tests/assets/logo.png');
     $image->setResourceLimit(6, 1);
     $image->watermark($mark, TRUE, TRUE)->save('unit-tests/assets/production/imagick-watermark.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-watermark.jpg'));
     // Mask image
     $mask = new Phalcon\Image\Adapter\Imagick('unit-tests/assets/logo.png');
     $image->setResourceLimit(6, 1);
     $image->mask($mask)->save('unit-tests/assets/production/imagick-mask.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-mask.jpg'));
     //		// Add a text to the bottom right of the image
     //		$image->text('hello', TRUE, TRUE);
     // Set font size
     //$image->text('hello', TRUE, TRUE, NULL, NULL, 12);
     // Set font
     //$image->text('hello', TRUE, TRUE, NULL, NULL, 12, /usr/share/fonts/truetype/wqy/wqy-microhei.ttc);
     // Add a text to the center of the image
     //$image->text('hello');
     // Make the image background black
     $mark->background('#000')->save('unit-tests/assets/production/imagick-background.jpg');
     $this->assertTrue(file_exists('unit-tests/assets/production/imagick-background.jpg'));
     // Make the image background black with 50% opacity
     //$image->background('#000', 50);
     // Save the image as a PNG
     //$image->save('saved/gd.png');
     // Overwrite the original image
     //$image->save();
     // Render the image at 50% quality
     //$data = $image->render(NULL, 50);
     // Render the image as a PNG
     //$data = $image->render('png');
 }