PageRenderTime 42ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/scotlandyardphp/header.php

http://massey-se-c-team2.googlecode.com/
PHP | 418 lines | 326 code | 78 blank | 14 comment | 17 complexity | bc334adff82b8363c963ca654dd20053 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require 'openid/openid.php';
  3. try {
  4. # Change 'localhost' to your domain name.
  5. $openid = new LightOpenID('http://www.hamte.com/scotlandyard');
  6. if(!$openid->mode) {
  7. if(isset($_POST['openid_identifier'])) {
  8. $openid->identity = $_POST['openid_identifier'];
  9. $openid->required = array( 'namePerson/friendly',
  10. 'contact/email',
  11. 'namePerson',
  12. 'birthDate',
  13. 'person/gender',
  14. 'contact/postalCode/home',
  15. 'contact/country/home',
  16. 'pref/language',
  17. 'pref/timezone',
  18. 'namePerson/first',
  19. 'namePerson/last',
  20. 'pref/language'
  21. );
  22. header('Location: ' . $openid->authUrl());
  23. }
  24. }elseif($openid->mode == 'cancel') {
  25. //echo 'User has canceled authentication!';
  26. } else {
  27. //echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
  28. if($openid->validate()){
  29. $arr = $openid->getAttributes();
  30. header('Location: connect_through_openid.php?gender=M&img=images/profile/d0.gif&userid=' . $arr['contact/email'] . '&email=' . $arr['contact/email'] . '&name=' . $arr['namePerson/first'] . ' ' . $arr['namePerson/last']);
  31. //setcookie("user", $arr['namePerson/first'], time()+3600);
  32. //setcookie("email", $arr['contact/email'], time()+3600);
  33. //header('Location: index.php');
  34. }
  35. }
  36. } catch(ErrorException $e) {
  37. echo $e->getMessage();
  38. }
  39. $email = nz($_COOKIE['email']);
  40. $img = nz($_COOKIE['img']);
  41. $f_name = nz($_COOKIE['f_name']);
  42. $l_name = nz($_COOKIE['l_name']);
  43. $n_name = nz($_COOKIE['n_name']);
  44. function nz($v,$r=''){
  45. if(isset($v) && !is_null($v)){
  46. return $v;
  47. }
  48. return $r;
  49. }
  50. header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
  51. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  52. <!--
  53. Author : Hussain Al-Mutawa
  54. Date : 02-08-2011
  55. main page for scotlandyard game
  56. -->
  57. <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
  58. <head>
  59. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  60. <title>ScotlandYard Game</title>
  61. <link href="css/jquery/alerts.css" type="text/css" rel="stylesheet" />
  62. <link href="css/ui-lightness/jquery-ui-1.8.14.custom.css" type="text/css" rel="stylesheet" />
  63. <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
  64. <style type="text/css">
  65. * {
  66. font-family: Arial,Trebuchet MS, Tahoma, Verdana, sans-serif
  67. }
  68. .divider
  69. {
  70. vertical-align:top;
  71. }
  72. .loc-icon{
  73. background-position:left;
  74. background-attachement:fixed;
  75. background-repeat:no-repeat;
  76. font-weight:normal;
  77. }
  78. .loc-icon-facebook{
  79. background-image:url(images/icons/Facebook-icon.png);
  80. }
  81. .loc-icon-facebook{
  82. background-image:url(images/icons/google-icon.png);
  83. }
  84. .mainLinks{
  85. background-color:black;
  86. padding:5pt;
  87. color:#eee;
  88. }
  89. .subLinks{
  90. background-color:grey;
  91. padding:5pt;
  92. color:#ccc;
  93. }
  94. #op1 {color:#000}
  95. #op1 a.sublink_a { color:navy }
  96. .mainLinks a,.subLinks a{
  97. color:#fff;
  98. text-decoration:none;
  99. margin:3pt;
  100. }
  101. div.mainLinks a:hover {
  102. text-decoration:underline;
  103. }
  104. div.subLinks a:hover {
  105. text-decoration:underline;
  106. }
  107. div#save_reg_result,div#login_result,div#game_result,div#whoisonline_result{
  108. background-color:rgb(230,241,243);
  109. padding:5pt;
  110. text-align:center;
  111. }
  112. thead tr td {
  113. font-weight:bold;
  114. color:green;
  115. }
  116. img.loading{
  117. vertical-align:middle;
  118. align:center;
  119. width:100%;
  120. height:100%;
  121. }
  122. div#signup_div_t{
  123. color:#ffffff;
  124. font-size:larger;
  125. font-weight:bold;
  126. background-color:rgb(100,110,230);
  127. padding:3pt;
  128. margin-top:0;
  129. margin-bottom:3px;
  130. margin-left:0;
  131. margin-right:0;
  132. }
  133. body{
  134. background-image: url(images/body-bg.png);
  135. background-attachment: scroll;
  136. background-position:top;
  137. background-repeat: repeat-x;
  138. background-color: rgb(230,241,243)
  139. }
  140. </style>
  141. <script type="text/javascript" src="js/jQuery.js"></script>
  142. <script type="text/javascript" src="js/jquery.alerts.js"></script>
  143. <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
  144. <script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
  145. <script type="text/javascript" src="js/jquery.corner.js"></script>
  146. <script src="http://jqueryui.com/ui/jquery.ui.core.js"></script>
  147. <script src="http://jqueryui.com/ui/jquery.ui.widget.js"></script>
  148. <script src="http://jqueryui.com/ui/jquery.ui.accordion.js"></script>
  149. <script type="text/javascript">
  150. //<!--
  151. jQuery.ajaxSetup({
  152. beforeSend: function() {
  153. $('#loader').show()
  154. },
  155. complete: function(){
  156. $('#loader').hide()
  157. },
  158. success: function() {}
  159. });
  160. function load_dialog(dialog){
  161. $( "#" + dialog ).css("display","normal");
  162. $( "#" + dialog ).css("visibility","visible");
  163. $( "#" + dialog ).dialog({modal:true});
  164. }
  165. function unload_dialog(dialog){
  166. $( "#" + dialog ).dialog().dialog( "destroy" );
  167. }
  168. function setCookie(c_name,value,exdays)
  169. {
  170. var exdate=new Date();
  171. exdate.setDate(exdate.getDate() + exdays);
  172. var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
  173. document.cookie=c_name + "=" + c_value;
  174. }
  175. //-->
  176. </script>
  177. </head>
  178. <body><div id="fb-root"></div>
  179. <script type="text/javascript">
  180. FB.init({
  181. appId : '196915460364965',
  182. status : true, // check login status
  183. cookie : true, // enable cookies to allow the server to access the session
  184. xfbml : true//, // parse XFBML
  185. //channelURL : 'http://www.hamte.com/scotlandyard/channel.html', // channel.html file
  186. //oauth : true // enable OAuth 2.0
  187. });
  188. function after_facebook_login(){
  189. $('#div_form').html("<span style='color:orange;padding:10pt'>"+
  190. "<img src='images/loading-2.gif' width='105' height='105' alt='loading' style='vertical-align:middle;display:inline-block' /> <strong>You are authenticated</strong> . Redirecting, just wait a second..."
  191. +"</span>");
  192. FB.getLoginStatus(function(login_status){
  193. if(login_status.session){
  194. FB.api('/me',
  195. function(user){
  196. if(user.id){
  197. FB.api(
  198. {
  199. method: 'fql.query',
  200. query: 'SELECT uid,name,email,sex FROM user WHERE uid='+user.id
  201. },
  202. function(response) {
  203. if(response[0].uid==user.id){
  204. $.get('connect_through_facebook.php?gender='+response[0].sex+'&img=https://graph.facebook.com/' + user.id + '/picture&userid='+user.id+'&name='+response[0].name+'&email='+response[0].email,
  205. function(result){
  206. if(result=='ok'){
  207. location.reload();
  208. }else{
  209. $('#div_form').html("<span style='font-size:larger;font-weight:bold;color:red'>"+result+"</span>");
  210. }
  211. }
  212. );
  213. }
  214. }
  215. );
  216. }
  217. }
  218. );
  219. }
  220. });
  221. }
  222. function getCookie(c_name)
  223. {
  224. var i,x,y,ARRcookies=document.cookie.split(";");
  225. for (i=0;i<ARRcookies.length;i++)
  226. {
  227. x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  228. y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  229. x=x.replace(/^\s+|\s+$/g,"");
  230. if (x==c_name)
  231. {
  232. return unescape(y);
  233. }
  234. }
  235. }
  236. </script>
  237. <div id="l1201" class="mainLinks">
  238. <a href="index.php">Home</a> |
  239. <a href="about.php">About</a> |
  240. <a href="bugs.php">Report a bug</a> |
  241. <a href="privacy.php">Privacy policy</a> |
  242. <a href="tac.php">Terms and conditions</a> |
  243. <a href="feedback.php">Feedback</a> |
  244. <a href="faq.php">FAQ</a> |
  245. </div>
  246. <div style="display:inline-block;vertical-align:top;float:left;margin:10pt">
  247. <a href="index.php">
  248. <img src="images/scotland-icon.gif" height="68" width="68" style="border:0px;width:68px;height:68px" alt="logo" />
  249. </a>
  250. </div>
  251. <h1 style="color: #ffffff">Welcome to ScotlandYard Game</h1>
  252. <p style="color: #ffffff">A project developed by Team 2, Software Engineering C
  253. from School of Engineering and Advanced
  254. Technology (SEAT) at Massey University in
  255. Palmerston North, New Zealand. &copy; 2011</p>
  256. <br />
  257. <div id="l1202" class="subLinks">
  258. <div id="op1" style="background-color:white;margin:0.2em;border:1px solid #eeeeee">
  259. <table width="100%">
  260. <tr>
  261. <?php
  262. if(!(isset($_COOKIE['user']) && $_COOKIE['user']!='')){
  263. ?>
  264. <td>
  265. <!--<a href="javascript:void($.get('signup.php',function(data){$('#div_form').html(data);}))">Sign Up</a> |
  266. <a href="javascript:void($.get('facebook_registeration.php',function(data){$('#div_form').html(data);}))">Facebook registeration</a> |
  267. -->
  268. <table><tr><td>
  269. Guest </td><td>|
  270. <!--
  271. <div style='background-image:url(images/facebook_button.png);background-repeat:no-repeat;background-position:top;background-attachement:fixed;height:24px;width:101px;text-align:center;padding-left:12pt;padding-top:3pt;font-weight:bold;font-family:tahoma;font-size:8pt;display:inline-block'><a href="#" onclick="$.get('facebook_registeration.php',function(data){$('#div_form').html(data);})">Register</a></div>
  272. -->
  273. <fb:login-button perms="email,user_checkins" onlogin="after_facebook_login()">Log In</fb:login-button>
  274. </td><td>
  275. <form action="" method="post">
  276. <!--
  277. <select id="openid_identifier" name="openid_identifier" >
  278. <option value="https://www.google.com/accounts/o8/id">Google</option>
  279. <option value="http://openid.yahoo.com/">Yahoo</option>
  280. <option value="http://orange.fr/">Orange</option>
  281. </select>
  282. -->
  283. <input type="hidden" value="https://www.google.com/accounts/o8/id" name="openid_identifier" id="openid_identifier" />
  284. <button>
  285. <img style="vertical-align:middle;display:block-inline" src="images/openid.png" height="20" width="20" alt="g" />
  286. <span style="font-size:9pt">Google OpenID OAuth</span>
  287. </button>
  288. </form>
  289. <!--<a href="#" onclick="FB.Connect.logout(function (){ document.location='http://www.hamte.com/scotlandyard/index.php'; });">-->
  290. </td></tr></table>
  291. <!--<a href="javascript:void($.get('login.php',function(data){$('#div_form').html(data);}))">Log In</a>-->
  292. </td><td>
  293. <?php
  294. }else{
  295. $links = "
  296. <a class='sublink_a' href='#'>test link 1</a> |
  297. <a class='sublink_a' href='#'>test link 2</a> |
  298. <a class='sublink_a' href='#'>test link 3</a>
  299. ";
  300. echo("<td>$links</td><td align='right'><span> welcome &nbsp;");
  301. ?>
  302. <div style='color:black;display:inline-block;vertical-align:middle' id="connected_status">Guest</div>
  303. <script type="text/javascript">
  304. $('#connected_status').html("<table><tr><td>" +
  305. "<img class='profile_img_of_" + getCookie('n_name') + "' height='32' width='32' src='"+ getCookie('img') +"' /></td>" +
  306. "<th>" + getCookie('n_name').replace('+',' ') +
  307. "</th><td><pre>" +
  308. " [" + getCookie('userid') + "]" +
  309. "</pre></td></tr></table>"
  310. );
  311. </script>
  312. <button onclick="$.get('logout.php',function(){location.reload()})">
  313. <img style="vertical-align:middle;display:block-inline" src="images/openid.png" height="20" width="20" alt="g" />
  314. <img id="fb_logout_image" src="http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif"
  315. style="vertical-align:middle;border: none;" alt="Connect" />
  316. </button>
  317. <?php } // end if-else ?>
  318. </td></tr></table>
  319. </div></div>
  320. <script type="text/javascript">
  321. //<!--
  322. $("button").button();
  323. $(document).ready(function(){
  324. $('#l1201').corner();
  325. $('#l1202').corner();
  326. $('#op1').corner();
  327. });
  328. //-->
  329. </script>
  330. <br />
  331. <?php
  332. if(nz($email)=='')
  333. include 'social.txt';
  334. ?>
  335. <div id="div_form" style="align:center;padding:5pt"></div>
  336. <?php
  337. function finish(){
  338. echo '</body></html>';
  339. }
  340. ?>