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 !'); } }
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 formatPrice($price) { $price = round($price, 2); if ($this->currencyWrittenAfter) { $formattedPrice = sprintf('%s %s', $price, $this->currency); } else { $formattedPrice = sprintf('%s %s', $this->currency, $price); } return $this->stringHelper->makeSpacesNonBreakable($formattedPrice); }
/** * Make handle from source name. * * @param $name * * @return string */ private function _makeHandle($name, $sourceId) { // Remove HTML tags $handle = preg_replace('/<(.*?)>/', '', $name); $handle = preg_replace('/<[\'"‘’“”\\[\\]\\(\\)\\{\\}:]>/', '', $handle); $handle = StringHelper::toLowerCase($handle); $handle = StringHelper::asciiString($handle); $handle = preg_replace('/^[^a-z]+/', '', $handle); // In case it was an all non-ASCII handle, have a default. if (!$handle) { $handle = 'source' . $sourceId; } $handleParts = preg_split('/[^a-z0-9]+/', $handle); $handle = ''; foreach ($handleParts as $index => &$part) { if ($index) { $part = ucfirst($part); } $handle .= $part; } $appendix = ''; while (true) { $taken = craft()->db->createCommand()->select('handle')->from('assetsources')->where('handle = :handle', array(':handle' => $handle . $appendix))->queryScalar(); if ($taken) { $appendix = (int) $appendix + 1; } else { break; } } return $handle . $appendix; }
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()); } }
public static function generateHandle($sourceVal) { // Remove HTML tags $handle = preg_replace('/<(.*?)>/', '', $sourceVal); // Remove inner-word punctuation $handle = preg_replace('/[\'"‘’“”\\[\\]\\(\\)\\{\\}:]/', '', $handle); // Make it lowercase $handle = strtolower($handle); // Convert extended ASCII characters to basic ASCII $handle = StringHelper::asciiString($handle); // Handle must start with a letter $handle = preg_replace('/^[^a-z]+/', '', $handle); // Get the "words" $words = array_filter(preg_split('/[^a-z0-9]+/', $handle)); $handle = ''; // Make it camelCase for ($i = 0; $i < count($words); $i++) { if ($i == 0) { $handle .= $words[$i]; } else { $handle .= strtoupper($words[$i][0]) . substr($words[$i], 1); } } return $handle; }
function dispatch() { global $ModuleDir, $ClassDir, $template, $DefaultModule, $DefaultPage, $timer; $this->path_info = ltrim(getenv("PATH_INFO"), "/"); $this->setDefualtModule($DefaultModule); $this->setDefualtPage($DefaultPage); $module_name = $this->getModuleName() ? $this->getModuleName() : $this->getDefualtModule(); $page_name = $this->getPageName() ? $this->getPageName() : $this->getDefualtPage(); $action_name = $this->getActionName() ? $this->getActionName() : $this->default_action; include_once $ClassDir . "StringHelper.class.php"; $page_class_name = StringHelper::CamelCaseFromUnderscore($page_name); $include_file = $ModuleDir . $module_name . DIRECTORY_SEPARATOR . $page_class_name . ".class.php"; if (file_exists($include_file)) { include_once $include_file; $TempObj = new $page_class_name(); $Action = "execute" . ucfirst($action_name); $TempObj->{$Action}(); } // printf("module %s/ page %s/ action %s/ ",$module_name,$page_name,$action_name); // $template->setFile(array ( // "TAB" => "tab.html", // )); // $template->setBlock("TAB", "tab"); $this->parseTemplateLang(true); $template->parse("OUT", array("LAOUT")); $template->p("OUT"); if (defined('APF_DEBUG') && APF_DEBUG == true) { $timer->stop(); $timer->display(); } }
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(); } }
/** * 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 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)); } }
/** * Returns stream only including * lines from the original stream which don't start with any of the * specified comment prefixes. * * @param null $len * @return mixed the resulting stream, or -1 * if the end of the resulting stream has been reached. * */ public function read($len = null) { if (!$this->getInitialized()) { $this->_initialize(); $this->setInitialized(true); } $buffer = $this->in->read($len); if ($buffer === -1) { return -1; } $lines = explode("\n", $buffer); $filtered = array(); $commentsSize = count($this->_comments); foreach ($lines as $line) { for ($i = 0; $i < $commentsSize; $i++) { $comment = $this->_comments[$i]->getValue(); if (StringHelper::startsWith($comment, ltrim($line))) { $line = null; break; } } if ($line !== null) { $filtered[] = $line; } } $filtered_buffer = implode("\n", $filtered); return $filtered_buffer; }
function main() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (array_key_exists('content', $_POST)) { // define password bytes $passwordBytes = Configuration::$aesPasswordBytes; // decode $content = $_POST['content']; $decodedContent = base64_decode($content); // decrypt $decryptedContent = EncryptionHelper::decryptMessage($decodedContent, $passwordBytes); $decryptedContent = StringHelper::untilLastOccurence($decryptedContent, '}'); // json decode $highscoreData = json_decode($decryptedContent); // store $config = ConfidentialConfiguration::getDatabaseConfiguration(); $highscore = new Highscore($config->databaseHost, $config->databaseUserName, $config->databaseUserPassword, $config->databaseName); $highscore->insert($highscoreData); die(ResponseHelper::serializeResponse('Success', 'Success')); } else { die(ResponseHelper::serializeResponse('Error', 'The request must contain a POST parameter')); } } else { die(ResponseHelper::serializeResponse('Error', 'Not a POST request, sorry')); } }
public function __construct() { parent::__construct(); $this->fractionDigits = StringHelper::trim($this->numberFormatter->getAttribute(NumberFormatter::FRACTION_DIGITS)); if ($this->fractionDigits === FALSE) { throw new IllegalStateException(t('Cannot detect OS fraction digits')); } }
public static function getInstance() { if (self::$objInstance == null) { self::$objInstance = new StringHelper(); } return self::$objInstance; }
public function setPassword($pass1, $pass2 = false, $emptyIsOk = false) { if ($pass1 || $emptyIsOk) { // a pass has been set if ($pass2 !== false && $pass1 != $pass2) { // a confirmation has been set but is different $this->_error['password'] = '******'; return false; } $this->set('salt', StringHelper::genRandom(8, 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')); if ($pass1) { $arr = explode(',', $this->_properties[$key]); $class = array_shift($arr); if (VarPss::checkValid($pass1, $arr)) { $this->setRawPassword($pass1, $this->get('salt')); } else { $this->_error['password'] = '******'; return false; } } else { $this->data['password'] = ''; } return true; } else { if (!$emptyIsOk) { $this->_error['password'] = '******'; return false; } return true; } }
/** * Initializes the console app by creating the command runner. * * @return null */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath(craft()->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // No need for these. craft()->log->removeRoute('WebLogRoute'); craft()->log->removeRoute('ProfileLogRoute'); // Load the plugins craft()->plugins->loadPlugins(); // Validate some basics on the database configuration file. craft()->validateDbConfigFile(); // Call parent::init before the plugin console command logic so craft()->commandRunner will be available to us. parent::init(); foreach (craft()->plugins->getPlugins() as $plugin) { $commandsPath = craft()->path->getPluginsPath() . StringHelper::toLowerCase($plugin->getClassHandle()) . '/consolecommands/'; if (IOHelper::folderExists($commandsPath)) { craft()->commandRunner->addCommands(rtrim($commandsPath, '/')); } } }
public function __construct($configuration, $wildcard, $anyCharactersOnLeft = FALSE, $anyCharactersOnRight = FALSE) { parent::__construct($configuration); $this->wildcard = StringHelper::trim($wildcard); $this->anyCharactersOnLeft = $anyCharactersOnLeft; $this->anyCharactersOnRight = $anyCharactersOnRight; }
public function counter($requestData) { $period = isset($requestData['period']) ? $requestData['period'] : null; $dimension = isset($requestData['options']['dimension']) ? $requestData['options']['dimension'] : null; $metric = isset($requestData['options']['metric']) ? $requestData['options']['metric'] : null; $start = date('Y-m-d', strtotime('-1 ' . $period)); $end = date('Y-m-d'); // Counter $criteria = new Analytics_RequestCriteriaModel(); $criteria->startDate = $start; $criteria->endDate = $end; $criteria->metrics = $metric; if ($dimension) { $optParams = array('filters' => $dimension . '!=(not set);' . $dimension . '!=(not provided)'); $criteria->optParams = $optParams; } $response = craft()->analytics->sendRequest($criteria); if (!empty($response['rows'][0][0]['f'])) { $count = $response['rows'][0][0]['f']; } else { $count = 0; } $counter = array('count' => $count, 'label' => StringHelper::toLowerCase(Craft::t(craft()->analytics_metadata->getDimMet($metric)))); // Return JSON return ['type' => 'counter', 'counter' => $counter, 'response' => $response, 'metric' => Craft::t(craft()->analytics_metadata->getDimMet($metric)), 'period' => $period, 'periodLabel' => Craft::t('this ' . $period)]; }
protected function afterFind() { if (StringHelper::isNullOrEmpty($this->icon_src)) { $this->icon_src = Group::DEFAULT_IMG_PATH; } return parent::afterFind(); }
/** * @return array * @throws Exception */ public function processDownload() { Craft::log('Starting to process the update download.', LogLevel::Info, true); $tempPath = craft()->path->getTempPath(); // Download the package from ET. Craft::log('Downloading patch file to ' . $tempPath, LogLevel::Info, true); if (($fileName = craft()->et->downloadUpdate($tempPath)) !== false) { $downloadFilePath = $tempPath . $fileName; } else { throw new Exception(Craft::t('There was a problem downloading the package.')); } $uid = StringHelper::UUID(); // Validate the downloaded update against ET. Craft::log('Validating downloaded update.', LogLevel::Info, true); if (!$this->_validateUpdate($downloadFilePath)) { throw new Exception(Craft::t('There was a problem validating the downloaded package.')); } // Unpack the downloaded package. Craft::log('Unpacking the downloaded package.', LogLevel::Info, true); $unzipFolder = craft()->path->getTempPath() . $uid; if (!$this->_unpackPackage($downloadFilePath, $unzipFolder)) { throw new Exception(Craft::t('There was a problem unpacking the downloaded package.')); } return array('uid' => $uid); }
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'); }
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'); }
/** * @param string $filename * @return string */ public static function sanitizeFilename($filename) { $filename = StringHelper::unaccent($filename); $filename = mb_strtolower($filename); $filename = preg_replace("/[^a-z0-9\\. -]/", "", $filename); return preg_replace('/( +)|(-+)/', '-', $filename); }
/** * Prefix to apply to properties loaded using <code>file</code>. * A "." is appended to the prefix if not specified. * @param string $prefix prefix string * @return void * @since 2.0 */ function setPrefix($prefix) { $this->prefix = $prefix; if (!StringHelper::endsWith(".", $prefix)) { $this->prefix .= "."; } }
protected function beforeValidate() { if (!parent::beforeValidate()) { return false; } if ($this->scenario == "fromAdmin") { if ($this->teacher_path_file == NULL) { $this->addError("teacher_avatar", "teacher_avatar is required"); return false; } if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) { return FALSE; } $ext = $this->teacher_path_file->getExtension(); $name = StringHelper::unicode_str_filter($this->teacher_path_file->name); $storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/'; $targetPath = $storeFolder; //4 $teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name; if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") { $this->teacher_path_file->save($targetPath, $name); $this->teacher_avatar = $teacher_ava; } } return TRUE; }
public function updateOrder($attr) { $order = OrderMedlatec::model()->findByPk($attr['order_id']); if ($order) { $order->setAttributes($attr); $order->time_meet = StringHelper::dateToTime($attr['time_meet']); $order->time_confirm = StringHelper::dateToTime($attr['time_confirm']); $order->updated_at = time(); if ($order->save(FALSE)) { $meboo = $order->user_meboo; // echo $meboo; die; //echo $order->status; die; $device_tokens = DeviceTk::model()->findAllByAttributes(array('user_id' => $meboo)); $ios_alert = null; if ($order->status == 2) { $ios_alert = 'Dịch vụ bạn đặt (' . ServiceMedlatec::model()->getServiceNameById($order->service_id) . ') đã được Meboo xác nhận'; } else { if ($order->status == 4) { $ios_alert = 'Dịch vụ bạn đặt (' . ServiceMedlatec::model()->getServiceNameById($order->service_id) . ') đã được hoàn thành'; } } $message_android = array('medlatec_order' => array('order_id' => $attr['order_id'])); $message_ios = array('alert' => $ios_alert, 'sound' => 'default', 'data' => array('id' => $attr['order_id'], 'type' => '0', 'user_id' => $meboo)); $message = array('message_android' => $message_android, 'message_ios' => $message_ios); foreach ($device_tokens as $token) { // echo $token->platform; Util::sendNotificationBasedOnStatus($token->device_token, $order->status, $message); } //die; return TRUE; } } return FALSE; }
public function formatCitation() { $citation = ""; $citation .= $this->formatAuthors() . '. '; $citation .= $this->year . '. '; $citation .= StringHelper::sentenceCase($this->title) . '. '; $citation .= "Di dalam: "; if ($this->editors) { $citation .= $this->formatEditors() . ', editor. '; } if ($this->book_title) { $citation .= '<em>' . StringHelper::titleCase($this->book_title) . '</em>; '; } else { $citation .= '[Judul buku tidak diketahui]; '; } if ($this->pub) { $citation .= $this->pub_city . ' (' . $this->pub_country . '): ' . $this->pub . '. '; } else { $citation .= '[Penerbit tidak diketahui]. '; } if ($this->pages) { $citation .= 'hlm ' . $this->pages . '. '; } else { $citation .= '[No halaman tidak diketahui]. '; } return $citation; }
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 action_createOrUpdateWarehouse() { try { $post = Validate::factory($_POST)->rule('warehouse_name', 'not_empty')->rule('warehouse_short_name', 'not_empty')->rule('warehouse_office_location', 'not_empty'); if (!$post->check()) { echo "0|ERROR - Empty Data Post"; die; } $warehouse_id = StringHelper::cleanEmptyString4NULL($_POST['warehouse_id']); $warehouse_name = StringHelper::cleanEmptyString4NULL($_POST['warehouse_name']); $warehouse_short_name = StringHelper::cleanEmptyString4NULL($_POST['warehouse_short_name']); $warehouse_office_location = StringHelper::cleanEmptyString4NULL($_POST['warehouse_office_location']); $warehouse = new Model_Warehouse(); if ($warehouse_id != 0) { $warehouse = ORM::factory('Warehouse', $warehouse_id); } $warehouse->name = trim($warehouse_name); $warehouse->shortName = trim($warehouse_short_name); $warehouse->status = $this->GENERAL_STATUS['ACTIVE']; $warehouse->idOfficeLocation = $warehouse_office_location; $warehouse->save(); echo "1|ok"; } catch (Exception $exc) { echo "0|" . $exc->getTraceAsString(); } die; }
public function action_createOrUpdateOfficeLocation() { try { $post = Validate::factory($_POST)->rule('office_location_name', 'not_empty')->rule('office_location_address', 'not_empty')->rule('office_location_country', 'not_empty'); if (!$post->check()) { echo "0|ERROR - Empty Data Post"; die; } $office_location_id = StringHelper::cleanEmptyString4NULL($_POST['office_location_id']); $office_location_name = StringHelper::cleanEmptyString4NULL($_POST['office_location_name']); $office_location_address = StringHelper::cleanEmptyString4NULL($_POST['office_location_address']); $office_location_country = StringHelper::cleanEmptyString4NULL($_POST['office_location_country']); $office_location = new Model_Officelocation(); if ($office_location_id != 0) { $office_location = ORM::factory('Officelocation', $office_location_id); } $office_location->name = trim($office_location_name); $office_location->address = trim($office_location_address); $office_location->status = $this->GENERAL_STATUS['ACTIVE']; $office_location->idCountry = $office_location_country; $office_location->save(); echo "1|ok"; } catch (Exception $exc) { echo "0|" . $exc->getTraceAsString(); } die; }