$theq\n"; $j++; } } } else { if($type == "allq") $range2 = mysql_num_rows($query); for($i = $range1; $i < $range2; $i++) { $questionid = mysql_result($query, $i, 0); if(!empty($questionid)) { $questionq = mysql_query("SELECT question FROM ${table_prefix}questions WHERE questionid='$questionid'"); $theq = mysql_result($questionq, 0, 0); $theq = str_replace("\\'", "'", $theq); $theq = str_replace("\\\"", """, $theq); $theq = parsetext($theq); echo "
  • $theq
  • \n"; $j++; } } } global $txt_none; if(mysql_num_rows($query) == "0") echo "
  • -- $txt_none --
  • \n"; return mysql_num_rows($query); } function loadsearch($search, $type) { global $link_id, $dbname, $table_prefix; $search = mysql_real_escape_string($search); if($type == "tags") { $query = mysql_query("SELECT * FROM ${table_prefix}questions WHERE tags LIKE '%$search%' ORDER BY askedtime DESC"); } elseif($type == "user") { $query = mysql_query("SELECT * FROM ${table_prefix}questions WHERE askedby='$search' ORDER BY askedtime DESC"); } elseif($type == "link") { $query = mysql_query("SELECT * FROM ${table_prefix}questions WHERE questionid='$search'"); } else { $rebuilt = ""; $search = str_replace(" ", "%", $search); $search = str_replace("\\\\\\'", "\'", $search); $search = str_replace("\\\\\\\"", "\"", $search); while(strstr($search, "\"")) { $pos = strpos($search, "\""); $rebuilt .= substr($search, 0, $pos); $search = "%" . substr($search, $pos + 1); if(strstr($search, "\"")) { $pos = strpos($search, "\""); $thatbit = substr($search, 0, $pos); $search = "%" . substr($search, $pos + 1); $thatbit = str_replace("%", " ", $thatbit); $rebuilt .= $thatbit; } else { $search = str_replace("%", " ", $search); $rebuilt .= $search; } } if(!empty($rebuilt)) $search = $rebuilt . $search; $search = "%$search"; $search = str_replace("%%", "%", $search); $search = str_replace("% ", "%", $search); $search = str_replace(" %", "%", $search); $search = explode("%", $search); $string = ""; for($i = 1; $i < count($search); $i++) { if($i != "1") { $string .= "AND "; $string2 .= "AND "; } $string .= "(tags LIKE '%$search[$i]%' OR question LIKE '%$search[$i]%' OR details LIKE '%$search[$i]%') "; $string2 .= "(answer LIKE '%$search[$i]%') "; } $query = mysql_query("SELECT * FROM ${table_prefix}questions WHERE $string ORDER BY askedtime DESC"); } $range1 = $startpos; $range2 = $startpos + $loadno; $j = $range1 + 1; for($i = 0; $i < mysql_num_rows($query); $i++) { $questionid = mysql_result($query, $i, "questionid"); if(!empty($questionid)) { $usedid .= "$questionid, "; $theq = mysql_result($query, $i, "question"); $theq = str_replace("\\'", "'", $theq); $theq = str_replace("\\\"", """, $theq); $theq = parsetext($theq); echo "
  • $theq
  • \n"; $j++; } } $query2 = mysql_query("SELECT * FROM ${table_prefix}answers WHERE $string2 ORDER BY answeredtime DESC"); for($i = 0; $i < mysql_num_rows($query2); $i++) { $questionid = mysql_result($query2, $i, "questionid"); if(!empty($questionid) && !strstr($usedid, "$questionid, ")) { $query3 = mysql_query("SELECT question FROM ${table_prefix}questions WHERE questionid='$questionid'"); echo "
  • " . mysql_result($query3, 0, 0) . "
  • \n"; $j++; } } return $j - 1; } function parsetext($text) { $text = str_replace("\r", "", $text); $text = str_replace("\n", "
    ", $text); $text = str_replace("

    ", "

    \n\n", $text); $text = str_replace("
    ", "
    \n", $text); $text = preg_replace( "/([^\/=\"\]])((http|ftp)+(s)?:\/\/[^<>\s]+)/i", "\\1\\2", $text); $text = preg_replace('/([^\/=\"\]])(www\.)(\S+)/', '\\1\\2\\3', $text); // Now check if any of the new URLs are really long unset($matches); preg_match_all("/()([^\"\]]+)(<\/a>)/", $text, $matches); for($i = 0; $i < count($matches[4]); $i++) { $cururl = $matches[4][$i]; if(strlen($cururl) > 70) { $newurl = substr($cururl, 0, 30) . "..." . substr($cururl, strlen($cururl) - 30); $text= str_replace(">$cururl<", ">$newurl<", $text); } } return $text; } function entryprep($input) { $input = stripslashes($input); $input = htmlentities($input, ENT_QUOTES, UTF-8); $input = str_replace("Â&", "&", $input); return $input; } ?>

    :
    :
    :
    :