Skip to content

Facebook #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 45 additions & 20 deletions blitz.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,45 @@
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- &#1087;&#1086;&#1076;&#1082;&#1083;&#1102;&#1095;&#1072;&#1077;&#1084; xd_connection.js -->
<script src="//vk.com/js/api/xd_connection.js?2" type="text/javascript"></script>
<script type="text/javascript">
VK.init(function() {
VK.api('users.get', {fields: 'photo_50', https: '1'}, function(data) {
if (data.response) {
document.getElementById('users_id').value = data.response[0].id;
document.getElementById('users_name').value = data.response[0].first_name + ' ' + data.response[0].last_name;
document.getElementById('photo_url').value = data.response[0].photo_50;
}
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '398899940526365',
xfbml : true,
version : 'v2.11'
});

function onLogin(response) {
if (response.status == 'connected') {
FB.api('/me/?fields=picture,name', function(data) {
document.getElementById('users_id').value = data.id;
document.getElementById('users_name').value = data.name;
document.getElementById('photo_url').value = data.picture.data.url;
});

}, function() {
alert("ERROR");
}, '5.44');
}
}

FB.getLoginStatus(function(response) {
// Check login status on load, and if the user is
// already logged in, go directly to the welcome message.
if (response.status == 'connected') {
onLogin(response);
} else {
// Otherwise, show Login dialog first.
FB.login(function(response) {
onLogin(response);
}, {scope: 'public_profile, user_photos'});
}
});
};

(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
Expand All @@ -34,9 +59,9 @@
<td width="175"> <span onClick = 'chose_alert()' style = 'cursor: pointer'> <p class = 'text2'> Режим <img src = "img/point.png" style = "valign: bottom; margin-left: 10px"> </p> </span>
<div align = 'left' id = 'chose'>
<?php
$viewer_id = $_GET['viewer_id'];
echo "<a class = 'text3' href = 'index.php?viewer_id=".$_GET['viewer_id']."'> Классика </a> <br/>";
echo "<a class = 'text3' href = 'blitz.php?viewer_id=".$_GET['viewer_id']."'> Блиц </a> <br/>";
$viewer_id = $_GET['#users_id'];
echo "<a class = 'text3' href = 'index.php?viewer_id=".$viewer_id."'> Классика </a> <br/>";
echo "<a class = 'text3' href = 'blitz.php?viewer_id=".$viewer_id."'> Блиц </a> <br/>";
?>
</div> </td>
<td width="51"></td>
Expand Down Expand Up @@ -132,12 +157,12 @@
}
mysqli_set_charset($link, "utf8");
mysqli_select_db($link, "db");

$viewer_id = $_GET['#users_id'];

$viewer_id = $_GET['viewer_id'];

$data1 = mysqli_query($link, "SELECT * FROM `results` WHERE `id` = '$viewer_id'");
$data1 = mysqli_query($link, "SELECT * FROM `results_facebook` WHERE `id` = '$viewer_id'");
$row1 = mysqli_fetch_array($data1, MYSQLI_ASSOC);
$data2 = mysqli_query($link, "SELECT * FROM `blitz` WHERE `id` = '$viewer_id'");
$data2 = mysqli_query($link, "SELECT * FROM `blitz_facebook` WHERE `id` = '$viewer_id'");
$row2 = mysqli_fetch_array($data2, MYSQLI_ASSOC);
echo '<b>Ваш рекорд: ' . $row1[score] . ' очк. </b> в классической игре и <b>' . $row2[score] . ' очк.</b> в блиц-режиме.';
?>
Expand Down
6 changes: 3 additions & 3 deletions blitz_.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
mysqli_select_db($link, "db");

$y = 1;
$data = mysqli_query($link, "SELECT * FROM `blitz` ORDER BY score DESC, time");
$data = mysqli_query($link, "SELECT * FROM `blitz_facebook` ORDER BY score DESC, time");
echo '<table style = "font: normal normal normal 14px Comic Sans MS; color: #000000;" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top"> ';

while ($y < 7 and $row = mysqli_fetch_array($data, MYSQLI_ASSOC)){
echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
//echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
echo '<a> <strong>' . $y . '. ' .$row['name'] . '</strong><br /> ' . $row['score'] . ' очк. </a> <br />';
echo '<br / >';
$y++;
}
echo '</td> <td valign="top"> ';
while ($row = mysqli_fetch_array($data, MYSQLI_ASSOC) and $y < 13){
echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
//echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
echo '<a> <strong>' . $y . '. ' .$row['name'] . '</strong><br /> ' . $row['score'] . ' очк. </a> <br />';
echo '<br / >';
$y++;
Expand Down
11 changes: 5 additions & 6 deletions classic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<html>
<head>
<script src="//vk.com/js/api/xd_connection.js?2" type="text/javascript"></script>
<style type=”text/css”>
body {
background-color: transparent;
Expand All @@ -27,7 +26,6 @@
}

</style>

</head>

<body>
Expand All @@ -41,26 +39,27 @@
mysqli_select_db($link, "db");

$y = 1;
$data = mysqli_query($link, "SELECT * FROM `results` ORDER BY score DESC, time");
$data = mysqli_query($link, "SELECT * FROM `results_facebook` ORDER BY score DESC, time");
echo '<table style = "font: normal normal normal 14px Comic Sans MS; color: #000000;" width="100%" cellspacing="0" cellpadding="0"> <tr> <td valign="top">';

while ($y < 7 and $row = mysqli_fetch_array($data, MYSQLI_ASSOC)){
echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
//echo '<img src = ' . $row['id'] . ' id = ' . $y . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
echo '<a> <strong>' . $y . '. ' .$row['name'] . '</strong><br /> ' . $row['score'] . ' очк. за ' . $row['time'] . ' &#1089;&#1077;&#1082;&#1091;&#1085;&#1076; </a> <br />';
echo '<br / >';
$y++;
}
echo '</td> <td valign="top"> ';
while ($row = mysqli_fetch_array($data, MYSQLI_ASSOC) and $y < 13){
echo '<img src = ' . $row['photo_url'] . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
//echo '<img src = ' . $row['id'] . ' id = ' . $y . ' height="32" width="32" style="float:left; margin: 0px 6px 0px 0; border: 3px #dec9ad groove">';
echo '<a> <strong>' . $y . '. ' .$row['name'] . '</strong><br /> ' . $row['score'] . ' очк. за ' . $row['time'] . ' &#1089;&#1077;&#1082;&#1091;&#1085;&#1076; </a> <br />';
echo '<br / >';
$y++;
}
echo '</td> </tr> </table> ';

mysqli_close($link);
?>
?>

</body>
</html>

6 changes: 3 additions & 3 deletions css/style_blitz.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ a {
}

#header {
width: 953px;
height: 87px;
width: 1050px;
height: 100px;
background-image: url(../img/head.png);
padding-top: 13px;
margin-top: 0;
Expand Down Expand Up @@ -194,7 +194,7 @@ a {
position: absolute;
top: 0;
left: 0;
width: 953px;
width: 1050px;
height: 800px;
display: none;
}
Expand Down
6 changes: 3 additions & 3 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ a {
}

#header {
width: 953px;
height: 87px;
width: 1050px;
height: 100px;
background-image: url(../img/head.png);
padding-top: 13px;
margin-top: 0;
Expand Down Expand Up @@ -194,7 +194,7 @@ a {
position: absolute;
top: 0;
left: 0;
width: 953px;
width: 1050px;
height: 800px;
display: none;
}
Expand Down
8 changes: 4 additions & 4 deletions handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
mysqli_set_charset($link, "utf8");
mysqli_select_db($link, "db");

$data = mysqli_query($link, "SELECT * FROM `results` WHERE `id` = '$_POST[id]'");
$data = mysqli_query($link, "SELECT * FROM `results_facebook` WHERE `id` = '$_POST[id]'");
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
if ($row) {
if ($row['score'] < $_POST[score]) {
mysqli_query($link, "UPDATE `results` SET `score` = '$_POST[score]', `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
mysqli_query($link, "UPDATE `results_facebook` SET `score` = '$_POST[score]', `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
} else if ($row['score'] == $_POST[score] and $row['time'] > $_POST[time]) {
mysqli_query($link, "UPDATE `results` SET `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
mysqli_query($link, "UPDATE `results_facebook` SET `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
}
} else {
mysqli_query($link, "INSERT INTO `results` (`score`, `time`, `id`, `name`, `photo_url`) VALUES ('$_POST[score]', '$_POST[time]', '$_POST[id]', '$_POST[name]', '$_POST[photo_url]')") or die(mysqli_error($link));
mysqli_query($link, "INSERT INTO `results_facebook` (`score`, `time`, `id`, `name`, `photo_url`) VALUES ('$_POST[score]', '$_POST[time]', '$_POST[id]', '$_POST[name]', '$_POST[photo_url]')") or die(mysqli_error($link));
}
mysqli_close($link);
?>
10 changes: 5 additions & 5 deletions handler_blitz.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
die('Ошибка подключения (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}

mysqli_set_charset($link, "utf8");

mysqli_select_db($link, "db");

$data = mysqli_query($link, "SELECT * FROM `blitz` WHERE `id` = '$_POST[id]'");
$data = mysqli_query($link, "SELECT * FROM `blitz_facebook` WHERE `id` = '$_POST[id]'");
$row = mysqli_fetch_array($data, MYSQLI_ASSOC);
if ($row) {
if ($row['score'] < $_POST[score]) {
mysqli_query($link, "UPDATE `blitz` SET `score` = '$_POST[score]', `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
mysqli_query($link, "UPDATE `blitz_facebook` SET `score` = '$_POST[score]', `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
} else if ($row['score'] == $_POST[score] and $row['time'] > $_POST[time]) {
mysqli_query($link, "UPDATE `blitz` SET `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
mysqli_query($link, "UPDATE `blitz_facebook` SET `time` = '$_POST[time]' WHERE `id` = '$_POST[id]'");
}
} else {
mysqli_query($link, "INSERT INTO `blitz` (`score`, `time`, `id`, `name`, `photo_url`) VALUES ('$_POST[score]', '$_POST[time]', '$_POST[id]', '$_POST[name]', '$_POST[photo_url]')") or die(mysqli_error($link));
mysqli_query($link, "INSERT INTO `blitz_facebook` (`score`, `time`, `id`, `name`, `photo_url`) VALUES ('$_POST[score]', '$_POST[time]', '$_POST[id]', '$_POST[name]', '$_POST[photo_url]')") or die(mysqli_error($link));
}
mysqli_close($link);
?>
71 changes: 47 additions & 24 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,47 @@
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- подключаем xd_connection.js -->
<script src="//vk.com/js/api/xd_connection.js?2" type="text/javascript"></script>
<script type="text/javascript">
VK.init(function() {
VK.api('users.get', {fields: 'photo_50', https: '1'}, function(data) {
if (data.response) {
document.getElementById('users_id').value = data.response[0].id;
document.getElementById('users_name').value = data.response[0].first_name + ' ' + data.response[0].last_name; // replaced 'namee' with name
document.getElementById('photo_url').value = data.response[0].photo_50;
}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '398899940526365',
xfbml : true,
version : 'v2.11'
});

function onLogin(response) {
if (response.status == 'connected') {
FB.api('/me/?fields=picture,name', function(data) {
document.getElementById('users_id').value = data.id;
document.getElementById('users_name').value = data.name;
document.getElementById('photo_url').value = data.picture.data.url;
});

}, function() {
alert("ERROR");
}, '5.44');
}
}

FB.getLoginStatus(function(response) {
// Check login status on load, and if the user is
// already logged in, go directly to the welcome message.
if (response.status == 'connected') {
onLogin(response);
} else {
// Otherwise, show Login dialog first.
FB.login(function(response) {
onLogin(response);
}, {scope: 'public_profile, user_photos'});
}
});
};

(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>


<title>Set</title>
<link href="css/styles.css" rel="stylesheet">
Expand All @@ -33,9 +56,9 @@
<td width="175"> <span onClick = 'chose_alert()' style = 'cursor: pointer'> <p class = 'text2'> Режим <img src = "img/point.png" style = "valign: bottom; margin-left: 10px"> </p> </span>
<div align = 'left' id = 'chose'>
<?php
$viewer_id = $_GET['viewer_id'];
echo "<a class = 'text3' href = 'index.php?viewer_id=".$_GET['viewer_id']."'> Классика </a> <br/>";
echo "<a class = 'text3' href = 'blitz.php?viewer_id=".$_GET['viewer_id']."'> Блиц </a> <br/>";
$viewer_id = $_GET["#users_id"];
echo "<a class = 'text3' href = 'index.php?viewer_id=".$viewer_id."'> Классика </a> <br/>";
echo "<a class = 'text3' href = 'blitz.php?viewer_id=".$viewer_id."'> Блиц </a> <br/>";
?>
</div> </td>
<td width="51"></td>
Expand Down Expand Up @@ -64,7 +87,7 @@
</tr>
<tr>
<td colspan = '2' align = center>
<div id = 'butt_help' onClick = 'find_set()' onMouseOver= "newColor('butt_help')" onMouseOut = "backColor('butt_help')"> Подсказка </div>
<div id = 'butt_help' onClick = 'find_set()' onMouseOver= "newColor('butt_help')" onMouseOut = "backColor('butt_help')"> Подсказка </div>
<div onClick = 'show_results()' id = 'butt_result' onMouseOver= "newColor('butt_result')" onMouseOut = "backColor('butt_result')"> Завершить игру </div>
</td>
<td style = 'padding-left: 6px' rowspan = '2'> <img src = "img/0122.gif" height="160" width="115" onClick = "save_clicked(id)" id = 4> </td>
Expand Down Expand Up @@ -131,11 +154,11 @@
mysqli_set_charset($link, "utf8");
mysqli_select_db($link, "db");

$viewer_id = $_GET['viewer_id'];

$data1 = mysqli_query($link, "SELECT * FROM `results` WHERE `id` = '$viewer_id'");
$viewer_id = $_GET['#users_id'];
$data1 = mysqli_query($link, "SELECT * FROM `results_facebook` WHERE `id` = '$viewer_id'");
$row1 = mysqli_fetch_array($data1, MYSQLI_ASSOC);
$data2 = mysqli_query($link, "SELECT * FROM `blitz` WHERE `id` = '$viewer_id'");
$data2 = mysqli_query($link, "SELECT * FROM `blitz_facebook` WHERE `id` = '$viewer_id'");
$row2 = mysqli_fetch_array($data2, MYSQLI_ASSOC);
echo '<b>Ваш рекорд: ' . $row1[score] . ' очк. </b> в классической игре и <b>' . $row2[score] . ' очк.</b> в блиц-режиме. <br/>';
?>
Expand Down