Ejemplo n.º 1
0
/**
* Browser upload form
*
* @param    int     album_id    album_id upload media
* @return   string              HTML
*
*/
function MG_userUpload($album_id)
{
    global $album_selectbox, $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG01, $LANG_MG03;
    $retval = '';
    // build a select box of valid albums for upload
    $valid_albums = 0;
    $level = 0;
    $album_selectbox = '<select name="album_id">';
    $valid_albums += $MG_albums[0]->buildAlbumBox($album_id, 3, -1, 'upload');
    $album_selectbox .= '</select>';
    // build category list...
    $result = DB_query("SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC");
    $nRows = DB_numRows($result);
    $catRow = array();
    for ($i = 0; $i < $nRows; $i++) {
        $catRow[$i] = DB_fetchArray($result);
    }
    $cRows = count($catRow);
    if ($cRows > 0) {
        $cat_select = '<select name="cat_id[]">';
        $cat_select .= '<option value="0">' . $LANG_MG01['no_category'] . '</option>';
        for ($i = 0; $i < $cRows; $i++) {
            $cat_select .= '<option value="' . $catRow[$i]['cat_id'] . '">' . $catRow[$i]['cat_name'] . '</option>';
        }
        $cat_select .= '</select>';
    } else {
        $cat_select = '';
    }
    $T = new Template(MG_getTemplatePath($album_id));
    $T->set_file('mupload', 'userupload.thtml');
    $user_quota = MG_getUserQuota($_USER['uid']);
    if ($user_quota > 0) {
        $disk_used = MG_quotaUsage($_USER['uid']);
        $user_quota = $user_quota / 1024;
        $disk_used = $disk_used / 1024;
        // $disk_used / 1048576;
        $quota = sprintf($LANG_MG01['user_quota'], $user_quota, $disk_used, $user_quota - $disk_used);
    } else {
        $quota = '';
    }
    $post_max_size = ini_get('post_max_size');
    $post_max_size_b = MG_return_bytes($post_max_size);
    $upload_max_size = ini_get('upload_max_filesize');
    $upload_max_size_b = MG_return_bytes($upload_max_size);
    $max_upload_size = $upload_max_size_b / 1048576;
    // take to Mb
    $post_max_size = $post_max_size_b / 1048576;
    // take to Mb
    $html_max_filesize = $upload_max_size_b;
    $msg_upload_size = sprintf($LANG_MG03['upload_size'], $post_max_size, $max_upload_size);
    $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'lang_upload_help' => $LANG_MG03['upload_help'], 'lang_upload_size' => $msg_upload_size, 'lang_zip_help' => $_MG_CONF['zip_enabled'] == 1 ? $LANG_MG03['zip_file_help'] . '<br/><br/>' : '', 'lang_media_upload' => $LANG_MG01['upload_media'], 'lang_caption' => $LANG_MG01['title'], 'lang_file' => $LANG_MG01['file'], 'lang_description' => $LANG_MG01['description'], 'lang_attached_tn' => $LANG_MG01['attached_thumbnail'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 'lang_category' => $cRows > 0 ? $LANG_MG01['category'] : '', 'lang_keywords' => $LANG_MG01['keywords'], 'lang_destination_album' => $LANG_MG01['destination_album'], 'lang_do_not_convert_orig' => $LANG_MG01['do_not_convert_orig'], 'lang_file_number' => $LANG_MG01['file_number'], 'cat_select' => $cat_select, 'album_id' => $album_id, 'action' => 'upload', 'max_file_size' => '<input type="hidden" name="MAX_FILE_SIZE" value="' . $html_max_filesize . '"/>', 'lang_quota' => $quota, 'album_select' => $album_selectbox, 'max_upload_size' => $max_upload_size, 'post_max_size' => $post_max_size, 'csrf_token' => CSRF_TOKEN, 'csrf_token_value' => SEC_createToken()));
    $T->parse('output', 'mupload');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
Ejemplo n.º 2
0
/**
* Return the max upload file size for the specified album
*
* @param    intval      album_id        the album_id to return the max upload file size for
* @return   intval      upload_limit    the upload size imit, in bytes
*
* if the type cannot be determined from the extension because the extension is
* not known, then the default value is returned (even if null)
*
* NOTE: the album array must be pre-initialized via MG_AlbumsInit()
*
*/
function MG_getUploadLimit($album_id)
{
    global $MG_albums;
    $post_max = MG_return_bytes(ini_get('post_max_size'));
    $album_max = $MG_albums[$album_id]->max_filesize;
    if ($album_max > 0 && $album_max < $post_max) {
        return $album_max;
    } else {
        return $post_max;
    }
}
Ejemplo n.º 3
0
/**
* Return the max upload file size for the specified album
*
* @param    intval      album_id        the album_id to return the max upload file size for
* @return   intval      upload_limit    the upload size imit, in bytes
*
* if the type cannot be determined from the extension because the extension is
* not known, then the default value is returned (even if null)
*
* NOTE: the album array must be pre-initialized via MG_AlbumsInit()
*
*/
function MG_getUploadLimit($album_id)
{
    global $_TABLES;
    $post_max = MG_return_bytes(ini_get('post_max_size'));
    $album_max = DB_getItem($_TABLES['mg_albums'], 'max_filesize', 'album_id = ' . intval($album_id));
    if ($album_max > 0 && $album_max < $post_max) {
        return $album_max;
    }
    return $post_max;
}
Ejemplo n.º 4
0
    $display = COM_siteHeader();
    $display .= COM_startBlock($LANG_MG00['access_denied']);
    $display .= $LANG_MG00['access_denied_msg'];
    $display .= COM_endBlock();
    $display .= COM_siteFooter(true);
    echo $display;
    exit;
}
// Sucess!
$display = '';
if (is_array($TEMPLATE_OPTIONS)) {
    $tc_installed = 1;
} else {
    $tc_installed = 0;
}
$memory_limit = MG_return_bytes(ini_get('memory_limit'));
if ($tc_installed == 0) {
    $noCache = 1;
    $cacheCheck = '<div style="background-color:#ffff00;color:#000000;vertical-align:middle;padding:5px;"><img src="redX.png" alt="error" style="padding:5px;vertical-align:middle;">&nbsp;' . $LANG_MG00['tc_error'] . '</div>';
} else {
    $noCache = 0;
    $cacheCheck = '<div style="vertical-align:middle;padding:5px;"><img src="check.png" alt="OK" style="padding:5px;vertical-align:middle;">' . $LANG_MG00['tc_ok'] . '</div>';
}
if ($memory_limit < 50331648) {
    $noMemory = 1;
    $memoryCheck = '<div style="background-color:#ffff00;color:#000000;vertical-align:middle;padding:5px;"><img src="redX.png" alt="error" style="padding:5px;vertical-align:middle;">&nbsp;' . $LANG_MG00['ml_error'] . '</div>';
} else {
    $noMemory = 0;
    $memoryCheck = '<div style="vertical-align:middle;padding:5px;"><img src="check.png" alt="OK" style="padding:5px;vertical-align:middle;">' . $LANG_MG00['ml_ok'] . '</div>';
}
$T = new Template($_MG_CONF['template_path'] . '/admin');