| Current Path : /var/www/html/mmishra/indem/iiita/ |
| Current File : /var/www/html/mmishra/indem/iiita/links.php1 |
<?php
checkadmin($role);
$tbl = 'links';
$scope_arr = array('admin','public');
$userfile = basename($_FILES['userfile']['name']);
$id = $_REQUEST['id'];
$title = $_POST['title'];
$href = $_POST['href'];
$scope = $_POST['scope'];
$zindex = $_POST['zindex'];
$submit = $_POST['submit'];
if ($submit == 'DELETE') {
//delete if submenu exists
mysql_query("delete from $tbl where id=$id");
links();
} else if ($submit == 'SAVE') {
if ($title) {
if ($userfile) $href = upload_file();
if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
mysql_query("update $tbl set title='$title',href='$href',scope='$scope',zindex=$zindex,dated=now() where id=$id");
} else {
mysql_query("insert into $tbl (title,href,scope,zindex,dated)
values('$title','$href','$scope',$no+1,now())");
}
}
links();
} else if ($submit == 'UP') {
$rs = mysql_query("select * from $tbl where id=$id");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$zindex = $o->zindex;
if ($zindex > 1) {
mysql_query("update $tbl set zindex=$zindex where zindex=$zindex-1");
mysql_query("update $tbl set zindex=$zindex-1 where id=$id");
links();
}
}
} else if ($submit == 'DOWN') {
$rs = mysql_query("select * from $tbl where id=$id");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$zindex = $o->zindex;
mysql_query("update $tbl set zindex=$zindex where zindex=$zindex+1");
mysql_query("update $tbl set zindex=$zindex+1 where id=$id");
links();
}
}
echo "<div align='right'>Upload pdf file linked to this menu <input type='file' name='userfile'></div>
Site supports 2 levels of menus with max. 10 submenus under each. Select menu/submenu to add/edit page content.
<input type='hidden' name='id' value='$id'>
<table width='90%' class='normal'>";
if (!$id) {
echo "<tr><td>Title</td><td><input type='text' name='title' value='$o->title' size='20'></td><tr>
<tr><td>HREF</td><td><input type='text' name='href' value='$o->href' size='20'></td></tr>
<tr><td>Scope</td><td><select name='scope'>";
foreach ($scope_arr as $sc) {
echo "<option value='$sc'>$sc</option>";
}
echo "</select></td></tr>";
} else {
echo "<tr><td>[ <a href='$PHP_SELF?conf=$conf&id=mm'>New link</a> ]</td></tr>";
}
echo "</table>
<table width='90%' class='normal'>";
$rs = mysql_query("select * from $tbl order by zindex");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td>$i</td><td>";
if ($id == $o->id) {
echo "<tr><td>Title</td><td><input type='text' name='title' value='$o->title' size='20'></td><tr>
<tr><td>HREF</td><td><input type='text' name='href' value='$o->href' size='20'></td></tr>
<tr><td>Scope</td><td><select name='scope'>";
foreach ($scope_arr as $sc) {
echo "<option value='$sc'>$sc</option>";
}
echo "</select></td></tr>";
echo "<tr><td></td><td><input type='submit' name='submit' value='$o->scope' size='20'></td>";
} else {
echo "<td><a href='$PHP_SELF?conf=$conf&id=$o->id'>$o->title</a></td>";
echo "<td>$o->href</td>";
echo "<td>$o->scope</td>";
}
echo "</tr>";
echo "<a href='$PHP_SELF?conf=$conf&id=mm'>Add new link</a>";
}
$i++;
echo "<li>";
if ($referer == 0 && $id == 'mm') {
echo "<input type='text' name='menutitle' value='' size='20'>";
$i=0;
$rs = mysql_query("select * from $tbl where referer=0 order by zindex");
while ($o = mysql_fetch_object($rs)) {
$i++; $j = 0;
mysql_query("update $tbl set zindex=$i where id=$o->id");
$rs1 = mysql_query("select * from $tbl where referer=$o->id order by zindex");
while ($p = mysql_fetch_object($rs1)) {
$j++;
mysql_query("update $tbl set zindex=$j where id=$p->id");
}
}
} else {
echo "<a href='$PHP_SELF?conf=$conf&referer=0&id=mm'>Add new Menu</a>";
}
?>
</li></ol>
</td></tr><tr><td>
<input type='submit' name='submit' value='SAVE' style="width:80px">
<input type='submit' name='submit' value='UP' style="width:80px">
<input type='submit' name='submit' value='DOWN' style="width:80px">
<input type='submit' name='submit' value='DELETE' style="width:80px">
</td></tr></table>
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.