Location: PHPKode > projects > Ads Exchange Server > estigi_0.1.1_RC2/groups.php
<?php

/***************************************************************************
 *                             groups.php
 *                            -------------------
 *   begin                : lun, sep 03, 2007
 *   copyright            : (C)
 *   email                : hide@address.com
 *   Desc                 : Manage groups
 *
 *
 ***************************************************************************/

define('IN_ADSERVER', true);

include_once("./inc/common.inc.php");

checkLogin($web_address);
get_User_Settings($session['id_User'], 'edit_Cat', $web_address);

/* Declare the TPL */
$groups_Tpl = new tpl($s_path_Tpl . "/groups.tpl");

$s_Id_Group = (isset($_POST['id_Group']) ? $_POST['id_Group'] : 1);
$s_Group_List = "";

//Create new group
if(isset($_POST['add_Group']) && $_POST['new_Group_Name'] != ""){

	$q = "
		INSERT INTO ".$db_Pre."groups (group_Name)
		VALUES ('".$_POST['new_Group_Name']."')
		";

	$q_Creat_Group = mysql_query($q) or die("Unable to Create Groups: " . mysql_error());

$s_Warning = "Group succesfully created";
}

//Update Group
if(isset($_POST['mod_Group']) && $_POST['id_Group'] != ""){

	$_POST['view_Ratio']  = ($_POST['view_Ratio']  < 0 ? 1 : $_POST['view_Ratio']);
	$_POST['click_Ratio'] = ($_POST['click_Ratio'] < 0 ? 1 : $_POST['click_Ratio']);

	$allow_Formats  = (isset($_POST['jpg']) ? ".jpg.jpeg"          : "");
	$allow_Formats .= (isset($_POST['gif']) ? ".gif"               : "");
	$allow_Formats .= (isset($_POST['png']) ? ".png"               : "");
	$allow_Formats .= (isset($_POST['fla']) ? ".x-shockwave-flash" : "");

	$q = "
		UPDATE ".$db_Pre."groups
		SET
			group_Name			 	  = '" . $_POST['group_Name'] . "', 
			edit_Users			 	  = " . (isset($_POST['edit_Users']) ? 1 : 0) . ",
			delete_Users		 	  = " . (isset($_POST['delete_Users']) ? 1 : 0) . ",
			user_List			 	  = " . (isset($_POST['user_List']) ? 1 : 0) . ",
			edit_Cat				 	  = " . (isset($_POST['edit_Cat']) ? 1 : 0) . ",
			edit_Sites			 	  = " . (isset($_POST['edit_Sites']) ? 1 : 0) . ",
			edit_Banners		 	  = " . (isset($_POST['edit_Banners']) ? 1 : 0) . ",
			reports				 	  = " . (isset($_POST['reports']) ? 1 : 0) . ",
			restrict_Countries 	  = " . (isset($_POST['allow_Restrict_Country']) ? 1 : 0) . ",
			view_Ratio				  = " . str_replace(",", ".", $_POST['view_Ratio']) . ",
			click_Ratio				  = " . str_replace(",", ".", $_POST['click_Ratio']) . ",
			def_Ad_State			  = " . (isset($_POST['def_Ad_State']) ? 1 : 3) . ",
			def_Website_State		  = " . (isset($_POST['def_Website_State']) ? 1 : 0) . ",
			max_Text_Ads			  = " . $_POST['max_Text_Ads'] . ",
			max_Img_Ads 			  = " . $_POST['max_Img_Ads'] . ",
			restrict_Cats_Shown    = " . (isset($_POST['restrict_Cats_Shown']) ? 1 : 0) . ",
			restrict_Cats_Display  = " . (isset($_POST['restrict_Cats_Display']) ? 1 : 0) . ",
			restrict_Times         = " . (isset($_POST['restrict_Times']) ? 1 : 0) . ",
			allow_Formats 			  = '" . $allow_Formats . "'
			WHERE id_Group 		  = "  . $_POST['id_Group']."
			";

	$q_Update_Group = mysql_query($q) or die("Unable to Update Groups: " . mysql_error());

$s_Warning = $_lang['groups_Msg_Updated'];
}

//Get group list
$q = "
	SELECT group_Name, id_Group
	FROM  ".$db_Pre."groups
	";

$q_Get_Groups = mysql_query($q) or die("Unable to Get Groups: " . mysql_error());

while($row = mysql_fetch_array($q_Get_Groups, MYSQL_ASSOC)){
	$s_Group_List .= "<option value=".$row['id_Group'].">".$row['group_Name']."</option>";
}

//Get permitions
$q = "
	SELECT ".$db_Pre."groups.*
	FROM  ".$db_Pre."groups
	WHERE id_Group = ".$s_Id_Group."
	";

$q_Get_Groups = mysql_query($q) or die("Unable to Get Groups: " . mysql_error());

$row = mysql_fetch_array($q_Get_Groups, MYSQL_ASSOC);

/* Main Values */
$a_Groups = array(
	"{GROUPS_HELP_TITLE}" => $_lang['groups_Help_Groups'],
	"{GROUPS_HELP_TEXT}" => $_lang['groups_Help_Text'],
	"{GROUPS_MODIFY}" => $_lang['groups_Modify'],
	"{GROUPS_SELECT_GROUP}" => $_lang['groups_Select_Group'],
	"{GROUPS_GROUP_SELECT}" => $s_Group_List,
	"{GROUPS_NEW_NAME}" => $_lang['groups_Group_Name'],
	"{GROUPS_CREATE}" => $_lang['groups_Create'],
	"{GROUPS_DETAILS}" => $_lang['groups_Group_Details'],
	"{GROUPS_NAME}" => $_lang['groups_Name'],
	"{GROUPS_NAME_V}" => $row['group_Name'],
	"{GROUPS_EDIT_USERS}" => $_lang['groups_Edit_Users'],
	"{GROUPS_EDIT_CHECK}" =>  ($row['edit_Users'] == 1 ? "checked" : ""),
	"{GROUPS_EDIT_CATS}" => $_lang['groups_Edit_Cats'],
	"{GROUPS_EDIT_CATS_CHECK}" => ($row['edit_Cat'] == 1 ? "checked" : ""),
	"{GROUPS_EDIT_SITES}" => $_lang['groups_Edit_Sites'],
	"{GROUPS_EDIT_SITES_NOTE}" => $_lang['groups_Edit_Sites_Note'],
	"{GROUPS_EDIT_SITES_CHECK}" => ($row['edit_Sites'] == 1 ? "checked" : ""),
	"{GROUPS_EDIT_BANNERS}" => $_lang['groups_Edit_Banners'],
	"{GROUPS_EDIT_BANNERS_NOTE}" => $_lang['groups_Edit_Banners_Note'],
	"{GROUPS_EDIT_BANNERS_CHECK}" => ($row['edit_Banners'] == 1 ? "checked" : ""),
	"{GROUPS_GLOBAL_REPORTS}" => $_lang['groups_Global_Reprts'],
	"{GROUPS_GLOBAL_REPORTS_CHECK}" => ($row['reports'] == 1 ? "checked" : ""),
	"{GROUPS_VIEW_RATIO}" => $_lang['groups_Ratio_Show'],
	"{GROUPS_VIEW_RATIO_V}" => $row['view_Ratio'],
	"{GROUPS_CLICK_RATIO}" => $_lang['groups_Ratio_Click'],
	"{GROUPS_CLICK_RATIO_V}" => $row['click_Ratio'],
	"{GROUPS_APP_DEFAULT}" => $_lang['groups_App_Default'],
	"{GROUPS_APP_DEFAULT_CHECK}" => ($row['def_Ad_State'] == 1 ? "checked" : ""),
	"{GROUPS_MAX_TEXTS}" => $_lang['groups_Max_Texts'],
	"{GROUPS_MAX_TEXTS_V}" => $row['max_Text_Ads'],
	"{GROUPS_MAX_IMGS}" => $_lang['groups_Max_Imgs'],
	"{GROUPS_MAX_IMG_V}" => $row['max_Img_Ads'],
	"{GROUPS_REST_CATS_S}" => $_lang['groups_Rest_Cats_S'],
	"{GROUPS_REST_CATS_S_CHECK}" => ($row['restrict_Cats_Shown'] == 1 ? "checked" : ""),
	"{GROUPS_REST_CATS_D}" => $_lang['groups_Rest_Cats_D'],
	"{GROUPS_REST_CATS_D_CHECK}" => ($row['restrict_Cats_Display'] == 1 ? "checked" : ""),
	"{GROUPS_REST_HOURS}" => $_lang['groups_Rest_Hours'],
	"{GROUPS_REST_HOURS_CHECK}" => ($row['restrict_Times'] == 1 ? "checked" : ""),
	"{GROUPS_ALLOWED_TYPES}" => $_lang['groups_Allowed_Types'],
	"{GROUPS_TYPES_JPG_CHECKED}" => (strpos($row['allow_Formats'], "jpg")               !== FALSE ? "checked" : ""),
	"{GROUPS_TYPES_GIF_CHECKED}" => (strpos($row['allow_Formats'], "gif")               !== FALSE ? "checked" : ""),
	"{GROUPS_TYPES_PNG_CHECKED}" => (strpos($row['allow_Formats'], "png")               !== FALSE ? "checked" : ""),
	"{GROUPS_TYPES_FLA_CHECKED}" => (strpos($row['allow_Formats'], "x-shockwave-flash") !== FALSE ? "checked" : ""),
	"{GROUPS_ID_GROUP}" => $row['id_Group'],
	"{GROUPS_SUBMIT}" => $_lang['groups_Submit']
);

$groups_Tpl->rBlock($a_Groups, "");
$groups_Tpl->localize_It($_lang);
include_once("./header.inc.php");
$groups_Tpl->print_Tpl();
include_once("./footer.inc.php");

?>
Return current item: Ads Exchange Server