<?php
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"
\"http://www.wapforum.org/DTD/wml_1.1.xml\">";
$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);
$kenelle = str_replace ($swe_from[$t], $swe_to[$t], $kenelle);
}
$l="0";
$nimet=file_get_contents('chatpaikalla.txt');
$nim=file('chatpaikalla.txt');
$salasana=crypt($salasana,'password');
$privanimet=file('privnims.txt');
$privaviestit=file('privnea.txt');
$salnim=file('nims.txt');
$salsan=file('sals.txt');
for ($i=0; $i<count($nim); $i++)
{
$alo=explode("¤",$nim[$i]);
if ($nimi==$alo[0]){$l="1";$hee=$nim[$i];}
}
$kenelle = strtolower($kenelle);
if ($kenelle==''){$kenelle='?';}
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=\"Private\">";
echo "<p>";
echo "<a href=\"home.php\">Home</a>";
echo "</p>";
echo "</card>";
echo "</wml>";
exit();
}
$nimi= htmlspecialchars($nimi);
$viesti= htmlspecialchars($viesti);
$viesti= stripslashes($viesti);
$kenelle=stripslashes($kenelle);
$nimoni=$viesti;
$turska=file('toisto.txt');
if ($viesti !=''){
for ($l=0; $l<count($turska); $l++)
{ if (rtrim($turska[$l])==$nimoni){$viesti='';}}
$toistoke = fopen('toisto.txt', 'r+');
$hypro=file_get_contents ('toisto.txt');
$hape=$nimoni . '
' . $hypro;
fputs($toistoke, $hape);
if (filesize('toisto.txt')>400)
{ftruncate ($toistoke,400);}
fclose($toistoke);
}
echo "<wml>";
echo "<card title=\"Private ";echo date('H:i:s');echo "\" ontimer=\"prividis.php?time=";
echo date('dmHis');echo '&nimi=$nimi&salasana=$salasana';
echo "\">";
echo "<timer value=\"600\"/>";
echo "<p><small>";
if ($viesti !=''){
$uusirivi ='('.date('H:i:s').')'.$nimi . '->' . $kenelle . ': ' .$viesti.'<br/>
';
$tiedosto = fopen('privnea.txt', 'r+');
$kolmas=file_get_contents ('privnea.txt');
$tiedosto3 = fopen('privnims.txt', 'r+');
$kolmas3=file_get_contents ('privnims.txt');
$toinen='*'.$kenelle.'¤'.$uusirivi . $kolmas;
$toinen3=$kenelle . '
'. $kolmas3;
fputs($tiedosto, $toinen); fputs($tiedosto3, $toinen3);
fclose($tiedosto); fclose($tiedosto3);
$tiedosto = fopen('privnea.txt', 'r+');
$kolmas=file_get_contents ('privnea.txt');
$tiedosto4 = fopen('privnims.txt', 'r+');
$kolmas4=file_get_contents ('privnims.txt');
$toinen=$nimi.'¤'.$uusirivi.$kolmas; $toinen4=$nimi .'
'.$kolmas4;
fputs($tiedosto, $toinen);fputs($tiedosto4, $toinen4);
fclose($tiedosto); fclose($tiedosto4);
}
echo "<anchor>Msg";
echo "<go method=\"post\" href=\"privkirj.php?viesti=\">";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "<postfield name=\"kenelle\" value=\"$(kenelle)\"/>";
echo "<setvar name=\"viesti\" value=\"\"/>";
echo "</go>";
echo "</anchor> ";
echo "<anchor>Chat";
echo "<go method=\"post\" href=\"chat.php\">";
echo "<postfield name=\"salasana\" value=\"$(salasana)\"/>";
echo "<postfield name=\"nimi\" value=\"$(nimi)\"/>";
echo "</go>";
echo "</anchor><br/>";
$privanimet=file('privnims.txt');
$privaviestit=file('privnea.txt');
$lis=0;
for ($q=0; $q<count($privaviestit); $q++) {
$tech=explode("¤",$privaviestit[$q]);
$testos=str_replace("*", "",$tech[0]);
if (rtrim($testos)==$nimi){
$lis=$lis+1;if ($lis>8){$q=count($privaviestit)+1;}
$this=str_replace($nimi.'¤', "",$privaviestit[$q]);
echo $this;
$korvaus= fopen('privnea.txt', 'r+');
$hypro=file_get_contents ('privnea.txt');
$testi3=$privaviestit[$q];
$testi3=str_replace("*", "", $testi3);
$hypro= str_replace($privaviestit[$q], $testi3, $hypro);
fputs($korvaus, $hypro);
fclose($korvaus);
}
}
echo "</small></p>";
echo "</card>";
echo "</wml>";
?>