<?php
if (!defined('ADMIN_FILE') || !is_admin_modul($aid, "Page")) die("Illegal File Access");

function PageNavi() {
	global $admin_file;
	GraphicAdmin();
	OpenTable();
    echo "<center><font class=\"title\"><b>"._PAGE_NAME."</b></font><br><br>"
	."[ <a href=".$admin_file.".php?op=page>"._HOME."</a>"
	." | <a href=".$admin_file.".php?op=add_page>"._ADD."</a>"
	." | <a href=".$admin_file.".php?op=cat_page>"._CATEGORIES."</a>"
	." | <a href=\"".$admin_file.".php?op=PageConf\">"._PREFERENCES."</a> ]</center>";
	CloseTable();
}

function pagesgetparent($parentid, $title) {
    global $prefix, $db, $admin_file;
    list($cid, $ptitle, $pparentid) = $db->sql_fetchrow($db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_page_categories WHERE cid='$parentid'"));
    if ($ptitle != "") $title = $ptitle."/".$title;
    if ($pparentid != 0) $title = pagesgetparent($pparentid, $title);
    return $title;
}

function page() {
	global $prefix, $db, $multilingual, $admin_file;
    head();
    PageNavi();
	$storynum = 25;
	$pagenum = intval($_GET['pagenum']) ? $_GET['pagenum'] : "1";
	$offset = ($pagenum-1) * $storynum;
	$offset = intval($offset);
	$storynum = intval($storynum);
	$result = $db->sql_query("SELECT p.pid, p.cid, p.title, p.active, c.cid, c.title FROM ".$prefix."_page AS p LEFT JOIN ".$prefix."_page_categories AS c ON (p.cid=c.cid) ORDER BY pid DESC LIMIT $offset, $storynum");
    if ($db->sql_numrows($result) > 0) {
		OpenTable();
		echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" class=\"bgcolor4\" width=\"100%\">\n"
		."<tr><th>"._TITLE."</th><th>"._CATEGORY."</th><th>"._STATUS."</th><th>"._FUNCTIONS."</b></th></tr>";
		while (list($pid, $cid, $title, $active, $ccid, $ctitle) = $db->sql_fetchrow($result)) {
			$act = ($active) ? "<font color=\"#009900\">"._ACTIVATE."</font>" : "<font color=\"#FF0000\">"._INACTIVE."</font>";
			$actedit = ($active) ? "<a href=\"".$admin_file.".php?op=active_page&id=$pid&act=0&pagenum=$pagenum\" title=\""._INACTIVE."\"><img src=images/inactive.gif border=\"0\" alt=\""._INACTIVE."\"></a>" : "<a href=\"".$admin_file.".php?op=active_page&id=$pid&act=1&pagenum=$pagenum\" title=\""._ACTIVATE."\"><img src=images/activate.gif border=\"0\" alt=\""._ACTIVATE."\">";
			$cat_title = (!$cid) ? ""._HOMECAT."" : $ctitle;
			echo "<tr><td class=\"bgcolor1\">$title</td>"
			."<td class=\"bgcolor1\">$cat_title</td>"
			."<td class=\"bgcolor1\" align=\"center\">$act</td>"
			."<td class=\"bgcolor1\" align=\"center\">$actedit <a href=".$admin_file.".php?op=add_page&id=$pid title=\""._EDIT."\"><img src=images/edit.gif border=\"0\" alt=\""._EDIT."\"></a> <a href=".$admin_file.".php?op=delete_pages&id=$pid title=\""._DELETE."\"><img src=images/delete.gif border=\"0\" alt=\""._DELETE."\"></a></td></tr>";
		}
		echo "</table>";
		CloseTable();
		list($numstories) = $db->sql_fetchrow($db->sql_query("SELECT Count(pid) FROM ".$prefix."_page"));
		$numpage = ceil($numstories / $storynum);
		num_page($module_name, $numstories, $numpage, $storynum, "op=page&");
	}
	foot();
}

function add_page() {
    global $prefix, $db, $admin_file, $multilingual, $stop;
    head();
	PageNavi();
	if ($stop) warning($stop, "", "", 1);
	if (isset($_REQUEST['id'])) {
		$pid = intval($_REQUEST['id']);
		$result = $db->sql_query("SELECT pid, cid, title, hometext, bodytext, date, active FROM ".$prefix."_page WHERE pid='$pid'");
        list($pid, $cat, $title, $hometext, $bodytext, $time, $status) = $db->sql_fetchrow($result);
		$associated = explode("-", $associated);
		$functitle = ""._PAGEEDIT."";
	} else {
		$pid = $_POST['pid'];
		$cat = $_POST['cid'];
		$title = $_POST['title'];
		$hometext = save_text($_POST['hometext']);
		$bodytext = save_text($_POST['bodytext']);
		$status = $_POST['status'];
		if (isset($_POST['year'])) {
			$time = "".$_POST['year']."-".$_POST['mon']."-".$_POST['day']." ".$_POST['hour'].":".$_POST['min'].":00";
		} else {
			$today = getdate();
			$time = "".$today[year]."-".$today[mon]."-".$today[mday]." ".$today[hours].":".$today[minutes].":00";
		}
		$functitle = ""._ADDPAGE."";
	}
	if ($hometext) preview("<b>".$title."</b><br /><br />".bb_decode($hometext)."<br /><br />".bb_decode($bodytext)."");
	OpenTable();
	echo "<center><font class=\"option\">".$functitle."</font><br /><br />"
    .""._ADDPAGENOTE."</center>";
    CloseTable();
	OpenTable();
	echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\"><form name=\"post\" action=\"".$admin_file.".php\" method=\"post\">"
	."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" value=\"".$title."\" maxlength=\"80\" size=\"65\" style=\"width:400px\"></td></tr>"
	."<tr><td>"._CATEGORY.":</td><td><select name=\"cid\" style=\"width:400px\"><option value=\"0\">"._HOMECAT."</option>";
	$result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_page_categories ORDER BY parentid,title");
	while (list($cid, $title, $parentid) = $db->sql_fetchrow($result)) {
		if ($parentid != 0) $title = pagesgetparent($parentid, $title);
		$sel = ($cat == $cid) ? "selected" : "";
		echo "<option value=\"$cid\" $sel>$title</option>";
	}
    echo "</select></td></tr>";
	echo "<tr><td>"._HOMETEXTPAGE.":</td><td><textarea id=\"area\" name=\"hometext\" cols=\"65\" rows=\"10\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".replace_break($hometext)."</textarea>".get_code("area")."</td></tr>"
	."<tr><td>"._BODYTEXTPAGE.":</td><td><textarea id=\"area1\" name=\"bodytext\" cols=\"65\" rows=\"25\" style=\"width:400px\" OnKeyPress=\"TransliteFeld(this, event)\" OnSelect=\"FieldName(this, this.name)\" OnClick=\"FieldName(this, this.name)\" OnKeyUp=\"FieldName(this, this.name)\">".replace_break($bodytext)."</textarea>".get_code("area1")."</td></tr>";
	preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime);
	echo "<tr class=\"bgcolor1\"><td>"._CHNGSTORY.":</td><td>"
	.""._HOURS.": <select name=\"hour\">";
	$hour = 0;
	while ($hour <= 23) {
		$sel = ($hour == $datetime[4]) ? "selected" : "";
		$hour = ($hour < 10) ? "0".$hour."" : $hour;
		echo "<option value=\"$hour\" $sel>$hour</option>";
		$hour++;
	}
	echo "</select>:<select name=\"min\">";
	$min = 0;
	while ($min <= 60) {
		$sel = ($min == $datetime[5]) ? "selected" : "";
		$min = ($min < 10) ? "0".$min."" : $min;
		echo "<option value=\"$min\" $sel>$min</option>";
		$min++;
	}
	echo "</select> "._DAY.": <select name=\"day\">";
	$day = 1;
	while ($day <= 31) {
		$sel = ($day == $datetime[3]) ? "selected" : "";
		echo "<option value=\"$day\" $sel>$day</option>";
		$day++;
	}
	echo "</select> "._UMONTH.": <select name=\"mon\">";
	$mon = 1;
	while ($mon <= 12) {
		$sel = ($mon == $datetime[2]) ? "selected" : "";
		echo "<option value=\"$mon\" $sel>$mon</option>";
		$mon++;
	}
	echo "</select> "._YEAR.": <select name=\"year\">";
	$date = getdate();
	$year = $date[year] + 10;
	$years = $date[year] - 10;
	while ($years <= $year) {
		$sel = ($year == $datetime[1]) ? "selected" : "";
		echo "<option value=\"$year\" $sel>$year</option>";
		$year--;
	}
	echo "</select></td></tr>";
	$sel1 = ($status) ? "checked" : "";
	$sel2 = (!$status) ? "checked" : "";
	echo "<tr><td>"._ACTIVPAGE."</td><td>"
	."<input type=\"radio\" name=\"status\" value=\"1\" $sel1>"._YES." &nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"0\" $sel2>"._NO."</td></tr>"
	."<tr><td colspan=\"2\" align=\"center\"><br /><select name=\"posttype\">"
	."<option value=\"preview\">"._PREVIEW."</option>"
	."<option value=\"save\">"._SEND."</option></select>"
	." <input type=\"hidden\" name=\"pid\" value=\"$pid\">"
	." <input type=\"hidden\" name=\"op\" value=\"save_page\">"
	."<input type=\"submit\" value=\""._OK."\"></td></tr></form></table>";
	CloseTable();
    foot();
}

function save_page() {
    global $prefix, $db, $multilingual, $admin_file, $stop;
	$pid = intval($_POST['pid']);
	$title = $_POST['title'];
	$cat = $_POST['cid'];
	$hometext = save_text($_POST['hometext']);
	$bodytext = save_text($_POST['bodytext']);
	$status = $_POST['status'];
	if (isset($_POST['year'])) {
		$time = "".$_POST['year']."-".$_POST['mon']."-".$_POST['day']." ".$_POST['hour'].":".$_POST['min'].":00";
	} else {
		$today = getdate();
		$time = "".$today[year]."-".$today[mon]."-".$today[mday]." ".$today[hours].":".$today[minutes].":00";
	}
	if (!$hometext) $stop = ""._CERROR1."";
	if (!$stop && $_POST['posttype'] == "save") {
		if ($pid) {
			$db->sql_query("UPDATE ".$prefix."_page SET cid='$cat', title='$title', hometext='$hometext', bodytext='$bodytext', date='$time', active='$status' WHERE pid='$pid'");
		} else {
			$db->sql_query("INSERT INTO ".$prefix."_page VALUES (NULL, '$cat', '$title', '$hometext', '$bodytext', '$time', '0', '$status')");
		}
		Header("Location: ".$admin_file.".php?op=page");
	} else {
		add_page();
	}
}

function delete_pages() {
    global $prefix, $db, $admin_file;
	$pid = intval($_REQUEST['id']);
	$ok = intval($_GET['ok']);
    if ($pid && $ok == 1) {
		$db->sql_query("DELETE FROM ".$prefix."_page WHERE pid='$pid'");
	        $db->sql_query("DELETE FROM ".$prefix."_comment WHERE cid='$pid' AND modul='Page'");

		Header("Location: ".$admin_file.".php?op=page");
	} else {
		list($title) = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_page WHERE pid='$pid'"));
		head();
        PageNavi();
		OpenTable();
		echo "<center>"._DELETE." \"$title\"?<br /><br>[ <a href=\"".$admin_file.".php?op=delete_pages&id=$pid&ok=1\">"._YES."</a> | <a href=\"".$admin_file.".php\">"._NO."</a> ]</center>";
		CloseTable();
		foot();
	}
}

function cat_page() {
	global $prefix, $db, $multilingual, $language, $admin_file;
    head();
    PageNavi();
	OpenTable();
    echo "<center><font class=\"option\"><b>"._ADDCATEGORY."</b></font></center><br>"
	."<form action=\"".$admin_file.".php\" method=\"post\">"
	."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
	."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"65\" style=\"width:400px\"></td></tr>"
	."<tr><td>"._SUBTITLE.":</td><td><textarea name=\"description\" cols=\"65\" rows=\"5\" style=\"width:400px\"></textarea></td></tr>";
	if ($multilingual == 1) echo "<tr><td>"._LANGUAGE.":</td><td><select name=\"alanguage\" style=\"width:400px\">".language()."</select></td></tr>";
	echo "<tr><td colspan=\"2\" align=\"center\"><br><input type=\"hidden\" name=\"op\" value=\"add_cat_page\">"
	."<input type=\"submit\" value=\""._ADDCATEGORY."\"></td></tr></form></table>";
    CloseTable();
	$result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_page_categories ORDER BY parentid, title");
    if ($db->sql_numrows($result) > 0) {
        OpenTable();
		echo "<center><font class=\"option\"><b>"._ADDSUBCATEGORY."</b></font></center><br>"
		."<form action=\"".$admin_file.".php\" method=\"post\">"
		."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
        ."<tr><td>"._INCAT.":</td><td><select name=\"cid\" style=\"width:400px\">";
		while (list($cid2, $title, $parentid2) = $db->sql_fetchrow($result)) {
			if ($parentid2 != 0) $title = pagesgetparent($parentid2, $title);
			echo "<option value=\"$cid2\">$title</option>";
		}
		echo "</select></td></tr>"
        ."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" size=\"65\" style=\"width:400px\"></td></tr>"
        ."<tr><td>"._SUBTITLE.":</td><td><textarea name=\"description\" cols=\"65\" rows=\"5\" style=\"width:400px\"></textarea></td></tr>"
        ."<tr><td colspan=\"2\" align=\"center\"><br><input type=\"hidden\" name=\"op\" value=\"add_subcat_page\">"
        ."<input type=\"submit\" value=\""._ADDSUBCATEGORY."\"></td></tr></form></table>";
        CloseTable();
    }
	$result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_page_categories ORDER BY parentid, title");
	if ($db->sql_numrows($result) > 0) {
		OpenTable();
		echo "<center><font class=\"option\"><b>"._EDITCATEGORY."</b></font></center><br>"
		."<form action=\"".$admin_file.".php\" method=\"post\">"
		."<center><select name=\"cid\" style=\"width:400px\">";
		while (list($cid2, $title, $parentid2) = $db->sql_fetchrow($result)) {
			if ($parentid2 != 0) $title = pagesgetparent($parentid2, $title);
			echo "<option value=\"$cid2\">$title</option>";
		}
		echo "</select>"
		." <input type=\"hidden\" name=\"op\" value=\"edit_cat_page\">"
		."<input type=\"submit\" value=\""._EDIT."\"></center></form>";
        CloseTable();
    }
	foot();
}

function edit_cat_page($cid) {
    global $prefix, $db, $multilingual, $admin_file;
    head();
    PageNavi();
    OpenTable();
    $cid = intval($cid);
    $result = $db->sql_query("SELECT title, description, parentid, planguage FROM ".$prefix."_page_categories WHERE cid='$cid'");
    list($title, $description, $parentid, $mylanguage) = $db->sql_fetchrow($result);
	echo "<center><font class=\"option\">"._EDITCATEGORY."</font></center><br />"
	."<form action=\"".$admin_file.".php\" method=\"post\">"
	."<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" align=\"center\">"
	."<tr><td>"._TITLE.":</td><td><input type=\"text\" name=\"title\" value=\"$title\" size=\"65\" style=\"width:400px\"></td></tr>";
	if ($parentid != 0) {
        $sql2 = "SELECT cid, title, parentid FROM ".$prefix."_page_categories WHERE parentid != '$parentid'";
        $result2 = $db->sql_query($sql2);
        echo "<tr><td>"._INCAT.":</td><td><select name=\"parentid\" style=\"width:400px\">";
        while (list($cid2, $ctitle2, $parentid2) = $db->sql_fetchrow($result2)) {
			if ($parentid2 != 0) $ctitle2 = pagesgetparent($parentid2, $ctitle2);
			$sel = ($cid2 == $parentid) ? "selected" : "";
			echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
        }
        echo "</select></td></tr>";
	} else {
		echo "<input type=\"hidden\" name=\"parentid\" value=\"0\">";
	}
	if ($multilingual == 1) echo "<tr><td>"._LANGUAGE.":</td><td><select name=\"alanguage\" style=\"width:400px\">".language($mylanguage)."</select></td></tr>";
	echo "<tr><td>"._SUBTITLE.":</td><td><textarea name=\"description\" cols=\"65\" rows=\"5\" style=\"width:400px\">$description</textarea></td></tr>"
	."<tr><td align=\"center\" colspan=\"2\"><table><tr><td><input type=\"hidden\" name=\"cid\" value=\"$cid\"><input type=\"hidden\" name=\"op\" value=\"save_cat_page\"><input type=\"submit\" value=\""._SAVECHANGES."\"></td></form><form action=\"".$admin_file.".php\" method=\"post\"><td><input type=\"hidden\" name=\"cid\" value=\"$cid\"><input type=\"hidden\" name=\"op\" value=\"del_page_cat\"><input type=\"submit\" value=\""._DELETE."\"></td></tr></form></table></tr></td></table>";
	CloseTable();
	foot();
}

function del_page_cat($cid, $ok=0) {
    global $prefix, $db, $admin_file;
    if ($ok == 1) {
        $db->sql_query("DELETE FROM ".$prefix."_page_categories WHERE cid='$cid'");
        $db->sql_query("DELETE FROM ".$prefix."_page_categories WHERE parentid='$cid'");
		$db->sql_query("DELETE FROM ".$prefix."_page WHERE cid='$cid'");
		Header("Location: ".$admin_file.".php?op=cat_page");
    } else {
        head();
        PageNavi();
        OpenTable();
		list($title) = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_page_categories WHERE cid='$cid'"));
		echo "<center><font class=\"option\">"._DELCATEGORY.": $title</font><br /><br />"
		.""._DELNOTE."<br /><br />[ <a href=\"".$admin_file.".php?op=cat_page\">"._NO."</a> | <a href=\"".$admin_file.".php?op=del_page_cat&cid=$cid&ok=1\">"._YES."</a> ]</center>";
		CloseTable();
		foot();
    }
}

function PageConf() {
	global $prefix, $db, $admin_file;
	head();
	PageNavi();
	include("config/config_page.php");
	$permtest = end_chmod("config/config_page.php", 666);
	if ($permtest) warning($permtest, "", "", 1);
	OpenTable();
	echo "<center><font class='option'><b>"._GENSITEINFO."</b></font></center><br>"
    ."<form action='".$admin_file.".php' method='post'>"
	."<table border='0' align='center' cellpadding='3' cellspacing='0'>"
	."<tr><td>"._P_1.":</td><td><input type='text' name='xtablenumhome' value='$tablenumhome' maxlength='25' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._P_2.":</td><td><input type='text' name='xnewhomenum' value='$newhomenum' maxlength='25' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._P_3.":</td><td><input type='text' name='xnumpage' value='$numpage' maxlength='25' size='45' style='width:300px'></td></tr>"
	."<tr><td>"._P_4.":</td><td><input type='text' name='xpagecatnumlinc' value='$pagecatnumlinc' maxlength='25' size='45' style='width:300px'></td></tr>";
	echo "</td></tr><tr><td>"._P_5."</td><td>";
	if ($catdescrhome == 1) {
		echo "<input type='radio' name='xcatdescrhome' value='1' checked>"._YES." &nbsp;<input type='radio' name='xcatdescrhome' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xcatdescrhome' value='1'>"._YES." &nbsp;<input type='radio' name='xcatdescrhome' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._P_6."</td><td>";
	if ($homesubcat == 1) {
		echo "<input type='radio' name='xhomesubcat' value='1' checked>"._YES." &nbsp;<input type='radio' name='xhomesubcat' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xhomesubcat' value='1'>"._YES." &nbsp;<input type='radio' name='xhomesubcat' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._P_7."</td><td>";
	if ($newhome == 1) {
		echo "<input type='radio' name='xnewhome' value='1' checked>"._YES." &nbsp;<input type='radio' name='xnewhome' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xnewhome' value='1'>"._YES." &nbsp;<input type='radio' name='xnewhome' value='0' checked>"._NO."";
    }
	echo "</td></tr><tr><td>"._P_8."</td><td>";
	if ($pagecatlink == 1) {
		echo "<input type='radio' name='xpagecatlink' value='1' checked>"._YES." &nbsp;<input type='radio' name='xpagecatlink' value='0'>"._NO."";
    } else {
        echo "<input type='radio' name='xpagecatlink' value='1'>"._YES." &nbsp;<input type='radio' name='xpagecatlink' value='0' checked>"._NO."";
    }
	echo "</td></tr></table>";
	echo "<center><br><input type='hidden' name='op' value='PageSave'><input type='submit' value='" . _SAVECHANGES . "'></center></form>";
	CloseTable();
	foot();
}

function PageSave($xtablenumhome, $xnewhomenum, $xnumpage, $xpagecatnumlinc, $xcatdescrhome, $xhomesubcat, $xnewhome, $xpagecatlink) {
	global $admin_file;
	$content = "\$tablenumhome = \"$xtablenumhome\";\n";
	$content .= "\$newhomenum = \"$xnewhomenum\";\n";
	$content .= "\$numpage = \"$xnumpage\";\n";
	$content .= "\$pagecatnumlinc = \"$xpagecatnumlinc\";\n";
	$content .= "\$catdescrhome = \"$xcatdescrhome\";\n";
	$content .= "\$homesubcat = \"$xhomesubcat\";\n";
	$content .= "\$newhome = \"$xnewhome\";\n";
	$content .= "\$pagecatlink = \"$xpagecatlink\";\n";
	save_conf("config/config_page.php", $content);
	Header("Location: ".$admin_file.".php?op=PageConf");
}

switch ($op) {
	case "page":
    page();
    break;

	case "add_page":
    add_page();
    break;

	case "save_page":
    save_page();
    break;
	
	case "active_page":
	$pid = intval($_GET['id']);
	$act = intval($_GET['act']);
	$pagenum = (!intval($_GET['pagenum'])) ? "" : "&pagenum=".intval($_GET['pagenum'])."";
	$db->sql_query("UPDATE ".$prefix."_page SET active='$act' WHERE pid='$pid'");
    Header("Location: ".$admin_file.".php?op=page".$pagenum."");
	break;
	
	case "delete_pages":
    delete_pages();
    break;
	
	case "cat_page":
    cat_page();
    break;

    case "add_cat_page":
	$db->sql_query("INSERT INTO ".$prefix."_page_categories (cid, title, description, parentid, planguage) VALUES (NULL, '$title', '$description', '0', '$alanguage')");
    Header("Location: ".$admin_file.".php?op=cat_page");
    break;

    case "add_subcat_page":
	$db->sql_query("INSERT INTO ".$prefix."_page_categories (cid, title, description, parentid) VALUES (NULL, '$title', '$description', '$cid')");
    Header("Location: ".$admin_file.".php?op=cat_page");
    break;

    case "edit_cat_page":
    edit_cat_page($cid);
    break;

    case "save_cat_page":
    $db->sql_query("UPDATE ".$prefix."_page_categories SET title='$title', description='$description', parentid='$parentid', planguage='$alanguage' WHERE cid='$cid'");
    Header("Location: ".$admin_file.".php?op=cat_page");
    break;

    case "del_page_cat":
    del_page_cat($cid, $ok);
    break;

	case "PageConf":
    PageConf();
    break;

    case "PageSave":
    PageSave($xtablenumhome, $xnewhomenum, $xnumpage, $xpagecatnumlinc, $xcatdescrhome, $xhomesubcat, $xnewhome, $xpagecatlink);
    break;
}
?>

