Example #1
0
<?php

require_once dirname(dirname(__FILE__)) . "/include/common.inc.php";
require_once SLINEINC . "/view.class.php";
require_once "QunarXml.php";
//$xml = new QunarXml();
//$filename = dirname(__FILE__).'/line.xml';
//$body = getlines();
//$xml->writeXml($body,$filename);
$weburl = 'http://www.lvyou.com';
$xml = new QunarXml();
getlines();
//获取线路
function getLines()
{
    global $dsql, $xml, $weburl;
    $xml_url_list = '';
    $sql = "select * from sline_line limit 10";
    $arr = $dsql->getAll($sql);
    foreach ($arr as $row) {
        $filename = dirname(__FILE__) . '/' . $row['id'] . '.xml';
        $url = $GLOBALS['cfg_basehost'] . "/lines/show_{$row['aid']}.html";
        $price_arr = XmlLine::getLineMinPrice($row['id']);
        $overcity = explode(',', $row['overcity']);
        $overspot_arr = XmlLine::getOverSpot($row['id']);
        //线路图片处理
        $lineimages = explode(",", $row['piclist']);
        $image_arr = array();
        foreach ($lineimages as $image) {
            $im = explode('||', $image);
            $image_arr[] = $GLOBALS['cfg_basehost'] . $im[0];
Example #2
0
function getlines($fl)
{
    return count($fl);
}
$state = htmlentities(strip_tags($_GET['state']), ENT_QUOTES);
$file = htmlentities(strip_tags($_GET['file']), ENT_QUOTES);
$finish = time() + 50;
$count = getlines(getfile($file));
while ($count <= $state) {
    $now = time();
    usleep(10000);
    if ($now <= $finish) {
        $count = getlines(getfile($file));
    } else {
        break;
    }
}
if ($state == $count) {
    $log['state'] = $state;
    $log['t'] = "continue";
} else {
    $text = array();
    $log['state'] = $state + getlines(getfile($file)) - $state;
    foreach (getfile($file) as $line_num => $line) {
        if ($line_num >= $state) {
            $text[] = $line = str_replace("\n", "", $line);
        }
        $log['text'] = $text;
    }
}
echo json_encode($log);