Forum Moderators: coopster

Message Too Old, No Replies

PHP URL Checker

         

chrisuuc

12:42 pm on Dec 3, 2008 (gmt 0)

10+ Year Member



In university at the minute with a final year project ... Designing this function within PHP. Its main purpose is to take any given url entered by a user and search its meta data and html <a> tag words against an sql database made up of forbidden words and if they match then have to return a forbidden site answer or if not they approve the site of use in a university module.

Ive a prototype due in soon and for its function all it has to do is take a pre fixed website designed by myself in html ... which ive done and included to start with some words within the meta data keywords like "sport" "fashion".

Ive also created a sql database called urlcheck housing these keywords and a prefixed key field id.

Im trying to link the words found in the meta data to that in the database and have hit a brick wall ...

Coding so far on the comparison script is:

<?php
$tags = get_meta_tags('testsite.html');

echo $tags['keywords']; // Key meta data that can be compared
echo $tags['description']; // Key meta desciption that can be searched

echo "\n";

if (? ) {
echo "Your URL is invalid!<br />";
}
echo "Approved!";

?>

////////////////////////////////////

Code for the actual user entry page is below excuse the bad coding as im new to this.

<?php
// calling commontop for this page
include("urlcommontop2.php");

// connecting to the project database
include("dbConnect.php");

$db=mysql_connect($dbHost, $dbUsername, $dbPassword);
mysql_select_db($databasename,$db);

//SQL query to select all from urlcheck database where keyword match keywords in metadata
$dbQuery="SELECT * FROM urlcheck WHERE ?";
$result = mysql_query($dbQuery,$db);

?>


<p>&nbsp;</p>


This web tool is designed to scroll various URL's and research the genres and
content of the site so the user can make a safe decision to add the URL to their
database.<p>&nbsp;</p>
&nbsp;

<?php
// URL entry form for user to paste/type url.
// Hidden field to search keyword in database.
?>

<span style="width:500; float:;">
<form action="searchurl.php" method="post"><p>Paste URL:</p>
<input name="keyword" type="hidden" id="keyword">
<input type="text" name="url" size="105" value="">
<input type="Submit" name="submit" value="Check URL">
</form>

<?php
// URL add to database form.
// Hidden field to search keyword in database.
?>

<span style="width:500; float:;"></span>
<form id="addurl" name="addurl" method="post" action="URL-collector.php">
<input type="hidden" name="addClient" value="yes">
<div id="url " class="smallBottomSpace"><span class="formLabel">Enter approved URL:
<br> </span><br>
<input class="pinkForm" name="url" type="text" size="30" value="" style="width: 410px"><br>
<input type="submit" value="Add URL" onclick="verifyForm()">&nbsp;&nbsp;&nbsp;
</div></form>

<?php
// closing common bottom ... </body></html>
include ("commonBottom.php");
?>

///////////////////////////////////////////////////////////

cant seem to get what i want the query to do on to the page ... complete block ... could anyone give me some advice on this please ...

Thanks in advance ... :)

jatar_k

6:48 pm on Dec 4, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld chrisuuc,

do these return the right thing?

echo $tags['keywords'];
echo $tags['description'];

i am assuming so since they don't have any question marks

addressing the ?s

if (? ) {
echo "Your URL is invalid!<br />";
}

well here you want to say

if the content from the meta tags ($tags) matches the bad words from my db

you probably should figure out how you are going to format that data so you can wquery the db with it

$dbQuery="SELECT * FROM urlcheck WHERE ?";

ah, there you go, we could look at the structure of your table and see how to query this

how about using IN, maybe we could make our words into a comma separated list and feed the to our query

$dbQuery="SELECT * FROM urlcheck WHERE word IN (" . $mylistofkeywords . ")";

if mysql_num_rows gives you >0 then I think they have bad words in there