Ver Fonte

Fixing PHP warnings.

Julio Montoya há 11 anos atrás
pai
commit
f7ebd14fe4

+ 1 - 2
main/chat/chat.php

@@ -48,9 +48,8 @@ $cidreq = Security::remove_XSS($_GET['cidReq']);
 
 ?>
 <!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
+<meta charset="<?php echo api_get_system_encoding(); ?>" />
 <?php
 echo'<title>'.get_lang('Chat').' - '.$mycourseid.' - '.api_get_setting('siteName').'</title>';
 

+ 2 - 2
main/chat/chat_chat.php

@@ -132,10 +132,10 @@ if (!empty($course)) {
 	array_splice($content, 0, $remove);
 	require 'header_frame.inc.php';
 
-	if ($_GET['origin'] == 'whoisonline') {  //the caller
+	if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonline') {  //the caller
 		$content[0] = get_lang('CallSent').'<br />'.$content[0];
 	}
-	if ($_GET['origin'] == 'whoisonlinejoin') {   //the joiner (we have to delete the chat request to him when he joins the chat)
+	if (isset($_GET['origin']) && $_GET['origin'] == 'whoisonlinejoin') {   //the joiner (we have to delete the chat request to him when he joins the chat)
 		$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
 		$sql = "UPDATE $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = ".$_user['user_id'].")";
 		$result = Database::query($sql);

+ 17 - 16
main/chat/chat_hidden.php

@@ -34,8 +34,8 @@ $isMaster = (bool)$is_courseAdmin;
 
 $date_now = date('Y-m-d');
 
-$group_id = intval($_SESSION['_gid']);
-$session_id = intval($_SESSION['id_session']);
+$group_id = api_get_group_id();
+$session_id = api_get_session_id();
 $session_condition = api_get_session_condition($session_id);
 $group_condition = " AND to_group_id = '$group_id'";
 
@@ -68,7 +68,7 @@ if (!empty($group_id)) {
 	$basename_chat = 'messages-'.$date_now;
 }
 
-$chat_size_old = intval($_POST['chat_size_old']);
+$chat_size_old = isset($_POST['chat_size_old']) ? intval($_POST['chat_size_old']) : null;
 
 $file = $chat_path.$basename_chat.'.log.html';
 $chat_size_new = 0;
@@ -92,7 +92,7 @@ Database::query($query);
 $query = "SELECT COUNT(user_id) FROM $tbl_chat_connected WHERE last_connection>'".date('Y-m-d H:i:s',time()-60*5)."' $extra_condition";
 $result = Database::query($query);
 
-$connected_old = intval($_POST['connected_old']);
+$connected_old = isset($_POST['connected_old']) ? intval($_POST['connected_old']) : null;
 list($connected_new) = Database::fetch_row($result);
 /*disconnected user of chat*/
 disconnect_user_of_chat ();
@@ -104,16 +104,17 @@ require 'header_frame.inc.php';
 </form>
 <?php
 
-if ($_SESSION["origin"] == 'whoisonline') {  //check if our target has denied our request or not
-	$talk_to = $_SESSION["target"];
-	$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
-	$sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
-	$result = Database::query($sql);
-	$row = Database::fetch_array($result);
-	if ($row['chatcall_text'] == 'DENIED') {
-		echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
-		$sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
-		$result = Database::query($sql);
-	}
+if (isset($_SESSION["origin"]) && $_SESSION["origin"] == 'whoisonline') {
+    //check if our target has denied our request or not
+    $talk_to = $_SESSION["target"];
+    $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
+    $sql = "select chatcall_text from $track_user_table where ( user_id = $talk_to )";
+    $result = Database::query($sql);
+    $row = Database::fetch_array($result);
+    if ($row['chatcall_text'] == 'DENIED') {
+        echo "<script language=\"javascript\" type=\"text/javascript\"> alert('".get_lang('ChatDenied')."'); </script>";
+        $sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='' WHERE (user_id = $talk_to)";
+        $result = Database::query($sql);
+    }
 }
-require 'footer_frame.inc.php';
+require 'footer_frame.inc.php';

+ 1 - 1
main/chat/chat_message.php

@@ -250,7 +250,7 @@ if (!empty($course) && !empty($_user['user_id'])) {
 		echo  "<a href=\"javascript:insert('".$emoticon_text7."')\">".$emoticon_img7."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text8."')\">".$emoticon_img8."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text9."')\">".$emoticon_img9."</a>";
-		echo  "<a href=\"javascript:insert('".$emoticon_text10."')\">".$emoticon_img10."</a>";
+		//echo  "<a href=\"javascript:insert('".$emoticon_text10."')\">".$emoticon_img10."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text11."')\">".$emoticon_img11."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text12."')\">".$emoticon_img12."</a>";
 		echo  "<a href=\"javascript:insert('".$emoticon_text13."')\">".$emoticon_img13."</a>";

+ 23 - 34
main/chat/header_frame.inc.php

@@ -35,35 +35,29 @@ if (empty($mycourseid)) {
  * Choose CSS style (platform's, user's, or course's)
  */
 $my_style = api_get_visual_theme();
+$chat_size_old = isset($chat_size_old) ? $chat_size_old : null;
+$chat_size_new = isset($chat_size_new) ? $chat_size_new : null;
+$connected_new = isset($connected_new) ? $connected_new : null;
+$connected_old = isset($connected_old) ? $connected_old : null;
 
-?><!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" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
+?><!DOCTYPE html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
-<title>Chat</title>
-<link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css">
-<style>
-	a{
-		font-size: 12px;
-	}
-
-	.background_submit{
-		background: url(../img/chat_little.gif) 2px 2px no-repeat;
-		padding: 2px 1px 1px 20px;
-	}
-	TH{
-		font-size: 12px;
-	}
-</style>
-
-<script type="text/javascript" language="javascript">
-<!--
+    <meta charset="<?php echo api_get_system_encoding(); ?>" />
+    <title>Chat</title>
+    <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CSS_PATH).$my_style; ?>/default.css">
+    <style>
+        .background_submit {
+            background: url(../img/chat_little.gif) 2px 2px no-repeat;
+            padding: 2px 1px 1px 20px;
+        }
+        th {
+            font-size: 12px;
+        }
+    </style>
+<script>
 function updateChat()
 {
-	if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>')
-	{
+	if ('<?php echo $chat_size_old; ?>' != '<?php echo $chat_size_new; ?>') {
 		parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size_new.'&'.api_get_cidreq(); ?>#bottom';
 	}
 }
@@ -83,27 +77,22 @@ function submitHiddenForm()
 
 function eventMessage()
 {
-	<?php if($chat_size): ?>
+	<?php if (isset($chat_size) && $chat_size): ?>
 	parent.chat_hidden.document.formHidden.chat_size_old.value='<?php echo $chat_size; ?>';
 	parent.chat_chat.location.href='chat_chat.php?size=<?php echo $chat_size.'&'.api_get_cidreq(); ?>#bottom';
 	<?php endif; ?>
 	document.formMessage.message.focus();
 }
 
-function send_message(evenement){
-
-    for (prop in evenement)
-    {
+function send_message(evenement) {
+    for (prop in evenement) {
     	if(prop == 'which') touche = evenement.which; else touche = evenement.keyCode;
     }
 
-    if (touche == 13)
-    {
+    if (touche == 13) {
     	document.formMessage.submit();
     }
 }
-
-//-->
 </script>
 </head>
 <body <?php echo $bodyXtra; ?> >