refactoring
This commit is contained in:
@@ -2,49 +2,53 @@
|
||||
require_once 'functions/init.php';
|
||||
require_once 'functions/functions.php';
|
||||
|
||||
// UI Components
|
||||
foreach (glob('components/admin/*.php') as $file)
|
||||
require_once $file;
|
||||
|
||||
include_once 'components/head.php';
|
||||
|
||||
if (!isset($_COOKIE['role_id']))
|
||||
header('Location: user.php');
|
||||
header('Location: user.php');
|
||||
else if ($_COOKIE['role_id'] >= 3)
|
||||
header('Location: user.php?action=view&user_id=' . $_COOKIE['user_id']);
|
||||
header('Location: user.php?action=view&user_id=' . $_COOKIE['user_id']);
|
||||
|
||||
include_once 'functions/admin_functions.php';
|
||||
|
||||
if (isset($_POST['action']) && isset($_POST['form_id']) || isset($_FILES['csv'])) {
|
||||
if (!empty($_FILES['csv']['name'])) {
|
||||
upload($_FILES['csv'], $_ENV['UPLOAD_TMP_FQ_PATH'], 'new_users');
|
||||
create_users_from_csv($_ENV['UPLOAD_TMP_FQ_PATH'] . 'new_users.csv');
|
||||
delete_file($_ENV['UPLOAD_TMP_FQ_PATH'] . 'new_users.csv');
|
||||
} else {
|
||||
switch ($_POST['action']) {
|
||||
case 'delete':
|
||||
if ($_POST['form_id'] == 'users')
|
||||
foreach ($_POST['selected_users'] as $id)
|
||||
delete_account($id);
|
||||
else if ($_POST['form_id'] == 'articles')
|
||||
foreach ($_POST['selected_articles'] as $id)
|
||||
delete_article($id);
|
||||
break;
|
||||
if (!empty($_FILES['csv']['name'])) {
|
||||
upload($_FILES['csv'], $_ENV['UPLOAD_TMP_FQ_PATH'], 'new_users');
|
||||
create_users_from_csv($_ENV['UPLOAD_TMP_FQ_PATH'] . 'new_users.csv');
|
||||
delete_file($_ENV['UPLOAD_TMP_FQ_PATH'] . 'new_users.csv');
|
||||
} else {
|
||||
switch ($_POST['action']) {
|
||||
case 'delete':
|
||||
if ($_POST['form_id'] == 'users')
|
||||
foreach ($_POST['selected_users'] as $id)
|
||||
delete_account($id);
|
||||
else if ($_POST['form_id'] == 'articles')
|
||||
foreach ($_POST['selected_articles'] as $id)
|
||||
delete_article($id);
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
header('Location: user.php?action=view&user_id=' . $_POST['selected_users'][0]);
|
||||
case 'view':
|
||||
header('Location: user.php?action=view&user_id=' . $_POST['selected_users'][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['view'])) {
|
||||
switch ($_GET['view']) {
|
||||
case 'users':
|
||||
echo admin_user_view();
|
||||
break;
|
||||
switch ($_GET['view']) {
|
||||
case 'users':
|
||||
echo admin_user_view();
|
||||
break;
|
||||
|
||||
case 'articles':
|
||||
echo admin_article_view();
|
||||
break;
|
||||
}
|
||||
case 'articles':
|
||||
echo admin_article_view();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
echo admin_article_view();
|
||||
echo admin_article_view();
|
||||
}
|
||||
|
||||
include_once 'components/foot.php';
|
||||
|
||||
Reference in New Issue
Block a user