public function _createForgotPassForm() { $form = new Form(); $form->action = "/forgotpass"; $form->add(EmailField::name('email')->label('Email')->help('What is your email address?')->required(true)); return $form; }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('security/groups/edit' . ($id ? '/' . $id : '')); $form->add("name", 'Name', Form::STRING, '', array('not_empty'))->add('is_admin', 'Administrative group', Form::BOOL)->add('show_all_jobs', 'Show all jobs (unchecked - show only assigned jobs)', Form::BOOL)->add('allow_assign', 'Allow assigning jobs', Form::BOOL)->add('allow_reports', 'Allow tracking changes', Form::BOOL)->add('allow_submissions', 'Allow tracking submissions', Form::BOOL)->add('allow_finance', 'Financial reports', Form::BOOL)->add('allow_forms', 'Forms submission', Form::BOOL)->add('allow_custom_forms', 'Custom forms submission', Form::BOOL)->add('edit_custom_forms', 'Edit custom forms reports', Form::BOOL)->add('time_machine', 'Time Machine', Form::BOOL); $form->add('columns', 'Show columns in job search', Form::INFO); foreach (Columns::$fixed as $key => $value) { $form->add($key, $value, Form::BOOL); } $item = $id ? Group::get($id) : array(); if ($item) { $columns = explode(',', $item['columns']); foreach ($columns as $column) { $item[$column] = 1; } unset($item['columns']); } $form->values($item); if ($_POST) { $value = $form->filter($_POST); if ($value['is_admin']) { $value['show_all_jobs'] = 1; $value['allow_assign'] = 1; $value['allow_reports'] = 1; $value['allow_submissions'] = 1; $value['allow_finance'] = 1; $value['allow_forms'] = 0; $value['allow_custom_forms'] = 1; $value['edit_custom_forms'] = 1; $value['time_machine'] = 1; $value['columns'] = implode(',', array_keys(Columns::$fixed)); } else { $columns = array(); foreach (Columns::$fixed as $key => $name) { if (Arr::get($value, $key)) { $columns[] = $key; } } $value['columns'] = implode(',', $columns); } $value = array_diff_key($value, Columns::$fixed); if (!$form->validate($value)) { if ($id) { DB::update('groups')->set($value)->where('id', '=', $id)->execute(); } else { $origin = Arr::get($_POST, 'permissions'); unset($_POST['permissions']); $id = Arr::get(DB::insert('groups', array_keys($value))->values(array_values($value))->execute(), 0); DB::query(Database::INSERT, DB::expr("INSERT INTO `group_columns` (`group_id`, `column_id`, `permissions`) \n (SELECT :id, `column_id`, `permissions` FROM `group_columns` WHERE `group_id` = :origin)")->param(':id', $id)->param(':origin', $origin)->compile())->execute(); } Messages::save('Group successfully saved!', 'success'); $this->redirect('/security/groups'); } } if (!$id) { $groups = DB::select('id', 'name')->from('groups')->execute()->as_array('id', 'name'); $form->add('permissions', 'Copy permissions from group', Form::SELECT, $groups); } $this->response->body($form->render()); }
public function action_edit() { $type = $this->request->param('id'); $id = Arr::get($_GET, 'id'); $uoms = DB::select('id', 'name')->from('uoms')->execute()->as_array('id', 'name'); $form = new Form('items/edit/' . $type . '?id=' . ($id ?: '')); $form->add('code', 'Code', Form::STRING, '', array('not_empty'))->add('name', 'Name', Form::STRING, '', array('not_empty')); if ($type == 'item') { $table = 'items'; $form->add('descr', 'Description', Form::TEXT); } else { $table = 'bom_items'; } $form->add('uom', 'UOM', Form::SELECT, array(0 => 'Not selected') + $uoms); $item = DB::select()->from($table)->where('id', '=', $id)->execute()->current(); $form->values($item); if ($_POST) { $value = $form->filter($_POST); if (!$form->validate($value)) { if ($id) { DB::update($table)->set($value)->where('id', '=', $id)->execute(); } else { $id = Arr::get(DB::insert($table, array_keys($value))->values(array_values($value))->execute(), 0, 0); } $value['id'] = $id; $value['success'] = true; $value['uom'] = Arr::get($uoms, $value['uom'], 'Unknown'); if (isset($value['descr'])) { $value['descr'] = nl2br($value['descr']); } die(json_encode($value)); } } $this->response->body($form->render()); }
public function action_edit() { $id = $this->request->param('id'); $groups = DB::select()->from('groups')->execute()->as_array('id', 'name'); $companies = DB::select()->from('companies')->execute()->as_array('id', 'name'); $form = new Form('users/edit' . ($id ? '/' . $id : '')); $form->add("login", 'Login', Form::STRING, '', array('not_empty', 'min_length' => array(':value', 4)))->add('name', 'Real Name', Form::STRING)->add('group_id', 'Group', Form::SELECT, array(0 => 'Not selected') + $groups, array('not_empty'))->add('company_id', 'Company', Form::SELECT, array(0 => 'Not selected') + $companies, array('not_empty'))->add("email", 'E-Mail', Form::STRING, '', array('not_empty', 'email'))->add('is_admin', 'Admin', Form::BOOL); $form->add('passw', 'Password', Form::PASSWORD, '', $id ? false : array('not_empty', 'min_length' => array(':value', 6)))->add('pass2', 'Confirm password', Form::PASSWORD, '', array('matches' => array(':validation', 'pass2', 'passw'))); $item = $id ? User::get($id) : array(); $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); $error = $form->validate($item); if (!$error) { unset($item['pass2']); $exists = DB::select('id')->from('users')->where_open()->where('login', '=', $item['login'])->or_where('email', '=', $item['email'])->where_close()->and_where('id', '<>', $id)->execute()->get('id'); if ($exists) { if ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = 'exists'; header('Content-type: application/json'); die(json_encode($item)); } Messages::save("User with given login or email already exists! Please, enter different login/email!"); } else { if ($id) { if (!Arr::get($item, 'passw')) { unset($item['passw']); } DB::update('users')->set($item)->where('id', '=', $id)->execute(); } else { $result = DB::insert('users', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } $item['id'] = $id; $item['success'] = true; $item['group'] = Arr::get($groups, $item['group_id'], 'Unknown'); $item['company'] = Arr::get($companies, $item['company_id'], 'Unknown'); if ($this->request->is_ajax()) { header('Content-type: application/json'); die(json_encode($item)); } Messages::save('User successfully saved!', 'success'); $this->redirect('/users'); } } elseif ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = $error; header('Content-type: application/json'); die(json_encode($item)); } $form->values($item); } $this->response->body($form->render($error)); }
function _createAddCommentForm($content_id, $content_type) { $form = new Form(); $form->action = "/comment/add"; $form->submitText = "Add Comment"; $form->add(HiddenField::name('content_id')->value($content_id)); $form->add(HiddenField::name('content_type')->value($content_type)); $form->add(TextareaField::name('comment')->required(true)->width('50%')->rows(3)); return $form; }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('security/users/edit' . ($id ? '/' . $id : '')); $groups = DB::select('id', 'name')->from('groups')->execute()->as_array('id', 'name'); $partners = DB::select('id', 'name')->from('companies')->execute()->as_array('id', 'name'); $regions = DB::select('id', 'name')->from('regions')->execute()->as_array('id', 'name'); $form->add("login", 'Login', Form::STRING, '', array('not_empty', 'min_length' => array(':value', 4)))->add("email", 'E-Mail', Form::STRING, '', array('not_empty', 'email'))->add('group_id', 'Group', Form::SELECT, array('' => 'Please select...') + $groups, array('not_empty'), array('class' => 'multiselect'))->add('company_id', 'Partner', Form::SELECT, array('' => 'None') + $partners, null, array('class' => 'multiselect'))->add('default_region', 'Default region', Form::SELECT, array(0 => 'None') + $regions, null, array('class' => 'multiselect')); $form->add('region[]', 'Available regions', Form::SELECT, $regions, null, array('multiple' => 'multiple', 'class' => 'multiselect')); $form->add('passw', 'Password', Form::PASSWORD, '', $id ? false : array('not_empty', 'min_length' => array(':value', 6)))->add('pass2', 'Confirm password', Form::PASSWORD, '', array('matches' => array(':validation', 'pass2', 'passw'))); $item = $id ? User::get($id) : array(); if ($id) { $item['region[]'] = DB::select('region_id')->from('user_regions')->where('user_id', '=', $id)->execute()->as_array(NULL, 'region_id') ?: false; } $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); if (!$form->validate($item)) { unset($item['pass2']); $exists = DB::select('id')->from('users')->where_open()->where('login', '=', $item['login'])->or_where('email', '=', $item['email'])->where_close()->and_where('id', '<>', $id)->execute()->get('id'); if ($exists) { Messages::save("User with given login or email already exists! Please, enter different login/email!"); } else { $regs = Arr::get($_POST, 'region'); if ($id) { if (!Arr::get($item, 'passw')) { unset($item['passw']); } DB::update('users')->set($item)->where('id', '=', $id)->execute(); DB::delete('user_regions')->where('user_id', '=', $id)->execute(); } else { $result = DB::insert('users', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } if ($regs) { $result = DB::insert('user_regions', array('user_id', 'region_id')); foreach ($regs as $reg) { $result->values(array($id, $reg)); } $result->execute(); } Messages::save('User successfully saved!', 'success'); $this->redirect('/security/users'); } } $form->values($item); } $this->response->body($form->render($error)); }
public function roles($params) { //Load necessary models $usersModel = Model::load("auth.users"); $usersRolesModel = Model::load("auth.users_roles"); $rolesModel = Model::load("auth.roles"); //required queries $user = $usersModel->getWithField("user_id", $params[0]); $usersRoles = $usersRolesModel->getWithField("user_id", $params[0]); $loggedInUsersRoles = $usersRolesModel->getWithField("user_id", $_SESSION['user_id']); $roles = $rolesModel->get(); $this->label = "Select Role(s) for " . $user[0]['first_name'] . " " . $user[0]['last_name']; //create a new form $form = new Form(); $form->setRenderer("table"); $fieldset = Element::create('ColumnContainer', 3); $form->add($fieldset); foreach ($roles as $role) { if ($role['role_id'] == 1) { //Boolean to determine if the outer foreach loop should "continue" particular loop or not $continueBool = false; //Loop through all the current user's foreach ($loggedInUsersRoles as $userRole) { if ($userRole['role_id'] == 1) { $continueBool = false; break; } else { $continueBool = true; } } if ($continueBool) { continue; } } $checkbox = Element::create("Checkbox", $role['role_name'], self::underscore($role['role_name']), "", $role['role_id']); foreach ($usersRoles as $userRole) { if ($userRole['role_id'] == $role['role_id']) { $checkbox->setValue($role['role_id']); } } $fieldset->add($checkbox); } $userIdHiddenField = Element::create("HiddenField", "user_id", $params[0]); $form->add($userIdHiddenField); $form->setValidatorCallback("{$this->getClassName()}::roles_callback"); $form->setShowClear(false); //render the form return $form->render(); }
function getNetworkSettingsMask() { $tbl = new Table(array("", "")); $rIp = $tbl->createRow(); $rIp->setAttribute(0, new Text("IP:")); $rIp->setAttribute(1, new Textfield("ip", $this->getLocalIp())); $tbl->addRow($rIp); $rMask = $tbl->createRow(); $rMask->setAttribute(0, new Text("Subnet-Mask:")); $rMask->setAttribute(1, new Textfield("mask", $this->getLocalMask())); $tbl->addRow($rMask); $rGate = $tbl->createRow(); $rGate->setAttribute(0, new Text("Gateway:")); $rGate->setAttribute(1, new Textfield("gate", $this->getLocalGate())); $tbl->addRow($rGate); $rDns = $tbl->createRow(); $rDns->setAttribute(0, new Text("DNS-Server:")); $rDns->setAttribute(1, new Textfield("dns", $this->getLocalDns())); $tbl->addRow($rDns); $rOk = $tbl->createRow(); $rOk->setSpawnAll(true); $rOk->setAttribute(0, new Button("saveNetworkSettingsMask", $this->SAVE_BTN_LABEL)); $tbl->addRow($rOk); $f = new Form(); $f->add($tbl); return $f; }
public function testFormElementsMoves() { $this->assertTrue(is_array($this->object->elements())); $this->assertFalse($this->object->has('test')); $element = new Elements\Text('test'); $element2 = new Elements\Text('test2'); $this->object->add($element); $this->object->add($element2); $this->assertTrue($this->object->has('test')); $this->assertEquals($element, $this->object->element('test')); $this->object->remove('test'); $this->assertFalse($this->object->has('test')); $this->assertEquals(1, count($this->object->elements())); $this->object->addAll(array(new Elements\Text('test2'), new Elements\Text('test3'))); $this->setExpectedException('Fwk\\Form\\Exceptions\\UnknownElementException'); $this->object->element('nonExistant'); }
function showFullname() { $fp = new Text($this->getPath(), 3, true); $btnDel = new Button("clearLog", "Log leeren"); $hdnDel = new Hiddenfield("clearLogFile", $this->FULLPATH); $frmDel = new Form(); $tblTtl = new Table(array("", "")); $tblTtl->setColSizes(array(null, 100)); $tblTtl->setAlignments(array("left", "right")); $rTtl = $tblTtl->createRow(); $rTtl->setAttribute(0, $fp); $rTtl->setAttribute(1, $btnDel); $tblTtl->addRow($rTtl); $frmDel->add($tblTtl); $frmDel->add($hdnDel); $frmDel->show(); }
/** * @param FormBuilder|Form $builder */ public function appendToForm(&$builder, $data, $formArea) { if ($formArea == 'features') { $name = strtolower($this->getName()); if ($this->factory->serviceExists('mautic.form.type.cloudstorage.' . $name)) { $builder->add('provider', 'cloudstorage_' . $name, ['label' => 'mautic.integration.form.provider.settings', 'required' => false, 'data' => isset($data['provider']) ? $data['provider'] : []]); } } }
/** * The default page which shows the login form. * @see lib/controllers/Controller#getContents() */ public function getContents() { Application::addStylesheet("css/login.css"); Application::$template = "login.tpl"; Application::setTitle("Login"); if ($_SESSION["logged_in"]) { Application::redirect(Application::getLink("/")); } $form = new Form(); $form->setRenderer("default"); $username = new TextField("Username", "username"); $form->add($username); $password = new PasswordField("Password", "password"); $form->add($password); $form->setSubmitValue("Login"); $form->setCallback("{$this->getClassName()}::callback", $this); return $form->render(); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('groups/edit' . ($id ? '/' . $id : '')); $form->add("name", 'Name', Form::STRING, '', array('not_empty')); $roles = DB::select()->from('roles')->execute()->as_array('id', 'name'); foreach ($roles as $key => $role) { $form->add($key, $role, Form::BOOL); } $item = $id ? Group::get($id) : array(); $form->values($item); if ($_POST) { $value = $form->filter($_POST); if (!$form->validate($value)) { Database::instance()->begin(); if ($id) { DB::update('groups')->set(array('name' => $value['name']))->where('id', '=', $id)->execute(); DB::delete('group_roles')->where('group_id', '=', $id)->execute(); } else { $id = Arr::get(DB::insert('groups', array('name'))->values(array($value['name']))->execute(), 0); } $list = array(); foreach ($roles as $key => $role) { if (Arr::get($_POST, $key)) { $list[] = array($id, $key); } } if ($list) { $query = DB::insert('group_roles', array('group_id', 'role_id')); foreach ($list as $role) { $query->values($role); } $query->execute(); } Database::instance()->commit(); $value['id'] = $id; $value['success'] = true; die(json_encode($value)); //Messages::save('Group successfully saved!', 'success'); //$this->redirect('/groups'); } } $this->response->body($form->render()); }
/** * @param RenderAPI $renderApi * @param Unit $unit * @param ModuleInfo $moduleInfo */ public function renderContent($renderApi, $unit, $moduleInfo) { $formSend = false; $this->http = new \Request(); $form = new \Form(); $honeyPotComponent = new \HoneyPotComponent(); $this->formSubmit = new \FormSubmit(); $postRequest = $this->formSubmit->getPostValues(); $elementProperties = $form->getElementProperties(); $elementProperties->setId("form" . str_replace("-", "", $unit->getId())); $elementProperties->addAttribute('action', $_SERVER['REQUEST_URI'] . '#' . $unit->getId()); $elementProperties->addAttribute('method', 'post'); $elementProperties->addAttribute('enctype', 'multipart/form-data'); $form->add($honeyPotComponent->getHoneyPot()); $form->add($honeyPotComponent->getFormUnitIdentifier($unit->getId())); if ($this->formSubmit->isValid($renderApi, $unit) && count($postRequest) > 0 && $honeyPotComponent->isValidHoneyPot($postRequest) && $this->hasValidFormData($renderApi, $unit)) { $this->formSubmit->setFieldLabelsToFormValueSet($renderApi); try { $this->sentEmail($renderApi, $unit, $postRequest); $formSend = true; } catch (\Exception $e) { $errorText = new \Span(); $errorText->setContent("Unable to send email:<br />" . $e->getMessage()); $errorContainer = new \Container(); $errorContainer->add($errorText); $errorContainer->getElementProperties()->addClass('vf__main_error'); $form->add($errorContainer); } } if ($formSend) { $confirmationText = new \Span(); $confirmationText->setContent(preg_replace('/\\n/', '<br>', $renderApi->getFormValue($unit, 'confirmationText'))); $confirmationContainer = new \Container(); $confirmationContainer->add($confirmationText); $confirmationContainer->getElementProperties()->addClass('confirmationText'); $form->add($confirmationContainer); echo $form->renderElement(); } else { echo $form->renderElementProgressive($renderApi, $unit); } }
/** * Test validate */ public function testIsValid() { $this->form->add('<div>Test</div>'); $element_valid = $this->getMockBuilder('Jasny\\FormBuilder\\Element')->getMockForAbstractClass(); $element_valid->expects($this->exactly(2))->method('isValid')->will($this->returnValue(true)); $element_invalid = $this->getMockBuilder('Jasny\\FormBuilder\\Element')->getMockForAbstractClass(); $element_invalid->expects($this->once())->method('isValid')->will($this->returnValue(false)); $this->form->add($element_valid); $this->assertTrue($this->form->isValid()); $this->form->add($element_invalid); $this->assertFalse($this->form->isValid()); }
public function action_edit() { $id = $this->request->param('id'); if (!User::current('is_admin') && !(Group::current('item_create') && !$id) && !(Group::current('item_edit') && $id)) { throw new HTTP_Exception_403('Forbidden'); } $uoms = DB::select()->from('uoms')->execute()->as_array('id', 'name'); $form = new Form('items/edit' . ($id ? '/' . $id : '')); $form->add("sku", 'SKU/Barcode', Form::STRING, '', array('not_empty'))->add("name", 'Description', Form::STRING, '', array('not_empty'))->add("uom", 'UOM', Form::SELECT, array(0 => 'Not selected') + $uoms, array('not_empty'))->add("cost", 'Cost (each)', Form::NUMBER, '', array('not_empty'))->add("qty", 'Qty Tracked', Form::BOOL); if ($id) { $item = DB::select()->from('items')->where('id', '=', $id)->execute()->current(); } else { $item = array(); } $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); $error = $form->validate($item); if (!$error) { if ($id) { DB::update('items')->set($item)->where('id', '=', $id)->execute(); } else { $result = DB::insert('items', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } $item['id'] = $id; $item['success'] = true; if ($this->request->is_ajax()) { $item['uom'] = Arr::get($uoms, Arr::get($item, 'uom', 0), 'Unknown'); header('Content-type: application/json'); die(json_encode($item)); } Messages::save('Item successfully saved!', 'success'); $this->redirect('/items'); } elseif ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = $error; header('Content-type: application/json'); die(json_encode($item)); } $form->values($item); } $this->response->body($form->render($error)); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('projects/edit' . ($id ? '/' . $id : '')); $form->add("client_code", 'Client Code', Form::STRING, '', array('not_empty'))->add("internal_code", 'Internal Code', Form::STRING, '', array('not_empty'))->add("name", 'Project Name', Form::STRING, '', array('not_empty')); if ($id) { $item = DB::select()->from('projects')->where('id', '=', $id)->execute()->current(); } else { $item = array(); } $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); $error = $form->validate($item); if (!$error) { if ($id) { DB::update('projects')->set($item)->where('id', '=', $id)->execute(); } else { $result = DB::insert('projects', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } $item['id'] = $id; $item['success'] = true; if ($this->request->is_ajax()) { header('Content-type: application/json'); die(json_encode($item)); } Messages::save('Project successfully saved!', 'success'); $this->redirect('/projects'); } elseif ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = $error; header('Content-type: application/json'); die(json_encode($item)); } $form->values($item); } $this->response->body($form->render($error)); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('companies/edit' . ($id ? '/' . $id : '')); $form->add("logo", 'Logo', Form::IMAGE)->add("name", 'Project Name', Form::STRING, '', array('not_empty'))->add("prefix", 'Order Number Prefix', Form::STRING, '', array('not_empty'))->add("abn", 'ABN', Form::STRING, '', array('not_empty'))->add("address", 'Address', Form::STRING, '', array('not_empty'))->add("contact", 'Contact Name', Form::STRING, '', array('not_empty'))->add("phone", 'Contact Phone', Form::STRING, '', array('not_empty'))->add("email", 'E-Mail', Form::STRING, '', array('not_empty', 'email'))->add("note", 'Note', Form::TEXT)->add("note2", 'Note2', Form::TEXT); if ($id) { $item = DB::select()->from('companies')->where('id', '=', $id)->execute()->current(); } else { $item = array(); } $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); $error = $form->validate($item); if (!$error) { if ($id) { DB::update('companies')->set($item)->where('id', '=', $id)->execute(); } else { $result = DB::insert('companies', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } $item['id'] = $id; $item['success'] = true; if ($this->request->is_ajax()) { header('Content-type: application/json'); die(json_encode($item)); } Messages::save('Company successfully saved!', 'success'); $this->redirect('/companies'); } elseif ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = $error; header('Content-type: application/json'); die(json_encode($item)); } $form->values($item); } $this->response->body($form->render($error)); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('address/edit' . ($id ? '/' . $id : '')); $form->add("name", 'Site Name', Form::STRING, '', array('not_empty'))->add("address", 'Delivery Address', Form::STRING, '', array('not_empty'))->add("contact", 'Attention to', Form::STRING, '', array('not_empty'))->add("phone", 'Phone Number', Form::STRING, '', array('not_empty'))->add("note", 'Note', Form::TEXT); if ($id) { $item = DB::select()->from('address')->where('id', '=', $id)->execute()->current(); } else { $item = array(); } $form->values($item); $error = false; if ($_POST) { $item = $form->filter($_POST); $error = $form->validate($item); if (!$error) { if ($id) { DB::update('address')->set($item)->where('id', '=', $id)->execute(); } else { $result = DB::insert('address', array_keys($item))->values(array_values($item))->execute(); $id = Arr::get($result, 0); } $item['id'] = $id; $item['success'] = true; if ($this->request->is_ajax()) { header('Content-type: application/json'); die(json_encode($item)); } Messages::save('Address successfully saved!', 'success'); $this->redirect('/address'); } elseif ($this->request->is_ajax()) { $item['success'] = false; $item['error'] = $error; header('Content-type: application/json'); die(json_encode($item)); } $form->values($item); } $this->response->body($form->render($error)); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('security/companies/edit' . ($id ? '/' . $id : '')); $types = DB::select('id', 'name')->from('company_types')->execute()->as_array('id', 'name'); $form->add("name", 'Name', Form::STRING, '', array('not_empty'))->add('type', 'Company type', Form::SELECT, $types, array('not_empty')); $item = DB::select()->from('companies')->where('id', '=', $id)->execute()->current(); $form->values($item); if ($_POST) { $value = $form->filter($_POST); if (!$form->validate($value)) { if ($id) { DB::update('companies')->set($value)->where('id', '=', $id)->execute(); } else { DB::insert('companies', array_keys($value))->values(array_values($value))->execute(); } Messages::save('Company successfully saved!', 'success'); $this->redirect('/security/companies'); } } $this->response->body($form->render()); }
public function action_edit() { $id = $this->request->param('id'); $form = new Form('companies/edit' . ($id ? '/' . $id : '')); $form->add("name", 'Name', Form::STRING, '', array('not_empty')); $item = DB::select()->from('companies')->where('id', '=', $id)->execute()->current(); $form->values($item); if ($_POST) { $value = $form->filter($_POST); if (!$form->validate($value)) { Database::instance()->begin(); if ($id) { DB::update('companies')->set(array('name' => $value['name']))->where('id', '=', $id)->execute(); } else { $id = Arr::get(DB::insert('companies', array('name'))->values(array($value['name']))->execute(), 0); } Database::instance()->commit(); $value['id'] = $id; $value['success'] = true; die(json_encode($value)); } } $this->response->body($form->render()); }
$netstat .= " | /usr/bin/head -n {$_REQUEST['limit']}"; } echo htmlspecialchars_decode(shell_exec($netstat)); exit; } $pgtitle = array(gettext("Diagnostics"), gettext("Routes")); $shortcut_section = "routing"; include 'head.inc'; $form = new Form(false); $form->addGlobal(new Form_Input('isAjax', null, 'hidden', 1)); $section = new Form_Section('Routing Table Display Options'); $section->addInput(new Form_Checkbox('resolve', 'Resolve names', 'Enable', $resolve))->setHelp('Enabling name resolution may cause the query to take longer.' . ' It can be stopped at any time by clicking the Stop button in the browser.'); $validLimits = array('10', '50', '100', '200', '500', '1000', 'all'); $section->addInput(new Form_Select('limit', 'Rows to display', $limit, array_combine($validLimits, $validLimits))); $section->addInput(new Form_Input('filter', 'Filter', 'text', $host))->setHelp('Use a regular expression to filter the tables.'); $form->add($section); $form->addGlobal(new Form_Button('Submit', 'Update', null, 'fa-refresh'))->addClass('btn-primary'); print $form; ?> <script type="text/javascript"> //<![CDATA[ function update_routes(section) { $.ajax( '/diag_routes.php', { type: 'post', data: $(document.forms[0]).serialize() +'&'+ section +'=true', success: update_routes_callback, }); }
<?php if (!user_connected()) { include PATH_LIB . 'form.php'; $form_reset_pwd = new Form('form_reset_pwd'); $form_reset_pwd->method('POST'); $form_reset_pwd->add('Text', 'email_adress')->label('Votre adresse e-mail'); $form_reset_pwd->add('Submit', 'submit')->value('Envoyer informations'); //errors and message arrays $error_reset_pwd = array(); $msg_confirm = array(); //operations on the reset form if ($form_reset_pwd->is_valid($_POST)) { $email_addr = $form_reset_pwd->get_cleaned_data('email_adress'); $user_id = find_user_id($email_addr); if ($user_id !== false) { $new_pwd = gen_new_pwd(); //generate a new password update_password_user($user_id, $new_pwd); //update the modification $msg_confirm[] = "Mot de passe réinitialisé avec succès, vous recevrez prochainement un mél avec vos différentes informations de connexion. Attention pensez à changer le nouveau mot de passe pour le retenir plus facilement."; $infos_user = read_infos_user($user_id); // Preparation du mail $message_mail = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"> </head><body> <p>Nouveau mot de passe <b>NabzFood</b>.</p> <p>Vous avez demandé à changer votre mot de passe pour le site Nabzfood, ce mél est la confirmation que tout s'est bien passé.</p><p>Vos nouvelles informations de connexion : </p><p>Login : "******"</p><p>Mot de passe : " . $new_pwd . "</p>"; if (!empty($infos_user['hash_validation'])) { print_r($infos_user); $hash_validation = $infos_user['hash_validation']; $message_mail .= "<p>Lien pour valider votre compte : <a href=\"http:\\//" . $_SERVER['PHP_SELF'] . "?module=members&action=valid_account&hash=" . $hash_validation . "\">ce lien</a> pour activer votre compte !</p>"; } //end of empty hash_validation $message_mail .= "</body></html>";
$section->addInput(new Form_Select('type', 'IPv4 Configuration Type', $pconfig['type'], $types4)); $section->addInput(new Form_Select('type6', 'IPv6 Configuration Type', $pconfig['type6'], $types6)); $macaddress = new Form_Input('mac', 'MAC Address', 'text', $pconfig['mac'], ['placeholder' => 'xx:xx:xx:xx:xx:xx']); $btnmymac = new Form_Button('btnmymac', 'Copy My MAC'); $btnmymac->removeClass('btn-primary')->addClass('btn-success btn-sm'); $group = new Form_Group('MAC controls'); $group->add($macaddress); // $group->add($btnmymac); $group->setHelp('This field can be used to modify ("spoof") the MAC address of this interface.' . '<br />' . 'Enter a MAC address in the following format: xx:xx:xx:xx:xx:xx or leave blank'); $section->add($group); $section->addInput(new Form_Input('mtu', 'MTU', 'number', $pconfig['mtu']))->setHelp('If you leave this field blank, the adapter\'s default MTU will be used. ' . 'This is typically 1500 bytes but can vary in some circumstances.'); $section->addInput(new Form_Input('mss', 'MSS', 'number', $pconfig['mss']))->setHelp('If you enter a value in this field, then MSS clamping for TCP connections to the value entered above minus 40 (TCP/IP ' . 'header size) will be in effect.'); if (count($mediaopts_list) > 0) { $section->addInput(new Form_Select('mediaopt', 'Speed and Duplex', rtrim($mediaopt_from_config), build_mediaopts_list()))->setHelp('Here you can explicitly set speed and duplex mode for this interface.' . '<br />' . 'WARNING: You MUST leave this set to autoselect (automatically negotiate speed) unless the port this interface connects to has its speed and duplex forced.'); } $form->add($section); $section = new Form_Section('Static IPv4 configuration'); $section->addClass('staticv4'); $section->addInput(new Form_IpAddress('ipaddr', 'IPv4 Address', $pconfig['ipaddr']))->addMask('subnet', $pconfig['subnet'], 32); $group = new Form_Group('IPv4 Upstream gateway'); $group->add(new Form_Select('gateway', 'IPv4 Upstream Gateway', $pconfig['gateway'], build_gateway_list())); $group->add(new Form_Button('addgw', 'Add a new gateway'))->removeClass('btn-primary')->setAttribute('data-target', '#newgateway')->setAttribute('data-toggle', 'modal'); $group->setHelp('If this interface is an Internet connection, select an existing Gateway from the list or add a new one using the "Add" button.' . '<br />' . 'On local LANs the upstream gateway should be "none".' . gettext('You can manage gateways by ') . '<a target="_blank" href="system_gateways.php">' . gettext(" clicking here") . '</a>'); $section->add($group); $form->add($section); // Add new gateway modal pop-up $modal = new Modal('New gateway', 'newgateway', 'large'); $modal->addInput(new Form_Checkbox('defaultgw', 'Default', 'Default gateway', $if == "wan" || $if == "WAN")); $modal->addInput(new Form_Input('name', 'Gateway name', 'text', $wancfg['descr'] . "GW")); $modal->addInput(new Form_IpAddress('gatewayip', 'Gateway IPv4', null)); $modal->addInput(new Form_Input('gatewaydescr', 'Description', 'text'));
$js_array = array(); // Now loop through all of the fields defined in the XML foreach ($pkg['fields']['field'] as $pkga) { $action = ""; $uid = ""; if ($pkga['type'] == "sorting") { continue; } // Generate a new section if ($pkga['type'] == "listtopic") { if (isset($pkga['advancedfield']) && isset($advfield_count)) { $advanced->addInput(new Form_StaticText(strip_tags($pkga['name']), null)); $advfield_count++; } else { if (isset($section)) { $form->add($section); } if (isset($pkga['collapse'])) { $uid = uniqid("section"); $action = COLLAPSIBLE; if ($pkga['collapse'] == "open") { $action |= SEC_OPEN; } else { $action |= SEC_CLOSED; } } $section = new Form_Section(strip_tags($pkga['name']), $uid, $action); } continue; } // 'begin' starts a form group. ('end' ends it)
<?php if (!user_admin()) { include PATH_GLOBAL_VIEW . 'error_not_admin.php'; } else { require_once PATH_MODEL . 'admin.php'; require_once PATH_MODEL . 'nabz.php'; require_once PATH_LIB . "nabz_lib.php"; require_once PATH_LIB . "form.php"; $form_mail_nabz = new Form('form_mail_nabz'); $form_mail_nabz->method('POST'); $form_mail_nabz->add('Textarea', 'mail_content')->label('Message')->cols(100)->rows(20); $form_mail_nabz->add('Select', 'lang_select')->label('Langue')->choices('Français', 'Anglais'); $form_mail_nabz->add('Submit', 'Envoyer'); if ($form_mail_nabz->is_valid($_POST)) { $message = $_POST['mail_content']; //dont use get_cleaned because it loose the aspect of the txt //Messages in different languages $lang = $form_mail_nabz->get_cleaned_data('lang_select'); if ($lang != 'Français') { $lang = "us"; } else { $lang = "fr"; } $tbx = list_all_rabbits(); foreach ($tbx as $key => $value) { $nabz_serial = $tbx[$key]['rabbit_serial']; $nabz_token = $tbx[$key]['rabbit_token']; //Send message with lib+API $nabaztag = new Nabaztag($nabz_serial, $nabz_token, $lang); $nabaztag->dire($message);
$disableMenu = true; $auth = new auth("OBJ_USAGE"); $page = new page("Object Usage"); // start processing $oid = value("oid", "NUMERIC"); $objFolder = getDBCell("content", "CATEGORY_ID", "CID={$oid}"); //// ACL Check //// $aclf = aclFactory($objFolder, "folder"); $aclf->load(); if (!$aclf->checkAccessToFunction("OBJ_USAGE")) { header("Location: " . $c["docroot"] . "modules/common/noaccess.php?sid={$sid}&guid={$pnode}"); } //// ACL Check //// $form = new Form("Object: " . $objectName, ""); $form->width = 250; $form->add(new Label("lbl", "The object {$objectName} is used in following pages...", "informationheader", 2)); // Initializing Array $clusters = array(); // Determine cluster_templates using the object as static content... $sql = "SELECT CLT_ID FROM cluster_template_items WHERE FKID = {$oid}"; $query = new query($db, $sql); while ($query->getrow()) { // Determine clusters using this template $sql = "SELECT CLNID FROM cluster_node WHERE CLT_ID = " . $query->field("CLT_ID"); $subquery = new query($db, $sql); while ($subquery->getrow()) { array_push($clusters, $subquery->field("CLNID")); } $subquery->free(); } $query->free();
//only display this page if user is connected if (!user_connected() || !verify_get_id($_GET['id'], $_SESSION['id'])) { include PATH_GLOBAL_VIEW . 'error_not_connected.php'; } else { include PATH_LIB . 'form.php'; //extract infos about the nabz //$infos_nabz = read_infos_nabz($_GET['id']); //Edit infos form $form_edit_infos = new Form('form_edit_infos'); $form_edit_infos->method('POST'); $form_edit_infos->add('Email', 'email_addr')->label('Votre adresse e-mail')->Required(false)->value($_SESSION['email']); $form_edit_infos->add('Submit', 'submit')->initial('Modifier ces informations'); //Edit password form $form_edit_password = new Form('form_edit_password'); $form_edit_password->method('POST'); $form_edit_password->add('Password', 'old_password')->label('Votre ancien mot de passe'); $form_edit_password->add('Password', 'new_password')->label('Votre nouveau mot de passe'); $form_edit_password->add('Password', 'verif_new_password')->label('Confirmation nouveau mot de passe'); $form_edit_password->add('Submit', 'submit')->initial('Modifier mon mot de passe'); //Errors array $errors_form_infos = array(); $errors_form_password = array(); //Message array if (!empty($_POST['message'])) { $msg_confirm = $_POST['message']; } //Retrieve the message confirmation if is not empty if ($form_edit_infos->is_valid($_POST)) { $email_addr = $form_edit_infos->get_cleaned_data('email_addr'); //user wants to update his email if (!empty($email_addr)) {
} if ($cbwww == "1" && reg_load("SYSTEM/MAINTENANCE/WWW") != "1") { switchToMaintenanceMode("live"); } if ($cbwwwdev == "" && reg_load("SYSTEM/MAINTENANCE/WWWDEV") == "1") { disableMaintenanceMode("dev"); } if ($cbwww == "" && reg_load("SYSTEM/MAINTENANCE/WWW") == "1") { disableMaintenanceMode("live"); } reg_save("SYSTEM/MAINTENANCE/WWWDEV", $cbwwwdev); reg_save("SYSTEM/MAINTENANCE/WWW", $cbwww); reg_save("SYSTEM/MAINTENANCE/BB", $cbbb); } else { $cbwwwdev = reg_load("SYSTEM/MAINTENANCE/WWWDEV"); $cbwww = reg_load("SYSTEM/MAINTENANCE/WWW"); $cbbb = reg_load("SYSTEM/MAINTENANCE/BB"); } $page->tipp = $lang->get("maint_descr", "Maintenance mode displays a 'Page under maintance' message for the development or the live-website. <br>You can also switch the whole backend into maintenance mode. Then only the user ADMINISTRATOR can log in!"); $form = new Form($lang->get("maint_mode", "Maintenance Mode")); $form->add(new Label("lbl", $lang->get("maint_bb", "Backend Maintenance"), "standard")); $form->add(new Checkbox("cbbb", "1", "standard", $cbbb)); $form->add(new Label("lbl", $lang->get("maint_www", "Live Website Maintenance"), "standard")); $form->add(new Checkbox("cbwww", "1", "standard", $cbwww)); $form->add(new Label("lbl", $lang->get("maint_wwwdev", "Dev Website Maintenance"), "standard")); $form->add(new Checkbox("cbwwwdev", "1", "standard", $cbwwwdev)); $form->add(new Hidden("processing", "yes")); $form->add(new Spacer(2)); $form->add(new FormButtons(true, true)); $page->add($form); $page->draw();
function filter_form_vpn() { global $filter_active, $rawfilter, $filterfieldsarray, $filtertext, $filterlogentries_qty, $nentries, $Include_Act, $interfacefilter; global $logfile; global $system_logs_filter_form_hidden; if ($filter_active) { $panel_state = 'in'; $panel_body_state = SEC_OPEN; } else { if ($system_logs_filter_form_hidden) { $panel_state = 'out'; $panel_body_state = SEC_OPEN; } else { $panel_state = 'in'; $panel_body_state = SEC_CLOSED; } } if (!$rawfilter) { // Advanced log filter form $form = new Form(false); $form->setAttribute('id', 'filter-form')->addClass('collapse ' . $panel_state); $section = new Form_Section('Advanced Log Filter', 'filter-panel', COLLAPSIBLE | $panel_body_state); if ($logfile == "vpn") { $group = new Form_Group(''); $group->add(new Form_Input('filterlogentries_time', null, 'text', $filterfieldsarray['time']))->setWidth(3)->setHelp('Time'); $group->add(new Form_Input('filterlogentries_action', null, 'text', $filterfieldsarray['action']))->setWidth(3)->setHelp('Action'); $group->add(new Form_Input('filterlogentries_qty', null, 'number', $filterlogentries_qty, ['placeholder' => $nentries]))->setWidth(2)->setHelp('Quantity'); $section->add($group); $group = new Form_Group(''); $group->add(new Form_Input('filterlogentries_user', null, 'text', $filterfieldsarray['user']))->setWidth(3)->setHelp('User'); $group->add(new Form_Input('filterlogentries_ip_address', null, 'text', $filterfieldsarray['ip_address']))->setWidth(4)->setHelp('IP Address'); } else { $group = new Form_Group(''); $group->add(new Form_Input('filterlogentries_time', null, 'text', $filterfieldsarray['time']))->setWidth(3)->setHelp('Time'); $group->add(new Form_Input('filterlogentries_type', null, 'text', $filterfieldsarray['type']))->setWidth(2)->setHelp('Type'); $group->add(new Form_Input('filterlogentries_pid', null, 'text', $filterfieldsarray['pid']))->setWidth(2)->setHelp('PID'); $group->add(new Form_Input('filterlogentries_qty', null, 'number', $filterlogentries_qty, ['placeholder' => $nentries]))->setWidth(2)->setHelp('Quantity'); $section->add($group); $group = new Form_Group(''); $group->add(new Form_Input('filterlogentries_message', null, 'text', $filterfieldsarray['message']))->setWidth(7)->setHelp('Log Message'); } $btnsubmit = new Form_Button('filterlogentries_submit', ' ' . gettext('Apply Filter'), null, 'fa-filter'); } else { // Simple log filter form $form = new Form(false); $form->setAttribute('id', 'filter-form')->addClass('collapse ' . $panel_state); $section = new Form_Section('Log Filter', 'filter-panel', COLLAPSIBLE | $panel_body_state); $group = new Form_Group(''); $group->add(new Form_Input('filtertext', null, 'text', $filtertext))->setWidth(6)->setHelp('Filter Expression'); $group->add(new Form_Input('filterlogentries_qty', null, 'number', $filterlogentries_qty, ['placeholder' => $nentries]))->setWidth(2)->setHelp('Quantity'); $btnsubmit = new Form_Button('filtersubmit', ' ' . gettext('Apply Filter'), null, 'fa-filter'); } $btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm'); $group->add(new Form_StaticText('', $btnsubmit)); $group->setHelp('<a target="_blank" href="http://www.php.net/manual/en/book.pcre.php">' . gettext('Regular expression reference') . '</a> ' . gettext('Precede with exclamation (!) to exclude match.')); $section->add($group); $form->add($section); print $form; }