added maintinance script to keep database clean
This commit is contained in:
parent
9afe2e0633
commit
3cc496420f
1 changed files with 37 additions and 0 deletions
37
maintinance.php
Normal file
37
maintinance.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* smzint/Auth (c) schmamazon.com 2025
|
||||||
|
*/
|
||||||
|
|
||||||
|
include('db.ini.php');
|
||||||
|
|
||||||
|
function cleanSessions(){
|
||||||
|
global $dbservername;
|
||||||
|
global $dbname;
|
||||||
|
global $dbusername;
|
||||||
|
global $dbpassword;
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
|
||||||
|
// Check connection
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sql to delete a record
|
||||||
|
$sql = "DELETE FROM smz_sessions WHERE expiry < ".time()." OR active = 0";
|
||||||
|
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
echo "Record deleted successfully";
|
||||||
|
} else {
|
||||||
|
echo "Error deleting record: " . $conn->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Starte SessionCleaner";
|
||||||
|
cleanSessions();
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue