Esempio n. 1
0
 /** Initiate request to create a yahoo token. This can only be done when
  * logged into Yahoo
  * and also as an admin
  * @return void
  * @access public
  */
 public function yahooaccessAction()
 {
     $yahoo = new Yahoo();
     $yahoo->access();
     $this->getFlash()->addMessage('Token created');
     $this->redirect('/admin/oauth/');
 }
Esempio n. 2
0
 /** Initiate request to create a yahoo token. This can only be done when logged into Yahoo
  * and also as an admin
  */
 public function yahooaccessAction()
 {
     $yahoo = new Yahoo();
     $yahoo->access();
     $this->_flashMessenger->addMessage('Token created');
     $this->_redirect('/admin/oauth/');
 }
Esempio n. 3
0
 /**
  * Retrieves and stores incoming links for a page, and
  * incoming link count and pagerank of each incoming link.
  *
  * @return null
  */
 public function site_page_update()
 {
     $db = DB::connect();
     $url = $_GET['url'];
     for ($start = 1; $start <= 1000; $start += 100) {
         $params = array('start' => $start, 'query' => $url);
         $data = Yahoo::get_inlink_data($params);
         foreach ($data['ResultSet']['Result'] as $page) {
             $title = mysql_escape_string($page['Title']);
             $linking_page = mysql_escape_string($page['Url']);
             $pagerank = Google::get_pagerank($linking_page);
             $q = "SELECT COUNT(1) FROM inlink WHERE url = '{$linking_page}'";
             if ($db->query($q)->fetchColumn() == 0) {
                 $db->exec("INSERT INTO inlink VALUES('','{$url}','{$linking_page}','{$title}','{$pagerank}','0')");
             } else {
                 $db->exec("UPDATE inlink SET inlink_count='{$incoming_links}',pagerank='{$pagerank}' WHERE url = '{$linking_page}' LIMIT 1");
             }
             // @todo this should be a part of the preceding INSERT query
             $inlink_count = Yahoo::get_inlink_count(array('query' => $linking_page));
             $db->exec("UPDATE inlink SET inlink_count='{$inlink_count}' WHERE url = '{$linking_page}' LIMIT 1");
         }
     }
     // redirect to site subpage page
     header('HTTP/1.1 302 Found');
     header("Location: " . Options::get('base_url') . "site/page/?url=" . urlencode($url));
     exit;
 }
Esempio n. 4
0
 /**
  * Updates PageRank and inlink count for the Page.
  *
  * @return null
  */
 public function update_statistics()
 {
     $db = DB::connect();
     $pagerank = Google::get_pagerank($this->url);
     $db->exec("INSERT INTO page_data VALUES({$this->id}, '0', NOW(), {$pagerank})");
     $inlink_count = Yahoo::get_inlink_count(array('query' => $this->url));
     $db->exec("INSERT INTO page_data VALUES({$this->id}, '1', NOW(), {$inlink_count})");
 }
Esempio n. 5
0
 /**
  * Retrieves and stores current rankings for the keyword.
  *
  * @return null
  */
 public function update_rankings()
 {
     $db = DB::connect();
     $site = Sites::get(array('id' => $this->site_id));
     $rank = Scroogle::get_ranking($this->text, $site->domain);
     $q = "INSERT INTO keyword_rank (site_id, search_engine_id, keyword_id, created_at, rank)" . " VALUES ({$site->id}, 1, {$this->id}, NOW(), {$rank})";
     $db->exec($q);
     $rank = Yahoo::get_ranking($this->text, $site->domain);
     $q = "INSERT INTO keyword_rank (site_id, search_engine_id, keyword_id, created_at, rank)" . " VALUES ({$site->id}, 2, {$this->id}, NOW(), {$rank})";
     $db->exec($q);
 }
Esempio n. 6
0
 public function __construct($woeid = null, $type = 12, $start = 0, $count = 0)
 {
     $this->woeid = $woeid;
     $this->url = 'place/' . $woeid . '/children.type(' . $type . ');start=' . $start . ';count=' . $count;
     parent::__construct();
 }
Esempio n. 7
0
 /**
  * Retrieves and stores site pages
  *
  * @return null
  */
 public function refresh_pages()
 {
     $site_url = 'http://' . $this->domain;
     $db = DB::connect();
     // retrieve and add site pages
     for ($start = 1; $start <= 1000; $start += 100) {
         $params = array('query' => $site_url, 'start' => $start);
         $data = Yahoo::get_page_data($params);
         foreach ($data['ResultSet']['Result'] as $page) {
             $page_url = $page['Url'];
             $page_title = $page['Title'];
             // check for existence
             if ($db->query("SELECT COUNT(1) FROM page WHERE url = '{$page_url}'")->fetchColumn() == 0) {
                 // insert the page
                 $db->exec("INSERT INTO page VALUES('','{$page_url}','{$page_title}')");
             }
         }
     }
 }
Esempio n. 8
0
    $query = str_replace($characters, $replacements, $query);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "q={$query}&format={$format}");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    $response = curl_exec($ch);
    $headers = curl_getinfo($ch);
    curl_close($ch);
    return $response;
}
$text = 'For the thousands of refugees and migrants landing on its beaches every day Greece Lesbos island is a step to safety and a brighter future in Europe';
//$text = 'Computer programming (often shortened to programming or coding) is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs.';
$text = substr($text, 0, 120);
$query = "select * from contentanalysis.analyze where text = '" . $text . "'";
$url = 'http://query.yahooapis.com/v1/public/yql';
$yql_query_url = $url . "?q=" . urlencode($query);
$yql_query_url .= "&format=json";
$yql_query_url .= "&enable_categorizer=true";
$yql_query_url .= "&diagnostics=false";
$yql_query_url .= "&related_entities=true";
$yql_query_url .= "&show_metadata=true";
$ch = curl_init($yql_query_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
$response = yahoo_content_analysis($text);
$logger = null;
$yahoo = new Yahoo();
$tags = $yahoo->tag($text);
Esempio n. 9
0
 public function __construct($woeid = null)
 {
     $this->woeid = $woeid;
     $this->url = 'place/' . $woeid . '/parent';
     parent::__construct();
 }
Esempio n. 10
0
 public function __construct($woeid = null)
 {
     $this->woeid = $woeid;
     parent::__construct();
 }
Esempio n. 11
0
                    $conditions = $weatherfeed->query->results->channel->item->condition->text;
                    $source_id = 1;
                    $second_date = new Datetime($weatherfeed->query->results->channel->item->forecast[1]->date);
                    $second_date = $second_date->format('Y-m-d');
                    $second_mintemp = $weatherfeed->query->results->channel->item->forecast[1]->low;
                    $second_maxtemp = $weatherfeed->query->results->channel->item->forecast[1]->high;
                    $second_conditions = $weatherfeed->query->results->channel->item->forecast[1]->text;
                    $second_avg = $second_maxtemp / 2 + $second_mintemp / 2;
                }
                $presentforecast = "INSERT INTO weather_forecast (request_date, forecast_date, feed_url, town, postcode_prefix, min_temp, max_temp, avg_temp, wind_dir, conditions, source_id)\n\t\t\tVALUES ('{$request_date}', '{$forecast_date}', '{$feed_url}', '{$town}', '{$postcode}', '{$min_temp}', '{$max_temp}', '{$avg_temp}', '{$wind_dir}', '{$conditions}', '{$source_id}')";
                $secondforecast = "INSERT INTO weather_forecast (request_date, forecast_date, feed_url, town, postcode_prefix, min_temp, max_temp, avg_temp, wind_dir, conditions, source_id)\n\t\t\tVALUES ('{$request_date}', '{$second_date}', '{$feed_url}', '{$town}', '{$postcode}', '{$second_mintemp}', '{$second_maxtemp}', '{$second_avg}', null, 'second_conditions', '{$source_id}')";
                if ($dbcon->query($presentforecast) === TRUE) {
                    echo "New first created successfully \n";
                    if ($dbcon->query($secondforecast) === TRUE) {
                        echo "New second forecast created successfully \n\n";
                    } else {
                        echo "Error: \n" . $dbcon->error;
                    }
                } else {
                    echo "Error: \n" . $dbcon->error;
                }
            }
            $log->lwrite('Script Run on: ' . $date);
            // close log file
            $log->lclose();
            $dbcon->close();
        }
    }
}
$yahoo = new Yahoo();
$location = $yahoo->getAllTowns();