统计网站访问量,以GD2库图像形式输出
index.php页面
<?php session_start();
if($_SESSION[temp]==""){ //判断$_SESSION[temp]==""的值是否为空,其中的temp为自定义的变量
if(($fp=fopen("counter.txt","r"))==false){
echo "打开文件失败!";
}else{
$counter=fgets($fp,); //读取文件中数据
fclose($fp); //关闭文本文件
$counter++; //计数器增加1
$fp=fopen("counter.txt","w"); //以写的方式打开文本文件<!---->
fputs($fp,$counter); //将新的统计数据增加1
fclose($fp); //关闭文本文件
}
$_SESSION[temp]=; //登录以后,$_SESSION[temp]的值不为空,给$_SESSION[temp]赋一个值1
}
?> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>通过文本文件统计页面访问量</title>
<style type="text/css">
.STYLE1 {
font-size: 12px;
font-weight: bold;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE2 {
color: #FF0000;
font-weight: bold;
}
body,td,th {
font-size: 12px;
}
</style>
</head>
<body>
<table width="" border="" align="center" cellpadding="" cellspacing="">
<tr>
<td height="" colspan="" bgcolor="#FFFFFF"><img src="data:images/bg01.jpg" width="" height=""></td>
</tr>
<tr>
<td width="" bgcolor="#FFFFFF"> </td>
<td width="" align="center" valign="top" bgcolor="#FFFFFF"><table width="" border="" cellpadding="" cellspacing="" background="images/bg03.jpg">
<tr>
<td width="" height="" ><p align="center">
《<strong>PHP</strong><strong>编程词典》系列产品</strong></p>
<h5>《PHP编程词典》系列产品:</h5>
<table width="" border="" cellpadding="" cellspacing="" bordercolor="#F9FAF5" bgcolor="#90BF3B">
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p align="center">《编程词典》名称 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p align="center">《编程词典》价格 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p align="center">《编程词典》升级 </p></td>
</tr>
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p>《PHP编程全能词典》 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>98元 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>12次/年 </p></td>
</tr>
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p>《PHP编程词典》标准版 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>368元 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>实时升级 </p></td>
</tr>
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p>《PHP编程词典》珍藏版 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>698元 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>实时升级 </p></td>
</tr>
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p>《PHP编程词典》企业版 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>2998元 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>实时升级 </p></td>
</tr>
<tr>
<td width="" valign="top" bgcolor="#FFFFFF"><p>《PHP编程词典》钻石版 </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>5998元(2998元) </p></td>
<td width="" valign="top" bgcolor="#FFFFFF"><p>实时升级 </p></td>
</tr>
</table>
<p>注意:<br />
.《PHP编程词典》钻石版价格为5998元(含三年网络课堂学习),如果不学习网络课堂,价格为2998元<br />
.《PHP编程全能词典》就是《PHP编程词典》普及版</p>
<h5> </h5>
</td>
</tr>
<tr>
<td height="" align="center"><img src="gd1.php" /></td>
</tr>
</table></td>
<td width="" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td height="" colspan="" bgcolor="#FFFFFF"><div align="center"><img src="data:images/bg02.jpg" width="" height=""> </div></td>
</tr>
</table>
<p> </p>
</body>
</html>
gd1.php页面
<?php
//以图形的形式输出数据库中的记录数
if(($fp=fopen("counter.txt","r"))==false){
echo"打开文件失败";
}else{
$counter=fgets($fp,);
fclose($fp);
//利用GD2函数创建画布
$im=imagecreate(,);
$gray=imagecolorallocate($im,,,);//定义画布背景颜色
$color=imagecolorallocate($im,rand(,),rand(,),rand(,)); //定义字体颜色
//输出中文字符
$text="网站的访问量";
$font = "Fonts/FZHCJW.TTF";
imagettftext($im,,,,,$color,$font,$text);//输出中文
//输出网站的访问次数
imagestring($im,,,,$counter,$color);
imagepng($im);
imagedestroy($im);
}
注:需要在其服务器端目录下建一个counter.txt文件用于存储访问量
统计网站访问量,以GD2库图像形式输出的更多相关文章
- js实现精确统计网站访问量的代码分享
JS 精确统计网站访问量. 代码如下: /** * vlstat 浏览器统计脚本 */ var statIdName = "vlstatId"; var xmlHttp; /** ...
- 《ASP.NET1200例》统计网站访问量源代码
void Application_Start(object sender, EventArgs e) { //在应用程序启动时运行的代码 int count=0; ...
- Java 和 JSP 实现网站访问量统计 (刷新过滤)
java 和 JSP 实现的统计网站访问量,不需要数据库,将数据存储在 指定位置的 txt 文件中,代码块分为两部分 首先, java 部分: import java.io.File; import ...
- 如何实现ASP.NET中网站访问量的统计
如何实现ASP.NET中网站访问量的统计 2009-07-30 15:50 佚名 网翼教程网 字号:T | T 本文介绍了如何在asp.net中进行网站访问量的统计. AD:51CTO 网+ 第十二期 ...
- Google Analytics SEO 实时 网站 访问量 统计
/*************************************************************************** * Google Analytics SEO ...
- ASP.net中网站访问量统计方法代码(在线人数,本月访问,本日访问,访问流量,累计访问)
一.建立一个数据表IPStat用于存放用户信息 我在IPStat表中存放的用户信息只包括登录用户的IP(IP_Address),IP来源(IP_Src)和登录时间 (IP_DateTime),些表的信 ...
- PHP使用GD2库画图,图像无法输出解决方法
在CS6编辑环境下,使用php的GD2库绘制图像,在浏览器上输出可能会出现图像无法输出的情况,目前发现两个解决方法:方法1:用记事本写,再另存为utf-8 no bom的格式. 方法2:在代码中添加o ...
- PHP文件操作,多行句子的读取,file()函数,file_get_contents()函数,file_put_contents()函数,is_file,统计网站pv (访问量),文件的复制 copy,文件重命名 rename,删除文件 unlink
php中添加utf-8: header("Content-type:text/html;charset='UTF-8'"); 文件操作步骤: 1.在同一目录下建立一个file.tx ...
- github+hexo搭建自己的博客网站(四)主题之外的一些基本配置(统计配置,网站访问量显示)
1.百度.谷歌统计配置 百度统计配置 申请账号:https://tongji.baidu.com/web/welcome/login 在代码获取的地方只要填入key即可 注册的时候,填的域名和url, ...
随机推荐
- [转]SRTM、ASTER GDEM等全球数字高程数据(DEM)下载方式简介
之前写过一篇短文对比过几种数字高程数据的区别:5种全球高程数据对比,这篇文章简要介绍下如何下载这些数据. 1.DLR的数字高程数据.该数据也是SRTM(shuttle radar topo ...
- cookie+memcached实现单点登陆
10年的时候在iteye的第一篇文章记录了一下当时怎么实现我们系统的单点登陆.不过那个时候文章写的不好,思路也很浮躁,很难看懂,在csdn的第一篇技术博客打算重新温顾一下当时实现单点登陆的思路.先来看 ...
- 基于.NET平台常用的框架整理 (转)
http://www.cnblogs.com/hgmyz/p/5313983.html 自从学习.NET以来,优雅的编程风格,极度简单的可扩展性,足够强大开发工具,极小的学习曲线,让我对这个平台产生了 ...
- 分享到微信微博空间等第三方平台的JS代码
分享功能有利于传播更多优质的内容,所以在web项目中也是比较常用的.今天就抽空整理下常用的分享平台的JS代码.这些代码可以在对应平台的官方网站上生成,官网上对分享内容的参数也有详尽说明.这里只对常用的 ...
- Android Drawable的9种子类 介绍
原文: Android Drawable的9种子类 介绍 Drawable 在android里面 就是代表着图像,注意是图像 而不是图片. 图片是图像的子集.图像除了可以包含图片以外 还可以包含颜 ...
- Linux常用指令---find | locate(查找)
1.locate locate指令和find找寻档案的功能类似,但locate是透过update程序将硬盘中的所有档案和目录资料先建立一个索引数据库,在 执行loacte时直接找该索引,查询速度会较快 ...
- [CareerCup] 3.7 Adopt Animal 领养动物
3.7 An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out ...
- [CareerCup] 8.1 Implement Blackjack 实现21点纸牌
8.1 Design the data structures for a generic deck of cards. Explain how you would subclass the data ...
- [CareerCup] 9.3 Magic Index 魔法序号
9.3 A magic index in an array A[0.. .n-1] is defined to be an index such that A[i] = i. Given a sort ...
- Jenkins问题汇总
1.在jenkins里使用shell,如果shell起子进程会被jenkins强制杀掉的解决方法. http://scmbob.org/start-process-in-jenkins.html