_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q264500
|
Host.whoamiSet
|
test
|
public function whoamiSet($ident, $value = null)
{
$this->whoami();
$this->whoami[$ident] = (is_numeric($value)) ? intval($value)
|
php
|
{
"resource": ""
}
|
q264501
|
ValidatorFactory.getValidator
|
test
|
protected function getValidator(ServiceLocatorInterface $serviceLocator, string $name,
|
php
|
{
"resource": ""
}
|
q264502
|
PageFetcher.setCurlContent
|
test
|
private function setCurlContent($curl, PageFetcherRequestInterface $request): void
{
$rawContent = $request->getRawContent();
if ($rawContent !== '') {
curl_setopt($curl, CURLOPT_POSTFIELDS, $rawContent);
return;
}
$postFields = [];
$hasFiles = false;
foreach ($request->getFiles() as $name => $filePath) {
/** @var FilePathInterface $filePath */
$curlFile = curl_file_create($filePath->__toString(), mime_content_type($filePath->__toString()), $filePath->getFilename());
$postFields[$name] = $curlFile;
$hasFiles = true;
|
php
|
{
"resource": ""
}
|
q264503
|
PageFetcher.parseResult
|
test
|
private function parseResult(string $result): PageFetcherResponseInterface
{
$resultParts = explode("\r\n\r\n", $result, 2);
$headers = explode("\r\n", $resultParts[0]);
$statusLine = array_shift($headers);
$statusLineParts = explode(' ', $statusLine);
$httpCode = intval($statusLineParts[1]);
if ($httpCode === 100) {
|
php
|
{
"resource": ""
}
|
q264504
|
ExtensionsConfiguration.commonApplicationAttributes
|
test
|
public function commonApplicationAttributes()
{
return [
'components' => [
'i18n' => [
'translations' => [
'extensions-manager' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => __DIR__ . '/messages',
]
]
],
],
'modules' => [
|
php
|
{
"resource": ""
}
|
q264505
|
Options.getOption
|
test
|
protected function getOption($option)
{
return in_array($option, $this->getOptions())
|
php
|
{
"resource": ""
}
|
q264506
|
Options.buildOptions
|
test
|
protected function buildOptions(array $defaults = null)
{
$options = $this->getOptions();
if ($defaults) $options = array_merge($defaults, $options);
foreach ($options as $option) {
if ( ! array_key_exists($option, $this->options)) continue;
if ( ! isset($optionsBitwise)) {
|
php
|
{
"resource": ""
}
|
q264507
|
Securepass.user
|
test
|
public function user($type, $params = array()) {
$command_mapping = array(
'auth' => 'UserAuth',
'info' => 'UserInfo',
'add' => 'UserAdd',
'provision' => 'UserProvision',
'list' => 'UserList',
'delete' => 'UserDelete'
);
if (!isset($command_mapping[$type])) {
throw new InvalidArgumentException(sprintf('"%s" is not a valid user command.', $type));
}
// check if exists a specific implementation for this
|
php
|
{
"resource": ""
}
|
q264508
|
Securepass.ping
|
test
|
public function ping()
{
$command = $this->client->getCommand('Ping');
|
php
|
{
"resource": ""
}
|
q264509
|
BoxSizer.setAttribute
|
test
|
public function setAttribute($key, $value)
{
switch ($key) {
case 'orientation':
$this->attributes[$key] =
|
php
|
{
"resource": ""
}
|
q264510
|
Money.format
|
test
|
public function format(bool $displayCountryForUS = false): string
{
$formatter = new NumberFormatter('en', NumberFormatter::CURRENCY);
if ($displayCountryForUS && $this->currency === 'USD') {
|
php
|
{
"resource": ""
}
|
q264511
|
Money.formatForAccounting
|
test
|
public function formatForAccounting(): string
{
$amount = $this->getRoundedAmount();
$negative = 0 > $amount;
if ($negative) {
$amount *= -1;
}
$amount = number_format($amount,
|
php
|
{
"resource": ""
}
|
q264512
|
Money.getRoundedAmount
|
test
|
public function getRoundedAmount(): float
{
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($this->currency);
$roundingIncrement = Intl::getCurrencyBundle()->getRoundingIncrement($this->currency);
$value = round($this->amount, $fractionDigits);
// Swiss rounding
if (0 <
|
php
|
{
"resource": ""
}
|
q264513
|
Money.split
|
test
|
public function split(array $percentages, bool $round = true): array
{
$totalPercentage = array_sum($percentages);
if ($totalPercentage > 100) {
throw new InvalidArgumentException('Only 100% can be allocated');
}
$amounts = [];
$total = 0;
if (!$round) {
foreach ($percentages as $percentage) {
$share = $this->percentage($percentage);
$total += $share->getAmount();
$amounts[] = $share;
}
if ($totalPercentage != 100) {
$amounts[] = new static($this->amount - $total, $this->currency);
}
return $amounts;
}
$count = 0;
if ($totalPercentage != 100) {
$percentages[] = 0; //Dummy record to trigger the rest of the amount being assigned to a final pot
}
|
php
|
{
"resource": ""
}
|
q264514
|
Factory.prepareAndInjectElements
|
test
|
protected function prepareAndInjectElements($elements, FieldsetInterface $fieldset, $method)
{
$elements = $this->validateSpecification($elements, $method);
foreach ($elements as $elementSpecification) {
|
php
|
{
"resource": ""
}
|
q264515
|
MeRepository.getMe
|
test
|
public function getMe($accessToken)
{
if (empty($accessToken)) {
throw new \InvalidArgumentException('Empty access token provided', 1);
}
$response
|
php
|
{
"resource": ""
}
|
q264516
|
Router.run
|
test
|
function run()
{
//Resolve request
$this->resolve();
//If is a CALLBACK...
if (is_object($this->controller)) {
exit(call_user_func_array($this->controller, [$this->request, $this->params]));
}
if ($this->controller === null) {
$this->controller = $this->method == 'CLI' ? $this->defaultCliController : $this->defaultController;
}
if ($this->action === null) {
$this->action = $this->method == 'CLI' ? $this->defaultCliAction : $this->defaultAction;
}
//Name format to Controller namespace
$ctrl = $this->formatePrsr4Name($this->controller, $this->method == 'CLI' ? $this->namespaceCliPrefix : $this->namespacePrefix);
//Save the controller...
$this->controller = $ctrl;
//Check whether to automatically run the Controller
//
|
php
|
{
"resource": ""
}
|
q264517
|
Router.searchRouter
|
test
|
private function searchRouter($routes)
{
foreach ($routes as $route) {
if ($route['controller'] === null
|| !preg_match_all('#^' . $route['request'] . '$#',
$this->request,
$matches,
PREG_SET_ORDER)
) {
|
php
|
{
"resource": ""
}
|
q264518
|
Router.requestMethod
|
test
|
private function requestMethod()
{
if (php_sapi_name() === 'cli') {
return 'CLI';
}
// Take the method as found in $_SERVER
$method = $_SERVER['REQUEST_METHOD'];
if ($_SERVER['REQUEST_METHOD'] == 'HEAD') {
ob_start();
$method = 'GET';
|
php
|
{
"resource": ""
}
|
q264519
|
LogTruck.getLogs
|
test
|
public function getLogs()
{
$logsArray = [];
$logs = LoggerORM::findAll();
foreach ($logs as $log) {
$isException = false;
$log = (array) $log;
$logCabin = [];
if ($log['exception'] !== null && is_array($log['exception']) && count($log['exception']) > 0) {
$isException = true;
foreach ($log['exception'] as $key => $value) {
$key = $this->deathByCamels($key);
$logCabin[$key] = $value;
}
if (($options = $this->getOptions($log['log_hash'])) !== null) {
$logCabin['options'] = $options->details;
|
php
|
{
"resource": ""
}
|
q264520
|
LogTruck.deathByCamels
|
test
|
private function deathByCamels($string)
{
$this->index = 0;
return implode('', array_map(function($el) {
|
php
|
{
"resource": ""
}
|
q264521
|
Convert.bytes
|
test
|
public static function bytes($bytes)
{
$kbytes = sprintf("%.02f", $bytes/1024);
$mbytes = sprintf("%.02f", $kbytes/1024);
$gbytes = sprintf("%.02f", $mbytes/1024);
$tbytes = sprintf("%.02f", $gbytes/1024);
if($tbytes >= 1)
return $tbytes . " TB";
if($gbytes >= 1)
return
|
php
|
{
"resource": ""
}
|
q264522
|
Convert.codec
|
test
|
public static function codec($codec)
{
if($codec == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::CODEC_SPEEX_NARROWBAND)
return "Speex Narrowband (8 kHz)";
if($codec == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::CODEC_SPEEX_WIDEBAND)
return "Speex Wideband (16 kHz)";
if($codec == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::CODEC_SPEEX_ULTRAWIDEBAND)
|
php
|
{
"resource": ""
}
|
q264523
|
Convert.groupType
|
test
|
public static function groupType($type)
{
if($type == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_TEMPLATE)
return "Template";
if($type ==
|
php
|
{
"resource": ""
}
|
q264524
|
Convert.permissionType
|
test
|
public static function permissionType($type)
{
if($type == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::PERM_TYPE_SERVERGROUP)
return "Server Group";
if($type == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::PERM_TYPE_CLIENT)
return "Client";
if($type == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::PERM_TYPE_CHANNEL)
return "Channel";
|
php
|
{
"resource": ""
}
|
q264525
|
Convert.logLevel
|
test
|
public static function logLevel($level)
{
if(is_numeric($level))
{
if($level == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_CRITICAL)
return "CRITICAL";
if($level == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_ERROR)
return "ERROR";
if($level == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_DEBUG)
return "DEBUG";
if($level == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_WARNING)
return "WARNING";
if($level == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_INFO)
return "INFO";
return "DEVELOP";
}
else
{
if(strtoupper($level) == "CRITICAL")
return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_CRITICAL;
if(strtoupper($level) == "ERROR")
return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_ERROR;
|
php
|
{
"resource": ""
}
|
q264526
|
Convert.logEntry
|
test
|
public static function logEntry($entry)
{
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_ERROR;
$array["channel"] = "ParamParser";
$array["server_id"] = "";
$array["msg"] = "convert error (" . trim($entry) . ")";
$array["msg_plain"] = $entry;
$array["malformed"] = TRUE;
}
else
{
$array["timestamp"] = strtotime(trim($parts[0]));
$array["level"]
|
php
|
{
"resource": ""
}
|
q264527
|
TimedNoticeAdmin.getList
|
test
|
public function getList()
{
$list = parent::getList();
$r = $this->getRequest();
if ($q = $r->requestVar('q')) {
if (isset($q['Status'])) {
$status = $q['Status'];
$now = date('Y-m-d H:i:s');
if ($status == 'Future') {
return $list->where("StartTime > '$now'");
} else if ($status == 'Expired') {
return $list->where("EndTime < $now");
|
php
|
{
"resource": ""
}
|
q264528
|
EntityTrait.getTraits
|
test
|
protected static function getTraits()
{
if (isset(static::$traitsList[static::class]) === false) {
$className = static::class;
static::$traitsList[static::class] = [];
do {
foreach (class_uses($className) as $value) {
static::$traitsList[static::class][$value]
|
php
|
{
"resource": ""
}
|
q264529
|
EntityTrait.callTraitMethod
|
test
|
protected function callTraitMethod($traitName, $methodName)
{
return method_exists($this, $traitName
|
php
|
{
"resource": ""
}
|
q264530
|
EntityTrait.callEvents
|
test
|
protected function callEvents($eventName)
{
foreach (static::getTraits() as $name) {
if ($name === 'EntityTrait') {
continue;
|
php
|
{
"resource": ""
}
|
q264531
|
EntityTrait.attributeLabels
|
test
|
public function attributeLabels()
{
if (isset(static::$attributeLabelsList[static::class]) === false) {
static::$attributeLabelsList[static::class] = isset($this->attributeLabels) === true
? $this->attributeLabels
: [];
foreach (static::getTraits() as $name) {
|
php
|
{
"resource": ""
}
|
q264532
|
EntityTrait.attributeHints
|
test
|
public function attributeHints()
{
if (isset(static::$attributeHintsList[static::class]) === false) {
static::$attributeHintsList[static::class] = isset($this->attributeHints) === true
? $this->attributeHints
: [];
foreach (static::getTraits() as $name) {
|
php
|
{
"resource": ""
}
|
q264533
|
Reply.toArray
|
test
|
public function toArray()
{
$array = array();
$table = $this->toTable(1);
for($i = 0; $i < count($table); $i++)
{
foreach($table[$i] as $pair)
{
if(!$pair->contains(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_PAIR))
{
$array[$i][$pair->toString()] = null;
}
|
php
|
{
"resource": ""
}
|
q264534
|
Reply.fetchError
|
test
|
protected function fetchError($err)
{
$cells = $err->section(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_CELL, 1, 3);
foreach($cells->split(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_CELL) as $pair)
{
list($ident, $value) = $pair->split(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_PAIR);
$this->err[$ident->toString()] = $value->isInt() ? $value->toInt() : $value->unescape();
}
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyError", $this);
if($this->getErrorProperty("id", 0x00) != 0x00)
{
if($permid = $this->getErrorProperty("failed_permid"))
{
try
{
$suffix = " (failed on " . $this->con->permissionGetNameById($permid) . ")";
|
php
|
{
"resource": ""
}
|
q264535
|
Reply.fetchReply
|
test
|
protected function fetchReply($rpl)
{
foreach($rpl as $key => $val)
{
if($val->startsWith(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GREET))
{
unset($rpl[$key]);
}
elseif($val->startsWith(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::EVENT))
{
$this->evt[] = new Event($rpl[$key], $this->con);
unset($rpl[$key]);
}
|
php
|
{
"resource": ""
}
|
q264536
|
AuthenticationService.getIdentity
|
test
|
public function getIdentity()
{
if ($this->identity instanceof User) {
return $this->identity;
}
$identity = parent::getIdentity();
if (empty($identity)) {
$this->clearIdentity();
return;
}
$identity = $this->tableGateway->selectByPrimary($identity);
if (!($identity instanceof User)) {
$this->clearIdentity();
return;
}
|
php
|
{
"resource": ""
}
|
q264537
|
AuthenticationService.hasIdentity
|
test
|
public function hasIdentity()
{
$storageCheck = !$this->getStorage()->isEmpty();
if (!$storageCheck) {
|
php
|
{
"resource": ""
}
|
q264538
|
SoftDeleteTrait.restore
|
test
|
public function restore()
{
/** @var ActiveRecord $this */
if (((boolean) $this->{$this->isDeletedAttribute}) !== false) {
$this->{$this->isDeletedAttribute} = false;
|
php
|
{
"resource": ""
}
|
q264539
|
UserRepository.getUser
|
test
|
public function getUser($userId)
{
$response = $this->getClient()->get(self::ENDPOINT.$userId);
$data
|
php
|
{
"resource": ""
}
|
q264540
|
UserRepository.getUserFollowedGames
|
test
|
public function getUserFollowedGames($userId, $params = array())
{
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
// need old api version to get user's followed games
$client = $this->getClient()->setUrl(Client::URL_PROTOCOL.'://'.Client::URL_HOST.'/'.Client::URL_OLD_VERSION.'/');
$response = $this->setClient($client)->getClient()->get(self::ENDPOINT.$userId.'/follows/games/live/'.$params);
// reset api endpoint to current version
$client =
|
php
|
{
"resource": ""
}
|
q264541
|
TimedNotice.get_notices
|
test
|
public static function get_notices($context = null)
{
// fallback to the CMS as the context - this is required to be consistent with the original behaviour.
if ($context == null) {
$context = 'CMS';
}
// prepare and filter the possible result
$now = DBDatetime::now()->getValue();
$member = Member::currentUser();
$notices = TimedNotice::get()->filter(
[
"Context" => $context,
"StartTime:LessThan" => $now
]
)->filterAny(
[
"EndTime:GreaterThan" => $now,
"EndTime" => null
]
);
// if there are notices verify if those are allowed for this group
if ($notices->count()) {
// turn the
|
php
|
{
"resource": ""
}
|
q264542
|
ChannelRepository.getChannel
|
test
|
public function getChannel($channelId)
{
$response = $this->getClient()->get(self::ENDPOINT.$channelId);
$data
|
php
|
{
"resource": ""
}
|
q264543
|
String.escape
|
test
|
public function escape()
{
foreach(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::getEscapePatterns() as
|
php
|
{
"resource": ""
}
|
q264544
|
String.unescape
|
test
|
public function unescape()
{
$this->string = strtr($this->string, array_flip(\ManiaLivePlugins\Standard\T
|
php
|
{
"resource": ""
}
|
q264545
|
TeamRepository.getTeam
|
test
|
public function getTeam($teamId)
{
$response = $this->getClient()->get(self::ENDPOINT.$teamId);
$data
|
php
|
{
"resource": ""
}
|
q264546
|
ContainerResult.addResult
|
test
|
public function addResult(ResultInterface $result, string $name = null): ContainerResult
{
$this->valid = $this->isValid() && $result->isValid();
if (is_string($name) === true) {
|
php
|
{
"resource": ""
}
|
q264547
|
StreamRepository.getStream
|
test
|
public function getStream($channelId)
{
$response = $this->getClient()->get(self::ENDPOINT.$channelId);
$data = $this->jsonResponse($response);
|
php
|
{
"resource": ""
}
|
q264548
|
StreamRepository.getStreams
|
test
|
public function getStreams($params = array())
{
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
$response = $this->getClient()->get(self::ENDPOINT.$params);
|
php
|
{
"resource": ""
}
|
q264549
|
StreamRepository.getFeaturedStreams
|
test
|
public function getFeaturedStreams($params = array())
{
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
$response = $this->getClient()->get(self::ENDPOINT.'featured'.$params);
|
php
|
{
"resource": ""
}
|
q264550
|
StreamRepository.getFollowedStreams
|
test
|
public function getFollowedStreams($accessToken, $params = array())
{
if (empty($accessToken)) {
throw new \InvalidArgumentException('Empty access token provided', 1);
}
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
|
php
|
{
"resource": ""
}
|
q264551
|
StreamRepository.getStreamsSummary
|
test
|
public function getStreamsSummary($params = array())
{
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
$response = $this->getClient()->get(self::ENDPOINT.'summary'.$params);
|
php
|
{
"resource": ""
}
|
q264552
|
GameRepository.getTop
|
test
|
public function getTop($params = array())
{
$params = 0 < count($params) ? '?'.http_build_query($params) : '';
$response = $this->getClient()->get(self::ENDPOINT.'/top'.$params);
|
php
|
{
"resource": ""
}
|
q264553
|
TextBox.getValue
|
test
|
public function getValue()
{
if ($this->element) {
|
php
|
{
"resource": ""
}
|
q264554
|
TSDNS.resolve
|
test
|
public function resolve($tsdns)
{
$this->getTransport()->sendLine($tsdns);
$repl = $this->getTransport()->readLine();
$this->getTransport()->disconnect();
if($repl->section(":", 0)->toInt() == 404)
{
throw new TSDNS\Exception("unable to resolve TSDNS hostname (" . $tsdns . ")");
}
|
php
|
{
"resource": ""
}
|
q264555
|
ConfigurationUpdater.getConfigurables
|
test
|
protected function getConfigurables($ignoreCache = false)
{
if (count($this->_configurables) === 0 || true === $ignoreCache) {
|
php
|
{
"resource": ""
}
|
q264556
|
Client.message
|
test
|
public function message($msg)
{
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(),
|
php
|
{
"resource": ""
}
|
q264557
|
Client.kick
|
test
|
public function kick($reasonid = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::KICK_CHANNEL, $reasonmsg = null)
{
|
php
|
{
"resource": ""
}
|
q264558
|
Client.avatarDownload
|
test
|
public function avatarDownload()
{
if($this["client_flag_avatar"] == 0) return;
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0,
|
php
|
{
"resource": ""
}
|
q264559
|
Events.bindEvents
|
test
|
protected function bindEvents()
{
$callback = new ClosureCallback(function($method) {
$controller = $this->collection->getController();
$args = array_slice(func_get_args(), 1);
return call_user_func_array([$controller, $method], $args);
});
|
php
|
{
"resource": ""
}
|
q264560
|
Events.connectEvent
|
test
|
protected function connectEvent($constant, callable $callback)
{
if ( ! method_exists($this->element, 'GetId')) {
return $this->element->Connect($constant, $callback);
|
php
|
{
"resource": ""
}
|
q264561
|
Uri.getQueryVar
|
test
|
public function getQueryVar($key, $default = null)
{
if(!$this->hasQuery()) return $default;
parse_str($this->query, $queryArray);
if(array_key_exists($key, $queryArray))
{
$val = $queryArray[$key];
if(ctype_digit($val))
{
|
php
|
{
"resource": ""
}
|
q264562
|
Uri.getBaseUri
|
test
|
public static function getBaseUri()
{
$scriptPath = new String(dirname(self::getHostParam("SCRIPT_NAME")));
|
php
|
{
"resource": ""
}
|
q264563
|
ServerQuery.request
|
test
|
public function request($cmd)
{
$query = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory($cmd)->section(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_CELL);
if(strstr($cmd, "\r") || strstr($cmd, "\n"))
{
throw new Exception("illegal characters in command '" . $query . "'");
}
elseif(in_array($query, $this->block))
{
throw new ServerQuery\Exception("command not found", 0x100);
}
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("serverqueryCommandStarted", $cmd);
|
php
|
{
"resource": ""
}
|
q264564
|
ServerQuery.wait
|
test
|
public function wait()
{
if($this->getTransport()->getConfig("blocking"))
{
throw new Exception("only available in non-blocking mode");
}
do {
$evt = $this->getTransport()->readLine();
} while($evt instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String &&
|
php
|
{
"resource": ""
}
|
q264565
|
ServerQuery.prepare
|
test
|
public function prepare($cmd, array $params = array())
{
$args = array();
$cells = array();
foreach($params as $ident => $value)
{
$ident = is_numeric($ident) ? "" : strtolower($ident) . \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SEPARATOR_PAIR;
if(is_array($value))
{
$value = array_values($value);
for($i = 0; $i < count($value); $i++)
{
if($value[$i] === null) continue;
elseif($value[$i] === FALSE) $value[$i] = 0x00;
elseif($value[$i] === TRUE) $value[$i] = 0x01;
elseif($value[$i] instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\AbstractNode) $value[$i] = $value[$i]->getId();
$cells[$i][] = $ident . \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory($value[$i])->escape();//->toUtf8();
}
}
else
{
if($value === null) continue;
elseif($value === FALSE) $value = 0x00;
|
php
|
{
"resource": ""
}
|
q264566
|
ServerQuery.getHost
|
test
|
public function getHost()
{
if($this->host === null)
{
$this->host = new
|
php
|
{
"resource": ""
}
|
q264567
|
ExtensionController.actionList
|
test
|
public function actionList($sort = true)
{
$sort = (bool) $sort;
if ($sort) {
ksort($this->extensions);
}
foreach ($this->extensions as $name => $extension) {
if ($extension['is_active']) {
$this->stdout('[active] ', Console::FG_GREEN);
} else {
$this->stdout(' ', Console::FG_RED);
}
$this->stdout(str_pad($name, 50, ' '));
$this->stdout(' - ');
$color = Console::FG_BLACK;
switch
|
php
|
{
"resource": ""
}
|
q264568
|
ExtensionController.writeConfig
|
test
|
private function writeConfig()
{
$fileName = Yii::getAlias($this->module->extensionsStorage);
$writer = new ApplicationConfigWriter([
'filename' => $fileName,
]);
$writer->addValues($this->extensions);
if (true === $writer->commit()) {
$this->stdout('Extensions configuration successfully updated.' . PHP_EOL);
if (true === $this->module->configurationUpdater->updateConfiguration(false)) {
$this->stdout('Application configuration successfully updated.' . PHP_EOL);
return true;
} else
|
php
|
{
"resource": ""
}
|
q264569
|
MenuBar.setParent
|
test
|
public function setParent(ElementInterface $parent)
{
|
php
|
{
"resource": ""
}
|
q264570
|
Describe.columns
|
test
|
public function columns($table)
{
try {
$columns = $this->driver->columns($table);
return $columns;
} catch (\PDOException $error) {
|
php
|
{
"resource": ""
}
|
q264571
|
GuzzleTranscoder.createTranscoder
|
test
|
private function createTranscoder() {
if ($this->transcoder === null) {
|
php
|
{
"resource": ""
}
|
q264572
|
GuzzleTranscoder.getByCaseInsensitiveKey
|
test
|
private static function getByCaseInsensitiveKey(array $words, $key) {
foreach ($words as $headerWord => $value) {
if (strcasecmp($headerWord, $key)
|
php
|
{
"resource": ""
}
|
q264573
|
GuzzleTranscoder.setByCaseInsensitiveKey
|
test
|
private static function setByCaseInsensitiveKey(array $words, $key, $newValue) {
foreach ($words as $headerWord => $value) {
if (strcasecmp($headerWord, $key) === 0) {
$key = $headerWord;
|
php
|
{
"resource": ""
}
|
q264574
|
TimedNoticeController.notices
|
test
|
public function notices($context = null)
{
$notices = [];
// fallback to the CMS as the context - this is required to be consistent with the original behaviour.
if ($context == null || $context instanceof HTTPRequest) {
|
php
|
{
"resource": ""
}
|
q264575
|
ExtensionsController.actionIndex
|
test
|
public function actionIndex()
{
$extensions = ExtensionsManager::module()->getExtensions();
return $this->render(
'index',
[
'dataProvider' => new ArrayDataProvider([
'allModels' => $extensions,
'sort' => [
'attributes' => ['composer_name', 'composer_type', 'is_active'],
],
|
php
|
{
"resource": ""
}
|
q264576
|
ExtensionsController.doRequest
|
test
|
private static function doRequest($url, $headers = [])
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
if (0 !== $errno
|
php
|
{
"resource": ""
}
|
q264577
|
ExtensionsController.actionRunTask
|
test
|
public function actionRunTask()
{
if (false === Yii::$app->request->isAjax) {
throw new NotFoundHttpException('Page not found');
}
$module = ExtensionsManager::module();
$packageName = Yii::$app->request->post('packageName');
$extension = $module->getExtensions($packageName);
$taskType = Yii::$app->request->post('taskType');
if (true === empty($extension) && $taskType != ExtensionsManager::INSTALL_DEFERRED_TASK) {
return self::runTask(
[
realpath(Yii::getAlias('@app') . '/yii'),
'extension/dummy',
'Undefined extension: ' . $packageName,
],
ExtensionsManager::EXTENSION_DUMMY_DEFERRED_GROUP
);
}
if ($module->extensionIsCore($packageName)
&& !Yii::$app->user->can('extensions-manager-access-to-core-extension')
) {
throw new ForbiddenHttpException;
}
$chain = new ReportingChain();
switch ($taskType) {
case ExtensionsManager::INSTALL_DEFERRED_TASK :
if ($module->extensionIsCore($packageName)
|| !Yii::$app->user->can('extensions-manager-install-extension')
) {
throw new ForbiddenHttpException;
}
return self::runTask(
[
$module->composerPath,
'require',
$packageName,
'--no-interaction',
'--no-ansi',
"--working-dir={$module->getLocalExtensionsPath()}",
'--prefer-dist',
'-o',
$module->verbose == 1 ? '-vvv' : '',
],
ExtensionsManager::COMPOSER_INSTALL_DEFERRED_GROUP
);
case ExtensionsManager::UNINSTALL_DEFERRED_TASK :
|
php
|
{
"resource": ""
}
|
q264578
|
ExtensionsController.deactivate
|
test
|
private static function deactivate($extension, ReportingChain $chain)
{
if ($extension['is_active'] == 1) {
ExtensionDataHelper::prepareMigrationTask(
$extension,
$chain,
ExtensionsManager::MIGRATE_TYPE_DOWN,
ExtensionsManager::EXTENSION_DEACTIVATE_DEFERRED_GROUP
);
$deactivationTask = ExtensionDataHelper::buildTask(
[
realpath(Yii::getAlias('@app') . '/yii'),
|
php
|
{
"resource": ""
}
|
q264579
|
ExtensionsController.activate
|
test
|
private static function activate($extension, ReportingChain $chain)
{
if ($extension['is_active'] == 0) {
ExtensionDataHelper::prepareMigrationTask(
$extension,
$chain,
ExtensionsManager::MIGRATE_TYPE_UP,
ExtensionsManager::EXTENSION_ACTIVATE_DEFERRED_GROUP
);
$activationTask = ExtensionDataHelper::buildTask(
[
realpath(Yii::getAlias('@app') . '/yii'),
|
php
|
{
"resource": ""
}
|
q264580
|
ExtensionsController.uninstall
|
test
|
private static function uninstall($extension, ReportingChain $chain)
{
$module = ExtensionsManager::module();
if (true === $module->extensionIsCore($extension['composer_name'])) {
$dummyTask = ExtensionDataHelper::buildTask(
[
realpath(Yii::getAlias('@app') . '/yii'),
'extension/dummy',
'--no-interaction',
'-o',
'You are unable to uninstall core extensions!',
],
ExtensionsManager::EXTENSION_DUMMY_DEFERRED_GROUP
);
$chain->addTask($dummyTask);
} else {
self::deactivate($extension, $chain);
$uninstallTask = ExtensionDataHelper::buildTask(
[
$module->composerPath,
|
php
|
{
"resource": ""
}
|
q264581
|
ExtensionsController.runTask
|
test
|
private static function runTask($command, $groupName)
{
$task = ExtensionDataHelper::buildTask($command, $groupName);
if ($task->registerTask()) {
DeferredHelper::runImmediateTask($task->model()->id);
Yii::$app->response->format = Response::FORMAT_JSON;
return [
|
php
|
{
"resource": ""
}
|
q264582
|
Channel.clientGetByName
|
test
|
public function clientGetByName($name)
{
foreach($this->clientList() as $client)
{
if($client["client_nickname"] ==
|
php
|
{
"resource": ""
}
|
q264583
|
Channel.iconDownload
|
test
|
public function iconDownload()
{
if($this->iconIsLocal("channel_icon_id") || $this["channel_icon_id"] == 0) return;
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("channel_icon_id"));
$transfer =
|
php
|
{
"resource": ""
}
|
q264584
|
Channel.message
|
test
|
public function message($msg, $cpw = null)
{
if($this->getId() != $this->getParent()->whoamiGet("client_channel_id"))
{
$this->getParent()->clientMove($this->getParent()->whoamiGet("client_id"), $this->getId(),
|
php
|
{
"resource": ""
}
|
q264585
|
Channel.delete
|
test
|
public function delete($force = FALSE)
{
$this->getParent()->channelDelete($this-
|
php
|
{
"resource": ""
}
|
q264586
|
JWT.encode
|
test
|
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
{
$header = array('typ' => 'JWT', 'alg' => $alg);
if ($keyId !== null) {
$header['kid'] = $keyId;
}
if ( isset($head) && is_array($head) ) {
$header = array_merge($head, $header);
}
$segments = array();
$segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
|
php
|
{
"resource": ""
}
|
q264587
|
JWT.sign
|
test
|
public static function sign($msg, $key, $alg = 'HS256')
{
if (empty(self::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = self::$supported_algs[$alg];
switch($function) {
case 'hash_hmac':
return hash_hmac($algorithm, $msg, $key, true);
case 'openssl':
$signature = '';
|
php
|
{
"resource": ""
}
|
q264588
|
JWT.jsonDecode
|
test
|
public static function jsonDecode($input)
{
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
* to specify that large ints (like Steam Transaction IDs) should be treated as
* strings, rather than the PHP default behaviour of converting them to floats.
*/
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
} else {
/** Not all servers will support that, however, so for older versions we must
* manually detect large ints in the JSON string and quote them (thus converting
*them to strings) before decoding, hence
|
php
|
{
"resource": ""
}
|
q264589
|
ApplicationConfigWriter.commit
|
test
|
public function commit()
{
$data = <<<PHP
<?php
/*
* ! WARNING !
*
* This file is auto-generated.
* Please don't modify it by-hand or all your changes can be lost.
*/
{$this->append}
return
PHP;
$data .= VarDumper::export($this->configuration);
$data .=
|
php
|
{
"resource": ""
}
|
q264590
|
Bootstrap.bootstrap
|
test
|
public function bootstrap($app)
{
$app->i18n->translations['extensions-manager'] = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages',
];
DeferredQueueEvent::on(
DeferredController::className(),
DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE,
[DeferredQueueCompleteHandler::className(), 'handleEvent']
);
if ($app instanceof \yii\console\Application) {
$app->controllerMap['extension'] = ExtensionController::className();
$app->on(Application::EVENT_BEFORE_ACTION, function () {
$module = ExtensionsManager::module();
if ($module->autoDiscoverMigrations === true) {
if (isset(Yii::$app->params['yii.migrations']) === false) {
Yii::$app->params['yii.migrations'] = [];
}
/** @var array $extensions */
$extensions = $module->getExtensions();
foreach ($extensions as $name => $ext) {
if ($ext['composer_type'] === Extension::TYPE_DOTPLANT
&& $module->discoverDotPlantMigrations === false
) {
continue;
}
$extData =
|
php
|
{
"resource": ""
}
|
q264591
|
Channelgroup.copy
|
test
|
public function copy($name = null, $tcgid = 0, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
php
|
{
"resource": ""
}
|
q264592
|
Channelgroup.message
|
test
|
public function message($msg)
{
foreach($this as $client)
{
try
{
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::TEXTMSG_CLIENT));
}
|
php
|
{
"resource": ""
}
|
q264593
|
ApiController.formClassName
|
test
|
protected function formClassName(): string
{
if ($this->formClassName)
{
return $this->formClassName;
}
$entityClassName = $this->entityClassName();
|
php
|
{
"resource": ""
}
|
q264594
|
ApiController.getAction
|
test
|
public function getAction(int $id)
{
try {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->entityClassName())->find($id);
if ($entity) {
return $entity;
|
php
|
{
"resource": ""
}
|
q264595
|
ApiController.cgetAction
|
test
|
public function cgetAction(ParamFetcherInterface $paramFetcher)
{
try {
$offset = $paramFetcher->get('offset');
$limit = $paramFetcher->get('limit');
$order_by = $paramFetcher->get('order_by');
$filters = !is_null($paramFetcher->get('filters')) ? $paramFetcher->get('filters') : array();
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository($this->entityClassName())
->findBy($filters, $order_by, $limit, $offset);
if ($entities) {
|
php
|
{
"resource": ""
}
|
q264596
|
ApiController.postAction
|
test
|
public function postAction(Request $request)
{
/**
* @var $em ApiEntityManager
*/
$em = $this->getDoctrine()->getManager();
$data = json_decode($request->getContent(), true);
$entity = $em->createEntity($this->entityClassName());
$form = $this->createForm($this->formClassName(), $entity, [
|
php
|
{
"resource": ""
}
|
q264597
|
ApiController.putAction
|
test
|
public function putAction(Request $request, int $id)
{
try {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->entityClassName())->find($id);
$data = json_decode($request->getContent(), true);
$request->setMethod('PATCH'); //Treat all PUTs as PATCH
$form = $this->createForm($this->formClassName(), $entity, [
"method" => $request->getMethod(),
]);
$form->submit($data);
if ($form->isValid()) {
|
php
|
{
"resource": ""
}
|
q264598
|
ApiController.deleteAction
|
test
|
public function deleteAction(Request $request, int $id)
{
try {
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository($this->entityClassName())->find($id);
$em->remove($entity);
$em->flush();
|
php
|
{
"resource": ""
}
|
q264599
|
JsonDecodeFile.readFile
|
test
|
protected static function readFile($path)
{
// Workaround for https://github.com/kherge-php/file-manager/pull/2
$error = null;
set_error_handler(function ($severity, $message, $filename, $lineno) use (&$error) {
$error = new \ErrorException($message, 0, $severity, $filename, $lineno);
}, E_WARNING);
try {
$file = new File($path, 'r');
} finally {
restore_error_handler();
}
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.