PHP Counter to an XML file

This is a discussion on "PHP Counter to an XML file" within the PHP Forum section. This forum, and the thread "PHP Counter to an XML file are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 26th, 2005, 14:51
New Member
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Counter to an XML file

I have a PHP counter on my website and it writes the count to a text file as it incraments, but it also writes the visiting person's IP to another text file. I want to be able to write the IP's to an XML file, anyone know how I could edit my script to do that? Here's a copy of my current script (counter.php)

PHP: Select all

<?php 

session_start
();     
session_register('counter');        
$CountFile "txtfolder/counter.txt";     
$Count file($CountFile);     
$Count implode(""$Count);     
if(!
$_SESSION['counter']){     
$_SESSION['counter'] = true
$OpenFile fopen($CountFile"r+");     
$Count++;     
$user_ip GetHostByName($_SERVER['REMOTE_ADDR']);     
$banned = array('24.000.00.00''142.00.00.00');     
if (!
in_array($user_ip$banned)) {     
  if(
$OpenFile){     
  
fwrite($OpenFile$Count);     
  
fclose($OpenFile);     
  }       
}     
if (isset (
$_SERVER['HTTP_X_FORWARDED_FOR'])) { 
   
$user_ip $_SERVER['HTTP_X_FORWARDED_FOR']; 
} else { 
   
$user_ip $_SERVER['REMOTE_ADDR']; 

$string file_get_contents('txtfolder/ipaddresses.txt'); 
$pos strpos($string $user_ip); 
$ip_file "txtfolder/ipaddresses.txt"
$ip fopen($ip_file"a+"); 
if (
$pos === false) { 
    
fwrite($ip"$user_ip\n");     
    
fclose($ip); 

}    
?>
This is kinda what I wanted it to look like:

Code: Select all
<?xml version="1.1"?>

<iplist>
    <ipaddresses>
        <ip address="000.000.000.000">
        <ip address="999.999.999.999">
    </ipaddresses>
</iplist>
I was hoping to add other values to the ip field later like:

browser="IE"
referer="google.com"

but those are another issue for a later date, unless anyone can suggest a way to do that aswell

Thanks!
Reply With Quote

Reply

Tags
php, counter, xml, file

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Age Counter acrikey JavaScript Forum 4 Jun 2nd, 2008 12:37
Counter confused Website Planning 6 May 21st, 2007 03:27
hit counter? skyfire400 Web Page Design 6 Mar 7th, 2006 14:00
A PHP web counter? k3nshin PHP Forum 19 Feb 19th, 2004 22:35
print "$counter times 2 is ".($counter*2)."<br>" gwx03 PHP Forum 6 Dec 10th, 2003 10:50


All times are GMT. The time now is 18:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43