Browse Source

文章后台

master V0.0.5
刘道霖 3 years ago
parent
commit
b73a340869
  1. 103
      app/controller/ArticleController.php
  2. 14
      app/controller/index.php
  3. 3
      public/article/关于「男人身体」的事儿,女人最关心的都在这儿.doc
  4. 3
      public/article/关于男生「羞羞」的 7 个小知识.doc
  5. 3
      public/article/可乐杀精?精子的生存状况可真够凶险的.......doc
  6. 3
      public/article/如何帮女友 or 老婆买姨妈巾?.doc
  7. 3
      public/article/害羞的男孩看过来:关于遗精那件小事.doc
  8. 3
      public/article/真相 · 男人一辈子只能射精 6000 次?.doc
  9. 4
      public/article/精液真的有营养吗?.doc
  10. 3
      public/article/胡子会不会越刮越粗?关于胡子的 15 个秘密.doc
  11. 3
      public/article/除了啤酒肚,还有哪些原因让男人肚子变大?.doc
  12. 6
      public/article/骑自行车也会影响生殖能力吗?.doc
  13. 5
      route/app.php

103
app/controller/ArticleController.php

@ -4,6 +4,7 @@ namespace app\controller;
use app\BaseController;
use app\model\Article;
use think\facade\Db;
class ArticleController extends BaseController
{
@ -11,18 +12,35 @@ class ArticleController extends BaseController
public function sendArticle()
{
try {
$list = Article::field("*")->select()->toArray();
foreach($list as $value) {
$uuid = md5(time());
$html = $value['content'];
$this->start();
$wordname = $uuid.'/article/'.$value['title'].".doc";
echo $html;
$this->save($wordname);
}
$list = Article::where('status', 0)->where('publish_status', 2)->field("*")->select()->toArray();
foreach ($list as $value) {
$uuid = strtoupper(md5($value['id']));
//创建文件夹
$pathname = 'D:/AAAA_文章/' . $uuid;
if (!is_dir($pathname)) { //若目录不存在则创建之
mkdir($pathname, 0777, true);
}
//url图片保存本地
$this->down_img($pathname, $value['cover']);
$wordname = $pathname . "/a_文章.doc";
//html标签类文章转成word
$html = $value['content'];
$this->start();
echo $html;
$this->save($wordname);
file_put_contents($pathname . '/c_标题.txt', $value['title']);
file_put_contents($pathname . '/d_账号.txt', $value['account']);
Article::where('id',$value['id'])->update(['status' => 1]);
}
} catch (\Exception $e) {
dd($e);
}
return json(['msg' => 'success', 'data' => '生成成功!', 'code' => 200], 200);
}
function start()
@ -50,4 +68,71 @@ xmlns="http://www.w3.org/TR/REC-html40">';
fclose($fp);
}
function down_img($path,$img_url){
ob_start();
readfile($img_url);
$img=ob_get_contents();
ob_end_clean();
$filename = '/b_封面图.jpg';
$fp2=@fopen($path.$filename,'a');
fwrite($fp2,$img);
fclose($fp2);
unset($img,$url);
}
public function articleList()
{
$param = request()->param();
$list = Article::where(function ($q) use ($param) {
if(isset($param['publish_status'])){
$q->where('publish_status',$param['publish_status']);
}
if(isset($param['account'])){
$q->where('account',$param['account']);
}
})
->paginate([
'list_rows'=> $param["limit"],
'page' => $param["page"],
])->toArray();
return json(['msg' => 'success', 'data' => $list['data'],'count' => $list['total'], 'code' => 200], 200);
}
public function deleteArticle()
{
$param = request()->param();
$data = Article::where('id',$param['id'])->find();
if($data['status'] == 1){
return json(['msg' => 'fail', 'data' => '已发布的文章不能删除', 'code' => 201], 201);
}
$data->delete();
return json(['msg' => 'success', 'data' => '删除成功!', 'code' => 200], 200);
}
public function editArticle()
{
$param = request()->param();
$data = Article::where('id',$param['id'])->find();
if(empty($data)){
return json(['msg' => 'fail', 'data' => '文章不存在', 'code' => 201], 201);
}
Article::where('id',$param['id'])->update([
'account' => $param['account'] ?? $data['account'],
'title' => $param['title'] ?? $data['title'],
'cover' => $param['cover'] ?? $data['cover'],
'des' => $param['des'] ?? $data['des'],
'content' => $param['content'] ?? $data['content'],
'publish_status' => $param['publish_status'] ?? $data['publish_status'],
]);
return json(['msg' => 'success', 'data' => '编辑成功!', 'code' => 200], 200);
}
public function detailArticle()
{
$param = request()->param();
$data = Article::where('id',$param['id'])->find();
return json(['msg' => 'success', 'data' => $data, 'code' => 200], 200);
}
}

14
app/controller/index.php

@ -0,0 +1,14 @@
<?php
try {
while (true) {
$url = 'http://article.com:70/sendArticle';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$res = json_decode(curl_exec($curl), true);
curl_close($curl);
sleep(10);
}
}catch(\Exception $e) {
echo $e->getMessage();
}

3
public/article/关于「男人身体」的事儿,女人最关心的都在这儿.doc
File diff suppressed because it is too large
View File

3
public/article/关于男生「羞羞」的 7 个小知识.doc
File diff suppressed because it is too large
View File

3
public/article/可乐杀精?精子的生存状况可真够凶险的.......doc
File diff suppressed because it is too large
View File

3
public/article/如何帮女友 or 老婆买姨妈巾?.doc
File diff suppressed because it is too large
View File

3
public/article/害羞的男孩看过来:关于遗精那件小事.doc
File diff suppressed because it is too large
View File

3
public/article/真相 · 男人一辈子只能射精 6000 次?.doc
File diff suppressed because it is too large
View File

4
public/article/精液真的有营养吗?.doc
File diff suppressed because it is too large
View File

3
public/article/胡子会不会越刮越粗?关于胡子的 15 个秘密.doc
File diff suppressed because it is too large
View File

3
public/article/除了啤酒肚,还有哪些原因让男人肚子变大?.doc
File diff suppressed because it is too large
View File

6
public/article/骑自行车也会影响生殖能力吗?.doc
File diff suppressed because it is too large
View File

5
route/app.php

@ -15,4 +15,7 @@ Route::get('think', function () {
});
Route::get('sendArticle', 'ArticleController/sendArticle');
//Route::get('sendArticle', 'ArticleController/sendArticle');
Route::get('articleList', 'ArticleController/articleList');
Route::get('detailArticle', 'ArticleController/detailArticle');
Route::post('deleteArticle', 'ArticleController/deleteArticle');
Route::post('editArticle', 'ArticleController/editArticle');
Loading…
Cancel
Save