<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2013 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: cookie_control_admin.php
| Version: 2.00
| Author: PHP-Fusion Mods UK
| Developers: Craig
| Sites: http://www.phpfusionmods.co.uk
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../../maincore.php";

if (!checkrights("CCP") || !defined("iAUTH") || !isset($_GET['aid']) || $_GET['aid'] != iAUTH) { redirect("../index.php"); }

require_once THEMES."templates/admin_header.php";
require_once INCLUDES."bbcode_include.php";

if (file_exists(INFUSIONS."cookie_control/locale/".$settings['locale'].".php")) {
		include INFUSIONS."cookie_control/locale/".$settings['locale'].".php";
	} else {
		include INFUSIONS."cookie_control/locale/English.php";
	}
	
	include INFUSIONS."cookie_control/infusion_db.php";
	
add_to_title($locale['global_200'].$locale['ecdp_001'].$locale['global_200'].$locale['ecdp_034']);

global $settings;

if (isset($_GET['statusb']) && !isset($messageb)) {
	if ($_GET['statusb'] == "su") {
	$messageb = $locale['ecdp_041'];
	} elseif ($_GET['statusb'] == "nsu") {
	$messageb = $locale['ecdp_041b'];
	}
	if ($messageb) {	echo "<div id='close-message'><div class='admin-message'>".$messageb."</div></div>\n"; }
	}

	if (isset($_POST['save'])) {
	$result = dbquery("UPDATE ".DB_COOKIE_SETTINGS." SET  
	cc_enable='".(isNum($_POST['cc_enable']) ? $_POST['cc_enable'] : "0")."', 
	cc_text='".addslash($_POST['cc_text'])."', 
	cc_time='".addslash($_POST['cc_time'])."',
	cc_position='".(isNum($_POST['cc_position']) ? $_POST['cc_position'] : "0")."',
	cc_bgcolour='".addslashes($_POST['cc_bgcolour'])."',
	cc_border='".addslashes($_POST['cc_border'])."',
	cc_accept='".addslashes($_POST['cc_accept'])."',
	cc_accept_hover='".addslashes($_POST['cc_accept_hover'])."',
	cc_accept_border='".addslashes($_POST['cc_accept_border'])."',
	cc_accept_border_hover='".addslashes($_POST['cc_accept_border_hover'])."',
	cc_accept_text='".addslashes($_POST['cc_accept_text'])."',
	cc_accept_text_hover='".addslashes($_POST['cc_accept_text_hover'])."'
	");	
	
	if (!$result) { 
	redirect(FUSION_SELF.$aidlink."&statusb=nsu");
	} else {
	redirect(FUSION_SELF.$aidlink."&statusb=su");
	}
	}
	
	$cookie_control_settings = dbarray(dbquery("SELECT * FROM ".DB_COOKIE_SETTINGS));
	$cc_enable = isNum(stripinput($cookie_control_settings['cc_enable']));
	$cc_text = stripinput($cookie_control_settings['cc_text']);
    $cc_time = stripinput($cookie_control_settings['cc_time']);
	$cc_position = isNum(stripinput($cookie_control_settings['cc_position']));
	$cc_bgcolour = stripinput($cookie_control_settings['cc_bgcolour']);
	$cc_border = stripinput($cookie_control_settings['cc_border']);
	$cc_accept = stripinput($cookie_control_settings['cc_accept']);
	$cc_accept_hover = stripinput($cookie_control_settings['cc_accept_hover']);
	$cc_accept_border = stripinput($cookie_control_settings['cc_accept_border']);
	$cc_accept_border_hover = stripinput($cookie_control_settings['cc_accept_border_hover']);
	$cc_accept_text = stripinput($cookie_control_settings['cc_accept_text']);
	$cc_accept_text_hover = stripinput($cookie_control_settings['cc_accept_text_hover']);
    $forma_title = $locale['ecdp_034'];
	
	add_to_head("<script type='text/javascript' src='".INFUSIONS."cookie_control/includes/jscolor/jscolor.js'></script>");

	opentable($forma_title);
	$folder_img = INFUSIONS."cookie_control/images/folder_open.png";
	$subfolder_img = INFUSIONS."cookie_control/images/sub.png";
	echo "<table width='100%' border='0' cellpadding='2' cellspacing='0'><tr>";
	echo "<td width='1'><img src='".$folder_img."' alt=''></td>";
	echo "<td style='padding-left:3px;'><a href='".INFUSIONS."cookie_control/cookie_control_admin.php".$aidlink."' class='side'>".$locale['ecdp_001']."</a>";
	echo"</td>";
	echo "</tr></table>";
	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 10px;'><tr>";
	echo "<td style='width:31px;' align='right'><img src='".$subfolder_img."' alt=''></td>";
	echo "<td style='padding-left:3px;'><span style='font-weight: bold;'>".$locale['ecdp_034']."</span>";
	echo"</td></tr></table>";
	
    echo "<form name='cookie_settings_form' method='post' action='".FUSION_SELF.$aidlink."' onsubmit='return ValidateForm(this);'>\n";
    echo "<table cellpadding='0' cellspacing='0' width='95%'  class='tbl-border center' >\n<tr>\n";
	echo "<td  class='tbl' width='50%' align='left'>".$locale['ecdp_035'].":</td>\n";
	echo "<td  align='left' class='tbl'><select name='cc_enable' class='textbox'>\n";
	echo "<option value='1'".($cookie_control_settings['cc_enable'] == "1" ? " selected='selected'" : "").">".$locale['ecdp_039']."</option>\n";
	echo "<option value='0'".($cookie_control_settings['cc_enable'] == "0" ? " selected='selected'" : "").">".$locale['ecdp_040']."</option>\n";
	echo "</select></td></tr><tr>\n";
	echo "<td style='vertical-align: top;' class='tbl'>".$locale['ecdp_036'].":</td>\n";
	echo "<td class='tbl'><textarea name='cc_text' cols='60' rows='5'  class='textbox' style='width:400px;'>$cc_text</textarea><br />\n";
    echo display_bbcodes("400px;", "cc_text", "cookie_settings_form", "color|b|i|u|small|url")."\n";
    echo "</td>\n</tr>\n<tr>\n";
	echo" <td  class='tbl'>".$locale['ecdp_037']."</td>";
	echo" <td  class='tbl'><input class=' textbox' maxlength='3' name='cc_time' value='".$cc_time."' style='width: 30px;'/> ".$locale['ecdp_077']."</td></tr>\n";
	echo "<tr><td  class='tbl' width='50%' align='left'>".$locale['ecdp_049'].":</td>\n";
	echo "<td  align='left' class='tbl'><select name='cc_position' class='textbox'>\n";
	echo "<option value='1'".($cookie_control_settings['cc_position'] == "1" ? " selected='selected'" : "").">".$locale['ecdp_047']."</option>\n";
	echo "<option value='0'".($cookie_control_settings['cc_position'] == "0" ? " selected='selected'" : "").">".$locale['ecdp_048']."</option>\n";
	echo "</select></td></tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_050'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_bgcolour' value='".$cc_bgcolour."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_057'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_border' value='".$cc_border."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_051'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept' value='".$cc_accept."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_052'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept_hover' value='".$cc_accept_hover."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_053'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept_border' value='".$cc_accept_border."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_054'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept_border_hover' value='".$cc_accept_border_hover."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_055'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept_text' value='".$cc_accept_text."'/></td>\n";
	echo "</tr>\n";
	echo" <tr><td  width='50%' class='tbl'>".$locale['ecdp_056'].":</td>";
	echo" <td  align='left' class='tbl'><input class='color {required:false} textbox' maxlength='6' name='cc_accept_text_hover' value='".$cc_accept_text_hover."'/></td>\n";
	echo "</tr>\n";
	echo"</table>\n";
    echo "<table cellpadding='0' cellspacing='0' width='80%' class='center'>\n<tr>\n";
	echo "<td align='center' colspan='2' class='tbl'><br />\n";
	echo "<input type='submit' class='button' name='save' value='".$locale['ecdp_016']."' />\n";
	echo "</td></tr>\n";
	echo "</table>\n";
    echo "</form>\n";
    closetable();
	
			add_to_footer("<script type='text/javascript'>
function ValidateForm(frm) {
	
	if(frm.cc_text.value=='') {
		alert('".$locale['ecdp_044']."');
		return false;
	}	
	if(frm.cc_time.value=='') {
		alert('".$locale['ecdp_045']."');
		return false;
	}	
	if(isNaN(frm.cc_time.value)) {
		alert('".$locale['ecdp_046']."');
		return false;
	}
	
}
</script>");

require_once THEMES."templates/footer.php";
?>