<?php
/**
 * Created by PhpStorm.
 * User: jaskokoyn
 * Date: 2/21/2015
 * Time: 11:45 AM
 */

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

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

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

$name       =   secure($_POST['name']);
$desc       =   secure($_POST['desc']);
$header     =   $_POST['header'];
$footer     =   $_POST['footer'];
$sidebar    =   $_POST['sidebar'];
$words      =   $_POST['bad_words'];

$updateSettingsQuery    =   $db->prepare("UPDATE settings SET site_name = :sn,
                                                              site_desc = :sd,
                                                              header_ad ='" . $header . "',
                                                              footer_ad ='" . $footer . "',
                                                              sidebar_ad ='" . $sidebar . "',
                                                              bad_words = :bw
                                          WHERE id = :id");
$updateSettingsQuery->execute(array(
    ":sn"   =>  $name,
    ":sd"   =>  $desc,
    ":bw"   =>  $words,
    ":id"   =>  1
));

die("SUCCESS");