Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2009
    Posts
    90
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Making output in to a hyperlink

    Hello I have a .php page that will display a link to download a file but it only appears as text rather that a hyper link, it may be simple to do but my .php skills are very basic the code is below

    The particular bit of the code i need to modify is this below, i dont know but maybe changing print to echo?
    PHP Code:
    if ($dbim->num_rows($mirrors_result) == 1)
                {
                    
    $error_message $lm->language('frontend''error_no_file');
                    
    $error $uim->fetch_template('global/error');
                    
    $error->assign_var('error_message'$error_message);
                    
                    
    // Go
                    
    print(http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show='.$mirror['url']);    
                
    $error->show(); 

    The full .php page is below


    PHP Code:
    <?php
    /**********************************
    * Olate Download 3.4.1
    * http://www.olate.co.uk/od3
    **********************************
    * Copyright Olate Ltd 2005
    *
    * @author $Author: dsalisbury $ (Olate Ltd)
    * @version $Revision: 259 $
    * @package od
    *
    * Updated: $Date: 2006-10-10 20:27:12 +0100 (Tue, 10 Oct 2006) $
    */

    // Initialisation
    require('./includes/init.php');

    // Show categories
    $fcm->show_cats();

    // Start sessions
    session_start();

    // 1. Check isset($input'file']) then get details
    if (isset($input['file']))
    {    
        
    validate_types($input, array('file' => 'INT''go' => 'INT''mirror' => 'INT'));
        
        
    // Get file details
        
    $details $fldm->get_details($input['file']);
        
        if (empty(
    $details['password']) || isset($_SESSION[$input['file'].'_auth']))
        {    
            
    // 2. If page called !isset($input['go']) and there is an agreement, display
            
    if (!isset($input['go']) && $details['id'] != && !empty($details['agreement_id']))
            {
                
    // Get the agreement
                
    $agreement $fldm->get_agreement($details['agreement_id']);        
                
    $agreement_template $uim->fetch_template('files/agreement');        
                
    $agreement_template->assign_vars(array('agreement' => $agreement,
                                                        
    'file_id' => $details['id']));                            

        
                
    $agreement_template->show();
            }
            
    // 3. If !isset($input['go']) || $input['go'] == 1 check !empty($details) and get mirror data
            
    elseif (!isset($input['go']) || $input['go'] == 1)
            {    
                if (!empty(
    $details))
                {    
                    
    // Get mirrors
                    
    $mirrors_result $dbim->query('SELECT id, file_id, name, location, url
                                                    FROM '
    .DB_PREFIX.'mirrors
                                                    WHERE (file_id = '
    .$input['file'].')');
                    
                    
    // 4. If $dbim->num_rows($mirrors_result) == 1 redirect to get it
                    
    if ($dbim->num_rows($mirrors_result) == 1)
                    {                
                        
    $mirror $dbim->fetch_array($mirrors_result);
                        
    header('Location: download.php?go=2&file='.$input['file'].'&mirror='.$mirror['id']);
                    }
                    
    // 5. If $dbim->num_rows($mirrors_result) > 1 get and display list
                    
    elseif ($dbim->num_rows($mirrors_result) > 1)
                    {
                        
    // Fetch and display
                        
    $mirrors_template $uim->fetch_template('files/mirrors');
                        
                        while (
    $mirror $dbim->fetch_array($mirrors_result))
                        {
                            
    $mirrors_template->assign_var('file_id'$input['file']);
                            
    $mirrors_template->assign_var('mirror'$mirror);
                            
    $mirrors_template->use_block('mirror');
                        }
                        
                        
    $mirrors_template->show();
                    }
                    else
                    {
                        
    $error_message $lm->language('frontend''error_no_file');
                        
    $error $uim->fetch_template('global/error');
                        
    $error->assign_var('error_message'$error_message);
                        
    $error->show();
                    }
                }
                else
                {
                    
    $error_message $lm->language('frontend''error_no_id');
                    
    $error $uim->fetch_template('global/error');
                    
    $error->assign_var('error_message'$error_message);
                    
    $error->show();
                }
            }
            
    // 6. If $input['go'] == 2 and isset($input['mirror']), validate id, increment download count then redirect to URL
            
    elseif ($input['go'] == && isset($input['mirror']))
            {
                
    // Get referring domain
                
    if (empty($_SERVER['HTTP_REFERER']))
                {
                    
    $referer_domain false;
                }
                else
                {
                    
    $referer parse_url($_SERVER['HTTP_REFERER']);
                    
    $referer_domain $referer['host'];
                }
                
                if ((
    $referer_domain !== false && !$sm->domain_can_leech($referer_domain) && empty($_SESSION['valid_user'])) || ($site_config['enable_leech_protection'

    == 
    && empty($_SESSION['valid_user'])))
                {
                    
    header('Location: details.php?file='.$input['file']);
                    exit;
                }
                
                
    // Incrememnt and update
                
    $details['downloads']++;
                
    $update $dbim->query('UPDATE '.DB_PREFIX.'files
                                        SET downloads = '
    .$details['downloads'].'
                                        WHERE (id = '
    .$input['file'].')');
                                            
                if (
    $site_config['enable_stats'])
                {
                    
    $dbim->query('INSERT INTO '.DB_PREFIX.'stats
                                    SET file_id = '
    .$input['file'].',
                                        timestamp = "'
    .time().'",
                                        ip = "'
    .$_SERVER['REMOTE_ADDR'].'",
                                        referrer = "'
    .$_SERVER['HTTP_REFERRER'].'",
                                        user_agent = "'
    .$_SERVER['HTTP_USER_AGENT'].'"');
                }
                                                                        
                
    // Get URL
                
    $mirrors_result $dbim->query('SELECT id, url
                                                FROM '
    .DB_PREFIX.'mirrors
                                                WHERE (id = '
    .$input['mirror'].')');
                                                    
                
    $mirror $dbim->fetch_array($mirrors_result);
                    
                if (
    $dbim->num_rows($mirrors_result) == 1)
                {
                    
    $error_message $lm->language('frontend''error_no_file');
                    
    $error $uim->fetch_template('global/error');
                    
    $error->assign_var('error_message'$error_message);
                    
                    
    // Go
                    
    print('http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show='.$mirror['url']);    
                
    $error->show();


                        }
            }
        }
        else
        {
            
    // Get template
            
    $protection $uim->fetch_template('files/protected');
            
    $protection->assign_var('file_id'$input['file']);
                
            
    // Show template
            
    $protection->show();    
        }
    }
    else
    {
        
    $error_message $lm->language('frontend''error_no_id');
        
    $error $uim->fetch_template('global/error');
        
    $error->assign_var('error_message'$error_message);
        
    $error->show();
    }

    // End table
    $end $uim->fetch_template('global/end');
    $end->show();

    // Show everything
    $uim->generate(TITLE_PREFIX.$lm->language('frontend''download').' '.$details['name']);
    ?>
    Last edited by DJ Hands3; 03-02-2009 at 09:08 PM. Reason: php code tags

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    81
    Thanks
    0
    Thanked 11 Times in 11 Posts
    Change
    PHP Code:
        // Go
        
    print(http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show='.$mirror['url']); 
    to something like:
    PHP Code:
        // Go
        
    print('<a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show='.$mirror['url'] . '>Click here</a>'); 

  • Users who have thanked eu4ria for this post:

    DJ Hands3 (03-02-2009)

  • #3
    New Coder
    Join Date
    Feb 2009
    Posts
    90
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thanks eu4ria for that, I'v come stuck again to finish what i need to do i need to place the link in a pop up window i'v had a go but get loads of errors im trying this at the moment:

    PHP Code:
    $error_message $lm->language('frontend''error_no_file');
                    
    $error $uim->fetch_template('global/choosedownload');
                    
    $error->assign_var('error_message'$error_message);
                    
                        
    // Go 
       
    print('<div class=box><h1 style=margin:0>Mix options - stream or download this file</h1><h3><p style=border:0><a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1='.$mirror['url'] . ' onclick="return !window.open(this.href,'','scrollbars=0,height=50,width=50');"> Stream this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></br><a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show='.$mirror['url'] . '>Download this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></p></h3></div>');


                
    $error->show(); 
    PHP Code:
    <a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1='.$mirror['url'] . ' onclick="return !window.open(this.href,'','scrollbars=0,height=50,width=50');"> Stream this mix<a> 
    but says Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

    i tried a few ways but cant get it to work, i know theres away of writing it properly but not sure how to.

    The pop up parameters I will change as at the moment theres no point calling the page its set to in a pop up, but once i have changed the pop up will show a flyer for an event before the download.php calls the file to download.
    Last edited by DJ Hands3; 03-02-2009 at 11:30 PM.

  • #4
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Try:

    PHP Code:
                        // Go 
       
    print("<div class=box><h1 style=margin:0>Mix options - stream or download this file</h1><h3><p style=border:0><a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1=".$mirror['url']." onclick=\"return !window.open(this.href,'','scrollbars=0,height=50,width=50');\"> Stream this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></br><a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show=".$mirror['url'].">Download this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></p></h3></div>"); 

  • #5
    New Coder
    Join Date
    Feb 2009
    Posts
    90
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thanks or all the help so far its going good, iv now stumbled on 1 thing i would like to do, on this line of code below:

    PHP Code:
     // Go  
       
    print("<div class=box><h1 style=margin:0>Mix options - stream or download this file</h1><h3><p style=border:0><a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1=".$mirror['url']." onclick=\"return !window.open(this.href,'','scrollbars=0,height=50,width=50');\"> Stream this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></br><a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert=simplygarage.mp3&show=".$mirror['url'].">Download this mix<img border=0 src=images/files/icon_winamp.png width=18 height=18></a></p></h3></div>"); 
    you can see advert=simplygarage.mp3 but the file name being simplygarage.mp3 i would like to generate a random mp3 file name from a folder where all the mp3's are stored, just so the file name of a random mp3 file is inserted into the query string then the cgi script can take care of the rest,

    iv been thinking on javascript terms as its easier to understand but converting this into php is beyond me, on a thought i was thinking in javascript you could have the arrays or vars (i think) as the available file listed in which ever folder then the script would just generate a random order for the files, id rather keep in php as it better than javascript more stable.

    If you could help all good

  • #6
    New Coder
    Join Date
    Feb 2009
    Posts
    90
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Iv had a go in php trying to merge a radom text script in but go a problem Parse error: syntax error, unexpected T_VARIABLE

    PHP Code:

                $error_message 
    $lm->language('frontend''error_no_file');
                    
    $error $uim->fetch_template('global/choosedownload');
                    
    $error->assign_var('error_message'$error_message);
                
    $random_text = array("intro1.mp3",
                        
    "intro2.mp3",
                        
    "intro3.mp3",
                        
    "intro4.mp3",
                        
    "intro5.mp3");
    srand(time());
    $sizeof count($random_text);
    $random = (rand()%$sizeof);
                                           
    // Go
       
    print("<div class=box><h1 style=margin:0>Mix options - download or stream this file</h1><h3><p style=border:0><a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1=".$mirror['url']." onclick=\"return !window.open(this.href,'','scrollbars=0,height=50,width=50');\">Download this mix  <img border=0 src=images/files/download.gif width=18 height=18></a></br><a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert="$random_text[$random]&show=.$mirror['url'].">Stream this mix  <img border=0 src=images/files/winamp.gif width=18 height=18></a></p></h3></div>");




                
    $error->show(); 

    any advice on what i could do to make work

  • #7
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Error here:
    PHP Code:
    advert="$random_text[$random]&show=.$mirror['url']."
    Correct way
    PHP Code:
    advert=".$random_text[$random].'&show='.$mirror['url']."


    Corrected
    PHP Code:
    print("<div class=box><h1 style=margin:0>Mix options - download or stream this file</h1><h3><p style=border:0><a href=http://dj-promo.co.uk/mixes/downloadpromo.htm?filename1=".$mirror['url']." onclick=\"return !window.open(this.href,'','scrollbars=0,height=50,width=50');\">Download this mix  <img border=0 src=images/files/download.gif width=18 height=18></a></br><a href=http://dj-promo.co.uk/cgi-bin/play.m3u?advert=".$random_text[$random].'&show='.$mirror['url'].">Stream this mix  <img border=0 src=images/files/winamp.gif width=18 height=18></a></p></h3></div>"); 

  • Users who have thanked kokjj87 for this post:

    DJ Hands3 (03-06-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •