<?php
require("../class/connect.php");
require("../class/db_sql.php");
require("../data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
define('WapPage','index');
require("wapfun.php");
$pagetitle=$public_r['sitename'];
require('template/'.$usewapstyle.'/index.temp.php');
db_close();
$empire=null;
?>上面 $pagetitle=$public_r['sitename']; 这句看不明白,public_r是变量?sitename是参数?哎,为了改个页面,我第一天看php
require("../class/connect.php");
require("../class/db_sql.php");
require("../data/dbcache/class.php");
$link=db_connect();
$empire=new mysqlquery();
define('WapPage','index');
require("wapfun.php");
$pagetitle=$public_r['sitename'];
require('template/'.$usewapstyle.'/index.temp.php');
db_close();
$empire=null;
?>上面 $pagetitle=$public_r['sitename']; 这句看不明白,public_r是变量?sitename是参数?哎,为了改个页面,我第一天看php
$public_r是变量数组,sitename是变量数组$public_r里的一个项
再问一个,如下是“wapfun.php”文件。这是ecms ,我要修改其中的wap用。
php中的function如果不调用是不是不会运行?
那在头部和尾部之间显示出来的东东,是那个语句调用出来的?
就是说,我看不懂这个页面显示,时候的中间的数据 是代码那里调用来的!<?php
//-------- 编码转换
function DoWapIconvVal($str){
global $phome_ecms_charver,$iconv,$pr;
if($phome_ecms_charver!='utf-8')
{
$char=$phome_ecms_charver=='big5'?'BIG5':'GB2312';
$targetchar=$pr['wapchar']?'UTF8':'UNICODE';
$str=$iconv->Convert($char,$targetchar,$str);
}
return $str;
}//-------- 提示信息
function DoWapShowMsg($error,$returnurl='index.php'){
DoWapHeader('提示信息');
?>
<p><?php echo $error;?><br /><a href="<?php echo $returnurl;?>">返回</a></p>
<?php
DoWapFooter();
exit();
}//-------- 头部
function DoWapHeader($title){
global $phome_ecms_charver;
ob_start();
header("Content-type: text/vnd.wap.wml; charset=utf-8");
echo'<?xml version="1.0" encoding="UTF-8"?>';
?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=180,private" />
</head>
<card id="empirecms_wml" title="<?php echo $title;?>">
<?php
}//-------- 尾部
function DoWapFooter(){
?>
<p><br/><small>Powered by EmpireCMS</small></p>
</card></wml>
<?php
$str=ob_get_contents();
ob_end_clean();
echo DoWapIconvVal($str);
}//-------- 分页
function DoWapListPage($num,$line,$page,$search){
if(empty($num))
{
return '';
}
$str='';
$pagenum=ceil($num/$line);
$phpself=$_SERVER['PHP_SELF'];
if($page)//首页
{
$str.="<a href=\"".$phpself."?page=0".$search."\">首页</a> ";
}
if($page)
{
$str.="<a href=\"".$phpself."?page=".($page-1).$search."\">上一页</a> ";
}
if($page!=$pagenum-1)
{
$str.="<a href=\"".$phpself."?page=".($page+1).$search."\">下一页</a> ";
}
if($page!=$pagenum-1)
{
$str.="<a href=\"".$phpself."?page=".($pagenum-1).$search."\">尾页</a> ";
}
return $str;
}//-------- 替换<p> --------
function DoWapRepPtags($text){
$text=str_replace(array('<p>','<P>','</p>','</P>'),array('','','<br />','<br />'),$text);
$preg_str="/<(p|P) (.+?)>/is";
$text=preg_replace($preg_str,"",$text);
return $text;
}//-------- 字段属性 --------
function DoWapRepField($text,$f,$field){
global $modid,$emod_r;
if(strstr($emod_r[$modid]['tobrf'],','.$f.','))//加br
{
$text=nl2br($text);
}
if(!strstr($emod_r[$modid]['dohtmlf'],','.$f.','))//去除html
{
$text=htmlspecialchars($text);
}
return $text;
}//-------- 去除html代码 --------
function DoWapClearHtml($text){
$text=stripSlashes($text);
$text=htmlspecialchars(strip_tags($text));
return $text;
}//-------- 替换字段内容
function DoWapRepF($text,$f,$field){
$text=stripSlashes($text);
$text=DoWapRepPtags($text);
$text=DoWapRepField($text,$f,$field);
return $text;
}//-------- 替换文章内容字段
function DoWapRepNewstext($text){
$text=stripSlashes($text);
$text=DoWapRepPtags($text);
return $text;
}//-------- 特殊字符去除
function DoWapCode($string){
$string=str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string);
return $string;
}//-------- 返回使用模板
function ReturnWapStyle($add,$style){
global $empire,$dbtbpre,$pr,$class_r;
$styleid=$pr['wapdefstyle'];
$classid=0;
if(WapPage=='index')
{
$classid=(int)$add['bclassid'];
}
elseif(WapPage=='list')
{
$classid=(int)$add['classid'];
}
elseif(WapPage=='show')
{
$classid=(int)$add['classid'];
}
if($classid&&$class_r[$classid]['tbname'])
{
$cr=$empire->fetch1("select wapstyleid from {$dbtbpre}enewsclass where classid='$classid'");
if($cr['wapstyleid'])
{
$styleid=$cr['wapstyleid'];
}
}
if($style&&$styleid==$pr['wapdefstyle'])
{
$styleid=$style;
}
$sr=$empire->fetch1("select path from {$dbtbpre}enewswapstyle where styleid='$styleid'");
$wapstyle=$sr['path'];
if(empty($wapstyle))
{
$wapstyle=1;
}
return $wapstyle;
}
$pr=$empire->fetch1("select wapopen,wapdefstyle,wapshowmid,waplistnum,wapsubtitle,wapshowdate,wapchar from {$dbtbpre}enewspublic limit 1");//导入编码文件
if($phome_ecms_charver!='utf-8')
{
@include_once("../class/doiconv.php");
$iconv=new Chinese('');
}if(empty($pr['wapopen']))
{
DoWapShowMsg('网站没有开启WAP功能','index.php');
}$wapstyle=intval($_GET['style']);
//返回使用模板
$usewapstyle=ReturnWapStyle($_GET,$wapstyle);
if(!file_exists('template/'.$usewapstyle))
{
$usewapstyle=1;
}
?>
通过关联数组,我们可以把值作为键,并向它们赋值。
sitename就是他的键。