From: vincent@cubedesigners.com Date: Wed, 12 Dec 2018 17:47:54 +0000 (+0000) Subject: wip #2428 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=56c5892403ac33d1cde4d8e73ca4bc9e9f11911e;p=cubeextranet.git wip #2428 @2 --- diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index b8b28490e..6b2628367 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -539,6 +539,15 @@ class commonCore extends cubeCore $db->bourbon_suggestions->suggestion('text', 0, false); $db->bourbon_suggestions->page('varchar', 256, false); + // Table gpu + $db->gpu->gpu('varchar', 256, false); + $db->gpu->page('text', 0, false); + $db->gpu->version('integer', 0, false); + $db->gpu->date('integer', 0, false); + $db->gpu->score('integer', 0, false); + $db->gpu->benchmark('text', 0, false); + $db->gpu->primary('pk_gpu', 'gpu', 'version'); + try { $dbi = new CubeDbStruct($this->con); $dbi->synchronize($db); diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 77106e171..5910ef99d 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -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; + } } diff --git a/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php b/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php index 97c185e44..ceefad95e 100644 --- a/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php @@ -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'); }