日期:2014-05-17  浏览次数:20430 次

使用html模板获取不到php的变量值
PHP code
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC.'/arc.partview.class.php');

error_reporting(E_ERROR | E_WARNING | E_PARSE);
function get_sub_content($str, $start, $end){
    if($start == '' || $end == ''){
        return;
    }
    $str = explode($start, $str);
    $str = explode($end, $str[1]);
    return $str[0]; 
}
include('Snoopy.class.php');
if (!$_GET['hpzl'] || !in_array($_GET['hpzl'],array('01','02'))) {
    exit('<script>alert("请选择号牌种类!");history.back();</script>');
}
$hpzl = trim($_GET['hpzl']);

if (!$_GET['hphm']) {
    exit('<script>alert("请填写正确的车牌号码!");history.back();</script>');
}
$hphm = strtoupper(trim($_GET['hphm']));

if (!$_GET['tj'] || !in_array($_GET['tj'],array('SYR','SFZMHM','FDJH','CLSBDH'))) {
    exit('<script>alert("所有人不正确!");history.back();</script>');
}
$tj = trim($_GET['tj']);

if (!$_GET['tj_val']) {
    exit('<script>alert("所有人不正确!");history.back();</script>');
}
$tj_val = trim($_GET['tj_val']);
$tj_val = iconv('gb2312','utf-8',$tj_val);

$url = 'http://117.36.53.122:9082/wfcx/query.do?actiontype=vioSurveil&hpzl='.$hpzl.'&hphm='.$hphm.'&tj='.$tj.'&tj_val='.urlencode($tj_val);

$snoopy = new Snoopy();
$snoopy->fetch($url); 
$result = $snoopy->results;
$result = str_replace(chr(10),'',$result);
$result = str_replace(chr(13),'',$result);
$result = str_replace(chr(9),'',$result);


$alert = get_sub_content($result,'alert("','");');
if ($alert) {
    exit('<script>alert("没有查到该车辆信息,请检查是否输入正确!");history.back();</script>');
}

$car = array();
$car['hpzl'] = get_sub_content($result,'号牌种类</td><td>&nbsp;','</td>');
$car['hphm'] = get_sub_content($result,'号牌号码</td><td>&nbsp;','</td>');
$car['zwpp'] = get_sub_content($result,'中文品牌</td><td>&nbsp;','</td>');
$car['clxh'] = get_sub_content($result,'车辆型号</td><td>&nbsp;','</td>');
$car['cllx'] = get_sub_content($result,'车辆类型</td><td>&nbsp;','</td>');
$car['csys'] = get_sub_content($result,'车身颜色</td><td>&nbsp;','</td>');
$car['yxqz'] = get_sub_content($result,'检验有效期止</td><td>&nbsp;','</td>');
$car['bfqz'] = get_sub_content($result,'强制报废期止</td><td>&nbsp;','</td>');
$car['jdczt'] = get_sub_content($result,'机动车状态</td><td>&nbsp;','</td>');
$car['jdsyr'] = get_sub_content($result,'机动车所有人</td><td colspan="5">&nbsp;','</td>');

if(!$car){
    exit('<script>alert("没有查到该车辆信息,请检查是否输入正确!");history.back();</script>');
}

$weigui = get_sub_content($result,'信息来源</b></td></tr>','</table>');
$weigui = explode('</tr>',$weigui);
$weigui = array_filter($weigui);
if ($weigui) {
    foreach ($weigui as $wg){
        $wg = explode('</td>',$wg);
        $arr['hphm'] = str_replace('<TR style="cursor:hand"><td align="center" height="22">','',$wg[0]);
        $arr['hpzl'] = str_replace('<td align="center">','',$wg[1]);
        $arr['wfsj'] = str_replace('<td align="center">','',$wg[2]);
        $arr['wfdd'] = str_replace('<td align="center">','',$wg[3]);
        $arr['wfxw'] = str_replace('<td align="center">','',$wg[4]);
        $arr['fxjg'] = str_replace('<td align="center">','',$wg[5]);
        $arr['xxly'] = str_replace('<td align="center">','',$wg[6]);
        $car['weigui'][] = $arr;
    }
}else {
    $car['weigui'] = array();
}
//print_r($weigui);
//print_r($car);
$wg = new PartView();
$wg->SetTemplet($cfg_basedir.$cf