/Control/Notification.php
PHP | 187 lines | 148 code | 9 blank | 30 comment | 24 complexity | 8f6ac77e90b6a623c793b20d095d0c8a MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- require '../Model/Connect.php';
- require_once('PHPMailer/class.phpmailer.php');
- require_once('RegisterLogic.php');
- ob_start();
- ?>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Online Chess Portal </title>
- <!-- CSS Files -->
- <link href="css/sticky.full.css" rel="stylesheet" type="text/css" />
- <link href="css/reset.css" rel="stylesheet" type="text/css" />
- <link href="css/Form.css" rel="stylesheet" type="text/css" />
- <link href="css/style.css" rel="stylesheet" type="text/css" />
- <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen" />
- <link rel="stylesheet" type="text/css" href="css/jquery.gritter.css" />
- <!-- End of CSS Files -->
- <!-- Javascript Files -->
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
- <script type="text/javascript" src="javascript/jquery.cycle.all.js"></script>
- <script type="text/javascript" src="javascript/superfish.js"></script>
- <script type="text/javascript" src="javascript/dd.min.js"></script>
- <script type="text/javascript" src="javascript/popup-window.js"></script>
- <script type="text/javascript" src="javascript/wufoo.js"></script>
- <script type="text/javascript" src="js/sticky.full.js"></script>
- <script type="text/javascript" src="http://www.google.com/jsapi"></script>
- <script type="text/javascript">google.load('jquery', '1.5');</script>
- <script type="text/javascript" src="js/jquery.gritter.js"></script>
-
- <script type="text/javascript">
- function popups(x, id, type) {
- $.extend($.gritter.options, {
- class_name: 'gritter-light', // for light notifications (can be added directly to $.gritter.add too)
- position: 'bottom-right', // possibilities: bottom-left, bottom-right, top-left, top-right
- fade_in_speed: 100, // how fast notifications fade in (string or int)
- fade_out_speed: 100, // how fast the notices fade out
- time: 3000 // hang on the screen for...
- });
-
- $.gritter.add({
- // (string | mandatory) the heading of the notification
- title: 'Notification!',
- // (string | mandatory) the text inside the notification
- text: x,
- // (string | optional) the image to display on the left
- image: '../View/images/NotifyIcon.png',
- // (bool | optional) if you want it to fade out on its own or just sit there
- sticky: false,
- // (function) before the gritter notice is opened
- before_open: function(){
- if($('.gritter-item-wrapper').length == 2)
- {
- // Returning false prevents a new gritter from opening
- return false;
- }
- },
- after_open: function(e){
- if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
- xmlhttp=new XMLHttpRequest();
- } else {// code for IE6, IE5
- xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
- }
- xmlhttp.onreadystatechange=function() {
- if (xmlhttp.readyState==4 && xmlhttp.status==200) {
- //alert(xmlhttp.responseText);
- }
- }
- xmlhttp.open("GET","../Control/ChangeNotifyStatus.php?Id="+id+"&Type="+type,true);
- xmlhttp.send();
- },
- });
-
- return false;
- }
- </script>
- <!-- End of Javascript Files -->
- </head>
- <body>
- </body>
- </head>
- <?php
- /*DeleteExpired();
- $Script = CheckNotification($Username);
- echo $Script;*/
- //echo '<script type="text/javascript"> popups() </script>';
- if(GameNotify($_SESSION['username']) || MsgNotify($_SESSION['username'])) {
- return true;
- } else {
- return false;
- }
-
- function GameNotify($Username) {
- //echo '<script language="javascript">alert("game")</script>';
- //echo '<script language="javascript">alert("'.$Username.'")</script>';
- $QueryTo = "SELECT * FROM `user` WHERE `us_username` ='".$Username."'";
-
- if($QueryToRun = mysql_query($QueryTo)) {
- if (mysql_num_rows($QueryToRun) == 1) {
- $ToId = mysql_result ($QueryToRun, 0, 'us_id');
- }
- }
-
- $Query = "SELECT *, TIMEDIFF(ADDTIME( ga_datecreated, '5:0:0' ), NOW()) AS ga_timediff FROM `games` WHERE ga_blackplayer = '".$ToId."' AND ga_notified = 1";
- if($QueryRun = mysql_query($Query)) {
- $QueryNumRows = mysql_num_rows ($QueryRun);
- //echo '<script language="javascript">alert("'.$QueryNumRows.'")</script>';
- if($QueryNumRows == 0) {
- return false;
- } else {
-
- //$Code = '';
- while($info = mysql_fetch_assoc($QueryRun)) {
- $Id = $info['ga_gameid'];
- $From = $info['ga_whiteplayer'];
- $Time = $info['ga_datecreated'];
- $TimeDiff = $info['ga_timediff'];
- $Query1 = "SELECT * FROM `memberprofile`, `user` WHERE mp_username = us_username AND us_id = '".$info['ga_whiteplayer']."'";
- if($Query1Run = mysql_query($Query1)) {
- while($info1 = mysql_fetch_assoc($Query1Run)) {
- $From = $info1['mp_fullname'];
- }
- }
- $Text = '<li><a href="../View/Play.php">From '.$From.' </br>Sent at '.$Time.'</a></li>';
- //$Code .= $Text;
- //echo $Text;
- //echo '<script type="text/javascript"> popups('.json_encode($Text).') </script>';
- ?>
- <script type="text/javascript">
- text = <?php echo json_encode($Text); ?>;
- id = <?php echo json_encode($Id); ?>;
- popups(text,id, 'Game');
- </script>
- <?php
- //ChangeNotifyStatus($Id);
- }
- //echo $Code;
- //echo '<script type="text/javascript"> popups('.$Code.') </script>';
- }
- } else {
- return false;
- }
- }
-
- function MsgNotify($Username) {
- //echo '<script language="javascript">alert("msg")</script>';
- $Query1 = "SELECT * FROM `notify` WHERE no_to = '".$Username."' AND no_notified = 1";
- if($Query1Run = mysql_query($Query1)) {
- $Query1NumRows = mysql_num_rows ($Query1Run);
- //echo '<script language="javascript">alert("'.$Query1NumRows.'")</script>';
- if($Query1NumRows == 0) {
- return false;
- } else {
- //$Code = '';
- while($info = mysql_fetch_assoc($Query1Run)) {
- $Id = $info['no_id'];
- $Query1 = "SELECT * FROM `memberprofile` WHERE mp_username = '".$info['no_from']."'";
- if($Query1Run = mysql_query($Query1)) {
- while($info1 = mysql_fetch_assoc($Query1Run)) {
- $From = $info1['mp_fullname'];
- }
- }
- $Text = '<li><a href="../View/Inbox.php">You have received a new message.</br> From '.$From.'</a></li>';
- //$Code .= $Text;
- //echo $Text;
- //echo '<script type="text/javascript"> popups('.json_encode($Text).') </script>';
- ?>
- <script type="text/javascript">
- text = <?php echo json_encode($Text); ?>;
- id = <?php echo json_encode($Id); ?>;
- popups(text,id, 'Msg');
- </script>
- <?php
- //ChangeNotifyStatus($Id);
- }
- //echo $Code;
- //echo '<script type="text/javascript"> popups('.$Code.') </script>';
- }
- } else {
- return false;
- }
- }
- ?>