Your IP : 216.73.216.40


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

<span id='title'>Submission</span><br><br>
<?php
if (!isset($_SESSION["uid"])) {
        login($pg);
} else {
        $uid = $_SESSION["uid"];
	$id = htmlsafe($_REQUEST["id"]);
	$topic = htmlsafe($_REQUEST["topic"]);
	$question = htmlsafe($_POST["question"]);
	$action = htmlsafe($_REQUEST["action"]);
	$solution = htmlsafe($_POST["solution"]);

	$action = htmlsafe($_REQUEST["action"]);
	
	$ip = $_SERVER["REMOTE_ADDR"];
	$dated = date("Y-m-d H:i:s");

	if ($submit == "SUBMIT" && $uid) {
		if ($question) {
			mysql_query("insert into faqs(topic,question,uid,dated,ipaddress) 
			values('$topic','$question','$uid','$dated','$ip')");
		} else if ($solution) {
			mysql_query("insert into solutions(faqs,solution,uid,dated,ipaddress) 
			values($id,'$solution','$uid','$dated','$ip')");
		}
	}
	if ($action == 'solution_list') { 
		solution_list($topic, $uid, $role, $id);
	} else if ($action == 'solution_delete') {
		mysql_query("delete from solutions where id=$sid"); 
		solution_list($topic, $uid, $role, $id);
	} else if ($action == 'faqs_list') {
		faqs_list($topic, $uid, $role, $id, $pg);
	} else if ($action == 'faqs_delete') {
		mysql_query("delete from faqs where id=$id"); 
		faqs_list($topic, $uid, $role, $id, $pg);
	} else { 
		faqs_post($uid);
		note();
	}
}

function faqs_post($uid) {
  	$topic_arr = array('Unknown','Intercom','Mail','Proxy','LDAP','Firewall','DNS','Profile','Network','Miscellaneous');
  	echo "<div align='right'> Dated: " . date("Y-m-d H:i:s") . "</div>
       	Hi! <b>" . ucwords($uid) . "</b> 
	Please summarize your question/problem on specific topic and submit to <b>INDEM</b> for desired response. Thanks.
	<br><br>
	<table border='0' bgcolor='white' cellspacing='0' width='100%'>
       	<tr><td>Topic</td><td><select name='topic'>";
  	foreach ($topic_arr as $cat){
   		echo "<option value='$cat'>" . ucwords($cat) . " (";
		$ques = mysql_num_rows(mysql_query("select * from faqs where topic='$cat'"));
   		echo $ques . ")</option>";
  	}
  	echo "</select></td></tr>
       	<tr valign='top'><td>Problem</td><td><textarea name='question' rows=5 cols=50></textarea></td></tr>
       	<tr><td></td><td><input type='submit' name='submit' value='SUBMIT'>
       	<a href='?pg=submission&action=faqs_list&id='>Submitted Problem</a>
	</td></tr></table><center>| ";
  	$rs = mysql_query("select topic, count(id) as no from faqs group by topic");
  	while ($o = mysql_fetch_object($rs)) {
		$no += $o->no;
    		echo "<a href='?pg=submission&action=faqs_list&topic=$o->topic'>$o->topic ($o->no)</a> | ";
	}
	echo "Total ($no)</center>";
  	return;
}

function faqs_list($topic, $uid, $role, $id, $pg) {
  	echo "<b id='heading'>Submitted Problem</b><ul>";
	$no = ($pg-1) * 10;
	$i = $no;
  	if ($topic) $rs = mysql_query("select SQL_CALC_FOUND_ROWS * from faqs where topic='$topic' LIMIT $no,10");
  	else $rs = mysql_query("select SQL_CALC_FOUND_ROWS * from faqs LIMIT $no,10");
	$tro = mysql_fetch_object(mysql_query("select FOUND_ROWS() as no"));
  	while ($o = mysql_fetch_object($rs)) {
		$i++;
    		echo "<li>($i) <b><u>$o->topic</u></b> $o->question";
		if ($role == 'admin') {
			echo " [<a href='?pg=submission&action=faqs_delete&topic=$o->topic&id=$o->id&pg=$pg'>delete</a>]";
		}
		echo "<div align='right'><i>By $o->uid from $o->ipaddress dated $o->dated</i></div>";
		$sol = mysql_num_rows(mysql_query("select * from solutions where faqs=$o->id"));
		echo "<a href='?pg=submission&action=solution_list&topic=$o->topic&id=$o->id'>Solutions ($sol)</a><br><br></li>";
  	}
  	echo "</ul><a href='?pg=submission&action='>Submit Problem</a><br>";
	$total = $tro->no;
        if ($total > 10) {
                echo "<div align='right'>Goto Page: [ ";
                for($i=1; $i<=ceil($total/10); $i++) {
                        if ($i == $pg)
                                echo "<b>$i</b>&nbsp;";
                        else
        		        echo "<a href='?pg=submission&action=faqs_list&topic=$topic&pg=$i'>$i</a>&nbsp;";
                }
	        echo "]</div>";
        }
  	return;
}

function solution_list($topic, $uid, $role, $id) {
  	echo "<b id='heading'>Submitted Solutions</b><br>";
	$no = ($pg-1) * 10;
  	$query = mysql_query("select * from faqs where id=$id order by dated desc");
        if ($query) {
		$o = mysql_fetch_object($query);
		echo "<dir><b>Que:</b> <font color='red'><u>$o->topic - $o->question</u></font>
		<div align='right'>By $o->uid from $o->ipaddress dated $o->dated</div></dir><ol>";
		if (!$topic) $topic = $o->topic;	
        	$rs = mysql_query("select * from solutions where faqs=$id order by dated desc");
		while ($p = mysql_fetch_object($rs)) {
               		echo "<li>$p->solution";
			if ($role == 'admin') {
				echo " [<a href='?pg=submission&action=solution_delete&topic=$topic&id=$id&sid=$p->id'>delete</a>]";
			}
			echo "<div align='right'><i>By $p->uid from $p->ipaddress dated $p->dated</i></div></li>";
        	}
		echo "</ol>";
	}
  	echo "<center><br>
	<b>Submit your Solution on the above FAQ</b><br><input type='hidden' name='id' value='$id'>
	<textarea name='solution' rows='5' cols='50'></textarea><br>
  	<a href='?pg=submission&action='>Submit Problem</a> <input type='submit' name='submit' value='SUBMIT'>
       	<input type='submit' name='submit' value='LOGOUT'> <a href='?pg=submission&action=faqs_list&topic=$topic'>Submitted Problem</a>
	<input type='hidden' name='action' value='solution_list'> 
	</center>";
        return;
}

function note(){
  	echo "<ul>
      	<li>Please raise your question with complete technical details/observations.</li> 
	<li>Specify the topic for better understanding.</li>
	<li>Monitor contributed solutions online on your question/problem.</li>
	<li>Beware! posted questions/solutions are not editable at later stage.</li>
      	</ul>";
  	return;
}

include "footer.php";
?>
</body></html>