Jump to content

Need a script that I don't know the name of... HELP


Recommended Posts

Hi :)


I am a total newbie, and need a script... lol...


I have buildt a "information" website and I am looking for a script that changes predefined words (from a file) to a certaing color, size and maybe link to different pages...

Im not sure what to call this script, but the easiest way to explain this is to have a look at




Here you can see that there are links within the text, and I guess they are not entering links to each of these words when they create each site.... 


Do any of you know whether this script is available somewhere...? :confused:


I need it  :'(


please email/om me or post some tips for me here... I would need the full script though...

Link to comment
Share on other sites

ok, after reading a bit more on this forum and elsewhere,  I understand i am way off with my explanation, and it actually seems like this isnt a difficult problem as long as you know what to do.. AND I DONT  :'(


unfortunately I have noe clue on this kind of programming, and are beggin on my knees to someone that can help me point me in the right direction..




Link to comment
Share on other sites

haha...  I know...  Im not good in explaining things... lol


Ill try again:


If my text look like this:


"bla bla bla bla dog, bla bla bla, norway, bla bla bla bla  "

I want a script that automaticly changes some of the words in my text...


"bla bla bla bla dog, bla bla bla, norway, bla bla bla bla  "



Example: I want the script to change all words "dog" to be red, all words "norway" to be blue and so on, I want to maybe have a list with words that the script checks and then change my website... (change to same text, but with color, different size and  maybe links) To me it's  sound similar to a .css file, but I want the script to change the look of the words and maybe make them a link and so on...  and I don't think a .css file can to this  ;)


I found this: http://www.ifinity.com.au/Products/Inline_Html_Links_For_DNN


It's something like this I need, but in a script....


But I think this is a addon to a program or something....


I know I know, this explanation wasnt better, but hopefully some of you understand? :o:shrug:



Link to comment
Share on other sites

I just had a quick look, and It seems like this can solve the link "problem", but I still need something that changes the text to a different color or something...  Not all of them has to be links...  but now I have something to start with so I'll post a new thread later then :)


Like I said, it wasnt hard to the ones that have clue :)  Thanks :D :D



Link to comment
Share on other sites

Hi again :D

I have now look at the script posted above, and tried to get this to work with my pages...    ANd I don't know how I am going to do this...


I got two example files, chose one of them, but I need a description on where to put what code...  lol...


As I dont understand the script I need a total explanation to where I am going to put it...  The example code is below


I have understood that the classautokeyword.php and autolink.php keyword belongs together (thought it was to functions) 


The text on my site is not from a database, I don't know If these first lines is something I gotto change because of this...


code from examplefile:




  Projectname:  Autolink Keywords Application Script 2

  Version:      0.1

  Author:        Ver Pangonilo <smp@limbofreak.com>

  Last modified: 05 January 2007

  Copyright ©: 2007 Ver Pangonilo, All Rights Reserved


  * GNU General Public License (Version 2, June 1991)


  * This program is free software; you can redistribute

  * it and/or modify it under the terms of the GNU

  * General Public License as published by the Free

  * Software Foundation; either version 2 of the License,

  * or (at your option) any later version.


  * This program is distributed in the hope that it will

  * be useful, but WITHOUT ANY WARRANTY; without even the

  * implied warranty of MERCHANTABILITY or FITNESS FOR A

  * PARTICULAR PURPOSE. See the GNU General Public License

  * for more details.




Note: This class uses the output Automatic Keyword Generator.


This class can automatically create keywords link within an articles

if the keyword is found on a predetermined list of linked words.


The predetermined list could contain words and links to other

websites like advertisers or simply a link to other articles

in within your website.


Replacement Type:


This example use a CASE SENSITIVE string replacement. This prevents

proper words to be replaced with lower case letters.



//assuming that your site contents is from a database.

//set the outbase of the database to $data.


$data =<<<EOF

<p>Imagine being overseas and your identity being hofte, albu for the taking - your nationality, your name, your passport number. Everything.</p>


<p>That's the fear of privacy and security hofte albu specialists now that the state hofte, albu department plans to issue "e-Passports" to American travelers beginning in late August.</p>


<p>They'll have radio frequency identification (RFID) tags and are meant to cut down on human error of immigration officials, speed the processing of visitors and safeguard against counterfeit passports.</p>


<p>Yet critics are concerned that the security benefit of RFID technology, which combines silicon chips with antennas to make data accessible via radio waves, could be vastly outweighed by security threats to the passport holder.</p>


<p>"Basically, you've given everybody a little radio-frequency doodad that silently declares 'Hey, I'm a foreigner,'" says author and futurist Bruce Sterling, who lectures on the future of RFID technology. "If nobody bothers to listen, great.HD If people figure out they can listen to passport IDs, there will be a lot of strange and inventive ways to exploit that for criminal purposes."</p>


<p>RFID chips are used in security passes many companies issuehofte, albu  to employees. They don't have to be touched to a reader-machine, only waved near it. hd Following initial objections by security and privacy experts, the State Department added several security precautions.</p>


<p>But experts still fear the data could be "skimmed," or read remotely without the bearer's knowledge.</p>


<p>Kidnappers, hofte, albu, albuer identity thieves and terrorists could all conceivably commit "contactless" crimes against victims who wouldn't know they've been violated until after the fact.</p>


<p>"The basic problem with RFID is surreptitious access to ID," said Bruce Schneier security technologist, author and chief technology officer of Counterpane Internet Security, a technology security consultancy. "The odds are zero that RFID passport technology won't be hackable."</p>


<p>The State Department argues the concerns are overstated. "We wouldn't be issuing the passports to ourselves if we didn't think they're secure," said Deputy Assistant Secretary of State for Passport Services Frank Moss, who noted that RFID passports have already been issued to core State Department personnel, including himself. hofte, albu "We're our own test population.</p>







This is the automatice keyword generator class



//this the actual application.



echo "<H1>Input - text</H1>";

echo $data;

$params['content'] = $data; //page content


//set the length of keywords you like

$params['min_word_length'] = 2;  //minimum length of single words

$params['min_word_occur'] = 2;  //minimum occur of single words

$params['min_2words_length'] = 3;  //minimum length of words for 2 word phrases

$params['min_2words_phrase_length'] = 10; //minimum length of 2 word phrases

$params['min_2words_phrase_occur'] = 2; //minimum occur of 2 words phrase

$params['min_3words_length'] = 3;  //minimum length of words for 3 word phrases

$params['min_3words_phrase_length'] = 10; //minimum length of 3 word phrases

$params['min_3words_phrase_occur'] = 2; //minimum occur of 3 words phrase




$keyword = new autokeyword($params, "iso-8859-1");


$keywords =  $keyword->get_keywords();





This is the start of the auto link keyword!


print "<p></p><hr /><h1>Output Text with Auto Link Keyword</h1>";



$linkfile ='linkedKeywords.php';

//read the file

$fh = fopen($linkfile,'r') or die("can't read ".$linkfile." file!");

$keyword_array = array();

while (! feof($fh)) {

$s = rtrim(fgets($fh,1024));


list($word,$link) = explode(',',$s);

$word = trim($word);

$link = trim($link);

$keyword_array[$word] = $link;


fclose($fh) or die("can't close file ".$linkfile."!");


$style = <<< CEOF



#link {

font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;



font-size: 1.1em;

color: #069;

font-weight: bold;






print "<br/>".$style;




$autolink = new autolink($keywords, $keyword_array, $data, "link", "link");

echo $autolink->linkKeywords();




:'(  :'( HELP :shrug:

Link to comment
Share on other sites

I think I get it. You want certain words to be, say, red. And you want other words to be made in to a link? I think this should help:



$mytext = "Buffalo with an aqualung";

$mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext);
$mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext);

echo $mytext


So when you run the script, Buffalo will be replaced with a link to buffalo.php and aqualung will be made bold.


That, of course, is the simple way to do it. You can get complex with regexes and whatnot, but if you're only doing a few things at a time, this is ideal.

Link to comment
Share on other sites

But then I have to write $mytext = "Buffalo with an aqualung"; on every single page I have...  I want a script that finds ex "Buffalo" automaticcly in the whole site...  and If I understand your code right, this doesn't do that?


I want less manual work...  ;D



but yes, this is a kind of script I want!!  But I want it to work on the entire site :):D

Link to comment
Share on other sites

I think I get it. You want certain words to be, say, red. And you want other words to be made in to a link? I think this should help:



$mytext = "Buffalo with an aqualung";

$mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext);
$mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext);

echo $mytext


So when you run the script, Buffalo will be replaced with a link to buffalo.php and aqualung will be made bold.


That, of course, is the simple way to do it. You can get complex with regexes and whatnot, but if you're only doing a few things at a time, this is ideal.




bah..  Im still struggling with this... could you be helpful explaining to me how I can use your example in my site?  I don't understand a thing, and probably should't be messing with this kind of codes.. lol...



Before my text that needs to be converted I have three other pages included:


<?php include "../url/url.php"; ?>

<?php include "url.php"; ?>

<?php include "url/url.php"; ?>


These makes the top of my pages, and I was hoping that I could set the code in one of those so I don't have to copy&paste the script into every single page...


Do you mean that I don't need any more script than those three lines you wrote?


Im desperate....  lol....  please help...

Link to comment
Share on other sites

If you want to do this on content on your page, why not try using output buffering? It lets you catch a page before it's sent to the browser and do whatever you wish to it. Check out http://au2.php.net/manual/en/ref.outcontrol.php for information about that. But for now, here's a modification to my script that includes OB:





// .... more content here ....

$mytext = ob_get_contents();
$mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext);
$mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext);

echo $mytext;




So what this does, is turn on output buffering (ie. withholds the page from the browser) then tinkers with it using str_replace. Then when that's done, it outputs the text and turns off the buffer.


But if it were my script, I'd convert my pages into OOP (there are some great OOP tutorials on this site, check 'em out) and write a function to do this for me, and also add in some lines so I could do search / replace via a database. That way I wouldn't have to include the above code on every page, I could just call:



// ... content ...




and have it read the search and replace values from a database.


And before you ask, I can't / won't write up the full script here. Not only do I not have the time, but it'd be too long and require a lot of explanation. So instead I can point you to plenty of PHP tutorials because the results are a lot more exciting when you learn it yourself ;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.