このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
076server/app/helpers.php
2021-01-03 21:49:12 +09:00

67 行
2.2 KiB
PHP

<?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 getIp () {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else $ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}
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 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();
}
?>