mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-05-28 22:33:11 +00:00
Logs section added
This commit is contained in:
parent
32e6a356a3
commit
cb838ad53b
7 changed files with 185 additions and 45 deletions
|
@ -1,6 +1,12 @@
|
|||
<?php
|
||||
// Include server connection
|
||||
include dirname(__DIR__)."/server/conn.php";
|
||||
include dirname(__DIR__)."/app.php";
|
||||
|
||||
use App\Account;
|
||||
|
||||
$user_info = new Account();
|
||||
$user_ip = $user_info->get_ip();
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
|
@ -85,12 +91,15 @@ if (isset($_POST['submit_login'])) {
|
|||
//window.location.href = "../index.php?login=success";
|
||||
</script>
|
||||
<?php
|
||||
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New loggin to ".$_SESSION['username']."')");
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Password')");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -99,6 +108,7 @@ if (isset($_POST['submit_login'])) {
|
|||
sniffleAdd('Sus', 'Username or Password WRONG, please try again :3', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Username')");
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
|
@ -237,6 +247,7 @@ if (isset($_POST['submit_signup'])) {
|
|||
sniffleAdd('smelly', 'Enter Invite Code ;3', 'var(--red)', 'assets/icons/cross.svg');
|
||||
</script>
|
||||
<?php
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Failed to enter correct Invite Code')");
|
||||
$error = $error + 1;
|
||||
} else {
|
||||
// Prepare sql for sus
|
||||
|
@ -324,6 +335,7 @@ if (isset($_POST['submit_signup'])) {
|
|||
loginShow();
|
||||
</script>
|
||||
<?php
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','New account (".$username.") has been made')");
|
||||
} else {
|
||||
?>
|
||||
<script>
|
||||
|
|
34
app/app.php
34
app/app.php
|
@ -23,9 +23,9 @@ class Make {
|
|||
}
|
||||
|
||||
/*
|
||||
Clean up long text input and turn into an array for tags
|
||||
Clean up long text input and turn into an array for tags
|
||||
|
||||
Returns clean string of words with equal white space between it
|
||||
Returns clean string of words with equal white space between it
|
||||
*/
|
||||
function tags($string) {
|
||||
// Replace hyphens
|
||||
|
@ -43,10 +43,10 @@ class Make {
|
|||
|
||||
class Account {
|
||||
/*
|
||||
Check if user is loggedin
|
||||
Check if user is loggedin
|
||||
|
||||
Returns True if user is
|
||||
Returns False if user is NOT
|
||||
Returns True if user is
|
||||
Returns False if user is NOT
|
||||
*/
|
||||
function is_loggedin() {
|
||||
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
|
||||
|
@ -56,9 +56,9 @@ class Account {
|
|||
}
|
||||
}
|
||||
/*
|
||||
Get full user info from database
|
||||
Get full user info from database
|
||||
|
||||
Returns array with user info
|
||||
Returns array with user info
|
||||
*/
|
||||
function get_user_info($conn, $id) {
|
||||
// Setting SQL query
|
||||
|
@ -71,10 +71,10 @@ class Account {
|
|||
return($user_array);
|
||||
}
|
||||
/*
|
||||
Check if user is admin
|
||||
Check if user is admin
|
||||
|
||||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
Returns True if user is privilaged
|
||||
Returns False if user is NOT privilaged
|
||||
*/
|
||||
function is_admin($id) {
|
||||
if (isset($id) || !empty($id)) {
|
||||
|
@ -87,6 +87,20 @@ class Account {
|
|||
return False;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Get target IP, used for logging
|
||||
*/
|
||||
function get_ip() {
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$target_ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$target_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} else {
|
||||
$target_ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
return $target_ip;
|
||||
}
|
||||
}
|
||||
|
||||
class Image {
|
||||
|
|
|
@ -12,6 +12,8 @@ $user_info = new Account();
|
|||
$image_info = new Image();
|
||||
$make_stuff = new Make();
|
||||
|
||||
$user_ip = $user_info->get_ip();
|
||||
|
||||
/*
|
||||
|-------------------------------------------------------------
|
||||
| Delete image
|
||||
|
@ -49,6 +51,7 @@ if (isset($_POST['submit_delete'])) {
|
|||
unlink(dirname(__DIR__)."/images/previews/".$image_array['imagename']);
|
||||
}
|
||||
// TP user to the homepage with a success message
|
||||
mysqli_query($conn,"INSERT INTO logs (ipaddress, action) VALUES('$user_ip','Deleted image ".$_POST['id']."')");
|
||||
?>
|
||||
<script>
|
||||
window.location.replace("index.php?del=true&id=<?php echo $_POST['id']; ?>");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue