[Custom] CODE tag as Download Box

nitins60

New Member
this is my first modification which i have rewritten the CODE tag as DOWNLOAD tag...

the reason is simple, many warez sites basically CODE the download links to prevent URL tag and to show download links in clear manner. but after looking at DOWNLOAD bbcode, i decided to modify existing CODE bbcode as DOWNLOAD bbcode and modified it....

1. open up your style manager and click on edit templates
2. expand BBCODE Layout templates and open bbcode_code template
3. Find
PHP:
<div style="margin:20px; margin-top:5px">
    <div class="smallfont" style="margin-bottom:2px">$vbphrase[code]:</div>
    <pre class="alt2" dir="ltr" style="
        margin: 0px;
        padding: $stylevar[cellpadding]px;
        border: 1px inset;
        width: $stylevar[codeblockwidth];
        height: {$blockheight}px;
        text-align: left;
        overflow: auto">$code</pre>
</div>
and Replace with
PHP:
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td height="39" colspan="3">
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td width="113" background="images/misc/down1.gif" height="39">
                &nbsp;</td>
                <td background="images/misc/down2.gif">&nbsp;</td>
                <td width="48" style="background: url(images/misc/down3.gif) repeat-x;" height="39">
                &nbsp;</td>
            </tr>
        </table>
        </td>
    </tr>
<tr>
        <td bgcolor="#C0DDFF" width="10">&nbsp;</td>
        <td bgcolor="#C0DDFF">
        <table border="1" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse; border: 1px solid #007FD8" bgcolor="#FFFFFF">
            <tr>
               <td style="font-family: Arial; font-size: 12px; color: #707070; text-align: center">
                <pre class="alt2" dir="ltr" style="
        margin: 0px;
        padding: $stylevar[cellpadding]px;
        border: 1px inset;
        width: $stylevar[codeblockwidth];
        height: {$blockheight}px;
        text-align: left;
                background-color: #FFFFFF;
        overflow: auto">$code</pre>
        </td>
            </tr>
        </table>
        </td>
        <td bgcolor="#C0DDFF" width="10">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="3">

        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td background="images/misc/down4.gif" height="11" width="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
                <td bgcolor="#C0DDFF" height="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
                <td background="images/misc/down5.gif" height="11" width="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
            </tr>
        </table>
        </td>
    </tr>
</table>
4. that's all...
 

Hoxxy

New Member
Nice little mod but I got a small little niggle, if your site also needs the code tag for wrapping code other than links its gonna have the download box around it to, why not make it a custom bbcode:

Title: Download Box
Tag: dl
Replacement:
HTML:
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td height="39" colspan="3">
        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td width="113" background="images/misc/down1.gif" height="39">
                &nbsp;</td>
                <td background="images/misc/down2.gif">&nbsp;</td>
                <td width="48" style="background: url(images/misc/down3.gif) repeat-x;" height="39">
                &nbsp;</td>
            </tr>
        </table>
        </td>
    </tr>
<tr>
        <td bgcolor="#C0DDFF" width="10">&nbsp;</td>
        <td bgcolor="#C0DDFF">
        <table border="1" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse; border: 1px solid #007FD8" bgcolor="#FFFFFF">
            <tr>
               <td style="font-family: Arial; font-size: 12px; color: #707070; text-align: center">
                <pre class="alt2" dir="ltr" style="
        margin: 0px;
        padding: $stylevar[cellpadding]px;
        border: 1px inset;
        width: $stylevar[codeblockwidth];
        height: {$blockheight}px;
        text-align: left;
                background-color: #FFFFFF;
        overflow: auto">{param}</pre>
        </td>
            </tr>
        </table>
        </td>
        <td bgcolor="#C0DDFF" width="10">&nbsp;</td>
    </tr>
    <tr>
        <td colspan="3">

        <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
                <td background="images/misc/down4.gif" height="11" width="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
                <td bgcolor="#C0DDFF" height="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
                <td background="images/misc/down5.gif" height="11" width="11">
                <img border="0" src="images/misc/space.gif" width="1" height="1"></td>
            </tr>
        </table>
        </td>
    </tr>
</table>
Example: [dl]http://www.your-link.com[/dl]
Description: What ever you want.
Use {option}: No

------------------------------
CREDIT: nitins60
 

Hoxxy

New Member
Yeah thats cool, I see where your coming from..
Just another option thats all ;)

You could run a SQL Quiry to replace them tho'
What this would do is find all the code tages and then wrap them in the dl tag

Here's the code you would probably use (untested, so use at your own risk and backup your data):

HTML:
UPDATE post
SET pagetext = REPLACE(REPLACE(REPLACE(REPLACE(pagetext,'[CODE]','[DL][CODE]'),'[/CODE]','[/CODE][/DL]'),'[code]','[dl][code]'),'[/code]','[/code][/dl]')
WHERE pagetext LIKE '%[code]%' AND pagetext LIKE '%[/code]%';

Note that the mySQL replace function is case sensitive, so this will replace anything that is either tagged in all uppercase or all lower case.
It will not find tags with mixed case...

Because vBulletin stores a cache of parsed posts, you'll most likely need to clear this cache before you see the posts updated.
You can do that by executing this SQL:

Code:
TRUNCATE TABLE postparsed;
Following that you can rebuild the post cache if you wish or let it rebuild on its own.
If you want to rebuild it, in the AdminCP goto Maintenance -> Update Counters -> Rebuild Post Cache

Note that vBulletin automatically lowered the capitilzation in that SQL query to "prevent shouting." So, when you execute it, be sure to make the first 4 instances of the word "code" uppercase.
 

Gunner

New Member
Hoxxy, I did it your way but, the links are still active and there is a space between each one like:
link one

link two

link three
etc, how do I remove the spaces? like
one
two
three

Plus kill the active links?..

Many thanks to you all :)
 

nitins60

New Member
if u use the code which i posted, you won't have live links at all, until and unless you manually add [url ] tags......
 

Gunner

New Member
Oh,I see lol... I have done it your way now nitin as when I was looking at your post before, all I could/can see from you is:

1. open up your style manager and click on edit templates
2. expand BBCODE Layout templates and open bbcode_code template
3. Find
Content visible to registered users only.and Replace with
Content visible to registered users only.4. that's all...

I clicked "quote" for your original post on this and was going to say I don't understand when I saw all your code pop up! :\ strange, well... I doing it your way now (thank you very much) as I only want to use [ code] command and not any customised ones BUT, Thank You Hoxxy aswell because, if I hadnt of tried it your way, I wouldnt have found the custom BB code manager lmao!...

Gunner = vBulletin Newbie!

THANK YOU both :)
 

Notam

New Member
Thnx nitins60 for the hack. Is there anyway to code the links automatically if a user doesn't code the links.
 

nitins60

New Member
Notam said:
Thnx nitins60 for the hack. Is there anyway to code the links automatically if a user doesn't code the links.
i will try to see into it.. because it's not a big thing, instead of wrapping html tags, we have to use code tags... i will try tonight
 

Gunner

New Member
that would be cool thanks :)
maybe something that'll hide all code tags from the unregistered /awaiting registration usergroups??
 

Hoxxy

New Member
This involves editing a PHP file from vBulletin.

open includes/functions_newpost.php

Find:
PHP:
        $urlReplaceArray = array( 
            "[url]\\2\\4[/url]" 
        );

And replace with:
PHP:
   $urlReplaceArray = array( 
            "[code]\\2\\4[/code]" 
        );



Note: This system isn't very good, you can still make clickable urls, you just need to use URL tags.

Always back your files up!
 

Gunner

New Member
Hoxxy said:
If you mean my post from above read the coding very carefully!

I see the same aswell Hoxxy, this happened to me with nitims post before:
I think something is wrong with normal members viewing permission maybe?..


click.
 

nitins60

New Member
i am normal user and able to see.... please change your skin to VBSEO green in your profile and logout and login again and let us know if u face same problem ;)
 

Hoxxy

New Member
Gunner said:
I see the same aswell Hoxxy, this happened to me with nitims post before:
I think something is wrong with normal members viewing permission maybe?..


click.

Ok I see problem, how about now?! ;)
 

Gunner

New Member
that works nitin :) changed and saw it, also when I changed back to default one, I still see it lol thanks guys :)
 

Gunner

New Member
Hoxxy, it has come to that time when I need a code box AND a download box...

I (again) tried it your way but the links are still active, any ideas please??
 

Bad Guy

New Member
Hoxxy said:
This involves editing a PHP file from vBulletin.

open includes/functions_newpost.php

Find:
PHP:
        $urlReplaceArray = array( 
            "[url]\\2\\4[/url]" 
        );

And replace with:
PHP:
   $urlReplaceArray = array( 
            "[code]\\2\\4[/code]" 
        );



Note: This system isn't very good, you can still make clickable urls, you just need to use URL tags.

Always back your files up!

I have small question. If i use this, links on chatbox also are in code.
I would like so that it works in one category or forum.

I try :
PHP:
 if ( $foruminfo[forumid] == 7 ){
$urlReplaceArray = array( 
            "[code]\\2\\4[/code]" );
}
else 
{ $urlReplaceArray = array( 
            "[url]\\2\\4[/url]"  );
}
* 7 is id forum

it isn't working. some idea?
 
Top