<?php
/**
 * Created by PhpStorm.
 * User: jaskokoyn
 * Date: 2/16/2015
 * Time: 7:35 PM
 */

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

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

if( !isReady($_POST, array( "title", "desc", "headerBG", "headerColor", "footerBG", "footerColor" ) ) ){
    die( "EMPTY" );
}

$title  =   secure($_POST['title']);
$desc   =   secure($_POST['desc']);
$avatar =   (secure($_POST['showAvatar']) == "true") ? 1 : 2;
$hbg    =   secure($_POST['headerBG']);
$hfc    =   secure($_POST['headerColor']);
$fbg    =   secure($_POST['footerBG']);
$ffc    =   secure($_POST['footerColor']);

$insertChatQuery    =   $db->prepare("INSERT INTO chats(title,chat_desc,show_avatar,header_bg,header_font,footer_bg,footer_font)
                                      VALUES( :t, :cd, :sa, :hbg, :hfc, :fbg, :ffc )");
$insertChatQuery->execute(array(
    ":t"        =>  $title,
    ":cd"       =>  $desc,
    ":sa"       =>  $avatar,
    ":hbg"      =>  $hbg,
    ":hfc"      =>  $hfc,
    ":fbg"      =>  $fbg,
    ":ffc"      =>  $ffc,
));

die("SUCCESS");