TinyPortal

Development => Block Codes => Topic started by: akulion on December 27, 2006, 03:54:38 PM

Title: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on December 27, 2006, 03:54:38 PM
Hi,

This is a mod which will make it so that when guests are on your forum and try and download anything they will get a small popup telling them to register.

They will be able to browse the entire downloads section, but just not able to download.

PLEASE NOTE: This mod is a deterrent, but for people familiar with Tiny Portal they will easily be able to by-pass it. But for your average user, they wont know how.

The Mod demo can be seen in :

My live site download section:
http://path-to-peace.com/forum2/index.php?action=tpmod;dl

The mod file is attached below, to install it, just upload via your package manager and install normally as you would any other package.

Aku

Nearly forgot to mention...this will work with SMF 1.1 and 1.1.1 and TP 0.97
Also please remember when a new TP version is released and u want to upgrade, uninstall this mod FIRST and then upgrade!
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on December 28, 2006, 06:02:02 AM
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpath-to-peace.com%2Fforum%2FSmileys%2Fdefault%2Flookaround.gif&hash=7e79d7bb9dc1893ede344abb605785e81ef3f3f3) no one likes it (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fpath-to-peace.com%2Fforum%2FSmileys%2Fdefault%2Flookaround.gif&hash=7e79d7bb9dc1893ede344abb605785e81ef3f3f3)
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Thurnok on December 28, 2006, 06:35:41 AM
Sorry Aku, I've been sick yesterday and today.  I'll check it out, sounds like a good deal to me.  Let guests see that you have stuff, but they need to register to actually get it.   :up:
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on December 28, 2006, 03:25:07 PM
Oh no worries, I was just shamelessly bumping the topics (confession)

I hope u get well really soon :up: Take lotsa rest and drink hot choco :D

The hack is as simple as it can get - its just a conditional link lol The file for download is attached to the post above though :D
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: RoarinRow on December 28, 2006, 07:27:01 PM
Cool, the Mad Scientist is at it again   :up:  I like it.  Where is says 'Please Register' on the pop up, can it be a link to your registration page?   8)
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: rebelrose on December 28, 2006, 07:35:09 PM
That is a great hack, good job  :up:
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on December 28, 2006, 10:33:18 PM
Quote from: RoarinRow on December 28, 2006, 07:27:01 PM
Cool, the Mad Scientist is at it again   :up:  I like it.  Where is says 'Please Register' on the pop up, can it be a link to your registration page?   8)

yup it can
in fact ill get to it soon and make it a popup to adopt the theme of the forum as well as display the links
just gimme some time since ill have to check how to do that :D
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: RoarinRow on December 28, 2006, 10:58:49 PM
Quote from: Aku on December 28, 2006, 10:33:18 PM
Quote from: RoarinRow on December 28, 2006, 07:27:01 PM
Cool, the Mad Scientist is at it again   :up:  I like it.  Where is says 'Please Register' on the pop up, can it be a link to your registration page?   8)

yup it can
in fact ill get to it soon and make it a popup to adopt the theme of the forum as well as display the links
just gimme some time since ill have to check how to do that :D

ohhh, that would be cool    8)
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Dermot on January 16, 2007, 06:26:28 AM

I was looking for something like this, thanks aku :)



Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: samson on January 16, 2007, 10:46:15 AM
 ;D perfect just what I was looking for
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on January 16, 2007, 12:53:23 PM
oohh that reminds me making the popup window the same color as the window!

ill get to it today hopefully (gota write it down) or else i lose sight of things lol
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: st1905 on January 23, 2007, 10:05:19 AM
Thank you aku.
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: funxlab on January 27, 2007, 11:37:05 PM
Aku,
Is it the correct way to make this Mod work as I did?

After applying this Mod Download categories weren't still visible as guests so in TP Download Manager I set "Allowed membergroups" to guests also. Now these categories are visible to guest also but they can't download.

Regards,
Jim
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on January 28, 2007, 05:21:47 AM
u can make everything visible to everyone with this mod

but it wont let the guests download and members can :D
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: funxlab on January 28, 2007, 11:25:23 AM
ok. And the procedure I did was the correct way of doing that ..right?
:)
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: akulion on January 28, 2007, 02:04:39 PM
yes its correct

just test it as well - log out and then go and try to download something - if u fail then it means its working :up:
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: gravy on January 30, 2007, 12:15:27 AM
This hack was a God sent for me. My website depends on TP and its download section and I always wanted the guests to see what they could download, but be able to unless they were a member. So you made just what I was looking for, and I thank you so much for it. :laugh:
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: hoopty on January 30, 2007, 05:28:23 AM
I like this mod alot, but it was bothering me that the download button showed up in the category view.  Instead of downloading (or asking you to register), it takes you to the actual download page...  where you get another download button which actually will start the download (or ask you to register).  In the unmodded dlmanager, the button doesn't show up in the cat view.

Here's how I fixed it:

I changed the last bit of codeelse{
echo '
<a href="'.$dlitem['href'].'"><img src="' . $settings['images_url']. '/TPdownloadfile.gif" border="0" align="right" alt="" /></a>
<b><a href="'.$dlitem['href'].'">'. $dlitem['name'] .'</a></b> ' , ($context['TPortal']['dlaction']!='item' && isset($dlitem['filesize'])) ? '<br />'.$dlitem['filesize'] : '' ,  '<div class="smalltext">
'.$dlitem['description'];}

to:else{
if ($context['TPortal']['dlaction']=='item')
echo '
<a href="'.$dlitem['href'].'"><img src="' . $settings['images_url']. '/TPdownloadfile.gif" border="0" align="right" alt="" /></a>';
echo '
<b><a href="'.$dlitem['href'].'">'. $dlitem['name'] .'</a></b> ' , ($context['TPortal']['dlaction']!='item' && isset($dlitem['filesize'])) ? '<br />'.$dlitem['filesize'] : '' ,  '<div class="smalltext">
'.$dlitem['description'];}
and it now behaves just like it did before it was modded except guests get the popup.

Hope this helps someone out...

~hoopty
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: SRaven on January 30, 2007, 07:12:09 AM
This is great! I was wondering how to be able to let guests see that there ARE things available to download without actually letting them download anything, thankyou for this Aku!

And Hoopty, your modification to it worked like a charm, thanks!

EDIT: HAHAHA I just noticed this....
This works great with the Snap preview I have on my forum...it only works because for some reason the DL link is using my server IP instead of the actual domain name.(I have the preview set to only show previews for external links)
here's a screenshot of what it looks like when you mouseover the DL button:

Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Michelle_Reed on April 01, 2007, 06:02:47 PM
I would really love this to work with v0.9.8, are you planning to re-release this?
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Dermot on April 03, 2007, 07:52:44 PM

Yeah i noticed this is now broken, any idea if you will make this work?
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Dermot on April 03, 2007, 08:01:43 PM

Actually after some tweaking i did get it to work. thanks

This is slightly tweaked to work on 0.9.8 on smf 1.1.2



Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Michelle_Reed on April 03, 2007, 08:27:59 PM
Thanks so much, that works great for me!
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Uber_Tiny on April 10, 2007, 08:17:10 AM
Beautiful hack there man!!

Great job  :up:
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: Teck on April 12, 2007, 11:55:43 AM
Nice! Works perfectly :D
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: marzi on May 01, 2007, 08:59:21 PM
I have manually installed the  [hack] TP Downloads - Guests View Only Mod to a slightly earlier version combination:: SMF 1.1 RC3 and TinyPortal v0.9.6beta
Originally I had downloads set up to permit guests to download some files while others were reserved (and hidden) for members only.
With the Guests View Only Mod installed, guests can view but not download files-as promised-and  the Popup screen works just fine. The problem is that now all the download files are view only, even the ones that the public were previously permitted to download.

So this is my thought;
if the conditional statement is changed to included the authorID, shouldn't the code-hack be able to do what I thought it could originally? For example, I think the following code should be able to allow all uploads to be displayed to the public and members alike, but those that were uploaded by authorID 1 will be able to be viewed by guest but only be able to be downloaded by members....all others (guests) will get the warning popup screen. The problem is that the following code does not quite do it.
If anyone has a minute and any interest to look at it and give me your thoughts I would be grateful. If not, I understand.
global $user_info;
    if (($user_info['is_guest'])&&($context['TPortal']['dlaction']=='item')&&($context['TPortal']['authorID']=='1'))
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: adnan on June 28, 2007, 08:53:43 PM
Does download center update your mod ?
http://www.tinyportal.net/index.php?action=tpmod;dl=item639
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: IchBin on June 28, 2007, 09:26:51 PM
Update for what?
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: adnan on June 28, 2007, 09:41:49 PM
I mean that can I download this mod from download center or files which attached  in this topic is newer than it ?
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: IchBin on June 28, 2007, 10:04:33 PM
They should be the same AFAIK.
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: G6Cad on July 06, 2007, 10:42:36 AM
They are the same, but it will have to be updated for the next release.
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: yosemite on July 19, 2007, 08:06:52 PM
I have applied the mod and enabled the guest permissions. I can now see the download block but when i click on it ti shows the file repository but no files. What am i doing wrong?

thanks

cf
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: vdubbia on July 20, 2007, 02:41:32 AM
wouldn't a better solution just to make the download link viewable to registered members?  doesn't that already exist?

not dissing this mod, just thought this was already an option...
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: IchBin on July 20, 2007, 02:43:05 AM
Nope, only access to the actual view of download sections has a permission. More to come as always. :)
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: than on June 09, 2008, 09:09:09 PM
Hi,

I'm trying to make manual install in TP 1.0.5 beta 1. Editing Tpdlmanager.template, i found and change the first part of code:

In the mod:

<a href="'.$scripturl.'?action=tpmod;dl=get'.$item['id'].'"><img style="margin: 5px;" align="right" src="'.$settings['images_url'].'/TPdownloadfile.gif" alt="" /></a>';

In my file:
<a href="'.$scripturl.'?action=tpmod;dl=get'.$item['id'].'"><img style="margin: 5px;" align="right" src="' .$settings['images_url'].'/TPdownloadfile.gif" alt="" /></a>';

Only differs in space (="' .$settings)

The problem is in the second code modification. The mod code and my file code differs more than my knowledge in PHP.

In the mod:
if($context['TPortal']['dlaction']=='item')
echo '
<a href="'.$dlitem['href'].'"><img src="' . $settings['images_url']. '/TPdownloadfile.gif" border="0" align="right" alt="" /></a>';

echo '
<b><a href="'.$dlitem['href'].'">'. $dlitem['name'] .'</a></b> ' , ($context['TPortal']['dlaction']!='item' && isset($dlitem['filesize'])) ? '<br />'.$dlitem['filesize'] : '' ,  '<div class="smalltext">
'.$dlitem['description'];


In my file:
   if($context['TPortal']['dlaction']=='item'){

         // extra information like downloads, views etc.
         echo '
         <tr><td rowspan="2" class="windowbg2" align="center"><img src="' .$settings['tp_images_url']. '/TPinfo.gif" alt="" /></td>
             <td class="windowbg2"><a href="'.$dlitem['href'].'"><img src="' .$settings['tp_images_url']. '/TPdownloadfile.gif" alt="'.$txt['tp-download'].'" /></a>
             </td>
         </tr><tr>
             <td class="windowbg2"><span class="smalltext">
              '.$txt['tp-uploadedby'].': <a href="'.$scripturl.'?action=profile;u='.$dlitem['authorID'].'"><b>'.$dlitem['author'].'</b></a> (' , timeformat($dlitem['created']) , ')
                 </span>
             </td>
         </tr><tr>
<td align="center" valign="top" class="windowbg2" style="clear: both;" width="2%">
<img src="' .$settings['tp_images_url']. '/TPthumbup.gif" alt="" />
</td>
             <td class="windowbg2"><span class="smalltext">';

echo $txt['tp-ratingaverage'] . ' ' . ($context['TPortal']['showstars'] ? (str_repeat('<img src="' .$settings['tp_images_url']. '/TPblue.gif" style="width: .7em; height: .7em; margin-right: 2px;" alt="" />', $dlitem['rating_average'])) : $dlitem['rating_average']) . ' (' . $dlitem['rating_votes'] . ' ' . $txt['tp-ratingvotes'] . ')';

if($dlitem['can_rate']){
echo '<form style="margin-top: 1em;" name="tp_dlitem_rating" action="',$scripturl,'?action=tpmod;sa=rate_dlitem" method="post">
' , $txt['tp-ratedownload'] , ' <select size="1" name="tp_dlitem_rating">';
for($u=$context['TPortal']['maxstars'] ; $u>0 ; $u--){
echo '
<option value="'.$u.'">'.$u.'</option>';
}
echo '
</select>
<input type="submit" name="tp_dlitem_rating_submit" value="',$txt['tp_rate'],'">
<input name="tp_dlitem_type" type="hidden" value="dlitem_rating">
<input name="tp_dlitem_id" type="hidden" value="'.$dlitem['id'].'">
<input type="hidden" name="sc" value="', $context['session_id'], '" />
</form>
</div>';
}
else
echo '
<hr /><i>'.$txt['tp-dlhaverated'].'</i>';


echo '
</span>
             </td>
         </tr>';


Anyones have interest on make an adaptation for work with TP 1.0.5?? Or tell me what modifications i should make?

Really thanks, and sorry for my English.
Title: Re: [hack] TP Downloads - Guests View Only Mod
Post by: G6Cad on June 09, 2008, 10:04:49 PM
Will probably need a complete rewrite.
The download and the download module are in the workd to be a standalone module for TP so the code will probably change a whole lot from the one you posted now.