function perform_search($service, $descr, $tags, $crs) { Error::generate('debug', "perform_search({$service},{$descr},{$tags},crs)"); switch (strtolower($service)) { case 'youtube': return youtube_search($descr, $tags, $crs); case 'google': return google_search($descr); case 'itunesu': return itunesu_search($descr); case 'wikipedia': return wikipedia_search($descr); case 'khanacad': return khanacad_search($descr); } }
<?php header('Content-Type: text/html; charset=utf-8'); include_once 'simple_dom_parser/simple_html_dom.php'; require_once 'Unirest.php'; $name = "AC/DC Tickets"; $date = "3/17/2016"; $site = "ticketsnow"; $page_data = google_search($name, $date, $site); $page_info = google_html_data($page_data); page_event_info($page_info); function google_search($event_name, $event_date, $ticket_site) { $url = "https://www.google.com/search?q=" . $event_name . " " . $event_date . " " . $ticket_site; $google_page_data = Unirest::GET($url); return $google_page_data->raw_body; } function google_html_data($page_data) { $html = str_get_html($page_data); $link_url; foreach ($html->find('div[class=g] h3[class=r] a') as $element) { $link_check = $element->plaintext; if (strpos($link_check, '- TicketsNow') !== false) { if (strpos($link_check, 'AC/DC Tickets') !== false) { $link_url = $element->href; $link_url = explode("&", $link_url); $link_url = $link_url[0]; $link_url = explode("=", $link_url); $link_url = $link_url[1]; $link_url = str_replace("%3F", "?", $link_url);
$action = $key;*/ /** Identify course, populate fields */ if ($ACTIONS['search']->wasCalled()) { $params = $ACTIONS['search']->getParams(); $gcourse_code = $gtitle = $params[0]; $crs = new CourseDefn($gtitle); if (!$crs->load()) { Error::generate(Error::$PRIORITY['warn'], 'Course not found.'); } $gdescr = $crs->descr; $tags = split('[,]', $gtags); $procd_descr = process_description($gdescr); foreach ($procd_descr as $descr) { array_push($search_results, array('subject' => $descr, 'google' => google_search($descr), 'youtube' => youtube_search($descr, $tags), 'itunesu' => itunesu_search($descr), 'khanacad' => khanacad_search($descr))); } } /* else if(isset($_POST['save_name'])) { $crs = new Course( urlencode($_POST['save_name']), urlencode($_POST['course_prof']), $_SESSION['google'], $_SESSION['youtube']); $crs->save(); } else if(isset($_GET['course'])) { $crs = new Course($_GET['course'], $_GET['prof'], null, null); $crs->load(); $_SESSION['google'] = $crs->goog_res; $_SESSION['youtube'] = $crs->youtube_res; } else $first_load = true; */ $args = array('pagetitle' => 'Homepage', 'pageurl' => $_SERVER['REQUEST_URI'], 'course' => array('title' => $gtitle, 'code' => $gcourse_code, 'descr' => $gdescr), 'courses' => CourseDefn::ListAll(), 'searchresults' => $search_results, 'actions' => $ACTIONS); if ($CONFIG['debug']) {
<?php ##################################################################################################### /* exec:~google|20|0|0|1|||||php scripts/google.php %%trailing%% exec:~g|20|0|0|1|||||php scripts/google.php %%trailing%% */ ##################################################################################################### require_once "lib.php"; require_once "google_lib.php"; $trailing = trim($argv[1]); if ($trailing == "") { return; } $results = google_search($trailing); if ($results !== False) { if (count($results) > 0) { if (strlen($results[0]) > 300) { return; } privmsg("[google] " . $results[0]); } } #####################################################################################################
<?php header('Content-Type: text/html; charset=utf-8'); include_once 'simple_dom_parser/simple_html_dom.php'; require_once 'Unirest.php'; $name = "adele tickets"; $date = "7/5/2016"; $site = "vividseats"; $requested_url = google_search($name, $date, $site); $page_info = google_html_data($requested_url); event_info($page_info); function google_search($event_name, $event_date, $ticket_site) { $url = "https://www.google.com/search?q=" . $event_name . " " . $event_date . " " . $ticket_site; $google_page_data = Unirest::GET($url); return $google_page_data->raw_body; } function google_html_data($page_data) { $html = str_get_html($page_data); foreach ($html->find('div[class=g] h3[class=r] a') as $element) { $link_check = $element->plaintext; if (strpos($link_check, 'Adele') !== false) { if (strpos($link_check, '7/5/') !== false) { $link_url = $element->href; $link_url = explode("&", $link_url); $link_url = $link_url[0]; $link_url = explode("=", $link_url); $link_url = $link_url[1]; $link_url = str_replace("%3F", "?", $link_url); $link_url = str_replace("%3D", "=", $link_url);
function hardcoded($input, $db) { $out_type = 'append'; $element = 'output'; //Determine to which system will be input if (starts_with('google', $input)) { $query = substr($input, 7); include 'tools/search/google/google.php'; $google = google_search($query); foreach ($google['results'] as $result) { $output .= $result['formatted'] . '<br>'; } } elseif (starts_with('play', $input)) { $what_to_play = substr($input, 5); include 'tools/audio/search_music_local.php'; $music = search_music_local(); $games = get_windows_games(); $fuzzy_index = fuzzy_search($what_to_play, $music, $games); $output .= get_best_match($fuzzy_index); } elseif (starts_with('cmd', $input)) { //Request from user $command = substr($input, 4); $background = 0; $force_output = 1; $cmd = cmd($command, $background, $force_output); if ($cmd['command_not_found'] == FALSE) { $output = "<font color=green>"; if (count($cmd['lines']) != 0) { foreach ($cmd['lines'] as $line) { $output .= $line . "<br>"; } } else { $output .= 'Command executed: <b>' . $command . '</b>'; } $output .= "</font>"; } else { $output = "<font color=red>" . $command . " is possibly not a WIN CMD command</font><br>"; } } elseif (starts_with('random music', $input)) { $out_type = 'replace'; $element = 'audio'; include 'tools/audio/random_audio_file.php'; $path = random_audio_file(); $explode = explode(".", $path); $extension = $explode[1]; $localhost_path = $output = "<audio controls><source src='file:///" . $path . "' type='audio/" . $extension . "'></audio>"; } elseif (starts_with('network scan', $input)) { } elseif (starts_with('infobar request', $input)) { return process_infobar($db, $input); } else { return FALSE; } //It's not hardcoded return array('output' => $output . '<br>', 'element' => $element, 'out_type' => $out_type); }
<h1>Search Google</h1> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?> "><div> Query: <input type="text" name="q" /> <input type="submit" value="Search" /> </div></form> <?php if (isset($_REQUEST['q'])) { require 'google_search.php'; $results = google_search($_REQUEST['q']); echo '<h2>Google Results for ' . $_REQUEST['q'] . '</h2>' . "\n"; echo '<ul class="xoxo">' . "\n"; foreach ($results as $item) { echo ' <li><a href="' . htmlspecialchars($item['link']) . '">' . htmlspecialchars($item['title']) . '</a><br />' . $item['description'] . '</li>' . "\n"; } //end foreach results[items] echo '</ul>' . "\n"; } //end if q
" alt="" /> <img src="<?php echo $salon_pic_9; ?> " alt="" /> </div> <div class="col-sm-1" style="background-color:;"></div> </div> <br> <?php // グーグル検索結果 $fb_page = google_search($search_fb_page); // var_dump($fb_page); $fb_pic = $fb_page['items'][0]['link']; // explodeでurlを分解する $fb_key = explode('/', $fb_pic); // var_dump($fb_key); $facebook_search = $fb_key[3]; // フェイスブックの画像取得 $facebook_info = facebook_detail($facebook_search); // var_dump($pics); // 写真があるか確認 if ($facebook_info == null) { echo "no sns photos"; } else { for ($i = 0; $i < 24; $i++) { // 写真データの取得