Initial commit: 교육 프로젝트 배포
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!function_exists('edu_start_session')) {
|
||||
function edu_start_session(): void
|
||||
{
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('edu_current_member_id')) {
|
||||
function edu_current_member_id(): string
|
||||
{
|
||||
edu_start_session();
|
||||
return trim((string)($_SESSION['ss_mb_id'] ?? $_SESSION['member_id'] ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('edu_is_logged_in')) {
|
||||
function edu_is_logged_in(): bool
|
||||
{
|
||||
return edu_current_member_id() !== '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('edu_current_user')) {
|
||||
function edu_current_user(): array
|
||||
{
|
||||
edu_start_session();
|
||||
$user = $_SESSION['edu_user'] ?? [];
|
||||
return is_array($user) ? $user : [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('edu_user_field')) {
|
||||
function edu_user_field(string $field, $default = null)
|
||||
{
|
||||
$user = edu_current_user();
|
||||
if (array_key_exists($field, $user)) {
|
||||
return $user[$field];
|
||||
}
|
||||
|
||||
edu_start_session();
|
||||
$sessionKey = 'edu_user_' . $field;
|
||||
if (array_key_exists($sessionKey, $_SESSION)) {
|
||||
return $_SESSION[$sessionKey];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('edu_require_login')) {
|
||||
function edu_require_login(): void
|
||||
{
|
||||
if (edu_is_logged_in()) {
|
||||
return;
|
||||
}
|
||||
|
||||
header('Location: http://erp.baroncs.co.kr/mobile/sys/controller/Study_controller.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user