PHP Classes

File: Example2.php

Recommend this page to a friend!
  Classes of Ver Pangonilo   Autolink Keywords   Example2.php   Download  
File: Example2.php
Role: Example script
Content type: text/plain
Description: Example 2 using case sensitive replacement and a separate keyword array list file
Class: Autolink Keywords
Automatically creates links for content keywords
Author: By
Last change:
Date: 17 years ago
Size: 6,057 bytes


Class file image Download
   Projectname: Autolink Keywords Application Script 2
   Version: 0.1
   Author: Ver Pangonilo <>
   Last modified: 05 January 2007
   Copyright (C): 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 available for the taking - your nationality, your name, your passport number. Everything.</p>

<p>That's the fear of privacy and security specialists now that the state 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. 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 issue to employees. They don't have to be touched to a reader-machine, only waved near it. 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, 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. "We're our own test population.</p>


This is the automatice keyword generator class

//this the actual application.

"<H1>Input - text</H1>";
$params['content'] = $data; //page content

//set the length of keywords you like
$params['min_word_length'] = 5; //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));

$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;




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