文库网站建设在线小说源码分享

360 阅读1分钟

文库是指网上的开放供网友在线分享文档的平台,能够提供原创系统性知识的网站。现在的文库网站具有很大的营销能力,同时具有很大的广告能力。

我们的文库网站支持doc、docx 、ppt、 pptx、 pdf等主流文档格式。

image.png

下面分享一些源码

分类模块开发

image.png

namespace app\index\controller;
use app\Base;
use think\App;
use think\facade\Cache;
use think\Request;
use think\facade\View;
use think\facade\Db;
use app\index\model\Index as Indexmodel;
use app\index\service\UserInfo as UserInfoService;
class Common extends Base
{
    public function __construct()
    {
        parent::__construct();
        $user_info = Db::name('user') ->where(['uid' => session('user')['uid']])->find();
 
 
        $controller =  Request()->controller();
        $action = Request()->action();
        $lang_all = config('console')['lang'];
        $array_config = Db::name('webconfig')->where(['type'=>0])->select();
        $web_config = array();
        foreach ($array_config as $k => $v) {
            $web_config[$v['code']] = $v['value'];
        }
        //首页顶级分类展示
        $cate_parent = (new Indexmodel())->geTparentCateGory();
            foreach ($cate_parent as $k => $val ){
                $son = Db::name('category')->where('parent_id',$val['id'])->select();
                $cate_parent[$k]['son'] = $son;
            }
 
//            halt($cate_parent);
        // 首页子分类展示
        $cate_list = (new Indexmodel())->geTcateGory();
//        halt($cate_list);
        //底部文章的查询
        $article = Db::name('new')->select();
        //个人信息的查询
        $user_where['uid'] = session('user')['uid'];
        $user_info = (new UserInfoService())->getUser($user_where);
        if(!empty($user_info['uid'])){
            $is_login = 1;
        }else{
            $is_login = 0;
        }
        //友情链接
        $link = Db::name('link')->select();
        // 热门搜索
        $HotSearch = Db::name('search')->order('search_number','desc')->limit(5)->select();
        //系统处理
        $articledd = Db::name('article')->where('uid',session('user')['uid'])->where('status','7')->count();
        //处理失败
        $articled2 = Db::name('article')->where('uid',session('user')['uid'])->where('status','8')->count();
        //待自审
        $articled3 = Db::name('article')->where('uid',session('user')['uid'])->where('status','9')->count();
        //后台审核
        $articled4 = Db::name('article')->where('uid',session('user')['uid'])->where('status','1')->count();
        //审核被拒
        $articled5 = Db::name('article')->where('uid',session('user')['uid'])->where('status','3')->count();
        //已上架
        $articled6 = Db::name('article')->where('uid',session('user')['uid'])->where('status','2')->count();
        //已下架
        $articled7 = Db::name('article')->where('uid',session('user')['uid'])->where('status','0')->count();
 
        //我的消息
        $allmsg = Db::name('notification')->alias('n')->where('n.recipient_uid',session('user')['uid'])->join(['aws_notification_data'=>'b'],'n.notification_id = b.notification_id')->where('read_flag','0')->count();
        $id = session('user')['uid'];
        $where[] = ['recipient_uid','like',"%{$id}%"];
        $mail = Db::name('webmaster_msg')->where($where)->where('read_flag','0')->count();
        $countmsg = $allmsg+$mail;
 
        //企业认证状态
        $company_status =Db::name('user_company')->where('uid',session('user')['uid'])->find();
        //个人认证状态
        $authentication =Db::name('user_authentication')->where('uid',session('user')['uid'])->order('a_add_time','desc')->limit(1)->select();
 
        View::assign([
            'cate_list'=>$cate_list,
            'user_info' => $user_info,
            'controller'  => $controller,
            'action' => $action,
            'lang_all'=>$lang_all,
            'lang_cookie'=> cookie('think_lang'),
            'user_session'=>session('user'),
            'web_config'=>$web_config,
            'link'=>$link,
            'article'=>$article,
            'cate_parent'=>$cate_parent,
            'is_login' =>$is_login,
            'HotSearch' => $HotSearch,
            'articledd' => $articledd,
            'articled2' => $articled2,
            'articled3' => $articled3,
            'articled4' => $articled4,
            'articled5' => $articled5,
            'articled6' => $articled6,
            'articled7' => $articled7,
            'countmsg' => $countmsg,
            'company_status' => $company_status,
            'authentication' => $authentication,
        ]);
 
    }

语言包切换

public function langSwitch(){
        $post = input('post.');
        $lang = $post['lang'];
        cookie('think_lang',$lang);
        return 1;
    }

验证手机号码

function is_mobile($user_mobile){
//        $chars = "/^((\(\d{2,3}\))|(\d{3}\-))?1(3|5|8|9)\d{9}$/";
        $chars = "/^0?(13|14|15|17|18)[0-9]{9}$/";
        if (preg_match($chars, $user_mobile)){
            return true;
        }else{
            return false;
        }
    }

猜你喜欢

image.png

public function guessLove(){
        $user = Db::name('users')->orderRand()
            ->limit(6)
            ->alias('u')
            ->join('user_profile p', 'p.uid = u.id')
            ->select()->all();
        $year_b = date('Y');
        foreach ($user as $k => $v) {
            if ($v['age'] == 0) {
                $user[$k]['age'] = '0';
            } else {
                $user[$k]['age'] = $year_b - $v['age'];
            }
            if(!empty($v['provinceid'])){
                $address = Db::name('district')->where(['id'=>$v['provinceid']])->find();
                $user[$k]['address'] = $address['text'];
            }else{
                $user[$k]['address'] = '未填写';
            }
        }
        return json($user);
    }