_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q259700 | gapi.accountObjectMapper | test | protected function accountObjectMapper($json_string) {
$json = json_decode($json_string, true);
$results = array();
foreach ($json['items'] as $item) {
foreach ($item['webProperties'] as $property) {
if (isset($property['profiles'][0]['id'])) {
$property['ProfileId'] = $property['pr... | php | {
"resource": ""
} |
q259701 | gapi.reportObjectMapper | test | protected function reportObjectMapper($json_string) {
$json = json_decode($json_string, true);
$this->results = null;
$results = array();
$report_aggregate_metrics = array();
//Load root parameters
// Start with elements from the root level of the JSON that aren't themselves arrays.
$rep... | php | {
"resource": ""
} |
q259702 | gapi.ArrayKeyExists | test | public static function ArrayKeyExists($key, $search) {
if (array_key_exists($key, $search)) {
return $key;
}
if (!(is_string($key) && is_array($search))) {
return false;
}
$key = strtolower($key);
foreach ($search as $k => $v) {
if (strtolower($k) == $key) {
return $k;
... | php | {
"resource": ""
} |
q259703 | gapiOAuth2.fetchToken | test | public function fetchToken($client_email, $key_file, $delegate_email = null) {
$header = array(
"alg" => self::header_alg,
"typ" => self::header_typ,
);
$claimset = array(
"iss" => $client_email,
"scope" => self::scope_url,
"aud" => self::request_url,
"exp" => time() + (... | php | {
"resource": ""
} |
q259704 | gapiRequest.getUrl | test | public function getUrl($get_variables=null) {
if (is_array($get_variables)) {
$get_variables = '?' . str_replace('&', '&', urldecode(http_build_query($get_variables, '', '&')));
} else {
$get_variables = null;
}
return $this->url . $get_variables;
} | php | {
"resource": ""
} |
q259705 | gapiRequest.post | test | public function post($get_variables=null, $post_variables=null, $headers=null) {
return $this->request($get_variables, $post_variables, $headers);
} | php | {
"resource": ""
} |
q259706 | gapiRequest.get | test | public function get($get_variables=null, $headers=null) {
return $this->request($get_variables, null, $headers);
} | php | {
"resource": ""
} |
q259707 | gapiRequest.request | test | public function request($get_variables=null, $post_variables=null, $headers=null) {
$interface = self::http_interface;
if (self::http_interface == 'auto')
$interface = function_exists('curl_exec') ? 'curl' : 'fopen';
switch ($interface) {
case 'curl':
return $this->curlRequest($get_var... | php | {
"resource": ""
} |
q259708 | gapiRequest.curlRequest | test | private function curlRequest($get_variables=null, $post_variables=null, $headers=null) {
$ch = curl_init();
if (is_array($get_variables)) {
$get_variables = '?' . str_replace('&', '&', urldecode(http_build_query($get_variables, '', '&')));
} else {
$get_variables = null;
}
curl_set... | php | {
"resource": ""
} |
q259709 | gapiRequest.fopenRequest | test | private function fopenRequest($get_variables=null, $post_variables=null, $headers=null) {
$http_options = array('method'=>'GET', 'timeout'=>3);
$string_headers = '';
if (is_array($headers)) {
foreach ($headers as $key => $value) {
$string_headers .= "$key: $value\r\n";
}
}
if (... | php | {
"resource": ""
} |
q259710 | DashboardRecentFilesPanel.RecentFiles | test | public function RecentFiles() {
$records = File::get()
->filter(array(
'ClassName:not' => 'Folder'
))
->sort("LastEdited DESC")
->limit($this->Count);
$set = ArrayList::create(array());
foreach($records as $r) {
$set->push(ArrayData::create(array(
'EditLink' => Injector::inst()->get("AssetA... | php | {
"resource": ""
} |
q259711 | DashboardPanel.duplicate | test | public function duplicate($dowrite = true) {
$clone = parent::duplicate(true);
foreach($this->has_many() as $relationName => $relationClass) {
foreach($this->$relationName() as $relObject) {
$relClone = $relObject->duplicate(false);
$relClone->DashboardPanelID = $clone->ID;
$relClone->write();
}
... | php | {
"resource": ""
} |
q259712 | DashboardModelAdminPanel.getTemplate | test | protected function getTemplate() {
$templateName = get_class($this) . '_' . $this->ModelAdminClass . '_' . $this->ModelAdminModel;
if(SS_TemplateLoader::instance()->findTemplates($templateName)) {
return $templateName;
}
return parent::getTemplate();
} | php | {
"resource": ""
} |
q259713 | DashboardModelAdminPanel.ViewAllLink | test | public function ViewAllLink() {
if($this->ModelAdminClass && $this->ModelAdminModel) {
$url_segment = Injector::inst()->get($this->ModelAdminClass)->Link();
return Controller::join_links($url_segment, $this->ModelAdminModel);
}
} | php | {
"resource": ""
} |
q259714 | DashboardModelAdminPanel.ModelAdminItems | test | public function ModelAdminItems() {
if($this->ModelAdminModel) {
$SNG= Injector::inst()->get($this->ModelAdminModel);
if($SNG->hasExtension("Versioned")) {
Versioned::reading_stage("Stage");
}
$records = DataList::create($this->ModelAdminModel)
->limit($this->Count)
->sort("LastEdited DESC");
... | php | {
"resource": ""
} |
q259715 | DashboardModelAdmin_PanelRequest.modelsforpanel | test | public function modelsforpanel(SS_HTTPRequest $r) {
$panel = $r->requestVar('modeladminpanel');
return Convert::array2json($this->panel->getManagedModelsFor($panel));
} | php | {
"resource": ""
} |
q259716 | Dashboard.providePermissions | test | public function providePermissions() {
$title = _t("Dashboard.MENUTITLE", LeftAndMain::menu_title_for_class('Dashboard'));
return array(
"CMS_ACCESS_Dashboard" => array(
'name' => _t('Dashboard.ACCESS', "Access to '{title}' section", array('title' => $title)),
'category' => _t('Permission.CMS_ACCESS_CATE... | php | {
"resource": ""
} |
q259717 | Dashboard.sort | test | public function sort(SS_HTTPRequest $r) {
if($sort = $r->requestVar('dashboard-panel')) {
foreach($sort as $index => $id) {
if($panel = DashboardPanel::get()->byID((int) $id)) {
if($panel->MemberID == Member::currentUserID()) {
$panel->SortOrder = $index;
$panel->write();
}
} ... | php | {
"resource": ""
} |
q259718 | Dashboard.setdefault | test | public function setdefault(SS_HTTPRequest $r) {
foreach(SiteConfig::current_site_config()->DashboardPanels() as $panel) {
$panel->delete();
}
foreach(Member::currentUser()->DashboardPanels() as $panel) {
$clone = $panel->duplicate();
$clone->MemberID = 0;
$clone->SiteConfigID = SiteConfig::current_sit... | php | {
"resource": ""
} |
q259719 | Dashboard.applytoall | test | public function applytoall(SS_HTTPRequest $r) {
$members = Permission::get_members_by_permission(array("CMS_ACCESS_Dashboard","ADMIN"));
foreach($members as $member) {
if($member->ID == Member::currentUserID()) continue;
$member->DashboardPanels()->removeAll();
foreach(Member::currentUser()->DashboardP... | php | {
"resource": ""
} |
q259720 | Dashboard_PanelRequest.panel | test | public function panel(SS_HTTPRequest $r) {
if($this->panel->canView()) {
return $this->panel->PanelHolder();
}
return $this->httpError(403);
} | php | {
"resource": ""
} |
q259721 | Dashboard_PanelRequest.delete | test | public function delete(SS_HTTPRequest $r) {
if($this->panel->canDelete()) {
$this->panel->delete();
return new SS_HTTPResponse("OK");
}
} | php | {
"resource": ""
} |
q259722 | Dashboard_PanelRequest.ConfigureForm | test | public function ConfigureForm() {
$form = Form::create(
$this,
"ConfigureForm",
$this->panel->getConfiguration(),
FieldList::create(
FormAction::create("saveConfiguration",_t('Dashboard.SAVE','Save'))
->setUseButtonTag(true)
->addExtraClass('ss-ui-action-constructive'),
FormAction::creat... | php | {
"resource": ""
} |
q259723 | Dashboard_PanelRequest.saveConfiguration | test | public function saveConfiguration($data, $form) {
$panel = $this->panel;
$form->saveInto($panel);
$panel->write();
} | php | {
"resource": ""
} |
q259724 | DashboardSectionEditorPanel.Icon | test | public function Icon() {
$s = $this->Subject ? $this->Subject : "SiteTree";
$file = Config::inst()->get($s, "icon", Config::INHERITED).".png";
if(!Director::fileExists($file)) {
$file = Config::inst()->get($s, "icon", Config::INHERITED)."-file.gif";
}
if(!Director::fileExists($file)) {
$file = "dashboar... | php | {
"resource": ""
} |
q259725 | DashboardGoogleAnalyticsPanel.seconds_to_minutes | test | public static function seconds_to_minutes($seconds) {
$minResult = floor($seconds/60);
if($minResult < 10){$minResult = 0 . $minResult;}
$secResult = ($seconds/60 - $minResult)*60;
if($secResult < 10){$secResult = 0 . round($secResult);}
else { $secResult = round($secResult); }
return $min... | php | {
"resource": ""
} |
q259726 | DashboardGoogleAnalyticsPanel.api | test | public function api() {
if(!$this->gapi) {
try {
$this->gapi = new gapi(
self::config()->email,
Director::getAbsFile(self::config()->key_file_path)
);
}
catch(Exception $e) {
$this->error = $e->getMessage();
return $this->gapi;
}
}
return $this->gapi;
} | php | {
"resource": ""
} |
q259727 | DashboardGoogleAnalyticsPanel.getConfiguration | test | public function getConfiguration() {
$fields = parent::getConfiguration();
if(!$this->isValid()) {
$fields->push(LiteralField::create("warning",_t('Dashboard.NOGOOGLEACCOUNT','<p>You have not configured a valid Google Analytics account.</p>')));
return $fields;
}
$pages = $this->getHierarchy(0);
$fiel... | php | {
"resource": ""
} |
q259728 | DashboardGoogleAnalyticsPanel.IsConfigured | test | public function IsConfigured() {
$c = self::config();
return (
$c->email &&
$c->key_file_path &&
$c->profile &&
Director::fileExists($c->key_file_path)
);
} | php | {
"resource": ""
} |
q259729 | DashboardGoogleAnalyticsPanel.getPath | test | public function getPath() {
if($this->PathType == "list") {
return $this->SubjectPage()->exists() ? $this->SubjectPage()->Link() : "/";
}
elseif($this->PathType == "custom") {
return $this->CustomPath;
}
} | php | {
"resource": ""
} |
q259730 | DashboardGoogleAnalyticsPanel.ChartTitle | test | public function ChartTitle() {
$stamp = $this->getStartDateStamp();
$key = $this->DateFormat == "dmy" ? "j M, Y" : "M j, Y";
$title = date($key, $stamp) . " - " . date($key);
if($this->getPath()) {
$title .= " ("._t('Dashboard.PATH','Path').": {$this->getPath()})";
}
else {
$title .= " ("._t('Dashboar... | php | {
"resource": ""
} |
q259731 | Single.read | test | public function read(BinaryReader &$br, $length = null)
{
if (!$br->canReadBytes(4)) {
throw new \OutOfBoundsException('Cannot read 4-bytes floating-point, it exceeds the boundary of the file');
}
$segment = $br->readFromHandle(4);
if ($br->getCurrentBit() !== 0) {
... | php | {
"resource": ""
} |
q259732 | Byte.read | test | public function read(BinaryReader &$br, $length = null)
{
if (!is_int($length)) {
throw new InvalidDataException('The length parameter must be an integer');
}
$br->align();
if (!$br->canReadBytes($length)) {
throw new \OutOfBoundsException('Cannot read bytes... | php | {
"resource": ""
} |
q259733 | Endian.convert | test | public function convert($value)
{
$data = dechex($value);
if (strlen($data) <= 2) {
return $value;
}
$unpack = unpack("H*", strrev(pack("H*", $data)));
$converted = hexdec($unpack[1]);
return $converted;
} | php | {
"resource": ""
} |
q259734 | Bit.read | test | public function read(BinaryReader &$br, $length)
{
if (!is_int($length)) {
throw new InvalidDataException('The length parameter must be an integer');
}
$bitmask = new BitMask();
$result = 0;
$bits = $length;
$shift = $br->getCurrentBit();
if ($sh... | php | {
"resource": ""
} |
q259735 | Bit.readSigned | test | public function readSigned(&$br, $length)
{
$this->setSigned(true);
$value = $this->read($br, $length);
$this->setSigned(false);
return $value;
} | php | {
"resource": ""
} |
q259736 | Int16.read | test | public function read(BinaryReader &$br, $length = null)
{
if (!$br->canReadBytes(2)) {
throw new \OutOfBoundsException('Cannot read 16-bit int, it exceeds the boundary of the file');
}
$endian = $br->getEndian() == Endian::ENDIAN_BIG ? $this->endianBig : $this->endianLittle;
... | php | {
"resource": ""
} |
q259737 | Int16.readSigned | test | public function readSigned(&$br)
{
$this->setEndianBig('s');
$this->setEndianLittle('s');
$value = $this->read($br);
$this->setEndianBig('n');
$this->setEndianLittle('v');
$endian = new Endian();
if ($br->getMachineByteOrder() != Endian::ENDIAN_LITTLE && $b... | php | {
"resource": ""
} |
q259738 | Int64.read | test | public function read(BinaryReader &$br, $length = null)
{
if (!$br->canReadBytes(8)) {
throw new \OutOfBoundsException('Cannot read 64-bit int, it exceeds the boundary of the file');
}
$endian = $br->getEndian() == Endian::ENDIAN_BIG ? $this->endianBig : $this->endianLittle;
... | php | {
"resource": ""
} |
q259739 | Int64.readSigned | test | public function readSigned(&$br)
{
$value = $this->read($br);
if (bccomp($value, bcpow(2, 63)) >= 0) {
$value = bcsub($value, bcpow(2, 64));
}
return $value;
} | php | {
"resource": ""
} |
q259740 | StackdriverExporter.export | test | public function export(array $spans)
{
if (empty($spans)) {
return false;
}
// Pull the traceId from the first span
$spans = array_map([SpanConverter::class, 'convertSpan'], $spans);
$rootSpan = $spans[0];
$trace = self::$client->trace(
$rootS... | php | {
"resource": ""
} |
q259741 | StackdriverExporter.getCallback | test | protected function getCallback()
{
if (!isset(self::$client)) {
self::$client = new TraceClient($this->clientConfig);
}
return [self::$client, $this->batchMethod];
} | php | {
"resource": ""
} |
q259742 | PHPCrawlerRobotsTxtParser.parseRobotsTxt | test | public function parseRobotsTxt(PHPCrawlerURLDescriptor $Url, $user_agent_string)
{
PHPCrawlerBenchmark::start("processing_robotstxt");
// URL of robots-txt
$RobotsTxtUrl = self::getRobotsTxtURL($Url);
// Get robots.txt-content related to the given URL
$robots_txt_content = $this-... | php | {
"resource": ""
} |
q259743 | PHPCrawlerRobotsTxtParser.getApplyingLines | test | protected function getApplyingLines(&$robots_txt_content, $user_agent_string)
{
// Split the content into its lines
$robotstxt_lines = explode("\n", $robots_txt_content);
// Flag that will get TRUE if the loop over the lines gets
// into a section that applies to our user_agent_string
... | php | {
"resource": ""
} |
q259744 | PHPCrawlerRobotsTxtParser.buildRegExpressions | test | protected function buildRegExpressions(&$applying_lines, $base_url)
{
// First, get all "Disallow:"-pathes
$disallow_pathes = array();
for ($x=0; $x<count($applying_lines); $x++)
{
if (preg_match("#^Disallow:# i", $applying_lines[$x]))
{
preg_match("#^Disallow:[ ]*(.*)#", ... | php | {
"resource": ""
} |
q259745 | PHPCrawlerRobotsTxtParser.getRobotsTxtContent | test | protected function getRobotsTxtContent(PHPCrawlerURLDescriptor $Url)
{
// Request robots-txt
$this->PageRequest->setUrl($Url);
$PageInfo = $this->PageRequest->sendRequest();
// Return content of the robots.txt-file if it was found, otherwie
// reutrn NULL
if ($PageInfo->http_status_co... | php | {
"resource": ""
} |
q259746 | PHPCrawlerRobotsTxtParser.getRobotsTxtURL | test | public static function getRobotsTxtURL(PHPCrawlerURLDescriptor $Url)
{
$url_parts = PHPCrawlerUtils::splitURL($Url->url_rebuild);
$robots_txt_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"] . "/robots.txt";
return new PHPCrawlerURLDescriptor($robots_txt_url);
} | php | {
"resource": ""
} |
q259747 | PHPCrawler.initCrawlerProcess | test | protected function initCrawlerProcess()
{
// Create working directory
$this->createWorkingDirectory();
// Setup url-cache
if ($this->url_cache_type == PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE)
$this->LinkCache = new PHPCrawlerSQLiteURLCache($this->working_directory."urlcache.db3", t... | php | {
"resource": ""
} |
q259748 | PHPCrawler.goMultiProcessed | test | public function goMultiProcessed($process_count = 3, $multiprocess_mode = 1)
{
$this->multiprocess_mode = $multiprocess_mode;
// Check if fork is supported
if (!function_exists("pcntl_fork"))
{
throw new Exception("PHPCrawl running with multi processes not supported in this PHP-envi... | php | {
"resource": ""
} |
q259749 | PHPCrawler.startChildProcessLoop | test | protected function startChildProcessLoop()
{
$this->initCrawlerProcess();
// Call overidable method initChildProcess()
$this->initChildProcess();
// Start benchmark (if single-processed)
if ($this->is_chlid_process == false)
{
PHPCrawlerBenchmark::start("crawling_pro... | php | {
"resource": ""
} |
q259750 | PHPCrawler.checkForAbort | test | protected function checkForAbort()
{
PHPCrawlerBenchmark::start("checkning_for_abort");
$abort_reason = null;
// Get current status
$crawler_status = $this->ProcessCommunication->getCrawlerStatus();
// if crawlerstatus already marked for ABORT
if ($crawler_status->abo... | php | {
"resource": ""
} |
q259751 | PHPCrawler.createWorkingDirectory | test | protected function createWorkingDirectory()
{
$this->working_directory = $this->working_base_directory."phpcrawl_tmp_".$this->crawler_uniqid.DIRECTORY_SEPARATOR;
// Check if writable
if (!is_writeable($this->working_base_directory))
{
throw new Exception("Error creating working direc... | php | {
"resource": ""
} |
q259752 | PHPCrawler.getProcessReport | test | public function getProcessReport()
{
// Get current crawler-Status
$CrawlerStatus = $this->crawlerStatus;
// Create report
$Report = new PHPCrawlerProcessReport();
$Report->links_followed = $CrawlerStatus->links_followed;
$Report->files_received = $CrawlerStatus->documents_... | php | {
"resource": ""
} |
q259753 | PHPCrawler.addLinkPriority | test | function addLinkPriority($regex, $level)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true && preg_match("/^[0-9]*$/", $level))
{
$c = count($this->link_priority_array);
$this->link_priority_array[$c]["match"] = trim($regex);
$this->link_pr... | php | {
"resource": ""
} |
q259754 | PHPCrawler.setFollowMode | test | public function setFollowMode($follow_mode)
{
// Check mode
if (!preg_match("/^[0-3]{1}$/", $follow_mode)) return false;
$this->UrlFilter->general_follow_mode = $follow_mode;
return true;
} | php | {
"resource": ""
} |
q259755 | PHPCrawler.setTrafficLimit | test | public function setTrafficLimit($bytes, $complete_requested_files = true)
{
if (preg_match("#^[0-9]*$#", $bytes))
{
$this->traffic_limit = $bytes;
return true;
}
else return false;
} | php | {
"resource": ""
} |
q259756 | PHPCrawler.setWorkingDirectory | test | public function setWorkingDirectory($directory)
{
if (is_writeable($this->working_base_directory))
{
$this->working_base_directory = $directory;
return true;
}
else return false;
} | php | {
"resource": ""
} |
q259757 | PHPCrawler.setProxy | test | public function setProxy($proxy_host, $proxy_port, $proxy_username = null, $proxy_password = null)
{
$this->PageRequest->setProxy($proxy_host, $proxy_port, $proxy_username, $proxy_password);
} | php | {
"resource": ""
} |
q259758 | PHPCrawler.setConnectionTimeout | test | public function setConnectionTimeout($timeout)
{
if (preg_match("#[0-9]+#", $timeout))
{
$this->PageRequest->socketConnectTimeout = $timeout;
return true;
}
else
{
return false;
}
} | php | {
"resource": ""
} |
q259759 | PHPCrawler.setStreamTimeout | test | public function setStreamTimeout($timeout)
{
if (preg_match("#[0-9]+#", $timeout))
{
$this->PageRequest->socketReadTimeout = $timeout;
return true;
}
else
{
return false;
}
} | php | {
"resource": ""
} |
q259760 | PHPCrawler.resume | test | public function resume($crawler_id)
{
if ($this->resumtion_enabled == false)
throw new Exception("Resumption was not enalbled, call enableResumption() before calling the resume()-method!");
// Adobt crawler-id
$this->crawler_uniqid = $crawler_id;
if (!file_exists($this->working... | php | {
"resource": ""
} |
q259761 | PHPCrawlerURLFilter.setBaseURL | test | public function setBaseURL($starting_url)
{
$this->starting_url = $starting_url;
// Parts of the starting-URL
$this->starting_url_parts = PHPCrawlerUtils::splitURL($starting_url);
} | php | {
"resource": ""
} |
q259762 | PHPCrawlerURLFilter.keepRedirectUrls | test | public static function keepRedirectUrls(PHPCrawlerDocumentInfo $DocumentInfo)
{
$cnt = count($DocumentInfo->links_found_url_descriptors);
for ($x=0; $x<$cnt; $x++)
{
if ($DocumentInfo->links_found_url_descriptors[$x]->is_redirect_url == false)
{
$DocumentInfo->links_found_url_de... | php | {
"resource": ""
} |
q259763 | PHPCrawlerURLFilter.urlMatchesRules | test | protected function urlMatchesRules(PHPCrawlerURLDescriptor $url)
{
// URL-parts of the URL to check against the filter-rules
$url_parts = PHPCrawlerUtils::splitURL($url->url_rebuild);
// Kick out all links that r NOT of protocol "http" or "https"
if ($url_parts["protocol"] != "http://" && ... | php | {
"resource": ""
} |
q259764 | PHPCrawlerURLFilter.addURLFilterRule | test | public function addURLFilterRule($regex)
{
$check = PHPCrawlerUtils::checkRegexPattern($regex); // Check pattern
if ($check == true)
{
$this->url_filter_rules[] = trim($regex);
}
return $check;
} | php | {
"resource": ""
} |
q259765 | PHPCrawlerURLFilter.addURLFilterRules | test | public function addURLFilterRules($regex_array)
{
$cnt = count($regex_array);
for ($x=0; $x<$cnt; $x++)
{
$this->addURLFilterRule($regex_array[$x]);
}
} | php | {
"resource": ""
} |
q259766 | PHPCrawlerSQLiteURLCache.markUrlAsFollowed | test | public function markUrlAsFollowed(PHPCrawlerURLDescriptor $UrlDescriptor)
{
PHPCrawlerBenchmark::start("marking_url_as_followes");
$hash = md5($UrlDescriptor->url_rebuild);
$this->PDO->exec("UPDATE urls SET processed = 1, in_process = 0 WHERE distinct_hash = '".$hash."';");
PHPCrawlerBenchmark::s... | php | {
"resource": ""
} |
q259767 | PHPCrawlerSQLiteURLCache.containsURLs | test | public function containsURLs()
{
PHPCrawlerBenchmark::start("checking_for_urls_in_cache");
$Result = $this->PDO->query("SELECT id FROM urls WHERE processed = 0 OR in_process = 1 LIMIT 1;");
$has_columns = $Result->fetchColumn();
$Result->closeCursor();
PHPCrawlerBench... | php | {
"resource": ""
} |
q259768 | PHPCrawlerMemoryURLCache.getAllURLs | test | public function getAllURLs()
{
$URLs = array();
@reset($this->urls);
while (list($pri_lvl) = @each($this->urls))
{
$cnt = count($this->urls[$pri_lvl]);
for ($x=0; $x<$cnt; $x++)
{
$URLs[] = &$this->urls[$pri_lvl][$x];
}
}
return $URLs;
... | php | {
"resource": ""
} |
q259769 | PHPCrawlerMemoryURLCache.addURLs | test | public function addURLs($urls)
{
//PHPCrawlerBenchmark::start("caching_urls");
$cnt = count($urls);
for ($x=0; $x<$cnt; $x++)
{
if ($urls[$x] != null)
{
$this->addURL($urls[$x]);
}
}
//PHPCrawlerBenchmark::stop("caching_urls");
} | php | {
"resource": ""
} |
q259770 | PHPCrawlerBenchmark.start | test | public static function start($identifier, $temporary_benchmark = false)
{
self::$benchmark_starttimes[$identifier] = self::getmicrotime();
if (isset(self::$benchmark_startcount[$identifier]))
self::$benchmark_startcount[$identifier] = self::$benchmark_startcount[$identifier] + 1;
else sel... | php | {
"resource": ""
} |
q259771 | PHPCrawlerBenchmark.stop | test | public static function stop($identifier)
{
if (isset(self::$benchmark_starttimes[$identifier]))
{
$elapsed_time = self::getmicrotime() - self::$benchmark_starttimes[$identifier];
if (isset(self::$benchmark_results[$identifier])) self::$benchmark_results[$identifier] += $elapsed_time;
... | php | {
"resource": ""
} |
q259772 | PHPCrawlerBenchmark.resetAll | test | public static function resetAll($retain_benchmarks = array())
{
// If no benchmarks should be retained
if (count($retain_benchmarks) == 0)
{
self::$benchmark_results = array();
return;
}
// Else reset all benchmarks BUT the retain_benachmarks
@reset(self::$benchmark_... | php | {
"resource": ""
} |
q259773 | PHPCrawlerBenchmark.getAllBenchmarks | test | public static function getAllBenchmarks()
{
$benchmarks = array();
@reset(self::$benchmark_results);
while (list($identifier, $elapsed_time) = @each(self::$benchmark_results))
{
if (!isset(self::$temporary_benchmarks[$identifier])) $benchmarks[$identifier] = $elapsed_time;
}
... | php | {
"resource": ""
} |
q259774 | PHPCrawlerBenchmark.getmicrotime | test | public static function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
} | php | {
"resource": ""
} |
q259775 | PHPCrawlerSQLiteCookieCache.openConnection | test | protected function openConnection($create_tables = false)
{
//PHPCrawlerBenchmark::start("Connecting to SQLite-cache-db");
// Open sqlite-file
try
{
$this->PDO = new PDO("sqlite:".$this->sqlite_db_file);
}
catch (Exception $e)
{
throw new Exception("Error creati... | php | {
"resource": ""
} |
q259776 | PHPCrawlerURLCacheBase.getDistinctURLHash | test | protected function getDistinctURLHash(PHPCrawlerURLDescriptor $UrlDescriptor)
{
if ($this->url_distinct_property == self::URLHASH_URL)
return md5($UrlDescriptor->url_rebuild);
elseif ($this->url_distinct_property == self::URLHASH_RAWLINK)
return md5($UrlDescriptor->link_raw);
else
... | php | {
"resource": ""
} |
q259777 | PHPCrawlerURLCacheBase.getUrlPriority | test | protected function getUrlPriority($url)
{
$cnt = count($this->url_priorities);
for ($x=0; $x<$cnt; $x++)
{
if (preg_match($this->url_priorities[$x]["match"], $url))
{
return $this->url_priorities[$x]["level"];
}
}
return 0;
} | php | {
"resource": ""
} |
q259778 | PHPCrawlerURLCacheBase.addLinkPriority | test | public function addLinkPriority($regex, $level)
{
$c = count($this->url_priorities);
$this->url_priorities[$c]["match"] = trim($regex);
$this->url_priorities[$c]["level"] = trim($level);
// Sort url-priortie-array so that high priority-levels come firts.
PHPCrawlerUtils::sort2dArray($t... | php | {
"resource": ""
} |
q259779 | PHPCrawlerURLCacheBase.addLinkPriorities | test | public function addLinkPriorities($priority_array)
{
for ($x=0; $x<count($priority_array); $x++)
{
$this->addLinkPriority($priority_array[$x]["match"], $priority_array[$x]["level"]);
}
} | php | {
"resource": ""
} |
q259780 | PHPCrawlerDocumentInfoQueue.addDocumentInfo | test | public function addDocumentInfo(PHPCrawlerDocumentInfo $DocInfo)
{
// If queue is full -> wait a little
while ($this->getDocumentInfoCount() >= $this->queue_max_size)
{
sleep(0.5);
}
$this->createPreparedStatements();
$ser = serialize($DocInfo);
$this->PDO-... | php | {
"resource": ""
} |
q259781 | PHPCrawlerDocumentInfoQueue.getNextDocumentInfo | test | public function getNextDocumentInfo()
{
$this->createPreparedStatements();
$this->prepared_select_statement->execute();
$this->prepared_select_statement->bindColumn("document_info", $doc_info, PDO::PARAM_LOB);
$this->prepared_select_statement->bindColumn("id", $id);
$row = $this->prep... | php | {
"resource": ""
} |
q259782 | PHPCrawlerUrlPartsDescriptor.fromURL | test | public static function fromURL($url)
{
$parts = PHPCrawlerUtils::splitURL($url);
$tmp = new PHPCrawlerUrlPartsDescriptor();
$tmp->protocol = $parts["protocol"];
$tmp->host = $parts["host"];
$tmp->path = $parts["path"];
$tmp->file = $parts["file"];
$tmp->domain = $parts[... | php | {
"resource": ""
} |
q259783 | PHPCrawlerLinkFinder.setSourceUrl | test | public function setSourceUrl(PHPCrawlerURLDescriptor $SourceUrl)
{
$this->SourceUrl = $SourceUrl;
$this->baseUrlParts = PHPCrawlerUrlPartsDescriptor::fromURL($SourceUrl->url_rebuild);
} | php | {
"resource": ""
} |
q259784 | PHPCrawlerLinkFinder.findRedirectLinkInHeader | test | protected function findRedirectLinkInHeader(&$http_header)
{
PHPCrawlerBenchmark::start("checking_for_redirect_link");
// Get redirect-URL or link from header
$redirect_link = PHPCrawlerUtils::getRedirectURLFromHeader($http_header);
// Add redirect-URL to linkcache
if ($redirect_... | php | {
"resource": ""
} |
q259785 | PHPCrawlerUserSendDataCache.addPostData | test | public function addPostData($url_regex, $post_data_array)
{
// Check regex
$regex_okay = PHPCrawlerUtils::checkRegexPattern($url_regex);
if ($regex_okay == true)
{
@reset($post_data_array);
while (list($key, $value) = @each($post_data_array))
{
// Add data to... | php | {
"resource": ""
} |
q259786 | PHPCrawlerProcessCommunication.updateCrawlerStatus | test | public function updateCrawlerStatus($PageInfo, $abort_reason = null, $first_content_url = null)
{
PHPCrawlerBenchmark::start("updating_crawler_status");
// Set semaphore if crawler is multiprocessed
if ($this->multiprocess_mode == PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE || $... | php | {
"resource": ""
} |
q259787 | PHPCrawlerProcessCommunication.registerChildPID | test | public function registerChildPID($pid)
{
$sem_key = sem_get($this->crawler_uniqid);
sem_acquire($sem_key);
file_put_contents($this->working_directory."pids", $pid."\n", FILE_APPEND);
sem_release($sem_key);
} | php | {
"resource": ""
} |
q259788 | PHPCrawlerProcessCommunication.getChildPIDs | test | public function getChildPIDs($process_count = null)
{
$child_pids = array();
$try = true;
while ($try == true)
{
if (file_exists($this->working_directory."pids"))
{
$ct = file_get_contents($this->working_directory."pids");
$child_pids = preg_split("#\n#", $c... | php | {
"resource": ""
} |
q259789 | PHPCrawlerProcessCommunication.killChildProcesses | test | public function killChildProcesses()
{
$child_pids = $this->getChildPIDs();
for ($x=0; $x<count($child_pids); $x++)
{
posix_kill($child_pids[$x], SIGKILL);
}
} | php | {
"resource": ""
} |
q259790 | PHPCrawlerDNSCache.getIP | test | public function getIP($hostname)
{
// If host already was queried
if (isset($this->host_ip_array[$hostname]))
{
return $this->host_ip_array[$hostname];
}
// Else do DNS-query
else
{
$ip = gethostbyname($hostname);
$this->host_ip_array[$hostname] = $ip;
... | php | {
"resource": ""
} |
q259791 | PHPCrawlerDNSCache.urlHostInCache | test | public function urlHostInCache(PHPCrawlerURLDescriptor $URL)
{
$url_parts = PHPCrawlerUtils::splitURL($URL->url_rebuild);
return $this->hostInCache($url_parts["host"]);
} | php | {
"resource": ""
} |
q259792 | ExpressionTraverser.removeVisitor | test | public function removeVisitor(ExpressionVisitor $visitor)
{
while (false !== ($key = array_search($visitor, $this->visitors, true))) {
unset($this->visitors[$key]);
}
$this->visitors = array_values($this->visitors);
} | php | {
"resource": ""
} |
q259793 | ExpressionTraverser.traverse | test | public function traverse(Expression $expr)
{
// Do one full traversal per visitor. If any of the visitors removes
// the expression entirely, subsequent visitors are not invoked.
foreach ($this->visitors as $visitor) {
$expr = $this->traverseForVisitor($expr, $visitor);
... | php | {
"resource": ""
} |
q259794 | Expr.filter | test | public static function filter($collection, Expression $expr)
{
if (is_array($collection)) {
return array_filter($collection, array($expr, 'evaluate'));
}
if (!($collection instanceof Traversable && $collection instanceof ArrayAccess)) {
throw new InvalidArgumentExcep... | php | {
"resource": ""
} |
q259795 | Expr.method | test | public static function method($methodName, $args)
{
$args = func_get_args();
$methodName = array_shift($args);
$expr = array_pop($args);
return new Method($methodName, $args, $expr);
} | php | {
"resource": ""
} |
q259796 | StringUtil.formatValue | test | public static function formatValue($value)
{
if (null === $value) {
return 'null';
}
if (true === $value) {
return 'true';
}
if (false === $value) {
return 'false';
}
if (is_string($value)) {
return '"'.$value... | php | {
"resource": ""
} |
q259797 | StringUtil.formatValues | test | public static function formatValues(array $values)
{
foreach ($values as $key => $value) {
$values[$key] = self::formatValue($value);
}
return $values;
} | php | {
"resource": ""
} |
q259798 | Configure.write | test | public static function write($config, $value = null)
{
if (!is_array($config)) {
$config = [$config => $value];
}
foreach ($config as $name => $value) {
static::$values = Hash::insert(static::$values, $name, $value);
}
if (isset($config['debug'])) {
... | php | {
"resource": ""
} |
q259799 | Configure.consume | test | public static function consume($var)
{
if (strpos($var, '.') === false) {
if (!isset(static::$values[$var])) {
return null;
}
$value = static::$values[$var];
unset(static::$values[$var]);
return $value;
}
$value = H... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.