Example #1
0
 /**
  * Sends the arguments to the channel, like say from a user.
  *
  * IRC-Syntax: PRIVMSG [#channel]or[user] : [message]
  */
 public function command()
 {
     if (empty($this->arguments[0])) {
         return;
     }
     $query_string = urlencode(implode(' ', $this->arguments));
     $ret = google("site:imdb.com {$query_string}");
     if ($ret === FALSE) {
         echo '(' . "imdb {$query_string}" . ') returned false...', PHP_EOL;
         return;
     }
     $url = $ret['url'];
     $movie_id = substr($url, 0, -1);
     // Remove the last '/'
     $movie_id = substr($movie_id, strripos($movie_id, '/') + 1);
     // $movie_id = everything after the new last '/'
     $query = 'http://www.omdbapi.com/?i=' . $movie_id;
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $query);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $query_ret = curl_exec($ch);
     curl_close($ch);
     $decoded = json_decode($query_ret, true);
     if (isset($decoded['Error'])) {
         return;
     }
     $movie_title = $decoded['Title'];
     $movie_year = $decoded['Year'];
     $movie_plot = $decoded['Plot'];
     $movie_rating = $decoded['imdbRating'];
     $this->say("1,8IMDb {$movie_title} ({$movie_year}) {$movie_rating} - {$movie_plot} {$url}");
 }
Example #2
0
 /**
  * Main function to execute when listen occurs
  */
 public function execute($data)
 {
     $args = $this->getArguments($data);
     foreach ($args as $arg) {
         if ($listenee = strstr($arg, "imdb.com/title/")) {
             $ret = google($arg);
             if ($ret === FALSE) {
                 echo '(' . "imdb {$arg}" . ') returned false...', PHP_EOL;
                 return;
             }
             $url = $ret['url'];
             // Get movie id from url
             $parsed_url = parse_url($url);
             $movie_id = substr($parsed_url['path'], strlen('/title/'));
             $movie_id = substr($movie_id, 0, stripos($movie_id, '/'));
             // Get movie info via omdb's API
             $query = 'http://www.omdbapi.com/?i=' . $movie_id;
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $query);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $query_ret = curl_exec($ch);
             curl_close($ch);
             $decoded = json_decode($query_ret, true);
             if (isset($decoded['Error'])) {
                 return;
             }
             $movie_title = $decoded['Title'];
             $movie_year = $decoded['Year'];
             $movie_plot = $decoded['Plot'];
             $movie_rating = $decoded['imdbRating'];
             $this->say("1,8IMDb {$movie_title} ({$movie_year}) {$movie_rating} - {$movie_plot} {$url}", $args[2]);
             break;
         }
     }
 }
Example #3
0
 /**
  * Sends the arguments to the channel, like say from a user.
  *
  * IRC-Syntax: PRIVMSG [#channel]or[user] : [message]
  */
 public function command()
 {
     if (empty($this->arguments[0])) {
         return;
     }
     $ret = google(implode(' ', $this->arguments));
     if ($ret === FALSE) {
         echo "google() error\n";
     } else {
         $this->say("2,0G4,0o8,0o2,0g9,0l4,0e {$ret['title']} - {$ret['url']}");
     }
 }
Example #4
0
 /**
  * Sends the arguments to the channel, like say from a user.
  *
  * IRC-Syntax: PRIVMSG [#channel]or[user] : [message]
  */
 public function command()
 {
     if (empty($this->arguments[0])) {
         return;
     }
     $query_string = implode(' ', $this->arguments);
     $ret = google('site:youtube.com ' . $query_string);
     if ($ret !== FALSE) {
         echo $ret['url'], PHP_EOL;
         echo $ret['title'], PHP_EOL;
         $ret['title'] = substr($ret['title'], 0, -1 * strlen(' - YouTube'));
         $this->say("1,0You0,4Tube {$ret['title']} - {$ret['url']}");
     }
 }
Example #5
0
 /**
  * Sends the arguments to the channel, like say from a user.
  *
  * IRC-Syntax: PRIVMSG [#channel]or[user] : [message]
  */
 public function command()
 {
     if (empty($this->arguments[0])) {
         return;
     }
     $query_string = urlencode(implode(' ', $this->arguments));
     $ret = google("site:wikipedia.org {$query_string}");
     if ($ret === FALSE) {
         echo '(' . "wikipedia {$query_string}" . ') returned false...', PHP_EOL;
         return;
     }
     // Cut off the ugly part of the title
     $title = substr($ret['title'], 0, stripos($ret['title'], ' - Wikipedia,'));
     $this->say("1,0Wikipedia {$title} - {$ret['url']}");
 }
Example #6
0
<?php

require './common.php';
require './functions.php';
header("Content-Type: text/html;charset=utf-8");
$key = $_GET['word'];
$key = query($key);
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
}
$start = ($page - 1) * 10;
$cookie_file = dirname(__FILE__) . "/google.txt";
$html = google($key, $start, $cookie_file);
echo $html;
Example #7
0
 function gessLocation($address)
 {
     $maps_host = "maps.google.com";
     $key = google();
     $delay = 0;
     $base_url = "http://" . $maps_host . "/maps/geo?output=xml" . "&key=" . $key;
     $geocode_pending = true;
     while ($geocode_pending) {
         $request_url = $base_url . "&q=" . urlencode($address);
         $xml = simplexml_load_file($request_url) or die("url not loading");
         $status = $xml->Response->Status->code;
         if (strcmp($status, "200") == 0) {
             $geocode_pending = false;
             $res = array('address' => (string) $xml->Response->Placemark->address, 'country' => (string) $xml->Response->Placemark->AddressDetails->Country->CountryNameCode, 'region' => (string) $xml->Response->Placemark->AddressDetails->Country->AdministrativeArea->AdministrativeAreaName, 'city' => (string) $xml->Response->Placemark->AddressDetails->Country->AdministrativeArea->Locality->LocalityName);
             //debug($res);
             return $res;
         } else {
             if (strcmp($status, "620") == 0) {
                 // sent geocodes too fast
                 $delay += 100000;
             } else {
                 // failure to geocode
                 $geocode_pending = false;
                 $this->log("Address " . $address . " failed to geocoded.");
                 $this->log("Received status " . $status);
             }
         }
         usleep($delay);
     }
     return null;
 }
Example #8
0
					<div class='alert alert-danger' role='alert'><?php 
                    echo $m['social_error'];
                    ?>
</div>
				</div>
				<?php 
                }
            }
        }
        // Check if return is set
        if (!empty($_GET['return'])) {
            // Check if it is a callback from Google
            if ($_GET['return'] == "google" && getSetting("enable_google", "text") == "true") {
                if (!empty($_GET['code'])) {
                    // Check if the code is set
                    $client = google();
                    // Initialize Google
                    $objOAuthService = new Google_Service_Oauth2($client);
                    // Set OAuth object
                    try {
                        $client->authenticate($_GET['code']);
                        // Authenticate the given code
                        $_SESSION['access_token'] = $client->getAccessToken();
                        // Save access token in session
                        $client->setAccessToken($_SESSION['access_token']);
                        // Set access token
                        $userData = $objOAuthService->userinfo->get();
                        // Get user info from access token
                        if (!empty($userData)) {
                            // Check if user info is given
                            $sid = mysqli_real_escape_string($con, $userData->id);
function process_domain($d)
{
    global $stats;
    global $inputdir;
    global $triggers;
    global $domains;
    global $messages;
    global $nresources;
    // echo("$d\n");
    $stats['n_domains']++;
    $c = file_get_contents($inputdir . $d);
    $lines = explode("\n", $c);
    foreach ($lines as $i => $line) {
        if (substr($line, 0, 1) != '{') {
            $lines[$i] = '';
        }
    }
    $c = implode("\n", $lines);
    $c = "[" . $c . "]";
    $c = str_replace("\n", "", $c);
    $c = str_replace(",]", "]", $c);
    $c = str_replace("Syntax error: parse error", "", $c);
    $c = str_replace("\n", "", $c);
    $resources = array_unique(json_decode($c, 1), SORT_REGULAR);
    $n = count($resources);
    if ($n == 0) {
        echo "{$d} has errors\n";
        $stats['n_domains_with_errors']++;
        return;
    }
    @$nresources[$n / 10]++;
    if ($n > 500) {
        $messages[] = "{$d} has {$n} resources";
    }
    // and then update the statistics
    $has_js = false;
    $has_external_js = false;
    $has_flash = false;
    $has_external_flash = false;
    $has_external_content = false;
    $has_google = false;
    $has_facebook = false;
    $has_yahoo = false;
    $has_twitter = false;
    $has_ads = false;
    $triggered = [];
    foreach ($triggers as $trigger) {
        $triggered[$trigger] = false;
    }
    foreach ($resources as $res) {
        $url = $res['url'];
        $type = $res['content-type'];
        if (isflash($type, $url)) {
            $has_flash = true;
            $is_flash = true;
        } else {
            $is_flash = false;
        }
        if (isjs($type, $url)) {
            $has_js = true;
            $is_js = true;
        } else {
            $is_js = false;
        }
        if (!$has_ads) {
            if (ads($url)) {
                echo "{$d} contains ads from {$url}\n";
                $has_ads = true;
            }
        }
        foreach ($triggers as $trigger) {
            if (contains($url, $trigger)) {
                $triggered[$trigger] = $url;
            }
        }
        if (contains($url, 'jquery')) {
            $has_jquery = true;
        }
        if (facebook($url)) {
            $has_facebook = true;
        }
        if (google($url)) {
            $has_google = true;
        }
        if (yahoo($url)) {
            $has_yahoo = true;
        }
        if (twitter($url)) {
            $has_twitter = true;
        }
        if (!same_domain($d, $url)) {
            if ($is_js) {
                $has_external_js = true;
            }
            if ($is_flash) {
                $has_external_flash = true;
            }
            $has_external_content = true;
        }
    }
    foreach ($triggers as $trigger) {
        if ($triggered[$trigger]) {
            $stats["n_domains_with_{$trigger}"] += 1;
            $domains[$trigger][$d] = $triggered[$trigger];
        }
    }
    $stats['n_domains_with_js'] += $has_js ? 1 : 0;
    $stats['n_domains_with_external_js'] += $has_external_js ? 1 : 0;
    $stats['n_domains_with_external_content'] += $has_external_content ? 1 : 0;
    $stats['n_domains_clean'] += $has_external_content ? 0 : 1;
    $stats['n_domains_with_flash'] += $has_flash ? 1 : 0;
    $stats['n_domains_with_external_flash'] += $has_external_flash ? 1 : 0;
    $stats['n_domains_with_google'] += $has_google ? 1 : 0;
    $stats['n_domains_with_facebook'] += $has_facebook ? 1 : 0;
    $stats['n_domains_with_yahoo'] += $has_yahoo ? 1 : 0;
    $stats['n_domains_with_twitter'] += $has_twitter ? 1 : 0;
    $stats['n_domains_with_ads'] += $has_ads ? 1 : 0;
}
Example #10
0
    $fetch = $query->fetch();
    echo ($fetch !== FALSE) ? current($fetch) : "error";
  } else {
    echo "invalid";
  }
}


// Main auth control logic
if($_GET['a'] == "login") {
  switch($_GET['m']) {
  case "facebook":
    facebook();
    break;

  case "twitter":
    twitter();
    break;

  case "google":
    google();
    break;

  case "windows":
    break;
  }
} else if($_GET['a'] == "logout") {
  logout();
} else if($_GET['a'] == "check") {
  check();
}
Example #11
0
    $url = 'https://www.google.com/search?q=' . $key . '&start=' . $start;
    //exit($url);
    $cookie_file = dirname(__FILE__) . "/temp/google.txt";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Cookie: PREF=ID=fef74816681e7898:U=9ea73b7f54aa9005:FF=2:LD=en-US:NW=1:TM=1295952619:LM=1296005167:S=Dk6Hp_5SDKZ3OhJy;'));
    //加上这句抓取才不会乱码
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
    $contents = curl_exec($ch);
    curl_close($ch);
    return $contents;
}
$html = google($key, $start);
echo $html;
function is_utf8($word)
{
    if (preg_match("/^([" . chr(228) . "-" . chr(233) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}){1}/", $word) == true || preg_match("/([" . chr(228) . "-" . chr(233) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}){1}\$/", $word) == true || preg_match("/([" . chr(228) . "-" . chr(233) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}[" . chr(128) . "-" . chr(191) . "]{1}){2,}/", $word) == true) {
        return true;
    }
    return false;
}
function query($word)
{
    $word = strtr($word, ' ', "+");
    $word = strtr($word, '_', "+");
    $start = ($page - 1) * $rows;
    if ($word == '') {
        return false;