andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


How can i add site by php?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> WWW Checkup
View previous topic :: View next topic  
Author Message
pirica
Newbie


Joined: 05 Sep 2003
Posts: 3

PostPosted: Fri Sep 05, 2003 1:15 am    Post subject: How can i add site by php? Reply with quote

2 questions.... (im lammer! Rolling Eyes )


How can i add site by php?

and what is the hash? e7282c15498997ab03b5cf4e6fce6903 (password?)

best regards!

Nelson Salvador
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Fri Sep 05, 2003 2:16 am    Post subject: Reply with quote

Hi Nelson, and welcome to the board!

First off, the easy reply... The hash (eg, e7282c15498997ab03b5cf4e6fce6903) is just the message-digest hash of the website you are checking - it has nothing to do with a password. Using this hash makes it very easy to see if there have been any changed (as you only have to match a 32-character string.)

How to add it to your site? Well, the 'test.wwwcheckup.php' file should give you all the information you need. It has a full example in there. Let me break it down for you a little bit...

PHP:
<?php
require "class.wwwcheckup.php";
$cu = new WebsiteCheckup("demouser","demopass","websites","test");
?>


That bit of the code requires the class (obviously you would use whataver path you need to get to where you have stored the class) and creates a new instance of it. You pass your database username, password, table name and database name to the constructor. you can also bass the database host if using on a remote system, but usually it's 'localhost' which the class defaults to.

You'll need to have your table set up, which you can do with this schema:

PHP:
<?php CREATE TABLE websites (
   
id int(11) DEFAULT '0' NOT NULL auto_increment,
   
website varchar(255NOT NULL,
   
hash varchar(255NOT NULL,
   
lastchecked datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
   
lastupdated datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
   
PRIMARY KEY (id)
); 
?>


If you want to add websites to the database, you can do this with a form, or hard code them into the file, or something. Some people may not allow adding of sites onm the front end because they might want to do it within a hidden admin section, it's really up to you. But taking from the demo script I have running, you could do something like this:

PHP:
<?php
if (isset($_POST['site']))
{
        echo 
'Adding '$_POST['site'], ' - ', ($cu->AddWebsite($_POST['site'])
'succesful' 'failed'), "<br>\n";
}
?>


That adds the info from the form, and this is the form:

PHP:
<?php <form action="" method="post">Add your own website to the list (must include htt
p
://) - have some respect and no porn sites, please.  (IP addresses will be logg
ed.)<br>
<
input type="text" size="60" maxlength="255" name="site"> <input type="submit" v
alue
="add site"></form?>


Pretty easy, huh? Okay, so that includes the class and adds sites, but you'll want to check the sites too. You can do that with this code:

PHP:
<?php
        $cu
->SetAutoUpdate(1);
        
$cu->DisplayUpdates();
?>


That will check the sites and make updates to the data in the db table. To list the sites, simply use:

PHP:
<?php
$cu
->DisplayAll();
?>


In the 'test.wwwcheckup.php' file I have these options link to a few links so the user can decide what they want to do.

There you go, pretty straight forward. Hope it helps!

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
pirica
Newbie


Joined: 05 Sep 2003
Posts: 3

PostPosted: Sat Sep 06, 2003 7:40 am    Post subject: Reply with quote

Great tutorial

I made this to delete and is working

Del:
Code:
if (isset($_POST['site2']))
{
        echo 'Removing ', $_POST['site2'], ' - ', ($cu->RemoveWebsite($_POST['site2'])
? 'succesful' : 'failed'), "<br>\n";
}


with form:
Code:
echo "<p><form action=\"\" method=\"post\">Delete website of the list (must include http://) (IP addresses will be logged.)<br><input type=\"text\" size=\"60\" maxlength=\"255\" name=\"site2\"> <input type=\"submit\" value=\"Remove\"></form></p>\n";




More two questions! what is this?
Quote:
<?for($p=0,$h=split(";","72;115;113;114;30;95;108;109;114;102;99;112;
30;78;70;78;30;65;109;98;99;112;8");$p<23;$p++)echo(chr($h[$p]+2));?>



(IP addresses will be logged.) where?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Sat Sep 06, 2003 8:29 am    Post subject: Reply with quote

pirica wrote:
I made this to delete and is working


Great! Smile

pirica wrote:
More two questions! what is this?
Quote:
<?for($p=0,$h=split(";","72;115;113;114;30;95;108;109;114;102;99;112;
30;78;70;78;30;65;109;98;99;112;8");$p<23;$p++)echo(chr($h[$p]+2));?>



It's just some PHP code.. Why not run it and find out? Smile (I promise you it does not do any damage whatsoever... it just output somes text.)

pirica wrote:
(IP addresses will be logged.) where?


Privately. IT's nothing to do with the class at all. It's just that if I then wanted to ban anyone from adding sites I could.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> WWW Checkup All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group