implemented mass creation via csv, bug fixes
This commit is contained in:
@@ -153,7 +153,7 @@ function signup_form($error_msg = '')
|
||||
return $form;
|
||||
}
|
||||
|
||||
function signup($username, $email, $password, $verify_password, $role_id, $upload = null, $x = null, $y = null, $crop_width = null)
|
||||
function create_user($username, $email, $password, $verify_password, $role_id, $upload = null, $x = null, $y = null, $crop_width = null)
|
||||
{
|
||||
if ($password != $verify_password) {
|
||||
$error_msg = '
|
||||
@@ -184,10 +184,6 @@ function signup($username, $email, $password, $verify_password, $role_id, $uploa
|
||||
|
||||
$stmt = 'INSERT INTO user (user_id, username, email, password_hash, role_id' . (!empty($target) ? ', profile_picture' : '') . ') VALUES (' . $id . ', "' . $username . '", "' . $email . '", "' . $password_hash . '", ' . $role_id . (!empty($target) ? ', "' . $target . '"' : '') . ');';
|
||||
exec_statement($stmt, 0);
|
||||
|
||||
login($username, $password, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function profile_cropper()
|
||||
@@ -448,7 +444,7 @@ function delete_account($user_id, $password = null, $verify_password = null)
|
||||
exec_statement($stmt, 1);
|
||||
logout();
|
||||
} else if ($_COOKIE['role_id'] < 3) {
|
||||
$query = 'SELECT user_id FROM user WHERE user_id = ' . $user_id . ';';
|
||||
$query = 'SELECT user_id, profile_picture FROM user WHERE user_id = ' . $user_id . ';';
|
||||
$user = query_one_result($query);
|
||||
|
||||
if ($user['user_id'] == 2025) {
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
<?php
|
||||
require_once 'db_functions.php';
|
||||
require_once 'functions.php';
|
||||
require_once 'account_functions.php';
|
||||
require_once 'article_functions.php';
|
||||
|
||||
function create_users_from_csv($csv)
|
||||
{
|
||||
$csv = read_file($csv);
|
||||
while ($record = fgets($csv)) {
|
||||
$fields = explode(',', $record);
|
||||
|
||||
$username = $fields[0];
|
||||
$email = $fields[1];
|
||||
$password = $fields[2];
|
||||
$role_id = $fields[3];
|
||||
|
||||
create_user(
|
||||
$username,
|
||||
$email,
|
||||
$password,
|
||||
$password,
|
||||
$role_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function admin_create_user() {}
|
||||
|
||||
function admin_article_view()
|
||||
{
|
||||
$display = '
|
||||
@@ -71,6 +95,7 @@ function admin_article_view()
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
function admin_user_view()
|
||||
{
|
||||
$display = '
|
||||
@@ -80,13 +105,18 @@ function admin_user_view()
|
||||
<a href="admin.php?view=articles">View Articles</a>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
<form method="post">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="form_id" value="users">
|
||||
<div class="row">
|
||||
<label for="delete" class="form_checkbox_container">Delete
|
||||
<input type="radio" class="button" name="action" id="delete" value="delete">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
|
||||
<label id="create_users_from_csv_label" for="create_users_from_csv" class="upload_button">Upload a CSV</label>
|
||||
<input id="create_users_from_csv" class="file_input" name="csv" type="file" accept=".csv">
|
||||
<small class="file_input_feedback">No file selected.</small>
|
||||
|
||||
<input type="submit" class="button narrow" value="Commit">
|
||||
</div>
|
||||
|
||||
|
||||
+25
-6
@@ -41,19 +41,27 @@ function upload($input, $dest_dir, $filename = null)
|
||||
case 'png':
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
if (check_image_upload($dest_dir, $filetype, $input)) {
|
||||
if (check_image_upload($dest_dir, $filetype, $input))
|
||||
move_uploaded_file($input['tmp_name'], $dest_dir . ($filename ? $filename . '.' . $filetype : $input['name']));
|
||||
if ($filename)
|
||||
return basename($filename . '.' . $filetype);
|
||||
else
|
||||
return basename($input['name'] . '.' . $filetype);
|
||||
} else
|
||||
else
|
||||
return '';
|
||||
break;
|
||||
case 'csv':
|
||||
if (check_csv_upload($input))
|
||||
move_uploaded_file($input['tmp_name'], $dest_dir . ($filename ? $filename . '.' . $filetype : $input['name']));
|
||||
else
|
||||
return '';
|
||||
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
if ($filename)
|
||||
return basename($filename . '.' . $filetype);
|
||||
else
|
||||
return basename($input['name'] . '.' . $filetype);
|
||||
}
|
||||
|
||||
function crop_image($img_path, $x, $y, $height, $width)
|
||||
@@ -114,11 +122,22 @@ function read_file_one_string($file_path)
|
||||
return $string;
|
||||
}
|
||||
|
||||
function read_file($file_path)
|
||||
{
|
||||
$fs = fopen($file_path, 'r');
|
||||
return $fs;
|
||||
}
|
||||
|
||||
function check_image_upload($target, $filetype, $image)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function check_csv_upload($target)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function pretty_dump($arr)
|
||||
{
|
||||
echo '
|
||||
|
||||
+3
-1
@@ -20,5 +20,7 @@ if ($_SESSION['initialized'] && isset($_POST['theme'])) {
|
||||
unset($_POST['theme']);
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['user_id']))
|
||||
if (isset($_COOKIE['user_id'])) {
|
||||
exec_statement('UPDATE user SET is_active = true WHERE user_id = ' . $_COOKIE['user_id'] . ';', 1);
|
||||
exec_statement('UPDATE user SET last_active = CURRENT_TIMESTAMP WHERE user_id = ' . $_COOKIE['user_id'] . ';', 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user