public function testParseGeocoderCircle() { global $egMultiMaps_AllowGeocoderTests; if (!$egMultiMaps_AllowGeocoderTests) { return; } $this->assertRegExp('{"circles":\\[{"radius":\\[[0-9\\.]+\\],"pos":\\[{"lat":[0-9\\.]+,"lon":[0-9\\.]+}\\]}\\],"bounds":{"ne":{"lat":[0-9\\.]+,"lon":[0-9\\.]+},"sw":{"lat":[0-9\\.]+,"lon":[0-9\\.]+}}}', \FormatJson::encode($this->object->getMapData(array('circle=Moscow', 'service=google')))); }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); // if (empty($args['s'])) // return ''; $html = HTML(); extract($args); // prevent from dump if ($q and $request->isPost()) { require_once "lib/Google.php"; $google = new Google(); if (!$google) { return ''; } switch ($mode) { case 'search': $result = $google->doGoogleSearch($q); break; case 'cache': $result = $google->doGetCachedPage($q); break; case 'spell': $result = $google->doSpellingSuggestion($q); break; default: trigger_error("Invalid mode"); } if (isa($result, 'HTML')) { $html->pushContent($result); } if (isa($result, 'GoogleSearchResults')) { //TODO: result template if (!empty($result->resultElements)) { $list = HTML::ol(); foreach ($result->resultElements as $res) { $li = HTML::li(LinkURL($res['URL'], $res['directoryTitle']), HTML::br(), $res['directoryTitle'] ? HTML(HTML::raw(' '), HTML::em($res['summary']), ' -- ', LinkURL($res['URL'])) : ''); $list->pushContent($li); } $html->pushContent($list); } else { return _("Nothing found"); } } if (is_string($result)) { // cache content also? $html->pushContent(HTML::blockquote(HTML::raw($result))); } } if ($formsize < 1) { $formsize = 30; } // todo: template $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), HiddenInputs(array('pagename' => $basepage, 'mode' => $mode))); $form->pushContent(HTML::input(array('type' => 'text', 'value' => $q, 'name' => 'q', 'size' => $formsize))); $form->pushContent(HTML::input(array('type' => 'submit', 'class' => 'button', 'value' => gettext($mode)))); return HTML($html, $form); }
/** * 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})"); }
/** * Return the Google API services class files * * @return array $services with the format apiAdsenseService.php, */ public static function services() { // Fetch all Google API services classes from Bundle folder. // scandir returns the files of a folder including '.' & '..' so we slice // the returned array to remove them. $classes = array_slice(scandir(Bundle::path('google-api-php-client') . 'google-api-php-client' . DS . 'src' . DS . 'contrib' . DS), 2); return self::$services = $classes; }
function run_script($controller, $params) { $out = array(); $results = Google::search($params['query']); foreach ($results as $result) { $out[] = $result['title'] . "\n\t" . $result['url'] . "\n\t\t" . $result['note']; } $controller->ok(implode("\n\n", $out)); }
public function getData() { $tmp_arr = parent::getData(); $new_tmp_arr = $tmp_arr[0]; /*preg_match("/ (\d*) км\/ч/", $new_tmp_arr['wind_condition'], $arr); $new_wind = ceil($arr[1]*1000/3600); $first_wind_condition = substr($new_tmp_arr['wind_condition'], 0, strpos($new_tmp_arr['wind_condition'], ",")); $new_tmp_arr['wind_condition'] = $first_wind_condition.', '.$new_wind.' м/с';*/ return $new_tmp_arr; }
/** * Constructor * */ public function __construct() { parent::__construct(); self::$ga_email = Settings::get('google_analytics_email'); self::$ga_password = Settings::get('google_analytics_password'); self::$ga_profile_id = Settings::get('google_analytics_profile_id'); self::$ga_url = Settings::get('google_analytics_url'); if (self::$ga_email != '' && self::$ga_password != '' && self::$ga_profile_id != '' && self::$ga_url != '') { self::$should_access = TRUE; } }
protected function set_latlng() { $this->latitude = NULL; $this->longitude = NULL; $google = Google::geocode("address", "{$this->address} {$this->zip}"); if (is_null($google->latitude) and is_null($google->longitude)) { $google = Google::geocode("address", "{$this->zip}"); } if (!is_null($google->latitude) and !is_null($google->longitude)) { $this->latitude = (double) $google->latitude; $this->longitude = (double) $google->longitude; } }
protected function setLatLng() { $this->latitude = null; $this->longitude = null; $google = Google::geocode('address', "{$this->address} {$this->zip}"); if (is_null($google->latitude) && is_null($google->longitude)) { $google = Google::geocode("address", "{$this->zip}"); } if (!is_null($google->latitude) && !is_null($google->longitude)) { $this->latitude = (double) $google->latitude; $this->longitude = (double) $google->longitude; } }
public function execute($message) { $cmd = $message->getCommand(); global $api; $this->gc = new GoogleCache(); switch ($cmd) { case "g": $lines = array(); $res = $this->search(implode(" ", $message->getData())); foreach ($res as $id => $result) { $lines[] = "*" . $id . " - " . Google::bToUS($result["title"]) . "*"; $lines[] = Google::bToUS($result["content"]); $lines[] = "(" . Google::encodeUs($result["url"]) . ")"; $lines[] = ""; } $api->sendMessage($message->chat->id, implode("\n", $lines), "Markdown", true); break; case "img": $data = $this->img(implode(" ", $message->getData())); $id = mt_rand(0, sizeof($data["items"]) - 1); $api->sendPhoto($message->chat->id, $data["items"][$id]["link"], implode(" ", $message->getData())); break; } }
function makeSearchLink($url) { $n = new Google(); $links = $n->getSearchLinks($url); return $links[array_rand($links)]; }
$twig->addGlobal('image_corporation', $imageServer . 'Corporation/'); $twig->addGlobal('image_alliance', $imageServer . 'Alliance/'); $twig->addGlobal('image_item', $imageServer . 'Type/'); $twig->addGlobal('image_ship', $imageServer . 'Render/'); $twig->addGlobal('tqStatus', $redis->get('tqStatus')); $twig->addGlobal('tqCount', $redis->get('tqCount')); $twig->addGlobal('siteurl', $baseAddr); $twig->addGlobal('fullsiteurl', $fullAddr); $twig->addGlobal('requesturi', $_SERVER['REQUEST_URI']); $twig->addGlobal('topad', Google::ad($topCaPub, $topAdSlot, $adWidth = 728, $adHeight = 90)); $twig->addGlobal('bottomad', Google::ad($bottomCaPub, $bottomAdSlot, $adWidth = 728, $adHeight = 90)); $twig->addGlobal('mobiletopad', Google::ad($topCaPub, $topAdSlot, $adWidth = 320, $adHeight = 50)); $twig->addGlobal('mobilebottomad', Google::ad($bottomCaPub, $bottomAdSlot, $adWidth = 320, $adHeight = 50)); $twig->addGlobal('igbtopad', Google::ad($topCaPub, $topAdSlot, $adWidth = 728, $adHeight = 90)); $twig->addGlobal('igbbottomad', Google::ad($bottomCaPub, $bottomAdSlot, $adWidth = 728, $adHeight = 90)); $twig->addGlobal('analytics', Google::analytics($analyticsID, $analyticsName)); $disqus &= UserConfig::get('showDisqus', true); $twig->addGlobal('disqusLoad', $disqus); $noAdPages = array('/account/', '/moderator/', '/ticket', '/register/', '/information/', '/login'); foreach ($noAdPages as $noAdPage) { $showAds &= !Util::startsWith($uri, $noAdPage); $showAds &= $userShowAds; } $twig->addglobal('showAnalytics', $showAnalytics); if ($disqus) { $twig->addGlobal('disqusShortName', $disqusShortName); } if ($disqusSSO) { $twig->addglobal('disqusSSO', Disqus::init()); } // User's account balance
function scrapPageSnippets(&$snippets_array, $key_value, $conn, $page_url) { $function = new Functions(); $snippet_extractor = new Google(); $google_image = new ImagesGoogle(); $snippets_array = getPageSnippets($conn, $page_url); if (count($snippets_array) == 0) { #echo "Saving snippets."; $rand_index_array = array(); $index = 0; while (count($rand_index_array) < 3) { $rand_value = rand(0, 8); if (!in_array($rand_value, $rand_index_array)) { $rand_index_array[$index] = $rand_value; $index++; } } $snippet_image_array = $google_image->Start($key_value, count($rand_index_array), $function); $snippet_array = array(); while (!$snippet_array) { $snippet_array = $snippet_extractor->Start($key_value, 'ru', count($rand_index_array), $function); } for ($i = 0; $i < count($rand_index_array); $i++) { $snippets_array[$rand_index_array[$i]]['title'] = preg_replace('/ {0,}\\.{2,}/', '.', $snippet_array[$i]['title']); $snippets_array[$rand_index_array[$i]]['description'] = preg_replace('/ {0,}\\.{2,}/', '.', $snippet_array[$i]['description']); if ($snippet_image_array && $snippet_image_array[$i]) { $snippets_array[$rand_index_array[$i]]['small'] = $snippet_image_array[$i]['small']; $snippets_array[$rand_index_array[$i]]['large'] = $snippet_image_array[$i]['large']; } } savePageSnippets($conn, $page_url, $snippets_array); } }
<?php require $_SERVER['DOCUMENT_ROOT'] . '/ts2/config/consts.php'; require DOCUMENT_ROOT . 'classes/LoginHelper.php'; session_start(); $loginHelper = new LoginHelper(); if ($loginHelper->IsLoggedIn()) { header('Location: ' . SITE_URL); exit; } $loginHelper->suppressRegistration(OAUTH_GOOGLE); require 'config/client.php'; require 'config/login.php'; require 'Google/Google.php'; $google = new Google(APP_NAME, CLIENT_ID, CLIENT_SECRET, unserialize(SCOPES), REDIRECT_URI); header("Location: " . $google->getLoginURL()); exit;
public function on_google_search($pars) { self::setResult(Google::search($pars['query'])); }
/** * Updates statistics for the site domain. * * @return null */ public function update_statistics() { $pagerank = Google::get_pagerank($this->domain); DB::connect()->exec("UPDATE site SET pagerank = '{$pagerank}' WHERE id = '{$this->id}' LIMIT 1"); $this->update_keyword_rankings(); }
$google->setAccessToken(Session::get('token')); return View::make(Bundle::prefix(BUNDLE_NAME) . 'index')->with('services', Google::services()); } if ($google->getAccessToken()) { Session::put('token', $google->getAccessToken()); return View::make(Bundle::prefix(BUNDLE_NAME) . 'index')->with('services', Google::services()); } else { $data = array('google_auth_url' => $google->createAuthUrl()); return View::make(Bundle::prefix(BUNDLE_NAME) . 'index', $data); } }); Route::get('(:bundle)/(:any)', function ($service) { $google = IoC::resolve('google-api-php-client'); $class_name = 'Google_' . ucfirst($service) . 'Service'; $class_file = $class_name . ".php"; $classes = Google::services(); if (Session::has('token')) { $google->setAccessToken(Session::get('token')); try { if (in_array($class_file, $classes)) { $service = new $class_name($google); } else { throw new Exception('Google API Service not found'); } } catch (apiServiceException $e) { print 'There was an API service error ' . $e->getCode() . ':' . $e->getMessage(); } catch (apiException $e) { print 'There was a general API error ' . $e->getCode() . ':' . $e->getMessage(); } catch (Exception $e) { print 'There was a general error ' . $e->getCode() . ':' . $e->getMessage(); }
/** * @return string */ public function __toString() { return Google::toJSON($this->value); }
public function deleteMe() { if (Session::isPluginLoaded("mGoogle")) { Google::calendarDeleteEvent(mTodoGUI::getCalendarDetails("Todo", $this->getID())); } $AC = anyC::get("Todo", "TodoExceptionForID", $this->getID()); while ($T = $AC->getNextEntry()) { $T->deleteMe(); } if ($this->A("TodoClass") == "DBMail" and Session::isPluginLoaded("mMail")) { Mail::assignRevoke("Todo", $this->getID(), $this->A("TodoClassID")); } if (Session::isPluginLoaded("mAufgabe") and ($this->A("TodoType") == 3 or $this->A("TodoType") == 4 or $this->A("TodoType") == 5) and $this->A("TodoUserID") > 0) { $AC = anyC::get("Aufgabe", "AufgabeByClass", "Todo"); $AC->addAssocV3("AufgabeByClassID", "=", $this->getID()); while ($A = $AC->n()) { $A->deleteMe(); } } parent::deleteMe(); }
$registrar = new Registrar(); echo $registrar->getHTML(); exit; } /* If user doesn't grant the access, redirect to the login page */ if (isset($_GET['error']) && $_GET['error'] == 'access_denied') { header("Location: " . SITE_URL . "login/?access_denied"); exit; } // Load configurations require 'config/client.php'; require 'config/login.php'; require_once 'Google/Client.php'; require_once 'Google/Service/Oauth2.php'; require 'Google/Google.php'; $google = new Google(APP_NAME, CLIENT_ID, CLIENT_SECRET, unserialize(SCOPES), REDIRECT_URI); if (isset($_GET['code'])) { // Exchange the code for access token $google->authenticate($_GET['code']); $_SESSION['access_token'] = $google->getAccessToken(); $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); exit; } if ($google->IsAuthenticated()) { // Google User is authenticated and authorized // Login/Registration can be proceeded $gUser = $google->getUserProfile(); $loginHelper = new LoginHelper($db); $user_id = $loginHelper->IsRegistered(OAUTH_GOOGLE, $gUser['id']); if ($user_id) {
">Logout</a> <?php } ?> <ul> <?php if (isset($services)) { ?> <?php foreach ($services as $service) { ?> <li><a href="<?php echo URL::to('google-api/' . strtolower(Google::service_name($service))); ?> "><?php echo Google::service_name($service); ?> </a></li> <?php } ?> </ul> <?php } ?> </body> </html>
require_once "application/models/functions_decode.php"; require_once "application/libraries/parser.php"; require_once "application/plugins/snippets/Google.php"; require_once "application/plugins/snippets/Ukr.php"; require_once "application/plugins/images/ImagesGoogle.php"; require_once "utils/ya_news_extractor.php"; require_once "utils/config.php"; require_once "utils/proxy_config.php"; require_once "utils/snippets_dao.php"; $page_title = ""; $page_meta_keywords = ""; $page_meta_description = ""; $is_cached = false; $function = new Functions(); #$snippet_extractor = new Ukr; $snippet_extractor = new Google(); $google_image = new ImagesGoogle(); function rusdate($d, $format = 'j %MONTH% Y', $offset = 0) { $montharr = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'); $dayarr = array('понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота', 'воскресенье'); $d += 3600 * $offset; $sarr = array('/%MONTH%/i', '/%DAYWEEK%/i'); $rarr = array($montharr[date("m", $d) - 1], $dayarr[date("N", $d) - 1]); $format = preg_replace($sarr, $rarr, $format); return date($format, $d); } //заводим массивы ключей и городов $KEY_PER_PAGE = 25; $key_page_number = 1; $current_page = "MAIN_PAGE";
Graphics::captcha(180, 60, 5); }); $app->route('GET /identicon/@id/@size', function () { Graphics::identicon(f3::get('PARAMS.id'), f3::get('PARAMS.size')); }); $app->route('GET /invert', function () { Graphics::invert('{{@GUI}}test.jpg'); }); $app->route('GET /thumb', function () { Graphics::thumb('{{@GUI}}large.jpg', 256, 192); }, 60); $app->route('GET /screenshot', function () { Graphics::screenshot('http://www.yahoo.com', 150, 200); }); $app->route('GET /google/map', function () { Google::staticmap('Brooklyn Bridge', 12, '256x256'); }); $app->route('GET /minified/@script', function () use($app) { Web::minify($app->get('GUI'), array(f3::get('PARAMS.script'))); }); $app->run(); class Obj { public function hello() { echo 'hello'; } } class CustomObj { public function hello()
<?php require_once 'bing.class.php'; require_once 'google.class.php'; if (isset($_GET['search'])) { $q = $_GET['search']; } else { $q = 'MooTools'; } $appid = '49EB4B94127F7C7836C96DEB3F2CD8A6D12BDB71'; $obj = new Bing($appid); $obj->search($q); $bing = $obj->getHTML(); $obj2 = new Google($appid); $obj2->search($q); $google = $obj2->getHTML(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>GooBing - Search Google and Bind in one go</title> <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css"> <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/base/base.css" type="text/css"> <style type="text/css"> html,body{color:#fff;background:#222;font-family:calibri,verdana,arial,sans-serif;} h1{font-size:300%;margin:0;text-align:right;color:#3c3} h2{background:#369;padding:5px;color:#fff;font-weight:bold;-moz-box-shadow: 0px 4px 2px -2px #000;-moz-border-radius:5px;-webkit-border-radius:5px;text-shadow: #000 1px 1px;} h3 a{color:#69c;text-decoration:none;} h3{margin:0 0 .2em 0} .info{font-size:200%;color:#999;margin:1em 0;}
public function testGetUserInfo() { $api = new Google(); $this->assertThat($api->getStatus('alexgt9'), $this->equalTo('200')); }
private function site_create_from_sitemap() { $db = DB::connect(); $domain = parse_url($_POST['url'], PHP_URL_HOST); if (!Site::exists($domain)) { $pagerank = Google::get_pagerank($domain); $db->exec("INSERT INTO site VALUES('', '{$domain}', '{$pagerank}')"); } if (!($xml = simplexml_load_file($_POST['url']))) { trigger_error('Unable to load sitemap at ' . $_POST['url'], E_USER_ERROR); header('HTTP/1.1 302 Found'); header("Location: " . Options::get('base_url')); exit; } foreach ($xml->url as $url) { if (!Page::exists($url->loc)) { $db->exec("INSERT INTO page VALUES('', '{$url->loc}', '')"); // @todo update page metrics } } }
public function accesofb($social) { $cfg = Configuracion::getConfiguracion('social_login'); $app_id = ''; $app_secret = ''; $app_cb = ''; $url = ''; $oauthObj = null; if (isset($social) && $social == 'face') { $app_id = $cfg['FB_APP_ID']; $app_secret = $cfg['FB_APP_SECRET']; $app_cb = $cfg['FB_APP_CB']; $url = $cfg['FB_APP_INFO']; $oauthObj = new Facebook($app_id, $app_secret, $app_cb); } else { if (isset($social) && $social == 'twitter') { $app_id = $cfg['TW_APP_ID']; $app_secret = $cfg['TW_APP_SECRET']; $app_cb = $cfg['TW_APP_CB']; $url = $cfg['TW_APP_INFO']; $oauthObj = new Twitter($app_id, $app_secret, $app_cb); } else { if (isset($social) && $social == 'google') { $app_id = $cfg['GO_APP_ID']; $app_secret = $cfg['GO_APP_SECRET']; $app_cb = $cfg['GO_APP_CB']; $url = $cfg['GO_APP_INFO']; $oauthObj = new Google($app_id, $app_secret, $app_cb); } } } $scope = array('email'); $oauthObj->setScope($scope); if ($oauthObj->validateAccessToken()) { try { $response = $oauthObj->makeRequest($url); $this->verificarAutenticacion($social, $response); } catch (Exception $e) { echo $e; } } }
function google() { $this->set('title', 'Google'); $this->expect(is_null($this->get('ERROR')), 'No errors expected at this point', 'ERROR variable is set: ' . $this->get('ERROR.text')); $this->expect(extension_loaded('sockets'), 'Sockets extension available', 'Sockets extension is not active - unable to continue'); if (extension_loaded('sockets')) { $this->expect(TRUE, 'Google map<br/><img src="/google/map" alt="Google Map"/>'); $search = Google::search('google'); $this->set('QUIET', TRUE); $this->expect(is_array($search), 'Google search generated the following results:<br/>' . implode('<br/>', $this->pick($search['results'], 'url')), 'Google search failure: ' . var_export($search, TRUE)); $this->set('QUIET', FALSE); $geocode = Google::geocode('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA'); $this->set('QUIET', TRUE); $this->expect(is_array($geocode), 'Geocode API call success', 'Geocode API call failure: ' . var_export($geocode, TRUE)); $this->set('QUIET', FALSE); } echo $this->render('basic/results.htm'); }
/** * @brief get metadata for given ISBN * * @param string $isbn ISBN to use * @param arrayref &$meta OPDS metadata * @return bool $success (true if metadata found) */ public static function get($isbn, &$meta) { /* set ISBN in metadata; can be overwritten later with ISBN13 */ $meta['isbn'] = $isbn; /* try Google first, then ISBNdb */ if (!(Isbn::SUCCESS == Google::get($isbn, $meta)) && !(Isbn::SUCCESS == Isbndb::get($isbn, $meta))) { /* Try ISBNdb, then Google */ //if (!(Isbn::SUCCESS == Isbndb::get($isbn,$meta)) && (!(Isbn::SUCCESS == Google::get($isbn,$meta)))) { return false; } else { return true; } }
<?php /** * @author Andrew Zappella < http://www.suisseo.ch/ > * @copyright 2012 Suisseo SARL * @license http://creativecommons.org/licenses/by-sa/3.0/ * @package Google API PHP Client (Laravel Bundle) * @version 0.2.1 - 2013-03-17 */ const BUNDLE_NAME = 'google-api-php-client'; Autoloader::map(array('Google_Client' => Bundle::path(BUNDLE_NAME) . 'google-api-php-client' . DS . 'src' . DS . 'Google_Client.php')); // Autoloader::directories(array(Bundle::path(BUNDLE_NAME).'google-api-php-client'.DS.'src'.DS.'contrib')); Laravel\IoC::singleton('google-api-php-client', function () { $bundle_prefix = Bundle::prefix(BUNDLE_NAME); $config = array(); $config['application_name'] = Config::get($bundle_prefix . 'google.application_name'); $config['oauth2_client_id'] = Config::get($bundle_prefix . 'google.client_id'); $config['oauth2_client_secret'] = Config::get($bundle_prefix . 'google.client_secret'); $config['oauth2_redirect_uri'] = Config::get($bundle_prefix . 'google.redirect_uri'); $config['developer_key'] = Config::get($bundle_prefix . 'google.developer_key'); $config['use_objects'] = Config::get($bundle_prefix . 'google.use_objects'); $google = new Google_Client($config); $google->setScopes(Config::get($bundle_prefix . 'google.set_scopes')); $google->setAccessType(Config::get($bundle_prefix . 'google.access_type')); $google->setApprovalPrompt(Config::get($bundle_prefix . 'google.approval_prompt')); // autoload Google API services $classes = Google::services(); $mappings = Google::format_mappings($classes); Autoloader::map($mappings); return $google; });