public function start_process() { if (!$this->path_to_xml_file) { return false; } if (!$this->valid_xml) { return false; } $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => DOC_ROOT . 'temp/xml_to_archive/')); $this->taxon_ids = array(); $this->media_ids = array(); $this->vernacular_name_ids = array(); $this->reference_ids = array(); $this->agent_ids = array(); $reader = new \XMLReader(); $file = file_get_contents($this->path_to_xml_file); $file = iconv("UTF-8", "UTF-8//IGNORE", $file); $reader->XML($file); $i = 0; while (@$reader->read()) { if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "taxon") { $taxon_xml = $reader->readOuterXML(); $t = simplexml_load_string($taxon_xml, null, LIBXML_NOCDATA); if ($t) { $this->add_taxon_to_archive($t); } $i++; if ($i % 100 == 0) { echo "Parsed taxon {$i} : " . time_elapsed() . "\n"; } // if($i >= 5000) break; } } $this->archive_builder->finalize(); }
private function lookup_block($start, $limit) { $query = "SELECT tc.id taxon_concept_id, he.id hierarchy_entry_id, he.visibility_id, he.vetted_id, v.view_order vetted_view_order, h.id hierarchy_id, h.browsable, h.label\n FROM taxon_concepts tc\n STRAIGHT_JOIN hierarchy_entries he ON (tc.id=he.taxon_concept_id)\n STRAIGHT_JOIN hierarchies h ON (he.hierarchy_id=h.id)\n STRAIGHT_JOIN vetted v ON (he.vetted_id=v.id)\n WHERE tc.id BETWEEN {$start} AND " . ($start + $limit) . " AND he.published=1"; static $j = 0; $all_entries = array(); foreach ($this->mysqli->iterate_file($query) as $row_num => $row) { if ($j % 50000 == 0) { echo "{$start} : {$j} : " . time_elapsed() . " : " . memory_get_usage() . "\n"; } $j++; $taxon_concept_id = $row[0]; $hierarchy_entry_id = $row[1]; $visibility_id = $row[2]; $vetted_id = $row[3]; $vetted_view_order = $row[4]; $hierarchy_id = $row[5]; $browsable = $row[6]; $label = $row[7]; if (!$browsable) { $browsable = 0; } if ($browsable == 'NULL') { $browsable = 0; } if (@(!$all_entries[$taxon_concept_id])) { $all_entries[$taxon_concept_id] = array(); } $all_entries[$taxon_concept_id][$hierarchy_id] = array('hierarchy_entry_id' => $hierarchy_entry_id, 'visibility_id' => $visibility_id, 'vetted_id' => $vetted_id, 'vetted_view_order' => $vetted_view_order, 'hierarchy_id' => $hierarchy_id, 'browsable' => $browsable, 'hierarchy_sort_order' => self::hierarchy_sort_order($label)); } $curated_best_entries = $this->lookup_curated_best_entries($start, $limit); $this->sort_and_insert_best_entries($all_entries, $curated_best_entries); }
function lookup_names($start, $limit, &$taxon_concept_ids = array()) { debug("querying names"); $query = "SELECT n.id, n.string FROM names n WHERE n.id "; if ($taxon_concept_ids) { $query .= "IN (" . implode(",", $taxon_concept_ids) . ")"; } else { $query .= "BETWEEN {$start} AND " . ($start + $limit); } static $i = 0; foreach ($this->mysqli_slave->iterate_file($query) as $row_num => $row) { if ($i % 100000 == 0) { echo " ===> {$i} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $i++; $name_id = $row[0]; $name_string = $row[1]; if (preg_match("/[0-9]\\/[0-9]/", $name_string, $arr)) { if (Name::is_surrogate($name_string)) { continue; } $canonical_form = trim($this->name_parser->lookup_string($name_string)); echo "{$name_id}\t{$name_string}\t{$canonical_form}\n"; } } }
public static function get_eol_photos($per_page, $page, $auth_token = "", $user_id = NULL, $start_date = NULL, $end_date = NULL) { global $used_image_ids; $response = self::pools_get_photos(FLICKR_EOL_GROUP_ID, "", $per_page, $page, $auth_token, $user_id, $start_date, $end_date); echo "\n page " . $response->photos->page . " of " . $response->photos->pages . " | total taxa = " . $response->photos->total . "\n"; echo "\n -- response count: " . count($response); echo "\n -- response photos count per page: " . count($response->photos->photo) . "\n"; static $count_taxa = 0; $page_taxa = array(); foreach ($response->photos->photo as $photo) { if (@$used_image_ids[$photo->id]) { continue; } $count_taxa++; echo "taxon {$count_taxa} ({$photo->id}): " . time_elapsed() . "\n"; $taxa = self::get_taxa_for_photo($photo->id, $photo->secret, $photo->lastupdate, $auth_token, $user_id); if ($taxa) { foreach ($taxa as $t) { $page_taxa[] = $t; } } $used_image_ids[$photo->id] = true; } return $page_taxa; }
function profile($str) { if (!defined('PROFILE') || !PROFILE) { return; } echo time_elapsed() . ":{$str};"; }
public function get_nodes() { $path = $this->download_directory . "/nodes.dmp"; foreach (new FileIterator($path) as $line_number => $line) { if ($line_number % 10000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = explode("\t|", $line); $tax_id = trim($line_data[0]); $parent_tax_id = trim($line_data[1]); $rank = trim($line_data[2]); $comments = trim($line_data[12]); if (!is_numeric($tax_id)) { continue; } if (!is_numeric($parent_tax_id)) { continue; } if ($rank == "no rank") { $rank = ""; } // tax_id 1 is a sudo-node named 'root'. Things with 1 as a parent are the real roots if ($parent_tax_id == 1) { $parent_tax_id = 0; } if (isset($this->taxon_names[$tax_id])) { $t = new \eol_schema\Taxon(); $t->taxonID = $tax_id; $t->scientificName = $this->taxon_names[$tax_id]; $t->parentNameUsageID = $parent_tax_id; $t->taxonRank = $rank; $t->taxonomicStatus = "valid"; $t->taxonRemarks = $comments; $this->archive_builder->write_object_to_file($t); if (isset($this->taxon_synonyms[$tax_id])) { foreach ($this->taxon_synonyms[$tax_id] as $name_class => $names) { if (in_array($name_class, array("genbank common name", "common name", "blast name"))) { foreach ($names as $name => $junk) { $v = new \eol_schema\VernacularName(); $v->taxonID = $tax_id; $v->vernacularName = $name; $v->language = "en"; $this->archive_builder->write_object_to_file($v); } } else { foreach ($names as $name => $junk) { $t = new \eol_schema\Taxon(); $t->taxonID = $tax_id . "_syn_" . md5($name . $name_class); $t->scientificName = $name; $t->acceptedNameUsageID = $tax_id; $t->taxonomicStatus = $name_class; $this->archive_builder->write_object_to_file($t); } } } } } } }
public function index() { $this->template->setTitle($this->lang->line('text_title')); $this->template->setHeading($this->lang->line('text_heading')); $this->template->setStyleTag(root_url('assets/js/daterange/daterangepicker-bs3.css'), 'daterangepicker-css', '100400'); $this->template->setScriptTag(root_url('assets/js/daterange/moment.min.js'), 'daterange-moment-js', '1000451'); $this->template->setScriptTag(root_url('assets/js/daterange/daterangepicker.js'), 'daterangepicker-js', '1000452'); $this->template->setScriptTag(root_url('assets/js/Chart.min.js'), 'chart-min-js', '1000453'); $data['total_menus'] = $this->Dashboard_model->getTotalMenus(); $data['current_month'] = mdate('%Y-%m', time()); $data['months'] = array(); $pastMonth = date('Y-m-d', strtotime(date('Y-m-01') . ' -3 months')); $futureMonth = date('Y-m-d', strtotime(date('Y-m-01') . ' +3 months')); for ($i = $pastMonth; $i <= $futureMonth; $i = date('Y-m-d', strtotime($i . ' +1 months'))) { $data['months'][mdate('%Y-%m', strtotime($i))] = mdate('%F', strtotime($i)); } $data['default_location_id'] = $this->config->item('default_location_id'); $data['locations'] = array(); $results = $this->Locations_model->getLocations(); foreach ($results as $result) { $data['locations'][] = array('location_id' => $result['location_id'], 'location_name' => $result['location_name']); } $filter = array(); $filter['page'] = '1'; $filter['limit'] = '10'; $data['activities'] = array(); $this->load->model('Activities_model'); $results = $this->Activities_model->getList($filter); foreach ($results as $result) { $data['activities'][] = array('activity_id' => $result['activity_id'], 'icon' => 'fa fa-tasks', 'message' => $result['message'], 'time' => mdate('%h:%i %A', strtotime($result['date_added'])), 'time_elapsed' => time_elapsed($result['date_added']), 'state' => $result['status'] === '1' ? 'read' : 'unread'); } $data['top_customers'] = array(); $results = $this->Dashboard_model->getTopCustomers($filter); foreach ($results as $result) { $data['top_customers'][] = array('first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'total_orders' => $result['total_orders'], 'total_sale' => $result['total_sale']); } $filter = array(); $filter['page'] = ''; $filter['limit'] = 10; $filter['sort_by'] = 'orders.date_added'; $filter['order_by'] = 'DESC'; $data['order_by_active'] = 'DESC'; $data['orders'] = array(); $this->load->model('Orders_model'); $results = $this->Orders_model->getList($filter); foreach ($results as $result) { $current_date = mdate('%d-%m-%Y', time()); $date_added = mdate('%d-%m-%Y', strtotime($result['date_added'])); if ($current_date === $date_added) { $date_added = $this->lang->line('text_today'); } else { $date_added = mdate('%d %M %y', strtotime($date_added)); } $data['orders'][] = array('order_id' => $result['order_id'], 'location_name' => $result['location_name'], 'first_name' => $result['first_name'], 'last_name' => $result['last_name'], 'order_status' => $result['status_name'], 'status_color' => $result['status_color'], 'order_time' => mdate('%H:%i', strtotime($result['order_time'])), 'order_type' => $result['order_type'] === '1' ? $this->lang->line('text_delivery') : $this->lang->line('text_collection'), 'date_added' => $date_added, 'edit' => site_url('orders/edit?id=' . $result['order_id'])); } $this->template->render('dashboard', $data); }
public function get_all_taxa() { if (!file_exists(DOC_ROOT . 'tmp/natureserve')) { mkdir(DOC_ROOT . 'tmp/natureserve'); } if (!file_exists(DOC_ROOT . 'tmp/natureserve/images')) { mkdir(DOC_ROOT . 'tmp/natureserve/images'); } $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => DOC_ROOT . "/temp/dwc_archive_test/")); $species_list_path = DOC_ROOT . "update_resources/connectors/files/natureserve_species_list.xml"; shell_exec("rm -f {$species_list_path}"); shell_exec("curl " . self::SPECIES_LIST_URL . " -o {$species_list_path}"); $reader = new \XMLReader(); $reader->open($species_list_path); $records = array(); while (@$reader->read()) { if ($reader->nodeType == \XMLReader::ELEMENT && $reader->name == "DATA_RECORD") { $record = simplexml_load_string($reader->readOuterXML(), null, LIBXML_NOCDATA); $records[] = (string) $record->EGT_UID; } } echo "Total Records: " . count($records) . "\n"; $chunk_size = 1; // shuffle($records); // array_unshift($records, 'ELEMENT_GLOBAL.2.104470'); // Bald eagle array_unshift($records, 'ELEMENT_GLOBAL.2.102211'); // Polar bear // array_unshift($records, 'ELEMENT_GLOBAL.2.106470'); // bobcat - Lynx rufus // array_unshift($records, 'ELEMENT_GLOBAL.2.104731'); // striped bass - Morone saxatilis array_unshift($records, 'ELEMENT_GLOBAL.2.105926'); // American Bullfrog array_unshift($records, 'ELEMENT_GLOBAL.2.104777'); // White tailed deer array_unshift($records, 'ELEMENT_GLOBAL.2.100925'); // golden eagle $records = array_unique($records); $chunks = array_chunk($records, $chunk_size); $i = 0; $start_time = time_elapsed(); foreach ($chunks as $chunk) { $this->lookup_multiple_ids($chunk); // if($i % 500 == 0) print_r($this->archive_builder->file_columns); $i += $chunk_size; if ($i % 100 == 0) { $estimated_total_time = (time_elapsed() - $start_time) / $i * count($records); echo "Time spent ({$i} records) " . time_elapsed() . "\n"; echo "Estimated total seconds : {$estimated_total_time}\n"; echo "Estimated total hours : " . $estimated_total_time / (60 * 60) . "\n"; echo "Memory : " . memory_get_usage() . "\n"; } // if($i >= 100) break; } $this->archive_builder->finalize(); }
public function latest() { $filter = array(); $filter['page'] = '1'; $filter['limit'] = '10'; $data['activities'] = array(); $results = $this->Activities_model->getList($filter); foreach ($results as $result) { $data['activities'][] = array('activity_id' => $result['activity_id'], 'icon' => 'fa fa-tasks', 'message' => $result['message'], 'time' => mdate('%h:%i %A', strtotime($result['date_added'])), 'time_elapsed' => time_elapsed($result['date_added']), 'state' => $result['status'] === '1' ? 'read' : 'unread'); } $this->template->render('activities_latest', $data); }
function newsitem($profile_pic, $from, $to, $message, $picture, $name, $link, $caption, $description, $icon, $time, $comments, $likes) { if ($to) { $to_section = '<div class="to" >to</div><div class="news-friend-name"><strong><a>' . $to . '</a></strong></div><div class="clear"></div>'; } else { $to_section = ''; } if ($message) { $message_section = '<div class="message">' . $message . '</div>'; } else { $message_section = ''; } if ($picture) { $picture_section = '<div class="external-image"><img src="' . $picture . '"/></div><div class="news-external">'; } else { $picture_section = '<div class="news-external" style="width: 410px;">'; } if (!$link) { $link = '#'; } if ($name) { $name_section = '<div class="news-title"><h3><a href="' . $link . '" target="_blank">' . $name . '</a></h3></div>'; } else { $name_section = ''; } if ($caption) { $caption_section = '<div class="news-caption"><i>' . $caption . '</i></div>'; } else { $caption_section = ''; } if ($description) { $description_section = '<div class="news-desc">' . $description . '</div>'; } else { $description_section = ''; } if ($icon) { $icon_section = '<div class="news-icon" ><img src="' . $icon . '" /></div>'; } else { $icon_section = ''; } $time_converted = time_elapsed($time); $news = '<div class="news"> <div class="news-friend-thumb"><img src="' . $profile_pic . '"/></div> <div class="news-content"> <div class="news-friend-name"><strong><a>' . $from . '</a></strong></div>' . $to_section . '<div class="clear"></div>' . $message_section . $picture_section . $name_section . $caption_section . $description_section . '</div> <div class="clear"></div> <div class="comment-like">' . $icon_section . $time_converted . ' ago · ' . $comments . ' comments · ' . $likes . ' likes</div> </div> </div>'; return $news; }
public function begin_calculating($taxon_concept_ids = null, $range = null) { $GLOBALS['top_taxa'] = array(); $all_scores = array(); $batches = array(1); if ($taxon_concept_ids) { $batches = array_chunk($taxon_concept_ids, 10000); } foreach ($batches as $batch) { $query = "SELECT taxon_concept_id, image_trusted, image_unreviewed, text_trusted, text_unreviewed, text_trusted_words, text_unreviewed_words, video_trusted, video_unreviewed, sound_trusted, sound_unreviewed, flash_trusted, flash_unreviewed, youtube_trusted, youtube_unreviewed, iucn_total, data_object_references, info_items, content_partners, has_GBIF_map, BHL_publications, user_submitted_text FROM taxon_concept_metrics"; if ($taxon_concept_ids) { $query .= " WHERE taxon_concept_id IN (" . implode($batch, ",") . ")"; } elseif ($range) { $query .= " WHERE taxon_concept_id BETWEEN {$range}"; } foreach ($this->mysqli_slave->iterate_file($query) as $row_num => $row) { static $i = 0; if ($i == 0) { echo "QUERY IS DONE (" . time_elapsed() . ")\n"; } $i++; if ($i % 10000 == 0) { echo "{$i}: " . memory_get_usage() . "\n"; } $taxon_concept_id = $row[0]; $this_scores = $this->calculate_score_from_row($row); // if($this_scores['total'] >= .5) $all_scores[$taxon_concept_id] = $this_scores; $all_scores[$taxon_concept_id] = $this_scores['total']; } } echo "CALCULATIONS ARE DONE (" . time_elapsed() . ") {$range}\n"; // uasort($all_scores, array('self', 'sort_by_total_score')); static $num = 0; // $OUT = fopen(DOC_ROOT . '/tmp/richness.txt', 'w+'); // fwrite($OUT, "RANK\tID\tNAME\tBREADTH\tDEPTH\tDIVERSITY\tTOTAL\n"); // foreach($all_scores as $id => $scores) // { // $num++; // // if($num >= 2500) break; // $str = "$num\t$id\t" . TaxonConcept::get_name($id) ."\t"; // $str .= $scores['breadth'] / TaxonConceptMetric::$BREADTH_WEIGHT ."\t"; // $str .= $scores['depth'] / TaxonConceptMetric::$DEPTH_WEIGHT ."\t"; // $str .= $scores['diversity'] / TaxonConceptMetric::$DIVERSITY_WEIGHT ."\t"; // $str .= $scores['total']."\n"; // fwrite($OUT, $str); // } // fclose($OUT); return $all_scores; }
function run_stats_gathering_methods($methods_to_run, $single_method_to_run = null) { foreach ($methods_to_run as $method) { if ($single_method_to_run && $method != $single_method_to_run) { continue; } $time_start = time_elapsed(); echo "Calling {$method}\n"; // create and/or truncate the stats file for this category $this->initialize_category_file($method); call_user_func(array($this, $method)); echo "Finished {$method}\n"; echo "in " . round((time_elapsed() - $time_start) / 60, 2) . " minutes\n\n"; } }
public static function start($resource_file = null) { // $document_list_html = Functions::get_remote_file(self::DOCUMENT_LIST); $document_list_html = file_get_contents('plazii.html'); if (preg_match_all("/<a href=\"((http:\\/\\/plazi.cs.umb.edu\\/exist\\/rest\\/db\\/taxonx_docs\\/plazi\\/(.*?))\\?_xsl.*?)\">(.*)<\\/a>/", $document_list_html, $matches, PREG_SET_ORDER)) { $count = 0; foreach ($matches as $match) { $xml_with_stylesheet_url = $match[1]; $xml_url = $match[2]; $xml_filename = $match[3]; echo "{$xml_with_stylesheet_url}\n"; self::get_metadata($xml_with_stylesheet_url); $xml = Functions::lookup_with_cache($xml_url, array('validation_regex' => 'xmlns:')); $count += 1; echo "\n >>>>>>>> COUNT: {$count} >> " . time_elapsed() . "\n\n"; // if($count >= 400) break; } } }
public function read_data() { $this->column_labels = array(); $this->column_indices = array(); foreach (new FileIterator($this->text_path["obis"]["ranges_OBIS"]) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $this->process_line_data($line_data); } }
private function lookup_block2($start, $limit) { $query = "SELECT tc.id taxon_concept_id, he.id hierarchy_entry_id, he.identifier, he.source_url, h.label, h.outlink_uri, r.title, h.id FROM taxon_concepts tc JOIN hierarchy_entries he ON (tc.id=he.taxon_concept_id) JOIN hierarchies h ON (he.hierarchy_id=h.id) LEFT JOIN resources r ON (h.id=r.hierarchy_id) WHERE tc.id BETWEEN {$start} AND " . ($start + $limit) . " AND he.published=1 AND he.visibility_id=1"; static $j = 0; $concept_links = array(); $links_from_hierarchy = array(); foreach ($this->mysqli->iterate_file($query) as $row_num => $row) { if ($j % 50000 == 0) { echo "{$start} : {$j} : " . time_elapsed() . " : " . memory_get_usage() . "\n"; } $j++; $taxon_concept_id = $row[0]; $hierarchy_id = $row[7]; if (@(!$concept_links[$taxon_concept_id])) { $concept_links[$taxon_concept_id] = array(); } if (@$links_from_hierarchy[$taxon_concept_id][$hierarchy_id]) { continue; } if ($link = $this->prepare_link($row)) { fwrite($this->LINKS_OUT, "{$taxon_concept_id}\t" . $link['title'] . "\t" . $link['url'] . "\n"); $concept_links[$taxon_concept_id][] = $link; $links_from_hierarchy[$taxon_concept_id][$hierarchy_id] = 1; } // $all_entries[$taxon_concept_id][$hierarchy_id] = array( // 'hierarchy_entry_id' => $hierarchy_entry_id, // 'visibility_id' => $visibility_id, // 'vetted_id' => $vetted_id, // 'vetted_view_order' => $vetted_view_order, // 'hierarchy_id' => $hierarchy_id, // 'browsable' => $browsable); } // foreach($concept_links as $taxon_concept_id => $links) // { // if(!$links) continue; // usort($links, array("php_active_record\GoogleDumpPreparer", "sort_by_title")); // // echo "$taxon_concept_id\n"; // // print_r($links); // // } }
public function view() { if (!($result = $this->Messages_model->viewMessage($this->uri->rsegment(3), $this->customer->getId()))) { // check if customer_id is set in uri string $this->alert->set('danger', $this->lang->line('alert_unknown_error')); redirect('account/inbox'); } $this->Messages_model->updateState($result['message_id'], $this->customer->getId(), 'read'); $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/'); $this->template->setBreadcrumb($this->lang->line('text_my_account'), 'account/account'); $this->template->setBreadcrumb($this->lang->line('text_heading'), 'account/inbox'); $this->template->setBreadcrumb($this->lang->line('text_view_heading'), 'account/inbox/view'); $this->template->setTitle($this->lang->line('text_view_heading')); $this->template->setHeading($this->lang->line('text_view_heading')); $data['back_url'] = site_url('account/inbox'); $data['message_id'] = $result['message_id']; $data['date_added'] = time_elapsed($result['date_added']) . ' - ' . mdate('%d %M %y - %H:%i', strtotime($result['date_added'])); $data['subject'] = $result['subject']; $data['body'] = $result['body']; $this->template->render('account/inbox_view', $data); }
public function build_archive() { $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/"; $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory)); $this->column_labels = array(); $this->column_indices = array(); $this->taxon_occurrences = array(); foreach (new FileIterator(self::TAXA_URL) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $taxon = $this->add_taxon($line_data); $this->taxon_occurrences[$taxon->taxonID] = $this->add_occurrence($line_data, $taxon); } $this->column_labels = array(); $this->column_indices = array(); foreach (new FileIterator(self::DUMP_URL) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $this->process_line_data($line_data); } $this->archive_builder->finalize(true); }
public function build_archive() { $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/"; $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory)); $this->setup(); $this->column_labels = array(); $this->column_indices = array(); foreach (new FileIterator(self::DUMP_URL) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = explode("\t", $line); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $this->process_line_data($line_data); // if($line_number >= 1000) break; } $this->archive_builder->finalize(true); }
private function getList($data, $filter) { $url = '?'; if ($this->input->get('page')) { $filter['page'] = (int) $this->input->get('page'); } else { $filter['page'] = 1; } if ($this->config->item('page_limit')) { $filter['limit'] = $this->config->item('page_limit'); } else { $filter['limit'] = ''; } if ($this->input->get('filter_search')) { $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search'); } else { $data['filter_search'] = ''; } if ($this->input->get('filter_access')) { $filter['filter_access'] = $data['filter_access'] = $this->input->get('filter_access'); $url .= 'filter_access=' . $filter['filter_access'] . '&'; } else { $filter['filter_access'] = $data['filter_access'] = ''; } if ($this->input->get('filter_date')) { $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date'); $url .= 'filter_date=' . $filter['filter_date'] . '&'; } else { $filter['filter_date'] = $data['filter_date'] = ''; } if ($this->input->get('sort_by')) { $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by'); } else { $filter['sort_by'] = $data['sort_by'] = 'date_added'; } if ($this->input->get('order_by')) { $filter['order_by'] = $data['order_by'] = $this->input->get('order_by'); $data['order_by_active'] = $this->input->get('order_by') . ' active'; } else { $filter['order_by'] = $data['order_by'] = 'DESC'; $data['order_by_active'] = ''; } if ($filter['filter_type'] === 'online') { $data['text_empty'] = $this->lang->line('text_empty'); } else { $data['text_empty'] = $this->lang->line('text_empty_report'); } $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC'; $data['sort_date'] = site_url('customers_online' . $url . 'sort_by=date_added&order_by=' . $order_by); $customers_online = $this->Customer_online_model->getList($filter); $data['customers_online'] = array(); foreach ($customers_online as $online) { $country_code = $online['country_code'] ? strtolower($online['country_code']) : 'no_flag'; $data['customers_online'][] = array('activity_id' => $online['activity_id'], 'ip_address' => $online['ip_address'], 'customer_name' => $online['customer_id'] ? $online['first_name'] . ' ' . $online['last_name'] : $this->lang->line('text_guest'), 'access_type' => ucwords($online['access_type']), 'browser' => $online['browser'], 'user_agent' => $online['user_agent'], 'request_uri' => !empty($online['request_uri']) ? $online['request_uri'] : '--', 'referrer_uri' => !empty($online['referrer_uri']) ? $online['referrer_uri'] : '--', 'request_url' => !empty($online['request_uri']) ? root_url($online['request_uri']) : '#', 'referrer_url' => !empty($online['referrer_uri']) ? root_url($online['referrer_uri']) : '#', 'date_added' => time_elapsed($online['date_added']), 'country_code' => image_url('data/flags/' . $country_code . '.png'), 'country_name' => $online['country_name'] ? $online['country_name'] : $this->lang->line('text_private')); } $data['types'] = array('online' => array('badge' => '', 'url' => site_url('customers_online'), 'title' => $this->lang->line('text_online')), 'all' => array('badge' => '', 'url' => site_url('customers_online/all'), 'title' => $this->lang->line('text_all'))); $data['online_dates'] = array(); $online_dates = $this->Customer_online_model->getOnlineDates($filter); foreach ($online_dates as $date) { $month_year = mdate('%Y-%m', strtotime($date['year'] . '-' . $date['month'])); $data['online_dates'][$month_year] = mdate('%F %Y', strtotime($date['date_added'])); } if ($this->input->get('sort_by') and $this->input->get('order_by')) { $url .= 'sort_by=' . $filter['sort_by'] . '&'; $url .= 'order_by=' . $filter['order_by'] . '&'; } $config['base_url'] = page_url() . $url; $config['total_rows'] = $this->Customer_online_model->getCount($filter); $config['per_page'] = $filter['limit']; $this->pagination->initialize($config); $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links()); return $data; }
$menu_name .= '<div class="quick-form" id="qf-' . $row->mid . '">'; $menu_name .= form_open('sso/menus/act', 'class="form-horizontal"', array('mid' => $row->mid, 'quick' => TRUE)); $menu_name .= '<div class="form-group">'; $menu_name .= form_label('Name', 'mnme', array('class' => 'col-xs-4 col-md-2 control-label')); $menu_name .= '<div class="col-xs-4 col-md-10">'; $menu_name .= form_input('mnme', str_replace('_', NULL, $row->mnme), 'class="input-sm form-control" id="mnme" placeholder="Menu name"'); $menu_name .= '</div>'; $menu_name .= '</div>'; $menu_name .= '<div class="form-group">'; $menu_name .= '<div class="col-sm-offset-2 col-sm-10">'; $menu_name .= '<button type="submit" class="btn btn-sm btn-primary">Update menu</button>'; $menu_name .= '<button type="button" class="btn btn-sm btn-default" id="cqe-' . $row->mid . '">Cancel</button>'; $menu_name .= '</div>'; $menu_name .= '</div>'; $menu_name .= form_close(); $menu_name .= '</div>'; $menu_icon = '<span class="fa' . $row->mico . '"></span>'; $menu_link = base_url($row->mlnk); $menu_update = mdate('%F %j, %Y on %H:%i', strtotime($row->ud)) . br() . '<span class="small text-muted">' . time_elapsed($row->ud) . nbs() . '<em>by</em>' . nbs() . $row->ufnme . '</span>'; $menu_status = $row->mstat; $menu_id = $row->mid; $results['aaData'][$i] = array($menu_name, $menu_icon, $menu_link, $menu_update, $menu_status, $menu_id); ++$i; } } else { //jika data kosong, sistem iddle for ($i = 0; $i < 6; ++$i) { $results['aaData'][0][$i] = ''; } } print $callback . '(' . json_encode($results) . ')';
private function save_big_file_to_local($source, $destination) { $timestart = time_elapsed(); $handles = self::prepare_file_handles($source, $destination); $source_handle = $handles["source"]; $destination_handle = $handles["destination"]; $contents = ''; $i = 0; while (!feof($source_handle)) { $i++; echo "{$i} "; if ($contents = fread($source_handle, 8192)) { fwrite($destination_handle, $contents); } else { echo "\n fread error \n"; sleep(300); // sleep for 5 minutes fclose($source_handle); fclose($destination_handle); $handles = self::prepare_file_handles($source, $destination); $source_handle = $handles["source"]; $destination_handle = $handles["destination"]; $contents = ''; $i = 0; } } fclose($source_handle); fclose($destination_handle); $elapsed_time_sec = time_elapsed() - $timestart; echo "\n\n"; echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n"; echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n"; echo "\nDone processing.\n"; }
</tr> </thead> <tbody> '; foreach ($submissions as $submission) { echo ' <tr> <td> <a href="challenge?id=', htmlspecialchars($submission['challenge_id']), '"> ', htmlspecialchars($submission['title']), ' </a> (', htmlspecialchars($submission['category_title']), ') </td> <td> ', get_position_medal($submission['pos'], true), ' ', time_elapsed($submission['added'], $submission['available_from']), ' after release (', date_time($submission['added']), ') </td> <td>', number_format($submission['points']), '</td> </tr> '; } echo ' </tbody> </table> '; } else { echo ' <div class="alert alert-info"> No challenges solved, yet! </div>
private static function debug_iterations($message_prefix, $iteration_size = 500) { static $iteration_counts = array(); if (!isset($iteration_counts[$message_prefix])) { $iteration_counts[$message_prefix] = 0; } if ($iteration_counts[$message_prefix] % $iteration_size == 0) { if ($GLOBALS['ENV_DEBUG']) { echo $message_prefix . " {$iteration_counts[$message_prefix]}: " . memory_get_usage() . ": " . time_elapsed() . "\n"; } write_to_resource_harvesting_log($message_prefix . " {$iteration_counts[$message_prefix]}: " . memory_get_usage() . ": " . time_elapsed()); } $iteration_counts[$message_prefix]++; }
function lookup_names($start, $limit, &$taxon_concept_ids = array()) { debug("querying names"); $query = "SELECT tc.id, n.string, cf.string\n FROM taxon_concepts tc\n JOIN taxon_concept_preferred_entries pe ON (tc.id=pe.taxon_concept_id)\n JOIN hierarchy_entries he ON (pe.hierarchy_entry_id=he.id)\n JOIN names n ON (he.name_id=n.id)\n LEFT JOIN canonical_forms cf ON (n.canonical_form_id=cf.id)\n WHERE tc.supercedure_id=0\n AND tc.published=1\n AND tc.id "; if ($taxon_concept_ids) { $query .= "IN (" . implode(",", $taxon_concept_ids) . ")"; } else { $query .= "BETWEEN {$start} AND " . ($start + $limit); } static $i = 0; foreach ($this->mysqli_slave->iterate_file($query) as $row_num => $row) { if ($i % 1000 == 0) { echo "{$i} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $i++; $taxon_concept_id = $row[0]; $name_string = $row[1]; $canonical_form = $row[2]; if ($name_string == 'NULL') { $name_string = NULL; } if ($canonical_form == 'NULL') { $canonical_form = NULL; } if (!$name_string) { continue; } $t = new \eol_schema\Taxon(); $t->taxonID = $taxon_concept_id; $t->scientificName = $name_string; if ($rank_label = @$this->ranks[$taxon_concept_id]) { if ($rank_label == "gen.") { $rank_label = 'genus'; } elseif ($rank_label == "sp.") { $rank_label = 'species'; } elseif ($rank_label == "subsp.") { $rank_label = 'subspecies'; } elseif ($rank_label == "var.") { $rank_label = 'variety'; } $t->taxonRank = $rank_label; if ($rank_label == 'species' && $canonical_form) { $words = explode(" ", $canonical_form); if (count($words) == 2) { $t->genus = $words[0]; $t->specificEpithet = $words[1]; } } elseif ($rank_label == 'genus' && $canonical_form) { $words = explode(" ", $canonical_form); if (count($words) == 1) { $t->genus = $words[0]; } } elseif (in_array($rank_label, array('subspecies', 'variety', 'infraspecies', 'infraspecificname', 'form')) && $canonical_form) { $words = explode(" ", $canonical_form); if (count($words) == 3) { $t->genus = $words[0]; $t->specificEpithet = $words[1]; $t->infraspecificEpithet = $words[2]; } } } $this->archive_builder->write_object_to_file($t); unset($t); } }
foreach ($u->obj_system_kinds as $usk) { if ($usk->id == $job_node->id_sk) { if (strtolower($usk->name) == "windows") { $show_rdp = true; } } } echo "<table width='{$log_width}' align='left' border='1'>"; $timespan = ""; $is_past = false; $is_future = false; if (intval(gmdate('U')) > intval($job_node->last_ping)) { $timespan = time_elapsed(intval(gmdate('U')) - intval($job_node->last_ping)); $is_past = true; } elseif (intval(gmdate('U')) < intval($job_node->last_ping)) { $timespan = time_elapsed(intval($job_node->last_ping) - intval(gmdate('U'))); $is_future = true; } if (strlen($timespan) == 0) { $timespan = "0s"; $is_past = true; } $bgcolor = "white"; $tcolor = "black"; if (strpos($timespan, "s") !== FALSE) { $bgcolor = "green"; $tcolor = "white"; } if (strpos($timespan, "m") !== FALSE) { $bgcolor = "yellow"; $tcolor = "black";
u.id AS user_id, u.team_name, s.added, s.correct, s.flag, c.id AS challenge_id, c.title AS challenge_title ' . $query . ' ORDER BY s.added DESC LIMIT ' . $from . ', ' . $results_per_page, array_values($where)); foreach ($submissions as $submission) { echo ' <tr> <td><a href="', CONFIG_SITE_URL, 'challenge.php?id=', htmlspecialchars($submission['challenge_id']), '">', htmlspecialchars($submission['challenge_title']), '</a></td> <td><a href="', CONFIG_SITE_ADMIN_URL, 'user.php?id=', htmlspecialchars($submission['user_id']), '">', htmlspecialchars($submission['team_name']), '</a></td> <td>', time_elapsed($submission['added']), ' ago</td> <td>', htmlspecialchars($submission['flag']), '</td> <td> ', $submission['correct'] ? '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/accept.png" alt="Correct!" title="Correct!" />' : '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/stop.png" alt="Wrong!" title="Wrong!" />', ' </td> <td> <form method="post" action="actions/list_submissions" class="discreet-inline">'; form_xsrf_token(); echo ' <input type="hidden" name="action" value="', $submission['correct'] ? 'mark_incorrect' : 'mark_correct', '" /> <input type="hidden" name="id" value="', htmlspecialchars($submission['id']), '" /> <button type="submit" class="btn btn-sm btn-', $submission['correct'] ? 'warning' : 'success', '">Mark ', $submission['correct'] ? 'incorrect' : 'correct', '</button> </form> <form method="post" action="actions/list_submissions" class="discreet-inline">'; form_xsrf_token();
private function getList($data, $filter) { if ($this->input->post('message_state')) { if ($this->_updateMessageState($this->input->post('message_state'), '', $this->user->getStaffId()) === TRUE) { redirect(current_url()); } } $url = '?'; if ($this->input->get('page')) { $filter['page'] = (int) $this->input->get('page'); } else { $filter['page'] = ''; } if ($this->config->item('page_limit')) { $filter['limit'] = $this->config->item('page_limit'); } if ($this->input->get('filter_search')) { $filter['filter_search'] = $data['filter_search'] = $this->input->get('filter_search'); $url .= 'filter_search=' . $filter['filter_search'] . '&'; } else { $data['filter_search'] = ''; } if ($this->input->get('filter_recipient')) { $filter['filter_recipient'] = $data['filter_recipient'] = $this->input->get('filter_recipient'); $url .= 'filter_recipient=' . $filter['filter_recipient'] . '&'; } else { $filter['filter_recipient'] = $data['filter_recipient'] = ''; } if ($this->input->get('filter_type')) { $filter['filter_type'] = $data['filter_type'] = $this->input->get('filter_type'); $url .= 'filter_type=' . $filter['filter_type'] . '&'; } else { $filter['filter_type'] = $data['filter_type'] = ''; } $filter['filter_staff'] = $this->user->getStaffId(); if ($this->input->get('filter_date')) { $filter['filter_date'] = $data['filter_date'] = $this->input->get('filter_date'); $filter['filter_date']; $url .= 'filter_date=' . $filter['filter_date'] . '&'; } else { $filter['filter_date'] = $data['filter_date'] = ''; } if ($this->input->get('sort_by')) { $filter['sort_by'] = $data['sort_by'] = $this->input->get('sort_by'); } else { $filter['sort_by'] = $data['sort_by'] = 'messages.date_added'; } if ($this->input->get('order_by')) { $filter['order_by'] = $data['order_by'] = $this->input->get('order_by'); $data['order_by_active'] = $this->input->get('order_by') . ' active'; } else { $filter['order_by'] = $data['order_by'] = 'DESC'; $data['order_by_active'] = 'DESC'; } $order_by = (isset($filter['order_by']) and $filter['order_by'] == 'ASC') ? 'DESC' : 'ASC'; $data['sort_type'] = site_url($data['page_uri'] . $url . 'sort_by=send_type&order_by=' . $order_by); $data['sort_date'] = site_url($data['page_uri'] . $url . 'sort_by=messages.date_added&order_by=' . $order_by); $message_state = $data['filter_folder'] === 'inbox' ? 'message message-unread' : 'message'; $data['messages'] = array(); $results = $this->Messages_model->getList($filter); foreach ($results as $result) { $data['messages'][] = array('message_id' => $result['message_id'], 'from' => $result['staff_name'], 'send_type' => $result['send_type'], 'type_icon' => (isset($result['send_type']) and $result['send_type'] === 'account') ? 'user' : 'envelope', 'subject' => strlen($result['subject']) > 30 ? substr(strip_tags(html_entity_decode($result['subject'], ENT_QUOTES, 'UTF-8')), 0, 30) . '..' : strip_tags(html_entity_decode($result['subject'], ENT_QUOTES, 'UTF-8')), 'recipient' => ucwords(str_replace('_', ' ', $result['recipient'])), 'date_added' => time_elapsed($result['date_added']), 'body' => strlen($result['body']) > 40 ? substr(strip_tags(html_entity_decode($result['body'], ENT_QUOTES, 'UTF-8')), 0, 40) . '..' : strip_tags(html_entity_decode($result['body'], ENT_QUOTES, 'UTF-8')), 'state' => (isset($result['state']) and $result['state'] === '1') ? 'message message-read' : $message_state, 'view' => $filter['filter_folder'] === 'draft' ? site_url('messages/compose?id=' . $result['message_id']) : site_url('messages/view?id=' . $result['message_id'])); } $message_unread = $this->user->unreadMessageTotal(); $data['folders'] = array('inbox' => array('title' => $this->lang->line('text_inbox'), 'icon' => 'fa-inbox', 'badge' => $message_unread, 'url' => site_url('messages')), 'draft' => array('title' => $this->lang->line('text_draft'), 'icon' => 'fa-file-text-o', 'badge' => '', 'url' => site_url('messages/draft')), 'sent' => array('title' => $this->lang->line('text_sent'), 'icon' => 'fa-paper-plane-o', 'badge' => '', 'url' => site_url('messages/sent')), 'all' => array('title' => $this->lang->line('text_all'), 'icon' => 'fa-briefcase', 'badge' => '', 'url' => site_url('messages/all')), 'archive' => array('title' => $this->lang->line('text_archive'), 'icon' => 'fa-archive', 'badge' => '', 'url' => site_url('messages/archive'))); $data['labels'] = array('account' => array('title' => $this->lang->line('text_account'), 'icon' => 'fa-circle-o text-primary', 'url' => page_url() . '?filter_type=account'), 'email' => array('title' => $this->lang->line('text_email'), 'icon' => 'fa-circle-o text-danger', 'url' => page_url() . '?filter_type=email')); $data['message_dates'] = array(); $message_dates = $this->Messages_model->getMessageDates(); foreach ($message_dates as $message_date) { $month_year = $message_date['year'] . '-' . $message_date['month']; $data['message_dates'][$month_year] = mdate('%F %Y', strtotime($message_date['date_added'])); } if ($this->input->get('sort_by') and $this->input->get('order_by')) { $url .= 'sort_by=' . $filter['sort_by'] . '&'; $url .= 'order_by=' . $filter['order_by'] . '&'; } $config['base_url'] = site_url($data['page_uri'] . $url); $config['total_rows'] = $this->Messages_model->getCount($filter); $config['per_page'] = $filter['limit']; $this->pagination->initialize($config); $data['pagination'] = array('info' => $this->pagination->create_infos(), 'links' => $this->pagination->create_links()); return $data; }
/** * Template for comments and pingbacks. * * To override this walker in a child theme without modifying the comments template * simply create your own twentyeleven_comment(), and that function will be used instead. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Twenty Eleven 1.0 */ function meme_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; switch ($comment->comment_type) { case 'pingback': case 'trackback': ?> <li class="post pingback"> <p><?php _e('Pingback:', 'twentyeleven'); ?> <?php comment_author_link(); edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?> </p> <?php break; default: $author = get_comment_author(); //now let's see if this is a character list($name, $class, $thumbnail) = get_character_info($author); ?> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?> "> <div id="comment-<?php comment_ID(); ?> " class="comment"> <div class="comment-meta"> <div class="comment-author vcard" style="height:60px;"> <img src="<?php echo $thumbnail; ?> " width="60" height="60" alt=""> </div><!-- .comment-author .vcard --> </div> <div class="comment-content"> <div class="comment-info"><?php $elapsed = time_elapsed(get_comment_time('U')); ?> <strong class="the-comment-author class-<?php echo $class; ?> "><?php echo $name; ?> </strong> <span class="the-comment-time"><?php echo $elapsed; ?> </span></div> <?php if ($comment->comment_approved == '0') { ?> <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.', 'twentyeleven'); ?> </em> <?php } else { comment_text(); } ?> </div> <?php if (ext_smf_logged_in()) { ?> <div class="reply"> <?php edit_comment_link(__('Edit', 'twentyeleven'), '<span class="edit-link">', '</span>'); ?> <?php comment_reply_link(array_merge($args, array('reply_text' => __('Reply', 'twentyeleven'), 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?> </div><!-- .reply --> <?php } ?> </div><!-- #comment-## --> <?php break; } }
<?php namespace php_active_record; /* NCBI Bio Projects partner provides an XML dump estimated execution time: */ include_once dirname(__FILE__) . "/../../config/environment.php"; require_library('connectors/NCBIProjectsAPI'); $timestart = time_elapsed(); $resource_id = 173; $func = new NCBIProjectsAPI($resource_id); $func->get_all_taxa(); if (filesize(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_working/taxon.tab") > 1000) { if (is_dir(CONTENT_RESOURCE_LOCAL_PATH . $resource_id)) { recursive_rmdir(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_previous"); Functions::file_rename(CONTENT_RESOURCE_LOCAL_PATH . $resource_id, CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_previous"); } Functions::file_rename(CONTENT_RESOURCE_LOCAL_PATH . $resource_id . "_working", CONTENT_RESOURCE_LOCAL_PATH . $resource_id); Functions::set_resource_status_to_force_harvest($resource_id); } $elapsed_time_sec = time_elapsed() - $timestart; echo "\n\n elapsed time = " . $elapsed_time_sec / 60 . " minutes"; echo "\n elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours"; echo "\n Done processing.\n";
function setMyDate($d, $t) { $err = 0; $d = strtotime($d); if (date('Y', $d) == '1970') { $err = 1; } switch ($t) { case 1: $d = date('d.m.Y', $d); break; # 30.06.2014 # 30.06.2014 case 2: $d = date('d.m.Y H:i:s A', $d); break; # 30.06.2014 08:13:47 # 30.06.2014 08:13:47 case 3: $d = convDat(date('n', $d), 0, 'months') . date(' d Y, H:s A', $d); break; # March 10, 2001, 5:16 pm //case 4 : $d = time_elapsed($d); break; # x time ago # March 10, 2001, 5:16 pm //case 4 : $d = time_elapsed($d); break; # x time ago case 4: $d = tago($d); break; # x time ago # x time ago case 5: $d = time_elapsed($d); break; # remaning time # remaning time case 6: $d = date('Y/m/d H:i:s', $d); break; # 2014/01/18 08:13:47 Used for JS counter # 2014/01/18 08:13:47 Used for JS counter default: $d = date('d.m.Y', $d); break; } if ($err) { return '-'; } else { return $d; } }