/
helpdeskfaq.inc
139 lines (134 loc) · 4.42 KB
/
helpdeskfaq.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?
// Copyright 2002 Brian Ronald. All rights reserved.
// Portable PHP/MySQL Corporate Intranet System
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////////////
function displayfaq($faqid, $question, $faqcategory)
{
global $PHP_SELF;
print("<tr>");
print("<td class=\"list\">\n");
print($faqid." <a href=\"$PHP_SELF?callmodule=".rawurlencode($GLOBALS["callmodule"])."&faqnumber=$faqid\">".strip_tags($question)."</a>");
print("</td>\n");
print("<td class=\"list\">\n");
print($faqcategory);
print("</td>\n");
print("</tr>\n");
return(true);
}
if($faqnumber>0)
{ // This section is the part that lets you edit a specific FAQ.
{
$sql = "SELECT * FROM faq WHERE faqid = ".$faqnumber;
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if((@ mysqli_num_rows($result) != 0) OR ($faqnumber==0))
{
{
$sql = "SELECT * FROM faq WHERE faqid = ".$faqnumber;
$result = @ mysqli_query($intranet_db,$sql);
showerror();
}
print("<table>");
$row = @ mysqli_fetch_array($result,MYSQLI_ASSOC);
print("<tr>");
print("<th class=\"detail\">");
print($lang['category'].":</th>");
print("<th class=\"detail\">");
foreach($faqc as $categoryid => $name)
{
if($categoryid==$row["categoryid"])
print($name);
}
print("</th>\n");
print("</tr>\n");
print("<tr>");
print("<th class=\"detail\">");
print($lang['question'].":</th><th class=\"detail\"><h2>".$row["question"] . "</h2>\n");
print("</th>\n");
print("</tr>\n");
print("<tr>");
print("<th class=\"detail\">");
print($lang['answer'].":</th><td class=\"detail\">\n");
print(nl2br(strip_tags($row["answer"],$allowed_tags)));
print("</td>\n");
print("</tr>\n");
print("</table>");
}
else
{
printf("<h1>".$lang['faq_not_exist']."</h1>\n",$faqnumber );
}
}
}
else
{ // This section lets you locate a specific FAQ.
unset($faqnumber);
print("<form method=\"get\" action=\"$PHP_SELF\">\n");
print("<input type=\"hidden\" name=\"callmodule\" value=\"$callmodule\">");
print("<select name=\"category\">\n");
print("<option value=\"0\">".$lang['all_categories']."</option>\n");
foreach($faqc as $categoryid => $name)
{
print("<option ");
if($categoryid==$category)
print("selected ");
print("value=\"$categoryid\">$name</option>\n");
}
print("</select>\n");
print(" ".$lang['word_search'].":<input type=\"text\" name=\"faqsearch\" value=\"$faqsearch\">");
print(" ".$lang['faq_number'].":<input type=\"text\" name=\"faqnumber\" value=\"$faqnumber\">");
print("<input class=\"button\" type=\"submit\" value=\"".$lang['filter']."\">");
print("</form>\n");
$sql = "SELECT * FROM faq WHERE 1";
if ($category > 0)
{
$sql .= " AND categoryid=$category";
}
if ($faqsearch != "")
{
$sql .= " AND question LIKE '%$faqsearch%'";
}
$sql .= " ORDER BY faqid";
if ($faqnumber > 0)
{
$sql = "SELECT * FROM faq WHERE faqid=$faqnumber";
}
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
print("<table>\n");
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
displayfaq($row["faqid"],$row["question"],$faqc[$row["categoryid"]]);
}
print("</table>\n");
}
else
{
print("<h1>".$lang['no_faqs_found']."</h1>\n");
}
}
$help_keyword="helpdeskfaq";
if(isset($faqnumber))
{
if($faqnumber>0)
$help_keyword.="r";
else
$help_keyword.="l";
}
?>