Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2013, 08:53 PM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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



dbtech_downloads_file



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($vbulletinfetch_tag_list());

        
// Fix description
        
$download['description'] = $parser->parse($download['description'], 'nonforum'truefalse);

        
/*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'], 2true);

            
// 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",
                
"&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($vbulletinfetch_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'truefalse);

                
// 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), truetruetrue);

    
// 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']));
    }
Reply With Quote
  #2  
Old 05-31-2013, 09:00 PM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

download.php part2

PHP Code:
    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_extensionbit');
            
$templater->register('extension',     $extension['extension']);
            
$templater->register('maxsize',     vb_number_format($extension['maxsize'], 2true));
        
$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'falsefalsefalse);
    
    
// 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_required_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_invalid_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'], -1PREG_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_private_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'$vbulletinERRTYPE_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'$vbulletinERRTYPE_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'$vbulletinERRTYPE_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'$vbulletinERRTYPE_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_downloads_file_added'));
}
?> 
Reply With Quote
  #3  
Old 05-31-2013, 11:02 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
Code:
        $mirrorList = @unserialize($download['mirrors']);
Reply With Quote
  #4  
Old 06-01-2013, 12:05 AM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I do not know about coding how I do this and how I call specific link in that blob field
Reply With Quote
  #5  
Old 06-01-2013, 12:57 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 06-01-2013, 01:10 AM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

PHP Code:
        <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

PHP 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=$itarget="_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
Reply With Quote
  #7  
Old 06-01-2013, 01:18 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #8  
Old 06-01-2013, 01:34 AM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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)
Reply With Quote
  #9  
Old 06-01-2013, 01:48 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by arabuser View Post
$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.
Reply With Quote
  #10  
Old 06-01-2013, 01:54 AM
arabuser arabuser is offline
 
Join Date: Aug 2004
Posts: 43
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks man, I will continue try maybe i find a suitable way
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:31 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09467 seconds
  • Memory Usage 2,709KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (4)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete