function error($msg, $url) { parent::error($msg); //if there are no customer id, then the error will go back to the original page if ($url == "") { echo "<input type='button' value='Back' onclick=\"handleEvent('location.php')\">"; } else { echo "<input type='button' value='Back' onclick=\"handleEvent('" . $url . "')\">"; } }
function error($msg, $id = '') { parent::error($msg); //if there are no customer id, then the error will go back to the original page if ($id == "") { echo "<input type='button' value='Back' onclick=\"handleEvent('configurations.php')\">"; } else { echo "<input type='button' value='Back' onclick=\"handleEvent('configurations.php?action=edit&ID={$id}')\">"; } }
/** * Check the submitted value of the input * * @param Form $form The form the input is associated with * * @return boolean true if the uploaded files are correct, else false */ public function check(&$form = null) { if (empty($this->errorAt)) { $this->errorAt = $this->name; } $basename = preg_replace("/^(\\w+)(\\[.*)?\$/", "\$1", $this->name); $upload = Upload::getInstance($basename); if ($this->required && !$upload) { // No file were uploaded $form->error($this->errorAt, Lang::get('form.required-field')); return false; } if ($upload && $this->extensions) { foreach ($upload->getFiles() as $file) { if (!in_array($file->extension, $this->extensions)) { // One of the uploaded files has no good extension $form && $form->error($this->errorAt, Lang::get('form.invalid-file-extension')); return false; } } } return true; }
/** * @abstract Add a new page * @access public */ public function add() { $form = new Form('pages'); // process the form if submitted if ($form->isSubmitted()) { $form->setCurrentValue('page_sort_order', $model->quickValue('SELECT MAX(page_sort_order) FROM pages', 'MAX(page_sort_order)') + 1); // form field validation if (!$form->isFilled('page_title')) { $form->addError('page_title', 'You must enter a page title.'); } // if we have no errors, save the record if (!$form->error()) { // set the link text field to the page title if blank if (!$form->isFilled('page_link_text')) { $form->setCurrentValue('page_link_text', $form->cv('page_title')); } return $form->save(); } } return false; }
</div> </div> <div class="form-group<?php echo Form::has_error('category_id', $errors); ?> "> <?php echo TB_Form::label_required(__('publications.category')); ?> <div class="col-sm-10"> <?php echo $sel_category; ?> <?php echo Form::error('category_id', $errors); ?> </div> </div> <div class="form-group"> <?php echo TB_Form::label(__('publications.page_text_preview')); ?> <div class="col-sm-10"> <?php echo Editor::CK('text_short', $obj->text_short, ['class' => 'form-control', 'rows' => 6], 'preview'); ?> </div> </div>
<?php echo Form::error('thumbnail', $err); ?> </div> </div> <div class="form-group"> <?php echo Form::label(__('common.info'), 'info', array('class' => 'col-sm-2 control-label')); ?> <div class="col-sm-9"> <?php echo Form::textarea('info', Input::post('info'), array('class' => 'form-control', 'rows' => 4)); ?> <?php echo Form::error('info', $err); ?> </div> </div> <div class="form-group"> <?php echo Form::label('', 'display', array('class' => 'col-sm-2 control-label')); ?> <div class="col-sm-6 checkbox"> <label> <?php if (Input::method() != 'POST') { echo Form::checkbox('active', true, true); } else { echo Form::checkbox('active', true, Input::post('active') == true);
function displayDevice($devices) { //global all variables global $deviceKey, $deviceForm, $tool, $headings, $titles, $deviceTypes, $location; //if this isn't in ajax mode display the Ajax buttons if (!isset($_GET['mode'])) { if ($_GET['tab'] == 2) { $name = array($devices->get_name(), "Interface", "Device Control.first."); } else { if ($_GET['tab'] == 1) { $name = array($devices->get_name(), "Interface.first.", "Device Control"); } else { $name = array($devices->get_name() . ".first.", "Interface", "Device Control"); } } $page = array("devices.php?action=showID&ID={$_GET['ID']}&mode=deviceInfo", "devices.php?action=showID&ID={$_GET['ID']}&mode=deviceInterface", "devices.php?action=showID&ID={$_GET['ID']}&mode=deviceControl"); echo $tool->createNewButtons($name, "devicePart", $page); } //the division for the interfae, control port, and info page to show echo "<div id='devicePart'>"; //success message for the ajax mode switch (success) { case $_GET['update']: $deviceForm->success("Updated successfully"); break; case $_GET['add']: $deviceForm->success("Added new data successfully"); break; case $_GET['delete']: $deviceForm->success("Deleted and archived data successfully"); break; } //if ajax mod is part of displaying the interface if ($_GET['mode'] == deviceInterface || $_GET['tab'] == 1) { //set the table attributes $deviceForm->setCols(11); $deviceForm->setTableWidth("100%"); $deviceForm->setTitleWidth("10%"); //create tools for this mode /*Taken out for user interface issues $toolNames = array("All Devices", "All Archived Device"); $toolIcons = array("devices", "devices"); $toolHandlers = array("handleEvent('devices.php')", "handleEvent('devices.php?action=showArchived')"); echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);*/ //can be displayed in both percent and bPS mode if ($_GET['output'] == percent) { $headings = array("Interface name", "Interface alias", "Interface description", "Status", "Discovered interface speed(bps)", "Current throughput in % \n\t\t\t\t\t\t <a href='#' style='color:yellow;' onclick=\"handleEvent('devices.php?action=showID&ID={$_GET['ID']}&output=bps&tab=1');\">[switch to bps] </a>", "Interface MTU", "IPv4/IPv6 address", "Interface duplex", "Interface type", "Discovered interface index"); } else { $headings = array("Interface name", "Interface alias", "Interface description", "Status", "Discovered interface speed(bps)", "Current throughput in bps\n\t\t\t\t\t\t\t <a href='#' style='color:yellow;' onclick=\"handleEvent('devices.php?action=showID&ID={$_GET['ID']}&output=percent&tab=1');\">[switch to percent] </a>", "Interface MTU", "IPv4/IPv6 address", "Interface duplex", "Interface type", "Discovered interface index"); } //get all the interfacese $interfaces = $devices->get_interfaces(); $info = array(); $title = array(); $handlers = array(); //put all the interface information into the arrays foreach ($interfaces as $id => $value) { //array_push($title, ""); array_push($title, $value->get_name() . '//' . $value->get_interface_id() . '//' . $value->get_device_id()); array_push($info, $value->get_alias()); array_push($info, $value->get_descr()); array_push($info, $value->get_oper_status()); $speed = $tool->calculator("convertBits", $value->get_speed()); array_push($info, $speed); //calculate the percentage if it's in percent mode, otherwise convert it in to the right bits if ($value->get_inbits() > $value->get_outbits()) { $highBits = $value->get_inbits(); } else { $highBits = $value->get_outbits(); } if ($_GET['output'] == percent) { if ($value->get_speed() > 0) { $percentage = $highBits / $value->get_speed(); $percentage = $tool->calculator("convertPercent", $percentage); } else { $percentage = "0%"; } array_push($info, $percentage); } else { $highBits = $tool->calculator("convertBits", $highBits); array_push($info, $highBits); } array_push($info, $value->get_mtu()); $ipv4 = $value->get_ipv4_addresses(); $ipv6 = $value->get_ipv6_addresses(); $ip = ""; //store both ipv4 and ipv6 addresses foreach ($ipv4 as $ipID => $ipValue) { $ip .= $ipID . "<br/>"; } foreach ($ipv6 as $ipID => $ipValue) { $ip .= $ipID . "<br/>"; } array_push($info, $ip); array_push($info, ""); array_push($info, $value->get_type()); array_push($info, $value->get_ifindex()); //prepare strings into html format to display the graph and push it into the handler $nameTitle = str_replace(" ", "%20", $value->get_name()); $name = str_replace(" ", "-", $value->get_name()); $name = str_replace("/", "-", $name); $graphLink = "rrdgraph.php?file=deviceid" . $value->get_device_id() . "_" . $name . ".rrd&title=" . $nameTitle . "---Bits%20Per%20Second&type=traffic"; array_push($handlers, $graphLink); } //If there are info, display the interfaces, else give a warniing message if (count($info) > 0) { echo $deviceForm->showAll($headings, $title, $info, $handlers, 3); } else { $deviceForm->warning("You have no Interfaces"); } } elseif ($_GET['mode'] == deviceControl || $_GET['tab'] == 2) { //set the form attributes $deviceForm->setCols(7); /*check if the device type is a power or console device *if it is a control or console device, the user can add both management and control port *Otherwise the user can only add management ports */ //if ($devices->get_device_type()==5 || $devices->get_device_type()==6) if ($devices->get_device_class() == 'console_server' || $devices->get_device_class() == 'power_control') { $cPorts = array(); if ($_SESSION['access'] >= 50) { $toolNames = array("New management port.tip.Management Ports are ports that help you manage this device using power or console ports.", "New control port.tip.Control ports are ports that help you manage connected devices. Examples are power ports on remote power controls and serial ports on console servers."); $toolIcons = array("add", "add"); $toolHandlers = array("return LoadPage('devices.php?action=add&item=mPort&mode=deviceControl&ID={$_GET['ID']}', 'devicePart');", "return LoadPage('devices.php?action=add&item=cPort&mode=deviceControl&ID={$_GET['ID']}&deviceClass=" . $devices->get_device_class() . "', 'devicePart');"); } } else { if ($_SESSION['access'] >= 50) { $toolNames = array("New management port.tip.Management Ports are ports that help you manage this device using power or console ports."); $toolIcons = array("add"); $toolHandlers = array("return LoadPage('devices.php?action=add&item=mPort&mode=deviceControl&ID={$_GET['ID']}', 'devicePart');"); } } //create the tool echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); //create the headings titles and info emptyy arrays for both management and control ports $cHeadings = array("Description", "Physical port", "Port name", "Port type", "Group", "Managed device", "Action"); $mHeadings = array("Description", "Physical port", "Port name", "Port type", "Group", "Control device", "Action"); $cTitles = array(); $mTitles = array(); $cInfo = array(); $mInfo = array(); //get all the control and management ports to store in an array for display $management = $devices->get_management_ports(); $control = $devices->get_control_ports(); $mPorts = array(); $index = 0; //insert the ports into an array foreach ($management as $id => $value) { $mPorts[$index] = new ControlPort($id); $index++; } foreach ($control as $id => $value) { $cPorts[$index] = new ControlPort($id); $index++; } //push the info of these ports into the table foreach ($mPorts as $id => $value) { array_push($mTitles, $mPorts[$id]->get_description()); } if (isset($cPorts)) { foreach ($cPorts as $id => $value) { array_push($cTitles, $cPorts[$id]->get_description()); } } foreach ($mPorts as $id => $value) { array_push($mInfo, $mPorts[$id]->get_port()); array_push($mInfo, $mPorts[$id]->get_name()); array_push($mInfo, $mPorts[$id]->get_type()); array_push($mInfo, $mPorts[$id]->get_group()); array_push($mInfo, $mPorts[$id]->get_control_device_name()); $portID = $mPorts[$id]->get_id(); if ($_SESSION['access'] >= 50) { array_push($mInfo, "<a href='#' onclick=\"return LoadPage('devices.php?action=edit&ID={$_GET['ID']}&mode=deviceControl&mportID={$id}&portID={$portID}', 'devicePart');\">Edit</a> | <a href='#' onclick=\"handleEvent('devices.php?action=remove&ID={$_GET['ID']}&mportID={$id}&portID={$portID}');\">Delete</a>"); } else { array_push($mInfo, 'No Access'); } } if (isset($cPorts)) { foreach ($cPorts as $id => $value) { array_push($cInfo, $cPorts[$id]->get_port()); array_push($cInfo, $cPorts[$id]->get_name()); array_push($cInfo, $cPorts[$id]->get_type()); array_push($cInfo, $cPorts[$id]->get_group()); array_push($cInfo, $cPorts[$id]->get_managed_device_name()); $portID = $cPorts[$id]->get_id(); if ($_SESSION['access'] >= 50) { array_push($cInfo, "<a href='#' onclick=\"return LoadPage('devices.php?action=edit&ID={$_GET['ID']}&mode=deviceControl&cportID={$id}&portID={$portID}', 'devicePart');\">Edit</a> | <a href='#' onclick=\"handleEvent('devices.php?action=remove&ID={$_GET['ID']}&cportID={$id}&portID={$portID}');\">Delete</a>"); } else { array_push($cInfo, 'No Access'); } } } //if the user is editting this information, make it all editable if ($_GET['action'] == edit) { $deviceForm->setCols(2); $fieldType = array("hidden", "", "", "", "static", "", "drop_down"); //checks to see if it's management or control ports to give different forms if (isset($_GET['mportID'])) { $name = $devices->get_name(); $headings = array("Port Information for " . $name); $titles = array("pType", "Description.tip.A descriptive name for this connection, i.e. \"console connection for router1, routing engine 2\" or \"Remote power cycle group for router1\"", "Physical port.tip.Which port is this device physically connected to", "Port name.tip.Name of port. This will also be the name used for scripts", "Port type", "Group", "Control device"); $group = $mPorts[$_GET['mportID']]->get_group(); if ($group == '') { $fieldType = array("hidden", "", "", "", "static", "static", "drop_down"); $group = "NOT APPLICABLE"; } $info = array("mport", $mPorts[$_GET['mportID']]->get_description(), $mPorts[$_GET['mportID']]->get_port(), $mPorts[$_GET['mportID']]->get_name(), $mPorts[$_GET['mportID']]->get_type(), $group, $mPorts[$_GET['mportID']]->get_control_device_name()); if ($mPorts[$_GET['mportID']]->get_type() == "console") { $portTypeName = "console_server"; } else { $portTypeName = "power_control"; } $types = $devices->get_devices_by_class($portTypeName); $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "group", "controlledDevice"); } else { if (isset($_GET['cportID'])) { $name = $devices->get_name(); $headings = array("Port Information for " . $name); $titles = array("pType", "Description.tip.A descriptive name for this connection, i.e. \"console connection for router1, routing engine 2\" or \"Remote power cycle group for router1\"", "Physical port.tip.Which port is this device physically connected to", "Port name.tip.Name of port. This will also be the name used for scripts", "Port type", "Group", "Managed device.tip.Select a device or select \"Other Device\" if you want to manage a device that is not in the database. If you select \"Other Device\" please make sure to have a good port description."); $group = $cPorts[$_GET['cportID']]->get_group(); if ($group == '') { $fieldType = array("hidden", "", "", "", "static", "static", "drop_down"); $group = "NOT APPLICABLE"; } $info = array("cport", $cPorts[$_GET['cportID']]->get_description(), $cPorts[$_GET['cportID']]->get_port(), $cPorts[$_GET['cportID']]->get_name(), $cPorts[$_GET['cportID']]->get_type(), $group, $cPorts[$_GET['cportID']]->get_managed_device_name()); $types = $devices->get_devices(); array_push($types, "Other devices"); $deviceKey = array("pType", "description", "physicalPort", "portName", "portType", "group", "managedDevice"); } } $deviceForm->setFieldType($fieldType); echo $deviceForm->editPortForm($headings, $titles, $info, $deviceKey, $types); } else { if ($_GET['action'] == showID) { //show the ports if (isset($cPorts)) { echo "<div style='clear:both;'></div><h2>Control Ports</h2>"; echo $deviceForm->showAll($cHeadings, $cTitles, $cInfo); } if (isset($mPorts)) { echo "<div style='clear:both;'></div><h2>Management Ports</h2>"; echo $deviceForm->showAll($mHeadings, $mTitles, $mInfo); } if (!isset($mPorts) && !isset($cPorts)) { $deviceForm->warning("You have no Ports"); } } } } else { $deviceForm->setCols(2); //make the tool bar for this page if ($_SESSION['access'] >= 50) { $toolNames = array("Edit Device", "Delete Device"); $toolIcons = array("edit", "delete"); $toolHandlers = array("handleEvent('devices.php?action=edit&ID={$_GET['ID']}');", "handleEvent('devices.php?action=remove&ID={$_GET['ID']}')"); } echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers); //make the headings $headings = array("Device Information"); //store all the device information values into an array $info = array($devices->get_name(), $devices->get_device_fqdn(), $devices->get_location_name(), $devices->get_type_name(), $devices->get_snmp_ro(), $devices->get_device_oob(), $devices->get_notes()); //if the user is editting this information, make it all editable if ($_GET['action'] == edit) { $deviceKey = array("name", "device_fqdn", "location", "device_type", "SNMP Community String.tip.Read only SNMP community used for SNMP data collection", "device_oob", "notes"); $fieldType = array("", "", "drop_down", "drop_down", "", "", "text_area"); $deviceForm->setFieldType($fieldType); $type = array($location, $deviceTypes); echo $deviceForm->editDeviceForm($headings, $titles, $info, $deviceKey, $type); } elseif ($_GET['action'] == showID) { //store all the device information values into an array $info = array($devices->get_name(), $devices->get_device_fqdn(), $devices->get_location_name(), $devices->get_type_name(), $devices->get_snmp_ro(), $devices->get_device_oob(), nl2br($devices->get_notes())); echo $deviceForm->showDeviceForm($headings, $titles, $info); // Everything below is for viewing & edditing Private Data for this device. $modalForms = ""; echo "<div style='clear:both;'></div>"; echo "<h2>Private Data</h2>"; // Here we check if we just deleted a private data entry if (isset($_POST['delete_private_data'])) { $form = new Form(); // Yes update $privDataObj = new PrivateData($_POST['private_data_id']); if ($privDataObj->delete($_POST['group_pass'])) { $form->success("Private entry Deleted"); $_SESSION['action'] = "Removed private data for: " . $devices->get_name(); } else { $form->error("Warning: Failed to delete Private data Reason: " . $privDataObj->get_error(), $_GET['ID']); unset($_POST['group_pass']); } } // Check if we just added a private data Type if (isset($_POST['add_private_data_type'])) { $form = new Form(); $no_error = true; // Check mandotry fields if ($_POST['pdtype_name'] == '') { $form->error("Error: Private DataType name is empty"); $no_error = false; } elseif ($_POST['pdtype_desc'] == '') { $form->error("Error: Private DataType Description is empty"); $no_error = false; } if ($no_error) { $privDataTypeObj = new PrivateDataType(); $privDataTypeObj->set_name($_POST['pdtype_name']); $privDataTypeObj->set_desc($_POST['pdtype_desc']); if ($privDataTypeObj->insert()) { $form->success("Private data type '" . $_POST['pdtype_name'] . "' Added"); $_SESSION['action'] = "Added private data Type"; } else { $form->error("Warning: Failed to Add Private data Reason: " . $privDataTypeObj->get_error()); } } } // Check if we just added a private data entry if (isset($_POST['add_private_data_for_group'])) { $form = new Form(); $no_error = true; // Check mandotry fields if (!is_numeric($_POST['device_id'])) { $form->error("Error: Invalid device id"); $no_error = false; } elseif (!is_numeric($_POST['group_id'])) { $form->error("Error: No Group Specified"); $no_error = false; } elseif (!is_numeric($_POST['private_data_type'])) { $form->error("Error: No Private Data type specified"); $no_error = false; } elseif ($_POST['private_data_password'] == '') { $form->error("Warning: Private Data string was empty"); //$no_error = false; } if ($no_error) { $privDataObj = new PrivateData(); $privDataObj->set_group_id($_POST['group_id']); $privDataObj->set_type_id($_POST['private_data_type']); $privDataObj->set_device_id($_POST['device_id']); $privDataObj->set_notes($_POST['private_data_notes']); $privDataObj->set_name($_POST['private_data_desc']); $privDataObj->set_private_data($_POST['private_data_password']); if ($privDataObj->insert($_POST['group_pass'])) { $form->success("Private data entry Added"); $_SESSION['action'] = "Added private data for: " . $devices->get_name(); } else { $form->error("Warning: Failed to Add Private data Reason: " . $privDataObj->get_error(), $_GET['ID']); unset($_POST['group_pass']); } } } echo "<a name='modal' href='#Add_privatedata_modal'><img src='icons/Add.png' height=18>Add Private Data</a><br>"; // Add Modal for adding Private data types $modalForm = new Form("auto", 2); $modalForm->setHeadings(array("<br><br>Add Private Data Type")); $modalForm->setTitles(array("Name.tip.Descriptive String for this type", "Description")); $modalForm->setData(array("", "")); $modalForm->setDatabase(array("pdtype_name", "pdtype_desc")); // Change button text $modalForm->setUpdateValue("add_private_data_type"); $modalForm->setUpdateText("Add Private Data Type"); $modalForm->setModalID("add_pdtype_modal"); $private_data_type_modal = $modalForm->modalForm(); unset($modalForm); // End Modal for adding Private data types // Create modal for adding a new Private data entry // This modal should ask for which group to add it as and the password // We need to know all groups this user is in: $user = new User($_SESSION['userid']); $user_groups = $user->get_groups(); if (sizeof($user_groups) == 1) { foreach ($user_groups as $gid => $gname) { $group_data = $gname; } } else { $group_data = ""; } $modalForm = new Form("auto", 2); $modalForm->setHeadings(array("For which group would you like to add private")); $modalForm->setTitles(array("Group", "Group Password.tip.This is the shared secret for the group you selected above.", "Fill in Private Data Details below:", "Description", "Private Data<br><small>Stored encrypted</small>.tip.This is the data that will be encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>Add Private data type</a></small>", "Notes <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "device_id")); $modalForm->setData(array("{$group_data}", "", "", "", "", "", "", $_GET['ID'])); $modalForm->setDatabase(array("group_id", "group_pass", "dummy", "private_data_desc", "private_data_password", "private_data_type", "private_data_notes", "device_id")); $modalForm->setFieldType(array(0 => 'drop_down', 1 => 'password_autocomplete_off', 2 => 'static', 5 => 'drop_down', 6 => 'text_area', 7 => 'hidden')); // Drop down // We need to know all groups this user is in: $modalForm->setType($user_groups); $dataTypes = PrivateDataType::get_private_data_types(); $modalForm->setType($dataTypes); //End Dropdown // Change button text $modalForm->setUpdateValue("add_private_data_for_group"); $modalForm->setUpdateText("Add"); $modalForm->setModalID("Add_privatedata_modal"); echo $modalForm->modalForm(); unset($modalForm); // End modal // Also create a table with PrivateData // 1st get all entries for this device $all_private_data = PrivateData::get_private_data_by_device($_GET['ID']); // Only if there is any private data for this device if ($all_private_data && $_GET['action'] == showID) { $i++; // Check if we just updated the info, // If so we need to update Private data if (isset($_POST['update_private_data'])) { // Yes update $tmpform = new Form(); $privDataObj = new PrivateData($_POST['private_data_id']); $privDataObj->set_name($_POST['private_data_desc']); $privDataObj->set_notes($_POST['private_data_notes']); $privDataObj->set_type_id($_POST['private_data_type']); $privDataObj->set_private_data($_POST['private_data_password']); if ($privDataObj->update($_POST['group_pass'])) { $tmpform->success("Private data updated Succesfully"); unset($tmpform); $_SESSION['action'] = "Updated private data for: " . $devices->get_name(); } else { print "NOK " . $privDataObj->get_error(); $tmpform->error("Warning: Failed to Update Private data Reason: " . $privDataObj->get_error(), $_GET['ID']); } } // Placeholder for modal forms $heading = array("Type", "Description", "Private Data", "Group", "Actions"); $data = array(); foreach ($all_private_data as $id => $group_id) { $privDataObj = new PrivateData($id); // Only show tooltip when data is available // This is for type description if ($privDataObj->get_type_desc() != '') { $type_tooltip = ".tip.Private Data Type keyword:<br> " . $privDataObj->get_type_name(); } else { $type_tooltip = ""; } // This is for type name + Notes //if ($privDataObj->get_notes() != '') { // $name_tooltip = ".tip.<b>Notes:</b><br>".nl2br($privDataObj->get_notes()); //} else { // $name_tooltip = ""; //} // We also need to create a modal that will Ask the user for a password // We only need one per group, as passwords are unqiue per group $modalForm = new Form("auto", 2); $modalForm->setHeadings(array("Please provide group password for " . $privDataObj->get_group_name())); $modalForm->setTitles(array("Password", "group_id")); $modalForm->setData(array("", $privDataObj->get_group_id())); $modalForm->setDatabase(array('group_pass', 'group_id')); $modalForm->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden')); $myModalID = "modal_group_pass_" . $privDataObj->get_group_id(); // Change button text $modalForm->setUpdateValue("Decrypt_Private_Data"); $modalForm->setUpdateText("Submit"); $modalForm->setModalID($myModalID); $modalForms .= $modalForm->modalForm(); unset($modalForm); // End modal $name_tooltip = ""; // Here we check if the user submitted a group password // Only for the group for which the pasword has been provided if (isset($_POST['group_pass']) && $_POST['group_pass'] != '' && $privDataObj->get_group_id() == $_POST['group_id']) { // now get private data (password) $password = $privDataObj->get_private_data($_POST['group_pass']); if ($password != false) { // Decrypted successful! // This is for type name + Notes if ($privDataObj->get_notes($_POST['group_pass']) != '') { $name_tooltip = ".tip.<b>Notes:</b><br>" . nl2br($privDataObj->get_notes($_POST['group_pass'])); } // Get historical data, and create modal $modalForm = new Form("auto", 2); $modalForm->setHeadings(array("Changed (exipred) at:", "Private Data")); // Loop through old data and fill arrays for form $Htitles = array(); $Hdata = array(); $HfieldType = array(); $historical_passwords = $privDataObj->get_history($_POST['group_pass']); if ($historical_passwords) { foreach ($historical_passwords as $old_date => $old_data) { array_push($Htitles, $old_date); array_push($Hdata, $old_data); array_push($HfieldType, "static"); } } $modalForm->setTitles($Htitles); $modalForm->setData($Hdata); $modalForm->setFieldType($HfieldType); unset($Htitles); unset($Hdata); unset($HfieldType); $modalForm->setTitleWidth("40%"); $modalForm->setDatabase(array('date', 'old_data')); $myHistoryModalID = "modal_old_pass_" . $id; // Change button text $modalForm->setUpdateValue("close"); $modalForm->setUpdateText("Press cancel"); $modalForm->setModalID($myHistoryModalID); $modalForms .= $modalForm->modalForm(); unset($modalForm); // End modal // Now create a modal that allows us to update the private data object // Start Update Modal $PdataModal = new Form("auto", 2); $PdataModal->setHeadings(array("Update Private Data")); $PdataModal->setTitles(array("Description", "Private Data <br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "Type <br><small><a name='modal' href='#add_pdtype_modal'>Add Private data type</a></small>", "Notes<br><small><i>Stored encrypted</i></small>.tip.This data will be AES encrypted", "PDid", "", "")); $PdataModal->setData(array($privDataObj->get_name(), $password, $privDataObj->get_type_name(), $privDataObj->get_notes($_POST['group_pass']), $id, $_POST['group_id'], $_POST['group_pass'])); $PdataModal->setDatabase(array('private_data_desc', 'private_data_password', 'private_data_type', 'private_data_notes', 'private_data_id', 'group_id', 'group_pass')); $PdataModal->setFieldType(array(2 => 'drop_down', 3 => 'text_area', 4 => 'hidden', 5 => 'hidden', 6 => 'hidden')); // Creat dropdown $dataTypes = PrivateDataType::get_private_data_types(); $PdataModal->setType($dataTypes); $PdataModal->setUpdateValue('update_private_data'); $PdataModalID = "modal_private_data_id" . $id; // Change button text $PdataModal->setModalID($PdataModalID); $modalForms .= $PdataModal->modalForm(); // End Update modal // Now a Modal to Delete an Entry // We'll ask for the password again. $modalFormDelete = new Form("auto", 2); $modalFormDelete->setHeadings(array("Delete " . $privDataObj->get_name() . "<br>Please provide group password for " . $privDataObj->get_group_name())); $modalFormDelete->setTitles(array("Password", "group_id", "")); $modalFormDelete->setData(array("", $privDataObj->get_group_id(), $id)); $modalFormDelete->setDatabase(array('group_pass', 'group_id', 'private_data_id')); $modalFormDelete->setFieldType(array(0 => 'password_autocomplete_off', 1 => 'hidden', 2 => 'hidden')); $myDeleteModalID = "modal_delete_pass_" . $id; // Change button text $modalFormDelete->setUpdateValue("delete_private_data"); $modalFormDelete->setUpdateText("Delete"); $modalFormDelete->setModalID($myDeleteModalID); $modalForms .= $modalFormDelete->modalForm(); // End Delete modal if (count($historical_passwords) > 0) { $history_string = "<a name='modal' href='#" . $myHistoryModalID . "'>History</a>"; } else { $history_string = "<i>No History</i>"; } array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name() . "{$name_tooltip}", $password, $privDataObj->get_group_name(), "<a name='modal' href='#" . $PdataModalID . "'>Edit</a>        \n\t\t\t\t\t\t\t\t<a name='modal' href='#" . $myDeleteModalID . "'>Delete</a>        \n\t\t\t\t\t\t\t\t{$history_string}"); // Replace Heading of original Form, where used to be Group, // we now make the Edit / Delete fields } else { array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name(), "*********", $privDataObj->get_group_name(), "<b>Could not retrieve Private Data. Reason: " . $privDataObj->get_error() . "</b><br><a name='modal' href='#" . $myModalID . "'>Unlock Private Data</a>"); } } else { array_push($data, $privDataObj->get_type_desc() . $type_tooltip, $privDataObj->get_name() . $name_tooltip, "*********", $privDataObj->get_group_name(), "<a name='modal' href='#" . $myModalID . "'>Unlock Private Data</a>"); } } $pdata_form = new Form("auto", 5); $pdata_form->setSortable(true); $pdata_form->setHeadings($heading); $pdata_form->setData($data); $pdata_form->setTableWidth("777px"); echo $pdata_form->showForm(); echo $modalForms; } else { //echo "No Private data for this Device"; } echo $private_data_type_modal; } } echo "</div>"; }
/** * Create a custom theme */ public function create() { $form = new Form(array('id' => 'create-theme-form', 'labelWidth' => '20em', 'fieldsets' => array('form' => array(new TextInput(array('name' => 'name', 'required' => true, 'pattern' => '/^[\\w\\-]+$/', 'label' => Lang::get($this->_plugin . '.theme-create-name-label'))), new TextInput(array('name' => 'title', 'required' => true, 'label' => Lang::get($this->_plugin . '.theme-create-title-label'))), new SelectInput(array('name' => 'extends', 'invitation' => '-', 'options' => array_map(function ($theme) { return $theme->getTitle(); }, Theme::getAll()), 'label' => Lang::get($this->_plugin . '.theme-create-extends-label'))), new TextInput(array('name' => 'version', 'required' => true, 'pattern' => '/^(\\d+\\.){2,3}\\d+$/', 'label' => Lang::get($this->_plugin . '.theme-create-version-label'), 'default' => '0.0.1')), new TextInput(array('name' => 'author', 'label' => Lang::get($this->_plugin . '.theme-create-author-label')))), 'submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.load(app.getUri("available-themes"), { selector : $("#admin-themes-select-tab")} );')); if (!$form->submitted()) { // Display the form return View::make(Theme::getSelected()->getView('dialogbox.tpl'), array('title' => Lang::get($this->_plugin . '.theme-create-title'), 'icon' => 'picture-o', 'page' => $form)); } else { if ($form->check()) { $dir = THEMES_DIR . $form->getData('name') . '/'; if (is_dir($dir)) { $form->error('name', Lang::get($this->_plugin . '.theme-create-name-already-exists-error')); return $form->response(Form::STATUS_CHECK_ERROR, Lang::get($this->_plugin . '.theme-create-name-already-exists-error')); } // The theme can be created try { // Create the main directory if (!mkdir($dir)) { throw new \Exception('Impossible to create the directory ' . $dir); } // Create the directory views if (!mkdir($dir . 'views')) { throw new \Exception('Impossible to create the directory ' . $dir . 'views'); } // Get the parent theme $parent = null; if ($form->getData('extends')) { $parent = Theme::get($form->getData('extends')); } // Create the file manifest.json $conf = array('title' => $form->getData('title'), 'version' => $form->getData('version'), 'author' => $form->getData('author')); if ($parent) { $conf['extends'] = $parent->getName(); } if (file_put_contents($dir . Theme::MANIFEST_BASENAME, json_encode($conf, JSON_PRETTY_PRINT)) === false) { throw new \Exception('Impossible to create the file ' . $dir . Theme::MANIFEST_BASENAME); } $theme = Theme::get($form->getData('name')); if ($parent) { // The theme extends another one, make a copy of the parent theme except manifest.json and views foreach (glob($parent->getRootDir() . '*') as $element) { if (!in_array(basename($element), array(Theme::MANIFEST_BASENAME, 'views'))) { App::fs()->copy($element, $theme->getRootDir()); } } } else { // Create the directory less if (!mkdir($dir . 'less')) { throw new \Exception('Impossible to create the directory ' . $dir . 'less'); } // Create the file theme.less if (!touch($theme->getBaseLessFile())) { throw new \Exception('Impossible to create the file ' . $theme->getBaseLessFile()); } } return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.theme-create-success')); } catch (\Exception $e) { if (is_dir($dir)) { App::fs()->remove($dir); } return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get($this->_plugin . '.theme-create-error')); } } } }
?> <?php echo Form::error('city', $errors); ?> </div> </div> <div class="form-group"> <label for="address" class="col-sm-2 control-label">Адрес</label> <div class="col-sm-10"> <?php echo Form::input('address', $obj_order->address, ['class' => 'form-control', 'placeholder' => 'Адрес', 'required']); ?> <?php echo Form::error('address', $errors); ?> </div> </div> <div class="form-group"> <label for="postcode" class="col-sm-2 control-label">Индекс</label> <div class="col-sm-10"> <?php echo Form::input('postcode', $obj_order->postcode, ['class' => 'form-control', 'placeholder' => 'Индекс', 'required']); ?> <?php echo Form::error('postcode', $errors); ?> </div> </div>
</div> <div class="form-group"> <label class="col-sm-2 control-label required">Mật khẩu mới</label> <div class="col-sm-6"> <?php echo Form::password('new_pass', '', array('autocomplete' => 'off', 'class' => 'form-control', 'placeholder' => 'Mật khẩu mới')); ?> <?php echo Form::error('new_pass', $err); ?> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label required">Xác nhận</label> <div class="col-sm-6"> <?php echo Form::password('confirm_pass', '', array('autocomplete' => 'off', 'class' => 'form-control', 'placeholder' => 'Nhập lại mật khẩu mới')); ?> <?php echo Form::error('confirm_pass', $err); ?> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default">Đổi mật khẩu</button> </div> </div> <?php echo Form::close();
?> <div class="tab-content"> <div class="tab-pane fade in active" id="home"> <div class="form-group<?php echo Form::has_error('text', $errors); ?> "> <?php echo TB_Form::label(__('home.page_text')); ?> <div class="col-sm-10"> <?php echo Editor::CK('text', $data['text'], ['class' => 'form-control', 'rows' => 6]); echo Form::error('text', $errors); ?> </div> </div> </div> <div class="tab-pane fade" id="seo"> <?php echo View::factory('backend/v_seo', ['t' => [$data['meta_t'], __('home.meta_t_h'), true], 'd' => [$data['meta_d'], __('home.meta_d_h'), true], 'k' => [$data['meta_k'], __('home.meta_k_h'), true]])->bind('errors', $errors); ?> </div> </div> <?php
/** * Display and treat application settings */ public function settings() { $languages = array_map(function ($language) { return $language->label; }, Language::getAll('tag')); $roleObjects = Role::getListByExample(new DBExample(array('id' => array('$ne' => 0))), 'id'); $roles = array(); foreach ($roleObjects as $role) { $roles[$role->id] = Lang::get("roles.role-{$role->id}-label"); } $items = MenuItem::getAvailableItems(); $menuItems = array(); foreach ($items as $item) { if ($item->action && !preg_match('/^(javascript\\:|#)/', $item->action) && (!$item->target || $item->target == 'newtab')) { if ($item->label === 'user.username') { $item->label = App::session()->getUser()->username; } $menuItems[$item->action] = $item->label; } else { foreach ($item->visibleItems as $subitem) { if ($item->label === 'user.username') { $item->label = App::session()->getUser()->username; } if (!preg_match('/^(javascript\\:|#)/', $subitem->action) && (!$subitem->target || $subitem->target == 'newtab')) { $menuItems[$subitem->action] = $item->label . " > " . $subitem->label; } } } } $api = new HawkApi(); try { $updates = $api->getCoreAvailableUpdates(); } catch (\Hawk\HawkApiException $e) { $updates = array(); } $param = array('id' => 'settings-form', 'upload' => true, 'fieldsets' => array('main' => array(new TextInput(array('name' => 'main_sitename', 'required' => true, 'default' => Option::get('main.sitename'), 'label' => Lang::get('admin.settings-sitename-label'))), new SelectInput(array('name' => 'main_language', 'required' => true, 'options' => $languages, 'default' => Option::get('main.language'), 'label' => Lang::get('admin.settings-language-label'))), new SelectInput(array('name' => 'main_timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => Option::get('main.timezone'), 'label' => Lang::get('admin.settings-timezone-label'))), new SelectInput(array('name' => 'main_currency', 'required' => true, 'options' => array('EUR' => 'Euro (€)', 'USD' => 'US Dollar ($)'), 'default' => Option::get('main.currency'), 'label' => Lang::get('admin.settings-currency-label'))), new FileInput(array('name' => 'logo', 'label' => Lang::get('admin.settings-logo-label'), 'after' => Option::get('main.logo') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.logo')) . '" class="settings-logo-preview" />' : '', 'maxSize' => 200000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg'))), new FileInput(array('name' => 'favicon', 'label' => Lang::get('admin.settings-favicon-label'), 'after' => Option::get('main.favicon') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.favicon')) . '" class="settings-favicon-preview" />' : '', 'maxSize' => 20000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg', 'ico')))), 'referencing' => call_user_func(function () use($languages) { $inputs = array(); foreach ($languages as $tag => $language) { $inputs[] = new TextInput(array('name' => 'main_page-title-' . $tag, 'default' => Option::get('main.page-title-' . $tag))); $inputs[] = new TextareaInput(array('name' => 'main_page-description-' . $tag, 'default' => Option::get('main.page-description-' . $tag))); $inputs[] = new TextInput(array('name' => 'main_page-keywords-' . $tag, 'default' => Option::get('main.page-keywords-' . $tag))); } return $inputs; }), 'home' => array(new RadioInput(array('name' => 'main_home-page-type', 'options' => array('default' => Lang::get('admin.settings-home-page-type-default'), 'custom' => Lang::get('admin.settings-home-page-type-custom'), 'page' => Lang::get('admin.settings-home-page-type-page')), 'default' => Option::get('main.home-page-type') ? Option::get('main.home-page-type') : 'default', 'label' => Lang::get('admin.settings-home-page-type-label'), 'layout' => 'vertical', 'attributes' => array('e-value' => 'homePage.type'))), new WysiwygInput(array('name' => 'main_home-page-html', 'id' => 'home-page-html', 'label' => Lang::get('admin.settings-home-page-html-label'), 'default' => Option::get('main.home-page-html'))), new SelectInput(array('name' => 'main_home-page-item', 'id' => 'home-page-item', 'label' => Lang::get('admin.settings-home-page-item-label'), 'options' => $menuItems, 'value' => Option::get('main.home-page-item'))), new CheckboxInput(array('name' => 'main_open-last-tabs', 'label' => Lang::get('admin.settings-open-last-tabs'), 'default' => Option::get('main.open-last-tabs'), 'dataType' => 'int'))), 'users' => array(new RadioInput(array('name' => 'main_allow-guest', 'options' => array(0 => Lang::get('main.no-txt'), 1 => Lang::get('main.yes-txt')), 'default' => Option::get('main.allow-guest') ? Option::get('main.allow-guest') : 0, 'label' => Lang::get('admin.settings-allow-guest-label'))), new RadioInput(array('name' => 'main_open-register', 'options' => array(0 => Lang::get('admin.settings-open-register-off'), 1 => Lang::get('admin.settings-open-register-on')), 'layout' => 'vertical', 'label' => Lang::get('admin.settings-open-registers-label'), 'default' => Option::get('main.open-register') ? Option::get('main.open-register') : 0, 'attributes' => array('e-value' => 'register.open'))), new CheckboxInput(array('name' => 'main_confirm-register-email', 'label' => Lang::get('admin.settings-confirm-email-label'), 'default' => Option::get('main.confirm-register-email'), 'dataType' => 'int', 'attributes' => array('e-value' => 'register.checkEmail'))), new WysiwygInput(array('name' => 'main_confirm-email-content', 'id' => 'settings-confirm-email-content-input', 'default' => Option::get('main.confirm-email-content'), 'label' => Lang::get('admin.settings-confirm-email-content-label'), 'labelWidth' => 'auto')), new CheckboxInput(array('name' => 'main_confirm-register-terms', 'label' => Lang::get('admin.settings-confirm-terms-label'), 'default' => Option::get('main.confirm-register-terms'), 'dataType' => 'int', 'labelWidth' => 'auto', 'attributes' => array('e-value' => 'register.checkTerms'))), new WysiwygInput(array('name' => 'main_terms', 'id' => 'settings-terms-input', 'label' => Lang::get('admin.settings-terms-label'), 'labelWidth' => 'auto', 'default' => Option::get('main.terms'))), new SelectInput(array('name' => 'roles_default-role', 'label' => Lang::get('admin.settings-default-role-label'), 'options' => $roles, 'default' => Option::get('roles.default-role')))), 'email' => array(new EmailInput(array('name' => 'main_mailer-from', 'default' => Option::get('main.mailer-from') ? Option::get('main.mailer-from') : App::session()->getUser()->email, 'label' => Lang::get('admin.settings-mailer-from-label'))), new TextInput(array('name' => 'main_mailer-from-name', 'default' => Option::get('main.mailer-from-name') ? Option::get('main.mailer-from-name') : App::session()->getUser()->getDisplayName(), 'label' => Lang::get('admin.settings-mailer-from-name-label'))), new SelectInput(array('name' => 'main_mailer-type', 'default' => Option::get('main.mailer-type'), 'options' => array('mail' => Lang::get('admin.settings-mailer-type-mail-value'), 'smtp' => Lang::get('admin.settings-mailer-type-smtp-value'), 'pop3' => Lang::get('admin.settings-mailer-type-pop3-value')), 'label' => Lang::get('admin.settings-mailer-type-label'), 'attributes' => array('e-value' => 'mail.type'))), new TextInput(array('name' => 'main_mailer-host', 'default' => Option::get('main.mailer-host'), 'label' => Lang::get('admin.settings-mailer-host-label'))), new IntegerInput(array('name' => 'main_mailer-port', 'default' => Option::get('main.mailer-port'), 'label' => Lang::get('admin.settings-mailer-port-label'), 'size' => 4)), new TextInput(array('name' => 'main_mailer-username', 'default' => Option::get('main.mailer-username'), 'label' => Lang::get('admin.settings-mailer-username-label'))), new PasswordInput(array('name' => 'main_mailer-password', 'encrypt' => 'Crypto::aes256Encode', 'decrypt' => 'Crypto::aes256Decode', 'default' => Option::get('main.mailer-password'), 'label' => Lang::get('admin.settings-mailer-password-label'))), new SelectInput(array('name' => 'main_smtp-secured', 'options' => array('' => Lang::get('main.no-txt'), 'ssl' => 'SSL', 'tsl' => 'TSL'), 'label' => Lang::get('admin.settings-smtp-secured-label')))), '_submits' => array(empty($updates) ? new HtmlInput(array('value' => '<span class="btn btn-success">' . Lang::get('admin.hawk-version-up-to-date', array('version' => HAWK_VERSION)) . '</span>')) : new ButtonInput(array('name' => 'update-hawk', 'value' => Lang::get('admin.update-page-update-hawk-btn', array('version' => end($updates)['version'])), 'icon' => 'refresh', 'id' => 'update-hawk-btn', 'attributes' => array('e-click' => 'function(){ updateHawk("' . end($updates)['version'] . '"); }'), 'class' => 'btn-warning')), new SubmitInput(array('name' => 'save', 'value' => Lang::get('main.valid-button'), 'class' => 'pull-right'))))); $form = new Form($param); if (!$form->submitted()) { // Display the form $this->addCss(Plugin::current()->getCssUrl('settings.less')); $page = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form, 'languages' => $languages)); $this->addKeysToJavaScript('admin.update-page-confirm-update-hawk'); $this->addJavaScript(Plugin::current()->getJsUrl('settings.js')); return NoSidebarTab::make(array('icon' => 'cogs', 'title' => Lang::get('admin.settings-page-name'), 'description' => Lang::get('admin.settings-page-description'), 'page' => $page)); } else { // treat the form try { if ($form->check()) { // register scalar values foreach ($form->inputs as $name => $field) { if (!$field instanceof \Hawk\FileInput && !$field instanceof \Hawk\ButtonInput && !$field instanceof \Hawk\HtmlInput) { $value = $field->dbvalue(); if ($value === null) { $value = '0'; } $optionName = str_replace('_', '.', $name); App::logger()->error("Option name =" . $optionName . 'X'); App::logger()->error("basename=" . $value . 'X'); Option::set($optionName, $value); } elseif ($field instanceof \Hawk\FileInput) { $upload = Upload::getInstance($name); if ($upload) { try { $file = $upload->getFile(); $dir = Plugin::get('main')->getPublicUserfilesDir(); if (!is_dir($dir)) { mkdir($dir, 0755); } if ($name == 'favicon') { $basename = uniqid() . '.ico'; $generator = new \PHPICO($file->tmpFile, array(array(16, 16), array(32, 32), array(48, 48), array(64, 64))); $generator->save_ico($dir . $basename); } else { $basename = uniqid() . '.' . $file->extension; $upload->move($file, $dir, $basename); } // remove the old image @unlink($dir . Option::get("main.{$name}")); App::logger()->error("Option name = " . $name); App::logger()->error("main.{$name}"); App::logger()->error("basename=" . $basename); Option::set("main.{$name}", $basename); } catch (ImageException $e) { $form->error($name, Lang::get('form.image-format')); throw $e; } } } } // Register the favicon App::logger()->info('The options of the application has been updated by ' . App::session()->getUser()->username); return $form->response(Form::STATUS_SUCCESS, Lang::get('admin.settings-save-success')); } } catch (Exception $e) { App::logger()->error('An error occured while updating application options'); return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get('admin.settings-save-error')); } } }
$options[$label] = array('value' => $label); } $select = array('name' => 'panetag', 'selected' => $panetag, 'options' => $options, 'emptyoption' => '--', 'class' => ''); $panetag_select = $form->makeselect($select); //make style select $options = array(); foreach ($styles as $label) { $options[$label] = array('value' => $label); } $select = array('name' => 'style', 'selected' => $style, 'options' => $options, 'emptyoption' => '--', 'class' => ''); $style_select = $form->makeselect($select); //prep $do = 'editdatapt2'; $backto = "setup.php?do=config&id_view={$id_view}"; //assemble form $bodyinsert = "\r\n\t\t<form action='setup.php' method='post'>\r\n\t\t\t<fieldset>\r\n\t\t\t\t<legend>Edit datapt element</legend>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Datapoint:</label>\r\n\t\t\t\t\t{$datapt_select}\r\n\t\t\t\t\t{$form->error('datapt')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Label:</label>\r\n\t\t\t\t\t<input type='text' name='name' value='{$name}' /> \r\n\t\t\t\t\t{$form->error('name')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Pane:</label>\r\n\t\t\t\t\t{$panetag_select}\r\n\t\t\t\t\t{$form->error('panetag')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Style:</label>\r\n\t\t\t\t\t{$style_select}\r\n\t\t\t\t\t{$form->error('style')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Decimals:</label>\r\n\t\t\t\t\t<input type='text' name='resolution' value='{$resolution}' /> \r\n\t\t\t\t\t{$form->error('resolution')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='row'>\r\n\t\t\t\t\t<label>Order:</label>\r\n\t\t\t\t\t<input type='text' name='position' value='{$position}' /> \r\n\t\t\t\t\t{$form->error('position')}\r\n\t\t\t\t</div>\r\n\t\t\t\t<div class='buttons'>\r\n\t\t\t\t\t<input type='hidden' name='do' value='{$do}' />\r\n\t\t\t\t\t<input type='hidden' name='id_view' value='{$id_view}' />\r\n\t\t\t\t\t<input type='hidden' name='id_element' value='{$id_element}' />\r\n\t\t\t\t\t<input type='button' value='Cancel' onClick=\"document.location.href='{$backto}';\" />\r\n\t\t\t\t\t<input type='submit' value='OK' />\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t</form>\r\n\t"; //Display page $page->tags['PageTitle'] = 'Setup'; $page->tags['Body'] = $bodyinsert; $page->render(); } ### EDIT GRAPH SERIES 2 ### ############################################### if ($do == 'editseries2' or $do == 'delseries') { if (!$id_view) { die('Invalid id ' . __LINE__); } if (!$id_element) { die('Invalid id ' . __LINE__); }
<?php echo Form::open(); echo Form::label('username', 'Username'); echo Form::input('username'); echo @Form::error('username', $errors); echo '<br/>'; echo Form::label('password', 'Password'); echo Form::password('password'); echo @Form::error('password', $errors); echo '<br/>'; echo Form::submit('submit', 'Log In'); echo Form::close();
</fieldset> <fieldset> <legend> <i class="fa fa-truck fa-flip-horizontal text-muted"></i> Адрес доставки </legend> <div class="form-group"> <label for="delivery_id" class="col-sm-2 control-label">Доставка</label> <div class="col-sm-10"> <?php echo Form::select('delivery_id', $sel_deliveries, $obj_order->delivery_id ? $obj_order->delivery_id : 1, ['class' => 'form-control', 'id' => 'delivery_id', 'required']); ?> <?php echo Form::error('delivery_id', $errors); ?> </div> </div> <div class="delivery_address"> <?php echo $v_delivery_address; ?> </div> </fieldset> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-success">
echo Form::error('password', $errors); ?> </div> <div class="form-group<?php echo Form::has_error('password_confirm', $errors); ?> "> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span> <?php echo Form::password('password_confirm', '', ['placeholder' => __('user.password_confirm'), 'class' => 'form-control']); ?> </div> <?php echo Form::error('password_confirm', $errors); ?> </div> <div class="form-group"> <button class="btn btn-primary btn-block btn-lg" type="submit"> <?php echo HTML::chars(__('user.sign_up')); ?> </button> </div> <div class="form-group"> <?php echo HTML::anchor(Route::url('f_auth', ['action' => 'login']), __('user.log_in'), ['class' => 'btn btn-default btn-block btn-lg']); ?>
echo TB_Form::label(__('settings.pg_for_frontend') . Form::$required); ?> <div class="col-sm-10"> <?php echo Form::input('per_page_frontend', $data['per_page_frontend'], ['class' => 'form-control']); echo Form::error('per_page_frontend', $errors); ?> </div> </div> <div class="form-group<?php echo Form::has_error('per_page_backend', $errors); ?> "> <?php echo TB_Form::label(__('settings.pg_for_backend') . Form::$required); ?> <div class="col-sm-10"> <?php echo Form::input('per_page_backend', $data['per_page_backend'], ['class' => 'form-control']); echo Form::error('per_page_backend', $errors); ?> </div> </div> <?php echo TB_Form::btn_save(); ?> <?php echo Form::close();
?> <div class="tab-content"> <div class="tab-pane fade in active" id="store"> <div class="form-group<?php echo Form::has_error('title', $errors); ?> "> <?php echo TB_Form::label_required(__('shop.category_title')); ?> <div class="col-sm-10"> <?php echo Form::input('title', $obj->title, ['class' => 'form-control']); echo Form::error('title', $errors); ?> </div> </div> <?php if ($settings_mod['max_nested'] > 1) { ?> <div class="form-group"> <?php echo TB_Form::label(__('shop.category_parent')); ?> <div class="col-sm-10"> <?php echo $sel_category; ?>
private function update_entry() { $content = ''; if (isset($_POST['update_private_data'])) { // Yes update $tmpform = new Form(); $privDataObj = new PrivateData($_POST['private_data_id']); $privDataObj->set_name($_POST['private_data_desc']); $privDataObj->set_notes($_POST['private_data_notes']); $privDataObj->set_type_id($_POST['private_data_type']); $privDataObj->set_private_data($_POST['private_data_password']); if ($privDataObj->update($_POST['group_pass'])) { $content .= $tmpform->success("Private data updated Succesfully"); $_SESSION['action'] = "Updated private data for: " . $_POST['private_data_desc']; } else { $content .= $tmpform->error("Warning: Failed to Update Private data Reason: " . $privDataObj->get_error(), $_GET['ID']); } } return $content; }
<?php include ROOT_DIR . 'include/header.php'; include ROOT_DIR . 'include/menu.php'; ?> <!--table lay out div--> <div class="container"> <form action="action_delete_banner.php" method="post"> <div class="row topmargin"> <?php echo $Form->error('success', 'alert alert-success'); ?> <?php echo $Form->error('error', 'alert alert-danger'); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <a href="add-banner.php" class="addmin">Upload a banner</a> </div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <ul class="editdelete"> <li><input onclick="return confirm('Are you sure you want to delete this banner?')" type="submit" name="delete_banner" value="DELETE"/></li> </ul> </div> </div>
<?php echo Form::textarea('meta_d', $d[0], ['class' => 'form-control', 'id' => 'meta_d', 'rows' => 2]); echo Form::help((isset($d[1]) ? $d[1] : '') . '<div id="chars_meta_d"></div>'); echo Form::error('meta_d', $errors); ?> </div> </div> <?php } ?> <?php if (isset($k)) { ?> <div class="form-group<?php echo Form::has_error('meta_k', $errors); ?> "> <?php echo TB_Form::label(__('settings.seo_meta_k') . (isset($k['2']) ? Form::$required : '')); ?> <div class="col-sm-10"> <?php echo Form::textarea('meta_k', $k[0], ['class' => 'form-control', 'id' => 'meta_k', 'rows' => 2]); echo Form::help((isset($k[1]) ? $k[1] : '') . '<div id="chars_meta_k"></div>'); echo Form::error('meta_k', $errors); ?> </div> </div> <?php }
<h1 class="page-header">Thêm logo chính</h1> <?php echo Form::open(array("class" => "form-horizontal", 'enctype' => 'multipart/form-data')); ?> <div class="form-group"> <label class="col-sm-3 control-label required">Chọn hình</label> <span class="img-size-helper glyphicon glyphicon-question-sign" data-tooltip-content="#tooltip_content" style="cursor: pointer; float: left;"></span> <div class="col-sm-4"> <?php echo Form::file('thumbnail', array('class' => '')); ?> <?php echo Form::error('thumbnail', $err); ?> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label required">Hiển thị</label> <div class="col-sm-4"> <input name="active" value="1" type="checkbox" class="checkbox"> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-10"> <button type="submit" class="btn btn-success">Đăng ký</button> <a href="<?php echo \Fuel\Core\Uri::base() . 'admin/mainlogo'; ?> " class="btn btn-default">Quay lại</a> </div>
<div class="c"></div> </div> </div> </div> <div class="container" style="margin-top:20px;"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <h2 class="" style="font-size:26px; line-height:30px;">New Leads</h2> <div class="clearfix"></div> <div id="reg"> <?php echo $Form->error('error', 'alert alert-danger alert-dismissible'); ?> <?php echo $Form->error('leadsError', 'alert alert-danger alert-dismissible'); ?> <?php if (isset($_GET['leads'])) { if ($_GET['leads'] == "success") { ?> <p class="alert alert-success"> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> A new lead has been submitted successfully</p> <?php } }
<?php foreach ($data['default_langs'] as $parent_key => $lang_keys) { ?> <?php foreach ($lang_keys as $key => $content) { ?> <tr> <td> <?php echo $content; ?> </td> <td> <?php echo Form::input("langs[{$parent_key}][{$key}]", $data['new_langs'][$parent_key][$key], array('class' => 'form-control')); ?> <?php echo Form::error("{$parent_key}.{$key}", $err); ?> </td> </tr> <?php } ?> <?php } ?> <tbody> </table> </div> </div>
<body> <?php include ROOT_DIR . 'include/header.php'; include ROOT_DIR . 'include/menu.php'; ?> <!--table lay out div--> <div class="container"> <form action="manage_admin_action.php" method="POST"> <div class="row topmargin"> <?php echo $Form->error('error', 'alert alert-danger alert-dismissible'); ?> <?php echo $Form->error('success', 'alert alert-success alert-dismissible'); ?> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <a href="<?php echo WEBSITE_URL; ?> admin/administrator/add-a-administrator.php">add an administrator</a> </div> <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"> <ul class="editdelete"> <li><input type="submit" name="edit_admin" value="EDIT"/></li>
<h1 class="page-header">Thêm ngôn ngữ mới</h1> <?php echo Form::open(array('class' => 'form-horizontal')); ?> <div class="form-group"> <label class="col-sm-4 control-label required">Ngôn ngữ viết tắt <br> <font style="font-weight: normal"> Hỗ trợ những ngôn ngữ sau (ar, be, bg, cs, da, de, el, en, es, et, fi, fr, ga, hi, hr, hu, in, is, it, iw, jp, kr, lt, lv, mk, ms, mt, nl, no, pl, pt, ro, ru, sk, sl, sq, sr, sv, th, tr, uk, vi, zh)</font></label> <div class="col-sm-4"> <?php echo Form::input('shortname', $data['shortname'], array('autocomplete' => 'off', 'class' => 'form-control', 'placeholder' => 'vi, en, ...')); ?> <?php echo Form::error('shortname', $err); ?> </div> </div> <?php require_once '_form.php'; ?> <div class="form-group"> <div class="col-md-4"></div> <div class="col-md-8" style="padding-left: 0;"> <a href="<?php echo \Fuel\Core\Uri::base() . 'admin/language'; ?> " class="btn btn-default">Quay lại</a> <button type="submit" class="btn btn-success">Đăng ký</button> </div> </div> <?php
<?php include ROOT_DIR . 'include/header.php'; include ROOT_DIR . 'include/menu.php'; ?> <!--header div end--> <!--table lay out div--> <div class="container"> <div style="margin-top:20px;"> <?php echo $form->error('agency_error', 'alert alert-danger alert-dismissible'); echo $form->error('agency_success', 'alert-success alert-dismissible'); ?> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <h2 class="" style="font-size:26px; line-height:30px;">Add Agency</h2> <div class="clearfix"></div> <div id="reg"> <form action="<?php echo WEBSITE_URL; ?> admin/user/action_add_agency.php" method="POST"> <input name="name" value="<?php echo $form->value('name'); ?>
if ($_POST['inh_assigned'] == "on") { $host->set_assigned_to_id($ip_info->get_assigned_to_id()); } if ($_POST['inh_status'] == "on") { if ($ip_info->get_status() == 'PARENT') { $host->set_status('FREE'); } else { $host->set_status($ip_info->get_status()); } } if ($_POST['inh_tags'] == "on") { $host->set_tags($ip_info->get_tags()); } //if insert fails, show why if (!$host->insert("host")) { echo Form::error("CANNOT ADD HOST! Details: " . $host->get_error()); } else { //update status to parent $ip_info->set_status("PARENT"); $ip_info->update(); } } else { //if all checks fail, show that. echo Form::warning("INVALID HOST"); } } else { //if checks fail, show that echo Form::warning("INVALID HOST"); } } else { if (isset($_POST['ip_update'])) {
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12 centeralign"> <a href="#"> <img src="img/logo.png" alt="Life Department" /> </a> </div> <div class="col-lg-7 col-md-7 col-sm-7"> <a class="login_button" href="login.php">Login</a> </div> </div> </div> </div> <!--header div end--> <div class="container" style="margin-top:50px;"> <?php if ($Form->error('success', '')) { echo $Form->error('success', 'alert alert-success text-center alert-dismissible'); } else { ?> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 col-md-offset-4 text-center visittext"> <h4>Forgot Password</h4> <?php echo $Form->error('notFound', 'alert alert-danger'); ?> <form action="action_forgot_password.php" method="post"> <?php echo $Form->error('email', 'alert alert-danger alert-dismissible'); ?> <input name="email" style="width: 90%;margin: 5px 5%;padding: 7px;text-align: center" type="email" placeholder="Email Address"/> <button name="submit" style="width: 90%;margin: 0 5%;padding: 7px;background: #1c8c7e;color: #ffffff" type="submit">Send Mail</button>
/** * @abstract Edits an event recprd * @param integer $id * @access public */ public function edit($id = false) { $form = new Form('courses', $id); // grab existing groups settings $model = model()->open('course_groups_link'); $model->where('course_id', $id); $group_records = $model->results(); $groups = array(); if ($group_records) { foreach ($group_records as $course_record) { $groups[] = $course_record['group_id']; } } $form->addField('groups', $groups, $groups); // proces the form if submitted if ($form->isSubmitted()) { // validation if (!$form->isFilled('title')) { $form->addError('title', 'You must enter a course title.'); } // if we have no errors, process sql if (!$form->error()) { if ($res_id = $form->save($id)) { $id = $id ? $id : $res_id; // update course groups $model->delete('course_groups_link', $id, 'course_id'); $groups = $form->cv('groups'); foreach ($groups as $group) { $sql = sprintf('INSERT INTO course_groups_link (course_id, group_id) VALUES ("%s", "%s")', $id, $group); $model->query($sql); } // if successful insert, redirect to the list sml()->say('The course has successfully been saved.'); router()->redirect('view'); } } } $data['form'] = $form; template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php'); template()->addView(template()->getModuleTemplateDir() . DS . 'edit.tpl.php'); template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php'); template()->display($data); }