r726: Add max packet testing
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jan 2006 08:47:05 +0000 (08:47 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 15 Jan 2006 08:47:05 +0000 (08:47 +0000)
attachment.php

index 91bd7909d4ef2ee3fe936923a64f3306df70b33d..77b2270b2f0eaffab150a736f633a1e395bab5dc 100755 (executable)
@@ -50,6 +50,10 @@ if ($_POST['do'] == 'insert')
                $message->error_permission();
        }
        
+       // max packet size
+       $var = $db->query_first("SHOW VARIABLES LIKE 'max_allowed_packet'");
+       $bugsys->debug("max_allowed_packet = $var[Value]");
+       
        // create alias
        $FILE =& $_FILES['attachment'];
        
@@ -72,6 +76,11 @@ if ($_POST['do'] == 'insert')
        
        // #*# put some MIME-type validation here
        
+       if (filesize($FILE['tmp_name']) > $var['Value'])
+       {
+               $message->items[] = $lang->string('The file you specified exceeds MySQL\'s maximum allowed packet.');
+       }
+       
        $filedata = $bugsys->escape(file_get_contents($FILE['tmp_name']), true, true);
        $time = TIMENOW;