Free web development scripts for the webmasterDevelopment Scripts


 social media marketing services
 Site Navigation
Clicky Web Analytics
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 1 user online
 o Most users online: 67
 o Home
  o PHP
   o Searching Stuff
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Paper Free Invoicing
 o Tutorials
 o Expired Domain Crawler

Uchase pay-per-click search (Rated 0)

Description:

Very small, simple, and easy to install script that will add value to your website and will generate income for you everytime somebody uses it and clicks on the search results. You need to register as an affiliate at uchase.com and change the affiliate id in the script to get paid. When user tipes in a search term and hits submit, XML feed from uchase.com is pooled by the script, parsed, and results are displayed on your website. You can completely change the design of search box and output result pages to suit your website using HTML and CSS

Code starts here


<?
/*******************************/
//Configuration
//please make appropriate settings


//your uchase affiliate id
$affiliateid=1000;

//the maximum number of results you
$maxres=10;


//change this if you want a hard coded keyword value; use urlencode() function,
// for example: $keyword=urlencode("free cigarettes for kids");
$keyword=urlencode($_GET['search']);


/*******************************/
//there is no need to change anything below this line except the footer where you can

include "./header.php";

if(
$keyword){
$file = "http://www.uchase.test/xml/xmlfeed.php?a=".$affiliateid."&kw=".$keyword."&maxres=".$maxres."&ip=".$HTTP_SERVER_VARS["REMOTE_ADDR"];
echo
$file;
if(
$_GET['page']) $file.="&page=".$_GET['page'];
$results = array();
$params=array();
$linknum=0;

function
startElement($parser, $name, $attrs)
{
global
$linknum, $params;
switch(
$name){
case
"RECORD":
$linknum++;
break;
case
"RESULTS":
while(list(
$k,$v)=each($attrs)) $params[strtolower($k)]=$v;
break;

}
}

function
endElement($parser, $name)
{
global
$results, $linknum, $thedata;

switch(
$name){
case
"TITLE":
$results[$linknum]["title"].=$thedata;
break;
case
"DESCRIPTION":
$results[$linknum]["description"].=$thedata;
break;

case
"DISPLAYURL":
$results[$linknum]["displayurl"].=$thedata;
break;
case
"CLICKURL":
$results[$linknum]["clickurl"].=$thedata;
break;
}
$thedata="";
}

function
characterData($parser, $data) {
global
$results, $linknum, $thedata;

$thedata.=$data;
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!(
$fp = fopen($file, "r"))) {
die(
"could not open XML input");
}

while (
$data = fread($fp, 4096)) {
if (!
xml_parse($xml_parser, $data, feof($fp))) {
die(
sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}

//header

echo $params['total']." results found<br> Shown results from ".$params['from']." to ".$params['to']."<br><br>";

for(
$i=1;$i<=$linknum;$i++){
echo
"<a class=resulttitle target=_self href=".$results[$i]['clickurl'].">".$results[$i]['title']."</a><br><span class=resultdescription>".$results[$i]['description']."</span><br><span class=resulturl>".$results[$i]['displayurl']."</span><br><br>";



}

//
xml_parser_free($xml_parser);

$pages=ceil($params['total']/$maxres);
for(
$i=0;$i<$pages;$i++){
echo
" | ";
if(
$i!=$params['page']) echo "<a class=pages href=".$HTTP_SELF."?search=".urlencode($search)."&page=".($i).">";
echo (
$i+1);
if(
$i!=$params['page']) echo "</a>";
echo
" | ";


}

}else{
echo
"Please enter a phrase to search";
}


//the html footer foloows. You can change it to you likeing
include "./footer.htm";
?>


Submitted by uchase on 02-09-2004 8:08


Recent Additions (from all categories)

(PHP) T Shirt Printing Software

(PHP) Youtube Video Organizer Script

(PHP) MP3z - MP3 Search Engine Script

(PHP) Recipez- PHP Recipe Script

(ASP) Stop image hotlinking and downloading. Web image protection is easy with Image Trapper.

Top Rated Scripts

(Javascripts) Javascript Delayed Redirection Rating: 5

(PHP) Random Links and images with PHP & MySQL Rating: 5

(PHP) RSS/XML news feed headline grabber! Rating: 5

(PHP) Random Signatures/Avatars Rating: 5

(Javascripts) Detecting Client Web Browser Rating: 5

© Copyright 2003 - Devscripts.net  Web Analytics