_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q4100
LdapHydrator.hydrateCollection
train
public static function hydrateCollection(array $ldaps) { $hydrated = []; foreach ($ldaps as $ldap) { $hydrated[] = self::hydrate($ldap); } return $hydrated; }
php
{ "resource": "" }
q4101
LdapHydrator.hydrate
train
public static function hydrate(stdClass $ldap) { $hydrated = new LdapEntity(); if (isset($ldap->id)) { $hydrated->setId($ldap->id); } if (isset($ldap->enabled)) { $hydrated->setEnabled($ldap->enabled); } if (isset($ldap->search_dn)) { $hydrated->setSearchDn($ldap->search_dn); } if (isset($ldap->search_password)) { $hydrated->setSearchPassword($ldap->search_password); } if (isset($ldap->search_query)) { $hydrated->setSearchQuery($ldap->search_query); } if (isset($ldap->base_dn)) { $hydrated->setBaseDn($ldap->base_dn); } if (isset($ldap->email_key)) { $hydrated->setEmailKey($ldap->email_key); } if (isset($ldap->user_dn)) { $hydrated->setUserDn($ldap->user_dn); } if (isset($ldap->host)) { $hydrated->setHost($ldap->host); } if (isset($ldap->port)) { $hydrated->setPort($ldap->port); } if (isset($ldap->encryption)) { $hydrated->setEncryption($ldap->encryption); } if (isset($ldap->protocol_version)) { $hydrated->setProtocolVersion($ldap->protocol_version); } if (isset($ldap->expired_accounts)) { $hydrated->setExpiredAccounts($ldap->expired_accounts); } if (isset($ldap->last_sync_at)) { $hydrated->setLastSyncAt(new DateTime($ldap->last_sync_at)); } return $hydrated; }
php
{ "resource": "" }
q4102
LocalDriver.getData
train
public function getData(string $table, $name = ""){ $file = $this->base . '/' . $table . '.json'; if(file_exists($file)){ return json_decode(file_get_contents($file), true); }else{ throw new \NonDB\Exceptions\DriverException('Table Not Exists.', 1002); } }
php
{ "resource": "" }
q4103
LocalDriver.setData
train
public function setData(string $table, $data){ $file = $this->base . '/' . $table . '.json'; if(file_exists($file)){ if(file_put_contents($file, json_encode($data))){ $status = true; }else{ $status = false; } return new \NonDB\Components\Status($status); }else{ throw new \NonDB\Exceptions\DriverException('Table Not Exists.', 1002); } }
php
{ "resource": "" }
q4104
LocalDriver.newTable
train
public function newTable(string $name){ $status = file_put_contents($file = $this->base . '/' . $name . '.json', "[]"); return new \NonDB\Components\Status($status); }
php
{ "resource": "" }
q4105
LocalDriver.removeTable
train
public function removeTable(string $name){ $status = unlink($file = $this->base . '/' . $name . '.json'); return new \NonDB\Components\Status($status); }
php
{ "resource": "" }
q4106
APIService.initialize
train
public function initialize($email, $password, $config) { $this->api = new API($email, $password, $config); }
php
{ "resource": "" }
q4107
ProcessHydrator.hydrateCollection
train
public static function hydrateCollection(array $processes) { $hydrated = []; foreach ($processes as $process) { $hydrated[] = self::hydrate($process); } return $hydrated; }
php
{ "resource": "" }
q4108
ProcessHydrator.hydrate
train
public static function hydrate(stdClass $process) { $hydrated = new ProcessEntity(); if (isset($process->id)) { $hydrated->setId($process->id); } if (isset($process->pid)) { $hydrated->setPid($process->pid); } if (isset($process->version)) { $hydrated->setVersion($process->version); } if (isset($process->name)) { $hydrated->setName($process->name); } if (isset($process->started_at)) { $hydrated->setStartedAt(new DateTime($process->started_at)); } if (isset($process->finished_at)) { $hydrated->setFinishedAt(new DateTime($process->finished_at)); } if (isset($process->finished)) { $hydrated->setFinished($process->finished); } if (isset($process->memory)) { $hydrated->setMemory($process->memory); } if (isset($process->phase)) { $hydrated->setPhase($process->phase); } if (isset($process->percent)) { $hydrated->setPercent($process->percent); } if (isset($process->weight)) { $hydrated->setWeight($process->weight); } return $hydrated; }
php
{ "resource": "" }
q4109
ExtensionHydrator.hydrateCollection
train
public static function hydrateCollection(array $extensions) { $hydrated = []; foreach ($extensions as $extension) { $hydrated[] = self::hydrate($extension); } return $hydrated; }
php
{ "resource": "" }
q4110
ExtensionHydrator.hydrate
train
public static function hydrate(stdClass $extension) { $hydrated = new ExtensionEntity(); if (isset($extension->id)) { $hydrated->setId($extension->id); } if (isset($extension->extension)) { $hydrated->setExtension($extension->extension); } return $hydrated; }
php
{ "resource": "" }
q4111
QuotaHydrator.hydrateCollection
train
public static function hydrateCollection(array $quotas) { $hydrated = []; foreach ($quotas as $quota) { $hydrated[] = self::hydrate($quota); } return $hydrated; }
php
{ "resource": "" }
q4112
CNabuSiteTargetSectionListBase.createSecondaryIndexes
train
protected function createSecondaryIndexes() { $this->addIndex( new CNabuDataObjectListIndex($this, 'nb_site_target_section_key', 'nb_site_target_section_order', self::INDEX_KEY) ); $this->addIndex( new CNabuDataObjectListIndex($this, 'nb_site_target_section_order', 'nb_site_target_section_order', self::INDEX_ORDER) ); }
php
{ "resource": "" }
q4113
CNabuSiteTargetSectionListBase.acquireItem
train
public function acquireItem($key, $index = false) { $retval = false; if ($index === false && CNabuEngine::getEngine()->isMainDBAvailable()) { $item = new CNabuSiteTargetSection($key); if ($item->isFetched()) { $retval = $item; } } return $retval; }
php
{ "resource": "" }
q4114
CNabuMessagingBase.getAllMessagings
train
public static function getAllMessagings(CNabuCustomer $nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, 'nb_customer_id'); if (is_numeric($nb_customer_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_messaging_id', 'select * ' . 'from nb_messaging ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuMessagingList(); } return $retval; }
php
{ "resource": "" }
q4115
ProcessService.getAll
train
public function getAll($appId, $scanId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->processes() ->getAll($appId, $scanId, $queryParams); return new ProcessesResponse($response); }
php
{ "resource": "" }
q4116
ProcessService.getById
train
public function getById($appId, $scanId, $processId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->processes() ->getById($appId, $scanId, $processId, $queryParams); return new ProcessResponse($response); }
php
{ "resource": "" }
q4117
ProcessService.create
train
public function create($appId, $scanId, $input, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->processes() ->create($appId, $scanId, $input->toArray(), $queryParams); return new ProcessResponse($response); }
php
{ "resource": "" }
q4118
CNabuDataObjectList.clear
train
public function clear() { $this->list = null; if (is_array($this->secondary_indexes)) { foreach ($this->secondary_indexes as $index) { $index->clear(); } } }
php
{ "resource": "" }
q4119
CNabuDataObjectList.addIndex
train
public function addIndex(CNabuDataObjectListIndex $index) { $name = $index->getName(); if (is_array($this->secondary_indexes)) { $this->secondary_indexes[$name] = $index; } else { $this->secondary_indexes = array($name => $index); } return $index; }
php
{ "resource": "" }
q4120
CNabuDataObjectList.getIndex
train
public function getIndex($index) { if (is_string($index) && is_array($this->secondary_indexes) && array_key_exists($index, $this->secondary_indexes) ) { return $this->secondary_indexes[$index]; } else { throw new ENabuCoreException(ENabuCoreException::ERROR_INVALID_INDEX, array(print_r($index, true))); } }
php
{ "resource": "" }
q4121
CNabuDataObjectList.getKeys
train
public function getKeys($index = false) { $retval = null; if ($index === false) { $retval = is_array($this->list) ? array_keys($this->list) : null; } elseif (is_string($index) && is_array($this->secondary_indexes) && array_key_exists($index, $this->secondary_indexes) ) { $retval = $this->secondary_indexes[$index]->getKeys(); } else { throw new ENabuCoreException(ENabuCoreException::ERROR_INVALID_INDEX, array(print_r($index, true))); } return $retval; }
php
{ "resource": "" }
q4122
CNabuDataObjectList.addItem
train
public function addItem(CNabuDataObject $item) { $retval = false; if ($this->index_field !== false) { if ($item->contains($this->index_field)) { if (is_array($this->list)) { $this->list[$item->getValue($this->index_field)] = $item; $retval = $item; } else { $this->list = array( $item->getValue($this->index_field) => $item ); $retval = $item; } } } else { if (is_array($this->list)) { $this->list[] = $item; $retval = $item; } else { $this->list = array($item); $retval = $item; } } $this->indexItem($item); return $retval; }
php
{ "resource": "" }
q4123
CNabuDataObjectList.indexItem
train
protected function indexItem(CNabuDataObject $item) { if (is_array($this->secondary_indexes)) { foreach ($this->secondary_indexes as $index) { $index->addItem($item); } } }
php
{ "resource": "" }
q4124
CNabuDataObjectList.removeItemIndex
train
protected function removeItemIndex(CNabuDataObject $item) { if (is_array($this->secondary_indexes)) { foreach ($this->secondary_indexes as $index) { $index->removeItem($item->getValue($this->index_field)); } } }
php
{ "resource": "" }
q4125
CNabuDataObjectList.removeItem
train
public function removeItem($item) { $nb_index_id = nb_getMixedValue($item, $this->index_field); if ((is_numeric($nb_index_id) || nb_isValidGUID($nb_index_id)) && $this->containsKey($nb_index_id)) { unset($this->list[$nb_index_id]); $this->removeItemIndex($item); } }
php
{ "resource": "" }
q4126
CNabuDataObjectList.mergeArray
train
public function mergeArray(array $array = null) { $count = 0; if (is_array($array)) { if (count($array) > 0) { foreach ($array as $key => $item) { if (!$this->containsKey($key)) { $this->addItem($item); $count++; } } } } elseif ($array !== null) { throw new ENabuCoreException( ENabuCoreException::ERROR_METHOD_PARAMETER_NOT_VALID, array('$array', print_r($array, true)) ); } return $count; }
php
{ "resource": "" }
q4127
MigrationCompiler.compile
train
public function compile($stub, $modelName, $modelData, stdClass $scaffolderConfig, $hash, array $extensions, $extra = null) { // Add time to migration $this->date->addSeconds(5); if (File::exists(base_path('scaffolder-config/cache/migration_' . $hash . self::CACHE_EXT))) { return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); } else { $this->stub = $stub; $this->replaceClassName($modelName) ->replaceTableName($scaffolderConfig, $modelName) ->addFields($modelData); foreach ($extensions as $extension) { $this->stub = $extension->runAfterMigrationIsCompiled($this->stub, $modelData, $scaffolderConfig); } return $this->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash)); } }
php
{ "resource": "" }
q4128
MigrationCompiler.replaceTableName
train
private function replaceTableName(stdClass $scaffolderConfig, $modelName) { $tableName = isset($scaffolderConfig->tableName) && !empty($scaffolderConfig->tableName) ? $scaffolderConfig->tableName : $modelName . 's'; $this->stub = str_replace('{{table_name}}', strtolower($tableName), $this->stub); return $this; }
php
{ "resource": "" }
q4129
MigrationCompiler.addFields
train
private function addFields($modelData) { // Default primary key $fields = $this->tab(3) . "\$table->increments('id');" . PHP_EOL . PHP_EOL; // Check primary key foreach ($modelData->fields as $field) { if ($field->index == 'primary') { $fields = ''; break; } } foreach ($modelData->fields as $field) { $parsedModifiers = ''; // Check modifiers if (!empty($field->modifiers)) { $modifiersArray = explode(':', $field->modifiers); foreach ($modifiersArray as $modifier) { $modifierAndValue = explode(',', $modifier); if (count($modifierAndValue) == 2) { $parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')'; } else { $parsedModifiers .= '->' . $modifierAndValue[0] . '()'; } } } // Check indexes if ($field->index != 'none') { $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index); } else { $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers); } // Check foreign key if (!empty($field->foreignKey)) { $foreignKey = explode(':', $field->foreignKey); $fields .= sprintf($this->tab(3) . "\$table->foreign('%s')->references('%s')->on('%s');" . PHP_EOL . PHP_EOL, $field->name, $foreignKey[0], $foreignKey[1]); } } $fields .= PHP_EOL . $this->tab(3) . "\$table->timestamps();" . PHP_EOL; $this->stub = str_replace('{{fields}}', $fields, $this->stub); return $this; }
php
{ "resource": "" }
q4130
CNabuCatalog.getTaxonomies
train
public function getTaxonomies(bool $force = false) { if ($this->nb_catalog_taxonomy_list->isEmpty() || $force) { $this->nb_catalog_taxonomy_list->clear(); $this->nb_catalog_taxonomy_list->merge( CNabuCatalogTaxonomy::getAllCatalogTaxonomies($this) ); } return $this->nb_catalog_taxonomy_list; }
php
{ "resource": "" }
q4131
CNabuCatalog.getTags
train
public function getTags(bool $force = false) { if ($this->nb_catalog_tag_list->isEmpty() || $force) { $this->nb_catalog_tag_list->clear(); $this->nb_catalog_tag_list->merge( CNabuCatalogTag::getAllCatalogTags($this) ); } return $this->nb_catalog_tag_list; }
php
{ "resource": "" }
q4132
CNabuXMLSiteMap.setTarget
train
private function setTarget(SimpleXMLElement $element) { $target = $element->addChild('target'); switch ($this->nb_data_object->getUseURI()) { case 'T': if (($nb_site = $this->nb_data_object->getSite()) instanceof CNabuSite && ($nb_site_target = $nb_site->getTarget($this->nb_data_object->getSiteTargetId())) instanceof CNabuSiteTarget ) { $target->addAttribute('useURI', 'T'); $target->addAttribute('target', $nb_site_target->getHash()); } else { error_log("Target not exists"); } break; case 'U': $translations = $this->nb_data_object->getTranslations(); $urls = array(); $translations->iterate(function ($lang, $nb_translation) use (&$urls) { $urls[$lang] = array( 'url' => $nb_translation->getURL(), 'match' => $nb_translation->getMatchURLFragment() ); return true; }); if (count($urls) > 0) { $target->addAttribute('useURI', 'U'); foreach ($urls as $lang => $url) { if (strlen($url) > 0) { $nb_language = $this->nb_data_object->getLanguage($lang); $address = $target->addChild('url'); $address->addAttribute('lang', $nb_language->getHash()); $address->addAttribute('url', $url['url']); $address->addAttribute('match', $url['match']); } } } break; default: } }
php
{ "resource": "" }
q4133
CNabuXMLSiteMap.setSecurity
train
private function setSecurity(SimpleXMLElement $element) { $security = $element->addChild('security'); $xml_roles = new CNabuXMLSiteMapRoleList($this->nb_data_object->getRoles()); $xml_roles->build($security); }
php
{ "resource": "" }
q4134
CNabuXMLSiteMap.setMapChilds
train
private function setMapChilds(SimpleXMLElement $element) { $nb_map_list = $this->nb_data_object->getChilds(); if ($nb_map_list->getSize() > 0) { $xml_childs = new CNabuXMLSiteMapList($nb_map_list); $xml_childs->build($element); } }
php
{ "resource": "" }
q4135
Tool.checkImplement
train
public static function checkImplement($class, string $interface){ $ref = new \ReflectionClass($class); $names = $ref->getInterfaceNames(); if(in_array($interface, $names)){ return true; }else{ return false; } }
php
{ "resource": "" }
q4136
Dump.arrayToXML
train
protected static function arrayToXML($data, &$xml = null){ if($xml === null) $xml = new \SimpleXMLElement("<?xml version=\"1.0\"?><nondb></nondb>"); foreach($data as $k=>$v){ if(is_array($v)){ $sub = $xml->addChild("$k"); self::arrayToXML($v, $sub); }else{ $xml->addChild("$k", htmlspecialchars("$v")); } } return $xml->asXML(); }
php
{ "resource": "" }
q4137
ProfileHydrator.hydrateCollection
train
public static function hydrateCollection(array $profiles) { $hydrated = []; foreach ($profiles as $profile) { $hydrated[] = self::hydrate($profile); } return $hydrated; }
php
{ "resource": "" }
q4138
ProfileHydrator.hydrate
train
public static function hydrate(stdClass $profile) { $hydrated = new ProfileEntity(); if (isset($profile->id)) { $hydrated->setId($profile->id); } if (isset($profile->name)) { $hydrated->setName($profile->name); } if (isset($profile->setting)) { $hydrated->setSetting(SettingHydrator::hydrate($profile->setting)); } if (isset($profile->controllers) && is_array($profile->controllers)) { $hydrated->setControllers(ControllerHydrator::hydrateCollection($profile->controllers)); } if (isset($profile->sources) && is_array($profile->sources)) { $hydrated->setSources(SourceHydrator::hydrateCollection($profile->sources)); } if (isset($profile->sinks) && is_array($profile->sinks)) { $hydrated->setSinks(SinkHydrator::hydrateCollection($profile->sinks)); } if (isset($profile->validators) && is_array($profile->validators)) { $hydrated->setValidators(ValidatorHydrator::hydrateCollection($profile->validators)); } if (isset($profile->sanitizers) && is_array($profile->sanitizers)) { $hydrated->setSanitizers(SanitizerHydrator::hydrateCollection($profile->sanitizers)); } if (isset($profile->ignored_codes) && is_array($profile->ignored_codes)) { $hydrated->setIgnoredCodes(IgnoredCodeHydrator::hydrateCollection($profile->ignored_codes)); } if (isset($profile->ignored_locations) && is_array($profile->ignored_locations)) { $hydrated->setIgnoredLocations(IgnoredLocationHydrator::hydrateCollection($profile->ignored_locations)); } if (isset($profile->extensions) && is_array($profile->extensions)) { $hydrated->setExtensions(ExtensionHydrator::hydrateCollection($profile->extensions)); } if (isset($profile->application)) { $hydrated->setApplication(ApplicationHydrator::hydrate($profile->application)); } if (isset($profile->created_by)) { $hydrated->setCreatedBy(UserHydrator::hydrate($profile->created_by)); } if (isset($profile->default)) { $hydrated->setDefault($profile->default); } return $hydrated; }
php
{ "resource": "" }
q4139
Verb.equals
train
public function equals(Verb $verb): bool { if (!$this->id->equals($verb->id)) { return false; } if (null === $this->display && null === $verb->display) { return true; } if (null !== $this->display xor null !== $verb->display) { return false; } if (count($this->display) !== count($verb->getDisplay())) { return false; } foreach ($this->display as $language => $value) { if (!isset($verb->display[$language])) { return false; } if ($value !== $verb->display[$language]) { return false; } } return true; }
php
{ "resource": "" }
q4140
JavaHydrator.hydrateCollection
train
public static function hydrateCollection(array $javas) { $hydrated = []; foreach ($javas as $java) { $hydrated[] = self::hydrate($java); } return $hydrated; }
php
{ "resource": "" }
q4141
JavaHydrator.hydrate
train
public static function hydrate(stdClass $java) { $hydrated = new JavaEntity(); if (isset($java->id)) { $hydrated->setId($java->id); } if (isset($java->major_version)) { $hydrated->setMajorVersion($java->major_version); } if (isset($java->minor_version)) { $hydrated->setMinorVersion($java->minor_version); } if (isset($java->release_version)) { $hydrated->setReleaseVersion($java->release_version); } if (isset($java->implementation)) { $hydrated->setImplementation($java->implementation); } if (isset($java->setting)) { $hydrated->setSetting(SettingHydrator::hydrate($java->setting)); } return $hydrated; }
php
{ "resource": "" }
q4142
ParentClass.setParent
train
public function setParent($parent){ $this->parent = $parent; if($this->parentCallback){ call_user_func($this->parentCallback); } return $this; }
php
{ "resource": "" }
q4143
ParentClass.setCallback
train
public function setCallback(Callable $callback, bool $force = false){ if($force || !$this->parentCallback){ $this->parentCallback = $callback; } return $this; }
php
{ "resource": "" }
q4144
FoundationSupports.withFoundation
train
public function withFoundation() { $this->make('events')->listen('orchestra.auth: roles', UserAccess::class); $this->registerMemoryBindings(); $this->registerAuthorizationBindings(); return $this; }
php
{ "resource": "" }
q4145
CNabuDBAbstractDescriptor.getPrimaryConstraint
train
protected function getPrimaryConstraint($force = false) { if ($this->primary_constraint === null || $force) { $this->primary_constraint = null; if (array_key_exists('constraints', $this->storage_descriptor)) { foreach ($this->storage_descriptor['constraints'] as $constraint) { if (is_array($constraint) && array_key_exists('primary', $constraint) && $constraint['primary'] === true ) { $this->primary_constraint = $constraint; break; } } } } return $this->primary_constraint; }
php
{ "resource": "" }
q4146
TNabuSiteTargetCTAChild.setSiteTargetCTA
train
public function setSiteTargetCTA(CNabuSiteTargetCTA $nb_site_target_cta, $field = NABU_SITE_TARGET_CTA_FIELD_ID) { $this->nb_site_target_cta = $nb_site_target_cta; if ($this instanceof CNabuDataObject) { $this->transferValue($nb_site_target_cta, NABU_SITE_TARGET_CTA_FIELD_ID, $field); } return $this; }
php
{ "resource": "" }
q4147
TNabuMediotecaChild.getMedioteca
train
public function getMedioteca($nb_customer = false, $force = false) { if (($this->nb_medioteca === null || $force) && !$this->isValueNull(NABU_MEDIOTECA_FIELD_ID)) { $this->nb_medioteca = null; if (($nb_final_cust = nb_grantCustomer($nb_customer, $force)) !==false) { $this->nb_medioteca = $nb_final_cust->getMedioteca($this); } } return $this->nb_medioteca; }
php
{ "resource": "" }
q4148
TNabuMediotecaChild.setMedioteca
train
public function setMedioteca(CNabuMedioteca $nb_medioteca, $field = NABU_MEDIOTECA_FIELD_ID) { $this->nb_medioteca = $nb_medioteca; if ($this instanceof CNabuDataObject) { $this->transferValue($nb_medioteca, NABU_MEDIOTECA_FIELD_ID, $field); } return $this; }
php
{ "resource": "" }
q4149
CNabuMediotecaBase.getAllMediotecas
train
public static function getAllMediotecas(CNabuCustomer $nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, 'nb_customer_id'); if (is_numeric($nb_customer_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_medioteca_id', 'select * ' . 'from nb_medioteca ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuMediotecaList(); } return $retval; }
php
{ "resource": "" }
q4150
CNabuMediotecaBase.getCustomerUsedLanguages
train
public static function getCustomerUsedLanguages($nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID); if (is_numeric($nb_customer_id)) { $nb_language_list = CNabuLanguage::buildObjectListFromSQL( 'nb_language_id', 'select l.* ' . 'from nb_language l, ' . '(select distinct nb_language_id ' . 'from nb_medioteca ca, nb_medioteca_lang cal ' . 'where ca.nb_medioteca_id=cal.nb_medioteca_id ' . 'and ca.nb_customer_id=%cust_id$d) as lid ' . 'where l.nb_language_id=lid.nb_language_id', array('cust_id' => $nb_customer_id) ); } else { $nb_language_list = new CNabuLanguageList(); } return $nb_language_list; }
php
{ "resource": "" }
q4151
QueryBuilder.forge
train
public static function forge($classname = null, $db_table_alias = null, $escape = true){ if (!is_null($classname)) { $object = new $classname; } else if(get_called_class() != "Pragma\ORM\QueryBuilder") { $object = new static(); } else { throw new \Exception("QueryBuilder can't be built without classname"); } $object->db_table_alias = $db_table_alias; $object->escape = $escape; return $object; }
php
{ "resource": "" }
q4152
IdGenerator.encode
train
public static function encode( $cacheVersion = WurflConstants::API_NAMESPACE, $namespace = AbstractAdapter::DEFAULT_NAMESPACE, $cacheId = '' ) { $cacheId = implode(':', array($cacheVersion, $namespace, $cacheId)); return hash('sha512', $cacheId); }
php
{ "resource": "" }
q4153
CNabuMessagingService.getTemplateConnections
train
public function getTemplateConnections(bool $force = false) : CNabuMessagingServiceTemplateList { if ($this->nb_messaging_template_service_list->isEmpty() || $force) { $this->nb_messaging_template_service_list->clear(); $this->nb_messaging_template_service_list->merge( CNabuMessagingServiceTemplate::getTemplatesForService($this) ); } return $this->nb_messaging_template_service_list; }
php
{ "resource": "" }
q4154
CNabuMessagingService.isTemplateConnected
train
public function isTemplateConnected($nb_template) : bool { $retval = false; if (is_numeric($nb_template_id = nb_getMixedValue($nb_template, NABU_MESSAGING_TEMPLATE_FIELD_ID))) { $this->getTemplateConnections(); $retval = $this->nb_messaging_template_service_list->containsKey($nb_template_id); } return $retval; }
php
{ "resource": "" }
q4155
CNabuMessagingService.getActiveMessagingServices
train
public static function getActiveMessagingServices(CNabuMessaging $nb_messaging) { $nb_messaging_id = nb_getMixedValue($nb_messaging, 'nb_messaging_id'); if (is_numeric($nb_messaging_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_messaging_service_id', 'SELECT * FROM nb_messaging_service WHERE nb_messaging_id=%messaging_id$d AND nb_messaging_service_status=\'E\'', array( 'messaging_id' => $nb_messaging_id ), $nb_messaging ); } else { $retval = new CNabuMessagingServiceList(); } return $retval; }
php
{ "resource": "" }
q4156
TNabuUserChild.getUser
train
public function getUser($force = false) { if ($this->nb_user === null || $force) { $this->nb_user = null; if ($this instanceof CNabuDataObject && $this->contains(NABU_USER_FIELD_ID) && $this->isValueNumeric(NABU_USER_FIELD_ID) ) { $nb_user = new CNabuUser($this->getValue(NABU_USER_FIELD_ID)); if ($nb_user->isFetched()) { $this->nb_user = $nb_user; } } } return $this->nb_user; }
php
{ "resource": "" }
q4157
TNabuUserChild.setUser
train
public function setUser(CNabuUser $nb_user) { $this->nb_user = $nb_user; if ($this instanceof CNabuDataObject) { $this->transferValue($nb_user, NABU_USER_FIELD_ID); } return $this; }
php
{ "resource": "" }
q4158
TNabuSiteTargetChild.setSiteTarget
train
public function setSiteTarget(CNabuSiteTarget $nb_site_target = null, $field = NABU_SITE_TARGET_FIELD_ID) { $this->nb_site_target = $nb_site_target; if ($this instanceof CNabuDataObject) { if ($nb_site_target instanceof CNabuSiteTarget) { $this->transferValue($nb_site_target, NABU_SITE_TARGET_FIELD_ID, $field); } else { $this->setValue($field, null); } } return $this; }
php
{ "resource": "" }
q4159
AuthServiceProvider.bindAuthForApiToken
train
protected function bindAuthForApiToken() { Auth::viaRequest('api', function ($request) { if ($request->input('api_token')) { return User::where('api_token', $request->input('api_token'))->first(); } }); }
php
{ "resource": "" }
q4160
AuthServiceProvider.bindAuthForJwtToken
train
protected function bindAuthForJwtToken() { Auth::viaRequest('jwt', function ($request) { try { if (! $user = JWTAuth::parseToken()->authenticate()) { return; } } catch (Exception $e) { return; } return $user; }); }
php
{ "resource": "" }
q4161
BaseBuilder.toArray
train
public function toArray() { $out = []; foreach ($this->setFields as $key) { $property = $this->{$key}; if ($property instanceof DateTime) { $out[$key] = $property->format(DateTime::ISO8601); } else { $out[$key] = $property; } } return $out; }
php
{ "resource": "" }
q4162
CNabuSiteMapRoleBase.setSiteMapId
train
public function setSiteMapId(int $nb_site_map_id = 0) : CNabuDataObject { if ($nb_site_map_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_site_map_id") ); } $this->setValue('nb_site_map_id', $nb_site_map_id); return $this; }
php
{ "resource": "" }
q4163
CNabuSiteMapRoleBase.setZone
train
public function setZone(string $zone = "B") : CNabuDataObject { if ($zone === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$zone") ); } $this->setValue('nb_site_map_role_zone', $zone); return $this; }
php
{ "resource": "" }
q4164
CNabuDomainZoneBase.getAllDomainZones
train
public static function getAllDomainZones(CNabuCustomer $nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, 'nb_customer_id'); if (is_numeric($nb_customer_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_domain_zone_id', 'select * ' . 'from nb_domain_zone ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuDomainZoneList(); } return $retval; }
php
{ "resource": "" }
q4165
CNabuDomainZoneBase.setOrigin
train
public function setOrigin($origin) : CNabuDataObject { if ($origin === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$origin") ); } $this->setValue('nb_domain_zone_origin', $origin); return $this; }
php
{ "resource": "" }
q4166
CNabuDomainZoneBase.setTtl
train
public function setTtl(int $ttl = 86400) : CNabuDataObject { if ($ttl === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$ttl") ); } $this->setValue('nb_domain_zone_ttl', $ttl); return $this; }
php
{ "resource": "" }
q4167
CNabuDomainZoneBase.setAdminEmail
train
public function setAdminEmail(string $admin_email) : CNabuDataObject { if ($admin_email === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$admin_email") ); } $this->setValue('nb_domain_zone_admin_email', $admin_email); return $this; }
php
{ "resource": "" }
q4168
CNabuDomainZoneBase.setSerial
train
public function setSerial(int $serial = 1) : CNabuDataObject { if ($serial === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$serial") ); } $this->setValue('nb_domain_zone_serial', $serial); return $this; }
php
{ "resource": "" }
q4169
CNabuDomainZoneBase.setRefresh
train
public function setRefresh(int $refresh = 10800) : CNabuDataObject { if ($refresh === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$refresh") ); } $this->setValue('nb_domain_zone_refresh', $refresh); return $this; }
php
{ "resource": "" }
q4170
CNabuDomainZoneBase.setRetry
train
public function setRetry(int $retry = 3600) : CNabuDataObject { if ($retry === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$retry") ); } $this->setValue('nb_domain_zone_retry', $retry); return $this; }
php
{ "resource": "" }
q4171
CNabuDomainZoneBase.setExpiry
train
public function setExpiry(int $expiry = 604800) : CNabuDataObject { if ($expiry === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$expiry") ); } $this->setValue('nb_domain_zone_expiry', $expiry); return $this; }
php
{ "resource": "" }
q4172
CNabuDomainZoneBase.setMinimum
train
public function setMinimum(int $minimum = 10800) : CNabuDataObject { if ($minimum === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$minimum") ); } $this->setValue('nb_domain_zone_minimum', $minimum); return $this; }
php
{ "resource": "" }
q4173
CNabuDomainZoneBase.setDns01
train
public function setDns01(string $dns_01) : CNabuDataObject { if ($dns_01 === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$dns_01") ); } $this->setValue('nb_domain_zone_dns_01', $dns_01); return $this; }
php
{ "resource": "" }
q4174
CNabuDomainZoneBase.setDns02
train
public function setDns02(string $dns_02) : CNabuDataObject { if ($dns_02 === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$dns_02") ); } $this->setValue('nb_domain_zone_dns_02', $dns_02); return $this; }
php
{ "resource": "" }
q4175
CNabuDomainZoneBase.setDnsOrigin
train
public function setDnsOrigin($dns_origin) : CNabuDataObject { if ($dns_origin === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$dns_origin") ); } $this->setValue('nb_domain_zone_dns_origin', $dns_origin); return $this; }
php
{ "resource": "" }
q4176
CNabuDomainZoneBase.setShareAll
train
public function setShareAll(string $share_all = "F") : CNabuDataObject { if ($share_all === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$share_all") ); } $this->setValue('nb_domain_zone_share_all', $share_all); return $this; }
php
{ "resource": "" }
q4177
SettingHydrator.hydrateCollection
train
public static function hydrateCollection(array $settings) { $hydrated = []; foreach ($settings as $setting) { $hydrated[] = self::hydrate($setting); } return $hydrated; }
php
{ "resource": "" }
q4178
SettingHydrator.hydrate
train
public static function hydrate(stdClass $setting) { $hydrated = new SettingEntity(); if (isset($setting->key)) { $hydrated->setKey($setting->key); } if (isset($setting->value)) { $hydrated->setValue($setting->value); } if (isset($setting->created_at)) { $hydrated->setCreatedAt(new DateTime($setting->created_at)); } return $hydrated; }
php
{ "resource": "" }
q4179
CNabuMessagingTemplateBase.getAllMessagingTemplates
train
public static function getAllMessagingTemplates(CNabuMessaging $nb_messaging) { $nb_messaging_id = nb_getMixedValue($nb_messaging, 'nb_messaging_id'); if (is_numeric($nb_messaging_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_messaging_template_id', 'select * ' . 'from nb_messaging_template ' . 'where nb_messaging_id=%messaging_id$d', array( 'messaging_id' => $nb_messaging_id ), $nb_messaging ); } else { $retval = new CNabuMessagingTemplateList(); } return $retval; }
php
{ "resource": "" }
q4180
CommandsServiceProvider.registerEntityScanner
train
protected function registerEntityScanner() { $app = $this->app; $app->singleton('datamapper.entity.scanner', function ($app) { $reader = $app['datamapper.annotationreader']; $validator = new EntityValidator; return new EntityScanner($reader, $validator); }); }
php
{ "resource": "" }
q4181
CNabuCatalogTagBase.findByKey
train
public static function findByKey($nb_catalog, $key) { $nb_catalog_id = nb_getMixedValue($nb_catalog, 'nb_catalog_id'); if (is_numeric($nb_catalog_id)) { $retval = CNabuCatalogTag::buildObjectFromSQL( 'select * ' . 'from nb_catalog_tag ' . 'where nb_catalog_id=%catalog_id$d ' . "and nb_catalog_tag_key='%key\$s'", array( 'catalog_id' => $nb_catalog_id, 'key' => $key ) ); } else { $retval = null; } return $retval; }
php
{ "resource": "" }
q4182
CNabuCatalogTagBase.getAllCatalogTags
train
public static function getAllCatalogTags(CNabuCatalog $nb_catalog) { $nb_catalog_id = nb_getMixedValue($nb_catalog, 'nb_catalog_id'); if (is_numeric($nb_catalog_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_catalog_tag_id', 'select * ' . 'from nb_catalog_tag ' . 'where nb_catalog_id=%catalog_id$d', array( 'catalog_id' => $nb_catalog_id ), $nb_catalog ); } else { $retval = new CNabuCatalogTagList(); } return $retval; }
php
{ "resource": "" }
q4183
CNabuCatalogTagBase.getFilteredCatalogTagList
train
public static function getFilteredCatalogTagList($nb_catalog, $q = null, $fields = null, $order = null, $offset = 0, $num_items = 0) { $nb_catalog_id = nb_getMixedValue($nbu_customer, NABU_CATALOG_FIELD_ID); if (is_numeric($nb_catalog_id)) { $fields_part = nb_prefixFieldList(CNabuCatalogTagBase::getStorageName(), $fields, false, true, '`'); $order_part = nb_prefixFieldList(CNabuCatalogTagBase::getStorageName(), $fields, false, false, '`'); if ($num_items !== 0) { $limit_part = ($offset > 0 ? $offset . ', ' : '') . $num_items; } else { $limit_part = false; } $nb_item_list = CNabuEngine::getEngine()->getMainDB()->getQueryAsArray( "select " . ($fields_part ? $fields_part . ' ' : '* ') . 'from nb_catalog_tag ' . 'where ' . NABU_CATALOG_FIELD_ID . '=%catalog_id$d ' . ($order_part ? "order by $order_part " : '') . ($limit_part ? "limit $limit_part" : ''), array( 'catalog_id' => $nb_catalog_id ) ); } else { $nb_item_list = null; } return $nb_item_list; }
php
{ "resource": "" }
q4184
CNabuMessagingPoolManager.getFactory
train
public function getFactory(CNabuMessaging $nb_messaging) { $retval = false; $nb_customer = $this->getCustomer(); if ($nb_messaging->validateCustomer($nb_customer)) { if (is_numeric($nb_messaging_id = nb_getMixedValue($nb_messaging, NABU_MESSAGING_FIELD_ID))) { $retval = $this->nb_messaging_factory_list->getItem($nb_messaging_id); } if (!$retval) { $retval = $this->nb_messaging_factory_list->addItem(new CNabuMessagingFactory($nb_messaging)); } } else { throw new ENabuCoreException(ENabuCoreException::ERROR_CUSTOMERS_DOES_NOT_MATCH); } return $retval; }
php
{ "resource": "" }
q4185
LibraryHydrator.hydrateCollection
train
public static function hydrateCollection(array $libraries) { $hydrated = []; foreach ($libraries as $library) { $hydrated[] = self::hydrate($library); } return $hydrated; }
php
{ "resource": "" }
q4186
LibraryHydrator.hydrate
train
public static function hydrate(stdClass $library) { $hydrated = new LibraryEntity(); if (isset($library->id)) { $hydrated->setId($library->id); } if (isset($library->name)) { $hydrated->setName($library->name); } if (isset($library->version)) { $hydrated->setVersion($library->version); } if (isset($library->implementation)) { $hydrated->setImplementation($library->implementation); } if (isset($library->group)) { $hydrated->setGroup($library->group); } return $hydrated; }
php
{ "resource": "" }
q4187
CheckIfDead.isLinkDead
train
public function isLinkDead( $url ) { $deadVal = $this->areLinksDead( [ $url ] ); $deadVal = $deadVal[$url]; return $deadVal; }
php
{ "resource": "" }
q4188
CheckIfDead.performFullRequest
train
protected function performFullRequest( $urls ) { // Create multiple curl handle $multicurl_resource = curl_multi_init(); if ( $multicurl_resource === false ) { return false; } $curl_instances = []; $deadlinks = []; foreach ( $urls as $id => $url ) { $curl_instances[$id] = curl_init(); if ( $curl_instances[$id] === false ) { return false; } // Get appropriate curl options curl_setopt_array( $curl_instances[$id], $this->getCurlOptions( $this->sanitizeURL( $url, false, true ), true ) ); // Add the instance handle curl_multi_add_handle( $multicurl_resource, $curl_instances[$id] ); } // Let's do the CURL operations $active = null; do { $mrc = curl_multi_exec( $multicurl_resource, $active ); } while ( $mrc == CURLM_CALL_MULTI_PERFORM ); while ( $active && $mrc == CURLM_OK ) { if ( curl_multi_select( $multicurl_resource ) == -1 ) { // To prevent CPU spike usleep( 100 ); } do { $mrc = curl_multi_exec( $multicurl_resource, $active ); } while ( $mrc == CURLM_CALL_MULTI_PERFORM ); } // Let's process our curl results and extract the useful information foreach ( $urls as $id => $url ) { $headers = curl_getinfo( $curl_instances[$id] ); $error = curl_errno( $curl_instances[$id] ); $errormsg = curl_error( $curl_instances[$id] ); $curlInfo = [ 'http_code' => $headers['http_code'], 'effective_url' => $headers['url'], 'curl_error' => $error, 'curl_error_msg' => $errormsg, 'url' => $this->sanitizeURL( $url, false, true ), 'rawurl' => $url ]; // Remove each of the individual handles curl_multi_remove_handle( $multicurl_resource, $curl_instances[$id] ); $deadlinks[$url] = $this->processCurlResults( $curlInfo, true ); } // Close resource curl_multi_close( $multicurl_resource ); return $deadlinks; }
php
{ "resource": "" }
q4189
CheckIfDead.queueRequests
train
protected function queueRequests( $urls ) { $this->curlQueue = []; if ( $this->queuedTesting === false ) { $this->curlQueue[] = $urls; return; } foreach ( $urls as $url ) { $domain = $this->parseURL( $url )['host']; $queuedUrl = false; $queueIndex = -1; foreach ( $this->curlQueue as $queueIndex => $urlList ) { if ( $queuedUrl === false && !isset( $urlList[$domain] ) ) { $this->curlQueue[$queueIndex][$domain] = $url; $queuedUrl = true; } } if ( $queuedUrl === false ) { $this->curlQueue[++$queueIndex][$domain] = $url; } } }
php
{ "resource": "" }
q4190
CheckIfDead.getCurlOptions
train
protected function getCurlOptions( $url, $full = false ) { $requestType = $this->getRequestType( $url ); if ( $requestType == "MMS" ) { $url = str_ireplace( "mms://", "rtsp://", $url ); } $options = [ CURLOPT_URL => $url, CURLOPT_HEADER => 1, CURLOPT_RETURNTRANSFER => true, CURLOPT_AUTOREFERER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => $this->curlTimeoutNoBody, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_COOKIEJAR => sys_get_temp_dir() . "checkifdead.cookies.dat" ]; if ( $requestType == "RTSP" || $requestType == "MMS" ) { $header = []; $options[CURLOPT_USERAGENT] = $this->mediaAgent; } else { // Emulate a web browser request but make it accept more than a web browser $header = [ // @codingStandardsIgnoreStart Line exceeds 100 characters 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', // @codingStandardsIgnoreEnd 'Cache-Control: max-age=0', 'Connection: keep-alive', 'Keep-Alive: 300', 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Accept-Language: en-us,en;q=0.7,*;q=0.5', 'Accept-Encoding: *', 'Pragma: ' ]; if ( $this->customUserAgent === false ) { $options[CURLOPT_USERAGENT] = $this->userAgent; } else { $options[CURLOPT_USERAGENT] = $this->customUserAgent; } } if ( $requestType == 'FTP' ) { $options[CURLOPT_FTP_USE_EPRT] = 1; $options[CURLOPT_FTP_USE_EPSV] = 1; $options[CURLOPT_FTPSSLAUTH] = CURLFTPAUTH_DEFAULT; $options[CURLOPT_FTP_FILEMETHOD] = CURLFTPMETHOD_SINGLECWD; if ( $full ) { // Set CURLOPT_USERPWD for anonymous FTP login $options[CURLOPT_USERPWD] = "anonymous:anonymous@domain.com"; } } if ( $full ) { // Extend timeout since we are requesting the full body $options[CURLOPT_TIMEOUT] = $this->curlTimeoutFull; $options[CURLOPT_HTTPHEADER] = $header; if ( $requestType != "MMS" && $requestType != "RTSP" ) { $options[CURLOPT_ENCODING] = 'gzip,deflate'; } $options[CURLOPT_USERAGENT] = $this->userAgent; } else { $options[CURLOPT_NOBODY] = 1; } return $options; }
php
{ "resource": "" }
q4191
CheckIfDead.processCurlResults
train
protected function processCurlResults( $curlInfo, $full = false ) { // Determine if we are using FTP or HTTP $requestType = $this->getRequestType( $curlInfo['url'] ); // Get HTTP code returned $httpCode = $curlInfo['http_code']; // Get final URL $effectiveUrl = $curlInfo['effective_url']; // Clean final url, removing scheme, 'www', and trailing slash $effectiveUrlClean = $this->cleanURL( $effectiveUrl ); // Get an array of possible root urls $possibleRoots = $this->getDomainRoots( $curlInfo['url'] ); if ( $httpCode >= 400 && $httpCode < 600 ) { if ( $full ) { $this->errors[$curlInfo['rawurl']] = "RESPONSE CODE: $httpCode"; return true; } else { // Some servers don't support NOBODY requests, so if an HTTP error code // is returned, we'll check the URL again with a full page request. return null; } } // Check for error messages in redirected URL string if ( strpos( $effectiveUrlClean, '/404.htm' ) !== false || strpos( $effectiveUrlClean, '/404/' ) !== false || stripos( $effectiveUrlClean, 'notfound' ) !== false ) { if ( $full ) { $this->errors[$curlInfo['rawurl']] = "REDIRECT TO 404"; return true; } else { // Some servers don't support NOBODY requests, so if redirect to a 404 page // is returned, we'll check the URL again with a full page request. return null; } } // Check if there was a redirect by comparing final URL with original URL if ( $effectiveUrlClean != $this->cleanURL( $curlInfo['url'] ) ) { // Check against possible roots foreach ( $possibleRoots as $root ) { // We found a match with final url and a possible root url if ( $root == $effectiveUrlClean ) { $this->errors[$curlInfo['rawurl']] = "REDIRECT TO ROOT"; return true; } } } // If there was an error during the CURL process, check if the code // returned is a server side problem if ( in_array( $curlInfo['curl_error'], $this->curlErrorCodes ) ) { $this->errors[$curlInfo['rawurl']] = "Curl Error {$curlInfo['curl_error']}: {$curlInfo['curl_error_msg']}"; return true; } if ( $httpCode === 0 ) { if ( $full ) { $this->errors[$curlInfo['rawurl']] = "NO RESPONSE FROM SERVER"; return true; } else { // Some servers don't support NOBODY requests, so if redirect to a 404 page // is returned, we'll check the URL again with a full page request. return null; } } // Check for valid non-error codes for HTTP or FTP if ( $requestType != "FTP" && !in_array( $httpCode, $this->goodHttpCodes ) ) { $this->errors[$curlInfo['rawurl']] = "HTTP RESPONSE CODE: $httpCode"; return true; // Check for valid non-error codes for FTP } elseif ( $requestType == "FTP" && !in_array( $httpCode, $this->goodFtpCodes ) ) { $this->errors[$curlInfo['rawurl']] = "FTP RESPONSE CODE: $httpCode"; return true; } // Yay, the checks passed, and the site is alive. return false; }
php
{ "resource": "" }
q4192
CheckIfDead.getDomainRoots
train
protected function getDomainRoots( $url ) { $roots = []; $pieces = parse_url( $url ); if ( !isset( $pieces['host'], $pieces['host'] ) ) { return []; } $roots[] = $pieces['host']; $roots[] = $pieces['host'] . '/'; $domain = isset( $pieces['host'] ) ? $pieces['host'] : ''; if ( preg_match( '/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs ) ) { $roots[] = $regs['domain']; $roots[] = $regs['domain'] . '/'; } $parts = explode( '.', $pieces['host'] ); if ( count( $parts ) >= 3 ) { $roots[] = implode( '.', array_slice( $parts, -2 ) ); $roots[] = implode( '.', array_slice( $parts, -2 ) ) . '/'; } return $roots; }
php
{ "resource": "" }
q4193
CheckIfDead.parseURL
train
public function parseURL( $url ) { // Feeding fully encoded URLs will not work. So let's detect and decode if needed first. // This is just idiot proofing. // See if the URL is fully encoded by checking if the :// is encoded. // This prevents URLs where double encoded values aren't mistakenly decoded breaking the URL. if ( preg_match( '/^([a-z0-9\+\-\.]*)(?:%3A%2F%2F|%3A\/\/|:%2F%2F)/i', $url ) ) { // First let's break the fragment out to prevent accidentally mistaking a decoded %23 as a # $fragment = parse_url( $url, PHP_URL_FRAGMENT ); if ( !is_null( $fragment ) ) { $url = strstr( $url, "#", true ); } // Decode URL $url = rawurldecode( $url ); // Re-encode the remaining #'s $url = str_replace( "#", "%23", $url ); // Reattach the fragment if ( !is_null( $fragment ) ) { $url .= "#$fragment"; } } // Sometimes the scheme is followed by a single slash instead of a double. // Web browsers and archives support this, so we should too. if ( preg_match( '/^([a-z0-9\+\-\.]*:)?\/([^\/].+)/i', $url, $match ) ) { $url = $match[1] . "//" . $match[2]; } // Sometimes protocol relative URLs are not formatted correctly // This checks to see if the URL starts with :/ or :// // We will assume http in these cases if ( preg_match( '/^:\/\/?([^\/].+)/i', $url, $match ) ) { $url = "http://" . $match[1]; } // If we're missing the scheme and double slashes entirely, assume http. // The parse_url function fails without this if ( !preg_match( '/(?:[a-z0-9\+\-\.]*:)?\/\//i', $url ) ) { $url = "http://" . $url; } $encodedUrl = preg_replace_callback( '%[^:/@?&=#;]+%sD', function ( $matches ) { return urlencode( $matches[0] ); }, $url ); $parts = parse_url( $encodedUrl ); // Check if the URL was actually parsed. if ( $parts !== false ) { foreach ( $parts as $name => $value ) { $parts[$name] = urldecode( $value ); } } return $parts; }
php
{ "resource": "" }
q4194
CheckIfDead.cleanURL
train
public function cleanURL( $input ) { // scheme and www $url = preg_replace( '/^((https?:|ftp:)?(\/\/))?(www\.)?/', '', $input ); // fragment $url = preg_replace( '/#.*/', '', $url ); // trailing slash $url = preg_replace( '{/$}', '', $url ); return $url; }
php
{ "resource": "" }
q4195
CNabuSiteAliasHostBase.setSiteAliasId
train
public function setSiteAliasId(int $nb_site_alias_id) : CNabuDataObject { if ($nb_site_alias_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_site_alias_id") ); } $this->setValue('nb_site_alias_id', $nb_site_alias_id); return $this; }
php
{ "resource": "" }
q4196
CNabuSiteAliasHostBase.setServerHostId
train
public function setServerHostId(int $nb_server_host_id) : CNabuDataObject { if ($nb_server_host_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_server_host_id") ); } $this->setValue('nb_server_host_id', $nb_server_host_id); return $this; }
php
{ "resource": "" }
q4197
CNabuSiteAliasHostBase.setLastUpdateErrorCode
train
public function setLastUpdateErrorCode(int $last_update_error_code = 0) : CNabuDataObject { if ($last_update_error_code === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$last_update_error_code") ); } $this->setValue('nb_site_alias_host_last_update_error_code', $last_update_error_code); return $this; }
php
{ "resource": "" }
q4198
CNabuHTTPRenderDescriptor.setKey
train
public function setKey($key) { if ($key === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$key") ); } $this->setValue("nb_http_render_descriptor_key", $key); return $this; }
php
{ "resource": "" }
q4199
CNabuHTTPRenderDescriptor.setClassName
train
public function setClassName($class_name) { if ($class_name === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$class_name") ); } $implements_list = class_implements($class_name, true); if (is_array($implements_list) && array_search('nabu\http\interfaces\INabuHTTPResponseRender', $implements_list) ) { $this->setValue("nb_http_render_descriptor_class_name", $class_name); } else { throw new ENabuCoreException(ENabuCoreException::ERROR_INVALID_RENDER_DESCRIPTOR_CLASS); } return $this; }
php
{ "resource": "" }