Location: PHPKode > projects > ViperWeb Portal System > httpdocs/modules/Admin/modules/themes.php
<?php

/************************************************************************/
/* ViperWeb: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Raptr & Godboko                                */
/* http://development.ea-hq.net                                         */
/*                                                                      */
/* 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.       */
/*                                                                      */
/* Based on PHP-Nuke found at http://www.phpnuke.org                    */
/************************************************************************/



$result = sql_query("select radminsuper from ".$prefix."_users where aid='$aid'", $dbi);
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {

/*********************************************************/
/* REVIEWS Block Functions                               */
/*********************************************************/

function modules() {
    global $prefix, $dbi, $multilingual, $bgcolor2;
    include ("includes/admin/header.php");
    
    GraphicAdmin();
    OpenTable();
    echo "<center><font class=\"title\"><b>Themes Administration</b></font></center>";
    CloseTable();
    $handle=opendir('themes');
    while ($file = readdir($handle)) {
	if ( (!ereg("[.]",$file)) ) {
		$themes .= "$file ";
	}
    }
    closedir($handle);
    $themes = explode(" ", $themes);
    sort($themes);
    for ($i=0; $i < sizeof($themes); $i++) {
	if($themes[$i] != "") {
	    $result = sql_query("select tid from ".$prefix."_main_themes where name='$themes[$i]'", $dbi);
	    list ($tid) = sql_fetch_row($result, $dbi);
	    if ($mid == "") {
		sql_query("insert into ".$prefix."_main_themes values (NULL, '$themes[$i]', '1')", $dbi);
	    }
	}
    }
    $result = sql_query("select name from ".$prefix."_main_themes", $dbi);
    while (list($title) = sql_Fetch_row($result, $dbi)) {
	$a = 0;
	$handle=opendir('themes');
	while ($file = readdir($handle)) {
	    if ($file == $title) {
		$a = 1;
	    }
	}
	closedir($handle);
	if ($a == 0) {
	    sql_query("delete from ".$prefix."_main_themes where name='$title'", $dbi);
	}
    }
    echo "<br>";
    OpenTable();
    echo "<br><center><font class=\"option\">Themes and Themes (not Modules and Addons (inside joke that only the head coder will understand))</font><br><br>"
	."<font class=\"content\">Turn themes on and off and hopefully edit their content soon!!!!!!!!!!!!!!!!!!!</font><br><br>"
	."<form action=\"index.php?mod=Admin\" method=\"post\">"
        ."<table border=\"1\" align=\"center\" width=\"90%\"><tr><td align=\"center\" bgcolor=\"$bgcolor2\">"
	."<b>"._TITLE."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._CUSTOMTITLE."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._STATUS."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._VIEW."</b></td><td align=\"center\" bgcolor=\"$bgcolor2\"><b>"._FUNCTIONS."</b></td></tr>";
    $main_m = sql_query("select main_module from ".$prefix."_main", $dbi);
    list($main_module) = sql_fetch_row($main_m, $dbi);
    $result = sql_query("select mid, title, custom_title, active, view from ".$prefix."_main_themes order by title ASC", $dbi);
    while(list($mid, $title, $custom_title, $active, $view) = sql_fetch_row($result, $dbi)) {
	if ($active == 1) {
	    $active = _ACTIVE;
	    $change = _DEACTIVATE;
	    $act = 0;
	} else {
	    $active = "<i>"._INACTIVE."</i>";
	    $change = _ACTIVATE;
	    $act = 1;
	}
	if ($custom_title == "") {
	    $custom_title = ereg_replace("_", " ", $title);
	}
	echo "<tr><td $background>&nbsp;$title</td><td align=\"center\" $background>$custom_title</td><td align=\"center\" $background>$active</td><td align=\"center\" $background>$who_view</td><td align=\"center\" $background>[ <a href=\"index.php?mod=Admin&op=module_edit&mid=$mid\">"._EDIT."</a> | $change_status | $puthome ]</td></tr>";
    }
    echo "</table>";
    CloseTable();
    include ("includes/admin/footer.php");
}

function module_status($mid, $active) {
    global $prefix, $dbi;
    sql_query("update ".$prefix."_main_themes set active='$active' where mid='$mid'", $dbi);
    Header("Location: index.php?mod=Admin&op=modules");
}

function module_edit($mid) {
    global $prefix, $dbi;
    $main_m = sql_query("select main_module from ".$prefix."_main", $dbi);
    list($main_module) = sql_fetch_row($main_m, $dbi);
    $result = sql_query("select title, custom_title, view from ".$prefix."_main_themes where mid='$mid'", $dbi);
    list($title, $custom_title, $view) = sql_fetch_row($result, $dbi);
    include ("includes/admin/header.php");
    
    GraphicAdmin();
    title(""._MODULEEDIT."");
    OpenTable();
    if ($view == 0) {
	$sel1 = "selected";
	$sel2 = "";
	$sel3 = "";
    } elseif ($view == 1) {
	$sel1 = "";
	$sel2 = "selected";
	$sel3 = "";
    } elseif ($view == 2) {
	$sel1 = "";
	$sel2 = "";
	$sel3 = "selected";    
    }
    if ($title == $main_module) {
	$a = " - "._INHOME."";
    } else {
	$a = "";
    }
    echo "<center><b>"._CHANGEMODNAME."</b><br>($title$a)</center><br><br>"
	."<form action=\"index.php?mod=Admin\" method=\"post\">"
	."<table border=\"0\"><tr><td>"
	.""._CUSTOMMODNAME."</td><td>"
	."<input type=\"text\" name=\"custom_title\" value=\"$custom_title\" size=\"50\"></td></tr>";
    if ($title == $main_module) {
	echo "<input type=\"hidden\" name=\"view\" value=\"0\">"
	    ."</table><br><br>";
    } else {
	echo "<tr><td>"._VIEWPRIV."</td><td><select name=\"view\">"
	    ."<option value=\"0\" $sel1>"._MVALL."</option>"
	    ."<option value=\"1\" $sel2>"._MVUSERS."</option>"
	    ."<option value=\"2\" $sel3>"._MVADMIN."</option>"
	    ."</select>"
	    ."</td></tr></table><br><br>";
    }
    echo "<input type=\"hidden\" name=\"mid\" value=\"$mid\">"
	."<input type=\"hidden\" name=\"op\" value=\"module_edit_save\">"
	."<input type=\"submit\" value=\""._SAVECHANGES."\">"
	."</form>"
	."<br><br><center>"._GOBACK."</center>";
    CloseTable();
    include("includes/admin/footer.php");
}

function module_edit_save($mid, $custom_title, $view) {
    global $prefix, $dbi;
    $result = sql_query("update ".$prefix."_main_themes set custom_title='$custom_title', view='$view' where mid='$mid'", $dbi);
    Header("Location: index.php?mod=Admin&op=modules");
}

switch ($op){

    case "modules":
    modules();
    break;

    case "module_status":
    module_status($mid, $active);
    break;

    case "module_edit":
    module_edit($mid);
    break;
    
    case "module_edit_save":
    module_edit_save($mid, $custom_title, $view);
    break;

    case "home_module":
    home_module($mid, $ok);
    break;

}

} else {
    echo "Access Denied";
}

?>
Return current item: ViperWeb Portal System