| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/forumhet/public_html/google_login/ |
Upload File : |
<?php
define('_IN_JOHNCMS',1);
require('../incfiles/core.php');
require('../incfiles/lib/class.upload.php');
if($user_id){
header('Location: '.$home.'');
exit();
} else {
require_once ('libraries/Google/autoload.php');
$client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
$redirect_uri = $home.'/google_login/';
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->addScope("email");
$client->addScope("profile");
$service = new Google_Service_Oauth2($client);
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
exit;
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$client->setAccessToken($_SESSION['access_token']);
} else {
$authUrl = $client->createAuthUrl();
}
if (isset($authUrl)){
header('Location: '.$authUrl.'');
} else {
$g_user = $service->userinfo->get();
$g_name = @functions::check($g_user->name);
$g_picture = $g_user->picture;
$g_mail = @functions::check($g_user->mail);
$gsex = $g_user->gender;
if($gsex == 'male'){$sex = 'm';} else {$sex = 'zh';}
$pass_rand = rand(100000,999999);
$password = md5(md5($pass_rand));
$check = mysql_query("select * from `users` where `google_ID` = '".$g_user->id."'");
$check_number = mysql_num_rows($check);
if($check_number != 0){
$user_login = mysql_fetch_array($check);
$_SESSION['uid'] = $user_login['id'];
$_SESSION['ups'] = $user_login['password'];
$url = $g_picture;
if (($source = @file_get_contents($url)) == true)
{
$name = preg_replace('/([^A-Za-z0-9_\-\.]+)/i', '', $url);
$url_ext = $url;
if (($qs_ext_pos = strrpos($url, '?')) !== false) {
$url_ext = substr($url, 0, $qs_ext_pos);
}
$dot_ext_pos = strrpos($url_ext, '.');
$url_ext = strtolower(substr($url_ext, $dot_ext_pos + 1, strlen($url_ext) - $dot_ext_pos));
if (preg_match('/^(jpg|jpeg|png)$/', $url_ext)) {
$original_file = $usid . '.' . $url_ext;
$register_cover = @file_put_contents($original_file, $source);
$handle = new upload($original_file);
if ($handle->uploaded) {
// Обрабатываем фото
$handle->file_new_name_body = $user_login['id'];
//$handle->mime_check = false;
$handle->allowed = array(
'image/jpeg',
'image/gif',
'image/png'
);
$handle->file_max_size = 1024 * $set['flsz'];
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 150;
$handle->image_y = 150;
$handle->image_convert = 'png';
$handle->process('../files/users/avatar/');
if ($handle->processed) {
} else {
echo functions::display_error($handle->error);
}
$handle->clean();
}
}
}
header('Location: '.$home.'');
} else {
mysql_query("INSERT INTO `users` SET
`name` = '".$g_name."',
`name_lat` = '".$g_name."',
`imname` = '".$g_name."',
`google_ID` = '".$g_user->id."',
`google_Link` = '".$g_user->link."',
`google_Update` = '" . time() . "',
`password` = '" . mysql_real_escape_string($password) . "',
`sex` = '".$sex."',
`rights` = '0',
`ip` = '" . core::$ip . "',
`ip_via_proxy` = '" . core::$ip_via_proxy . "',
`browser` = '" . mysql_real_escape_string($agn) . "',
`datereg` = '" . time() . "',
`lastdate` = '" . time() . "',
`sestime` = '" . time() . "',
`preg` = '1',
`mail` = '".$g_mail."'
") or exit(__LINE__ . ': ' . mysql_error());
$usid = mysql_insert_id();
$_SESSION['uid'] = $usid;
$_SESSION['ups'] = $password;
$url = $g_picture;
if (($source = @file_get_contents($url)) == true)
{
$name = preg_replace('/([^A-Za-z0-9_\-\.]+)/i', '', $url);
$url_ext = $url;
if (($qs_ext_pos = strrpos($url, '?')) !== false) {
$url_ext = substr($url, 0, $qs_ext_pos);
}
$dot_ext_pos = strrpos($url_ext, '.');
$url_ext = strtolower(substr($url_ext, $dot_ext_pos + 1, strlen($url_ext) - $dot_ext_pos));
if (preg_match('/^(jpg|jpeg|png)$/', $url_ext)) {
$original_file = $usid . '.' . $url_ext;
$register_cover = @file_put_contents($original_file, $source);
$handle = new upload($original_file);
if ($handle->uploaded) {
// Обрабатываем фото
$handle->file_new_name_body = $usid;
//$handle->mime_check = false;
$handle->allowed = array(
'image/jpeg',
'image/gif',
'image/png'
);
$handle->file_max_size = 1024 * $set['flsz'];
$handle->file_overwrite = true;
$handle->image_resize = true;
$handle->image_x = 150;
$handle->image_y = 150;
$handle->image_convert = 'png';
$handle->process('../files/users/avatar/');
if ($handle->processed) {
} else {
echo functions::display_error($handle->error);
}
$handle->clean();
}
}
}
header('Location: '.$home.'');
}
}
}
?>