要很多由Chevereto源码搭建的图床首页有显示上传图片总数量的功能,其实只要在一个文件里加上几行代码就能解决。
第一种方法
本站共托管 <?php $stats = CHV\Stat::getTotals(); echo $stats['images'] > 999999 ? $stats['images'] : number_format($stats['images']); ?> 张图片
在文件/app/themes/Peafowl/views/index.php 合适位置加入以上代码。
第二种方法
1、新建文件--保存为 count.php<?php
error_reporting(0);
$con = mysql_connect("localhost", "数据库用户名", "数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db("tu",$con);
$sql = "SELECT * FROM chv_images";
$result = mysql_query($sql,$con);
echo mysql_num_rows($result);
mysql_close($con);
?>
2、放在 app/themes/Peafowl/views/index.php 文件中的合适位置<?php
$data = file_get_contents('https://网站域名/count.php');
?>
本站已托管图片 <?php echo $data ?> 张