Location: PHPKode > projects > PHP-PROXIMA > proximaXP790/admin/modules/layout.php
<?php
/************************************************************************/
/* PHP-PROXIMA                                                          */
/* Copyright (c) 2003-2004 by Roberto Beltrame                          */
/* mail:(hide@address.com)                                     */
/* http://www.php-proxima.com                                           */
/* <title>Proxima</title>                                               */
/************************************************************************/
/* based on:                                                            */
/* PHP-NUKE: Advanced Content Management System                         */
/* ============================================                         */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/************************************************************************/
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
global $prefix, $db;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT radminsuper FROM " . $prefix . "_authors WHERE aid='$aid'"));
if ($row['radminsuper'] == 1) {
$tipovisibility=0;
//-----------------------------------------------------
//--- menu
//-----------------------------------------------------
global $menu;
$menu="<div align=\"center\">[ 
<a href=\"admin.php?op=proxima_modules\">"._MODULELIST."</a> | 
<a href=\"admin.php?op=proxima_modules&amp;option=block\">"._MODBLOCKLIST."</a> | 
<a href=\"admin.php?op=proxima_newmodblock_create\">"._MODBLOCKCREATE."</a> | 
<a href=\"admin.php?op=Menu_javascript_list\">"._MENUBUILDER."</a>
 ]</div>";
//-----------------------------------------------------
//--- list all modules
//-----------------------------------------------------
function proxima_modules($option) {
global $prefix, $db, $multilingual;
proxima_insert_new_modules();
proxima_delete_old_modules();
include("header.php");
GraphicAdmin();
Opentable();
echo "<form action=\"admin.php\" method=\"post\">
<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"classTable\" align=\"center\" width=\"100%\">
<tr>
<td align=\"center\" class=\"classHeaderTR\">
	<b><img src=\"images/admin/module.gif\" border=\"0\" alt=\""._MODULES."\"  hspace=\"5\" vspace=\"5\">
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._TITLE."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._STATUS."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._WYSILOAD."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._VIEW."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._CENTRALCOLUMNS."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._PRIORITY."</b>
</td>
<td align=\"center\" class=\"classHeaderTR\">
	<b>"._FUNCTIONS."</b>
</td>
</tr>";
if ($option) {
echo "
<tr class=\"classFooterTR\">
<td align=\"center\">
	<img src=\"images/admin/addblock.gif\" border=\"0\" alt=\""._BLOCKS."\" hspace=\"5\" vspace=\"5\">
</td>
<td align=\"center\">
	<b>"._TITLE."</b>
</td>
<td align=\"center\">
	<b>"._STATUS."</b>
</td>
<td align=\"center\">
	<b>"._BLOCKORDER."</b>
</td>
<td align=\"center\">
	<b>"._VIEW."</b>
</td>
<td align=\"center\">
	<b>"._ACTION."</b>
</td>
<td align=\"center\">
	<b>"._LANGUAGE."</b>
</td>
<td align=\"center\">
	<b>"._FUNCTIONS."</b>
</td>
</tr>";
}

$query = "SELECT group_id,
       			 group_name
		  FROM ".$prefix."_users_group";
$resultgroup=$db->sql_query($query);
while( list($group_id, $group_name) = $db->sql_fetchrow($resultgroup)){
	$gruppo[$group_id] = $group_name;
}

$query = "SELECT *
		  FROM ".$prefix."_webpages
		  ORDER BY page_title";
$result = $db->sql_query($query);
while($page = $db->sql_fetchrow($result)) {
    if ($page['page_home'] == 1) {   
        $background = "class=\"classHeaderTR\"";
	} else {
		if (ereg("!",$page['page_title'])) {
			$background = "class=\"classFooterTD\"";
		} else {
        	$background = "class=\"classHeaderTD\"";
		}
    }
echo "
<tr>
<td align=\"center\" $background>";
if ($page['page_home'] == 0 && !ereg("!",$page['page_title'])) {
	echo "<a href=\"admin.php?op=proxima_home_module&pageid=".$page['page_id']."\"><img src=\"images/admin/putinhome-".$page['page_home'].".gif\" alt=\""._PUTINHOME."\" border=\"0\"></a>";
} else {
	echo "<img src=\"images/admin/putinhome-".$page['page_home'].".gif\" alt=\"\" border=\"0\">";
}
echo "</td>
<td $background>
".$page['page_id']." - <strong>".$page['page_title']."</strong><br><em>".$page['page_custom_title']."</em>
</td>  
<td $background align=\"center\">
	<a href=\"admin.php?op=proxima_module_status&amp;pageid=".$page['page_id']."&amp;status=".$page['page_status']."\"><img src=\"images/admin/active-".$page['page_status'].".gif\" border=\"0\" alt=\""._CHANGESTATUS."\"></a>
	<a href=\"admin.php?op=proxima_module_menu&amp;pageid=".$page['page_id']."&amp;status=".$page['page_inmenu']."\"><img src=\"images/admin/inmenu-".$page['page_inmenu'].".gif\" border=\"0\" alt=\""._CHANGEMENU."\"></a>
</td>
<td align=\"center\" $background>
	<a href=\"admin.php?op=proxima_module_wysiload&amp;pageid=".$page['page_id']."&amp;wysiload=".$page['page_wysiload']."\"><img src=\"images/admin/wysiwyg-".$page['page_wysiload'].".gif\" border=\"0\" alt=\""._CHANGEWYSIWYG."\"></a>
</td>  
<td align=\"center\" $background>";
visibility_mod($page, $option, $gruppo);
echo "</td>
<td align=\"center\" $background>
	<a href=\"admin.php?op=proxima_changecolumns&amp;pageid=".$page['page_id']."&amp;columns=".$page['page_block_center']."\"><img src=\"images/admin/bcenter-".$page['page_block_center'].".gif\" border=\"0\" alt=\""._CHANGECOLUMNS."\" hspace=\"5\"></a>
</td>
<td align=\"center\" $background>
	<a href=\"admin.php?op=proxima_changepriority&amp;pageid=".$page['page_id']."&amp;priority=".$page['page_mod_block']."\"><img src=\"images/admin/modblock-".$page['page_mod_block'].".gif\" border=\"0\" alt=\""._CHANGEPRIORITY."\" hspace=\"5\"></a>
</td>
<td align=\"center\" $background>
	<a href=\"admin.php?op=proxima_module_edit&pageid=".$page['page_id']."\"><img src=\"images/admin/editmodule.gif\" alt=\""._EDIT."\" border=\"0\" hspace=\"2\"></a>
	<a href=\"admin.php?op=proxima_blocks_associate&pageid=".$page['page_id']."\"><img src=\"images/admin/addblock.gif\" alt=\""._ADDBLOCK."\" border=\"0\" hspace=\"2\"></a>
</td>
</tr>";
$backgroundblock= "class=\"classData\"";
if ($option) {
$query1 = "SELECT *
           FROM ".$prefix."_webblocks 
		   WHERE ((page_id = '".$page['page_id']."'))  
		   ORDER BY block_position, block_weight";
$result1 = $db->sql_query($query1);
while($block = $db->sql_fetchrow($result1)) {
	$weight1 = $block['block_weight'] - 1;
	$weight3 = $block['block_weight'] + 1;
	$query = "SELECT block_id 
		      FROM ".$prefix."_webblocks 
	    	  WHERE page_id='".$page['page_id']."' 
			  AND block_weight='".$weight1."' 
			  AND block_position='".$block['block_position']."'";
	$res = $db->sql_query($query);
	list ($bid1) = $db->sql_fetchrow($res);
	$con1 = "$bid1";
	$query = "SELECT block_id
		      FROM ".$prefix."_webblocks 
			  WHERE page_id='".$page['page_id']."' 
			  AND block_weight='".$weight3."' 
			  AND block_position='".$block['block_position']."'";
	$res2 = $db->sql_query($query);
	list ($bid2) = $db->sql_fetchrow($res2);
	$con2 = "$bid2";
	echo "
<tr>
<td $backgroundblock align=\"right\">
	<a href=\"admin.php?op=proxima_blocks_position&amp;pageid=".$page['page_id']."&amp;blockid=".$block['block_id']."&amp;position=".$block['block_position']."\"><img src=\"images/admin/block-".$block['block_position'].".gif\" border=\"0\" alt=\""._SWITCHPOSITION."\" hspace=\"5\"></a>
</td>
<td $backgroundblock>
	<div align=\"left\">&nbsp;&nbsp;&nbsp;".$block['block_weight']."&nbsp;-&nbsp;<strong>".$block ['block_title']."</strong></div>";
	if ($block['block_file'] != "") {
		echo "<div align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[FILE:&nbsp;<em>".$block ['block_file']."</em>]</div>";
	} elseif ($block['block_url'] != "") {
		echo "<div align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[RSS:&nbsp;<em>".substr($block['block_url'],0,30)."...</em>]</div>";
	} else {
		echo "<div align=\"left\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[HTML]</div>";	
	}
echo "</td>
<td $backgroundblock align=\"center\">
<a href=\"admin.php?op=proxima_block_status&amp;pageid=".$page['page_id']."&amp;blockid=".$block['block_id']."&amp;status=".$block['block_status']."\"><img src=\"images/admin/active-".$block['block_status'].".gif\" border=\"0\" alt=\""._CHANGESTATUS."\"></a>
</td>
<td $backgroundblock align=\"center\">";
    if ($con1) { 
		echo "<a href=\"admin.php?op=proxima_blocks_order&amp;pageid=".$page['page_id']."&amp;weight=".$block['block_weight']."&amp;bidori=".$block['block_id']."&amp;weightrep=".$weight1."&amp;bidrep=".$con1."&amp;header=proxima_modules&amp;option=$option\"><img src=\"images/admin/block-arrow-up.gif\" border=\"0\" hspace=\"3\" alt=\""._CHANGEORDER."\"></a>";  
	}
    if ($con2) { 
		echo "<a href=\"admin.php?op=proxima_blocks_order&amp;pageid=".$page['page_id']."&amp;weight=".$block['block_weight']."&amp;bidori=".$block['block_id']."&amp;weightrep=".$weight3."&amp;bidrep=".$con2."&amp;header=proxima_modules&amp;option=$option\"><img src=\"images/admin/block-arrow-down.gif\" border=\"0\" hspace=\"3\" alt=\""._CHANGEORDER."\"></a>";  
	}
    echo "
</td>
<td $backgroundblock align=\"center\">";
visibility_block($page, $block, $option, $gruppo);
echo "
</td>
<td $backgroundblock align=\"center\">";
	if ($block['block_expire']>0) {
	$expire = number_format((ceil(($block['block_expire'] - time()) / 3600)/24),1,',','.');
		echo "[$expire]&nbsp;<a href=\"admin.php?op=proxima_block_action&amp;pageid=".$page['page_id']."&amp;blockid=".$block['block_id']."&amp;action=".$block['block_action']."\"><img src=\"images/admin/expire-".$block['block_action'].".gif\" border=\"0\" alt=\""._CHANGEACTION."\" align=\"absmiddle\"></a>";
	}
echo "
</td>
<td $backgroundblock align=\"center\">
	<img src=\"images/language/flag-".$block['block_language'].".png\" border=\"0\" alt=\""._LANGUAGE."\" align=\"absmiddle\">
</td>
<td $backgroundblock align=\"center\">
	<a href=\"admin.php?op=proxima_blocks_edit&amp;pageid=".$page['page_id']."&amp;blockid=".$block['block_id']."\"><img src=\"images/admin/editblock.gif\" alt=\""._EDIT."\"hspace=\"2\" border=\"0\" align=\"absmiddle\"></a>
	<a href=\"admin.php?op=proxima_blocks_delete&pageid=".$page['page_id']."&blockid=".$block['block_id']."&amp;option=block\"><img src=\"images/admin/delete.gif\" alt=\""._DELETE."\"hspace=\"2\" border=\"0\" align=\"absmiddle\"></a>

</td>
";
}
}
}
echo "
</tr></table>";
Closetable();
proxima_legend();
}
//-----------------------------------------------------
//--- vibility modules
//-----------------------------------------------------
function visibility_mod($page, $option, $gruppo) {
global $prefix, $db, $tipovisibility;
if ($tipovisibility==1) {
	echo "
	<div align=\"left\">"._GROUP_FROM."&nbsp;&nbsp;<a href=\"admin.php?op=proxima_changeviewfrom&amp;pageid=".$page['page_id']."&amp;viewfrom=".$page['viewfrom']."&amp;viewto=".$page['viewto']."&amp;table=webpages&amp;option=$option\">[".$gruppo[$page['viewfrom']]."]</a></div>
    <div align=\"right\">"._GROUP_TO."&nbsp;&nbsp; <a href=\"admin.php?op=proxima_changeviewto&amp;pageid=".$page['page_id']."&amp;viewfrom=".$page['viewfrom']."&amp;viewto=".$page['viewto']."&amp;table=webpages&amp;option=$option\">[".$gruppo[$page['viewto']]."]</a></div>";
	return $page;
} else {
	$usergroupmod=array(0=>"". _MVALL ."",1=>"". _MVUSERS ."", 2=>"". _MVADMIN ."", 3=>"". _SUBUSERS ."");
	echo "
	<div align=\"left\">[<a href=\"admin.php?op=proxima_changeviewmod&amp;pageid=".$page['page_id']."&amp;viewfrom=".$page['viewfrom']."&amp;viewto=".$page['viewto']."&amp;table=webpages&amp;option=$option\">".$usergroupmod[$page['viewfrom']]."</a>]</div>
    <div align=\"right\">[<a href=\"admin.php?op=proxima_changeviewmodgroup&amp;pageid=".$page['page_id']."&amp;viewto=".$page['viewto']."\">";
 	if ($page['viewto'] != 0 && $page['viewfrom'] == 1) {
		$query = "SELECT name 
			      FROM ".$prefix."_groups 
				  WHERE id='".$page['viewto']."'";
		$result = $db->sql_query($query);
	    $grp = $db->sql_fetchrow($result);
	    $mod_group = $grp['name'];
	} else {
	    $mod_group = _NONEGROUP;
	}
 	echo "".$mod_group."</a>]</div>";
}
}
//-----------------------------------------------------
//--- vibility block
//-----------------------------------------------------
function visibility_block($page,$block, $option, $gruppo) {
global $prefix, $db, $tipovisibility;
if ($tipovisibility==1) {
	echo "
    <div align=\"left\">"._GROUP_FROM."&nbsp;&nbsp;<a href=\"admin.php?op=proxima_changeviewfrom&amp;pageid=".$block['block_id']."&amp;viewfrom=".$block['viewfrom']."&amp;viewto=".$block['viewto']."&amp;table=webpages&amp;option=$option\">[".$gruppo[$block['viewfrom']]."]</a></div>
    <div align=\"right\">"._GROUP_TO."&nbsp;&nbsp;  <a href=\"admin.php?op=proxima_changeviewto&amp;pageid=".$block['block_id']."&amp;viewfrom=".$block['viewfrom']."&amp;viewto=".$block['viewto']."&amp;table=webpages&amp;option=$option\">[".$gruppo[$block['viewto']]."]</a></div>";
	return $block;
} else {
	$usergroupblock=array(0=>""._MVALL."",1=>""._MVUSERS."", 2=>""._MVADMIN."", 3=>""._MVANON."");
	echo "<div align=\"left\">[".$usergroupblock[$block['viewfrom']]."]</div>
	<div align=\"right\"></div>";
}
}
//-----------------------------------------------------
//--- legenda
//-----------------------------------------------------
function proxima_legend() {
echo "<br>";
Opentable();
echo "<table border=\"1\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" align=\"left\" width=\"100%\"><tr>
<td align=\"left\" width=\"20%\">"._STATUS."</td>
<td align=\"left\" width=\"80%\">
<img src=\"images/admin/active-1.gif\" align=\"absmiddle\" >: "._ACTIVE." &nbsp;&nbsp;
<img src=\"images/admin/active-0.gif\" align=\"absmiddle\" >: "._INACTIVE." &nbsp;&nbsp;
<img src=\"images/admin/inmenu-1.gif\" align=\"absmiddle\" >: "._VISIBLE." &nbsp;&nbsp;
<img src=\"images/admin/inmenu-0.gif\" align=\"absmiddle\" >: "._INVISIBLE." &nbsp;&nbsp;
</tr><tr>
<td align=\"left\" width=\"10%\">"._CENTRALCOLUMNS."</td>
<td align=\"left\" width=\"90%\">
<img src=\"images/admin/bcenter-1.gif\" align=\"absmiddle\" >: 1 col &nbsp;
<img src=\"images/admin/bcenter-2.gif\" align=\"absmiddle\" >: 2 cols &nbsp;
<img src=\"images/admin/bcenter-3.gif\" align=\"absmiddle\" >: 3 cols &nbsp;
<img src=\"images/admin/bcenter-4.gif\" align=\"absmiddle\" >: 4 cols &nbsp;
</tr><tr>
<td align=\"left\" width=\"10%\">"._PRIORITY."</td>
<td align=\"left\" width=\"90%\">
<img src=\"images/admin/modblock-0.gif\" align=\"absmiddle\" >: "._MODBLOCK."&nbsp;&nbsp;
<img src=\"images/admin/modblock-1.gif\" align=\"absmiddle\" >: "._BLOCKMOD."
</td>
</tr>
<tr>
<td align=\"left\" width=\"10%\">Editor&nbsp;"._WYSILOAD."</td>
<td align=\"left\" width=\"90%\">
<img src=\"images/admin/wysiwyg-0.gif\" align=\"absmiddle\" >: "._INACTIVE."&nbsp;&nbsp;
<img src=\"images/admin/wysiwyg-1.gif\" align=\"absmiddle\" >: "._ACTIVE."
</td>
</tr>
<tr>
<td align=\"left\" width=\"10%\">"._EXPIRE."</td>
<td align=\"left\" width=\"90%\">
[4]: "._DAYTOEXPIRE."&nbsp;&nbsp;
<img src=\"images/admin/expire-d.gif\" align=\"absmiddle\">: "._INACTIVETOEXPIRE."&nbsp;&nbsp;
<img src=\"images/admin/expire-r.gif\" align=\"absmiddle\">: "._DELETETOEXPIRE."
</td>
</tr>
<tr>
<td align=\"left\" width=\"10%\">"._FUNCTIONS."</td>
<td align=\"left\" width=\"90%\">
<img src=\"images/admin/editmodule.gif\" align=\"absmiddle\">: "._EDIT." "._MODULES."&nbsp;&nbsp;
<img src=\"images/admin/editblock.gif\" align=\"absmiddle\">: "._EDIT." "._BLOCKS."&nbsp;&nbsp;
<img src=\"images/admin/addblock.gif\" align=\"absmiddle\">: "._ADDBLOCK."&nbsp;&nbsp;
<img src=\"images/admin/delete.gif\" align=\"absmiddle\">: "._DELETE."
</td>
</tr>
</table>";
Closetable();
echo "<div align=\"left\">";copyright($proxima); echo "</div>";
include("footer.php");
}
//-----------------------------------------------------
//--- change homepage
//-----------------------------------------------------
function proxima_home_module($pageid) {
global $prefix, $db;
	$query = "SELECT MIN(group_id), MAX(group_id) 
	          FROM ".$prefix."_users_group";
	$result = $db->sql_query($query);
	list($viewmin,$viewmax) = $db->sql_fetchrow($result);
	$query = "UPDATE ".$prefix."_webpages 
	          SET page_home='0'";
	$result = $db->sql_query($query);
	$query = "UPDATE ".$prefix."_webpages 
	          SET page_status='1', page_home='1', page_inmenu='1', viewfrom='".$viewmin."', viewto='".$viewmax."' 
			  WHERE page_id='".$pageid."'";
	$result = $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- activate/deactivate module
//-----------------------------------------------------
function proxima_module_status() {
	$pageid  = $_GET['pageid'];
	$status  = $_GET['status'];
    global $prefix, $db;
	if ($status == 1 ) {
		$query = "SELECT page_home, page_inmenu 
	          FROM ".$prefix."_webpages
			  WHERE page_id='".$pageid."'";
		$result = $db->sql_query($query);
		list($pagehome,$pagemenu) = $db->sql_fetchrow($result);
		if ($pagehome == 0) {
			$query = "UPDATE ".$prefix."_webpages 
					  SET page_status='0',page_inmenu='0' 
					  WHERE page_id='".$pageid."'";
		}
	} elseif ($status == 0 )  { 
		$query = "UPDATE ".$prefix."_webpages 
				  SET page_status='1'
				  WHERE page_id='".$pageid."'";
	}
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- activate/deactivate $wiswisig editor
//-----------------------------------------------------
function proxima_module_wysiload() {
	$pageid  = $_GET['pageid'];
	$wysiload  = $_GET['wysiload'];
    global $prefix, $db;
	if ($wysiload == 1 ) {
		$query = "UPDATE ".$prefix."_webpages 
				  SET page_wysiload='0' 
				  WHERE page_id='".$pageid."'";
	} elseif ($wysiload == 0 )  { 
		$query = "UPDATE ".$prefix."_webpages 
				  SET page_wysiload='1'
				  WHERE page_id='".$pageid."'";
	}
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- activate/deactivate block
//-----------------------------------------------------
function proxima_block_status() {
    global $prefix, $db;
	$pageid  = $_GET['pageid'];
	$blockid = $_GET['blockid'];
	$status  = $_GET['status'];
	if ($status == 1 ) { 
		$query = "UPDATE ".$prefix."_webblocks 
				  SET block_status='0' 
				  WHERE page_id='".$pageid."'
				  AND block_id = ".$blockid."";
	} elseif ($status == 0 )  { 
		$query = "UPDATE ".$prefix."_webblocks 
				  SET block_status='1'
				  WHERE page_id='".$pageid."'
				  AND block_id = ".$blockid."";
	}
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules&option=block");
}
//-----------------------------------------------------
//--- change action (deactivate/delete)
//-----------------------------------------------------
function proxima_block_action() {
    global $prefix, $db;
	$pageid  = $_GET['pageid'];
	$blockid = $_GET['blockid'];
	$action  = $_GET['action'];
	if ($action == 'r' ) { 
		$query = "UPDATE ".$prefix."_webblocks 
				  SET block_action='d' 
				  WHERE page_id='".$pageid."'
				  AND block_id = ".$blockid."";
	} elseif ($action == 'd' )  { 
		$query = "UPDATE ".$prefix."_webblocks 
				  SET block_action='r'
				  WHERE page_id='".$pageid."'
				  AND block_id = ".$blockid."";
	}
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules&option=block");
}
//-----------------------------------------------------
//--- show module in menu
//-----------------------------------------------------
function proxima_module_menu($pageid, $status) {
    global $prefix, $db;
	if ($status == 1 ) { 
		$query = "UPDATE ".$prefix."_webpages 
				  SET page_inmenu='0' 
				  WHERE page_id='".$pageid."'";
	} elseif ($status == 0 )  { 
		$query = "UPDATE ".$prefix."_webpages 
				  SET page_inmenu='1', page_status='1'
				  WHERE page_id='".$pageid."'";
	}
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- change number of central columns
//-----------------------------------------------------
function proxima_changecolumns($pageid, $columns) {
    global $prefix, $db;
	switch ($columns) {
		case 0: $new_cols=1; break;
		case 1: $new_cols=2; break;
		case 2: $new_cols=3; break;
		case 3: $new_cols=4; break;
		case 4: $new_cols=1; break;
	}
	$query = "UPDATE ".$prefix."_webpages 
		      SET page_block_center='".$new_cols."' 
		      WHERE page_id='".$pageid."'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- change order modules/blocks
//-----------------------------------------------------
function proxima_changepriority($pageid, $priority) {
    global $prefix, $db;
	if ($priority == 1) { $new_blockmod = 0; } else { $new_blockmod = 1; }
    $query = "UPDATE ".$prefix."_webpages
		      SET page_mod_block='".$new_blockmod."' 
		      WHERE page_id='".$pageid."'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- change block position
//-----------------------------------------------------
function proxima_blocks_position($pageid, $blockid, $position) {
    global $prefix, $db;
	switch ($position) {
		case "l":
		$new_position = "c";
		break;
		case "c":
		$new_position = "r";
		break;
		case "r":
		$new_position = "x";
		break;
		case "x":
		$new_position = "a";
		break;
		case "a":
		$new_position = "l";
		break;
	}
    $query = "UPDATE ".$prefix."_webblocks
		      SET block_position='".$new_position."' 
		      WHERE page_id='".$pageid."'
			  AND block_id='".$blockid."'";
    $db->sql_query($query);
	proxima_fixweight($pageid);
    Header("Location: admin.php?op=proxima_modules&option=block");
}
//-----------------------------------------------------
//--- change permissions viewfrom
//-----------------------------------------------------
function proxima_changeviewfrom($pageid, $blockid="", $viewfrom, $viewto, $table, $option) {
    global $prefix, $db;
	$query = "SELECT MIN(group_id), MAX(group_id) 
	          FROM ".$prefix."_users_group";
	$result = $db->sql_query($query);
	list($viewmin,$viewmax) = $db->sql_fetchrow($result);
	$new_viewfrom = $viewfrom+1;    $new_viewto = $viewto;
	if ($new_viewfrom > $viewmax) { $new_viewfrom = $viewmin; }
	if ($new_viewfrom > $viewto ) { $new_viewto = $new_viewfrom; }
	if ($blockid) { $queryblock = "AND block_id='".$blockid."'";}
	$query = "UPDATE ".$prefix."_".$table." 
		      SET viewfrom='".$new_viewfrom."',	viewto='".$new_viewto."'
		      WHERE page_id='".$pageid."' $queryblock";
    $db->sql_query($query);
	$query = "UPDATE ".$prefix."_webpages 
		      SET viewfrom='".$viewmin."', viewto='".$viewmax."'
		      WHERE page_home='1'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules&option=$option");
}
//-----------------------------------------------------
//--- change permissions viewto
//-----------------------------------------------------
function proxima_changeviewto($pageid, $blockid="", $viewfrom, $viewto, $table, $option) {
    global $prefix, $db;
	$query = "SELECT MIN(group_id), MAX(group_id) 
	          FROM ".$prefix."_users_group";
	$result = $db->sql_query($query);
	list($viewmin,$viewmax) = $db->sql_fetchrow($result);
	$new_viewto = $viewto+1;
	if ($new_viewto > $viewmax) { $new_viewto = $viewfrom; }
	if ($blockid) { $queryblock = "AND block_id='".$blockid."'";}
	$query = "UPDATE ".$prefix."_".$table." 
		      SET viewto='".$new_viewto."' 
		      WHERE page_id='".$pageid."' $queryblock";
    $db->sql_query($query);
	$query = "UPDATE ".$prefix."_webpages 
		      SET viewfrom='".$viewmin."', viewto='".$viewmax."'
		      WHERE page_home='1'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules&option=$option");
}
//-----------------------------------------------------
//--- change permissions standard modules
//-----------------------------------------------------
function proxima_changeviewmod($pageid, $blockid="", $viewfrom, $viewto, $table, $option) {
    global $prefix, $db;
	$viewmin=0; $viewmax=3;
	$new_viewfrom = $viewfrom+1;    $new_viewto = $viewto;
	if ($new_viewfrom > $viewmax) { $new_viewfrom = $viewmin; }
	if ($new_viewfrom > $viewto ) { $new_viewto = $new_viewfrom; }
	if ($blockid) { $queryblock = "AND block_id='".$blockid."'";}
	$query = "UPDATE ".$prefix."_".$table." 
		      SET viewfrom='".$new_viewfrom."',	viewto='".$new_viewto."'
		      WHERE page_id='".$pageid."' $queryblock";
    $db->sql_query($query);
	$query = "UPDATE ".$prefix."_webpages 
		      SET viewfrom='".$viewmin."'
		      WHERE page_home='1'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules&option=$option");
}
//-----------------------------------------------------
//--- change permissions modules group
//-----------------------------------------------------
function proxima_changeviewmodgroup($pageid, $viewto) {
    global $prefix, $db;
	$query = "SELECT MIN(id), MAX(id) 
	          FROM ".$prefix."_groups";
	$result = $db->sql_query($query);
	list($viewmin,$viewmax) = $db->sql_fetchrow($result);
	if ($viewto==0) { $viewto=1; }
	$new_viewto = $viewto+1;
	if ($new_viewto > $viewmax) { $new_viewto = $viewmin; }
	$query = "UPDATE ".$prefix."_webpages 
		      SET viewto='".$new_viewto."' 
		      WHERE page_id='".$pageid."'";
    $db->sql_query($query);
    Header("Location: admin.php?op=proxima_modules");
}
//-----------------------------------------------------
//--- change block order
//-----------------------------------------------------
function proxima_blocks_order ($pageid, $weightrep, $weight, $bidrep, $bidori, $header, $option) {
    global $prefix, $db;
	$query = "UPDATE ".$prefix."_webblocks 
	          SET block_weight='$weight' 
			  WHERE page_id='".$pageid."' 
			  AND block_id='".$bidrep."'";
    $result = $db->sql_query($query);
	$query = "UPDATE ".$prefix."_webblocks 
	          SET block_weight='$weightrep' 
			  WHERE page_id='".$pageid."' 
			  AND block_id='".$bidori."'";
    $result2 = $db->sql_query($query);
	$query = "ALTER TABLE ".$prefix."_webblocks 
	          ORDER by page_id, block_id";
    $result = $db->sql_query($query);
	proxima_fixweight($pageid);
    Header("Location: admin.php?op=".$header."&option=$option");
}
//-----------------------------------------------------
//--- show preview block
//-----------------------------------------------------
function proxima_block_show($pageid,$blockid) {
    global $prefix, $db;
	$query = "SELECT * 
	          FROM ".$prefix."_webblocks 
			  WHERE page_id='".$pageid."' 
			  AND blockid='".$blockid."'";
    $result = $db->sql_query($query);
    list($block) = $db->sql_fetchrow($result);
    include("header.php");
        Opentable();
	if ($block['block_content'] != "") {
    	echo "
		<table cellspacing=\"2\" cellpadding=\"2\" border=\"0\">
        <tr><td widht=33%></td><td widht=33%>
        ".$block['title']."<br><br>".$block['block_content']."<br>
        </td><td widht=33%></td></tr></table>";
	}
	if ($block['block_file'] != "") {
    	$file = @file("blocks/".$block['block_file']."");
        include("blocks/".$block['block_file']."");
    	$image = ereg_replace("_", "_", "".$block['block_file']."");
        $image = str_replace(".php",".gif","$image");
    	echo "<table cellspacing=\"2\" cellpadding=\"2\" border=\"0\">
    	<tr><td widht=33%></td><td widht=33%>
    	".$block['title']."<br><br>".$block['block_content']."<br>
    	</td><td widht=33%></td></tr></table>";
	}
    Closetable();
    echo "
	<div align=\"center\"><br><br>
    [ <a href=\"admin.php?op=proxima_blocks_associate&pageid=".$pageid."\">Back</a> ]
    </div><br>";
    include("footer.php");
}
//-----------------------------------------------------
//--- delete blocks
//-----------------------------------------------------
function proxima_blocks_delete() {
    global $prefix, $db;
	$pageid  = $_GET['pageid'];
	$blockid = $_GET['blockid'];
	$option  = $_GET['option'];
		$query = "SELECT position, weight 
	    	      FROM ".$prefix."_webblocks 
				  WHERE page_id='".$pageid."' 
			  	AND block_id='".$blockid."'";
	    $result = $db->sql_query($query);
    	list($position, $weight) = $db->sql_fetchrow($result);
	    $query = "SELECT block_id 
		          FROM ".$prefix."_webblocks 
				  WHERE page_id='".$pageid."' 
				  AND weight>'".$weight."' 
				  AND position='".$position."'";
    	$result = $db->sql_query($query);
	    while (list($nbid) = $db->sql_fetchrow($result)) {
			$query = "UPDATE ".$prefix."_webblocks 
			          SET weight='".$weight."' 
					  WHERE page_id='".$pageid."' 
					  AND block_id='".$nbid."'";
	    	$db->sql_query($query);
    	    $weight++;
	    }
    	$query = "DELETE FROM ".$prefix."_webblocks 
	    	      WHERE page_id='".$pageid."' 
				  AND block_id='".$blockid."'";
		$db->sql_query($query);
		$query = "ALTER TABLE ".$prefix."_webblocks 
	    	      ORDER by page_id, block_id";
	    $result = $db->sql_query($query);
		proxima_fixweight($pageid);
    Header("Location: admin.php?op=proxima_modules&option=$option");
}
//-----------------------------------------------------
//--- block fix weight
//-----------------------------------------------------
function proxima_fixweight($pageid) {
global $prefix, $db;
$blockpos=array(0=>"l",	1=>"c",	2=>"r",	3=>"a",	4=>"x");
for ($x=0; $x<5; $x++) {
	$query = "SELECT block_id 
	          FROM ".$prefix."_webblocks 
			  WHERE page_id='".$pageid."' 
			  AND block_position='".$blockpos[$x]."' 
		      ORDER by block_weight ASC";
	$result = $db->sql_query($query);
    $weight = 0;
    while(list($blockid) = $db->sql_fetchrow($result)) {
        $weight++;
		$query = "UPDATE ".$prefix."_webblocks 
		          SET block_weight='".$weight."' 
				  WHERE page_id='".$pageid."' 
				  AND block_id='".$blockid."'
				  AND block_position='".$blockpos[$x]."'";
        $db->sql_query($query);
    }
}
	$query = "ALTER TABLE ".$prefix."_webblocks 
	          ORDER by page_id, block_id";
    $result = $db->sql_query($query);
return;
}
//-----------------------------------------------------
//--- RSS fail
//-----------------------------------------------------
function proxima_rssfail() {
    include("header.php");
    GraphicAdmin();
    Opentable();
    echo "<div align=\"center\"><b>"._BLOCKSADMIN."</b></div>";
    Closetable();
    echo "<br>";
    Opentable();
    echo "<div align=\"center\"><b>"._RSSFAIL."</b><br><br>"
        .""._RSSTRYAGAIN."<br><br>"
        .""._GOBACK."</div>";
    Closetable();
    include("footer.php");
    die;
}
//-----------------------------------------------------
//  edit module
//-----------------------------------------------------
function proxima_module_edit($pageid) {
global $prefix, $db, $multilingual, $currentlang, $noHtmlEditor, $tipovisibility;
$noHtmlEditor=1;
include("header.php");
GraphicAdmin();
Opentable();
$query = "SELECT * 
		  FROM ".$prefix."_webpages
		  WHERE page_id = '".$pageid."';";
$result = $db->sql_query($query);
$pageEdit = $db->sql_fetchrow($result);
echo "
<form action=\"admin.php\" method=\"post\">
<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._MID."</td>
<td class=\"classData\">
	<input type=\"text\" name=\"pageid\" value=\"".$pageEdit['page_id']."\" size=\"5\" readonly>&nbsp;</strong>
	<input type=\"text\" name=\"pageid\" value=\"".$pageEdit['page_title']."\" size=\"40\" readonly></strong>&nbsp;&nbsp;
	<a href=\"admin.php?op=proxima_blocks_associate&pageid=".$pageEdit['page_id']."\"><img src=\"images/admin/addblock.gif\" alt=\""._ADDBLOCK."\" border=\"0\" hspace=\"2\"></a>
</td>
</tr>";
//--- nome modulo personalizzato -------------------------//
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._CUSTOMMODNAME."</td>
<td class=\"classData\"><input type=\"text\" name=\"pageEdit[2]\" value=\"".$pageEdit[2]."\" size=\"49\"></td>
</tr>";
//--- scelta 1 o 2 colonne per blocchi centrali ----------//
$modcenter=array(1=>"1 col",2=>"2 col",3=>"3 col",4=>"4 col");
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._LAYOUTCENTERBLOCK."</td>
<td class=\"classData\"><select name=\"pageEdit[8]\">";
for ($i=1; $i<5; $i++) {
	if ($pageEdit[8]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$modcenter[$i]."</option>";
}
echo "</select></td></tr>";
//--- scelta blocchi o moduli prima ------------------------//
$modorblock=array(0=>"mod-block",1=>"block-mod");
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._LAYOUTMODBLOCK."</td>
<td class=\"classData\"><select name=\"pageEdit[9]\">";
for ($i=0; $i<2; $i++) {
	if ($pageEdit[9]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$modorblock[$i]."</option>";
}
echo "</select></td></tr>";
//--- scelta visibilità utenti -------------------------//
	echo "
	<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._VIEWPRIV."</td>";
if ($tipovisibility==1) {
	echo "
	<td align=\"left\" class=\"classData\">da  
	<select name=\"pageEdit[6]\">";
	$query = "SELECT * 
	          FROM ".$prefix."_users_group 
			  ORDER BY group_id ASC";
	$result=$db->sql_query($query);
	while ($group = $db->sql_fetchrow($result)) {
		if ($pageEdit[6]==$group['group_id']) { $sel="selected"; } else {$sel="";}
		echo "<option value=".$group['group_id']." $sel>".$group['group_name']."</option>";
	}
		echo "</select> a...
	<select name=\"pageEdit[7]\">";
	$query = "SELECT * 
	          FROM ".$prefix."_users_group 
			  ORDER BY group_id DESC";
	$result=$db->sql_query($query);
	while ($group = $db->sql_fetchrow($result)) {
			if ($pageEdit[7]==$group['group_id']) { $sel="selected"; } else {$sel="";}
			echo "<option value=".$group['group_id']." $sel>".$group['group_name']."</option>";
	}
		echo "</select>";
echo "</td>";
} else {
	$usergroup=array(0=>"". _MVALL ."",1=>"" . _MVUSERS . "", 2=>"" . _MVADMIN . "", 3=>"" . _SUBUSERS . "");
	echo "
	<td align=\"left\" class=\"classData\">";
	echo "<select name=\"pageEdit[6]\">";
	for ($i=0; $i<5; $i++) {
		if ($pageEdit[6]==$i) { $sel="selected"; } else {$sel="";}
		echo "<option value=\"$i\" $sel>".$usergroup[$i]."</option>";
	}
	echo "</select>";
	$numrow = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_groups"));
	if ($numrow > 0) {
	    echo "&nbsp;&nbsp;"._UGROUP."&nbsp;<select name=\"pageEdit[7]\">";
        $result2 = $db->sql_query("SELECT id, name FROM " . $prefix . "_groups");
        while ($row2 = $db->sql_fetchrow($result2)) {
			if ($row2['id'] == $pageEdit[7]) { 
				$gsel = "selected"; 
			} else { 
				$gsel = ""; 
			}
			if ($dummy != 1) {
		    	if ($page['viewto'] == 0) { 
					$ggsel = "selected"; 
				} else { 
					$ggsel = ""; 
				}
		    	echo "<option value=\"0\" $ggsel>"._NONE."</option>";
		    	$dummy = 1;
			}
			echo "<option value=\"$row2[id]\" $gsel>$row2[name]</option>";
			$gsel = "";
	    }
	    echo "</select>&nbsp;<i>("._VALIDIFREG.")</i></td></tr>";
	} else {
	    echo "<input type=\"hidden\" name=\"pageEdit[7]\" value=\"0\">";
	}
}
echo "</td></tr>";
//--- scelta visibilità in menu -------------------------//
$visinmenu=array(0=>""._NO."",1=>""._YES."");
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._SHOWINMENU."</td>
<td class=\"classData\"><select name=\"pageEdit[5]\">";
for ($i=0; $i<2; $i++) {
	if ($pageEdit[5]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$visinmenu[$i]."</option>";
}
echo "</select></td></tr>";
//--- scelta attivo/disattivo ----------------------------//
$doactive=array(0=>""._NO."",1=>""._YES."");
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._ACTIVE."</td>
<td class=\"classData\">
<select name=\"pageEdit[4]\">";
for ($i=0; $i<2; $i++) {
	if ($pageEdit[4]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$doactive[$i]."</option>";
}
echo "</select></td></tr>";
//--- scelta abilitazione wysiload -------------------------//
$wysiloadactive=array(0=>""._NO."",1=>""._YES."");
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._ACTIVEWYSILOAD."</td>
<td class=\"classData\"><select name=\"pageEdit[10]\">";
for ($i=0; $i<2; $i++) {
	if ($pageEdit[10]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$wysiloadactive[$i]."</option>";
}
echo "</select></td></tr>";
//--- scelta tipo titolo modulo -------------------------//
$modtitle=array(0=>""._HEADERNULL."",1=>""._HEADERONLYTEXT."",2=>""._HEADERONLYIMGBCK."",3=>""._HEADERTEXTIMGBCK."",4=>""._HEADERTEXTIMG."", 5=>""._HEADERTEXTIMGSAME."",6=>""._HEADERCSS.""  ,7=>""._HEADERDYNTEXT.""  );
echo "
<tr><td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">"._HEADERMODULE."</td>
<td class=\"classData\"><select name=\"pageEdit[11]\">";
for ($i=0; $i<8; $i++) {
	if ($pageEdit[11]==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>$modtitle[$i]</option>";
}
echo "</select><hr>";
//--- ricerca fonts ---------------------//
echo "
<SCRIPT TYPE=\"text/javascript\" LANGUAGE=\"Javascript\">
var cp = new ColorPicker('window'); // Popup window
</SCRIPT>";
echo ""._FONTTTF."&nbsp;
	<select name=\"pageEdit[89]\">";
		$dynfontdir = dir("layout/includes/dynText/fonts");
		while($dyn=$dynfontdir->read()) {
			if ((eregi(".ttf",$dyn))) {
   				$dynfontlist .= "$dyn ";
			}
		}
        closedir($dynfontdir->handle);
        $dynfontlist = explode(" ", $dynfontlist);
        sort($dynfontlist);
        for ($i=0; $i < sizeof($dynfontlist); $i++) {
            if ($dynfontlist[$i]!="") {
                echo "<option value=\"$dynfontlist[$i]\" ";
                if ($pageEdit[89] == $dynfontlist[$i]) { echo "selected"; }
                echo ">$dynfontlist[$i]</option>\n";
            }
        }
        echo "</select>

"._FONTDIM."&nbsp;<input type=\"text\" name=\"pageEdit[90]\" value=\"$pageEdit[90]\" size=\"8\">
"._FONTBG."&nbsp; <input type=\"text\" name=\"title_bgcolor\"  value=\"".$pageEdit[91]."\"  size=\"8\" maxlength=\"7\">&nbsp;<A HREF=\"#\" onClick=\"cp.select(document.forms[0].title_bgcolor,'pick');return false;\" NAME=\"pick\" ID=\"pick\">  <img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0></A>
"._FONTCOL."&nbsp;<input type=\"text\" name=\"title_color\"    value=\"".$pageEdit[92]."\"    size=\"8\" maxlength=\"7\">&nbsp;<A HREF=\"#\" onClick=\"cp.select(document.forms[0].title_color,'pick2');return false;\"  NAME=\"pick2\" ID=\"pick2\"><img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0></A>
</td></tr>";
echo "</table>";
Closetable();
echo "<br>";
Opentable();
//--- dimensioni dei TD -------------------------//
$titleforTD=array("td1","tdLEFT","td2L","td2C","td2R","tdCENTER","td3L","td3C","td3R","tdRIGHT","td4");
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\"><tr>";
for ($i=73; $i <84; $i++) {
	echo "<td valign=\"top\" class=\"classHeaderTD\" align=\"center\">$titleforTD[$i]</td>";
}
echo "</tr><tr>";
for ($i=73; $i <84; $i++) {
	echo "<td class=\"classData\" align=\"center\"><input type=\"text\" name=\"pageEdit[$i]\" value=\"$pageEdit[$i]\" size=\"8\" maxlength=\"7\" class=\"setarea\"></td>";
}
echo "</tr></table>";
//--- riporta dati riepilogativi --------//
echo "
<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<td class=\"classData\">&nbsp;table:&nbsp;</td>      			<td class=\"classData\"><input type=\"text\" size=\"8\" value=\"".$pageEdit[84]."\" readonly></td>
<td class=\"classData\">&nbsp;LEFT+CENTER:&nbsp;</td>			<td class=\"classData\"><input type=\"text\" size=\"8\" value=\"".$pageEdit[85]."\" readonly></td>
<td class=\"classData\">&nbsp;CENTER+RIGHT:&nbsp;</td>		    <td class=\"classData\"><input type=\"text\" size=\"8\" value=\"".$pageEdit[86]."\" readonly></td>
<td class=\"classData\">&nbsp;LEFT+CENTER+RIGHT:&nbsp;</td>     <td class=\"classData\"><input type=\"text\" size=\"8\" value=\"".$pageEdit[87]."\" readonly></td>
</tr></table>\n";
Closetable();
echo "<br>";
//--- setting caratteristiche grafiche ----------------------//
Opentable();
$acceso="images/admin/acceso.gif";
$spento="images/admin/spento.gif";
$errore="images/admin/errore.gif";
//--- scelta caratteristiche per zone -----------------------//
$titleforzone=array(13=>"themezone1",19=>"themezone2",25=>"themezone3",31=>"block-top",37=>"core-zone",43=>"block-bot",49=>"themezone4",55=>"themezone5",61=>"themezone6",67=>"opentable");
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">";
echo "<tr>
<td class=\"classHeaderTD\">Zona</td>
<td class=\"classHeaderTD\">Scelta template</td>
<td class=\"classHeaderTD\">blocco&nbsp;<img src=\"images/admin/templblock.gif\" align=\"top\" border=0 onClick=\"javascript:popUp('layout/templates/blocks/blockstype.htm')\"></td>
<td class=\"classHeaderTD\">prefix&nbsp;<img src=\"images/admin/templprefix.gif\" align=\"top\" border=0 onClick=\"javascript:popUp('layout/templates/preview.htm')\"></td>
<td class=\"classHeaderTD\">colors&nbsp;<img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0 onClick=\"javascript:popUp('layout/templates/ColorPicker.htm')\"></td>
</tr>";
echo "<tr>";
$max=73;
for ($i=13; $i <$max ; $i+=6) {
	echo "<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">";
	$vocezone=$i+5;$voceblock=$i;$vocepref=$i+1;$vocecoltable=$i+2;$vocecoltitle=$i+3;$vocecolbox=$i+4;
	echo strtoupper($titleforzone[$i]);
	echo "</td>";
	if ($i==13 || $i==19 || $i==25 || $i==49 || $i==55 || $i==61) {
		echo "
		<td class=\"classDataRow1\">
		<select name=\"pageEdit[$vocezone]\">
		<option name=\"pageEdit[$vocezone]\" value=\"$pageEdit[$vocezone]\" selected>$pageEdit[$vocezone]</option>
		<optgroup label=\"-----------------\">";
		$zonetypelist=templatezone();
		$zonetypelist = explode(" ",$zonetypelist);
		sort($zonetypelist);
		for ($a=0; $a < sizeof($zonetypelist); $a++) {
			if($zonetypelist[$a]!="") {
		    	$zonetype = ereg_replace("zone-","",$zonetypelist[$a]);
		        $zonetype = ereg_replace(".php","",$zonetype);
		       	echo "<option name=\"pageEdit[$vocezone]\" value=\"$zonetype\">$zonetype</option>\n";
		    }    
		}
		echo "</select>";
		$zonetypelist = implode(" ", $zonetypelist);
		if ($pageEdit[$i]=="personalizzato"){
			$notfound=$errore;
		} else {
			$notfound=$spento;
		}
		$imgsta="layout/$titleforzone[$i].php";
		if (file_exists("layout/$titleforzone[$i].php")) { 
			echo "&nbsp;&nbsp;<img src=$acceso alt=\"$imgsta ok!\">";
		} else { 
			echo "&nbsp;&nbsp;<img src=$notfound alt=\"$imgsta not found!\">";
		}
		echo "</td>";
	} elseif ($i==37 )  {
		$breakcore=array(0=>"no",1=>"top [BR]",2=>"bottom [BR]",3=>"top+bottom [BR]");
		echo "<td class=\"classDataRow2\">Break space? 
		<select name=\"pageEdit[88]\">";
		for ($bc=0; $bc<4; $bc++) {
			if ($pageEdit[88]==$bc) { 
				$sel="selected"; 
			} else {
				$sel="";
			}
			echo "<option value=\"$bc\" $sel>".$breakcore[$bc]."</option>";
		}
		echo "</select></td>";
	} else {
		echo "<td class=\"classDataRow2\"></td>";
	}
//------------------------------------------------------//
	echo "<td class=\"classDataRow1\" align=\"center\">
	<select name=\"pageEdit[$voceblock]\">
	<option value=\"$pageEdit[$voceblock]\" selected>$pageEdit[$voceblock]</option>
	<optgroup label=\"-----\">";
	$blockstypelist=templateblocks();
	$blockstypelist = explode(" ",$blockstypelist);
	sort($blockstypelist);
	for ($a=0; $a < sizeof($blockstypelist); $a++) {
		if($blockstypelist[$a]!="") {
    		$blocktype = ereg_replace("block-","",$blockstypelist[$a]);
        	$blocktype = ereg_replace(".php","",$blocktype);
        	echo "<option name=\"pageEdit[$voceblock]\" value=\"$blocktype\">$blocktype</option>\n";
    	}
	}
	$blockstypelist = implode(" ",$blockstypelist);
	echo "</td>";

	$prefxforzone=array(14=>"ZONE1",20=>"ZONE2",26=>"ZONE3",32=>"BLOCKTOP",38=>"CORE",44=>"BLOCKBOT",50=>"ZONE4",56=>"ZONE5",62=>"ZONE6",66=>"OPENTABLE",74=>"INDEXNEWS");
	echo "
	<td class=\"classDataRow1\" align=\"center\">
	<select name=\"pageEdit[$vocepref]\">
	<option value=\"$pageEdit[$vocepref]\" selected>$pageEdit[$vocepref]</option>
	<optgroup label=\"------------\">
	<option value=\"$prefxforzone[$vocepref]\">$prefxforzone[$vocepref]</option>";
	$prefixlist=templateprefix();
	$prefixlist = explode(" ", $prefixlist);
	sort($prefixlist);
	for ($a=0; $a < sizeof($prefixlist); $a++) {
		if($prefixlist[$a]!="") {
			$prefixtype=eregi_replace("-top-left.gif","",$prefixlist[$a]);
			echo "<option value=\"$prefixtype\">$prefixtype</option>\n";
    	}    
	}
	echo "</select>";
	$imgsta="layout/style/$pageEdit[$vocepref].css";
	if (file_exists("layout/style/$pageEdit[$vocepref].css")) { 
		echo "&nbsp;&nbsp;<img src=$acceso alt=\"$imgsta ok!\">";
	} else { 
		echo "&nbsp;&nbsp;<img src=$spento alt=\"$imgsta not found!\">";
	}
	echo "</td>";
	$prefixlist= implode(" ",$prefixlist);
	$colta=$i-3;$colti=$i-2;$colbo=$i-1;
	echo "
	<td class=\"classDataRow1\" align=\"center\">
		TBL:&nbsp;<input type=\"text\" name=\"pageEdit[$vocecoltable]\"  value=\"$pageEdit[$vocecoltable]\"  size=\"8\" maxlength=\"7\"><br><div style=\"background: $pageEdit[$vocecoltable]; border: 1px solid #000000; \">&nbsp;</div>
		BOR:&nbsp;<input type=\"text\" name=\"pageEdit[$vocecoltitle]\"  value=\"$pageEdit[$vocecoltitle]\"  size=\"8\" maxlength=\"7\"><br><div style=\"background: $pageEdit[$vocecoltitle]; border: 1px solid #000000;\">&nbsp;</div>
		BOX:&nbsp;<input type=\"text\" name=\"pageEdit[$vocecolbox]\"    value=\"$pageEdit[$vocecolbox]\"    size=\"8\" maxlength=\"7\"><br><div style=\"background: $pageEdit[$vocecolbox];   border: 1px solid #000000;\">&nbsp;</div>
	</td>";
	echo "</tr><tr>";
}
echo "</tr></table>";
Closetable();
echo "<br>";
//--- style sheet
if ($page['page_title']=="!Standard") {
Opentable();
echo "<div align=\"center\"><b>"._THEMESTYLE."</b></div><br>";
if (file_exists("layout/style/style.css")) { 
$filestyle = fopen("layout/style/style.css", "r");
$style =fread($filestyle, filesize("layout/style/style.css"));
fclose($filestyle);
}
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<tr>
<td valign=\"top\" class=\"classHeaderTD\">STYLE.CSS</td>
<td valign=\"top\" class=\"classHeaderTD\">Example</td>
</tr><tr>
<td class=\"classData\" width=\"50%\"><textarea name=\"style\" cols=\"75\" rows=\"30\">$style</textarea></td>
<td valign=\"top\">
	<table width=100% cellspacing=\"2\" cellpadding=\"2\" border=\"1\" valign=\"top\">
    <tr><td valign=\"top\" class=\"classHeaderTD\" colspan=\"2\" align=\"center\">generic</td></tr>	
	<tr><td valign=\"top\" class=\"classHeaderTD\">BODY</td><td class=\"classData\">"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">A.link</td><td class=\"classData\"><a href=//>"._THEMESTYLEVER."</a></td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\" colspan=\"2\" align=\"center\">phpnuke</td></tr>	
    <tr><td valign=\"top\" class=\"classHeaderTD\">title</td><td class=\"classData\">"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">content</td><td class=\"classData\">"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">storytitle</td><td class=\"classData\">"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">storycat</td><td class=\"classData\">"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">boxtitle</td><td class=\"classData\"><font class=boxtitle>"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">option</td><td class=\"classData\"><font class=option>"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">tiny</td><td class=\"classData\"><font class=tiny>"._THEMESTYLEVER."</td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\" colspan=\"2\" align=\"center\">proxima</td></tr>	
    <tr><td valign=\"top\" class=\"classHeaderTD\">button</td><td class=\"classData\"><input type=\"submit\" name=\"Button\" value=\"button\" class=\"classButton\"></td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">textarea</td><td class=\"classData\"><input type=\"text\" name=\"text\" value=\"text area\" class=\"textarea\"></td></tr>
    <tr><td valign=\"top\" class=\"classHeaderTD\">formtext</td><td class=\"classData\"><textarea cols=\"15\" rows=\"3\" name=\"form text\" class=\"formtext\">"._THEMESTYLEVER."</textarea></td></tr>
    </table>
</td>
</tr></table>";
Closetable();
//--- style sheet: style-tables.css
if (file_exists("layout/style/style-tables.css")) { 
	$filestyletables = fopen("layout/style/style-tables.css", "r");
	$styletables =fread($filestyletables, filesize("layout/style/style-tables.css"));
	fclose($filestyletables);
}
echo "<hr>";
Opentable();
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"50%\">TABLES.CSS</td>
<td class=\"classData\" width=\"50%\">Example Table style<br></td>
</tr><tr>
<td class=\"classData\" align=\"left\"><textarea name=\"styletables\" cols=\"75\" rows=\"30\">$styletables</textarea></td>
<td>
<table>
<tr>
<td class=\"classHeaderTR\" colspan=\"4\">HeaderTR</td>
</tr><tr>
<td class=\"classHeaderTD\">HeaderTD</td>
<td class=\"classHeaderTD\">HeaderTD</td>
<td class=\"classHeaderTD\">HeaderTD</td>
<td class=\"classHeaderTD\">HeaderTD</td>
</tr><tr>
<td class=\"classColLeft\">ColumnLeftTD</td>
<td class=\"classData\">DataTD</td>
<td class=\"classDataAlt\">DataAltTD</td>
<td class=\"classColRight\">ColumnRight</td>
</tr><tr>
<td class=\"classColLeft\">ColumnLeftTD</td>
<td class=\"classDataRow1\">RowDataTD1</td>
<td class=\"classDataRow1\">RowDataTD1</td>
<td class=\"classColRight\">ColumnRight</td>
</tr><tr>
<td class=\"classColLeft\">ColumnLeftTD</td>
<td class=\"classDataRow2\">RowDataTD2</td>
<td class=\"classDataRow2\">RowDataTD2</td>
<td class=\"classColRight\">ColumnRight</td>
</tr><tr>
<td class=\"classColLeft\">ColumnLeftTD</td>
<td class=\"classDataCol1\">ColDataTD1</td>
<td class=\"classDataCol2\">ColDataTD2</td>
<td class=\"classColRight\">ColumnRight</td>
</tr><tr>
<td class=\"classFooterTD\">FooterTD</td>
<td class=\"classFooterTD\">FooterTD</td>
<td class=\"classFooterTD\">FooterTD</td>
<td class=\"classFooterTD\">FooterTD</td>
</tr><tr>
<td class=\"classFooterTR\" colspan=\"4\">FooterTR</td>
</tr>
</table>
</td>
</tr>
</table>";
Closetable();
} else {
//--- style sheet: module style sheet
if (file_exists("layout/style/style-$pageEdit[1].css")) { 
	$filestylemodule = fopen("layout/style/style-$pageEdit[1].css", "r");
	$stylemodule = fread($filestylemodule, filesize("layout/style/style-$pageEdit[1].css"));
	fclose($filestylemodule);
}
echo "<hr>";
Opentable();
echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<tr>
<td valign=\"top\" class=\"classHeaderTD\">".$pageEdit[1]."</td>
</tr><tr>
<td class=\"classData\"><textarea name=\"stylemodule\" cols=\"85\" rows=\"30\">$stylemodule</textarea></td>
</tr></table>";
}
Closetable();
echo "<hr>";
Opentable();
echo "<br>
<input type=\"hidden\" name=\"pageid\"         value=\"".$pageEdit['page_id']."\">
<input type=\"hidden\" name=\"pageEdit[1]\"    value=\"".$pageEdit[1]."\">
<input type=\"hidden\" name=\"pageEdit[3]\"    value=\"".$pageEdit[3]."\">
<input type=\"hidden\" name=\"op\" value=\"proxima_module_edit_save\">";
echo "<div align=\"center\"><input type=\"submit\" value=\""._SAVECHANGES."\" class=\"classButton\"></div>
</form><br>
<div class=\"classHeaderTD\" align=\"center\">&nbsp;</div><br>
<form action=\"admin.php\" method=\"post\">
<div align=\"center\">
"._COPYMODULESETTING."&nbsp;&nbsp;
<select name=\"mid_templ\">";
$query = "SELECT page_id, page_title 
          FROM ".$prefix."_webpages 
		  WHERE page_id<>'".$pageEdit['page_id']."'
		  ORDER BY page_title ASC";
$result=$db->sql_query($query);
while(list($mid_templ, $title_templ) = $db->sql_fetchrow($result)) {
	echo "<option value=\"$mid_templ\">$title_templ</option>\n";
}    
echo "</select>&nbsp;
<input type=\"hidden\" name=\"pageid\" value=\"".$pageid."\">
<input type=\"hidden\" name=\"op\" value=\"proxima_copymodule_save\">
&nbsp;"._COPYALLMODULES."&nbsp;&nbsp;
<input type=\"checkbox\" name=\"allmodules\" value=\"1\">&nbsp;&nbsp;&nbsp;
<input type=\"submit\" value=\""._GO."\" class=\"classButton\">
</form><br>"._GOBACK."<br><br></div>";
Closetable();
include("footer.php");
}
//-----------------------------------------------------
//--- Update module (SAVE)
//-----------------------------------------------------
function proxima_module_edit_save($pageid, $pageEdit, $stylemodule, $style, $styletables) {
global $prefix, $db;
$pageEdit[91] = ereg_replace("#","",$_POST['title_bgcolor']);
$pageEdit[92] = ereg_replace("#","",$_POST['title_color']);
$pageEdit[84] = 0;
$pageEdit[85] = 0;
$pageEdit[86] = 0;
$pageEdit[87] = 0;
for ($tt=73;  $tt<84; $tt++ )  { $pageEdit[84]=$pageEdit[84]+$pageEdit[$tt];  }
if ($pageEdit[84] < 150) { $pageEdit[84]=$pageEdit[84]."%"; }
for ($lc=74;  $lc<82; $lc++ )  { $pageEdit[85]=$pageEdit[85]+$pageEdit[$lc];  }
if ($pageEdit[84] < 150) { $pageEdit[85]=$pageEdit[85]."%"; }
for ($cr=78;  $cr<84; $cr++ )  { $pageEdit[86]=$pageEdit[86]+$pageEdit[$cr];  }
if ($pageEdit[84] < 150) { $pageEdit[86]=$pageEdit[86]."%"; }
for ($lcr=74; $lcr<84; $lcr++) { $pageEdit[87]=$pageEdit[87]+$pageEdit[$lcr]; }
if ($pageEdit[84] < 150) { $pageEdit[87]=$pageEdit[87]."%"; }
$field_query = "SHOW FIELDS 
                FROM ".$prefix."_webpages";
$result=$db->sql_query("$field_query");
$query_update="UPDATE ".$prefix."_webpages 
		       SET ";
while (list($field_name, $field_type, $field_null, $field_key, $field_default, $field_extra)= $db->sql_fetchrow($result)) {
if ($a>0) { $query_update .=", ";}
if ($i>0) { $query_update .="".$field_name."='".$pageEdit[$i]."'"; $a=1;}
$i++;
}
$query_update .="  where page_id ='".$pageid."'";
$result = $db->sql_query($query_update);
$result = $db->sql_query("ALTER TABLE ".$prefix."_webpages ORDER BY page_id");
$result = $db->sql_query("ALTER TABLE ".$prefix."_webblocks ORDER BY page_id, block_id");
@mysql_free_result($result);
if ($page['page_id']<>1) {
$stylemodule = FixQuotes($stylemodule);
$stylemodule = trim($stylemodule);
$filestylemodule = fopen("layout/style/style-$pageEdit[1].css","w");
fwrite($filestylemodule, $stylemodule);
fclose($filestylemodule);
} else {
$style = FixQuotes($style);
$style = trim($style);
$filestyle = fopen("layout/style/style.css","w");
fwrite($filestyle, $style);
fclose($filestyle);
$styletables = FixQuotes($styletables);
$styletables = trim($styletables);
$filestyletables = fopen("layout/style/style-tables.css","w");
fwrite($filestyletables, $styletables);
fclose($filestyletables);
}
Header("Location: admin.php?op=proxima_module_edit&pageid=".$pageid."");
}
//-----------------------------------------------------
//--- Copy settings module to module
//-----------------------------------------------------
function proxima_copymodule_save($pageid, $mid_templ, $allmodules) {
global $prefix, $db;
$query = "SELECT * 
          FROM ".$prefix."_webpages 
		  WHERE page_id='".$mid_templ."'";
$result=$db->sql_query($query);
$pageUpdate=$db->sql_fetchrow($result);
$field_query = "SHOW FIELDS 
                FROM ".$prefix."_webpages";
$result=$db->sql_query("$field_query");
$query_update="UPDATE ".$prefix."_webpages 
               SET ";
while (list($field_name, $field_type, $field_null, $field_key, $field_default, $field_extra)= $db->sql_fetchrow($result)) {
	if ($a>0) { $query_update .=", ";}
	if ($i>8) { $query_update .="$field_name ='".$pageUpdate[$i]."'"; $a=1;}
	$i++;
	}
	if ($allmodules==0) {
		$query_update .="  WHERE page_id ='".$pageid."'";
	} else {
		$query_update .="";
}
	if (file_exists("layout/style/style-$pageUpdate[1].css")) { 
		$filestylemodule = fopen("layout/style/style-$pageUpdate[1].css", "r");
		$stylemodule =fread($filestylemodule, filesize("layout/style/style-$pageUpdate[1].css"));
		fclose($filestylemodule);
		$stylemodule = FixQuotes($stylemodule);
		$stylemodule = trim($stylemodule);
			if ($allmodules==0) {
				$result2=$db->sql_query("SELECT title 
				                         FROM ".$prefix."_webpages 
										 WHERE page_id='".$pageid."'");
				list($page['page_title'])=$db->sql_fetchrow($result2);
				$filestylemodule = fopen("layout/style/style-".$page['page_title'].".css","w");
				fwrite($filestylemodule, $stylemodule);
				fclose($filestylemodule);
			} else {
				$result2=$db->sql_query("SELECT title 
				                         FROM ".$prefix."_webpages");
				while(list($page['page_title'])=$db->sql_fetchrow($result2)) {
					$filestylemodule = fopen("layout/style/style-".$page['page_title'].".css","w");
					fwrite($filestylemodule, $stylemodule);
					fclose($filestylemodule);
				}
			}
	}
$result = $db->sql_query("$query_update");
//echo $query_update;
//break;
Header("Location: admin.php?op=proxima_module_edit&pageid=".$pageid."");
}    
//-----------------------------------------------------
//--- block add
//-----------------------------------------------------
function proxima_blocks_associate($pageid, $blockid="") {
global $prefix, $db, $multilingual;
include("header.php");
proxima_form_block($pageid, $blockid="", $function="add");
echo "
<div align=\"left\">";copyright($proxima); echo "</div>";
include("footer.php");
}
//-----------------------------------------------------
//--- block edit
//-----------------------------------------------------
function proxima_blocks_edit($pageid, $blockid) {
global $prefix, $db, $multilingual;
include("header.php");
proxima_form_block($pageid, $blockid, $function="edit");
echo "
<div align=\"left\">";copyright($proxima); echo "</div>";
include("footer.php");
}
//-----------------------------------------------------
//--- form for block edit and add
//-----------------------------------------------------
function proxima_form_block($pageid, $blockid, $function) {
global $prefix, $db, $multilingual;
//--- ricerca prefix frames -------------------------//
$prefixlist = templateprefix();
//--- ricerca templates blocchi ---------------------//
$blockstypelist = templateblocks();
//--- costruisce file preview.htm -------------------//
previewprefix();
//--- inizio funzione -------------------------------//
GraphicAdmin();
Opentable();
if (empty($block['block_block'])){$block['block_block']=67;}
if (empty($block['block_coltable'])){$block['block_coltable']="#000080";}
if (empty($block['block_coltitle'])){$block['block_coltitle']="#708090";}
if (empty($block['block_colbox'])){$block['block_colbox']="#DCDCDC";}
if (empty($block['block_width'])){$block['block_width']="100";}
if (empty($block['block_break'])){$block['block_break']="1";}
if (empty($block['block_image'])){$block['block_image']="1";}
if ($function=="edit") {
	$query = "SELECT * 
	          FROM ".$prefix."_webblocks 
			  WHERE page_id='".$pageid."' 
			  AND  block_id='".$blockid."'";
    $result = $db->sql_query($query);
    $block = $db->sql_fetchrow($result);
} 
	$query = "SELECT * 
	          FROM ".$prefix."_webpages 
			  WHERE page_id='".$pageid."'";
    $result = $db->sql_query($query);
    $webpage = $db->sql_fetchrow($result);
//---------------------- 
echo "
<form action=\"admin.php\" method=\"post\">
<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"classTable\" width=\"100%\">
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._MODULE." 
</td>
<td class=\"classColRight\" colspan=\"3\">
	<input type=\"text\" name=\"\" value=\"".$webpage['page_title']."\" readonly >&nbsp;&nbsp;<a href=\"admin.php?op=proxima_module_edit&amp;pageid=".$webpage['page_id']."\"><img src=\"images/admin/module.gif\" border=\"0\" alt=\""._MODULE."\" align=\"absmiddle\"></a>
</td>
</tr>\n";
//---------------------- 
echo "<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._TITLE.": 
</td>
<td  class=\"classData\" colspan=\"3\">
	<input type=\"text\" name=\"block[block_title]\" value=\"".$block['block_title']."\" size=\"30\" maxlength=\"60\">
</td>
</tr>\n";
//---------------------- 
if ($function == "add" || $block['block_file'] != "" ) {
if ($function == "add") { $sel= "selected";}
        echo "
		<tr><td class=\"classHeaderTD\" width=\"20%\">"._FILENAME.":</td>
		<td class=\"classData\" colspan=\"3\">
        <select name=\"block[block_file]\">
	    <option name=\"block[block_file]\" value=\"$block[block_file]\" $sel>$block[block_file]</option>";
        $blocksdir = dir("blocks");
        while($func=$blocksdir->read()) {
            if(substr($func, 0, 6) == "block-") {
                $bl = ereg_replace("block-","",$func);
                $bl = ereg_replace(".php","",$bl);
                $bl = ereg_replace("_"," ",$bl);
                echo "<option value=\"blocks/".$func."\" ";
                if ($block['block_file'] == $func) { echo "selected"; }
                echo ">$bl</option>\n";
            }
        }
        closedir($blocksdir->handle);
		$result = $db->sql_query("SELECT page_title 
	                              FROM ".$prefix."_webpages ");
    	while ($row = $db->sql_fetchrow($result)) {
	//	sort($row[page_title]);
	      if (is_dir("modules/".$row[page_title]."/blocks")) {
          $blocksdir = dir("modules/".$row[page_title]."/blocks");
		    echo " <optgroup label=\"--".$row[page_title]."--\">";
              while($func=$blocksdir->read()) {
    	        if(substr($func, 0, 6) == "block-") {
				  $bl = ereg_replace("block-","",$func);
                  $bl = ereg_replace(".php","",$bl);
                  $bl = ereg_replace("_"," ",$bl);
                  echo "<option value=\"modules/".$row[page_title]."/blocks/".$func."\" ";
                  if ($block['block_file'] == "modules/".$row[page_title]."/blocks/".$func) { echo "selected"; }
                  echo ">$bl</option>\n";
                }
		      }
              closedir($blocksdir->handle);
          }
        }
     echo "</select>&nbsp;&nbsp;"._FILEINCLUDE."</td></tr>";
}
//---------------------- 
if ($function == "add" || $block['block_content'] != "" ) {
echo "
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._CONTENT."<br>Html:
</td>
<td class=\"classData\" align=\"left\" colspan=\"3\">
	<textarea name=\"block[block_content]\" cols=\"80\" rows=\"15\">".$block['block_content']."</textarea><br>";
	if ($func == "add") {
		echo ""._IFRSSWARNING."";
	}
echo "
</td>
</tr>\n";
}
//---------------------- 
if ($function == "add" || $block['block_url'] != "" ) {
echo "
<script type=\"text/javascript\">
  function put(){
    option=document.forms[0].dropdown.options[document.forms[0].dropdown.selectedIndex].text
    txt=option
    document.forms[0]['block[block_url]'].value=txt
  }
</script>";
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._RSSFILE.":
</td>
<td class=\"classData\" colspan=\"3\">
	<input type=\"text\" name=\"block[block_url]\" value=\"".$block['block_url']."\" size=\"64\" maxlength=\"200\"><br><hr>
	<select name=\"dropdown\" onchange=\"put()\">";
	$query = "SELECT hid, sitename, headlinesurl 
	          FROM ".$prefix."_headlines";
    $res = $db->sql_query($query);
	    while (list($hid, $htitle, $hurl) = $db->sql_fetchrow($res)) {
    	    echo "<option>$hurl</option>";
        }
    echo "</select>&nbsp;[ <a href=\"admin.php?op=HeadlinesAdmin\">Setup</a> ]<br>
    "._SETUPHEADLINES."
</td>
</tr>\n";
}
//--- refresh time -----------//
if ($function=="add" || $block['block_url'] != "") {
echo "
<tr><td class=\"classHeaderTD\" width=\"20%\">
	"._REFRESHTIME."<br>"._ONLYHEADLINES.":
</td>
<td class=\"classData\" colspan=\"3\">";
$blockrefresh=array(
	1800=>"1/2"._HOUR."",
	3600=>"1 "._HOURS."",
	18000=>"5 "._HOURS."",
	36000=>"10 "._HOURS."",
	86400=>"24"._HOURS."");
show_generic_select_row($name="block[block_refresh]", $value=$block['block_refresh'], $matrix=$blockrefresh);
echo "
</td></tr>\n";
}
//---------------------- 
echo "
<tr>
<td class=\"classHeaderTD\" width=\"20%\">
	"._POSITION.":
</td>
<td class=\"classData\" colspan=\"3\">";
$blockpos=array(
	"l"=>""._LEFT."",
	"c"=>""._CENTER."",
	"r"=>""._RIGHT."",
	"a"=>""._TOP."",
	"x"=>""._BOTTOM."");
show_generic_select_row($name="block[block_position]", $value=$block['block_position'], $matrix=$blockpos);
echo "
</td>\n
</tr>";
//---------------------- 
if ($multilingual == 1) {
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._LANGUAGE.":
</td>
<td class=\"classData\" colspan=\"3\">
<select name=\"block[block_language]\">";
	$handle=opendir('language');
    while ($file = readdir($handle)) {
   		if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
     		$langFound = $matches[1];
        	$languageslist .= "$langFound ";
     	}
    }
    closedir($handle);
    $languageslist = explode(" ", $languageslist);
    sort($languageslist);
    for ($i=0; $i < sizeof($languageslist); $i++) {
    	if($languageslist[$i]!="") {
        	echo "<option value=\"$languageslist[$i]\" ";
            if ($languageslist[$i]==$block['block_language']) echo "selected";
         	    echo ">".ucfirst($languageslist[$i])."</option>\n";
          	}
        }
        if ($block['block_language'] != "") {
            $sel3 = "";
        } else {
            $sel3 = "selected";
        }
        echo "<option value=\"\" $sel3>"._ALL."</option></select></td></tr>";
    } else {
        echo "<input type=\"hidden\" name=\"block[block_language]\" value=\"\">";
    }
//---------------------- 
echo "
<tr>
<td class=\"classHeaderTD\" width=\"20%\">
	"._ACTIVATE2.":
</td>
<td class=\"classData\"  colspan=\"3\">";
if ($function=="add" ) { $block['block_status']=1; }
$blockactive=array(
    1=>""._YES."",
	0=>""._NO."");
show_generic_select_row($name="block[block_status]", $value=$block['block_status'], $matrix=$blockactive);
echo "</td></tr>\n";

//---------------------- 
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._VIEWPRIV."
</td>";
if ($typovisibility == 1) {
echo "<td class=\"classData\" colspan=\"3\">
	"._GROUP_FROM."&nbsp;&nbsp;
	<select name=\"block[viewfrom]\">";
	$result=$db->sql_query("select group_id,group_name from ".$prefix."_users_group ORDER BY group_id ASC ");
	while (list($group_id,$group_name)=$db->sql_fetchrow($result)) {
		if ($block['viewfrom']==$group_id) { $sel="selected"; } else {$sel="";}
		echo "<option value=$group_id $sel>$group_name</option>";
	}
	echo "</select>&nbsp;&nbsp;"._GROUP_TO."&nbsp;&nbsp;
	<select name=\"block[viewto]\">";
	$result=$db->sql_query("select group_id,group_name from ".$prefix."_users_group ORDER BY group_id DESC ");
	while (list($group_id,$group_name)=$db->sql_fetchrow($result)) {
		if ($block['viewto']==$group_id) { $sel="selected"; } else {$sel="";}
		echo "<option value=$group_id $sel>$group_name</option>";
	}
	echo "</select></td>";
} else {
	$usergroup=array(0=>""._MVALL."",1=>""._MVUSERS."", 2=>""._MVADMIN."", 3=>""._MVANON."");
	echo "
	<td align=\"left\" class=\"classData\"   colspan=\"3\">";
	echo "<select name=\"block[viewfrom]\">";
	for ($i=0; $i<5; $i++) {
		if ($block['viewfrom']==$i) { $sel="selected"; } else {$sel="";}
		echo "<option value=\"$i\" $sel>".$usergroup[$i]."</option>";
	}
	echo "</select>";
}
//----------------------------------
if ($function=="add" ) { $block['block_expire'] = 0; } 
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._EXPIRATION."
</td>
<td class=\"classData\" colspan=\"3\">";

if ($function=="edit" ) {
    if ($block['block_expire'] != 0) {
        $oldexpire = $block['block_expire'];
        $block['block_expire'] = intval(($block['block_expire'] - time()) / 3600);
        $exp_day = ceil($block['block_expire'] / 24);
        echo "<input type=\"hidden\" name=\"block[block_expire]\" value=\"$oldexpire\">".$block['block_expire']." "._HOURS." (".substr($exp_day,0,5)." "._DAYS.")";
    } else {
        echo "<input type=\"text\" name=\"block[block_expire]\" value=\"0\" size=\"4\" maxlength=\"3\"> "._DAYS."";
    }
} else {
	echo "<input type=\"text\" name=\"block[block_expire]\" size=\"4\" maxlength=\"3\" value=\"".$block['block_expire']."\"> "._DAYS."&nbsp;&nbsp;";
}
echo "&nbsp;-->&nbsp;&nbsp;"._AFTEREXPIRATION.":&nbsp;&nbsp;";
$blockafter=array(
    "d"=>""._DEACTIVATE."",
	"r"=>""._DELETE."");
show_generic_select_row($name="block[block_action]", $value=$block['block_action'], $matrix=$blockafter);
echo "</td></tr>\n";

//----------------------------------
echo "
<tr>
<td valign=\"top\" class=\"classHeaderTD\" width=\"20%\">
	"._SUBVISIBLE."
</td>
<td class=\"classData\"  colspan=\"3\">";
if ($function=="add" ) { $block['block_subscription']=1; }
$blocksubscript=array(
    1=>""._YES."",
	0=>""._NO."");
show_generic_select_row($name="block[block_subscription]", $value=$block['block_subscription'], $matrix=$blocksubscript);
echo "</td></tr>\n";
//----------------------------------
	echo "</tr><tr>
	<td class=\"classHeaderTD\" rowspan=\"6\">"._BLOCKDEFINITION."</td>
	<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">"._THEMEBLOCKTYPE.":</td>
	<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">prefix: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[style check]</td>
	<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">boxwidth:</td>
</tr>\n";
//---------------------- 
echo "<tr>
<td class=\"classData\" align=\"center\" width=\"33%\">
	<select name=\"block[block_block]\">
	<option value=\"".$block['block_block']."\" selected>".$block['block_block']."</option>
	<optgroup label=\"-----\">";
	$blockstypelist = explode(" ",$blockstypelist);
	sort($blockstypelist);
	for ($a=0; $a < sizeof($blockstypelist); $a++) {
		if($blockstypelist[$a]!="") {
    		$blocktype = ereg_replace("block-","",$blockstypelist[$a]);
       		$blocktype = ereg_replace(".php","",$blocktype);
       		echo "<option value=\"$blocktype\">$blocktype</option>\n";
    	}
	}
	$blockstypelist = implode(" ",$blockstypelist);
	echo "</select>&nbsp;<input type=\"button\" class=\"blockclass\" value=\"B\"  onClick=\"javascript:popUp('layout/templates/blocks/blockstype.htm')\"></td>";
//---------------------- 
echo "
<td class=\"classData\" align=\"center\" width=\"33%\">
<select name=\"block[block_pref]\">
<option value=\"".$block['block_pref']."\" selected>".$block['block_pref']."</option>
<optgroup label=\"-----------------\">
<option value=\"$prefxforpageEdit[$i]\">$prefxforpageEdit[$i]</option>";
	$prefixlist=templateprefix();
	$prefixlist = explode(" ", $prefixlist);
	sort($prefixlist);
	for ($a=0; $a < sizeof($prefixlist); $a++) {
		if($prefixlist[$a]!="") {
			$prefixtype=eregi_replace("-top-left.gif","",$prefixlist[$a]);
			echo "<option value=\"$prefixtype\">$prefixtype</option>\n";
    	}    
	}
	
echo "</select>&nbsp;<input type=\"button\" class=\"previewclass\" value=\"P\" onClick=\"javascript:popUp('layout/templates/preview.htm')\">";
$prefixlist= implode(" ",$prefixlist);
echo "</td>
<SCRIPT TYPE=\"text/javascript\" LANGUAGE=\"Javascript\">
var cp = new ColorPicker('window'); // Popup window
</SCRIPT>
<td class=\"classData\" align=\"center\"><input type=\"text\" name=\"block[block_width]\" value=\"".$block['block_width']."\" size=\"7\" maxlength=\"7\"></td>
	</tr><tr>
	<td valign=\"top\" width=\"33%\" class=\"classHeaderTR\">border color:&nbsp;&nbsp;<input type=\"button\" class=\"colorclass\" value=\"C\" onClick=\"javascript:popUp('layout/templates/ColorPicker.htm')\"></td>
	<td valign=\"top\" width=\"33%\" class=\"classHeaderTR\">title color:&nbsp;&nbsp; <input type=\"button\" class=\"colorclass\" value=\"C\" onClick=\"javascript:popUp('layout/templates/ColorPicker.htm')\"></td>
	<td valign=\"top\" width=\"33%\" class=\"classHeaderTR\">box color:&nbsp;&nbsp;   <input type=\"button\" class=\"colorclass\" value=\"C\" onClick=\"javascript:popUp('layout/templates/ColorPicker.htm')\"></td>
	</tr><tr>
<td class=\"classData\" width=\"33%\" align=\"center\"><input type=\"text\" name=\"block[block_coltable]\"  value=\"".$block['block_coltable']."\"  size=\"9\" maxlength=\"7\">&nbsp;<A HREF=\"#\" onClick=\"cp.select(document.forms[0]['block[block_coltable]'],'pick');return false;\" NAME=\"pick\" ID=\"pick\"><img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0></a>&nbsp;&nbsp;<span style=\"background: ".$block['block_coltable']."; border: 1px solid #000000; \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</td>
<td class=\"classData\" width=\"33%\" align=\"center\"><input type=\"text\" name=\"block[block_coltitle]\"  value=\"".$block['block_coltitle']."\"  size=\"9\" maxlength=\"7\">&nbsp;<A HREF=\"#\" onClick=\"cp.select(document.forms[0]['block[block_coltitle]'],'pick2');return false;\" NAME=\"pick2\" ID=\"pick2\"><img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0></a>&nbsp;&nbsp;<span style=\"background: ".$block['block_coltitle']."; border: 1px solid #000000; \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</td>
<td class=\"classData\" width=\"33%\" align=\"center\"><input type=\"text\" name=\"block[block_colbox]\"    value=\"".$block['block_colbox']."\"    size=\"9\" maxlength=\"7\">&nbsp;<A HREF=\"#\" onClick=\"cp.select(document.forms[0]['block[block_colbox]'],'pick3');return false;\" NAME=\"pick3\" ID=\"pick3\"><img src=\"images/admin/show-colorpicker.gif\" align=\"top\" border=0></a>&nbsp;&nbsp;<span style=\"background: ".$block['block_colbox']."; border: 1px solid #000000; \">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</td>
	</tr><tr>
<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">Break space?</td>
<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">block image?</td>
<td valign=\"top\" class=\"classHeaderTR\" width=\"33%\">null</td>
</tr><tr>";

$descbr=array(0=>""._THEMENO."",1=>""._THEMEYES."", 2=>""._THEMEBRDIV."", 3=>""._THEMEBRCSS."", 4=>""._THEMEBRLINE."");
echo "<td class=\"classData\" align=\"center\" width=\"33%\">
<select name=\"block[block_break]\">";
for ($i=0; $i<sizeof($descbr); $i++) {
	if ($block['block_break']==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$descbr[$i]."</option>";
}
echo "</select></td>"; 
$descsameimg=array(0=>""._THEMEIMGNONOTITLE."",1=>""._THEMEIMGNO."", 2=>""._THEMEIMGNOTITLE."", 3=>""._THEMEIMGDIFF."", 4=>""._THEMEIMGSAME."");
echo "<td class=\"classData\" align=\"center\"  width=\"33%\">
<select name=\"block[block_image]\">";
for ($i=0; $i<sizeof($descsameimg); $i++) {
	if ($block['block_image']==$i) { $sel="selected"; } else {$sel="";}
	echo "<option value=\"$i\" $sel>".$descsameimg[$i]."</option>";
}
echo "</select></td> 
<td class=\"classData\" align=\"center\"  width=\"33%\"><input type='text' name='null' id='null' size='25' maxlength='0' readonly></td>\n";
echo "
</tr>
</table><br>";
if ($function == "edit") {
	$blocksave = "proxima_blocks_edit_save";
	$button = _SAVE;
} else {
	$blocksave = "proxima_blocks_add_save";
	$button = _ADDBLOCK;
}
echo "<br>
<div align=\"center\">
    <input type=\"hidden\" name=\"pageid\" value=\"".$pageid."\">
    <input type=\"hidden\" name=\"blockid\" value=\"".$blockid."\">
	<input type=\"hidden\" name=\"op\" value=\"".$blocksave."\">
	<input type=\"submit\" value=\"".$button."\" class=\"classButton\"><br>
</div>
</form><br>
<div align=\"center\" class=\"classHeaderTD\">&nbsp;&nbsp;</div>
<form action=\"admin.php\" method=\"post\">
<br><div align=\"left\">
&nbsp;&nbsp;"._COPYBLOCKSSETTING."&nbsp;&nbsp;
<select name=\"block_templ\">";
$query = "SELECT webblocks.page_id page_id, webblocks.block_id block_id, webblocks.block_title block_title, webpages.page_title page_title
          FROM ".$prefix."_webpages as webpages
          INNER JOIN ".$prefix."_webblocks as webblocks ON (webpages.page_id = webblocks.page_id)
          ORDER BY webblocks.page_id, webblocks.block_id";
$result = $db->sql_query($query);
while($block_templ = $db->sql_fetchrow($result)) {
	$i++;
	echo "<option value=\"".substr("-----".$block_templ['page_id'],-5).substr("-----".$block_templ['block_id'],-5)."\">[".$block_templ['page_id']."] ".$block_templ['page_title']." - [".$block_templ['block_id']."] ".$block_templ['block_title']."</option>\n";
}    
echo "</select>&nbsp;
<input type=\"hidden\" name=\"pageid\"  value=\"".$pageid."\">
<input type=\"hidden\" name=\"blockid\" value=\"".$blockid."\">
<input type=\"hidden\" name=\"op\" value=\"proxima_copyblock_save\">
&nbsp;"._COPYALLBLOCKS."&nbsp;&nbsp;
<input type=\"checkbox\" name=\"allblocks\" value=\"1\"><br><br>";
echo "&nbsp;&nbsp;"._COPYBLOCKFORMODULE."&nbsp;&nbsp;
<select name=\"page_templ\">
<option value = \"0\">&nbsp;&nbsp;</option>";
$query = "SELECT page_id, page_title
          FROM ".$prefix."_webpages 
          ORDER BY page_title";
$result = $db->sql_query($query);
while($page_templ = $db->sql_fetchrow($result)) {
	echo "<option value=\"".$page_templ['page_id']."\">".$page_templ['page_title']."</option>\n";
}    
echo "</select>&nbsp;
<input type=\"submit\" value=\""._GO."\" class=\"classButton\"><hr>
</form><br>"._GOBACK."<br><br></div>";
     Closetable();
}
//-----------------------------------------------------
//--- save a block added
//-----------------------------------------------------
function proxima_blocks_add_save() {
	global $prefix, $db;
//	include("layout/includes/proxima_debug.php");
	$pageid  = $_POST['pageid'];
	$blockid = $_POST['blockid'];
	$block   = $_POST['block'];
	$query = "SELECT MAX(block_weight) as block_weight
    	      FROM ".$prefix."_webblocks 
			  WHERE page_id ='".$pageid."' 
		  	  AND block_position='".$block['block_position']."'";
	$result = $db->sql_query($query);
	$row = $db->sql_fetchrow($result);
	$block['block_weight'] = $row['block_weight']+1;
	//echo "weight: ".$row['block_weight'];
    //break;
	$block['block_key'] = "";
	$block['block_time'] = "";
    if ($block['block_expire'] == "") {
	    $block['block_expire'] = 0;
    }
    if ($block['block_expire'] != 0 AND $block['block_expire'] <= 999) {
    	$block['block_expire'] = time() + ($block['block_expire'] * 86400);
    }
	if ($block['block_file'] != "") {
		$block['block_url'] = "";
		if ($block['block_title'] == "") {
            $blockfile = pathinfo($block['block_file']); 
            $block['block_title'] = $blockfile["basename"];
	    	$block['block_title'] = ereg_replace("block-","",$block['block_title']);
	    	$block['block_title'] = ereg_replace(".php","",$block['block_title']);
	    	$block['block_title'] = ereg_replace("_"," ",$block['block_title']);
		}
	}
//	print_a($block);
//	break;
	if ($block['block_url'] != "") {
		if ($block['block_title'] == "") {
			 $query = "SELECT sitename 
	                   FROM ".$prefix."_headlines
					   WHERE headlinesurl = '".$block['block_url']."'";
    	     $result = $db->sql_query($query);
	         list($sitename) = $db->sql_fetchrow($result);
			 $block['block_title']=$sitename;
		}
		$btime = time();
		if (!ereg("http://",$block['block_url'])) {
	    	$block['block_url'] = "http://$url";
		}
		$rdf = parse_url($block['block_url']);
		$fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
		if (!$fp) {
	    	proxima_rssfail();
	    	exit;
		}
		if ($fp) {
	    	fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n");
	    	fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n");
	    	$string = "";
	    	while(!feof($fp)) {
	    		$pagetext = fgets($fp,228);
	    		$string .= chop($pagetext);
	    	}
	    	fputs($fp,"Connection: close\r\n\r\n");
	    	fclose($fp);
	    	$items = explode("</item>",$string);
	    	$block['block_content'] = "<font class=\"content\">";
	    	for ($i=0;$i<10;$i++) {
				$link = ereg_replace(".*<link>","",$items[$i]);
				$link = ereg_replace("</link>.*","",$link);
				$title2 = ereg_replace(".*<title>","",$items[$i]);
				$title2 = ereg_replace("</title>.*","",$title2);
				if ($items[$i] == "" AND $cont != 1) {
		    		$block['block_content'] = "";
				} else {
		    		if (strcmp($link,$title2) AND $items[$i] != "") {
						$cont = 1;
						$block['block_content'] .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"$link\" target=\"new\">$title2</a><br>\n";
		    		}
				}
	    	}
		}
	}
	$block['block_content'] = FixQuotes($block['block_content']);
	if (($block['block_content'] == "") AND ($block['block_file'] == "")) { 
		proxima_rssfail();
	} else {
    	if ($expire == "") {
        	$expire = 0;
    	}
    	if ($expire != 0) {
        	$expire = time() + ($expire * 86400);
    	}
	}
	$query = "INSERT INTO ".$prefix."_webblocks
	   	  	  SET page_id='".$pageid."', block_id='null' ";
    foreach ($block as $key => $value) {
	    $query .=", ".ereg_replace("'","",stripslashes(trim($key)))."='".$value."'";
    }
    //echo $query;
    //break;
    $query .= "	";
    $result = $db->sql_query($query);
	$query = "ALTER TABLE ".$prefix."_webblocks 
	          ORDER by page_id, block_id";
    $result = $db->sql_query($query);
	proxima_fixweight($pageid);
Header("Location: admin.php?op=proxima_modules&option=block");
}
//-----------------------------------------------------
//--- update blocks (save)
//-----------------------------------------------------
function proxima_blocks_edit_save() {
global $prefix, $db;
$pageid  = $_POST['pageid'];
$blockid = $_POST['blockid'];
$block   = $_POST['block'];
$query .= "UPDATE ".$prefix."_webblocks
	       SET page_id='".$pageid."', block_id='".$blockid."' ";
foreach ($block as $key => $value) {
	$query .=", ".$key." = '".$value."'";
}
$query .= "	WHERE page_id='".$pageid."' AND block_id='".$blockid."'";
   // echo "block title: $block[block_title] <br>block file: $block[block_file]<br><br> QUERY:<br>  $query<br><br>";
   // break;
$result = $db->sql_query($query);
proxima_fixweight($pageid);
$query = "ALTER TABLE ".$prefix."_webblocks 
          ORDER by page_id, block_id";
$result = $db->sql_query($query);
Header("Location: admin.php?op=proxima_blocks_edit&pageid=".$pageid."&blockid=".$blockid."");
}
//-----------------------------------------------------
//--- Copy settings block to block
//-----------------------------------------------------
function proxima_copyblock_save($pageid, $blockid, $block_templ, $allblocks, $page_templ) {
global $prefix, $db;
$page_orig=ereg_replace("-","",substr($block_templ,1,5));
$block_orig=ereg_replace("-","",substr($block_templ,6,5));
$query = "SELECT * 
          FROM ".$prefix."_webblocks 
		  WHERE page_id='".$page_orig."'
		  AND block_id ='".$block_orig."'";
$result=$db->sql_query($query);
$pageUpdate=$db->sql_fetchrow($result);
$field_query = "SHOW FIELDS 
                FROM ".$prefix."_webblocks";
$result=$db->sql_query("$field_query");
$query_update="UPDATE ".$prefix."_webblocks 
               SET ";
while (list($field_name, $field_type, $field_null, $field_key, $field_default, $field_extra)= $db->sql_fetchrow($result)) {
	if ($a>0) { $query_update .=", ";}
	if ($i>15) { $query_update .="$field_name ='".$pageUpdate[$i]."'"; $a=1;}
	$i++;
	}
	if ($allblocks==0 && $page_templ==0 ) {
		$query_update .="  WHERE page_id ='".$pageid."' AND block_id ='".$blockid."'";
	} elseif ($page_templ!=0) {
		$query_update .="  WHERE page_id ='".$page_templ."'";
	} else {
		$query_update .="";
	}
$result = $db->sql_query("$query_update");
Header("Location: admin.php?op=proxima_modules");
}    

//=====================================================
//=== GENERIC FUNCTIONS
//=====================================================
//-----------------------------------------------------
//--- search and show templates zones
//-----------------------------------------------------
function templatezone() {
	$zonetypedir = dir("layout/templates/zones");
	while($zone=$zonetypedir->read()) {
		if(substr($zone, 0, 5) == "zone-") {
    		$zonetypelist .= "$zone ";   
		}
	}
	closedir($zonetypedir->handle);
	return $zonetypelist;
}
//-----------------------------------------------------
//--- search and show templates blocks
//-----------------------------------------------------
function templateblocks() {
	$blockstypedir = dir("layout/templates/blocks");
	while($block=$blockstypedir->read()) {
		if(substr($block, 0, 6) == "block-") {
			$blockstypelist .= "$block ";   
		}
	}
	closedir($blockstypedir->handle);
	return $blockstypelist;
}
//-----------------------------------------------------
//--- search and show prefix for blocks frames
//-----------------------------------------------------
function templateprefix() {
	$prefixdir = dir("layout/images/frames");
	$prefixlist .= "!RIGHT !CENTER !LEFT ";
	while($prefx = $prefixdir->read()) {
		if (eregi("-middle-center.gif",$prefx) || eregi("-divider.gif",$prefx)) {
			$prefx = eregi_replace("-middle-center.gif","",$prefx);
			$prefx = eregi_replace("-divider.gif","",$prefx);
   			$prefixlist .= "$prefx ";
		}
	}
	closedir($prefixdir->handle);
	return $prefixlist;
}
//-----------------------------------------------------
//--- search and show blocks
//-----------------------------------------------------
function searchblocks() {
global $prefix, $db;
	$blocksdir = dir("blocks");
    while($func=$blocksdir->read()) {
    	if(substr($func, 0, 6) == "block-") {
        	$blockslist .= "$func ";
        }
    }
    closedir($blocksdir->handle);
    $result = $db->sql_query("SELECT page_title 
	                          FROM ".$prefix."_webpages ");
	while ($row = $db->sql_fetchrow($result)) {
	  if (is_dir("modules/".$row[title]."/blocks")) {
	    $blocksdir = dir("modules/".$row[title]."/blocks");
          while($func=$blocksdir->read()) {
    	    if(substr($func, 0, 6) == "block-") {
        	  $blockslist .= "$func ";
            }
          }
        closedir($blocksdir->handle);
      } 
    }
    return $blockslist;
}
//-----------------------------------------------------
//--- search and show font for dyntext
//-----------------------------------------------------
function dyntext_font() {
	$dynfontdir = dir("layout/includes/dynText/fonts");
	while($dyn=$dynfontdir->read()) {
		if ((eregi(".ttf",$dyn))) {
			$dyn=eregi_replace(".ttf","",$dyn);
   			$dynfontlist .= "$dyn ";
		}
	}
	closedir($dynfontdir->handle);
	return $dynfontlist;
}
//-----------------------------------------------------
//--- read images and write preview.htm
//-----------------------------------------------------
function previewprefix() {
$prefixdir = dir("layout/images/frames");
while($prefx=$prefixdir->read()) {
	if ((eregi("-middle-center.gif",$prefx))) {
    	$prefixlist .= "$prefx ";
	}
}
closedir($prefixdir->handle);
$prefixlist = explode(" ",$prefixlist);
sort($prefixlist);
$filepreview = fopen("layout/templates/preview.htm", "w");
for ($i=1; $i < sizeof($prefixlist); $i++) {
	if($prefixlist[$i]!="") { $prefixlist[$i]=eregi_replace("-middle-center.gif","",$prefixlist[$i]);}
	$th=$i+1;$t1h=$i+2;$t2h=$i+3;$bh=$i+4;$lw=$i+5;$rw=$i+6;$xth=$i+7;$xbh=$i+8;$xlw=$i+9;$xrw=$i+10;
	$topheight  =@getimagesize("layout/images/frames/$prefixlist[$i]-top-left.gif");
	$tabheight  =@getimagesize("layout/images/frames/$prefixlist[$i]-tab-left.gif");
	$tab2height =@getimagesize("layout/images/frames/$prefixlist[$i]-tab2-left.gif");
	$botheight  =@getimagesize("layout/images/frames/$prefixlist[$i]-bottom-left.gif");
	$leftwidth  =@getimagesize("layout/images/frames/$prefixlist[$i]-middle-left.gif");
	$rightwidth =@getimagesize("layout/images/frames/$prefixlist[$i]-middle-right.gif");
	$xtopheight =@getimagesize("layout/images/frames/$prefixlist[$i]-xtop-left.gif");
	$xbotheight =@getimagesize("layout/images/frames/$prefixlist[$i]-xbottom-left.gif");
	$xleftwidth =@getimagesize("layout/images/frames/$prefixlist[$i]-xtop-left.gif");
	$xrightwidth=@getimagesize("layout/images/frames/$prefixlist[$i]-xbottom-right.gif");
// SCRIVE IL FILE PREVIEW.HTM //
$preview .="<hr><div align=center>$i: <b>$prefixlist[$i]</b><br></div>\n";
$preview .="<!-- END MAIN --><table width=300 cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\">\n";
if ($xtopheight[1]>0) {
	$preview .="<!-- XTOP --><tr><td><table width=100% cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td background=\"../images/frames/$prefixlist[$i]-xtop-left.gif\" height=$xtopheight[1] width=$xleftwidth[0]></td><td background=\"../images/frames/$prefixlist[$i]-xtop-center.gif\" height=$xtopheight[1]>&nbsp;</td><td background=\"../images/frames/$prefixlist[$i]-xtop-right.gif\" height=$xtopheight[1] width=$xrightwidth[0]></td></tr></table></td></tr><!-- END XTOP -->\n";
}
$preview .="<!-- SUBMAIN --><tr><td><table width=100% cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\">\n";
if ($topheight[1]>0) {
	$preview .="<!-- TOP --><tr><td background=\"../images/frames/$prefixlist[$i]-top-left.gif\" height=$topheight[1] width=$leftwidth[0]></td><td background=\"../images/frames/$prefixlist[$i]-top-center.gif\" height=$topheight[1]>&nbsp;</td>       <td background=\"../images/frames/$prefixlist[$i]-top-right.gif\" height=$topheight[1] width=$rightwidth[0]></td></tr><!-- END TOP -->\n";
}
if ($tabheight[1]>0) {
	$preview .="<!-- TAB --><tr><td background=\"../images/frames/$prefixlist[$i]-tab-left.gif\" height=$tabheight[1] width=$leftwidth[0]></td><td background=\"../images/frames/$prefixlist[$i]-tab-center.gif\" height=$tabheight[1]>		<font class=$prefixlist[$i]-tab-blocktitle>TITLE\n 		<td background=\"../images/frames/$prefixlist[$i]-tab-right.gif\" height=$tabheight[1] width=$rightwidth[0]></td></tr><!-- END TAB -->\n";
}
$preview .="<!-- page_idDLE --><tr><td background=\"../images/frames/$prefixlist[$i]-middle-left.gif\" width=$leftwidth[0]</td><td background=\"../images/frames/$prefixlist[$i]-middle-center.gif\">here<br>the content<br>of block<br></td>       <td background=\"../images/frames/$prefixlist[$i]-middle-right.gif\" width=$rightwidth[0]></td></tr><!-- END page_idDLE -->\n";
if ($tab2height[1]>0) {
	$preview .="<!-- TAB2 --><tr><td background=\"../images/frames/$prefixlist[$i]-tab2-left.gif\" height=$tab2height[1] width=$leftwidth[0]></td><td background=\"../images/frames/$prefixlist[$i]-tab2-center.gif\" height=$tab2height[1]>&nbsp;</td>       <td background=\"../images/frames/$prefixlist[$i]-tab2-right.gif\" height=$tab2height[1] width=$rightwidth[0]></td></tr><!-- END TAB2 -->\n";
}
if ($botheight[1]>0) {
	$preview .="<!-- BOTTOM --><tr><td background=\"../images/frames/$prefixlist[$i]-bottom-left.gif\" height=$botheight[1] width=$leftwidth[0]></td><td background=\"../images/frames/$prefixlist[$i]-bottom-center.gif\" height=$botheight[1]></td>       <td background=\"../images/frames/$prefixlist[$i]-bottom-right.gif\" height=$botheight[1] width=$rightwidth[0]></td></tr><!-- BOTTOM -->\n";
}
$preview .="</td></tr></table><!-- END SUBMAIN -->\n";
if ($xbotheight[1]>0) {
	$preview .="<!-- XBOT --><tr><td><table width=100% cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tr><td background=\"../images/frames/$prefixlist[$i]-xbottom-left.gif\"   height=$xbotheight[1] width=$xleftwidth[0]></td>    <td background=\"../images/frames/$prefixlist[$i]-xbottom-center.gif\" height=$xbotheight[1]>&nbsp;</td>    <td background=\"../images/frames/$prefixlist[$i]-xbottom-right.gif\" height=$xbotheight[1] width=$xrightwidth[0]></td></tr></table></td></tr><!-- END XBOT -->\n";
}
$preview .="</td></tr></table><!-- END MAIN -->\n";
$preview .="<br><br><br>\n";
//
	}
fwrite($filepreview, $preview);
fclose($filepreview);
$prefixlist= implode(" ",$prefixlist);
}
//-----------------------------------------------------
//--- addslashes
//-----------------------------------------------------
function addslashes_array($array) {
  foreach ($array as $key => $val) {
    $array[$key] = (is_array($val)) ? addslashes_array($val) : addslashes($val);
  }
  return $array;
}
//-----------------------------------------------------
//--- show a select row
//-----------------------------------------------------
function show_generic_select_row($name, $value, $matrix="") {
  	echo "<select name=".$name.">\n";
	foreach ($matrix as $key => $valuematrix) {
		if ($key==$value) { $sel="SELECTED"; } else { $sel=""; }
		echo "<option value=\"".$key."\" $sel>".$valuematrix."</option>";
	}
  	echo "</select>\n";
}
//-----------------------------------------------------
//--- insert new modules into DB
//-----------------------------------------------------
function proxima_insert_new_modules() {
	global $prefix, $db;
	$handle=opendir('modules');
	while ($file = readdir($handle)) {
		if ( (!ereg("[.]",$file)) ) {
    		$modlist .= "$file ";
    	}
	}
	closedir($handle);
	$modlist = explode(" ", $modlist);
	sort($modlist);
	$result=$db->sql_query("ALTER TABLE ".$prefix."_webpages AUTO_INCREMENT = 1");
	for ($i=0; $i < sizeof($modlist); $i++) {
  		if($modlist[$i] != "") {
    	$query = "SELECT page_id 
	              FROM ".$prefix."_webpages 
				  WHERE page_title='$modlist[$i]'";
			$result=$db->sql_query($query);
        	list ($page_id) = $db->sql_fetchrow($result);
    		if ($page_id == "") {
	  			$query = "SELECT * 
	  					  FROM ".$prefix."_webpages 
	  					  WHERE page_home='1'";
				$result2=$db->sql_query($query);
	  			$webpage_base=$db->sql_fetchrow($result2,0);
	  			$query="INSERT INTO ".$prefix."_webpages 
	  					VALUES ('null', '$modlist[$i]', '$modlist[$i]', '0', '0', '0'";
	  			for ($a=6;$a<93; $a++) {
	    			$query .= ", '".$webpage_base[$a]."' ";
	  			}
	  			$query .=")";
	  			$db->sql_query($query);
    		}
  		}
	}
}
//-----------------------------------------------------
//--- delete old modules from DB
//-----------------------------------------------------
function proxima_delete_old_modules() {
	global $prefix, $db;
	$query = "SELECT page_id, page_title 
			  FROM ".$prefix."_webpages";
	$result=$db->sql_query($query);
	while (list($pageid, $page['page_title']) = $db->sql_fetchrow($result)) {
  		$a = 0;
		$handle=opendir('modules');
  		while ($file = readdir($handle)) {
      		if ($file == $page['page_title']) { $a = 1; }
  		}
  		closedir($handle);
  		if ($a == 0 && !ereg("!",$page['page_title'])) {
    		$query = "DELETE FROM ".$prefix."_webpages
					  WHERE page_title='".$page['page_title']."'";
			$db->sql_query($query);
    		$query = "DELETE FROM ".$prefix."_webblocks
					  WHERE page_id='$pageid'";
			$db->sql_query($query);
  		}
	}
}
//=====================================================
//=== FUNCTIONS FOR CREATE MODULES AND BLOCKS NEW
//=====================================================
//-----------------------------------------------------
//--- create a new module [start]
//-----------------------------------------------------
function proxima_newmodblock_create() {
	include("header.php");
	GraphicAdmin();
	Opentable();
	echo "
	<table class=\"classTable\" width=\"100%\">
	<tr>
	<td class=\"classData\" width=\"50%\">
	<br><div align=\"center\"><img src=\"images/admin/newmodule.gif\" border=\"0\" alt=\""._MODULECREATENEW."\"></div><br>
	<div align=\"center\">"._MODULECREATENEW."<br>
	<form action=\"admin.php\" method=\"post\">
	<input type=\"hidden\" name=\"op\" value=\"proxima_newmodule_edit\">
	<br><input type=\"submit\" value=\""._CREATENEWMODULE."\" class=\"classButton\"><br><br>
	</form></div>
	<td class=\"classData\" width=\"50%\">
	<br><div align=\"center\"><img src=\"images/admin/newblock.gif\" border=\"0\" alt=\""._BLOCKCREATENEW."\"></div><br>
	<div align=\"center\">"._BLOCKCREATENEW."<br>
	<form action=\"admin.php\" method=\"post\">
	<input type=\"hidden\" name=\"op\" value=\"proxima_newblock_edit\">
	<br><input type=\"submit\" value=\""._CREATENEWBLOCK."\" class=\"classButton\"><br><br>
	</form></div>
	</td></tr></table>";
	Closetable();
	include("footer.php");
}
//-----------------------------------------------------
//--- create a new module 
//-----------------------------------------------------
function proxima_newmodule_edit() {
include("header.php");
GraphicAdmin();
Opentable();
echo "<form action=\"admin.php\" method=\"post\">"
."<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"><tr>"
."<td width=\"30%\" class=\"classHeaderTD\">"._NAMEOFNEWMODULE."</td>"
."<td class=\"classData\"><input type=\"text\" name=\"dirnewmodule\" value=\"\" size=\"30\"></td>"
."</tr><tr>"
."<td  width=\"30%\" valign=\"top\" class=\"classHeaderTD\">"._CONTENTOFNEWMODULE."</td>"
."<td class=\"classData\"><textarea cols=\"80\" rows=\"20\" name=\"contentnewmodule\" value=\"\"></textarea></td>"
."</tr><tr>"
."<td class=\"classHeaderTD\"><b>Type</b><br>(html / php)</td>"
."<td class=\"classData\">
<select name=\"type\">
	<option value=\"0\" SELECTED>null</option>
	<option value=\"1\">html</option>
	<option value=\"2\">php</option>
</select>
</td>"
."</tr><tr>"
."<td colspan=\"2\" align=\"center\" valign=\"top\" >"
."<input type=\"hidden\" name=\"op\" value=\"proxima_newmodule_save\">"
."<br><input type=\"submit\" value=\""._CONFIRMCREATENEW."\" class=\"classButton\"><br></td>"
."</tr></table>"
."</form>";
Closetable();
echo "<div align=\"left\">";copyright($proxima); echo "</div>";
include("footer.php");
}
//-----------------------------------------------------
//--- save a new module 
//-----------------------------------------------------
function proxima_newmodule_save($dirnewmodule, $contentnewmodule, $type) {
    include("header.php");
    GraphicAdmin();
    Opentable();
	$totalcontent  ="<?php\n";
    $totalcontent .="/************************************************************************/\n";
    $totalcontent .="/* Code generated with PROXIMA-LAYOUT                                   */\n";
    $totalcontent .="/* Copyright (c) 2003-2004 Roberto Beltrame (hide@address.com) */\n";
    $totalcontent .="/* http://www.php-proxima.com                                           */\n";
    $totalcontent .="/************************************************************************/\n";
    $totalcontent .="/* please dont remove this copyright please dont remove this copyright  */\n";
    $totalcontent .="/************************************************************************/\n";
    $totalcontent .="/* based on:                                                            */\n";
    $totalcontent .="/* PHP-NUKE: Advanced Content Management System                         */\n";
    $totalcontent .="/* Copyright (c) 2002 by Francisco Burzi                                */\n";
    $totalcontent .="/* http://phpnuke.org                                                   */\n";
    $totalcontent .="/************************************************************************/\n";
    $totalcontent .="/* This program is free software. You can redistribute it and/or modify */\n";
    $totalcontent .="/* it under the terms of the GNU General Public License as published by */\n";
    $totalcontent .="/* the Free Software Foundation; either version 2 of the License.       */\n";
    $totalcontent .="/************************************************************************/\n";
	$totalcontent .="if (!defined('MODULE_FILE')) {\n    die (\"You can't access this file directly...\");}\n	require_once(\"mainfile.php\");\n	\$module_name = basename(dirname(__FILE__));\n	include(\"header.php\");\n";
	switch ($type){
    case "0":
		$totalcontent .="\n";
    break;
    case "1":
		$contentnewmodule=Fixquotes($contentnewmodule);
		$totalcontent .="    Opentable();\n ";
		$totalcontent .="	  echo \"\n $contentnewmodule \";\n";
		$totalcontent .="    Closetable();\n";
    break;
    case "2":
		$contentnewmodule=stripslashes($contentnewmodule);
		$totalcontent .="$contentnewmodule \n";
    break;
	}
	$totalcontent .="    include(\"footer.php\");\n ?>\n";
	$dirnewmodule = ereg_replace(" ", "_", "$dirnewmodule");
	@chmod("modules", 0755);
	if (is_dir("modules/$dirnewmodule")) {
	    echo ""._NEWMODULECREATENOTPOSSIBLE."<hr><br>";
		echo "<input type=\"checkbox\" name=\"scrittura\" value=\"1\" checked disabled>&nbsp;&nbsp;$dirnewmodule:&nbsp;"._NEWMODULEEXIST."<br><br><div align=\"center\">"._GOBACK."<br><br></div>";
	} elseif (!is_writeable("modules")) { 
	    echo ""._NEWMODULECREATENOTPOSSIBLE."<hr><br>";
		echo "<input type=\"checkbox\" name=\"scrittura\" value=\"1\" checked disabled>&nbsp;&nbsp;$dirnewmodule:&nbsp;"._NEWMODULECHMOD."<br><br><div align=\"center\">"._GOBACK."<br><br></div>";
	} else {
	    $oldumask = umask(0);
    	$result = mkdir("modules/".$dirnewmodule."", 0775);
    	umask($oldumask);
    	if (!@is_dir("modules/".$dirnewmodule."") || !$result) {
		  $result = mkdir("modules/".$dirnewmodule."", 0775);
		  @chmod("modules/".$dirnewmodule."", 0775);
		}
		$file = fopen("modules/".$dirnewmodule."/index.php","w");
		fwrite($file, $totalcontent);
		fclose($file);
		@chmod("modules/".$dirnewmodule."/index.php", 0666);
		echo "<div align=\"center\"><br><br><b>".$dirnewmodule."</b>:&nbsp;"._NEWMODULECREATE."<br><br><a href=admin.php?op=proxima_modules>LAYOUT</a><br></div><br><br>";
	}
    Closetable();
	echo "<br><br>";
    include("footer.php");
}
//-----------------------------------------------------
//--- create a new block
//-----------------------------------------------------
function proxima_newblock_edit() {
include("header.php");
GraphicAdmin();
Opentable();
echo "<form action=\"admin.php\" method=\"post\">"
."<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"><tr>"
."<td width=\"30%\" class=\"classHeaderTD\">"._NAMEOFNEWBLOCK."</td>"
."<td class=\"classData\"><input type=\"text\" name=\"dirnewblock\" value=\"\" size=\"30\"></td>"
."</tr><tr>"
."<td  width=\"30%\" valign=\"top\" class=\"classHeaderTD\">"._CONTENTOFNEWBLOCK."</td>"
."<td class=\"classData\"><textarea cols=\"80\" rows=\"20\" name=\"contentnewblock\" value=\"\"></textarea></td>"
."</tr><tr>"
."<td class=\"classHeaderTD\"><b>Type</b><br>(html / php)</td>"
."<td class=\"classData\">
<select name=\"type\">
	<option value=\"1\" SELECTED>html</option>
	<option value=\"2\">php</option>
</select>
</td>"
."</tr><tr>"
."<td colspan=\"2\" align=\"center\" valign=\"top\" >"
."<input type=\"hidden\" name=\"op\" value=\"proxima_newblock_save\">"
."<br><input type=\"submit\" value=\""._CONFIRMCREATENEWBLOCK."\" class=\"classButton\"><br></td>"
."</tr></table>"
."</form>";
Closetable();
echo "<div align=\"left\">";copyright($proxima); echo "</div>";
include("footer.php");
}
//-----------------------------------------------------
//--- save a new block
//-----------------------------------------------------
function proxima_newblock_save($dirnewblock, $contentnewblock, $type) {
    include("header.php");
    GraphicAdmin();
    Opentable();
	switch ($type){
    case "1":
		$totalcontent="<?php\nif (eregi(\"block-$dirnewblock.php\", \$PHP_SELF)) {\n	Header(\"Location: index.php\");\n	die();\n}\n\n";
		$contentnewmodule=Fixquotes($contentnewblock);
		$totalcontent .="\$content=\"\n $contentnewblock \";\n";
		$totalcontent .=" \n ?>\n";
    break;
    case "2":
		$totalcontent="<?php\nif (eregi(\"block-$dirnewblock.php\", \$PHP_SELF)) {\n  Header(\"Location: index.php\");\n  die();\n}\n	?>\n";
		$contentnewblock=stripslashes($contentnewblock);
		$totalcontent .="$contentnewblock \n";
    break;
	}
	
	if (!is_writeable("blocks")) { 
	    echo "<br><br>"._NEWBLOCKCREATENOTPOSSIBLE."<br><br><hr><br>";
		echo "<input type=\"checkbox\" name=\"scrittura\" value=\"1\" checked disabled>&nbsp;&nbsp;$dirnewmodule:&nbsp;"._NEWMODULECHMOD."<br><br><div align=\"center\">"._GOBACK."<br><br></div>";
	} else {	
    $file = fopen("blocks/block-$dirnewblock.php","w");
	fwrite($file, $totalcontent);
	fclose($file);
	//@chmod("blocks",0755);
	echo "<br><br><div align=\"center\">"._NEWBLOCKCREATE."</div><br><br><div align=\"center\"><a href=admin.php?op=proxima_modules>LAYOUT</a><br><br><br></div><b>$dirnewmodule</b>";
	}
    Closetable();
    include("footer.php");
}
//-----------------------------------------------------
//--- palette
//-----------------------------------------------------
function proxima_palette() {
$palette=file("layout/palettes/PspPalette.cfm");
for ($i=0; $i < sizeof($palette); $i++) {

    $newpalettevar[$i] = explode(" ", $palette[$i]);
	  echo $newpalettevar[1].$newpalettevar[2].$newpalettevar[3]."<br>";
}


}

//-----------------------------------------------------
//--- SWITCH FUNCTIONS
//-----------------------------------------------------
switch ($op){
    case "proxima_modules":
    proxima_modules($option);
    break;
//-----------------------------------------------------
    case "proxima_module_status":
    proxima_module_status();
    break;
//-----------------------------------------------------
    case "proxima_module_wysiload":
    proxima_module_wysiload();
    break;
//-----------------------------------------------------
    case "proxima_block_status":
    proxima_block_status();
    break;
//-----------------------------------------------------
    case "proxima_block_action":
    proxima_block_action();
    break;
//-----------------------------------------------------
    case "proxima_blocks_position":
    proxima_blocks_position($pageid, $blockid, $position);
    break;
//-----------------------------------------------------
    case "proxima_module_menu":
    proxima_module_menu($pageid, $status);
    break;
//-----------------------------------------------------
    case "proxima_changecolumns":
    proxima_changecolumns($pageid, $columns);
    break;
//-----------------------------------------------------
    case "proxima_changepriority":
    proxima_changepriority($pageid, $priority);
    break;
//-----------------------------------------------------
	case "proxima_changeviewfrom":
	proxima_changeviewfrom($pageid, $blockid, $viewfrom, $viewto, $table, $option);
	break;
//-----------------------------------------------------
	case "proxima_changeviewmod":
	proxima_changeviewmod($pageid, $blockid, $viewfrom, $viewto, $table, $option);
	break;
//-----------------------------------------------------
	case "proxima_changeviewmodgroup":
	proxima_changeviewmodgroup($pageid, $viewto);
	break;	
//-----------------------------------------------------
	case "proxima_changeviewto":
	proxima_changeviewto($pageid, $blockid, $viewfrom, $viewto, $table, $option);
	break;
//-----------------------------------------------------
    case "proxima_module_edit":
    proxima_module_edit($pageid);
    break;
//-----------------------------------------------------
    case "proxima_blocks_associate":
	proxima_blocks_associate($pageid, $blockid);
	break;
//-----------------------------------------------------
	case "proxima_copymodule_save":
	proxima_copymodule_save($pageid, $mid_templ, $allmodules);
    break;
//-----------------------------------------------------
	case "proxima_copyblock_save":
	proxima_copyblock_save($pageid, $blockid, $block_templ, $allblocks, $page_templ);
    break;
//-----------------------------------------------------
    case "proxima_module_edit_save":
    proxima_module_edit_save($pageid, $pageEdit, $stylemodule, $style, $styletables);
    break;
//-----------------------------------------------------
    case "proxima_home_module":
    proxima_home_module($pageid);
    break;
//-----------------------------------------------------
    case "proxima_blocks_add_save":
    proxima_blocks_add_save();
    break;
//-----------------------------------------------------
    case "proxima_blocks_edit":
    proxima_blocks_edit($pageid,$blockid);
    break;
//-----------------------------------------------------
    case "proxima_blocks_edit_save":
    proxima_blocks_edit_save();
    break;
//-----------------------------------------------------
    case "proxima_ChangeStatus":
    proxima_ChangeStatus($pageid, $block[block_id], $ok, $de);
    break;
//-----------------------------------------------------
    case "proxima_blocks_delete":
    proxima_blocks_delete();
    break;
//-----------------------------------------------------
    case "proxima_blocks_order":
    proxima_blocks_order($pageid, $weightrep, $weight, $bidrep, $bidori, $header, $option);
    break;
//-----------------------------------------------------
    case "proxima_fixweight":
    proxima_fixweight($pageid);
    break;
//-----------------------------------------------------
    case "proxima_block_show":
    proxima_block_show($pageid,$blockid);
    break;
//------------------------------------------------------------
    case "layoutMenuBuilderchoose":
        Menu_javascript_list();
    break;
//-----------------------------------------------------
    case "proxima_newmodblock_create":
    	proxima_newmodblock_create();
    break;
//-----------------------------------------------------
	case "proxima_newmodule_edit":
    	proxima_newmodule_edit();
    break;
//-----------------------------------------------------
    case "proxima_newmodule_save":
    	proxima_newmodule_save($dirnewmodule, $contentnewmodule, $type);
    break;
//-----------------------------------------------------
    case "proxima_newblock_edit":
    	proxima_newblock_edit();
    break;
//-----------------------------------------------------
    case "proxima_newblock_save":
    	proxima_newblock_save($dirnewblock, $contentnewblock, $type);
    break;
//-----------------------------------------------------
    case "proxima_palette":
    	proxima_palette();
    break;
//-----------------------------------------------------
}
} else {
    echo "Access Denied";
}


?>

Return current item: PHP-PROXIMA