_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q5900
Webservice.getNextResult
train
public static function getNextResult(&$response) { //====================================================================// // Extract Next Task From Buffer $task = self::getNextTask($response); //====================================================================// // Analyze SOAP Results if (!$task || !isset($task->data)) { return false; } //====================================================================// // Return Task Data return $task->data; }
php
{ "resource": "" }
q5901
Webservice.getNextTask
train
public static function getNextTask(&$response) { //====================================================================// // Analyze SOAP Results if (!$response || !isset($response->result) || (true != $response->result)) { return false; } //====================================================================// // Check if Tasks Buffer is Empty if (!Splash::count($response->tasks)) { return false; } //====================================================================// // Detect ArrayObjects if ($response->tasks instanceof ArrayObject) { $response->tasks = $response->tasks->getArrayCopy(); } //====================================================================// // Shift Task Array return array_shift($response->tasks); }
php
{ "resource": "" }
q5902
Webservice.getServerInfos
train
public function getServerInfos() { //====================================================================// // Init Result Array $response = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); //====================================================================// // Server Infos $response->ServerType = 'PHP'; // INFO - Server Language Type $response->ServerVersion = PHP_VERSION; // INFO - Server Language Version $response->ProtocolVersion = SPL_PROTOCOL; // INFO - Server Protocal Version //====================================================================// // Server Infos $response->Self = Splash::input('PHP_SELF'); // INFO - Current Url $response->ServerAddress = Splash::input('SERVER_ADDR'); // INFO - Server IP Address // Read System Folder without symlinks $response->ServerRoot = realpath((string) Splash::input('DOCUMENT_ROOT')); $response->UserAgent = Splash::input('HTTP_USER_AGENT'); // INFO - Browser User Agent $response->WsMethod = Splash::configuration()->WsMethod; // Current Splash WebService Component //====================================================================// // Server Urls //====================================================================// // CRITICAL - Server Host Name $response->ServerHost = $this->getServerName(); //====================================================================// // Server IPv4 Address $response->ServerIP = Splash::input('SERVER_ADDR'); //====================================================================// // Server WebService Path if (isset(Splash::configuration()->ServerPath)) { $response->ServerPath = Splash::configuration()->ServerPath; } else { $fullPath = dirname(__DIR__); $relPath = explode((string) $response->ServerRoot, $fullPath); if (is_array($relPath) && isset($relPath[1])) { $response->ServerPath = $relPath[1].'/soap.php'; } else { $response->ServerPath = null; } } $response->setFlags(ArrayObject::STD_PROP_LIST); return $response; }
php
{ "resource": "" }
q5903
Webservice.getServerName
train
public function getServerName() { //====================================================================// // Check if Server Name is Overiden by Application Module if (isset(Splash::configuration()->ServerHost)) { return Splash::configuration()->ServerHost; } //====================================================================// // Check if Available with Secured Reading if (!empty(Splash::input('SERVER_NAME'))) { return Splash::input('SERVER_NAME'); } //====================================================================// // Fallback to Unsecured Mode (Required for Phpunit) if (isset($_SERVER['SERVER_NAME'])) { return $_SERVER['SERVER_NAME']; } return ''; }
php
{ "resource": "" }
q5904
Webservice.verify
train
private function verify() { //====================================================================// // Verify host address is present if (empty($this->host)) { return Splash::log()->err('ErrWsNoHost'); } //====================================================================// // Verify Server Id not empty if (empty($this->id)) { return Splash::log()->err('ErrWsNoId'); } //====================================================================// // Verify Server Id not empty if (empty($this->key)) { return Splash::log()->err('ErrWsNoKey'); } //====================================================================// // Verify Http Auth Configuration if ($this->httpAuth) { if (empty($this->httpUser)) { return Splash::log()->err('ErrWsNoHttpUser'); } if (empty($this->httpPassword)) { return Splash::log()->err('ErrWsNoHttpPwd'); } } return true; }
php
{ "resource": "" }
q5905
Webservice.cleanIn
train
private function cleanIn() { //====================================================================// // Free current output buffer $this->inputs = null; //====================================================================// // Initiate a new input buffer $this->inputs = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); return true; }
php
{ "resource": "" }
q5906
Webservice.cleanOut
train
private function cleanOut() { //====================================================================// // Free current tasks list $this->tasks = null; //====================================================================// // Initiate a new tasks list $this->tasks = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); //====================================================================// // Free current output buffer $this->outputs = null; //====================================================================// // Initiate a new output buffer $this->outputs = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); return true; }
php
{ "resource": "" }
q5907
Webservice.init
train
private function init($service) { //====================================================================// // Debug Splash::log()->deb('MsgWsCall'); //====================================================================// // Safety Check if (!$this->verify()) { return Splash::log()->err('ErrWsInValid'); } //====================================================================// // Clean Data Input Buffer $this->cleanIn(); //====================================================================// // Prepare Data Output Buffer //====================================================================// // Fill buffer with Server Core infos $this->outputs->server = $this->getServerInfos(); // Remote Service to call $this->outputs->service = $service; // Share Debug Flag with Server $this->outputs->debug = (int) SPLASH_DEBUG; return true; }
php
{ "resource": "" }
q5908
Webservice.addTasks
train
private function addTasks($tasks = null) { //====================================================================// // No tasks to Add if (is_null($tasks) && empty($this->tasks)) { return true; } //====================================================================// // Prepare Tasks To Perform //====================================================================// //====================================================================// // Add Internal Tasks to buffer if (!empty($this->tasks)) { $this->outputs->tasks = $this->tasks; $this->outputs->taskscount = count($this->outputs->tasks); Splash::log()->deb('[WS] Call Loaded '.$this->outputs->tasks->count().' Internal tasks'); } else { $this->outputs->tasks = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); } //====================================================================// // Add External Tasks to the request if (!empty($tasks)) { $this->outputs->tasks->append($tasks); $this->outputs->taskscount = count($tasks); Splash::log()->deb('[WS] Call Loaded '.count($tasks).' External tasks'); } return true; }
php
{ "resource": "" }
q5909
Webservice.buildClient
train
private function buildClient() { //====================================================================// // Compute target client url if ((false === strpos($this->host, 'http://')) && (false === strpos($this->host, 'https://'))) { $this->url = 'https://'.$this->host; } else { $this->url = $this->host; } //====================================================================// // Build Webservice Client Splash::com()->buildClient($this->url, $this->httpUser, $this->httpPassword); return true; }
php
{ "resource": "" }
q5910
Webservice.decodeResponse
train
private function decodeResponse($isUncrypted) { //====================================================================// // Unpack NuSOAP Answer //====================================================================// if (!empty($this->rawIn)) { //====================================================================// // Unpack Data from Raw packet $this->inputs = $this->unPack($this->rawIn, $isUncrypted); //====================================================================// // Merge Logging Messages from remote with current class messages if (isset($this->inputs->log)) { Splash::log()->merge($this->inputs->log); } } else { //====================================================================// // Add Information to Debug Log Splash::log()->deb("[WS] Id='".print_r($this->id, true)."'"); //====================================================================// // Error Message return Splash::log()->err('ErrWsNoResponse', $this->outputs->service, $this->url); } return true; }
php
{ "resource": "" }
q5911
Webservice.getClientUrl
train
private function getClientUrl() { //====================================================================// // Fetch Server Informations $serverInfos = $this->getServerInfos(); //====================================================================// // Build Server Url $host = $serverInfos['ServerHost']; if ((false !== strpos($host, 'http://')) || (false !== strpos($host, 'https://'))) { return $host.$serverInfos['ServerPath']; } return $this->getServerScheme().'://'.$host.$serverInfos['ServerPath']; }
php
{ "resource": "" }
q5912
Webservice.getClientDebugLink
train
private function getClientDebugLink() { //====================================================================// // Compute target client debug url $url = $this->getClientUrl(); $params = '?node='.$this->id; return '<a href="'.$url.$params.'" target="_blank" >'.$url.'</a>'; }
php
{ "resource": "" }
q5913
OpensearchFactory.getClient
train
protected function getClient(array $config) { $client = new CloudsearchClient( $config['client_id'], $config['client_secret'], $config['host'], 'aliyun' ); $search = new CloudsearchSearch($client); $search->addIndex($config['app']); return $search; }
php
{ "resource": "" }
q5914
GenericFieldsTrait.setGenericObject
train
protected function setGenericObject($fieldName, $fieldData, $objectName = "object", $nullable = true) { //====================================================================// // Load New Object Id $newId = null; if ($fieldData && method_exists($fieldData, "getId") && $fieldData->getId()) { $newId = $fieldData->getId(); } //====================================================================// // Read Current Object Id $currentId = $this->getObjectId($fieldName, $objectName); //====================================================================// // No Changes if ($newId == $currentId) { return $this; } //====================================================================// // Check Pointed Object Exists & Has an Id if (null == $newId) { if ($nullable) { //====================================================================// // Set Pointed Object to Null $this->{$objectName}->{ "set".$fieldName}(null); $this->needUpdate(); } return $this; } //====================================================================// // Update Pointed Object to New Value $this->{$objectName}->{ "set".$fieldName}($fieldData); $this->needUpdate(); return $this; }
php
{ "resource": "" }
q5915
GenericFieldsTrait.getGeneric
train
protected function getGeneric($fieldName, $objectName = "object") { $this->out[$fieldName] = $this->{$objectName}->{ "get".$fieldName}(); return $this; }
php
{ "resource": "" }
q5916
GenericFieldsTrait.getGenericBool
train
protected function getGenericBool($fieldName, $objectName = "object") { $this->out[$fieldName] = $this->{$objectName}->{ "is".$fieldName}(); return $this; }
php
{ "resource": "" }
q5917
GenericFieldsTrait.getGenericDate
train
protected function getGenericDate($fieldName, $objectName = "object") { $date = $this->{$objectName}->{ "get".$fieldName}(); $this->out[$fieldName] = $date ? $date->format(SPL_T_DATECAST) : ""; return $this; }
php
{ "resource": "" }
q5918
GenericFieldsTrait.setGenericDate
train
protected function setGenericDate($fieldName, $fieldData, $objectName = "object") { //====================================================================// // Compare Field Data $current = $this->{$objectName}->{ "get".$fieldName}(); if (($current instanceof DateTime) && ($current->format(SPL_T_DATECAST) == $fieldData)) { return $this; } //====================================================================// // Update Field Data $this->{$objectName}->{ "set".$fieldName}($fieldData ? new DateTime($fieldData) : null); $this->needUpdate($objectName); return $this; }
php
{ "resource": "" }
q5919
GenericFieldsTrait.getGenericDateTime
train
protected function getGenericDateTime($fieldName, $objectName = "object") { $date = $this->{$objectName}->{ "get".$fieldName}(); $this->out[$fieldName] = $date ? $date->format(SPL_T_DATETIMECAST) : ""; return $this; }
php
{ "resource": "" }
q5920
GenericFieldsTrait.setGenericDateTime
train
protected function setGenericDateTime($fieldName, $fieldData, $objectName = "object") { //====================================================================// // Compare Field Data $current = $this->{$objectName}->{ "get".$fieldName}(); if (($current instanceof DateTime) && ($current->format(SPL_T_DATETIMECAST) == $fieldData)) { return $this; } //====================================================================// // Update Field Data $this->{$objectName}->{ "set".$fieldName}($fieldData ? new DateTime($fieldData) : null); $this->needUpdate($objectName); return $this; }
php
{ "resource": "" }
q5921
ClassBasedTypeHandler.resolveType
train
protected function resolveType(string $class): string { $name = str_replace(['\\', '_'], $this->delimiter, ucwords($class, '\\_')); if ($this->fullName) { return $name; } $pos = strrpos($name, $this->delimiter); if ($pos === false) { return $name; } return substr($name, $pos + 1); }
php
{ "resource": "" }
q5922
Server.printServerFinger
train
private function printServerFinger() { $version = $this->version; $software = SERVER_MODE === 'swoole' ? 'Swoole Server' : 'PHP Development Server'; $document_root = APP_PATH . '/public'; echo <<<EOT -----------------------------------\033[32m ____ __ __ ____ /\ _`\ /\ \/\ \/\ _`\ __\ \ \ \ \ \ \_\ \ \ \ \ \ /'__`\ \ ,__/\ \ _ \ \ ,__/ /\ __/\ \ \ \ \ \ \ \ \ \ \ \____ \\ \_\ \ \_\ \_\ \_\ \/____/ \/_/ \/_/\/_/\/_/ \033[43;37mv{$version}\033[0m \033[0m >>> \033[35m{$software}\033[0m started ... Listening on \033[36;4mhttp://{$this->config['host']}:{$this->config['port']}/\033[0m Document root is \033[34m{$document_root}\033[0m Press Ctrl-C to quit. ----------------------------------- EOT; echo "\033[32m>>> Http Server is enabled\033[0m \n"; if ( !empty($this->config['enable_websocket']) ) { echo "\033[32m>>> WebSocket Server is enabled\033[0m \n"; } echo "-----------------------------------\n"; }
php
{ "resource": "" }
q5923
Server.devServer
train
public function devServer(string $host, int $port) { // Mark server mode define('SERVER_MODE', 'buildin'); $this->config['host'] = $host; $this->config['port'] = $port; $this->printServerFinger(); // Start cli Development Server $bind_http = $host . ':' . $port; passthru("php -S {$bind_http} -t " . APP_PATH . "/public"); }
php
{ "resource": "" }
q5924
Server.createServer
train
public function createServer(array $config) { // Mark server mode define('SERVER_MODE', 'swoole'); $this->config = $config + [ 'host' => '0.0.0.0', 'port' => '8000', 'task_worker_num' => 0, 'enable_websocket'=> false ]; // Start websocket or http server if ( empty($config['enable_websocket']) ) { $this->server = new \Swoole\Http\Server($this->config['host'], $this->config['port']); } else { $this->config['open_http_protocol'] = true; $this->server = new \Swoole\WebSocket\Server($config['host'], $config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP); } $this->server->set($this->config); // Show welcome finger $this->printServerFinger(); return $this; }
php
{ "resource": "" }
q5925
Server.add_event_listener
train
public function add_event_listener(string $event) { // Automatically instantiate this class if ( class_exists("\App\Boot") ) { // Excute a boot instance $boot = new \App\Boot(); if ( method_exists($boot, $event) ) { call_user_func([$boot, $event], $this->server); } // Listen Background task listener if ($event == 'onBoot') { $this->server->on('task', [$boot, 'onTask']); $this->server->on('finish', [$boot, 'onFinish']); } } }
php
{ "resource": "" }
q5926
Server.start
train
public function start() { // Linsten http Event $this->server->on('request', [$this, 'onRequest']); $this->server->on('start', [$this, 'onStart']); $this->server->on('shutdown', [$this, 'onShutdown']); $this->server->on('workerStart', [$this, 'onWorkerStart']); $this->server->on('workerStop', [$this, 'onWorkerStop']); $this->server->on('workerError', [$this, 'onWorkerError']); // listen websocket if ( !empty($this->config['enable_websocket']) ) { $this->server->on('open', [$this, 'onOpen']); $this->server->on('message', [$this, 'onMessage']); $this->server->on('close', [$this, 'onClose']); } // Add event Listener $this->add_event_listener('onBoot'); // Start a new http server $this->server->start(); }
php
{ "resource": "" }
q5927
Server.onRequest
train
public function onRequest(Request $request, Response $response) { // Compat fpm server $this->_compatFPM($request); // 注入全局变量 $GLOBALS['__$response'] = $response; $response->header('Server', 'ePHP/'. $this->version); $filename = APP_PATH . '/public'. $_SERVER['PATH_INFO']; // !in_array($extname, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif', 'ico']) // Try files, otherwise route to app if ( !is_file($filename) ) { ob_start(); (new \ePHP\Core\Application())->run(); $h = ob_get_clean(); // Fixed output o byte // if (strlen($h) === 0) { // $h = ' '; // } $response->end($h); } else { $extname = substr($filename, strrpos($filename, '.') + 1); if ( isset( $this->contentType[$extname] ) ) { $response->header('Content-Type', $this->contentType[$extname]); } $response->sendfile($filename); } // 非调试模式,打印访问日志 $this->printAccessLog(); }
php
{ "resource": "" }
q5928
Server.onWorkerStart
train
public function onWorkerStart(\Swoole\Server $server, int $worker_id) { // STDOUT_LOG模式,不打印 worker stop 输出 if ( getenv('STDOUT_LOG') ) { echo date('Y-m-d H:i:s') . " |\033[31m ...... http worker process start[id={$worker_id} pid={$server->worker_pid}] ......\033[0m \n"; } // Add event Listener $this->add_event_listener('onWorkerStart'); }
php
{ "resource": "" }
q5929
Server.onWorkerError
train
public function onWorkerError(\Swoole\Server $server, int $worker_id, int $worker_pid, int $exit_code) { echo date('Y-m-d H:i:s') . " |\033[31m http worker process error[id={$worker_id} pid={$worker_pid}] ......\033[0m \n"; // Add event Listener $this->add_event_listener('onWorkerError'); }
php
{ "resource": "" }
q5930
Server.onOpen
train
public function onOpen(\Swoole\WebSocket\Server $server, \Swoole\Http\Request $request) { // echo "[websocket][onopen]server: handshake success with fd{$request->fd} url={$request->server['request_uri']}?{$request->server['query_string']}\n"; // Compat fpm server $this->_compatFPM($request); // print_r(self::$websocketFrameContext); // filter websocket router class // route struct: [$controller_name, $controller_class] $controller_class = (\ePHP\Core\Route::init())->findWebSocketRoute(); if ( !empty($controller_class) ) { // Save websocket connection Context self::$websocketFrameContext[$request->fd] = [ 'get' => $_GET, 'cookie' => $_COOKIE, 'controller_class' => $controller_class ]; // echo 'pid='. getmypid() . ', fd=' . implode(',', array_keys(self::$websocketFrameContext)) // . ', connections=' . count($this->server->connections) . "\n"; call_user_func([new $controller_class(), 'onOpen'], $server, $request); } }
php
{ "resource": "" }
q5931
Server.onMessage
train
public function onMessage(\Swoole\WebSocket\Server $server, \Swoole\WebSocket\Frame $frame) { // echo "[websocket][onmessage]receive from {$frame->fd}:{$frame->data},opcode:{$frame->opcode},fin:{$frame->finish}\n"; // $server->push($frame->fd, "this is server"); // print_r(self::$websocketFrameContext); if ( empty(self::$websocketFrameContext[$frame->fd]) ) { if ( getenv('STDOUT_LOG') ) { echo date('Y-m-d H:i:s') . " |\033[31m [ERROR][onMessage] WebSocket has been stoped before frame sending data\033[0m \n"; } return; } // Save websocket connection Context $context = self::$websocketFrameContext[$frame->fd]; // Restore global data $_POST = $_SERVER = []; $_GET = $_REQUEST = $context['get']; $_COOKIE = $context['cookie']; $controller_class = $context['controller_class']; call_user_func([new $controller_class(), 'onMessage'], $server, $frame); }
php
{ "resource": "" }
q5932
Server.onClose
train
public function onClose(\Swoole\WebSocket\Server $server, int $fd) { // echo "[websocket][onclose]client fd{$fd} closed\n"; if ( empty(self::$websocketFrameContext[$fd]) ) { if ( getenv('STDOUT_LOG') ) { echo date('Y-m-d H:i:s') . " |\033[31m [ERROR][onClose] fd{$fd} WebSocket has been stoped...\033[0m \n"; } return; } // Save websocket connection Context $context = self::$websocketFrameContext[$fd]; // Restore global data $_POST = $_SERVER = []; $_GET = $_REQUEST = $context['get']; $_COOKIE = $context['cookie']; $controller_class = $context['controller_class']; // Clear websocket cache unset(self::$websocketFrameContext[$fd]); call_user_func([new $controller_class(), 'onClose'], $server, $fd); }
php
{ "resource": "" }
q5933
BaseElement.prepareItems
train
public function prepareItems($items) { if (!is_array($items)) { return $items; } elseif (self::isAssoc($items)) { $items = $this->prepareItem($items); } else { foreach ($items as $key => $item) { $items[ $key ] = $this->prepareItem($item); } } return $items; }
php
{ "resource": "" }
q5934
BaseElement.prepareItem
train
protected function prepareItem($item) { if (!isset($item["type"])) { return $item; } if (isset($item["children"])) { $item["children"] = $this->prepareItems($item["children"]); } switch ($item['type']) { case 'select': if (isset($item['sql'])) { $connectionName = isset($item['connection']) ? $item['connection'] : 'default'; $sql = $item['sql']; $options = isset($item["options"]) ? $item["options"] : array(); unset($item['sql']); unset($item['connection']); /** @var Connection $connection */ $connection = $this->container->get("doctrine.dbal.{$connectionName}_connection"); $all = $connection->fetchAll($sql); foreach ($all as $option) { $options[] = array(reset($option), end($option)); } $item["options"] = $options; } if (isset($item['service'])) { $serviceInfo = $item['service']; $serviceName = isset($serviceInfo['serviceName']) ? $serviceInfo['serviceName'] : 'default'; $method = isset($serviceInfo['method']) ? $serviceInfo['method'] : 'get'; $args = isset($serviceInfo['args']) ? $item['args'] : ''; $service = $this->container->get($serviceName); $options = $service->$method($args); $item['options'] = $options; } if (isset($item['dataStore'])) { $dataStoreInfo = $item['dataStore']; $dataStore = $this->container->get('data.source')->get($dataStoreInfo["id"]); $options = array(); foreach ($dataStore->search() as $dataItem) { $options[ $dataItem->getId() ] = $dataItem->getAttribute($dataStoreInfo["text"]); } if (isset($item['dataStore']['popupItems'])) { $item['dataStore']['popupItems'] = $this->prepareItems($item['dataStore']['popupItems']); } $item['options'] = $options; } break; } return $item; }
php
{ "resource": "" }
q5935
BaseElement.decodeRequest
train
public function decodeRequest(array $request) { foreach ($request as $key => $value) { if (is_array($value)) { $request[ $key ] = $this->decodeRequest($value); } elseif (strpos($key, '[')) { preg_match('/(.+?)\[(.+?)\]/', $key, $matches); list($match, $name, $subKey) = $matches; if (!isset($request[ $name ])) { $request[ $name ] = array(); } $request[ $name ][ $subKey ] = $value; unset($request[ $key ]); } } return $request; }
php
{ "resource": "" }
q5936
BaseElement.getType
train
public static function getType() { $clsInfo = explode('\\', get_called_class()); $namespaceParts = array_slice($clsInfo, 0, -1); // convention: AdminType classes are placed into the "<bundle>\Element\Type" namespace $namespaceParts[] = "Type"; $bareClassName = implode('', array_slice($clsInfo, -1)); // convention: AdminType class name is the same as the element class name suffixed with AdminType return implode('\\', $namespaceParts) . '\\' . $bareClassName . 'AdminType'; }
php
{ "resource": "" }
q5937
BaseElement.autoTemplate
train
private static function autoTemplate($section, $suffix = '.html.twig') { $cls = get_called_class(); $bundleName = str_replace('\\', '', preg_replace('/^([\w]+\\\\)*?(\w+\\\\\w+Bundle).*$/', '\2', $cls)); $elementName = implode('', array_slice(explode('\\', $cls), -1)); $elementSnakeCase = strtolower(preg_replace('/([^A-Z])([A-Z])/', '\\1_\\2', $elementName)); return "{$bundleName}:{$section}:{$elementSnakeCase}{$suffix}"; }
php
{ "resource": "" }
q5938
IdentifierCollectionContainer.identifiersToArray
train
protected function identifiersToArray(): array { $data = []; foreach ($this->getIdentifiers() as $identifier) { $data[] = $identifier->toArray(); } return $data; }
php
{ "resource": "" }
q5939
QueryFactory.instantiateQuery
train
protected function instantiateQuery($queryClass, $apiQueryName) { if (!is_a($queryClass, static::$queryInterface, true)) { throw new RuntimeException("Query class '{$queryClass}' does not implements '" . static::$queryInterface . "' interface."); } return new $queryClass($apiQueryName); }
php
{ "resource": "" }
q5940
Request.withUri
train
public function withUri(UriInterface $uri, $preserveHost = false) { $clone = clone $this; $clone->uri = $uri; if ($preserveHost) { /** * Si l'en-tête Host est manquant ou vide, et que le nouvel URI contient * un composant hôte, cette méthode DOIT mettre à jour l'en-tête Host dans le retour. */ $headerHost = $this->getHeader('Host'); if (empty($headerHost) && $uri->getHost() !== '') { return $clone->withHeader('Host', $uri->getHost()); } } return $clone; }
php
{ "resource": "" }
q5941
Validate.ip
train
private function ip($ip) { return ((false === ip2long($ip)) || (long2ip(ip2long($ip)) !== $ip)) ? false : true; }
php
{ "resource": "" }
q5942
IncludedResourcesContainer.includedResourcesToArray
train
protected function includedResourcesToArray(): array { $data = []; foreach ($this->includedResources as $resource) { $data[] = $resource->toArray(); } return $data; }
php
{ "resource": "" }
q5943
Stream.getContents
train
public function getContents() { $this->valideAttach()->valideRead(); if (($stream = stream_get_contents($this->stream)) === false) { throw new \RuntimeException('An error occurred while reading the stream.'); } return $stream; }
php
{ "resource": "" }
q5944
Attachment.toArray
train
public function toArray() { return [ 'id' => $this->id, 'filename' => $this->filename, 'filetype' => $this->filetype, 'filesize' => $this->filesize, 'tags' => $this->tags, 'preview_url' => $this->previewUrl(), 'url' => $this->downloadUrl() ]; }
php
{ "resource": "" }
q5945
Files.detectFilePath
train
private static function detectFilePath($params) { if (isset($params->path) && !empty($params->path)) { return $params->path; } if (isset($params->file) && !empty($params->file)) { return $params->path; } return false; }
php
{ "resource": "" }
q5946
ImagesTrait.images
train
public static function images() { // Helper Class Exists if (isset(self::$ImagesHelper)) { return self::$ImagesHelper; } // Initialize Class self::$ImagesHelper = new ImagesHelper(); // Return Helper Class return self::$ImagesHelper; }
php
{ "resource": "" }
q5947
NativeTypesHandler.process
train
protected function process($value, string $type) { if ($type === 'integer') { return (int) $value; } if ($type === 'float') { return (float) $value; } if ($type === 'boolean') { return (bool) $value; } return (string) $value; }
php
{ "resource": "" }
q5948
Splash.commit
train
public static function commit($objectType, $local = null, $action = null, $user = '', $comment = '') { //====================================================================// // Stack Trace self::log()->trace(); //====================================================================// // Verify this Object Class is Valid ==> No Action on this Node if (false == Splash::object($objectType)) { return true; } //====================================================================// // Initiate Tasks parameters array $params = self::getCommitParameters($objectType, $local, $action, $user, $comment); //====================================================================// // Add This Commit to Session Logs static::$commited[] = $params; //====================================================================// // Verify this Object is Locked ==> No Action on this Node if (!self::isCommitAllowed($objectType, $local, $action)) { return true; } //====================================================================// // Add Task to Ws Task List Splash::ws()->addTask( SPL_F_COMMIT, $params, Splash::trans('MsgSchRemoteCommit', (string) $action, $objectType, (string) Splash::count($local)) ); //====================================================================// // Execute Task $response = self::ws()->call(SPL_S_OBJECTS); //====================================================================// // Analyze NuSOAP results return self::isCommitSuccess($response); }
php
{ "resource": "" }
q5949
Splash.getCommitParameters
train
private static function getCommitParameters($objectType, $local = null, $action = null, $user = '', $comment = '') { $params = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $params->type = $objectType; // Type of the Object $params->id = $local; // Id of Modified object $params->action = $action; // Action Type On this Object $params->user = $user; // Operation User Name for Historics $params->comment = $comment; // Operation Comment for Historics return $params; }
php
{ "resource": "" }
q5950
Splash.isCommitAllowed
train
private static function isCommitAllowed($objectType, $local = null, $action = null) { //====================================================================// // Verify this Object is Locked ==> No Action on this Node //====================================================================// if (is_array($local)) { foreach ($local as $value) { if (Splash::object($objectType)->isLocked($value)) { return false; } } } else { if (Splash::object($objectType)->isLocked($local)) { return false; } } //====================================================================// // Verify Create Object is Locked ==> No Action on this Node if ((SPL_A_CREATE === $action) && Splash::object($objectType)->isLocked()) { return false; } //====================================================================// // Verify if Travis Mode (PhpUnit) ==> No Commit Allowed return !self::isTravisMode($objectType, $local, $action); }
php
{ "resource": "" }
q5951
Splash.isTravisMode
train
private static function isTravisMode($objectType, $local, $action = null) { //====================================================================// // Detect Travis from SERVER CONSTANTS if (empty(Splash::input('SPLASH_TRAVIS'))) { return false; } $objectIds = is_array($local) ? implode('|', $local) : $local; self::log()->war('Module Commit Skipped ('.$objectType.', '.$action.', '.$objectIds.')'); return true; }
php
{ "resource": "" }
q5952
Definition.merge
train
public function merge(self $definition) { if ($this->type === null && $definition->hasType()) { $this->type = $definition->getType(); } $this->mergeLinks($definition); $this->mergeAttributes($definition); $this->mergeRelationships($definition); }
php
{ "resource": "" }
q5953
ObjectsHelper.encode
train
public static function encode($objectType, $objectId) { //====================================================================// // Safety Checks if (empty($objectType)) { return false; } if (empty($objectId)) { return false; } //====================================================================// // Create & Return Field Id Data String return $objectId.IDSPLIT.$objectType; }
php
{ "resource": "" }
q5954
ObjectsHelper.load
train
public static function load($fieldData, $objectClass = null) { //====================================================================// // Decode Object Type & Id $objectType = self::objectType($fieldData); $objectId = self::objectId($fieldData); if (!$objectType || !$objectId) { return null; } //====================================================================// // Load Splash Object $splashObject = Splash::object($objectType); if (empty($splashObject)) { return null; } //====================================================================// // Ensure Splash Object uses InteliParserTrait if (!in_array(IntelParserTrait::class, class_uses($splashObject), true)) { return null; } if (!method_exists($splashObject, 'load')) { return null; } //====================================================================// // Load Remote Object $remoteObject = $splashObject->load($objectId); if (!$remoteObject) { return null; } //====================================================================// // Verify Remote Object if (!empty($objectClass) && !($remoteObject instanceof $objectClass)) { return null; } //====================================================================// // Return Remote Object return $remoteObject; }
php
{ "resource": "" }
q5955
File.getMime
train
protected function getMime(UploadedFileInterface $upload) { $file = $upload->getStream()->getMetadata('uri'); return (new \finfo(FILEINFO_MIME_TYPE))->file($file); }
php
{ "resource": "" }
q5956
File.getExtension
train
protected function getExtension(UploadedFileInterface $upload) { $filename = $filename = $upload->getClientFilename(); return strtolower(pathinfo($filename, PATHINFO_EXTENSION)); }
php
{ "resource": "" }
q5957
Encrypt.edcode
train
public static function edcode($string, $operation, $key = 'ePHP') { // ENCODE $key_length = strlen($key); $string = $operation == 'DECODE' ? \ePHP\Misc\Func::safe_b64decode($string) : substr(md5($string . $key), 0, 8) . $string; $string_length = strlen($string); $rndkey = $box = array(); $result = ''; for ($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($key[$i % $key_length]); $box[$i] = $i; } for ($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for ($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); } // DECODE if ($operation == 'DECODE') { if (substr($result, 0, 8) == substr(md5(substr($result, 8) . $key), 0, 8)) { return substr($result, 8); } else { return ''; } } else { return \ePHP\Misc\Func::safe_b64encode($result); } }
php
{ "resource": "" }
q5958
Controller.setHeader
train
protected function setHeader($key, $value) { if (SERVER_MODE === 'swoole') { $GLOBALS['__$response']->header($key, $value); } else { if (!headers_sent()) { header($key . ': '. $value); } } }
php
{ "resource": "" }
q5959
Controller.redirect
train
protected function redirect($url, $code = 302) { if (!headers_sent()) { if (SERVER_MODE === 'swoole' ) { $GLOBALS['__$response']->status($code); } else if ($code == 301) { header('HTTP/1.1 301 Moved Permanently'); } else { header('HTTP/1.1 302 Found'); } $this->setHeader("Location", $url); $this->stopRun(); } else { echo '<html><head><meta charset="UTF-8" /><title></title></head><body>'; echo '<script>window.location.href="'. $url .'";</script></body></html>'; $this->stopRun(); } }
php
{ "resource": "" }
q5960
DBPool.init
train
public static function init($name) { if (empty(self::$instance[$name]) || !self::$instance[$name] instanceof self) { self::$instance[$name] = new self(); self::$instance[$name]->queue = new \SplQueue(); } return self::$instance[$name]; }
php
{ "resource": "" }
q5961
ODataResource.orderBy
train
public function orderBy($orderBy = NULL) { if (isset($orderBy)) { $this->setOrderBy($orderBy); return $this; } return $this->getOrderBy(); }
php
{ "resource": "" }
q5962
Image.getDimensions
train
protected function getDimensions(UploadedFileInterface $upload) { $dimension = getimagesize($upload->getStream()->getMetadata('uri')); return [ 'width' => $dimension[ 0 ], 'height' => $dimension[ 1 ] ]; }
php
{ "resource": "" }
q5963
Image.validMimeImage
train
private function validMimeImage($extension, $mimes) { if (is_array($mimes)) { foreach ($mimes as $mime) { if (!strstr($mime, 'image/')) { throw new \InvalidArgumentException(htmlspecialchars( "The extension $extension is not an image extension." )); } } } else { if (!strstr($mimes, 'image/')) { throw new \InvalidArgumentException(htmlspecialchars( "The extension $extension is not an image extension." )); } } }
php
{ "resource": "" }
q5964
FileExporterTrait.addLogToFile
train
protected static function addLogToFile($message, $logType = 'Unknown') { //====================================================================// // Safety Check if (0 == Splash::configuration()->Logging) { return true; } //====================================================================// // Detect Log File Directory $logfile = dirname(__DIR__).'/splash.log'; if (defined('SPLASH_DIR') && realpath(SPLASH_DIR)) { $logfile = realpath(SPLASH_DIR).'/splash.log'; } //====================================================================// // Open Log File $filefd = @fopen($logfile, 'a+'); //====================================================================// // Write Log File if ($filefd) { $message = date('Y-m-d H:i:s').' '.sprintf('%-15s', $logType).$message; fwrite($filefd, $message."\n"); fclose($filefd); @chmod($logfile, 0604); } return true; }
php
{ "resource": "" }
q5965
FileExporterTrait.addLogBlockToFile
train
protected static function addLogBlockToFile($msgArray, $logType = 'Unknown') { //====================================================================// // Safety Check if (false == Splash::configuration()->Logging) { return true; } //====================================================================// // Run a Messages List if ((is_array($msgArray) || $msgArray instanceof Countable) && count($msgArray)) { foreach ($msgArray as $message) { //====================================================================// // Add Message To Log File self::addLogToFile(utf8_decode(html_entity_decode($message)), $logType); } } return true; }
php
{ "resource": "" }
q5966
ProgressBar.render
train
public function render() { $percentage = (double) ($this->value / $this->total); $progress = floor($percentage * $this->size); $output = "\r[" . str_repeat('=', $progress); if ($progress < $this->size) { $output .= ">" . str_repeat(' ', $this->size - $progress); } else { $output .= '='; } $output .= sprintf('] %s%% %s/%s', round($percentage * 100, 0), $this->value, $this->total); if ($this->showRemainingTime) { $speed = (time() - $this->startTime) / $this->value; $remaining = number_format(round($speed * ($this->total - $this->value), 2), 2); $output .= " - $remaining sec remaining"; } return $output; }
php
{ "resource": "" }
q5967
ProgressBar.write
train
public function write() { if ($this->textWriter === null) { throw new ConsoleException('No TextWriter object specified'); } $this->textWriter->write($this->render()); return $this; }
php
{ "resource": "" }
q5968
JsonConfigurator.getConfigPath
train
private function getConfigPath() { //====================================================================// // Load Module Configuration $cfg = Splash::configuration(); //====================================================================// // Check if Custom Configuration Path is Defined $cfgPath = Splash::getLocalPath()."/configuration.json"; if (isset($cfg->ConfiguratorPath) && is_string($cfg->ConfiguratorPath)) { $cfgPath = $cfg->ConfiguratorPath; } //====================================================================// // Check if Custom Configuration File Exists Splash::log()->deb("Try Loading Custom Configuration From: ".$cfgPath); if (!is_file($cfgPath)) { return false; } return $cfgPath; }
php
{ "resource": "" }
q5969
JsonConfigurator.getConfigArray
train
private function getConfigArray($cfgPath) { //====================================================================// // Check if Custom Configuration File Exists if (!is_file($cfgPath)) { return false; } //====================================================================// // Load File Contents $rawJson = file_get_contents($cfgPath); if (!is_string($rawJson)) { return false; } //====================================================================// // Decode Json Contents $json = json_decode($rawJson, true); if (!is_array($json)) { Splash::log()->war("Invalid Json Configuration. Overrides Skipped!"); return false; } Splash::log()->deb("Loaded Custom Configuration From: ".$cfgPath); return $json; }
php
{ "resource": "" }
q5970
Container.has
train
public function has($key) { if (!is_string($key)) { throw new \InvalidArgumentException(htmlspecialchars( "Get function only accepts strings. Input was: $key." )); } return isset($this->services[ $key ]) || isset($this->instances[ $key ]); }
php
{ "resource": "" }
q5971
Container.loadHooks
train
protected function loadHooks(array $services) { foreach ($services as $service => $value) { if (!isset($value[ 'hooks' ])) { continue; } foreach ($value[ 'hooks' ] as $key => $hook) { $this->hooks[ $key ][ $service ] = $hook; } } }
php
{ "resource": "" }
q5972
HtmlExportsTrait.getHtmlListItem
train
public function getHtmlListItem($message, $type = null) { switch ($type) { case 'Error': $color = '#FF3300'; $text = '&nbsp;KO&nbsp;'; break; case 'Warning': $color = '#FF9933'; $text = '&nbsp;WAR&nbsp;'; break; default: $color = '#006600'; $text = '&nbsp;OK&nbsp;'; break; } return '[<font color="'.$color.'">'.$text.'</font>]&nbsp;&nbsp;&nbsp;'.$message.PHP_EOL.'</br>'; }
php
{ "resource": "" }
q5973
DataStoreService.get
train
public function get($name) { if (!isset($this->storeList[ $name ])) { $configs = $this->getDataStoreDeclarations(); $this->storeList[ $name ] = new DataStore($this->container, $configs[ $name ]); } return $this->storeList[ $name ]; }
php
{ "resource": "" }
q5974
QueryConfig.setEndPoint
train
public function setEndPoint($endPoint) { if (strlen($this->getEndPointGroup()) > 0) { throw new RuntimeException( "End point group has been already set. You can set either end point or end point group." ); } $this->endPoint = (int) $endPoint; return $this; }
php
{ "resource": "" }
q5975
QueryConfig.setEndPointGroup
train
function setEndPointGroup($endPointGroup) { if (strlen($this->getEndPoint()) > 0) { throw new RuntimeException( "End point has been already set. You can set either end point or end point group." ); } $this->endPointGroup = (int) $endPointGroup; }
php
{ "resource": "" }
q5976
QueryConfig.setGatewayUrl
train
public function setGatewayUrl($gatewayUrl, $gatewayMode) { $this->checkGatewayMode($gatewayMode); switch ($gatewayMode) { case self::GATEWAY_MODE_SANDBOX: { $this->setGatewayUrlSandbox($gatewayUrl); break; } case self::GATEWAY_MODE_PRODUCTION: { $this->setGatewayUrlProduction($gatewayUrl); break; } } return $this; }
php
{ "resource": "" }
q5977
QueryConfig.getGatewayUrl
train
public function getGatewayUrl() { switch ($this->getGatewayMode()) { case self::GATEWAY_MODE_SANDBOX: { return $this->getGatewayUrlSandbox(); } case self::GATEWAY_MODE_PRODUCTION: { return $this->getGatewayUrlProduction(); } default: { throw new RuntimeException('You must set gatewayMode property first'); } } }
php
{ "resource": "" }
q5978
PropertyAccessor.getValue
train
static public function getValue($object, $propertyPath, $failOnError = true) { if (!is_object($object)) { throw new RuntimeException('Object expected, ' . gettype($object) . ' given'); } // immediately return value if propertyPath contains only one level if (strpos($propertyPath, '.') === false) { return static::getByGetter($object, $propertyPath, $failOnError); } list($firstPropertyPath, $pathRest) = explode('.', $propertyPath, 2); $firstObject = static::getByGetter($object, $firstPropertyPath, $failOnError); // get value recursively while propertyPath has many levels if (is_object($firstObject)) { return static::getValue($firstObject, $pathRest, $failOnError); } elseif ($failOnError === true) { throw new RuntimeException("Object expected for property path '{$firstPropertyPath}', '" . gettype($firstObject) . "' given"); } }
php
{ "resource": "" }
q5979
PropertyAccessor.setValue
train
static public function setValue($object, $propertyPath, $propertyValue, $failOnError = true) { if (!is_object($object)) { throw new RuntimeException('Object expected, ' . gettype($object) . ' given'); } // immediately return value if propertyPath contains only one level if (strpos($propertyPath, '.') === false) { return static::setBySetter($object, $propertyPath, $propertyValue, $failOnError); } list($firstPropertyPath, $pathRest) = explode('.', $propertyPath, 2); $firstObject = static::getByGetter($object, $firstPropertyPath, $failOnError); // set value recursively while propertyPath has many levels if (is_object($firstObject)) { return static::setValue($firstObject, $pathRest, $propertyValue, $failOnError); } elseif ($failOnError === true) { throw new RuntimeException("Object expected for property path '{$firstPropertyPath}', '" . gettype($firstObject) . "' given"); } }
php
{ "resource": "" }
q5980
PropertyAccessor.getByGetter
train
static protected function getByGetter($object, $propertyName, $failOnUnknownGetter) { $getter = array($object, 'get' . $propertyName); if (is_callable($getter)) { return call_user_func($getter); } elseif ($failOnUnknownGetter === true) { throw new RuntimeException("Unknown getter for property '{$propertyName}'"); } }
php
{ "resource": "" }
q5981
PropertyAccessor.setBySetter
train
static protected function setBySetter($object, $propertyName, $propertyValue, $failOnUnknownGetter) { $setter = array($object, 'set' . $propertyName); if (is_callable($setter)) { return call_user_func($setter, $propertyValue); } elseif ($failOnUnknownGetter === true) { throw new RuntimeException("Unknown setter for property '{$propertyName}'"); } }
php
{ "resource": "" }
q5982
ModelMongodb._clear_var
train
protected function _clear_var() { $this->field = array(); $this->limit = ''; $this->skip = ''; $this->where = array(); $this->orderby = array(); $this->data = array(); }
php
{ "resource": "" }
q5983
RelationshipHandler.createIdentifierCollectionRelationship
train
protected function createIdentifierCollectionRelationship($object, RelationshipDefinition $definition, MappingContext $context): IdentifierCollectionRelationship { $relationship = new IdentifierCollectionRelationship(); $collection = $object->{$definition->getGetter()}(); $dataLimit = $definition->getDataLimit(); if ($dataLimit > 0) { $collection = new \LimitIterator($collection, 0, $dataLimit); } $mapper = $context->getMapper(); foreach ($collection as $relatedObject) { $resource = $mapper->toResourceIdentifier($relatedObject); $relationship->addIdentifier($resource); } return $relationship; }
php
{ "resource": "" }
q5984
Typo3.createItem
train
public function createItem( array $values = [] ) { $values['customer.siteid'] = $this->getContext()->getLocale()->getSiteId(); return $this->createItemBase( $values ); }
php
{ "resource": "" }
q5985
Typo3.deleteItems
train
public function deleteItems( array $ids ) { $path = 'mshop/customer/manager/typo3/delete'; $this->deleteItemsBase( $ids, $path, false, 'uid' ); $manager = $this->getObject()->getSubManager( 'address' ); $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); $search->setConditions( $search->compare( '==', 'customer.address.parentid', $ids ) ); $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); $manager = $this->getObject()->getSubManager( 'lists' ); $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); $search->setConditions( $search->compare( '==', 'customer.lists.parentid', $ids ) ); $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); $manager = $this->getObject()->getSubManager( 'property' ); $search = $manager->createSearch()->setSlice( 0, 0x7fffffff ); $search->setConditions( $search->compare( '==', 'customer.property.parentid', $ids ) ); $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) ); }
php
{ "resource": "" }
q5986
Typo3.getSubManager
train
public function getSubManager( $manager, $name = null ) { return $this->getSubManagerBase( 'customer', $manager, ( $name === null ? 'Typo3' : $name ) ); }
php
{ "resource": "" }
q5987
Typo3.getPasswordHelper
train
protected function getPasswordHelper() { if( $this->helper ) { return $this->helper; } $classname = \Aimeos\MShop\Common\Helper\Password\Typo3::class; if( class_exists( $classname ) === false ) { throw new \Aimeos\MShop\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); } $context = $this->getContext(); $object = ( method_exists( $context, 'getHasherTypo3' ) ? $context->getHasherTypo3() : null ); $helper = new $classname( array( 'object' => $object ) ); return $this->helper = self::checkClass( \Aimeos\MShop\Common\Helper\Password\Iface::class, $helper ); }
php
{ "resource": "" }
q5988
JBDump.i
train
public static function i($options = array()) { static $instance; if (!isset($instance)) { $instance = new self($options); if (self::$_config['profiler']['showStart']) { self::mark('jbdump::start'); } } return $instance; }
php
{ "resource": "" }
q5989
JBDump.showErrors
train
public static function showErrors($reportLevel = -1) { if (!self::isDebug()) { return false; } if ($reportLevel === null || $reportLevel === false) { return false; } if ($reportLevel != 0) { error_reporting($reportLevel); ini_set('error_reporting', $reportLevel); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); } else { error_reporting(0); ini_set('error_reporting', 0); ini_set('display_errors', 0); ini_set('display_startup_errors', 0); } return true; }
php
{ "resource": "" }
q5990
JBDump.maxTime
train
public static function maxTime($time = 600) { if (!self::isDebug()) { return false; } ini_set('max_execution_time', $time); set_time_limit($time); return self::i(); }
php
{ "resource": "" }
q5991
JBDump.setParams
train
public function setParams($data, $section = null) { if ($section) { $newData = array($section => $data); $data = $newData; unset($newData); } if (isset($data['errors']['reporting'])) { $this->showErrors($data['errors']['reporting']); } // set root directory if (!isset($data['root']) && !self::$_config['root']) { $data['root'] = $_SERVER['DOCUMENT_ROOT']; } // set log path if (isset($data['log']['path']) && $data['log']['path']) { $this->_logPath = $data['log']['path']; } elseif (!self::$_config['log']['path'] || !$this->_logPath) { $this->_logPath = dirname(__FILE__) . self::DS . 'logs'; } // set log filename $logFile = 'jbdump'; if (isset($data['log']['file']) && $data['log']['file']) { $logFile = $data['log']['file']; } elseif (!self::$_config['log']['file'] || !$this->_logfile) { $logFile = 'jbdump'; } $this->_logfile = $this->_logPath . self::DS . $logFile . '_' . date('Y.m.d') . '.log.php'; // merge new params with of config foreach ($data as $key => $value) { if (is_array($value)) { foreach ($value as $keyInner => $valueInner) { if (!isset(self::$_config[$key])) { self::$_config[$key] = array(); } self::$_config[$key][$keyInner] = $valueInner; } } else { self::$_config[$key] = $value; } } return $this; }
php
{ "resource": "" }
q5992
JBDump.ip
train
public static function ip() { if (!self::isDebug()) { return false; } $ip = self::getClientIP(); $data = array( 'ip' => $ip, 'host' => gethostbyaddr($ip), 'source' => '$_SERVER["' . self::getClientIP(true) . '"]', 'inet_pton' => inet_pton($ip), 'ip2long' => ip2long($ip), ); return self::i()->dump($data, '! my IP = ' . $ip . ' !'); }
php
{ "resource": "" }
q5993
JBDump.memory
train
public static function memory($formated = true) { if (!self::isDebug()) { return false; } $memory = self::i()->_getMemory(); if ($formated) { $memory = self::i()->_formatSize($memory); } return self::i()->dump($memory, '! memory !'); }
php
{ "resource": "" }
q5994
JBDump.functions
train
public static function functions($showInternal = false) { if (!self::isDebug()) { return false; } $functions = get_defined_functions(); if ($showInternal) { $functions = $functions['internal']; $type = 'internal'; } else { $functions = $functions['user']; $type = 'user'; } return self::i()->dump($functions, '! functions (' . $type . ') !'); }
php
{ "resource": "" }
q5995
JBDump.defines
train
public static function defines($showAll = false) { if (!self::isDebug()) { return false; } $defines = get_defined_constants(true); if (!$showAll) { $defines = (isset($defines['user'])) ? $defines['user'] : array(); } return self::i()->dump($defines, '! defines !'); }
php
{ "resource": "" }
q5996
JBDump.extensions
train
public static function extensions($zend = false) { if (!self::isDebug()) { return false; } return self::i()->dump(get_loaded_extensions($zend), '! extensions ' . ($zend ? '(Zend)' : '') . ' !'); }
php
{ "resource": "" }
q5997
JBDump.headers
train
public static function headers() { if (!self::isDebug()) { return false; } if (function_exists('apache_request_headers')) { $data = array( 'Request' => apache_request_headers(), 'Response' => apache_response_headers(), 'List' => headers_list() ); } else { $data = array( 'List' => headers_list() ); } if (headers_sent($filename, $linenum)) { $data['Sent'] = 'Headers already sent in ' . self::i()->_getRalativePath($filename) . ':' . $linenum; } else { $data['Sent'] = false; } return self::i()->dump($data, '! headers !'); }
php
{ "resource": "" }
q5998
JBDump.path
train
public static function path() { if (!self::isDebug()) { return false; } $result = array( 'get_include_path' => explode(PATH_SEPARATOR, trim(get_include_path(), PATH_SEPARATOR)), '$_SERVER[PATH]' => explode(PATH_SEPARATOR, trim($_SERVER['PATH'], PATH_SEPARATOR)) ); return self::i()->dump($result, '! paths !'); }
php
{ "resource": "" }
q5999
JBDump.json
train
public static function json($json, $name = '...') { if (!self::isDebug()) { return false; } $jsonData = json_decode($json); $result = self::i()->_jsonEncode($jsonData); return self::i()->dump($result, $name); }
php
{ "resource": "" }