本文整理汇总了PHP中extension_allowed函数的典型用法代码示例。如果您正苦于以下问题:PHP extension_allowed函数的具体用法?PHP extension_allowed怎么用?PHP extension_allowed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extension_allowed函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: login_forum_box
if ($row['forum_password']) {
// Do something else ... ?
login_forum_box($row);
}
} else {
//trigger_error('SORRY_AUTH_VIEW_ATTACH');
}
} else {
$row['forum_id'] = 0;
if (!$_CLASS['auth']->acl_get('u_pm_download') || !$config['auth_download_pm']) {
trigger_error('SORRY_AUTH_VIEW_ATTACH');
}
}
// disallowed ?
$extensions = array();
if (!extension_allowed($row['forum_id'], $attachment['extension'], $extensions)) {
trigger_error(sprintf($_CLASS['core_user']->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
if (!download_allowed()) {
trigger_error($_CLASS['core_user']->lang['LINKAGE_FORBIDDEN']);
}
$download_mode = (int) $extensions[$attachment['extension']]['download_mode'];
// Fetching filename here to prevent sniffing of filename
$sql = 'SELECT attach_id, in_message, post_msg_id, extension, physical_filename, real_filename, mimetype
FROM ' . FORUMS_ATTACHMENTS_TABLE . "\n\tWHERE attach_id = {$download_id}";
$result = $_CLASS['core_db']->query_limit($sql, 1);
if (!($attachment = $_CLASS['core_db']->fetch_row_assoc($result))) {
trigger_error('ERROR_NO_ATTACHMENT');
}
$_CLASS['core_db']->free_result($result);
$attachment['physical_filename'] = basename($attachment['physical_filename']);
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:31,代码来源:download.php
示例2: display_attachments
/**
* Display Attachments
*/
function display_attachments($forum_id, $blockname, &$attachment_data, &$update_count, $force_physical = false, $return = false)
{
global $template, $cache, $user;
global $extensions, $config, $phpbb_root_path, $phpEx;
$return_tpl = array();
$template->set_filenames(array('attachment_tpl' => 'attachment.html'));
if (empty($extensions) || !is_array($extensions)) {
$extensions = array();
$cache->obtain_attach_extensions($extensions);
}
foreach ($attachment_data as $attachment) {
// We need to reset/empty the _file block var, because this function might be called more than once
$template->destroy_block_vars('_file');
$block_array = array();
// Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension']));
$filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']);
$thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']);
$upload_icon = '';
if (isset($extensions[$attachment['extension']])) {
if ($user->img('icon_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) {
$upload_icon = $user->img('icon_attach', '');
} else {
if ($extensions[$attachment['extension']]['upload_icon']) {
$upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />';
}
}
}
$filesize = $attachment['filesize'];
$size_lang = $filesize >= 1048576 ? $user->lang['MB'] : ($filesize >= 1024 ? $user->lang['KB'] : $user->lang['BYTES']);
$filesize = $filesize >= 1048576 ? round(round($filesize / 1048576 * 100) / 100, 2) : ($filesize >= 1024 ? round(round($filesize / 1024 * 100) / 100, 2) : $filesize);
$comment = str_replace("\n", '<br />', censor_text($attachment['comment']));
$block_array += array('UPLOAD_ICON' => $upload_icon, 'FILESIZE' => $filesize, 'SIZE_LANG' => $size_lang, 'DOWNLOAD_NAME' => basename($attachment['real_filename']), 'COMMENT' => $comment);
$denied = false;
if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) {
$denied = true;
$block_array += array('S_DENIED' => true, 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
if (!$denied) {
$l_downloaded_viewed = $download_link = '';
$display_cat = $extensions[$attachment['extension']]['display_cat'];
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
if ($attachment['thumbnail']) {
$display_cat = ATTACHMENT_CATEGORY_THUMB;
} else {
if ($config['img_display_inlined']) {
if ($config['img_link_width'] || $config['img_link_height']) {
list($width, $height) = @getimagesize($filename);
$display_cat = !$width && !$height ? ATTACHMENT_CATEGORY_IMAGE : ($width <= $config['img_link_width'] && $height <= $config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE);
}
} else {
$display_cat = ATTACHMENT_CATEGORY_NONE;
}
}
}
switch ($display_cat) {
// Images
case ATTACHMENT_CATEGORY_IMAGE:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
$block_array += array('S_IMAGE' => true);
$update_count[] = $attachment['attach_id'];
break;
// Images, but display Thumbnail
// Images, but display Thumbnail
case ATTACHMENT_CATEGORY_THUMB:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = !$force_physical && $attachment['attach_id'] ? append_sid("{$phpbb_root_path}download.{$phpEx}", 'id=' . $attachment['attach_id']) : $filename;
$block_array += array('S_THUMBNAIL' => true, 'THUMB_IMAGE' => $thumbnail_filename);
break;
// Windows Media Streams
// Windows Media Streams
case ATTACHMENT_CATEGORY_WM:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
$block_array += array('S_WM_FILE' => true);
// Viewed/Heared File ... update the download count (download.php is not called here)
$update_count[] = $attachment['attach_id'];
break;
// Real Media Streams
// Real Media Streams
case ATTACHMENT_CATEGORY_RM:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
$block_array += array('S_RM_FILE' => true, 'U_FORUM' => generate_board_url(), 'ATTACH_ID' => $attachment['attach_id']);
// Viewed/Heared File ... update the download count (download.php is not called here)
$update_count[] = $attachment['attach_id'];
break;
/* // Macromedia Flash Files
case SWF_CAT:
list($width, $height) = swf_getdimension($filename);
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
$block_array += array(
'S_SWF_FILE' => true,
//.........这里部分代码省略.........
开发者ID:yunsite,项目名称:gloryroad,代码行数:101,代码来源:functions_display.php
示例3: parse_attachments
/**
* General attachment parsing
*
* @param mixed $forum_id The forum id the attachments are displayed in (false if in private message)
* @param string &$message The post/private message
* @param array &$attachments The attachments to parse for (inline) display. The attachments array will hold templated data after parsing.
* @param array &$update_count The attachment counts to be updated - will be filled
* @param bool $preview If set to true the attachments are parsed for preview. Within preview mode the comments are fetched from the given $attachments array and not fetched from the database.
*/
function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $preview = false)
{
if (!sizeof($attachments)) {
return;
}
global $template, $cache, $user, $phpbb_dispatcher;
global $extensions, $config, $phpbb_root_path, $phpEx;
//
$compiled_attachments = array();
if (!isset($template->filename['attachment_tpl'])) {
$template->set_filenames(array('attachment_tpl' => 'attachment.html'));
}
if (empty($extensions) || !is_array($extensions)) {
$extensions = $cache->obtain_attach_extensions($forum_id);
}
// Look for missing attachment information...
$attach_ids = array();
foreach ($attachments as $pos => $attachment) {
// If is_orphan is set, we need to retrieve the attachments again...
if (!isset($attachment['extension']) && !isset($attachment['physical_filename'])) {
$attach_ids[(int) $attachment['attach_id']] = $pos;
}
}
// Grab attachments (security precaution)
if (sizeof($attach_ids)) {
global $db;
$new_attachment_data = array();
$sql = 'SELECT *
FROM ' . ATTACHMENTS_TABLE . '
WHERE ' . $db->sql_in_set('attach_id', array_keys($attach_ids));
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
if (!isset($attach_ids[$row['attach_id']])) {
continue;
}
// If we preview attachments we will set some retrieved values here
if ($preview) {
$row['attach_comment'] = $attachments[$attach_ids[$row['attach_id']]]['attach_comment'];
}
$new_attachment_data[$attach_ids[$row['attach_id']]] = $row;
}
$db->sql_freeresult($result);
$attachments = $new_attachment_data;
unset($new_attachment_data);
}
// Sort correctly
if ($config['display_order']) {
// Ascending sort
krsort($attachments);
} else {
// Descending sort
ksort($attachments);
}
foreach ($attachments as $attachment) {
if (!sizeof($attachment)) {
continue;
}
// We need to reset/empty the _file block var, because this function might be called more than once
$template->destroy_block_vars('_file');
$block_array = array();
// Some basics...
$attachment['extension'] = strtolower(trim($attachment['extension']));
$filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);
$thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']);
$upload_icon = '';
if (isset($extensions[$attachment['extension']])) {
if ($user->img('icon_topic_attach', '') && !$extensions[$attachment['extension']]['upload_icon']) {
$upload_icon = $user->img('icon_topic_attach', '');
} else {
if ($extensions[$attachment['extension']]['upload_icon']) {
$upload_icon = '<img src="' . $phpbb_root_path . $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) . '" alt="" />';
}
}
}
$filesize = get_formatted_filesize($attachment['filesize'], false);
$comment = bbcode_nl2br(censor_text($attachment['attach_comment']));
$block_array += array('UPLOAD_ICON' => $upload_icon, 'FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment);
$denied = false;
if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) {
$denied = true;
$block_array += array('S_DENIED' => true, 'DENIED_MESSAGE' => sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
if (!$denied) {
$l_downloaded_viewed = $download_link = '';
$display_cat = $extensions[$attachment['extension']]['display_cat'];
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
if ($attachment['thumbnail']) {
$display_cat = ATTACHMENT_CATEGORY_THUMB;
} else {
if ($config['img_display_inlined']) {
if ($config['img_link_width'] || $config['img_link_height']) {
//.........这里部分代码省略.........
开发者ID:41px,项目名称:phpbb-auth-passage,代码行数:101,代码来源:functions_content.php
示例4: display_attachments
function display_attachments($forum_id, $attachment_data, &$update_count, $force_physical = false, $parse = false)
{
global $config, $_CLASS;
$datas = array();
$extensions = obtain_attach_extensions();
if (!is_array($update_count)) {
$update_count = array();
}
foreach ($attachment_data as $attachment) {
$attachment['extension'] = strtolower(trim($attachment['extension']));
if (!extension_allowed($forum_id, $attachment['extension'], $extensions)) {
$data['category'] = 'DENIED';
$data['lang'] = sprintf($_CLASS['core_user']->get_lang('EXTENSION_DISABLED_AFTER_POSTING'), $attachment['extension']);
} else {
$filename = $config['upload_path'] . '/' . basename($attachment['physical_filename']);
// to easy isn't it ?
$thumbnail_filename = $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']);
$display_cat = $extensions[$attachment['extension']]['display_cat'];
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE) {
if ($attachment['thumbnail']) {
$display_cat = ATTACHMENT_CATEGORY_THUMB;
} else {
if ($config['img_display_inlined']) {
if ($config['img_link_width'] || $config['img_link_height']) {
list($width, $height) = getimagesize($filename);
$display_cat = !$width && !$height ? ATTACHMENT_CATEGORY_IMAGE : ($width <= $config['img_link_width'] && $height <= $config['img_link_height'] ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE);
}
} else {
$display_cat = ATTACHMENT_CATEGORY_NONE;
}
}
}
switch ($display_cat) {
// Images
case ATTACHMENT_CATEGORY_IMAGE:
$data['category'] = 'IMAGE';
$data['image_src'] = $filename;
//$attachment['download_count']++;
$update_count[] = $attachment['attach_id'];
break;
// Images, but display Thumbnail
// Images, but display Thumbnail
case ATTACHMENT_CATEGORY_THUMB:
$data['category'] = 'THUMBNAIL';
$data['image_src'] = $thumbnail_filename;
$data['link'] = !$force_physical ? generate_link('Forums&file=download&id=' . $attachment['attach_id']) : $filename;
break;
// Windows Media Streams
// Windows Media Streams
case ATTACHMENT_CATEGORY_WM:
$data['category'] = 'WM_STREAM';
$data['link'] = $filename;
// Viewed/Heared File ... update the download count (download.php is not called here)
//$attachment['download_count']++;
$update_count[] = $attachment['attach_id'];
break;
// Real Media Streams
// Real Media Streams
case ATTACHMENT_CATEGORY_RM:
$data['category'] = 'RM_STREAM';
$data['link'] = $filename;
// Viewed/Heared File ... update the download count (download.php is not called here)
//$attachment['download_count']++;
$update_count[] = $attachment['attach_id'];
break;
default:
$data['category'] = 'FILE';
$data['link'] = !$force_physical ? generate_link('Forums&file=download&id=' . $attachment['attach_id']) : $filename;
break;
}
$data['lang_size'] = $attachment['filesize'] >= 1048576 ? round(round($attachment['filesize'] / 1048576 * 100) / 100, 2) . $_CLASS['core_user']->lang['MB'] : ($attachment['filesize'] >= 1024 ? round(round($attachment['filesize'] / 1024 * 100) / 100, 2) . $_CLASS['core_user']->lang['KB'] : $attachment['filesize'] . $_CLASS['core_user']->lang['BYTES']);
$data['lang_views'] = !$attachment['download_count'] ? $_CLASS['core_user']->lang['DOWNLOAD_NONE'] : ($attachment['download_count'] == 1 ? sprintf($_CLASS['core_user']->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($_CLASS['core_user']->lang['DOWNLOAD_COUNTS'], $attachment['download_count']));
$data['icon'] = isset($extensions[$attachment['extension']]['upload_icon']) && $extensions[$attachment['extension']]['upload_icon'] ? $config['upload_icons_path'] . '/' . trim($extensions[$attachment['extension']]['upload_icon']) : false;
$data['name'] = basename($attachment['real_filename']);
$data['comment'] = str_replace("\n", '<br />', censor_text($attachment['comment']));
}
if ($parse) {
$_CLASS['core_template']->assign_vars_array('attachments', $data);
$datas[] = $_CLASS['core_template']->display('modules/Forums/attachments.html', true);
} else {
$datas[] = $data;
}
}
return $datas;
}
开发者ID:BackupTheBerlios,项目名称:viperals-svn,代码行数:85,代码来源:functions_display.php
注:本文中的extension_allowed函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论