Home  >  Article  >  CMS Tutorial  >  How to add statistical functions to phpcms

How to add statistical functions to phpcms

藏色散人
藏色散人Original
2020-01-08 10:33:202975browse

How to add statistical functions to phpcms

How to count phpcms?

PHPCMS adds the whole site access statistics function

The current PHPCMS V9 version does not have the whole site access statistics function, but I don’t want to use a third-party plug-in. manage? Here is a tutorial on the website-wide page access statistics function implemented by PHPCMS.

The first step is to customize the function code of access statistics

1. Open the extension.func.php file

File path: phpcms/libs/functions/extention.func .php

2. Type the following code in extension.func.php

function getNewsContent($id){
session_start();
$log = 'log.txt';
if(!$handle = fopen($log,"a+")){ echo '日志文件打开失败'; exit(); }
if(!fwrite($handle,session_id().chr(13))){ echo '数据写入失败'; exit(); }
fclose($handle);
$file = file_get_contents($log);
$content = explode(chr(13),$file);
echo "访问统计:".(count($content)-1)."";
}

How to add statistical functions to phpcms

The second step is to use the tag in the html template to call it

If I need to add access statistics at the bottom of the website:

Open the file path: phpcms/templates/default/content/footer.html

Add in footer.html {getNewsContent($r['id'])}

can achieve the effect of access statistics.

PHP Chinese website, a large number of free PHPCMS tutorials, welcome to learn online!

The above is the detailed content of How to add statistical functions to phpcms. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn