| Current Path : /var/www/html/mmishra/mm/ada/ |
| Current File : /var/www/html/mmishra/mm/ada/menus.php.bak |
<?php
if ($role != "Admin") {
echo "<div align=center>You must be a Site Administrator to access this page</div>";
exit;
}
$tbl = 'menus';
$submit = $_POST['submit'];
$id = $_REQUEST['id'];
$subid = $_REQUEST['subid'];
$menutitle = $_POST['menutitle'];
$subtitle = $_POST['subtitle'];
if ($menutitle && $subtitle) $pagetitle = $menutitle . ' > ' . $subtitle;
if ($pagetitle) $pageid = strtolower(str_replace(" ","-",$menutitle . $subtitle));
$menuindex = $_POST['menuindex'];
$subindex = $_POST['subindex'];
$content = $_POST['content'];
$keywords = $_POST['keywords'];
$dated = date("Y-m-d");
if ($submit == 'DELETE') {
mysql_query("delete from $tbl where id=$subid and referer=$menuid");
if (!mysql_num_rows(mysql_query("select * from $tbl where referer=$menuid"))) {
//delete if submenu exasts
mysql_query("delete from $tbl where id=$menuid");
}
menu();
} else if ($submit == 'SAVE') {
if ($menutitle) {
if (mysql_num_rows(mysql_query("select * from $tbl where id=$menuid"))) {
if (mysql_num_rows(mysql_query("select * from $tbl where id=$menuid and zindex=$menuindex"))) {
//if index has been changed
mysql_query("update $tbl set zindex=$zindex+1
where zindex>=$menuindex and $id<>$menuid");
}
mysql_query("update $tbl set title='$menutitle',zindex=$menuindex,dated='$dated'
where id=$menuid");
} else {
if (mysql_num_rows(mysql_query("select * from $tbl where referer=0"))<12) {
mysql_query("insert into $tbl (title,zindex,href,referer,dated)
values('$menutitle',$menuindex,'submenu',0,'$dated')");
} else
echo "<h2>Sorry! Total 12 menus can be added as per displayed area.</h2>";
}
}
if ($subtitle) {
if (mysql_num_rows(mysql_query("select * from $tbl where id=$subid and referer=$menuid"))) {
if (!mysql_num_rows(mysql_query("select * from $tbl where id=$subid and zindex=$subindex"))) {
//if index has been changed
mysql_query("update $tbl set zindex=$zindex+1
where referer=$menuindex and zindex>=$subindex and $id<>$subid");
}
mysql_query("update $tbl set title='$subtitle',zindex=$subindex,href='$pageid',dated='$dated'
where id=$subid and referer=$menuid");
} else {
mysql_query("insert into $tbl (title,zindex,href,referer,dated)
values('$subtitle',$subindex,'$pageid',$menuid,'$dated')");
}
}
if ($pageid) {
if (mysql_num_rows(mysql_query("select * from webpages where id='$pageid'"))) {
mysql_query("update webpages set title='$pagetitle',content='$content',keywords='$keywords',
dated='$dated' where id='$pageid'");
} else {
mysql_query("insert into webpages(id,title,content,keywords,dated)
values('$pageid','$pagetitle','$content','$keywords','$dated')");
}
}
echo "<h2>Success! webpage with navigation info saved properly.</h2>";
menu();
}
echo "Site supports 2 levels of menus with max. 10 submenus under each. Select menu/submenu to add/edit page content.
<table width='100%' class='search'><tr valign='top'>
<td><b>Menu</b></td><td><select size='8' style='width: 170px' name='menuid'
onchange=\"document.location.href='$PHP_SELF?conf=$conf&menuid='+this.value\">";
$rs1 = mysql_query("select * from $tbl where referer=0 order by zindex");
while ($q = mysql_fetch_object($rs1)) {
$i++;
echo "<option value='$q->id'";
if ($menuid == $q->id) {
$menutitle = $q->title;
$menuindex = $q->zindex;
echo " selected";
}
echo "> $i $q->title</option>";
}
echo "</select></td>
<td><b>Submenu</b></td><td><select size='8' style='width: 170px' name='subid'
onchange=\"document.location.href='$PHP_SELF?conf=$conf&menuid=$menuid&subid='+this.value\">";
$rs2 = mysql_query("select * from $tbl where referer>0 and referer=$menuid order by zindex");
while ($p = mysql_fetch_object($rs2)) {
$j++;
echo "<option value='$p->id'";
if ($subid == $p->id) {
$subtitle = $p->title;
$subindex = $p->zindex;
$pageid = $p->href;
echo " selected";
}
echo "> $j $p->title</option>";
}
$pagetitle = $menutitle . ' > ' . $subtitle;
//mysql_query("update webpages set title='$pagetitle' where id='$href'");
$rs3 = mysql_query("select * from webpages where id='$pageid'");
if ($rs3) {
$o = mysql_fetch_object($rs3);
$pageid = $o->id;
$content = $o->content;
$keywords = $o->keywords;
}
echo "</select></td>
</tr><tr>
<td>New menu</td><td><input type='text' name='menutitle' value='$menutitle' size='22'>
Index <input type='text' name='menuindex' value='$menuindex' size='5'></td>
<td>New submenu</td><td><input type='text' name='subtitle' value='$subtitle' size='22'>
Index <input type='text' name='subindex' value='$subindex' size='5'></td>
</tr><tr>
<th colspan='4'><b><u>Page to open on CLICK of SUBMENU</u></b><br>
<table class='search'>
<tr><td><b>Title</b></td><td><b id='title'>$pagetitle</b>
[ <a href='$PHP_SELF?conf=$pageid' target='preview'>Preview</a> ]</td></tr>
<tr valign='top'><td>Content</td><td><textarea name='content' rows='8' cols='60'>$content</textarea></td></tr>
<tr><td>Keywords</td><td><input type='text' name='keywords' value='$keywords' size='60'>
<input type='submit' name='submit' value='SAVE'>
<input type='submit' name='submit' value='DELETE'>
</td></tr>
</table>
</th></tr>
</table>
";
?>
<b>Note</b><br>
Add new menu/submenu by typing title in the respective box.<br>
Set display order by typing no. in the respective INDEX box.<br>
Page will be opened on click of submenu only.<br>
Please remember that deleting Menu will not delete SUBMENU under it.<br>
Therefore submenus of deleted menus can be used with another menus.