// *************************** OBSAH **************************
if ($_GET['view']!='HELP') echo '
'.$lang['DEMO'].'
';
if ($_GET['view']!='PLAYER' && $_GET['view']!='HELP') {echo '
'.$lang[$_GET['view']].'
';} else {echo ' ';}
if ($EDIT_PLAYER>-1){
echo '';
if ($COUNTDOWN>-1){
echo $lang['MY:LOGIN_EXPIRE'].' '.msToText($COUNTDOWN*1000,false).' ';
}
echo ' '.$lang['MY:LOGOUT'].'';
}
// ******************************************************************************
if ($_GET['view']=='CUBE'){?>
Scanning Paused
// ******************************************************************************
}elseif ($_GET['view']=='PLAYERS'){
if (!isset($_GET['search'])) $_GET['search']='';
if (isset($_GET['player_serial'])){
$result = dotazSQL("SELECT * FROM `sc_profiles` WHERE CONCAT(serial,'_',profile)='".$_GET['player_serial']."'");
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if (mysql_num_rows($result)==1) $_GET['player_id']=$row['id'];
}
$where='';
if ($_GET['search']!=''){
$_GET['search']=trim(str_replace(' ;',";",$_GET['search']));
$_GET['search']=str_replace('; ',";",$_GET['search']);
$where="nick like '%".str_replace(';',"%' or nick like '%",$_GET['search'])."%'";
$where.=" or CONCAT(serial,'_',profile) like '%".str_replace(';',"%' or CONCAT(serial,'_',profile) like '%",$_GET['search'])."%'";
$where="AND (".$where.")";
//$where="AND (nick like '%".$_GET['search']."%' or CONCAT(serial,'_',profile) like '%".$_GET['search']."%')";
}
$sort='';
if (isset($_GET['sort'])) {
if ($_GET['sort']=='HOF') $sort='hof_points desc, hof_rank,';
if ($_GET['sort']=='NICK') $sort='nick,serial,';
if ($_GET['sort']=='SERIAL') $sort='serial,profile,';
if ($_GET['sort']=='MEDAL') $sort='medal, hof_points desc,';
}else{
$_GET['sort']="LAST";
}
if ($EDIT_PLAYER>-1){
if (isset($_POST['addfriend'])){
$resultFRE = dotazSQL("SELECT serial, profile FROM `sc_profiles` WHERE id='".intval($_POST['addfriend'])."'");
$rowFRE = mysql_fetch_array($resultFRE, MYSQL_ASSOC);
dotazSQL("INSERT IGNORE INTO sc_friends (id_profile, friend_serial, friend_profile) VALUES ('".$EDIT_PLAYER."', '".$rowFRE['serial']."',".$rowFRE['profile'].')');
}
}
//Pocet zaznamu
$zaznamu_na_stranku=30;
/*if (isset($_GET['player_id'])){ //Kdyz ma zobrazit hrace, zjisti na ktere strance je
$result = dotazSQL("SELECT * FROM sc_profiles WHERE active=1 ".$where);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$_GET['side']=intval(1+($row['rank']-1)/$zaznamu_na_stranku); //&side='.intval(1+($row['rank']-1)/80).
//if (mysql_num_rows($result)==1) $_GET['player_id']=$row['id'];
} */
//side
if (!isset($_GET['side'])) $_GET['side']=1;
if ($_GET['side']<1) $_GET['side']=1;
$poc=0;
if (!isset($_GET['player_id'])) $_GET['player_id']=-1;
$result = dotazSQL("SELECT COUNT(*) FROM sc_profiles WHERE active=1 ".$where);
$pocet_zaznamu=mysql_result($result, 0);
$FRIE="";
if ($EDIT_PLAYER>-1) $FRIE=", (SELECT count(*) FROM sc_friends WHERE id_profile=".$EDIT_PLAYER." AND sc_profiles.serial=sc_friends.friend_serial AND sc_profiles.profile=sc_friends.friend_profile) as friend";
$result = dotazSQL("SELECT *, IFNULL((SELECT CONCAT(GROUP_CONCAT(rank ORDER BY rank SEPARATOR ',' ) ,',x') FROM sc_scores_best LEFT JOIN sc_games ON sc_games.id=sc_scores_best.id_game WHERE rank<5 AND public=0 AND sc_profiles.id=sc_scores_best.id_profile),'x') as medal". $FRIE." FROM sc_profiles WHERE active=1 ".$where." ORDER BY ".$sort."last_upload desc, serial, profile limit ".(($_GET['side']-1)*$zaznamu_na_stranku).",".$zaznamu_na_stranku);
//Next/Prev side
echo ""; //SEM NAJEDE PO NACTENI STRANKY
echo '';
echo '';
?>
// ******************************************************************************
}elseif ($_GET['view']=='GAMES'){
$poc=0;
//$result = dotazSQL("SELECT *, MAX(score) as top_score FROM sc_scores INNER JOIN sc_profiles ON sc_scores.id_profile=sc_profiles.id RIGHT OUTER JOIN sc_games ON sc_scores.id_game=sc_games.id GROUP BY hash ORDER BY score desc");
//$result = dotazSQL("SELECT * FROM sc_scores_best INNER JOIN sc_games ON sc_scores_best.id_game=sc_games.id GROUP BY hash ORDER BY score desc");
$result = dotazSQL("SELECT *,sc_games.id as id_game_ok FROM sc_scores_best RIGHT OUTER JOIN sc_games ON sc_scores_best.id_game=sc_games.id and rank between 1 AND 3 WHERE public <8 ORDER BY public, script_name, game_ver,id_game,rank");
echo '
';
echo '
'.$lang['TAB:NAME'].'
'.$lang['TAB:TOP_SCORE'].'
';
$id_game_pred='';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($id_game_pred==$row['id_game_ok']){
/*echo '
';
// ******************************************************************************
}elseif ($_GET['view']=='PLAYER' || $_GET['view']=='MY_PROFILE'){
echo ""; //SEM NAJEDE PO NACTENI STRANKY
if ($_GET['view']=='MY_PROFILE'){ // ****** view=MY_PROFILE
if ($EDIT_PLAYER>-1 && isset($_POST['id'])){
if ($_POST['id']==$EDIT_PLAYER){ // V PORADKU
if (isset($_POST['save_user'])){ // ******** ULOZ DATA **********
//echo 'Data uložena';
//HIST (0,'sc_games',"id",$_POST['id']);
$_POST['about'] = strip_tags($_POST['about'], '
');
$_POST['city'] = strip_tags($_POST['city'], '');
dotazSQL("UPDATE sc_profiles SET country='$_POST[country]',
city='$_POST[city]',
born='$_POST[born]',
sex='$_POST[sex]',
about='$_POST[about]'
WHERE id=".$EDIT_PLAYER);
//RebuildBestScores();
}
if (isset($_POST['send_mail_on'])) $result = dotazSQL("UPDATE sc_profiles SET send_mail=1 WHERE id=".$EDIT_PLAYER);
if (isset($_POST['send_mail_off'])) $result = dotazSQL("UPDATE sc_profiles SET send_mail=0 WHERE id=".$EDIT_PLAYER);
if (isset($_POST['mail_newsletter_on'])) $result = dotazSQL("UPDATE sc_profiles SET mail_newsletter=1 WHERE id=".$EDIT_PLAYER);
if (isset($_POST['mail_newsletter_off'])) $result = dotazSQL("UPDATE sc_profiles SET mail_newsletter=0 WHERE id=".$EDIT_PLAYER);
if (isset($_POST['remove_login'])){ // ******** SMAZE MAIL **********
dotazSQL("UPDATE sc_profiles SET
pass=NULL,
mail_verified=NULL,
send_mail=0
WHERE id=".$EDIT_PLAYER);
}
if (isset($_POST['remove_friend'])){
dotazSQL("DELETE FROM sc_friends WHERE id_profile='".$EDIT_PLAYER."' AND CONCAT(friend_serial,'_',friend_profile)='".$_POST['remove_friend']."'");
}
if (isset($_POST['create_login'])){ // ******** OVER MAIL **********
function check_email($email) {
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // znaky tvorící uživatelské jméno
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // jedna komponenta domény
return preg_match("(^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$)i", $email);
}
$_POST['mail']=strtolower($_POST['mail']);
// KONTROLA MAILU
if (!check_email($_POST['mail'])){
$msg_mail=$lang['MAIL_MSG:ERR'];
}
if (mysql_num_rows(dotazSQL("SELECT mail FROM `sc_profiles` WHERE mail='".$_POST['mail']."' AND id<>".$EDIT_PLAYER))!=0){
$msg_mail=$lang['MAIL_MSG:EXIST'];
}
// KONTROLA HESLA
if (strlen($_POST['pass'])<5){
$msg_pass=$lang['MAIL_MSG:PASS_SHORT'];
}
//ULOZI MAIL A HESLO, POSLE MAIL
if ($msg_mail=='' && $msg_pass==''){
function generateRandomString($length = 50) {
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length);
//return bin2hex(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $mail_aes128_init_iv_key,$EDIT_PLAYER , MCRYPT_MODE_ECB));
}
$randomtxt=generateRandomString();
dotazSQL("UPDATE sc_profiles SET
mail='".$_POST['mail']."',
pass_no_verify='".crypt($_POST['pass'],$EDIT_PLAYER)."',
mail_verified='$randomtxt'
WHERE id=".$EDIT_PLAYER);
$resultMAIN = dotazSQL("SELECT * FROM `sc_profiles` WHERE id=".$EDIT_PLAYER);
$rowMAIN = mysql_fetch_array($resultMAIN, MYSQL_ASSOC);
$lng_html=($lng=='en' ? '' : $lng.'/');
$lng_html=str_replace('cz','cs',$lng_html);
$odkaz_mail='http://www.futurocube.com/'.$lng_html.'score/?mailverify='.$randomtxt.'&mail='.$rowMAIN['mail'];
//$zprava = "Zažádali jste na serveru $_SERVER[SERVER_NAME] o ověření e-mailové adresy, to učiníte navštívením tohoto odkazu:$odkaz_mail Pokud o služby serveru zájem nemáte, tak tuto zprávu prosím ignorujte.";
$zprava = ''.sprintf($lang['MAIL_VERIFY:BODY'],$rowMAIN['nick'],$rowMAIN['serial'].'_'.$rowMAIN['profile'],$odkaz_mail).'';
/*$hlavicky = "MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit";
mail($_POST["mail"], "Overeni adresy", $zprava, $hlavicky);*/
SendMail($_POST['mail'], $lang['MAIL_VERIFY:SUBJECT'], $zprava);
}
}
}
}
$resultMAIN = dotazSQL("SELECT * FROM `sc_profiles` WHERE id=".$EDIT_PLAYER);
if (mysql_num_rows($resultMAIN)!=1){
if (isset($_COOKIE['logmail'])) $logmail=$_COOKIE['logmail'];
if (isset($_POST['logmail'])) $logmail=$_POST['logmail'];
if (!isset($logmail)) $logmail='';
if (isset($msg_login)) echo ''.$msg_login;
echo ' ';
if ($EVO) echo 'Připojit kostku';
echo '
'.$lang['HOW_EDIT_PROFILE'].'
';
echo '';
exit;
}
}else{ // *************** view=PLAYER
if (isset($_GET['player_serial'])){
$resultMAIN = dotazSQL("SELECT * FROM `sc_profiles` WHERE CONCAT(serial,'_',profile)='".$_GET['player_serial']."'");
}else{
if (isset($_GET['player_id'])){
$resultMAIN = dotazSQL("SELECT * FROM `sc_profiles` WHERE id=".$_GET['player_id']);
}else{
echo $lang['NO_PLAYER'].'