Файловый менеджер - Редактировать - /var/www/jonas-eriksen.dk/pic/private/user.tar
Назад
profile.php 0000644 00000030131 15233453650 0006721 0 ustar 00 <?php include('../include.php'); include('../admin/consent.php'); include('../export/export-user.php'); $admin = new admin($db); $admin->passwordResetCheck(); $user = new user($db); $event = new event($db); $log = new log($db); if (!isset($_GET['user'])) { echo "Intet id valgt se <a href='./'>brugerlisten</a>"; } elseif (!$user->getUser($_GET['user'])) { } else { $profile = $user->getUser($_GET['user']); $pictureUrl = '/static/profile-picture/' . $profile[0] . '.jpg'; if ($_POST) { if (isset($_POST['cross'])) { $log->addLog($_SESSION['userId'], "Opdateret abonnoment betalt", "Admin", "/user/profile.php?user=" . $_GET['user']); $user->updateSubcription($_POST['cross'], 1); $admin->redirect('/user/profile.php?user=' . $_GET['user']); } if (isset($_POST['checkmark'])) { $log->addLog($_SESSION['userId'], "Opdateret abonnoment ikke betalt", "Admin", "/user/profile.php?user=" . $_GET['user']); $user->updateSubcription($_POST['checkmark'], 0); $admin->redirect('/user/profile.php?user=' . $_GET['user']); } if (isset($_POST['point']) && isset($_POST['crossten'])) { $log->addLog($_SESSION['userId'], "Tilføjede event", "Event", "/user/profile.php?user=" . $_GET['user']); $event->newEvent(DATE('Y'), $_GET['user'], $_POST['point'], $_POST['crossten'], $_POST['weaponSelect']); $user->changeEventNumber($_GET['user'], -1); $admin->redirect('/user/profile.php?user=' . $_GET['user']); } if (isset($_POST['amount'])) { $log->addLog($_SESSION['userId'], "Tilføjede " . $_POST['amount'] . " point til brugeren", "Admin", "/user/profile.php?user=" . $_GET['user']); $user->changeEventNumber($_GET['user'], $_POST['amount']); $admin->redirect('/user/profile.php?user=' . $_GET['user']); } if (isset($_POST['consentButton'])) { getConsent($profile, $logoName, $companySlogan, $companyLink, $companyName); } if (isset($_POST['exportButton'])) { getReport($user, $admin, $event, $_GET['user'], $_SESSION['userId'], $encryptKey, $logoName); $log->addLog($_SESSION['userId'], "Eksporterende report for brugeren " . $profile[3], "Admin", "/user/profile.php?user=" . $_GET['user']); } } include('../static/header.php'); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <?php echo "<h2>Profil for " . $profile[3]; if ($profile[10]) { echo "<p style='color:red; display: inline'> (Slettet)</p>"; } echo "</h2>"; if ($admin->admin_level(0)) { echo "<i><a href='./update.php?user=$profile[0]'>(Opdater profil)</a></i><br>"; } if (is_file('../static/profile-picture/' . $profile[0] . '.jpg') && file_exists('../static/profile-picture/' . $profile[0] . '.jpg')) { ?> <img src="<?php echo $pictureUrl ?>" style="height: 150px;"/> <?php } else { echo '<img src="../static/' . $logoName . '" style="height: 150px;"/>'; } if ($admin->admin_level(1)) { $user->getSKV($_GET['user']); ?> <form method="post" name="consentButton"> <button name="consentButton" style="float: right"> Hent samtykke </button> </form> <form method="post" name="exportButton"> <button name="exportButton" style="float: right"> Hent brugerrepport </button> </form> <?php } ?> <table id="userTable" class="display table-bordered" cellspacing="0" width="100%"> <tr> <?php if ($admin->admin_level(1)) { echo "<th>CPR</th>"; } ?> <th>Skyttenummer</th> <th>Navn</th> <th>Skytteklasse</th> <?php if ($admin->admin_level(0)) { ?> <th>Adresse</th> <th>Fødselsdag</th> <th>Telefon</th> <th>Email</th> <th>Indmeldelses år</th> <th>Må tages billede af</th> <th>Har egent våben</th> <th>Kontigent betalt</th> <?php } ?> <th>Skydninger tilbage</th> </tr> <tr> <?php if ($admin->admin_level(1)) { $cpr = decrypt($profile[2], $encryptKey); echo "<td>$cpr</td>"; } echo "<td>$profile[1]</td>"; echo "<td>$profile[3]</td>"; echo "<td>$profile[17]</td>"; if ($admin->admin_level(0)) { echo "<td>$profile[4]</td>"; echo "<td>" . date_format(new DateTime($profile[5]), 'd-m-Y') . "<br/>" . date_diff(date_create($profile[5]), date_create('today'))->y . " år</td>"; echo "<td>$profile[9]</td>"; echo "<td>$profile[6]</td>"; echo "<td>$profile[13]</td>"; if ($profile[7] == 1) { echo "<td align='center'><img src='/static/checkmark.gif' alt='Ja' width='40'> </td>"; } else { echo "<td align='center'><img src='/static/red_cross.png' alt='nej' width='40'> </td>"; } if ($profile[11] == 0) { echo "<td>Nej</td>"; } elseif ($profile[11] == 1) { echo "<td>Ja, gevær</td>"; } elseif ($profile[11] == 2) { echo "<td>Ja, pistol</td>"; } else { echo "<td>Ja, både gevær og pistol</td>"; } echo "<form method='POST'>"; if ($profile[8] == 1) { echo "<td align='center'><button style=\"background-color: white;\" name='checkmark' value='$profile[0]'><img src='/static/checkmark.gif' alt='Ja' width='40'></button></td>"; } else { echo "<td align='center'><button style=\"background-color: white;\" name='cross' value='$profile[0]'><img src='/static/red_cross.png' alt='nej' width='40'></button></td>"; } echo "</form>"; } echo "<td>$profile[12]</td>"; echo "</tr>"; ?> </table> </div> </div> </div> <br/> <style> div.container { width: 100%; } input[type=number] { width: 80px; } </style> <?php $weaponStmt = $db->prepare("SELECT id, name FROM result_weapon ORDER BY CASE WHEN name LIKE 'Riffel%' THEN 1 ELSE 2 END, name"); $weaponStmt->execute(); if ($admin->admin_level(0)) { ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <table class="table-bordered"> <tr> <th>Point</th> <th>Krydstier</th> <th>Type</th> <th></th> </tr> <form method="post"> <td><input type="number" name="point"></td> <td><input type="number" name="crossten"></td> <td> <select name="weaponSelect"> <?php foreach ($weaponStmt->fetchAll() as $weaponType) { ?> <option value="<?php echo $weaponType[0] ?>"><?php echo $weaponType[1] ?></option> <?php } ?> </select> </td> <td><input type="submit"></td> </form> </table> <form method="post">Indsæt <input type="number" value="0" width="10px" name="amount">skydninger på kontoen <input type="submit"></form> </div> </div> </div> <?php } if (!isset($_GET['year'])) { $getYear = date("Y"); } else { $getYear = $_GET['year']; } $result = $event->getAllForUser($getYear, $_GET['user']); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <?php echo "<h2>Træningsresultater i $getYear</h2>"; foreach ($event->getYearsForUser($_GET['user']) as $year) { ?> <a href="/user/profile.php?user=<?php echo $_GET['user'] ?>&year=<?php echo $year[0] ?>"> <button class="btn btn-primary" type="button"> <?php echo $year[0] ?> <span class="badge"><?php $event->getYearCountForUser($year[0], $_GET['user']) ?></span> </button> </a> <?php } ?> <table id="eventTable" class="table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th style="display: none"></th> <th>Point</th> <th>Krydsti</th> <th>Type</th> <th>Dato</th> <th></th> </tr> </thead> <tfoot> <tr> <th style="display: none"></th> <th>Point</th> <th>Krydsti</th> <th>Type</th> <th>Dato</th> <th></th> </tr> </tfoot> <tbody> <?php foreach ($result as $row) { echo "<tr>"; echo "<td style='display: none'>$row[0]</td>"; echo "<td>$row[1]</a></td>"; echo "<td>$row[2]</td>"; echo "<td>$row[3]</td>"; echo "<td>" . date("d/m/Y", strtotime($row[9])) . "</td>"; echo "<td><a href='/event/edit.php?event=" . $row[0] . "'>Edit</a></td>"; echo "</tr>"; } ?> </tbody> </table> </div> </div> </div> <?php include("../static/footer.php"); ?> <script> $(document).ready(function () { $('#eventTable').DataTable({ "order": [[0, "desc"]] }); }); </script> <?php } ?> Class.user.php 0000644 00000023525 15233472040 0007306 0 ustar 00 <?php class user { private $db; function __construct($DB_con) { $this->db = $DB_con; } public function getAllUsers($show) { try { if ($show == 0) { $stmt = $this->db->prepare("SELECT id, cpr, shooterId, fullname, adress, birthday, phone, email, allowPicture, newShooter, subscriptionPaid FROM result_users WHERE isDeleted = 0 ORDER BY fullname ASC"); } elseif ($show == 1) { $stmt = $this->db->prepare("SELECT id, cpr, shooterId, fullname, adress, birthday, phone, email, allowPicture, newShooter, subscriptionPaid, isDeleted FROM result_users ORDER BY fullname ASC"); } $stmt->execute(); $users = $stmt->fetchAll(); return $users; } catch (PDOException $e) { echo $e->getMessage(); } } public function register($shooterId, $cpr, $fullname, $adress, $birthday, $email, $allowPicture, $phone, $ownWeapon, $class, $memberDate) { try { $stmt = $this->db->prepare("INSERT INTO result_users(shooterId, cpr, fullname, adress, birthday, email, allowPicture, phone, ownWeapon, class, memberDate) VALUES (:shooterId, :cpr, :fullname, :adress, :birthday, :email, :allowPicture, :phone, :ownWeapon, :class, :memberDate)"); $stmt->execute(array(":shooterId" => $shooterId, ":cpr" => $cpr, ":fullname" => $fullname, ":adress" => $adress, ":birthday" => $birthday, ":email" => $email, ":allowPicture" => $allowPicture, ":phone" => $phone, ":ownWeapon" => $ownWeapon, ":class" => $class, ":memberDate" => $memberDate)); return $stmt; } catch (PDOException $e) { echo $e->getMessage(); } } public function update($id, $shooterId, $cpr, $fullname, $adress, $birthday, $email, $allowPicture, $phone, $isDeleted, $ownWeapon, $class, $new, $memberDate) { try { $stmt = $this->db->prepare("UPDATE result_users SET shooterId = :shootId, cpr = :cpr, fullname = :fullname, adress = :adress, birthday = :birthday, email = :email, allowPicture = :allowpiture, phone = :phone, isDeleted = :isDeleted, ownWeapon = :ownWeapon, class = :class, newShooter = :new, memberDate = :memberDate WHERE id = :id"); $stmt->execute(array(":id" => $id, ":shootId" => $shooterId, ":cpr" => $cpr, ":fullname" => $fullname, ":adress" => $adress, ":birthday" => $birthday, ":email" => $email, ":allowpiture" => $allowPicture, ":phone" => $phone, ":isDeleted" => $isDeleted, ":ownWeapon" => $ownWeapon, ":class" => $class, ":new" => $new, ":memberDate" => $memberDate)); return $stmt; } catch (PDOException $e) { echo $e->getMessage(); } } public function getUser($userId) { $stmt = $this->db->prepare("SELECT * FROM result_users JOIN result_class ON result_users.class = result_class.id WHERE result_users.id = :userId"); $stmt->execute(array(':userId' => $userId)); $userRow = $stmt->fetch(PDO::FETCH_BOTH); if ($stmt->rowCount() == 1) { return $userRow; } else { ?> Ingen bruger med id <?php echo $userId ?><br> Se venligst <a href="/user/new.php">opretelse af ny bruger</a>. <?php return false; } } public function updateSubcription($userId, $sub) { $stmt = $this->db->prepare("SELECT * FROM result_users WHERE id = :userId"); $stmt->execute(array(':userId' => $userId)); $userRow = $stmt->fetch(PDO::FETCH_BOTH); if ($stmt->rowCount() == 1) { $query = $this->db->prepare("UPDATE result_users SET subscriptionPaid = :sub WHERE id = :userId"); $query->execute(array(':sub' => $sub, ':userId' => $userId)); } } public function getSKV($userId, $report = null) { $stmt = $this->db->prepare("SELECT * FROM result_skv WHERE shooterId = :userId"); $stmt->execute(array(':userId' => $userId)); $skvRow = $stmt->fetchAll(); if ($report == null) { if ($skvRow) { ?> <table class="table-bordered" style="float: right"> <thead> <th>SKV nummer</th> <th>Acceptdato</th> <th>Udløbsdato</th> </thead> <tbody> <?php foreach ($skvRow as $row) { ?> <tr> <td><?php echo $row[2] ?></td> <td><?php echo date_format(new DateTime($row[3]), 'd-m-Y'); ?></td> <td><?php $date = new DateTime($row[3]); date_add($date, date_interval_create_from_date_string('5 years')); echo date_format($date, 'd-m-Y'); ?></td> </tr> <?php } ?> </tbody> </table> <?php } } else { return $skvRow; } } public function getSKVOnId($skvId) { try { $stmt = $this->db->prepare("SELECT id, `skv-id` FROM result_skv WHERE id = :id"); $stmt->execute(array(':id' => $skvId)); $skv = $stmt->fetch(PDO::FETCH_BOTH); return $skv; } catch (PDOException $e) { echo $e->getMessage(); } } public function changeEventNumber($userId, $amount) { $stmt = $this->db->prepare("SELECT eventsLeft FROM result_users WHERE id = :userId"); $stmt->execute(array(":userId" => $userId)); $eventsLeft = $stmt->fetch(PDO::FETCH_BOTH); $currentEventsLeft = $eventsLeft[0]; $newAmount = $currentEventsLeft + $amount; $stmt = $this->db->prepare("UPDATE result_users SET eventsLeft = :newAmount WHERE id = :userId"); $stmt->execute(array(":userId" => $userId, ":newAmount" => $newAmount)); } public function newSKV($userId, $skvNumber, $date, $skvId) { try { $stmt = $this->db->prepare("INSERT INTO result_skv (shooterId, skvNumber, date, `skv-id`) VALUES (:userId, :skvNumber, :date, :skvId)"); $stmt->execute(array(":userId" => $userId, ":skvNumber" => $skvNumber, ":date" => $date, ":skvId" => $skvId)); return $stmt; } catch (PDOException $e) { echo $e->getMessage(); } } public function updateSKV($id, $skvNumber, $date, $skvId) { try { $stmt = $this->db->prepare("UPDATE result_skv SET skvNumber = :skvNumber, date = :date, `skv-id` = :skvId WHERE id = :id"); $stmt->execute(array(":id" => $id, ":skvNumber" => $skvNumber, ":date" => $date, ":skvId" => $skvId)); } catch (PDOException $e) { echo $e->getMessage(); } } public function deleteSKV($id) { try { $stmt = $this->db->prepare("DELETE FROM result_skv WHERE id = :id"); $stmt->execute(array(":id" => $id)); header("location: /admin/skv.php"); } catch (PDOException $e) { echo $e->getMessage(); } } public function getAllSKV() { try { $stmt = $this->db->prepare("SELECT result_users.id, result_users.shooterId, result_users.fullname, result_skv.`skv-id`, result_skv.skvNumber, result_skv.date, result_skv.id FROM result_skv JOIN result_users ON result_users.id = result_skv.shooterId ORDER BY result_skv.date"); $stmt->execute(); return $stmt; } catch (PDOException $e) { echo $e->getMessage(); } } public function getUserSKV($id) { try { $stmt = $this->db->prepare("SELECT result_users.fullname, result_skv.skvNumber, result_skv.date, result_skv.`skv-id` FROM result_skv JOIN result_users ON result_users.id = result_skv.shooterId WHERE result_skv.id = :id"); $stmt->execute(array(':id' => $id)); $skvRow = $stmt->fetch(PDO::FETCH_BOTH); return $skvRow; } catch (PDOException $e) { echo $e->getMessage(); } } public function getLatestUser() { try { $stmt = $this->db->prepare("Select id FROM result_users ORDER BY id DESC LIMIT 1"); $stmt->execute(); $id = $stmt->fetch(); return $id[0]; } catch (PDOException $e) { echo $e->getMessage(); } } public function getUserForConsentForm($userId) { try { $stmt = $this->db->prepare("SELECT fullname, adress, email, phone FROM result_users WHERE id = :userId"); $stmt->execute(array(":userId" => $userId)); $user = $stmt->fetch(PDO::FETCH_BOTH); return $user; } catch (PDOException $e) { echo $e->getMessage(); } } public function getUserAnniversary() { try { $stmt = $this->db->prepare("SELECT id, fullname, memberDate FROM result_users WHERE isDeleted = 0 ORDER BY fullname ASC;"); $stmt->execute(); $users = $stmt->fetchAll(); $anniversaries = [20, 30, 40, 50, 60, 70, 80, 90, 100]; $anniversary_combined_array = []; foreach($users AS $a) { if(in_array(date_diff(date_create($a[2]."-01-01"), date_create('today'))->y,$anniversaries)) { array_push($anniversary_combined_array,$a); } } return $anniversary_combined_array; } catch (PDOException $e) { echo $e->getMessage(); } } } index.php 0000644 00000011714 15233472040 0006370 0 ustar 00 <?php include('../include.php'); error_reporting(0); ini_set('display_errors', 0); ?> <style> div.container { width: 100%; } </style> <?php $admin = new admin($db); $admin->passwordResetCheck(); $user = new user($db); $u = $user->getUserForConsentForm(5); $users = $user->getAllUsers(0); if (isset($_GET['showAll'])) { $users = $user->getAllUsers(1); } if (isset($_GET['login']) && $_GET['login'] == "true") { echo "Du er allerede logget ind som " . $_SESSION['username']; } include('../static/header.php'); ?> <div class="container"> <div class="row"> <div class="col-lg-12"> <h2>Skytteliste</h2> <?php if (isset($_GET['showAll'])) { echo "<i><a href='/user/'>Skjul slettede</a> </i>"; } else { echo "<i><a href='?showAll'>Vis alle skytter</a> </i><br/>"; } ?> <table id="userTable" class="table-bordered" cellspacing="0" width="100%"> <thead> <tr> <th>Skyttenummer</th> <th>Navn</th> <?php if ($admin->admin_level(0)) { ?> <th>Adresse</th> <th>Fødselsdag</th> <th>Telefon</th> <th>Email</th> <th>Kontigent betalt</th> <th>Må tages billede af</th> <?php } ?> </tr> </thead> <tfoot> <tr> <th>Skyttenummer</th> <th>Navn</th> <?php if ($admin->admin_level(0)) { ?> <th>Adresse</th> <th>Fødselsdag</th> <th>Telefon</th> <th>Email</th> <th>Kontigent betalt</th> <th>Må tages billede af</th> <?php } ?> </tr> </tfoot> <tbody> <?php foreach ($users as $row) { $birthday = date_format(new DateTime($row[5]), 'd-m-Y'); if ($row[9] == 1) { $new = " (ny)"; } else { $new = ""; } echo "<tr>"; if ($admin->admin_level(1)) { $cpr = decrypt($row[1], $encryptKey); echo "<td>$cpr</td>"; } echo "<td><a href='/user/profile.php?user=$row[0]'>$row[2]</a></td>"; if (isset($_GET['showAll'])) { if ($row[11]) { echo "<td><a href='/user/profile.php?user=$row[0]' style='color: red;'>$row[3] (Deleted)</a></td>"; } else { echo "<td><a href='/user/profile.php?user=$row[0]'>$row[3]</a></td>"; } } else { echo "<td><a href='/user/profile.php?user=$row[0]'>$row[3] $new</a></td>"; } if ($admin->admin_level(0)) { echo "<td>$row[4]</td>"; echo "<td>$birthday</td>"; echo "<td>$row[6]</td>"; echo "<td>$row[7]</td>"; if ($row[10] == 1) { echo "<td align='center'><img src='/static/checkmark.gif' alt='Ja' width='40'></td>"; } else { echo "<td align='center'><img src='/static/red_cross.png' alt='nej' width='40'></td>"; } if ($row[8] == 1) { echo "<td align='center'><img src='/static/checkmark.gif' alt='Ja' width='40'></td>"; } else { echo "<td align='center'><img src='/static/red_cross.png' alt='nej' width='40'></td>"; } echo "</tr>"; } } echo "</tbody>"; ?> </table> </div> </div> </div> <script> $(document).ready(function () { $('#userTable').DataTable(); }); </script> <?php include('../static/footer.php'); ?>