| Current Path : /var/www/html/mmishra/indem/icdp/ |
| Current File : /var/www/html/mmishra/indem/icdp/webpages.php |
<?php
checkadmin($role);
?>
Edit page content of the site. Familiarity with HTML tags is must to work at this advance level of site administration.<br>
<?php
$rowid = $_REQUEST['rowid'];
$hypertext = $_POST['hypertext'];
$parentid = $_REQUEST['parentid'];
if (!$parentid) $parentid = 0; //top level link
$pagetitle = $_POST['pagetitle'];
$pageid = $_REQUEST['pageid'];
if (!$pageid) $pageid = str_replace(" ","",strtolower($pagetitle));
$pageaccess = $_POST['pageaccess'];
$pagetype = $_POST['pagetype'];
if (!$pagetype) $pagetype = 'html'; //static webpage
$pagecontent = htmlsafe($_POST['pagecontent']);
if ($pagecontent) $pagecontent = str_replace("\"", "'", $pagecontent);
$keyword = $_POST['keyword'];
$dateexpiry = $_POST['dateexpiry'];
if (!$dateexpiry) $dateexpiry = date('Y-m-d');
$visibility = $_POST['visibility'];
$submit = $_POST['submit'];
$tbl = 'webpages';
$pagetypes = array('html','php','url','file');
$pageaccesses = array('public','user','admin');
$visibilities = array('enable','disable','scroll');
switch ($submit) {
case "SAVE":
if (mysql_num_rows(mysql_query("select * from $tbl where rowid=$rowid"))) {
mysql_query("update $tbl set hypertext='$hypertext',parentid=$parentid,
pageid='$pageid',pagetitle='$pagetitle',pagetype='$pagetype',pageaccess='$pageaccess',pagecontent='$pagecontent',
keyword='$keyword',visibility='$visibility',dateupdation=now(),dateexpiry='$dateexpiry'
where rowid=$rowid");
} else {
mysql_query("insert into $tbl
(hypertext,parentid,
pageid,pagetitle,pagetype,pageaccess,pagecontent,
keyword,datecreation,dateupdation,dateexpiry,visibility)
values('$hypertext',$parentid,
'$pageid','$pagetitle','$pagetype','$pageaccess','$pagecontent',
'$keyword',now(),now(),'$datexpiry','$visibility')");
}
break;
case "DELETE":
mysql_query("delete from $tbl where rowid=$rowid");
$hypertext = ''; $parentid = 0; $pagetitle = ''; $pagetype = ''; $pageaccess = ''; $pagecontent = ''; $keyword = ''; $visibility = '';
$dateexpiry = '0000-00-00';
break;
}
echo "<br>
<table>
<tr><td>Webpage</td>
<td><select name='rowid' style='width: 200px' onchange=\"document.location.href='$PHP_SELF?conf=$conf&rowid='+this.value\">
<option value='997'>Announcement</option>
<option value='996'";
if ($rowid == 996) echo ' selected';
echo ">Advertisement</option>
<option value='0'";
if ($rowid == 0) echo ' selected';
echo ">Linkpage</option>";
$rs = mysql_query("select * from $tbl order by pageid");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->rowid'";
if ($o->rowid == $rowid) {
echo " selected";
$hypertext = $o->hypertext;
$parentid = $o->parentid;
$pageid = $o->pageid;
$pagetitle = $o->pagetitle;
$pagetype = $o->pagetype;
$pageaccess = $o->pageaccess;
$pagecontent = $o->pagecontent;
$keyword = $o->keyword;
$visibility = $o->visibility;
$dateexpiry = $o->dateexpiry;
}
$star = '';
if ($o->pagetype == 'html' && !$o->pagecontent) $star = '*';
echo ">$o->pagetitle $star</option>";
}
echo "</select> select page to edit content (* indicates blank page)
</td></tr>
<tr><td>Hypertext</td>
<td><input type='text' name='hypertext' size='60' value='$hypertext'>
</td></tr>
<tr><td>Link Under</td>
<td><select name='parentid' style='width: 200px'>
<option value='0'>Homepage</option>";
$rs = mysql_query("select rowid,pagetitle from $tbl where visibility='enable' and pagecontent='' order by pagetitle");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->rowid'";
if ($parentid == $o->rowid) echo " selected";
echo ">$o->pagetitle</option>";
}
echo "</select></td></tr>
<tr><td>Page ID</td>
<td><input type='text' name='pageid' size='60' value='$pageid'>
</td></tr>
<tr><td>Page Title</td>
<td><input type='text' name='pagetitle' size='60' value='$pagetitle'>
</td></tr>
<tr><td>Access</td>
<td><select name='pageaccess' style='width: 200px'>";
foreach ($pageaccesses as $pa) {
echo "<option value='$pa'";
if ($pageaccess == $pa) echo ' selected';
echo ">$pa</option>";
}
echo "</select> Admin/user pages will be accessible after proper authentication
</td></tr>
<tr><td>Type</td>
<td><select name='pagetype' style='width: 200px'>";
foreach ($pagetypes as $pt) {
echo "<option value='$pt'";
if ($pagetype == $pt) echo ' selected';
echo ">" . strtoupper($pt) . "</option>";
}
echo "</select> HTML for static, PHP for dynamic content, URL for weblink, FILE for pdf,doc etc.
</td></tr>
<tr valign='top'><td>Content</td>
<td><textarea id='content' name='pagecontent' rows='10' cols='70'>$pagecontent</textarea></td></tr>
<tr><td>Keyword</td>
<td><input type='text' name='keyword' size='60' value='$keyword'>
</td></tr>
<tr><td>Expiry Date</td>
<td><input type='text' name='dateexpiry' size='20' value='$dateexpiry'>
</td></tr>
<tr><td>Visibility</td>
<td><select name='visibility' style='width: 200px'>";
foreach ($visibilities as $vs) {
echo "<option value='$vs'";
if ($visibility == $vs) echo ' selected';
echo ">$vs</option>";
}
echo "</select> Desabled pages will not be linked on this website
</td></tr>
<tr><td></td>
<td><input type='submit' name='submit' value='SAVE' style='width: 80px'> ";
if ($rowid > 0) echo "<input type='submit' name='submit' value='DELETE' style='width: 80px'>";
echo "</td></tr>
</table>";
?>
These pages are stored in the database and is accessible through click of some link only.