/** * The index action */ public function indexAction() { if (!$this->request->isPost()) { Tag::setDefault('username', '*****@*****.**'); Tag::setDefault('password', 'hhf'); } }
public function verifyAction($code) { if ($code) { $results = VerifyEmail::FindFirst("verifyCode = '" . $code . "'"); if (!isset($results->cid)) { return $this->response->redirect("index/index"); } $form = new RegisterForm(); if (isset($results) && $results != '') { if ($results->active == 'Y') { if (md5($results->time . '+' . $results->email) == $code) { $this->view->form = $form; Tag::setDefault('password', null); Tag::setDefault('cid', $results->cid); Tag::setDefault('email', $results->email); $this->view->setVar("email", $results->email); } else { $this->flash->error('邮箱验证错误!'); $this->response->redirect("account/index"); } } else { $this->flash->error('邮箱已经验证通过,请登录!'); $this->response->redirect("account/index"); } } else { $this->flash->error('验证码已过期!'); $this->response->redirect("index/index"); } } else { $this->response->redirect("index/index"); } }
public function profileAction() { $auth = $this->session->get('auth'); $user = Users::findFirst($auth['id']); if ($user == false) { $this->_forward('index/index'); } $request = $this->request; if (!$request->isPost()) { Tag::setDefault('name', $user->name); Tag::setDefault('email', $user->email); } else { $name = $request->getPost('name', 'string'); $email = $request->getPost('email', 'email'); $name = strip_tags($name); $user->name = $name; $user->email = $email; if ($user->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error((string) $message); } } else { $this->flash->success('更新成功'); } } }
public function indexAction() { if (!$this->request->isPost()) { Tag::setDefault('email', '*****@*****.**'); Tag::setDefault('password', 'phalcon'); } }
public function indexAction() { if (!$this->request->isPost()) { Tag::setDefault('email', ' '); Tag::setDefault('password', ''); } }
public function registerAction() { $request = $this->request; if ($request->isPost()) { $name = $request->getPost('name', array('string', 'striptags')); $username = $request->getPost('username', 'alphanum'); $email = $request->getPost('email', 'email'); $password = $request->getPost('password'); $repeatPassword = $this->request->getPost('repeatPassword'); if ($password != $repeatPassword) { $this->flash->error('Passwords are diferent'); return false; } $user = new Users(); $user->username = $username; $user->password = sha1($password); $user->name = $name; $user->email = $email; $user->created_at = new Phalcon\Db\RawValue('now()'); $user->active = 'Y'; if ($user->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error((string) $message); } } else { Tag::setDefault('email', ''); Tag::setDefault('password', ''); $this->flash->success('Thanks for sign-up, please log-in to start generating invoices'); return $this->forward('session/index'); } } }
/** * @see 2402 issue * @link https://github.com/phalcon/cphalcon/issues/2402 * @throws Exception */ public function testDisplayValues() { Tag::setDefault('property1', 'testVal1'); Tag::setDefault('property2', 'testVal2'); Tag::setDefault('property3', 'testVal3'); $this->assertTrue(Tag::hasValue('property1')); $this->assertTrue(Tag::hasValue('property2')); $this->assertTrue(Tag::hasValue('property3')); $this->assertEquals('testVal1', Tag::getValue('property1')); $this->assertEquals('testVal2', Tag::getValue('property2')); $this->assertEquals('testVal3', Tag::getValue('property3')); }
public function editAction($fileName) { $fileName = str_replace('..', '', $fileName); $controllersDir = Tools::getConfig()->application->controllersDir; if (!file_exists($controllersDir . '/' . $fileName)) { $this->flash->error('Controller could not be found', 'alert alert-error'); return $this->dispatcher->forward(array('controller' => 'controllers', 'action' => 'list')); } Tag::setDefault('code', file_get_contents($controllersDir . '/' . $fileName)); Tag::setDefault('name', $fileName); $this->view->setVar('name', $fileName); }
public function testIssue947() { $di = new Phalcon\DI\FactoryDefault(); \Phalcon\Tag::setDI($di); $html = \Phalcon\Tag::radioField(array('test', 'value' => 1, 'checked' => 'checked')); $pos = strpos($html, 'checked="checked"'); $this->assertTrue($pos !== FALSE); $html = \Phalcon\Tag::radioField(array('test', 'value' => 0)); $pos = strpos($html, 'checked="checked"'); $this->assertTrue($pos === FALSE); \Phalcon\Tag::setDefault("test", "0"); $html = \Phalcon\Tag::radioField(array('test', 'value' => 0)); $pos = strpos($html, 'checked="checked"'); $this->assertTrue($pos !== FALSE); }
public function indexAction() { if (!$this->request->isPost()) { Tag::setDefault('email', ' '); Tag::setDefault('password', ''); } else { $name = trim($this->request->getPost('name', array('string', 'striptags'))); $password = trim($this->request->getPost('password')); $password = sha1($password); $detail = Customer::find("name = " . $name); if ($password == sha1($detail->num)) { return $this->forward("search/jump"); } else { $this->flash->error("错误"); } } }
/** * Edits a vehicle * * @param string $id */ public function editAction($id) { if (!$this->request->isPost()) { $vehicle = Vehicles::findFirstById($id); if (!$vehicle) { $this->flash->error("vehicle was not found"); return $this->dispatcher->forward(array("controller" => "vehicles", "action" => "index")); } $this->view->id = $vehicle->id; Tag::setDefault("id", $vehicle->id); Tag::setDefault("name", $vehicle->name); Tag::setDefault("maxCapacityMap", $vehicle->maxCapacityMap); Tag::setDefault("timeWindow", $vehicle->timeWindow); Tag::setDefault("maxWorkingTime", $vehicle->maxWorkingTime); Tag::setDefault("maxDrivingTime", $vehicle->maxDrivingTime); Tag::setDefault("status", $vehicle->status); Tag::setDefault("created", $vehicle->created); Tag::setDefault("modified", $vehicle->modified); } }
/** * Edits a waypoint * * @param string $id */ public function editAction($id) { if (!$this->request->isPost()) { $waypoint = Waypoints::findFirstById($id); if (!$waypoint) { $this->flash->error("waypoint was not found"); return $this->dispatcher->forward(array("controller" => "waypoints", "action" => "index")); } $this->view->id = $waypoint->id; Tag::setDefault("id", $waypoint->id); Tag::setDefault("name", $waypoint->name); Tag::setDefault("location", $waypoint->location); Tag::setDefault("latitude", $waypoint->latitude); Tag::setDefault("longitude", $waypoint->longitude); Tag::setDefault("deliveryMap", $waypoint->deliveryMap); Tag::setDefault("serviceTime", $waypoint->serviceTime); Tag::setDefault("timeWindows", $waypoint->timeWindows); Tag::setDefault("priority", $waypoint->priority); Tag::setDefault("status", $waypoint->status); Tag::setDefault("created", $waypoint->created); Tag::setDefault("modified", $waypoint->modified); } }
public function registerAction() { $request = $this->request; if ($request->isPost()) { $full_name = $request->getPost('firstname', array('string', 'striptags')) . " " . $request->getPost('lastname', array('string', 'striptags')); $organisation_name = $request->getPost('organisation_name', array('string', 'striptags')); $email = $request->getPost('email', 'email'); $password = $request->getPost('password'); $repeat_password = $this->request->getPost('password2'); if ($password != $repeat_password) { $this->flash->error("Passwords don't match"); return $this->forward('session/register'); } $organisation = new Organisation(); $organisation->name = $organisation_name; $organisation->theme = 'make'; if ($organisation->save() == true) { $config = new \Phalcon\Config\Adapter\Ini('/../app/config/config.ini'); $database = new OrgDatabase(); $database->db_host = $config->database->host; $database->db_username = "******" . $organisation_name; $database->db_password = sha1($password); $database->db_name = "db_" . $organisation_name; $database->organisation_id = $organisation->id; $user = new Users(); $user->password = sha1($password); $user->full_name = $full_name; $user->role = 'Admin'; $user->email = $email; $user->created_at = new \Phalcon\Db\RawValue('now()'); $user->status = 'disable'; $user->organisation_id = $organisation->id; if ($user->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error((string) $message); } } else { if ($database->save() == false) { foreach ($database->getMessages() as $message) { $this->flash->error((string) $message); } } else { //Read the configuration $host = $config->database->host; $root = $config->database->username; $root_password = $config->database->password; $user = "******" . $organisation_name; $pass = sha1($password); $db = "db_" . $organisation_name; Tag::setDefault('email', ''); Tag::setDefault('password', ''); $this->flash->success('Thanks for signing up for a new PRIME Dashboard, our consultants will contact you soon.'); return $this->forward('session/index'); } } } else { foreach ($organisation->getMessages() as $message) { $this->flash->error((string) $message); } } } }
public function editAction($id) { $request = $this->request; if (!$request->isPost()) { $id = $this->filter->sanitize($id, array("int")); $Finance = Finance::findFirst('id="' . $id . '"'); if (!$Finance) { $this->flash->error("这条记录没有找到!"); return $this->forward("products/list"); } $departments = Department::find(); $this->view->setVar("departments", $departments); Tag::displayTo("company", $Finance->did); $typeArr; $type = Type::find(); foreach ($type as $k => $v) { $types = Types::find("fid = '" . $v->id . "'"); $typeArr[$v->name] = $types->toArray(); } $this->view->setVar("typeArr", $typeArr); $this->view->setVar("id", $Finance->id); $datas = json_decode($Finance->data, true); foreach ($typeArr as $key => $val) { foreach ($val as $k => $v) { if (isset($datas['cost'][$v['name']]) && $datas['cost'][$v['name']] != '') { Tag::displayTo("cost[" . $v['name'] . "]", $datas['cost'][$v['name']]); } if (isset($datas['remark'][$v['name']]) && $datas['remark'][$v['name']] != '') { Tag::displayTo("remark[" . $v['name'] . "]", $datas['remark'][$v['name']]); } if (isset($datas['limit'][$v['name']]) && $datas['limit'][$v['name']] != '') { Tag::displayTo("limit[" . $v['name'] . "]", $datas['limit'][$v['name']]); } } } Tag::displayTo("id", $Finance->id); $auth = $this->session->get("auth"); if ($auth['did'] != 0) { Tag::setDefault("company", $auth['did']); } $this->view->setVar('did', $auth['did']); /* Tag::displayTo("product_types_id", $products->product_types_id); Tag::displayTo("name", $products->name); Tag::displayTo("price", $products->price); Tag::displayTo("active", $products->active); $this->view->setVar("productTypes", ProductTypes::find()); */ } }
public function beforeRender($params) { Tag::setDefault($params['id'], $params['value']); }
public function verifyemailAction($code) { if ($code) { $results = VerifyEmail::FindFirst("verifyCode = '" . $code . "'"); $form = new RegisterForm(); if (isset($results) && $results != '') { if ($results->active == 'Y') { if (md5($results->time . '+' . $results->email) == $code) { $this->view->form = $form; Tag::setDefault('username', ' '); Tag::setDefault('name', ' '); Tag::setDefault('password', ''); $department = Department::FindFirst("id = " . $results->did); Tag::setDefault('did', $results->did); $this->view->setVar("deparment", $department->name); $this->view->setVar("email", $results->email); } else { $this->flash->error('邮箱验证错误!'); $this->response->redirect("register/index"); } } else { $this->flash->error('邮箱已经验证通过,请登录!'); $this->response->redirect("session/index"); } } else { $this->flash->error('验证码已过期!'); $this->response->redirect("index/index"); } } else { $this->response->redirect("index/index"); } }
public function accountAction($id) { $id = $this->filter->sanitize($id, array("int")); $userInfo = Users::findFirst('did = "' . $id . '"'); if (!$userInfo) { $this->flash->notice("还木有帐号,请创建并保存"); $this->view->setVar("aid", $id); Tag::displayTo("did", $id); Tag::setDefault('email', ' '); Tag::setDefault('password', ''); $this->view->pick("session/register"); } else { $this->view->setVar("aid", $id); Tag::displayTo("id", $userInfo->id); Tag::displayTo("username", $userInfo->username); Tag::displayTo("name", $userInfo->name); Tag::displayTo("email", $userInfo->email); } }
/** * Reconstructing \Phalcon\Tag::setDefault via method chaining * * @param string $key * @param string $val * * @return mixed */ public function formDefault($key, $val) { Tag::setDefault($key, $val); return $this; }
/** * Clears every element in the form to its default value * * @return \Phalcon\Forms\Element */ public function clear() { Tag::setDefault($this->_name, null); return $this; }
public static function setDefault($id, $value) { parent::setDefault($id, $value); }
public function testDefault() { Tag::setDefault('username', 'dreamsxin'); $this->assertEquals(Tag::getDefault('username'), 'dreamsxin'); $data = array('username' => 'dreamsxin', 'email' => '*****@*****.**'); Tag::setDefaults($data); $this->assertEquals(Tag::getDefaults(), $data); }
/** * Tests selectStatic with setDefault to an non existent element * * @author Nikos Dimopoulos <*****@*****.**> * @since 2012-10-26 */ public function testSelectStaticSetDefaultElementNotPresentXHTML() { $params = array('some_field_name', 'class' => 'some_class', 'size' => '10'); \Phalcon\Tag::setDefault('some_field', 'I'); $options = array('A' => 'Active', 'I' => 'Inactive'); $expected = '<select id="some_field_name" name="some_field_name" class="some_class" size="10">' . PHP_EOL . chr(9) . '<option value="A">Active</option>' . PHP_EOL . chr(9) . '<option value="I">Inactive</option>' . PHP_EOL . '</select>'; $actual = \Phalcon\Tag::selectStatic($params, $options); \Phalcon\Tag::setDefault('some_field', ''); $this->assertEquals($expected, $actual, sprintf($this->message, 'XHTML selectStatic with setDefault')); }
/** * Tests clearing the Form Elements by using Form::bind * * @issue 11978 * @author Serghei Iakovlev <*****@*****.**> * @since 2016-10-01 * @param IntegrationTester $I */ public function clearFormElementsByUsingFormBind(IntegrationTester $I) { $name = new Text('sel_name'); $text = new Text('sel_text'); $form = new Form(); $form->add($name)->add($text); $entity = new MvcModel(); $I->assertNull(Tag::getValue('sel_name')); $I->assertNull($form->getValue('sel_name')); $I->assertNull($form->get('sel_name')->getValue()); $I->assertNull($name->getValue()); Tag::setDefault('sel_name', 'Please specify name'); $_POST = ['sel_name' => 'Some Name', 'sel_text' => 'Some Text']; $form->bind($_POST, $entity); $I->assertEquals('Some Name', $entity->getName()); $I->assertEquals('Some Text', $entity->getText()); $I->assertEquals('Some Name', $form->getValue('sel_name')); $I->assertEquals('Some Name', $form->get('sel_name')->getValue()); $I->assertEquals('Some Name', $name->getValue()); $I->assertEquals('Some Text', $form->getValue('sel_text')); $I->assertEquals('Some Text', $form->get('sel_text')->getValue()); $I->assertEquals('Some Text', $text->getValue()); $form->clear(['sel_name']); $I->assertNull(Tag::getValue('sel_name')); $I->assertNull($form->getValue('sel_name')); $I->assertNull($form->get('sel_name')->getValue()); $I->assertNull($name->getValue()); $I->assertEquals('Some Text', $form->getValue('sel_text')); $I->assertEquals('Some Text', $form->get('sel_text')->getValue()); $I->assertEquals('Some Text', $text->getValue()); $form->clear(['non_existent', 'another_filed']); $I->assertEquals('Some Text', $form->getValue('sel_text')); $I->assertEquals('Some Text', $form->get('sel_text')->getValue()); $I->assertEquals('Some Text', $text->getValue()); $form->clear(); $I->assertNull(Tag::getValue('sel_text')); $I->assertNull($form->getValue('sel_text')); $I->assertNull($form->get('sel_text')->getValue()); $I->assertNull($text->getValue()); $I->assertEquals('Some Name', $entity->getName()); $I->assertEquals('Some Text', $entity->getText()); $I->assertEquals(['sel_name' => 'Some Name', 'sel_text' => 'Some Text'], $_POST); }