PHP Classes

File: Example1.php

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

Contents

Class file image Download
<?php
/******************************************************************
   Projectname: Autolink Keywords Application Script 1
   Version: 0.1
   Author: Ver Pangonilo <smp@limbofreak.com>
   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.

Description:
============
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:
=================
Since the autokeyword generator class produces only lower case words
and phrases, this example uses Case Sensitive string replacement.
******************************************************************/

//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>



EOF;

/**********************************************
This is the automatice keyword generator class
***********************************************/

//this the actual application.
include('class.autokeyword.php');

echo
"<H1>Input - text</H1>";
echo
$data;
$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>";

// this list could be an output of a database query
// or just from a plain text file.
$keyword_array = array(
"security" => "http://myscripts.itsp.info/security",
"technology" => "http://myscripts.itsp.info/technology",
"passport" => "http://myscripts.itsp.info/passport",
"state department" => "http://myscripts.itsp.info/state department",
"bruce" => "http://myscripts.itsp.info/bruce",
"radio frequency" => "http://myscripts.itsp.info/radio frequency"
);

$style = <<< CEOF

<style>
#link {
    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
    }
.link{
    font-size: 1.1em;
    color: #069;
    font-weight: bold;
}
</style>

CEOF;

print
"<br/>".$style;

include(
'class.autolink.php');

$autolink = new autolink($keywords, $keyword_array, $data, "link", "link","i");
echo
$autolink->linkKeywords();
?>