]> _ Git - cubeextranet.git/commitdiff
wip #2428 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 12 Dec 2018 17:47:54 +0000 (17:47 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 12 Dec 2018 17:47:54 +0000 (17:47 +0000)
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php

index b8b28490e4babdb35de686ebca5dc781a2b0fb1a..6b2628367c02ebf98b050cde09f78a00e34fe4de 100644 (file)
@@ -539,6 +539,15 @@ class commonCore extends cubeCore
                $db->bourbon_suggestions->suggestion('text', 0, false);\r
                $db->bourbon_suggestions->page('varchar', 256, false);\r
 \r
+               // Table gpu\r
+               $db->gpu->gpu('varchar', 256, false);\r
+               $db->gpu->page('text', 0, false);\r
+               $db->gpu->version('integer', 0, false);\r
+               $db->gpu->date('integer', 0, false);\r
+               $db->gpu->score('integer', 0, false);\r
+               $db->gpu->benchmark('text', 0, false);\r
+               $db->gpu->primary('pk_gpu', 'gpu', 'version');\r
+\r
                try {\r
                        $dbi = new CubeDbStruct($this->con);\r
                        $dbi->synchronize($db);\r
index 77106e171951be12781d68b8cf93ab6a405db3c0..5910ef99d9c9ba2617e2fba4e3817263fa22884c 100644 (file)
@@ -1326,4 +1326,109 @@ class wsServices extends cubeFlashGateway
                $api->subscribe('33699982ca', $data);
 
        }
+
+       public static function gpuSeparators()
+       {
+               return ['Direct3D', 'DirectX', 'OpenGL', 'Graphics'];
+       }
+
+       public function gup()
+       {
+               global $core;
+
+               $this->outputXML = false;
+
+               $gpu = base64_decode($_GET['gup']);
+               if (preg_match('/\(([^\)]*)\)/', $gpu, $matches)) {
+                       $gpu = $matches[1];
+               }
+               $version = 40;
+
+               $split = self::gpuSeparators();
+
+               foreach ($split as $item) {
+                       $e = explode($item, $gpu);
+                       if (count($e) > 1) {
+                               $gpu = $e[0];
+                               break;
+                       }
+               }
+
+               $gpu = trim($gpu);
+
+               $r = $core->con->select("SELECT * FROM gpu WHERE version=" . $version . " AND gpu='" . $core->con->escape($gpu) . "'");
+               header('Content-type: text/plain');
+               if ($r->isEmpty()) {
+                       $ugpu = urlencode($gpu);
+                       $url = 'https://gfxbench.com/device.jsp?benchmark=gfx' . $version . '&api=gl&hwtype=dGPU&os=Linux&hwname=' . $ugpu . '&D=' . $ugpu . '&testgroup=graphics&var=median';
+
+                       $ch = curl_init();
+                       curl_setopt($ch, CURLOPT_URL, $url);
+                       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+                       curl_setopt($ch, CURLOPT_VERBOSE, 1);
+                       curl_setopt($ch, CURLOPT_HEADER, 1);
+                       curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0');
+                       $response = curl_exec($ch);
+                       $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+                       $f = substr($response, $header_size);
+
+                       $doc = new DOMDocument();
+                       $doc->strictErrorChecking = FALSE;
+                       $doc->loadHTML($f);
+                       $xml = simplexml_import_dom($doc);
+
+                       $links = $xml->xpath("//a");
+                       foreach ($links as $link) {
+                               $h = parse_url($link['href']);
+                               if (trim($h['path']) != 'subtest_results_of_device.jsp') {
+                                       continue;
+                               }
+                               parse_str($h['query'], $data);
+                               if (!isset($data['id'])) {
+                                       continue;
+                               }
+                               $values = $link->xpath('span[@class=\'value\']');
+                               if (!count($values)) {
+                                       continue;
+                               }
+                               $value = trim((string)$values[0]);
+                               if ($value == 'N/A') {
+                                       continue;
+                               }
+                               if (!stristr($value, 'frame')) {
+                                       continue;
+                               }
+                               $res[$data['id']] = intval($value);
+                       }
+
+                       $scoreids = [680, 544, 632, 546];
+                       $num = 0;
+                       $score = 0;
+                       foreach ($scoreids as $scoreid) {
+                               if (!isset($res[$scoreid])) {
+                                       continue;
+                               }
+                               $num++;
+                               $score += $res[$scoreid];
+                       }
+
+                       $score /= $num;
+                       $score = round($score);
+
+                       $c = $core->con->openCursor('gpu');
+                       $c->gpu = $gpu;
+                       $c->page = $f;
+                       $c->version = $version;
+                       $c->benchmark = serialize($res);
+                       $c->score = $score;
+                       $c->date = time();
+                       $c->insert();
+
+                       echo $score;
+               } else {
+                       $r->fetch();
+                       echo $r->score;
+               }
+               exit;
+       }
 }
index 97c185e44728725af65fa132e1228735834e266f..ceefad95e006a246742205b90690f07293e4b587 100644 (file)
@@ -336,6 +336,8 @@ class wsHTML5Compiler
                        $this->config->manifest = $this->writeManifest();
                }
 
+               $this->writeGPUDatabase();
+
                if ($this->config->form == 'bulle') {
                        $this->addJsLib('bulle', 'js/libs/fluidbook/forms/fluidbook.form.bulle.js');
                } else if ($this->config->form == 'bourbon') {
@@ -380,6 +382,18 @@ class wsHTML5Compiler
                $this->config->seoArticles = $this->seoArticles;
        }
 
+       public function writeGPUDatabase()
+       {
+               global $core;
+               $r = $core->con->select('SELECT gpu,score FROM gpu');
+               $gpu = [];
+               while ($r->fetch()) {
+                       $gpu[$r->gpu] = $r->score;
+               }
+               $this->config->gupsc = $gpu;
+               $this->config->gupse = wsServices::gpuSeparators();
+       }
+
        public function log($step)
        {
                $currenttime = microtime(true);
@@ -756,7 +770,7 @@ class wsHTML5Compiler
                        $svg = '';
                        foreach ($svgfiles as $svgfile) {
                                if (file_exists($svgfile)) {
-                                       $svg .= str_replace('$bookmark-color',wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor),file_get_contents($svgfile));
+                                       $svg .= str_replace('$bookmark-color', wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor), file_get_contents($svgfile));
                                } else {
                                        die($svgfile . ' does not exist');
                                }