{
$maxgbmes=10;
$id=idsg($page);
if(sizeof($id) >=$maxgbmes) delguest($id [0]);
$conn = db_connect();
$query = "insert into guests values (null, '". $idstud. "', '". $message. "', '". $ip. "', '". $page. "', now())";
$result = mysql_query($query);
if (! $result)
return false;
return true;
}
function smiles($mes)
{
$mes=str_replace(":: smile:: ","<img src=smiles/icon_smile. gif>",$mes);
$mes=str_replace(":: dedmoroz:: ","<img src=smiles/dedmoroz. gif>",$mes);
$mes=str_replace(":: sad:: ","<img src=smiles/icon_sad. gif>",$mes);
$mes=str_replace(":: lol:: ","<img src=smiles/icon_lol. gif>",$mes);
$mes=str_replace(":: cry:: ","<img src=smiles/icon_cry. gif>",$mes);
$mes=str_replace(":: imad:: ","<img src=smiles/icon_imad. gif>",$mes);
$mes=str_replace(":: arrow:: ","<img src=smiles/icon_arrow. gif>",$mes);
$mes=str_replace(":: exclaim:: ","<img src=smiles/icon_exclaim. gif>",$mes);
$mes=str_replace(":: question:: ","<img src=smiles/icon_question. gif>",$mes);
$mes=str_replace(":: dont:: ","<img src=smiles/icon_dont. gif>",$mes);
$mes=str_replace(":: wink:: ","<img src=smiles/icon_wink. gif>",$mes);
$mes=str_replace(":: shock:: ","<img src=smiles/icon_shock. gif>",$mes);
$mes = str_replace(":: kiss:: ","<IMG src=smiles/kiss. gif border=0>",$mes);
$mes = str_replace(":: frag:: ","<IMG src=smiles/frag. gif border=0>",$mes);
$mes = str_replace(":: flag:: ","<IMG src=smiles/flag. gif border=0>",$mes);
$mes=str_replace(" [b] ","<b>",$mes);
$mes=str_replace(" [/b] ","</b>",$mes);
$mes=str_replace(" [i] ","<i>",$mes);
$mes=str_replace(" [/i] ","</i>",$mes);
$mes=str_replace(" [u] ","<u>",$mes);
$mes=str_replace(" [/u] ","</u>",$mes);
$mes=str_replace(" [*] ","<li>",$mes);
return $mes;
}
? >
В.1 Листинг модуля "chat. php"
<?
session_start();
if(! isset($_SESSION ['student']))
{
$_SESSION ['error_fill'] ['bool'] =true;
$_SESSION ['error_fill'] ['message'] ='<b>Чтобы войти в чат надо зарегистрироваться! </b>';
include 'InternetTechnology. php';
}else
{
echo "
<html><head>
<title>Чат</title>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>
</head>
<body leftmargin='0' rightmargin='0' topmargin='0' background='images/blocks_bg. gif'>";
$color1='#e5e5e5';
$color2='#cbdff7';
$color3='#84adel'; // '#009999';
$row=0;
include("all. php");
doheader('Интернет технологии', ' - Чат');
$color_replace = array ('#\ [color=(\# [0-9A-F] {6}| [a-z\-] +) \] (. *?) \ [/color\] #si' => '<font color="\1">\2</font>');
$link_replace=array('#([\w] +?: // [^ \"\n\r\t<] *) #si' => '<a href="\1" target=_blank><u>\1</a></u>');
$group=$_SESSION ['student'] ['group'] ;
if(isset($_REQUEST ['message'])) $message=$_REQUEST ['message'] ; else $message='';
if(isset($_REQUEST ['history'])) $history=$_REQUEST ['history'] ; else $history='';
$ip=$_SERVER ['REMOTE_ADDR'] ;
if(badip($ip, 'chat')) echo "<script> alert ('Запись с этого IP - адреса запрещена администратором! ') </script>";
else {
if($message! =''&$group! ='')
if(! storemessage($group, $message, $ip)) echo "<script> alert ('Не удалось записать сообщение! ') </script>";
}
echo "
<center><TABLE border=0 width=100% height=85% cellspacing=0 cellpadding=0>
<tr><td><table width=100% cellspacing=3 cellpadding=3>
<tr><td class=bor width=33%><a href=chat. php? history=1><font class=for>История</font></a></td>
<td class=bor width=33%><a href=chat. php><font class=for>Чат</font></a></td>
<td class=bor width=33%><a href=InternetTechnology. php>
<font class=for>Выйти из чата</font></a></td></tr></table></td></tr>";
echo "<tr><td> </td></tr>
<tr><td height=60% valign=middle align=center>";
echo "<table width=95% border=1 bgcolor=$color2><tr><td><table width=100% bgcolor=$color3 cellspacing=1 cellpadding=3><tr>";
echo"<td valign=middle align=center width=10%><font color=darkblue><b>Автор</b></font></td>
<td width=80% align=center><font color=darkblue><b>Сообщение</b></font></td>
<td width=12% align=center ><font color=darkblue><b>Записано</b></font></td></tr></table><tr><td>
<table width=100% cellpadding=3 bgcolor=$color3>";
$idch=ids('chatmessages','idchmes');
if(sizeof($idch) >0) $idch=array_reverse($idch);
if($history) $n=sizeof($idch);
elseif(sizeof($idch) <=10) $n=sizeof($idch); else $n=10;
for($i=$n-1; $i>=0; $i--)
{
$mes=mes($idch [$i], 'idchmes', 'chatmessages');
$guest=returnchatguest($idch [$i]);
foreach($color_replace as $k=>$v) $mes ['message'] =preg_replace($k,$v,$mes ['message']);
foreach($link_replace as $key=>$value) $mes ['message'] =preg_replace($key, $value, $mes ['message']);
$mes ['message'] =smiles($mes ['message']);
$date=reformat_date($mes ['time']);
if ($row%2) $col=$color2; else $col=$color1;
echo
"<tr bgcolor=". $col. "><td valign=center align=center width=10%>
<a href=mailto: ". $guest ['email']. " title=\" Нажмите для отправки по e-mail\"><b>". $guest ['login']. "</b>
<a></td><td align=left width=80%> ". $mes ['message']. "</td><td align=center width=10%>
<font size=2>". $date. "</font></td></tr>";
$row++;
} echo"</table><tr></tr></table><tr><td> </td></tr></td></tr><tr><td>";
echo "<form name=gb action=chat. php method=post>";
if(! $history)
{
echo "<center><table width=95%><tr><td align=center>";
include('postmodule. php');
echo"</td></tr></table></center>";
}
else echo "<center><table width=100% cellspacing=1 cellpadding=3><tr><td class=bor>
<a href=chat. php><font class=for>Вернуться в чат</font></a></td></tr></center>";
echo "</center></td></tr></table>";
doout('');
echo "</form></body></html>";
}
? >
В.2 Листинг модуля "chat. php"
<?
function delchguest($id) // Oaaeaiea anao ioieoia
{
$conn = db_connect();
$query = "select idchmes from chatmessages where idchg='$id'";
$result = mysql_query($query);
if(! $result) return false;
if(mysql_numrows($result) ==0)
{
$query="delete from chatguests where idchguest='$id'";
$result = mysql_query($query);
if(! $result) return false;
return true;
} else echo"<b>Не удается удалить участника, сначала удалите его сообщения! </b><br>";
}
function badip($ip, $sub) // Eiee? anoai ioieoia id
{
$conn = db_connect();
$query = "select idip from ips where ip='$ip' and sub='$sub'";
$result = mysql_query($query);
if(! $result) return false;
$num=mysql_numrows($result);
if($num>0) return true;
else return false;
}
function del($d, $tab, $table) // Oaaeaiea anao ioieoia
{
$conn = db_connect();
$query="delete from $table where $tab='$d'";
$result = mysql_query($query);
if(! $result) return false;
return true;
}
function idsip($sub) // Eiee? anoai ioieoia id
{
$conn = db_connect();
$query = "select idip from ips where sub='$sub'";
$result = mysql_query($query);
if(! $result) return false;
$num=mysql_numrows($result);
if($num>0)
{
for($i=0; $i<$num; $i++)
$idsip [$i] =mysql_result($result,$i,0);
return $idsip;
}
}
function storeip($ip, $sub)
{
$conn = db_connect();
$query ="select* from ips where ip='$ip' and sub='$sub'";
$result = mysql_query($query);
if(mysql_numrows($result) ==0)
{
$query = "insert into ips values (null, '". $ip. "', '". $sub. "')";
$result = mysql_query($query);
if(! $result) return false;
return true;
}
}
function storemessage($idstud, $mes, $ip)
{
$maxchmes=100;
$id=ids('chatmessages', 'idchmes');
if(sizeof($id) >$maxchmes) delchatmes($id [0]);
$conn = db_connect();
$query = "insert into chatmessages values (null, '". $idstud. "', '". $mes. "', '". $ip. "', now())";
$result = mysql_query($query);
if(! $result) return false;
return true;
}
function returnchatguest($id)
{
$conn = db_connect();
$query = "select idstudc from chatmessages where idchmes='$id'";
$result = mysql_query($query);
if(! $result) return false;
$num=mysql_numrows($result);
if($num==1)
$idchg=mysql_result($result,0,0);
$query = "select * from students where idstud='$idchg'";
$result = mysql_query($query);
if(! $result) return false;
return mysql_fetch_array($result);
}
? >
Г.1 Листинг модуля "shop. php"
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<h2><font size="+2" class=color> Магазин почтой</font></h2>
<form action="InternetTechnology. php? mode=store_zakaz" method="post">
<?
$color3="#84ade1";
$color2="#cbdff7";
$color1='#e5e5e5';
$done=isset($_REQUEST ['done'])? $_REQUEST ['done']: '';
$id=isset($_REQUEST ['id'])? $_REQUEST ['id']: '';
$_SESSION ['client'] =isset($_SESSION ['client'])? $_SESSION ['client']: '';
if($_SESSION ['client'] =='')
{
if(isset($_SESSION ['student']))
{
$_SESSION ['client'] ['name'] =$_SESSION ['student'] ['name'] ;
$_SESSION ['client'] ['sname'] =$_SESSION ['student'] ['family'] ;
$_SESSION ['client'] ['email'] =$_SESSION ['student'] ['email'] ;
$_SESSION ['client'] ['fhone'] ='';
$_SESSION ['client'] ['address'] ='';
}else
{
$_SESSION ['client'] ['name'] ='';
$_SESSION ['client'] ['sname'] ='';
$_SESSION ['client'] ['fhone'] ='';
$_SESSION ['client'] ['email'] ='';
$_SESSION ['client'] ['address'] ='';
}
}
if($done) $id='';
if($id)
{
$cd=mes($id, 'idc', 'cd');
echo"<center><table bgcolor=$color2 width=95% cellspacing=2 cellpadding=6>
<tr bgcolor=$color1><td><b>Название: </b> ". $cd ['title']. "</td></tr>
<tr bgcolor=$color1><td><b>Описание</b>: ". $cd ['description']. "</td></tr>
<tr bgcolor=$color1><td><b>Цена: </b> ". $cd ['price']. "</td></tr>
<tr><td>Количество: <br><input type='text' name='count' value=1 size='3' maxlength=3></td></tr>
<tr><td>Имя: <br><input type='text' name='name' value='". $_SESSION ['client'] ['name']. "' size='15' maxlength=15></td></tr>
<tr><td>Фамилия: <br><input type='text' name='sname' value='". $_SESSION ['client'] ['sname']. "' size='15' maxlength=15></td></tr>
<tr><td>Адрес электронной почты: <br><input type='text' name='email' value='". $_SESSION ['client'] ['email']. "' size='30' maxlength=30></td></tr>
<tr><td>Введите номер телефона без пробелов и разделителей: <br><input type='text' name='fhone' value='". $_SESSION ['client'] ['fhone']. "' size=12 maxlength=12></td></tr>
<tr><td>Введите адрес почтовой доставки: <br><textarea name=address cols=50 rows=3>". $_SESSION ['client'] ['address']. "</textarea></td></tr>
<tr><td bgcolor=$color1><input type=hidden name=id value=". $id. "><input type=submit value='Заказать'>
</td></tr></table></center></form>";
}
else
{
? >
<form action="InternetTechnology. php? mode=shop" method="post">
<table width="95%" border="0" cellspacing="2" cellpadding="6" bgcolor=<? =$color2? >>
<tr>
<td width=30%><b>Название</b></td>
<td width=60%><b>Описание</b></td>
<td width=10%><b>Цена</b></td>
</tr>
<?
$num=ids('cd', 'idc');
for($i=0; $i<sizeof($num); $i++)
{
$cd=mes($num [$i], 'idc', 'cd');
echo"<tr bgcolor=$color1><td>
<a href=InternetTechnology. php? mode=shop&id=". $cd ['idc']. ">". $cd ['title']. "</a></td><td>". $cd ['description']. "</td>
<td>". $cd ['price']. "</td></tr>";
}echo" </table></form>";
}
? >
Г.2 Листинг модуля "shopping. php"
<?
$pod=isset($_REQUEST ['pod'])? $_REQUEST ['pod']: '';
if($pod)
{
if(! session_id()) session_start();
echo"<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>";