<?php

// This is used to delete individual user accounts and all associated comments and photos
session_name('reglogin');
session_start();
$userid = $_SESSION['user_id'];
include "/export/home/mclaug67/source_html/public_html/awp/PhotoSite/Connect-webuser.php";
include "DB_Functions.php";
$dbh = ConnectDB();
$username = GetUsername($dbh, $userid);
$baseDir = "/home/mclaug67/public_html/awp/PhotoSite/UPLOADED/archive/" . $username;
$photoList = ListAllPix($dbh, $username);
foreach ($photoList as $photo) {
    $targetname = GetPhotoLocation($dbh, $photo->photo_id);
    if (!file_exists($targetname)) {
        die("<p>File doesn't exist.</p>");
    } else {
        try {
            $junk = RemovePicComments($dbh, $photo->photo_id);
            unlink($targetname);
            RemovePicture($dbh, $photo->photo_id);
        } catch (PDOException $e) {
            die("error deleting photo");
        }
    }
}
#remove user dir
try {
    rmdir($baseDir);
} catch (PDOException $e) {
    die("error removing user");
<?php

// Used to delete a selected picture
session_name('reglogin');
session_start();
include "/export/home/mclaug67/source_html/public_html/awp/PhotoSite/Connect-webuser.php";
include "DB_Functions.php";
$dbh = ConnectDB();
$targetname = GetPhotoLocation($dbh, $_GET['photoid']);
$junk = RemovePicComments($dbh, $_GET['photoid']);
if (!file_exists($targetname)) {
    die("<p>File doesn't exist.</p>");
} else {
    try {
        unlink($targetname);
    } catch (PDOException $e) {
        die("error deleting photo");
    }
}
echo RemovePicture($dbh, $_GET['photoid']);
?>