It provides basic name resolution features and the ability to rotate between different IP addresses belonging to a single DNS name.
저자: Sebastian Staudt
예제 #1
0
파일: Server.php 프로젝트: T-REX-XP/UPnP
 public static function forge($request)
 {
     $server = new Server();
     $server->setRequest($request);
     $server->parse();
     return $server;
 }
예제 #2
0
 /**
  * Start server
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $stor = new TestingStorage();
     $stor->add(new TestingCollection('/', $stor));
     $stor->add(new TestingCollection('/.trash', $stor));
     $stor->add(new TestingElement('/.trash/do-not-remove.txt', $stor));
     $stor->add(new TestingCollection('/htdocs', $stor));
     $stor->add(new TestingElement('/htdocs/file with whitespaces.html', $stor));
     $stor->add(new TestingElement('/htdocs/index.html', $stor, "<html/>\n"));
     $stor->add(new TestingCollection('/outer', $stor));
     $stor->add(new TestingCollection('/outer/inner', $stor));
     $stor->add(new TestingElement('/outer/inner/index.html', $stor));
     $auth = newinstance('lang.Object', array(), '{
     public function authenticate($user, $password) {
       return ("testtest" == $user.$password);
     }
   }');
     $protocol = newinstance('peer.ftp.server.FtpProtocol', array($stor, $auth), '{
     public function onShutdown($socket, $params) {
       $this->answer($socket, 200, "Shutting down");
       $this->server->terminate= TRUE;
     }
   }');
     isset($args[0]) && $protocol->setTrace(Logger::getInstance()->getCategory()->withAppender(new FileAppender($args[0])));
     $s = new Server('127.0.0.1', 0);
     try {
         $s->setProtocol($protocol);
         $s->init();
         Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
         $s->service();
         Console::writeLine('+ Done');
     } catch (Throwable $e) {
         Console::writeLine('- ', $e->getMessage());
     }
 }
예제 #3
0
 public function __construct(array $options = null)
 {
     if (!is_array($options)) {
         $options = [];
     }
     if (empty($options["smtpServer"])) {
         $hostname = "localhost";
     } else {
         $hostname = $options["smtpServer"];
     }
     if ($hostname === "localhost") {
         $port = isset($options["local-port"]) ? $options["local-port"] : 25;
     } else {
         $port = isset($options["port"]) ? $options["port"] : 465;
     }
     $server = new Server($hostname, $port);
     if (!empty($options["username"]) || !empty($options["password"])) {
         $server->setCredentials($options["username"], $options["password"]);
     }
     if (!empty($options["encryption"])) {
         $server->setEncryptionMethod($options["encryption"]);
     }
     if (!empty($options["returnPath"])) {
         $server->setReturnPath($options["returnPath"]);
     }
     parent::__construct($server);
     if (!empty($options["fromAddress"])) {
         $this->setFromAddress($options["fromAddress"], $options["fromName"]);
     }
 }
예제 #4
0
파일: Client.php 프로젝트: eridal/vindinium
 /**
  * @param string $url
  * @param array $params [optional]
  * @return State
  */
 function send($url, array $params = null)
 {
     if ($data = $this->server->send($url, $params)) {
         return new State($data);
     }
     throw new ServerException("Bad Response from Server");
 }
 public function testServerAcceptClient()
 {
     self::$server->onConnectPeer(function (Peer $peer) {
         self::$peer_accepted++;
     });
     self::$server->listen();
 }
예제 #6
0
 public function getStreamSrc($args, $querySep = '&amp;')
 {
     if (isset($this->{'ServerId'}) and $this->{'ServerId'}) {
         $Server = new Server($this->{'ServerId'});
         $streamSrc = ZM_BASE_PROTOCOL . '://' . $Server->Hostname() . ZM_PATH_ZMS;
     } else {
         $streamSrc = ZM_BASE_URL . ZM_PATH_ZMS;
     }
     $args[] = "monitor=" . $this->{'Id'};
     if (ZM_OPT_USE_AUTH) {
         if (ZM_AUTH_RELAY == "hashed") {
             $args[] = "auth=" . generateAuthHash(ZM_AUTH_HASH_IPS);
         } elseif (ZM_AUTH_RELAY == "plain") {
             $args[] = "user="******"pass="******"none") {
             $args[] = "user="******"mode=single", $args) && !empty($GLOBALS['connkey'])) {
         $args[] = "connkey=" . $GLOBALS['connkey'];
     }
     if (ZM_RAND_STREAM) {
         $args[] = "rand=" . time();
     }
     if (count($args)) {
         $streamSrc .= "?" . join($querySep, $args);
     }
     return $streamSrc;
 }
 public function testListen_shouldDieIfAttemptsLimit()
 {
     $server = new Server($this->createMockStore([[], [], ['test']]));
     $server->setDelay(0.1);
     $server->setAttemptsLimit(2);
     $events = $server->listen(time());
     $this->assertEquals([], $events, 'Завершение работы при достижении attemptsLimit');
 }
예제 #8
0
 public static function factory($socket)
 {
     $context = new \ZMQContext();
     $socketDealer = $context->getSocket(\ZMQ::SOCKET_DEALER);
     $queueServer = new Server($socketDealer);
     $queueServer->setSocket($socket);
     return $queueServer;
 }
예제 #9
0
 public function showAction(Server $server, Player $me, Request $request)
 {
     if ($server->staleInfo()) {
         $server->forceUpdate();
     }
     if ($request->get('forced') && $me->canEdit($server)) {
         $server->forceUpdate();
     }
     return array("server" => $server);
 }
예제 #10
0
파일: Cache.php 프로젝트: heiglandreas/zf2
 /**
  * Cache a service map description (SMD) to a file
  *
  * Returns true on success, false on failure
  *
  * @param  string $filename
  * @param  \Zend\Json\Server\Server $server
  * @return boolean
  */
 public static function saveSmd($filename, Server $server)
 {
     if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) {
         return false;
     }
     if (0 === @file_put_contents($filename, $server->getServiceMap()->toJson())) {
         return false;
     }
     return true;
 }
예제 #11
0
 private function buildUrl($path)
 {
     $url = sprintf('smb://%s/%s', $this->server->getHost(), $this->name);
     if ($path) {
         $path = trim($path, '/');
         $url .= '/';
         $url .= implode('/', array_map('rawurlencode', explode('/', $path)));
     }
     return $url;
 }
예제 #12
0
파일: Ldif.php 프로젝트: smalot/ldap
 /**
  * @param string   $content
  * @param callable $callback
  *
  * @return bool
  */
 public function importContent($content, $callback = null)
 {
     $content = trim(str_replace("\r", '', $content));
     // Split full content into small blocs
     $blocs = explode("\n\n", $content);
     $this->repository = $this->server->getDefaultRepository();
     foreach ($blocs as $bloc) {
         $this->handleObject($bloc, $callback);
     }
     return true;
 }
예제 #13
0
 /**
  * Execute commands as console
  *
  * @param Server $server - pocketmine\Server instance
  * @param str[]|str $cmd - commands to execute
  * @param bool $show - show commands being executed
  */
 public static function console($server, $cmd, $show = false)
 {
     if (!is_array($cmd)) {
         $cmd = [$cmd];
     }
     foreach ($cmd as $c) {
         if ($show) {
             $server->getLogger()->info("CMD> {$cmd}");
         }
         $server->dispatchCommand(new ConsoleCommandSender(), $c);
     }
 }
예제 #14
0
 /**
  * Start server
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     $s = new Server('127.0.0.1', 0);
     try {
         $s->setProtocol(XPClass::forName($args[0])->newInstance());
         $s->init();
         Console::writeLinef('+ Service %s:%d', $s->socket->host, $s->socket->port);
         $s->service();
         Console::writeLine('+ Done');
     } catch (Throwable $e) {
         Console::writeLine('- ', $e->getMessage());
     }
 }
 function testUpdatePropertiesEventSuccess()
 {
     $tree = [new SimpleCollection('foo')];
     $server = new Server($tree);
     $server->on('propPatch', function ($path, PropPatch $propPatch) {
         $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function () {
             return ['{DAV:}foo' => 200, '{DAV:}foo2' => 201];
         });
     });
     $result = $server->updateProperties('foo', ['{DAV:}foo' => 'bar', '{DAV:}foo2' => 'bla']);
     $expected = ['{DAV:}foo' => 200, '{DAV:}foo2' => 201];
     $this->assertEquals($expected, $result);
 }
예제 #16
0
파일: Ticker.php 프로젝트: beentrill/aerys
 public function update(Server $server) : Promise
 {
     switch ($server->state()) {
         case Server::STARTED:
             $this->watcherId = \Amp\repeat([$this, "updateTime"], 1000);
             $this->updateTime();
             break;
         case Server::STOPPED:
             \Amp\cancel($this->watcherId);
             $this->watcherId = null;
             break;
     }
     return new Success();
 }
예제 #17
0
파일: server.php 프로젝트: qieangel2013/zys
function hproseserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(__DIR__) . "/application");
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $hprose_config = $config_obj->hprose->toArray();
    $server = new Server("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port']);
    $server->setErrorTypes(E_ALL);
    $server->setDebugEnabled();
    $server->addFunction('zys');
    $server->start();
}
예제 #18
0
 public function setPool()
 {
     $pool = new Pool();
     foreach ($this->getConfiguration() as $key => $value) {
         $array = new ArrayObject($value);
         $server = new Server();
         $server->setHost($array->offsetGet(self::SERVER_PROPERTY_HOST))->setPort($array->offsetGet(self::SERVER_PROPERTY_PORT))->setName($key);
         if ($array->offsetExists(self::SERVER_PROPERTY_AUTH)) {
             $server->setAuth($array->offsetGet(self::SERVER_PROPERTY_AUTH));
         }
         $pool->attach($server);
     }
     $this->pool = $pool;
 }
 /**
  * Register endpoints for DPS API
  *
  * @param Server $server
  */
 public function register_endpoints($server)
 {
     $server->register_endpoint('entitlements', 'Entitlements');
     $server->register_endpoint('SignInWithCredentials', 'SignInWithCredentials');
     $server->register_endpoint('RenewAuthToken', 'RenewAuthToken');
     $server->register_endpoint('verifyEntitlement', 'VerifyEntitlement');
     $server->register_endpoint('CreateAccount', 'CreateAccount');
     $server->register_endpoint('ForgotPassword', 'ForgotPassword');
     $server->register_endpoint('ExistingSubscription', 'ExistingSubscription');
     $server->register_endpoint('Banner', 'Banner');
 }
예제 #20
0
파일: Mail.php 프로젝트: retailcrm/legacy
 public function parse()
 {
     $server = new Server($this->mailSettings[2], $this->mailSettings[3], $this->mailSettings[4]);
     $server->setAuthentication($this->mailSettings[0], $this->mailSettings[1]);
     if (!empty($this->mailSettings[5])) {
         $server->setMailBox($this->mailSettings[5]);
     }
     $mailCriteria = $this->clean($this->mailBox, 'criteria');
     $mailHandler = $this->clean($this->mailBox, 'handler');
     $criteria = $this->rule->getCriteria($mailCriteria);
     $handler = $this->rule->getHandler($mailHandler);
     error_reporting(E_ERROR | E_PARSE);
     $messages = $server->search($criteria);
     return $handler->prepare($messages);
 }
예제 #21
0
 public function setClassLoader(\ClassLoader $loader = null)
 {
     if ($loader === null) {
         $loader = Server::getInstance()->getLoader();
     }
     $this->classLoader = $loader;
 }
function getDisabledFunctions()
{
    Server::InitDataBlock(array("INTERNAL", "GROUPS"));
    $currentMIV = @ini_get("max_input_vars");
    $currentMIVText = $currentMIV;
    if (empty($currentMIV)) {
        $currentMIV = 1000;
        $currentMIVText = "unknown (default=1000)";
    }
    $message = null;
    if (count(Server::$Operators) > 0 && ($miv = (count(Server::$Groups) + count(Server::$Operators)) * 75) > $currentMIV) {
        $message .= "<span class=\"lz_index_error_cat\">PHP Configuration:<br></span> <span class=\"lz_index_red\">PHP configuration \"max_input_vars\" (see php.ini) must be increased to " . $miv . " (or greater).<br><br>Your current configuration is " . $currentMIVText . ".</span><br><br>";
    }
    if (!function_exists("file_get_contents") && ini_get('allow_url_fopen')) {
        $message .= "<span class=\"lz_index_error_cat\">Disabled function: file_get_contents<br></span> <span class=\"lz_index_red\">LiveZilla requires the PHP function file_get_contents to be activated.</span><br><br>";
    }
    if (!function_exists("fsockopen")) {
        $message .= "<span class=\"lz_index_error_cat\">Disabled function: fsockopen<br></span> <span class=\"lz_index_orange\">LiveZilla requires the PHP function fsockopen to be activated in order to send and receive emails.</span><br><br>";
    }
    if (!function_exists("iconv_mime_decode")) {
        $message .= "<span class=\"lz_index_error_cat\">Missing PHP extension: ICONV<br></span> <span class=\"lz_index_orange\">LiveZilla requires the PHP extension iconv to parse incoming emails. Please add the iconv package to your PHP configuration.</span><br><br>";
    }
    if (!ini_get('allow_url_fopen')) {
        $message .= "<span class=\"lz_index_error_cat\">Disabled wrapper: allow_url_fopen<br></span> <span class=\"lz_index_orange\">LiveZilla requires allow_url_fopen to be activated in order to send PUSH Messages to APPs and to send/receive Social Media updates.</span><br><br>";
    }
    return $message;
}
예제 #23
0
 /**
  * Sends the actual response.
  *
  * @param string $pHttpCode
  * @param        $pMessage
  */
 public function sendResponse($pHttpCode = '200', $pMessage)
 {
     $suppressStatusCode = isset($_GET['_suppress_status_code']) ? $_GET['_suppress_status_code'] : false;
     if ($this->controller->getHttpStatusCodes() && !$suppressStatusCode && php_sapi_name() !== 'cli') {
         $status = self::$statusCodes[intval($pHttpCode)];
         header('HTTP/1.0 ' . ($status ? $pHttpCode . ' ' . $status : $pHttpCode), true, $pHttpCode);
     } elseif (php_sapi_name() !== 'cli') {
         header('HTTP/1.0 200 OK');
     }
     $pMessage = array_reverse($pMessage, true);
     $pMessage['status'] = intval($pHttpCode);
     $pMessage = array_reverse($pMessage, true);
     $method = $this->getOutputFormatMethod($this->getOutputFormat());
     echo $this->{$method}($pMessage);
     exit;
 }
예제 #24
0
 public function actionIndex()
 {
     // 推荐产品
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $products = Product::model()->localized()->findAll($criteria);
     // 推荐品牌
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $brands = Brand::model()->localized()->findAll($criteria);
     // 推荐服务
     $criteria = new CDbCriteria();
     $criteria->compare('t.is_recommend', 1);
     $criteria->compare('t.is_released', 1);
     $criteria->order = 't.sort_order ASC';
     $servers = Server::model()->localized()->findAll($criteria);
     $this->layout = 'main';
     $this->pageTitle = Yii::t('common', '首页') . SEPARATOR . Setting::getValueByCode('inside_title', true);
     $this->metaKeywords = Setting::getValueByCode('meta_keywords', true);
     $this->metaDescription = Setting::getValueByCode('meta_description', true);
     $this->render('index', array('products' => $products, 'brands' => $brands, 'servers' => $servers));
     //$this->renderPartial('index');
 }
 private function put()
 {
     //$postarray = json_decode(file_get_contents('php://input'), true);
     $req = \Server::getCurrentRequest();
     $postarray = json_decode($req->getRawData(), true);
     $faculty = new FacultyDB();
     $faculty->setId($postarray['id']);
     $faculty->setUsername($postarray['username']);
     $faculty->setFirstName($postarray['first_name']);
     $faculty->setLastName($postarray['last_name']);
     $faculty->setPhone($postarray['phone']);
     $faculty->setFax($postarray['fax']);
     $faculty->setStreetAddress1($postarray['street_address1']);
     $faculty->setStreetAddress2($postarray['street_address2']);
     $faculty->setCity($postarray['city']);
     $faculty->setState($postarray['state']);
     $faculty->setZip($postarray['zip']);
     // Save the faculty object
     try {
         DatabaseStorage::saveObject($faculty);
     } catch (\Exception $e) {
         header('HTTP/1.1 500 Internal Server Error');
         exit;
     }
     echo json_encode($faculty->extractVars());
     // Exit, since this is called by JSON
     exit;
 }
예제 #26
0
 /**
  * @param  array of string|callable
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):\\s*(.+)#', $job, $m)) {
             $out = $err = NULL;
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0 ? "exit code {$code}" : NULL;
             } elseif ($m[1] === 'remote') {
                 try {
                     $out = $this->server->execute($m[2]);
                 } catch (ServerException $e) {
                     $err = $e->getMessage() ?: 'unknown error';
                 }
             } else {
                 $out = Helpers::fetchUrl($job, $err);
             }
             $this->logger->log($job . ($out == NULL ? '' : ": {$out}"));
             // intentionally ==
             if ($err) {
                 throw new \RuntimeException('Job failed, ' . $err);
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Job failed');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }
예제 #27
0
 static function req($nombre)
 {
     if (Server::isPost() && self::post($nombre) != NULL) {
         return self::post($nombre);
     }
     return self::get($nombre);
 }
예제 #28
0
파일: myvm.php 프로젝트: cherry-wb/Qemu
 public function action_start()
 {
     Routing::getInstance()->appendRender($this, "action_default");
     $vm = new QemuVm($_GET['vmID']);
     $status = Server::hasRessources($vm->ram);
     if ($status == Server::RUN) {
         if ($vm->isOwner()) {
             if ($vm->status == QemuMonitor::RUNNING) {
                 return "<div class='notice'>Die VM scheint bereits aus zu laufen.</div>";
             } else {
                 try {
                     $vm->startVM();
                     $vm->connect();
                 } catch (Exception $e) {
                     $vm->setStatus(QemuMonitor::SHUTDOWN);
                     return "<div class='notice warning'>Die VM scheint nicht zu starten.</div>";
                 }
                 if (!isset($e)) {
                     return "<div class='notice success'>Die VM wurde gestartet.</div>";
                 }
             }
         }
     } elseif ($status == Server::USER_LIMIT) {
         return "<div class='notice error'>Sie können maximal " . $GLOBALS['config']['running_vms'] . " VMs gleichzeitig laufen lassen</div>";
     } else {
         return "<div class='notice error'>Es sind keine Ressourcen mehr verfügbar um die VM zu starten</div>";
     }
 }
 function activate()
 {
     $setup = Config::get('RPC');
     $class = URL::getPathPart($setup['class']);
     $method = URL::getPathPart($setup['method']);
     list($action, $type) = explode('.', URL::getPathPart($setup['action']), 2);
     $path = $setup["path"] . "/" . $class . "/" . ucwords($method) . ucwords($action) . "Controller";
     if (file_exists(Loader::getPath("controller", $path))) {
         Debugger::log("CONTROLLER: <span style=\"color: #990000\">" . ucwords($method) . ucwords($action) . "Controller</span>");
         $controller = Loader::loadNew("controller", $path);
         $controller->activate();
         if (is_callable(array($controller, $type))) {
             echo $controller->{$type}();
         }
         return;
     }
     $controller_class = ucwords($class) . ucwords($method) . ucwords($action) . "Controller";
     Debugger::log("CONTROLLER: <span style=\"color: #990000\">{$controller_class}</span>");
     if (file_exists(Loader::getPath("controller", "{$setup['path']}/{$controller_class}"))) {
         $controller = Loader::loadNew("controller", "{$setup['path']}/{$controller_class}");
         $controller->activate();
     } else {
         Loader::load("utility", "Server");
         $ip = Server::getIP();
         $self = Server::getSelf();
         Debugger::log("Possible RPC Injection: RPC call to non-existent controller at path {$setup["path"]}/{$controller_class} {$ip} {$self}");
         error_log("Possible RPC Injection: RPC call to non-existent controller at path {$setup['path']}/{$controller_class} {$ip} {$self}");
     }
 }
예제 #30
0
 /**
  * @return void
  */
 private function runJobs(array $jobs)
 {
     foreach ($jobs as $job) {
         if (is_string($job) && preg_match('#^(https?|local|remote):(.+)#', $job, $m)) {
             if ($m[1] === 'local') {
                 $out = @system($m[2], $code);
                 $err = $code !== 0;
             } elseif ($m[1] === 'remote') {
                 $out = $this->server->execute($m[2]);
                 $err = FALSE;
             } else {
                 $err = ($out = @file_get_contents($job)) === FALSE;
             }
             $this->logger->log("{$job}: {$out}");
             if ($err) {
                 throw new \RuntimeException("Error in job {$job}");
             }
         } elseif (is_callable($job)) {
             if ($job($this->server, $this->logger, $this) === FALSE) {
                 throw new \RuntimeException('Error in job');
             }
         } else {
             throw new \InvalidArgumentException("Invalid job {$job}.");
         }
     }
 }