public function uploadPhoto($file, $userId, $uploadDir = null) { if (empty($userId)) { throw new InvalidArgumentException("\$userId is empty!"); } if (isset($this->config->maxPhotosCount) and $this->config->maxPhotosCount > 0) { $filter = new UserPhotosFilter(); $filter->setUserId($userId); $filter->setStatusNotEqual(UserPhotoManager::MODERATION_STATUS_DECLINED); $userPhotos = $this->getPhotos($filter); if (count($userPhotos) >= $this->config->maxPhotosCount) { throw new UserPhotosException("Maximum photos volume reached for this user.", static::EXCEPTION_MAX_COUNT_REACHED); } } if ($uploadDir !== null) { $imageUploaderConfig = new Config(); $imageUploaderConfig->uploadDir = $uploadDir; $image = ImageUploader::upload($file, null, $imageUploaderConfig); } else { $image = ImageUploader::upload($file); } $photo = new UserPhoto(); $photo->fileName = $image->fileName; $photo->userId = $userId; $photo->status = self::MODERATION_STATUS_NEW; return $this->addPhoto($photo); }
public function profileCover() { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('cover-image', 'img/user/covers/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/user/covers/original/{$imageName}"; $destination = "img/user/covers/edited/"; // Make the avatar version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); $_POST['cover-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } if ($this->totalErrors == 0) { $result = $this->model->changeCover(); // If the result was good if ($result) { // Redirect the user to login header('Location: index.php?page=profile'); $this->userSuccess = 'Successfully changed your info'; } else { $this->userFail = 'Info not updated'; } } }
public function add() { $this->set('title_for_layout', 'Add Book'); if ($this->request->isPost()) { if ($this->Author->find('first', array('conditions' => array('id_author' => $this->request->data['id_author'])))) { if (!$this->Book->find('first', array('conditions' => array('id_book' => $this->request->data['id_book'])))) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_BOOK, $this->params['form']['image'], $this->request->data('id_user'), $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $this->request->data('id_user') . '.' . $this->img_check_pattern['ext']; $this->User->save(array('id_user' => $this->request->data('id_user'), 'avatar' => $img)); } if ($this->Wrote->save(array('id_author' => $this->request->data('id_author'), 'id_book' => $this->request->data('id_book')))) { $remain = $this->request->data('price') * (100 - $this->request->data('remain')) / 100; if (!$this->request->data('adult')) { $adult = 0; } else { $adult = $this->request->data('adult'); } if (!$this->request->data('ebook')) { $adult = 0; } else { $adult = $this->request->data('ebook'); } if ($this->request->data('book')) { $adult = 1; } else { $adult = $this->request->data('book'); } if ($this->Book->save(array('id_book' => $this->request->data('id_book'), 'name' => $this->request->data('name'), 'description' => $this->request->data('description'), 'descriptionpro' => $this->request->data('descriptionpro'), 'description404' => $this->request->data('description404'), 'sale' => $this->request->data('remain'), 'price' => $this->request->data('price'), 'remain' => $remain, 'adult' => $this->request->data('adult'), 'ebook' => $this->request->data('ebook'), 'book' => $this->request->data('book')))) { $this->Session->setFlash(GlobalVar::get_html_success("Add Book succeed")); $this->redirect(ADMIN_ROOT_URL . 'adminbook/index'); exit; } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } } } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } }
/** * * @param array $file e.g. $_FILES['photo'] * @return ConversationAttachment */ public function addAttachment($file) { $systemFilename = self::findNewFileName($this->config->uploadDir); $attachsImgUpConfig = $this->config->imageUploaderConfig; $attachsImgUpConfig->uploadDir = $this->config->uploadDir; if (in_array($file["type"], $attachsImgUpConfig->acceptedMimeTypes->toArray())) { ImageUploader::upload($file, $systemFilename, $attachsImgUpConfig); } else { FileUploader::upload($file, $systemFilename, $this->config->uploadDir); } $qb = new QueryBuilder(); $qb->insert(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->values(array('system_filename' => $systemFilename, 'filename' => $file['name'], 'mime_type' => $file['type'])); $attachmentId = $this->query->exec($qb->getSQL())->getLastInsertId(); $filter = new ConversationAttachmentFilter(); $filter->setId($attachmentId); return $this->getAttachment($filter); }
public function processRecipe() { // If there is a file if (isset($_FILES['recipe-image']) && $_FILES['recipe-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('recipe-image', 'img/recipes/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/recipes/original/{$imageName}"; $destination = "img/recipes/cover/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); // Make thumbnail $destination = "img/recipes/thumbnail/"; $imageUploader->resize($fileLocation, 230, $destination, $imageName); $_POST['recipe-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $result = $this->model->updateRecipe(); // If the result was good if ($result) { // Redirect the user to login header('Location: index.php?page=recipe&recipeid=' . $_GET['recipeid']); $this->userSuccess = 'Successfully changed your info'; } else { $this->userFail = 'Info not updated'; } } }
public function uploadPhoto($file, $userId, $uploadDir = null) { if (empty($userId)) { throw new InvalidArgumentException("\$userId is empty!"); } if (isset($this->config->maxPhotosCount) and $this->config->maxPhotosCount > 0) { $filter = new UserPhotosFilter(); $filter->setUserId($userId); $userPhotos = $this->getPhotos($filter); if (count($userPhotos) >= $this->config->maxPhotosCount) { throw new UserPhotosException("Maximum photos volume reached for this user.", static::EXCEPTION_MAX_COUNT_REACHED); } } if ($uploadDir !== null) { $imageUploaderConfig = new Config(); $imageUploaderConfig->uploadDir = $uploadDir; $image = ImageUploader::upload($file, null, $imageUploaderConfig); } else { $image = ImageUploader::upload($file); } $this->query->exec("INSERT INTO `" . Tbl::get('TBL_USERS_PHOTOS') . "` \n\t\t\t\t\t\t\t\t\t\t\t\t\t(`user_id`, `filename`) \n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$userId}', '" . $image->fileName . "')"); $photoId = $this->query->getLastInsertId(); return $photoId; }
private function processAdditionalInfo() { // Validation if (strlen($_POST['first-name']) < 2) { $this->userFirstNameError = 'Needs to be at least 2 characters.'; $this->totalErrors++; } elseif (strlen($_POST['first-name']) > 20) { $this->userFirstNameError = 'Needs to be at most 20 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[a-zA-Z \\-]{2,20}$/', $_POST['first-name'])) { $this->userFirstNameError = 'Can only use characters of the alphabet, spaces and hyphens.'; $this->totalErrors++; } if (strlen($_POST['last-name']) < 2) { $this->userLastNameError = 'Needs to be at least 2 characters.'; $this->totalErrors++; } elseif (strlen($_POST['last-name']) > 20) { $this->userLastNameError = 'Needs to be at most 20 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[a-zA-Z \\-]{2,20}$/', $_POST['last-name'])) { $this->userLastNameError = 'Can only use characters of the alphabet, spaces and hyphens.'; $this->totalErrors++; } if (strlen($_POST['last-name']) > 2000) { $this->userBioError = 'Needs to be at most 2000 characters.'; $this->totalErrors++; } // Attemp to upload the image if ($this->totalErrors == 0 && isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] != '') { //require image uploader require 'vendor/ImageUploader.php'; // Create an instance $imageUploader = new ImageUploader(); // Attemp to upload the file $result = $imageUploader->upload('profile-image', 'img/profile-images/original/'); // If the upload was a success if ($result) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/profile-images/original/{$imageName}"; $fileDestination = "img/profile-images/avatar/"; // Make the avatar version $imageUploader->resize($fileLocation, 320, $fileDestination, $imageName); // Make icons $fileDestination = "img/profile-images/icon/"; $imageUploader->resize($fileLocation, 32, $fileDestination, $imageName); $_POST['newUserImage'] = $imageName; } else { // Something went wrong $this->userImageError = $imageUploader->errorMessage; $this->totalErrors++; } } elseif (isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] == '') { $_POST['newUserImage'] = 'default.png'; } if ($this->totalErrors == 0) { $result = $this->model->additionalInfo(); //If the result was good if ($result) { $this->userSuccess = 'Account has been updated'; } else { $this->userFail = 'You have entered the same information'; } } }
public function processRecipe() { $recipeTitle = trim($_POST['recipe-title']); $recipeDirections = trim($_POST['recipe-directions']); $recipeTime = trim($_POST['cook-time']); $recipeServes = trim($_POST['serves']); $recipeVideo = trim($_POST['recipe-video']); $this->recipeTitle = $recipeTitle; $this->recipeDirections = $recipeDirections; $this->recipeTime = $recipeTime; $this->recipeVideo = $recipeVideo; if (strlen($recipeTitle) > 40) { $this->recipeTitleError = 'Recipe name is too long, 45 characters max.'; $this->totalErrors++; } elseif (strlen($recipeTitle) == 0) { $this->recipeTitleError = 'Recipe title is required.'; $this->totalErrors++; } if (strlen($recipeDirections) > 2000) { $this->recipeDirectionsError = 'Recipe directions is too long please shorten, 2000 characters max.'; $this->totalErrors++; } elseif (strlen($recipeDirections) == 0) { $this->recipeDirectionsError = 'Recipe directions is required.'; $this->totalErrors++; } if (strlen($recipeTime) > 3) { $this->recipeTimeError = 'Please enter up to 3 digits.'; $this->totalErrors++; } else { if ($recipeTime == '') { $this->recipeTimeError = 'Please enter a time.'; $this->totalErrors++; } elseif (!preg_match('/^[0-9]{1,3}$/', $recipeTime)) { $this->recipeTimeError = 'Use only numbers. With a maximum of 3 digits.'; $this->totalErrors++; } } if ($_FILES['cover-image']['name'] == '') { $this->userImageError = 'You must upload an image with your recipe.'; $this->totalErrors++; } else { // If there is a file if (isset($_FILES['cover-image']) && $_FILES['cover-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('cover-image', 'img/recipes/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/recipes/original/{$imageName}"; $destination = "img/recipes/cover/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); // Make thumbnail $destination = "img/recipes/thumbnail/"; $imageUploader->resize($fileLocation, 230, $destination, $imageName); $_POST['cover-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } } if ($this->totalErrors == 0) { $this->model->addRecipe(); } }
public function edit($id = null) { $this->set('title_for_layout', ' Edit Author'); $success_message = ''; if ($this->request->isPost()) { if (isset($this->data['cancel'])) { $this->redirect(ADMIN_ROOT_URL . 'adminauthor/index'); return; } if (isset($this->data['editauthor'])) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_AUTHOR, $this->params['form']['image'], $id, $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $id . '.' . $this->img_check_pattern['ext']; $this->Author->save(array('id_author' => $id, 'img' => $img)); } } $this->Author->save(array('id_author' => $id, 'name' => $this->request->data('name'), 'biography' => $this->request->data('biography'))); $success_message = 'Update succeed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } } $authorupdate = $this->Author->find('first', array('conditions' => array('id_author' => $id))); $this->set('Author', $authorupdate); }
$errors[] = "File size is Big"; } if (!$image->checkHeight()) { //check image height $errors[] = "File height is Big"; } if (!$image->checkWidth()) { //check image width $errors[] = "File width is Big"; } if (!$image->checkExt()) { //check image extension $errors[] = "File ext is not supported"; } if (!isset($errors)) { $image->setImageName($userid); //set image name $image->deleteExisting(); $image->upload(); echo "<h2>Avatar Changed Successfully</h2>"; } else { echo "<h2>You must correct the errors to proceed</h2><br>"; print_r($errors); } } ?> <form enctype="multipart/form-data" action="" method="POST"> <input name="input_field_name" type="file" /> <input type="submit" name="submit" value="Change Avatar" /> </form>
private function processAddStaff() { $this->firstName = trim($_POST['first-name']); $this->lastName = trim($_POST['last-name']); $this->jobTitle = trim($_POST['job-title']); $this->bio = trim($_POST['bio']); // Validate the form to make sure the user has provided all the appropriate fields if (strlen($this->firstName) < 2) { $this->firstNameError = 'First name needs to be at least 2 characters.'; } elseif (strlen($this->firstName > 20)) { $this->firstNameError = 'First name is limited to 20 characters.'; } elseif (!preg_match('/^[\\w.\\-\\s]{2,20}$/', $this->firstName)) { $this->firstNameError = 'First Name is limited to letters, hyphens and fullstops.'; } if (strlen($this->lastName) < 2) { $this->lastNameError = 'Last name needs to be at least 2 characters.'; } elseif (strlen($this->lastName > 20)) { $this->lastNameError = 'Last name is limited to 20 characters.'; } elseif (!preg_match('/^[\\w.\\-\\s]{2,20}$/', $this->lastName)) { $this->lastNameError = 'Last Name can only include letters, hyphens & fullstops.'; } if (strlen($this->jobTitle == '')) { $this->jobTitleError = 'Job Title is required'; } elseif (strlen($this->jobTitle) > 30) { $this->jobTitleError = 'Job title is limited to 30 characters'; } elseif (!preg_match('/^[\\w\\- \\.]{2,30}$/', $this->jobTitle)) { $this->jobTitleError = 'Job Title can only include letters, hyphens & fullstops'; } if (strlen($this->bio > 200)) { $this->bioError = 'Bio is limited to 200 characters. You have ' . (strlen($this->bio) - 200); } elseif (!preg_match('/^[\\w\\s\\-\\.]{2,200}$/', $this->bio)) { $this->bioError = 'Bio can only include letters, hyphens & fullstops'; } // Make life easier $file = $_FILES['profile-image']; $imageName = $file['name']; // if the user has not provided an image // first brackets['source']second brackets['What field we want'] if ($imageName == '') { $this->profileImageError = 'Required'; } elseif ($this->firstNameError == '' && $this->lastNameError == '' && $this->jobTitleError == '' && $this->bioError == '') { // require the image upload class require 'vendor/ImageUploader.php'; // Instantiate the class $imageUploader = new ImageUploader(); // Mkae new filename based oon the staff members name $fileName = $this->firstName . '-' . $this->lastName; // Upload the image and make sure all went well $result = $imageUploader->upload('profile-image', 'img/staff/original/', $fileName); // If something went wrong if (!$result) { $this->profileImageError = $imageUploader->errorMessage; } else { $newImage = $imageUploader->getImageName(); $imageUploader->resizeImage('img/staff/original/' . $newImage, 320, 'img/staff/thumbnails/', $newImage); } // If there are no errors then insert a new staff member if ($this->profileImageError == '') { $result = $this->model->addNewStaff($newImage); // if success if ($result) { $this->staffSuccessMessage = 'Success'; } else { $this->staffErrorMessage = 'Something went wrong in the Database'; } } } }
public function processChangeInfo() { $firstname = $_POST['first-name']; $lastname = $_POST['last-name']; $bio = $_POST['bio']; if (strlen($firstname) > 40) { $this->firstnameError = 'First name is too long please abbreviate or use a nickname. 40 Character max.'; $this->totalErrors++; } if (strlen($lastname) > 40) { $this->lastnameError = 'Last name is too long please abbreviate or use a nickname. 40 Character max.'; $this->totalErrors++; } if (strlen($bio) > 400) { $this->bioError = 'Your description is too long please abbreviate. 400 Character max.'; $this->totalErrors++; } if (isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('profile-image', 'img/user/avatar/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/user/avatar/original/{$imageName}"; $destination = "img/user/avatar/edited/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 110, $destination, $imageName); // Make thumbnail $destination = "img/user/avatar/icon/"; $imageUploader->resize($fileLocation, 34, $destination, $imageName); $_POST['profile-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $this->model->updateInfo(); $this->detailsSuccess = 'Your details have been updated successfully.'; } }
<?php require "../src/ImageUploader.php"; try { $imageUploader = new ImageUploader("../upload", "random_salt"); // An optional custom callback to process the uploaded image using GD library $img_filter = IMG_FILTER_GRAYSCALE; $custom_callback = function (&$image) use($img_filter) { imagefilter($image, $img_filter); }; $res = $imageUploader->upload($_FILES["my_image"], "my_id", $custom_callback); var_dump($res); } catch (Exception $e) { var_dump($e); }
private function processUpdateFile() { $fileNameUpdate = trim($_POST['file-name']); $fileTypeUpdate = $_POST['file-type-upload-dropdown']; $fileTagUpdate = $_POST['tag-checkbox']; $fileDescriptionUpdate = trim($_POST['file-description']); $this->fileNameUpdate = $fileNameUpdate; $this->fileTypeUpdate = $fileTypeUpdate; $this->fileTagUpdate = $fileTagUpdate; $this->fileDescriptionUpdate = $fileDescriptionUpdate; //Validation if ($fileNameUpdate == '') { $this->fileNameUpdateError = 'Required'; $this->totalErrors++; } elseif (strlen($fileNameUpdate) > 30 || strlen($fileNameUpdate) < 3) { $this->fileNameUpdateError = 'Job Title must be between 3 and 30 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[\\w0-9_\\-. ]{3,20}$/', $fileNameUpdate)) { $this->fileNameUpdateError = 'Use only letters, numbers, hyphens underscore and periods.'; $this->totalErrors++; } $FileTypeUpdate = $_POST['file-type-upload-dropdown']; if (!is_numeric($FileTypeUpdate)) { $this->fileTypeUpdateError = 'Something Wrong'; $this->totalErrors++; } if ($fileDescriptionUpdate == '') { $this->fileDescriptionUpdateError = 'Required'; $this->totalErrors++; } elseif (strlen($fileDescriptionUpdate) > 2000 || strlen($fileDescriptionUpdate) < 3) { $this->fileDescriptionUpdateError = 'Job Title must be between 3 and 2000 characters. you have gone over by' . (strlen($fileDescription) - 2000); $this->totalErrors++; } elseif (!preg_match('/^[\\w0-9_\\-. ]{3,2000}$/', $fileDescriptionUpdate)) { $this->fileDescriptionUpdateError = 'Use only letters, numbers, hyphens underscore and periods.'; $this->totalErrors++; } // Only if the user has seleted some checkboxes if (isset($fileTagUpdate)) { // Loop through each checkbox and make sure they are a number foreach ($fileTagUpdate as $tagUpdate) { // If it is not a number if (!is_numeric($uploadTag)) { $this->totalErrors++; $this->tagUpdateError = 'Something wrong with checkboxes'; } } } //attempt to upload the image if ($this->totalErrors == 0 && isset($_FILES['file-image']) && $_FILES['file-image']['name'] != '') { //Require the image uploader require_once 'vendor/ImageUploader.php'; //create instance of the image uploader $imageUploader = new ImageUploader(); //Attempt to upload the image $result = $imageUploader->upload('file-image', 'img/file-images/original/'); //if upload was success if ($result) { //get the file name $imageName = $imageUploader->getImageName(); //Prepare the variables $fileLocation = "img/file-images/original/{$imageName}"; //Prepare the preview version $previewDestination = "img/file-images/preview/"; $imageUploader->resize($fileLocation, 400, $previewDestination, $imageName); //Make the thumbnail version $thumbnailDestination = "img/file-images/thumbnail/"; $imageUploader->resize($fileLocation, 200, $thumbnailDestination, $imageName); $_POST['newFileImage'] = $imageName; } else { //Something went wrong $this->totalErrors++; $this->fileImageUpdateError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $result = $this->model->updateFile(); //if result was good if ($result) { $this->fileUpdateSuccess = 'Successfully updated your file'; } else { $this->fileUpdateFail = 'File not updated'; } } }
public function add() { $this->set('title_for_layout', ' Add User'); $success_message = ''; if ($this->request->isPost()) { if (isset($this->data['cancel'])) { $this->redirect(ADMIN_ROOT_URL . 'adminusers/index'); return; } if (isset($this->data['adduser'])) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_USER, $this->params['form']['image'], $this->request->data('id_user'), $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $this->request->data('id_user') . '.' . $this->img_check_pattern['ext']; $this->User->save(array('id_user' => $this->request->data('id_user'), 'avatar' => $img)); } } if ($this->User->save(array('id_user' => $this->request->data('id_user'), 'username' => $this->request->data('username'), 'password' => sha1($this->request->data('password')), 'birth' => $this->request->data('birth'), 'mail' => $this->request->data('mail'), 'sex' => $this->request->data('gender'), 'mail' => $this->request->data('mail'), 'facebook' => $this->request->data('facebook'), 'balance' => $this->request->data('balance'), 'created' => $this->request->data('created'), 'nearest' => $this->request->data('nearest')))) { $success_message = 'Add succeed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } else { $success_message = 'Add failed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } } } }