Browse Source

SEO优化

dev
xiaoz 6 years ago
parent
commit
b008707ae7
  1. 3
      application/config/mimes.php
  2. 10
      application/controllers/Found.php
  3. 18
      application/controllers/Home.php
  4. 1
      application/controllers/Img.php
  5. 13
      application/controllers/Page.php
  6. 4
      application/controllers/Upload.php
  7. 8
      application/libraries/Image.php
  8. 2
      application/views/user/header.php
  9. 39
      data/pages/readme.md
  10. 2
      static/embed.js

3
application/config/mimes.php

@ -180,5 +180,6 @@ return array(
'odt' => 'application/vnd.oasis.opendocument.text', 'odt' => 'application/vnd.oasis.opendocument.text',
'odm' => 'application/vnd.oasis.opendocument.text-master', 'odm' => 'application/vnd.oasis.opendocument.text-master',
'ott' => 'application/vnd.oasis.opendocument.text-template', 'ott' => 'application/vnd.oasis.opendocument.text-template',
'oth' => 'application/vnd.oasis.opendocument.text-web' 'oth' => 'application/vnd.oasis.opendocument.text-web',
'webp' => 'image/webp'
); );

10
application/controllers/Found.php

@ -32,7 +32,14 @@
//每页显示16张图片 //每页显示16张图片
$limit = 16; $limit = 16;
//echo $page; //echo $page;
$siteinfo->title = '探索发现 - '.$siteinfo->title; //设置页面标题
if($page == 0){
$siteinfo->title = $siteinfo->title.',探索发现';
}
else{
$siteinfo->title = $siteinfo->title.',探索发现 - '."第{$page}页";
}
//根据条件生成不同的SQL语句 //根据条件生成不同的SQL语句
switch($type){ switch($type){
@ -82,6 +89,7 @@
$this->pagination->initialize($config); $this->pagination->initialize($config);
$data['page'] = $this->pagination->create_links(); $data['page'] = $this->pagination->create_links();
//设置标题
//加载视图 //加载视图
$this->load->view('user/header',$siteinfo); $this->load->view('user/header',$siteinfo);
$this->load->view('user/found',$data); $this->load->view('user/found',$data);

18
application/controllers/Home.php

@ -54,9 +54,27 @@
$siteinfo = json_decode($siteinfo->values); $siteinfo = json_decode($siteinfo->values);
//echo $siteinfo->title; //echo $siteinfo->title;
//$data['title'] = '图片上传'; //$data['title'] = '图片上传';
$siteinfo->title = "ImgURL更新日志";
$this->load->view('user/header.php',$siteinfo); $this->load->view('user/header.php',$siteinfo);
$this->load->view('user/log.php'); $this->load->view('user/log.php');
$this->load->view('user/footer.php'); $this->load->view('user/footer.php');
} }
//站点地图页面
public function sitemap(){
//页面路径
$page_path = FCPATH.'data/pages';
$pages = scandir($page_path);
foreach ($pages as $page) {
if(($page === '.') OR ($page === '..')){
continue;
}
$page = str_replace('.md','',$page);
echo "<li><a href = '/page/{$page}'>{$page}</a></li>";
}
//加载数据库模型
$this->load->view('user/sitemap.php');
}
} }
?> ?>

1
application/controllers/Img.php

@ -31,6 +31,7 @@
$imginfo = $this->query->onepic($imgid); $imginfo = $this->query->onepic($imgid);
//查询的img_imginfo //查询的img_imginfo
$picinfo = $this->query->imginfo($imgid); $picinfo = $this->query->imginfo($imgid);
$siteinfo->description = $picinfo->client_name.",由网友上传至ImgURL图床。";
//查询图片域名 //查询图片域名
@$domain = $this->query->domain($imginfo->storage); @$domain = $this->query->domain($imginfo->storage);

13
application/controllers/Page.php

@ -22,12 +22,25 @@
//载入markdown解析类 //载入markdown解析类
$this->load->library("parsedown"); $this->load->library("parsedown");
$content = $this->parsedown->text($content); $content = $this->parsedown->text($content);
//截取页面标题
$pattern = '/<h1>(.*)<\/h1>/';
preg_match($pattern,$content,$arr);
//截取描述
$description = mb_substr($content, 0, 180,'utf-8');
$description = str_replace('#','',$description);
//$description = str_replace('','',$description);
$description = strip_tags($description);
$description = trim($description);
//echo $description;
//echo $title;
//$data['content'] = $content; //$data['content'] = $content;
//加载数据库视图 //加载数据库视图
$this->load->model('query','',TRUE); $this->load->model('query','',TRUE);
$data = $this->query->site_setting('1'); $data = $this->query->site_setting('1');
$data->content = $content; $data->content = $content;
$data->title = $arr[1];
$data->description = $description;
//载入页面视图 //载入页面视图
$this->load->view('/user/header',$data); $this->load->view('/user/header',$data);
$this->load->view('/user/page',$data); $this->load->view('/user/page',$data);

4
application/controllers/Upload.php

@ -64,7 +64,7 @@
} }
// var_dump(); // var_dump();
$config['upload_path'] = $upload_path; $config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png|bmp|webp'; $config['allowed_types'] = 'gif|jpg|jpeg|png|bmp|webp';
$config['max_size'] = 5120; $config['max_size'] = 5120;
$config['file_ext_tolower'] = TRUE; //文件名转换为小写 $config['file_ext_tolower'] = TRUE; //文件名转换为小写
$config['overwrite'] = TRUE; //覆盖同名文件 $config['overwrite'] = TRUE; //覆盖同名文件
@ -123,7 +123,7 @@
} }
//CI获取获取.bmp 图片的像素,认为.bmp不是图像类型,改用其它方法获取像素 //CI获取获取.bmp 图片的像素,认为.bmp不是图像类型,改用其它方法获取像素
if($data['file_type'] == 'image/x-ms-bmp'){ if(($data['file_type'] == 'image/x-ms-bmp') OR ($data['file_type'] == 'image/webp')){
$tmpinfo = getimagesize($full_path); $tmpinfo = getimagesize($full_path);
$data['image_width'] = $tmpinfo[0]; $data['image_width'] = $tmpinfo[0];
$data['image_height'] = $tmpinfo[1]; $data['image_height'] = $tmpinfo[1];

8
application/libraries/Image.php

@ -20,6 +20,8 @@
$img_w = $imginfo[0]; $img_w = $imginfo[0];
//图片高 //图片高
$img_h = $imginfo[1]; $img_h = $imginfo[1];
//图片MIME类型
$mime = $imginfo['mime'];
//获取源文件名 //获取源文件名
$filename = end($imgarr); $filename = end($imgarr);
$imgname = explode(".",$filename); $imgname = explode(".",$filename);
@ -33,8 +35,12 @@
// 创建缩略图 // 创建缩略图
//原图宽高大于缩略图 //原图宽高大于缩略图
if(($img_w > $width) || ($img_h > $height)){ if(($img_w > $width) || ($img_h > $height)){
//如果是WEBP则不裁剪
if($mime === 'image/webp'){
return FALSE;
}
//检测是否支持ImageMagick //检测是否支持ImageMagick
if($this->check()){ elseif($this->check()){
//使用ImageMagick裁剪图像 //使用ImageMagick裁剪图像
$image = new Imagick($source); $image = new Imagick($source);
$image->cropThumbnailImage( $width, $height ); $image->cropThumbnailImage( $width, $height );

2
application/views/user/header.php

@ -6,7 +6,7 @@
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh-cmn-Hans" xmlns="http://www.w3.org/1999/xhtml"> <html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title><?php echo @$title; ?></title> <title><?php echo @$title; ?></title>

39
data/pages/readme.md

@ -1,39 +0,0 @@
# zdir
使用PHP开发的目录列表程序
![](https://imgurl.org/upload/1806/349f3b54028d58d6.png)
### 使用方法
* 下载源码放到站点根目录
* 修改`config.php`设置自己的网站标题/关键词/描述
* 如果需要排除某个目录,再次修改`config.php` ,里面有说明
* 更多说明请查看帮助文档:[https://doc.xiaoz.me/docs/zdir](https://doc.xiaoz.me/docs/zdir)
### 主要功能
* 目录浏览
* MarkDown文件预览
* CSS/JavaScript一键复制
* 文件hash
* 图片预览
* 视频播放(仅支持mp4格式)
* 文本查看器(支持的格式有.txt .sh .py .go .c .cpp)
* 文件索引
* 二维码生成
* 文件删除
* 详细说明请访问: [Zdir 实用的目录列表程序](https://www.xiaoz.me/archives/10465)
### 注意事项
* ~~不要使用中文命名目录/文件,否则可能发生不可预料的错误。~~
* 2018.08.30 已解决中文命名问题(仅在Linux下做过测试)
### Demo
* [http://soft.xiaoz.org/](http://soft.xiaoz.org/)
### 获取捐赠版
扫描下方二维码,并留言您的网址可获取捐赠版,捐赠版可去除底部版权。
![](https://imgurl.org/upload/1712/cb349aa4a1b95997.png)
### 联系我
* Blog:[https://www.xiaoz.me/](https://www.xiaoz.me/)
* QQ:337003006

2
static/embed.js

@ -41,6 +41,8 @@ layui.use(['upload','form','element','layer','flow'], function(){
//this.url = '/upload/' + storage; //this.url = '/upload/' + storage;
//console.log(this.url); //console.log(this.url);
} }
,accept:'file'
,acceptMime:'image/webp,image/jpeg,image/pjpeg,image/bmp,image/png,image/x-png,image/gif'
,size:5120 ,size:5120
,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 ,before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
layer.load(); //上传loading layer.load(); //上传loading

Loading…
Cancel
Save