TaoLer/app/index/controller/Index.php

89 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2020-01-01 13:17:19 +08:00
<?php
2022-08-02 21:13:36 +08:00
/*
* @Author: TaoLer <317927823@qq.com>
* @Date: 2021-12-06 16:04:50
* @LastEditTime: 2022-07-27 09:14:12
* @LastEditors: TaoLer
* @Description: 首页优化版
* @FilePath: \github\TaoLer\app\index\controller\Index.php
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
*/
2020-01-01 13:17:19 +08:00
namespace app\index\controller;
use app\common\controller\BaseController;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;
2020-11-30 17:13:55 +08:00
use app\facade\Article;
2020-11-25 15:29:48 +08:00
use app\common\lib\Msgres;
2020-01-01 13:17:19 +08:00
2024-04-14 12:03:38 +08:00
use addons\pay\controller\AlipayFactory;
use addons\pay\controller\WeixinFactory;
2020-01-01 13:17:19 +08:00
class Index extends BaseController
{
/**
* 首页
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
2020-01-01 13:17:19 +08:00
public function index()
2022-04-17 17:09:19 +08:00
{
2024-04-14 12:08:53 +08:00
// $res = get_addons_info('callme1');
// halt($res);
// $htmlString = "<p>这是一个<a href='http://example.com'>链接</a>和其他文本。</p>";
// $cleanString = preg_replace("/<a\b[^>]*>(.*?)<\/a>/is", "", $htmlString);
// //$cleanString = preg_replace("(<a [^>]*>|</a>)","",$htmlString);
// echo $cleanString;
// $ip = file_get_contents('https://myip.ipip.net');
// echo "My public IP address is: " . $ip;
// $alipay = AlipayFactory::createPayMethod();
// $weixin = WeixinFactory::createPayMethod();
// $a = $alipay->index();
// $b= $weixin->index();
// var_dump($a,$b);
2020-01-08 17:37:41 +08:00
$types = input('type');
2020-01-01 13:17:19 +08:00
//置顶文章
2020-11-30 17:13:55 +08:00
$artTop = Article::getArtTop(5);
2023-07-03 12:52:34 +08:00
//首页文章列表,显示10个
2024-04-01 10:20:25 +08:00
$artList = Article::getArtList(10);
2020-01-01 13:17:19 +08:00
$vs = [
'artTop' => $artTop,
'artList' => $artList,
'type' => $types,
2021-05-20 11:52:40 +08:00
'jspage' => '',
2020-01-01 13:17:19 +08:00
];
View::assign($vs);
return View::fetch();
}
public function jump()
{
$username = Request::param('username');
$u = Db::name('user')->whereOr('nickname', $username)->whereOr('name', $username)->find();
2020-04-30 18:35:46 +08:00
return redirect((string) url('user/home',['id'=>$u['id']]));
2020-01-01 13:17:19 +08:00
}
2020-11-01 18:13:05 +08:00
2020-11-02 21:54:26 +08:00
public function language()
2020-11-01 18:13:05 +08:00
{
2020-11-02 21:54:26 +08:00
if(request()->isPost()){
$language = new \app\common\controller\Language;
$lang = $language->select(input('language'));
if($lang){
return Msgres::success();
2020-11-02 21:54:26 +08:00
}
}else {
2020-11-25 15:29:48 +08:00
return Msgres::error('illegal_request');
2020-11-01 18:13:05 +08:00
}
}
2020-01-01 13:17:19 +08:00
}