Commit 13da3ddd by 杨昕

Merge branch 'test' into 'master'

Test

See merge request !4
parents 3b565298 0b444b36
Pipeline #9983 passed with stages
in 38 seconds
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:5TOB7tyWQJe7Nbxd6iK+WP26zGcMrzwWUbHWGNQ1uks=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
QINIU_ACCESS_KEY=5ClMHcAd5KN6oN6SC7ni7uuwOOpaSvoDRMHR_3l8
QINIU_SECRET_KEY=xoJZ_3crOqMOsznLU8lbjlNU8pXJwEq5-n5vd3Fv
vendor
storage/laravels.pid
storage/logs/laravel.log
.idea/
storage/logs/*
stages:
- build
- test
- deploy
variables:
projName: "offcn-media-resource"
before_script:
- source /builds/cicd/base.sh
docker-build:
tags:
- offcn-media-resource-shell
stage: build
retry: 1
script:
- source $PROJDIR/$projName/build.sh
k8s-deploy:
tags:
- offcn-media-resource-shell
stage: deploy
retry: 1
script:
- set -xe
- source $PROJDIR/$projName/deploy.sh
This diff is collapsed. Click to expand it.
<p align="center"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1100 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost you and your team's skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[British Software Development](https://www.britishsoftware.co)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- [UserInsights](https://userinsights.com)
- [Fragrantica](https://www.fragrantica.com)
- [SOFTonSOFA](https://softonsofa.com/)
- [User10](https://user10.com)
- [Soumettre.fr](https://soumettre.fr/)
- [CodeBrisk](https://codebrisk.com)
- [1Forge](https://1forge.com)
- [TECPRESSO](https://tecpresso.co.jp/)
- [Runtime Converter](http://runtimeconverter.com/)
- [WebL'Agence](https://weblagence.com/)
- [Invoice Ninja](https://www.invoiceninja.com)
- [iMi digital](https://www.imi-digital.de/)
- [Earthlink](https://www.earthlink.ro/)
- [Steadfast Collective](https://steadfastcollective.com/)
- [We Are The Robots Inc.](https://watr.mx/)
- [Understand.io](https://www.understand.io/)
- [Abdel Elrafa](https://abdelelrafa.com)
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).
File added
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
<?php
/**
* Srs hook表单异常
*/
namespace App\Exceptions;
use Exception;
class ControllerException extends Exception
{
public function __construct() {
$message = func_get_args();
# 记录表单错误日志
parent::__construct(json_encode($message));
}
}
\ No newline at end of file
<?php
/**
* Srs database操作异常处理
*/
namespace App\Exceptions;
use Exception;
class DatabaseException extends Exception
{
public function __construct() {
$message = func_get_args();
# 记录表单错误日志
parent::__construct(json_encode($message));
}
}
\ No newline at end of file
<?php
/**
* Srs hook表单异常
*/
namespace App\Exceptions;
use Exception;
class FormException extends Exception
{
public function __construct() {
$message = func_get_args();
parent::__construct(json_encode($message));
}
}
\ No newline at end of file
<?php
namespace App\Exceptions;
use Exception;
use App\Tool\ToolFunc;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
use ToolFunc;
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
if (!self::handlerException($exception)) {
parent::report($exception);
}
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
$path = $request->path();
#检测当前请求是否是api路由
if (stripos($path,'api/') === 0
&& ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) ) {
return error('resources not found',\Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND);
}
if( ( (stripos($path,'web/') === 0 && strrpos($path,'.php') !== false) || (stripos($path,'web/') === 0 && strrpos($path,'.html') !== false ) ) && ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) ) {
if (view()->exists('errors.404')) {
return response()->view('errors.404');
}
}
if (self::handlerException($exception)) {
# 获取常量类里面的异常常量
$message = json_decode($exception->getMessage(),true);
return error(...$message);
} else if ($exception instanceof AuthenticationException) {
return error($exception->getMessage(),\Symfony\Component\HttpFoundation\Response::HTTP_UNAUTHORIZED);
} else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException) {
return error('请求方法不被允许',\Symfony\Component\HttpFoundation\Response::HTTP_METHOD_NOT_ALLOWED);
} else if ($exception instanceof \Symfony\Component\HttpKernel\Exception\HttpException) {
if ($exception->getMessage() == 'Too Many Attempts.') {
return error('请求接口过于频繁',429);
}
}
if ($request->is('api/*')) {
return error('服务器请求异常:'.$exception->getMessage()."异常信息详情:".$exception->getTraceAsString(),500);
} else {
if ($exception->getMessage() != '') {
//print_r($exception->getMessage());
if ($exception->getMessage() == 403) {
return response()->view('errors.403');
}
return response()->view('errors.404');
}
#return response()->json(['code'=>403, 'msg'=>'您没有权限']);
}
return parent::render($request, $exception);
}
}
<?php
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\Session;
function success($data = [], $code = Response::HTTP_OK, $msg = '操作成功')
{
return response()->json(['code' => $code, 'data' => $data, 'msg' => $msg]);
}
function error(string $msg, $code = Response::HTTP_INTERNAL_SERVER_ERROR)
{
return response()->json(['code' => $code, 'msg' => $msg]);
}
function handler_drive($callback)
{
try {
if (!is_callable($callback)) {
throw new \Exception('callback is not callable');
}
$result = $callback();
} catch (\Exception $e) {
$error_message = $e->getMessage();
$result = \App\Tool\ToolFunc::handlerException($e);
if ($result) {
$message = json_decode($error_message, true);
$exception = '\\App\\Exceptions\\' . $result[0];
throw new $exception(...$message);
}
throw new \App\Exceptions\ControllerException($error_message);
}
return $result;
}
/**
* 通过curl获取数据
* @param $url
* @param bool $isHearder
* @param bool $post
* @return mixed
*/
function http_request_code($url, $isHearder = null, $post = 'GET', $data = null, $timeout = 1)
{
//初始化curl
$ch = curl_init();
//设置URL地址
curl_setopt($ch, CURLOPT_URL, $url);
//设置header信息
if (!empty($isHearder)) {
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $isHearder);
}
//如果是post,则把data的数据传递过去
if (($post == 'POST') && $data) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
//如果是删除方法,则是以delete请求
if ($post == 'DELETE') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
}
//设置超时时间,毫秒
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout * 100);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//执行CURL时间
$result = curl_exec($ch);
//如果有异常,记录到日志当中
$curl_errno = curl_errno($ch);
if ($curl_errno > 0) {
}
//关闭URL,返回数据
curl_close($ch);
return $result;
}
//添加日志
function addLog($content, int $level = 0)
{
$levelArr = ['info', 'warn', 'error'];
//准备数据
$data = [
'app' => 'center-cloud',
'content' => $content,
'level' => $levelArr[$level],
'create_time' => date('Y-m-d H:i:s', time())
];
$date = date('Y-m-d');
$path = "/data/logs/center-cloud{$date}.json";
file_put_contents($path, json_encode($data, JSON_UNESCAPED_UNICODE), FILE_APPEND);
}
/**
* 记录本地日志
* @param $content
* @param bool $clean
* @param bool $exit
*/
function nodeFileLog($content, $clean = false)
{
//转换成json存储
$content = json_encode($content, JSON_UNESCAPED_UNICODE) . PHP_EOL;
//判断是否覆盖
$append = $clean ? null : FILE_APPEND;
//写入日志
$date = date('Y-m-d');
file_put_contents("/data/logs/simple{$date}.json", $content, $append);
}
#获取客户端ip
function getIp()
{
if (isset ($_SERVER ['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER ['HTTP_X_FORWARDED_FOR'];
} elseif (isset ($_SERVER ['HTTP_X_REAL_IP'])) {
$clientIP = $_SERVER ['HTTP_X_REAL_IP'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}
addLog($_SERVER);
return $clientIP;
}
#比较两个日期字符串的大小
function compare_data($data1, $data2)
{
return (strtotime($data1) > strtotime($data2)) ? true : false;
}
function updateRule($rule, $data)
{
foreach ($data as $key => $val) {
if (!isset($rule[$key])) {
continue;
}
foreach ($rule[$key] as $rkey => $rval) {
$tmp = check($val, $rval, $rkey);
if ($tmp == false) {
return error("未通过验证规则:$key-$rkey-" . json_encode($rval));
}
}
}
}
/**
* 验证数据 支持 in between equal length regex expire
* @access public
* @param string $value 验证数据
* @param mixed $rule 验证表达式
* @param string $type 验证方式 默认为正则验证
* @return boolean
*/
function check($value, $rule, $type = 'regex')
{
$type = strtolower(trim($type));
switch ($type) {
case 'in':// 验证是否在某个指定范围之内 逗号分隔字符串或者数组
case 'notin':
$range = is_array($rule) ? $rule : explode(',', $rule);
return 'in' == $type ? in_array($value, $range) : !in_array($value, $range);
case 'between':// 验证是否在某个范围
case 'notbetween': // 验证是否不在某个范围
if (is_array($rule)) {
$min = $rule[0];
$max = $rule[1];
} else {
list($min, $max) = explode(',', $rule);
}
return 'between' == $type ? $value >= $min && $value <= $max : $value < $min || $value > $max;
case 'equal':// 验证是否等于某个值
case 'notequal': // 验证是否等于某个值
return 'equal' == $type ? $value == $rule : $value != $rule;
case 'length': // 验证长度
$length = mb_strlen($value, 'utf-8'); // 当前数据长度
if (strpos($rule, ',')) {
// 长度区间
list($min, $max) = explode(',', $rule);
return $length >= $min && $length <= $max;
} else {
// 指定长度
return $length == $rule;
}
case 'expire':
list($start, $end) = explode(',', $rule);
if (!is_numeric($start)) {
$start = strtotime($start);
}
if (!is_numeric($end)) {
$end = strtotime($end);
}
return NOW_TIME >= $start && NOW_TIME <= $end;
case 'regex':
default: // 默认使用正则验证 可以使用验证类中定义的验证名称
// 检查附加规则
return regex($value, $rule);
}
}
/**
* 使用正则验证数据
* @access public
* @param string $value 要验证的数据
* @param string $rule 验证规则
* @return boolean
*/
function regex($value, $rule)
{
$validate = array(
'require' => '/\S+/',
'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(:\d+)?(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/',
'currency' => '/^\d+(\.\d+)?$/',
'number' => '/^\d+$/',
'zip' => '/^\d{6}$/',
'integer' => '/^[-\+]?\d+$/',
'double' => '/^[-\+]?\d+(\.\d+)?$/',
'english' => '/^[A-Za-z]+$/',
'datetime' => '/^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/',
);
// 检查是否有内置的正则表达式
if (isset($validate[strtolower($rule)])) {
$rule = $validate[strtolower($rule)];
}
return preg_match($rule, $value) === 1;
}
/**
* 获取用户基本信息
* @return array|mixed
*/
function getAdmin(){
$userStr = Session::get("user");
if (!$userStr){
$user = new stdClass();
$user->name = '';
}else{
$user = json_decode($userStr);
}
return $user;
}
function parse_custom_str($str, $handle = '/')
{
$str = substr($str, strpos($str, $handle) + 1);
return $str;
}
function get_prefix()
{
$current = \Illuminate\Support\Facades\URL::current();
$url_arr = explode('/', $current);
$prefix = '/' . $url_arr[3] ?? '/web';
return $prefix;
}
/**
* 生成UUID标识并检测UUID是否重复
*/
function generateRandomNum( $len = 32, $md5 = true ) {
# Seed random number generator
# Only needed for PHP versions prior to 4.2
mt_srand( (double)microtime()*1000000 );
# Array of characters, adjust as desired
$chars = array(
'Q', '@', '8', 'y', '%', '^', '5', 'Z', '(', 'G', '_', 'O', '`',
'S', '-', 'N', '<', 'D', '{', '}', '[', ']', 'h', ';', 'W', '.',
'/', '|', ':', '1', 'E', 'L', '4', '&', '6', '7', '#', '9', 'a',
'A', 'b', 'B', '~', 'C', 'd', '>', 'e', '2', 'f', 'P', 'g', ')',
'?', 'H', 'i', 'X', 'U', 'J', 'k', 'r', 'l', '3', 't', 'M', 'n',
'=', 'o', '+', 'p', 'F', 'q', '!', 'K', 'R', 's', 'c', 'm', 'T',
'v', 'j', 'u', 'V', 'w', ',', 'x', 'I', '$', 'Y', 'z', '*'
);
# Array indice friendly number of chars;
$numChars = count($chars) - 1; $token = '';
# Create random token at the specified length
for ( $i=0; $i<$len; $i++ )
$token .= $chars[ mt_rand(0, $numChars) ];
# Should token be run through md5?
if ( $md5 ) {
# Number of 32 char chunks
$chunks = ceil( strlen($token) / 32 ); $md5token = '';
# Run each chunk through md5
for ( $i=1; $i<=$chunks; $i++ )
$md5token .= md5( substr($token, $i * 32 - 32, 32) );
# Trim the token
$token = substr($md5token, 0, $len);
}
return $token;
}
\ No newline at end of file
<?php
namespace App\Http\Controllers\Api\Client;
use App\Model\MediaCategoryModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class MediaCategoryController extends Controller
{
public function index(Request $request){
$result = handler_drive(function () use ($request) {
$catgList = MediaCategoryModel::catgList($request);
return $catgList;
});
return success($result);
}
}
<?php
namespace App\Http\Controllers\Api\Client;
use App\Exceptions\FormException;
use App\Model\MediaModel;
use App\Model\QiniuModel;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Qiniu\Config;
use Qiniu\Storage\FormUploader;
class MediaController extends Controller
{
private $bucketList = [
'develop' => 'dev-offcncloud',
'test' => 'test-offcncloud',
'master' => 'media-offcncloud',
];
protected $domain = [
'develop' => 'qcoenfz67.bkt.clouddn.com',
'test' => 'qcoenfz67.bkt.clouddn.com',
'master' => 'qcoenfz67.bkt.clouddn.com'
];
/**
* 获取媒资ID
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function index(Request $request){
$result = handler_drive(function () use ($request) {
return ["mediaID" => 'mda-'.generateRandomNum(16)];
});
return success($result);
}
/**
* 获取上传媒资token
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function getUploadMediaToken(Request $request){
$result = handler_drive(function () use ($request) {
$branch = empty(getenv('branch')) ? 'test' : getenv('branch');
SrsHookValidate::srsHookCallback($request,[
'key' => ''
]);
$key = $request->key??null;
$token = QiniuModel::uploadToken($this->bucketList[$branch],$key);
$domain = $this->domain[$branch];
return ["token" => $token,'domain' => $domain];
});
return success($result);
}
/**
* 视频上传成功之后,回调重新上传
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function hookRestoreMedia(Request $request){
// $this->testUploadFile($request);
$id = handler_drive(function () use ($request) {
SrsHookValidate::srsHookCallback($request,array_merge([
'media_name' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
'media_url' => 'required',
'description' => '',
'start_time' => 'required|date',
'end_time' => 'required|date|after_or_equal:start_time',
],config('app.client_request_parameters')),null,[
'start_time.date' => '开始时间格式错误',
'start_time.required'=> '开始时间不能为空',
'end_time.required' => '结束时间不能为空',
'end_time.date' => '结束时间格式错误',
'end_time.after_or_equal' => '结束时间不能小于开始时间'
]);
$id = MediaModel::hookRestoreMedia($request);
return $id;
});
return success($id);
}
/**
* 更新媒资信息
* @param Request $request
* @param $id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function updatehookMedia(Request $request,$id){
$id = handler_drive(function () use($request,$id){
SrsHookValidate::srsHookCallback($request,[
'media_name' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
'media_url' => 'required',
'description' => '',
'start_time' => 'required|date',
'end_time' => 'required|date|after_or_equal:start_time',
],null,[
'start_time.date' => '开始时间格式错误',
'start_time.required'=> '开始时间不能为空',
'end_time.required' => '结束时间不能为空',
'end_time.date' => '结束时间格式错误',
'end_time.after_or_equal' => '结束时间不能小于开始时间'
]);
MediaModel::updatehookMedia($request,$id);
return $id;
});
return success($id);
}
/**
* 获取媒资列表
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function mediaList(Request $request){
$res = handler_drive(function () use($request){
SrsHookValidate::srsHookCallback($request,[
'media_name' => '',
'username' => '',
'page' => 'integer',
'media_id' => '',
'description' => '',
'sort' => '',
'page_size' => 'integer',
]);
return MediaModel::mediaList($request);
});
return success($res);
}
/**
* 测试上传文件
* @param Request $request
*/
function testUploadFile(Request $request){
$token = $token = QiniuModel::uploadToken($this->bucketList['test']);
$file = $request->file('file_name');
$conf = new Config();
$res = FormUploader::putFile($token,$file->getFilename(),$file->getRealPath(),$conf,null,null);
var_dump($res);die;
}
}
<?php
namespace App\Http\Controllers\Api\Client;
use App\Model\OrganizationModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class OrganizationController extends Controller
{
public function getOrigList(Request $request){
$response = handler_drive(function () use ($request) {
OrganizationModel::orgList();
});
}
}
<?php
namespace App\Http\Controllers\Api\Client;
use App\Exceptions\ControllerException;
use App\Exceptions\DatabaseException;
use App\Model\LogModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
class UsersController extends Controller
{
private $baseAuth = [
'develop' => 'http://zgadmin.in.d.eoffcn.com',
'test' => 'http://zgadmin.d.eoffcn.com',
'master' => 'http://zgadmin.in.eoffcn.com',
];
/**
* 第三方验权
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws ControllerException
*/
public function store(Request $request){
$response = handler_drive(function () use ($request) {
LogModel::addlog("日志测试");
if (!$request->password) {
throw new ControllerException('口令不能为空',400);
}
if ($request->filled('username')) {
if (mb_strlen($request->username)>=20) {
$request->username = mb_substr($request->username,0,20,"UTF-8").'...';
}
} else {
throw new ControllerException('昵称必须填写',400);
}
if (preg_match("['|\"|\/|\\\|\.|:]", $request->uuid)) {
throw new ControllerException('uuid含有非法字符',400);
}
$password = strtolower($request->password);
$username = $request->username;
/**
* 用户为offcn,不走第三方认证
*/
if ($username == 'offcn'){
$user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$username)->first();
if (empty($user)){
$data = [
'name' => $username,
'password' => md5(123123),
'organization_id' => 0,
'status' => 0,
'create_time' => date('Y-m-d H:i:s',time()),
'user_type' => 1
];
$id = DB::connection("mongodb")->collection("users")->insertGetId($data);
if (!$id){
$result = false;
}else{
$result = true;
}
}else{
if ($user['password'] == md5($password)){
$result = true;
}else{
$result = false;
}
}
}else{
$branch = empty(getenv('branch')) ? 'test' : getenv('branch');
$baseUrl = $this->baseAuth[$branch];
$url = $baseUrl."/api/user?action=check_user&user_name=".$username."&password=".$password;
$result = http_request_code($url,
['Content-Type'=>'application/x-www-form-urlencoded'],
'POST',
['username' => $username,'password' => $password],
2000
);
$result = json_decode($result,true);
if ($result['code']!=0){
$result = false;
}
}
if ($result){
$data = [
'name' => $username,
'password' => md5($password),
'organization_id' => 0,
'status' => 0,
'create_time' => date('Y-m-d H:i:s',time()),
];
$user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$username)->first();
$token = $this->generateToken();
if (!empty($user)){
$data['user_type'] = $user['user_type'];
$idArr = ($user['_id'])->jsonSerialize();
}else{
$data['user_type'] = 0;
$id = DB::connection("mongodb")->collection("users")->insertGetId($data);
if (!$id){
throw new DatabaseException('用户存储失败');
}
$idArr = ($id)->jsonSerialize();
}
$_id = $idArr['$oid'];
$newtoken = encrypt($_id.'|'.$token."|1ZGHd3pCc87AsQFBLLJeMjM4t57cli6Ar78qowe7");
$data['token'] = $newtoken;
$flag = DB::connection('mongodb')->collection('users')->where('_id',$_id)->update($data);
if (!$flag){
throw new DatabaseException('用户名信息更新失败');
}
return $newtoken;
}else{
throw new DatabaseException('用户名称或者密码错误');
}
});
return success($response);
}
/**
* 生成UUID标识并检测UUID是否重复
*/
private function generateToken( $len = 32, $md5 = true ) {
# Seed random number generator
# Only needed for PHP versions prior to 4.2
mt_srand( (double)microtime()*1000000 );
# Array of characters, adjust as desired
$chars = array(
'Q', '@', '8', 'y', '%', '^', '5', 'Z', '(', 'G', '_', 'O', '`',
'S', '-', 'N', '<', 'D', '{', '}', '[', ']', 'h', ';', 'W', '.',
'/', '|', ':', '1', 'E', 'L', '4', '&', '6', '7', '#', '9', 'a',
'A', 'b', 'B', '~', 'C', 'd', '>', 'e', '2', 'f', 'P', 'g', ')',
'?', 'H', 'i', 'X', 'U', 'J', 'k', 'r', 'l', '3', 't', 'M', 'n',
'=', 'o', '+', 'p', 'F', 'q', '!', 'K', 'R', 's', 'c', 'm', 'T',
'v', 'j', 'u', 'V', 'w', ',', 'x', 'I', '$', 'Y', 'z', '*'
);
# Array indice friendly number of chars;
$numChars = count($chars) - 1; $token = '';
# Create random token at the specified length
for ( $i=0; $i<$len; $i++ )
$token .= $chars[ mt_rand(0, $numChars) ];
# Should token be run through md5?
if ( $md5 ) {
# Number of 32 char chunks
$chunks = ceil( strlen($token) / 32 ); $md5token = '';
# Run each chunk through md5
for ( $i=1; $i<=$chunks; $i++ )
$md5token .= md5( substr($token, $i * 32 - 32, 32) );
# Trim the token
$token = substr($md5token, 0, $len);
}
return $token;
}
}
<?php
namespace App\Http\Controllers\Api;
use App\Model\MediaModel;
use App\Model\QiniuModel;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Qiniu\Auth;
class MediaController extends Controller
{
/**
* 获取媒资ID
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function media_list(Request $request){
$result = handler_drive(function () use ($request){
SrsHookValidate::srsHookCallback($request,[
'params' => 'required'
]);
return MediaModel::getMediaList($request);
});
return success($result);
}
/**
* 获取媒资播放地址
* @param Request $request
* @param $media_id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function play_url(Request $request,$media_id){
$result = handler_drive(function () use ($request,$media_id){
return MediaModel::playUrl($media_id);
});
return success($result);
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:6', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
}
<?php
/**
* Created by PhpStorm.
* User: yangx
* Date: 2020/6/23
* Time: 下午12:15
*/
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
class IndexController extends Controller
{
function index(){
$userInfo = getAdmin();
return view('admin.index');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: yangx
* Date: 2020/6/23
* Time: 下午12:19
*/
namespace App\Http\Controllers\Web;
use App\Exceptions\ControllerException;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Session;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class LoginController extends Controller
{
/**
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
*/
public function login(Request $request)
{
if (request()->isMethod('post')) {
if (!$request->password) {
throw new ControllerException(400, '口令不能为空');
}
if (!$request->name) {
throw new ControllerException(400, '昵称必须填写');
}
$user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$request->name)->where("user_type",1)->first();
if (!empty($user)){
if ($user['password'] == md5($request->password)){
$result = true;
}else{
$result = false;
}
if (!$result){
return error('用户验证失败');
}
if ($user['status']){
return error('用户已被限制,请联系管理员');
}
$id = ($user['_id'])->jsonSerialize();
$user['_id'] = $id['$oid'];
Session::put("user",json_encode($user));
return success($user);
}
return error('用户验证失败');
} else {
return view('admin.login');
}
}
/**
* 退出
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function logout(Request $request)
{
Session::remove('user');
return Redirect('/web/login');
}
}
\ No newline at end of file
<?php
namespace App\Http\Controllers\Web;
use App\Model\MediaCategoryModel;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class MediaCategoryController extends Controller
{
public function index(Request $request){
$result = handler_drive(function () use ($request) {
$catgList = MediaCategoryModel::catgListPage($request);
return $catgList;
});
$data['name'] = $request->name;
$data['media_categories'] = $result;
return view('admin.media_category.list',$data);
}
/**
* 会员添加
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws ControllerException
*/
public function create()
{
return view('admin.media_category.add');
}
}
<?php
namespace App\Http\Controllers\Web;
use App\Model\MediaCategoryModel;
use App\Model\MediaModel;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class MediaController extends Controller
{
/**
* 媒资列表
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\DatabaseException
* @throws \App\Exceptions\FormException
*/
public function index(Request $request){
// php 特殊字符转义,实现字符串安全存入数据库,
SrsHookValidate::srsHookCallback($request,[
'media_name' => '',
'username' => '',
'page' => 'integer',
'media_id' => '',
'description' => '',
'sort' => '',
'page_size' => 'integer',
'start_time' => 'date',
'end_time' => 'date',
]);
$medias = MediaModel::mediaList($request);
return view('admin.media.media_list', [
'medias' => $medias,
'start_time' => substr($request->start_time, 0, 10),
'end_time' => substr($request->end_time, 0, 10),
'name' => $request->media_name,
'media_id' => $request->media_id,
'STATUS' => ['启用','停用'],
]);
}
/**
* 编辑房间
* @param Request $request
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\ControllerException
*/
public function edit(Request $request,$id){
$media = handler_drive(function () use ($request,$id){
return MediaModel::getMediaDetail($id);
});
$media_types = MediaCategoryModel::catgList($request);
return view('admin.media.media_edit', [
'media' => $media,
'media_types' => $media_types
]);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function update(Request $request,$id){
$res = handler_drive(function () use ($request,$id){
return MediaModel::updatehookMedia($request,$id);
});
return success($res);
}
/**
* 显示
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws \App\Exceptions\ControllerException
*/
public function create(Request $request){
$reslut = handler_drive(function () use($request){
$media_types = MediaCategoryModel::catgList($request);
return $media_types;
});
$data['media_types'] = $reslut;
$data['media_id'] = 'mda-'.generateRandomNum(16);
return view('admin.media.media_add',$data);
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function store(Request $request){
$id = handler_drive(function () use($request){
SrsHookValidate::srsHookCallback($request,[
'media_name' => 'required',
'media_type' => 'required',
'media_id' => 'required',
'access_key' => '',
'secret_key' => '',
'media_url' => 'required',
]);
return MediaModel::hookRestoreMedia($request);
});
return success($id);
}
/**
* 删除媒资信息
* @param Request $request
* @param $id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function destroy(Request $request,$id){
$id = handler_drive(function () use($request,$id){
return MediaModel::deleteMediaById($request,$id);
});
return success($id);
}
}
<?php
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Tool\SrsHookValidate;
use Illuminate\Http\Request;
use App\Model\UserModel;
use App\Exceptions\ControllerException;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Auth;
class MemberController extends Controller
{
/**
* users表单验证
*/
protected $users_add_verify = [
'name' => 'required|unique:users',
'password' => 'required|string|min:6,max:16',
];
/**
* users跟新验证
*/
protected $users_update_verify = [
'id' => 'required',
'name' => 'required',
'status' => ''
];
/**
* 返回错误提示
*/
protected $users_error_tips = [
'name.required' => '用户名不能为空',
'name.unique' => '用户名已存在',
'password.required' => '密码为6到16位',
'password.min' => '密码为6到16位',
'password.max' => '密码为6到16位',
];
/**
* 管理员列表
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws ControllerException
*/
public function index(Request $request)
{
$users = UserModel::getUserList($request);
return view('admin.member.member_list', [
'users' => $users,
'start_time' => substr($request->start_time, 0, 10),
'end_time' => substr($request->end_time, 0, 10),
'name' => $request->name,
'STATUS' => ['启用','停用'],
]);
}
/**
* 会员添加
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws ControllerException
*/
public function create()
{
return view('admin.member.member_add');
}
/**
* 添加保存
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws ControllerException
*/
public function store(Request $request)
{
$flag = handler_drive(function () use ($request) {
return UserModel::createUser($request);
});
return success($flag);
}
/**
* 会员查看 不存在这个页面
* @param $id
*/
public function show($id)
{
abort(404);
}
/**
* 会员编辑
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @throws ControllerException
*/
public function edit($id)
{
$user = UserModel::getUserInfoById($id);
return view('admin.member.member_edit', [
'info' => $user,
]);
}
/**
* 编辑保存
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws ControllerException
* @throws \App\Exceptions\FormException
*/
public function update(Request $request,$id)
{
handler_drive(function () use ($request,$id) {
SrsHookValidate::srsHookCallback($request, $this->users_update_verify);
if (!$this->checkOwnHandle($id)) {
throw new \App\Exceptions\FormException('你不能操作别人的');
}
if ($id == getAdmin()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己');
}
UserModel::createOrUpdateUser($request);
});
return success();
}
/**
* 启用-停用
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws ControllerException
* @throws \App\Exceptions\FormException
*/
public function disable(Request $request)
{
$id = $request->id;
if (!$this->checkOwnHandle($id)) {
throw new \App\Exceptions\FormException('你不能操作别人的');
}
if ($id == getAdmin()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己');
}
UserModel::updateUserStatus($request);
return success();
}
/**
* 密码修改
* @param $id
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View
* @throws ControllerException
* @throws \App\Exceptions\FormException
*/
public function password($id, Request $request)
{
if (request()->isMethod('post')) {
if (!$this->checkOwnHandle($request->id)) {
throw new \App\Exceptions\FormException('你不能操作别人的');
}
handler_drive(function () use ($request) {
SrsHookValidate::srsHookCallback($request, [
'id' => 'required',
'password' => 'required|string',
'repass' => 'required|same:password',
], false, [
'id.required' => '用户id必须',
'password.required' => '密码为6到16位',
'repass.required' => '确认密码',
'repass.same' => '两次密码不一致',
]);
//dd($this->user);
$rand = $this->user['rand'];
//echo $rand;
//exit;
//$request->password = bcrypt($request->password);
$request->password = md5($request->password.$rand);
$request->tvpw = $request->password;
UserModel::forgotPassword($request);
});
return success();
}
return view('admin.member.member_password', [
'user' => UserModel::find($id),
]);
}
/**
* 会员删除
* @param $id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\FormException
*/
public function destroy($id)
{
handler_drive(function () use ($id) {
if (!$this->checkOwnHandle($id)) {
throw new \App\Exceptions\FormException('你不能操作别人的');
}
if ($id == getAdmin()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己');
}
UserModel::deleteUserById($id);
});
return success();
}
/**
* 检测是否自己操作自己添加的用户
* @param $user_id
* @return bool
*/
public function checkOwnHandle($user_id)
{
$user = getAdmin();
if ($user->name != config('custom.supper_admin.name')) {
$result = UserModel::find($user_id);
if ($result === null) {
return false;
}
if (!$user->user_type) {
return false;
}
}
return true;
}
}
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
*
* These middleware are run during every request to your application.
*
* @var array
*/
protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
];
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\ApiMiddleware::class,
],
'auth' => [\App\Http\Middleware\Apprialisal::class],
'api' => [
'throttle:60,1',
'bindings',
],
];
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];
/**
* The priority-sorted list of middleware.
*
* This forces non-global middleware to always be in the given order.
*
* @var array
*/
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
];
}
<?php
namespace App\Http\Middleware;
use App\Exceptions\ControllerException;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Redirect;
class ApiMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$url = $request->path();
$except_url = [
'web/login',
'web/logout',
];
if (in_array($url,$except_url)){
return $next($request);
}
$user = getAdmin();
$ajax = $request->ajax();
if (empty($user->name)){
if ($ajax){
throw new ControllerException(Response::HTTP_UNAUTHORIZED);
}
return Redirect::to("web/logout");
}
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Closure;
use Carbon\Carbon;
use App\Exceptions\ControllerException;
//use Illuminate\Support\Facades\DB;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\DB;
class Apprialisal
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//DB::connection()->disableQueryLog();
$headers = $request->header();
if ($request->path() == 'api/v1/users' && request()->method() == 'POST') {
return $next($request);
}
if (!isset($headers['authorization']) || empty($headers['authorization'][0])) {
return error("请求异常:Authorization不存在",1013);
}
$token = substr($headers['authorization'][0],7);
$user = DB::connection('mongodb')->collection("users")->where("token",$token)->first();
if (empty($user)){
return error("请求异常:Authorization不存在",1014);
}
try {
$params = decrypt($token);
} catch (DecryptException $e) {
return error('token非法');
}
$idArr = ($user['_id'])->jsonSerialize();
$_id = $idArr['$oid'];
$request->replace(array_merge($request->all(), [
'access_token' => substr($headers['authorization'][0], 7),
'token_username' => $user['name'],
'token_user_id' => $_id,
]));
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
//
];
}
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
return $next($request);
}
}
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
class TrimStrings extends Middleware
{
/**
* The names of the attributes that should not be trimmed.
*
* @var array
*/
protected $except = [
'password',
'password_confirmation',
];
}
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/
protected $addHttpCookie = true;
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'*'
];
}
<?php
/**
* Created by PhpStorm.
* User: nxtvadmin
* Date: 2018/7/17
* Time: 13:59
*/
namespace App\Http\Routes\Web;
use Illuminate\Contracts\Routing\Registrar;
use Illuminate\Support\Facades\Route;
class AuthenRoute
{
public function map(Registrar $router, $callback)
{
if (is_subclass_of($this, __CLASS__)) {
#子类调用
Route::group(
['prefix' => 'web', 'middleware' => ['web'], 'namespace' => 'Web'],
function ($router) use ($callback) {
$callback($router);
}
);
}
}
}
<?php
/**
* Created by PhpStorm.
* User: nxtvadmin
* Date: 2018/7/17
* Time: 11:28
* 会用路由
*/
namespace App\Http\Routes\Web;
use Illuminate\Contracts\Routing\Registrar;
class MediaCategoryRoute extends AuthenRoute
{
public function map(Registrar $router,$callback){
parent::map($router,function() use ($router){
$router->resource('media_category','MediaCategoryController');
});
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: nxtvadmin
* Date: 2018/7/17
* Time: 11:28
* 会用路由
*/
namespace App\Http\Routes\Web;
use Illuminate\Contracts\Routing\Registrar;
class MediaRoute extends AuthenRoute
{
public function map(Registrar $router,$callback){
parent::map($router,function() use ($router){
$router->resource('media_manager','MediaController');
});
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: nxtvadmin
* Date: 2018/7/17
* Time: 11:28
* 会用路由
*/
namespace App\Http\Routes\Web;
use Illuminate\Contracts\Routing\Registrar;
class MemberRoute extends AuthenRoute
{
public function map(Registrar $router,$callback){
parent::map($router,function() use ($router){
$router->resource('member','MemberController');
$router->post('member/disable','MemberController@disable');
});
}
}
\ No newline at end of file
<?php
namespace App\Model;
use App\Tool\Log;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class LogModel extends Eloquent
{
/**
* 与模型关联的数据表
* @var string
*/
protected $table = 'log';
# 是否自动维护时间戳
public $timestamps = false;
/**
* 添加一个日志
* @param $content
* @param int $type 1 一般 2 警告 3 错误
* @param string $uid 账户标示
*/
public static function addlog($content, int $type = 1, string $uid = '', $code = '')
{
$uri = $_SERVER['REQUEST_URI'] ?? 'cli';
//写入数据库
$data = ['msg' => $content, 'type' => $type, 'uri' => $uri];
// self::add($data);
//写入文件
$jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
//根据类型不同,生成不同日志
if ($type == 1) {
app()->make('logs')::info($uid, $code, $jsonData);
} elseif ($type == 2) {
app()->make('logs')::warn($uid, $code, $jsonData);
} elseif ($type == 3) {
app()->make('logs')::fatal($uid, $code, $jsonData);
}
}
}
\ No newline at end of file
<?php
namespace App\Model;
use App\Exceptions\DatabaseException;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class MediaCategoryModel extends Eloquent
{
protected $collection = "media_category";
protected $connection = 'mongodb'; //使用mongodb
protected $primaryKey = '_id';
public function medias()
{
return $this->hasMany('MediaModel');
}
/**
* 查询所有媒资列表(不分页)
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function catgList(){
try{
$catgList = MediaCategoryModel::get()->toArray();
}catch (\Exception $exception){
throw new DatabaseException("类别不存在");
}
return $catgList;
}
/**
* 查询所有媒资列表(分页)
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function catgListPage($request){
try{
$where = [];
if ($request->name){
$where['name'] = $request->name;
}
$catgList = MediaCategoryModel::where($where)->paginate(10);
}catch (\Exception $exception){
throw new DatabaseException("类别不存在");
}
return $catgList;
}
/**
* 添加媒资类别
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function addMediaCatg($request){
try{
$data = [
'name' => $request->name??"百度",
'status' => 0
];
$mediaCatg = MediaCategoryModel::where('name',$request->name)->first();
if (!empty($mediaCatg)){
throw new \Exception('媒资类别已经存在');
}
$id = MediaCategoryModel::insertGetId($data);
}catch (\Exception $exception){
throw new DatabaseException("组织不存在");
}
return $id;
}
}
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class ModuleModel extends Model
{
public static function getModuleList(){
$module = file_get_contents('module.json');
return json_decode($module,true);
}
}
<?php
namespace App\Model;
use App\Exceptions\DatabaseException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class OrganizationModel extends Model
{
protected static $collection = "organization";
public static function orgList($request){
try{
$orgList = DB::connection("mongodb")->collection(self::$collection)->paginate(10);
}catch (\Exception $exception){
throw new DatabaseException("组织不存在");
}
return $orgList;
}
}
<?php
/**
* Created by PhpStorm.
* User: yangx
* Date: 2020/6/30
* Time: 下午1:35
*/
namespace App\Model;
final class QiniuModel
{
private static $accessKey = "5ClMHcAd5KN6oN6SC7ni7uuwOOpaSvoDRMHR_3l8";
private static $secretKey = "xoJZ_3crOqMOsznLU8lbjlNU8pXJwEq5-n5vd3Fv";
// public function __construct($accessKey, $secretKey)
// {
// $this->accessKey = $accessKey;
// $this->secretKey = $secretKey;
// }
public static function getAccessKey()
{
return getenv('QINIU_ACCESS_KEY')??self::$accessKey;
}
private static function sign($data)
{
$sercetKey = getenv('QINIU_SECRET_KEY')??self::$secretKey;
$hmac = hash_hmac('sha1', $data, $sercetKey, true);
return self::$accessKey . ':' . \Qiniu\base64_urlSafeEncode($hmac);
}
public static function signWithData($data)
{
$encodedData = \Qiniu\base64_urlSafeEncode($data);
return self::sign($encodedData) . ':' . $encodedData;
}
public function signRequest($urlString, $body, $contentType = null)
{
$url = parse_url($urlString);
$data = '';
if (array_key_exists('path', $url)) {
$data = $url['path'];
}
if (array_key_exists('query', $url)) {
$data .= '?' . $url['query'];
}
$data .= "\n";
if ($body !== null && $contentType === 'application/x-www-form-urlencoded') {
$data .= $body;
}
return $this->sign($data);
}
public function verifyCallback($contentType, $originAuthorization, $url, $body)
{
$authorization = 'QBox ' . $this->signRequest($url, $body, $contentType);
return $originAuthorization === $authorization;
}
public function privateDownloadUrl($baseUrl, $expires = 3600)
{
$deadline = time() + $expires;
$pos = strpos($baseUrl, '?');
if ($pos !== false) {
$baseUrl .= '&e=';
} else {
$baseUrl .= '?e=';
}
$baseUrl .= $deadline;
$token = $this->sign($baseUrl);
return "$baseUrl&token=$token";
}
public static function uploadToken($bucket="", $key = null, $expires = 3600, $policy = null, $strictPolicy = true)
{
$deadline = time() + $expires;
$scope = $bucket;
if ($key !== null) {
$scope .= ':' . $key;
}
$args = self::copyPolicy($args, $policy, $strictPolicy);
$args['scope'] = $scope;
$args['deadline'] = $deadline;
$b = json_encode($args);
return self::signWithData($b);
}
/**
*上传策略,参数规格详见
*http://developer.qiniu.com/docs/v6/api/reference/security/put-policy.html
*/
private static $policyFields = array(
'callbackUrl',
'callbackBody',
'callbackHost',
'callbackBodyType',
'callbackFetchKey',
'returnUrl',
'returnBody',
'endUser',
'saveKey',
'insertOnly',
'detectMime',
'mimeLimit',
'fsizeMin',
'fsizeLimit',
'persistentOps',
'persistentNotifyUrl',
'persistentPipeline',
'deleteAfterDays',
'fileType',
'isPrefixalScope',
);
private static function copyPolicy(&$policy, $originPolicy, $strictPolicy)
{
if ($originPolicy === null) {
return array();
}
foreach ($originPolicy as $key => $value) {
if (!$strictPolicy || in_array((string)$key, self::$policyFields, true)) {
$policy[$key] = $value;
}
}
return $policy;
}
public function authorization($url, $body = null, $contentType = null)
{
$authorization = 'QBox ' . $this->signRequest($url, $body, $contentType);
return array('Authorization' => $authorization);
}
public function authorizationV2($url, $method, $body = null, $contentType = null)
{
$urlItems = parse_url($url);
$host = $urlItems['host'];
if (isset($urlItems['port'])) {
$port = $urlItems['port'];
} else {
$port = '';
}
$path = $urlItems['path'];
if (isset($urlItems['query'])) {
$query = $urlItems['query'];
} else {
$query = '';
}
//write request uri
$toSignStr = $method . ' ' . $path;
if (!empty($query)) {
$toSignStr .= '?' . $query;
}
//write host and port
$toSignStr .= "\nHost: " . $host;
if (!empty($port)) {
$toSignStr .= ":" . $port;
}
//write content type
if (!empty($contentType)) {
$toSignStr .= "\nContent-Type: " . $contentType;
}
$toSignStr .= "\n\n";
//write body
if (!empty($body)) {
$toSignStr .= $body;
}
$sign = $this->sign($toSignStr);
$auth = 'Qiniu ' . $sign;
return array('Authorization' => $auth);
}
}
\ No newline at end of file
<?php
namespace App\Model;
use App\Exceptions\DatabaseException;
use http\Env\Request;
use Illuminate\Support\Facades\DB;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class UserModel extends Eloquent
{
/**
* mongodb collection 名字
*/
protected $collection = 'users';
protected $connection = 'mongodb'; //使用mongodb
protected $primaryKey = '_id';
/*
* 获取用户列表
*/
public static function getUserList($request){
try{
$where = [];
if ($request->name){
$where['name'] = $request->name;
}
$users = DB::connection('mongodb')->collection('users')->where($where)
->paginate(10);
foreach ( $users as $user){
$idArr = ($user['_id'])->jsonSerialize();
$user['_id'] = $idArr['$oid'];
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $users;
}
/**
* 更新用户状态
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function updateUserStatus($request){
$id = $request->id;
try{
$user = UserModel::find($id);
if (empty($user)){
throw new \Exception('用户不存在');
}
$isshow=$user->status==1?0:1;
$flag = UserModel::where('_id',$id)->update(['status'=>$isshow]);
if (!$flag){
throw new \Exception("更新失败");
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
/**
* 获取用户基本信息
* @param $id
* @return mixed
* @throws DatabaseException
*/
public static function getUserInfoById($id){
try{
$user = DB::connection("mongodb")->collection("users")->find($id);
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $user;
}
/**
* 更新用户信息
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function createOrUpdateUser($request){
$id = $request->id;
try{
$user = UserModel::find($id);
if (empty($user)){
throw new \Exception('用户不存在');
}
$flag = UserModel::where('_id',$id)->update(array_merge([
'status' => $request->status? 1 :0,
],$request->all()));
if (!$flag){
throw new \Exception("更新失败");
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
/**
* 根据id删除用户
* @param $id
* @return mixed
* @throws \Exception
*/
public static function deleteUserById($id){
try{
$user = UserModel::find($id);
if (empty($user)){
throw new \Exception('用户不存在');
}
$flag = UserModel::where('_id',$id)->delete();
}catch (\Exception $exception){
throw new \Exception($exception->getMessage());
}
return $flag;
}
/**
* 添加用户
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function createUser($request){
try{
$user = UserModel::where("name",$request->name)->first();
if (!empty($user)){
throw new \Exception("用户已存在");
}
$data = [
'name' => $request->name,
'password' => md5($request->password),
'organization_id' => 0,
'status' => 0,
'create_time' => date('Y-m-d H:i:s',time()),
'user_type' => 1
];
$idArr = UserModel::insertGetId($data);
if (empty($idArr)){
throw new \Exception("添加用户失败");
}
$_id = $idArr['$oid'];
$token = generateRandomNum();
$newtoken = encrypt($_id.'|'.$token."|1ZGHd3pCc87AsQFBLLJeMjM4t57cli6Ar78qowe7");
$data['token'] = $newtoken;
$flag = UserModel::where("_id",$_id)->update($data);
if (!$flag){
throw new \Exception("用户添加失败");
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
}
<?php
namespace App\Providers;
use App\Model\ModuleModel;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
$this->app->bind('logs',\App\Tool\Log::class);
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
view()->composer('*', function ($view) {
$result = ModuleModel::getModuleList();
$view->with([
'left' => $result,
]);
});
}
}
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
Route::group(['namespace' => $this->namespace],function($router){
$route_path = app_path('Http/Routes');
$files = \File::allFiles($route_path);
if (!empty($files)) {
foreach ($files as $k => $v) {
$name = str_replace('/','\\',$files[$k]->getRelativePathname());
if (strpos($name,'.php',true) !== false) {
$this->app->make('App\\Http\\Routes\\'.str_replace('.php','',$name))
->map($router,$callback=null);
}
}
}
});
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
<?php
namespace App\Tool;
/**
* 主节点常量
*/
class Constant {
# 接口响应成功
const RESPONSE_SUCCESS = 0;
# 表单验证失败
const EXCEPTION_FORM_FAIL = 1;
# 数据库操作失败
const EXCEPTION_DATA_FAIL = 2;
# 控制器异常
const EXCEPTION_CTRL_FAIL = 3;
# 默认分页数
const PAGE_NUMBER = 10;
# 升序
const SORT_ASC = 'asc';
# 降序
const SORT_DESC = 'desc';
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: li
* Date: 18/5/16
* Time: 12:14
*/
namespace App\Tool;
class SrsHookValidate {
/***
* 返回验证message
* @return array
*/
public static function getMessage(){
return [
'required' => '字段 :attribute 是必须的.',
'unique' => '该数据已经存在.',
'between' => '字段 :attribute 必须在 :min - :max.之间',
'ip' => '不是合法的IP',
'integer' => '字段必须是整形'
];
}
/**
* 公有验证方法
* @param $all request请求参数
* @param $rules 验证规则
* @param bool 验证规则回调hook
* @param bool 验证错误提示
* @return bool
*/
public static function validate($request,$rules,$callback=false,$message=false) {
if(!$message){
$message=self::getMessage();
}
# 过滤多余参数
$params = $request->all();
$request->replace(self::filterField($params,array_keys($rules)));
$validator = \Illuminate\Support\Facades\Validator::make($request->all(), $rules,$message);
if ($callback) {
$validator->after(function() use ($callback,$validator,$request){
if (is_callable($callback)) {
return $callback($request,$validator);
}
});
}
if ($validator->fails()) {
return $validator->errors()->toArray();
}
return false;
}
/**
* 过滤多余请求请求和过滤字段内容为空的字段
* @param Array $requestParams 请求参数
* @return Array $requestParams 保留自定义后的字段
*/
public static function filterField($requestParams,$keys) {
return array_filter($requestParams,function($v,$k) use ($keys){
return in_array($k,$keys) && $v;
},ARRAY_FILTER_USE_BOTH);
}
/**
* srsHookCallback 验证不通过抛出异常
*/
public static function srsHookCallback(...$params) {
$result = self::validate(...$params);
# 参数不合法
if ($result) {
throw new \App\Exceptions\FormException(array_shift($result)[0]);
}
}
}
\ No newline at end of file
<?php
namespace App\Tool;
use \Symfony\Component\HttpFoundation\Response;
/**
* 常用函数
*/
trait ToolFunc
{
/**
* 检测当前异常是否属于自定义异常
* @param Exception $exception 抛出的异常
* @return Array $arr 当前异常的类名和自定义异常的数组
*/
public static function handlerException($exception)
{
$class_name = self::getClassName($exception);
$files = self::getExceptionFileName();
$bool = in_array($class_name, $files);
if ($bool) {
return [$class_name,$files];
} else {
return false;
}
}
/**
* getClassName 获取当前触发异常的异常类名
* @param Exception $exception 异常对象
* @return String $str 异常类名字
*/
public static function getClassName($exception)
{
return substr(strrchr(get_class($exception), '\\'), 1);
}
/**
* getExceptionFileName获取app/Exceptions下面所有的异常类文件并按照文件名排序
* @return Array $files 文件名数组
*/
public static function getExceptionFileName()
{
$files = array_map(function ($v) {
return basename($v, '.php');
}, glob(app_path('Exceptions').'/*Exception.php'));
return $files;
}
/**
* 控制器抛出异常
*/
public static function exceptionHandler($e, ...$ext)
{
$error_message = $e->getMessage();
$result = self::handlerException($e);
if ($result) {
$message = json_decode($error_message, true);
if ($ext[0] == 'throw') {
$exception = '\\App\\Exceptions\\'.$result[0];
throw new $exception(...$message);
} else {
return $message;
}
} else {
if ($ext[0] == 'throw') {
array_shift($ext);
throw new \App\Exceptions\ControllerException(...$ext);
} else {
return $error_message;
}
}
}
// function handler_drive($callback)
// {
// try {
// if (!is_callable($callback)) {
// throw new \Exception('callback is not callable');
// }
// $result = $callback();
// } catch (\Exception $e) {
// $error_message = $e->getMessage();
// $result = \App\Tool\ToolFunc::handlerException($e);
// if ($result) {
// $message = json_decode($error_message, true);
// $exception = '\\App\\Exceptions\\' . $result[0];
// throw new $exception(...$message);
// }
//
// throw new \App\Exceptions\ControllerException($error_message);
// }
// return $result;
// }
/**
* 处理put传过来的值
* @param str
* @return array data
*/
public static function getPutValueHandle($request)
{
$str = $request->getContent();
$r = explode(PHP_EOL, $str);
$request_temp = [];
foreach ($r as $k => $v) {
$v = trim($v);
if ($v == '' || ( strpos($v, '---') ) === 0) {
unset($r[$k]);
}
if (preg_match('/"(.*)"/', $v, $name)) {
$request_temp[$name[1]] = str_replace(["\r\n","\r","\n"], '', $r[$k+2]);
}
}
$request->replace($request_temp);
}
/**
* 节点排序
*/
public static function sortPermission($temp, $temp1)
{
foreach ($temp as $key => $value) {
foreach ($temp1 as $k => $v) {
if ($value['id'] == $k) {
array_unshift($v, $value);
unset($temp[$key]);
array_splice($temp, $key, 0, $v);
unset($temp1[$k]);
return [$temp,$temp1];
}
}
}
}
/**
* 添加分页浏览ID
* @param obj $obj 数据集
* @param int $page 当前页码
* @return $obj
*/
public static function addPageNum($obj, $page = 1)
{
foreach ($obj as $k => $v) {
if ($page && $page > 1) {
$v->num = 10 * ($page - 1) + $k + 1;
} else {
$v->num = $k+1;
}
}
return $obj;
}
/**
* 转换一个int为byte大小
* @param $val 需要转换的字符串
* @return **MB
*/
public static function calc($size, $digits = 2)
{
if (!$size) {
return 0;
}
if (is_numeric($size)) {
$unit= array('','K','M','G','T','P');
$base= 1024;
$i = floor(log($size, $base));
$n = count($unit);
if ($i >= $n) {
$i=$n-1;
}
return round($size/pow($base, $i), $digits).' '.$unit[$i] . 'B';
} else {
return $size;
}
}
/**
* 房间是否失效
*/
public static function checkRoomFail($room_id)
{
$r = \App\Model\RoomModel::where('id', $room_id)->first();
if ($r === null) {
throw new \App\Exceptions\ControllerException(1019, '房间不存在');
}
$r = $r->toArray();
if ($r['status'] == 0) {
throw new \App\Exceptions\ControllerException(1020, '房间还未编辑,不能进行该操作');
}
$time = strtotime($r['end_time']);
if (time() >= ($time + 86400)) {
throw new \App\Exceptions\ControllerException(1021, ',不能进行该操作');
}
}
/**
* 对称加密
* @param string $string
* @param string $skey
* @return mixed
*/
public static function encode($string = "")
{
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split('20190115.offcn.com') as $key => $value) {
$key < $strCount && $strArr[$key] .= $value;
}
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join($strArr));
}
/**
* 判断是否有base64加密
* @param $str
* @return bool
*/
public static function is_base64($str)
{
if(mb_strlen($str) >= 8) {
return $str == base64_encode(base64_decode($str)) ? true : false;
}
}
/**
* sign签名
*/
public static function get_sign($data)
{
//对数组的值按key排序
ksort($data);
// 生成url的形式
$params = http_build_query($data);
// 生成sign
$sign = md5($params . '69b72c8$M^O(F`F8CdN5f13517');
return $sign;
}
public function validatorBoolean($value)
{
return preg_match('/^[01]{1}$/', $value);
}
}
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Jenssegers\Mongodb\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
protected $collection = 'users';
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"jacobcyl/ali-oss-storage": "^2.1",
"jenssegers/mongodb": "^3.4.1",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"qiniu/php-sdk": "^7.2"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
],
"files": [
"app/Helpers/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', true),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Asia/Shanghai',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
*/
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
/*
* 自定义
*/
Jenssegers\Mongodb\MongodbServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
/**
* 自定义
*/
'Mongo' => Jenssegers\Mongodb\MongodbServiceProvider::class,
'Moloquent' => 'Jenssegers\Mongodb\Eloquent\Model',
],
'client_request_parameters' => [
'token_user_id' => 'required',
'access_token' => 'required',
'token_username' => 'required'
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'encrypted' => true,
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
];
<?php
use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
],
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
];
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAo+8g8CvasfIwe4uToDzY8ir2rZoaBBV8EqM2gu+EwpmYnfBD
FYagyWvNDYNRYBKJgZuT/BU4f/dF0bFTFp0KwxcYDkhYE1TBNsnPqTNZGp0K2C9m
v2ATLyf+2DuVhW4etlQVnsqQBxPEoWCPmf4Mrta4xy83ZqS7BRBmi8avGyzhYjjB
hYLVuDAyOb+pDSGe9rpgcp0pyzpJ/4u8xLRO08CAUbyhN5l9ubrIBmV1F4PMhy1H
mmq26cJdMXcumzUZRebWtKK4xxZFteG8GNZIA0Oz8sk1RKjMgAVko7Uu6eR4rSlG
+R6pI79Npps3REIm1m8A3kMDCEmdDnl5q+ef3wIDAQABAoIBAHN4Mkk5epewsfmz
vM43TdB19r8dNon94CD4maLstySjL96/p2D4LTTzG8IS5zS2meiS/0+mWt+3+pPT
RWU+RKBaGfWle3RSVK4UxJK3umGGkGbqLINMVvb2QwloHs+XW0auP3RT1dNGV1Ac
RcoAKkrUr96NIYbJLXpJrRFzZ0/JzaKeHNB0OB8xQeWTVdM6liBgKhE8EMKqzA7E
Z3vZaB5Z4ezcYM+eKjKCkXkkhwc4AxibKdFdfBmdB6oFvMGoZjLbET/8CeOp6xKH
ovNEPohKpz0ewz932ZrpcikvnucXXhzhaxwmUmLF74WvVU+T5uIMjkj8jyylrUxw
kMzgufECgYEA9ew+hKtS8wWfnDqfURpDezjMueQF5/2kUVKuwsNhERLuXCe4XLFb
USAvHWrCiEqO0RA4Y+CybTS9kekMyC3lRHc+3otZ9ienp9BAcqA1T8UO2HEfFrfG
knUH9Xw7vjKwKBHPBARlnURqoiX5B9pjRs/Kya+19XVcAB7RNfbcvBsCgYEAqqbQ
b/3RYkM+fhy7xTITP6ommjRcnfI2RV/gGlt4jYM6/2GJ1PH3zOv+nhZfoffw/NYp
3A7zKfUe37frp5eYyoeZB1nB6Xo+aNsF0nSsc0x/Jms83gT5mfT3v9zUpOhe9FvH
iKgS0SYJVe9D5yuefLP1WNuYCy6/BLqE7nvyX40CgYBiD+s6EesItyRXMtUWjQd9
mj+gnHlycaTVPMgtJ6WMHmVn3/rXE23bYp8G9uxNVpWube5efVoIy/APv8N2Cz8R
1w79xMmBq3xiIVuhmZrIjUaHLkx8TZnkCsC6tehIxoOR5tAKxQoT9RUkRUoRRJcz
xGYTmHpRP5QJBEDeaOrKIwKBgBQ+zBWtOAz/S0es4v3nDe+MoR3EPoSiepvKXwzh
czDes74edTqlJi/Sg5d/sgLGJnnocnjf8Ss2IF6MNFHio0bLxXTgyieH0CWiblNk
ch0PozoMmOECGBaSwF2rtjKGOtWkmcx1nB3h9FOUmiqvuxKyStYq3yPcfN7zvdeJ
Ltz1AoGAI2P5xabnyBT2RU0pHth+YLg6SX0KNAPDuASTEUVcEFxftPmv90QRQhMU
2Ks6BpL+hwGxL6qu6heeq4PU9MVsFWCEZh9/igHDf0hHM60+euo/g8FHUkNn4/1q
2dd8CJM1uD/LSY0Cu7I3o2TOILHX9METraw6EWDq4iHnPy/tySI=
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIGxTCCBa2gAwIBAgIQBlYKeyjVKIgKNuFr3A2gfzANBgkqhkiG9w0BAQsFADBf
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMR4wHAYDVQQDExVHZW9UcnVzdCBDTiBSU0EgQ0EgRzEw
HhcNMTkwOTE2MDAwMDAwWhcNMjEwOTE1MTIwMDAwWjB4MQswCQYDVQQGEwJDTjES
MBAGA1UECAwJ5YyX5Lqs5biCMS0wKwYDVQQKDCTljJfkuqzkuK3lhazmlZnogrLn
p5HmioDmnInpmZDlhazlj7gxCzAJBgNVBAsTAklUMRkwFwYDVQQDDBAqLm9mZmNu
Y2xvdWQuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo+8g8Cva
sfIwe4uToDzY8ir2rZoaBBV8EqM2gu+EwpmYnfBDFYagyWvNDYNRYBKJgZuT/BU4
f/dF0bFTFp0KwxcYDkhYE1TBNsnPqTNZGp0K2C9mv2ATLyf+2DuVhW4etlQVnsqQ
BxPEoWCPmf4Mrta4xy83ZqS7BRBmi8avGyzhYjjBhYLVuDAyOb+pDSGe9rpgcp0p
yzpJ/4u8xLRO08CAUbyhN5l9ubrIBmV1F4PMhy1Hmmq26cJdMXcumzUZRebWtKK4
xxZFteG8GNZIA0Oz8sk1RKjMgAVko7Uu6eR4rSlG+R6pI79Npps3REIm1m8A3kMD
CEmdDnl5q+ef3wIDAQABo4IDYjCCA14wHwYDVR0jBBgwFoAUkZ9eMRWuEJ+tYMH3
wcyqSDQvDCYwHQYDVR0OBBYEFBdhbm8eOCcYqUMMraPc3XpinOcDMCsGA1UdEQQk
MCKCECoub2ZmY25jbG91ZC5jb22CDm9mZmNuY2xvdWQuY29tMA4GA1UdDwEB/wQE
AwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwdQYDVR0fBG4wbDA0
oDKgMIYuaHR0cDovL2NybDMuZGlnaWNlcnQuY29tL0dlb1RydXN0Q05SU0FDQUcx
LmNybDA0oDKgMIYuaHR0cDovL2NybDQuZGlnaWNlcnQuY29tL0dlb1RydXN0Q05S
U0FDQUcxLmNybDBMBgNVHSAERTBDMDcGCWCGSAGG/WwBATAqMCgGCCsGAQUFBwIB
FhxodHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMAgGBmeBDAECAjBvBggrBgEF
BQcBAQRjMGEwIQYIKwYBBQUHMAGGFWh0dHA6Ly9vY3NwLmRjb2NzcC5jbjA8Bggr
BgEFBQcwAoYwaHR0cDovL2NybC5kaWdpY2VydC1jbi5jb20vR2VvVHJ1c3RDTlJT
QUNBRzEuY3J0MAkGA1UdEwQCMAAwggF9BgorBgEEAdZ5AgQCBIIBbQSCAWkBZwB2
ALvZ37wfinG1k5Qjl6qSe0c4V5UKq1LoGpCWZDaOHtGFAAABbTkJDU8AAAQDAEcw
RQIhAKxPVhYZl6lmgwkrHtPR6Tj+w07w8OEzzIi5tCux/F+NAiBzfajUaCWyHBkq
FmzUoZ2WRxhwDLJsGMfY/GVcLOf+XgB2AId1v+dZfPiMQ5lfvfNu/1aNR1Y2/0q1
YMG06v9eoIMPAAABbTkJDbUAAAQDAEcwRQIhAJ+oKOIjCEdBwBsdj9CYaJ1PBLoS
BfEAGv/rOy7t6rNoAiBdK24FvESSzbrN5hfPRCyZKTDQ0CCqsMn/5ztQ/z5iNAB1
AESUZS6w7s6vxEAH2Kj+KMDa5oK+2MsxtT/TM5a1toGoAAABbTkJDLoAAAQDAEYw
RAIgXX/xR8XI24dq8iZxhZBmLOLuo4ZbjOvdNz9wPV35eQQCICQu0+sZQ9aQXp9I
jRAnxxVtibIkystgYpgTn/VqMN/MMA0GCSqGSIb3DQEBCwUAA4IBAQBt0ddC3sUW
hRmTThB9ohImhH+pkwkDNRMF8YbOiDFuxFVBcvpKLjE+4BS0Tznkl7kMY/uCCmoo
PZeIdvpSIqVq6GmixWjcixOSXZ1gqiRHomqFOIYPi3emJbDV+J6c1rUzQvr8LFNb
Fen0xrT1ZNVK4W1GVM0givqjlvz0MI+8ds35HwuofzO8OUiJmcKziOTnlqHn/qNC
nFHlyCU33NYZw2YsZXZorJiPqoYAGSMcvunwKA7g0cZNMq9TXzOm9xDYrJ+wcEcU
uy0B6LfHkftgHlJ+7cOzQu4Gx8HI/eoJuTayifkjQQIAd4WgVmFLjDFkU0fZA5vL
S+8iHnMiCHok
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFGjCCBAKgAwIBAgIQCgRw0Ja8ihLIkKbfgm7sSzANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
QTAeFw0xOTA2MjAxMjI3NThaFw0yOTA2MjAxMjI3NThaMF8xCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xHjAcBgNVBAMTFUdlb1RydXN0IENOIFJTQSBDQSBHMTCCASIwDQYJKoZIhvcN
AQEBBQADggEPADCCAQoCggEBALFJ+j1KeZVG4jzgQob23lQ8PJUNhY31ufZihuUx
hYc6HSU4Lw0fxfA43a9DpJl74M3E6F1ZRBOfJ+dWnaiyYD0PxRIQd4wJisti4Uad
vz61IYY/oQ/Elxk/X7GFDquYuxCSyBdHtTVMXCxFSvQ2C/7jWZFDfGGKKNoQSiJy
wDe8iiHbUOakLMmXmOTZyWJnFdR/TH5YNTiMKCNUPHAleG4IigGxDyL/gbwrdDNi
bDA4lUNhD0xNvPjQ8BNKqm5HWDvirUuHdC+4hpi0GJO34O3iiRV16YmWTuVFNboU
LDZ0+PQtctJnatpuZKPGyKX6jCpPvzzPw/EhNDlpEdrYHZMCAwEAAaOCAc4wggHK
MB0GA1UdDgQWBBSRn14xFa4Qn61gwffBzKpINC8MJjAfBgNVHSMEGDAWgBQD3lA1
VtFMu2bwo+IbG8OXsj3RVTAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0lBBYwFAYIKwYB
BQUHAwEGCCsGAQUFBwMCMA8GA1UdEwEB/wQFMAMBAf8wMQYIKwYBBQUHAQEEJTAj
MCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5kY29jc3AuY24wRAYDVR0fBD0wOzA5
oDegNYYzaHR0cDovL2NybC5kaWdpY2VydC1jbi5jb20vRGlnaUNlcnRHbG9iYWxS
b290Q0EuY3JsMIHOBgNVHSAEgcYwgcMwgcAGBFUdIAAwgbcwKAYIKwYBBQUHAgEW
HGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwgYoGCCsGAQUFBwICMH4MfEFu
eSB1c2Ugb2YgdGhpcyBDZXJ0aWZpY2F0ZSBjb25zdGl0dXRlcyBhY2NlcHRhbmNl
IG9mIHRoZSBSZWx5aW5nIFBhcnR5IEFncmVlbWVudCBsb2NhdGVkIGF0IGh0dHBz
Oi8vd3d3LmRpZ2ljZXJ0LmNvbS9ycGEtdWEwDQYJKoZIhvcNAQELBQADggEBABfg
eXrxIrtlixBv+KMDeqKxtNJbZiLDzJBkGCd4HI63X5eS6BElJBn6mI9eYVrr7qOL
Tp7WiO02Sf1Yrpaz/ePSjZ684o89UAGpxOfbgVSMvo/a07n/220jUWLxzaJhQNLu
lACXwwWsxYf8twP8glkoIHnUUNTlhsyyl1ZzvVC4bDpI4hC6QkJGync1MNqYSMj8
tZbhQNw3HdSmcTO0Nc/J/pK2VZc6fFbKBgspmzdHc6jMKG2t4lisXEysS3wPcg0a
Nfr1Odl5+myh3MnMK08f6pTXvduLz+QZiIh8IYL+Z6QWgTZ9e2jnV8juumX1I8Ge
7cZdtNnTCB8hFfwGLUA=
-----END CERTIFICATE-----
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'supper_admin' => [
'name' => 'offcn',
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mongodb'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
'mongodb' => [
'driver' => 'mongodb',
'host' => 'mongo.eoffcn.com',
'port' => '28017',
'database' => 'video_media',
'username' => 'root',
'password' => 'FHHTH98AWAPoyweEasdfadfaaf',
'options' => [
'database' => 'admin', // sets the authentication database required by mongo 3
]
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
];
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment