Location: PHPKode > projects > Simple But Mighty Blog > sbmb03/functions.php
<?
//Simple But Mighty Blog, version 0.3.1
//copyright © 2007, Mighty Mind
// @license http://opensource.org/licenses/gpl-license.php GNU Public License
// Äàííàÿ ïðîãðàììà ÿâëÿåòñÿ ñâîáîäíûì ïðîãðàììíûì îáåñïå÷åíèåì. Âû âïðàâå ðàñïðîñòðàíÿòü åå è/èëè ìîäèôèöèðîâàòü â ñîîòâåòñòâèè ñ
//óñëîâèÿìè âåðñèè 3 Ñòàíäàðòíîé Îáùåñòâåííîé Ëèöåíçèè GNU, îïóáëèêîâàííîé Free Software Foundation. 
// Ìû ðàñïðîñòðàíÿåì äàííóþ ïðîãðàììó â íàäåæäå íà òî, ÷òî îíà áóäåò âàì ïîëåçíîé, îäíàêî ÍÅ ÏÐÅÄÎÑÒÀÂËßÅÌ ÍÀ ÍÅÅ ÍÈÊÀÊÈÕ ÃÀÐÀÍÒÈÉ,
//â òîì ÷èñëå ÃÀÐÀÍÒÈÈ ÒÎÂÀÐÍÎÃÎ ÑÎÑÒÎßÍÈß ÏÐÈ ÏÐÎÄÀÆÅ è ÏÐÈÃÎÄÍÎÑÒÈ ÄËß ÈÑÏÎËÜÇÎÂÀÍÈß Â ÊÎÍÊÐÅÒÍÛÕ ÖÅËßÕ.
//Äëÿ ïîëó÷åíèÿ áîëåå ïîäðîáíîé èíôîðìàöèè îçíàêîìüòåñü ñî Ñòàíäàðòíîé Îáùåñòâåííîé Ëèöåíçèåé GNU.
//Âìåñòå ñ äàííîé ïðîãðàììîé âû äîëæíû áûëè ïîëó÷èòü ýêçåìïëÿð Ñòàíäàðòíîé Îáùåñòâåííîé Ëèöåíçèè GNU.
//Åñëè âû åãî íå ïîëó÷èëè, ñîîáùèòå îá ýòîì â Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//

function check_string($string)
{
return htmlspecialchars(stripslashes(trim($string)), ENT_QUOTES);
}

function check_email($string)
{
return htmlspecialchars(stripslashes(substr(trim(strtolower($string)),0,30)), ENT_QUOTES);
}

function get_smiles($element)
{
global $t_smiles;
@$result=mysql_query("SELECT * FROM `$t_smiles`") or die("<p>Îøèáêà ïðè ïîèñêå ñìàéëîâ!<p>");
while ($row=mysql_fetch_array($result)):
$file=$row["file"];
$alt=$row["alt"];
$change=$row["change"];
echo "<img width=15 height=15 src=smiles/$file onclick=\"javascript:document.all.$element.value=document.all.$element.value+'$change'\">";
$k++;
if ($k==5) {echo "<br>";$k=0;}
endwhile;
}

function getstatus($id,$ip)
{
global $t_users;
@$result=mysql_query("SELECT * FROM `$t_users` WHERE id='$id'") or die("<p>Îøèáêà ïðè îïðåäåëåíèè ïîëüçîâàòåëÿ!<p>");
if (mysql_num_rows($result)!=0)
	{$row=mysql_fetch_array($result);
	return $row["status"];}
	else {
	return 1;
	}
}

function message($date,$time,$text,$author,$id,$theme)
{
global $_SESSION;
global $_SERVER;
?>
<br>
<div id="t<? echo $id;?>" align="justify" style="padding-right: 5; padding-left: 5; margin:5;">
<p align=center><b><? echo getusername($author);?></b></p>
<p align=center><? echo $theme;?></p>
<p align=center><? echo $date.", ".$time;?></p>
<hr>
<p><? echo nl2br($text);?>
<p align=left>
<? if (getstatus($_SESSION["id"],check_string($_SERVER["REMOTE_ADDR"]))==3)
{
echo "<a href=\"#deltop\" onClick=\"sendRequest('ajax.php?action=deltopic&topic=$id', 'search_div', getRequest);\"><img src=\"images/del.gif\" alt=\"Óäàëèòü\" title=\"Óäàëèòü\"></a> ",
"<a href=\"#loadtop\" onClick=\"adjustMessage('ajax.php?action=loadtopic&topic=$id','loadtopicDiv', event);\"><img src=\"images/edit.gif\" alt=\"Ðåäàêòèðîâàòü\" title=\"Ðåäàêòèðîâàòü\"></a>";
} ?></p>
</div>
<?
}

function message_theme($date,$time,$author,$id,$theme)
{
?>
<br>
<div id="t<? echo $id;?>" align="justify" style="padding-right: 5; padding-left: 5; margin:5;">
<br><b><? echo getusername($author);?></b>, <br><? echo $theme;?><hr>
<p align=right><? echo $date;?>, <? echo $time;?>
</div>
<?
}

function message_comment($author,$date,$time,$text,$status,$id)
{
?>
<br>
<div id="m<? echo $id?>" align="justify" style="padding-right: 10; padding-left: 15; margin:5;">
<b><? echo getusername($author);?></b>, <? echo $date;?>, <? echo $time;?>
<br><hr><? echo nl2br($text);?>
<p align=left>
<? if (getstatus($_SESSION["id"],check_string($_SERVER["REMOTE_ADDR"]))==3)
{
echo "<a href=\"#delcomment\" onClick=\"sendRequest('ajax.php?action=delcomment&comment=$id', 'm$id', getRequest);\"><img src=\"images/del.gif\" alt=\"Íàðóøàåò ïðàâèëà!\" title=\"Íàðóøàåò ïðàâèëà!\"></a> ";
} ?></p>
</div>
<?
}

function gettopics()
{
global $t_topics;
@$result=mysql_query("SELECT * FROM `".$t_topics."` ORDER BY id DESC LIMIT 20") or die("<p>Îøèáêà âûáîðà òîïèêîâ!<p>");
	if (mysql_num_rows($result)!=0)
	{
	while ($row=mysql_fetch_array($result)):
message_theme($row["date"],$row["time"],$row["author"],$row["id"],$row["theme"]."<p align=right><a href=\"#pretop\" onClick=\"sendRequest('preview.php?topic=".$row["id"]."', 't".$row["id"]."', getRequest);\">Îòêðûòü çäåñü</a>, <a href=?topic=".$row["id"].">Îòêðûòü ñ êîììåíòàðèÿìè</a>");
	endwhile;
	}
	else {	echo "<b>Â ÁÄ íåò òîïèêîâ!</b>";	}
}

function viewtopic($topic)
{
global $t_topics;
global $t_mess;
@$result=mysql_query("SELECT * FROM `".$t_topics."` WHERE id='$topic'") or die("<p>Îøèáêà âûáîðà òîïèêîâ!<p>");

if (mysql_num_rows($result)===1)
{
$row=mysql_fetch_array($result);
message($row["date"],$row["time"],$row["text"],$row["author"],$topic,$row["theme"]);
}

@$result=mysql_query("SELECT * FROM `".$t_mess."` WHERE topic='$topic' ORDER BY id") or die("<p>Îøèáêà âûáîðà êîììåíòàðèåâ!<p>");
if (mysql_num_rows($result)!=0)
{
	while ($row=mysql_fetch_array($result)):
message_comment($row["author"],$row["date"],$row["time"],$row["text"],$row["status"],$row["id"]);
	endwhile;
}
	else {	echo "<div align=center style=\"padding-right: 10; padding-left: 15; margin:5;\"><b>Íåò êîììåíòàðèåâ ïî äàííîìó òîïèêó!</b></div>";	}
}

function get_topics_archive($year,$month)
{
global $t_topics;
$date="$year-$month";
@$result=mysql_query("SELECT * FROM `".$t_topics."` WHERE date LIKE '%$date%' ORDER BY id") or die("<p>Îøèáêà âûáîðà òîïèêîâ!<p>");
	if (mysql_num_rows($result)!=0)
	{
	while ($row=mysql_fetch_array($result)):
message_theme($row["date"],$row["time"],$row["author"],$row["id"],$row["theme"]."<p align=right><a href=\"#pretop\" onClick=\"sendRequest('preview.php?topic=".$row["id"]."', 't".$row["id"]."', getRequest);\">Îòêðûòü çäåñü</a>, <a href=?topic=".$row["id"].">Îòêðûòü ñ êîììåíòàðèÿìè</a>");
	endwhile;
	}
	else {	echo "<b>Â ÁÄ íåò òîïèêîâ çà ýòîò ïåðèîä: $date!</b>";	}
}

function genarchivelist()
{
global $t_topics;
for ($j=date("Y");$j>=(date("Y")-2); $j--)
{
$stroka_mes="Çàïèñè çà";
for ($i=1;$i<=12; $i++)
	{
	if ($i<10) {$i="0$i";}
	$date="$j-$i";
	@$result=mysql_query("SELECT date FROM `".$t_topics."` WHERE date LIKE '%$date%'") or die("<p>Îøèáêà âûáîðà òîïèêîâ!<p>");
	if (mysql_num_rows($result)!=0)
	{
		$stroka_mes.=" <a href=index.php?year=$j&month=$i>$i</a> ";
	}
	}
$stroka_mes.="ìåñÿö $j ãîäà<br>";
if ($stroka_mes<>"Çàïèñè çàìåñÿö $j ãîäà<br>") {echo $stroka_mes;}
}
}

function getusername($id)
{
global $t_users;
@$result=mysql_query("SELECT login FROM `$t_users` WHERE id='$id'") or die("<p>ERROR0003!!!<p>");
if (mysql_num_rows($result)!=0)
{
$row=mysql_fetch_array($result);
return "<a href=\"#user\" onClick=\"adjustMessage('ajax.php?action=getuserstatus&id=$id','userDiv',event);\">".$row["login"]."</a>";
} else {return "<font size=-2 color=red>Óäàëåííûé ïîëüçîâàòåëü</font>";}
}

function check_reg($login,$password,$ip)
{
global $t_users;
global $_SESSION;
@$result=mysql_query("SELECT * FROM `$t_users` WHERE login='$login' AND password='$password'") or die("<p>ERROR0005!!!<p>");
	if (mysql_num_rows($result)===1)
	{
	$row=mysql_fetch_array($result);
			$_SESSION["style"]=$row["style"];
			$id=$row["id"];
			mysql_query("UPDATE `$t_users` SET ip='$ip' WHERE id='$id'") or die("<p>ERROR0006!!!<p>");
			return $id;
	}
	else {
	return 0;
	}
}

function getbans($nick,$ip)
{
global $t_users;
@$result=mysql_query("SELECT id,login FROM `$t_users` WHERE status=0") or die("<p>Îøèáêà âûáîðà íèêîâ!<p>");
echo "<p>Çàáàíåííûå íèêè:<p>";
while ($row=mysql_fetch_array($result)):
if ($nick==$row["login"]) {echo "<b>".getusername($row["id"]).",</b> ";} else {echo getusername($row["id"]).", ";}
endwhile;
echo "<br></div>";
}

function post_change($post)
{
global $t_smiles;
global $t_changes;
$str=array();
@$result=mysql_query("SELECT `p_from`,`p_to` FROM `$t_changes`") or die("<p>ERROR0012!!!<p>");
while ($row=mysql_fetch_array($result)):
$p_from=$row["p_from"];
$p_to=$row["p_to"];
$str["$p_from"]="$p_to";
endwhile;
$post=strtr($post,$str);
@$result=mysql_query("SELECT `file`,`change`,`alt` FROM `$t_smiles`") or die("<p>ERROR0013!!!<p>");
while ($row=mysql_fetch_array($result)):
$file=$row["file"];
$change=$row["change"];
$alt=$row["alt"];
$str["$change"]="<img src=smiles/$file>";
endwhile;
$post=strtr($post,$str);
return $post;
}

function topic_title($topic)
{
global $t_topics;
@$result=mysql_query("SELECT theme FROM `".$t_topics."` WHERE id='$topic'") or die("Òîïèê íå íàéäåí!");
if (mysql_num_rows($result)===1)
{
$row=mysql_fetch_array($result);
$title=$row["theme"];
}
else { $title="Îøèáêà çàïðîñà çàãîëîâêà!";}
return $title;
}

function previewtopic($topic)
{
global $t_topics;
@$result=mysql_query("SELECT * FROM `".$t_topics."` WHERE id='$topic'") or die("<p>Îøèáêà âûáîðà òîïèêîâ!<p>");
if (mysql_num_rows($result)===1)
{
$row=mysql_fetch_array($result);
preview_message($row["date"],$row["time"],$row["text"],$row["author"],$topic,$row["theme"]);
}
}

function preview_message($date,$time,$text,$author,$id,$theme)
{
global $_SESSION;
global $_SERVER;
?>
<p align=center><b><? echo getusername($author);?></b></p>
<p align=center><? echo $theme;?></p>
<p align=center><? echo $date.", ".$time;?></p>
<hr>
<p><? echo nl2br($text);?>
<p align=right><a href=index.php?topic=<? echo $id;?>>Êîììåíòèðîâàòü</a><p>
<?
}

function get_textformat_button()
{
?>
<input type=button value="Æèðíûé" onclick="javascript:document.all.post.value=document.all.post.value+'[b][/b]'">
<input type=button value="Íàêëîí" onclick="javascript:document.all.post.value=document.all.post.value+'[i][/i]'">
<input type=button value="Ïîä÷åðêíóòûé" onclick="javascript:document.all.post.value=document.all.post.value+'[u][/u]'">
<input type=button value="Ru 2 En" onclick="postRequest('ajax.php', 'post', 'action=ru2en'+'&post='+encodeURIComponent(document.getElementById('post').value), ajax_get_value);">
<input type=button value="En 2 Ru" onClick="postRequest('ajax.php','post','action=en2ru&post='+encodeURIComponent(document.getElementById('post').value), ajax_get_value);">
<br><br>
<?
}

function check_user_params() {
global $_POST;
global $_SESSION;
global $CONFIG;
if ((isset($_POST["login"])) and (isset($_POST["password"])))
{
$_SESSION["id"]=check_reg(check_string($_POST["login"]),md5(check_string($_POST["password"])),check_string($_SERVER["REMOTE_ADDR"]));
$_SESSION["login"]=check_string($_POST["login"]);
$_SESSION["password"]=check_string($_POST["password"]);
$_SESSION["status"]=getstatus($_SESSION["id"],check_string($_SERVER["REMOTE_ADDR"]));
$_SESSION["blog_indef"]=$CONFIG["blog_indef"];
}
else
{
if ( (isset($_SESSION["id"])) && ($CONFIG["blog_indef"]===$_SESSION["blog_indef"]) )
{
$_SESSION["status"]=getstatus($_SESSION["id"],check_string($_SERVER["REMOTE_ADDR"]));
//if (isset($_GET["style"])) {$_SESSION["style"]=check_string($_GET["style"]);}
}
else
{
$_SESSION["status"]=getstatus(0,check_string($_SERVER["REMOTE_ADDR"]));
}
}
}

function get_headers_list(){
global $CONFIG;
Header("Content-type: text/html; charset=".$CONFIG["charset"]); 
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");   
Header("Cache-Control: no-cache, must-revalidate");   
Header("Pragma: no-cache");   
Header("Last-Modified: ".gmdate("D, d M Y H:i:s")."GMT");
}

function get_html_head() {
global $CONFIG;
global $_GET;
global $_SESSION;
?>
<head>
<meta content="<? echo $CONFIG["blog_keywords"];?>" name=keywords>
<meta name=description content="<? echo $CONFIG["blog_content"];?>">
<meta HTTP-EQUIV=Cache-Control content=no-cache>
<title>
<?
if (isset($_GET["topic"])) {
echo topic_title(check_string($_GET["topic"]));
} else {
echo $CONFIG["blog_title"];
}
?>
</title>
<meta http-equiv="Content-Type" content="text/html; charset=<? echo $CONFIG["charset"];?>">
<link href="styles/sbmb_style.css" type=text/css rel=stylesheet>
<? if (!isset($_SESSION["style"])) {echo "<link href=\"".$CONFIG["blog_style"]."\" type=\"text/css\" rel=stylesheet>";} else { echo "<style type=\"text/css\"> @import \"".$_SESSION["style"]."\"; </style>";} ?>
<link rel=icon href="<? echo $CONFIG["ico"];?>" type=image/x-icon>
<script language="JavaScript" src="ajax.js" type="text/javascript"></script>
<link rel="alternate" type="application/rss+xml" title="<? echo $CONFIG["blog_title"];?>" href="<? echo $CONFIG["sitename"]."/".$CONFIG["rss_module"];?>" />
</head>
<?
}

function get_login_form() {
?>
<form method=POST>
<p id="loginform" align=center>Ëîãèí <input type=text name=login> Ïàðîëü <input type=password name=password> <input type=submit value=Âîéòè></p>
</form><p align=center><a href=reg.php>Ïîäàòü çàïðîñ íà ðåãèñòðàöèþ</a>
<?
}

function get_login_info() {
global $_SESSION;
global $_SERVER;
if (!empty($_SESSION["id"]))
{
echo "<p align=center>Âû âîøëè êàê <strong>".$_SESSION["login"]."</strong>";
?><br>
<strong>
<a href="#loadfoto" onClick="adjustMessage('ajax.php?action=getform&form=1','loadfotoDiv',event);">Çàãðóçèòü ôîòî</a>
<a href="#edmail" onClick="adjustMessage('ajax.php?action=getform&form=2','editemailDiv',event);">Ðåäàêòèðîâàòü E-mail</a>
<a href="#edstyle" onClick="adjustMessage('ajax.php?action=getform&form=4','editstyleDiv',event);">Ñòèëü îôîðìëåíèÿ</a>
</strong>
<?
if (getstatus($_SESSION["id"],check_string($_SERVER["REMOTE_ADDR"]))==0)
{
echo "<div align=center><h1>Âàø íèê çàáàíåí!</h1></div>";
}
echo "<p align=center><a href=ajax.php?action=quit>Âûéòè</a>";
}
else
{
get_login_form();
}
}

function get_main_search_menu() {
?>
<p align=center>
<?
get_mainmenu_links();
?>
</p>
<p align=center>
<form method=POST action=index.php>
<p align=center>
<input type=text name=search size=60>
<input type=submit value="Ïîèñê">
</p>
</form>
<?
}

function get_mainmenu_links() {
global $t_mainmenu;
@$result=mysql_query("SELECT * FROM `".$t_mainmenu."` ORDER BY id") or die("<p>Îøèáêà ïîèñêà ññûëîê!<p>");
if (mysql_num_rows($result)!=0)
{
	while ($row=mysql_fetch_array($result)):
		echo "<a href=\"".$row["link"]."\">".$row["text"]."</a> ";
	endwhile;
}
}

function get_comment_form($topic) {
?>
<div align=center id=predpr><b>Ïðåäïðîñìîòð âêëþ÷åí.</b></div>
<form action=newpost.php method=POST>
<input type=hidden id=topic name=topic value="<? echo $topic;?>">
<p align=center>
Ââåäèòå âàø êîììåíòàðèé:<br>
<textarea id=post name=post cols=100 rows=12></textarea><br>
<input type=submit name=submit value="Ïîñëàòü">
<input type=reset value="Î÷èñòèòü">
<input type=button value="Ïðåäïðîñìîòð" onClick="postRequest('preview.php','predpr','topic='+encodeURIComponent(document.getElementById('topic').value)+'&message='+encodeURIComponent(document.getElementById('post').value),getRequest);">
</p>
</form>
<p align=center>
<?
get_textformat_button();
get_smiles('post');
}

function get_comment_adminform($topic) {
?>
<div align=center id=predpr><b>Ïðåäïðîñìîòð âêëþ÷åí. Àäìèíèñòðàòîðû ìîãóò ââîäèòü HTML-òåãè è JavaScript.</b></div>
<form action=newpost.php method=POST>
<input type=hidden id=topic name=topic value="<? echo $topic;?>">
<p align=center>
<textarea id=post name=post cols=100 rows=12></textarea><br>
<input type=submit name=submit value="Ïîñëàòü">
<input type=reset value="Î÷èñòèòü">
<input type=button value="Ïðåäïðîñìîòð" onClick="postRequest('preview.php','predpr','topic='+encodeURIComponent(document.getElementById('topic').value)+'&message='+encodeURIComponent(document.getElementById('post').value),getRequest);">
<input type=button value="Ru 2 En" onClick="postRequest('ajax.php','post','action=ru2en&post='+encodeURIComponent(document.getElementById('post').value), ajax_get_value);">
<input type=button value="En 2 Ru" onClick="postRequest('ajax.php','post','action=en2ru&post='+encodeURIComponent(document.getElementById('post').value), ajax_get_value);">
</form>
<br>
<input type=button value="Êàðòèíêà" onclick="javascript:document.all.post.value=document.all.post.value+'<img src= align= alt= title= width= height= border=0>'">
<input type=button value="Àáçàö" onclick="javascript:document.all.post.value=document.all.post.value+'<p align=justify></p>'">
<input type=button value="Ñêðèïò" onclick="javascript:document.all.post.value=document.all.post.value+'<script></script>'">
<input type=button value="Æèðíûé" onclick="javascript:document.all.post.value=document.all.post.value+'<b></b>'">
<input type=button value="Êóðñèâ" onclick="javascript:document.all.post.value=document.all.post.value+'<i></i>'">
<input type=button value="Ïîä÷åðêíóòûé" onclick="javascript:document.all.post.value=document.all.post.value+'<u></u>'">
<input type=button value="Øðèôò" onclick="javascript:document.all.post.value=document.all.post.value+'<font color= size= title= id=></font>'">
<input type=button value="&lt;" onclick="javascript:document.all.post.value=document.all.post.value+'&l'+'t;'">
<input type=button value="&gt;" onclick="javascript:document.all.post.value=document.all.post.value+'&g'+'t;'">
<input type=button value="&quot;" onclick="javascript:document.all.post.value=document.all.post.value+'&qu'+'ot;'">
<br>
<input type=button value="Ôîðìà" onclick="javascript:document.all.post.value=document.all.post.value+'<form action= method=get></form>'">
<input type=button value="Ñêðûòîå ïîëå" onclick="javascript:document.all.post.value=document.all.post.value+'<input name= id= type=hidden value=>'">
<input type=button value="Button" onclick="javascript:document.all.post.value=document.all.post.value+'<input name= id= type=button value=>'">
<input type=button value="Êíîïêà" onclick="javascript:document.all.post.value=document.all.post.value+'<input name= id= type=submit value=>'">
<input type=button value="Òåêñò" onclick="javascript:document.all.post.value=document.all.post.value+'<input name= id= type=text value=>'">
<input type=button value="Ïàðîëü" onclick="javascript:document.all.post.value=document.all.post.value+'<input name= id= type=password value=>'">
<input type=button value="Òåêñòîâîå ïîëå" onclick="javascript:document.all.post.value=document.all.post.value+'<textarea name= cols= rows=></textarea>'">
<br>
<?
get_smiles('post');
}

function blog_quit() {
global $_SESSION;
unset($_SESSION["login"]);
unset($_SESSION["password"]);
unset($_SESSION["status"]);
unset($_SESSION["topic"]);
unset($_SESSION["id"]);
session_destroy();
header("location: index.php");
}

function search_text_in_blog($text) {
global $t_topics;
global $t_mess;
$text_array=split(" ",$text);

echo "<div align=\"justify\" style=\"padding-right: 5; padding-left: 5; margin:5;\"><b>Ïîèñê &quot;$text&quot; â òîïèêàõ:</b><br>";
@$result=mysql_query("SELECT id,theme FROM `$t_topics` WHERE text LIKE '%$text%'") or die("<p>Îøèáêà ïðè ïîèñêå â òîïèêàõ!1<p>");
while ($row=mysql_fetch_array($result)):
echo "<a href=index.php?topic=".$row["id"].">".$row["theme"]."</a><br>";
endwhile;
echo "<br></div>";

echo "<div align=\"justify\" style=\"padding-right: 5; padding-left: 5; margin:5;\"><b>Ïîèñê &quot;$text&quot; â êîììåíòàðèÿõ:</b><br>";
@$result=mysql_query("SELECT topic,id,text FROM `$t_mess` WHERE text LIKE '%$text%'") or die("<p>Îøèáêà ïðè ïîèñêå â êîììåíòàðèÿõ!2<p>");
while ($row=mysql_fetch_array($result)):
echo "<a href=index.php?topic=".$row["topic"]."#m".$row["id"].">".substr($row["text"],0,100)."...</a><br>";
endwhile;
echo "<br></div>";

foreach($text_array as $index => $word) {
if ($word<>$text) {
echo "<div align=\"justify\" style=\"padding-right: 5; padding-left: 5; margin:5;\"><b>Ïîèñê &quot;$word&quot; â òîïèêàõ:</b><br>";
@$result=mysql_query("SELECT id,theme FROM `$t_topics` WHERE text LIKE '%$word%'") or die("<p>Îøèáêà ïðè ïîèñêå â òîïèêàõ!3<p>");
while ($row=mysql_fetch_array($result)):
echo "<a href=index.php?topic=".$row["id"].">".$row["theme"]."</a><br>";
endwhile;
echo "<br></div>";

echo "<div align=\"justify\" style=\"padding-right: 5; padding-left: 5; margin:5;\"><b>Ïîèñê &quot;$word&quot; â êîììåíòàðèÿõ:</b><br>";
@$result=mysql_query("SELECT topic,id,text FROM `$t_mess` WHERE text LIKE '%$word%'") or die("<p>Îøèáêà ïðè ïîèñêå â êîììåíòàðèÿõ!4<p>");
while ($row=mysql_fetch_array($result)):
echo "<a href=index.php?topic=".$row["topic"]."#m".$row["id"].">".substr($row["text"],0,100)."...</a><br>";
endwhile;
echo "<br></div>";
}
}
}

function translit($type,$string)  {
$string=trim($string);
$string=stripslashes($string);
switch($type)
{
case 0:	$string=strtr($string,"àáâãäåçèéêëìíîïðñòóôõüûý","abvgdeziiklmnoprstufh'ye");
	$string=strtr($string,"ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÜÛÝ","ABVGDEZIIKLMNOPRSTUFH'YE");
	$string=strtr($string,array("¸"=>"yo","¨"=>"YO","æ"=>"zh", "ö"=>"ts", "÷"=>"ch", "ø"=>"sh","ù"=>"shch","ú"=>"", "þ"=>"yu", "ÿ"=>"ya","Æ"=>"ZH", "Ö"=>"TS", "×"=>"CH", "Ø"=>"SH","Ù"=>"SHCH","Ú"=>"", "Þ"=>"YU", "ß"=>"YA", "¹"=>"#"));
	break;
case 1:	$string=strtr($string,array("yo"=>"¸","YO"=>"¨","Yo"=>"¨","zh"=>"æ", "ts"=>"ö", "ch"=>"÷", "sh"=>"ø","shch"=>"ù", "yu"=>"þ", "ya"=>"ÿ","ZH"=>"Æ", "TS"=>"Ö", "CH"=>"×", "SH"=>"Ø","SHCH"=>"Ù","YU"=>"Þ", "YA"=>"ß","Yu"=>"Þ", "Ya"=>"ß", "#"=>"¹"));
	$string=strtr($string,"abvgdeziklmnoprstufh'y","àáâãäåçèêëìíîïðñòóôõüû");
	$string=strtr($string,"ABVGDEZIKLMNOPRSTUFH'Y","ÀÁÂÃÄÅÇÈÊËÌÍÎÏÐÑÒÓÔÕÜÛ");
	break;
default:break;
}
return $string;
}

function admin_get_new_users() {
global $t_users;
?>
Íîâûå ïîëüçîâàòåëè:
<?
@$result=mysql_query("SELECT * FROM `$t_users` WHERE status=1") or die("<p>Îøèáêà ïðè ïîèñêå ïîëüçîâàòåëåé!<p>");
echo "<table width=100%>";
while ($row=mysql_fetch_array($result)):
echo "<tr>";
echo "<td>".$row["id"]."</td><td>".$row["login"]."</td><td>".$row["email"]."</td><td>".$row["ip"]."</td><td><a href=\"#newuser\" onClick=\"sendRequest('ajax.php?action=yesuser&id=".$row["id"]."&us=2','search_div',getRequest);\">Ïîäòâåðäèòü</a></td><td><a href=\"#deluser\" onClick=\"sendRequest('ajax.php?action=nouser&id=".$row["id"]."','search_div',getRequest);\">Îòêëîíèòü</a></td>";
echo "</tr>";
endwhile;
echo "</table>";
}

?>
Return current item: Simple But Mighty Blog