当前位置: 首页>>代码示例>>PHP>>正文


PHP Device::fromDatabaseByIpAddress方法代码示例

本文整理汇总了PHP中Device::fromDatabaseByIpAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::fromDatabaseByIpAddress方法的具体用法?PHP Device::fromDatabaseByIpAddress怎么用?PHP Device::fromDatabaseByIpAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Device的用法示例。


在下文中一共展示了Device::fromDatabaseByIpAddress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getOutput

 public function getOutput()
 {
     global $gvPath;
     $ip = $_SERVER['REMOTE_ADDR'];
     //Check whether the address is registered
     $device = Device::fromDatabaseByIpAddress($ip);
     if (!$device) {
         $page = new WebPageOutput();
         $page->setHtmlPageTitle('Dispositivo non riconosciuto');
         $page->addHtmlHeader('<meta http-equiv="refresh" content="5">');
         $page->setHtmlBodyContent($this->getPageContentForUnknown($ip));
         return $page;
     }
     if ((int) $device->getDeskNumber() === 0) {
         // DisplayMain
         $td_code = $device->getTdCode();
         if ($td_code) {
             $td_code = "?td_code=" . urlencode($td_code);
         } else {
             $td_code = '';
         }
         $redirect = new RedirectOutput("{$gvPath}/device/main{$td_code}");
         return $redirect;
     }
     $num = $device->getDeskNumber();
     $redirect = new RedirectOutput("{$gvPath}/device/desk?desk_number={$num}");
     return $redirect;
 }
开发者ID:adntec,项目名称:queueManage,代码行数:28,代码来源:DeviceMainPage.php

示例2: execute

 public function execute()
 {
     global $gvPath;
     // Trim data
     $this->desk_number = trim($this->desk_number);
     $this->desk_ip_address = trim($this->desk_ip_address);
     // Data validation
     if ($this->desk_number === '' && $this->desk_ip_address === '') {
         $this->message = "Errore: tutti i campi sono obbligatori.";
         return true;
     }
     // desk_number should contain... numbers
     if (preg_match('/^[1-9][0-9]*$/', $this->desk_number) !== 1) {
         $this->message = "Errore: il numero dello sportello non è valido.";
         return true;
     }
     // Check ip_address
     if (!filter_var($this->desk_ip_address, FILTER_VALIDATE_IP)) {
         $this->message = "Errore: l'indirizzo IP non è valido.";
         return true;
     }
     $desk = Desk::fromDatabaseByNumber($this->desk_number);
     if ($desk && ($this->desk_id === 0 || $this->desk_id !== (int) $desk->getId())) {
         $this->message = "Errore: il numero sportello non è disponibile.";
         return true;
     }
     unset($desk);
     // Check ip is not taken
     $desk = Desk::fromDatabaseByIpAddress($this->desk_ip_address);
     $device = Device::fromDatabaseByIpAddress($this->desk_ip_address);
     if ($device || $desk && ($this->desk_id === 0 || $this->desk_id !== (int) $desk->getId())) {
         $this->message = "Errore: l'indirizzo IP è gia stato assegnato.";
         return true;
     }
     unset($desk);
     if ($this->desk_id === 0) {
         $desk = Desk::newRecord();
     } else {
         $desk = Desk::fromDatabaseById($this->desk_id);
     }
     if ($desk->isOpen()) {
         $this->message = "Errore: il desk è aperto. Chiudere la sessione prima di continuare.";
         return true;
     }
     $desk->setNumber($this->desk_number);
     $desk->setIpAddress($this->desk_ip_address);
     if ($desk->save()) {
         gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok');
         $redirect = new RedirectOutput("{$gvPath}/application/adminDeskList");
         return $redirect;
     } else {
         $this->message = "Impossibile salvare le modifiche. Ritentare in seguito.";
         return true;
     }
 }
开发者ID:adntec,项目名称:queueManage,代码行数:55,代码来源:AdminDeskEdit.php

示例3: main

function main()
{
    // Check whether this device needs to be redirected somewhere
    $dev = Device::fromDatabaseByIpAddress($_SERVER['REMOTE_ADDR']);
    if ($content = getContentForRedirect($dev, 0)) {
        $output = new JsonOutput();
        $output->setContent($content);
        $output->output();
        exit;
    }
    $td_code = gfGetVar('td_code', '');
    $lastTicket = gfGetVar('lastTicket', 'A000');
    $content = null;
    $startTime = time();
    while (time() - $startTime < 120) {
        sleep(1);
        // Check every second
        $currentState = DisplayMain::fromDatabaseCompleteList($td_code);
        if (count($currentState) == 0) {
            continue;
        }
        if ($lastTicket != $currentState[0]->getTicket()) {
            // Something changed, compute new tickets
            $newTickets = array($currentState[0]);
            $i = 1;
            while ($i < count($currentState) && $i < 8 && $lastTicket != $currentState[$i]->getTicket()) {
                $newTickets[] = $currentState[$i];
                $i++;
            }
            $content = array('status' => 'changed', 'count' => count($newTickets), 'entries' => $newTickets);
            break;
        }
        unset($currentState);
    }
    // End while
    if (!$content) {
        // Polling wait expired
        $content = array('status' => 'unchanged');
    }
    $output = new JsonOutput();
    $output->setContent($content);
    $output->output();
}
开发者ID:adntec,项目名称:queueManage,代码行数:43,代码来源:displayMainPolling.php

示例4: gfGetVar

<?php

include '../includes/Setup.php';
include './displayFunctions.php';
// Do not lock tables
Database::lockTables(false);
$deskNumber = gfGetVar('deskNumber');
// Check whether this device needs to be redirected somewhere
$dev = Device::fromDatabaseByIpAddress($_SERVER['REMOTE_ADDR']);
if ($content = getContentForRedirect($dev, (int) $deskNumber)) {
    $output = new JsonOutput();
    $output->setContent($content);
    $output->output();
    exit;
}
// Response is json
$output = new JsonOutput();
$pageTicketCode = gfGetVar('ticketCode', '');
$pageTicketNumber = gfGetVar('ticketNumber', '');
$startTime = time();
while (time() - $startTime < 120) {
    sleep(1);
    // Check every second
    // Update table for session timed out
    $desk = Desk::fromDatabaseByNumber($deskNumber);
    $desk->isOpen();
    $currentTicket = Ticket::fromDatabaseByDesk($deskNumber);
    if (!$currentTicket) {
        if ($pageTicketCode == '' && $pageTicketNumber == '') {
            // Still no ticket
            continue;
开发者ID:adntec,项目名称:queueManage,代码行数:31,代码来源:displayDeskPolling.php

示例5: execute

 public function execute()
 {
     global $gvPath;
     // Trim data
     $this->dev_ip_address = trim($this->dev_ip_address);
     $this->dev_desk_number = trim($this->dev_desk_number);
     // Data validation
     if ($this->dev_ip_address === '' || $this->dev_desk_number === '') {
         $this->message = "Errore: tutti i campi sono obbligatori.";
         return true;
     }
     // dev_desk_number should contain... numbers
     if (preg_match('/^(0|[1-9][0-9]*)$/', $this->dev_desk_number) !== 1) {
         $this->message = "Errore: il numero dello sportello non è valido.";
         return true;
     }
     // Check ip_address
     if (!filter_var($this->dev_ip_address, FILTER_VALIDATE_IP)) {
         $this->message = "Errore: l'indirizzo IP non è valido.";
         return true;
     }
     // Check if desk number really exists
     if ((int) $this->dev_desk_number !== 0) {
         $desk = Desk::fromDatabaseByNumber($this->dev_desk_number);
         if (!$desk) {
             $this->message = "Errore: lo sportello specificato non esiste.";
             return true;
         }
         unset($desk);
     }
     // Check tdCode exists and active
     if ($this->dev_td_code) {
         $td = TopicalDomain::fromDatabaseByCode($this->dev_td_code);
         if (!$td || !$td->getActive()) {
             $this->message = "Errore: l'area tematica selezionata non è disponibile.";
             return true;
         }
     }
     // Check ip is not taken
     $device = Device::fromDatabaseByIpAddress($this->dev_ip_address);
     $desk = Desk::fromDatabaseByIpAddress($this->dev_ip_address);
     if ($desk || $device && ($this->dev_id === 0 || $this->dev_id !== (int) $device->getId())) {
         $this->message = "Errore: l'indirizzo IP è gia stato assegnato.";
         return true;
     }
     unset($device);
     if ($this->dev_id === 0) {
         $device = Device::newRecord();
     } else {
         $device = Device::fromDatabaseById($this->dev_id);
     }
     $device->setIpAddress($this->dev_ip_address);
     $device->setDeskNumber($this->dev_desk_number);
     $device->setTdCode($this->dev_td_code);
     if ($device->save()) {
         gfSetDelayedMsg('Operazione effettuata correttamente', 'Ok');
         $redirect = new RedirectOutput("{$gvPath}/application/adminDeviceList");
         return $redirect;
     } else {
         $this->message = "Impossibile salvare le modifiche. Ritentare in seguito.";
         return true;
     }
 }
开发者ID:adntec,项目名称:queueManage,代码行数:63,代码来源:AdminDeviceEdit.php


注:本文中的Device::fromDatabaseByIpAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。