Esempio n. 1
0
 public static function read_key($key)
 {
     $quote = self::read(['*'], TRUE, ["`key` = ?", $key]);
     $quote['items'] = QuoteItem::read_items($quote['id']);
     $annual_fee = 0;
     foreach ($quote['items'] as $item) {
         $annual_fee += $item['annual_fee'];
     }
     $quote['first_fee'] = $annual_fee;
     $quote['annual_fee'] = $annual_fee;
     if (!is_null($quote['discount'])) {
         $quote['first_fee'] -= $quote['discount'];
     }
     $quote['expiration'] = Util2::future_date(substr($quote['created'], 0, 10), 60);
     return $quote;
 }
Esempio n. 2
0
 private function sizeFromCtrlByte($ctrlByte, $offset)
 {
     $size = $ctrlByte & 0x1f;
     $bytesToRead = $size < 29 ? 0 : $size - 28;
     $bytes = Util2::read($this->fileStream, $offset, $bytesToRead);
     $decoded = $this->decodeUint($bytes);
     if ($size == 29) {
         $size = 29 + $decoded;
     } elseif ($size == 30) {
         $size = 285 + $decoded;
     } elseif ($size > 30) {
         $size = ($decoded & 0xfffffff >> 32 - 8 * $bytesToRead) + 65821;
     }
     return array($size, $offset + $bytesToRead);
 }
Esempio n. 3
0
 private function get_days_left_text()
 {
     $daysleft = Util2::days_left(gmdate('Y-m-d'), $this->data['CertExpirationDate']);
     if ($daysleft <= 0) {
         return 'expired';
     }
     $s = $daysleft . ' day';
     if ($daysleft != 1) {
         $s .= 's';
     }
     $s .= ' left';
     return $s;
 }
Esempio n. 4
0
 public function download($params = [])
 {
     //echo '<pre>'; print_r($params); echo '</pre>'; exit;
     $setups_map = ['NET' => ['setup-4.0.msi' => 'WinWrap-NET4.0-setup.msi'], 'WPF' => ['setup-4.0-wpf.msi' => 'WinWrap-WPF4.0-setup.msi'], 'AZW' => ['setup-4.0-azw.msi' => 'WinWrap-AZW4.0-setup.msi'], 'COM' => ['setup32.msi' => 'WinWrap-COM32-setup.msi', 'setup64.msi' => 'WinWrap-COM64-setup.msi']];
     $all = [];
     foreach ($setups_map as $setup_map) {
         $all += $setup_map;
     }
     //$setups_map['ALL'] = $all; // disable for now (1/8/15)
     // select the platform's setup_map
     $platform = $params['platform'];
     $setup_map = $setups_map[$platform];
     if (!isset($setup_map)) {
         error_404();
     }
     // select the evaluator
     $key = $params['key'];
     $evaluator = Evaluator::read_by_key($key);
     //Render::json($evaluator); exit; // debug
     $error = false;
     if (!isset($evaluator['id'])) {
         $error = 'Invalid evaluator key.';
     } else {
         if (Util2::expired($evaluator['agreement_date'], 60, $evaluator['expiration_date'])) {
             $error = 'Evaluation period has expired.';
         }
     }
     if ($error) {
         Render::html(Doc::by_name('message')['content'], ['title' => 'Download Request Failed', 'message' => $error]);
         return;
     }
     // create evaluator cerificate
     $readme = Template::render_doc_by_name('evaluate-readme');
     $certificate = new Certificate();
     $certificate->set_by_evaluator($evaluator, true);
     // add download record
     $version = file_get_contents(EVALDIR . 'version.txt');
     $model = ['evaluator_id' => $evaluator['id'], 'ip' => $_SERVER['REMOTE_ADDR'], 'platform' => $platform != 'ALL' ? $platform : implode(',', array_keys($setups_map)), 'version' => $version];
     $download = EvaluatorDownload::create($model);
     // create signed certificate
     $html = $certificate->sign();
     //Render::text($_SERVER['HTTP_HOST'] . SUBDIR . "\r\n" . $html); exit;
     // create a temporary file
     $path = tempnam("tmp", "zip");
     $zipname = 'WinWrap-Basic-Evaluation-' . $platform;
     $zip = new ZipArchive();
     $okay = $zip->open($path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
     $okay |= $zip->addEmptyDir($zipname);
     $okay |= $zip->addFromString($zipname . '/readme.htm', $readme);
     $okay |= $zip->addFromString($zipname . '/Evaluation.htm', $html);
     $okay |= $zip->addFromString($zipname . '/version.txt', $version);
     foreach ($setup_map as $setup => $name) {
         $okay |= $zip->addFile(EVALDIR . $setup, $zipname . '/' . $name);
     }
     $okay |= $zip->close();
     if (!$okay) {
         Render::text("ZipArchive failed.");
         return;
     }
     //$contents = file_get_contents($path);
     //file_put_contents(TEMPDIR . 'x.zip', $contents);
     // send zip file
     if (true) {
         header('Cache-Control: max-age=288000');
         header('Content-Description: File Transfer');
         header('Content-Type: application/zip');
         //header("Content-Type: application/force-download");
         header('Content-Length: ' . filesize($path));
         header('Content-Transfer-Encoding: binary');
         header('Content-Disposition: attachment; filename="' . $zipname . '.zip"');
         ob_end_flush();
         readfile($path);
     }
     unlink($path);
     // set download date
     $update = ['download_date' => gmdate('Y-m-d')];
     EvaluatorDownload::update($update, $download['id']);
     // done
     exit;
 }
Esempio n. 5
0
<div class="container white">
  <div class="content left">
    <table class="data">
      <thead>
        <th>Date</th>
        <th>Expires</th>
        <th>Company</th>
        <th>Contact/Email/Key</th>
        <th>Items</th>
        <th>Views</th>
      </thead>
      <tbody>
        <?php 
$quotes = Quote::read(['*'], FALSE, ['created > CURRENT_DATE - INTERVAL 2 MONTH'], 'created DESC');
foreach ($quotes as $quote) {
    $expiration = Util2::future_date(substr($quote['created'], 0, 10), 60);
    $items = QuoteItem::read_items($quote['id']);
    $views = QuoteView::read_views($quote['id']);
    $item_details = [];
    foreach ($items as $item) {
        $item_details[] = $item['quantity'] . ' ' . $item['part'];
    }
    $view_details = [];
    foreach ($views as $view) {
        $view_details[] = $view['created'] . ' ' . $view['ip'];
    }
    echo '<tr>';
    echo '<td>' . htmlspecialchars($quote['created']) . '</td>';
    echo '<td>' . htmlspecialchars($expiration) . '</td>';
    echo '<td>' . htmlspecialchars($quote['company']) . '</td>';
    echo '<td>' . htmlspecialchars($quote['technical_name']) . '<br/>';