欢迎使用 PHPStat Counter 用户开发手册
范例:读取每月ALEXA数据; <? Initialize( $_GET, array( 'Date_Year'=>'intval', 'Date_Month'=>'intval','website'=>'strval' ) );
} //读取当月统计信息 if(count($MTmp[$i]) == 0)
//当月统计信息处理结束 $Tpl->assign( 'Year', $Year ); $Tpl->assign( 'Title', 'Alexa工具条 - '.$SoftWareName .$SoftWareVersion ); ?>
|
另外还包括可选文件:
include_once './include.inc/function_language.php'; //系统语言函数;
使用方法:加载文件,获取变量 $language = GetLanguage('zh-cn');
include_once './include.inc/function_system.php'; //操作系统函数;
使用方法:加载文件,获取变量 $system = GetSystem('windows nt 5.2');
include_once './include.inc/function_timezone.php'; //系统时区函数;
使用方法:加载文件,获取变量 $timezone = GetTimeZone('-8');注意变量$timezone返回一个数组$timezone[0]='GMT+08:00',$timezone[1]='北京,重庆,广州,上海,香港,乌鲁木齐,台北,新加坡,佩思'
include_once './include.inc/page.inc.php'; //分页函数;
使用方法:具体用文件来讲解;
软件全部使用ADODB_LITE来实现数据库的读写操作,有助于进行数据库更换操作,提前规划好软件更新换代工作的工作.具体连接设置请查看源文件(include.inc/conn.db.inc.php).这里不讲解全部的使用方法,遇到具体问题请查阅相关手册,以获取帮助!接下来讲解数据库的插入(Insert into ),查询(Select),编辑(Update )和删除(Delete)操作.
请查看本页的前面代码部分的加粗地方
$Res = $Conn->Execute( " select counts, times from $TableList[alexa] where times <= $EndTime and times >= $MonthTime and website = '$website'" );
这里看到的是最常遇到的执行操作($Conn->Execute),相当于mysql_query().需要注意的是上面的数据库连接返回一个变量$Conn,用来执行相关数据库操作.$Res->FetchRow()用来获取结果集里面的每一条数据,相当于mysql_fetch_row(),如果获取的数据多于一条,请加上while($Row = $Res->FetchRow()), 循环执行.
分页
.....
//记录总数
$Res = $Conn->Execute( " select id from $TableList[ip_limit] where website = '$website' group by country" );
$DataCount = $Res->RecordCount(); //纪录总数
$PageSize = 20; //每页显示数
if( $DataCount > 0 )
{
include_once ( './include.inc/page.inc.php' ); //加载分页类文件
$PageItems = MakePageItems ( $DataCount, $PageSize );
$PageLinks = MakePageLinks ( $PageItems, '记录','条' );
$Tpl->assign( 'PageLinks', $PageLinks );
}
if($PageItems[Offset] == "")$PageItems[Offset] = 0;
$Res = $Conn->SelectLimit( " select count(id) as counts,country from $TableList[ip_limit] where website = '$website' group by country ORDER BY `counts` DESC ",$PageSize , $PageItems[Offset] );
$CountAll = 0;//国家总和
while( $Tmp = @$Res->FetchRow() )
......
软件全部使用Smarty模板处理界面问题,需要您懂Smarty基本语法知识!
全部模版放置在templates/business下面,左右分界符号是'{/'和''/}',象这样的使用方法:{/$myvar/}.
$Tpl->assign( 'Year', $Year ); //变量赋值
$Tpl->assign( 'Month', $Month ); //变量赋值
$Tpl->assign( 'DataTime', $MonthTime ); //变量赋值
$Tpl->assign( 'website', $website ); //变量赋值
$Tpl->assign( 'Main', $Tpl->fetch( 'stat_alexa.html' ) ); //读取子模板
$Tpl->assign( 'Title', 'Alexa工具条 - '.$SoftWareName .$SoftWareVersion );
$Tpl->assign( 'NowView', 'Alexa工具条' ); //变量赋值
$Tpl->assign( 'CopyRight', $PHPStatBottomRight );
//变量赋值
_out( $Tpl->fetch( 'main.html' ) ); //读取主模板