<?php
/*======================================================================*\
|| #################################################################### ||
|| #                     الشامل اتلوين المجموعات                        ||
|| # ----------------------------------------------------------------   ||
|| #                          تطوير أبو راشد                            ||
|| #                      مشرف عام منتديات المودة                       ||
|| #            http://www.mwadah.com    mrs@mwadah.com                 ||
|| #################################################################### ||
\*======================================================================*/

// ########################################################################
// ######################### PRE-CACHE TEMPLATES AND DATA #################
// ########################################################################
define('THIS_SCRIPT', 'mwamwausergroupcolors');
$phrasegroups = array('style');
$specialtemplates = array('products');
$specialtemplates = array();

// ########################################################################
// ######################### SET PHP ENVIRONM ENT #########################
// ########################################################################
error_reporting(E_ALL & ~E_NOTICE);

// ########################################################################
// ######################### PRE-CACHE TEMPLATES AND DATA #################
// ########################################################################
$phrasegroups = array();
$specialtemplates = array();
$globaltemplates = array();
$actiontemplates = array();

// ########################################################################
// ######################### REQUIRE BACK-END #############################
// ########################################################################
require_once('./global.php');
require_once(DIR . '/includes/functions_file.php');
require_once(DIR . '/includes/adminfunctions_template.php');
print_cp_header('');

// ########################################################################
// ######################### function script  #############################
// ########################################################################
global $id;
function squreomwa($color)
{
         $open = '<input type="text" name="T1" style="'.$color.'" value="';
         $final = $open;
         return $final ;
}

function squrecmwa()
{
         $final = '</textarea>';
         return $final ;
}

// ########################################################################
// ######################### start script  ################################
// ########################################################################
print_description_row("$vbphrase[alchemy_display_func1]");
if ( empty($_REQUEST['do']) )
{
         print_cp_header($vbphrase['mwausergroupcolors']);
         print_form_header($vbphrase['mwausergroupcolors_g']);
         print_table_header($vbphrase['mwausergroupcolors_g'], 10);
         //print_description_row("$vbphrase[alchemy_display_func1]");
         print_cells_row(array(
                       $vbphrase['mwausergroupcolors_ug'],
                       $vbphrase['mwausergroupcolors_c'],
                       $vbphrase['mwausergroupcolors_xxx']
                       ), 1, 'tcat');
         //print_description_row("$vbphrase[alchemy_display_func2]");

         $usergroups = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "usergroup");
         while ($usergroup = $db->fetch_array($usergroups))
         {
	   $usergroup[opentag] = str_replace('mwaextrastatus/bak/', '../mwaextrastatus/bak/', $usergroup[opentag]);
         $cell = array();
         $cell[] = $usergroup[title];
         $cell[] = "$usergroup[opentag] $usergroup[title] $usergroup[closetag]";
         $cell[] = construct_button_code($vbphrase['mwausergroupcolors_x'], '?do=x&id='.$usergroup[usergroupid]);
         print_cells_row($cell);
         }
	   print_table_footer(4,construct_button_code('حذف التلوين من جميع المجموعات', '?do=xall').construct_button_code('تعديل الوان المجموعات', 'mwausergroupcolors.php?do=add&id=1'));
}
$action =$_GET['action'];
$id = $_GET['id'];

if ($_REQUEST['do'] == 'add')
{
$usergroups = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "usergroup where usergroupid =" .$id);
$usergroup = $db->fetch_array($usergroups);
	  echo '<script type="text/javascript" src="jscolor.js"></script>';
        echo '<form action="mwausergroupcolors.php" method="post">';
        echo '<input type="hidden" name="groupid" size="20"  value="'.$id.'">';
        echo '<input type="hidden" name="adminhash" value="' . ADMINHASH . '" />';
$id = $usergroup['usergroupid'] ;
$usergroups = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "usergroup where usergroupid =" .$id);
$usergroup = $db->fetch_array($usergroups);
print_form_header($vbphrase['mwausergroupcolors_g']);
print_table_header($vbphrase['mwausergroupcolors_cm']);
$usergroup[opentag] = str_replace('mwaextrastatus/bak/', '../mwaextrastatus/bak/', $usergroup[opentag]);

$mwacolorsel = "<SELECT id=sel_nlp_usertextformatting_background onchange=nlp_usertextformatting('set'); name=nlp_usertextformatting_background>
<OPTION style=' ' value=>بدون صورة خلفية</OPTION>
<OPTION selected style='BACKGROUND-COLOR: black' value=url(../mwaextrastatus/bak/1.png)>&nbsp;صورة رقم 1&nbsp;</OPTION>";
for ($i = 2; $i <= 422; $i++)
{
$mwacolorsel .= "<OPTION style='BACKGROUND-COLOR: black' value=url(../mwaextrastatus/bak/" . $i . ".png)>&nbsp;صورة رقم " . $i . "&nbsp;</OPTION>\n";
}
for ($i = 1; $i <= 165; $i++)
{
$ia = $i+422;
$mwacolorsel .= "<OPTION style='BACKGROUND-COLOR: black' value=url(../mwaextrastatus/bak/" . $i . ".gif)>&nbsp;صورة رقم " . $ia . "&nbsp;</OPTION>\n";
}
$mwacolorsel .= "</SELECT>";

print_description_row('<br /><br />
لون الخلفية : <input class="color {adjust:false}" id="sel_nlp_usertextformatting_background1" onchange="nlp_usertextformatting(\'set\');" name="nlp_usertextformatting_background1" value="FFFFFF">

<LABEL for=sel_nlp_usertextformatting_trans>بدون لون خلفية :</LABEL>

<INPUT id=sel_nlp_usertextformatting_trans onclick="nlp_usertextformatting(\'set\');" onchange="nlp_usertextformatting(\'set\');" value=1 CHECKED type=checkbox name=nlp_usertextformatting_trans>

<br><br>صورة الخلفية : ' . $mwacolorsel .'<br> 

<SCRIPT language=javascript type=text/javascript>
<!--
function nlp_usertextformatting(req) {
	var prefix = \'sel_nlp_usertextformatting_\';

	switch(req) {
		case \'color\':
			fetch_object(prefix + \'fontcolor\').style.backgroundColor = fetch_object(prefix + \'fontcolor\').value;
			nlp_usertextformatting(\'set\');
		break;
		case \'set\':
			fetch_object(prefix + \'preveiw\').style.padding = (fetch_object(prefix + \'padding\').value)+\' 0px 0px\';
			var mwatrans = fetch_object(prefix + \'trans\').checked;
			fetch_object(prefix + \'preveiw\').style.font = (fetch_object(prefix + \'fontweight\').checked == 1 ? \'bold\' : \'normal\') + \' \' + (fetch_object(prefix + \'fontsize\').value != -1 ? fetch_object(prefix + \'fontsize\').value : \'\') + \' \' + (fetch_object(prefix + \'fonttype\').value != -1 ? fetch_object(prefix + \'fonttype\').value : \'\');
			fetch_object(prefix + \'preveiw\').style.color = \'#\'+(fetch_object(prefix + \'fontcolor\').value != -1 ? fetch_object(prefix + \'fontcolor\').value : \'\');
			if (mwatrans)
			{
			var mwabackground = \'transparent \' + fetch_object(prefix + \'background\').value;
			fetch_object(prefix + \'preveiw\').style.background = mwabackground;
			} else {
			var mwabackground = fetch_object(prefix + \'background1\').value + \' \' + fetch_object(prefix + \'background\').value;
			fetch_object(prefix + \'preveiw\').style.background = \'#\'+mwabackground;
			}
			var mwaborder = fetch_object(prefix + \'border\').value + \' \' + fetch_object(prefix + \'borderkind\').value + \' #\' + fetch_object(prefix + \'bordercolor\').value;
			fetch_object(prefix + \'preveiw\').style.border = mwaborder;
			fetch_object(prefix + \'preveiw\').style.width = (fetch_object(prefix + \'width\').value != -1 ? fetch_object(prefix + \'width\').value : \'\');
			fetch_object(prefix + \'preveiw\').style.height = (fetch_object(prefix + \'height\').value != -1 ? fetch_object(prefix + \'height\').value : \'\');
			fetch_object(prefix + \'preveiw\').style.width1 = (fetch_object(prefix + \'width1\').value != -1 ? fetch_object(prefix + \'width1\').value : \'\');
			document.getElementById(\'sel_nlp_usertextformatting_preveiw\').value = \'منتديات المودة\';
		break;
	}
}
//-->
</SCRIPT>
<br />
نوع الخط :
<SELECT id=sel_nlp_usertextformatting_fonttype onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_fonttype>
<OPTION value=Times New Roman>إستخدام الإفتراضي</OPTION>
<OPTION selected value="Times New Roman">Times New Roman</OPTION>
<OPTION value="Microsoft Sans Serif">Microsoft Sans Serif</OPTION>
<OPTION value="Mudir MT">Mudir MT</OPTION>
<OPTION value="Arabic Transparent">Arabic Transparent</OPTION>
<OPTION value="Monotype Koufi">Monotype Koufi</OPTION>
<OPTION value="Traditional Arabic">Traditional Arabic</OPTION>
<OPTION value="MS Sans Serif">MS Sans Serif</OPTION>
<OPTION value=Arial>Arial</OPTION>
<OPTION value=Tahoma>Tahoma</OPTION>
<OPTION value="Trebuchet MS">Trebuchet MS</OPTION>
<OPTION value=Verdana>Verdana</OPTION>
<OPTION value="Comic Sans MS">Comic Sans MS</OPTION>
<OPTION value="Courier New">Courier New</OPTION>
</SELECT>

<LABEL for=sel_nlp_usertextformatting_fontweight>خط سميك :</LABEL>

<INPUT id=sel_nlp_usertextformatting_fontweight onclick="nlp_usertextformatting(\'set\');" onchange="nlp_usertextformatting(\'set\');" value=1 CHECKED type=checkbox name=nlp_usertextformatting_fontweight>

<br /><br />
حجم الخط :
<SELECT id=sel_nlp_usertextformatting_fontsize onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_fontsize>
<OPTION value=12pt>إستخدام الإفتراضي</OPTION>
<OPTION value=6pt>6pt</OPTION>
<OPTION value=8pt>8pt</OPTION>
<OPTION value=10pt>10pt</OPTION>
<OPTION selected value=12pt>12pt</OPTION>
<OPTION value=14pt>14pt</OPTION>
<OPTION value=16pt>16pt</OPTION>
<OPTION value=18pt>18pt</OPTION>
</SELECT>

<br /><br />
لون الكتابة : <input class="color" id="sel_nlp_usertextformatting_fontcolor" onchange="nlp_usertextformatting(\'color\');" name="nlp_usertextformatting_fontcolor" value="A50000">

<br /><br />
عرض الإطار :
<SELECT id=sel_nlp_usertextformatting_border onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_border>
<OPTION selected value=0>بدون إطار</OPTION>
<OPTION value=1px>1</OPTION>
<OPTION value=2px>2</OPTION>
<OPTION value=3px>3</OPTION>
<OPTION value=4px>4</OPTION>
<OPTION value=5px>5</OPTION>
<OPTION value=6px>6</OPTION>
<OPTION value=7px>7</OPTION>
<OPTION value=8px>8</OPTION>
</SELECT>
<br /><br />
نوع الإطار :
<SELECT id=sel_nlp_usertextformatting_borderkind onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_borderkind>
<OPTION selected value=solid>عادي</OPTION>
<OPTION value=dotted>منقط</OPTION>
<OPTION value=dashed>متقطع</OPTION>
<OPTION value=groove>محفور</OPTION>
<OPTION value=double>مزدوج</OPTION>
</SELECT>
<br /><br />
لون الإطار : <input class="color" id="sel_nlp_usertextformatting_bordercolor" onchange="nlp_usertextformatting(\'set\');" name="nlp_usertextformatting_bordercolor">

<br /><br />
العرض :
<SELECT id=sel_nlp_usertextformatting_width onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_width>
<OPTION value=50px>50</OPTION>
<OPTION value=60px>60</OPTION>
<OPTION value=70px>70</OPTION>
<OPTION value=80px>80</OPTION>
<OPTION value=90px>90</OPTION>
<OPTION value=100px>100</OPTION>
<OPTION value=101px>101</OPTION>
<OPTION value=102px>102</OPTION>
<OPTION value=103px>103</OPTION>
<OPTION value=104px>104</OPTION>
<OPTION value=105px>105</OPTION>
<OPTION value=106px>106</OPTION>
<OPTION value=107px>107</OPTION>
<OPTION value=108px>108</OPTION>
<OPTION value=109px>109</OPTION>
<OPTION selected value=110px>110</OPTION>
<OPTION value=111px>111</OPTION>
<OPTION value=112px>112</OPTION>
<OPTION value=113px>113</OPTION>
<OPTION value=114px>114</OPTION>
<OPTION value=115px>115</OPTION>
<OPTION value=120px>120</OPTION>
<OPTION value=130px>130</OPTION>
<OPTION value=140px>140</OPTION>
<OPTION value=150px>150</OPTION>
</SELECT>

<br /><br />
الإرتفاع :
<SELECT id=sel_nlp_usertextformatting_height onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_height>
<OPTION value=10px>10</OPTION>
<OPTION value=11px>11</OPTION>
<OPTION value=12px>12</OPTION>
<OPTION value=13px>13</OPTION>
<OPTION value=14px>14</OPTION>
<OPTION value=15px>15</OPTION>
<OPTION value=16px>16</OPTION>
<OPTION value=17px>17</OPTION>
<OPTION value=18px>18</OPTION>
<OPTION value=19px>19</OPTION>
<OPTION value=20px>20</OPTION>
<OPTION value=21px>21</OPTION>
<OPTION selected value=22px>22</OPTION>
<OPTION value=23px>23</OPTION>
<OPTION value=24px>24</OPTION>
<OPTION value=25px>25</OPTION>
<OPTION value=26px>26</OPTION>
<OPTION value=27px>27</OPTION>
<OPTION value=28px>28</OPTION>
<OPTION value=29px>29</OPTION>
<OPTION value=30px>30</OPTION>
<OPTION value=32px>32</OPTION>
<OPTION value=34px>34</OPTION>
<OPTION value=36px>36</OPTION>
<OPTION value=38px>38</OPTION>
<OPTION value=40px>40</OPTION>
</SELECT>
<br /><br />
الهامش العلوي :
<SELECT id=sel_nlp_usertextformatting_padding onchange="nlp_usertextformatting(\'set\');" name=nlp_usertextformatting_padding>
<OPTION value=0px>0</OPTION>
<OPTION value=1px>1</OPTION>
<OPTION selected value=2px>2</OPTION>
<OPTION value=3px>3</OPTION>
<OPTION value=4px>4</OPTION>
<OPTION value=5px>5</OPTION>
<OPTION value=6px>6</OPTION>
<OPTION value=7px>7</OPTION>
<OPTION value=8px>8</OPTION>
<OPTION value=9px>9</OPTION>
</SELECT>
<br /><br /><br /><br /><br /><br />
شكل التصميم الجديد : <textarea valign="middle" type="text" style="overflow:hidden; margin:1px; width1:55; text-align:center; width:110px; height:22px; FONT-SIZE:12pt; FONT-FAMILY: Times New Roman; COLOR: white; FONT-WEIGHT: bold; padding:2px;" id="sel_nlp_usertextformatting_preveiw" value="منتديات المودة" readonly>منتديات المودة</textarea>
<br /><br />

<script>
nlp_usertextformatting(\'set\');
function nlp_mwasave(mwareq)
{
var prefix = \'sel_nlp_usertextformatting_\';
var mwafontcolor = fetch_object(prefix + \'fontcolor\').value;
var mwafont = (fetch_object(prefix + \'fontweight\').checked == 1 ? \'bold\' : \'normal\') + \' \' + (fetch_object(prefix + \'fontsize\').value != -1 ? fetch_object(prefix + \'fontsize\').value : \'\') + \' \' + (fetch_object(prefix + \'fonttype\').value != -1 ? fetch_object(prefix + \'fonttype\').value : \'\');
var mwaborder = fetch_object(prefix + \'border\').value + \' \' + fetch_object(prefix + \'borderkind\').value + \'\' + fetch_object(prefix + \'bordercolor\').value;
var mwaborderrep = fetch_object(prefix + \'borderkind\').value;
var mwawidth = fetch_object(prefix + \'width\').value;
var mwaheight = fetch_object(prefix + \'height\').value;
var mwapadding = (fetch_object(prefix + \'padding\').value)+\' 0px 0px\';
var mwatrans = fetch_object(prefix + \'trans\').checked;
if (mwatrans)
{
var mwabackground = \'transparent \' + fetch_object(prefix + \'background\').value;
} else {
var mwabackground = fetch_object(prefix + \'background1\').value + \' \' + fetch_object(prefix + \'background\').value;
}
var mwaall = \'<textarea readonly valign="top" type="text" name="T1" style="overflow:hidden; box-sizing:content-box; -moz-box-sizing: content-box; -webkit-box-sizing:content-box; margin:1px; cursor:pointer; text-align:center; font:\'+mwafont+\'; padding:\'+mwapadding+\'; color:\'+mwafontcolor+\'; border:\'+mwaborder+\'; width:\'+mwawidth+\'; height:\'+mwaheight+\'; background:\'+mwabackground+\';">\';
var id = fetch_object(prefix + \'width1\').value;
//window.location = \'mwausergroupcolors.php?do=endmwa&id=\'+id+\'&color=\'+mwaall;
window.open(\'mwausergroupcolors.php?do=endmwa&id=\'+id+\'&color=\'+mwaall+\'&mwafontcolor=\'+mwafontcolor+\'&mwaborderrep=\'+mwaborderrep);
}
</script>

<br /><br /></center>
');
         $usergroups = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "usergroup");
	   $mwagroupssel = "<SELECT id=sel_nlp_usertextformatting_width1 onchange=nlp_usertextformatting(\'set\'); name=nlp_usertextformatting_width1>";
         while ($usergroup = $db->fetch_array($usergroups))
         {
	   $mwagroupssel .= "<OPTION selected value=".$usergroup[usergroupid].">".$usergroup[title]."</OPTION>";
         }
	   $mwagroupssel .= "</SELECT>";

print_description_row("<br><input type=hidden name=mwasgroupid size=10  value=99> المجموعة المطلوب تغيير لونها : $mwagroupssel <INPUT class=button onclick=javascript:nlp_mwasave($id) value='حفظ التصميم الجديد للمجموعة المختارة' type=button><INPUT class=button onclick=javascript:window.open('mwausergroupcolors.php'); value='مشاهدة وحذف الوان المجموعات' type=button><br><br>");


print_description_row('<script>
nlp_usertextformatting(\'set\');
</script>');
}

// do insert
if ($_REQUEST['do'] == 'endmwa')
{

      if($_REQUEST['id'] && $_REQUEST['color'])
      {
		$mwatagstart = $_REQUEST['color'];
		$mwatagstart = str_replace('../mwaextrastatus', 'mwaextrastatus', $mwatagstart);
		$mwasemp = "\'";
		$mwatagstart = str_replace('"', $mwasemp, $mwatagstart);
		$mwatagstart = str_replace('color:', 'color:#', $mwatagstart);
		$mwaborderrep = $_REQUEST['mwaborderrep'];
		$mwaborderrep1 = $mwaborderrep.' #';
		$mwatagstart = str_replace($mwaborderrep, $mwaborderrep1, $mwatagstart);
		if (!strpos ($mwatagstart, "background:transparent"))
		{
		$mwatagstart = str_replace('background:', 'background:#', $mwatagstart);
		}
		$mwatagend = squrecmwa();
		$mwatagend = str_replace('"', $mwasemp, $mwatagend);

		if ((strpos ($mwatagstart, "background:transparent ;")) and (strpos ($mwatagstart, "border:0")))
		{
		$mwatagstart = '<font color=#'.$_REQUEST['mwafontcolor'].'>';
		$mwatagend = '</font>';
		}
            $db->query_write("UPDATE " . TABLE_PREFIX . "usergroup SET opentag = '".$mwatagstart."', closetag = '".$mwatagend."' where usergroupid = '".$_REQUEST['id']."'");
            require_once(DIR . '/includes/functions_databuild.php');
            build_forum_permissions();
            print_cp_header($vbphrase['vbulletin_message']);
            print_form_header('', '', 0, 1, 'messageform', '50%');
            print_table_header($vbphrase['vbulletin_message']);
            print_description_row("<center>".$vbphrase['mwausergroupcolors_done']."</center>");
            print_table_footer(2, construct_button_code($vbphrase['go_back'], 'mwausergroupcolors.php'));
      }
}
if ($_REQUEST['do'] == 'x')
{
      if($_REQUEST['id'])
      {
            $db->query_write("UPDATE " . TABLE_PREFIX . "usergroup SET opentag = '', closetag = '' where usergroupid = '".$_REQUEST['id']."'");
            require_once(DIR . '/includes/functions_databuild.php');
            build_forum_permissions();
            print_cp_header($vbphrase['vbulletin_message']);
            print_form_header('', '', 0, 1, 'messageform', '50%');
            print_table_header($vbphrase['vbulletin_message']);
            print_description_row("<center>".$vbphrase['mwausergroupcolors_xx']."</center>");
            print_table_footer(2, construct_button_code($vbphrase['go_back'], 'mwausergroupcolors.php'));
      }
}

if ($_REQUEST['do'] == 'xall')
{
            $db->query_write("UPDATE " . TABLE_PREFIX . "usergroup SET opentag = '', closetag = ''");
            require_once(DIR . '/includes/functions_databuild.php');
            build_forum_permissions();
            print_cp_header($vbphrase['vbulletin_message']);
            print_form_header('', '', 0, 1, 'messageform', '50%');
            print_table_header($vbphrase['vbulletin_message']);
            print_description_row("<center>تم حذف التلوين من جميع المجموعات بنجاح</center>");
            print_table_footer(2, construct_button_code($vbphrase['go_back'], 'mwausergroupcolors.php'));
}

// ########################################################################
// ######################### footer #######################################
// ########################################################################

$mwausergroupcolors_ver = 2.0;
$mwausergroupcolors_useover_fontcolor = '#D04850';
function da_print_footer ()
{
       global $mwausergroupcolors_ver;
       echo '<p align="center"><a href="http://www.mwadah.com" target="_blank">الشامل لتلوين المجموعات الإصدار '.$mwausergroupcolors_ver.' بواسطة ابو راشد مشرف عام منتديات المودة </a>';
}

echo '<center><table><tr><td></p>';
echo '<br>';
echo '</td></tr></table></p>';
print_description_row("$vbphrase[alchemy_display_func2]");
da_print_footer();
print_cp_footer();

/*======================================================================*\
|| #################################################################### ||
|| #                     الشامل اتلوين المجموعات                        ||
|| # ----------------------------------------------------------------   ||
|| #                          تطوير أبو راشد                            ||
|| #                      مشرف عام منتديات المودة                       ||
|| #            http://www.mwadah.com    mrs@mwadah.com                 ||
|| #################################################################### ||
\*======================================================================*/
?>