home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / forums / functions.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  40.5 KB  |  1,469 lines

  1. <?php
  2. ######################################################################
  3. # Modulo Splatt Forum per PHP-NUKE 
  4. #-------------------------
  5. # Versione: 3.2
  6. #
  7. # Copyright (c) 2002 by:
  8. #
  9. # Giorgio Ciranni (~Splatt~)
  10. # (http://www.splatt.it)
  11. # (webmaster@splatt.it)
  12. #
  13. # Supporto tecnico disponibile sul Forum di www.splatt.it
  14. ######################################################################
  15. # Splatt Forum is free software. You can redistribute it and/or modify
  16. # it under the terms of the GNU General Public License as published by
  17. # the Free Software Foundation; either version 2 of the License.
  18. # Splatt Forum is distributed in the hope that it will be useful,
  19. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. # GNU General Public License for more details.
  22. #
  23. # You should have received a copy of the GNU General Public License
  24. # along with this program; if not, write to the Free Software
  25. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
  26. # 02111-1307  USA
  27. ######################################################################
  28. $forumver = "3.2";  //non toccare
  29. ######################################################################
  30.  
  31. $module_name = "$name";
  32.  
  33. if (isset($indexut) && $indexut != $userindex[0]){
  34.  
  35.       setcookie("userindex", $indexut, 0);
  36.  
  37. header("Location:".$PHP_SELF."?op=modload&name=".$module_name."&file=index");
  38.  
  39. }
  40.  
  41. $index = $userindex[0];
  42. include("config.php");
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. ###################################
  50. function secure($message)
  51. {
  52. global $adminmail,$nukeurl,$poster_ip,$topic_id,$forum;
  53. if(stristr("$message","<script>")||stristr("$message","document.cookie")||stristr("$message","javascript")||stristr("$message","unescape"))
  54.  {
  55.   $messageor = $message;
  56.   $message = strtolower($message);
  57.   $message = str_replace("<script>", "<"._FISCRIPT.">", $message);
  58.   $message = str_replace("</script>", "<"._FINSCRIPT.">", $message);
  59.   $message = str_replace("document.cookie", ""._FHACK."", $message);
  60.   $message = str_replace("javascript", "J A V A S C R I P T", $message);
  61.   $message = str_replace("unescape", ""._FHACK."", $message);
  62.  
  63. $subject = "Forum Alert message";
  64. $alert_message = "HACKER ALERT NOTIFY \n A post inserted on your forums is a probable hacker attack. \n\n Post detail:\n $messageor \n\n $nukeurl \n\n POSTER IP ADRESS: $poster_ip \n\n Post Url: $nukeurl/modules.php?op=modload&name=Forums&file=viewtopic&topic=$topic_id&forum=$forum \n\n";
  65.     mail($adminmail, $subject, $alert_message, "From: $adminmail\nX-Mailer: PHP/" . phpversion());
  66.  
  67.  return($message);
  68.   }
  69.   else {
  70.   return($message);
  71.   }
  72. }
  73.  
  74. ###################################
  75.  
  76. // Keledan Begin
  77. function convertiData($data)
  78. {
  79. $data = strtotime($data);
  80. $data = strftime(_LOCALDATETIME, $data);
  81. return($data);
  82. }
  83. // Keledan End
  84.  
  85. ###################################
  86. function addForumScripts()
  87. {
  88.     echo "<SCRIPT type=\"text/javascript\">\n\n<!--\n";
  89.     echo "function x () {\n";
  90.     echo "return;\n";
  91.     echo "}\n";
  92.     echo "\n";
  93.     echo "function DoSmilie(addSmilie) {\n";
  94.     echo "\n";
  95.     echo "var addSmilie;\n";
  96.     echo "var revisedMessage;\n";
  97.     echo "var currentMessage = document.coolsus.message.value;\n";
  98.     echo "revisedMessage = currentMessage+addSmilie;\n";
  99.     echo "document.coolsus.message.value=revisedMessage;\n";
  100.     echo "document.coolsus.message.focus();\n";
  101.     echo "return;\n";
  102.     echo "}\n";
  103.     echo "\n";
  104.     echo "function DoPrompt(action) {\n";
  105.     echo "var revisedMessage;\n";
  106.     echo "var currentMessage = document.coolsus.message.value;\n";
  107.     echo "\n";
  108.     echo "if (action == \"url\") {\n";
  109.     echo "var thisURL = prompt(\"Enter the URL for the link you want to add.\", \"http://\");\n";
  110.     echo "var thisTitle = prompt(\"Enter the web site title\", \"Page Title\");\n";
  111.     echo "var urlBBCode = \"[URL=\"+thisURL+\"]\"+thisTitle+\"[/URL]\";\n";
  112.     echo "revisedMessage = currentMessage+urlBBCode;\n";
  113.     echo "document.coolsus.message.value=revisedMessage;\n";
  114.     echo "document.coolsus.message.focus();\n";
  115.     echo "return;\n";
  116.     echo "}\n";
  117.     echo "\n";
  118.     echo "if (action == \"email\") {\n";
  119.     echo "var thisEmail = prompt(\"Enter the email address you want to add.\", \"\");\n";
  120.     echo "var emailBBCode = \"[EMAIL]\"+thisEmail+\"[/EMAIL]\";\n";
  121.     echo "revisedMessage = currentMessage+emailBBCode;\n";
  122.     echo "document.coolsus.message.value=revisedMessage;\n";
  123.     echo "document.coolsus.message.focus();\n";
  124.     echo "return;\n";
  125.     echo "}\n";
  126.     echo "\n";
  127.     echo "if (action == \"bold\") {\n";
  128.     echo "var thisBold = prompt(\"Enter the text that you want to make bold.\", \"\");\n";
  129.     echo "var boldBBCode = \"[B]\"+thisBold+\"[/B]\";\n";
  130.     echo "revisedMessage = currentMessage+boldBBCode;\n";
  131.     echo "document.coolsus.message.value=revisedMessage;\n";
  132.     echo "document.coolsus.message.focus();\n";
  133.     echo "return;\n";
  134.     echo "}\n";
  135.     echo "\n";
  136.     echo "if (action == \"italic\") {\n";
  137.     echo "var thisItal = prompt(\"Enter the text that you want to make italic.\", \"\");\n";
  138.     echo "var italBBCode = \"[I]\"+thisItal+\"[/I]\";\n";
  139.     echo "revisedMessage = currentMessage+italBBCode;\n";
  140.     echo "document.coolsus.message.value=revisedMessage;\n";
  141.     echo "document.coolsus.message.focus();\n";
  142.     echo "return;\n";
  143.     echo "}\n";
  144.     echo "\n";
  145.     echo "if (action == \"image\") {\n";
  146.     echo "var thisImage = prompt(\"Enter the URL for the image you want to display.\", \"http://\");\n";
  147.     echo "var imageBBCode = \"[IMG]\"+thisImage+\"[/IMG]\";\n";
  148.     echo "revisedMessage = currentMessage+imageBBCode;\n";
  149.     echo "document.coolsus.message.value=revisedMessage;\n";
  150.     echo "document.coolsus.message.focus();\n";
  151.     echo "return;\n";
  152.     echo "}\n";
  153.     echo "\n";
  154.     echo "if (action == \"quote\") {\n";
  155.     echo "var quoteBBCode = \"[QUOTE]  [/QUOTE]\";\n";
  156.     echo "revisedMessage = currentMessage+quoteBBCode;\n";
  157.     echo "document.coolsus.message.value=revisedMessage;\n";
  158.     echo "document.coolsus.message.focus();\n";
  159.     echo "return;\n";
  160.     echo "}\n";
  161.     echo "\n";
  162.     echo "if (action == \"code\") {\n";
  163.     echo "var codeBBCode = \"[CODE]  [/CODE]\";\n";
  164.     echo "revisedMessage = currentMessage+codeBBCode;\n";
  165.     echo "document.coolsus.message.value=revisedMessage;\n";
  166.     echo "document.coolsus.message.focus();\n";
  167.     echo "return;\n";
  168.     echo "}\n";
  169.     echo "\n";
  170.     echo "if (action == \"listopen\") {\n";
  171.     echo "var liststartBBCode = \"[LIST]\";\n";
  172.     echo "revisedMessage = currentMessage+liststartBBCode;\n";
  173.     echo "document.coolsus.message.value=revisedMessage;\n";
  174.     echo "document.coolsus.message.focus();\n";
  175.     echo "return;\n";
  176.     echo "}\n";
  177.     echo "\n";
  178.     echo "if (action == \"listclose\") {\n";
  179.     echo "var listendBBCode = \"[/LIST]\";\n";
  180.     echo "revisedMessage = currentMessage+listendBBCode;\n";
  181.     echo "document.coolsus.message.value=revisedMessage;\n";
  182.     echo "document.coolsus.message.focus();\n";
  183.     echo "return;\n";
  184.     echo "}\n";
  185.     echo "\n";
  186.     echo "if (action == \"listitem\") {\n";
  187.     echo "var thisItem = prompt(\"Enter the new list item. Note that each list group must be preceeded by a List Close and must be ended with List Close.\", \"\");\n";
  188.     echo "var itemBBCode = \"[*]\"+thisItem;\n";
  189.     echo "revisedMessage = currentMessage+itemBBCode;\n";
  190.     echo "document.coolsus.message.value=revisedMessage;\n";
  191.     echo "document.coolsus.message.focus();\n";
  192.     echo "return;\n";
  193.     echo "}\n";
  194.     echo "\n";
  195.     echo "}\n";
  196.     echo "//--></SCRIPT>\n";
  197.     echo "\n";
  198. }
  199.  
  200. ######################################################
  201. function putitems() {
  202. global $atch;
  203.  
  204.     echo " <A href=\"javascript: x()\" onClick=\"DoPrompt('url');\"><IMG src=\"images/forum/b_url.gif\" border=\"0\" alt=\"BBCode: Web Address\"></A>\n";
  205.  
  206.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('email');\"><IMG src=\"images/forum/b_email.gif\" border=\"0\" alt=\"BBCode: Email Address\"></A>\n";
  207.  
  208.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('image');\"><IMG src=\"images/forum/b_image.gif\" border=\"0\" alt=\"BBCode: Load Image from Web\"></A>\n";
  209.  
  210.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('bold');\"><IMG src=\"images/forum/b_bold.gif\" border=\"0\" alt=\"BBCode: Bold Text\"></A>\n";
  211.  
  212.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('italic');\"><IMG src=\"images/forum/b_italic.gif\" border=\"0\" alt=\"BBCode: Italic Text\"></A>\n";
  213.  
  214.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('quote');\"><IMG src=\"images/forum/b_quote.gif\" border=\"0\" alt=\"BBCode: Quote\"></A>\n";
  215.  
  216.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('code');\"><IMG src=\"images/forum/b_code.gif\" border=\"0\" alt=\"BBCode: Code\"></A>\n";
  217.  
  218.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listopen');\"><IMG src=\"images/forum/b_listopen.gif\" border=\"0\" alt=\"BBCode: Open List\"></A>\n";
  219.  
  220.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listitem');\"><IMG src=\"images/forum/b_listitem.gif\" border=\"0\" alt=\"BBCode: List Item\"></A>\n";
  221.  
  222.     echo "<A href=\"javascript: x()\" onClick=\"DoPrompt('listclose');\"><IMG src=\"images/forum/b_listclose.gif\" border=\"0\" alt=\"BBCode: Close List\"></A>\n";
  223.  
  224. echo "<br><br>";
  225.  
  226.  
  227.  
  228.  
  229.  
  230.    // echo ""._CLICONSMI."<br>";
  231.  
  232.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-) ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_smile.gif\" border=\"0\" alt=\":-)\" hspace=\"5\"></A>";
  233.  
  234.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-( ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_frown.gif\" border=\"0\" alt=\":-(\" hspace=\"5\"></A>";
  235.  
  236.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-D ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_biggrin.gif\" border=\"0\" alt=\":-D\" hspace=\"5\"></A>";
  237.  
  238.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' ;-) ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_wink.gif\" border=\"0\" alt=\";-)\" hspace=\"5\"></A>";
  239.  
  240.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-o ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_eek.gif\" border=\"0\" alt=\":-0\" hspace=\"5\"></A>";
  241.  
  242.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' 8-) ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_cool.gif\" border=\"0\" alt=\"8-)\" hspace=\"5\"></A>";
  243.  
  244.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-? ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_confused.gif\" border=\"0\" alt=\":-?\" hspace=\"5\"></A>";
  245.  
  246.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-P ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_razz.gif\" border=\"0\" alt=\":-P\" hspace=\"5\"></A>";
  247.  
  248.     echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-| ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon_mad.gif\" border=\"0\" alt=\":-|\" hspace=\"5\"></A>";
  249.  
  250. echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-Z ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon27.gif\" border=\"0\" alt=\":-|\" hspace=\"5\"></A>";
  251.  
  252. echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-W ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon24.gif\" border=\"0\" alt=\":-|\" hspace=\"5\"></A>";
  253.  
  254. echo "<A href=\"javascript: x()\" onClick=\"DoSmilie(' :-Y ');\"><IMG width=\"19\" height=\"19\" src=\"images/forum/icons/icon21.gif\" border=\"0\" alt=\":-|\" hspace=\"5\"></A>";
  255.  
  256. }
  257.  
  258. #################################################
  259.  
  260. function bbsearchblock() {
  261. global $module_name, $prefix;
  262.  
  263. $risult = mysql_query("select index_foot from ${prefix}_forum_config");
  264. list($index_foot) = mysql_fetch_row($risult);
  265.  
  266.     OpenTable();
  267.     echo "<table width=\"100%\"><tr><td>";
  268.     echo "<form action=\"modules.php?op=modload&name=".$module_name."&file=searchbb\" method=\"post\">";
  269.     echo "<input type=\"hidden\" name=\"addterm\" value=\"any\">";
  270.     echo "<input type=\"hidden\" name=\"sortby\" value=\"p.post_time\">";
  271.     echo "<br>";
  272.     echo "<b>"._SEARCH."</b> <input type=\"text\" name=\"term\" size=\"15\">";
  273.     echo "<input type=\"hidden\" name=\"submit\" value=\"submit\"></form>";
  274.     echo "</td><td align=\"right\">    <img src=\"images/topics/AllTopics.gif\"></td>";
  275. $index_foot = stripslashes($index_foot);
  276.     echo "<td><i>$index_foot</i></td>";
  277.     echo "</td></tr></table>";
  278.  
  279. //    echo "<div align=\"left\"><font size=\"2\">  [ <a href=\"modules.php?op=modload&name=".$module_name."&file=searchbb&addterm=any&sortby=p.post_time&adv=1\">"._FRICAV."</a> ]</font></div>";
  280.  
  281.     CloseTable();
  282.  
  283. }
  284.  
  285. ##################################################
  286.  
  287. function get_total_topics($forum_id, $db) {
  288.     global $prefix;
  289.  
  290.         $sql = "SELECT count(*) AS total FROM ${prefix}_forumtopics WHERE forum_id = '$forum_id'";
  291.  
  292.         if(!$result = mysql_query($sql, $db))
  293.             return("ERROR");
  294.  
  295.         if(!$myrow = mysql_fetch_array($result))
  296.             return("ERROR");
  297.  
  298.         return($myrow[total]);
  299. }
  300.  
  301. ##################################################
  302.  
  303. function get_total_posts($id, $db, $type) {
  304.      global $prefix, $user_prefix;
  305.  
  306.         switch($type) {
  307.  
  308.                 case 'users':
  309.  
  310.                         $sql = "SELECT count(*) AS total FROM ".$user_prefix."_users WHERE uid != 1";
  311.                 break;
  312.  
  313.                 case 'all':
  314.  
  315.                         $sql = "SELECT count(*) AS total FROM ${prefix}_posts";
  316.                 break;
  317.  
  318.                 case 'forum':
  319.  
  320.                         $sql = "SELECT count(*) AS total FROM ${prefix}_posts WHERE forum_id = '$id'";
  321.                 break;
  322.  
  323.                 case 'topic':
  324.  
  325.                         $sql = "SELECT count(*) AS total FROM ${prefix}_posts WHERE topic_id = '$id'";
  326.                 break;
  327.  
  328.                 case 'user':
  329.  
  330.                         die("Should be using the users.user_posts column for this.");
  331.  
  332.         }
  333.  
  334.         if(!$result = mysql_query($sql, $db))
  335.  
  336.                 return("ERROR");
  337.  
  338.         if(!$myrow = mysql_fetch_array($result))
  339.  
  340.                 return("0");
  341.  
  342.  
  343.         return($myrow[total]);
  344.  
  345. }
  346.  
  347. ###################################################
  348.  
  349. function get_last_post($id, $db, $type) {
  350.   global $prefix, $user_prefix;
  351.  
  352.         switch($type) {
  353.  
  354.                 case 'forum':
  355.  
  356.                 {
  357.  
  358.                   // $sql = "SELECT p.post_time, p.poster_id, u.uname FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE p.forum_id = '$id' ORDER BY post_time DESC";
  359.  
  360.  
  361.  
  362. /*
  363.  
  364. $sql = "SELECT p.poster_id FROM ${prefix}_posts p WHERE p.forum_id = '$id' ORDER BY post_time DESC limit 0, 1"; 
  365.  
  366.                   $result=mysql_query($sql);
  367.  
  368.                   $ergebnis=mysql_fetch_array($result);
  369.  
  370.                   if($ergebnis["poster_id"]=='1' || '-1') $sql = "SELECT p.topic_id, p.post_time, p.poster_id, u.uname FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE p.forum_id = '$id' ORDER BY post_time DESC limit 0, 1";
  371.  
  372.                   else
  373.  
  374. */
  375.  
  376.  $sql = "SELECT p.topic_id, p.post_time, p.poster_id, u.uname FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE p.forum_id = '$id' AND p.poster_id = u.uid ORDER BY post_time DESC limit 0, 1";
  377.  
  378.                       
  379.  
  380.                 }
  381.  
  382.                 break;
  383.  
  384.                 case 'topic':
  385.  
  386.                 {
  387.  
  388.                       ### Changed by Jens Ferner
  389.  
  390.                           ### $sql was minimized and limited
  391.  
  392.  
  393.  
  394. /*    
  395.  
  396.                           $sql = "SELECT p.poster_id FROM ${prefix}_posts p WHERE p.topic_id = '$id' ORDER BY post_time DESC limit 0, 1";
  397.  
  398.                           $result=mysql_query($sql);
  399.  
  400.                           $ergebnis=mysql_fetch_array($result);
  401.  
  402.                           if($ergebnis["poster_id"]=='1') $sql = "SELECT p.post_time, p.poster_id, u.uname FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE p.topic_id = '$id' ORDER BY post_time DESC limit 0, 1";
  403.  
  404.                           else*/
  405.  
  406.  $sql = "SELECT p.post_time, p.poster_id, u.uname FROM ${prefix}_posts p, ".$user_prefix."_users u WHERE p.topic_id = '$id' AND p.poster_id = u.uid ORDER BY post_time DESC limit 0, 1";
  407.  
  408.                         
  409.  
  410.                 }
  411.  
  412.                 break;
  413.  
  414.         }
  415.  
  416.         if(!$result = mysql_query($sql, $db))
  417.  
  418.         {
  419.  
  420.                 $val[post_time]="ERROR";
  421.  
  422.                 return ($val);
  423.  
  424.         }
  425.  
  426.         if(!$myrow = mysql_fetch_array($result))
  427.  
  428.         {
  429.  
  430.                 $val[post_time]= "";
  431.  
  432.                 return ($val);
  433.  
  434.         }
  435.  
  436.         if($myrow[poster_id]=='1') $myrow[uname]=""._FANONIMO."";
  437.  
  438.         $val[post_time]=$myrow[post_time];
  439.         $val[user]=$myrow[uname];
  440.         $val[topic_id]=$myrow[topic_id];
  441.  
  442. //        $val = sprintf("%s <br> by %s", $myrow[post_time], $myrow[uname]);
  443.  
  444.         return($val);
  445.  
  446. }
  447.  
  448. /*
  449.  
  450.  * Returns an array of all the moderators of a forum
  451.  
  452.  */
  453.  
  454. function get_moderators($forum_id, $db) {
  455.  
  456.          global $prefix, $user_prefix;
  457.  
  458.     $sql = "SELECT u.uid, u.uname FROM ".$user_prefix."_users u, ${prefix}_forum_mods f WHERE f.forum_id = '$forum_id' and f.user_id = u.uid";
  459.  
  460.     if(!$result = mysql_query($sql, $db))
  461.  
  462.      return("-1");
  463.  
  464.    if(!$myrow = mysql_fetch_array($result))
  465.  
  466.      return("-1");
  467.  
  468.    do {
  469.  
  470.       $array[] = array("$myrow[uid]" => "$myrow[uname]");
  471.  
  472.    } while($myrow = mysql_fetch_array($result));
  473.  
  474.    return($array);
  475.  
  476. }
  477.  
  478.  
  479.  
  480. /*
  481.  
  482.  * Checks if a user (user_id) is a moderator of a perticular forum (forumid)
  483.  
  484.  * Retruns 1 if TRUE, 0 if FALSE or Error
  485.  
  486.  */
  487.  
  488. function is_moderator($forum_id, $user_id, $db) {
  489.  
  490.         global $prefix;
  491.  
  492.    $sql = "SELECT userid FROM ${prefix}_forum_mods WHERE forum_id = '$forum_id' AND user_id = '$user_id'";
  493.  
  494.    if(!$result = mysql_query($sql, $db))
  495.  
  496.      return("0");
  497.  
  498.    if(!$myrow = mysql_fetch_array($result))
  499.  
  500.      return("0");
  501.  
  502.    if($myrow[userid] != '')
  503.  
  504.      return("1");
  505.  
  506.    else
  507.  
  508.      return("0");
  509.  
  510. }
  511.  
  512.  
  513.  
  514.  
  515.  
  516. function get_moderator($user_id, $db) {
  517.  
  518.          global $prefix, $user_prefix;
  519.  
  520.  
  521.  
  522. /*
  523.  
  524.         if ($user_id == 0) {
  525.  
  526.                 return("None");
  527.  
  528.         }
  529.  
  530. */
  531.  
  532.         if ($user_id == -1) {
  533.  
  534.                 return("None");
  535.  
  536.         }
  537.  
  538.  
  539.  
  540.         if ($user_id == 1) {
  541.  
  542.                 return("None");
  543.  
  544.         
  545.  
  546.  }
  547.  
  548.  
  549.  
  550.  
  551.  
  552.         $sql = "SELECT uname FROM ".$user_prefix."_users WHERE uid = '$user_id' ";
  553.  
  554.         if(!$result = mysql_query($sql, $db))
  555.  
  556.                 return("ERROR");
  557.  
  558.         if(!$myrow = mysql_fetch_array($result))
  559.  
  560.                 return("ERROR");
  561.  
  562.         return("$myrow[uname]");
  563.  
  564. }
  565.  
  566.  
  567.  
  568. function get_forum_mod($forum_id, $db) {
  569.  
  570.         global $prefix;
  571.  
  572.         $sql = "SELECT forum_moderator FROM ${prefix}_forums WHERE forum_id = '$forum_id'";
  573.  
  574.         if(!$result = mysql_query($sql, $db))
  575.  
  576.                 return("-1");
  577.  
  578.         if(!$myrow = mysql_fetch_array($result))
  579.  
  580.                 return("-1");
  581.  
  582.         return("$myrow[forum_moderator]");
  583.  
  584. }
  585.  
  586.  
  587.  
  588. /**
  589.  
  590.  * Nathan Codding - July 19, 2000
  591.  
  592.  * Checks the given password against the DB for the given username. Returns true if good, false if not.
  593.  
  594.  */
  595.  
  596. function check_user_pw($username, $password, $db, $system) {
  597.  
  598.          global $prefix, $user_prefix;
  599.  
  600.         // if (!$system) $password = crypt($password);
  601.  
  602.  
  603.  
  604.         // KingRichard Fix (Add-On 2.0.4)
  605.  
  606.         if (!$system) $password = crypt($password,substr($password,0,2));
  607.  
  608.         else $password = $password;
  609.  
  610.  
  611.  
  612.         $sql = "SELECT uid FROM ".$user_prefix."_users WHERE (uname = '$username') AND (pass = '$password')";
  613.  
  614.         $resultID = mysql_query($sql, $db);
  615.  
  616.         if (!$resultID) {
  617.  
  618.                 echo mysql_error() . "<br>";
  619.  
  620.                 die("Error doing DB query in check_user_pw()");
  621.  
  622.         }
  623.  
  624.         return mysql_num_rows($resultID);
  625.  
  626. } // check_user_pw()
  627.  
  628.  
  629.  
  630.  
  631.  
  632. /**
  633.  
  634.  * Nathan Codding - July 19, 2000
  635.  
  636.  * Returns a count of the given userid's private messages.
  637.  
  638.  */
  639.  
  640. function get_pmsg_count($user_id, $db) {
  641.  
  642.         global $prefix;
  643.  
  644.         $sql = "SELECT msg_id FROM ${prefix}_splattforum_priv_msgs WHERE (to_userid = $user_id)";
  645.  
  646.         $resultID = mysql_query($sql);
  647.  
  648.         if (!$resultID) {
  649.  
  650.                 echo mysql_error() . "<br>";
  651.  
  652.                 die("Error doing DB query in get_pmsg_count");
  653.  
  654.         }
  655.  
  656.         return mysql_num_rows($resultID);
  657.  
  658. } // get_pmsg_count()
  659.  
  660.  
  661.  
  662.  
  663.  
  664. /**
  665.  
  666.  * Nathan Codding - July 19, 2000
  667.  
  668.  * Checks if a given username exists in the DB. Returns true if so, false if not.
  669.  
  670.  */
  671.  
  672. function check_username($username, $db) {
  673.  
  674.          global $prefix, $user_prefix;
  675.  
  676.         $sql = "SELECT uid FROM ".$user_prefix."_users WHERE (uname = '$username')";
  677.  
  678.         $resultID = mysql_query($sql);
  679.  
  680.         if (!$resultID) {
  681.  
  682.                 echo mysql_error() . "<br>";
  683.  
  684.                 die("Error doing DB query in check_username()");
  685.  
  686.         }
  687.  
  688.         return mysql_num_rows($resultID);
  689.  
  690. } // check_username()
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698. ################################
  699.  
  700. function get_userdata_from_id($userid, $db) {
  701.  
  702.          global $prefix, $user_prefix;
  703.  
  704.  
  705.  
  706.      /*
  707.  
  708.    $sql = "SELECT * FROM ${prefix}_um_users_status  WHERE uid = $userid";
  709.  
  710. // die("<center><b>Errore!!! User NON Valido!</b></center>");
  711.  
  712.         $result = mysql_query($sql, $db);
  713.  
  714.         if(mysql_num_rows($result)<1)
  715.  
  716.            {
  717.  
  718.             $sql="INSERT into ${prefix}_splattforum_users_status (uid, posts, attachsig, rank, level) VALUES ('".$userid."',0,1,0,1)";
  719.  
  720.             mysql_query($sql);
  721.  
  722.            }
  723.  
  724. */
  725.  
  726. /*
  727.  
  728. $sql = "SELECT u.*, s.* FROM ".$user_prefix."_users u, ${prefix}_splattforum_users_status s WHERE s.uid = $userid AND u.uid = $userid";
  729.  
  730. */
  731.  
  732.  
  733.  
  734.         $sql = "SELECT * FROM ".$user_prefix."_users WHERE uid = $userid";
  735.  
  736.  
  737.  
  738.  
  739.  
  740.         if(!$result = mysql_query($sql, $db)) {
  741.  
  742.                 $userdata = array("error" => "1");
  743.  
  744.                 return ($userdata);
  745.  
  746.         }
  747.  
  748.         if(!$myrow = mysql_fetch_array($result)) {
  749.  
  750.                 $userdata = array("error" => "1");
  751.  
  752.                 return ($userdata);
  753.  
  754.         }
  755.  
  756.  
  757.  
  758.         return($myrow);
  759.  
  760. }
  761.  
  762.  
  763.  
  764. ################################
  765.  
  766. function get_userdata($username, $db) {
  767.  
  768.          global $prefix, $user_prefix;
  769.  
  770.         $sql = "SELECT * FROM ".$user_prefix."_users WHERE uname = '$username'";
  771.  
  772.         if(!$result = mysql_query($sql, $db))
  773.  
  774.                 $userdata = array("error" => "1");
  775.  
  776.         if(!$myrow = mysql_fetch_array($result))
  777.  
  778.                 $userdata = array("error" => "1");
  779.  
  780.  
  781.  
  782.         return($myrow);
  783.  
  784. }
  785.  
  786.  
  787.  
  788.  
  789.  
  790. function does_exists($id, $db, $type) {
  791.  
  792.         global $prefix;
  793.  
  794.         switch($type) {
  795.  
  796.                 case 'forum':
  797.  
  798.                         $sql = "SELECT forum_id FROM ${prefix}_forums WHERE forum_id = '$id'";
  799.  
  800.                 break;
  801.  
  802.                 case 'topic':
  803.  
  804.                         $sql = "SELECT topic_id FROM ${prefix}_forumtopics WHERE topic_id = '$id'";
  805.  
  806.                 break;
  807.  
  808.         }
  809.  
  810.         if(!$result = mysql_query($sql, $db))
  811.  
  812.                 return(0);
  813.  
  814.         if(!$myrow = mysql_fetch_array($result))
  815.  
  816.                 return(0);
  817.  
  818.         return(1);
  819.  
  820. }
  821.  
  822.  
  823.  
  824. function is_locked($topic, $db) {
  825.  
  826.         global $prefix;
  827.  
  828.         $sql = "SELECT topic_status FROM ${prefix}_forumtopics WHERE topic_id = '$topic'";
  829.  
  830.         if(!$r = mysql_query($sql, $db))
  831.  
  832.                 return(FALSE);
  833.  
  834.         if(!$m = mysql_fetch_array($r))
  835.  
  836.                 return(FALSE);
  837.  
  838.         if($m[topic_status] == 1)
  839.  
  840.                 return(TRUE);
  841.  
  842.         else
  843.  
  844.                 return(FALSE);
  845.  
  846. }
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854. function smile($message) {
  855.  
  856.         $message = str_replace(":)", "<IMG SRC=\"images/forum/icons/icon_smile.gif\">", $message);
  857.  
  858.         $message = str_replace(":-)", "<IMG SRC=\"images/forum/icons/icon_smile.gif\">", $message);
  859.  
  860.         $message = str_replace(":(", "<IMG SRC=\"images/forum/icons/icon_frown.gif\">", $message);
  861.  
  862.         $message = str_replace(":-(", "<IMG SRC=\"images/forum/icons/icon_frown.gif\">", $message);
  863.  
  864.         $message = str_replace(":-D", "<IMG SRC=\"images/forum/icons/icon_biggrin.gif\">", $message);
  865.  
  866.         $message = str_replace(":D", "<IMG SRC=\"images/forum/icons/icon_biggrin.gif\">", $message);
  867.  
  868.         $message = str_replace(";)", "<IMG SRC=\"images/forum/icons/icon_wink.gif\">", $message);
  869.  
  870.         $message = str_replace(";-)", "<IMG SRC=\"images/forum/icons/icon_wink.gif\">", $message);
  871.  
  872.         $message = str_replace(":o", "<IMG SRC=\"images/forum/icons/icon_eek.gif\">", $message);
  873.  
  874.         $message = str_replace(":O", "<IMG SRC=\"images/forum/icons/icon_eek.gif\">", $message);
  875.  
  876.         $message = str_replace(":-o", "<IMG SRC=\"images/forum/icons/icon_eek.gif\">", $message);
  877.  
  878.         $message = str_replace(":-O", "<IMG SRC=\"images/forum/icons/icon_eek.gif\">", $message);
  879.  
  880.         $message = str_replace("8)", "<IMG SRC=\"images/forum/icons/icon_cool.gif\">", $message);
  881.  
  882.         $message = str_replace("8-)", "<IMG SRC=\"images/forum/icons/icon_cool.gif\">", $message);
  883.  
  884.         $message = str_replace(":?", "<IMG SRC=\"images/forum/icons/icon_confused.gif\">", $message);
  885.  
  886.         $message = str_replace(":-?", "<IMG SRC=\"images/forum/icons/icon_confused.gif\">", $message);
  887.  
  888.         $message = str_replace(":p", "<IMG SRC=\"images/forum/icons/icon_razz.gif\">", $message);
  889.  
  890.         $message = str_replace(":P", "<IMG SRC=\"images/forum/icons/icon_razz.gif\">", $message);
  891.  
  892.         $message = str_replace(":-p", "<IMG SRC=\"images/forum/icons/icon_razz.gif\">", $message);
  893.  
  894.         $message = str_replace(":-P", "<IMG SRC=\"images/forum/icons/icon_razz.gif\">", $message);
  895.  
  896.         $message = str_replace(":-|", "<IMG SRC=\"images/forum/icons/icon_mad.gif\">", $message);
  897.  
  898.         $message = str_replace(":|", "<IMG SRC=\"images/forum/icons/icon_mad.gif\">", $message);
  899.  
  900.         $message = str_replace(":-Z", "<IMG SRC=\"images/forum/icons/icon27.gif\">", $message);
  901.  
  902.         $message = str_replace(":-W", "<IMG SRC=\"images/forum/icons/icon24.gif\">", $message);
  903.  
  904.         $message = str_replace(":-Y", "<IMG SRC=\"images/forum/icons/icon21.gif\">", $message);
  905.  
  906.         return($message);
  907.  
  908. }
  909.  
  910. function desmile($message) {
  911.  
  912.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_smile.gif\">", ":-)",  $message);
  913.  
  914.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_frown.gif\">", ":-(", $message);
  915.  
  916.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_biggrin.gif\">",":-D",  $message);
  917.  
  918.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_wink.gif\">", ";-)", $message);
  919.  
  920.          $message = str_replace("<IMG SRC=\"images/forum/icons/icon_eek.gif\">", ":-o", $message);
  921.  
  922.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_eek.gif\">", ":-O", $message);
  923.  
  924.          $message = str_replace("<IMG SRC=\"images/forum/icons/icon_cool.gif\">", "8-)", $message);
  925.  
  926.          $message = str_replace("<IMG SRC=\"images/forum/icons/icon_confused.gif\">", ":-?", $message);
  927.  
  928.          $message = str_replace("<IMG SRC=\"images/forum/icons/icon_razz.gif\">", ":-p", $message);
  929.  
  930.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_razz.gif\">", ":-P", $message);
  931.  
  932.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon_mad.gif\">", ":-|", $message);
  933.  
  934.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon27.gif\">", ":-Z", $message);
  935.  
  936.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon24.gif\">", ":-W", $message);
  937.  
  938.         $message = str_replace("<IMG SRC=\"images/forum/icons/icon21.gif\">", ":-Y", $message);
  939.  
  940.  
  941.  
  942.         return($message);
  943.  
  944. }
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954. /*
  955.  
  956.  * Changes :) to an <IMG> tag based on the smiles table in the database
  957.  
  958.  * TODO: Get rid of global variables.
  959.  
  960.  */
  961.  
  962. /* function smile($message) {
  963.  
  964.    global $db, $url_smiles;
  965.  
  966.  
  967.  
  968.    $url_smiles = "images/forum/smiles";
  969.  
  970.  
  971.  
  972.    if ($getsmiles = mysql_query("SELECT * FROM forum_smiles")){
  973.  
  974.       while ($smiles = mysql_fetch_array($getsmiles)) {
  975.  
  976.          $message = str_replace($smiles[code], "<IMG SRC=\"$url_smiles/$smiles[smile_url]\">", $message);
  977.  
  978.       }
  979.  
  980.    }
  981.  
  982.    return($message);
  983.  
  984. }
  985.  
  986. */
  987.  
  988. /*
  989.  
  990.  * Changes a Smiliy <IMG> tag into its corrasponding smile
  991.  
  992.  * TODO: Get rid of golbal variables, and implement a method of distinguishing between :D and :grin: using the <IMG> tag
  993.  
  994.  */
  995.  
  996. /* function desmile($message) {
  997.  
  998.    // Ick Ick Global variables...remind me to fix these! - theFinn
  999.  
  1000.    global $db, $url_smiles;
  1001.  
  1002.  
  1003.  
  1004.    $url_smiles = "images/forum/smiles";
  1005.  
  1006.  
  1007.  
  1008.    if ($getsmiles = mysql_query("SELECT * FROM forum_smiles")){
  1009.  
  1010.       while ($smiles = mysql_fetch_array($getsmiles)) {
  1011.  
  1012.          $message = str_replace("<IMG SRC=\"$url_smiles/$smiles[smile_url]\">", $smiles[code], $message);
  1013.  
  1014.       }
  1015.  
  1016.    }
  1017.  
  1018.    return($message);
  1019.  
  1020. }
  1021.  
  1022. */
  1023. /**
  1024.  * bbdecode/bbencode functions:
  1025.  * Rewritten - Nathan Codding - Aug 24, 2000
  1026.  * Using Perl-Compatible regexps now. Won't kill special chars
  1027.  * outside of a [code]...[/code] block now, and all BBCode tags
  1028.  * are implemented.
  1029.  * Note: the "i" matching switch is used, so BBCode tags are
  1030.  * case-insensitive.
  1031.  */
  1032. function bbdecode($message) {
  1033.  
  1034.                 // Undo [code]
  1035.  
  1036.                 $message = preg_replace("#<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Code:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><PRE>(.*?)</PRE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End -->#s", "[code]\\1[/code]", $message);
  1037.  
  1038.  
  1039.  
  1040.                 // Undo [quote]
  1041.  
  1042. $quote_start_html = "<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>"; 
  1043.                 $quote_end_html = "</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->"; 
  1044.                 $message = str_replace($quote_start_html, "[quote]", $message); 
  1045.                 $message = str_replace($quote_end_html, "[/quote]", $message); 
  1046.  
  1047.  
  1048. /*
  1049.                 $message = preg_replace("#<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>(.*?)</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->#s", "[quote]\\1[/quote]", $message);
  1050. */
  1051.  
  1052.  
  1053.                 // Undo [b] and [i]
  1054.  
  1055.                 $message = preg_replace("#<!-- BBCode Start --><B>(.*?)</B><!-- BBCode End -->#s", "[b]\\1[/b]", $message);
  1056.  
  1057.                 $message = preg_replace("#<!-- BBCode Start --><I>(.*?)</I><!-- BBCode End -->#s", "[i]\\1[/i]", $message);
  1058.  
  1059.  
  1060.  
  1061.                 // Undo [url] (both forms)
  1062.  
  1063.                 $message = preg_replace("#<!-- BBCode Start --><A HREF=\"http://(.*?)\" TARGET=\"_blank\">(.*?)</A><!-- BBCode End -->#s", "[url=\\1]\\2[/url]", $message);
  1064.  
  1065.  
  1066.  
  1067.                 // Undo [email]
  1068.  
  1069.                 $message = preg_replace("#<!-- BBCode Start --><A HREF=\"mailto:(.*?)\">(.*?)</A><!-- BBCode End -->#s", "[email]\\1[/email]", $message);
  1070.  
  1071.  
  1072.  
  1073.                 // Undo [img]
  1074.  
  1075.                 $message = preg_replace("#<!-- BBCode Start --><IMG SRC=\"(.*?)\"><!-- BBCode End -->#s", "[img]\\1[/img]", $message);
  1076.  
  1077.  
  1078.  
  1079.                 // Undo lists (unordered/ordered)
  1080.  
  1081.  
  1082.  
  1083.                 // unordered list code..
  1084.  
  1085.                 $matchCount = preg_match_all("#<!-- BBCode ulist Start --><UL>(.*?)</UL><!-- BBCode ulist End -->#s", $message, $matches);
  1086.  
  1087.  
  1088.  
  1089.                 for ($i = 0; $i < $matchCount; $i++)
  1090.  
  1091.                 {
  1092.  
  1093.                         $currMatchTextBefore = preg_quote($matches[1][$i]);
  1094.  
  1095.                         $currMatchTextAfter = preg_replace("#<LI>#s", "[*]", $matches[1][$i]);
  1096.  
  1097.  
  1098.  
  1099.                         $message = preg_replace("#<!-- BBCode ulist Start --><UL>$currMatchTextBefore</UL><!-- BBCode ulist End -->#s", "[list]" . $currMatchTextAfter . "[/list]", $message);
  1100.  
  1101.                 }
  1102.  
  1103.  
  1104.  
  1105.                 // ordered list code..
  1106.  
  1107.                 $matchCount = preg_match_all("#<!-- BBCode olist Start --><OL TYPE=([A1])>(.*?)</OL><!-- BBCode olist End -->#si", $message, $matches);
  1108.  
  1109.  
  1110.  
  1111.                 for ($i = 0; $i < $matchCount; $i++)
  1112.  
  1113.                 {
  1114.  
  1115.                         $currMatchTextBefore = preg_quote($matches[2][$i]);
  1116.  
  1117.                         $currMatchTextAfter = preg_replace("#<LI>#s", "[*]", $matches[2][$i]);
  1118.  
  1119.  
  1120.  
  1121.                         $message = preg_replace("#<!-- BBCode olist Start --><OL TYPE=([A1])>$currMatchTextBefore</OL><!-- BBCode olist End -->#si", "[list=\\1]" . $currMatchTextAfter . "[/list]", $message);
  1122.  
  1123.                 }
  1124.  
  1125.  
  1126.  
  1127.                 return($message);
  1128.  
  1129. }
  1130.  
  1131.  
  1132.  
  1133. function bbencode($message) {
  1134.  
  1135.  
  1136.  
  1137.         // [CODE] and [/CODE] for posting code (HTML, PHP, C etc etc) in your posts.
  1138.  
  1139.         $matchCount = preg_match_all("#\[code\](.*?)\[/code\]#si", $message, $matches);
  1140.  
  1141.  
  1142.  
  1143.         for ($i = 0; $i < $matchCount; $i++)
  1144.  
  1145.         {
  1146.  
  1147.                 $currMatchTextBefore = preg_quote($matches[1][$i]);
  1148.  
  1149.                 $currMatchTextAfter = htmlspecialchars($matches[1][$i]);
  1150.  
  1151.                 $message = preg_replace("#\[code\]$currMatchTextBefore\[/code\]#si", "<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Code:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><PRE>$currMatchTextAfter</PRE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End -->", $message);
  1152.  
  1153.         }
  1154.  
  1155.  
  1156.  
  1157.         // [QUOTE] and [/QUOTE] for posting replies with quote, or just for quoting stuff.
  1158.  
  1159. $quote_start_html = "<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>"; 
  1160.         $quote_end_html = "</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->"; 
  1161.         $message = str_replace("[quote]", $quote_start_html, $message); 
  1162.         $message = str_replace("[/quote]", $quote_end_html, $message); 
  1163. /*
  1164.         $message = preg_replace("#\[quote\](.*?)\[/quote]#si", "<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>\\1</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->", $message);
  1165. */
  1166.  
  1167.  
  1168.         // [b] and [/b] for bolding text.
  1169.  
  1170.         $message = preg_replace("#\[b\](.*?)\[/b\]#si", "<!-- BBCode Start --><B>\\1</B><!-- BBCode End -->", $message);
  1171.  
  1172.  
  1173.  
  1174.         // [i] and [/i] for italicizing text.
  1175.  
  1176.         $message = preg_replace("#\[i\](.*?)\[/i\]#si", "<!-- BBCode Start --><I>\\1</I><!-- BBCode End -->", $message);
  1177.  
  1178.  
  1179.  
  1180.         // [url]www.phpbb.com[/url] code..
  1181.  
  1182.         $message = preg_replace("#\[url\](http://)?(.*?)\[/url\]#si", "<!-- BBCode Start --><A HREF=\"http://\\2\" TARGET=\"_blank\">\\2</A><!-- BBCode End -->", $message);
  1183.  
  1184.  
  1185.  
  1186.         // [url=www.phpbb.com]phpBB[/url] code..
  1187.  
  1188.         $message = preg_replace("#\[url=(http://)?(.*?)\](.*?)\[/url\]#si", "<!-- BBCode Start --><A HREF=\"http://\\2\" TARGET=\"_blank\">\\3</A><!-- BBCode End -->", $message);
  1189.  
  1190.  
  1191.  
  1192.         // [email]user@domain.tld[/email] code..
  1193.  
  1194.         $message = preg_replace("#\[email\](.*?)\[/email\]#si", "<!-- BBCode Start --><A HREF=\"mailto:\\1\">\\1</A><!-- BBCode End -->", $message);
  1195.  
  1196.  
  1197.  
  1198.         // [img]image_url_here[/img] code..
  1199.  
  1200.         $message = preg_replace("#\[img\](.*?)\[/img\]#si", "<!-- BBCode Start --><IMG SRC=\"\\1\"><!-- BBCode End -->", $message);
  1201.  
  1202.  
  1203.  
  1204.         // unordered list code..
  1205.  
  1206.         $matchCount = preg_match_all("#\[list\](.*?)\[/list\]#si", $message, $matches);
  1207.  
  1208.  
  1209.  
  1210.         for ($i = 0; $i < $matchCount; $i++)
  1211.  
  1212.         {
  1213.  
  1214.                 $currMatchTextBefore = preg_quote($matches[1][$i]);
  1215.  
  1216.                 $currMatchTextAfter = preg_replace("#\[\*\]#si", "<LI>", $matches[1][$i]);
  1217.  
  1218.  
  1219.  
  1220.                 $message = preg_replace("#\[list\]$currMatchTextBefore\[/list\]#si", "<!-- BBCode ulist Start --><UL>$currMatchTextAfter</UL><!-- BBCode ulist End -->", $message);
  1221.  
  1222.         }
  1223.  
  1224.  
  1225.  
  1226.         // ordered list code..
  1227.  
  1228.         $matchCount = preg_match_all("#\[list=([a1])\](.*?)\[/list\]#si", $message, $matches);
  1229.  
  1230.  
  1231.  
  1232.         for ($i = 0; $i < $matchCount; $i++)
  1233.  
  1234.         {
  1235.  
  1236.                 $currMatchTextBefore = preg_quote($matches[2][$i]);
  1237.  
  1238.                 $currMatchTextAfter = preg_replace("#\[\*\]#si", "<LI>", $matches[2][$i]);
  1239.  
  1240.  
  1241.  
  1242.                 $message = preg_replace("#\[list=([a1])\]$currMatchTextBefore\[/list\]#si", "<!-- BBCode olist Start --><OL TYPE=\\1>$currMatchTextAfter</OL><!-- BBCode olist End -->", $message);
  1243.  
  1244.         }
  1245.  
  1246.  
  1247.  
  1248.         return($message);
  1249.  
  1250. }
  1251.  
  1252.  
  1253.  
  1254. function get_forum_name($forum_id, $db) {
  1255.  
  1256.         global $prefix;
  1257.  
  1258.         $sql = "SELECT forum_name FROM ${prefix}_forums WHERE forum_id = '$forum_id'";
  1259.  
  1260.         if(!$r = mysql_query($sql, $db))
  1261.  
  1262.                 return("ERROR");
  1263.  
  1264.         if(!$m = mysql_fetch_array($r))
  1265.  
  1266.                 return("None");
  1267.  
  1268.         return($m[forum_name]);
  1269.  
  1270. }
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280. function convertidatasolo($data) 
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287. $data = strtotime($data); 
  1288.  
  1289. $data = strftime(_LOCALDATE, $data); 
  1290.  
  1291.  
  1292.  
  1293. return($data); 
  1294.  
  1295.  
  1296.  
  1297. }
  1298.  
  1299.  
  1300. /**
  1301.  
  1302.  * Modified by Nathan Codding - July 20, 2000.
  1303.  
  1304.  * Made it only work on URLs and e-mail addresses preceeded by a space, in order to stop
  1305.  
  1306.  * mangling HTML code.
  1307.  
  1308.  *
  1309.  
  1310.  * The Following function was taken from the Scriplets area of http://www.phpwizard.net, and was written by Tobias Ratschiller.
  1311.  
  1312.  *   Visit phpwizard.net today, its an excellent site!
  1313.  
  1314.  */
  1315.  
  1316.  
  1317.  
  1318. function make_clickable($text) {
  1319.  
  1320.         $ret = eregi_replace(" ([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", " <a href=\"\\1://\\2\\3\" target=\"_blank\" target=\"_new\">\\1://\\2\\3</a>", $text);
  1321.  
  1322.         $ret = eregi_replace(" (([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", " <a href=\"mailto:\\1\" target=\"_new\">\\1</a>", $ret);
  1323.  
  1324.         return($ret);
  1325.  
  1326. }
  1327.  
  1328.  
  1329.  
  1330. /**
  1331.  
  1332.  * Nathan Codding - August 24, 2000.
  1333.  
  1334.  * Takes a string, and does the reverse of the PHP standard function
  1335.  
  1336.  * htmlspecialchars().
  1337.  
  1338.  */
  1339.  
  1340. function undo_htmlspecialchars($input) {
  1341.  
  1342.         $input = preg_replace("/>/i", ">", $input);
  1343.  
  1344.         $input = preg_replace("/</i", "<", $input);
  1345.  
  1346.         $input = preg_replace("/"/i", "\"", $input);
  1347.  
  1348.         $input = preg_replace("/&/i", "&", $input);
  1349.  
  1350.  
  1351.  
  1352.         return $input;
  1353.  
  1354. }
  1355.  
  1356.  
  1357.  
  1358. function validate_username($username, $db) {
  1359.  
  1360.         global $prefix;
  1361.  
  1362.         $sql = "SELECT disallow_username FROM ${prefix}_splattforum_disallow WHERE disallow_username = '" . addslashes($username) . "'";
  1363.  
  1364.         if(!$r = mysql_query($sql, $db))
  1365.  
  1366.                 return(0);
  1367.  
  1368.         if($m = mysql_fetch_array($r)) {
  1369.  
  1370.                 if($m[disallow_username] == $username)
  1371.  
  1372.                         return(1);
  1373.  
  1374.                 else
  1375.  
  1376.                         return(0);
  1377.  
  1378.         }
  1379.  
  1380.         return(0);
  1381.  
  1382. }
  1383.  
  1384.  
  1385.  
  1386. /*
  1387.  
  1388.  * Replaces banned words in a string with their replacements
  1389.  
  1390.  */
  1391.  
  1392. /*function censor_string($string, $db) {
  1393.  
  1394.    $sql = "SELECT word, replacement FROM words";
  1395.  
  1396.    if(!$r = mysql_query($sql, $db))
  1397.  
  1398.       die("Error, could not contact the database! Please check your database settings in config.$phpEx");
  1399.  
  1400.    while($w = mysql_fetch_array($r)) {
  1401.  
  1402.       $word = quotemeta(stripslashes($w[word]));
  1403.  
  1404.       $replacement = stripslashes($w[replacement]);
  1405.  
  1406.       $string = eregi_replace(" $word", " $replacement", $string);
  1407.  
  1408.       $string = eregi_replace("^$word", "$replacement", $string);
  1409.  
  1410.       $string = eregi_replace("<BR>$word", "<BR>$replacement", $string);
  1411.  
  1412.    }
  1413.  
  1414.    return($string);
  1415.  
  1416. }
  1417.  
  1418.  
  1419.  
  1420. function is_banned($ipuser, $type, $db) {
  1421.  
  1422.    
  1423.  
  1424.    // Remove old bans
  1425.  
  1426.    $sql = "DELETE FROM banlist WHERE (ban_end < ". mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")).") AND (ban_end > 0)";
  1427.  
  1428.    @mysql_query($sql, $db);
  1429.  
  1430.    switch($type) {
  1431.     case "ip":
  1432.       $sql = "SELECT ban_ip FROM banlist";
  1433.       if($r = mysql_query($sql, $db)) {
  1434.      while($iprow = mysql_fetch_array($r)) {
  1435.         $ip = $iprow[ban_ip];
  1436.         if($ip[strlen($ip) - 1] == ".") {
  1437.            $db_ip = explode(".", $ip);
  1438.            $this_ip = explode(".", $ipuser);
  1439.   
  1440.            for($x = 0; $x < count($db_ip) - 1; $x++) 
  1441.          $my_ip .= $this_ip[$x] . ".";
  1442.  
  1443.            if($my_ip == $ip)
  1444.          return(TRUE);
  1445.         }
  1446.         else {
  1447.            if($ipuser == $ip)
  1448.          return(TRUE);
  1449.         }
  1450.      }
  1451.       }
  1452.       else 
  1453.     return(FALSE);
  1454.       break;
  1455.     case "username":
  1456.       $sql = "SELECT ban_userid FROM banlist WHERE ban_userid = '$ipuser'";
  1457.       if($r = mysql_query($sql, $db)) {
  1458.      if(mysql_num_rows($r) > 0)
  1459.        return(TRUE);
  1460.       }
  1461.       break;
  1462.    }
  1463.    return(FALSE);
  1464. }
  1465.  
  1466. */
  1467.  
  1468. ?>