]*>
]*>(.*)<\/td>
| ]*>(.*)<\/td>
| ]*>(.*)<\/td>/Ux", $val, $sub_ext);
foreach($sub[0] as $key => $val) {
switch (trim(strip_tags($sub[1][$key]))) {
case "Thread Safety": {
$result = trim(strip_tags($sub[2][$key]));
$env['php_ts'] = (strcasecmp($result, "enabled") == 0);
break;
}
case "Architecture": {
$env['php_arch'] = trim(strip_tags($sub[2][$key]));
break;
}
case "PHP Extension Build": {
$env['php_id'] = trim(strip_tags($sub[2][$key]));
break;
}
}
}
}
}
}
function IsLinux() {
return (stristr(PHP_OS, 'linux') !== false);
}
function IsWindows() {
return (stristr(PHP_OS, 'winnt')!==false || stristr(PHP_OS, 'win32')!==false);
}
function GetGlibcVersion() {
$glibc = '';
if (IsLinux()) {
$glibc = `/lib/libc.so.6 2>/dev/null`;
if ($glibc) {
$pat = '/GNU.*version\s*(\\d+\\.\\d+)/i';
}
else {
$libc_path_out = `ldd \`which ls\`|grep -w libc`;
$libc_path = preg_match('/=>[ ]+([^ ]+)[ ]/i', $libc_path_out, $libc_path_out) ? $libc_path_out[1] : '';
$glibc = false;
if ($libc_path) {
$glibc = `$libc_path 2>/dev/null`;
}
if ($glibc) {
$pat = '/GNU.*version\s*(\\d+\\.\\d+)/i';
}
else {
$glibc = `ldd --version`;
if ($glibc) {
$pat = '/ldd\s*\([^ \t]*\s*(?:[e]?[g]?)?libc.*\)\s*(\\d+\\.\\d+)/i';
}
}
}
$glibc = (preg_match($pat, $glibc, $glibc)) ? $glibc[1] : '';
}
return $glibc;
}
function is_32bit() {
if (version_compare(PHP_VERSION, '4.4.0', '>=') && (PHP_INT_SIZE > 4)) {
return false;
}
$a=@0x7FFFFFFFFF;
if (($a >> 24) == 0x7FFF) {
return false;
} else {
return true;
}
}
function server($idx) {
return (isset($_SERVER[$idx])) ? $_SERVER[$idx] : '';
}
function get_env($idx) {
$val = getenv($idx);
return (isset($val)) ? $val : '';
}
function doexplode($delim, $str) {
$token = strtok($str, $delim);
$r = array();
while ($token !== false) {
array_push($r, $token);
$token = strtok($delim);
}
return array_unique($r);
}
function get_client_address() {
$val = server('HTTP_X_FORWARDED_FOR');
if (!empty($val)) {
$val = doexplode(' ,;', $val);
$val = $val[0];
} else {
$val = server('REMOTE_ADDR');
if (empty($val)) {
$val = get_env('SSH_CLIENT');
if (empty($val))
$val = get_env('SSH_CONNECTION');
if (!empty($val)) {
$val = doexplode(' ,;', $val);
$val = $val[0];
}
}
}
return $val;
}
function is_running_srv() {
return (stristr(server('SERVER_SOFTWARE'), "Srv") !== false);
}
function is_dbg_installed() {
return extension_loaded('dbg');
}
function get_platform($is_ide, &$env) {
global $expected_dbg;
$platform = '';
$CPU = '';
$platform_is_supported = true;
$platform_errmsg = array();
$dbg_module = '';
$php_ts = '';
$dbg_loc_instr = "";
$dbg_arch = "";
chk_phpinfo($env);
$php_ts = $env['php_ts'];
$dbg_path_prefix = $is_ide ? "@PHPED_PATH@" : "<PhpED install path>";
$dbg_path = "\\debugger\\server\\";
$php_version = explode('.', phpversion());
if (!IsWindows()) {
$CPU = php_uname('m');
$dbg_module = sprintf("dbg-php-%d.%d.so", $php_version[0], $php_version[1]);
}
if (IsWindows()) {
$dbg_module = sprintf("dbg-php-%d.%d.dll", $php_version[0], $php_version[1]);
if (isset($env['php_arch'])) {
if (stristr($env['php_arch'], 'x64')!==false||stristr($env['php_arch'], 'x86_64')!==false||stristr($env['php_arch'], 'amd64')!==false) {
$CPU = 'x86_64';
if (!$php_ts)
$CPU .= "_NTS";
if (isset($env['php_id'])&&stristr($env['php_id'],'vs16')!==false) {
$CPU .= '_VS16';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc15')!==false) {
$CPU .= '_VC15';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc14')!==false) {
$CPU .= '_VC14';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc11')!==false) {
$CPU .= '_VC11';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc9')!==false) {
$CPU .= '_VC9';
} else if (empty($env['php_id'])) {
$CPU .= '_VC9';
} else {
$platform_errmsg[] = "Unrecognized/unsuppoted Run-Time ({$env['php_id']})";
$platform_is_supported = false;
}
} else if (stristr($env['php_arch'], 'x86')!==false||stristr($env['php_arch'], '386')!==false) {
$CPU = 'x86';
if (!$php_ts)
$CPU .= "_NTS";
if (isset($env['php_id'])&&stristr($env['php_id'],'vs16')!==false) {
$CPU .= '_VS16';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc15')!==false) {
$CPU .= '_VC15';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc14')!==false) {
$CPU .= '_VC14';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc11')!==false) {
$CPU .= '_VC11';
} else if (isset($env['php_id'])&&stristr($env['php_id'],'vc9')!==false) {
$CPU .= '_VC9';
} else if (!empty($env['php_id'])) {
$platform_errmsg[] = "Unrecognized/unsuppoted Run-Time ({$env['php_id']})";
$platform_is_supported = false;
}
}
}
if (empty($CPU)) {
$CPU = php_uname('m');
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
$CPU = 'x86';
if (!@is_32bit())
$CPU .="_64";
if (!$php_ts)
$CPU .= "_NTS";
} else {
$platform_is_supported = false;
$platform_errmsg[] = "Windows platform under $CPU CPU is not supported";
}
}
$dbg_path .= "Windows\\";
$dbg_loc_instr = "$dbg_module is located in $dbg_path_prefix$dbg_path$CPU directory";
}
elseif (stristr(PHP_OS, 'darwin')!==false||stristr(PHP_OS, 'mac')!==false) {
$platform = php_uname('r');
if (version_compare($platform, '12.6.0', '>=')) {
$package = "MacOSX";
} else {
$platform_is_supported = false;
$platform_errmsg[] = "Mac Darwin Kernel version $platform is not supported";
}
$CPU = php_uname('m');
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
}
else {
$platform_is_supported = false;
$platform_errmsg[] = "Mac OS X platform under $CPU CPU is not supported";
}
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
elseif (IsLinux()) {
$base='2.12';
if (stristr($CPU, 'unknown')!==false)
$CPU = php_uname('m');
if (!function_exists('shell_exec')) {
$platform_errmsg[] = "function shell_exec() is disabled, results may not be accurate";
$platform = $base;
} else if (stristr(ini_get('safe_mode'), '1') !== false || stristr(ini_get('safe_mode'), 'on') !== false){
$platform_errmsg[] = "safe_mode is turned on, results may not be accurate";
$platform = $base;
} else {
$platform=GetGlibcVersion();
}
if (stristr($CPU, 'arm')!==false)
$base='2.13';
else if (stristr($CPU, 'aarch64')!==false)
$base='2.27';
if (version_compare($platform, $base, '>=')) {
$package='Linux';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "Linux glibc version $platform is not supported";
}
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
} else if (preg_match("/armv([0-9]+)/i", $CPU, $matches) && (int)$matches[1] >= 7) {
$CPU = 'armv6';
} else if (stristr($CPU, 'aarch64')!==false) {
$CPU = 'aarch64';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "Linux platform under $CPU CPU is not supported";
}
$platform = "glibc-$platform";
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
elseif (stristr(PHP_OS, 'freebsd')!==false) {
$platform = (int)trim(php_uname('r'));//(int)`uname -r|sed 's,\\([0-9]*\\).*,\\1,g'`;
if ($platform >= 10) {
$package = 'FreeBSD';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "FreeBSD version $platform is not supported";
}
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
} else {
$platform_is_supported = false;
$platform_errmsg[] = "FreeBSD platform under $CPU CPU is not supported";
}
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
elseif (stristr(PHP_OS, 'netbsd')!==false) {
$platform = (int)trim(php_uname('r'));//(int)`uname -r|sed 's,\\([0-9]*\\).*,\\1,g'`;
if ($platform >= 7) {
$package = 'NetBSD';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "NetBSD version $platform is not supported";
}
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
} else {
$platform_is_supported = false;
$platform_errmsg[] = "NetBSD platform under $CPU CPU is not supported";
}
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
elseif (stristr(PHP_OS, 'openbsd')!==false) {
$platform = (int)trim(php_uname('r')); //`uname -r|sed 's,\\([0-9]*\\).*,\\1,g'`;
if ($platform >= 6) {
$package = 'OpenBSD';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "OpenBSD version $platform is not supported";
}
$CPU = php_uname('m');
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
} else {
$platform_is_supported = false;
$platform_errmsg[] = "OpenBSD platform under $CPU CPU is not supported";
}
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
elseif (stristr(PHP_OS, 'sunos')!==false||stristr(PHP_OS, 'solaris')!==false) {
$platform = trim(php_uname('r'));
$CPU = php_uname('m');
if (version_compare($platform, '5.11', '>=')) {
$package='SunOS';
} else {
$platform_is_supported = false;
$platform_errmsg[] = "Sun OS $platform is not supported";
}
if (stristr('i86pc', $CPU)!==false)
$CPU='i386';
if (stristr($CPU, 'amd64')!==false||stristr($CPU, 'x86_64')!==false||stristr($CPU, 'i386')!==false||stristr($CPU, 'x86')!==false||stristr($CPU, 'i686')!==false||stristr($CPU, 'i586')!==false) {
if (@is_32bit()) {
$CPU = 'x86';
} else {
$CPU = 'x86_64';
}
} else {
$platform_is_supported = false;
$platform_errmsg[] = "SUN platform under $CPU CPU is not supported";
}
$dbg_arch = sprintf("dbg-%s-%s.tar.gz", $expected_dbg, $package);
$dbg_loc_instr = "$dbg_module is packed into $dbg_path_prefix$dbg_path$dbg_arch archive, in $CPU subdirectory inside the archive";
}
else {
$platform = PHP_OS . ' ' . php_uname('r');
$platform_is_supported = false;
$platform_errmsg[] = "$platform is not supported";
}
if (!IsWindows() && $php_ts) {
$CPU .= '_TS';
}
$platform = PHP_OS . (empty($platform) ? "" : "-$platform");
if (version_compare(PHP_VERSION, DBGWIZ_MIN_PHP_VERSION, '<')) {
$platform_errmsg[] = "Php version " . PHP_VERSION . " is too outdated and not supported by this product. Please update to " . DBGWIZ_MIN_PHP_VERSION . " or higher";
$platform_is_supported = false;
}
elseif (version_compare(PHP_VERSION, DBGWIZ_MAX_PHP_VERSION, '>')) {
$platform_errmsg[] = "Php version " . PHP_VERSION . " is not supported by this product. Please check for the product updates at https://shop.nusphere.com/";
$platform_is_supported = false;
}
elseif (version_compare(PHP_VERSION, DBGWIZ_BUNDLED_MIN_PHP_VERSION, '<')) {
$dbg_path = "";
$dbg_arch = "";
$dbg_loc_instr = "$dbg_module is supported but not bundled with this product. Please contact support for the module(s) http://www.nusphere.com/contact_us";
}
$env['platform'] = $platform;
$env['CPU'] = $CPU;
$env['platform_is_supported'] = $platform_is_supported;
$env['platform_errmsg'] = count($platform_errmsg) > 0 ? implode(', ', $platform_errmsg) : '';
$env['dbg_module'] = $dbg_module;
$env['dbg_arch'] = $dbg_arch;
$env['dbg_path'] = $dbg_path;
$env['dbg_loc_instr'] = $dbg_loc_instr;
}
function normalize_path($apath) {
if (IsWindows()) {
$apath = strtolower(str_replace("/", "\\", $apath));
} else {
$apath = realpath($apath);
}
return $apath;
}
function get_webserver_details(&$remote_path, &$remote_root, &$local_webserver, &$php_ini, &$extensions_dir, &$remote_url, &$server_name, &$sapi_name, &$php_version) {
$php_ini = (string)get_cfg_var("cfg_file_path");
$php_version = (string)phpversion();
$server_name = server('SERVER_NAME');
$client_addr = get_client_address();
$local_webserver = (($client_addr == server('SERVER_ADDR')) || $server_name == 'localhost');
$port = server('SERVER_PORT');
$sapi_name = php_sapi_name();
$extensions_dir = ini_get('extension_dir');
$remote_path = normalize_path(dirname(__FILE__) . DIRECTORY_SEPARATOR);
$url_path = '';
if (isset($_SERVER['DOCUMENT_ROOT'])) {
$remote_root = normalize_path($_SERVER['DOCUMENT_ROOT']);
if (!empty($remote_root)) {
$ch = $remote_root[strlen($remote_root) - 1];
if ($ch !== '/' && $ch !== "\\") {
$remote_root = $remote_root . DIRECTORY_SEPARATOR;
}
}
$url_path = @strstr( $remote_path, $remote_root);
$outside_of_root = $url_path === false;
if (!$outside_of_root) {
$url_path = substr ($remote_path, strlen($remote_root));
} else {
$url_path = server('REQUEST_URI');
$r = strrpos($url_path, '/');
if ($r === false) $r = strlen($url_path);
$url_path = substr ($url_path, 1, $r - 1);
}
if (!empty($url_path)) {
$ch = $url_path[strlen($url_path) - 1];
if ($ch !== '/' && $ch !== "\\") {
$url_path = $url_path . '/';
}
}
} else {
$remote_root = '';
$outside_of_root = true;
}
if (IsWindows()) {
$extensions_dir = str_replace("/", "\\", $extensions_dir);
$remote_root = str_replace("/", "\\", $remote_root);
$remote_path = str_replace("/", "\\", $remote_path);
}
$url_path = str_replace("\\", "/", $url_path);
$is_ssl = (strtolower(server('HTTPS')) == 'on') || (server('SERVER_PORT') == 443);
if (!empty($server_name)) {
$remote_url = (($is_ssl) ? "https://" : "http://") . $server_name;
if (!empty($port) && !(!$is_ssl && $port =="80") && !($is_ssl && $port == 443))
$remote_url .=':'.$port;
if (!$outside_of_root || !empty($url_path))
$remote_url .='/'.$url_path;
else if (empty($url_path))
$remote_url .= '/';
} else {
$remote_url = '';
}
}
function _exec($cmd) {
$descriptorspec = array(
0 => array("null", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
if (version_compare(phpversion(), '7.4.0') < 0) {
$descriptorspec[0] = array("pipe", "r");
}
if (IsWindows()) {
$p = proc_open($cmd, $descriptorspec, $pipes, NULL, NULL, array('bypass_shell' => TRUE));
} else {
$p = proc_open($cmd, $descriptorspec, $pipes);
}
$out = "";
$err = "";
if ($p && is_resource($p)) {
if (isset($pipes[0]) && is_resource($pipes[0]))
fclose($pipes[0]);
while (1) {
$has_stdout = isset($pipes[1]) && is_resource($pipes[1]);
$has_stderr = isset($pipes[2]) && is_resource($pipes[2]);
if (!$has_stdout && !$has_stderr) {
break;
}
if ($has_stderr) {
$err .= fread($pipes[2], 256);
if (feof($pipes[2])) {
fclose($pipes[2]);
unset($pipes[2]);
}
}
if ($has_stdout) {
$out .= fread($pipes[1], 256);
if (feof($pipes[1])) {
fclose($pipes[1]);
unset($pipes[1]);
}
}
}
$rv = proc_close($p);
return array('ret_code' => $rv, 'stdout' => $out, 'stderr' => $err);
} else {
return array('ret_code' => -1, 'stdout' => '', 'stderr' => 'Failed to run: $cmd');
}
}
function find_file($file_name, $dflt, $dir_list) {
if (!$file_name) {
$file_name = $dflt;
}
if (!$file_name) {
return null;
}
$lst = explode(PATH_SEPARATOR, $dir_list);
foreach($lst as $dir) {
$res = join(DIRECTORY_SEPARATOR,
array(
rtrim($dir, DIRECTORY_SEPARATOR),
ltrim($file_name, DIRECTORY_SEPARATOR)));
if (file_exists($res)) {
return $res;
}
}
if ($file_name !== $dflt && $dflt) {
foreach($lst as $dir) {
$res = join(DIRECTORY_SEPARATOR,
array(
rtrim($dir, DIRECTORY_SEPARATOR),
trim($file_name, DIRECTORY_SEPARATOR),
ltrim($dflt, DIRECTORY_SEPARATOR)));
if (file_exists($res)) {
return $res;
}
}
}
return null;
}
function unquote_str($str) {
if (strlen($str) >= 2 && ($str[0] === "'" || $str[0] === '"') && $str[strlen($str) - 1] === $str[0]) {
return substr($str, 1, strlen($str) - 2);
}
return $str;
}
function get_phpunit($path, &$rslt) {
global $php_bin;
$path = unquote_str($path);
if (!$path || (!is_absolute_path($path) && !file_exists($path))) {
$path = find_file($path, 'phpunit', $_ENV['PATH']);
}
if ($path && file_exists($path)) {
$rslt['phpunit_path'] = $path;
$rslt['php_bin'] = $php_bin;
$rv = _exec("\"$php_bin\" \"$path\" --version");
if (!IsWindows() && ($rv['ret_code'] < 0) && is_executable($path)) {
// try phpunit shell script wrapper
$rv = _exec("\"$path\" --version");
}
$rslt['phpunit_version'] = trim($rv['stdout']);
$rslt['phpunit_error'] = trim($rv['stderr']);
}
else if (!$path) {
$rslt['phpunit_error'] = "phpunit is not found";
}
else {
$rslt['phpunit_error'] = "phpunit ($path) is not found";
}
}
function is_absolute_path($path) {
if($path === null || !is_string($path) || $path === '')
return false;
if (IsWindows()) {
return preg_match('~^[A-Z]:(?![^/\\\\])~i',$path) > 0;
} else {
return $path[0] === DIRECTORY_SEPARATOR;
}
}
function get_results($is_ide, &$rslt, &$notices, &$env, &$dbg_instructions, &$proj_settings) {
global $expected_dbg, $expected_phpunit;
$rslt = array();
$notices = array();
$dbg_instructions = array();
$proj_settings = array();
$env = array();
get_platform($is_ide, $env);
get_webserver_details($env['remote_path'], $env['remote_root'], $env['local_webserver'], $env['php_ini'], $env['extensions_dir'], $env['remote_url'], $env['server_name'], $env['sapi_name'], $env['php_version']);
if (!empty($expected_phpunit)) {
get_phpunit($expected_phpunit, $env);
}
$env['client_ip'] = get_client_address();
$env['server_ip'] = server('SERVER_ADDR');
if (empty($env['server_ip']) && server('SERVER_NAME')==='localhost') {
$env['server_ip'] = '127.0.0.1';
}
if (empty($env['server_ip']) && server('SERVER_NAME')==='localhost6') {
$env['server_ip'] = '::1';
}
if (empty($env['remote_root']) || $env['remote_root'] === DIRECTORY_SEPARATOR)
$notices[] = 'Please make sure that you run this script under WEB server, not by invoking php in the console';
if (empty($env['php_ini']))
$notices[] = 'path to php.ini is not determined';
if (substr($env['extensions_dir'], 0, 2) === './' || substr($env['extensions_dir'], 0, 2) === '.\\')
$notices[] = 'I highly recommend you to update extension_dir in your php.ini file to contain absolute path';
$rslt['php_version_string'] = array('caption' => 'PHP Version:', 'value' => phpversion());
$rslt['webserver'] = array('caption' => 'Web Server:', 'value' => server('SERVER_SOFTWARE'));
$rslt['server_name'] = array('caption' => 'Server Name:', 'value' => $env['server_name']);
$rslt['platform'] = array('caption' => 'Platform:', 'value' => $env['platform'] . "/" . $env['CPU']);
$rslt['client_ip'] = array('caption' => 'Your Client IP Address:', 'value' => $env['client_ip']);
$rslt['server_ip'] = array('caption' => 'Your Server IP Address:', 'value' => $env['server_ip']);
$rslt['port'] = array('caption' => 'Port:', 'value' => server('SERVER_PORT'));
$rslt['is_local'] = array('caption' => $env['local_webserver'] ?
'Your Web Server is on the same machine with PhpED' :
'Your Web Server and PhpED are on different machines');
$rslt['remote_path'] = array('caption' => 'Path to website files:', 'value' => $env['remote_path']);
$rslt['remote_root'] = array('caption' => 'Document Root is:', 'value' => $env['remote_root']);
$rslt['php_ini'] = array('caption' => 'Your PHP.INI file is:', 'value' => $env['php_ini']);
$rslt['extension_dir'] = array('caption' => 'PHP extensions directory is:', 'value' => $env['extensions_dir']);
if (is_dbg_installed()) {
$dbg_version = phpversion("dbg");
$env['dbg_version'] = $dbg_version;
$version_array = explode(".",$dbg_version);
$inred = false;
if (!version_compare($dbg_version, $expected_dbg, '=')) {
if (version_compare($dbg_version, $expected_dbg, '<')) {
$notices[] = 'Installed DBG module is of an older version than currently available from NuSphere';
$inred = true;
} else {
$notices[] = 'Perhaps, DBG Wizard is outdated, please download the latest one from this link';
}
}
$rslt['dbg_installed'] = array('caption' => "DBG (PHP DEBUGGER) Version $dbg_version is ", 'value' => ($inred ? '':'') . 'INSTALLED' . ($inred ? '':''));
}
else {
$notices[] = 'DBG (PHP DEBUGGER) is not installed';
$dbg_instructions[] = "Your debugger module " . $env['dbg_loc_instr'];
$dbg_instructions[] = "Copy {$env['dbg_module']} into {$env['extensions_dir']} on your server {$env['server_name']}.";
$phpfilename = !empty($env['php_ini']) ? $env['php_ini'] : "php.ini";
$lines = "Add the following lines into $phpfilename
";
if (substr($env['extensions_dir'], -1, 1) == DIRECTORY_SEPARATOR)
$zend_extension_path = $env['extensions_dir'] . $env['dbg_module'];
else
$zend_extension_path = $env['extensions_dir'] . DIRECTORY_SEPARATOR . $env['dbg_module'];
if ($env['php_ts'] && version_compare(PHP_VERSION, '5.3.0', '<'))
$zend_ext_key = "zend_extension_ts";
else
$zend_ext_key = "zend_extension";
$lines .= "$zend_ext_key=\"$zend_extension_path\"
Note: if debugger module is loaded using this way, please make sure extension={$env['dbg_module']} line is removed or commented out.";
$lines .= " |
[debugger]
debugger.hosts_allow= {$env['client_ip']} localhost ::1 127.0.0.1
debugger.hosts_deny=ALL
debugger.ports=7869 |
";
$dbg_instructions[] = $lines;
$lines = 'debugger.hosts_allow has should be in format debugger.hosts_allow= host1 host2 host3, where host1, host2 and host3are host names or IP or network addresses
allowed to start debug sessions.';
if (!$env['local_webserver']) {
$lines .= 'If you run debug session through
an SSH tunnel, you need to
list only local IP addresses (localhost ::1 127.0.0.1)';
}
$dbg_instructions[] = $lines;
$dbg_instructions[] = 'Restart web server';
$dbg_instructions[] = 'Launch phpinfo and check its output. Make sure that one of the topmost headers contains
Zend Engine vX.X.0, Copyright (c) 1998-200x Zend Technologies with DBG v ' . $expected_dbg . ', (C) 2000, 2018 by Dmitri Dmitrienko ';
}
// Project Root Directory
$lines = $env['remote_path'];
if (!$env['local_webserver']) {
$lines .= "";
}
$proj_settings['project_root'] = array('caption' => 'Project -> Root Directory:', 'value' => $lines);
// Run Mode
if (is_running_srv())
$lines = 'HTTP Mode (SRV local WEB server)';
else {
$lines = 'HTTP Mode (3-rd party WEB server)';
}
$proj_settings['run_mode'] = array('caption' => 'Mapping -> Run Mode:', 'value' => $lines);
if (!is_running_srv()) {
// Remote URL
$proj_settings['remote_url'] = array('caption' => 'Mapping -> Remote URL:', 'value' => $env['remote_url']);
if (empty($env['remote_url']))
$notices[] = 'Please make sure that you run this script under a WEB server, not by invoking php directly';
// Remote Root
$lines = $env['remote_path'];
if ($env['local_webserver'])
$lines .= " (same as Project -> Root Directory)";
$proj_settings['remote_root'] = array('caption' => 'Mapping -> Remote Root Directory:', 'value' => $lines);
}
}
function print_value(&$avalue) {
if (is_array($avalue)) {
if (isset($avalue['value'])) {
if (strlen($avalue['value']) == 0)
return "not determined";
else
return "{$avalue['value']}";
}
} else {
if (empty($avalue))
return "not determined";
else
return "$avalue";
}
}
$args = array();
if (isset($_GET) && count($_GET) > 0) {
foreach($_GET as $k=>$arg) {
if (!isset($arg) || empty($arg)) {
$args[] = $k;
} else {
$args[] = "$k=$arg";
}
}
} else if (isset($argv)) {
foreach ($argv as $k=>$arg) {
if ($k != '0') {
if (strpos($arg, '?') === 0)
$arg = substr($arg, 1);
$args[] = $arg;
}
}
}
if (isset($_COOKIE["DBGW-ARG"])) {
$argcookie = explode('&', $_COOKIE["DBGW-ARG"]);
foreach ($argcookie as $arg) {
if (!empty($arg)) {
$args[] = $arg;
}
}
}
if (is_array($args) && count($args) > 0) foreach ($args as $arg) {
if (strpos($arg, '--') !== FALSE) {
$arg = substr($arg, 2);
}
if (strpos($arg, '=') >= 1) {
$arg = explode('=', $arg);
$val = array_pop($arg);
$arg = $arg[0];
}
switch($arg) {
case "version":
header("Content-type: text/plain");
printf("version=%s\n", DBG_WIZARD_VERSION);
die();
case "phpinfo":
phpinfo();
die();
case "extensions":
$rslt = get_loaded_extensions();
printf("extensions=%s\n", serialize($rslt));
die();
case "expected-dbg":
$expected_dbg = $val;
break;
case "php_bin":
$php_bin = $val;
break;
case "phpunit":
$expected_phpunit = $val;
break;
case "ide":
header("Content-type: text/plain");
get_results(true, $rslt, $notices, $env, $dbg_instructions, $proj_settings);
if (version_compare(PHP_VERSION, '5.2.4', '>=')) {
$zend_extensions=@get_loaded_extensions(TRUE);
} else if (version_compare(phpversion('dbg'), '3.6.3', '>=')) {
$zend_extensions=@dbg_get_loaded_zendextensions();
} else {
$zend_extensions=array();
}
$extensions = get_loaded_extensions();
printf("result=%s\n", serialize($rslt));
printf("notices=%s\n", serialize($notices));
printf("env=%s\n", serialize($env));
printf("zend_extensions=%s\n", serialize($zend_extensions));
printf("extensions=%s\n", serialize($extensions));
die();
}
}
?>
NuSphere PHP Debugger (DBG) Helper
Thank you for using NuSphere DBG Wizard (v). I am your DBG (PHP Debugger) Helper Script.
I will try to help you with setting up your PhpED project and installing DBG - NuSphere
PHP Debugger. I'll do my best and suggest the ways to configure things, but if you still having problems, please don't forget:
NuSphere's team is committed to making you successful. Here is the list of resources you can use:
What did I find out about your system
I assume that you placed me in the root directory of your web server
and on your PhpED machine pointed your browser to me - like this: <URL of your web site>/dbg-wizard.php
I see that:
$cap " . print_value($value) . "\n";
}
?>
$i. $value \n";
$i++;
}
if ($env['platform_errmsg']) {
echo " $i. {$env['platform_errmsg']}\n";
echo "Please consult with this table regarding supported platforms.";
}
?>
You ran this script under Srv
I have detected that you are running me with Srv - PhpED internal Web Server.
Srv is perfect for local debugging and if that's what you are planning to do - you are all set!
However, if your intention is to debug and run the scripts in your Apache or IIS Web Server
environment you need to place me in the directory that is served by those servers and execute me again.
How to install Server side DBG module
I noticed that DBG (PHP DEBUGGER) is NOT INSTALLED on your server echo server('SERVER_NAME') ?>.
";
foreach ($dbg_instructions as $value)
echo "- $value
";
echo ' ';
}
?>
How to setup your PhpED Project Properties
I can suggest the following settings for your Project to debug PHP scripts on Server :
You can create new Project by selecting File->New Project or by selecting New Project in the Workspace Pop up Menu
In the Project Properties Dialog set:
$cap " . print_value($value) . "\n";
}
?>
All rights reserved. Copyright © 2000-2023 NuSphere Corp http://www.nusphere.com
|