Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Subject: how do i fetch some text
At 04:51 29/05/2005 +0000, you wrote:
>Message-ID: <02.10.02217.F0449924@pb1.pair.com>
>To: php-db@lists.php.net
>Date: Sun, 29 May 2005 09:54:50 +0530
>From: chintan <chintanonnet@hotmail.com>
>MIME-Version: 1.0
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Content-Transfer-Encoding: 7bit
>Subject: how do i fetch some text
>
>how do i fetch some text from a webpage for some generated field?

You would have to retrieve the whole web page. Look up fopen(url) in the
PHP manual, and then the related fgets() and fclose() functions. Using
these you can read the HTML of the web page into a string or array, and use
regular expressions such as preg_match() to extract the string of numbers
after the string "score" which is inside your "generated field".

>like i want to fetch a score line from a sport site in which the line says
>"score"?
>actually i want to fetch an IP from my ISP's page which displays it with
>my user name.

Actually ? You mean this was a bogus example and you are wasting our time ?

Why not say what you *actually* want. If you want to retrive your IP
addresss, then write code to do that.
But it's a waste of time to go to your ISPs web page, to extract that, when
you can do it as easily yourself.

This code returns your current IP address :

<?php
function getUserIPAddr() {
global $_SERVER;
$privip=false;
$remote=$_SERVER["REMOTE_ADDR"];

$comes_from=array("HTTP_VIA", "HTTP_X_COMING_FROM",
"HTTP_X_FORWARDED_FOR",
"HTTP_X_FORWARDED","HTTP_COMING_FROM",
"HTTP_FORWARDED_FOR",
"HTTP_FORWARDED");
//      By preference, replace the remote IP with the proxied-for IP
foreach ($comes_from as $value) {
if
(ereg("^([0-9]{1,3}\.){3,3}[0-9]{1,3}",$_SERVER[$value],$remote_temp)) {
$remote=$remote_temp[0]; //     Fish out IP match
if ereg returns a value
}
}

//      Check range against private IP addresses
if (ereg("^192\.168\.[0-9]{1,3}\.[0-9]{1,3}",$remote,$remote_temp)) {
$privip=true;
$remote=$_SERVER["REMOTE_ADDR"];
}

if (ereg("^172\.([0-9]{1,3}\.){2}[0-9]{1,3}",$remote,$remote_temp)) {
//      Extra check on range
if ($remote_temp[1]>=16 && $remote_temp[2]<32 ) {
//      is in class B private address range
$privip=true;
$remote=$_SERVER["REMOTE_ADDR"];
}
}

if (ereg("^10\.([0-9]{1,3}\.){2}[0-9]{1,3}",$remote,$remote_temp)) {
$privip=true;
$remote=$_SERVER["REMOTE_ADDR"];
}

return $remote;
}       //      End function getUserIPAddr()
?>

Cheers - Neil

Report this thread to moderator Post Follow-up to this message
Old Post
Neil Smith [MVP, Digital media]
05-30-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP DB archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:38 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.