How to use executable_in_path method of pts_client class

Best Phoronix-test-suite code snippet using pts_client.executable_in_path

phodevi_system.php

Source:phodevi_system.php Github

copy

Full Screen

...122 }123 public static function sw_system_layer()124 {125 $layer = null;126 if(phodevi::is_windows() && pts_client::executable_in_path('winecfg.exe') && ($wine = phodevi::read_property('system', 'wine-version')))127 {128 $layer = $wine;129 }130 else131 {132 // Report virtualization133 $layer = phodevi::read_property('system', 'virtualized-mode');134 }135 return $layer;136 }137 public static function sw_hostname()138 {139 $hostname = 'Unknown';140 if(($bin = pts_client::executable_in_path('hostname')))141 {142 $hostname = trim(shell_exec($bin . ' 2>&1'));143 }144 else if(phodevi::is_windows())145 {146 $hostname = getenv('USERDOMAIN');147 }148 return $hostname;149 }150 public static function sw_vendor_identifier()151 {152 // Returns the vendor identifier used with the External Dependencies and other distro-specific features153 $vendor = phodevi::is_linux() ? phodevi_linux_parser::read_lsb_distributor_id() : false;154 if(!$vendor)155 {156 $vendor = phodevi::read_property('system', 'operating-system');157 if(($spos = strpos($vendor, ' ')) > 1)158 {159 $vendor = substr($vendor, 0, $spos);160 }161 }162 return str_replace(array(' ', '/'), '', strtolower($vendor));163 }164 public static function sw_filesystem()165 {166 // Determine file-system type167 $fs = null;168 if(phodevi::is_macosx())169 {170 $fs = phodevi_osx_parser::read_osx_system_profiler('SPSerialATADataType', 'FileSystem');171 if($fs == null && pts_client::executable_in_path('mount'))172 {173 $mount = shell_exec('mount 2>&1');174 if(stripos($mount, ' on / (hfs, local, journaled)') !== false)175 {176 $fs = 'Journaled HFS+';177 }178 else if(stripos($mount, ' on / (hfs') !== false)179 {180 $fs = 'HFS+';181 }182 }183 }184 else if(phodevi::is_bsd())185 {186 if(pts_client::executable_in_path('mount'))187 {188 $mount = shell_exec('mount 2>&1');189 if(($start = strpos($mount, 'on / (')) != false)190 {191 // FreeBSD, DragonflyBSD mount formatting192 /*193 -bash-4.0$ mount194 ROOT on / (hammer, local)195 /dev/da0s1a on /boot (ufs, local)196 /pfs/@@-1:00001 on /var (null, local)197 /pfs/@@-1:00002 on /tmp (null, local)198 /pfs/@@-1:00003 on /usr (null, local)199 /pfs/@@-1:00004 on /home (null, local)200 /pfs/@@-1:00005 on /usr/obj (null, local)201 /pfs/@@-1:00006 on /var/crash (null, local)202 /pfs/@@-1:00007 on /var/tmp (null, local)203 procfs on /proc (procfs, local)204 */205 // TODO: improve this in case there are other partitions, etc206 $fs = substr($mount, $start + 6);207 $fs = substr($fs, 0, strpos($fs, ','));208 }209 else if(($start = strpos($mount, 'on / type')) != false)210 {211 // OpenBSD 5.0 formatting is slightly different from above FreeBSD example212 // TODO: improve this in case there are other partitions, etc213 $fs = substr($mount, $start + 10);214 $fs = substr($fs, 0, strpos($fs, ' '));215 }216 }217 }218 else if(phodevi::is_hurd())219 {220 // Very rudimentary Hurd filesystem detection support but works for at least a clean Debian GNU/Hurd EXT2 install221 if(pts_client::executable_in_path('mount'))222 {223 $mount = shell_exec('mount 2>&1');224 if(($start = strpos($mount, 'on / type')) != false)225 {226 $fs = substr($mount, $start + 10);227 $fs = substr($fs, 0, strpos($fs, ' '));228 if(substr($fs, -2) == 'fs')229 {230 $fs = substr($fs, 0, -2);231 }232 }233 }234 }235 else if(phodevi::is_linux() || phodevi::is_solaris())236 {237 $fs = trim(shell_exec('stat ' . pts_client::test_install_root_path() . ' -L -f -c %T 2> /dev/null'));238 switch($fs)239 {240 case 'ext2/ext3':241 if(isset(phodevi::$vfs->mounts))242 {243 $fstab = phodevi::$vfs->mounts;244 $fstab = str_replace('/boot ', 'IGNORE', $fstab);245 $using_ext2 = strpos($fstab, ' ext2') !== false;246 $using_ext3 = strpos($fstab, ' ext3') !== false;247 $using_ext4 = strpos($fstab, ' ext4') !== false;248 if(!$using_ext2 && !$using_ext3 && $using_ext4)249 {250 $fs = 'ext4';251 }252 else if(!$using_ext2 && !$using_ext4 && $using_ext3)253 {254 $fs = 'ext3';255 }256 else if(!$using_ext3 && !$using_ext4 && $using_ext2)257 {258 $fs = 'ext2';259 }260 else if(is_dir('/proc/fs/ext4/'))261 {262 $fs = 'ext4';263 }264 else if(is_dir('/proc/fs/ext3/'))265 {266 $fs = 'ext3';267 }268 }269 break;270 case 'Case-sensitive Journaled HFS+':271 $fs = 'HFS+';272 break;273 case 'MS-DOS FAT32':274 $fs = 'FAT32';275 break;276 case 'UFSD_NTFS_COMPR':277 $fs = 'NTFS';278 break;279 case 'ecryptfs':280 if(isset(phodevi::$vfs->mounts))281 {282 // An easy attempt to determine what file-system is underneath ecryptfs if being compared283 // For now just attempt to figure out the root file-system.284 if(($s = strrpos(phodevi::$vfs->mounts, ' / ')) !== false)285 {286 $s = substr(phodevi::$vfs->mounts, ($s + 3));287 $s = substr($s, 0, strpos($s, ' '));288 if($s != null && !isset($s[18]) && $s != 'rootfs'&& pts_strings::string_only_contains($s, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC))289 {290 $fs = $s . ' (ecryptfs)';291 }292 }293 }294 break;295 default:296 if(substr($fs, 0, 9) == 'UNKNOWN (')297 {298 $magic_block = substr($fs, 9, -1);299 $known_magic_blocks = array(300 '0x9123683e' => 'Btrfs',301 '0x2fc12fc1' => 'zfs', // KQ Infotech ZFS302 '0x482b' => 'HFS+',303 '0x65735546' => 'FUSE',304 '0x565a4653' => 'ReiserFS',305 '0x52345362' => 'Reiser4',306 '0x3434' => 'NILFS2',307 '0x5346414f' => 'OpenAFS',308 '0x47504653' => 'GPFS',309 '0x5941ff53' => 'YAFFS',310 '0xff534d42' => 'CIFS',311 '0x24051905' => 'UBIFS',312 '0x1021994' => 'TMPFS',313 '0x73717368' => 'SquashFS',314 '0xc97e8168' => 'LogFS',315 '0x5346544E' => 'NTFS',316 '0xf15f' => 'eCryptfs',317 '0x61756673' => 'AuFS',318 '0xbd00bd0' => 'Lustre',319 '0xaad7aaea' => 'PanFS', // Panasas FS320 '0xf2f52010' => 'F2FS',321 '0xc36400' => 'CephFS',322 '0xca451a4e' => 'BcacheFS'323 );324 foreach($known_magic_blocks as $hex => $name)325 {326 if($magic_block == $hex)327 {328 $fs = $name;329 break;330 }331 }332 }333 break;334 }335 if(strpos($fs, 'UNKNOWN') !== false && isset(phodevi::$vfs->mounts))336 {337 $mounts = phodevi::$vfs->mounts;338 $fs_r = array();339 $fs_checks = array(340 'squashfs' => 'SquashFS',341 'aufs' => 'AuFS',342 'unionfs' => 'UnionFS'343 );344 foreach($fs_checks as $fs_module => $fs_name)345 {346 if(strpos($mounts, $fs_module) != false)347 {348 array_push($fs_r, $fs_name);349 }350 }351 if(count($fs_r) > 0)352 {353 $fs = implode(' + ', $fs_r);354 }355 }356 }357 else if(phodevi::is_windows())358 {359 return null;360 }361 if(empty($fs))362 {363 $fs = 'Unknown';364 }365 return $fs;366 }367 public static function sw_virtualized_mode()368 {369 // Reports if system is running virtualized370 $virtualized = null;371 $mobo = phodevi::read_name('motherboard');372 $gpu = phodevi::read_name('gpu');373 $cpu = phodevi::read_property('cpu', 'model');374 if(strpos($cpu, 'QEMU') !== false || (is_readable('/sys/class/dmi/id/bios_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/bios_vendor') == 'QEMU'))375 {376 $virtualized = 'QEMU';377 if(strpos($cpu, 'QEMU Virtual') !== false)378 {379 $qemu_version = substr($cpu, (strrpos($cpu, ' ') + 1));380 if(pts_strings::is_version($qemu_version))381 {382 $virtualized .= ' ' . $qemu_version;383 }384 }385 }386 else if(stripos($gpu, 'VMware') !== false || (is_readable('/sys/class/dmi/id/product_name') && stripos(pts_file_io::file_get_contents('/sys/class/dmi/id/product_name'), 'VMware') !== false))387 {388 $virtualized = 'VMware';389 }390 else if(stripos($gpu, 'VirtualBox') !== false || stripos(phodevi::read_name('motherboard'), 'VirtualBox') !== false)391 {392 $virtualized = 'VirtualBox';393 if($vbox_manage = pts_client::executable_in_path('VBoxManage'))394 {395 $vbox_manage = trim(shell_exec($vbox_manage . ' --version 2> /dev/null'));396 if(is_numeric(substr($vbox_manage, 0, 1)))397 {398 $virtualized .= ' ' . $vbox_manage;399 }400 }401 else if($modinfo = pts_client::executable_in_path('modinfo'))402 {403 $modinfo = trim(shell_exec('modinfo -F version vboxguest 2> /dev/null'));404 if($modinfo != null && pts_strings::is_version(str_ireplace(array('_', 'RC', 'beta'), null, $modinfo)))405 {406 $virtualized .= ' ' . $modinfo;407 }408 }409 }410 else if(is_file('/sys/class/dmi/id/sys_vendor') && pts_file_io::file_get_contents('/sys/class/dmi/id/sys_vendor') == 'Xen')411 {412 $virtualized = pts_file_io::file_get_contents('/sys/class/dmi/id/product_name');413 if(strpos($virtualized, 'Xen') === false)414 {415 $virtualized = 'Xen ' . $virtualized;416 }417 // version string418 $virtualized .= ' ' . pts_file_io::file_get_contents('/sys/class/dmi/id/product_version');419 // $virtualized should be then e.g. 'Xen HVM domU 4.1.1'420 }421 else if(stripos($gpu, 'Microsoft Hyper-V') !== false)422 {423 $virtualized = 'Microsoft Hyper-V Server';424 }425 else if(stripos($mobo, 'Parallels Software') !== false)426 {427 $virtualized = 'Parallels Virtualization';428 }429 else if(is_file('/sys/hypervisor/type'))430 {431 $type = pts_file_io::file_get_contents('/sys/hypervisor/type');432 $version = array();433 foreach(array('major', 'minor', 'extra') as $v)434 {435 if(is_file('/sys/hypervisor/version/' . $v))436 {437 $v = pts_file_io::file_get_contents('/sys/hypervisor/version/' . $v);438 }439 else440 {441 continue;442 }443 if($v != null)444 {445 if(!empty($version) && substr($v, 0, 1) != '.')446 {447 $v = '.' . $v;448 }449 array_push($version, $v);450 }451 }452 $virtualized = ucwords($type) . ' ' . implode('', $version) . ' Hypervisor';453 }454 if($systemd_virt = pts_client::executable_in_path('systemd-detect-virt'))455 {456 $systemd_virt = trim(shell_exec($systemd_virt . ' 2> /dev/null'));457 if($systemd_virt != null && $systemd_virt != 'none')458 {459 switch($systemd_virt)460 {461 case 'kvm':462 $systemd_virt = 'KVM';463 break;464 case 'oracle':465 $systemd_virt = 'Oracle';466 break;467 }468 if($virtualized != null && stripos($virtualized, $systemd_virt) === false && stripos($systemd_virt, $virtualized) === false)469 {470 $virtualized = $systemd_virt . ' ' . $virtualized;471 }472 else if($virtualized == null)473 {474 $virtualized = $systemd_virt;475 }476 }477 }478 return $virtualized;479 }480 public static function sw_environment_variables()481 {482 $check_variables = array('LIBGL', '__GL', 'DRI_');483 $to_report = array();484 if(stripos(phodevi::read_property('system', 'opengl-driver'), 'Mesa'))485 {486 array_push($check_variables, 'MESA', 'GALLIUM');487 }488 if(isset($_SERVER))489 {490 foreach($_SERVER as $name => &$value)491 {492 foreach($check_variables as $var)493 {494 if(stripos($name, $var) !== false && $name != '__GL_SYNC_TO_VBLANK')495 {496 array_push($to_report, $name . '=' . $value);497 break;498 }499 }500 }501 }502 return implode(' ', array_unique($to_report));503 }504 public static function sw_compiler()505 {506 // Returns version of the compiler (if present)507 $compilers = array();508 if($gcc = pts_client::executable_in_path('gcc'))509 {510 if(!is_link($gcc) || strpos(readlink($gcc), 'gcc') !== false)511 {512 // GCC513 // If it's a link, ensure that it's not linking to llvm/clang or something514 $version = trim(shell_exec('gcc -dumpversion 2>&1'));515 if(pts_strings::is_version($version))516 {517 $v = shell_exec('gcc -v 2>&1');518 if(($t = strrpos($v, $version . ' ')) !== false)519 {520 $v = substr($v, ($t + strlen($version) + 1));521 $v = substr($v, 0, strpos($v, ' '));522 if($v != null && is_numeric($v))523 {524 // On development versions the release date is expressed525 // e.g. gcc version 4.7.0 20120314 (prerelease) (GCC)526 $version .= ' ' . $v;527 }528 else529 {530 $v = shell_exec('gcc --version 2>&1');531 if(($t = strrpos($v, $version)) !== false)532 {533 $v = substr($v, $t);534 $v = substr($v, 0, strpos(str_replace(PHP_EOL, ' ', $v), ' '));535 if(($t = strpos($v, ')')) !== false)536 {537 $v = substr($v, 0, $t);538 }539 if(pts_strings::is_version($version))540 {541 $version = $v;542 }543 }544 }545 }546 $compilers['gcc'] = 'GCC ' . $version;547 }548 }549 }550 if(pts_client::executable_in_path('opencc'))551 {552 // Open64553 $compilers['opencc'] = 'Open64 ' . trim(shell_exec('opencc -dumpversion 2>&1'));554 }555 if(pts_client::executable_in_path('pathcc'))556 {557 // PathCC / EKOPath / PathScale Compiler Suite558 $compilers['pathcc'] = 'PathScale ' . trim(shell_exec('pathcc -dumpversion 2>&1'));559 }560 if(pts_client::executable_in_path('tcc'))561 {562 // TCC - Tiny C Compiler563 $tcc = explode(' ', trim(shell_exec('tcc -v 2>&1')));564 if($tcc[1] == 'version')565 {566 $compilers['opencc'] = 'TCC ' . $tcc[2];567 }568 }569 if(pts_client::executable_in_path('pcc'))570 {571 // PCC - Portable C Compiler572 $pcc = explode(' ', trim(shell_exec('pcc -version 2>&1')));573 if($pcc[0] == 'pcc')574 {575 $compilers['pcc'] = 'PCC ' . $pcc[1] . (is_numeric($pcc[2]) ? ' ' . $pcc[2] : null);576 }577 }578 if(pts_client::executable_in_path('pgcpp') || pts_client::executable_in_path('pgCC'))579 {580 // The Portland Group Compilers581 $compilers['pgcpp'] = 'PGI C-C++ Workstation';582 }583 if(pts_client::executable_in_path('clang'))584 {585 // Clang586 $compiler_info = shell_exec('clang --version 2> /dev/null');587 if(($cv_pos = stripos($compiler_info, 'clang version')) !== false)588 {589 // With Clang 3.0 and prior, the --version produces output where the first line is:590 // e.g. clang version 3.0 (branches/release_30 142590)591 $compiler_info = substr($compiler_info, ($cv_pos + 14));592 $clang_version = substr($compiler_info, 0, strpos($compiler_info, ' '));593 // XXX: the below check bypass now because e.g. Ubuntu appends '-ubuntuX', etc that breaks check594 if(pts_strings::is_version($clang_version) || true)595 {596 // Also see if there is a Clang SVN tag to fetch597 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));598 if(($cv_pos = strpos($compiler_info, ')')) !== false)599 {600 $compiler_info = substr($compiler_info, 0, $cv_pos);601 $compiler_info = substr($compiler_info, (strrpos($compiler_info, ' ') + 1));602 if(is_numeric($compiler_info))603 {604 // Right now Clang/LLVM uses SVN system and their revisions are only numeric605 $clang_version .= ' (SVN ' . $compiler_info . ')';606 }607 }608 $compiler_info = 'Clang ' . $clang_version;609 }610 else611 {612 $compiler_info = null;613 }614 }615 else616 {617 $compiler_info = substr($compiler_info, 0, strpos($compiler_info, PHP_EOL));618 }619 // Clang620 if(empty($compiler_info) && stripos($compiler_info, 'not found'))621 {622 // At least with Clang ~3.0 the -dumpversion is reporting '4.2.1' ratherthan the useful information...623 // This is likely just for GCC command compatibility, so only use this as a fallback624 $compiler_info = 'Clang ' . trim(shell_exec('clang -dumpversion 2> /dev/null'));625 }626 $compilers['clang'] = $compiler_info;627 }628 if(($llvm_ld = pts_client::executable_in_path('llvm-link')) || ($llvm_ld = pts_client::executable_in_path('llvm-ld')))629 {630 // LLVM - Low Level Virtual Machine631 // Reading the version from llvm-ld (the LLVM linker) should be safe as well for finding out version of LLVM in use632 // As of LLVM 3.2svn, llvm-ld seems to be llvm-link633 $info = trim(shell_exec($llvm_ld . ' -version 2> /dev/null'));634 if(($s = strpos($info, 'version')) != false)635 {636 $info = substr($info, 0, strpos($info, PHP_EOL, $s));637 $info = substr($info, (strrpos($info, ' ') + 1));638 if(pts_strings::is_version(str_replace('svn', null, $info)))639 {640 $compilers['llvmc'] = 'LLVM ' . $info;641 }642 }643 }644 else if(pts_client::executable_in_path('llvm-config'))645 {646 // LLVM - Low Level Virtual Machine config647 $info = trim(shell_exec('llvm-config --version 2> /dev/null'));648 if(pts_strings::is_version(str_replace('svn', null, $info)))649 {650 $compilers['llvmc'] = 'LLVM ' . $info;651 }652 }653 else if(pts_client::executable_in_path('llvmc'))654 {655 // LLVM - Low Level Virtual Machine (llvmc)656 $info = trim(shell_exec('llvmc -version 2>&1'));657 if(($s = strpos($info, 'version')) != false)658 {659 $info = substr($info, 0, strpos($info, "\n", $s));660 $info = substr($info, strrpos($info, "\n"));661 $compilers['llvmc'] = trim($info);662 }663 }664 if(pts_client::executable_in_path('suncc'))665 {666 // Sun Studio / SunCC667 $info = trim(shell_exec('suncc -V 2>&1'));668 if(($s = strpos($info, 'Sun C')) != false)669 {670 $info = substr($info, $s);671 $info = substr($info, 0, strpos($info, "\n"));672 $compilers['suncc'] = $info;673 }674 }675 if(pts_client::executable_in_path('ioc'))676 {677 // Intel Offline Compiler (IOC) SDK for OpenCL678 // -v e.g. : Intel(R) SDK for OpenCL* - Offline Compiler 2012 Command-Line Client, version 1.0.2679 $info = trim(shell_exec('ioc -version 2>&1')) . ' ';680 if(($s = strpos($info, 'Offline Compiler ')) != false)681 {682 $compilers['ioc'] = 'Intel IOC SDK';683 $sv = substr($info, ($s + 17));684 $sv = substr($sv, 0, strpos($sv, ' '));685 if(is_numeric($sv))686 {687 $compilers['ioc'] .= ' ' . $sv;688 }689 if(($s = strpos($info, 'version ')) != false)690 {691 $sv = substr($info, ($s + 8));692 $sv = substr($sv, 0, strpos($sv, ' '));693 if(pts_strings::is_version($sv))694 {695 $compilers['ioc'] .= ' v' . $sv;696 }697 }698 }699 }700 if(pts_client::executable_in_path('icc'))701 {702 // Intel C++ Compiler703 $compilers['icc'] = 'ICC';704 }705 if(phodevi::is_macosx() && pts_client::executable_in_path('xcodebuild'))706 {707 $xcode = phodevi_osx_parser::read_osx_system_profiler('SPDeveloperToolsDataType', 'Xcode');708 $xcode = substr($xcode, 0, strpos($xcode, ' '));709 if($xcode)710 {711 $compilers['Xcode'] = 'Xcode ' . $xcode;712 }713 }714 if(($nvcc = pts_client::executable_in_path('nvcc')) || is_executable(($nvcc = '/usr/local/cuda/bin/nvcc')))715 {716 // Check outside of PATH too since by default the CUDA Toolkit goes to '/usr/local/cuda/' and relies upon user to update system717 // NVIDIA CUDA Compiler Driver718 $nvcc = shell_exec($nvcc . ' --version 2>&1');719 if(($s = strpos($nvcc, 'release ')) !== false)720 {721 $nvcc = str_replace(array(','), null, substr($nvcc, ($s + 8)));722 $nvcc = substr($nvcc, 0, strpos($nvcc, ' '));723 if(pts_strings::is_version($nvcc))724 {725 $compilers['CUDA'] = 'CUDA ' . $nvcc;726 }727 }728 }729 // Try to make the compiler that's used by default to appear first730 if(pts_client::read_env('CC') && isset($compilers[basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '))]))731 {732 $cc_env = basename(pts_strings::first_in_string(pts_client::read_env('CC'), ' '));733 $default_compiler = $compilers[$cc_env];734 unset($compilers[$cc_env]);735 array_unshift($compilers, $default_compiler);736 }737 else if(pts_client::executable_in_path('cc') && is_link(pts_client::executable_in_path('cc')))738 {739 $cc_link = basename(readlink(pts_client::executable_in_path('cc')));740 if(isset($compilers[$cc_link]))741 {742 $default_compiler = $compilers[$cc_link];743 unset($compilers[pts_client::read_env('CC')]);744 array_unshift($compilers, $default_compiler);745 }746 }747 return implode(' + ', array_unique($compilers));748 }749 public static function sw_kernel_string()750 {751 return trim(phodevi::read_property('system', 'kernel') . ' (' . phodevi::read_property('system', 'kernel-architecture') . ') ' . phodevi::read_property('system', 'kernel-date'));752 }753 public static function sw_kernel_date()754 {755 $date = null;756 $k = phodevi::read_property('system', 'kernel');757 if(strpos($k, '99') !== false || stripos($k, 'rc') !== false)758 {759 // For now at least only report kernel build date when it looks like it's a devel kernel760 $v = php_uname('v');761 if(($x = stripos($v, 'SMP ')) !== false)762 {763 $v = substr($v, ($x + 4));764 $date = strtotime($v);765 if($date != false)766 {767 $date = date('Ymd', $date);768 }769 }770 }771 return $date;772 }773 public static function sw_kernel()774 {775 return php_uname('r');776 }777 public static function sw_kernel_parameters()778 {779 $parameters = null;780 if(is_file('/proc/cmdline') && is_file('/proc/modules'))781 {782 $modules = array();783 foreach(explode(PHP_EOL, pts_file_io::file_get_contents('/proc/modules')) as $module_line)784 {785 $module_line = explode(' ', $module_line);786 if(isset($module_line[0]) && !empty($module_line[0]))787 {788 array_push($modules, $module_line[0]);789 }790 }791 if(!empty($modules))792 {793 $to_report = array();794 $cmdline = explode(' ', pts_file_io::file_get_contents('/proc/cmdline'));795 foreach($cmdline as $option)796 {797 if(($t = strpos($option, '.')) !== false)798 {799 if(in_array(substr($option, 0, $t), $modules))800 {801 array_push($to_report, $option);802 }803 }804 }805 if(!empty($to_report))806 {807 $parameters = implode(' ', $to_report);808 }809 }810 }811 return $parameters;812 }813 public static function sw_kernel_architecture()814 {815 // Find out the kernel archiecture816 if(phodevi::is_windows())817 {818 //$kernel_arch = strpos($_SERVER['PROCESSOR_ARCHITECTURE'], 64) !== false || strpos($_SERVER['PROCESSOR_ARCHITEW6432'], 64 != false) ? 'x86_64' : 'i686';819 if(isset($_SERVER['PROCESSOR_ARCHITEW6432']))820 {821 $kernel_arch = $_SERVER['PROCESSOR_ARCHITEW6432'] == 'AMD64' ? 'x86_64' : 'i686';822 }823 else824 {825 $kernel_arch = 'x86_64';826 }827 }828 else829 {830 $kernel_arch = php_uname('m');831 switch($kernel_arch)832 {833 case 'X86-64':834 case 'amd64':835 $kernel_arch = 'x86_64';836 break;837 case 'i86pc':838 case 'i586':839 case 'i686-AT386':840 $kernel_arch = 'i686';841 break;842 }843 }844 return $kernel_arch;845 }846 public static function sw_os_version()847 {848 // Returns OS version849 if(phodevi::is_macosx())850 {851 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');852 853 $start_pos = strpos($os, '.');854 $end_pos = strrpos($os, '.');855 $start_pos = strrpos(substr($os, 0, $start_pos), ' ');856 $end_pos = strpos($os, ' ', $end_pos);857 858 $os_version = substr($os, $start_pos + 1, $end_pos - $start_pos);859 }860 else if(phodevi::is_linux())861 {862 $os_version = phodevi_linux_parser::read_lsb('Release');863 if($os_version == null)864 {865 if(is_readable('/etc/os-release'))866 $os_release = parse_ini_file('/etc/os-release');867 else if(is_readable('/usr/lib/os-release'))868 $os_release = parse_ini_file('/usr/lib/os-release');869 else870 $os_release = null;871 if(isset($os_release['VERSION_ID']) && !empty($os_release['VERSION_ID']))872 {873 $os_version = $os_release['VERSION_ID'];874 }875 else if(isset($os_release['VERSION']) && !empty($os_release['VERSION']))876 {877 $os_version = $os_release['VERSION'];878 }879 $os_version = pts_strings::keep_in_string($os_version, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE);880 }881 }882 else883 {884 $os_version = php_uname('r');885 }886 887 return $os_version;888 }889 public static function sw_operating_system()890 {891 if(!PTS_IS_CLIENT)892 {893 // TODO: Figure out why this function is sometimes called from OpenBenchmarking.org....894 return false;895 }896 // Determine the operating system release897 if(phodevi::is_linux())898 {899 $vendor = phodevi_linux_parser::read_lsb_distributor_id();900 if($vendor == null)901 {902 if(is_readable('/etc/os-release'))903 $os_release = parse_ini_file('/etc/os-release');904 else if(is_readable('/usr/lib/os-release'))905 $os_release = parse_ini_file('/usr/lib/os-release');906 else907 $os_release = null;908 if(isset($os_release['PRETTY_NAME']) && !empty($os_release['PRETTY_NAME']))909 {910 $vendor = $os_release['PRETTY_NAME'];911 }912 else if(isset($os_release['NAME']) && !empty($os_release['NAME']))913 {914 $vendor = $os_release['NAME'];915 }916 }917 if(($x = stripos($vendor, ' for ')) !== false)918 {919 $vendor = substr($vendor, 0, $x);920 }921 $vendor = str_replace(array(' Software'), null, $vendor);922 }923 else if(phodevi::is_hurd())924 {925 $vendor = php_uname('v');926 }927 else928 {929 $vendor = null;930 }931 $version = phodevi::read_property('system', 'os-version');932 if(!$vendor)933 {934 $os = null;935 // Try to detect distro for those not supplying lsb_release936 $files = pts_file_io::glob('/etc/*-version');937 for($i = 0; $i < count($files) && $os == null; $i++)938 {939 $file = file_get_contents($files[$i]);940 if(trim($file) != null)941 {942 $os = substr($file, 0, strpos($file, "\n"));943 }944 }945 946 if($os == null)947 {948 $files = pts_file_io::glob('/etc/*-release');949 for($i = 0; $i < count($files) && $os == null; $i++)950 {951 $file = file_get_contents($files[$i]);952 if(trim($file) != null)953 {954 $proposed_os = substr($file, 0, strpos($file, PHP_EOL));955 if(strpos($proposed_os, '=') == false)956 {957 $os = $proposed_os;958 }959 }960 else if($i == (count($files) - 1))961 {962 $os = ucwords(substr(($n = basename($files[$i])), 0, strpos($n, '-')));963 } 964 }965 }966 if($os == null && is_file('/etc/release'))967 {968 $file = file_get_contents('/etc/release');969 $os = substr($file, 0, strpos($file, "\n"));970 }971 if($os == null && is_file('/etc/palm-build-info'))972 {973 // Palm / webOS Support974 $os = phodevi_parser::parse_equal_delimited_file('/etc/palm-build-info', 'PRODUCT_VERSION_STRING');975 }976 if($os == null)977 {978 if(phodevi::is_windows())979 {980 $os = trim(exec('ver'));981 }982 if(is_file('/etc/debian_version'))983 {984 $os = 'Debian ' . php_uname('s') . ' ' . ucwords(pts_file_io::file_get_contents('/etc/debian_version'));985 }986 else987 {988 $os = php_uname('s');989 }990 }991 else if(strpos($os, ' ') === false)992 {993 // The OS string is only one word, likely a problem...994 if(is_file('/etc/arch-release') && stripos($os, 'Arch') === false)995 {996 // On at least some Arch installs (ARM) the file is empty so would have missed above check997 $os = trim('Arch Linux ' . $os);998 }999 }1000 }1001 else if(stripos($vendor, $version) === false)1002 {1003 $os = $vendor . ' ' . $version;1004 }1005 else1006 {1007 $os = $vendor;1008 }1009 if(($break_point = strpos($os, ':')) > 0)1010 {1011 $os = substr($os, $break_point + 1);1012 }1013 1014 if(phodevi::is_macosx())1015 {1016 $os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');1017 }1018 if(($break_point = strpos($os, '(')) > 0)1019 {1020 $os = substr($os, 0, $break_point);1021 }1022 $os = trim($os);1023 return $os;1024 }1025 public static function sw_desktop_environment()1026 {1027 $desktop = null;1028 $desktop_environment = null;1029 $desktop_version = null;1030 $desktop_session = pts_client::read_env('DESKTOP_SESSION');1031 if(pts_client::is_process_running('gnome-shell'))1032 {1033 // GNOME 3.0 / GNOME Shell1034 $desktop_environment = 'GNOME Shell';1035 if(pts_client::executable_in_path('gnome-shell'))1036 {1037 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-shell --version 2> /dev/null')));1038 }1039 }1040 else if(pts_client::is_process_running('gnome-panel') || $desktop_session == 'gnome')1041 {1042 // GNOME1043 $desktop_environment = 'GNOME';1044 if(pts_client::executable_in_path('gnome-about'))1045 {1046 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-about --version 2> /dev/null')));1047 }1048 else if(pts_client::executable_in_path('gnome-session'))1049 {1050 $desktop_version = pts_strings::last_in_string(trim(shell_exec('gnome-session --version 2> /dev/null')));1051 }1052 }1053 else if(pts_client::is_process_running('unity-2d-panel') || $desktop_session == 'ubuntu-2d')1054 {1055 // Canonical / Ubuntu Unity 2D Desktop1056 $desktop_environment = 'Unity 2D';1057 if(pts_client::executable_in_path('unity'))1058 {1059 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1060 }1061 }1062 else if(pts_client::is_process_running('unity-panel-service') || $desktop_session == 'ubuntu')1063 {1064 // Canonical / Ubuntu Unity Desktop1065 $desktop_environment = 'Unity';1066 if(pts_client::executable_in_path('unity'))1067 {1068 $desktop_version = pts_strings::last_in_string(trim(shell_exec('unity --version 2> /dev/null')));1069 }1070 }1071 else if($desktop_session == 'mate')1072 {1073 $desktop_environment = 'MATE';1074 if(pts_client::executable_in_path('mate-about'))1075 {1076 $desktop_version = pts_strings::last_in_string(trim(shell_exec('mate-about --version 2> /dev/null')));1077 }1078 }1079 else if(($kde5 = pts_client::is_process_running('kded5')))1080 {1081 // KDE 5.x1082 $desktop_environment = 'KDE Frameworks 5';1083 $desktop_version = null; // TODO XXX1084 }1085 else if(($dde = pts_client::is_process_running('dde-desktop')))1086 {1087 // KDE 5.x1088 $desktop_environment = 'Deepin Desktop Environment';1089 $desktop_version = null; // TODO XXX1090 }1091 else if(($kde4 = pts_client::is_process_running('kded4')) || pts_client::is_process_running('kded'))1092 {1093 // KDE 4.x1094 $desktop_environment = 'KDE';1095 $kde_output = trim(shell_exec(($kde4 ? 'kde4-config' : 'kde-config') . ' --version 2>&1'));1096 $kde_lines = explode("\n", $kde_output);1097 for($i = 0; $i < count($kde_lines) && empty($desktop_version); $i++)1098 {1099 $line_segments = pts_strings::colon_explode($kde_lines[$i]);1100 if(in_array($line_segments[0], array('KDE', 'KDE Development Platform')) && isset($line_segments[1]))1101 {1102 $v = trim($line_segments[1]);1103 if(($cut = strpos($v, ' ')) > 0)1104 {1105 $v = substr($v, 0, $cut);1106 }1107 $desktop_version = $v;1108 }1109 }1110 }1111 else if(pts_client::is_process_running('chromeos-wm'))1112 {1113 $chrome_output = trim(shell_exec('chromeos-wm -version'));1114 if($chrome_output == 'chromeos-wm')1115 {1116 // No version actually reported1117 $chrome_output = 'Chrome OS';1118 }1119 $desktop_environment = $chrome_output;1120 }1121 else if(pts_client::is_process_running('lxsession') || $desktop_session == 'lxde')1122 {1123 $lx_output = trim(shell_exec('lxpanel --version'));1124 $version = substr($lx_output, strpos($lx_output, ' ') + 1);1125 $desktop_environment = 'LXDE';1126 $desktop_version = $version;1127 }1128 else if(pts_client::is_process_running('xfce4-session') || pts_client::is_process_running('xfce-mcs-manager') || $desktop_session == 'xfce')1129 {1130 // Xfce 4.x1131 $desktop_environment = 'Xfce';1132 $xfce_output = trim(shell_exec('xfce4-session-settings --version 2>&1'));1133 if(($open = strpos($xfce_output, '(Xfce')) > 0)1134 {1135 $xfce_output = substr($xfce_output, strpos($xfce_output, ' ', $open) + 1);1136 $desktop_version = substr($xfce_output, 0, strpos($xfce_output, ')'));1137 }1138 }1139 else if(pts_client::is_process_running('sugar-session'))1140 {1141 // Sugar Desktop Environment (namely for OLPC)1142 $desktop_environment = 'Sugar';1143 $desktop_version = null; // TODO: where can the Sugar version be figured out?1144 }1145 else if(pts_client::is_process_running('openbox'))1146 {1147 $desktop_environment = 'Openbox';1148 $openbox_output = trim(shell_exec('openbox --version 2>&1'));1149 if(($openbox_d = stripos($openbox_output, 'Openbox ')) !== false)1150 {1151 $openbox_output = substr($openbox_output, ($openbox_d + 8));1152 $desktop_version = substr($openbox_output, 0, strpos($openbox_output, PHP_EOL));1153 }1154 }1155 else if(pts_client::is_process_running('cinnamon'))1156 {1157 $desktop_environment = 'Cinnamon';1158 $desktop_version = pts_strings::last_in_string(trim(shell_exec('cinnamon --version 2> /dev/null')));1159 }1160 else if(pts_client::is_process_running('enlightenment'))1161 {1162 $desktop_environment = 'Enlightenment';1163 $desktop_version = null; // No known -v / --version command on any Enlightenment component1164 }1165 else if(pts_client::is_process_running('consort-panel'))1166 {1167 $desktop_environment = 'Consort';1168 $desktop_version = null; // TODO: Haven't tested Consort Desktop yet1169 }1170 else if(pts_client::is_process_running('razor-desktop'))1171 {1172 $desktop_environment = 'Razor-qt';1173 $desktop_version = null; // TODO: Figure out how to determine razor version1174 }1175 else if(pts_client::is_process_running('icewm'))1176 {1177 $desktop_environment = 'IceWM';1178 $desktop_version = null;1179 }1180 if(!empty($desktop_environment))1181 {1182 $desktop = $desktop_environment;1183 if(!empty($desktop_version) && pts_strings::is_version($desktop_version))1184 {1185 $desktop .= ' ' . $desktop_version;1186 }1187 }1188 return $desktop;1189 }1190 public static function sw_display_server()1191 {1192 $display_servers = array();1193 if(phodevi::is_windows())1194 {1195 // TODO: determine what to do for Windows support1196 }1197 else1198 {1199 if(pts_client::is_process_running('weston'))1200 {1201 $info = 'Wayland Weston';1202 $vinfo = trim(shell_exec('weston --version 2>&1'));1203 if(pts_strings::last_in_string($vinfo) && pts_strings::is_version(pts_strings::last_in_string($vinfo)))1204 {1205 $info .= ' ' . pts_strings::last_in_string($vinfo);1206 }1207 array_push($display_servers, $info);1208 }1209 if(pts_client::is_process_running('unity-system-compositor'))1210 {1211 $unity_system_comp = trim(str_replace('unity-system-compositor', null, shell_exec('unity-system-compositor --version 2>&1')));1212 if(pts_strings::is_version($unity_system_comp))1213 {1214 array_push($display_servers, 'Unity-System-Compositor ' . $unity_system_comp);1215 }1216 }1217 if(($x_bin = (is_executable('/usr/libexec/Xorg.bin') ? '/usr/libexec/Xorg.bin' : false)) || ($x_bin = pts_client::executable_in_path('Xorg')) || ($x_bin = pts_client::executable_in_path('X')))1218 {1219 // Find graphics subsystem version1220 $info = shell_exec($x_bin . ' ' . (phodevi::is_solaris() ? ':0' : '') . ' -version 2>&1');1221 $pos = (($p = strrpos($info, 'Release Date')) !== false ? $p : strrpos($info, 'Build Date'));1222 $info = trim(substr($info, 0, $pos));1223 if($pos === false || getenv('DISPLAY') == false)1224 {1225 $info = null;1226 }1227 else if(($pos = strrpos($info, '(')) === false)1228 {1229 $info = trim(substr($info, strrpos($info, ' ')));1230 }1231 else1232 {1233 $info = trim(substr($info, strrpos($info, 'Server') + 6));1234 }1235 if($info != null)1236 {1237 array_push($display_servers, 'X Server ' . $info);1238 }1239 }1240 if(pts_client::is_process_running('surfaceflinger'))1241 {1242 array_push($display_servers, 'SurfaceFlinger');1243 }1244 if(pts_client::is_process_running('gnome-shell-wayland'))1245 {1246 array_push($display_servers, 'GNOME Shell Wayland');1247 }1248 if(empty($display_servers) && getenv('WAYLAND_DISPLAY') != false)1249 {1250 array_push($display_servers, 'Wayland');1251 }1252 }1253 return implode(' + ', $display_servers);1254 }1255 public static function sw_display_driver($with_version = true)1256 {1257 if(phodevi::is_windows())1258 {1259 return null;1260 }1261 $display_driver = phodevi::read_property('system', 'dri-display-driver');1262 if(empty($display_driver))1263 {1264 if(phodevi::is_ati_graphics() && phodevi::is_linux())1265 {1266 $display_driver = 'fglrx';1267 }1268 else if(phodevi::is_nvidia_graphics() || is_file('/proc/driver/nvidia/version'))1269 {1270 $display_driver = 'nvidia';1271 }1272 else if((phodevi::is_mesa_graphics() || phodevi::is_bsd()) && stripos(phodevi::read_property('gpu', 'model'), 'NVIDIA') !== false)1273 {1274 if(is_file('/sys/class/drm/version'))1275 {1276 // If there's DRM loaded and NVIDIA, it should be Nouveau1277 $display_driver = 'nouveau';1278 }1279 else1280 {1281 // The dead xf86-video-nv doesn't use any DRM1282 $display_driver = 'nv';1283 }1284 }1285 else1286 {1287 // Fallback to hopefully detect the module, takes the first word off the GPU string and sees if it is the module1288 // This works in at least the case of the Cirrus driver1289 $display_driver = strtolower(pts_strings::first_in_string(phodevi::read_property('gpu', 'model')));1290 }1291 }1292 if(!empty($display_driver))1293 {1294 $driver_version = phodevi_parser::read_xorg_module_version($display_driver . '_drv');1295 if($driver_version == false || $driver_version == '1.0.0')1296 {1297 switch($display_driver)1298 {1299 case 'amd':1300 // See if it's radeon driver1301 $driver_version = phodevi_parser::read_xorg_module_version('radeon_drv');1302 if($driver_version != false)1303 {1304 $display_driver = 'radeon';1305 }1306 // See if it's the newer AMDGPU driver1307 $driver_version = phodevi_parser::read_xorg_module_version('amdgpu_drv');1308 if($driver_version != false)1309 {1310 $display_driver = 'amdgpu';1311 }1312 break;1313 case 'vmwgfx':1314 // See if it's VMware driver1315 $driver_version = phodevi_parser::read_xorg_module_version('vmware_drv');1316 if($driver_version != false)1317 {1318 $display_driver = 'vmware';1319 }1320 break;1321 case 'radeon':1322 // RadeonHD driver also reports DRI driver as 'radeon', so try reading that instead1323 $driver_version = phodevi_parser::read_xorg_module_version('radeonhd_drv');1324 if($driver_version != false)1325 {1326 $display_driver = 'radeonhd';1327 }1328 $driver_version = phodevi_parser::read_xorg_module_version('amdgpu_drv');1329 if($driver_version != false)1330 {1331 $display_driver = 'amdgpu';1332 }1333 break;1334 case 'nvidia':1335 case 'NVIDIA':1336 case 'nouveau':1337 // NVIDIA's binary driver usually ends up reporting 1.0.01338 if(($nvs_value = phodevi_parser::read_nvidia_extension('NvidiaDriverVersion')))1339 {1340 $display_driver = 'NVIDIA';1341 $driver_version = $nvs_value;1342 }1343 else1344 {1345 // NVIDIA's binary driver appends their driver version on the end of the OpenGL version string1346 $glxinfo = phodevi_parser::software_glxinfo_version();1347 if(($pos = strpos($glxinfo, 'NVIDIA ')) != false)1348 {1349 $display_driver = 'NVIDIA';1350 $driver_version = substr($glxinfo, ($pos + 7));1351 }1352 }1353 break;1354 default:1355 if(is_readable('/sys/class/graphics/fb0/name'))1356 {1357 // This path works for at least finding NVIDIA Tegra 2 DDX (via tegra_fb)1358 $display_driver = file_get_contents('/sys/class/graphics/fb0/name');1359 $display_driver = str_replace(array('drm', '_fb'), null, $display_driver);1360 $driver_version = phodevi_parser::read_xorg_module_version($display_driver . '_drv');1361 }1362 break;1363 }1364 }1365 if($driver_version == false)1366 {1367 // If the version is empty, chances are the DDX driver string is incorrect1368 $display_driver = null;1369 // See if the VESA or fbdev driver is in use1370 foreach(array('modesetting', 'fbdev', 'vesa') as $drv)1371 {1372 $drv_version = phodevi_parser::read_xorg_module_version($drv . '_drv');1373 if($drv_version)1374 {1375 $display_driver = $drv;1376 $driver_version = $drv_version;1377 break;1378 }1379 }1380 }1381 if(!empty($driver_version) && $with_version && $driver_version != '0.0.0')1382 {1383 $display_driver .= ' ' . $driver_version;1384 // XXX: The below check is disabled since the Catalyst Version no longer seems reliably reported (circa Catalyst 13.x)1385 if(false && phodevi::is_ati_graphics() && strpos($display_driver, 'fglrx') !== false)1386 {1387 $catalyst_version = phodevi_linux_parser::read_amd_pcsdb('AMDPCSROOT/SYSTEM/LDC,Catalyst_Version');1388 if($catalyst_version != null && $catalyst_version > 10.1 && $catalyst_version != 10.5 && $catalyst_version != 11.8)1389 {1390 // This option was introduced around Catalyst 10.5 but seems to not be updated properly until Catalyst 10.11/10.121391 $display_driver .= ' Catalyst ' . $catalyst_version . '';1392 }1393 }1394 }1395 }1396 return $display_driver;1397 }1398 public static function sw_opengl_driver()1399 {1400 // OpenGL version1401 $info = null;1402 if(phodevi::is_windows())1403 {1404 $info = null; // TODO: Windows support1405 }1406 else if(pts_client::executable_in_path('nvidia-settings'))1407 {1408 $info = phodevi_parser::read_nvidia_extension('OpenGLVersion');1409 }1410 if($info == null)1411 {1412 $info = phodevi_parser::software_glxinfo_version();1413 if($info && ($pos = strpos($info, ' ')) != false && strpos($info, 'Mesa') === false)1414 {1415 $info = substr($info, 0, $pos);1416 }1417 $renderer = phodevi_parser::read_glx_renderer();1418 if($renderer && ($s = strpos($renderer, 'Gallium')) !== false)1419 {1420 $gallium = substr($renderer, $s);1421 $gallium = substr($gallium, 0, strpos($gallium, ' ', strpos($gallium, '.')));1422 $info .= ' ' . $gallium . '';1423 }1424 if($renderer && ($s = strpos($renderer, 'LLVM ')) !== false)1425 {1426 $llvm = substr($renderer, $s);1427 $llvm = substr($llvm, 0, strpos($llvm, ')'));1428 $info .= ' (' . $llvm . ')';1429 }1430 }1431 return $info;1432 }1433 public static function sw_vulkan_driver()1434 {1435 // Vulkan driver/version1436 $info = null;1437 if(isset(phodevi::$vfs->vulkaninfo))1438 {1439 if(($pos = strpos(phodevi::$vfs->vulkaninfo, 'Vulkan API Version:')) !== false)1440 {1441 $info = substr(phodevi::$vfs->vulkaninfo, $pos + 20);1442 $info = trim(substr($info, 0, strpos($info, "\n")));1443 }1444 }1445 if($info == null)1446 {1447 // A less than ideal fallback for some detection now1448 foreach(array_merge(pts_file_io::glob('/etc/vulkan/icd.d/*.json'), pts_file_io::glob('/usr/share/vulkan/icd.d/*.json')) as $icd_json)1449 {1450 $icd_json = json_decode(file_get_contents($icd_json), true);1451 if(isset($icd_json['ICD']['api_version']) && !empty($icd_json['ICD']['api_version']))1452 {1453 $info = trim($icd_json['ICD']['api_version']);1454 break;1455 }1456 }1457 }1458 return $info;1459 }1460 public static function sw_opencl_driver()1461 {1462 // OpenCL driver/version1463 $info = array();1464 if(isset(phodevi::$vfs->clinfo))1465 {1466 $sea = phodevi::$vfs->clinfo;1467 while(($pos = strpos($sea, 'Platform Version')) != false)1468 {1469 $sea = substr($sea, $pos + 18);1470 $info[] = trim(substr($sea, 0, strpos($sea, "\n")));1471 }1472 }1473 return implode(' + ', $info);1474 }1475 public static function sw_opengl_vendor()1476 {1477 // OpenGL version1478 $info = null;1479 if(pts_client::executable_in_path('glxinfo'))1480 {1481 $info = shell_exec('glxinfo 2>&1 | grep vendor');1482 if(($pos = strpos($info, 'OpenGL vendor string:')) !== false)1483 {1484 $info = substr($info, $pos + 22);1485 $info = trim(substr($info, 0, strpos($info, "\n")));1486 }1487 }1488 else if(is_readable('/dev/nvidia0'))1489 {1490 $info = 'NVIDIA';1491 }1492 else if(is_readable('/sys/module/fglrx/initstate') && pts_file_io::file_get_contents('/sys/module/fglrx/initstate') == 'live')1493 {1494 $info = 'ATI';1495 }1496 else if(is_readable('/dev/dri/card0'))1497 {1498 $info = 'Mesa';1499 }1500 else if(phodevi::is_bsd() && phodevi_bsd_parser::read_sysctl('dev.nvidia.0.%driver'))1501 {1502 $info = 'NVIDIA';1503 }1504 return $info;1505 }1506 public static function sw_compiler_build_configuration($compiler)1507 {1508 $cc = shell_exec($compiler . ' -v 2>&1');1509 if(($t = stripos($cc, 'Configured with: ')) !== false)1510 {1511 $cc = substr($cc, ($t + 18));1512 $cc = substr($cc, 0, strpos($cc, PHP_EOL));1513 $cc = explode(' ', $cc);1514 array_shift($cc); // this should just be the configure call (i.e. ../src/configure)1515 $drop_arguments = array(1516 '--with-pkgversion=',1517 '--with-bugurl=',1518 '--prefix=',1519 '--program-suffix=',1520 '--libexecdir=',1521 '--infodir=',1522 '--libdir=',1523 '--with-cloog=',1524 '--with-isl=',1525 '--with-java-home=',1526 '--manddir=',1527 '--with-ecj-jar=',1528 '--with-jvm-jar-dir=',1529 '--with-jvm-root-dir=',1530 '--with-sysroot=',1531 '--with-gxx-include-dir=',1532 '--with-system-zlib',1533 '--enable-linker-build-id',1534 '--without-included-gettext'1535 );1536 foreach($cc as $i => $argument)1537 {1538 $arg_length = strlen($argument);1539 if($argument[0] != '-')1540 {1541 unset($cc[$i]);1542 }1543 else1544 {1545 foreach($drop_arguments as $check_to_drop)1546 {1547 $len = strlen($check_to_drop);1548 if($len <= $arg_length && substr($argument, 0, $len) == $check_to_drop)1549 {1550 unset($cc[$i]);1551 }1552 }1553 }1554 }1555 sort($cc);1556 $cc = implode(' ', $cc);1557 }1558 else if(($t = stripos($cc, 'clang')) !== false)1559 {1560 $cc = null;1561 // Clang doesn't report "configured with" but has other useful tid-bits...1562 if(($c = pts_client::executable_in_path('llvm-ld')) || ($c = pts_client::executable_in_path('llvm-link')))1563 {1564 $llvm_ld = shell_exec($c . ' -version 2>&1');1565 /*1566 EXAMPLE OUTPUT:1567 LLVM (http://llvm.org/):1568 LLVM version 3.1svn1569 Optimized build.1570 Built Mar 23 2012 (08:53:34).1571 Default target: x86_64-unknown-linux-gnu1572 Host CPU: corei7-avx1573 */1574 if(stripos($llvm_ld, 'build') && (stripos($llvm_ld, 'host') || stripos($llvm_ld, 'target')))1575 {1576 $llvm_ld = explode(PHP_EOL, $llvm_ld);1577 if(stripos($llvm_ld[0], 'http://'))1578 {1579 array_shift($llvm_ld);1580 }1581 if(stripos($llvm_ld[0], 'version'))1582 {1583 array_shift($llvm_ld);1584 }1585 foreach($llvm_ld as $i => &$line)1586 {1587 $line = trim($line);1588 if(substr($line, -1) == '.')1589 {1590 $line = substr($line, 0, -1);1591 }1592 if($line == null)1593 {1594 unset($llvm_ld[$i]);1595 }1596 }1597 $cc = implode('; ', $llvm_ld);1598 }1599 }1600 }1601 else1602 {1603 $cc = null;1604 }1605 return $cc;1606 }1607 public static function sw_dri_display_driver()1608 {1609 $dri_driver = false;1610 if(is_file('/proc/driver/nvidia/version'))1611 {1612 $dri_driver = 'nvidia';1613 }1614 else if(is_file('/proc/dri/0/name'))1615 {1616 $driver_info = file_get_contents('/proc/dri/0/name');1617 $dri_driver = substr($driver_info, 0, strpos($driver_info, ' '));1618 if(in_array($dri_driver, array('i915', 'i965')))1619 {1620 $dri_driver = 'intel';1621 }1622 }1623 else if(is_file('/sys/class/drm/card0/device/vendor'))1624 {1625 $vendor_id = pts_file_io::file_get_contents('/sys/class/drm/card0/device/vendor');1626 switch($vendor_id)1627 {1628 case 0x1002:1629 $dri_driver = 'radeon';1630 break;1631 case 0x8086:1632 $dri_driver = 'intel';1633 break;1634 case 0x10de:1635 // NVIDIA1636 $dri_driver = 'nouveau';1637 break;1638 }1639 }1640 return $dri_driver;1641 }1642 public static function sw_java_version()1643 {1644 $java_version = trim(shell_exec('java -version 2>&1'));1645 if(strpos($java_version, 'not found') == false && strpos($java_version, 'Java') !== FALSE)1646 {1647 $java_version = explode("\n", $java_version);1648 if(($cut = count($java_version) - 2) > 0)1649 {1650 $v = $java_version[$cut];1651 }1652 else1653 {1654 $v = array_pop($java_version);1655 }1656 $java_version = trim($v);1657 }1658 else1659 {1660 $java_version = null;1661 }1662 return $java_version;1663 }1664 public static function sw_python_version()1665 {1666 $python_version = null;1667 if(pts_client::executable_in_path('python') != false)1668 {1669 $python_version = trim(shell_exec('python -V 2>&1'));1670 }1671 return $python_version;1672 }1673 public static function sw_wine_version()1674 {1675 $wine_version = null;1676 if(pts_client::executable_in_path('wine') != false)1677 {1678 $wine_version = trim(shell_exec('wine --version 2>&1'));1679 }1680 else if(pts_client::executable_in_path('winecfg.exe') != false && pts_client::read_env('WINE_VERSION'))1681 {1682 $wine_version = trim(pts_client::read_env('WINE_VERSION'));1683 if(stripos($wine_version, 'wine') === false)1684 {1685 $wine_version = 'wine-' . $wine_version;1686 }1687 }1688 return $wine_version;1689 }1690}1691?>...

Full Screen

Full Screen

pts_network.php

Source:pts_network.php Github

copy

Full Screen

...365 public static function get_active_network_interface()366 {367 $dev = '';368 // try and get the device with the default route369 if ($ip = pts_client::executable_in_path('ip'))370 {371 $out = shell_exec("$ip route 2>&1");372 $start = strpos($out, ' dev ');373 if($start !== false)374 {375 $start += 5; // length of ' dev '376 if(($xx = strpos($out, ' ', $start)) !== false)377 {378 $dev = substr($out, $start, $xx - $start);379 }380 }381 }382 // we grab the last field of the `netstat -nr` output, betting on *bsd not expiring it's default route383 if(empty($dev) && $netstat = pts_client::executable_in_path('netstat')) {384 $out = shell_exec("$netstat -rn 2>&1");385 $lines = explode("\n", $out);386 foreach ($lines as $line) {387 $start = substr($line,0,7);388 if ($start == '0.0.0.0' || $start === 'default') {389 $dev = trim(substr(trim($line),strrpos($line,' ')));390 return $dev;391 }392 }393 }394 return $dev;395 }396 public static function get_local_ip()397 {398 $local_ip = false;399 $interface = self::get_active_network_interface();400 if(($ifconfig = pts_client::executable_in_path('ifconfig')))401 {402 $ifconfig = shell_exec($ifconfig . " $interface 2>&1");403 $offset = 0;404 while(($ipv4_pos = strpos($ifconfig, 'inet addr:', $offset)) !== false)405 {406 $ipv4 = substr($ifconfig, $ipv4_pos + strlen('inet addr:'));407 $ipv4 = substr($ipv4, 0, strpos($ipv4, ' '));408 $local_ip = $ipv4;409 if($local_ip != '127.0.0.1' && $local_ip != null)410 {411 break;412 }413 $offset = $ipv4_pos + 1;414 }415 if($local_ip == null)416 {417 while(($ipv4_pos = strpos($ifconfig, 'inet ', $offset)) !== false)418 {419 $ipv4 = substr($ifconfig, $ipv4_pos + strlen('inet '));420 $ipv4 = substr($ipv4, 0, strpos($ipv4, ' '));421 $local_ip = $ipv4;422 if($local_ip != '127.0.0.1' && $local_ip != null)423 {424 break;425 }426 $offset = $ipv4_pos + 1;427 }428 }429 }430 else if(phodevi::is_windows())431 {432 $ipconfig = shell_exec('ipconfig');433 $offset = 0;434 while(($ipv4_pos = strpos($ipconfig, 'IPv4 Address.', $offset)) !== false)435 {436 $ipv4 = substr($ipconfig, $ipv4_pos);437 $ipv4 = substr($ipv4, strpos($ipv4, ': ') + 2);438 $ipv4 = substr($ipv4, 0, strpos($ipv4, "\n"));439 $local_ip = trim($ipv4);440 if($local_ip != '127.0.0.1' && $local_ip != null && strpos($local_ip, '169.254') === false)441 {442 break;443 }444 $offset = $ipv4_pos + 3;445 }446 }447 else if(pts_client::executable_in_path('hostname'))448 {449 $hostname_i = explode(' ', trim(shell_exec('hostname -I 2>&1')));450 $hostname_i = array_shift($hostname_i);451 if(count(explode('.', $hostname_i)) == 4)452 {453 $local_ip = $hostname_i;454 }455 }456 if(empty($local_ip) && function_exists('net_get_interfaces'))457 {458 // The below code should work as of net_get_interfaces() as of PHP 7.3 in cross-platform manner459 $net_interfaces = net_get_interfaces();460 foreach($net_interfaces as $interface => $interface_info)461 {462 if(isset($interface_info['unicast'][1]['address']) && !empty($interface_info['unicast'][1]['address']) && $interface_info['unicast'][1]['address'] != '127.0.0.1')463 {464 $local_ip = $interface_info['unicast'][1]['address'];465 break;466 }467 }468 }469 return $local_ip;470 }471 public static function get_network_mac()472 {473 $mac = false;474 if(phodevi::is_linux())475 {476 if($interface = self::get_active_network_interface())477 {478 $addr = "/sys/class/net/$interface/address";479 if(is_file($addr))480 {481 $mac = pts_file_io::file_get_contents($addr);482 }483 }484 if(empty($mac))485 {486 foreach(pts_file_io::glob('/sys/class/net/*/operstate') as $net_device_state)487 {488 if(pts_file_io::file_get_contents($net_device_state) == 'up')489 {490 $addr = dirname($net_device_state) . '/address';491 if(is_file($addr))492 {493 $mac = pts_file_io::file_get_contents($addr);494 break;495 }496 }497 }498 }499 }500 else if(phodevi::is_windows())501 {502 $getmac = shell_exec('getmac');503 $getmac = trim(substr($getmac, strpos($getmac, "\n", strpos($getmac, '======='))));504 $getmac = substr($getmac, 0, strpos($getmac, ' '));505 if(strlen($getmac) <= 17)506 {507 $mac = str_replace('-', ':', $getmac);508 }509 }510 if(empty($mac) && ($ifconfig = pts_client::executable_in_path('ifconfig')))511 {512 $ifconfig = shell_exec($ifconfig . ' 2>&1');513 $offset = 0;514 while(($hwaddr_pos = strpos($ifconfig, 'HWaddr ', $offset)) !== false || ($hwaddr_pos = strpos($ifconfig, 'ether ', $offset)) !== false)515 {516 $hw_addr = substr($ifconfig, $hwaddr_pos);517 $hw_addr = substr($hw_addr, (strpos($hw_addr, ' ') + 1));518 $hw_addr = substr($hw_addr, 0, strpos($hw_addr, ' '));519 if(($x = strpos($hw_addr, PHP_EOL)) != false)520 {521 $hw_addr = substr($hw_addr, 0, $x);522 }523 $mac = $hw_addr;524 if($mac != null)525 {526 break;527 }528 $offset = $hwaddr_pos + 1;529 }530 }531 if(empty($mac) && ($netstat = pts_client::executable_in_path('netstat')))532 {533 // Needed on at least OpenBSD as their `ifconfig` does not expose the MAC address534 $netstat = shell_exec($netstat . ' -in 2>&1');535 foreach(explode(PHP_EOL, $netstat) as $line)536 {537 $line = explode(' ', $line);538 foreach($line as $i => $r)539 {540 if($r == null)541 unset($line[$i]);542 }543 $line = array_values($line);544 if(!isset($line[3]))545 {546 continue;547 }548 $address = explode(':', $line[3]);549 if(count($address) == 6 && $address[0] != '00' && $address[5] != '00')550 {551 foreach($address as $seg)552 {553 if(strlen($seg) != 2)554 {555 continue;556 }557 }558 $mac = $line[3];559 }560 }561 }562 return $mac;563 }564 public static function get_network_wol()565 {566 static $wol_support = null;567 if($wol_support === null)568 {569 $wol_support = array();570 if(is_dir('/sys/class/net'))571 {572 if(pts_client::executable_in_path('ethtool'))573 {574 foreach(pts_file_io::glob('/sys/class/net/*') as $net_device)575 {576 if(!is_readable($net_device . '/operstate') || trim(file_get_contents($net_device . '/operstate')) != 'up')577 {578 continue;579 }580 $net_name = basename($net_device);581 $ethtool_output = shell_exec('ethtool ' . $net_name . ' 2>&1');582 if(($x = stripos($ethtool_output, 'Supports Wake-on: ')) !== false)583 {584 $ethtool_output = substr($ethtool_output, $x + strlen('Supports Wake-on: '));585 $ethtool_output = trim(substr($ethtool_output, 0, strpos($ethtool_output, PHP_EOL)));586 $wol_support[$net_name] = $net_name . ': ' . $ethtool_output;587 }588 }589 }590 if(empty($wol_support) && pts_client::executable_in_path('nmcli'))591 {592 foreach(pts_file_io::glob('/sys/class/net/*') as $net_device)593 {594 if(!is_readable($net_device . '/operstate') || trim(file_get_contents($net_device . '/operstate')) != 'up')595 {596 continue;597 }598 $net_name = basename($net_device);599 $ethtool_output = shell_exec('nmcli c show ' . $net_name . ' 2>&1');600 if(($x = stripos($ethtool_output, '.wake-on-lan:')) !== false)601 {602 $ethtool_output = substr($ethtool_output, $x + strlen('.wake-on-lan:'));603 $ethtool_output = trim(substr($ethtool_output, 0, strpos($ethtool_output, PHP_EOL)));604 if(strpos($ethtool_output, '1') || strpos($ethtool_output, 'default'))605 {606 shell_exec('nmcli connection modify ' . $net_name . ' 802-3-ethernet.wake-on-lan magic 2>&1'); // TODO this really needed?607 $wol_support[$net_name] = $net_name . ': g';608 }609 }610 }611 }612 }613 }614 return $wol_support;615 }616 public static function send_wol_packet($ip_address, $mac_address)617 {618 $hwaddr = null;619 foreach(explode(':', $mac_address) as $o)620 {621 $hwaddr .= chr(hexdec($o));622 }623 $packet = null;624 for($i = 1; $i <= 6; $i++)625 {626 $packet .= chr(255);627 }628 for($i = 1; $i <= 16; $i++)629 {630 $packet .= $hwaddr;631 }632 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);633 if($sock)634 {635 $options = socket_set_option($sock, 1, 6, true);636 if($options >= 0)637 {638 $sendto = socket_sendto($sock, $packet, strlen($packet), 0, $ip_address, 7);639 socket_close($sock);640 return $sendto;641 }642 }643 return false;644 }645 public static function find_zeroconf_phoromatic_servers($find_multiple = false)646 {647 $hosts = $find_multiple ? array() : null;648 if(!pts_network::network_support_available())649 {650 return $hosts;651 }652 if(PTS_IS_CLIENT && pts_client::executable_in_path('avahi-browse'))653 {654 $avahi_browse = explode(PHP_EOL, shell_exec('avahi-browse -p -r -t _http._tcp 2>&1'));655 foreach(array_reverse($avahi_browse) as $avahi_line)656 {657 if(strrpos($avahi_line, 'phoromatic-server') !== false)658 {659 $avahi_line = explode(';', $avahi_line);660 if(isset($avahi_line[8]) && ip2long($avahi_line[7]) !== false && is_numeric($avahi_line[8]))661 {662 $server_ip = $avahi_line[7];663 $server_port = $avahi_line[8];664 //echo $server_ip . ':' . $server_port;665 if($find_multiple)666 {...

Full Screen

Full Screen

toggle_screensaver.php

Source:toggle_screensaver.php Github

copy

Full Screen

...49 // Right now there doesn't appear to be a better way to disable OS X screensaver automatically...50 return pts_module::MODULE_UNLOAD;51 }52 // GNOME Screensaver?53 if(($gt = pts_client::executable_in_path('gconftool')) != false || ($gt = pts_client::executable_in_path('gconftool-2')) != false)54 {55 self::$gnome_gconftool = $gt;56 }57 if(self::$gnome_gconftool != false)58 {59 $is_gnome_screensaver_enabled = trim(shell_exec(self::$gnome_gconftool . ' -g /apps/gnome-screensaver/idle_activation_enabled 2>&1'));60 if($is_gnome_screensaver_enabled == 'true')61 {62 // Stop the GNOME Screensaver63 shell_exec(self::$gnome_gconftool . ' --type bool --set /apps/gnome-screensaver/idle_activation_enabled false 2>&1');64 self::$gnome2_screensaver_halted = true;65 }66 $sleep_display_ac = trim(shell_exec(self::$gnome_gconftool . ' -g /apps/gnome-power-manager/timeout/sleep_display_ac 2>&1'));67 if($sleep_display_ac != 0)68 {69 // Don't sleep the display when on AC power70 shell_exec(self::$gnome_gconftool . ' --type int --set /apps/gnome-power-manager/timeout/sleep_display_ac 0 2>&1');71 self::$sleep_display_ac = $sleep_display_ac;72 }73 }74 if(pts_client::executable_in_path('qdbus'))75 {76 // KDE Screensaver?77 $is_kde_screensaver_enabled = trim(shell_exec('qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive 2>&1'));78 if($is_kde_screensaver_enabled == 'true')79 {80 // Stop the KDE Screensaver81 shell_exec('qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity 2>&1');82 self::$kde_screensaver_halted = true;83 }84 }85 if(self::$gnome2_screensaver_halted == false && pts_client::executable_in_path('gsettings'))86 {87 // GNOME 3.x Screensaver?88 $is_gnome3_screensaver_enabled = trim(shell_exec('gsettings get org.gnome.desktop.session idle-delay 2>&1'));89 if(stripos($is_gnome3_screensaver_enabled, 'no such key') === false && pts_strings::last_in_string($is_gnome3_screensaver_enabled) > 0)90 {91 // Stop the GNOME 3.x Screensaver92 shell_exec('gsettings set org.gnome.desktop.session idle-delay 0 2>&1');93 self::$gnome3_screensaver_halted = pts_strings::last_in_string($is_gnome3_screensaver_enabled);94 }95 // GNOME 3.x Lock-Screen96 $is_gnome3_lockscreen_enabled = trim(shell_exec('gsettings get org.gnome.desktop.lockdown disable-lock-screen 2>&1'));97 if(stripos($is_gnome3_lockscreen_enabled, 'no such key') === false && pts_strings::last_in_string($is_gnome3_lockscreen_enabled) == 'false')98 {99 // Stop the GNOME 3.x Lock Screen100 shell_exec('gsettings set org.gnome.desktop.lockdown disable-lock-screen true 2>&1');101 self::$gnome3_lockscreen_disabled = true;102 }103 // This GNOME3 GSettings method is deprecated on distributions like GNOME 3.8 with Fedora 19104 $is_gnome3_screensaver_enabled_old = trim(shell_exec('gsettings get org.gnome.desktop.screensaver idle-activation-enabled 2>&1'));105 if($is_gnome3_screensaver_enabled_old == 'true')106 {107 // Stop the GNOME 3.x Screensaver108 shell_exec('gsettings set org.gnome.desktop.screensaver idle-activation-enabled false 2>&1');109 self::$gnome3_screensaver_halted_old = true;110 }111 // GNOME 3.x Sleep Dispaly?112 $is_gnome3_sleep = trim(shell_exec('gsettings get org.gnome.settings-daemon.plugins.power sleep-display-ac 2>&1'));113 if($is_gnome3_sleep > 0)114 {115 // Stop the GNOME 3.x Display Sleep116 shell_exec('gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac 0 2>&1');117 self::$sleep_display_ac = $is_gnome3_sleep;118 }119 }120 if(pts_client::executable_in_path('xfconf-query'))121 {122 $is_xfce_screensaver_enabled = stripos(shell_exec('xfconf-query -c xfce4-session -p /startup/screensaver/enabled 2>&1'), 'false') !== false;123 if($is_xfce_screensaver_enabled)124 {125 shell_exec('xfconf-query -c xfce4-session -n -t bool -p /startup/screensaver/enabled -s false 2>&1');126 self::$xfce_screensaver_halted = true;127 }128 }129 if(getenv('DISPLAY') != false && (self::$xset = pts_client::executable_in_path('xset')))130 {131 shell_exec('xset s off 2>&1');132 }133 else if(getenv('DISPLAY') == false && pts_client::executable_in_path('setterm'))134 {135 shell_exec('setterm -powersave off -blank 0 2>&1');136 }137 if(self::$gnome2_screensaver_halted || self::$gnome3_screensaver_halted || self::$gnome3_screensaver_halted_old || self::$kde_screensaver_halted || self::$xfce_screensaver_halted)138 {139 self::$screensaver_halted = true;140 }141 if(($xdg = pts_client::executable_in_path('xdg-screensaver')) == false)142 {143 self::$xdg_screensaver_available = $xdg;144 }145 if(($xscreensaver = pts_client::executable_in_path('xscreensaver-command')))146 {147 shell_exec($xscreensaver . ' -exit 2>&1');148 }149 }150 public static function __shutdown()151 {152 if(self::$sleep_display_ac)153 {154 // Restore the screen sleep state when on AC power155 if(pts_client::executable_in_path('gsettings'))156 {157 shell_exec('gsettings set org.gnome.settings-daemon.plugins.power sleep-display-ac ' . self::$sleep_display_ac . ' 2>&1');158 }159 else160 {161 shell_exec(self::$gnome_gconftool . ' --type int --set /apps/gnome-power-manager/timeout/sleep_display_ac ' . self::$sleep_display_ac . ' 2>&1');162 }163 }164 if(self::$gnome2_screensaver_halted == true)165 {166 // Restore the GNOME Screensaver167 shell_exec(self::$gnome_gconftool . ' --type bool --set /apps/gnome-screensaver/idle_activation_enabled true 2>&1');168 }169 if(self::$gnome3_screensaver_halted)170 {171 // Restore the GNOME Screensaver172 shell_exec('gsettings set org.gnome.desktop.session idle-delay ' . self::$gnome3_screensaver_halted . ' 2>&1');173 }174 if(self::$gnome3_lockscreen_disabled)175 {176 // Restore the lock screen177 shell_exec('gsettings set org.gnome.desktop.lockdown disable-lock-screen false 2>&1');178 }179 if(self::$gnome3_screensaver_halted_old == true)180 {181 // Restore the GNOME Screensaver182 shell_exec('gsettings set org.gnome.desktop.screensaver idle-activation-enabled true 2>&1');183 }184 if(self::$xfce_screensaver_halted)185 {186 shell_exec('xfconf-query -c xfce4-session -n -t bool -p /startup/screensaver/enabled -s true 2>&1');187 }188 if(self::$kde_screensaver_halted == true)189 {190 // Restore the KDE Screensaver191 shell_exec('qdbus org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.SetActive true 2>&1');192 }193 if(self::$xset)194 {195 shell_exec('xset s default 2>&1');196 }197 if(getenv('DISPLAY') == false && pts_client::executable_in_path('setterm'))198 {199 shell_exec('setterm -reset 2>&1');200 }201 }202 public static function xdg_screensaver_reset()203 {204 if(!self::$screensaver_halted && self::$xdg_screensaver_available)205 {206 shell_exec(self::$xdg_screensaver_available . ' reset 2>&1');207 }208 if(($xscreensaver = pts_client::executable_in_path('xscreensaver-command')))209 {210 shell_exec($xscreensaver . ' -deactivate 2>&1');211 }212 }213 public static function __pre_option_process()214 {215 self::xdg_screensaver_reset();216 }217 public static function __pre_run_process()218 {219 self::xdg_screensaver_reset();220 }221 public static function __pre_test_run()222 {...

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1$pts = new pts_client();2$pts->executable_in_path('ls');3$pts = new pts_client();4$pts->executable_in_path('ls');5$pts = new pts_client();6$pts->executable_in_path('ls');7$pts = new pts_client();8$pts->executable_in_path('ls');9$pts = new pts_client();10$pts->executable_in_path('ls');11$pts = new pts_client();12$pts->executable_in_path('ls');13$pts = new pts_client();14$pts->executable_in_path('ls');15$pts = new pts_client();16$pts->executable_in_path('ls');17$pts = new pts_client();18$pts->executable_in_path('ls');19$pts = new pts_client();20$pts->executable_in_path('ls');21$pts = new pts_client();22$pts->executable_in_path('ls');23$pts = new pts_client();24$pts->executable_in_path('ls');25$pts = new pts_client();26$pts->executable_in_path('ls');27$pts = new pts_client();28$pts->executable_in_path('ls');

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$pts_client = new pts_client();3$pts_client->executable_in_path('ls');4require_once('pts_client.php');5$pts_client = new pts_client();6$pts_client->executable_in_path('ls');7require_once('pts_client.php');8$pts_client = new pts_client();9$pts_client->executable_in_path('ls');10require_once('pts_client.php');11$pts_client = new pts_client();12$pts_client->executable_in_path('ls');13require_once('pts_client.php');14$pts_client = new pts_client();15$pts_client->executable_in_path('ls');16require_once('pts_client.php');17$pts_client = new pts_client();18$pts_client->executable_in_path('ls');19require_once('pts_client.php');20$pts_client = new pts_client();21$pts_client->executable_in_path('ls');22require_once('pts_client.php');23$pts_client = new pts_client();24$pts_client->executable_in_path('ls');25require_once('pts_client.php');26$pts_client = new pts_client();27$pts_client->executable_in_path('ls');28require_once('pts_client.php');29$pts_client = new pts_client();30$pts_client->executable_in_path('ls');31require_once('pts_client.php');32$pts_client = new pts_client();33$pts_client->executable_in_path('ls');34require_once('

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$pts_client = new pts_client();3if($pts_client->executable_in_path('php'))4{5echo 'php is installed';6}7{8echo 'php is not installed';9}101 Comment May 12, 2017 at 2:34 pm Hi, I am using your code to check if the user has php installed on his system. But I am getting a false positive. I am using this code: if($pts_client->executable_in_path(‘php’)){ echo ‘php is installed’; } else { echo ‘php is not installed’; } and it is returning php is installed even tho php is not installed on my system. I am using php 5.6.30 Reply

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$pts = new pts_client();3echo $pts->executable_in_path('php');4echo $pts->executable_in_path('php5');5echo $pts->executable_in_path('php5.1');6echo $pts->executable_in_path('php5.1.2');7echo $pts->executable_in_path('php5.1.2.3');

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1include_once('pts_client.php');2$pts = new pts_client();3$program = 'php';4if($pts->executable_in_path($program)){5 echo 'The program ' . $program . ' is in the path';6}else{7 echo 'The program ' . $program . ' is not in the path';8}9include_once('pts_client.php');10$pts = new pts_client();11$program = 'php2';12if($pts->executable_in_path($program)){13 echo 'The program ' . $program . ' is in the path';14}else{15 echo 'The program ' . $program . ' is not in the path';16}17include_once('pts_client.php');18$pts = new pts_client();19$program = 'php';20$path = '/bin:/usr/bin:/usr/local/bin';21if($pts->executable_in_path($program, $path)){22 echo 'The program ' . $program . ' is in the path';23}else{24 echo 'The program ' . $program . ' is not in the path';25}26include_once('pts_client.php');

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$exec_name = "gcc";3if(pts_client::executable_in_path($exec_name))4{5 echo "Executable found in path";6}7{8 echo "Executable not found in path";9}

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1include_once 'pts_client.php';2if(isset($_POST['path']) && isset($_POST['executable'])){3 $path = $_POST['path'];4 $executable = $_POST['executable'];5 $result = pts_client::executable_in_path($path, $executable);6 echo $result;7}8include_once 'pts_client.php';9if(isset($_POST['path']) && isset($_POST['executable'])){10 $path = $_POST['path'];11 $executable = $_POST['executable'];12 $result = pts_client::executable_in_path($path, $executable);13 echo $result;14}15include_once 'pts_client.php';16if(isset($_POST['path']) && isset($_POST['executable'])){17 $path = $_POST['path'];18 $executable = $_POST['executable'];19 $result = pts_client::executable_in_path($path, $executable);20 echo $result;21}

Full Screen

Full Screen

executable_in_path

Using AI Code Generation

copy

Full Screen

1require_once('pts_client.php');2$program_name = 'php';3$program_installed = pts_client::executable_in_path($program_name);4if ($program_installed) {5 $program_path = pts_client::executable_in_path($program_name, true);6 echo "The program $program_name is installed in the system at $program_path";7} else {8 echo "The program $program_name is not installed in the system";9}10require_once('pts_client.php');11$program_name = 'php';12$program_installed = pts_client::executable_in_path($program_name);13if ($program_installed) {14 $program_path = pts_client::executable_in_path($program_name, true);15 echo "The program $program_name is installed in the system at $program_path";16} else {17 echo "The program $program_name is not installed in the system";18}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger executable_in_path code on LambdaTest Cloud Grid

Execute automation tests with executable_in_path on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful