<?php
header("Content-type: text/vnd.wap.wml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"windows-1251\" ?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n";
echo "<!-- MobiiliChat v1.07 -->\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);
}
$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 "<wml>";
echo "<card title=\"Chat\">";
echo "<p>";
echo "<a href=\"home.php\">[Home]</a>";
echo "</p>";
echo "</card>";
echo "</wml>";
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+');
ftruncate ($pek,0);
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="";
}
}
$salsan=file('sals.txt');
$salnim=file('nims.txt');
echo "<wml>";
echo "<head>";
echo "<meta http-equiv=\"Cache-Control\" content=\"max-age=0\"/>";
echo "</head>";
$chatpaik=file('chatpaikalla.txt');
echo "<card title=\"Chat(";echo count($chatpaik);echo ")";echo "\" ontimer=\"chat.php?time=";
echo date('dmHis');
echo '&nimi=$nimi&salasana=$salasana';
echo "\">";
echo "<timer value=\"200\"/>";
echo "<p>";
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><anchor>[Write]";
echo "<go method=\"post\" href=\"kirj.php?time=".time()."\">";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "<setvar name=\"viesti\" value=\"\"/>";
echo "<setvar name=\"joo\" value=\"h000\"/>";
echo "</go>";
echo "</anchor>";
echo "<anchor>[Private]";
if ($katsos>=1){
echo "(".$katsos." new)";}
echo "<go method=\"post\" href=\"prividis.php\">";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "</go>";
echo "</anchor><br/>";
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 ='('.date('H:i').' <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++)
{
echo $juttujoo[$k];
}
echo "<anchor>[Users(".count(file('chatpaikalla.txt')).")]";
echo "<go method=\"post\" href=\"paikalla.php?time=".date(ymdHis)."\">";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "</go>";
echo "</anchor><br/>";
echo "<anchor>[Logout]";
echo "<go method=\"post\" href=\"logout.php?time=".date(ymdHis)."\">";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "</go>";
echo "</anchor>";
echo "</small></p>";
echo "</card>";
echo "</wml>";
?>