Esempio n. 1
0
        $dir_model = dir($dir);
        while(($file = $dir_model->read()) !== false){
            if(substr($file,0,1) == '.') continue;
            $daf = "$dir/$file";
            if(is_dir($daf)){
                $this->run($daf);    
            }else{
                $item = $daf.":".md5_file($daf);
                $item .= "\n";
                fwrite($this->output_fp ,$item);
            }
        }        
    }
}
*/
$scanner = new scanner();
$scanner->set_target_dir("{$here}/../../shopex-single-4.8.5.45144");
$scanner->set_signature('shopex-single-4.8.5.45144.sig');
$scanner->init();
$scanner->scan_system();
$scanner->report();
class scanner
{
    function set_target_dir($dir)
    {
        $this->target_dir = $dir;
    }
    function set_target_version($version)
    {
        $this->target_version = $version;
    }
?>

  <div class="page-heaer">
    <h1>Application logs</h1>
  </div>

  <?php 
$limit = 30;
if (isset($_GET['page'])) {
    $page = $_GET['page'];
    $offset = $page * $limit;
} else {
    $page = 0;
    $offset = 0;
}
$scanner = new scanner();
$logs = $scanner->getLogs($offset, $limit);
$rows = $logs->total;
$pages = ceil($rows / $limit);
$i = 0;
$nextpage = $page + 1;
$prevpage = $page - 1;
$logs = $logs->logs;
if ($pages > 1) {
    ?>

  <ul class='pagination'>
    <?php 
    if ($prevpage >= 0) {
        ?>
    <li><a href="?page=<?php 
<?php

require_once 'inc/bootstrap.php';
$scanner = new scanner();
$ticket = new ticket();
$returnCodes = array(0 => 'Invalid Ticket ID', 1 => 'Duplicate Scan', 2 => 'Missing username', 3 => 'Success (cleared to enter)');
$col = TICKET_COL;
$user = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
$barcode = $ticket->sanitizeBarcode(filter_input(INPUT_POST, 'ticket', FILTER_SANITIZE_SPECIAL_CHARS));
if (!$user) {
    $return = json_encode(array('message' => "No username specified", 'code' => 2));
    $scanner->logEvent("NU", "Tried to scan without a username");
    return;
}
if ($barcode) {
    $return = $ticket->scanTicket($barcode, $user);
} else {
    $return = json_encode(array('message' => "Barcode cannot be empty", 'code' => 2));
}
if (isset($_GET['barcode']) && is_admin()) {
    $return = $ticket->scanTicket($_GET['barcode'], $_GET['user']);
}
if (isset($_GET['format'])) {
    require_once 'header.php';
    ?>
    <div class="jumbotron">
      <h1>Ready to scan</h1>
      <input id="username" name="username" placeholder="Who are you" />
      <input id="ticket" name="ticket" placeholder="Barcode" />
    </div>
    <div class="panel panel-default hide" id="ticketInfo">
 public function importTickets($tickets)
 {
     $db = new database();
     $scanner = new scanner();
     //Split our bundle of tickets into separate arrays
     $tickets = explode("\n", $tickets);
     //Prep the query
     $db->query("INSERT INTO tbl_ticket (firstname, barcode, scanned) VALUES (?,?, 0)");
     $i = 0;
     //Number of attempted imports
     $f = 0;
     //Number of failures (invalid barcodes)
     foreach ($tickets as $ticket) {
         $i++;
         //Increse attempt count
         $ticket = explode(',', $ticket);
         //kaboom
         $barcode = $this->sanitizeBarcode($ticket[1]);
         //Check if the barcode fits whatever pattern we're using.
         $invalidBarcodes = '';
         //Empty string of invalid barcodes
         if (!$barcode) {
             $invalidBarcodes .= $ticket[1] . ', ';
             $f++;
             //Failed import increase
             $i--;
             //Decrease attempt count
         } else {
             $db->bind(1, $ticket[0]);
             $db->bind(2, $barcode);
             try {
                 $db->execute();
             } catch (Exception $e) {
                 $f++;
                 //Same thing here. This catches duplicate barcodes
                 $i--;
             }
         }
     }
     $scanner->logEvent("IT", "Imported {$i} tickets");
     return json_encode(array('message' => "Imported {$i} tickets. {$f} tickets were invalid or duplicates and ignored.", 'code' => 3));
 }