Skip to content

Commit bf9e61e

Browse files
author
fengr06
committed
blog init
1 parent ead90da commit bf9e61e

312 files changed

Lines changed: 227870 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
"react",
4+
"es2017",
5+
"stage-1"
6+
],
7+
"plugins": [
8+
["import", { "libraryName": "antd", "style": "css" }],
9+
["transform-object-rest-spread"]
10+
]
11+
}

.env.example

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_LOG_LEVEL=debug
6+
APP_URL=http://localhost
7+
8+
DB_CONNECTION=mysql
9+
DB_HOST=127.0.0.1
10+
DB_PORT=3306
11+
DB_DATABASE=homestead
12+
DB_USERNAME=homestead
13+
DB_PASSWORD=secret
14+
15+
BROADCAST_DRIVER=log
16+
CACHE_DRIVER=file
17+
SESSION_DRIVER=file
18+
QUEUE_DRIVER=sync
19+
20+
REDIS_HOST=127.0.0.1
21+
REDIS_PASSWORD=null
22+
REDIS_PORT=6379
23+
24+
MAIL_DRIVER=smtp
25+
MAIL_HOST=smtp.mailtrap.io
26+
MAIL_PORT=2525
27+
MAIL_USERNAME=null
28+
MAIL_PASSWORD=null
29+
MAIL_ENCRYPTION=null
30+
31+
PUSHER_APP_ID=
32+
PUSHER_APP_KEY=
33+
PUSHER_APP_SECRET=

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
/.idea
7+
/.vagrant
8+
Homestead.json
9+
Homestead.yaml
10+
npm-debug.log
11+
yarn-error.log
12+
.env
13+
composer.lock
14+
package-lock.json

app/Article.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Article extends Model
8+
{
9+
/**
10+
* The attributes that are mass assignable.
11+
*
12+
* @var array
13+
*/
14+
protected $fillable = [
15+
'title', 'cover', 'content_raw', 'content_html', 'is_top', 'is_hidden', 'view', 'comment','cate_id'
16+
];
17+
18+
/**
19+
* 获得此博客文章的评论
20+
*/
21+
public function comments()
22+
{
23+
return $this->hasMany('App\Comment');
24+
}
25+
26+
/**
27+
* 获得此博客文章的标签
28+
*/
29+
public function tags()
30+
{
31+
return $this->belongsToMany('App\Tag');
32+
}
33+
34+
/**
35+
* 更新评论量
36+
* @var [int]
37+
*/
38+
static public function update_comment($id)
39+
{
40+
$article = Article::findOrFail($id);
41+
$article->comment = $article->comment + 1;
42+
$article->update([
43+
'comment' => $article->comment,
44+
]);
45+
}
46+
}

app/Blacklist.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Blacklist extends Model
8+
{
9+
protected $table = 'blacklist';
10+
11+
/**
12+
* 检查 IP 是否存在于黑名单中
13+
* @var [int]
14+
*/
15+
public static function check($ip)
16+
{
17+
if (Blacklist::where('ip', $ip)->first()) {
18+
return true;
19+
}else {
20+
return false;
21+
}
22+
}
23+
}

app/Cate.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Cate extends Model
8+
{
9+
/**
10+
* The attributes that are mass assignable.
11+
*
12+
* @var array
13+
*/
14+
protected $fillable = [
15+
'name', 'article_num', 'search_num'
16+
];
17+
18+
/**
19+
* 获得此分类下的文章
20+
*/
21+
public function articles()
22+
{
23+
return $this->hasMany('App\Article');
24+
}
25+
}

app/Comment.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Comment extends Model
8+
{
9+
/**
10+
* The attributes that are mass assignable.
11+
*
12+
* @var array
13+
*/
14+
protected $fillable = [
15+
'user_id', 'article_id', 'parent_id', 'content', 'name', 'email', 'website', 'avatar', 'ip', 'city', 'os', 'broswer',
16+
];
17+
18+
/**
19+
* 获得此评论所属的文章。
20+
*/
21+
public function article()
22+
{
23+
return $this->belongsTo('App\Article');
24+
}
25+
26+
/**
27+
* 获得此评论所有的回复
28+
*/
29+
public function replys()
30+
{
31+
return $this->hasMany('App\Comment', 'parent_id');
32+
}
33+
}

app/Common/MyFunction.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Common;
4+
5+
class MyFunction
6+
{
7+
/**
8+
* 获取 IP 地理位置
9+
* 淘宝IP接口
10+
* @Return: array
11+
*/
12+
static public function getCity($ip = '')
13+
{
14+
if($ip == ''){
15+
$url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json";
16+
$ip=json_decode(file_get_contents($url),true);
17+
$data = $ip;
18+
}else{
19+
$url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
20+
$ip=json_decode(file_get_contents($url));
21+
if((string)$ip->code=='1'){
22+
return false;
23+
}
24+
$data = (array)$ip->data;
25+
}
26+
27+
return $data;
28+
}
29+
}

app/Common/MyUpload.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Common;
4+
5+
use Illuminate\Http\Request;
6+
use Qcloud\Cos\Client;
7+
use App\Setting;
8+
9+
class MyUpload
10+
{
11+
/**
12+
* 根据设置的存储盘存储
13+
*/
14+
static public function uploadFile($file)
15+
{
16+
$fileName = md5_file($file).'.'.$file->extension();
17+
18+
$file_disk = Setting::where('key', 'file_disk')->value('value');
19+
if ($file_disk == 'cos') {
20+
//使用:腾讯云静态存储 COS
21+
$cosClient = new Client(array('region' => env('COS_REGION'),
22+
'credentials'=> array(
23+
'appId' => env('COS_APPID'),
24+
'secretId' => env('COS_KEY'),
25+
'secretKey' => env('COS_SECRET'))));
26+
27+
$result = $cosClient->putObject(array(
28+
'Bucket' => env('COS_BUCKET'),
29+
'Key' => $fileName,
30+
'Body' => file_get_contents($file),
31+
'ServerSideEncryption' => 'AES256'));
32+
33+
//return $result['ObjectURL']; 此项可生成 COS 完整地址
34+
}else {
35+
//使用:默认 Storage local 存储
36+
$file->storeAs('public/images', $fileName);
37+
}
38+
39+
return $fileName;
40+
}
41+
}

0 commit comments

Comments
 (0)