예제 #1
0
 public function support()
 {
     if (Session::$user) {
         Render::html(Doc::by_name('support')['content'], ['email' => Session::$user['email']]);
     } else {
         Render::php(HTML . 'login.php');
     }
 }
예제 #2
0
 public static function render_doc_by_name($name, $context = [])
 {
     $template = new Template(Doc::by_name($name)['content'], TRUE);
     return $template->scrape($context)->render($context);
 }
예제 #3
0
 public function template($params = [])
 {
     Render::text(Doc::by_name($params['name'])['content']);
 }
예제 #4
0
 public static function read_file($file_name, $link_style = 0)
 {
     //echo $file_name . ', ' . $link_style; exit;
     $parts = explode('-', $file_name, 2);
     $group = $parts[0];
     // remove / to prevent arbitrary file reading (Tom 1/5/15)
     $file = str_replace('/', '', $parts[1]);
     $dir_mapping = ['WWB' => 'ww10_000htm', 'COM' => 'wwbcomhtm', 'NET' => 'doc2', 'WPF' => 'doc4', 'ASP' => 'doc5', 'AZW' => 'doc6'];
     $heads = ['WWB' => 'Language', 'COM' => 'For COM Reference (v10)'];
     foreach (['COM', 'NET', 'WPF', 'AZW'] as $key) {
         $dir_mapping[$key . 'Q'] = 'query';
         // Query documentation
         $dir_mapping[$key . 'F'] = 'query/Feature';
         // Query feature documentation
         $heads[$key . 'Q'] = 'Query Command';
         $heads[$key . 'F'] = 'Query Feature';
     }
     switch ($link_style) {
         case -1:
             // # link (in an _escaped_fragement_ page)
         // # link (in an _escaped_fragement_ page)
         case 0:
             // # link
             $link = '/basic/#!/ref/';
             break;
         case 1:
             // escaped_fragment
             $link = '/basic/?_escaped_fragment_=/ref/';
             break;
         case 2:
             // test page
             $link = '/basic/ref/?page=';
             break;
     }
     if ($group == 'doc') {
         $doc = Doc::by_name('doc-' . $file);
         $doc['content'] = str_replace('/basic/#!/ref/', $link, $doc['content']);
         return $doc;
     }
     $file_name = REF . "{$dir_mapping[$group]}/{$file}";
     if (!file_exists($file_name)) {
         $format = '<div id="nsbanner" class="ng-scope">
       <div id="bannerrow1">
         <table class="bannerparthead" cellspacing="0">
           <tbody><tr id="hdr">
             <td class="runninghead">WinWrap&reg; Basic</td>
             <td class="product">
             </td>
           </tr>
         </tbody></table>
       </div>
       <div id="TitleRow">
         <h1 class="dtH1">Invalid</h1>
       </div>
       <div id="nstext">
         File "%s" does not exist.
       </div>
     </div>';
         return ['title' => 'Invalid', 'content' => sprintf($format, $file)];
     }
     $content = file_get_contents($file_name);
     $content = mb_convert_encoding($content, 'UTF-8', mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
     if (isset($heads[$group])) {
         $format = '<div id="nsbanner" class="ng-scope">
       <div id="bannerrow1">
         <table class="bannerparthead" cellspacing="0">
           <tbody><tr id="hdr">
             <td class="runninghead">WinWrap&reg; Basic %s</td>
             <td class="product">
             </td>
           </tr>
         </tbody></table>
       </div>
       <div id="TitleRow">
         <h1 class="dtH1">%s</h1>
       </div>
     </div>';
         $title = '';
         $head = $heads[$group];
         $content = preg_replace_callback('/^.*?<font.*?>.*?<\\/font>.*?<font.*?><b>(.*?)<\\/b><\\/font>.*?<hr\\/>/s', function ($matches) use($group, $format, $head, &$title) {
             $title = $matches[1];
             return sprintf($format, $head, $title);
         }, $content);
     } else {
         // UTF-8 encoding (needed for chrome and opera)
         $content = str_replace('charset=Windows-1252', 'charset=utf-8', $content);
         preg_replace_callback('/class="dtH1">([^<]*)</', function ($matches) use(&$title) {
             $title = $matches[1];
         }, $content);
     }
     $content = preg_replace('/<div id="footer">(.*?)<\\/div>/', '', $content);
     $format = '<i class="fa fa-%s" title="%s"></i> ';
     $public = sprintf($format, 'user', 'Public');
     $protected = sprintf($format, 'key', 'Protected');
     $internal = sprintf($format, 'dot-circle-o', 'internal');
     $private = sprintf($format, 'briefcase', 'Private');
     $event = sprintf($format, 'bolt', 'Event');
     $property = sprintf($format, 'hand-o-left', 'Property');
     $method = sprintf($format, 'share-square-o', 'Method');
     // replace old-school image-icons with font-awesome icons
     $icons = ['pubevent' => "{$public}{$event}", 'pubproperty' => "{$public}{$property}", 'pubmethod' => "{$public}{$method}", 'protproperty' => "{$protected}{$property}", 'protmethod' => "{$protected}{$method}", 'intproperty' => "{$protected}{$internal}{$property}", 'intmethod' => "{$protected}{$internal}{$method}"];
     $content = preg_replace_callback('/<pre class="code"><span class="lang">\\[(.*?)\\].*?<\\/span>(.*?)<\\/pre>/s', function ($matches) {
         $comment = '\'';
         $lang = 'wwbnet';
         switch ($matches[1]) {
             case 'Visual Basic':
             case 'VB.NET':
                 $lang = 'vbnet';
                 break;
             case 'C#':
             case 'C++':
                 $comment = '//';
                 $lang = 'csharp';
                 break;
         }
         return sprintf("<div data-md-code=\"{ lang: '%s' }\">%s %s\r\n%s</div>", $lang, $comment, $matches[1], $matches[2]);
     }, $content);
     $content = preg_replace_callback('/<img[^s]*src="([^.]*).gif"[^>]*>/', function ($matches) use($icons) {
         $icon = isset($icons[$matches[1]]) ? $icons[$matches[1]] : $matches[1];
         return "{$icon} &nbsp; &nbsp;";
     }, $content);
     // remove ms-help links
     $content = preg_replace('/<a href="ms-help:.*?>(.*?)<\\/a>/', '<b>$1</b>', $content);
     // reformat links for front-end linking
     if ($link_style == 0) {
         $link = SUBDIR . $link;
     }
     $content = preg_replace('/href="((WinWrap|doc_|pop_|WWB-).*?)"/', "href=\"{$link}{$group}-\$1\"", $content);
     if (strlen($group) == 3) {
         // change query links
         $content = preg_replace('/\\/web\\/basic\\/reference\\/query\\/\\?v=(com\\&|net\\&amp;)c=Feature/', $link . $group . 'Q-Feature.htm', $content);
         $content = preg_replace('/\\/web\\/basic\\/reference\\/query\\/\\?v=(com|net)/', $link . $group . 'Q-0Help.htm', $content);
     } else {
         $group3 = substr($group, 0, 3);
         $content = str_replace('[[GROUP]]', $group3, $content);
         $content = str_replace(['**com:True**', '**net:True**'], $group3 == 'COM' ? ['True', 'False'] : ['False', 'True'], $content);
     }
     // add registered trademarks to all instances of WinWrap
     $content = str_replace('WinWrap Basic', 'WinWrap&reg; Basic', $content);
     return ['title' => $title, 'content' => $content];
 }
예제 #5
0
 public function installed($params = [])
 {
     $key = $params['key'];
     $version = $params['version'];
     $status = isset($params['Status']) ? $params['Status'] : '';
     $evaluator = Evaluator::read_by_key($key);
     if (isset($evaluator['downloads']) && $version >= 1 && $version <= count($evaluator['downloads'])) {
         // downloads are in reverse order (newest to oldest)
         // version number 1 is the oldest
         $idx = count($evaluator['downloads']) - $version;
         $id = $evaluator['downloads'][$idx]['id'];
         $update = ['installed_date' => gmdate('Y-m-d'), 'status' => $status];
         EvaluatorDownload::update($update, $id, 'installed_count = installed_count+1');
     }
     // show the news page
     Render::html(Doc::by_name('news')['content']);
 }