Example #1
0
 public function order_request($params = [])
 {
     $quote = Quote::read_by_params($params);
     if (!isset($quote['id'])) {
         Render::error_404();
     }
     $order = $params;
     $order += $quote;
     $order['country'] = Util::get_countries()[$order['country']];
     $order['payment'] = Util::get_payments()[$order['payment']];
     if (!isset($order['po'])) {
         $order['po'] = '';
     }
     $body = Template::render_doc_by_name('order-email', $order);
     // send order request to "WinWrap Web Primary/web.primary@winwrap.com"
     $linkc = 'https://www.winwrap.com/web/basic/support/admin/new_company.asp' . '?license=16' . '&company=' . urlencode($order['company']) . '&country=' . urlencode($order['country']) . '&billingaddress=' . urlencode(str_replace("\r\n", '|', $order['address'])) . '&billingname=' . urlencode($order['billing_name']) . '&billingaddr=' . urlencode($order['billing_email']) . '&billingphone=' . urlencode($order['billing_phone']) . '&name=' . urlencode($order['technical_name']) . '&addr=' . urlencode($order['technical_email']);
     $link = 'https://www.winwrap.com/web/basic/support/admin/new_fees.asp' . '?licenseid=' . '&company=' . urlencode($order['company']) . '&feecount=0' . '&payment=' . urlencode($order['payment']) . '&po=' . urlencode($order['po']);
     if (!is_null($quote['discount'])) {
         $link .= '&WWXX00=' . urlencode($quote['discount']) . '&WWXX00_DESC=' . urlencode($quote['discount_desc']);
     }
     $problem = false;
     $parts = [];
     foreach ($quote['items'] as $item) {
         $link .= '&' . $item['part'] . '=' . $item['quantity'];
         $part = substr($item['part'], 0, 6);
         if (array_search($part, $parts)) {
             $problem = true;
         } else {
             $parts[] = $part;
         }
         if (isset($item['override'])) {
             $link .= '&' . $part . '-override=' . $item['override'];
         }
     }
     $bodyc = '1) Click on this link to create the new company:' . "\r\n" . $linkc . "\r\n\r\n";
     if ($problem) {
         $bodyc .= '*** the following link will not create the correct fees ***' . "\r\n";
     }
     $bodyc .= '2) Click on this link to create the fees and invoice:' . "\r\n" . $link . "\r\n\r\n" . $body;
     $args = ['IP: ' . $_SERVER['REMOTE_ADDR'] . "\r\n\r\n" . 'toname' => 'WinWrap Web Primary', 'toemail' => '*****@*****.**', 'fromname' => 'WinWrap Web Primary', 'fromemail' => '*****@*****.**', 'subject' => 'WinWrap Basic Order Request', 'body' => $bodyc];
     if (GoogleMail::send($args) !== true) {
         header('Status: 500');
         return;
     }
     $status = '1/2: send to ' . $args['toemail'] . "\r\n";
     //echo '<pre>' . $body . '</pre>'; exit;
     // send order request to puchaser
     $args = ['toname' => $order['billing_name'], 'toemail' => $order['billing_email'], 'fromname' => 'WinWrap Support', 'fromemail' => '*****@*****.**', 'subject' => 'WinWrap Basic Order Request', 'body' => $body];
     if (GoogleMail::send($args) !== true) {
         header('Status: 500');
         return;
     }
     $status .= '2/2: send to ' . $args['toemail'];
     Render::text($status);
 }
 public function get_ref($params = [])
 {
     //echo '<pre>'; print_r($params); echo '</pre>'; exit;
     if (isset($params['_escaped_fragment_'])) {
         $file_name = substr($params['_escaped_fragment_'], 5);
         $context = ['page' => $file_name, 'link_style' => -1];
         $content = Template::render_doc_by_name('basic-ref', $context);
         Render::html($content);
     } else {
         Render::include_script("app/mdCode");
         parent::doc($params);
     }
 }
Example #3
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;
 }