The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help me finish my next hack
Hey guys, I haven't been online much since the recent move I did. Don't have much computer access where I'm staying at the moment, but I can't live without my computer and got really bored so I started to dig threw old request threads and saw someone requested a hack to turn a specified 'text' in a post and replace it with a 'url/link'. Well I looked around and didn't find it so I was rather happy that I could make a new hack cause I really didn't know what to do on the computer with no internet, was getting bored. ^^
Anyways, I started to think how I can do this, and it seemed pretty simple actually, just make a new table in the database named 'textlink' with a few needed fields such as 'textlinkid', 'text', and 'link' to hold the info. So I completely finish the admincp part of the hack. Now the next part was to make it read all the text in each post and check to see if any of the text posted needed to be replaced with a link. This again seemed rather simple to me. I figure I could use the str_replace() function built into PHP. This is where I got a dead end. Inside that function I need to it read the database field 'text' and replace it with the the info in the database field 'link'. Here's what I think it will look like if I'm not mistaking. PHP Code:
Database information: -Textlink (table name) ---textlinkid (field name for the id of the text/link) ---text (field name for the text to replace) ---link (field name for the url to replace the text with) Thanks in advance everyone! |
#2
|
||||
|
||||
do you just replace for newposts or are you changing the bbcode parsing functions?
depending on your answer you'd have to use caching or not of course as for the general: PHP Code:
|
#3
|
|||
|
|||
Hey Xenon, again thanks again! I was planing on using the preg_replace() function, but like you said. Its damm complacated. I'm reading about it now in my PHP book. ^^.
|
#4
|
||||
|
||||
You're welcome
and yeah, play around with the preg_replace. i avoided it in the past as well, as it's very complicated but once you found out the little tricks it's a very strong tool |
#5
|
|||
|
|||
I'm not sure the best place to add this code. I was thinking about doing it in the includes/functions_bbcodeparse.php file and do the query and this:
PHP Code:
|
#6
|
||||
|
||||
putting it into the parse_bbcode function makes it required to cache your $find/$replace arrays, as if you don't do it, you would produce an extra query per post on every page which would be a big no no ^^
|
#7
|
|||
|
|||
Quote:
Thank man! |
#8
|
||||
|
||||
The answer is already posted there, and it should work the way he posted afaics
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|