Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/projects/rpsproject/

bacon-egg-pizza.php
createaccount.php
drop-rps-tables.php
legacy-code-rps.php
newpassword-verify.php
newpassword.php
rpsaccount-ajax-user-search.php
rpsaccount.php
rpsbetting-ajax-match-finder.php
rpsbetting.php
rpsbettingleaderboard.php
rpschangepassword.php
rpschangepassword.txt
rpsgame-ajax.php
rpsgame.php
rpsgameresults.php
rpshostnewgame.php
rpshub.php
rpsleaderboard.php
rpslib.php
rpslogin.php
rpsmaininclude.php
rpsusersearch.php
table-init.php
verification.php

drop-rps-tables.php

45 lines UTF-8 Windows (CRLF)
<?php
//ChatGPT-sida endast för att ta bort databaserna så de kan bli uppladdade igen efter ändringar

// Database connection settings
require("../incl/dbconnection.php");

$tablesToDrop = ['bets''forgotpasskeytable''matches','moves','pendingusers','rpsusers']; // <-- Your table names here

try {
    if (isset(
$_POST['drop_tables'])) {

        foreach (
$tablesToDrop as $table) {
            
$dbconn->exec("DROP TABLE IF EXISTS `$table`");
            echo 
"Dropped table: <strong>$table</strong><br>";
        }

        
// Re-enable foreign key checks
        
$dbconn->exec("SET FOREIGN_KEY_CHECKS = 1");

        echo 
"<p style='color:green'><strong>Selected tables dropped successfully.</strong></p>";
    }
} catch (
PDOException $e) {
    echo 
"<p style='color:red'>Database error: " $e->getMessage() . "</p>";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Drop Specified Tables</title>
</head>
<body>
    <h2>Drop Specific Tables</h2>
    <form method="POST">
        <p style="color:red;"><strong>This will permanently drop the following tables:</strong></p>
        <ul>
            <?php foreach ($tablesToDrop as $table): ?>
                <li><?php echo htmlspecialchars($table); ?></li>
            <?php endforeach; ?>
        </ul>
        <button type="submit" name="drop_tables" onclick="return confirm('Really drop these tables?')">Drop Tables</button>
    </form>
</body>
</html>