| Current Path : /var/www/html/mmishra/mm/ada/ |
| Current File : /var/www/html/mmishra/mm/ada/formats.php |
<?php
checklogin($user);
$tbl = "formats";
$id = $_REQUEST["id"];
$filename = strtolower($_FILES["userfile"]["name"]);
$description = $_POST["description"];
$action = $_REQUEST["action"];
$submit = $_POST["submit"];
if ($submit == 'SAVE') {
if ($filename) upload_file(); else $filename = strtolower($_POST["filename"]);
if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
mysql_query("update $tbl set filename='$filename',description='$description',
dated=now(),userid='$user' where id=$id");
} else {
mysql_query("insert into $tbl(filename,description,counter,dated,status,userid)
values('$filename','$description',0,now(),'current','$user')");
}
} else if ($submit == "DELETE") {
mysql_query("delete from $tbl where id=$id");
} else if ($action == 'hide') {
mysql_query("update $tbl set status='expired' where id=$id");
} else if ($action == 'show') {
mysql_query("update $tbl set status='current' where id=$id");
}
formatfeed();
echo "<div align='right'>Upload pdf file linked to this format <input type='file' name='userfile'></div>
Please select format file (.pdf only) to upload on server.
On server these files are stored under \"documents\" folder.
Please click <a href='documents/'>here</a> to list uploaded files under documents folder on server.
<br>
<table class='normal' width='90%'>";
if (!$id) {
echo "<tr valign='top'><td>Description</td>
<td><textarea name='description' rows='3' cols='50'>$description</textarea></td></tr>
<tr><td></td><td><input type='submit' name='submit' value='SAVE' style='width:80px'></td></tr>
";
} else {
echo "<tr><td>[ <a href='$PH_SELF?conf=$conf&id='>New Format</a> ]</td></tr>";
}
echo "</table><input type='hidden' name='id' value='$id'>
<table class='normal' width='98%'>
<tr><th>No.</th><th>Description</th><th>Filename</th><th>Conter</th><th>Dated</th></tr>";
$q = mysql_query("select * from $tbl order by id,description");
while ($o = mysql_fetch_object($q)) {
$i++;
if ($id == $o->id) {
echo "<tr><td>$i</td><td colspan='2' align='center'>
<input type='hidden' name='filename' value='$o->filename'>
<table class=normal width='90%'>
<tr><td>Uploaded file</td><td><b>$o->filename</b> (To replace with another select file above)</td></tr>
<tr valign='top'><td>Description</td>
<td><textarea name='description' rows='3' cols='50'>$o->description</textarea></td></tr>
<tr><td></td><td><input type='submit' name='submit' value='SAVE' style='width:80px'>
<input type='submit' name='submit' value='DELETE' style='width:80px'></td></tr>
</table></td></tr>";
} else {
if ($i % 2) echo "<tr valign='top' bgcolor='$col1'>";
else echo "<tr valign='top' bgcolor='$col2'>";
echo "<td>$i</td><td width='40%'>$o->description
[ <a href='$PH_SELF?conf=$conf&id=$o->id'>Edit</a> ] ";
if ($o->status == 'current') echo "[ <a href='$PH_SELF?conf=$conf&action=hide&id=$o->id'>Hide</a> ]";
else echo "[ <a href='$PH_SELF?conf=$conf&action=show&id=$o->id'>Show</a> ]";
echo "<div align='right'><i>Uploaded by: $o->userID</i></div></td>
<td>$o->filename</td><td>$o->counter</td><td>$o->dated</td></tr>";
}
}
echo "</table>";
?>