From 92f22c95609a9e317cef561201c3e2c7cc77a744 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Thu, 22 Apr 2021 03:24:59 +0800 Subject: [PATCH] admin base --- admin/package-lock.json | 47 +++- admin/package.json | 4 +- admin/public/favicon.ico | Bin 4286 -> 4286 bytes admin/src/App.vue | 212 ++++++++++++++---- admin/src/components/Footer.vue | 25 +++ admin/src/components/Header.vue | 122 ++++++++++ admin/src/main.js | 3 +- admin/src/router/index.js | 50 +++++ admin/src/utils/api.js | 47 ++++ admin/src/utils/axios.js | 28 +++ admin/src/utils/index.js | 50 +++++ admin/src/views/agent-allow/form.vue | 3 + admin/src/views/agent-allow/index.vue | 3 + admin/src/views/dashboard/index.vue | 3 + admin/src/views/exam/form.vue | 3 + admin/src/views/exam/index.vue | 3 + admin/src/views/login.vue | 128 +++++++++++ admin/src/views/user/form.vue | 3 + admin/src/views/user/index.vue | 3 + app/Models/User.php | 13 +- app/Repositories/AuthenticateRepository.php | 7 + composer.json | 15 +- composer.lock | 78 ++++++- config/sanctum.php | 50 +++++ ...01_create_personal_access_tokens_table.php | 36 +++ include/functions.php | 30 +-- 26 files changed, 891 insertions(+), 75 deletions(-) create mode 100644 admin/src/components/Footer.vue create mode 100644 admin/src/components/Header.vue create mode 100644 admin/src/router/index.js create mode 100644 admin/src/utils/api.js create mode 100644 admin/src/utils/axios.js create mode 100644 admin/src/utils/index.js create mode 100644 admin/src/views/agent-allow/form.vue create mode 100644 admin/src/views/agent-allow/index.vue create mode 100644 admin/src/views/dashboard/index.vue create mode 100644 admin/src/views/exam/form.vue create mode 100644 admin/src/views/exam/index.vue create mode 100644 admin/src/views/login.vue create mode 100644 admin/src/views/user/form.vue create mode 100644 admin/src/views/user/index.vue create mode 100644 app/Repositories/AuthenticateRepository.php create mode 100644 config/sanctum.php create mode 100644 database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php diff --git a/admin/package-lock.json b/admin/package-lock.json index 315df7ea..22e2aba1 100644 --- a/admin/package-lock.json +++ b/admin/package-lock.json @@ -7,8 +7,10 @@ "": { "version": "0.0.0", "dependencies": { + "axios": "^0.21.1", "element-plus": "^1.0.2-beta.40", - "vue": "^3.0.5" + "vue": "^3.0.5", + "vue-router": "^4.0.6" }, "devDependencies": { "@vitejs/plugin-vue": "^1.2.1", @@ -158,6 +160,14 @@ "resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-3.5.1.tgz", "integrity": "sha1-zWK5aIskZfSEIOJ620d2CrG1VZ8=" }, + "node_modules/axios": { + "version": "0.21.1", + "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.21.1.tgz", + "integrity": "sha1-IlY0gZYvTWvemnbVFu8OXTwJsrg=", + "dependencies": { + "follow-redirects": "^1.10.0" + } + }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npm.taobao.org/big.js/download/big.js-5.2.2.tgz", @@ -254,6 +264,14 @@ "resolved": "https://registry.npm.taobao.org/estree-walker/download/estree-walker-2.0.2.tgz?cache=0&sync_timestamp=1611956983677&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festree-walker%2Fdownload%2Festree-walker-2.0.2.tgz", "integrity": "sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw=" }, + "node_modules/follow-redirects": { + "version": "1.13.3", + "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.3.tgz", + "integrity": "sha1-5VmK1QF0wbxOhyMB6CrCzZf5Amc=", + "engines": { + "node": ">=4.0" + } + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npm.taobao.org/fsevents/download/fsevents-2.3.2.tgz", @@ -628,6 +646,14 @@ "@vue/shared": "3.0.11" } }, + "node_modules/vue-router": { + "version": "4.0.6", + "resolved": "https://registry.nlark.com/vue-router/download/vue-router-4.0.6.tgz", + "integrity": "sha1-kXUNtQfSZkLyJbDsYGRWjl/kSNY=", + "peerDependencies": { + "vue": "^3.0.0" + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npm.taobao.org/yallist/download/yallist-3.1.1.tgz", @@ -764,6 +790,14 @@ "resolved": "https://registry.npm.taobao.org/async-validator/download/async-validator-3.5.1.tgz", "integrity": "sha1-zWK5aIskZfSEIOJ620d2CrG1VZ8=" }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.21.1.tgz", + "integrity": "sha1-IlY0gZYvTWvemnbVFu8OXTwJsrg=", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "big.js": { "version": "5.2.2", "resolved": "https://registry.npm.taobao.org/big.js/download/big.js-5.2.2.tgz", @@ -839,6 +873,11 @@ "resolved": "https://registry.npm.taobao.org/estree-walker/download/estree-walker-2.0.2.tgz?cache=0&sync_timestamp=1611956983677&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Festree-walker%2Fdownload%2Festree-walker-2.0.2.tgz", "integrity": "sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw=" }, + "follow-redirects": { + "version": "1.13.3", + "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.3.tgz", + "integrity": "sha1-5VmK1QF0wbxOhyMB6CrCzZf5Amc=" + }, "fsevents": { "version": "2.3.2", "resolved": "https://registry.npm.taobao.org/fsevents/download/fsevents-2.3.2.tgz", @@ -1138,6 +1177,12 @@ "@vue/shared": "3.0.11" } }, + "vue-router": { + "version": "4.0.6", + "resolved": "https://registry.nlark.com/vue-router/download/vue-router-4.0.6.tgz", + "integrity": "sha1-kXUNtQfSZkLyJbDsYGRWjl/kSNY=", + "requires": {} + }, "yallist": { "version": "3.1.1", "resolved": "https://registry.npm.taobao.org/yallist/download/yallist-3.1.1.tgz", diff --git a/admin/package.json b/admin/package.json index 17af954a..9f3b9c13 100644 --- a/admin/package.json +++ b/admin/package.json @@ -7,8 +7,10 @@ "serve": "vite preview" }, "dependencies": { + "axios": "^0.21.1", "element-plus": "^1.0.2-beta.40", - "vue": "^3.0.5" + "vue": "^3.0.5", + "vue-router": "^4.0.6" }, "devDependencies": { "@vitejs/plugin-vue": "^1.2.1", diff --git a/admin/public/favicon.ico b/admin/public/favicon.ico index df36fcfb72584e00488330b560ebcf34a41c64c2..a024bec1ca42e3cbd5d1c0e4bdb401438dc49aca 100644 GIT binary patch literal 4286 zcmd6pdr(wW9LJA2qtjH{OfzNuAx{$rGj;Hhn&6`m$w5cR@i7{jk`KbSgqf0JWN4VE zyk8;$f@Y?f=one!BTUpRP)A^wW!d+=3%fjam;LoScRiQ8d%?!xkGjlff9HOGkMBAA zxC0^m@Xyz`1sdztdO7Q3yj7@IVEtZXKH`TA=*u3I8~sTS#MiI$L2qw& z)_CJyd~h#5K=bu6zP5%~zZ%5`zmqs)D-wbXd6xYsHxDD8*qUneIHT9AZk;cP#Q5Sq z{Gk35Kft{}!+L*SvC+S(%fhwL0XEH}44nTWE_?i*HEtbFJQ&z|y@YRnbW`Tvsj300 z*T)WfD%^!bVlRL3uv4+=O_g%<@Jr~k4+%rW&rB6Jf_N}exh25SuqgmcXTFrq0jm8Q zs>B&$4_%!b70 zcZ=Zv`6$xl#@kmLcZ>lB8>GuwC2A}ujZKMD!NI9nxfsn?(q(Q}i9u3g)JgAv z`m4zzY_Q=(jHpTTbls_}W@X^Sb8FKgMXmL>9QVGYNzlA^ToLuAXp+WDn2_6?{4O-_ zpDMxz8%twFO`7K~B(V}9wqDB<>N*=;dt&!uPx2H%&sgeB(d?VpP4eVw%{S9PlQLa| z4L6l-6g8ID9u3FyT387<%o?$#v+<6gTdo&~n$U-5L(fUno1#sg#2Bhg39)EX-vcRZ zICpxBn@(%mYbsb;h|(IH>aL(!ZXT2L%>->qumL?^!=&J^J1~VjAyk(-6Ld#I-CzdX znQd-5y_a6?wU^xTwx)YR+FEtITR$=jbSc5tFd=x;s7sm3*sf0t1%2lGZZHr2hfm#f zyP=Myz}aa5L;eD{yiNV5khlI()UBuE*$xIDq`nOOw;@Czb^2LD)*LY8guB5^%s*}y zb<2%xCJT|?d-mCyUH)yii@S3fvjM%Lm^Y33L(?eF8`5SyH0I6)W8OSBm{H4x9fHo4 zMdNv`Oa_Os-mRYX+netTHEq=;V%|Xg4^4ZE`Z5fMXAmU7m_5f~Iu-$*Fr$`>JB6H0 z`8$(@$aK#>yXG$;-+s5$HM3wo7&B(qq1OwT5dDouXAVXdneyiWSF}I|Gi$w^02Jxf zQF~ri&t}-QPyFwdxoQd{&_DFN)SIr2>9c}NnPK~BA78pe2J^H0oCsak?thD%HY=D< zuaecX8Ft;@LTktUQ$h`$Z%hyULgt?tHrJFJUe1-Ecln1hn7>_D!v3oYl? zAu+vTKD`of#wJg1dT+{$cvfD=p6N&&SGcg8FJ4;9mo2xu?+5pCKGp^9i$59V#QL#4 z`sYUyQ{NbX{lkz*uHb_tu4u_+zBEeBpIV9UQ8aolcVcdLPu{}$`{pe^$E5SoZxAvL z!RK1!C~5A0xCYn-;OLK#VCW!Z7cv;>PvLu@fslcoRAP^m1iVMQP!qseUQme!P6Qed G*Yyvbu#J)c literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S diff --git a/admin/src/App.vue b/admin/src/App.vue index c91b8732..b4c6be6a 100644 --- a/admin/src/App.vue +++ b/admin/src/App.vue @@ -1,56 +1,188 @@ - + diff --git a/admin/src/components/Footer.vue b/admin/src/components/Footer.vue new file mode 100644 index 00000000..04a2fdd3 --- /dev/null +++ b/admin/src/components/Footer.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/admin/src/components/Header.vue b/admin/src/components/Header.vue new file mode 100644 index 00000000..dc96f5ec --- /dev/null +++ b/admin/src/components/Header.vue @@ -0,0 +1,122 @@ + + + + + + diff --git a/admin/src/main.js b/admin/src/main.js index bee3963e..e4aa6b78 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -1,5 +1,6 @@ import { createApp } from 'vue' import App from './App.vue' import ElementPlus from 'element-plus' +import router from './router/index' import 'element-plus/lib/theme-chalk/index.css' -createApp(App).use(ElementPlus).mount('#app') +createApp(App).use(ElementPlus).use(router).mount('#app') diff --git a/admin/src/router/index.js b/admin/src/router/index.js new file mode 100644 index 00000000..838f1a36 --- /dev/null +++ b/admin/src/router/index.js @@ -0,0 +1,50 @@ +import { createRouter, createWebHashHistory } from 'vue-router' + +const router = createRouter({ + history: createWebHashHistory(), // hash模式:createWebHashHistory,history模式:createWebHistory + routes: [ + { + path: '/', + name: 'dashboard', + component: () => import('../views/dashboard/index.vue') + }, + { + path: '/login', + name: 'login', + component: () => import('../views/login.vue') + }, + { + path: '/user', + name: 'user', + component: () => import('../views/user/index.vue') + }, + { + path: '/user-form', + name: 'user-form', + component: () => import('../views/user/form.vue') + }, + { + path: '/exam', + name: 'exam', + component: () => import('../views/exam/index.vue') + }, + { + path: '/exam-form', + name: 'exam-form', + component: () => import('../views/exam/form.vue') + }, + { + path: '/agent-allow', + name: 'agent-allow', + component: () => import('../views/agent-allow/index.vue') + }, + { + path: '/agent-allow-form', + name: 'agent-allow-form', + component: () => import('../views/agent-allow/form.vue') + }, + + ] +}) + +export default router diff --git a/admin/src/utils/api.js b/admin/src/utils/api.js new file mode 100644 index 00000000..5164b3ad --- /dev/null +++ b/admin/src/utils/api.js @@ -0,0 +1,47 @@ +import axios from "./axios"; + +const api = { + listAllowAgent: (params = {}) => { + return axios.get('agent-allow', {params: params}); + }, + storeAllowAgent: (params = {}) => { + return axios.post('agent-allow', params); + }, + updateAllowAgent: (id, params = {}) => { + return axios.put('agent-allow/' + id, params); + }, + getAllowAgent: (id) => { + return axios.get('agent-allow/' + id); + }, + deleteAllowAgent: (id) => { + return axios.delete('agent-allow/' + id); + }, + + listUser: (params = {}) => { + return axios.get('user', {params: params}); + }, + storeUser: (params = {}) => { + return axios.post('user', params); + }, + + listExam: (params = {}) => { + return axios.get('exam', {params: params}); + }, + storeExam: (params = {}) => { + return axios.post('exam', params); + }, + updateExam: (id, params = {}) => { + return axios.put('exam/' + id, params); + }, + getExam: (id) => { + return axios.get('exam/' + id); + }, + deleteExam: (id) => { + return axios.delete('exam/' + id); + }, + listClass: (params = {}) => { + return axios.get('class', {params: params}); + }, +} + +export default api diff --git a/admin/src/utils/axios.js b/admin/src/utils/axios.js new file mode 100644 index 00000000..6fa9e907 --- /dev/null +++ b/admin/src/utils/axios.js @@ -0,0 +1,28 @@ +import axios from 'axios' +import { ElMessage } from 'element-plus' + +axios.defaults.baseURL = 'http://nexus-php8.tinyhd.net' +axios.defaults.withCredentials = true +axios.defaults.headers['X-Requested-With'] = 'XMLHttpRequest' +axios.defaults.headers['Content-Type'] = 'application/json' +axios.defaults.headers['Accept'] = 'application/json' + +// 请求拦截器,内部根据返回值,重新组装,统一管理。 +axios.interceptors.response.use(res => { + console.log(res) + if (typeof res.data !== 'object') { + ElMessage.error('Server Error 1') + return Promise.reject(res) + } + if (res.data.ret && res.data.ret != 0) { + ElMessage.error(res.data.msg) + return Promise.reject(res.data) + } + return res.data +}, error => { + console.log(error.response) + ElMessage.error(error.response.data.msg || 'Server Error 2') + return Promise.reject(error) +}) + +export default axios diff --git a/admin/src/utils/index.js b/admin/src/utils/index.js new file mode 100644 index 00000000..1e2a6a57 --- /dev/null +++ b/admin/src/utils/index.js @@ -0,0 +1,50 @@ +export function localGet (key) { + const value = window.localStorage.getItem(key) + try { + return JSON.parse(window.localStorage.getItem(key)) + } catch (error) { + return value + } +} + +export function localSet (key, value) { + window.localStorage.setItem(key, JSON.stringify(value)) +} + +export function localRemove (key) { + window.localStorage.removeItem(key) +} + +// 判断内容是否含有表情字符,现有数据库不支持。 +export function hasEmoji (str = '') { + const reg = /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g; + return str.match(reg) && str.match(reg).length +} + +// 单张图片上传 +export const uploadImgServer = 'http://backend-api-02.newbee.ltd/manage-api/v1/upload/file' +// 多张图片上传 +export const uploadImgsServer = 'http://backend-api-02.newbee.ltd/manage-api/v1/upload/files' + +export const pathMap = { + login: '登录', + introduce: '系统介绍', + dashboard: 'Dashboard', + add: '添加商品', + swiper: '轮播图配置', + hot: '热销商品配置', + new: '新品上线配置', + recommend: '为你推荐配置', + category: '分类管理', + level2: '分类二级管理', + level3: '分类三级管理', + good: '商品管理', + guest: '会员管理', + order: '订单管理', + order_detail: '订单详情', + account: '修改账户', + 'agent-allow': 'Agent allow', + 'agent-allow-form': 'Agent allow form', + 'user': 'User', + 'user-form': 'User form', +} diff --git a/admin/src/views/agent-allow/form.vue b/admin/src/views/agent-allow/form.vue new file mode 100644 index 00000000..45587e56 --- /dev/null +++ b/admin/src/views/agent-allow/form.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/agent-allow/index.vue b/admin/src/views/agent-allow/index.vue new file mode 100644 index 00000000..b714668f --- /dev/null +++ b/admin/src/views/agent-allow/index.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/dashboard/index.vue b/admin/src/views/dashboard/index.vue new file mode 100644 index 00000000..1a7b40cf --- /dev/null +++ b/admin/src/views/dashboard/index.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/exam/form.vue b/admin/src/views/exam/form.vue new file mode 100644 index 00000000..c23cd512 --- /dev/null +++ b/admin/src/views/exam/form.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/exam/index.vue b/admin/src/views/exam/index.vue new file mode 100644 index 00000000..4702895f --- /dev/null +++ b/admin/src/views/exam/index.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/login.vue b/admin/src/views/login.vue new file mode 100644 index 00000000..d869c6e7 --- /dev/null +++ b/admin/src/views/login.vue @@ -0,0 +1,128 @@ + + + + + + diff --git a/admin/src/views/user/form.vue b/admin/src/views/user/form.vue new file mode 100644 index 00000000..f9a89a8d --- /dev/null +++ b/admin/src/views/user/form.vue @@ -0,0 +1,3 @@ + diff --git a/admin/src/views/user/index.vue b/admin/src/views/user/index.vue new file mode 100644 index 00000000..1b4eb035 --- /dev/null +++ b/admin/src/views/user/index.vue @@ -0,0 +1,3 @@ + diff --git a/app/Models/User.php b/app/Models/User.php index 52d33a75..6256811c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,10 +5,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { - use HasFactory, Notifiable; + use HasFactory, Notifiable, HasApiTokens; public $timestamps = false; @@ -31,7 +32,7 @@ class User extends Authenticatable const CLASS_MODERATOR = "13"; const CLASS_ADMINISTRATOR = "14"; const CLASS_SYSOP = "15"; - const CLASS_STAFFLEADER = "16"; + const CLASS_STAFF_LEADER = "16"; public static $classes = [ self::CLASS_PEASANT => ['text' => 'Peasant'], @@ -42,7 +43,7 @@ class User extends Authenticatable self::CLASS_INSANE_USER => ['text' => 'Insane User'], self::CLASS_VETERAN_USER => ['text' => 'Veteran User'], self::CLASS_EXTREME_USER => ['text' => 'Extreme User'], - self::CLASS_ULTIMATE_USER => ['text' => 'Eltimate User'], + self::CLASS_ULTIMATE_USER => ['text' => 'Ultimate User'], self::CLASS_NEXUS_MASTER => ['text' => 'Nexus Master'], self::CLASS_VIP => ['text' => 'Vip'], self::CLASS_RETIREE => ['text' => 'Retiree'], @@ -50,10 +51,10 @@ class User extends Authenticatable self::CLASS_MODERATOR => ['text' => 'Moderator'], self::CLASS_ADMINISTRATOR => ['text' => 'Administrator'], self::CLASS_SYSOP => ['text' => 'Sysop'], - self::CLASS_STAFFLEADER => ['text' => 'Staff Leader'], + self::CLASS_STAFF_LEADER => ['text' => 'Staff Leader'], ]; - public function getClassTextAttribute() + public function getClassTextAttribute(): string { return self::$classes[$this->class]['text'] ?? ''; } @@ -66,7 +67,7 @@ class User extends Authenticatable * @param \DateTimeInterface $date * @return string */ - protected function serializeDate(\DateTimeInterface $date) + protected function serializeDate(\DateTimeInterface $date): string { return $date->format($this->dateFormat ?: 'Y-m-d H:i:s'); } diff --git a/app/Repositories/AuthenticateRepository.php b/app/Repositories/AuthenticateRepository.php new file mode 100644 index 00000000..dbcdf789 --- /dev/null +++ b/app/Repositories/AuthenticateRepository.php @@ -0,0 +1,7 @@ + explode(',', env( + 'SANCTUM_STATEFUL_DOMAINS', + 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1,'.parse_url(env('APP_URL'), PHP_URL_HOST) + )), + + /* + |-------------------------------------------------------------------------- + | Expiration Minutes + |-------------------------------------------------------------------------- + | + | This value controls the number of minutes until an issued token will be + | considered expired. If this value is null, personal access tokens do + | not expire. This won't tweak the lifetime of first-party sessions. + | + */ + + 'expiration' => null, + + /* + |-------------------------------------------------------------------------- + | Sanctum Middleware + |-------------------------------------------------------------------------- + | + | When authenticating your first-party SPA with Sanctum you may need to + | customize some of the middleware Sanctum uses while processing the + | request. You may change the middleware listed below as required. + | + */ + + 'middleware' => [ + 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, + 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, + ], + +]; diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php new file mode 100644 index 00000000..3ce00023 --- /dev/null +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->morphs('tokenable'); + $table->string('name'); + $table->string('token', 64)->unique(); + $table->text('abilities')->nullable(); + $table->timestamp('last_used_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('personal_access_tokens'); + } +} diff --git a/include/functions.php b/include/functions.php index 45abb5b2..210dc27e 100644 --- a/include/functions.php +++ b/include/functions.php @@ -369,7 +369,7 @@ function format_comment($text, $strip_html = true, $xssclean = false, $newtab = return $s; } -function highlight($search,$subject,$hlstart='',$hlend="") +function highlight($search,$subject,$hlstart='',$hlend="") { $srchlen=strlen($search); // lenght of searched string @@ -408,7 +408,7 @@ function get_user_class_name($class, $compact = false, $b_colored = false, $I18N } $this_lang_functions = $current_user_lang_functions; } - + $class_name = ""; switch ($class) { @@ -431,7 +431,7 @@ function get_user_class_name($class, $compact = false, $b_colored = false, $I18N case UC_SYSOP: {$class_name = $this_lang_functions['text_sysops']; break;} case UC_STAFFLEADER: {$class_name = $this_lang_functions['text_staff_leader']; break;} } - + switch ($class) { case UC_PEASANT: {$class_name_color = $en_lang_functions['text_peasant']; break;} @@ -453,7 +453,7 @@ function get_user_class_name($class, $compact = false, $b_colored = false, $I18N case UC_SYSOP: {$class_name_color = $en_lang_functions['text_sysops']; break;} case UC_STAFFLEADER: {$class_name_color = $en_lang_functions['text_staff_leader']; break;} } - + $class_name = ( $compact == true ? str_replace(" ", "",$class_name) : $class_name); if ($class_name) return ($b_colored == true ? "" . $class_name . "" : $class_name); } @@ -981,12 +981,12 @@ function begin_compose($title = "",$type="new", $body="", $hassubject=true, $sub if ($title) print("

".$title."

"); switch ($type){ - case 'new': + case 'new': { $framename = $lang_functions['text_new']; break; } - case 'reply': + case 'reply': { $framename = $lang_functions['text_reply']; break; @@ -1117,7 +1117,7 @@ function get_torrent_2_user_value($user_snatched_arr) } else // torrent already deleted, half blind guess, be conservative { - + if($user_snatched_arr['finished'] == 'no' && $user_snatched_arr['uploaded'] > 0 && $user_snatched_arr['downloaded'] == 0) // possibly owner { $torrent_2_user_value *= 0.55; //conservative @@ -2095,7 +2095,7 @@ function validlang($langid) { function get_if_restricted_is_open() { - global $sptime; + global $sptime; // it's sunday if($sptime == 'yes' && (date("w",time()) == '0' || (date("w",time()) == 6) && (date("G",time()) >=12 && date("G",time()) <=23))) { @@ -2256,7 +2256,7 @@ function stdhead($title = "", $msgalert = true, $script = "", $place = "") global $Advertisement; $Cache->setLanguage($CURLANGDIR); - + $Advertisement = new ADVERTISEMENT($CURUSER['id']); $cssupdatedate = $cssdate_tweak; // Variable for Start Time @@ -2379,7 +2379,7 @@ if ($enabledonation == 'yes'){?> / -cache_value('user_'.$CURUSER["id"].'_unread_message_count', $unread, 60); } - + $inboxpic = "\"inbox\""; $attend_desk = new Attendance($CURUSER['id']); $attendance = $attend_desk->check(); @@ -3269,7 +3269,7 @@ foreach ($rows as $row) else print("".$lang_functions['text_none']."\n"); } - + if ($CURUSER['showcomnum'] != 'no') { print(""); @@ -3675,7 +3675,7 @@ function getimdb($imdb_id, $cache_stamp, $mode = 'minor') $tagline = $movie->tagline (); switch ($mode) { - case 'minor' : + case 'minor' : { $autodata = "".$title." (".$year.")
".$lang_functions['text_imdb'].": ".$imdbrating." ".$lang_functions['text_country'].": ".$countries." ".$lang_functions['text_genres'].": ".$genres."
".$director_or_creator." ".$lang_functions['text_starring'].": ".$casts."

".$tagline."

"; break; @@ -3724,7 +3724,7 @@ $smallth } return $autodata; } - case "2" : + case "2" : { return false; break; @@ -4118,7 +4118,7 @@ function set_forum_moderators($name, $forumid, $limit=3){ } function get_plain_username($id){ - $row = get_user_row($id); + $row = get_user_row($id); if ($row) $username = $row['username']; else $username = "";