PDA

View Full Version : call link from blob field inside vbulletin template


arabuser
05-31-2013, 08:53 PM
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 1370037600 at 1370037600 ---------------


download.php part1

<?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_priva te_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_inval id_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_pas sword');
$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_scr eenshotbit');
$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_fil ebit');
$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_mor ebit');
$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_mir rorbit');
$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",
"&amp;perpage=$perpage&amp;tab=comments&amp;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_wrap per');
$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_inval id_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_inval id_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_priva te_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_inval id_x', $vbphrase['dbtech_downloads_category'], $download['categoryid']));
}

arabuser
05-31-2013, 09:00 PM
download.php part2

if ($vbulletin->GPC['downloadid'])
{
// Grab our permissions
$permissions = VBDOWNLOADS::fetchPermissions($download, $category);
}
else
{
// Grab our permissions
$permissions = VBDOWNLOADS::fetchPermissions(NULL, $category);
}

if (!$permissions['canupload'])
{
// We can't upload
print_no_permission();
}

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']]));
}

if ($vbulletin->GPC['downloadid'])
{
// Add to the navbits
$navbits[$vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'categoryid=' . $category['categoryid']] = $category['title'];
$navbits[$vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'do=download&amp;downloadid=' . $download['downloadid']] = $download['title'];
$navbits[''] = $pagetitle = construct_phrase($vbphrase['dbtech_downloads_editing_download_x'], $download['title']);
}
else
{
// Add to the navbits
$navbits[$vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'categoryid=' . $category['categoryid']] = $category['title'];
$navbits[''] = $pagetitle = $vbphrase['dbtech_downloads_add_new_download'];
}


for ($i = 0; $i < 10; $i++)
{
if (!isset($download['mirrors'][$i]))
{
// Default value
$download['mirrors'][$i] = array(
'link' => 'http://',
'hits' => 0,
);
}
else
{
if (!is_array($download['mirrors'][$i]))
{
// Need to convert it to array
$download['mirrors'][$i] = array(
'link' => $download['mirrors'][$i],
'hits' => 0,
);
}

if (!$download['mirrors'][$i]['link'])
{
// Set this to default
$download['mirrors'][$i]['link'] = 'http://';
}
else
{
// Ensure this is safe
$download['mirrors'][$i]['link'] = htmlspecialchars_uni($download['mirrors'][$i]['link']);
}
}
}

if ($download['password'])
{
// Set placeholder password
$download['password'] = '!>=Password=<!';
}

$extensioninfo = '';
$extensions = array();
foreach (VBDOWNLOADS::$cache['extension'] as $extension)
{
if (!in_array($extension['extensiongroupid'], $category['extensiongroups']))
{
// Not in allowed extension group
continue;
}

// Add to allowed extensions
$extensions[] = $extension['extension'];

$templater = vB_Template::create('dbtech_downloads_modify_exten sionbit');
$templater->register('extension', $extension['extension']);
$templater->register('maxsize', vb_number_format($extension['maxsize'], 2, true));
$extensioninfo .= $templater->render();
}

// Grab ordered list
$categoryList = construct_ordered_categories();

// Construct the list of select options
construct_category_select_options($categories, $categoryList);

$categoryOptions = '';
foreach ($categories as $categoryid => $title)
{
if (in_array($categoryid, $_excludeCategories))
{
// Can't view category
continue;
}

if (!$category = VBDOWNLOADS::$cache['category'][$categoryid])
{
// Invalid category
continue;
}

if (!is_array($category['permissions']['upload']))
{
$category['permissions']['upload'] = array();
}

$allowUgs = array();
foreach ($category['permissions']['upload'] as $usergroupid => $canupload)
{
if ($canupload)
{
// This UG can upload this
$allowUgs[] = $usergroupid;
}
}

if (
!count($allowUgs) OR
!is_member_of($vbulletin->userinfo, $allowUgs)/* OR (
$category['ownerid'] AND
$category['ownerid'] != $vbulletin->userinfo['userid'] AND
!VBDOWNLOADS::$permissions['ismanager']
)*/
)
{
// We can't access this category
continue;
}

$templater = vB_Template::create('option');
$templater->register('optionselected', $download['categoryid'] == $categoryid ? 'selected="selected"' : '');
$templater->register('optionvalue', $categoryid);
$templater->register('optiontitle', htmlspecialchars_uni($title));
$categoryOptions .= $templater->render();
}

require_once(DIR . '/includes/functions_editor.php');
$editorid = construct_edit_toolbar($download['description'], false, 'nonforum', false, false, false);

// Mail sending form
$page_templater = vB_Template::create('dbtech_downloads_modify');
$page_templater->register('download', $download);
$page_templater->register('editorid', $editorid);
$page_templater->register('messagearea', $messagearea);
$page_templater->register('categories', $categoryOptions);
$page_templater->register('extensioninfo', $extensioninfo);
$page_templater->register('extensions', implode('|', $extensions));
$page_templater->register('jQueryPath', VBDOWNLOADS::jQueryPath());
$page_templater->register('jQueryUiPath', VBDOWNLOADS::jQueryUiPath());
$HTML = $page_templater->render();
}

// ################################################## ###########################
if ($_POST['action2'] == 'update')
{
// Grab stuff
$vbulletin->input->clean_array_gpc('p', array(
'downloadid' => TYPE_UINT,
'download' => TYPE_ARRAY,
'wysiwyg' => TYPE_BOOL,
'subject' => TYPE_STR,
'message' => TYPE_STR,
'users' => TYPE_STR,
'filelist' => TYPE_ARRAY,
));

if ($vbulletin->GPC['subject'] == '' OR $vbulletin->GPC['message'] == '')
{
// Something was missin'
eval(standard_error(fetch_error('please_complete_r equired_fields')));
}

if (in_array($vbulletin->GPC['download']['categoryid'], $_excludeCategories))
{
// Can't view category
print_no_permission();
}

if ($vbulletin->GPC['wysiwyg'])
{
// We were using WYSIWYG editor
if (!file_exists(DIR . '/includes/functions_wysiwyg.php'))
{
// New editor
require_once(DIR . '/includes/class_wysiwygparser.php');
$html_parser = new vB_WysiwygHtmlParser($vbulletin);
$message = $html_parser->parse_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], true);
}
else
{
// Old editor
require_once(DIR . '/includes/functions_wysiwyg.php');
$message = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], true);
}
}
else
{
// Not WYSIWYG, interpret as-is
$message = $vbulletin->GPC['message'];
}

if (!function_exists('convert_url_to_bbcode'))
{
// Ensure we can convert URL to BBCode
require_once(DIR . '/includes/functions_newpost.php');
}

// Convert URL to BBCode
$vbulletin->GPC['download']['description'] = convert_url_to_bbcode($message);

if (!$category = VBDOWNLOADS::$cache['category'][$vbulletin->GPC['download']['categoryid']])
{
// Invalid category
standard_error(fetch_error('dbtech_downloads_inval id_x', $vbphrase['dbtech_downloads_category'], $vbulletin->GPC['download']['categoryid']));
}

$vbulletin->GPC['download']['private'] = array();
if ($category['canprivate'])
{
// We can have private downloads
$users = preg_split('#\s*,\s*#s', $vbulletin->GPC['users'], -1, PREG_SPLIT_NO_EMPTY);

$lookup = array();
foreach ($users as $username)
{
if (!$username)
{
// Just in case
continue;
}

// Lookup userid
$lookup[] = htmlspecialchars_uni($username);
}

if (count($lookup))
{
$vbulletin->GPC['download']['private'] = VBDOWNLOADS::$db->fetchAllSingleKeyed('SELECT username, userid FROM $user WHERE username :queryList', 'username', 'userid', array(':queryList' => VBDOWNLOADS::$db->queryList($lookup)));
}
}

if ($vbulletin->GPC['download']['password'])
{
// We have a password of some description
if (!$category['canpassword'])
{
// We couldn't have passworded downloads
$vbulletin->GPC['download']['password'] = '';
}
else if ($vbulletin->GPC['download']['password'] != '!>=Password=<!')
{
// hash the new password
$vbulletin->GPC['download']['password'] = md5($vbulletin->GPC['download']['password']);
}
else
{
// Our password was the PH pass, don't update it
unset($vbulletin->GPC['download']['password']);
}
}

if ($vbulletin->GPC['downloadid'])
{
// Grab the download
$download = VBDOWNLOADS::$db->fetchRow('SELECT * FROM $dbtech_downloads_download WHERE downloadid = ?', array($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_priva te_file_error'));
}
}
else
{
// I'm being lazy
$vbulletin->GPC['download']['userid'] = $vbulletin->userinfo['userid'];
}

for ($i = 0; $i < 10; $i++)
{
if (!isset($vbulletin->GPC['download']['mirrors'][$i]))
{
// Default value
$vbulletin->GPC['download']['mirrors'][$i] = array(
'link' => 'http://',
'hits' => 0,
);
}
else
{
if (!is_array($vbulletin->GPC['download']['mirrors'][$i]))
{
// Need to convert it to array
$vbulletin->GPC['download']['mirrors'][$i] = array(
'link' => $vbulletin->GPC['download']['mirrors'][$i],
'hits' => 0,
);
}

if (!$vbulletin->GPC['download']['mirrors'][$i]['link'])
{
// Set this to default
$vbulletin->GPC['download']['mirrors'][$i]['link'] = 'http://';
}
}
}

// I'm being lazy
$vbulletin->GPC['download']['title'] = $vbulletin->GPC['subject'];

// Update numfiles from form
$vbulletin->GPC['download']['numfiles'] = count($vbulletin->GPC['filelist']);

// init data manager
$dm =& VBDOWNLOADS::initDataManager('Download', $vbulletin, ERRTYPE_STANDARD);

// set existing info if this is an update
if ($vbulletin->GPC['downloadid'])
{
// Set existing
$dm->set_existing($download);
}

// download fields
foreach ($vbulletin->GPC['download'] AS $key => $val)
{
if (!$vbulletin->GPC['downloadid'] OR $existing[$key] != $val)
{
// Only set changed values
$dm->set($key, $val);
}
}

// Save! Hopefully.
$downloadid = $vbulletin->GPC['download']['downloadid'] = $dm->save();

if ($vbulletin->GPC['downloadid'])
{
// Ensure this is set
$downloadid = $vbulletin->GPC['download']['downloadid'] = $vbulletin->GPC['downloadid'];
}
/*DBTECH_PRO_START*/
else
{
if (class_exists('VBSHOUT'))
{
foreach ((array)VBSHOUT::$cache['instance'] as $instanceid => $instance)
{
// Init the Shout DM
$shout = VBSHOUT::initDataManager('Shout', $vbulletin, ERRTYPE_SILENT);
$shout->set_info('automated', true);
$shout->set('message', construct_phrase($vbphrase['dbtech_downloads_vbshout_message'],
$vbulletin->options['bburl'],
$vbulletin->options['dbtech_downloads_link'],
$downloadid,
$vbulletin->db->escape_string($vbulletin->GPC['subject']))
);
$shout->set('userid', $vbulletin->userinfo['userid']);
$shout->set('type', VBSHOUT::$shouttypes['notif']);
$shout->set('instanceid', $instanceid);
$shout->save();
unset($shout);
}
}

if ($category['forumid'])
{
// Post a new thread
$thread =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$thread->set('title', VBDOWNLOADS::convertVars($vbulletin->options['dbtech_downloads_thread_title'], $vbulletin->GPC['download']));
$thread->set('pagetext', VBDOWNLOADS::convertVars($vbulletin->options['dbtech_downloads_thread_message'], $vbulletin->GPC['download']));
$thread->set('forumid', $category['forumid']);
$thread->set('userid', $vbulletin->userinfo['userid']);
$thread->set('allowsmilie', true);
$thread->set('visible', true);
$thread->save();

require_once(DIR . '/includes/functions_databuild.php');
build_forum_counters($category['forumid']);
}
}
/*DBTECH_PRO_END*/

if (count($vbulletin->GPC['filelist']))
{
$fileIds = array();
foreach ($vbulletin->GPC['filelist'] as $fileid => $fileinfo)
{
$fileIds[] = $fileid;
}

$fileList = VBDOWNLOADS::$db->fetchAllKeyed('
SELECT *
FROM $dbtech_downloads_file
WHERE fileid :queryList
', 'fileid', array(
':queryList' => VBDOWNLOADS::$db->queryList($fileIds),
));

foreach ($vbulletin->GPC['filelist'] as $fileid => $fileinfo)
{
if (!is_array($fileList[$fileid]))
{
if (!$vbulletin->GPC['downloadid'])
{
VBDOWNLOADS::$db->delete('dbtech_downloads_file', array($fileid), 'WHERE fileid = ?');
VBDOWNLOADS::$db->query('UPDATE $dbtech_downloads_download SET numfiles = numfiles - 1 WHERE downloadid = ?', array($downloadid));
}

// Skip this
continue;
}

// Update the file
$dm =& VBDOWNLOADS::initDataManager('File', $vbulletin, ERRTYPE_SILENT);
$dm->set_existing($fileList[$fileid]);
$dm->set('downloadid', $downloadid);
$dm->set('screenshot', $fileinfo['screenshot']);
$dm->set('thumbnail', $fileinfo['thumbnail']);
$dm->save();
}
}

$vbulletin->url = $vbulletin->options['dbtech_downloads_link'] . '.php?' . $vbulletin->session->vars['sessionurl'] . 'do=download&amp;downloadid=' . $downloadid;
eval(print_standard_redirect('redirect_dbtech_down loads_file_added'));
}
?>

kh99
05-31-2013, 11:02 PM
It looks like it's serialized, so you need to unserialize() it before using it. If you look at the code you posted you'll see this being done:
$mirrorList = @unserialize($download['mirrors']);

arabuser
06-01-2013, 12:05 AM
I do not know about coding :) how I do this and how I call specific link in that blob field

kh99
06-01-2013, 12:57 AM
Oh, I see now that you said you're trying to use it in a template. Which template? Also, that looks like vb4 code but this is the vb3 section - which version are you using?

arabuser
06-01-2013, 01:10 AM
yes im try to call it inside one of these template dbtech_downloads_download or dbtech_downloads_download_mirrorbit
vbdownload is working on both vb4 and vb3 im using it on vb3


dbtech_downloads_download currently have this code for mirrors links calling

<if condition="$download['mirrorList'] AND $vboptions['dbtech_downloads_mirrors_enabled']">
<h2 class="downloads-filelist-heading">$vbphrase[dbtech_downloads_mirrors]</h2>
<ul class="stats">
$download[mirrorList]

</ul>

dbtech_downloads_download_mirrorbit currently have this code


<li class="downloads-filebits">
$i. &nbsp; <a href="$vboptions[dbtech_downloads_link].php?$session[sessionurl]do=file&amp;action=mirror&amp;downloadid=$download[downloadid]&amp;mirrorid=$i" target="_blank"><if condition="$mirror['image']"><img src="$mirror[image]" alt="" /><else />$mirror[link]</if></a>
<span style="float:$stylevar[right];">
<span class="smallfont"><a href="javascript://" name="report" data-reportform="link" data-contentid="$download[downloadid]">[$vbphrase[dbtech_downloads_report_link]]</a></span> &nbsp;&nbsp; <phrase 1="$mirror[hits]">$vbphrase[dbtech_downloads_mirror_x_hits]</phrase><br />
</span>
</li>

kh99
06-01-2013, 01:18 AM
OK, in dbtech_downloads_download_mirrorbit, try $mirror[link]. In dbtech_downloads_download, maybe $mirrorList[X] (where X is a number). I'm guessing a bit since you posted the vb4 code, it could be different in the vb3 version.

Have you thought about asking at the dbtech site?

arabuser
06-01-2013, 01:34 AM
$mirror[link] in dbtech_downloads_download_mirrorbit
list all the links in sequence if i tried $mirror[link][x] not work

$mirrorList[X] in dbtech_downloads_download
nothing happen

yes I posted on their topic here nobody answered me when i posted it in their website one of their team said (that's a customization too complex for me to help with, sorry) :(

kh99
06-01-2013, 01:48 AM
$mirror[link] in dbtech_downloads_download_mirrorbit
list all the links in sequence

Well, dbtech_downloads_download_mirrorbit is repeated once for each mirror, so that's probably why you're seeing all of them.

I'm not sure what else to tell you. Maybe someone else will have an idea.

arabuser
06-01-2013, 01:54 AM
thanks man, I will continue try maybe i find a suitable way

arabuser
06-02-2013, 05:16 PM
well finally i found the suitable way as following

<if condition="$mirrorid=$i == 1">$mirror[link]</if>
<if condition="$mirrorid=$i == 2">$mirror[link]</if>

I used if condition to check the mirror link numer :)