WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Ajax-based dictionary
Categories : PHP, Java Script, AJAX Click here to Update Your Picture
Dmitry Sheiko
Date : Jan 09th 2007
Grade : 5 of 5 (graded 2 times)
Viewed : 11592
File : 4563.zip
Images : Image 1
Search : More code by Dmitry Sheiko
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

The Web site advertising business became much more profitable to Web site owners, and more effective for advertisers, when Web advertising agencies invested in contextual advertising techniques, like those used by AdSense and IntelliTXT.

Instead of display almost randomly chosen ads, context advertising techniques show ads that are picked automatically by the ad servers to match the topics of the content displayed in each page.

This package implements a solution that can be used to display contextual advertising using PHP.

It can scan the text in the current page and submit it to the server via AJAX. In response to the AJAX request, contextual advertising may be displayed in a pop-up window.

Please see attached file above.


controller.php
<?PHP
/*
* Thesaurus
*
* @package Thesaurus
* @author $Author: sheiko $ 
* @version $Id: controller.php, v 1.5 2007/01/2 15:58:15 sheiko Exp $
* @since v.1.5
* @copyright (c) Dmitry Sheiko http://www.cmsdevelopment.com
*/

/**
* Thesaurus Controller Class
* @package Thesaurus
* @author $Author: sheiko $
*/


class Thesaurus {
   
    var
$DataSourceFile;
    var
$Output;
    var
$BodyContent;
    var
$Term;
    var
$ErrorMsg;
    var
$Length;
    var
$Tags;
   
   
/**
    * Class Constructor
    * @return object
    */     
   
   
function Thesaurus() {
       
$this->DataSourceFile = "sample.csv";
       
$this->BodyContent = false;
       
$this->ErrorMsg = false;
       
$this->Term = false;
       
$this->Length = 0;
       
$this->Output = '';       
        if(isset(
$_POST["body"])) $this->BodyContent = urldecode($_POST["body"]);
        if(isset(
$_POST["term"])) $this->Term = strtolower($_POST["term"]);
        if(!
$this->Term AND !$this->BodyContent) $this->ErrorMsg = "Incorrect parameters";
        return
$this;
    }

   
   
/**
    * Get data and filter data
    *
    * @return boolean
    */         
   
function getDataAndFitlering() {
       
$data = file($this->DataSourceFile);
       
$this->Length = count($data);
        foreach (
$data as $key => $line) {
           
$arr = split(";", $line);
            if(
$arr[0]==$this->Term) $this->Output = $arr[1];
            unset(
$data[$key]);
        }
    }
   
   
/**
    * Strip tags
    *
    */                 
   
function stripTags($Term) {
       
$mathes = array();
       
preg_match_all("/(<a[^>]*>)(".preg_quote($Term,"/").")([^>]*?)<\/a>/is", $this->BodyContent, $mathes);
       
$this->Tags = $mathes[0];
       
preg_match_all("/(<script[^>]*>)(".preg_quote($Term,"/").")([^>]*?)<\/script>/is", $this->BodyContent, $mathes);
       
$this->Tags = array_merge($this->Tags, $mathes[0]);
       
preg_match_all("/title=\"([^\"]*?)(".preg_quote($Term,"/").")([^>]*?)\"/is", $this->BodyContent, $mathes);
       
$this->Tags = array_merge($this->Tags, $mathes[0]);
       
preg_match_all("/alt=\"([^\"]*?)(".preg_quote($Term,"/").")([^>]*?)\"/is", $this->BodyContent, $mathes);
       
$this->Tags = array_merge($this->Tags, $mathes[0]);
       
        if(
$this->Tags) {
            foreach(
$this->Tags as $match) {
               
$this->BodyContent = preg_replace("/".preg_quote($match,"/")."/s", "{!".md5($match)."!}", $this->BodyContent);
            }
        }
    }

   
/**
    * Restore tags
    *
    */             
   
function retoreTags() {
        if(
$this->Tags) {
                foreach(
$this->Tags as $match) {
                   
$this->BodyContent = preg_replace("/\{!".md5($match)."!\}/s", $match, $this->BodyContent);
                }
            }       
    }   
   
   
/**
    * Get data and parse body content
    *
    * @return boolean
    */         
   
function getDataAndParsing() {
       
$tags = array();
       
$data = file($this->DataSourceFile);
       
$this->Length = count($data);
       
$this->BodyContent = preg_replace("/parseContent();/is", "", stripslashes($this->BodyContent));
        foreach (
$data as $key => $line) {
           
$arr = split(";", $line);
           
$this->stripTags($arr[0]);
           
// Replace all matches
           
if(preg_match("/\s/", $arr[0])) {
                if(   
preg_match("/".preg_quote($arr[0])."/is", $this->BodyContent ) )
                   
$this->BodyContent = preg_replace("/(".preg_quote($arr[0]).")/is", "<a class=\"thesaurus\" onmouseover=\"getDefinition('\\1', event);\" onmouseout=\"setTimer();\">\\1</a>", $this->BodyContent);
            } elseif(   
preg_match("/[\s<>]".preg_quote($arr[0])."[\s<>]/is", $this->BodyContent ) ) {
               
$this->BodyContent = preg_replace("/([\s<>])(".preg_quote($arr[0]).")([\s<>])/is", "\\1<a class=\"thesaurus\" onmouseover=\"getDefinition('\\2', event);\" onmouseout=\"setTimer();\">\\2</a>\\3", $this->BodyContent);
            }
           
$this->retoreTags();
            unset(
$data[$key]);
        }
       
$this->Output = preg_replace("/[\r\n]/", "", $this->BodyContent);
       
       
    }   

   
/**
    * Respond with JSON generation
    *
    * @return boolean
    */         
   
function execRespond() {
        if(
$this->Term) $this->getDataAndFitlering();
        if(
$this->BodyContent) $this->getDataAndParsing();
        if(
$this->Length==0) return false;
       
header("Content-type: text/html; charset=UTF-8");
       
$out = '{
        "thlength" : '
.$this->Length.',
        "errormsg" : "'
.$this->ErrorMsg.'",
        "content" : "'
.addslashes($this->Output).'"
        }'
;
        print
$out;
    }
   
}

$th = new Thesaurus();
$th->execRespond();
?>



Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
ezRemoteScripter - A little remote scripting (AJAX) helper
Categories : PHP, Java Script, AJAX
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
AJAX Data Grid System using php and mysql. A complete login system with the ability to display data in a grid using ajax. Add , update and delete the records without reloading the page.
Categories : PHP, AJAX, Databases, MySQL, Java Script
Zephyr: AJAX Based Framework for PHP5 Developers
Categories : PHP, AJAX, Frameworks, Java Script, Web Applications
How to check if JavaScript is enabled on a remote browser with PHP
Categories : PHP, Java Script
Validator 98 - a PHP-script to generate form-validation-code in JavaScript.
Categories : Complete Programs, Java Script, PHP, HTML and PHP
day and week grid with clickable fields on/off and possibility to insert in DB
Categories : PHP, Java Script, CSS
Activate an Ajax.Autocompleter with an onLoad Command
Categories : Java Script, AJAX
PHP3 generated gif / javascript mouseover.
Categories : PHP, Java Script, MySQL
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit.
Categories : PHP, Filesystem, Regexps, Java Script
Popup window creator for images on the Fly.
Categories : PHP, GD image library, Java Script
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script