functions_includes.php
来自「这是php编的论坛的原代码」· PHP 代码 · 共 613 行 · 第 1/2 页
PHP
613 行
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
'L_UPLOAD_QUOTA' => $lang['Upload_quota'],
'L_PM_QUOTA' => $lang['Pm_quota'])
);
}
if ($admin_mode == 'user' && $submit && $HTTP_POST_VARS['deleteuser'])
{
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, -1);
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, -1);
}
else if ($admin_mode == 'user' && $submit && $mode == 'save')
{
// Get the contents
$upload_quota = intval($HTTP_POST_VARS['user_upload_quota']);
$pm_quota = intval($HTTP_POST_VARS['user_pm_quota']);
if ($upload_quota <= 0)
{
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, -1);
}
else
{
process_quota_settings($admin_mode, $user_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
}
if ($pm_quota <= 0)
{
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, -1);
}
else
{
process_quota_settings($admin_mode, $user_id, QUOTA_PM_LIMIT, $pm_quota);
}
}
if ($admin_mode == 'group' && $mode == 'newgroup')
{
return;
}
if ($admin_mode == 'group' && !$submit && isset($HTTP_POST_VARS['edit']))
{
// Show the contents
$sql = "SELECT quota_limit_id, quota_type FROM " . QUOTA_TABLE . " WHERE group_id = " . $group_id;
if( !($result = attach_sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Unable to get Quota Settings', '', __LINE__, __FILE__, $sql);
}
$pm_quota = -1;
$upload_quota = -1;
while ($row = $db->sql_fetchrow($result))
{
if ($row['quota_type'] == QUOTA_UPLOAD_LIMIT)
{
$upload_quota = $row['quota_limit_id'];
}
else if ($row['quota_type'] == QUOTA_PM_LIMIT)
{
$pm_quota = $row['quota_limit_id'];
}
}
$template->assign_vars(array(
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
'L_UPLOAD_QUOTA' => $lang['Upload_quota'],
'L_PM_QUOTA' => $lang['Pm_quota'])
);
}
if ($admin_mode == 'group' && $submit && isset($HTTP_POST_VARS['group_delete']))
{
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, -1);
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, -1);
}
else if ($admin_mode == 'group' && $submit)
{
// Get the contents
$upload_quota = intval($HTTP_POST_VARS['group_upload_quota']);
$pm_quota = intval($HTTP_POST_VARS['group_pm_quota']);
if ($upload_quota <= 0)
{
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, -1);
}
else
{
process_quota_settings($admin_mode, $group_id, QUOTA_UPLOAD_LIMIT, $upload_quota);
}
if ($pm_quota <= 0)
{
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, -1);
}
else
{
process_quota_settings($admin_mode, $group_id, QUOTA_PM_LIMIT, $pm_quota);
}
}
}
//
// Called from usercp_viewprofile, displays the User Upload Quota Box, Upload Stats and a Link to the User Attachment Control Panel
// Groups are able to be grabbed, but it's not used within the Attachment Mod. ;)
//
function display_upload_attach_box_limits($user_id, $group_id = -1)
{
global $attach_config, $board_config, $phpbb_root_path, $lang, $db, $template, $phpEx, $userdata;
if (($userdata['user_level'] != ADMIN) && ($userdata['user_id'] != $user_id))
{
return;
}
// Return if the user is not within the to be listed Group
if ($group_id != -1)
{
if (!user_in_group($user_id, $group_id))
{
return;
}
}
$attachments = new attach_posting();
$attachments->PAGE = PAGE_INDEX;
// Get the assigned Quota Limit. For Groups, we are directly getting the value, because this Quota can change from user to user.
if ($group_id != -1)
{
$sql = "SELECT l.quota_limit FROM " . QUOTA_TABLE . " q, " . QUOTA_LIMITS_TABLE . " l
WHERE (q.group_id = " . $group_id . ") AND (q.quota_type = " . QUOTA_UPLOAD_LIMIT . ")
AND (q.quota_limit_id = l.quota_limit_id) LIMIT 1";
if ( !($result = attach_sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get Group Quota', '', __LINE__, __FILE__, $sql);
}
if ($db->sql_numrows($result) > 0)
{
$row = $db->sql_fetchrow($result);
$attach_config['upload_filesize_limit'] = intval($row['quota_limit']);
}
else
{
// Set Default Quota Limit
$quota_id = intval($attach_config['default_upload_quota']);
if ($quota_id == 0)
{
$attach_config['upload_filesize_limit'] = intval($attach_config['attachment_quota']);
}
else
{
$sql = "SELECT quota_limit FROM " . QUOTA_LIMITS_TABLE . "
WHERE quota_limit_id = " . $quota_id . " LIMIT 1";
if ( !($result = attach_sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get Quota Limit', '', __LINE__, __FILE__, $sql);
}
if ($db->sql_numrows($result) > 0)
{
$row = $db->sql_fetchrow($result);
$attach_config['upload_filesize_limit'] = intval($row['quota_limit']);
}
else
{
$attach_config['upload_filesize_limit'] = intval($attach_config['attachment_quota']);
}
}
}
}
else
{
$attachments->get_quota_limits($user_id);
}
if ( intval($attach_config['upload_filesize_limit']) == 0 )
{
$upload_filesize_limit = intval($attach_config['attachment_quota']);
}
else
{
$upload_filesize_limit = intval($attach_config['upload_filesize_limit']);
}
if ($upload_filesize_limit == 0)
{
$user_quota = $lang['Unlimited'];
}
else
{
$size_lang = ($upload_filesize_limit >= 1048576) ? $lang['MB'] : ( ($upload_filesize_limit >= 1024) ? $lang['KB'] : $lang['Bytes'] );
if ($upload_filesize_limit >= 1048576)
{
$user_quota = (round($upload_filesize_limit / 1048576 * 100) / 100) . ' ' . $size_lang;
}
else if ($upload_filesize_limit >= 1024)
{
$user_quota = (round($upload_filesize_limit / 1024 * 100) / 100) . ' ' . $size_lang;
}
else
{
$user_quota = ($upload_filesize_limit) . ' ' . $size_lang;
}
}
//
// Get all attach_id's the specific user posted, but only uploads to the board and not Private Messages
//
$sql = "SELECT attach_id
FROM " . ATTACHMENTS_TABLE . "
WHERE (user_id_1 = " . $user_id . ") AND (privmsgs_id = 0)
GROUP BY attach_id";
if ( !($result = attach_sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t query attachments', '', __LINE__, __FILE__, $sql);
}
$attach_ids = $db->sql_fetchrowset($result);
$num_attach_ids = $db->sql_numrows($result);
$attach_id = array();
for ($j = 0; $j < $num_attach_ids; $j++)
{
$attach_id[] = intval($attach_ids[$j]['attach_id']);
}
$upload_filesize = (count($attach_id) > 0) ? get_total_attach_filesize(implode(',', $attach_id)) : 0;
$size_lang = ($upload_filesize >= 1048576) ? $lang['MB'] : ( ($upload_filesize >= 1024) ? $lang['KB'] : $lang['Bytes'] );
if ($upload_filesize >= 1048576)
{
$user_uploaded = (round($upload_filesize / 1048576 * 100) / 100) . ' ' . $size_lang;
}
else if ($upload_filesize >= 1024)
{
$user_uploaded = (round($upload_filesize / 1024 * 100) / 100) . ' ' . $size_lang;
}
else
{
$user_uploaded = ($upload_filesize) . ' ' . $size_lang;
}
$upload_limit_pct = ( $upload_filesize_limit > 0 ) ? round(( $upload_filesize / $upload_filesize_limit ) * 100) : 0;
$upload_limit_img_length = ( $upload_filesize_limit > 0 ) ? round(( $upload_filesize / $upload_filesize_limit ) * $board_config['privmsg_graphic_length']) : 0;
$upload_limit_remain = ( $upload_filesize_limit > 0 ) ? $upload_filesize_limit - $upload_filesize : 100;
$l_box_size_status = sprintf($lang['Upload_percent_profile'], $upload_limit_pct);
$template->assign_block_vars('switch_upload_limits', array());
$template->assign_vars(array(
'L_UACP' => $lang['UACP'],
'L_UPLOAD_QUOTA' => $lang['Upload_quota'],
'U_UACP' => append_sid($phpbb_root_path . 'uacp.' . $phpEx . '?u=' . $user_id),
'UPLOADED' => sprintf($lang['User_uploaded_profile'], $user_uploaded),
'QUOTA' => sprintf($lang['User_quota_profile'], $user_quota),
'UPLOAD_LIMIT_IMG_WIDTH' => $upload_limit_img_length,
'UPLOAD_LIMIT_PERCENT' => $upload_limit_pct,
'PERCENT_FULL' => $l_box_size_status)
);
}
//
// Function responsible for viewonline (within viewonline.php and the admin index page)
//
// added directly after the switch statement
// viewonline.php:
// perform_attach_pageregister($row['session_page']);
// admin/index.php:
// perform_attach_pageregister($onlinerow_reg[$i]['user_session_page'], TRUE);
// perform_attach_pageregister($onlinerow_guest[$i]['session_page'], TRUE);
//
function perform_attach_pageregister($session_page, $in_admin = FALSE)
{
global $location, $location_url, $lang;
switch ($session_page)
{
case (PAGE_UACP):
$location = $lang['User_acp_title'];
$location_url = ($in_admin) ? "index.$phpEx?pane=right" : "index.$phpEx";
break;
case (PAGE_RULES):
$location = $lang['Rules_page'];
$location_url = ($in_admin) ? "index.$phpEx?pane=right" : "index.$phpEx";
break;
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?