Ejemplo n.º 1
0
<?php

//Require security helper functions
require_once 'authenticator.php';
require_once 'database-queries.php';
//Secured content, redirect unauthenticated users
$authenticator = new AuthenticatorHelper();
$databaseQueries = new DatabaseQueries();
if (!$authenticator->isAdmin()) {
    header('Location: /index.php?not-admin=yes');
}
switch ($_GET['action']) {
    case 'home':
        header('Location: index.php');
        break;
    case 'topic':
        header('Location: topic.php?topic=' . $databaseQueries->getChallenge('topic_challenge')['topic_id']);
        break;
    case 'image-page':
        header('Location: image.php?image=' . $databaseQueries->getChallenge('image_challenge')['image_id']);
        break;
    case 'about':
        header('Location: about.php');
        break;
    case 'profile':
        header('Location: profile.php?username='******'username']);
        break;
    case 'sitemap':
        header('Location: sitemap.php');
        break;
    case 'login':
Ejemplo n.º 2
0
<?php

require_once 'database-queries.php';
require_once 'upload.php';
$databaseQueries = new DatabaseQueries();
$uploadImage = new UploadHelper();
include 'header.php';
if ($_POST) {
    // Setting the $_POST data to $data for sticky form
    $data = $_POST;
    if (array_key_exists('bio', $data)) {
        $databaseQueries->addBio($data);
    } elseif (array_key_exists('submit_image', $data)) {
        $uploadImage->uploadImage($_FILES);
    } elseif (array_key_exists('delete', $data)) {
        $table = $data['table'];
        $id['id'] = $data['id'];
        die(var_dump($data));
        if ($databaseQueries->removePun($table, $id)) {
            $message = "Pun deleted";
            header('Location: /home.php?message=' . $message);
        }
    } elseif (array_key_exists('edit', $data)) {
        header('Location: /edit-pun.php?table=' . $data['table'] . '&id=' . $data['id']);
    }
}
if ($_GET) {
    if ($_GET['rating'] == 'up') {
        $databaseQueries->ratePun();
    } elseif ($_GET['rating'] == 'down') {
        $databaseQueries->ratePun();