function phorum_check_upload_limits($is_install) { global $PHORUM; if ($is_install) { return array(PHORUM_SANITY_SKIP, NULL, NULL); } // Keep track if uploads are used. $upload_used = false; // Get the maximum file upload size for PHP. list($system_max_upload, $php_max_upload, $db_max_upload) = phorum_api_system_get_max_upload(); // Check limits for file uploading in personal profile. if ($PHORUM["file_uploads"] && $PHORUM["max_file_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits($PHORUM["max_file_size"] * 1024, "the Max File Size option for user file uploads " . "(in their profile)", $php_max_upload, $db_max_upload); if ($res != NULL) { return $res; } } // Check limits for attachment uploading in forums. require_once './include/api/forums.php'; $forums = phorum_api_forums_get(NULL, NULL, NULL, NULL, PHORUM_FLAG_INCLUDE_INACTIVE | PHORUM_FLAG_FORUMS); foreach ($forums as $id => $forum) { if ($forum["max_attachments"] > 0 && $forum["max_attachment_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits($forum["max_attachment_size"] * 1024, "the Max File Size option for uploading attachments\n in the forum \"{$forum['name']}\"", $php_max_upload, $db_max_upload); if ($res != NULL) { return $res; } } } // No upload functionality found so far? Then we're done. if (!$upload_used) { return array(PHORUM_SANITY_OK, NULL); } // Check if the upload temp directory can be written. $tmpdir = get_cfg_var('upload_tmp_dir'); if (!empty($tmpdir)) { $fp = @fopen("{$tmpdir}/sanity_checks_dummy_uploadtmpfile", "w"); if (!$fp) { return array(PHORUM_SANITY_CRIT, "The system is unable to write files\n to PHP's upload tmpdir \"" . htmlspecialchars($tmpdir) . "\".\n The system error was:<br/><br/>" . htmlspecialchars($php_errormsg) . ".", "Change the upload_tmp_dir setting in your php.ini file\n or give your webserver more permissions for the current\n upload directory."); } fclose($fp); unlink("{$tmpdir}/sanity_checks_dummy_uploadtmpfile"); } return array(PHORUM_SANITY_OK, NULL, NULL); }
function phorum_check_upload_limits() { $PHORUM = $GLOBALS["PHORUM"]; // Keep track if uploads are used. $upload_used = false; // Get the maximum file upload size for PHP. $php_max_upload = phorum_php_max_upload(); // Get the maximum packet size for the database. // For determining the maximum allowed upload size, // we have to take packet overhead into account. $max_packetsize = phorum_db_maxpacketsize(); if ($max_packetsize == NULL) { $db_max_upload = $php_max_upload; } else { $db_max_upload = phorum_db_maxpacketsize() * 0.6; } // Check limits for file uploading in personal profile. if ($PHORUM["file_uploads"] && $PHORUM["max_file_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits( $PHORUM["max_file_size"]*1024, "the Max File Size option for user file uploads " . "(in their profile)", $php_max_upload, $db_max_upload ); if ($res != NULL) return $res; } // Check limits for attachment uploading in forums. $forums = phorum_db_get_forums(); foreach ($forums as $id => $forum) { if ($forum["max_attachments"] > 0 && $forum["max_attachment_size"]) { $upload_used = true; $res = phorum_single_check_upload_limits( $forum["max_attachment_size"]*1024, "the Max File Size option for uploading attachments in the forum \"{$forum['name']}\"", $php_max_upload, $db_max_upload ); } } // No upload functionality found so far? Then we're done. if (! $upload_used) return array(PHORUM_SANITY_OK, NULL); // Check if the upload temp directory can be written. $tmpdir = get_cfg_var('upload_tmp_dir'); if (!empty($tmpdir)) { $fp = @fopen("$tmpdir/sanity_checks_dummy_uploadtmpfile", "w"); if (! $fp) return array( PHORUM_SANITY_CRIT, "The system is unable to write files to PHP's upload tmpdir \"".htmlspecialchars($tmpdir)."\". The system error was:<br/><br/>". htmlspecialchars($php_errormsg).".", "Change the upload_tmp_dir setting in your php.ini file or give your webserver more permissions for the current upload directory." ); } fclose($fp); unlink("$tmpdir/sanity_checks_dummy_uploadtmpfile"); return array(PHORUM_SANITY_OK, NULL); }