Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?PHP
  2. addDashboardItem('Useful links', 'E-mail support', 'support/005');
  3. if (!isset($_POST['search'])) {
  4. define('SUPPORT_TITLE', 'Search');
  5. define('SUPPORT_BTITLE', 'Search support articles');
  6. $sbody = '
  7. <p class="blurb">Please enter the terms you would like to search the support
  8. database for.</p>
  9. <p>
  10. <form action="'.CP_PATH.'support/999" method="post">
  11. <input type="text" name="search">
  12. <input type="submit" value="Search">
  13. </form>
  14. </p>
  15. <p>If you can\'t find the answert to your query, please raise a ticket, or
  16. contact support via e-mail.</p>
  17. ';
  18. define('SUPPORT_BODY', $sbody);
  19. } else {
  20. if (get_magic_quotes_gpc()) { $_POST['search'] = stripslashes($_POST['search']); }
  21. $terms = strip_tags(urldecode($_POST['search']));
  22. define('SUPPORT_TITLE', 'Search :: '.$terms);
  23. define('SUPPORT_BTITLE', 'Search results for "'.$terms.'"');
  24. function filter ($terms) {
  25. $re1 = array('email');
  26. $re2 = array('e-mail');
  27. $terms = str_replace($re1, $re2, $terms);
  28. $terms = preg_replace('/\W/s',' ',$terms);
  29. $terms = preg_replace('/ {2,}/',' ',$terms);
  30. return $terms;
  31. }
  32. $terms = explode(" ", filter($terms));
  33. $sup = array();
  34. $titles = array();
  35. $files = glob('sup/search/*.txt');
  36. foreach ($files as $file) {
  37. $id = substr($file,-7,3);
  38. $data = file($file);
  39. $titles[$id] = $data[0];
  40. $sup[$id] = ' '.filter(implode('',$data)).' ';
  41. }
  42. $scores = array();
  43. foreach ($sup as $id => $data) {
  44. $scores[$id] = 0;
  45. foreach ($terms as $word) {
  46. $scores[$id] += preg_match_all('# '.$word.' #i',$data,$m);
  47. }
  48. $scores[$id] /= (count($terms)*count(explode("\n",$data)));
  49. }
  50. arsort($scores);
  51. $sbody = '<ol>';
  52. $done = false;
  53. foreach (array_slice($scores,0,10,true) as $id => $data) {
  54. if (round($data,2) == 0) { continue; }
  55. $done = true;
  56. $sbody .= '<li><a href="'.CP_PATH.'support/'.$id.'">'.$titles[$id].'</a>';
  57. $sbody .= '<br>Score: '.round($data,2).'<br></li>';
  58. }
  59. $sbody .= '</ol>';
  60. if (!$done) { $sbody = '<p>Sorry, no matching support articles.</p>'; }
  61. define('SUPPORT_BODY', $sbody);
  62. }
  63. ?>