<?php
/**
 * Created by PhpStorm.
 * User: jaskokoyn
 * Date: 2/21/2015
 * Time: 12:06 PM
 */

include( '../../inc/db.php' );
include( '../../inc/functions.php' );

if(!isset($_SESSION['loggedin']) || $user['mem_level'] != 2){
    die("AYYYYYY");
}

if( !isReady($_POST, array( "regEnabled" ) ) ){
    die( "EMPTY" );
}

$regEnabled                 =   secure($_POST['regEnabled']);
$upload_size                =   secure($_POST['upload_size']);
$files                      =   secure($_POST['files']);
$polls                      =   secure($_POST['polls']);

$updateSettingsQuery    =   $db->prepare("UPDATE settings SET registration = :r,
                                                              max_upload_size = :mus,
                                                              file_uploads = :fu,
                                                              create_polls = :cp
                                          WHERE id = :id");
$updateSettingsQuery->execute(array(
    ":r"    =>  $regEnabled,
    ":mus"  =>  $upload_size,
    ":fu"   =>  $files,
    ":cp"   =>  $polls,
    ":id"   =>  1
));

die("SUCCESS");