_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q10400
WaitingListRegistrationForm.doRegister
train
public function doRegister($data, WaitingListRegistrationForm $form) { $form->saveInto($registration = WaitingListRegistration::create()); $registration->EventID = $this->getController()->ID; $this->getController()->WaitingList()->add($registration); $this->getController()->redirect($this->getController()->Link('?waitinglist=1')); }
php
{ "resource": "" }
q10401
Database.getInfo
train
public function getInfo(string $key = null) { if ($this->info == null) { $resource = $this->linker->getLink()->getAgent()->getResource(); $resourceType = $resource->getType(); $serverVersion = $clientVersion = null; if ($resourceType == Resource::TYPE_MYSQL_LINK) { $object = $resource->getObject(); foreach (get_class_vars(get_class($object)) as $var => $_) { $this->info[$var] = $object->{$var}; } $serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $object->server_info); $clientVersion = preg_replace('~(?:[a-z]+\s+)?([^ ]+).*~i', '\1', $object->client_info); } elseif ($resourceType == Resource::TYPE_PGSQL_LINK) { $this->info = pg_version($resource->getObject()); $serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['server']); $clientVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['client']); } $this->info['serverVersion'] = $serverVersion; $this->info['clientVersion'] = $clientVersion; } return ($key == null) ? $this->info : $this->info[$key] ?? null; }
php
{ "resource": "" }
q10402
LayoutRow.updateSize
train
protected function updateSize() { $sizeY = abs($this->startY); $sizeX = 0; foreach ($this->elements as $idx => $element) { $sizeY += $element->getHeight() + $this->margin; if (abs($element->getX()) + $element->getWidth() > $sizeX) { $sizeX = abs($element->getX()) + $element->getWidth(); } } $this->setSize($sizeX, $sizeY); }
php
{ "resource": "" }
q10403
LayoutRow.setPosition
train
public function setPosition($x, $y) { $this->posX = $x; $this->posy = $y; return $this; }
php
{ "resource": "" }
q10404
AccountManager.getAccounts
train
public function getAccounts() { //Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups $accounts = array(); $this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts) { array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id)); }); return $accounts; }
php
{ "resource": "" }
q10405
AccountManager.getGroupsAccounts
train
public function getGroupsAccounts() { //Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups $accounts = array(); $this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts) { if($Account->is_group) { array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id)); } }); return $accounts; }
php
{ "resource": "" }
q10406
AccountManager.getAccountsTypes
train
public function getAccountsTypes() { //Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups $accountTypes = array(); $this->AccountType->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($AccountType) use (&$accountTypes) { array_push($accountTypes, array('label'=> $AccountType->name, 'value'=>$AccountType->id)); }); return $accountTypes; }
php
{ "resource": "" }
q10407
Node.accept
train
public function accept(VisitorInterface $visitor): void { $visitor->visitBefore($this); foreach ($this->getChildren() as $node) { $node->accept($visitor); } $visitor->visitAfter($this); }
php
{ "resource": "" }
q10408
Node.getChild
train
public function getChild(string $name): Node { foreach ($this->children as $node) { if (strcasecmp($node->getName(), $name) == 0) { return $node; } } return new NullNode; }
php
{ "resource": "" }
q10409
Node.hasChild
train
public function hasChild(string $name): bool { foreach ($this->children as $node) { if (strcasecmp($node->getName(), $name) == 0) { return true; } } return false; }
php
{ "resource": "" }
q10410
Node.getChildren
train
public function getChildren(string $name = ''): array { $nodes = []; foreach ($this->children as $node) { if (!$name || strcasecmp($node->getName(), $name) == 0) { $nodes[] = $node; } } return $nodes; }
php
{ "resource": "" }
q10411
SettingManager.getCountryAccountsChartsTypes
train
public function getCountryAccountsChartsTypes() { $accountsChartsTypes = array(); $this->AccountChartType->accountsChartsTypesByCountry($this->AuthenticationManager->getCurrentUserOrganizationCountry())->each(function($AccountChartType) use(&$accountsChartsTypes) { $name = $this->Lang->has($AccountChartType->lang_key) ? $this->Lang->get($AccountChartType->lang_key) : $AccountChartType->name; array_push($accountsChartsTypes, array('id' => $AccountChartType->id, 'name' => $name, 'url' => $AccountChartType->url)); }); return $accountsChartsTypes; }
php
{ "resource": "" }
q10412
SettingManager.getSystemCurrencies
train
public function getSystemCurrencies() { $currencies = array(); $this->Currency->all()->each(function($Currency) use (&$currencies) { array_push($currencies, array('label'=> $Currency->name . ' (' . $Currency->symbol . ')', 'value'=>$Currency->id)); }); return $currencies; }
php
{ "resource": "" }
q10413
SettingManager.getSettingJournals
train
public function getSettingJournals() { return $this->JournalManager->getJournalsByApp(array('appId' => 'acct-initial-acounting-setup', 'page' => 1, 'journalizedId' => $this->Setting->byOrganization($this->AuthenticationManager->getCurrentUserOrganization('id'))->first()->id, 'filter' => null, 'userId' => null, 'onlyActions' => false), true); }
php
{ "resource": "" }
q10414
Model.initModelProperties
train
private static function initModelProperties() { $currentModel = static::class; if (isset(self::$modelProperties[$currentModel])) { return; } $properties = [ 'connection' => ConnectionFactory::build(static::$connection), 'dateFields' => static::$dates ?: [], 'fields' => static::$fields ?: [], 'primaryKeys' => (array) static::$primaryKey, 'table' => static::$table, 'timestamps' => (bool) static::$timestamps, ]; if ($properties['timestamps']) { $properties['fields'][] = 'created_at'; $properties['fields'][] = 'updated_at'; $properties['dateFields'][] = 'created_at'; $properties['dateFields'][] = 'updated_at'; } self::$modelProperties[$currentModel] = $properties; }
php
{ "resource": "" }
q10415
Model.exists
train
public function exists() : bool { $query = static::createQuery(); $pks = static::getPrimaryKeys(); $pkValues = $this->getPrimaryKeyValues(); if (count($pks) != count($pkValues)) { return false; } $filterFunction = function (WhereClause $whereClause) use (&$pkValues, $query) { foreach ($pkValues as $field => $value) { $whereClause->and($field, '=', '?'); $query->bind($value); } }; $query->where($filterFunction) ->count('*'); $row = $query->execute()->fetch(); return $row['all_count'] > 0; }
php
{ "resource": "" }
q10416
Model.insert
train
public function insert() : Result { $result = self::getConnection()->insert($this); /* * In a successful insert operation, assign the new id to * current model. */ if ($result->count()) { $pks = static::getPrimaryKeys(); if (count($pks) == 1) { $this->data[$pks[0]] = static::getConnection()->lastId(); } } return $result; }
php
{ "resource": "" }
q10417
MelisModuleManager.sanitize
train
public static function sanitize($input, $skip = [], $textOnly = false, $removeFunctions = true) { if (!is_array($input)) { if (true === $removeFunctions) { $input = preg_replace('/[a-zA-Z][a-zA-Z0-9_]+(\()+([a-zA-Z0-9_\-$,\s\"]?)+(\))(\;?)/', '', $input); } $invalidValues = ['exec', '\\', '&amp;', '&#', '0x', '<script>', '</script>', '">', "'>"]; $allowableTags = '<p><br><img><label><input><textarea><div><span><a><strong><i><u>'; $input = str_replace($invalidValues, '', $input); $input = preg_replace('/%[a-zA-Z0-9]{2}/', '', $input); $input = strip_tags(trim($input), $allowableTags); if ($textOnly) { $input = str_replace(['<', '>', "'", '"'], '', $input); } return $input; } else { $array = []; foreach ($input as $key => $item) { if (in_array($key, $skip)) { $array[$key] = $item; } else { if (!is_array($item)) { $array[$key] = self::sanitize($item, $skip, $textOnly, $removeFunctions); } else { $array = array_merge($array, [$key => self::sanitize($item, $skip, $textOnly, $removeFunctions)]); } } } return $array; } }
php
{ "resource": "" }
q10418
XmlDualList.setDataSource
train
public function setDataSource($listLeft, $listRight = null) { $this->_listLeftDataSource = $listLeft; $this->_listRightDataSource = $listRight; }
php
{ "resource": "" }
q10419
XmlDualList.createDefaultButtons
train
public function createDefaultButtons() { $this->setButtonOneLeft(new DualListButton("&#60;--", DualListButtonType::Button)); $this->setButtonAllLeft(new DualListButton("&#60;&#60;&#60;", DualListButtonType::Button)); $this->setButtonOneRight(new DualListButton("--&#62;", DualListButtonType::Button)); $this->setButtonAllRight(new DualListButton("&#62;&#62;&#62;", DualListButtonType::Button)); }
php
{ "resource": "" }
q10420
XmlDualList.Parse
train
public static function Parse($context, $duallistaname) { $val = $context->get($duallistaname); if ($val != "") { return explode(",", $val); } else { return array(); } }
php
{ "resource": "" }
q10421
XmlDualList.buildListItens
train
private function buildListItens($list, $arr) { foreach ($arr as $key=>$value) { $item = XmlUtil::CreateChild($list, "item", ""); XmlUtil::AddAttribute($item, "id", $key); XmlUtil::AddAttribute($item, "text", $value); } }
php
{ "resource": "" }
q10422
XmlDualList.makeButton
train
private function makeButton($button, $name, $duallist, $from, $to, $all) { $newbutton = XmlUtil::CreateChild($duallist, "button", ""); XmlUtil::AddAttribute($newbutton, "name", $name); if ($button->type == DualListButtonType::Image ) { XmlUtil::AddAttribute($newbutton, "type", "image"); XmlUtil::AddAttribute($newbutton, "src", $button->href); XmlUtil::AddAttribute($newbutton, "value", $button->text); }else { XmlUtil::AddAttribute($newbutton, "type", "button"); XmlUtil::AddAttribute($newbutton, "value", $button->text); } XmlUtil::AddAttribute($newbutton, "from", $from); XmlUtil::AddAttribute($newbutton, "to", $to); XmlUtil::AddAttribute($newbutton, "all", $all); }
php
{ "resource": "" }
q10423
Collection.delete
train
function delete($key) { $this->data[$key] = null; unset($this->data[$key]); return $this; }
php
{ "resource": "" }
q10424
Collection.chunk
train
function chunk(int $numitems, bool $preserve_keys = false) { return (new self(\array_chunk($this->data, $numitems, $preserve_keys))); }
php
{ "resource": "" }
q10425
Collection.diff
train
function diff($arr) { if($arr instanceof self) { $arr = $arr->all(); } return (new self(\array_diff($this->data, $arr))); }
php
{ "resource": "" }
q10426
Collection.diffKeys
train
function diffKeys($arr) { if($arr instanceof self) { $arr = $arr->all(); } return (new self(\array_diff_key($this->data, $arr))); }
php
{ "resource": "" }
q10427
Collection.each
train
function each(callable $closure) { foreach($this->data as $key => $val) { $feed = $closure($val, $key); if($feed === false) { break; } } return $this; }
php
{ "resource": "" }
q10428
Collection.filter
train
function filter(callable $closure) { $new = array(); foreach($this->data as $key => $val) { $feed = (bool) $closure($val, $key); if($feed) { $new[$key] = $val; } } return (new self($new)); }
php
{ "resource": "" }
q10429
Collection.first
train
function first(callable $closure = null) { if($closure === null) { if(empty($this->data)) { return null; } $keys = \array_keys($this->data); return ($this->data[$keys[0]] ?? null); } foreach($this->data as $key => $val) { $feed = (bool) $closure($val, $key); if($feed) { return $val; } } return null; }
php
{ "resource": "" }
q10430
Collection.flatten
train
function flatten(int $depth = 0) { $data = $this->flattenDo($this->data, $depth); return (new self($data)); }
php
{ "resource": "" }
q10431
Collection.groupBy
train
function groupBy($column) { if($column === null || $column === '') { return $this; } $new = array(); foreach($this->data as $key => $val) { if(\is_callable($column)) { $key = $column($val, $key); } elseif(\is_array($val)) { $key = $val[$column]; } elseif(\is_object($val)) { $key = $val->$column; } $new[$key][] = $val; } return (new self($new)); }
php
{ "resource": "" }
q10432
Collection.implode
train
function implode($col, string $glue = ', ') { $data = ''; foreach($this->data as $key => $val) { if(\is_array($val)) { if(!isset($val[$col])) { throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on array'); } $data .= $glue.$val[$col]; } elseif(\is_object($val)) { if(!isset($val->$col)) { throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on object'); } $data .= $glue.$val->$col; } else { $data .= $glue.$val; } } return \substr($data, \strlen($glue)); }
php
{ "resource": "" }
q10433
Collection.indexOf
train
function indexOf($value) { $i = 0; foreach($this->data as $val) { if($val === $value) { return $i; } $i++; } return null; }
php
{ "resource": "" }
q10434
Collection.intersect
train
function intersect($arr) { if($arr instanceof self) { $arr = $arr->all(); } return (new self(\array_intersect($this->data, $arr))); }
php
{ "resource": "" }
q10435
Collection.last
train
function last(callable $closure = null) { if($closure === null) { if(empty($this->data)) { return null; } $keys = \array_keys($this->data); return $this->data[$keys[(\count($keys) - 1)]]; } $data = null; foreach($this->data as $key => $val) { $feed = $closure($val, $key); if($feed) { $data = $val; } } return $data; }
php
{ "resource": "" }
q10436
Collection.map
train
function map(callable $closure) { $keys = \array_keys($this->data); $items = \array_map($closure, $this->data, $keys); return (new self(\array_combine($keys, $items))); }
php
{ "resource": "" }
q10437
Collection.max
train
function max($key = null) { if($key !== null) { $data = \array_column($this->data, $key); } else { $data = $this->data; } return \max($data); }
php
{ "resource": "" }
q10438
Collection.min
train
function min($key = null) { if($key !== null) { $data = \array_column($this->data, $key); } else { $data = $this->data; } return \min($data); }
php
{ "resource": "" }
q10439
Collection.merge
train
function merge(\CharlotteDunois\Collect\Collection $collection) { return (new self(\array_merge($this->data, $collection->all()))); }
php
{ "resource": "" }
q10440
Collection.nth
train
function nth(int $nth, int $offset = 0) { if($nth <= 0) { throw new \InvalidArgumentException('nth must be a non-zero positive integer'); } $new = array(); $size = \count($this->data); for($i = $offset; $i < $size; $i += $nth) { $new[] = $this->data[$i]; } return (new self($new)); }
php
{ "resource": "" }
q10441
Collection.only
train
function only(array $keys) { $new = array(); foreach($this->data as $key => $val) { if(\in_array($key, $keys, true)) { $new[$key] = $val; } } return (new self($new)); }
php
{ "resource": "" }
q10442
Collection.partition
train
function partition(callable $closure) { $collection1 = new self(); $collection2 = new self(); foreach($this->data as $key => $val) { if($closure($val, $key)) { $collection1->set($key, $val); } else { $collection2->set($key, $val); } } return array($collection1, $collection2); }
php
{ "resource": "" }
q10443
Collection.pluck
train
function pluck($key, $index = null) { $data = array(); $i = 0; foreach($this->data as $v) { $k = ($index ? (\is_array($v) ? (\array_key_exists($index, $v) ? $v[$index] : $i) : (\is_object($v) ? (\property_exists($v, $index) ? $v->$index : $i) : $i)) : $i); if(\is_array($v) && \array_key_exists($key, $v)) { $data[$k] = $v[$key]; } elseif(\is_object($v) && \property_exists($v, $key)) { $data[$k] = $v->$key; } $i++; } return (new self($data)); }
php
{ "resource": "" }
q10444
Collection.random
train
function random(int $num = 1) { $rand = \array_rand($this->data, $num); if(!\is_array($rand)) { $rand = array($rand); } $col = new self(); foreach($rand as $key) { $col->set($key, $this->data[$key]); } return $col; }
php
{ "resource": "" }
q10445
Collection.reduce
train
function reduce(callable $closure, $carry = null) { foreach($this->data as $val) { $carry = $closure($carry, $val); } return $carry; }
php
{ "resource": "" }
q10446
Collection.search
train
function search($needle, bool $strict = true) { return \array_search($needle, $this->data, $strict); }
php
{ "resource": "" }
q10447
Collection.slice
train
function slice(int $offset, int $limit = null, bool $preserve_keys = false) { $data = $this->data; return (new self(\array_slice($data, $offset, $limit, $preserve_keys))); }
php
{ "resource": "" }
q10448
Collection.some
train
function some(callable $closure) { foreach($this->data as $key => $val) { if($closure($val, $key)) { return true; } } return false; }
php
{ "resource": "" }
q10449
Collection.sort
train
function sort(bool $descending = false, int $options = \SORT_REGULAR) { $data = $this->data; if($descending) { \arsort($data, $options); } else { \asort($data, $options); } return (new self($data)); }
php
{ "resource": "" }
q10450
Collection.sortKey
train
function sortKey(bool $descending = false, int $options = \SORT_REGULAR) { $data = $this->data; if($descending) { \krsort($data, $options); } else { \ksort($data, $options); } return (new self($data)); }
php
{ "resource": "" }
q10451
Collection.sortCustom
train
function sortCustom(callable $closure) { $data = $this->data; \uasort($data, $closure); return (new self($data)); }
php
{ "resource": "" }
q10452
Collection.sortCustomKey
train
function sortCustomKey(callable $closure) { $data = $this->data; \uksort($data, $closure); return (new self($data)); }
php
{ "resource": "" }
q10453
Collection.unique
train
function unique($key, $options = \SORT_REGULAR) { if($key === null) { return (new self(\array_unique($this->data, $options))); } $exists = array(); return $this->filter(function ($item) use ($key, &$exists) { if(\is_array($item)) { if(!isset($item[$key])) { throw new \BadMethodCallException('Specified key "'.$key.'" does not exist on array'); } $id = $item[$key]; } elseif(\is_object($item)) { if(!isset($item->$key)) { throw new \BadMethodCallException('Specified key "'.$key.'" does not exist on object'); } $id = $item->$key; } else { $id = $item; } if(\in_array($id, $exists, true)) { return false; } $exists[] = $id; return true; }); }
php
{ "resource": "" }
q10454
File.resolveClass
train
public function resolveClass(FoundClass $found) { Logger::trace("Resolving class %s", $found->name); if ($found->name[0] === '\\') { return new Classname($found->name); } $classParts = explode('\\', $found->name); if (count($classParts) >= 2) { $b = array_shift($classParts); $baseClass = $this->originalUse->get($b); if ($baseClass) { return new Classname($baseClass . '\\' . implode('\\', $classParts)); } } if ($c = $this->originalUse->get($found->name)) { Logger::trace("Found a use statement for class"); Logger::trace("Resolved to %s", $c); return $c; } else { $class = Classname::build($this->getOriginalNamespace(), $found->name); Logger::trace("Resolved to %s", $class->classname); return $class; } }
php
{ "resource": "" }
q10455
File.shortenClasses
train
public function shortenClasses($classesToFix, Configuration $config) { $cumulativeOffset = 0; /** @var FoundClass $c */ foreach ($classesToFix as $c) { $replacement = []; if (in_array($c->name, $this->ignoredClassNames)) { if ($c->name == $this->originalClassname) { $replacement = [[T_STATIC, "static", 2]]; } else { continue; } } if (!$replacement) { $resolvedClass = $this->resolveClass($c); $alias = $config->replace($this->originalUse->getAliasForClassname($resolvedClass)); Logger::trace("Resolved class %s to %s", array($resolvedClass->classname, $alias)); $replacement = array(array(308, $alias, 2)); } $offset = $c->from; $length = $c->to - $c->from + 1; array_splice($this->tokens, $offset + $cumulativeOffset, $length, $replacement); $cumulativeOffset -= $length - 1; } }
php
{ "resource": "" }
q10456
File.getSrc
train
public function getSrc() { $content = ""; foreach ($this->tokens as $token) { $content .= is_string($token) ? $token : $token[1];; } return $content; }
php
{ "resource": "" }
q10457
File.save
train
public function save($directory) { $parts = explode('_', $this->getClass()); array_unshift($parts, $directory); $path = join(DIRECTORY_SEPARATOR, $parts) . '.php'; self::saveToFile($path, $this->getSrc()); }
php
{ "resource": "" }
q10458
File.saveToFile
train
private static function saveToFile($path, $contents) { $directory = pathinfo($path, PATHINFO_DIRNAME); if (!file_exists($directory)) { mkdir($directory, 0777, true); } file_put_contents($path, $contents); }
php
{ "resource": "" }
q10459
HookReciever.saveLastProcessedVersion
train
public function saveLastProcessedVersion($version) { $this->lastProcessedVersion = $version; $this->myCreateColumn = null; $this->deleteFromSQL(['serverurl' => constant('FLEXIBEE_URL')]); if (is_null($this->insertToSQL(['serverurl' => constant('FLEXIBEE_URL'), 'changeid' => $version]))) { $this->addStatusMessage(_("Last Processed Change ID Saving Failed"), 'error'); } else { if ($this->debug === true) { $this->addStatusMessage(sprintf(_('Last Processed Change ID #%s Saved'), $version)); } } }
php
{ "resource": "" }
q10460
SyncPlugin.putFile
train
private function putFile(MountManager $mountManager, string $from, string $to, array $config): bool { $this->logger->debug("Copying file $from to $to"); list($prefixFrom, $from) = $mountManager->getPrefixAndPath($from); $buffer = $mountManager->getFilesystem($prefixFrom)->readStream($from); if ($buffer === false) { return false; } list($prefixTo, $to) = $mountManager->getPrefixAndPath($to); $result = $mountManager->getFilesystem($prefixTo)->putStream($to, $buffer, $config); if (is_resource($buffer)) { fclose($buffer); } return $result; }
php
{ "resource": "" }
q10461
IdGenerator.generateSessionId
train
public static function generateSessionId($length = 40) { if ($length < 1) { throw new \InvalidArgumentException('Length should be >= 1'); } $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; $numChars = 36; $bytes = random_bytes($length); $pos = 0; $result = ''; for ($i = 0; $i < $length; $i++) { $pos = ($pos + ord($bytes[$i])) % $numChars; $result .= $chars[$pos]; } return $result; }
php
{ "resource": "" }
q10462
PlayerFactory.createPlayer
train
public function createPlayer(PlayerInfo $playerInfo, PlayerDetailedInfo $playerDetailedInfo) { $class = $this->class; $player = new $class(); $player->merge($playerInfo); $player->merge($playerDetailedInfo); return $player; }
php
{ "resource": "" }
q10463
TwoDimensionalPoint.getRenderData
train
public function getRenderData( $useLabel = false ) { if ( ( $this->jsWriter->getType( $this->series->getTitle() ) instanceof \Altamira\Type\Flot\Donut ) ) { $value = array( 1, $this['y'] ); } else { $value = array($this['x'], $this['y']); if ( $useLabel ) { $value[] = $this->getLabel(); } } return $value; }
php
{ "resource": "" }
q10464
DlstatsHelper.checkIP
train
public function checkIP($UserIP = false) { // Check if IP present if ($UserIP === false) { $tempIP = $this->dlstatsGetUserIP(); if ($tempIP !== false) { $this->IP = $tempIP; } else { return false; // No IP, no search. } } else { $this->IP = $UserIP; } // IPv4 or IPv6 ? switch ($this->checkIPVersion($this->IP)) { case "IPv4": if ($this->checkIPv4($this->IP) === true) { $this->IP_Filter = true; return $this->IP_Filter; } break; case "IPv6": if ($this->checkIPv6($this->IP) === true) { $this->IP_Filter = true; return $this->IP_Filter; } break; default: $this->IP_Filter = false; return $this->IP_Filter; break; } $this->IP_Filter = false; return $this->IP_Filter; }
php
{ "resource": "" }
q10465
DlstatsHelper.checkIPVersion
train
protected function checkIPVersion($UserIP = false) { // Test for IPv4 if (ip2long($UserIP) !== false) { $this->IP_Version = "IPv4"; return $this->IP_Version; } // Test for IPv6 if (substr_count($UserIP, ":") < 2) { $this->IP_Version = false; return false; } // ::1 or 2001::0db8 if (substr_count($UserIP, "::") > 1) { $this->IP_Version = false; return false; // one allowed } $groups = explode(':', $UserIP); $num_groups = count($groups); if (($num_groups > 8) || ($num_groups < 3)) { $this->IP_Version = false; return false; } $empty_groups = 0; foreach ($groups as $group) { $group = trim($group); if (! empty($group) && ! (is_numeric($group) && ($group == 0))) { if (! preg_match('#([a-fA-F0-9]{0,4})#', $group)) { $this->IP_Version = false; return false; } } else { ++ $empty_groups; } } if ($empty_groups < $num_groups) { $this->IP_Version = "IPv6"; return $this->IP_Version; } $this->IP_Version = false; return false; // no (valid) IP Address }
php
{ "resource": "" }
q10466
DlstatsHelper.checkIPv6
train
protected function checkIPv6($UserIP = false) { // Check if IP present if ($UserIP === false) { return false; // No IP, no search. } // search for user bot IP-filter definitions in localconfig.php if (isset($GLOBALS['DLSTATS']['BOT_IPV6'])) { foreach ($GLOBALS['DLSTATS']['BOT_IPV6'] as $lineleft) { $network = explode("/", trim($lineleft)); if (! isset($network[1])) { $network[1] = 128; } if ($this->dlstatsIPv6InNetwork($UserIP, $network[0], $network[1])) { return true; // IP found } } } return false; }
php
{ "resource": "" }
q10467
DlstatsHelper.checkIPv4
train
protected function checkIPv4($UserIP = false) { // Check if IP present if ($UserIP === false) { return false; // No IP, no search. } // search for user bot IP-filter definitions in localconfig.php if (isset($GLOBALS['DLSTATS']['BOT_IPV4'])) { foreach ($GLOBALS['DLSTATS']['BOT_IPV4'] as $lineleft) { $network = explode("/", trim($lineleft)); if (! isset($network[1])) { $network[1] = 32; } if ($this->dlstatsIPv4InNetwork($UserIP, $network[0], $network[1])) { return true; // IP found } } } return false; }
php
{ "resource": "" }
q10468
DlstatsHelper.dlstatsAnonymizeDomain
train
protected function dlstatsAnonymizeDomain() { if ($this->IP_Version === false || $this->IP === '0.0.0.0') { return ''; } if (isset($GLOBALS['TL_CONFIG']['privacyAnonymizeIp']) && (bool) $GLOBALS['TL_CONFIG']['privacyAnonymizeIp'] === false) { // Anonymize is disabled $domain = gethostbyaddr($this->IP); return ($domain == $this->IP) ? '' : $domain; } // Anonymize is enabled $domain = gethostbyaddr($this->IP); if ($domain != $this->IP) // bei Fehler/keiner Aufloesung kommt IP zurueck { $arrURL = explode('.', $domain); $tld = array_pop($arrURL); $host = array_pop($arrURL); return (strlen($host)) ? $host . '.' . $tld : $tld; } else { return ''; } }
php
{ "resource": "" }
q10469
TextListConfig.add
train
public function add($element) { $currentValue = $this->getRawValue(); if (!in_array($element, $currentValue)) { $currentValue[] = $element; $this->setRawValue($currentValue); } return $this; }
php
{ "resource": "" }
q10470
TextListConfig.remove
train
public function remove($element) { $currentValue = $this->getRawValue(); if (($key = array_search($element, $currentValue)) !== false) { unset($currentValue[$key]); $this->setRawValue($currentValue); } }
php
{ "resource": "" }
q10471
JqPlot.useCursor
train
public function useCursor() { $this->files = array_merge_recursive( array( 'jqplot.cursor.js' ), $this->files ); $this->setNestedOptVal( $this->options, 'cursor', 'show', true ); $this->setNestedOptVal( $this->options, 'cursor', 'showTooltip', true ); return $this; }
php
{ "resource": "" }
q10472
JqPlot.setAxisOptions
train
public function setAxisOptions($axis, $name, $value) { if(strtolower($axis) === 'x' || strtolower($axis) === 'y') { $axis = strtolower($axis) . 'axis'; if ( in_array( $name, array( 'min', 'max', 'numberTicks', 'tickInterval', 'numberTicks' ) ) ) { $this->setNestedOptVal( $this->options, 'axes', $axis, $name, $value ); } elseif( in_array( $name, array( 'showGridline', 'formatString' ) ) ) { $this->setNestedOptVal( $this->options, 'axes', $axis, 'tickOptions', $name, $value ); } } return $this; }
php
{ "resource": "" }
q10473
JqPlot.setType
train
public function setType( $type, $options = array(), $series = 'default' ) { parent::setType( $type, $options, $series ); if ( $series == 'default' ) { $rendererOptions = $this->types['default']->getRendererOptions(); if ( $renderer = $this->types['default']->getRenderer() ) { $this->options['seriesDefaults']['renderer'] = $renderer; } if (! empty( $rendererOptions ) ) { $this->options['seriesDefaults']['rendererOptions'] = $rendererOptions; } } return $this; }
php
{ "resource": "" }
q10474
JqPlot.getOptionsJS
train
protected function getOptionsJS() { $opts = $this->options; foreach ( $opts['seriesStorage'] as $label => $options ) { $options['label'] = $label; $opts['series'][] = $options; } if ( $this->chart->titleHidden() ) { unset( $opts['title'] ); } unset($opts['seriesStorage']); return $this->makeJSArray( $opts ); }
php
{ "resource": "" }
q10475
JqPlot.setSeriesLabelSetting
train
public function setSeriesLabelSetting( $series, $name, $value ) { if ( ( $name === 'location' && in_array( $value, array( 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw' ) ) ) ||( in_array( $name, array( 'xpadding', 'ypadding', 'edgeTolerance', 'stackValue' ) ) ) ) { return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'pointLabels', $name, $value ); } return $this; }
php
{ "resource": "" }
q10476
TitleRenderer.preRender
train
public static function preRender( \Altamira\Chart $chart, array $styleOptions = array() ) { if ( $chart->titleHidden() ) { return ''; } $tagType = isset( $styleOptions['titleTag'] ) ? $styleOptions['titleTag'] : 'h3'; $title = $chart->getTitle(); $output = <<<ENDDIV <div class="altamira-chart-title"> <{$tagType}>{$title}</{$tagType}> ENDDIV; return $output; }
php
{ "resource": "" }
q10477
AdminGroups.getUserGroups
train
public function getUserGroups() { $groups = []; foreach ($this->adminGroupConfiguration->getGroups() as $groupName) { $groups[] = $this->getUserGroup("$groupName"); } $groups[] = $this->getUserGroup('guest'); return $groups; }
php
{ "resource": "" }
q10478
AdminGroups.getLoginUserGroups
train
public function getLoginUserGroups($login) { $groupName = $this->adminGroupConfiguration->getLoginGroupName($login); if (empty($groupName)) { $groupName = 'guest'; } return $this->getUserGroup("$groupName"); }
php
{ "resource": "" }
q10479
AdminGroups.hasPermission
train
public function hasPermission($recipient, $permission) { if ($recipient instanceof Group) { $check = true; foreach ($recipient->getLogins() as $login) { if ($this->hasLoginPermission($login, $permission) === false) { $check = false; } } return $check; } else { return $this->hasLoginPermission($recipient, $permission); } }
php
{ "resource": "" }
q10480
AdminGroups.hasGroupPermission
train
public function hasGroupPermission($groupName, $permission) { if (strpos($groupName, 'admin:') === 0) { $groupName = str_replace("admin:", '', $groupName); } $logins = $this->adminGroupConfiguration->getGroupLogins($groupName); if (!empty($logins)) { return $this->hasPermission($logins[0], $permission); } // If guest group is unknow it has no permissions. if ($groupName == 'guest' && is_null($logins)) { return false; } if (is_null($logins)) { throw new UnknownGroupException("'$groupName' admin group does not exist."); } return false; }
php
{ "resource": "" }
q10481
EmbedViewHelper.render
train
public function render($uri, $maxWidth = 0, $maxHeight = 0, $objectName = null) { $consumer = new Consumer(); $this->prepareRequestParameters($maxWidth, $maxHeight, $consumer); $resourceObject = $consumer->consume($uri); if ($resourceObject !== null) { if ($objectName !== null) { if ($this->templateVariableContainer->exists($objectName)) { throw new Exception('Object name for EmbedViewHelper given as: ' . htmlentities($objectName) . '. This variable name is already in use, choose another.', 1359969229); } $this->templateVariableContainer->add($objectName, $resourceObject); $html = $this->renderChildren(); $this->templateVariableContainer->remove($objectName); } else { $html = $resourceObject->getAsString(); } } else { $html = 'Invalid oEmbed Resource'; } return $html; }
php
{ "resource": "" }
q10482
ActiveRecord.removeAll
train
public final function removeAll($whereParams): int { $whereParams = [$whereParams]; if ($whereParams[0] === null || $whereParams[0] === '') { throw new InvalidValueException('You need to pass a parameter for delete action!'); } $return = $this->db->getLink()->getAgent() ->deleteAll($this->table, "{$this->tablePrimary} IN(?)", $whereParams); if (method_exists($this, 'onRemove')) { $this->onRemove($return); } return $return; }
php
{ "resource": "" }
q10483
ThriftyFileSession.end
train
public function end() { if ($this->isStarted()) { if (is_callable($this->getCleanupCallback())) { call_user_func($this->getCleanupCallback()); } session_write_close(); } return $this; }
php
{ "resource": "" }
q10484
ThriftyFileSession.setCleanupCallback
train
public function setCleanupCallback($callback) { if (!is_null($callback) && !is_callable($callback) ) { throw new InvalidArgumentException("No callable function provided"); } $this->cleanupCallback = $callback; return $this; }
php
{ "resource": "" }
q10485
ThriftyFileSession.setCookieLifetime
train
public function setCookieLifetime($ttl) { if (!is_null($ttl) && !is_numeric($ttl) ) { throw new InvalidArgumentException("No valid ttl provided"); } $this->cookieLifetime = (int)$ttl; return $this; }
php
{ "resource": "" }
q10486
ID.fixSforceId
train
public static function fixSforceId($shortId) { $shortId = (string)$shortId; if (strlen($shortId) !== 15) { return new self($shortId); } $suffix = ''; for ($i = 0; $i < 3; $i++) { $flags = 0; for ($j = 0; $j < 5; $j++) { $c = substr($shortId, $i * 5 + $j, 1); if (false !== strpos('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $c)) { $flags += (1 << $j); } } if ($flags <= 25) { $suffix .= substr('ABCDEFGHIJKLMNOPQRSTUVWXYZ', $flags, 1); } else { $suffix .= substr('012345', $flags - 26, 1); } } return new self($shortId . $suffix); }
php
{ "resource": "" }
q10487
Entity.getRoot
train
public function getRoot() { $tmp_parent = $this->getParent(); $root = $tmp_parent; while ($tmp_parent) { $root = $tmp_parent; $tmp_parent = $tmp_parent->getParent(); } return $root; }
php
{ "resource": "" }
q10488
Entity.setValue
train
public function setValue($attribute_name, $attribute_value) { $value_holder = $this->getValueHolderFor($attribute_name); $this->validation_results->setItem( $attribute_name, $value_holder->setValue($attribute_value, $this) ); return $this->isValid(); }
php
{ "resource": "" }
q10489
Entity.setValues
train
public function setValues(array $values) { foreach ($this->type->getAttributes()->getKeys() as $attribute_name) { if (array_key_exists($attribute_name, $values)) { $this->setValue($attribute_name, $values[$attribute_name]); } } return $this->isValid(); }
php
{ "resource": "" }
q10490
Entity.toArray
train
public function toArray() { $attribute_values = [ self::OBJECT_TYPE => $this->getType()->getPrefix() ]; foreach ($this->value_holder_map as $attribute_name => $value_holder) { $attribute_value = $value_holder->getValue(); if (is_object($attribute_value) && is_callable([ $attribute_value, 'toArray' ])) { $attribute_values[$attribute_name] = $attribute_value->toArray(); } else { $attribute_values[$attribute_name] = $value_holder->toNative(); } } return $attribute_values; }
php
{ "resource": "" }
q10491
Entity.isEqualTo
train
public function isEqualTo(EntityInterface $entity) { if ($entity->getType() !== $this->getType()) { return false; } if ($this->getType()->getAttributes()->getSize() !== $this->value_holder_map->getSize()) { return false; } foreach ($this->getType()->getAttributes()->getKeys() as $attribute_name) { $value_holder = $this->value_holder_map->getItem($attribute_name); if (!$value_holder->sameValueAs($entity->getValue($attribute_name))) { return false; } } return true; }
php
{ "resource": "" }
q10492
Entity.addEntityChangedListener
train
public function addEntityChangedListener(EntityChangedListenerInterface $listener) { if (!$this->listeners->hasItem($listener)) { $this->listeners->push($listener); } }
php
{ "resource": "" }
q10493
Entity.removeEntityChangedListener
train
public function removeEntityChangedListener(EntityChangedListenerInterface $listener) { if ($this->listeners->hasItem($listener)) { $this->listeners->removeItem($listener); } }
php
{ "resource": "" }
q10494
Entity.onValueChanged
train
public function onValueChanged(ValueChangedEvent $event) { // @todo Possible optimization: only track events for EmbedRoot entities, // what will save some memory when dealing with deeply nested embed structures. $this->changes->push($event); $this->propagateEntityChangedEvent($event); }
php
{ "resource": "" }
q10495
Entity.collateChildren
train
public function collateChildren(Closure $criteria, $recursive = true) { $entity_map = new EntityMap; $nested_attribute_types = [ EmbeddedEntityListAttribute::CLASS, EntityReferenceListAttribute::CLASS ]; foreach ($this->getType()->getAttributes([], $nested_attribute_types) as $attribute) { foreach ($this->getValue($attribute->getName()) as $child_entity) { if ($criteria($child_entity)) { $entity_map->setItem($child_entity->asEmbedPath(), $child_entity); } if ($recursive) { $entity_map->append($child_entity->collateChildren($criteria)); } } } return $entity_map; }
php
{ "resource": "" }
q10496
WindowHelpFactory.getChatCommands
train
protected function getChatCommands(ManialinkInterface $manialink) { $login = $manialink->getUserGroup()->getLogins()[0]; return array_map( function ($command) { /** @var AbstractChatCommand $command */ return [ 'command' => $command->getCommand(), 'description' => $command->getDescription(), 'help' => $command->getHelp(), 'aliases' => $command->getAliases(), ]; }, array_filter( $this->chatCommands->getChatCommands(), function ($command) use ($login) { if ($command instanceof AbstractAdminChatCommand) { return $command->hasPermission($login); } return true; } ) ); }
php
{ "resource": "" }
q10497
WindowHelpFactory.callbackCallCommand
train
public function callbackCallCommand(ManialinkInterface $manialink, $login, $params, $arguments) { $this->chatCommandDataProvider->onPlayerChat(-1, $login, '/'.$arguments['command'], true); }
php
{ "resource": "" }
q10498
WindowHelpFactory.callbackDescription
train
public function callbackDescription(ManialinkInterface $manialink, $login, $params, $arguments) { $chatCommands = $this->chatCommands->getChatCommands(); $this->windowHelpDetailsFactory->setCurrentCommand($chatCommands[$arguments['command']]); $this->windowHelpDetailsFactory->create($login); }
php
{ "resource": "" }
q10499
ErrorObject.addError
train
public function addError(string $msg, string ...$args): void { $this->errors[] = sprintf($msg, ...$args); }
php
{ "resource": "" }