[AppDB] Protect addmsg()
Tony Lambregts
tony_lambregts at telusplanet.net
Fri Jan 14 11:13:54 CST 2005
After talking to Paul and Johnathan on IRC, we came up with this to protect addmsg()
Change log: Protect addmsg() from using up all available memory and crashing.
Files changed: include/incl.php
-------------- next part --------------
Index: include/incl.php
===================================================================
RCS file: /home/wine/appdb/include/incl.php,v
retrieving revision 1.17
diff -u -r1.17 incl.php
--- include/incl.php 12 Jan 2005 16:22:55 -0000 1.17
+++ include/incl.php 14 Jan 2005 16:47:01 -0000
@@ -4,6 +4,7 @@
/*************************************************/
// get modules
+ini_set("memory_limit","64M");
require(BASE."include/"."config.php");
require(BASE."include/"."util.php");
require(BASE."include/"."user.php");
@@ -180,12 +181,18 @@
*/
function addmsg($text, $color = "black")
{
+ global $hAppdbLink;
+
if($color)
$text = "<font color='$color'> $text </font>\n";
- $text = str_replace("'", "\\'", $text);
- query_appdb("INSERT INTO sessionMessages VALUES (null, null, '".session_id()."', '$text')");
- echo mysql_error();
+ $text = addslashes($text);
+ $sQuery = "INSERT INTO sessionMessages VALUES (null, null, '".session_id()."', '$text')";
+ if (!mysql_query($sQuery,$hAppdbLink))
+ {
+ echo "An error has occured in addmsg(): ".mysql_error($hAppdbLink);
+ echo $text;
+ }
}
More information about the wine-patches
mailing list