A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.
1 <?php 2 if (!isset($submit)) { 3 session_start(); 4 if($fid){ 5 include ("connect.php"); 6 include ("links.php"); 7 8 ?> 9 <BR><P> 10 <font size=2 color=blue>Powered by <a href=http://www.campbus.com/faqadministrator.html>Faq Administrator</a></font> 11 <P> 12 <table border="0" width="30%"> 13 <tr> 14 <td bgcolor="#000000" width="120"><font color="#ffffff" face="arial" size="2"><b>Total Questions</b> </font></td> 15 <td bgcolor="#000000" width="120"><font color="#ffffff" face="arial" size="2"><b>Total Replies</b> </font></td></tr> 16 <?php 17 print ("<tr>"); 18 print ("<td bgcolor=#c3c3c3 ALIGN=CENTER><font color=#000000 face=arial size=2>"); 19 20 $zresult = mysql_query ("SELECT COUNT(*) as questions 21 from faq_dat 22 where faq_fid = '$fid' 23 "); 24 25 if ($myrow = mysql_fetch_array($zresult)) { 26 27 do { 28 29 print $myrow["questions"]; 30 31 } while ($myrow = mysql_fetch_array($zresult)); 32 } 33 34 print ("</font></td>"); 35 print ("<td bgcolor=#c3c3c3 ALIGN=CENTER><font color=#000000 face=arial size=2>"); 36 37 $zresult = mysql_query ("SELECT count(*) as replies 38 from faq_dat, faq_re_dat 39 WHERE faq_re_dat.faq_re_memo = faq_dat.faq_date 40 and faq_re_dat.faq_re_fid = '$fid' 41 and faq_re_dat.fodr = faq_dat.fodr 42 "); 43 44 if ($myrow = mysql_fetch_array($zresult)) { 45 46 do { 47 print $myrow["replies"]; 48 49 } while ($myrow = mysql_fetch_array($zresult)); 50 } 51 52 print ("</font></td></tr>"); 53 54 ?> 55 56 </table> 57 58 <BR> 59 60 <table border="0" width="100%"> 61 <tr><td bgcolor="#000000"><font color="#ffffff" face="arial" size="2"><b>Subject</b> </font></td> 62 <td bgcolor="#000000"><font color="#ffffff" face="arial" size="2"><b>From</b> </font></td> 63 <td bgcolor="#000000"><font color="#ffffff" face="arial" size="2"><b>Date Posted</b> </font></td> 64 <td bgcolor="#000000" width="10"><font color="#ffffff" face="arial" size="2"><b>Replies</b> </font></td> 65 <td bgcolor="#000000"><font color="#ffffff" face="arial" size="2"><b>Last Reply Posted</b> </font></td> 66 </tr> 67 68 <? 69 70 // Date formatting 71 function formatDate($val) 72 { 73 // split up the timestamp 74 $year=substr($val,0,4); 75 $month=substr($val,4,2); 76 $day=substr($val,6,2); 77 $hh=substr($val,8,2); 78 $mm=substr($val,10,2); 79 // convert into standard timestamp and format it 80 $date = date("d-M-Y@H:i"); 81 return $date; 82 } 83 84 $m1 = ("1"); 85 $limit=20; // rows to return 86 $numresults=mysql_query("select * from faq_dat where faq_fid = '$fid'"); 87 $numrows=mysql_num_rows($numresults); 88 89 if (empty($offset)) { 90 $offset=0; 91 } 92 93 $result = mysql_query ("SELECT * 94 FROM faq_dat 95 where faq_fid = '$fid' 96 order by fodr DESC 97 limit $offset,$limit 98 "); 99 100 if ($myrow = mysql_fetch_array($result)) { 101 102 103 do { 104 105 $alt2=str_replace(" ", "+", $myrow["faq_memo"]); 106 107 $fodrx = $myrow["fodr"]; 108 if ($myrow['redate'] == "") {$myrow['redate'] = "No Replies";} 109 110 print ("<tr><td bgcolor=#c3c3c3><font color=#000000 face=arial size=2>"); 111 printf("<a href=\"faqhist.php?fodrx=$fodrx&m1=$m1&fm=$alt2&fid=$fid\">%s</a><br>\n\n", $myrow["faq_memo"]); 112 print ("</font></td>"); 113 print ("<td bgcolor=#c3c3c3><font color=#000000 face=arial size=2>"); 114 print $myrow["faq_user"]; 115 print ("</font></td>"); 116 print ("<td bgcolor=#c3c3c3><font color=#000000 face=arial size=2>"); 117 print $myrow["faq_date"]; 118 print ("</font></td>"); 119 print ("<td bgcolor=#c3c3c3><font color=Green face=arial size=2><B>"); 120 print $myrow["replies"]; 121 print ("</B></font></td>"); 122 print ("<td bgcolor=#c3c3c3><font color=#000000 face=arial size=2>"); 123 print $myrow["redate"]; 124 print ("</font></td></tr>"); 125 126 } while ($myrow = mysql_fetch_array($result)); 127 128 $pages=intval($numrows/$limit); 129 if ($numrows%$limit) { 130 $pages++; 131 } 132 133 if (!((($page+$limit) / $limit) >= $pages) && $pages !=1) { // If last page don't give next link. 134 $newoffset=$offset+$limit; 135 $next_page = $page + $limit; 136 echo(" <a href=\"$PHP_SELF?fid=$fid&page=$next_page&offset=$newoffset\">Next</a>");} 137 138 if (((($page-$limit) / $limit) >= 0)) { // If first page don't give previous link. 139 $prevoffset=$offset-$limit; 140 $prev_page = '$page - $limit'; 141 echo(" <a href=\"$PHP_SELF?fid=$fid&page=$prev_page&offset=$prevoffset\">Prev</a>");} 142 143 } else { 144 echo "<b>Looks Like you're the first.. CONGRATULATIONS !!!!!</b>"; 145 146 } 147 148 session_destroy(); 149 ?> 150 151 </table> 152 <BR><BR> 153 <b>Post a new message:</b></font><br><br> 154 <table width=460 border="0"> 155 <FORM METHOD="post" ACTION=""> 156 <tr><td><font color="#000000" face="arial" size="2">Name:</font></td><td><input type="text" name="faq_user" SIZE="30" maxlength="30"></td></tr> 157 <tr><td><font color="#000000" face="arial" size="2">Email:</font></td><td><input type="text" name="faq_user_email" SIZE="30" maxlength="30"></td></tr> 158 <tr><td><font color="#000000" face="arial" size="2">Subject:</font></td><td><input type="text" name="faq_memo" SIZE="25" maxlength="25"></td></tr> 159 <tr><td><input type="hidden" name="faq_date" value="<? echo formatDate('timestamp') ?>" maxlength=25></td></tr> 160 <tr><td><input type="hidden" name="faq_fid" value="<? echo $fid ?>" maxlength=5></td></tr> 161 <tr><td><font color="#000000" face="arial" size="2">Email Replies To Me</font></td><td><font color="#000000" face="arial" size="2">Yes</font> <input type=radio name=email value=Y> <font color="#000000" face="arial" size="2">No</font> <input type=radio name=email value=N checked></td></tr> 162 <tr><td valign="top"><font color="#000000" face="arial" size="2">Message:</font></td> 163 <td valign="top"><textarea name="faq_dat" cols="40" rows="10"></textarea> 164 <tr><td></td><td><font face="arial"><input type="submit" name="submit" value="Post"> <INPUT TYPE=reset value=Cancel> 165 </font></form></td></tr> 166 </table></body> 167 </html> 168 <? 169 170 }else{echo "<h2>ERROR!</h2>";} 171 172 }else{?> 173 174 <html> 175 <HEAD> 176 <meta HTTP-EQUIV="REFRESH" CONTENT="1;URL=faq.php?fid=<? echo $faq_fid ?>"> 177 <title>Your Question has been Saved ! </title> 178 </HEAD> 179 <body bgcolor="ffffff"> 180 181 <?php 182 183 include ("connect.php"); 184 185 $faq_dat = addslashes($faq_dat); 186 $faq_dat = strip_tags($faq_dat, '<a><b><i><u>'); 187 188 $faq_memo = addslashes($faq_memo); 189 $faq_memo = strip_tags($faq_memo, '<a><b><i><u>'); 190 191 if(ereg("www","$faq_user_email")){header("Location: faq.php"); $m1 = "0"; exit();} 192 if(ereg("://","$faq_user_email")){header("Location: faq.php"); $m1 = "0"; exit();} 193 if(preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $faq_user_email)){$faq_user_email = "";} 194 195 196 if (ereg(".", $faq_memo) == 1) 197 { 198 199 $sql = "INSERT INTO faq_dat(faq_dat, faq_user, faq_memo, faq_user_email, faq_date, email, faq_fid) 200 VALUES ('$faq_dat', '$faq_user', '$faq_memo', '$faq_user_email', '$faq_date', '$email', '$faq_fid')"; 201 $result = mysql_query($sql); 202 203 echo "Your FAQ Has Been Saved !<BR> Thank You for using Faq Administrator<BR>\n"; 204 205 } 206 else 207 { 208 print ("<B>Error:</B> A Subject Title is required. Save was aborted!!"); 209 $verify = "bad"; 210 211 } 212 213 ?> 214 215 </body> 216 </html> 217 218 <?}?>