function part_avail($key, $val) { //$start_time = time(); if (item_exists($key, $prod_id)) { if ($val['price'] > 0) { update_post_meta($prod_id[$key], '_regular_price', $val['price']); } else { update_post_meta($prod_id[$key], '_regular_price', ''); } if ($val['count'] > 0) { update_post_meta($prod_id[$key], '_stock_status', 'instock'); } update_post_meta($prod_id[$key], '_stock', $val['count']); wp_update_post(array('ID' => $prod_id[$key])); error_log(current_time('mysql') . " Set avail " . $key . " Price: " . $val['price'] . " Count:" . $val['count'] . " \r\n", 3, "connect.log"); } /*if ((time() - $start_time) > 20) { restart_part_avail($avail_count, $prod_id); return; }*/ }
function boss_loot_fields($low, $high) { global $lootlog; global $raiddata; global $eventlog; $items = 0; $known_items = 0; $thiskill = 0; for ($i = 0; $i <= count($eventlog); $i++) { $ets = $raiddata[eventlog][$i][ts]; $etype = $raiddata[eventlog][$i][type]; if ($etype == 'BOSSKILL') { if ($ets == $low) { $thiskill = 1; } else { if ($thiskill == 1) { $thiskill = 0; } } } if ($etype == 'LOOT') { $ltype = 'bid'; if (isset($raiddata[lootlog][$ets][type])) { $ltype = $raiddata[lootlog][$ets][type]; } if ($thiskill == 1 and $ltype != 'DE' and $ltype != 'bank') { $items++; if ($item_id = item_exists($raiddata[lootlog][$ets][item])) { $known_items++; print "\n\n"; print '<input type="hidden" name="looters[]" value="' . player_exists($raiddata[lootlog][$ets][player]) . '">'; print '<input type="hidden" name="items[]" value="' . $item_id . '">'; print '<input type="hidden" name="fullprice[]" value="1">'; print "\n\n"; } } } } print "<i>{$items} items ({$known_items} known)</i>"; }
/** * @brief Harvest ION RSS Alerts * */ function main() { // Organism hierarchy from http://www.organismnames.com/alerts.htm // Extract these using Firefox Extract Links plugin $ids = array("Acanthocephala" => "http://www.organismnames.com/RSS/Acanthocephala.xml", "Acritarcha" => "http://www.organismnames.com/RSS/Acritarcha.xml", "Animalia" => "http://www.organismnames.com/RSS/Animalia.xml", "Annelida" => "http://www.organismnames.com/RSS/Annelida.xml", "Apicomplexa" => "http://www.organismnames.com/RSS/Apicomplexa.xml", "Archaeocyatha" => "http://www.organismnames.com/RSS/Archaeocyatha.xml", "Arthropoda" => "http://www.organismnames.com/RSS/Arthropoda.xml", "Ascetospora" => "http://www.organismnames.com/RSS/Ascetospora.xml", "Brachiopoda" => "http://www.organismnames.com/RSS/Brachiopoda.xml", "Bryozoa" => "http://www.organismnames.com/RSS/Bryozoa.xml", "Chaetognatha" => "http://www.organismnames.com/RSS/Chaetognatha.xml", "Chitinozoa" => "http://www.organismnames.com/RSS/Chitinozoa.xml", "Chordata" => "http://www.organismnames.com/RSS/Chordata.xml", "Ciliophora" => "http://www.organismnames.com/RSS/Ciliophora.xml", "Cnidaria" => "http://www.organismnames.com/RSS/Cnidaria.xml", "Conodonta" => "http://www.organismnames.com/RSS/Conodonta.xml", "Conulariida" => "http://www.organismnames.com/RSS/Conulariida.xml", "Ctenophora" => "http://www.organismnames.com/RSS/Ctenophora.xml", "Cycliophora" => "http://www.organismnames.com/RSS/Cycliophora.xml", "Echinodermata" => "http://www.organismnames.com/RSS/Echinodermata.xml", "Echiura" => "http://www.organismnames.com/RSS/Echiura.xml", "Entoprocta" => "http://www.organismnames.com/RSS/Entoprocta.xml", "Gastrotricha" => "http://www.organismnames.com/RSS/Gastrotricha.xml", "Gnathostomulida" => "http://www.organismnames.com/RSS/Gnathostomulida.xml", "Graptolithina" => "http://www.organismnames.com/RSS/Graptolithina.xml", "Hemichordata" => "http://www.organismnames.com/RSS/Hemichordata.xml", "Hemimastigophora" => "http://www.organismnames.com/RSS/Hemimastigophora.xml", "Kinorhyncha" => "http://www.organismnames.com/RSS/Kinorhyncha.xml", "Labyrinthomorpha" => "http://www.organismnames.com/RSS/Labyrinthomorpha.xml", "Loricifera" => "http://www.organismnames.com/RSS/Loricifera.xml", "Mesozoa" => "http://www.organismnames.com/RSS/Mesozoa.xml", "Micrognathozoa" => "http://www.organismnames.com/RSS/Micrognathozoa.xml", "Microspora" => "http://www.organismnames.com/RSS/Microspora.xml", "Mollusca" => "http://www.organismnames.com/RSS/Mollusca.xml", "Myxozoa" => "http://www.organismnames.com/RSS/Myxozoa.xml", "Nematoda" => "http://www.organismnames.com/RSS/Nematoda.xml", "Nematomorpha" => "http://www.organismnames.com/RSS/Nematomorpha.xml", "Nemertinea" => "http://www.organismnames.com/RSS/Nemertinea.xml", "Onychophora" => "http://www.organismnames.com/RSS/Onychophora.xml", "Perkinsozoa" => "http://www.organismnames.com/RSS/Perkinsozoa.xml", "Petalonamae" => "http://www.organismnames.com/RSS/Petalonamae.xml", "Phoronida" => "http://www.organismnames.com/RSS/Phoronida.xml", "Placididea" => "http://www.organismnames.com/RSS/Placididea.xml", "Placozoa" => "http://www.organismnames.com/RSS/Placozoa.xml", "Platyhelminthes" => "http://www.organismnames.com/RSS/Platyhelminthes.xml", "Porifera" => "http://www.organismnames.com/RSS/Porifera.xml", "Priapulida" => "http://www.organismnames.com/RSS/Priapulida.xml", "Protozoa" => "http://www.organismnames.com/RSS/Protozoa.xml", "Rotifera" => "http://www.organismnames.com/RSS/Rotifera.xml", "Sarcomastigophora" => "http://www.organismnames.com/RSS/Sarcomastigophora.xml", "Sipuncula" => "http://www.organismnames.com/RSS/Sipuncula.xml", "Tardigrada" => "http://www.organismnames.com/RSS/Tardigrada.xml", "Xenusia" => "http://www.organismnames.com/RSS/Xenusia.xml"); // Test for one id //$id = "Anura"; // Loop through all categories foreach ($ids as $taxon => $url) { // Get RSS feed for this taxon $data = new stdClass(); // Fetch RSS and transform into object $result = ion_fetch_rss($url, $data); if ($result == 0) { //print_r($data); // Extract details from each item foreach ($data->items as $item) { //print_r($item); $item->guid = str_replace('urn:lsid:organismnames.com:name:', '', $item->guid); // Don't hammer the server if (item_exists($item)) { echo "Item " . $item->guid . " exists\n"; } else { // Clean taxon name and extract taxonomic group if (preg_match('/New Taxon Alert:-\\s+\\((?<group>(.*))\\)\\s+(?<name>(.*)\\s*\\((.*)\\)\\s*(.*))$/', $item->title, $matches)) { $item->group = $matches['group']; $item->name = $matches['name']; } else { if (preg_match('/New Taxon Alert:-\\s+\\((?<group>(.*))\\)\\s+(?<name>(.*))$/', $item->title, $matches)) { #print_r($matches); $item->group = $matches['group']; $item->name = $matches['name']; } } // Clean publication title so we can remove this when we parse reference $item->publicationTitle = ''; $matches = array(); if (preg_match('/Publication Title:(.*)/', $item->description, $matches)) { //print_r($matches); $title = $matches[1]; $title = strip_tags($title); $title = trim($title); $item->publicationTitle = $title; //echo "$title\n"; } // Clean date $timestamp = strtotime($item->pubDate); $item->pubDate = strftime("%Y-%m-%d", $timestamp); //print_r($item); // Fetch HTML so we can harvest taxon author name and bibliographic details ion_process($item); // Output result print_r($item); sleep(5); } } } } }