Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/indem/
Upload File :
Current File : /var/www/html/mmishra/indem/glossary.inc

<h2>IT Glossary</h2>
<?php
dbConnect();
$tbl = 'glossary';
$submit = $_POST["submit"];
$id = $_REQUEST["id"];
$term = $_REQUEST["term"];
$term = str_replace("%", "", $term);
$definition = htmlsafe($_POST["definition"]);
$action = $_REQUEST["action"];
$pageno = $_REQUEST["pageno"];
if (!$pageno) $pageno = 1;
$remoteip = $_SERVER["REMOTE_ADDR"];
$dated = date("Y-m-d H:i:s");

echo "Search term <input type='text' name='term' size='20' value='$term'>
      <input type='submit' name='submit' value='SEARCH'>";

if ($submit == "SAVE" && $uid) {
	if ($definition) {
		if (mysql_num_rows(mysql_query("select * from $tbl where term='$term'"))) {
			mysql_query("update $tbl set definition='$definition' where term='$term'");
		} else {
			mysql_query("insert into $tbl(term,definition,contributor,remoteip,dated) 
			values('$term','$definition','$uid','$remoteip','$dated')");
		}
	}
} else if ($submit == 'DELETE' && $uid) {
	mysql_query("delete from $tbl where id=$id"); 
}

echo ("select upper(left(term,1)) alpha, count(term) no from $tbl group by lower(left(term,1))");
$rs = mysql_query("select upper(left(term,1)) alpha, count(term) no from $tbl group by lower(left(term,1))");
while ($o = mysql_fetch_object($rs)) {
	//if ($o->alpha)
		echo "[&nbsp;<a href='?pg=glossary&action=term_list&term=$o->alpha'>{$o->alpha}&nbsp;($o->no)</a>&nbsp;] ";
}
echo " [ <a href='?pg=glossary&action=term_post&id=0'>New Term</a> ]</div>";

if ($submit == 'SEARCH' && $term) {
	$term = "%{$term}%";
        $pagesize = 10;
        $start = ($pageno * $pagesize) - $pagesize;
        $rs = mysql_query("select SQL_CALC_FOUND_ROWS * from $tbl where term like '$term' order by term LIMIT $start, $pagesize");
        $tro = mysql_fetch_object(mysql_query("select FOUND_ROWS() as no"));
        echo "<div align='center'><b>Query on \"$term\" (Total: $tro->no)</b></br>
        <table width='100%'><tr><th>No.</th><th>Term</th><th>Definition</th></tr>";
        while($o = mysql_fetch_object($rs)) {
                $start++;
                echo "<tr valign='top'><td>$start</td><td><b>$o->term</b></td><td>$o->definition";
                if ($uid) echo "[&nbsp;<a href='?pg=glossary&action=term_post&term=$o->term'>Edit</a>&nbsp;]";
                echo "<div align='right'><i>By $o->contributor from $o->remoteip dated $o->dated</i></div></td></tr>";
        }
        echo "</table><br>";
        if ($tro->no > $pagesize) {
                echo "Goto Page: [ ";
                for($i=1; $i<=ceil($tro->no / $pagesize); $i++) {
                        if ($i == $pageno)
                                echo "<b>$i</b>&nbsp; ";
                        else if (strpos($term, '%') == 0)
                                echo "<a href='?pg=glossary&action=term_search&term=$term&pageno=$i'>$i</a>&nbsp; ";
                        else
                                echo "<a href='?pg=glossary&action=term_list&term=$term&pageno=$i'>$i</a>&nbsp; ";
                }
                echo "]";
        }

} else if ($action == 'term_list') {
	$term = "{$term}%";
        echo "<ol>";
        $rs = mysql_query("select * from $tbl where term like '$term'");
        while ($o = mysql_fetch_object($rs)) {
                $id = $o->id;
                $term = $o->term;
                $definition = $o->definition;
                echo "<li><a href='?pg=glossary&action=term_def&id=$o->id'>$o->term</a></li>";
        }
        echo "</ol>";

}

echo "<div align='right'> Dated: " . date("Y-m-d H:i:s") . "</div>";

if ($uid) {
        echo "Hi! <b>" . ucwords($uid) . ", </b> 
        Please define your term and submit to <b>INDEM GLOSSARY</b> to make it more comprehensive & useful. Thanks.
        <table border='0' cellspacing='0' width='100%'>
        <tr><td>Term</td><td><input type='text' name='term' size='20' value='$term'>
        <input type='submit' name='submit' value='SEARCH'></td></tr>
        <tr valign='top'><td>Definition</td><td><textarea name='definition' rows='8' cols='30'>$definition</textarea></td></tr>
        <tr><td></td><td><input type='submit' name='submit' value='SAVE'>
        </td></tr></table>";

        echo "<ul>
        <li>Pl. submit IT terms and their comprehensive definition.</li>
        <li>Spell your terms as used by common people.</li>
        <li>Editing is not facilitated so be careful before submission.</li>
        <li>Max. contribution will be highlighted on INDEM website.</li>
        <li>Alphabetical list of glossary with number of entries is listed above.</li>
        </ul>";
}


?>