function MG_quotaReport($page, $quotaquery, $usedquery) { global $_TABLES, $_MG_CONF, $_CONF, $LANG_MG01, $LANG_MG03; $counter = 0; $rowcounter = 1; $retval = ''; $start = $page * 50; $end = 50; $T = new Template($_MG_CONF['template_path'] . '/admin'); $T->set_file(array('report' => 'quotareport.thtml')); $retval .= COM_startBlock('', '', COM_getBlockTemplate('_admin_block', 'header')); $T->set_var(array('lang_username' => $LANG_MG01['username'], 'lang_active' => $LANG_MG01['active'], 'lang_quota' => $LANG_MG01['quota'], 'lang_used' => $LANG_MG01['used'])); $T->set_block('report', 'UserRow', 'uRow'); if ($quotaquery > 0) { $quotaselect = $quotaquery * 1048676; } else { $quotaselect = 0; } $tres = DB_query("SELECT COUNT(gl.uid) AS count FROM {$_TABLES['users']} AS gl LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid WHERE gl.status = 3 AND gl.uid > 2 AND mg.member_gallery=1 AND mg.quota >= " . $quotaselect); $trow = DB_fetchArray($tres); $total_records = $trow['count']; $sql = "SELECT gl.uid, gl.status, gl.username, gl.fullname, mg.member_gallery, mg.quota FROM {$_TABLES['users']} AS gl LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid WHERE gl.status = 3 AND gl.uid > 2 AND mg.member_gallery=1 AND mg.quota >= " . $quotaselect . " ORDER BY gl.username ASC LIMIT {$start},{$end}"; $result = DB_query($sql); while ($userRow = DB_fetchArray($result)) { $uid = $userRow['uid']; $quota_mb = MG_getUserQuota($uid) / 1048676; $quota = number_format($quota_mb, 2); $used_mb = (double) MG_quotaUsage($uid) / 1048576; $used = number_format($used_mb, 2); if ($quotaquery > 0) { // limit based on quota if ($quota_mb >= $quotaquery) { $show = 1; } else { $show = 0; } } else { $show = 1; } if ($show) { $T->set_var(array('result_row' => $rowcounter, 'rowclass' => $rowcounter % 2 ? '2' : '1', 'username' => '<a href="' . $_MG_CONF['admin_url'] . 'edituser.php?uid=' . $uid . '">' . $userRow['username'] . " (" . $userRow['fullname'] . ")</a>", 'uid' => $uid, 'quota' => $quota == 0 ? 'Unlimited' : $quota, 'used' => $used, 'active' => MG_getUserActive($uid))); $T->parse('uRow', 'UserRow', true); $rowcounter++; $counter++; } } $T->set_var(array('site_admin_url' => $_MG_CONF['admin_url'], 'used' => $usedquery, 'quota' => $quotaquery, 'lang_go' => $LANG_MG03['go'], 'lang_quota' => $LANG_MG01['quota'], 'lang_used' => $LANG_MG01['used'], 'lang_batch_update' => $LANG_MG01['batch_quota_update'], 'lang_update' => $LANG_MG01['update'], 'pagenav' => COM_printPageNavigation($_MG_CONF['admin_url'] . 'quotareport.php', $page + 1, ceil($total_records / 50)))); $T->parse('output', 'report'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Save browser upload(s) * * @param int album_id album_id save uploaded media * @return string HTML * */ function MG_saveUserUpload($album_id) { global $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $new_media_id; $retval = ''; $retval .= COM_startBlock($LANG_MG03['upload_results'], '', COM_getBlockTemplate('_admin_block', 'header')); $T = new Template(MG_getTemplatePath($album_id)); $T->set_file('mupload', 'useruploadstatus.thtml'); $statusMsg = ''; $file = array(); $file = $_FILES['newmedia']; $thumbs = $_FILES['thumbnail']; $albums = $album_id; $successfull_upload = 0; $upload = 1; $purge = 0; foreach ($file['name'] as $key => $name) { $filename = $file['name'][$key]; $filetype = $file['type'][$key]; $filesize = $file['size'][$key]; $filetmp = $file['tmp_name'][$key]; $upload = isset($file['_data_dir']) ? 0 : 1; $purge = isset($file['_data_dir']) ? 1 : 0; $error = $file['error'][$key]; $caption = $_POST['caption'][$key]; $description = $_POST['description'][$key]; $keywords = $_POST['keywords'][$key]; $category = 0; if (isset($_POST['cat_id'])) { $category = COM_applyFilter($_POST['cat_id'][$key], true); } $attachtn = isset($_POST['attachtn'][$key]) ? $_POST['attachtn'][$key] : ''; $thumbnail = isset($thumbs['tmp_name'][$key]) ? $thumbs['tmp_name'][$key] : ''; if (isset($_POST['dnc'][$key]) && $_POST['dnc'][$key] == 'on') { $dnc = 1; } else { $dnc = 0; } if ($filename == '') { continue; } if ($MG_albums[$album_id]->max_filesize != 0 && $filesize > $MG_albums[$album_id]->max_filesize) { COM_errorLog("MG Upload: File " . $filename . " exceeds maximum allowed filesize for this album"); $tmpmsg = sprintf($LANG_MG02['upload_exceeds_max_filesize'], $filename); $statusMsg .= $tmpmsg . '<br/>'; continue; } if ($attachtn == "on") { $attach_tn = 1; } else { $attach_tn = 0; } if ($error != UPLOAD_ERR_OK) { switch ($error) { case 1: $tmpmsg = sprintf($LANG_MG02['upload_too_big'], $filename); $statusMsg .= $tmpmsg . '<br/>'; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 2: $tmpmsg = sprintf($LANG_MG02['upload_too_big_html'], $filename); $statusMsg .= $tmpmsg . '<br/>'; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 3: $tmpmsg = sprintf($LANG_MG02['partial_upload'], $filename); $statusMsg .= $tmpmsg . '<br/>'; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 4: break; case 6: $statusMsg .= $LANG_MG02['missing_tmp'] . '<br/>'; break; case 7: $statusMsg .= $LANG_MG02['disk_fail'] . '<br/>'; break; default: $statusMsg .= $LANG_MG02['unknown_err'] . '<br/>'; break; } continue; } // check user quota -- do we have one? $user_quota = MG_getUserQuota($_USER['uid']); if ($user_quota > 0) { $disk_used = MG_quotaUsage($_USER['uid']); if ($disk_used + $filesize > $user_quota) { COM_errorLog("MG Upload: File " . $filename . " would exceeds the users quota"); $tmpmsg = sprintf($LANG_MG02['upload_exceeds_quota'], $filename); $statusMsg .= $tmpmsg . '<br/>'; continue; } } // override the determination for some filetypes $filetype = MG_getFileTypeFromExt($filename, $filetype); // process the uploaded files list($rc, $msg) = MG_getFile($filetmp, $filename, $albums, $caption, $description, $upload, $purge, $filetype, $attach_tn, $thumbnail, $keywords, $category, $dnc, 0); $statusMsg .= $filename . " " . $msg . '<br/>'; if ($rc == true) { $successfull_upload++; } } if ($successfull_upload) { MG_notifyModerators($albums); PLG_sendSubscriptionNotification('mediagallery', '', $albums, $new_media_id, $_USER['uid']); } // failsafe check - after all the uploading is done, double check that the database counts // equal the actual count of items shown in the database, if not, fix the counts and log // the error $dbCount = DB_count($_TABLES['mg_media_albums'], 'album_id', (int) $album_id); $aCount = DB_getItem($_TABLES['mg_albums'], 'media_count', "album_id=" . (int) $album_id); if ($dbCount != $aCount) { DB_query("UPDATE " . $_TABLES['mg_albums'] . " SET media_count=" . $dbCount . " WHERE album_id=" . (int) $album_id); COM_errorLog("MediaGallery: Upload processing - Counts don't match - dbCount = " . $dbCount . " aCount = " . $aCount); } MG_SortMedia($album_id); $T->set_var('status_message', $statusMsg); $tmp = $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1'; $redirect = sprintf($LANG_MG03['album_redirect'], $tmp); $T->set_var('redirect', $redirect); $T->parse('output', 'mupload'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Save browser upload(s) * * @param int album_id album_id save uploaded media * @return string HTML * */ function MG_saveUserUpload($album_id) { global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG02, $LANG_MG03; $retval = ''; $retval .= COM_startBlock($LANG_MG03['upload_results'], '', COM_getBlockTemplate('_admin_block', 'header')); $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('mupload', 'useruploadstatus.thtml'); $statusMsg = ''; $file = array(); $file = $_FILES['newmedia']; $thumbs = $_FILES['thumbnail']; $album = new mgAlbum($album_id); $successfull_upload = 0; $br = '<br' . XHTML . '>'; foreach ($file['name'] as $key => $name) { $filename = $file['name'][$key]; $filetype = $file['type'][$key]; $filesize = $file['size'][$key]; $filetmp = $file['tmp_name'][$key]; $error = $file['error'][$key]; $caption = COM_stripslashes($_POST['caption'][$key]); $description = COM_stripslashes($_POST['description'][$key]); $keywords = COM_stripslashes($_POST['keywords'][$key]); $category = COM_applyFilter($_POST['cat_id'][$key], true); $attachtn = isset($_POST['attachtn'][$key]) ? $_POST['attachtn'][$key] : ''; $thumbnail = isset($thumbs['tmp_name'][$key]) ? $thumbs['tmp_name'][$key] : ''; if (isset($_POST['dnc'][$key]) && $_POST['dnc'][$key] == 'on') { $dnc = 1; } else { $dnc = 0; } if ($filename == '') { continue; } if ($album->max_filesize != 0 && $filesize > $album->max_filesize) { COM_errorLog("MG Upload: File " . $filename . " exceeds maximum allowed filesize for this album"); $tmpmsg = sprintf($LANG_MG02['upload_exceeds_max_filesize'], $filename); $statusMsg .= $tmpmsg . $br; continue; } if ($attachtn == "on") { $attach_tn = 1; } else { $attach_tn = 0; } if ($error != UPLOAD_ERR_OK) { switch ($error) { case 1: $tmpmsg = sprintf($LANG_MG02['upload_too_big'], $filename); $statusMsg .= $tmpmsg . $br; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 2: $tmpmsg = sprintf($LANG_MG02['upload_too_big_html'], $filename); $statusMsg .= $tmpmsg . $br; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 3: $tmpmsg = sprintf($LANG_MG02['partial_upload'], $filename); $statusMsg .= $tmpmsg . $br; COM_errorLog('MediaGallery: Error - ' . $tmpmsg); break; case 4: break; case 6: $statusMsg .= $LANG_MG02['missing_tmp'] . $br; break; case 7: $statusMsg .= $LANG_MG02['disk_fail'] . $br; break; default: $statusMsg .= $LANG_MG02['unknown_err'] . $br; break; } continue; } // check user quota -- do we have one???? $user_quota = DB_getItem($_TABLES['mg_userprefs'], 'quota', "uid=" . intval($_USER['uid'])); if ($user_quota > 0) { $disk_used = MG_quotaUsage($_USER['uid']); if ($disk_used + $filesize > $user_quota) { COM_errorLog("MG Upload: File " . $filename . " would exceeds the users quota"); $tmpmsg = sprintf($LANG_MG02['upload_exceeds_quota'], $filename); $statusMsg .= $tmpmsg . $br; continue; } } // process the uploaded files $opt = array('caption' => $caption, 'description' => $description, 'filetype' => $filetype, 'atttn' => $attach_tn, 'thumbnail' => $thumbnail, 'keywords' => $keywords, 'category' => $category, 'dnc' => $dnc); list($rc, $msg) = MG_getFile($filetmp, $filename, $album_id, $opt); $statusMsg .= $filename . " " . $msg . $br; if ($rc == true) { $successfull_upload++; } } if ($successfull_upload) { MG_notifyModerators($album_id); } // failsafe check - after all the uploading is done, double check that the database counts // equal the actual count of items shown in the database, if not, fix the counts and log // the error $dbCount = DB_count($_TABLES['mg_media_albums'], 'album_id', intval($album_id)); $aCount = DB_getItem($_TABLES['mg_albums'], 'media_count', "album_id=" . intval($album_id)); if ($dbCount != $aCount) { DB_change($_TABLES['mg_albums'], 'media_count', $dbCount, 'album_id', intval($album_id)); COM_errorLog("MediaGallery: Upload processing - Counts don't match - dbCount = " . $dbCount . " aCount = " . $aCount); } MG_SortMedia($album_id); $T->set_var('status_message', $statusMsg); $tmp = $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1'; $redirect = sprintf($LANG_MG03['album_redirect'], $tmp); $T->set_var('redirect', $redirect); $T->parse('output', 'mupload'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }