ABP QAs:
define("DEBUG", "iON");
if (isset($_GET['stage'])) {
$stage=$_GET['stage'];
}
else {
$stage = "not_posted";
}
if (isset($_GET['target'])) {
$target=$_GET['target'];
}
else {
$target = "target";
}
$ip = $_SERVER['REMOTE_ADDR'];
$user_agent = $_SERVER["HTTP_USER_AGENT"];
if (DEBUG == "ON") {
echo "#DEBUG: Stage = $stage \n";
echo "#DEBUG: Target = $target \n";
}
?>
if ($target <> "target") {
$faq_values = Get_Answer($target);
$qname = $faq_values[0];
$question = $faq_values[1];
// $answer = nl2br($faq_values[2]);
$answer = $faq_values[2];
echo "\n";
echo " | \n";
echo " ";
echo " $question \n";
echo " ";
echo " $answer \n";
echo "Back \n";
echo " | \n";
} else {
// echo "No Target Selected Yet \n";
Get_Questions('yes');
}
function Get_Questions($status) {
if (DEBUG == "ON") {
echo "#DEBUG: Querying for All Questions \n";
}
$host = 'web.abptech.com';
$database = 'db_ABPWeb';
$table_id = 'qa';
$query = "SELECT qname, question FROM $table_id where `active` = '" . $status . "' ORDER BY `question`;";
if (DEBUG == "ON") {
echo "#DEBUG: Query = $query \n";
}
if (!$dbconnect = mysql_connect($host, 'root', 'qahelper')) {
echo "Password Check: Connection failed to the host $host.";
exit;
} // if
if (!mysql_select_db($database)) {
echo "Password Check: Cannot connect to database $database.";
exit;
} // if
$dbresult = mysql_query($query, $dbconnect);
/* Performing SQL query */
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$x = 1;
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
?>
|
}
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($dbconnect);
}
function Get_Answer($target) {
if (DEBUG == "ON") {
echo "#DEBUG: Querying for Answer = $target \n";
}
$host = 'web.abptech.com';
$user = 'www.abptech.com';
$password = 'whoopdee2376';
$database = 'db_ABPWeb';
$table_id = 'qa';
$query = "SELECT * FROM $table_id where qname = '" . $target . "';";
// $query = "SELECT mac.mac, mac.setting_server, customer.company_name FROM customer INNER JOIN mac ON customer.customer_number = mac.customer_number WHERE (((mac.mac)='" . $mac . "'));";
if (DEBUG == "ON") {
echo "#DEBUG: Query = $query \n";
}
if (!$dbconnect = mysql_connect($host, $user, $password)) {
echo "Password Check: Connection failed to the host $host.";
exit;
} // if
if (!mysql_select_db($database)) {
echo "Password Check: Cannot connect to database $database.";
exit;
} // if
$dbresult = mysql_query($query, $dbconnect);
/* Performing SQL query */
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$num=mysql_numrows($result);
$row = mysql_fetch_array($result, MYSQL_NUM);
$qname = "";
if ($num == "1") {
$qname = mysql_result($result,0,"qname");
$question = mysql_result($result,0,"question");
$answer = mysql_result($result,0,"answer");
}
if (DEBUG == "ON") {
echo "#DEBUG: Returned = $qname \n";
echo "#DEBUG: Returned = $question \n";
echo "#DEBUG: Returned = $answer \n";
}
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($dbconnect);
// return $qname;
if ($num == "1" ) {
return array ($qname, $question, $answer);
}
else {
return array ("Not found contact support @ abpusa.com", "Not found");
}
}
?>
|
|