/** * @Route("/device/create", name="device_create") */ public function createDeviceAction() { $request = Request::createFromGlobals(); $idDevice = $request->request->get('idDevice'); $last_visit = $request->request->get('last_visit'); $device = new device(); $device->setIdDevice($idDevice); $device->setLastVisit($last_visit); $em = $this->getDoctrine()->getManager(); $em->persist($device); $em->flush(); return $this->redirectToRoute('device_show'); }
/** * Render content of main page. */ public function render() { // Attach widgets to the view to render them in the view. $this->view->account = account::getInstance(); $this->view->device = device::getInstance(); $this->view->download = download::getInstance(); $this->_render(); exit; }
/** * @Route("/api/data", name="api_data") */ public function dataAction() { $request = Request::createFromGlobals(); $id = $request->query->get('id'); $device = $this->getDoctrine()->getRepository('AppBundle:Device')->findOneBy(array('idDevice' => $id)); if (!$device) { $device = new device(); $device->setIdDevice($id); $device->setLastVisit(); $em = $this->getDoctrine()->getManager(); $em->persist($device); $em->flush(); } $channel = $this->getDoctrine()->getRepository('AppBundle:Channel')->findAll(); $response = new Response(); $response->setContent(json_encode($channel)); $response->headers->set('Content-Type', 'application/json'); return $response; }
public function getHTML($Action = "") { switch ($Action) { case "showAddNewDevice": /* $device = new device(); $device->setID(0); $device->setName("iFrame"); $device->setTyp("iFrame"); $device->setVersion("V 0.0.1"); $device->setIP(""); $device->setPort(""); $device->setStatus(""); return $device->getHTML("showAddNewDevice"); */ return parent::getHTML("showAddNewDevice"); case "showEditDevice": $device = new device(); $device->setID($this->getID()); $device->setName($this->getName()); $device->setTyp($this->getTyp()); $device->setVersion($this->getVersion()); $device->setIP($this->getIP()); $device->setPort($this->getPort()); $device->setStatus($this->getStatus()); return $device->getHTML("showEditDevice"); default: $device = new device(); $device->setID($this->getID()); $device->setName($this->getName()); $device->setTyp($this->getTyp()); $device->setVersion($this->getVersion()); $device->setIP($this->getIP()); $device->setPort($this->getPort()); $device->setStatus($this->getStatus()); return $device->getHTML(); } }
public function getHTML($Action = "") { switch ($Action) { case "showAddNewDevice": //$device = new device(); /*$this->setID(0); $device->setName("USB4all-SocketServer"); $device->setTyp("USB4all-SocketServer"); $device->setVersion("V 0.0.1"); $device->setIP(""); $device->setPort(3500); $device->setStatus(""); //return $device->getHTML("showAddNewDevice");*/ //$Output=" "; return parent::getHTML("showAddNewDevice"); case "showEditDevice": $device = new device(); $device->setID($this->getID()); $device->setName($this->getName()); $device->setTyp($this->getTyp()); $device->setVersion($this->getVersion()); $device->setIP($this->getIP()); $device->setPort($this->getPort()); $device->setStatus($this->getStatus()); return $device->getHTML("showEditDevice"); default: $device = new device(); $device->setID($this->getID()); $device->setName($this->getName()); $device->setTyp($this->getTyp()); $device->setVersion($this->getVersion()); $device->setIP($this->getIP()); $device->setPort($this->getPort()); $device->setStatus($this->getStatus()); return $device->getHTML(); } }
} //check if provisioning has been enabled if ($provision["enabled"] != "true") { echo "access denied"; exit; } //send a request to a remote server to validate the MAC address and secret if (strlen($_SERVER['auth_server']) > 0) { $result = send_http_request($_SERVER['auth_server'], 'mac=' . check_str($_REQUEST['mac']) . '&secret=' . check_str($_REQUEST['secret'])); if ($result == "false") { echo "access denied"; exit; } } //use the mac address to get the vendor $device_vendor = device::get_vendor($mac); //keep backwards compatibility if (strlen($_SESSION['provision']["cidr"]["text"]) > 0) { $_SESSION['provision']["cidr"][] = $_SESSION['provision']["cidr"]["text"]; } //check the cidr range if (is_array($_SESSION['provision']["cidr"])) { $found = false; foreach ($_SESSION['provision']["cidr"] as $cidr) { if (check_cidr($cidr, $_SERVER['REMOTE_ADDR'])) { $found = true; break; } } if (!$found) { echo "access denied";
echo "\t\t\t\t\t<option value=\"" . $field["device_mac_address"] . "\" selected=\"selected\">" . $field["device_mac_address"] . "</option>\n"; } else { echo "\t\t\t\t\t<option value=\"" . $field["device_mac_address"] . "\">" . $field["device_mac_address"] . " " . $field['device_model'] . " " . $field['device_description'] . "</option>\n"; } } } } unset($sql, $result, $result_count); echo "\t\t\t\t</select>\n"; echo "\t\t\t\t<input type='button' id='btn_select_to_input_device_mac_address' class='btn' name='' alt='" . $text['button-back'] . "' onclick='changeToInput_device_mac_address(document.getElementById(\"device_mac_address\"));this.style.visibility = \"hidden\";' value='◁'>\n"; echo "\t</td>\n"; echo "\t</tr>\n"; echo "\t</table>\n"; echo "\t\t</td>\n"; echo "\t\t<td class='vtable'>"; $device = new device(); $template_dir = $device->get_template_dir(); echo "<select id='device_template' name='device_template' class='formfld'>\n"; echo "<option value=''></option>\n"; if ($dh = opendir($template_dir)) { while ($dir = readdir($dh)) { if ($file != "." && $dir != ".." && $dir[0] != '.') { if (is_dir($template_dir . "/" . $dir)) { echo "<optgroup label='{$dir}'>"; if ($dh_sub = opendir($template_dir . '/' . $dir)) { while ($dir_sub = readdir($dh_sub)) { if ($file_sub != '.' && $dir_sub != '..' && $dir_sub[0] != '.') { if (is_dir($template_dir . '/' . $dir . '/' . $dir_sub)) { if ($device_template == $dir . "/" . $dir_sub) { echo "<option value='" . $dir . "/" . $dir_sub . "' selected='selected'>" . $dir . "/" . $dir_sub . "</option>\n"; } else {
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Device; /* @var $this yii\web\View */ /* @var $model app\models\Users */ /* @var $form yii\widgets\ActiveForm */ $device_sys_id = device::find()->asArray()->all(); $listData = ArrayHelper::map($device_sys_id, 'sys_n', 'sys_n'); ?> <div class="users-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'rem_login')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'rem_pas')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'sys_n')->dropDownList($listData, ['promt' => 'Выберите тип']); ?> <div class="form-group"> <?php
} else { echo "access denied"; exit; } //add multi-lingual support $language = new text(); $text = $language->get(); //set the variables $cmd = check_str($_GET['cmd']); $rdr = check_str($_GET['rdr']); $profile = check_str($_GET['profile']); $domain = check_str($_GET['domain']); $show = check_str($_GET['show']); $user = check_str($_GET['user']); $agent = check_str($_GET['agent']); $vendor = device::get_vendor_by_agent($agent); //create the event socket connection $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); if ($fp) { //prepare the command if ($cmd == "unregister") { $command = "sofia profile " . $profile . " flush_inbound_reg " . $user . " reboot"; } else { $command = "lua app.lua event_notify " . $profile . " " . $cmd . " " . $user . " " . $vendor; //if ($cmd == "check_sync") { // $command = "sofia profile ".$profile." check_sync ".$user; //} } //send the command $response = event_socket_request($fp, "api " . $command); $response = event_socket_request($fp, "api log notice " . $command);
$deviceId = $_GET['deviceId']; } elseif (isset($_POST['deviceId'])) { $deviceId = $_POST['deviceId']; } else { // TODO exit(100); } if (isset($_GET['comments'])) { $comments = $_GET['comments']; } elseif (isset($_POST['comments'])) { $comments = $_POST['comments']; } else { // TODO exit(100); } $dev = new device($deviceId); $dev->updateComments($comments); // TODO - add result echo '<script>location.reload();</script>'; break; case 'commentForm': if (isset($_GET['deviceId'])) { $deviceId = $_GET['deviceId']; } elseif (isset($_POST['deviceId'])) { $deviceId = $_POST['deviceId']; } else { // TODO exit(100); } $dev = new device($deviceId); echo '<textarea name="comments" id="deviceCommentsTextarea" data-mini="true">' . $dev->comments . '</textarea>';