選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

159 行
4.1 KiB

<?php
use Illuminate\Support\Facades\DB;
function getPagesInMenu () {
$get = DB::table('blg_content')->select('title', 'slug')->where('public_status', 0)->where('isPost', 0)->where('isMenu', 1)->orderBy('sortorder', 'asc')->get();
$res = array();
$key = 0;
foreach ($get as $i) {
array_push($res, ['key' => $key, 'title' => $i->title, 'slug' => $i->slug]);
$key++;
}
return $res;
}
function getCss () {
$engine = new \App\Http\Controllers\Engine;
return $engine->css;
}
function getPerms () {
$engine = new \App\Http\Controllers\Engine;
return $engine->getPermissions((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
}
function getUser () {
$engine = new \App\Http\Controllers\Engine;
return $engine->user;
}
function getGroupColours () {
return DB::table('usr_perm_module')->select('id', 'colour_m', 'colour_f', 'colour_u')->get()->toArray();
}
function checkLegit ($t) {
if (!isset($t) || empty($t) || is_null($t)) return 0;
$check = DB::table('users')->select('id')->where('kero_token', $t)->first();
return $check->id;
}
function ptComeSrc ($v) {
$res = new \stdClass();
$res->bg = '#';
$res->fg = '#fcfcfc';
$res->tx = '不明';
switch ($v) {
case 'PT':
$res->bg .= 'ffad5c';
$res->tx = 'PeerTube';
break;
case 'TS':
$res->bg .= 'cb81ea';
$res->tx = 'テク諏訪';
break;
case 'YT':
$res->bg .= 'f50057';
$res->tx = 'YouTube';
break;
case 'OD':
$res->bg .= '33b58f';
$res->tx = 'LBRY';
break;
default:
$res->bg = 'transparent';
break;
}
return $res;
}
function ptFullHandle ($v) {
return $v->name.($v->host != str_replace('https://', '', env('PEER_URI')) ? '@'.$v->host : '');
}
function ptAvatar ($v) {
$placeholder = '/img/noicon.jpg';
$res = '';
if (isset($v->avatar)) {
if (is_null($v->avatar)) return $placeholder;
$ava = $v->avatar->path;
$ava = str_replace(env('APP_URL'), '', $ava);
$res = str_starts_with(env('APP_URL'), $ava) ? env('PEER_URI') : '';
if ($ava == '/') return '/img/noicon.jpg';
else if (str_starts_with($ava, '/lazy-static')) $res = env('PEER_URI');
return $res.$ava;
}
return '/img/noicon.jpg';
}
function userDetail ($id, $kero=null) {
if ($kero || $id) {
$log_username = null;
if (!is_null($id)) $log_username = DB::table('users')->select('id', 'username')->where('id', $id)->first();
else $log_username = DB::table('users')->select('id', 'username')->where('kero_token', $kero)->first();
$perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $log_username->id)->first()->perm_id;
$p3 = DB::table('usr_profile')->select('gender', 'avatar', 'name_style', 'display_name')->where('user_id', $log_username->id)->first();
$user_id = $log_username->id;
$log_username = $log_username->username;
$showname = '';
$showcol = '';
$ucol = DB::table('usr_perm_module')->select('id', 'colour_m', 'colour_f', 'colour_u')->get();
if (!empty($p3->display_name)) $showname = $p3->display_name;
else $showname = $log_username;
if (!empty($p3->name_style)) $showcol = $p3->name_style;
else {
foreach ($ucol as $j3) {
if ($j3->id == $perm_id) {
if ($p3->gender == 1) $showcol = $j3->colour_m;
else if ($p3->gender == 2) $showcol = $j3->colour_f;
else $showcol = $j3->colour_u;
}
}
}
$p3->avatar = ($p3->avatar ? '/'.$p3->avatar : '/img/noicon.jpg');
return array('user_id' => $user_id, 'showname' => $showname, 'showcol' => $showcol, 'avatar' => $p3->avatar);
}
return new \stdClass();
}
function getCountries () {
$flags = DB::table('nhn_country')->orderBy('id', 'asc')->get();
$res = array();
foreach ($flags as $flag) {
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';
$res[] = array(
'value' => $flag->nameEng,
'label' => $flag->name
);
}
return $res;
}
function makeToken () {
$c = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$!%&()';
$clen = strlen($c);
$token = '';
for ($i = 0; $i < 128; $i++) {
$token .= $c[rand(0, $clen - 1)];
}
return $token;
}
?>