Jump to content

no script, just a question "how to check for certain image"


boemboem

Recommended Posts

Hello all,

 

I'd like to provide people with a certain image, not just image, but a image with a unique numer something like this:

<img src="http://www.mydomain.nl/pl016342345.gif" width="30" height="30" />

 

This image will prove to me that that person keeps his promise. Is there a way I can check if this is on his website with the above link provided by me?

 

Any help would be great :)

 

Can I use this?/

 

<?
$keyword_to_find = "http://www.google.nl/logos/nl_doodle4google09.gif";s

if (is_keyword_found($keyword_to_find)== true) {
print "Image gevonden!"; 	//found
} else {
print "Image niet gevonden.";	//not found
}

//Verify if any line from the data file is existing in the given string

$data = explode("\n",$data);
foreach ($data as $line) {
	if (trim($line)!="") {
		if (!stristr($keyword,$line)===FALSE) {
			return true;
		}
	}
}
return false;
}
?>

ok, I tried this, will this work??

 

This is the imagecheck.php

 

<?
$keyword_to_find = "http://www.another-domain.com";

if (is_keyword_found($keyword_to_find)== true) {
print "image found!"; 	//found
} else {
print "sorry, image not found.";	//not found
}

function is_keyword_found($keyword) {
$filename = 'datafile.txt';
//Check if we have local copy of the remote data file saved in our server
if (!file_exists($filename)) {
	//Create data file in our server
	$data = get_remote_data($filename);
} else {
	//Read last modification date of the data file
	$lastmodified = date("d/m/y",filemtime($filename));
	$today = date("d/m/y");
	//Compare with today's date to make sure if 
	//the file has been updated today
	if ($lastmodified != $today) {
		//Update data file on server
		$data = get_remote_data($filename);
	} else {
		//Read data file from server
		$data = file_get_contents($filename);
	}
}
//Verify if any line from the data file is existing in the given string
//return (stristr($data,$keyword) === FALSE)?false:true;
$data = explode("\n",$data);
foreach ($data as $line) {
	if (trim($line)!="") {
		if (!stristr($keyword,$line)===FALSE) {
			return true;
		}
	}
}
return false;
}

?>

 

The content of the datafile.txt

http://www.keurmerk.coldcharlie.nl/keurmerkimages/12342345.gif

 

this is what I'm trying to do:

 

I want to have a image found in this domain: http://www.gadgetgarden.nl/index.php

the image location is here: http://www.gadgetgarden.nl/wp-content/uploads/2009/01/pro-motion_toetsenbord.jpg

 

This is what I did:

 

<?
$keyword_to_find = "http://www.gadgetgarden.nl/index.php";

if (is_keyword_found($keyword_to_find)== true) {
print "Keurmerk aanwezig!"; 	//found
} else {
print "Keurmerk niet aanwezig!";	//not found
}

function is_keyword_found($keyword) {
$filename = 'datafile.txt';
//Check if we have local copy of the remote data file saved in our server
if (!file_exists($filename)) {
	//Create data file in our server
	$data = get_remote_data($filename);
} else {
	//Read last modification date of the data file
	$lastmodified = date("d/m/y",filemtime($filename));
	$today = date("d/m/y");
	//Compare with today's date to make sure if 
	//the file has been updated today
	if ($lastmodified != $today) {
		//Update data file on server
		$data = get_remote_data($filename);
	} else {
		//Read data file from server
		$data = file_get_contents($filename);
	}
}
//Verify if any line from the data file is existing in the given string
$data = explode("\n",$data);
foreach ($data as $line) {
	if (trim($line)!="") {
		if (!stristr($keyword,$line)===FALSE) {
			return true;
		}
	}
}
return false;
}

?>

 

And the datafile.txt

 

http://www.gadgetgarden.nl/wp-content/uploads/2009/01/pro-motion_toetsenbord.jpg

 

What I try to accomplish is the following.

 

I have a image on my own server

<img src="http://www.my-domain.nl/images/29092008.jpg" width="60" height="60" />

 

the image above, this code I provide to people. The thing I want to do is to check if this piece of code excists on an other domain. for example http://www.another-domain.com.

 

This is a  part of a code I found. And edited it to fit for my own use.

With the code.

 

<?
$keyword_to_find = "http://www.another-domain.com";

if (is_keyword_found($keyword_to_find)== true) {
   print "Keurmerk aanwezig!";    //found
} else {
   print "Keurmerk niet aanwezig!";   //not found
}

function is_keyword_found($keyword) {
   $filename = 'datafile.txt';
     //Compare with today's date to make sure if
      //the file has been updated today
     
       //Read data file from server
         $data = file_get_contents($filename);
      }
   }
   //Verify if any line from the data file is existing in the given string
   $data = explode("\n",$data);
   foreach ($data as $line) {
      if (trim($line)!="") {
         if (!stristr($keyword,$line)===FALSE) {
            return true;
         }
      }
   }
   return false;
}

?>

 

The tekst wich is in the datafile.txt

http://www.my-domain.nl/images/29092008.jpg

 

Can somebody explain to me how I can make this work??

<?php
$domainCheck = "http://anotherdomain.com";
$codeToCheck = '<img src="http://www.my-domain.nl/images/29092008.jpg" width="60" height="60" />';

$html = file_get_contents($domainCheck);

if (stristr($html, $codeToCheck) !== false) {
    echo 'Success, they have the code';
}else {
    echo 'Failed, no code found.';
}
?>

 

Simple as that. Note the img code must be exactly like that or it will return false.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.