Пример #1
0
/**
 * Determines the system's upload limit. This limit is determined by
 * the maximum upload filesize (PHP), the maximum POST request size (PHP)
 * and the maximum database packet size.
 *
 * @return An array containing three elements: the overall system's maximum
 *         upload size, the maximum as imposed by PHP and the maximum as
 *         imposed by the database.
 */
function phorum_get_system_max_upload()
{
    global $PHORUM;
    // Determine limit as imposed by PHP.
    $pms = phorum_phpcfgsize2bytes(ini_get('post_max_size'));
    $umf = phorum_phpcfgsize2bytes(ini_get('upload_max_filesize'));
    $php_limit = $umf > $pms ? $pms : $umf;
    // Determines the database server's limit for file uploads. This limit
    // is determined by the maximum packet size that the database can handle.
    // We asume that there's a 40% overhead in the packet, so that 60% of
    // the packet can be used for sending an uploaded file to the database.
    $db_limit = phorum_db_maxpacketsize();
    if ($db_limit != NULL) {
        $db_limit = $db_limit * 0.6;
    }
    $limit = $php_limit;
    if ($db_limit && $db_limit < $php_limit) {
        $limit = $db_limit;
    }
    $data = array($limit, $php_limit, $db_limit);
    /*
     * [hook]
     *     system_max_upload
     *
     * [description]
     *     This hook allows a module to control the maximum file size for
     *     a file upload.  Most notable would be file system storage.  It
     *     could ignore the db_limit.
     *
     * [category]
     *     File storage
     *
     * [when]
     *     In
     *     <filename>include/upload_functions.php</filename>,
     *     in the function phorum_get_system_max_upload.
     *
     * [input]
     *     An array containing the default limit, the data layer limit and
     *     the PHP limit
     *
     * [output]
     *     A 3 part array with the limits adjusted as you wish.  The first
     *     element in the array would be the most important.
     *
     * [example]
     *     <hookcode>
     *     function phorum_mod_foo_system_max_upload($data)
     *     {
     *         // ignore the db_limit
     *         $data[0] = $data[2];
     *         return $data;
     *     }
     *     </hookcode>
     */
    if (isset($PHORUM["hooks"]["system_max_upload"])) {
        $data = phorum_hook("system_max_upload", $data);
    }
    return $data;
}
Пример #2
0
/**
 * Determines the system's upload limit. This limit is determined by
 * the maximum upload filesize (PHP), the maximum POST request size (PHP)
 * and the maximum database packet size.
 *
 * @return An array containing three elements: the overall system's maximum
 *         upload size, the maximum as imposed by PHP and the maximum as
 *         imposed by the database.
 */
function phorum_get_system_max_upload()
{
    // Determine limit as imposed by PHP.
    $pms = phorum_phpcfgsize2bytes(ini_get('post_max_size'));
    $umf = phorum_phpcfgsize2bytes(ini_get('upload_max_filesize'));
    $php_limit = $umf > $pms ? $pms : $umf;
    // Determines the database server's limit for file uploads. This limit
    // is determined by the maximum packet size that the database can handle.
    // We asume that there's a 40% overhead in the packet, so that 60% of
    // the packet can be used for sending an uploaded file to the database.
    $db_limit = phorum_db_maxpacketsize();
    if ($db_limit != NULL) {
        $db_limit = $db_limit * 0.6;
    }
    $limit = $php_limit;
    if ($db_limit && $db_limit < $php_limit) {
        $limit = $db_limit;
    }
    return array($limit, $php_limit, $db_limit);
}
Пример #3
0
    function phorum_php_max_upload()
    {
        // Determine the PHP system upload limit. The limit for
        // maximum upload filesize is not the only thing we
        // have to look at. We should also take the maximum
        // POST size in account.
        $pms = phorum_phpcfgsize2bytes(get_cfg_var('post_max_size'));
        $umf = phorum_phpcfgsize2bytes(get_cfg_var('upload_max_filesize'));
        $limit = ($umf > $pms ? $pms : $umf);

        return $limit;
    }