<?php
require'f_anagrame.php';
require'f_conectare.php';
conectare('Anagrame','joaca-anagrame');
if($de>0)
{
require'f_refresh.php';
$head[4]=refresh('/joaca-anagrame');
}
$titlu='Anagrame';
require'f_tabelare.php';
require'f_sus.php';
$anagrame=$conn->query('SELECT`valoare1`,`valoare2`FROM`setari_jocuri`WHERE`nume`="anagrame2"')->fetch_row();
$actiune='';
if($anagrame[0]<$_SERVER['REQUEST_TIME']&&$anagrame[1]!=0)
{
if($anagrame[1]!=0)
$actiune=3;
}
else
{
if($anagrame[1]==0&&($anagrame[0]-$_SERVER['REQUEST_TIME']<0))
$actiune=0;
if($anagrame[1]==1&&($anagrame[0]-$_SERVER['REQUEST_TIME']<120))
$actiune=1;
if($anagrame[1]==2&&($anagrame[0]-$_SERVER['REQUEST_TIME']<60))
$actiune=2;
if($anagrame[1]==3&&($anagrame[0]-$_SERVER['REQUEST_TIME']<0))
$actiune=3;
}
if($anagrame[0]==0)
$actiune=0;
switch($actiune)
{
case'0':
$cuvant=$conn->query('SELECT`id`,`cuvant`,`cid`,`de`FROM`anagrame_cuvinte`WHERE`valid`>0 ORDER BY RAND() LIMIT 1')->fetch_row();
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="32",`valoare2`="'.$cuvant[0].'"WHERE`nume`="anagrame1"');
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`text`="[b]'.str_shuffle(mb_strtolower($cuvant[1])).'[/b][br/]Categoria: [b]'.$conn->query('SELECT`nume`FROM`anagrame_categorii`WHERE`id`="'.$cuvant[2].'"')->fetch_row()[0].'[/b][br/]Ajutor: [span]'.preg_replace('/[a-z0-9]/i','*',$cuvant[1]).'[/span]'.($cuvant[3]!=$id_robot&&$cuvant[3]>0?'[br/]Cuvânt adăugat de '.nume($cuvant[3],1):'').'",`de`="0"');
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="'.($_SERVER['REQUEST_TIME']+180).'",`valoare2`="1"WHERE`nume`="anagrame2"');
break;
case'1':
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="16"WHERE`nume`="anagrame1"');
$cuvant=$conn->query('SELECT`cuvant`,`cid`FROM`anagrame_cuvinte`WHERE`id`="'.$conn->query('SELECT`valoare2`FROM`setari_jocuri`WHERE`nume`="anagrame1"')->fetch_row()[0].'"')->fetch_row();
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`text`="[b]'.str_shuffle(mb_strtolower($cuvant[0])).'[/b][br/]Categoria: [b]'.$conn->query('SELECT`nume`FROM`anagrame_categorii`WHERE`id`="'.$cuvant[1].'"')->fetch_row()[0].'[/b][br/]Ajutor 2: [span]'.$cuvant[0][0].mb_substr(preg_replace('/[a-z0-9]/i','*',$cuvant[0]),1).'[/span]",`de`="0"');
$conn->query('UPDATE`setari_jocuri`SET`valoare2`="2"WHERE`nume`="anagrame2"');
break;
case'2':
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="8"WHERE`nume`="anagrame1"');
$cuvant=$conn->query('SELECT`cuvant`,`cid`FROM`anagrame_cuvinte`WHERE`id`="'.$conn->query('SELECT`valoare2`FROM`setari_jocuri`WHERE`nume`="anagrame1"')->fetch_row()[0].'"')->fetch_row();
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`text`="[b]'.str_shuffle(mb_strtolower($cuvant[0])).'[/b][br/]Categoria: [b]'.$conn->query('SELECT`nume`FROM`anagrame_categorii`WHERE`id`="'.$cuvant[1].'"')->fetch_row()[0].'[/b][br/]Ajutor 3: [span]'.$cuvant[0][0].mb_substr(preg_replace('/[a-z0-9]/i','*',$cuvant[0]),1,-1).$cuvant[0][-1].'[/span]",`de`="0"');
$conn->query('UPDATE`setari_jocuri`SET`valoare2`="3"WHERE`nume`="anagrame2"');
break;
case'3':
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`text`="Timpul a expirat :(, răspunsul corect era: [b]'.$conn->query('SELECT`cuvant`FROM`anagrame_cuvinte`WHERE`id`="'.$conn->query('SELECT`valoare2`FROM`setari_jocuri`WHERE`nume`="anagrame1"')->fetch_row()[0].'"')->fetch_row()[0].'[/b].[br/]Următorul cuvânt peste [b]10[/b] secunde.",`de`="0"');
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="'.($_SERVER['REQUEST_TIME']+10).'",`valoare2`="0"WHERE`nume`="anagrame2"');
break;
}
function caractere_anagrame($text)
{
return str_replace(['ă','â','î','ș','ş','ț','ţ'],['a','a','i','s','s','t','t'],mb_strtolower($text));
}
$raspuns=caractere_anagrame($conn->query('SELECT`cuvant`FROM`anagrame_cuvinte`WHERE`id`="'.$conn->query('SELECT`valoare2`FROM`setari_jocuri`WHERE`nume`="anagrame1"')->fetch_row()[0].'"')->fetch_row()[0]);
$pmtext=caractere_anagrame($pmtext);
if($pmtext==$raspuns&&$anagrame[1]!=0)
{
$puncte=$conn->query('SELECT`valoare1`FROM`setari_jocuri`WHERE`nume`="anagrame1"')->fetch_row()[0];
$conn->query('UPDATE`membrii`SET`anagrame`=anagrame+'.$puncte.' WHERE`id`="'.$de.'"');
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`data`="'.$_SERVER['REQUEST_TIME'].'",`text`="Felicitări [b]'.nume($de,1).'[/b]!-bravo-[br/]Raspunsul corect era: [b]'.$raspuns.'[/b], ai câștigat [b]'.$puncte.'[/b] puncte Anagrame, și ai în total [b]'.number_format($conn->query('SELECT`anagrame`FROM`membrii`WHERE`id`="'.$de.'"')->fetch_row()[0]).'[/b] puncte Anagrame![br/]Următorul cuvânt în [b]10[/b] secunde.",`de`="0"');
$conn->query('INSERT INTO`evenimente`SET`text`="a scris un răspuns la Anagrame",`de`="'.$de.'",`data`="'.$_SERVER['REQUEST_TIME'].'"');
$conn->query('UPDATE`setari_jocuri`SET`valoare1`="'.($_SERVER['REQUEST_TIME']+10).'",`valoare2`="0"WHERE`nume`="anagrame2"');
}
if(!empty($pmtext)&&$pmtext!=$conn->query('SELECT`text`FROM`anagrame_raspunsuri`WHERE`de`="'.$de.'"ORDER BY`data`DESC LIMIT 1')->fetch_row()[0])
{
require'f_mut.php';
require'f_blocat.php';
if(blocat($pmtext))
{
$tip='mesaj Anagrame';
$text=$pmtext;
require'f_ban.php';
}
$conn->query('INSERT INTO`anagrame_raspunsuri`SET`de`="'.$de.'",`text`="'.$pmtext.'",`data`="'.$_SERVER['REQUEST_TIME'].'"');
$conn->query('INSERT INTO`evenimente`SET`text`="a scris un răspuns la Anagrame",`de`="'.$de.'",`data`="'.$_SERVER['REQUEST_TIME'].'"');
$conn->query('UPDATE`membrii`SET`mesaje_chat`=mesaje_chat+1 WHERE`id`="'.$de.'"');
}
require'f_filtru.php';
echo$div[10].filtru($conn->query('SELECT`text`FROM`anagrame_raspunsuri`WHERE`de`="0"ORDER BY`data`DESC LIMIT 1')->fetch_row()[0]).$div[0].$div[1].'[<a href="/scrie-mesaj-anagrame">Scrie</a>] [<a href="/joaca-anagrame">reîncarcă</a>] [<a href="/conectati/categorie/anagrame">conectați</a> <strong>'.number_format($conn->query('SELECT COUNT(*)FROM`anagrame_conectati`')->fetch_row()[0]).'</strong>]';
$alerte_necitite=$conn->query('SELECT COUNT(*)FROM`alerte`WHERE`citit`="0"&&`la`="'.$de.'"')->fetch_row();
if($alerte_necitite[0]>0)
echo' [<a href="/dialog-alerte/tip/primite">alerte noi</a> <strong>'.$alerte_necitite[0].'</strong>]';
echo$div[0];
require'f_profil.php';
$postari=$conn->query('SELECT`de`,`text`FROM`anagrame_raspunsuri`WHERE`de`>"0"ORDER BY`data`DESC LIMIT 10');
$elemente=$postari->num_rows;
if($elemente>0)
echo'<table'.$clasa_tabel.'>';
$cou=0;
while($postare=$postari->fetch_row())
{
$cou++;
echo'<tr><td'.$clasa_kk.'><a href="/profil-membru/la/'.$postare[0].'-'.seo(nume($postare[0],1)).'">'.avatar($postare[0]).'</a></td><td'.$clasa_k.'>'.$clasa_n.profil($postare[0]).$div[0].($is_pc=='1'?'':'<div class="'.($cou%2?'verde':'orange').'">').filtru($postare[1]).$div[0].'</td></tr>';
}
if($elemente>0)
echo'</table>';
echo$div[1].'<a href="/top-anagrame">'.img('topuri.gif',2).'Top Anagrame</a>'.$div[0].$div[1].'<a href="/adauga-cuvinte-anagrame"><img src="'.$domenii_statice[1].'adauga.gif" alt="" />Adaugă cuvinte Anagrame</a>'.$div[0].$div[1].'<a href="/cuvinte-anagrame">Cuvinte Anagrame</a> <strong>'.number_format($conn->query('SELECT COUNT(*)FROM`anagrame_cuvinte`WHERE`valid`>"0"')->fetch_row()[0]).'</strong>'.$div[0];
if($perm>0)
echo$div[1].'<a href="/admin-categorii-anagrame">'.img('administrare.png',1).'Administreaza categorii anagrame</a>'.$div[0];
require'f_jos.php';