<?php
require_once'fun.php';
$td=date('Y-m-d');
if($td!=$conn->query('SELECT`valoare`FROM`setari`WHERE`nume`="cron_zilnic"')->fetch_row()[0])
{
$cron_zilnic='';
require'f_notificare.php';
$mesaj=$conn->query('SELECT`valoare`FROM`setari`WHERE`nume`="mesaj_aniversar"')->fetch_row()[0];
$ppl=$conn->query('SELECT`id`FROM`membrii`WHERE month(`data_nastere`)=month(curdate())&&dayofmonth(`data_nastere`)=dayofmonth(curdate())');
while($mem=$ppl->fetch_row())
{
notificare($mesaj,$mem[0]);
}
$conn->query('DELETE FROM`chat_arhiva`WHERE`data`<'.($_SERVER['REQUEST_TIME']-30*86400));
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' mesaje din arhiva de chat, ';
$conn->query('DELETE FROM`alerte`WHERE NOT`la`IN('.join(',',$id_proprietari).')&&(`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"&&`citit`>"0"||`data`<"'.($_SERVER['REQUEST_TIME']-70*86400).'"||`de`<1||`la`<1)');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' alerte, ';
$conn->query('DELETE FROM`daruri_oferite`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"&&`citit`>"0"||`data`<"'.($_SERVER['REQUEST_TIME']-70*86400).'"||`de`<1||`la`<1');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' daruri, ';
$conn->query('DELETE FROM`evenimente`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' evenimente, ';
require'f_sterg.php';
$albume_poze=0;
$albume=$conn->query('SELECT`id`,`de`FROM`galerie_albume`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-86400).'"&&`id`NOT IN(SELECT`fid`FROM`galerie_poze`)');
while($album=$albume->fetch_row())
{
sterge_album_poze($album[0],$album[1]);
$albume_poze++;
}
if($albume_poze>0)
$cron_zilnic.=$albume_poze.' albume fără poze, ';
$conn->query('DELETE FROM`grup_membrii`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-7*86400).'"&&`citit`="0"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' cereri grupuri, ';
$conn->query('DELETE FROM`istoric_browsere`WHERE`data`<'.($_SERVER['REQUEST_TIME']-(90*86400)));
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' browsere din istoric, ';
$conn->query('DELETE FROM`istoric_logari`WHERE`data`<'.($_SERVER['REQUEST_TIME']-(90*86400)));
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' logari din istoric, ';
$conn->query('DELETE FROM`istoric_vizite_profil`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-7*86400).'"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' vizitatori profil, ';
$conn->query('DELETE FROM`mesaje`WHERE NOT`la`IN('.join(',',$id_proprietari).')&&(`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"&&`citit`>"0"&&`marcat`="0"||`data`<"'.($_SERVER['REQUEST_TIME']-70*86400).'"&&`marcat`="0"||`de`<1||`la`<1)');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' mesaje, ';
$conn->query('DELETE FROM`notificari`WHERE NOT`la`IN('.join(',',$id_proprietari).')&&(`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"&&`citit`>"0"||`data`<"'.($_SERVER['REQUEST_TIME']-70*86400).'"||`de`<1||`la`<1)');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' notificari, ';
$conn->query('DELETE FROM`parole_incercate`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-30*86400).'"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' parole încercate, ';
$conn->query('DELETE FROM`prieteni`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-7*86400).'"&&`citit`="0"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' cereri în prietenie, ';
$conn->query('DELETE FROM`recupereaza`WHERE`data`<"'.($_SERVER['REQUEST_TIME']-86400).'"');
if($conn->affected_rows>0)
$cron_zilnic.=$conn->affected_rows.' sesiuni de recuperare, ';
$conn->query('UPDATE`membrii`SET`banca_lei`=banca_lei*1.'.$dobanda_banca.' WHERE`banca_lei`>100');
$conn->query('UPDATE`membrii`SET`banca_euro`=banca_euro*1.'.$dobanda_banca.' WHERE`banca_euro`>100');
$conn->query('UPDATE`membrii`SET`status`=""WHERE`status`="Status șters de administratorii '.$adresasite[2].'"');
$conn->query('UPDATE`membrii`SET`status_prieteni`=""WHERE`status_prieteni`="Status șters de administratorii '.$adresasite[2].'"');
$conn->query('UPDATE`membrii`SET`descriere`=""WHERE`descriere`="Descriere ștearsă de administratorii '.$adresasite[2].'"');
$membrii=$conn->query('SELECT`id`FROM`membrii`WHERE`id`>"0"&&`id`NOT IN('.$id_robot.','.$id_sters.','.join(',',$id_proprietari).')&&`id`NOT IN(SELECT`la`FROM`membrii_de_sters`)&&((`logat`="0"&&`lastvst`="0"&&`data`<"'.($_SERVER['REQUEST_TIME']-(15*86400)).'")||(`activitate`<"'.($_SERVER['REQUEST_TIME']-(365*3*86400)).'")||(`sterg_cont`<'.$_SERVER['REQUEST_TIME'].'&&`sterg_cont`>"0"))ORDER BY`sterg_cont`DESC,`activitate`');
while($membru=$membrii->fetch_row())
{
$conn->query('INSERT INTO`membrii_de_sters`SET`la`="'.$membru[0].'"');
}
if($meniu['baiatul_si_fata_zilei']==1)
{
if(date('G')>=0&&date('G')<=5&&$conn->query('SELECT COUNT(*)FROM`baiatul_zilei_din`WHERE`data`="'.date('Y-m-d').'"')->fetch_row()[0]==0)
{
$items=$conn->query('SELECT DISTINCT`la`FROM`baiatul_zilei`');
while($item=$items->fetch_row())
{
$conn->query('UPDATE`baiatul_zilei`SET`voturi`="'.$conn->query('SELECT COUNT(*)FROM`baiatul_zilei`WHERE`la`="'.$item[0].'"')->fetch_row()[0].'"WHERE`la`="'.$item[0].'"');
}
$items=$conn->query('SELECT DISTINCT`la`,`de`FROM`baiatul_zilei`ORDER BY`voturi`DESC LIMIT 1');
if($items->num_rows>0)
{
while($item=$items->fetch_row())
{
$cate=$conn->query('SELECT COUNT(*)FROM`baiatul_zilei`WHERE`la`="'.$item[0].'"')->fetch_row()[0];
$conn->query('INSERT INTO`baiatul_zilei_din`SET`de`="'.$item[0].'",`voturi`="'.$cate.'",`data`="'.date('Y-m-d').'"');
$conn->query('UPDATE`membrii`SET`lei`=lei+'.$lei['membru'].' WHERE`id`="'.$item[0].'"');
notificare('felicitari![br/]Ai fost desemnat ca și castigator al concursului baiatul zilei, cu un număr de [b]'.$cate.'[/b] voturi, fapt pentru care '.$adresasite[1].' te-a premiat cu [b]'.$lei['membru'].'[/b] lei!',$item[0]);
}
$conn->query('TRUNCATE TABLE`baiatul_zilei`');
}
}
if(date('G')>=0&&date('G')<=5&&$conn->query('SELECT COUNT(*)FROM`fata_zilei_din`WHERE`data`="'.date('Y-m-d').'"')->fetch_row()[0]==0)
{
$items=$conn->query('SELECT DISTINCT`la`FROM`fata_zilei`');
while($item=$items->fetch_row())
{
$conn->query('UPDATE`fata_zilei`SET`voturi`="'.$conn->query('SELECT COUNT(*)FROM`fata_zilei`WHERE`la`="'.$item[0].'"')->fetch_row()[0].'"WHERE`la`="'.$item[0].'"');
}
$items=$conn->query('SELECT DISTINCT`la`,`de`FROM`fata_zilei`ORDER BY`voturi`DESC LIMIT 1');
if($items->num_rows>0)
{
while($item=$items->fetch_row())
{
$cate=$conn->query('SELECT COUNT(*)FROM`fata_zilei`WHERE`la`="'.$item[0].'"')->fetch_row()[0];
$conn->query('INSERT INTO`fata_zilei_din`SET`de`="'.$item[0].'",`voturi`="'.$cate.'",`data`="'.date('Y-m-d').'"');
$conn->query('UPDATE`membrii`SET`lei`=lei+'.$lei['membru'].' WHERE`id`="'.$item[0].'"');
notificare('felicitari![br/]Ai fost desemnata ca și castigatoare a concursului fata zilei, cu un număr de [b]'.$cate.'[/b] voturi, fapt pentru care '.$adresasite[1].' te-a premiat cu [b]'.$lei['membru'].'[/b] lei!',$item[0]);
}
$conn->query('TRUNCATE TABLE`fata_zilei`');
}
}
}
$conn->query('TRUNCATE TABLE`ora_lei`');
$conn->query('TRUNCATE TABLE`x_0`');
$conn->query('UPDATE`setari`SET`valoare`="'.$td.'"WHERE`nume`="cron_zilnic"');
if($cron_zilnic!='')
{
$fp=fopen('log/cron_zilnic.txt','a');
fwrite($fp,'Data: '.date('d-m-Y - H:i:s').'
'.$cron_zilnic.'


');
fclose($fp);
}
###Face pink la sitemap:

function myCurl($url)
{
$ch=curl_init($url);
curl_setopt($ch,CURLOPT_TIMEOUT,5);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_exec($ch);
$text=curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return$text;
}
$sitemapUrl1=$adresasite[0].'/sitemap.xml';
echo'<p>Google Sitemaps has been pinged (return code: '.myCurl('http://google.com/webmasters/sitemaps/ping?sitemap='.$sitemapUrl1).').</p><p>Bing / MSN Sitemaps has been pinged (return code: '.myCurl('http://bing.com/webmaster/ping.aspx?siteMap='.$sitemapUrl1).').</p>';

}
unset($td,$mesaj,$albume_poze,$cate,$cron_zilnic,$fp,$sitemapUrl1);
###require'f_fun.php';