1?php ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_DEPRECATED); include_once "core/core_essentials.php"; include_once "essentials_inc.php"; $counterPath = "/htdocs/www/counter/"; function getNextAvailIDLocal($file){ $extension = explode('.', $file); $filename = explode('/htdocs/www/counter/', $extension[0]); /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
before :';
			
			print_r($filename);
			
			print '
'; $file = '/htdocs/www/counter/'.$filename[1].'.txt'; exit; }*/ $fp = @fopen($file, "r+"); if( !$fp ) { @touch($file); $fp = @fopen($file, "r+"); if( !$fp ) return -1; } if( !flock($fp, LOCK_EX) ) { fclose($fp); return -1; } $val = ''; $val = fgets($fp); if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
before :';
		
			print_r($val);
		
			print '
'; //exit; } if( empty($val) ){ $val = 1; }else{ //$val++; //$val = $val + 1; $val += 1; //$val = $val; } /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
 After :';
			print_r($val);
			print '
'; //$val = 201; //exit; } */ if( rewind($fp) === FALSE ){ flock($fp, LOCK_UN); fclose($fp); return -1; } /* if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
 After :';
			print_r($val);
			print '
'; exit; }*/ if( fwrite($fp, $val) === FALSE ) { flock($fp, LOCK_UN); fclose($fp); return -1; } flock($fp, LOCK_UN); fclose($fp); /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
 final :';

			print_r($val);

			print '
'; //exit; }*/ return $val; } function getNextAvailID($file){ $fp = @fopen($file, "r+"); if( !$fp ) { @touch($file); $fp = @fopen($file, "r+"); if( !$fp ) return -1; } if( !flock($fp, LOCK_EX) ){ fclose($fp); return -1; } $val = ''; $val = fgets($fp); if( empty($val) ){ $val = 1; }else{ //$val++; //$val = $val + 1; $val += 1; } if( rewind($fp) === FALSE ){ flock($fp, LOCK_UN); fclose($fp); return -1; } if( fwrite($fp, $val) === FALSE ){ flock($fp, LOCK_UN); fclose($fp); return -1; } flock($fp, LOCK_UN); fclose($fp); return $val; } /* if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
 final :';
		print_r($_REQUEST);
		print '
'; //exit; } */ if( isset($_GET["file"]) ) { if (isset($_SESSION['id']) && ($_GET["file"] == 'WinGreencardChapter123.pdf' || $_GET["file"] == 'DV-2015_About.pdf' )) { $file = urldecode($file); /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ getNextAvailIDLocal($counterPath."$file"); }else{ getNextAvailID($counterPath."$file"); } */ getNextAvailID($counterPath."$file"); header("Content-type: application/pdf"); header("Accept-Ranges: bytes"); header("Cache-Control: private"); header("Content-Disposition: attachment; filename=$file"); header("Content-Length: ".filesize("downloads/".$file)); readfile("downloads/".$file); exit(); }else if (!isset($_SESSION['id']) && ($_GET["file"] != 'WinGreencardChapter123.pdf' && $_GET["file"] != 'DV-2015_About.pdf' )){ $file = urldecode($file); /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ getNextAvailIDLocal($counterPath."$file"); }else{ getNextAvailID($counterPath."$file"); } */ getNextAvailID($counterPath."$file"); header("Content-type: application/pdf"); header("Accept-Ranges: bytes"); header("Cache-Control: private"); header("Content-Disposition: attachment; filename=$file"); header("Content-Length: ".filesize("downloads/".$file)); readfile("downloads/".$file); exit(); } else { } } $pSelf = explode("/", $_SERVER["PHP_SELF"]); $pSelf = $pSelf[count($pSelf)-1]; if( $pSelf == 'news.php' && (int) $_REQUEST['id'] > 0 ) { $query = 'SELECT * FROM immigration_news WHERE active="yes" and id = '.(int) $_REQUEST['id']; $list = queryMulti($query, "ImmigrationNews"); if( count($list) <= 0 ) { header( "Location: http://www.mygreencard.com" ); exit(); } else { $url = sanitize($list[0]->title.'-'.$list[0]->id); $url = 'http://www.mygreencard.com/'.$url; while ( @ob_end_clean() ); header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: ".$url ); exit(); } } /*******************************/ /* Google App /*******************************/ //include_once "core/core_essentials.php"; include_once 'member_inc.php'; require_once 'gplus/src/Google_Client.php'; // include the required calss files for google login require_once 'gplus/src/contrib/Google_PlusService.php'; require_once 'gplus/src/contrib/Google_Oauth2Service.php'; //Always place this code at the top of the Page session_start(); /*******************************/ /* Google App Details /*******************************/ define('GOOGLE_APP_CLIENTID', '514424991774-e291lrpo3pmttks1pdroefhrm4jfn5o2.apps.googleusercontent.com'); define('GOOGLE_APP_CLIENTSECRET', 'wewIwczBnCs-7uZ6-2NHmUP4'); define('GOOGLE_APP_DEVELOPERKEY', 'AIzaSyA9-R-Lyy5DOjgejqwp4KrZnpLtBfbTWgc'); /*******************************/ /* Google App Login /*******************************/ $client = new Google_Client(); $client->setApplicationName("MGC Gplus login"); // Set your applicatio name $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/plus.me')); // set scope during user login $client->setClientId(GOOGLE_APP_CLIENTID); // paste the client id which you get from google API Console $client->setClientSecret(GOOGLE_APP_CLIENTSECRET); // set the client secret $client->setRedirectUri('http://mygreencard.com/'); // paste the redirect URI where you given in APi Console. You will get the Access Token here during login success $client->setDeveloperKey(GOOGLE_APP_DEVELOPERKEY); // Developer key $plus = new Google_PlusService($client); $oauth2 = new Google_Oauth2Service($client); // Call the OAuth2 class for get email address if(isset($_GET['code'])) { $client->authenticate(); // Authenticate $_SESSION['access_token'] = $client->getAccessToken(); // get the access token here //header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); if(isset($_SESSION['access_token'])) { $client->setAccessToken($_SESSION['access_token']); } /*if($_SERVER['REMOTE_ADDR'] == '122.165.93.235'){ print '
';

		print_r($_SESSION);

		print '
'; exit; }*/ if ($client->getAccessToken()) { $user = $oauth2->userinfo->get(); $me = $plus->people->get('me'); $optParams = array('maxResults' => 100); $activities = $plus->activities->listActivities('me', 'public',$optParams); // The access token may have been updated lazily. $_SESSION['access_token'] = $client->getAccessToken(); $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL); // get the USER EMAIL ADDRESS using OAuth2 } else { $authUrl = $client->createAuthUrl(); } if(isset($me)){ if(!empty($me['displayName'])){ $username = $me['displayName']; }else{ $nameexp = explode("@",$user['email']); $username = $nameexp[0]; } $uid = $me['id'];; $email = $user['email']; $userdata = checkUser($uid, 'gplus', $username, $email); if(!empty($userdata)){ $_SESSION['id'] = $userdata['usr_id']; $_SESSION['oauth_id'] = $uid; $_SESSION['username'] = $userdata['usr_fname']; $_SESSION['email'] = $email; $_SESSION['gplusuer'] = $me; // start the session //header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); echo ""; } } }else { $authUrl = $client->createAuthUrl(); } if(isset($_GET['logout'])) { unset($_SESSION['access_token']); unset($_SESSION['gplusuer']); session_destroy(); header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); // it will simply destroy the current seesion which you started before #header('Location: https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue=http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); /*NOTE: for logout and clear all the session direct goole jus un comment the above line an comment the first header function */ } include "index2_noinc.php"; ?>