示例#1
0
function parseGG($name)
{
    $url = "http://www.gamersgate.com/DD-" . $name . "/";
    $html = getHTML($url);
    preg_match("/price_price(.*)>([0-9]+)/", $html, $match);
    $price = $match[2];
    return $price;
}
示例#2
0
function parseGMG($name)
{
    $url = "http://www.greenmangaming.com/s/ru/en/pc/games/" . $name . "/";
    $html = getHTML($url);
    preg_match("/\"product_price_readable\": \"[0-9]+?(\\.[0-9]+)\"/", $html, $match);
    $price = $match[0];
    return explode(":", $price)[1];
}
示例#3
0
function parseSteam($gameid)
{
    $url = "http://store.steampowered.com/app/" . $gameid . "/";
    $html = getHTML($url);
    preg_match("/itemprop=\"price\".*\"([0-9]+?,?[0-9]+)\"/", $html, $match);
    $price = $match[1];
    return array($price, $url, "Steam");
}
示例#4
0
function fileupload_process($file)
{
    $attachment = handle_file($file);
    if (is_array($attachment)) {
        $html = getHTML($attachment);
        $response = array('success' => true, 'html' => $html, 'attach' => $attachment['id']);
        echo json_encode($response);
        exit;
    }
    $response = array('success' => false);
    echo json_encode($response);
    exit;
}
 public static function displayCFRow($row_key, $keyspace_name, $columnfamily_name, $row, $scf_key = null, $is_counter_column = false)
 {
     $vw_vars['scf_key'] = $scf_key;
     $vw_vars['row'] = $row;
     $vw_vars['keyspace_name'] = $keyspace_name;
     $vw_vars['columnfamily_name'] = $columnfamily_name;
     $vw_vars['row_key'] = $row_key;
     // If it's a column family of counter
     if ($is_counter_column) {
         return getHTML('columnfamily_row_counter.php', $vw_vars);
     } else {
         return getHTML('columnfamily_row.php', $vw_vars);
     }
 }
示例#6
0
function parseGOG($name)
{
    $gameName = prepareNameGOG($name);
    $url = "http://www.gog.com/game/" . $gameName;
    $html = getHTML($url);
    preg_match("/buy-price__new(.*)>([0-9]+)/", $html, $match_disc);
    preg_match("/class=\"buy-price(.*)>([0-9]+)/", $html, $match);
    if (count($match_disc[0]) != 0) {
        $price = $match[2] < $match_disc[2] ? $match[2] : $match_disc[2];
    } else {
        $price = $match[2];
    }
    return array($price, $url, "GOG");
}
 /**
  * @brief	Charge les fichiers Javascript selon le nom de la page et selon l'état de l'application (production ou développement)
  * @param	String		$controlName	Nom de la page qui demande à inclure le Javascript
  * @return 	String		Code HTML nécessaire à l'inclusion du/des codes Javascript
  * @see 		JSLoader::$production
  */
 public static function loader($controlName)
 {
     $result = "";
     if (self::$production == false) {
         $file = array();
         if (file_exists(self::$base . "common.js")) {
             $file[] = self::$base . 'common.js';
         }
         if (file_exists(self::$base . $controlName . ".js")) {
             $file[] = self::$base . $controlName . ".js";
         }
         foreach ($file as $f) {
             $result .= self::getHTML($f);
         }
     } else {
         $result = getHTML(self::$base . self::$prodJS);
     }
     return $result;
 }
示例#8
0
function getCast($tt, &$title = '')
{
    $html = getHTML($tt);
    if (preg_match('#<h3 itemprop="name">[\\s\\S]+?</h3>#i', $html, $match)) {
        $title = _clean($match[0]);
        // var_dump($title);
    }
    if (preg_match('#<table class="cast_list">([\\s\\S]+?)</table>#i', $html, $match)) {
        $table = $match[1];
        // preg_match_all('#itemprop="actor"[^<]+([\s\S]+?)</td>#', $table, $matches);
        // $actors = array_map(
        preg_match_all('#itemprop="actor"[\\s\\S]+?href="/name/(nm\\d+)[^>]+>([\\s\\S]+?)</a>#i', $table, $matches);
        $ids = array_map('_clean', $matches[1]);
        $actors = array_map('_clean', $matches[2]);
        // print_r($ids);
        $actors = array_combine($ids, $actors);
        // print_r($actors);
        preg_match_all('#<td class="character">([\\s\\S]+?)(?:\\(|/ \\.|</td)#i', $table, $matches);
        $characters = array_map('_clean', $matches[1]);
        $characters = array_combine($ids, $characters);
        // print_r($characters);
        return (object) compact('actors', 'characters');
    }
}
示例#9
0
        <?php 
$html = getHTML('http://themoneyballunion.com/game/StatsLab//widget.php?stat=pwar&topX=10', 10);
$html = utf8_encode($html);
echo $html;
?>
      </div>
      <div id='panel3' class="panel">
        <h3>HR leaders</h3>
        <?php 
$html = getHTML('http://themoneyballunion.com/game/StatsLab//widget.php?stat=hr&topX=10', 10);
$html = utf8_encode($html);
echo $html;
?>
        <h3>Hit leaders</h3>
        <?php 
$html = getHTML('http://themoneyballunion.com/game/StatsLab//widget.php?stat=h&topX=10', 10);
$html = utf8_encode($html);
echo $html;
?>
      
      </div>
      
      
    </aside>
    <div class="news">
      <h2>Breaking News</h2>
      <div class="articles">
      <?php 
include 'simple_html_dom.php';
//set up curl
$ch = curl_init("http://www.themoneyballunion.com/game/lgreports//leagues/league_100_home.html");
require 'helper/ClusterHelper.php';
require 'helper/ColumnFamilyHelper.php';
require 'helper/MX4J.php';
require 'conf.inc.php';
define('MINIMUM_THRIFT_API_VERSION_FOR_COUNTERS', '19.10.0');
$cluster_helper = new ClusterHelper($CASSANDRA_CLUSTERS);
session_start();
// Make sure the cluster index in the session still exists in the config array
if ($cluster_helper->getClusterIndex() > $cluster_helper->getClustersCount() - 1) {
    $_SESSION['cluster_index'] = 0;
}
try {
    $random_server = $cluster_helper->getRandomNodeForCurrentCluster();
    $sys_manager = new SystemManager($random_server, $cluster_helper->getCredentialsForCurrentCluster(), 1500, 1500);
} catch (TException $e) {
    die(getHTML('header.php') . getHTML('server_error.php', array('error_message' => displayErrorMessage('cassandra_server_error', array('error_message' => $e->getMessage())))) . getHTML('footer.php'));
}
/*
	Get the specified view and replace the php variables
*/
function getHTML($filename, $php_params = array())
{
    if (!file_exists('views/' . $filename)) {
        die('The view ' . $filename . ' doesn\'t exist');
    }
    // If we got some params to be treated in php
    extract($php_params);
    ob_start();
    include 'views/' . $filename;
    $content = ob_get_contents();
    ob_end_clean();
示例#11
0
    return $res;
}
function scrape_between($data, $start, $end)
{
    $data = stristr($data, $start);
    // Stripping all data from before $start
    $data = substr($data, strlen($start));
    // Stripping $start
    $stop = stripos($data, $end);
    // Getting the position of the $end of the data to scrape
    $data = substr($data, 0, $stop);
    // Stripping all data from after and including the $end of the data to scrape
    return $data;
    // Returning the scraped data from the function
}
$result = getHTML("http://www.snapdeal.com/product/hp-stream-8-windows-tablet/672158959721?", 0);
function getTitle($result)
{
    preg_match('/(.*)<\\/h1>/i', $result, $title);
    $ret = scrape_between($title[0], '<h1 itemprop="name" class=\'font20\'>', "</h1>");
    return $ret;
}
function getImg($result, $title)
{
    preg_match_all('/<img title=(.*) itemprop="image" (.*)>/i', $result, $img);
    $img_url = scrape_between($img[0][0], 'src="', '"');
    return $img_url;
}
function getMRP($result)
{
    preg_match_all('/original-price-id">(.*)</i', $result, $MRP);
示例#12
0
/**
 * entry point
 */
function init()
{
    try {
        //connect to database
        $db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASSWORD);
        $preparedParams = array();
        $statuses = $_POST["statuses"];
        $html = "";
        $pagingStatus = null;
        $filter = "";
        $sort = "";
        $query = "";
        if (isset($statuses)) {
            //statuses => array
            $statuses = json_decode(urldecode($statuses));
            foreach ($statuses as $key => $value) {
                switch ($value->action) {
                    case "paging":
                        $pagingStatus = $value;
                        break;
                    case "filter":
                        $filter .= getFilterQuery($value, $filter, $preparedParams);
                        break;
                    case "sort":
                        $sort = getSortQuery($value, $preparedParams);
                        break;
                }
            }
        }
        //count database items for pagination
        $query = "SELECT count(*) FROM Item " . $filter . " " . $sort;
        if (count($preparedParams) > 0) {
            $stmt = $db->prepare($query);
            //error_log(print_r($preparedParams, true));
            $stmt->execute($preparedParams);
            $count = $stmt->fetchColumn();
        } else {
            $count = $db->query($query)->fetchColumn();
        }
        //init pagination query
        if ($pagingStatus) {
            $paging = getPagingQuery($pagingStatus, $count, $preparedParams);
        }
        //init query with sort and filter
        $query = "SELECT title, description, image, likes, keyword1, keyword2 FROM Item " . $filter . " " . $sort . " " . $paging;
        if (count($preparedParams) > 0) {
            $stmt = $db->prepare($query);
            $stmt->execute($preparedParams);
            $items = $stmt->fetchAll();
        } else {
            $items = $db->query($query);
        }
        foreach ($items as $item) {
            $html .= getHTML($item);
        }
        //print html
        echo getHTMLWrapper($html, $count);
        //close the database connection
        $db = NULL;
    } catch (PDOException $ex) {
        print 'Exception: ' . $ex->getMessage();
    }
}
示例#13
0
<?php

/*
Stap3:
Het dowlaoden van alle posts en op te slaan
*/
//Open de csv waar de links in staan
if ($cvs = fopen("postList.csv", "r")) {
    //Voor elke relge gevodne in csv haal data op
    while ($data = fgetcsv($cvs, 1000, ",")) {
        //Haal de html op
        getHTML($data[1]);
        //Als er geen data gevodnen is geef een error
        if (!$html) {
            echo "There is no data found on this page\n";
        } else {
            //Open de locatie waar je het bestand wil opslaan en maar het bestand aan met als bestan naam de laaste gedeelte van de link
            $file = fopen('/var/www/test/bayw/allPost/' . str_replace($data[1], "", "site naam"), 'w');
            //Zet de html in het bestand
            fputs($file, $html);
            //sluit bestand
            fclose($file);
        }
        //Vertraag het script voor 2 sec om overload te voor komen
        sleep(2);
    }
    //sluit de csv
    fclose($cvs);
}
function create($entity)
{
    $html = getHTML($entity['source_url']);
    if (!$html) {
        return error_log('Could not import ' + $entity['source_url']);
    }
    // Clean title
    $entity['title'] = trim(html_entity_decode($entity['title'], ENT_COMPAT, 'UTF-8'));
    // Generate key
    $entity['key'] = 'ch/' . makeSlug($entity['title']);
    // Extract email
    $emailLink = $html->find('table.tabelleESK a[href^=mailto:]', 0);
    if ($emailLink) {
        $entity['email'] = str_replace('mailto:', '', trim($emailLink->href));
    }
    // Extract URL
    foreach ($html->find('table.tabelleESK tr') as $row) {
        $name = trim($row->children(0)->innertext);
        if (stripos('homepage', $name) !== false) {
            foreach ($row->children() as $i => $cell) {
                $link = $cell->find('a[href]', 0);
                if ($link) {
                    $entity['url'] = $link->href;
                    break;
                }
                // Ugly case: URL but no link
                if ($i && !$cell->children()) {
                    $entity['url'] = $cell->innertext;
                    break;
                }
            }
        }
    }
    // Find entity abbreviation
    $orgTitle = $html->find('h2.titleOrg', 0);
    if ($orgTitle) {
        $orgTitleParts = explode('-', $orgTitle->innertext);
        if (count($orgTitleParts) > 1) {
            $entity['abbr'] = trim(array_pop($orgTitleParts));
            $entity['abbr'] = html_entity_decode($entity['abbr'], ENT_COMPAT, 'UTF-8');
        }
    } else {
        error_log('No title on ' + $entity['source_url']);
    }
    // Find entity address
    $infoBlock = $html->find('div.infoblock', 0)->innertext;
    if (preg_match('/<\\/h2>(.+?)<div class="titleContent">/s', $infoBlock, $matches)) {
        $infoBlock = str_replace(array('<br>', '(neues Fenster)'), array(', ', ''), $matches[1]);
        $infoBlock = preg_replace('/\\s\\s+/', ' ', $infoBlock);
        $infoBlock = trim(html_entity_decode(strip_tags($infoBlock), ENT_COMPAT, 'UTF-8'));
        $entity['address'] = $infoBlock;
    }
    save($entity);
    getChildren($entity, $html);
}
示例#15
0
function init()
{
    if (empty($_POST['letters']) || empty($_POST['wordlen'])) {
        $html = getHTML(1);
    } else {
        $letters = trim($_POST['letters']);
        //Remove spaces in between
        $letters = strtolower(str_replace(' ', '', $letters));
        $wordlen = intval($_POST['wordlen']);
        if ($wordlen <= strlen($letters)) {
            $success = getMatches($letters, $wordlen);
            $html = getHTML(0, $success);
        } else {
            $success = array();
            $html = getHTML(0, $success);
        }
    }
    echo $html;
}
示例#16
0
// Attempt to find proper directory from current page to Root ...
$numAttempts = 0;
while (!file_exists($extension . $pathFile) && $numAttempts < 5) {
    $extension = '../' . $extension;
    $numAttempts++;
}
require $extension . $pathFile;
require 'SeriesManager.php';
// Need to define values as Global to be used between functions
$seriesArray = '';
$editLink = '';
// now we drive the application by calling the loadData(), processData(),
// and getHTML() routines
loadData();
processData();
echo getHTML();
//************************************************************************
/** 
 * loadData()
 *
 * Here we load up all the data we need to run this web page.
 */
function loadData()
{
    global $seriesArray;
    global $editLink;
    // Get a list of all the series entries in the table
    $seriesArray = array();
    $seriesManager = new RowManager_SeriesManager();
    // get all the rows in this table
    $list = $seriesManager->getListIterator();
示例#17
0
		<script type="text/javascript">
		try {

		<?php 
echo getJS();
?>
		
		} catch (e) {
			console.error(e.message);
			parent.window.onDifferent('Error');
		}

		$(function () {
		<?php 
@(include "{$path}/unit-tests.js");
?>
		});
		</script>
		
	</head>
	<body>

		<div id="qunit"></div>
		<div id="qunit-fixture"></div>
<?php 
echo getHTML($_GET['which']);
?>

	</body>
</html>
    if (isset($_GET['keyspace_name'])) {
        $keyspace_name = $_GET['keyspace_name'];
    }
    try {
        $time_start = microtime(true);
        $sys_manager->drop_keyspace($keyspace_name);
        $time_end = microtime(true);
        $_SESSION['success_message'] = 'drop_keyspace';
        $_SESSION['keyspace_name'] = $keyspace_name;
        $_SESSION['query_time'] = getQueryTime($time_start, $time_end);
        redirect('index.php?success_message=drop_keyspace');
    } catch (Exception $e) {
        $_SESSION['error_message'] = 'drop_keyspace';
        $_SESSION['keyspace_name'] = $keyspace_name;
        $_SESSION['message'] = $e->getMessage();
        redirect('index.php?error_message=drop_keyspace');
    }
}
if (!$included_header) {
    echo getHTML('header.php');
    if (!$is_valid_action) {
        // No action specified
        if (empty($action)) {
            echo displayErrorMessage('no_action_specified');
        } else {
            echo displayErrorMessage('invalid_action_specified', array('action' => $action));
        }
    }
}
echo getHTML('footer.php');
示例#19
0
/**
 * entry point
 */
function init()
{
    try {
        $statuses = $_POST["statuses"];
        $sort = "";
        $filterArr = array();
        $filter = "";
        $paging = "";
        $pagingStatus = null;
        $query = "";
        $html = "";
        //error_log(urldecode($_POST["statuses"]));
        if (isset($statuses)) {
            //statuses => array
            $statuses = json_decode(urldecode($statuses));
            foreach ($statuses as $key => $value) {
                switch ($value->action) {
                    case "paging":
                        $pagingStatus = $value;
                        break;
                    case "filter":
                        $filter .= getFilterQuery($value, $filter);
                        break;
                    case "sort":
                        $sort = getSortQuery($value);
                        break;
                }
            }
            //connect to SQLite database
            $db = new PDO("sqlite:jplist.db");
            //increases sqlite performance by turning syncing off
            $db->exec("pragma synchronous = off;");
            //count database items for pagination
            $query = "SELECT count(*) FROM Item " . $filter . " " . $sort;
            $count = $db->query($query)->fetchColumn();
            //init pagination query
            if ($pagingStatus) {
                $paging = getPagingQuery($pagingStatus, $count);
            }
            //init query with sort and filter
            $query = "SELECT title, desc, img, likes, keyword1, keyword2 FROM Item " . $filter . " " . $sort . " " . $paging;
            //select items
            $items = $db->query($query);
            foreach ($items as $item) {
                $html .= getHTML($item);
            }
            //init array for json data
            //$json_arr = array("html" => utf8_encode($html), "data" => array("count" => $count), "query"=> $query);
            //print html
            echo getHTMLWrapper($html, $count);
            //close the database connection
            $db = NULL;
        }
    } catch (PDOException $ex) {
        print 'Exception: ' . $ex->getMessage();
    }
}
示例#20
0
<?php

include "parse.php";
$gameName = $_POST["gameName"];
$url = "http://store.steampowered.com/search/?snr=1_7_7_151_12&term=" . $gameName;
$html = getHTML($url);
preg_match_all("/data-ds-appid.*\"([0-9]+)\"/", $html, $match_id, PREG_PATTERN_ORDER);
preg_match_all("/search_capsule\">(.*)alt/", $html, $match_logo, PREG_PATTERN_ORDER);
preg_match_all("/title\">(.*)</", $html, $match_title, PREG_PATTERN_ORDER);
$i = 0;
foreach ($match_title[1] as $title) {
    echo "<a href=\"http://localhost/greesha/getbestdeal/result/prices.php?name=" . $title . "&&id=" . $match_id[1][$i] . "\">";
    echo "<p>" . $title . "</p>";
    echo "</a>";
    ++$i;
}
示例#21
0
文件: export.php 项目: ExeErik/Test
            $xsl_template = 'export_time.xsl';
    }
    $xml = $taet->getExport($expstart, $expfinish, $users, $projectsarr, $groupby, $options);
    $erg = '';
    foreach ($xml as $rs) {
        $erg .= $rs . "\n";
    }
    if (!class_exists('DOMDocument') && !function_exists('xslt_process')) {
        $datatype = 'xml';
    }
    if ($datatype == 'html') {
        if (function_exists('xslt_process')) {
            echo XtDataWithFile($erg, $xsl_template);
        } else {
            if (class_exists('DOMDocument')) {
                echo getHTML($erg, $xsl_template);
            } else {
                $datatype = 'xml';
                echo $erg;
            }
        }
    } else {
        echo $erg;
    }
} else {
    echo <<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>{$dict['error']}</title>
<meta http-equiv="expires" content="0" />
示例#22
0
//flights.pdf
require 'fpdf181/fpdf.php';
//check if a terminal paramater was provided to the script when requested, if not set $requestedTerminal to "NONE"
if (isset($_GET["terminal"]) == false) {
    $requestedTerminal = "NONE";
} else {
    $requestedTerminal = $_GET['terminal'];
}
//if a valid paramater was passed to the script then set $requestedTerminal.
if ($requestedTerminal == 'n' || $requestedTerminal == 'N') {
    $requestedTerminal = 'North';
} elseif ($requestedTerminal == 's' || $requestedTerminal == 'S') {
    $requestedTerminal = 'South';
}
// get HTML from Gatwick webpage via cUrl function
$HTML = getHTML();
//Extract table from curl response
$tableStartPos = strpos($HTML, '<tbody>');
$tableEndPos = strpos($HTML, '</tbody>');
//check if there is a 2nd table of flight data
if (strpos($HTML, '</tbody>', $tableEndPos + 8) !== FALSE) {
    //if so replace current tableEndPos with new tableEndPos
    $tableEndPos = strpos($HTML, '</tbody>', $tableEndPos + 8);
}
//set length of table(s) to extract html data
$tableLength = $tableEndPos - $tableStartPos;
//output table for next block to process
$flightTable = substr($HTML, $tableStartPos, $tableLength);
//creat empty array for flight data
$flightData = [];
//find position of date in 1st table
示例#23
0
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    // follow redirects if any
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    // max. seconds to execute
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    // stop when it encounters an error
    // curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $res = curl_exec($ch);
    if ($res === false) {
        echo 'Curl error #' . curl_errno($ch) . ': ' . curl_error($ch);
    }
    return $res;
}
function scrape_between($data, $start, $end)
{
    $data = stristr($data, $start);
    // Stripping all data from before $start
    $data = substr($data, strlen($start));
    // Stripping $start
    $stop = stripos($data, $end);
    // Getting the position of the $end of the data to scrape
    $data = substr($data, 0, $stop);
    // Stripping all data from after and including the $end of the data to scrape
    return $data;
    // Returning the scraped data from the function
}
$result = getHTML("https://www.facebook.com/raysoflovearpan", 0);
$id = scrape_between($result, "r.php?profile_id=", "&");
echo $id;
 public static function displayCFTimeUUIDTypeRow($row_key, $keyspace_name, $columnfamily_name, $row, $scf_key = null, $is_counter_column = false)
 {
     $vw_vars['scf_key'] = $scf_key;
     $uuid_row = array();
     foreach ($row as $c => &$v) {
         $uuid_row[(string) unserialize($c)] = $v;
     }
     unset($row, $v);
     $vw_vars['row'] = $uuid_row;
     $vw_vars['keyspace_name'] = $keyspace_name;
     $vw_vars['columnfamily_name'] = $columnfamily_name;
     $vw_vars['row_key'] = $row_key;
     // If it's a column family of counter
     if ($is_counter_column) {
         return getHTML('columnfamily_row_counter.php', $vw_vars);
     } else {
         return getHTML('columnfamily_row.php', $vw_vars);
     }
 }
<?php

include 'connect.php';
// Only NPC spawned:
// $queryloots=mysql_query("SELECT entry FROM creature_template WHERE entry IN (SELECT id FROM creature WHERE id IN (SELECT entry FROM creature_template WHERE entry > $start AND (lootid=0 OR skinloot=0 OR pickpocketloot=0))) ORDER BY entry;");
// All NPC
//$queryloots=mysql_query("SELECT entry, lootid, skinloot, pickpocketloot FROM creature_template WHERE entry > $start AND (lootid=0 OR skinloot=0 OR pickpocketloot=0) ORDER BY entry;");
$queryloots = mysql_query("SELECT entry, lootid, skinloot, pickpocketloot FROM creature_template WHERE entry > {$start} AND (lootid=0 OR skinloot=0 OR pickpocketloot=0) ORDER BY entry;");
while ($executes = mysql_fetch_array($queryloots, MYSQL_ASSOC)) {
    echo "\n Checking {$executes['entry']}";
    $data = getHTML("http://www.wowhead.com/npc={$executes['entry']}", 10);
    if (strpos($data, "tab_drops")) {
        if ($executes['lootid'] == "0") {
            $file = fopen("All_Loot.txt", "a+");
            fwrite($file, "\n{$executes['entry']}");
            fclose($file);
            echo " -- loot";
            // if the NPC is bugged print this
        }
    }
    if (strpos($data, "tab_pickpocketing")) {
        if ($executes['pickpocketloot'] == "0") {
            $file = fopen("All_Pickpocket.txt", "a+");
            fwrite($file, "\n{$executes['entry']}");
            fclose($file);
            echo " -- pickpocketloot";
            // if the NPC is bugged print this
        }
    }
    if (strpos($data, "tab_skinning")) {
        if ($executes['skinloot'] == "0") {
function storeDataFrom($subject, $url)
{
    global $conn;
    list($doc, $hash) = readPage($url, true);
    $term = $doc->getElementsByTagName("i")->item(0)->textContent;
    $tables = $doc->getElementsByTagName("table");
    $count = array();
    $count[0] = 0;
    $count[1] = 0;
    $courses = array();
    foreach ($tables as $table) {
        $title = $table->previousSibling->previousSibling;
        // happens on the first element... HTML output is not well-formed
        if ($title->nodeType != XML_ELEMENT_NODE) {
            $title = $title->previousSibling;
        }
        $titleStr = trim($title->textContent);
        for ($i = 0; $i < strlen($titleStr); $i++) {
            if (ctype_space($titleStr[$i])) {
                break;
            }
        }
        // each course number consists of 3 characters that represent the course
        // number followed by a single optional variant character
        $nr = substr($titleStr, 0, $i);
        $var = '';
        if (strlen($nr) > 3) {
            $var = substr($nr, 3);
            $nr = substr($nr, 0, 3);
        }
        // check for an invalid course#.. if the length is less than 3, we
        // assume the data is invalid. ACCT11, for example, is invalid
        if (strlen($nr) < 3) {
            continue;
        }
        $str = trim(substr($titleStr, $i));
        $desc = "";
        // lazy load the catalog info..
        if (!isset($catDoc)) {
            if (!DISABLE_CATALOG_SCRAPING && !courseExists($subject, $nr, $var)) {
                $campus = strtolower(subjectTaughtAt($subject));
                $pageName = false;
                $query = "SELECT Rprefix FROM SubjectMap WHERE Lprefix='{$subject}'";
                if ($campus != "njit") {
                    $res = $conn->query($query);
                    if ($res) {
                        $row = $res->fetch_row();
                        if ($row) {
                            $pageName = $row[0];
                        }
                    }
                }
                if ($campus == "njit" || $pageName !== false) {
                    try {
                        // the script would run faster if it did not check the course
                        // catalog for course information.
                        $pagestr = $campus == "njit" ? $subject : $pageName;
                        $catDoc = readPage("http://catalog.njit.edu/courses/" . strtolower($pagestr) . ".php");
                    } catch (Exception $e) {
                        $catDoc = false;
                    }
                }
            }
        }
        if (isset($catDoc) && $catDoc !== false) {
            // search for the information excluding the variant
            //	example: BIOL100
            // then reduce the returned list if it is greater than
            $searchPrefix = $campus != "rutg" ? $subject . $nr : $subject . ":" . $nr;
            $searchPrefix = strtolower($searchPrefix);
            $list = findByAttribute($catDoc, "a", "name", $searchPrefix);
            if (count($list) > 1 && strlen($var) > 0) {
                $searchPrefix .= $var;
                while (count($list) > 0 && strcasecmp($list[0]->getAttribute("name"), $searchPrefix) != 0) {
                    array_shift($list);
                }
            }
            if (count($list) > 0) {
                $text = $list[0]->textContent;
                $titleStart = strpos($text, '-') + 1;
                $titleEnd = strpos($text, '(', $titleStart + 1);
                $numEnd = $titleEnd;
                while (ctype_digit($text[++$numEnd])) {
                }
                if ($text[$numEnd] == ')' || $text[$numEnd] == '-' || strpos(substr($text, $titleEnd + 1, strpos($text, ')', $titleEnd) - $titleEnd), "credits") !== false) {
                    $credits = floatval(substr($text, $titleEnd + 1, $numEnd - $titleEnd - 1));
                }
                $text = trim(substr($text, $titleStart, $titleEnd - $titleStart));
                $par = $list[0]->parentNode;
                $par->removeChild($list[0]);
                $desc = trim(str_replace("\\n", "", getHTML($par)));
                $prereq = strncasecmp("prerequisite", $desc, 12) == 0;
            }
        }
        if (array_key_exists($subject . $nr . strtoupper($var), $courses)) {
            $course = $courses[$subject . $nr . strtoupper($var)];
            $alt_title = $str;
        } else {
            $course = new Course();
            $course->title = $str;
            $course->name = $subject . $nr . strtoupper($var);
            $course->subject = $subject;
            $course->coursenr = $nr;
            $course->coursevar = strtoupper($var);
            $course->description = $desc;
        }
        //		echo "&gt; <b>$nr</b>$var - $str<br/>";
        if (!isset($alt_title)) {
            $alt_title = $course->title;
        }
        $sections = parseTableData($table, $course, $term, $alt_title);
        unset($alt_title);
        if (isset($credits) && $credits > 0) {
            $course->credits = $credits;
            $credits = 0;
        }
        if (!array_key_exists($course->name, $courses)) {
            $count[0]++;
            $courses[$course->name] = $course;
        }
        $count[1] += count($sections);
        //persist($course);
    }
    return array(array_values($courses), $count, $hash);
}
<?php

/*
	Cassandra Cluster Admin
	
	@author Sébastien Giroux
	@copyright All rights reserved - 2011
*/
require_once 'include/kernel.inc.php';
require_once 'include/verify_login.inc.php';
$vw_vars['cluster_details'] = $CASSANDRA_CLUSTERS;
$vw_vars['cluster_name'] = $sys_manager->describe_cluster_name();
$vw_vars['partitioner'] = $sys_manager->describe_partitioner();
$vw_vars['snitch'] = $sys_manager->describe_snitch();
$vw_vars['thrift_api_version'] = $sys_manager->describe_version();
$vw_vars['schema_version'] = $sys_manager->describe_schema_versions();
$vw_vars['cluster_helper'] = $cluster_helper;
$ks_and_cf_details = ColumnFamilyHelper::getKeyspacesAndColumnFamiliesDetails();
$keyspaces_name = $ks_and_cf_details['keyspaces_name'];
$keyspaces_details = $ks_and_cf_details['keyspaces_details'];
$vw_vars['keyspaces_name'] = $keyspaces_name;
$vw_vars['keyspaces_details'] = $keyspaces_details;
echo getHTML('cluster_info.php', $vw_vars);
示例#28
0
<?php

if ($_GET['what'] == 'good') {
    $names = array('Sherlock Holmes', 'John Watson', 'Hercule Poirot', 'Jane Marple');
    echo getHTML($names);
} else {
    if ($_GET['what'] == 'bad') {
        $names = array('Professor Moriarty', 'Sebastian Moran', 'Charles Milverton', 'Von Bork', 'Count Sylvius');
        echo getHTML($names);
    }
}
function getHTML($names)
{
    $strResult = '<ul>';
    for ($i = 0; $i < count($names); $i++) {
        $strResult .= '<li>' . $names[$i] . '</li>';
    }
    $strResult .= '</ul>';
    return $strResult;
}
?>

示例#29
0
<?php

$html = getHTML("http://www.whatismyip.com", 60);
preg_match("/the-ip\">(.*)div/i", $html, $match);
$data = $match[1];
$enc_ip = strip_tags($data);
$ip1 = str_replace(";", "", $enc_ip);
$ip2 = explode("&#", $ip1);
$new_ip = "";
foreach ($ip2 as $char) {
    $new_ip .= chr($char);
}
echo trim($new_ip);
function getHTML($url, $timeout)
{
    $HTTP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36";
    $ch = curl_init($url);
    // initialize curl with given url
    curl_setopt($ch, CURLOPT_USERAGENT, $HTTP_USER_AGENT);
    // set  useragent
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // write the response to a variable
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    // follow redirects if any
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    // max. seconds to execute
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    // stop when it encounters an error
    return @curl_exec($ch);
}
示例#30
0
function init()
{
    if (!isset($_POST['keyword'])) {
        $html = getInitHTML();
        echo $html;
    } else {
        $keyword = $_POST['keyword'];
        $data = getData($keyword);
        if (!$data) {
            echo "Error !!!!";
            exit;
        }
        $html = getHTML($data, $keyword);
        echo $html;
    }
}