;
}
}
}
}
}
$id_three[] = $id;
$family_three[] = $level;
$res_child = readfamily($id, "child");
while ($info_child=mysql_fetch_array($res_child))
{
$id_three[] = $info_child["id"];
$family_three[] = $level + 1;
}
if ($need == "id")
{
return $id_three;
}
elseif ($need == "family")
{
return $family_three;
}
}
//搜索文章可以按标题、内容、作者、时间等四种方式进行
//返回文章
搜索的结果
function search_forum($style_search, $text_search)
{
global $db;
$
sql = "select id,title,click,writer,importtime from article where ";
if ($text_search != "")
{
if ($style_search == "title")
{
$sql = $sql."title like '%$text_search%'";
}
if ($style_search == "content")
{
$sql = $sql."content like '%$text_search%'";
}
if ($style_search == "writer")
{
$sql = $sql."writer like '%$text_search%'";
}
if ($style_search == "time")
{
$sql = $sql."time like '%$text_search%'";
}
}
$result = mysql_query($sql, $db) or db_error();
if ($result)
{
return $result;
}
}
//用于将发表(或回复)的文章写入数据库中
function write_card($title, $content, $writer, $parent)
{
global $db;
if ($title != "")
{
//String_dowith, text_dowith分别调用了以前的函数
$title = string_dowith($title);
$content = text_dowith($content);
$importtime = date("Y-m-d H:i:s");
$click = 1;
//将文章写入数据库表
$sql = "insert into article ";
$sql = $sql."(title,content,importtime,writer,click,parent)";
$sql = $sql." values('$title','$content','$importtime','$writer','$click','$parent')";
$result = mysql_query($sql, $db) or db_error();
}
}
//将论坛中在线用户已加密的用户名解密,方法是再online表中根据cryptname查找name值
//返回在线用户的用户名
function undo_crypt($cryptname)
{
global $db;
$name = "";
if ($cryptname != "")
{
$sql = "select name from online where cryptname='$cryptname'";
$result = mysql_query($sql, $db) or db_error();
list($name) = mysql_fetch_row($result);
}
return $name;
}
//在article表中更新文章单击的数目
function update_click($id)
{
global $db;
$sql = "update article set click=click+1 where id='$id'";
$result = mysql_query($sql, $db) or db_error();
}
//显示文章的某种格式,用户可以修改此函数,将在文章
列表中显示不同的格式
function pri_readinfo($num, $id, $title, $writer, $num_click, $importtime, $space,
$cryptname, $nowpage, $theid)
{
echo "<TR bgColor='#CCCCFF'>";
echo "<TD width='5%'>";
echo "<FONT color='#000000'>$num</FONT>";
echo "</TD>";
echo "<TD width='50%'>";
for ($i=0; $i<$space; $i++)
{
echo " ";
}
if ($theid == $id)
{
echo "<FONT color='#FF6699'>$title</FONT>";
}
else
{
echo "<A href='read.php?id=$id&nowpage=$nowpage&cryptname=$cryptname'>";
echo "<FONT color='#000000'>$title</FONT>";
echo "</A>";
echo "</TD>";
}
echo "<TD width='15%'>";
echo "<FONT color='#000000'>";
echo "<A href='../user/infouser.php?name=$writer&cryptname=$cryptname'>$writer</A>";
echo "</FONT>";
echo "</TD>";
echo "<TD width='5%'>";
echo "<FONT color='#000000'>$num_click</FONT>";
echo "</TD>";
echo "<TD width='15%'>";
echo "<FONT color='#000000'>$importtime</FONT>";
echo "</TD>";
echo "</TR>";
}
//网页中的分页格式,用户可以对此进行修改,选择自己喜欢的格式
function pri_page($formname, $nowpage, $num_page)
{
echo "<TABLE>";
echo "<TBODY>";
echo "<TR>";
echo "<TD width='50%' height='15'> </TD>";
echo "<TD width='10%' height='15'>";
echo "<DIV align='center'>";
if ($nowpage <= 1)
{
echo "首页";
}
else
{
echo "<A href='
JavaScript:document.$formname.nowpage.value=1;";
echo "$formname.submit();'>首页</A>";
}
echo "</DIV>";
echo "</TD>";
echo "<TD width='10%' height='15'>";
echo "<DIV align='center'>";
if ($nowpage <= 1)
{
ech