arabuser |
05-31-2013 08:53 PM |
call link from blob field inside vbulletin template
hi im try to call specific links of blob field from vbdownload table inside vbulletin template
I tried $download[mirrorid][1] which 1 is the link id number but this didn't work with me it is seems mirrors filed is array and I dont know how to call the link from this array.
here is the tables and download.php
dbtech_downloads_download
https://vborg.vbsupport.ru/external/2013/05/1.jpg
dbtech_downloads_file
https://vborg.vbsupport.ru/external/2013/05/2.jpg
and the next post have the download.php file
--------------- Added [DATE]1370037600[/DATE] at [TIME]1370037600[/TIME] ---------------
download.php part1
PHP Code:
<?php
// ############################################################################# if ($_REQUEST['action'] == 'download' OR empty($_REQUEST['action'])) { $vbulletin->input->clean_gpc('r', 'downloadid', TYPE_UINT); $vbulletin->input->clean_gpc('r', 'fileid', TYPE_UINT);
if ($vbulletin->GPC['fileid'] AND !$vbulletin->GPC['downloadid']) { // Override to support old links $vbulletin->GPC['downloadid'] = $vbulletin->GPC['fileid']; }
$download = VBDOWNLOADS::$db->fetchRow(' SELECT user.*, download.* FROM $dbtech_downloads_download AS download LEFT JOIN $user AS user USING(userid) WHERE downloadid = ? ', array( $vbulletin->GPC['downloadid'], ));
// No hacsors here please $download['title'] = htmlspecialchars_uni($download['title']);
if ($download['moderation'] AND !VBDOWNLOADS::$permissions['ismanager']) { // File is under moderation standard_error(fetch_error('dbtech_downloads_file_being_reviewed')); }
$download['private'] = @unserialize($download['private']); if ( !is_array($download['private']) OR !count($download['private']) OR VBDOWNLOADS::$permissions['ismanager'] OR ( in_array($vbulletin->userinfo['userid'], $download['private']) AND $vbulletin->userinfo['userid'] ) OR ( $download['userid'] == $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['userid'] ) ) { // Grab musername $download['musername'] = fetch_musername($download); // Sort date and time $download['date'] = vbdate($vbulletin->options['dateformat'], $download['updated'], true); $download['time'] = vbdate($vbulletin->options['timeformat'], $download['updated']); } else { // Private download standard_error(fetch_error('dbtech_downloads_private_file_error')); }
if (in_array($download['categoryid'], $_excludeCategories)) { // Can't view category print_no_permission(); }
if (!$category = VBDOWNLOADS::$cache['category'][$download['categoryid']]) { // Invalid category standard_error(fetch_error('dbtech_downloads_invalid_x', $vbphrase['dbtech_downloads_category'], $download['categoryid'])); }
if ($category['parentid']) { // Store immediate category $parentCategory = VBDOWNLOADS::$cache['category'][$category['parentid']];
do { // Add to the navbits $navbits[$vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'categoryid=' . $parentCategory['categoryid']] = $parentCategory['title'];
if (isset(VBDOWNLOADS::$cache['category'][$parentCategory['parentid']])) { // Store -its- $parentCategory = VBDOWNLOADS::$cache['category'][$parentCategory['parentid']]; } } while (isset(VBDOWNLOADS::$cache['category'][$parentCategory['parentid']])); }
// Add to the navbits $navbits[$vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'categoryid=' . $category['categoryid']] = $category['title']; $navbits[''] = $pagetitle = $download['title'];
// Update cookie if we have one $vbulletin->input->clean_array_gpc('c', array( COOKIE_PREFIX . 'downloadpass_' . $download['downloadid'] => TYPE_STR, ));
if ( $download['password'] AND !VBDOWNLOADS::$permissions['ismanager'] AND $download['userid'] != $vbulletin->userinfo['userid'] AND md5($download['password'] . COOKIE_SALT) != $vbulletin->GPC[COOKIE_PREFIX . 'downloadpass_' . $download['downloadid']] ) { // We need to confirm password $page_templater = vB_Template::create('dbtech_downloads_download_password'); $page_templater->register('pagetitle', $pagetitle); $page_templater->register('download', $download); $HTML = $page_templater->render(); } else { // Grab our permissions $permissions = VBDOWNLOADS::fetchPermissions($download, $category);
if (!$permissions['canview']) { // We can't view print_no_permission(); }
if ($vbulletin->userinfo['dbtech_downloads_favourites']) { // Legacy code $favourites = @unserialize($vbulletin->userinfo['dbtech_downloads_favourites']); foreach ((array)$favourites as $downloadid) { // Insert new favourites VBDOWNLOADS::$db->insert('dbtech_downloads_favourite', array('userid' => $vbulletin->userinfo['userid'], 'downloadid' => $downloadid)); }
// Update old favourites VBDOWNLOADS::$db->update('user', array('dbtech_downloads_favourites' => ''), 'WHERE userid = ' . $vbulletin->userinfo['userid']); }
$isFavourite = VBDOWNLOADS::$db->fetchRow(' SELECT * FROM $dbtech_downloads_favourite WHERE userid = ? AND downloadid = ? ', array( $vbulletin->userinfo['userid'], $download['downloadid'], )); $show['is_favourite'] = ($isFavourite !== false AND count($isFavourite));
// We either don't need a password or we're all good require_once (DIR . '/includes/class_bbcode.php'); $parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
// Fix description $download['description'] = $parser->parse($download['description'], 'nonforum', true, false);
/*DBTECH_PRO_START*/ if ($vbulletin->options['dbtech_downloads_rate'] AND $permissions['canrate']) { $hasRated = VBDOWNLOADS::$db->fetchRow(' SELECT * FROM $dbtech_downloads_rating WHERE userid = ? AND downloadid = ? ', array( $vbulletin->userinfo['userid'], $download['downloadid'], ));
$show['ratingcontrols'] = empty($hasRated); } /*DBTECH_PRO_END*/
$fileList = VBDOWNLOADS::$db->fetchAll(' SELECT * FROM $dbtech_downloads_file WHERE downloadid = ? ', array( $vbulletin->GPC['downloadid'], ));
// Init these $download['fileList'] = $download['mirrorList'] = $download['screenshotList'] = $download['moreList'] = '';
foreach ($fileList as $file) { if ($file['screenshot']) { // This was a screenshot $templater = vB_Template::create('dbtech_downloads_download_screenshotbit'); $templater->register('file', $file); $download['screenshotList'] .= $templater->render(); continue; }
// Do file size $file['filesize'] = vb_number_format($file['filesize'], 2, true);
// Regular file $templater = vB_Template::create('dbtech_downloads_download_filebit'); $templater->register('file', $file); $templater->register('permissions', $permissions); $download['fileList'] .= $templater->render(); }
$moreList = VBDOWNLOADS::$db->fetchAll(' SELECT * FROM $dbtech_downloads_download WHERE downloadid != ? AND userid = ? AND moderation = 0 ORDER BY RAND() LIMIT :limit ', array( $download['downloadid'], $download['userid'], ':limit' => $vbulletin->options['dbtech_downloads_moremax'] )); foreach ($moreList as $file) { // No hacsors please $file['title'] = htmlspecialchars_uni($file['title']);
// Add this download $templater = vB_Template::create('dbtech_downloads_download_morebit'); $templater->register('download', $file); $download['moreList'] .= $templater->render(); }
/*DBTECH_PRO_START*/ $domains = array(); foreach (VBDOWNLOADS::$cache['domain'] as $domainid => $domain) { if (!$domain['active']) { // Skip inactives continue; }
// Store domains by domain $domains[$domain['domain']] = str_replace('./', '', $domain['image']); } /*DBTECH_PRO_END*/
$i = 1; $mirrorList = @unserialize($download['mirrors']); $mirrorList = is_array($mirrorList) ? $mirrorList : array(); foreach ($mirrorList as $file) { if (!is_array($file)) { $file = array( 'link' => $file, 'hits' => 0, ); }
if ($file['link'] == 'http://') { // Skip this continue; }
/*DBTECH_PRO_START*/ $domain = str_replace('www.', '', parse_url($file['link'], PHP_URL_HOST)); if (isset($domains[$domain])) { // Set image $file['image'] = $domains[$domain]; } /*DBTECH_PRO_END*/
// Format the hit counter $file['hits'] = vb_number_format($file['hits']);
// Add this download $templater = vB_Template::create('dbtech_downloads_download_mirrorbit'); $templater->register('i', $i++); $templater->register('mirror', $file); $templater->register('download', $download); $download['mirrorList'] .= $templater->render(); }
if (($download['userid'] == $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['userid']) OR VBDOWNLOADS::$permissions['ismanager']) { // We can manage screenshots and the file itself $show['screenshot'] = $show['edit_file'] = $show['delete_file'] = true; }
// Init this $download['comments'] = '';
// Display file list do { if (!$count = VBDOWNLOADS::$db->fetchOne(' SELECT COUNT(*) FROM $dbtech_downloads_comment WHERE downloadid = ? ', array( $download['downloadid'] ))) { // We need at least one file break; }
$vbulletin->input->clean_array_gpc('r', array( 'pagenumber' => TYPE_UINT, 'perpage' => TYPE_UINT, ));
// Ensure there's no errors or out of bounds with the page variables if ($vbulletin->GPC['pagenumber'] < 1) { $vbulletin->GPC['pagenumber'] = 1; } $pagenumber = $vbulletin->GPC['pagenumber']; $perpage = (!$vbulletin->GPC['perpage'] OR $vbulletin->GPC['perpage'] > 25) ? 25 : $vbulletin->GPC['perpage'];
// Ensure every result is as it should be sanitize_pageresults($count, $pagenumber, $perpage);
$startat = ($pagenumber - 1) * $perpage;
// Constructs the page navigation $pagenav = construct_page_nav( $pagenumber, $perpage, $count, $vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . "do=download", "&perpage=$perpage&tab=comments&downloadid=" . $download['downloadid'] );
if (!$results = VBDOWNLOADS::$db->fetchAll(' SELECT user.*, comment.* ' . ($vbulletin->options['avatarenabled'] ? ', avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight, customavatar.height_thumb AS avheight_thumb, customavatar.width_thumb AS avwidth_thumb, customavatar.filedata_thumb' : '') . ' FROM $dbtech_downloads_comment AS comment INNER JOIN $user AS user USING(userid) ' . ($vbulletin->options['avatarenabled'] ? " LEFT JOIN " . TABLE_PREFIX . "avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN " . TABLE_PREFIX . "customavatar AS customavatar ON (customavatar.userid = user.userid) " : '') . ' WHERE comment.downloadid = ? ORDER BY comment.dateline DESC LIMIT :limitStart, :limitEnd ', array( ':limitStart' => $startat, ':limitEnd' => $perpage, $download['downloadid'] ))) { // We need at least one limiter break; }
require_once (DIR . '/includes/class_bbcode.php'); $parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
if (!function_exists('fetch_avatar_from_userinfo')) { // Get the avatar function require_once(DIR . '/includes/functions_user.php'); }
$comments = ''; foreach ($results as $comment) { // Fix date $comment['date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline'], true); $comment['time'] = vbdate($vbulletin->options['timeformat'], $comment['dateline']); // Grab markup username $comment['musername'] = fetch_musername($comment);
// Fix description $comment['comment'] = $parser->parse($comment['comment'], 'nonforum', true, false);
// grab avatar from userinfo fetch_avatar_from_userinfo($comment);
// Set delete permissions $comment['canmanage'] = (($comment['userid'] == $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['userid']) OR VBDOWNLOADS::$permissions['ismanager']);
// Advanced search $templater = vB_Template::create('dbtech_downloads_comment_bit'); $templater->register('comment', $comment); $comments .= $templater->render(); }
// Advanced search $templater = vB_Template::create('dbtech_downloads_comment_wrapper'); $templater->register('comments', $comments); $templater->register('pagenav', $pagenav); $download['comments'] = $templater->render(); } while (false);
$page_templater = vB_Template::create('dbtech_downloads_download'); $page_templater->register('pagetitle', $pagetitle); $page_templater->register('download', $download); $page_templater->register('category', $category); $page_templater->register('permissions', $permissions); $HTML = $page_templater->render(); } }
// ############################################################################# if ($_POST['action'] == 'setpassword') { $vbulletin->input->clean_array_gpc('p', array( 'downloadid' => TYPE_UINT, 'vb_login_password' => TYPE_STR, 'vb_login_md5password' => TYPE_STR, 'vb_login_md5password_utf' => TYPE_STR, ));
$downloadPass = VBDOWNLOADS::$db->fetchOne(' SELECT password FROM $dbtech_downloads_download AS download WHERE downloadid = ? ', array( $vbulletin->GPC['downloadid'], ));
if ( $downloadPass != ($vbulletin->GPC['vb_login_password'] AND !$vbulletin->GPC['vb_login_md5password'] ? md5($vbulletin->GPC['vb_login_password']) : '') AND $downloadPass != ($vbulletin->GPC['vb_login_md5password'] ? $vbulletin->GPC['vb_login_md5password'] : '') AND $downloadPass != ($vbulletin->GPC['vb_login_md5password_utf'] ? $vbulletin->GPC['vb_login_md5password_utf'] : '') ) { // Wrong password standard_error(fetch_error('dbtech_downloads_invalid_password')); }
// Set the password cookie vbsetcookie('downloadpass_' . $vbulletin->GPC['downloadid'], md5($downloadPass . COOKIE_SALT), true, true, true);
// Do ze redirect exec_header_redirect($vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'do=download&downloadid=' . $vbulletin->GPC['downloadid']); }
// ############################################################################# if ($_REQUEST['action'] == 'modify') { $vbulletin->input->clean_gpc('r', 'downloadid', TYPE_UINT); $vbulletin->input->clean_gpc('r', 'categoryid', TYPE_UINT);
if (!$vbulletin->GPC['downloadid'] AND !$vbulletin->GPC['categoryid']) { // Git oot. print_no_permission(); }
$download = array( 'title' => '', 'description' => '', 'mirrors' => array(), 'private' => '', 'categoryid' => $vbulletin->GPC['categoryid'], ); if ($vbulletin->GPC['downloadid']) { // Grab the download if (!$download = VBDOWNLOADS::$db->fetchRow('SELECT * FROM $dbtech_downloads_download WHERE downloadid = ?', array($vbulletin->GPC['downloadid']))) { // Invalid download standard_error(fetch_error('dbtech_downloads_invalid_x', $vbphrase['dbtech_downloads_download'], $vbulletin->GPC['downloadid'])); }
if ($download['moderation'] AND !VBDOWNLOADS::$permissions['ismanager']) { // File is under moderation standard_error(fetch_error('dbtech_downloads_file_being_reviewed')); }
if ( !VBDOWNLOADS::$permissions['ismanager'] AND $download['userid'] != $vbulletin->userinfo['userid'] AND $vbulletin->userinfo['userid'] ) { // Private download standard_error(fetch_error('dbtech_downloads_private_file_error')); }
// No hacsors here please $download['title'] = htmlspecialchars_uni($download['title']);
// Unserialize these $download['private'] = @unserialize($download['private']); $download['mirrors'] = @unserialize($download['mirrors']);
if (!is_array($download['private']) OR !count($download['private'])) { // Init this $download['private'] = ''; } else { // Construct a comma-separated list of users $download['private'] = implode(',', VBDOWNLOADS::$db->fetchAllSingleKeyed(' SELECT username, userid FROM $user WHERE userid :queryList ', 'userid', 'username', array( ':queryList' => VBDOWNLOADS::$db->queryList($download['private']) ))); } }
if (!$category = VBDOWNLOADS::$cache['category'][$download['categoryid']]) { // Invalid category standard_error(fetch_error('dbtech_downloads_invalid_x', $vbphrase['dbtech_downloads_category'], $download['categoryid'])); }
|