Exemplo n.º 1
0
    $cur_post['message'] = $parser->parse_message($cur_post['message'], $cur_post['hide_smilies']);
    // Do signature parsing/caching
    if ($panther_config['o_signatures'] == '1' && $cur_post['signature'] != '' && $panther_user['show_sig'] != '0') {
        if (isset($signature_cache[$cur_post['poster_id']])) {
            $signature = $signature_cache[$cur_post['poster_id']];
        } else {
            $signature = $parser->parse_signature($cur_post['signature']);
            $signature_cache[$cur_post['poster_id']] = $signature;
        }
    } else {
        $signature = '';
    }
    $attachments = array();
    if ($download && isset($results[$cur_post['id']]) && count($results[$cur_post['id']]) > 0) {
        foreach ($results[$cur_post['id']] as $cur_attach) {
            $attachments[] = array('icon' => attach_icon(attach_get_extension($cur_attach['filename'])), 'link' => panther_link($panther_url['attachment'], array($cur_attach['id'])), 'name' => $cur_attach['filename'], 'size' => sprintf($lang_topic['Attachment size'], file_size($cur_attach['size'])), 'downloads' => sprintf($lang_topic['Attachment downloads'], forum_number_format($cur_attach['downloads'])));
        }
    }
    $posts[] = array('id' => $cur_post['id'], 'count' => $post_count++, 'number' => $start_from + $post_count, 'link' => panther_link($panther_url['post'], array($cur_post['id'])), 'posted' => format_time($cur_post['posted']), 'username' => $username, 'user_title' => $user_title, 'poster_id' => $cur_post['poster_id'], 'poster_reputation' => $cur_post['poster_reputation'], 'user_avatar' => $user_avatar, 'group_image' => $group_image, 'edited' => $cur_post['edited'] ? format_time($cur_post['edited']) : '', 'edited_by' => $cur_post['edited_by'], 'edit_reason' => $cur_post['edit_reason'], 'attachments' => $attachments, 'message' => $cur_post['message'], 'signature' => $signature, 'is_online' => $cur_post['is_online'], 'user_info' => $user_info, 'user_contacts' => $user_contacts, 'group_image' => $group_image, 'post_actions' => $post_actions, 'actions' => $actions);
}
$render['posts'] = $posts;
if ($cur_topic['parent']) {
    $render['parent_link'] = panther_link($panther_url['forum'], array($cur_topic['parent_forum'], url_friendly($cur_topic['parent'])));
}
($hook = get_extensions('topic_before_users_online')) ? eval($hook) : null;
if ($panther_config['o_users_online'] == '1') {
    require PANTHER_ROOT . 'lang/' . $panther_user['language'] . '/online.php';
    $guests_in_topic = $users = array();
    $online = $db->run('SELECT o.user_id, o.ident, o.currently, o.logged, u.group_id FROM ' . $db->prefix . 'online AS o INNER JOIN ' . $db->prefix . 'users AS u ON u.id=o.user_id WHERE o.currently LIKE \'%viewtopic.php%\' AND o.idle = 0');
    foreach ($online as $user_online) {
        if (strpos($user_online['currently'], '&p=') !== false) {
Exemplo n.º 2
0
$increase = isset($_POST['auto_increase']) && $_POST['auto_increase'] == '1' ? $start + $limit : $start;
$direction = isset($_POST['direction']) && $_POST['direction'] == '1' ? 'ASC' : 'DESC';
$order = isset($_POST['order']) ? intval($_POST['order']) : 0;
switch ($order) {
    case 1:
        $order = 'a.downloads';
        break;
    case 2:
        $order = 'a.size';
        break;
    case 3:
        $order = 'a.downloads*a.size';
        break;
    case 0:
    default:
        $order = 'a.id';
        break;
}
$data = array(':start' => $start, ':limit' => $limit);
$ps = $db->run('SELECT a.id, a.owner, a.post_id, a.filename, a.extension, a.size, a.downloads, u.username, u.group_id FROM ' . $db->prefix . 'attachments AS a LEFT JOIN ' . $db->prefix . 'users AS u ON u.id=a.owner ORDER BY ' . $order . ' ' . $direction . ' LIMIT :start, :limit', $data);
$page_title = array($panther_config['o_board_title'], $lang_admin_common['Admin'], $lang_admin_common['Attachments']);
define('PANTHER_ACTIVE_PAGE', 'admin');
require PANTHER_ROOT . 'header.php';
generate_admin_menu('attachments');
$attachments = array();
foreach ($ps as $cur_item) {
    $attachments[] = array('icon' => attach_icon($cur_item['extension']), 'link' => panther_link($panther_url['attachment'], array($cur_item['id'])), 'name' => $cur_item['filename'], 'username' => colourize_group($cur_item['username'], $cur_item['group_id'], $cur_item['owner']), 'post_link' => panther_link($panther_url['post'], array($cur_item['post_id'])), 'post_id' => $cur_item['post_id'], 'size' => file_size($cur_item['size']), 'downloads' => forum_number_format($cur_item['downloads']), 'transfer' => file_size($cur_item['size'] * $cur_item['downloads']), 'id' => $cur_item['id']);
}
$tpl = load_template('admin_attachments.tpl');
echo $tpl->render(array('lang_admin_attachments' => $lang_admin_attachments, 'lang_admin_common' => $lang_admin_common, 'form_action' => panther_link($panther_url['admin_attachments']), 'csrf_token' => generate_csrf_token(PANTHER_ADMIN_DIR . '/attachments.php'), 'increase' => $increase, 'start' => $start, 'limit' => $limit, 'order' => $order, 'direction' => $direction, 'attachments' => $attachments));
require PANTHER_ROOT . 'footer.php';
Exemplo n.º 3
0
    }
}
$attach_output = '';
$attach_output_two = '';
//check if this post has attachments, if so make the appropiate output
if ($attach_allow_delete || $attach_allow_owner_delete || $attach_allow_upload) {
    $attach_allowed = true;
    $result_attach = $db->query('SELECT af.id, af.owner, af.filename, af.extension, af.size, af.downloads FROM ' . $db->prefix . 'attach_2_files AS af WHERE post_id=\'' . $id . '\'') or error('Unable to fetch current attachments', __FILE__, __LINE__, $db->error());
    if ($db->num_rows($result_attach) > 0) {
        //time for some output ... create the existing files ...
        $i = 0;
        while (list($attach_id, $attach_owner, $attach_filename, $attach_extension, $attach_size, $attach_downloads) = $db->fetch_row($result_attach)) {
            if ($attach_owner == $pun_user['id'] && $attach_allow_owner_delete || $attach_allow_delete) {
                $attach_output .= '<br />' . "\n" . '<input type="checkbox" name="attach_delete_' . $i . '" value="' . $attach_id . '" />' . $lang_attach['Delete?'] . ' ' . attach_icon($attach_extension) . ' <a href="./attachment.php?item=' . $attach_id . '">' . $attach_filename . '</a>, ' . $lang_attach['Size:'] . ' ' . number_format($attach_size) . ' ' . $lang_attach['bytes'] . ', ' . $lang_attach['Downloads:'] . ' ' . number_format($attach_downloads);
            } else {
                $attach_output_two .= '<br />' . "\n" . attach_icon($attach_extension) . ' <a href="./attachment.php?item=' . $attach_id . '">' . $attach_filename . '</a>, ' . $lang_attach['Size:'] . ' ' . number_format($attach_size) . ' ' . $lang_attach['bytes'] . ', ' . $lang_attach['Downloads:'] . ' ' . number_format($attach_downloads);
            }
            $i++;
        }
        if (strlen($attach_output) > 0) {
            $attach_output = '<input type="hidden" name="attach_num_attachments" value="' . $db->num_rows($result_attach) . '" />' . $lang_attach['Existing'] . $attach_output;
        }
        if (strlen($attach_output_two) > 0) {
            $attach_output .= "<br />\n" . $lang_attach['Existing2'] . $attach_output_two;
        }
        $attach_output .= "<br />\n";
    } else {
        // we have not existing files
    }
}
//fix the 'new upload' field...
function show_attachments_post($attach_list, $post_id, $cur_topic)
{
    global $lang_attach, $forum_page, $forum_config, $attach_url, $forum_user;
    $result = '<div class="attachments"><strong id="attach' . $post_id . '">' . $lang_attach['Post attachs'] . '</strong>';
    $allow_downloading = $forum_user['g_id'] == FORUM_ADMIN || $cur_topic['g_pun_attachment_allow_download'];
    foreach ($attach_list as $attach) {
        if (in_array($attach['file_ext'], array('png', 'jpg', 'gif', 'tiff')) && $forum_config['attach_disp_small'] == '1') {
            list($width, $height, , ) = getimagesize(FORUM_ROOT . $forum_config['attach_basefolder'] . $attach['file_path']);
            $attach['img_width'] = $width;
            $attach['img_height'] = $height;
            $show_image = $attach['img_height'] <= $forum_config['attach_small_height'] && $attach['img_width'] <= $forum_config['attach_small_width'];
        } else {
            $show_image = false;
        }
        $download_link = forum_link($attach_url['misc_download'], $attach['id']);
        $attach_info = format_size($attach['size']) . ', ' . ($attach['download_counter'] ? sprintf($lang_attach['Since'], $attach['download_counter'], date('Y-m-d', $attach['uploaded_at'])) : $lang_attach['Never download']) . '&nbsp;';
        if ($allow_downloading) {
            if ($show_image) {
                $link = '<a href="' . $download_link . '"><img src="' . forum_link($attach_url['misc_view'], $attach['id']) . '" title="' . forum_htmlencode($attach['filename']) . ', ' . format_size($attach['size']) . ', ' . $attach['img_width'] . ' x ' . $attach['img_height'] . '" alt="' . forum_htmlencode($attach['filename']) . ', ' . format_size($attach['size']) . ', ' . $attach['img_width'] . ' x ' . $attach['img_height'] . '" /></a>';
            } else {
                if (in_array($attach['file_ext'], array('png', 'jpg', 'gif', 'tiff'))) {
                    $link = '<a href="' . forum_link($attach_url['misc_preview'], $attach['id']) . '">' . attach_icon($attach['file_ext']) . forum_htmlencode($attach['filename']) . '</a>';
                } else {
                    $link = '<a href="' . $download_link . '">' . attach_icon($attach['file_ext']) . forum_htmlencode($attach['filename']) . '</a>';
                }
            }
        } else {
            $link = '<b>' . forum_htmlencode($attach['filename']) . '</b>';
        }
        $result .= '<p>' . $link;
        if ($show_image) {
            $result .= '<br/>' . forum_htmlencode($attach['filename']) . '&nbsp;' . $attach_info;
        } else {
            $result .= '&nbsp;' . $attach_info;
        }
        $result .= '</p>';
    }
    if (!$allow_downloading) {
        $result .= $lang_attach['Download perm error'];
    }
    $result .= '</div>';
    return $result;
}
Exemplo n.º 5
0
    $attach_output = '';
    //search if we have any orphans
    $result_attach = $db->query('SELECT af.id, af.owner, af.post_id, af.filename, af.extension, af.mime, af.location, af.size, af.downloads FROM `' . $db->prefix . 'attach_2_files` AS af LEFT JOIN `' . $db->prefix . 'posts` AS p ON p.id=af.post_id WHERE p.id IS NULL') or error('Unable to search for orphans', __FILE__, __LINE__, $db->error());
    if ($db->num_rows($result_attach) > 0) {
        // if we have any orphans, output some info
        while (list($attach_id, $attach_owner, $attach_post_id, $attach_filename, $attach_extension, $attach_mime, $attach_location, $attach_size, $attach_downloads) = $db->fetch_row($result_attach)) {
            $attach_output .= '
				<div class="inform">
					<fieldset>
						<legend>Attachment: (' . $attach_id . ') ' . $attach_filename . '</legend>
						<div class="infldset">
						<table class="aligntop" cellspacing="0">
							<tr>
								<th scope="row">Filename</th>
								<td>
									<span>' . attach_icon($attach_extension) . '"<a href="attachment.php?item=' . $attach_id . '">' . $attach_filename . '</a>" Click to view/download. (Location on disk: "' . $attach_location . '")</span>
								</td>
							</tr>
							<tr>
								<th scope="row">Filesize</th>
								<td>
									<span>' . number_format($attach_size) . ' bytes</span>
								</td>
							</tr>
							<tr>
								<th scope="row">Downloads</th>
								<td>
									<span>' . number_format($attach_downloads) . ' downloads</span>
								</td>
							</tr>
							<tr>