public function getNetwork() { if (!$this->_network instanceof Network_Interface) { $this->_network = Network::create($this); } return $this->_network; }
/** * Тест удачной обработки потоков. */ public function testDispatchSuccess() { /* Настройка заглушек объектов */ $context = $this->getMock('Network_Context_Interface'); $opts = $this->getMock('Options_Interface'); $selector = $this->getMock('IO_Stream_Selector_Interface'); $stream = $this->getMock('IO_Stream_Buffered_Interface'); $listener = $this->getMock('IO_Stream_Listener_Interface'); /* Один раз будет создан новый объект настроек */ $context->expects($this->once())->method('createOptions')->will($this->returnValue($opts)); /* Один раз будут установлены опции */ $opts->expects($this->once())->method('apply'); /* Один раз будет создан селектор потоков */ $context->expects($this->once())->method('createStreamSelector')->will($this->returnValue($selector)); /* Один раз будет вызван метод регистрации потока */ $selector->expects($this->once())->method('register')->with($this->equalTo($stream)); /* Селектор вернёт 1 поток, готовый к обработке */ $selector->expects($this->once())->method('select')->will($this->returnValue(array($stream))); /* Один раз у потока будет запрошен обработчик событий */ $stream->expects($this->once())->method('getListener')->will($this->returnValue($listener)); /* Проверка, закрылся ли поток или нет, вернёт true */ $stream->expects($this->once())->method('isOpen')->will($this->returnValue(true)); /* Поток дважды скажет, что готов к операции */ $stream->expects($this->exactly(2))->method('getReady')->will($this->returnValue(true)); $callback = array($this, 'readCallback'); /* Будет два цикла чтения из потока */ $stream->expects($this->exactly(2))->method('read')->will($this->returnCallback($callback)); $callback = array($this, 'writeCallback'); /* И два цикла записи в поток */ $stream->expects($this->exactly(2))->method('write')->will($this->returnCallback($callback)); /* Будет вызван обработчик события чтения из потока */ $listener->expects($this->once())->method('onStreamRead')->with($this->equalTo($stream), $this->equalTo(4096)); /* И обработчик события записи в поток */ $listener->expects($this->once())->method('onStreamWrite')->with($this->equalTo($stream), $this->equalTo(4096)); $net = Network::create($context); $net->registerStream($stream); $net->dispatchStreams(); }
$url_location = htmlspecialchars($GPXIN['location']); #$url_login_user = base64_decode($GPXIN['login_user']); #$url_login_pass = base64_decode($GPXIN['login_pass']); #$url_login_port = base64_decode($GPXIN['login_port']); #$url_homedir = base64_decode($GPXIN['homedir']); $url_login_user = $GPXIN['login_user']; $url_login_pass = $GPXIN['login_pass']; $url_login_port = $GPXIN['login_port']; $url_homedir = $GPXIN['homedir']; // Create if ($url_do == 'create') { // NO root users if ($url_login_user == 'root') { die('Do not set <b>Login User</b> to <font color="red">root</font>! Set this to the normal Linux user created during Remote Server installation. See <a href="http://gamepanelx.com/wikiv3/index.php?title=Remote_Install" class="links" target="_blank">Remote Server Documentation</a>'); } echo $Network->create($url_ip, $url_local, $url_os, $url_dc, $url_location, $url_login_user, $url_login_pass, $url_login_port); } elseif ($url_do == 'save') { // Include config require DOCROOT . '/configuration.php'; $enc_key = $settings['enc_key']; if (empty($enc_key)) { die($lang['no_enc_key']); } @mysql_query("UPDATE network SET ip='{$url_ip}',is_local='{$url_local}',os='{$url_os}',datacenter='{$url_dc}',location='{$url_location}',login_user=AES_ENCRYPT('{$url_login_user}', '{$enc_key}'),login_pass=AES_ENCRYPT('{$url_login_pass}', '{$enc_key}'),login_port=AES_ENCRYPT('{$url_login_port}', '{$enc_key}'),homedir='{$url_homedir}' WHERE id = '{$url_id}'") or die('Failed to update network settings'); echo 'success'; } elseif ($url_do == 'delete') { echo $Network->delete($url_id); } elseif ($url_do == 'delete_ip') { @mysql_query("DELETE FROM network WHERE id = '{$url_id}'") or die('Failed to delete the IP Address'); echo 'success'; } elseif ($url_do == 'show_addip') {
fclose($fh); } $_SESSION['install_config'] = 1; ##################################################################################### // Insert configuration items if (!isset($_SESSION['install_configitems'])) { $gpx_version = GPX_VERSION; @mysql_query("INSERT INTO `configuration` (`config_setting`, `config_value`) VALUES('default_email_address', '{$url_admin_email}'),('language', '{$url_language}'),('company', 'GamePanelX'),('theme', 'default'),('api_key', '{$api_key}'),('version', '{$gpx_version}'),('steam_login_user',''),('steam_login_pass',''),('steam_auth','')") or die('Failed to insert configuration items: ' . mysql_error()); } $_SESSION['install_configitems'] = 1; ##################################################################################### // Add a default local server for the new people's sanity if (!isset($_SESSION['install_addnet'])) { require DOCROOT . '/includes/classes/network.php'; $Network = new Network(); $result_net = $Network->create($_SERVER['SERVER_ADDR'], '1', PHP_OS, '', 'Auto-Generated Local Server', '', '', ''); if ($result_net != 'success') { die('Failed to create default network server: ' . $result_net); } } $_SESSION['install_addnet'] = 1; ##################################################################################### // Create a default sample user if (!isset($_SESSION['install_adduser'])) { $username = '******'; $password = $Core->genstring(16); $fk_pass = $Core->genstring(24); $enc_key = $rand_string; @mysql_query("INSERT INTO users (date_created,sso_user,sso_pass,username,password,first_name,last_name) VALUES(NOW(),AES_ENCRYPT('{$username}', '{$enc_key}'),AES_ENCRYPT('{$password}', '{$enc_key}'),'{$username}',MD5('{$fk_pass}'),'Example','User')") or die('Failed to create user: '******'install_adduser'] = 1;
function CheckServer() { global $zbp; global $CheckResult; $CheckResult = array('server' => array(GetVars('SERVER_SOFTWARE', 'SERVER'), bingo), 'phpver' => array(PHP_VERSION, ''), 'zbppath' => array($zbp->path, bingo), 'gd2' => array('', ''), 'mysql' => array('', ''), 'mysqli' => array('', ''), 'pdo_mysql' => array('', ''), 'sqlite' => array('', ''), 'sqlite3' => array('', ''), 'pdo_sqlite' => array('', ''), 'pgsql' => array('', ''), 'pdo_pgsql' => array('', ''), 'mbstring' => array('', ''), 'zb_users' => array('', ''), 'cache' => array('', ''), 'data' => array('', ''), 'include' => array('', ''), 'theme' => array('', ''), 'plugin' => array('', ''), 'upload' => array('', ''), 'c_option.php' => array('', ''), 'curl' => array($zbp->lang['zb_install']['connect_appcenter'], ''), 'allow_url_fopen' => array($zbp->lang['zb_install']['connect_appcenter'], ''), 'gethostbyname' => array($zbp->lang['zb_install']['whois_dns'], '')); if (version_compare(PHP_VERSION, '5.2.0') >= 0) { $CheckResult['phpver'][1] = bingo; } else { $CheckResult['phpver'][1] = error; } if (function_exists("gd_info")) { $info = gd_info(); $CheckResult['gd2'][0] = $info['GD Version']; $CheckResult['gd2'][1] = $CheckResult['gd2'][0] ? bingo : error; } if (function_exists("mysql_get_client_info")) { $CheckResult['mysql'][0] = strtok(mysql_get_client_info(), '$'); $CheckResult['mysql'][1] = $CheckResult['mysql'][0] ? bingo : error; } if (function_exists("mysqli_get_client_info")) { $CheckResult['mysqli'][0] = strtok(mysqli_get_client_info(), '$'); $CheckResult['mysqli'][1] = $CheckResult['mysqli'][0] ? bingo : error; } if (function_exists("mb_language")) { $CheckResult['mbstring'][0] = mb_language(); $CheckResult['mbstring'][1] = $CheckResult['mbstring'][0] ? bingo : error; } if (class_exists("PDO", false)) { if (extension_loaded('pdo_mysql')) { //$pdo = new PDO( 'mysql:'); $v = ' '; //strtok($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION),'$'); $pdo = null; $CheckResult['pdo_mysql'][0] = $v; $CheckResult['pdo_mysql'][1] = $CheckResult['pdo_mysql'][0] ? bingo : error; } if (extension_loaded('pdo_sqlite')) { //$pdo = new PDO('sqlite::memory:'); $v = ' '; //$pdo->getAttribute(PDO::ATTR_CLIENT_VERSION); $pdo = null; $CheckResult['pdo_sqlite'][0] = $v; $CheckResult['pdo_sqlite'][1] = $CheckResult['pdo_sqlite'][0] ? bingo : error; } if (extension_loaded('pdo_pgsql')) { $v = ' '; $pdo = null; $CheckResult['pdo_pgsql'][0] = $v; $CheckResult['pdo_pgsql'][1] = $CheckResult['pdo_pgsql'][0] ? bingo : error; } } if (defined("PGSQL_STATUS_STRING")) { $CheckResult['pgsql'][0] = PGSQL_STATUS_STRING; $CheckResult['pgsql'][1] = $CheckResult['pgsql'][0] ? bingo : error; } if (function_exists("sqlite_libversion")) { $CheckResult['sqlite'][0] = sqlite_libversion(); $CheckResult['sqlite'][1] = $CheckResult['sqlite'][0] ? bingo : error; } if (class_exists('SQLite3', false)) { $info = SQLite3::version(); $CheckResult['sqlite3'][0] = $info['versionString']; $CheckResult['sqlite3'][1] = $CheckResult['sqlite3'][0] ? bingo : error; } getRightsAndExport('', 'zb_users'); getRightsAndExport('zb_users/', 'cache'); getRightsAndExport('zb_users/', 'data'); getRightsAndExport('zb_users/', 'theme'); getRightsAndExport('zb_users/', 'plugin'); getRightsAndExport('zb_users/', 'upload'); //getRightsAndExport('zb_users/','c_option.php'); $CheckResult['network'][0] = $zbp->lang['zb_install']['environment_network_description']; $CheckResult['simplexml_load_string'][0] = $zbp->lang['zb_install']['environment_xml_description']; $CheckResult['json_decode'][0] = $zbp->lang['zb_install']['environment_json_description']; $CheckResult['iconv'][0] = $zbp->lang['zb_install']['environment_iconv_description']; $CheckResult['mb_strlen'][0] = $zbp->lang['zb_install']['environment_mb_description']; $networkTest = Network::create(); $CheckResult['network'][1] = $networkTest == false ? error : bingo; $CheckResult['simplexml_load_string'][1] = function_exists('simplexml_load_string') ? bingo : error; $CheckResult['json_decode'][1] = function_exists('json_decode') ? bingo : error; $CheckResult['iconv'][1] = function_exists('iconv') ? bingo : error; $CheckResult['mb_strlen'][1] = function_exists('mb_strlen') ? bingo : error; }