<?php
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"
\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">\n";
echo "<!-- MobiiliChat v1.11color -->\n";
echo "<!-- Copyright (C) 2004-2005 Keijo Kangas ([email protected]) -->\n";
$swe_from = array("ГҐ","Г¤","Г¶","Г…","Г„","Г–","$","&","В");
$swe_to = array("е", "д", "ц", "Е", "Д", "Ц","d","j","");
for ($t=0; $t<count($swe_from); $t++)
{
$nimi = str_replace ($swe_from[$t], $swe_to[$t], $nimi);
$salasana = str_replace ($swe_from[$t], $swe_to[$t], $salasana);
$viesti = str_replace ($swe_from[$t], $swe_to[$t], $viesti);
}
$teoria=$salasana;
$salasana=crypt($salasana,'password');
$salnim=file('nims.txt');
$salsan=file('sals.txt');
for ($i=0; $i<count($salnim); $i++)
{ if (rtrim($salsan[$i])==$salasana && rtrim($salnim[$i])==$nimi){$a="1";}}
if ($a !="1"){
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";
echo "<title>Chatroom</title>\n";
echo "</head>\n";
echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">";
echo "<p>\n";
echo "<a href=\"home_fi.php\">Alkuun</a>\n";
echo "</p>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
$aikanyt=time();
$aika=file('ajat.txt');
$ero=$aikanyt-$aika[0];
if ($ero>=120){
$peke = fopen('chatpaikalla.txt', 'r+');
ftruncate ($peke,0);
fclose($peke);
}
$tiedo = fopen('ajat.txt', 'r+');
ftruncate ($tiedo,0);
$tos=$aikanyt;
fputs($tiedo, $tos);
fclose($tiedo);
$sama=0;
$paikalla=file('paikalla.txt');
for ($u=0; $u<count($paikalla); $u++)
{
if (rtrim($paikalla[$u])==$nimi)
{$sama="1";$u=count($paikalla)+1;}
}
if ($nimi != "admin" && $sama != "1")
{
$tie = fopen('paikalla.txt', 'r+');
$ko=file_get_contents ('paikalla.txt');
$to=$nimi .'
'. $ko;
fputs($tie, $to);
fclose($tie);
}
$lis=0;$katsos=0;$tyhja='';
$jepulio=file('paikalla.txt');
$privaviestit=file('privnea.txt');
$salasana=crypt($salasana,'password');
$chatpaik=file('chatpaikalla.txt');
$sama=0;
for ($u=0; $u<count($chatpaik); $u++)
{
$alio=explode("¤",$chatpaik[$u]);
if (rtrim($alio[0])==$nimi)
{$sama="1";$u=count($chatpaik)+1;}
}
if ($nimi != "admin" && $sama != "1") {
$tie = fopen('chatpaikalla.txt', 'r+');
$ko=file_get_contents ('chatpaikalla.txt');
$to=$nimi .'¤'.time().'
'. $ko;
fputs($tie, $to);
fclose($tie);
}
if ($sama=="1"){
$tie = fopen('chatpaikalla.txt', 'r+');
$jui=file('chatpaikalla.txt');
$ko=file_get_contents ('chatpaikalla.txt');
for ($i=0; $i<count($jui); $i++)
{
$alo=explode("¤",$jui[$i]);
if ($nimi==$alo[0]){$hee=$jui[$i];}
}
$ko = str_replace ($hee,$nimi.'¤'.time().'
', $ko);
fputs($tie, $ko);
fclose($tie);
}
$tie = fopen('chatpaikalla.txt', 'r+');
$jui=file('chatpaikalla.txt');
$ko=file_get_contents ('chatpaikalla.txt');
for ($i=0; $i<count($jui); $i++)
{
$hee=$jui[$i];
$alo=explode("¤",$jui[$i]);
$erotus=time()-$alo[1];
if ($erotus>=120){$ko = str_replace ($hee,'',$ko);}
}
ftruncate($tie,0);
fputs($tie, $ko);
fclose($tie);
if ($nimi == "admin" || $nimi=="admin"){
if ($viesti == "delprivate"){
$peke = fopen('privnea.txt', 'r+');
ftruncate ($peke,0);
fclose($peke);
$viesti="";}
if ($viesti == "delpaikalla"){
$peke = fopen('paikalla.txt', 'r+');
ftruncate ($peke,0);
fclose($peke);
$viesti="";}
if ($viesti == "delchat"){
$pek = fopen('chat.txt', 'r+');
$kolmanee=file_get_contents ('chat.txt');
$uusiriv="<br/>\n
<br/>\n
<br/>\n
<br/>\n
<br/>\n
<br/>\n
<br/>\n
<br/>\n";
$toinent="$uusiriv $kolmanee";
fputs($pek, $toinent);
fclose($pek);
$viesti="";}
$hmmm=explode('-',$viesti);
if ($hmmm[0]=="del"){
$kuka=$hmmm[1];
if ($hmmm[1]=="admin" || $hmmm[1]=="admin"){$kuka="kjyfvuykug";}
for ($pp=0; $pp<count($salnim); $pp++)
{ if (rtrim($salnim[$pp])==$kuka){
$tiedosto = fopen('nims.txt', 'r+');
$ko=file_get_contents ('nims.txt');
$ko = str_replace ($kuka.'
', $kuka.'_POISTETTU
', $ko);
fputs($tiedosto, $ko);
fclose($tiedosto);
$tiedsal = fopen('sals.txt', 'a');
$salasana = $kuka.'_POISTETTU';
$lissal=$salasana.'
';
fputs($tiedsal, $lissal);
fclose($tiedsal);
$tiednim= fopen('nims.txt', 'a');
$lisnim=$kuka.'
';
fputs($tiednim, $lisnim);
fclose($tiednim);
}}
$viesti="";
}
}
$chatpaik=file('chatpaikalla.txt');
$salsan=file('sals.txt');
$salnim=file('nims.txt');
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>";
echo "<meta http-equiv=\"refresh\" content=\"30;url=chat_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\" />\n";
echo "<title>Chatroom(".count($chatpaik).")</title>\n";
echo "</head>";
echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
for ($i=0; $i<count($salnim); $i++)
{ if (rtrim($salsan[$i])==$salasana && rtrim($salnim[$i])==$nimi){$a="1";}}
for ($q=0; $q<count($privaviestit); $q++)
{
$tech=explode('¤',$privaviestit[$q]);
$testos=str_replace("*", "",$tech[0]);
if ($testos==$nimi)
{
if ( strpos($privaviestit[$q],"*")===0)
{
$katsos=$katsos+1;
}
$lis=$lis+1;
if ($lis>7)
{
$q=count($privaviestit)+1;
}
}
}
echo "<small>\n";
echo "<a href=\"kirj_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\">[Kirjoita]</a>\n";
echo "<a href=\"prividis_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\">[Priva]";if ($katsos>=1){echo "(".$katsos." uutta)";}
echo "</a><br>\n";
if ($a != "1") { $ines=0; $viesti="";}
if ($viesti != ''){
$turska=file('toisto.txt');
for ($l=0; $l<count($turska); $l++)
{ if (rtrim($turska[$l])==$viesti){$viesti='';}}
$toistoke = fopen('toisto.txt', 'r+');
$hypro=file_get_contents ('toisto.txt');
$hape=$viesti . '
' . $hypro;
fputs($toistoke, $hape);
if (filesize('toisto.txt')>400)
{ftruncate ($toistoke,400);}
fclose($toistoke);
}
if ($joo=='h000'){$joo='';}
$viesti=$viesti.$joo;
if ($viesti != '') {
$swe_from = array("ГҐ","Г¤","Г¶","Г…","Г„","Г–","$","&","В");
$swe_to = array("е", "д", "ц", "Е", "Д", "Ц","d","j","");
for ($i=0; $i<count($swe_from); $i++)
{
$viesti = str_replace ($swe_from[$i], $swe_to[$i], $viesti);
$nimi = str_replace ($swe_from[$i], $swe_to[$i], $nimi);
}
$rumatsanat=file('sensuuri.txt');
for ($ri=0; $ri<count($rumatsanat); $ri++)
{
$vaihto=rtrim($rumatsanat[$ri]);
$viesti = str_replace ($vaihto,"****", $viesti);
}
$nimi= htmlspecialchars($nimi);
$nimi= stripslashes($nimi);
$viesti= htmlspecialchars($viesti);
$viesti=stripslashes($viesti);
$joo = array("h000", ":o", ":D", ";)", ":(", ":)", "8)");
$kuv=file('kuvat.txt');
for ($m=0; $m<count($joo); $m++)
{
$viesti = str_replace ($joo[$m], rtrim($kuv[$m]), $viesti);
}
$joo='';
$uusirivi ='<b>'.strip_tags($nimi) . '</b>: ' . $viesti . '<br/>
';
$tiedosto = fopen('chat.txt', 'r+');
$kolmas=file_get_contents ('chat.txt');
$toinen="$uusirivi $kolmas";
fputs($tiedosto, $toinen);
if (filesize('chat.txt')>1000000)
{ftruncate ($tiedosto,1000000);}
fclose($tiedosto);
$viestik=$viesti;
$nimik=$nimi;
$viesti = '';
}
$juttujoo=file('chat.txt');
for ($k=0; $k<8; $k++)
{
$juttujoo = str_replace ("wbmp", "gif", $juttujoo);
echo $juttujoo[$k];
}
echo "<a href=\"chat_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\">[Pдivitд]</a><br>\n";
echo "<a href=\"paikalla_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\">[Paikalla(".count(file('chatpaikalla.txt')).")]</a>\n";
echo "<br>\n";
echo "<a href=\"logout_fi.php?time=".date('dmHis').'&nimi='.$nimi.'&salasana='.$teoria."\">[Ulos]</a>\n";
echo "</small>";
echo "</body>\n";
echo "</html>\n";
?>