2008-05-21 22:33:21 +00:00
|
|
|
<?php
|
|
|
|
|
2009-11-17 21:38:44 +00:00
|
|
|
ini_set('display_errors', 'stdout');
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
2008-05-21 22:33:21 +00:00
|
|
|
// The platforms for a given project are stored in a file platforms/URL
|
|
|
|
|
|
|
|
function friendly_name($p) {
|
2009-11-17 21:38:44 +00:00
|
|
|
$x = explode('[', $p);
|
|
|
|
$pc = "";
|
|
|
|
if (sizeof($x) > 1) {
|
|
|
|
$p = $x[0];
|
|
|
|
$pc = substr($x[1], 0, -1);
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
2009-11-17 21:38:44 +00:00
|
|
|
|
2008-05-22 03:09:11 +00:00
|
|
|
if (strstr($p, "fubar")) return null;
|
2009-11-17 21:38:44 +00:00
|
|
|
if ($p == 'x86_64-unknown-linux-gnu') return null;
|
|
|
|
$q = $p;
|
|
|
|
switch ($p) {
|
|
|
|
case 'i686-pc-linux-gnu': $q = 'Linux/x86'; break;
|
|
|
|
case 'windows_intelx86': $q = 'Windows'; break;
|
|
|
|
case 'x86_64-pc-linux-gnu': $q = 'Linux/x64'; break;
|
|
|
|
case 'i686-apple-darwin': $q = 'Mac OS X'; break;
|
|
|
|
case 'x86_64-apple-darwin': $q = 'Mac OS X 64-bit'; break;
|
|
|
|
case 'powerpc-apple-darwin': $q = 'Mac OS X (PowerPC)'; break;
|
|
|
|
case 'sparc-sun-solaris2.7': $q = 'SPARC Solaris 2.7'; break;
|
|
|
|
case 'sparc-sun-solaris': $q = 'SPARC Solaris'; break;
|
|
|
|
case 'powerpc64-unknown-linux-gnu': $q = 'Linux/PowerPC64'; break;
|
|
|
|
case 'windows_x86_64': $q = 'Windows/x64'; break;
|
|
|
|
case 'powerpc64-ps3-linux-gnu': $q = 'Playstation3/Linux'; break;
|
2010-03-04 21:23:30 +00:00
|
|
|
case 'i386-portbld-freebsd': $q = 'FreeBSD/x86'; break;
|
|
|
|
case 'windows_amd64': $q = 'Windows/Opteron'; break;
|
|
|
|
case 'x86_64-pc-solaris': $q = 'Solaris/x64'; break;
|
|
|
|
case 'windows_intelx86_64': $q = 'Windows/x64'; break;
|
2012-09-30 20:30:58 +00:00
|
|
|
case 'arm-android-linux-gnu': $q = 'Android/ARM'; break;
|
2013-11-17 19:45:11 +00:00
|
|
|
case 'arm-android': $q = 'Android/ARM'; break;
|
2012-09-30 20:30:58 +00:00
|
|
|
case 'arm-unknown-linux-gnu': $q = 'Linux/ARM'; break;
|
|
|
|
case 'x86_64-pc-freebsd': $q = 'FreeBSD/x86'; break;
|
2013-11-18 23:12:34 +00:00
|
|
|
case 'arm-unknown-linux-gnueabihf': $q = 'Linux on ARM (e.g., Raspberry Pi)';
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
|
|
|
if (strlen($pc)) {
|
|
|
|
if (strstr($pc, 'cuda')) $q .= " (NVIDIA GPU)";
|
2012-05-25 18:44:56 +00:00
|
|
|
else if (strstr($pc, 'ati')) $q .= " (AMD/ATI GPU)";
|
2013-11-17 19:45:11 +00:00
|
|
|
else if (strstr($pc, 'intel_gpu')) $q .= " (Intel GPU)";
|
2009-11-17 21:38:44 +00:00
|
|
|
else if (strstr($pc, 'mt')) $q .= " (multicore)";
|
2013-11-17 19:45:11 +00:00
|
|
|
else if (strstr($pc, 'vbox32')) $q .= " (VirtualBox 32-bit)";
|
|
|
|
else if (strstr($pc, 'vbox64')) $q .= " (VirtualBox 64-bit)";
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
|
|
|
return $q;
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
2013-11-18 23:12:34 +00:00
|
|
|
function get_platform_icon_flags($l) {
|
|
|
|
$x = new StdClass;
|
|
|
|
$x->windows = false;
|
|
|
|
$x->mac = false;
|
|
|
|
$x->linux = false;
|
|
|
|
$x->android = false;
|
2013-11-19 19:23:38 +00:00
|
|
|
$x->freebsd = false;
|
|
|
|
$x->rasp_pi = false;
|
2013-11-18 23:12:34 +00:00
|
|
|
$x->nvidia_gpu = false;
|
|
|
|
$x->amd_gpu = false;
|
|
|
|
$x->intel_gpu = false;
|
|
|
|
$x->vbox = false;
|
|
|
|
foreach ($l as $p) {
|
|
|
|
$y = explode('[', $p);
|
|
|
|
$pc = "";
|
|
|
|
if (sizeof($y) > 1) {
|
|
|
|
$p = $y[0];
|
|
|
|
$pc = substr($y[1], 0, -1);
|
|
|
|
}
|
|
|
|
if (strstr($p, "windows")) $x->windows = true;
|
|
|
|
if (strstr($p, "darwin")) $x->mac = true;
|
|
|
|
if (strstr($p, "linux")) $x->linux = true;
|
|
|
|
if (strstr($p, "android")) $x->android = true;
|
2013-11-19 19:23:38 +00:00
|
|
|
if (strstr($p, "freebsd")) $x->freebsd = true;
|
|
|
|
if (strstr($p, "arm-unknown-linux-gnueabihf")) $x->rasp_pi = true;
|
|
|
|
if (strstr($p, "armv5")) $x->rasp_pi = true;
|
|
|
|
if (strstr($p, "armv6")) $x->rasp_pi = true;
|
2013-11-18 23:12:34 +00:00
|
|
|
if (strstr($pc, "ati")) $x->amd_gpu = true;
|
|
|
|
if (strstr($pc, "cuda")) $x->nvidia_gpu = true;
|
|
|
|
if (strstr($pc, "intel_gpu")) $x->intel_gpu = true;
|
|
|
|
if (strstr($pc, "vbox")) $x->vbox = true;
|
|
|
|
}
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
|
|
|
function platform_icons($f) {
|
|
|
|
$x = "";
|
|
|
|
$ht = 40;
|
|
|
|
$hs = 5;
|
|
|
|
if ($f->windows) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/windows.jpg title=\"Supports Microsoft Windows\">";
|
|
|
|
}
|
|
|
|
if ($f->mac) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/mac.jpg title=\"Supports Mac OS X\">";
|
|
|
|
}
|
|
|
|
if ($f->linux) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/linux.jpg title=\"Supports Linux\">";
|
|
|
|
}
|
|
|
|
if ($f->android) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/android.png title=\"Supports Android\">";
|
|
|
|
}
|
2013-11-19 19:23:38 +00:00
|
|
|
if ($f->freebsd) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/freebsd.png title=\"Supports FreeBSD\">";
|
|
|
|
}
|
|
|
|
if ($f->rasp_pi) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/raspberry-pi.jpg title=\"Supports Raspberry Pi\">";
|
|
|
|
}
|
2013-11-18 23:12:34 +00:00
|
|
|
if ($f->nvidia_gpu) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/nvidia.jpg title=\"Supports NVIDIA GPUs\">";
|
|
|
|
}
|
|
|
|
if ($f->amd_gpu) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/amd_gpu.jpg title=\"Supports AMD GPUs\">";
|
|
|
|
}
|
|
|
|
if ($f->intel_gpu) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/intel_gpu.jpg title=\"Supports Intel GPUs\">";
|
|
|
|
}
|
|
|
|
if ($f->vbox) {
|
|
|
|
$x .= "<img hspace=$hs height=$ht src=images/vbox.jpg title=\"Supports VirtualBox\">";
|
|
|
|
}
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2011-05-13 22:04:10 +00:00
|
|
|
function canonical_plan_class($pc) {
|
2012-05-15 17:29:53 +00:00
|
|
|
if (strstr($pc, "atiOpenCL")) return "opencl_ati";
|
|
|
|
if (strstr($pc, "nvidiaOpenCL")) return "opencl_nvidia";
|
2013-11-18 23:12:34 +00:00
|
|
|
if (strstr($pc, "intelOpenCL")) return "opencl_intel_gpu";
|
|
|
|
return $pc;
|
2011-05-13 22:04:10 +00:00
|
|
|
}
|
|
|
|
|
2009-11-17 21:38:44 +00:00
|
|
|
// get platforms from get_project_config.php (preferred method)
|
|
|
|
//
|
2010-02-07 04:01:11 +00:00
|
|
|
// format is either
|
|
|
|
//
|
|
|
|
// <project_config>
|
|
|
|
// <platforms>
|
|
|
|
// <platform>windows_intelx86</platform>
|
|
|
|
// ...
|
|
|
|
//
|
|
|
|
// or
|
|
|
|
//
|
|
|
|
// <project_config>
|
|
|
|
// <platforms>
|
|
|
|
// <platform>
|
|
|
|
// <platform_name>windows_intelx86</platform_name>
|
|
|
|
// <user_friendly_name>Windows</user_friendly_name>
|
|
|
|
// [<plan_class>xxx</plan_class>]
|
|
|
|
// </platform>
|
|
|
|
// ...
|
|
|
|
//
|
2013-11-17 19:45:11 +00:00
|
|
|
function get_platforms($url) {
|
2013-11-19 19:23:38 +00:00
|
|
|
if (strstr($url, "radioactive")) return null;
|
2009-01-13 19:34:04 +00:00
|
|
|
$url .= 'get_project_config.php';
|
2009-12-04 21:21:18 +00:00
|
|
|
$x = @file_get_contents($url);
|
2013-11-17 19:45:11 +00:00
|
|
|
if (!$x) {
|
|
|
|
//echo "no file $url";
|
|
|
|
return null;
|
|
|
|
}
|
2009-12-04 21:21:18 +00:00
|
|
|
libxml_use_internal_errors(true);
|
2013-11-17 19:45:11 +00:00
|
|
|
$x = trim($x);
|
2009-12-04 21:21:18 +00:00
|
|
|
$s = simplexml_load_string($x);
|
2013-11-17 19:45:11 +00:00
|
|
|
if (!$s) {
|
|
|
|
//echo "XML parse error";
|
|
|
|
return null;
|
|
|
|
}
|
2010-02-07 04:01:11 +00:00
|
|
|
if (!array_key_exists('platforms', $s)) {
|
|
|
|
return null;
|
|
|
|
}
|
2009-11-17 21:38:44 +00:00
|
|
|
$p = $s->platforms;
|
2010-02-07 04:01:11 +00:00
|
|
|
//print_r($p);
|
|
|
|
//echo "---\n";
|
|
|
|
//foreach ($p->children() as $x) {
|
|
|
|
// echo $x;
|
|
|
|
//}
|
|
|
|
if (!array_key_exists('platform', $p)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (sizeof($p->platform) == 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$list = array();
|
2009-11-17 21:38:44 +00:00
|
|
|
if (array_key_exists(0, $p->platform[0])) {
|
2010-02-07 04:01:11 +00:00
|
|
|
foreach ($p->children() as $r) {
|
|
|
|
$list[] = (string)$r;
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach ($p->platform as $r) {
|
2012-04-14 04:48:20 +00:00
|
|
|
$plat = (string)$r->platform_name;
|
2009-11-17 21:38:44 +00:00
|
|
|
if (array_key_exists('plan_class', $r)) {
|
2011-05-13 22:04:10 +00:00
|
|
|
$pc = canonical_plan_class((string)$r->plan_class);
|
2012-04-14 04:48:20 +00:00
|
|
|
if ($pc) {
|
|
|
|
$plat .= "[".$pc."]";
|
|
|
|
}
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
2012-04-14 04:48:20 +00:00
|
|
|
$list[] = $plat;
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
|
|
|
return array_unique($list);
|
|
|
|
}
|
|
|
|
|
2009-11-17 21:38:44 +00:00
|
|
|
// get platforms from app.php?xml=1 (deprecated)
|
|
|
|
//
|
2009-01-13 19:34:04 +00:00
|
|
|
function get_platforms2($url) {
|
|
|
|
$url .= 'apps.php?xml=1';
|
2009-12-04 21:21:18 +00:00
|
|
|
$x = @file_get_contents($url);
|
2013-11-17 19:45:11 +00:00
|
|
|
if (!$x) {
|
|
|
|
//echo "no file $url\n";
|
|
|
|
return null;
|
|
|
|
}
|
2009-12-04 21:21:18 +00:00
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
$s = simplexml_load_string($x);
|
2009-01-13 19:34:04 +00:00
|
|
|
$list = null;
|
2009-11-17 21:38:44 +00:00
|
|
|
foreach($s->application as $a) {
|
|
|
|
foreach ($a->version as $v) {
|
|
|
|
if (!array_key_exists('platform_short', $v)) continue;
|
|
|
|
$p = $v->platform_short[0];
|
|
|
|
$pc = "";
|
|
|
|
if (array_key_exists('plan_class', $v)) {
|
2011-05-13 22:04:10 +00:00
|
|
|
$pc = (string)$v->plan_class;
|
|
|
|
$pc = canonical_plan_class($pc);
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
|
|
|
if (strlen($pc)) {
|
2009-12-04 21:21:18 +00:00
|
|
|
$p = $p.'['.$pc.']';
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
2009-12-04 21:21:18 +00:00
|
|
|
$list[] = (string)$p;
|
2009-11-17 21:38:44 +00:00
|
|
|
}
|
2009-01-13 19:34:04 +00:00
|
|
|
}
|
|
|
|
return array_unique($list);
|
|
|
|
}
|
|
|
|
|
2009-01-08 19:12:13 +00:00
|
|
|
// convert an array of platform names into a comma-separated
|
|
|
|
// list of human-readable names
|
|
|
|
//
|
2013-11-18 23:12:34 +00:00
|
|
|
function make_friendly_string($l, $comma) {
|
2009-01-08 19:12:13 +00:00
|
|
|
if (!count($l)) return "Unknown";
|
2013-11-18 23:12:34 +00:00
|
|
|
$fn = array();
|
2008-05-21 22:33:21 +00:00
|
|
|
foreach($l as $p) {
|
2009-01-08 19:12:13 +00:00
|
|
|
$p = friendly_name($p);
|
|
|
|
if (!$p) continue;
|
2013-11-18 23:12:34 +00:00
|
|
|
$fn[] = $p;
|
|
|
|
}
|
|
|
|
$fn = array_unique($fn);
|
|
|
|
$x = "";
|
|
|
|
$first = true;
|
|
|
|
foreach($fn as $p) {
|
2008-05-21 22:33:21 +00:00
|
|
|
if ($first) {
|
|
|
|
$x .= "$p";
|
|
|
|
$first = false;
|
|
|
|
} else {
|
2013-11-18 23:12:34 +00:00
|
|
|
if ($comma) {
|
|
|
|
$x .= ", $p";
|
|
|
|
} else {
|
|
|
|
$x .= "<br>$p";
|
|
|
|
}
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $x;
|
|
|
|
}
|
|
|
|
|
2009-01-08 19:12:13 +00:00
|
|
|
// return platforms as an array of platform names
|
|
|
|
//
|
2008-05-22 03:09:11 +00:00
|
|
|
function get_platforms_cached($url) {
|
2008-05-21 22:33:21 +00:00
|
|
|
$u = urlencode($url);
|
|
|
|
$fname = "/home/boincadm/boinc/doc/platforms/$u";
|
|
|
|
$t = @filemtime($fname);
|
2013-07-17 04:57:28 +00:00
|
|
|
if ($t && $t > time() - 604800) {
|
2008-05-21 22:33:21 +00:00
|
|
|
$l = json_decode(file_get_contents($fname));
|
|
|
|
} else {
|
|
|
|
$l = get_platforms($url);
|
2009-01-13 19:34:04 +00:00
|
|
|
if (!$l) {
|
|
|
|
$l = get_platforms2($url);
|
|
|
|
}
|
2008-05-21 22:33:21 +00:00
|
|
|
if ($l) {
|
|
|
|
file_put_contents($fname, json_encode($l));
|
|
|
|
} else {
|
2008-06-05 18:36:31 +00:00
|
|
|
if (file_exists($fname)) {
|
|
|
|
touch($fname);
|
|
|
|
} else {
|
2008-05-21 22:33:21 +00:00
|
|
|
$l[] = "Unknown";
|
|
|
|
file_put_contents($fname, json_encode($l));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-08 19:12:13 +00:00
|
|
|
return $l;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return platforms as a human-readable string
|
|
|
|
//
|
2013-11-18 23:12:34 +00:00
|
|
|
function get_platforms_string($url, $comma=true) {
|
2009-01-08 19:12:13 +00:00
|
|
|
$l = get_platforms_cached($url);
|
2013-11-18 23:12:34 +00:00
|
|
|
return make_friendly_string($l, $comma);
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_platform_icons($url) {
|
|
|
|
$l = get_platforms_cached($url);
|
|
|
|
$flags = get_platform_icon_flags($l);
|
|
|
|
return platform_icons($flags);
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
2009-01-08 19:12:13 +00:00
|
|
|
|
2010-02-07 04:01:11 +00:00
|
|
|
//$u = "http://www.worldcommunitygrid.org/";
|
2013-11-19 19:23:38 +00:00
|
|
|
//$u = "http://asteroidsathome.net/boinc/";
|
2010-02-07 04:01:11 +00:00
|
|
|
//$u = "http://setiathome.berkeley.edu/";
|
2011-05-13 22:04:10 +00:00
|
|
|
//$u = "http://aqua.dwavesys.com/";
|
2012-04-14 04:48:20 +00:00
|
|
|
//$u = "http://lhcathome2.cern.ch/test4theory";
|
2013-11-17 19:45:11 +00:00
|
|
|
//$u = "http://www.rnaworld.de/rnaworld/";
|
|
|
|
//$u = "http://boinc.gorlaeus.net/";
|
2013-11-18 23:12:34 +00:00
|
|
|
//$u = "http://einstein.phys.uwm.edu/";
|
2010-02-07 04:01:11 +00:00
|
|
|
//$x = get_platforms($u);
|
|
|
|
//print_r($x);
|
2013-11-17 19:45:11 +00:00
|
|
|
//echo get_platforms_string($u);
|
2012-02-08 19:30:57 +00:00
|
|
|
//$x = "http://sat.isa.ru/pdsat/";
|
|
|
|
//print_r( get_platforms($x));
|
|
|
|
|
2008-05-21 22:33:21 +00:00
|
|
|
|
2013-11-18 23:12:34 +00:00
|
|
|
// Mediawiki extension to show a project's platforms.
|
|
|
|
//
|
2008-05-21 22:33:21 +00:00
|
|
|
function wfPlatforms() {
|
|
|
|
global $wgParser;
|
2009-01-08 19:12:13 +00:00
|
|
|
$wgParser->setHook( "platforms", "get_platforms_string" );
|
2008-05-21 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$wgExtensionFunctions[] = "wfPlatforms";
|
|
|
|
|
|
|
|
?>
|