public function sendAction() { if ($this->request->isPost() == true) { $name = $this->request->getPost('name', 'string'); $email = $this->request->getPost('email', 'email'); $comments = $this->request->getPost('comments', 'string'); $name = strip_tags($name); $comments = strip_tags($comments); $contact = new Contact(); $contact->name = $name; $contact->email = $email; $contact->comments = $comments; $contact->created_at = new Phalcon_Db_RawValue('now()'); if ($contact->save() == false) { foreach ($contact->getMessages() as $message) { Phalcon_Flash::error((string) $message, 'alert alert-error'); } return $this->_forward('contact/index'); } else { Phalcon_Flash::success('Thanks, We will contact you in the next few hours', 'alert alert-success'); return $this->_forward('index/index'); } } else { return $this->_forward('contact/index'); } }
public function indexAction() { if (!$this->request->isPost()) { Phalcon_Flash::notice('This is a sample application of the Phalcon PHP Framework. Please don\'t provide us any personal information. Thanks', 'alert alert-info'); } }
/** * Edit the active user profile * */ public function profileAction() { //Get session info $auth = Session::get('auth'); //Query the active user $user = Users::findFirst($auth['id']); if ($user == false) { $this->_forward('index/index'); } if (!$this->request->isPost()) { Tag::setDefault('name', $user->name); Tag::setDefault('email', $user->email); } else { $name = $this->request->getPost('name', 'string'); $email = $this->request->getPost('email', 'email'); $name = strip_tags($name); $user->name = $name; $user->email = $email; if ($user->save() == false) { foreach ($user->getMessages() as $message) { Flash::error((string) $message, 'alert alert-error'); } } else { Flash::success('Your profile information was updated successfully', 'alert alert-success'); } } }
public function saveAction() { $isIniConfig = false; $configPath = "app/config/config.ini"; if (file_exists($configPath)) { $isIniConfig = true; } if ($this->request->isPost()) { $newConfig = array(); foreach ($this->_posibleConfig as $section => $config) { foreach ($config as $name => $type) { if (isset($_POST[$name])) { $newConfig[$section][$name] = $this->request->getPost($name, $type); } } } if ($isIniConfig) { $ini = ''; foreach ($newConfig as $section => $settings) { $ini .= '[' . $section . ']' . PHP_EOL; foreach ($settings as $name => $value) { $ini .= $name . ' = ' . $value . PHP_EOL; } $ini .= PHP_EOL; } $path = Phalcon_WebTools::getPath("app/config/config.ini"); } else { $path = Phalcon_WebTools::getPath("app/config/config.php"); $ini = '<?php' . PHP_EOL . PHP_EOL . '$config = new Phalcon_Config(' . var_export($newConfig, true) . ');'; } $configPath = $path; if (is_writable($configPath)) { file_put_contents($configPath, $ini); $this->_readConfig(); Phalcon_Flash::success('Configuration was successfully updated', 'alert alert-success'); } else { Phalcon_Flash::error('Sorry, configuration file is not writable', 'alert alert-error'); } } return $this->_forward('config/index'); }
public function deleteAction($id) { $id = $this->filter->sanitize($id, array("int")); $producttypes = ProductTypes::findFirst('id="' . $id . '"'); if (!$producttypes) { Flash::error("product types was not found", "alert alert-error"); return $this->_forward("producttypes/index"); } if (!$producttypes->delete()) { foreach ($producttypes->getMessages() as $message) { Flash::error((string) $message, "alert alert-error"); } return $this->_forward("producttypes/search"); } else { Flash::success("product types was deleted", "alert alert-success"); return $this->_forward("producttypes/index"); } }
/** * Finishes the active session redirecting to the index * * @return unknown */ public function endAction() { unset($_SESSION['auth']); Flash::success('Goodbye!', 'alert alert-success'); return $this->_forward('index/index'); }