php-general Digest 29 Aug 2010 08:53:40 -0000 Issue 6916
Topics (messages 307726 through 307738):
Re: Questions about $_SERVER
307726 by: Per Jessen
307727 by: tedd
307728 by: Peter Lind
307729 by: tedd
307733 by: Tamara Temple
307736 by: Jim Lucas
Re: Making multiple RSS feeds for the blog website
307730 by: Michelle Konzack
Re: displaying constants
307731 by: David McGlone
array_walk_recursive pass by reference
307732 by: kranthi
Put all class in one file or different files
307734 by: Haulyn Jason
307735 by: Haulyn Jason
307737 by: Haulyn Jason
307738 by: Peter Lind
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
tedd wrote:
> Hi gang:
>
> The server global:
>
> $_SERVER['SERVER_ADDR']
>
> Provides the IP of the server where the current script is executing.
>
> And, the server global:
>
> $_SERVER['REMOTE_ADDR']
>
> Provides the IP of the server executing the script.
Yes, aka the client address.
> As such, you can enter the IP of either into a browser and see that
> specific domain.
Huh? If my server is 192.168.29.104 and my client is 192.168.29.114, I
might get the default website on the server address, and nothing on the
client (assuming it is not running a webserver).
> However, that doesn't work when you are dealing with shared hosting.
> Doing that will show you to the parent domain, but not the child
> domain (i.e., alias).
>
> So, how can I identify the exact location of the 'server_addr' and of
> the 'remote_addr' on shared hosting? Is that possible?
$_SERVER['SERVER_NAME'] will tell you the name of the virtual host - I
don't know if that is what you're after.
--
Per Jessen, Zürich (12.2°C)
--- End Message ---
--- Begin Message ---
At 9:41 PM +0200 8/28/10, Per Jessen wrote:
tedd wrote:
>
So, how can I identify the exact location of the 'server_addr' and of
the 'remote_addr' on shared hosting? Is that possible?
$_SERVER['SERVER_NAME'] will tell you the name of the virtual host - I
don't know if that is what you're after.
--
Per Jessen, Zürich (12.2°C)
Certainly, $_SERVER['SERVER_NAME'] will tell you
the name of the virtual host, but what about the
virtual remote?
You see, I can have a script on one server
communicate with another script on a another
server and the remote addresses reported on
either will not translate back to their
respective virtual hosts, but instead to their
hosts.
So, I'm trying to figure out a compliment to
$_SERVER['SERVER_NAME'] such as something like
$_SERVER['REMOTE_NAME'].
Is there such a beast?
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
On 28 August 2010 23:45, tedd <[email protected]> wrote:
> At 9:41 PM +0200 8/28/10, Per Jessen wrote:
>>
>> tedd wrote:
>> >
>>>
>>> So, how can I identify the exact location of the 'server_addr' and of
>>> the 'remote_addr' on shared hosting? Is that possible?
>>
>> $_SERVER['SERVER_NAME'] will tell you the name of the virtual host - I
>> don't know if that is what you're after.
>>
>> --
>> Per Jessen, Zürich (12.2°C)
>
> Certainly, $_SERVER['SERVER_NAME'] will tell you the name of the virtual
> host, but what about the virtual remote?
>
> You see, I can have a script on one server communicate with another script
> on a another server and the remote addresses reported on either will not
> translate back to their respective virtual hosts, but instead to their
> hosts.
>
> So, I'm trying to figure out a compliment to $_SERVER['SERVER_NAME'] such as
> something like $_SERVER['REMOTE_NAME'].
>
> Is there such a beast?
>
You're not making any sense. For the script on your local host to be
able to connect and communicate with the remote host, it would need to
know the name of the remote host. Hence, the local host already knows
the name and has no reason to ask the remote host for a name by which
to contact it.
That's what I get from your description of the problem. You probably
want to clarify some things.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---
--- Begin Message ---
At 12:15 AM +0200 8/29/10, Peter Lind wrote:
On 28 August 2010 23:45, tedd <[email protected]> wrote:
> So, I'm trying to figure out a compliment to
$_SERVER['SERVER_NAME'] such as
something like $_SERVER['REMOTE_NAME'].
> Is there such a beast?
You're not making any sense. For the script on your local host to be
able to connect and communicate with the remote host, it would need to
know the name of the remote host. Hence, the local host already knows
the name and has no reason to ask the remote host for a name by which
to contact it.
That's what I get from your description of the problem. You probably
want to clarify some things.
Regards
Peter
Peter:
Sorry for not making sense. But sometimes you have to confirm the
players (both server and remote) in communications.
Try this -- place this script on your site:
<?php
print_r($_SERVER);
?>
You will note that:
[SERVER_NAME] => is the domain name of your site.
Also:
[SERVER_ADDR] => is the IP of your site. If you are on a shared host,
then it will still be the IP of the main host.
Please note:
[REMOTE_ADDR] => is the IP of the remote server. It *will be* the IP
of the remote main host regardless of if the requesting script is
running on the remote main host OR is running under a remote shared
host.
Here's an example:
My site http://webbytedd.com is running on a shared host.
The server address reported for this site is: 74.208.162.186
However, if I enter 74.208.162.186 into a browser, I do not arrive at
webbytedd.com, but instead go to securelayer.com who is my host.
Now, if webbytedd.com was the requesting script, how could the
original script know what domain name the request came from? As it is
now, it can only know the main host ID, but not the domain name of
the requesting script. Does that make my question any clearer?
So my questions basically is -- how can I discover the actual domain
name of the remote script when it is running on a shared server?
I hope that makes better sense.
Cheers,
tedd
--
-------
http://sperling.com/
--- End Message ---
--- Begin Message ---
Sorry, forgot to include the mailing list email when I replied to this
originally...
On Aug 28, 2010, at 8:28 PM, tedd wrote:
Sorry for not making sense. But sometimes you have to confirm the
players (both server and remote) in communications.
Try this -- place this script on your site:
<?php
print_r($_SERVER);
?>
You will note that:
[SERVER_NAME] => is the domain name of your site.
Also:
[SERVER_ADDR] => is the IP of your site. If you are on a shared
host, then it will still be the IP of the main host.
Please note:
[REMOTE_ADDR] => is the IP of the remote server. It *will be* the IP
of the remote main host regardless of if the requesting script is
running on the remote main host OR is running under a remote shared
host.
Here's an example:
My site http://webbytedd.com is running on a shared host.
The server address reported for this site is: 74.208.162.186
However, if I enter 74.208.162.186 into a browser, I do not arrive
at webbytedd.com, but instead go to securelayer.com who is my host.
Now, if webbytedd.com was the requesting script, how could the
original script know what domain name the request came from? As it
is now, it can only know the main host ID, but not the domain name
of the requesting script. Does that make my question any clearer?
So my questions basically is -- how can I discover the actual domain
name of the remote script when it is running on a shared server?
I hope that makes better sense.
Cheers,
tedd
I really don't understand what you mean by "remote script" -- most
requests are made by clients. REMOTE_ADDR is the IP address of the
*client* - i.e. the requesting system. It may or may not be a script.
And it may or may not have an accessible hostname.
Is this a situation where you are establishing a service that is to be
called by other servers, i.e, some form of API? If not, and if it is a
case of a browser client calling a PHP script on your server, most
browser clients aren't running on very useful hostnames for the
outside world anyway. E.g. the hostname of my mac is "paladin.local"
but it obviously can't be called by the outside world by that name.
Maybe tell us what you are trying to accomplish by knowing the
hostname of the calling machine? Maybe there's another way.
Are you trying to set up two-way communication between the two
servers? Normally, communication is established without regard for
the calling machine's hostname, because it's going through the
connection established by the web server. PHP just returns info along
that connection to the calling machine. It seems you would only need
to know the requesting system's hostname if you were going to
establish some other channel of communication with it, i.e., if your
original script was somehow going to call back the calling machine,
webbytedd.com to do some other kind of activity. If that *is* what
you're doing, I can probably guarantee there's a better way to do it.
However, if what you're after is *authenticating* that the requester
is who they say they are, there are ways to do that as well without
knowing the requesting host's name (and better than knowing the
requesting host's name, you can establish authenticity and access
control for a particular script which is much better than just
establishing blanket authority for a particular hostname).
However, I'm really reaching here with trying to understand what you
want to accomplish by knowing the requesting machine's hostname.
So, please, explain what you are trying to do and maybe we can help
with that.
Tamara
--- End Message ---
--- Begin Message ---
tedd wrote:
At 12:15 AM +0200 8/29/10, Peter Lind wrote:
On 28 August 2010 23:45, tedd <[email protected]> wrote:
> So, I'm trying to figure out a compliment to
$_SERVER['SERVER_NAME'] such as
something like $_SERVER['REMOTE_NAME'].
> Is there such a beast?
You're not making any sense. For the script on your local host to be
able to connect and communicate with the remote host, it would need to
know the name of the remote host. Hence, the local host already knows
the name and has no reason to ask the remote host for a name by which
to contact it.
That's what I get from your description of the problem. You probably
want to clarify some things.
Regards
Peter
Peter:
Sorry for not making sense. But sometimes you have to confirm the
players (both server and remote) in communications.
Try this -- place this script on your site:
<?php
print_r($_SERVER);
?>
You will note that:
[SERVER_NAME] => is the domain name of your site.
Also:
[SERVER_ADDR] => is the IP of your site. If you are on a shared host,
then it will still be the IP of the main host.
Please note:
[REMOTE_ADDR] => is the IP of the remote server. It *will be* the IP of
the remote main host regardless of if the requesting script is running
on the remote main host OR is running under a remote shared host.
Here's an example:
My site http://webbytedd.com is running on a shared host.
The server address reported for this site is: 74.208.162.186
However, if I enter 74.208.162.186 into a browser, I do not arrive at
webbytedd.com, but instead go to securelayer.com who is my host.
Now, if webbytedd.com was the requesting script, how could the original
script know what domain name the request came from? As it is now, it can
only know the main host ID, but not the domain name of the requesting
script. Does that make my question any clearer?
So my questions basically is -- how can I discover the actual domain
name of the remote script when it is running on a shared server?
Their is not existing variable (if you would) that your server, when
connecting to a remote server, would be sending. So, to have the remote
end be able to identify the initiating host identity, the initiating
side would have to add some something to the headers or pass it along in
the body of the request itself.
What type of service are you trying to create on your server? And what
protocol would it be using to connect to the remote server? If you are
using cURL, you could add something to the headers before you send the
request. But, if you are using something like fopen or
file_get_contents, you are stuck. You would not be able to modify the
headers being sent in the request.
If you are in need of identifying the initial server from the second
server, then I would suggest using cURL and adding something unique to
the headers before you send the request to the remote server.
Hope that is clear as mud.
I hope that makes better sense.
Cheers,
tedd
--- End Message ---
--- Begin Message ---
Hello Andre Polykanine,
Am 2010-08-27 12:55:51, hacktest Du folgendes herunter:
> Hello Michelle,
>
> Hm. link rel="alternate"... that's a good one, thanks (btw, you say me
> that I should RTFM, but if I knew what to read....).
> Now there are two questions:
> 1. How do I do those .RSS files with PHP? All of mmy blog entries and
> other stuff are in MySql. There are classes that can echo the
> appropriate data as RSS, but there will be more .PHP files, not
> .RSS/.XML ones. So how do we manage that?
> 2. Should I make a separate .RSS file for each type of feeds (blog
> feed, comments feed, timeline feed, news feed)?
The Internet is full of HOWTOs which explain HOW-TO-MAKE-A-RSS-FEED...
However sometimes back I asked HERE IN THIS LIST the same IDIOTQUESTION!
You could have searched THIS LIST... :-P
OK, since I now know, how to make RSS Feeds here some advice:
1) you should know, how many days or hoe many items should be stored
in the RSS feed
2) Create for each article in the BLOG in a directory a file like
----8<--------------------------------------------------------------
<item>
<title>PHP Website</title>
<link>http://www.php.net/</link>
<description>Great programmers Website, where you an find nice peoples on
the mailinglist, which explain how RSS is working.</description>
<guid isPermaLink="true">http://blog.pnp.net/items/1258834764.html</guid>
<pubDate>Sat, 21 Nov 2009 21:20:12 +0100</pubDate>
</item>
----8<--------------------------------------------------------------
and save them using the UNIX serialtime like 1258834764.rss
The included "isPermaLink" should point to the BLOG article
3) Now you have to create the index.rss.tmp with the HEADER which looks
like
----8<--------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
<channel>
<title>PHP Superhere PHP RSS Feed</title>
<link>http://www.php.net/</link>
<description>PHP RSS Feed Overview</description>
<language>en</language>
<copyright>Copyright 2010, Michelle Konzack</copyright>
<lastBuildDate>Sun, 29 Aug 2010 04:13:17 +0200</lastBuildDate>
<docs>http://www.php.net/michelles_php_rss_feed/</docs>
<managingEditor>[email protected]</managingEditor>
<webMaster>[email protected]</webMaster>
<ttl>10</ttl>
<image>
<title>PHP Website</title>
<url>http://www.php.net/logo.png</url>
<link>www.php.net</link>
<width>120</width>
<height>160</height>
<description>PHP Logo</description>
</image>
----8<--------------------------------------------------------------
Now pipe how much (and in order ) the messages build under 2) at the
end and of this file...
4) close the RSS feed index.rss.tmp with
----8<--------------------------------------------------------------
</channel>
</rss>
----8<--------------------------------------------------------------
5) now move
mv index.rss.tmp <doc_root>/index.rss
thats all
Thanks, Greetings and nice Day/Evening
Michelle Konzack
--
##################### Debian GNU/Linux Consultant ######################
Development of Intranet and Embedded Systems with Debian GNU/Linux
itsyst...@tdnet France EURL itsyst...@tdnet UG (limited liability)
Owner Michelle Konzack Owner Michelle Konzack
Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France 77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix
<http://www.itsystems.tamay-dogan.net/> <http://www.flexray4linux.org/>
<http://www.debian.tamay-dogan.net/> <http://www.can4linux.org/>
Jabber [email protected]
ICQ #328449886
Linux-User #280138 with the Linux Counter, http://counter.li.org/
signature.pgp
Description: Digital signature
--- End Message ---
--- Begin Message ---
On Sat, 2010-08-28 at 11:13 -0400, Daniel P. Brown wrote:
> On Sat, Aug 28, 2010 at 10:58, David McGlone <[email protected]> wrote:
> > Hi all, could someone show me how to echo back a constant to check if
> > they are assigned correctly? Something like this:
> >
> > define('SITE_ROOT', dirname(dirname(__FILE__)));
> >
> > echo 'SITE_ROOT';
> >
> > I tried the echo but it wasn't working.
>
> To get the assigned value? Drop the quotes.
Thanks Daniel, that was it. I also want to apologize to the list, I
completely forgot about the php manual. Don't ask me how. Maybe old age
setting in. Anyway I realized what I did when another list member
pointed it out to me.
--
Blessings,
David M.
--- End Message ---
--- Begin Message ---
i have an array
$parms = array('1' => 'a', 'b' => array(3 => 'test'));
i want $mail = '1:a 3:test';
array_walk_recursive($parms, function($val, $key, &$mail) {
$mail .= ucwords($key) . ': '. ucwords($val) . "\n";
}, &$mail);
The above function worked perfectly well
but i am getting: Call-time pass-by-reference has been deprecated in
/var/www/html/test.php on line 31
if i change it to
array_walk_recursive($parms, function($val, $key, &$mail) {
$mail .= ucwords($key) . ': '. ucwords($val) . "\n";
}, $mail);
i am not getting the error but $mail is not being returned.
ny solution ?
Regards
KK
--- End Message ---
--- Begin Message ---
Hi, all:
I have many classes, from Java I have to put a class in one java files,
in PHP I know I can put all of them in one file, but this make my class
files too large, is there any best practice to guide these basic?
Thanks.
--
Thanks!
VVThumb Microproduction
Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
No. 1 Shunhua Rd High-Tech Development Zone
Jinan, China 250101
Website: http://www.haulynjason.net/haulyn
Mobile: +86 15854103759
Haulyn Jason
--- End Message ---
--- Begin Message ---
On 08/29/2010 01:06 PM, Josh Kehn wrote:
On Aug 29, 2010, at 12:56 AM, Haulyn Jason wrote:
Hi, all:
I have many classes, from Java I have to put a class in one java files, in PHP
I know I can put all of them in one file, but this make my class files too
large, is there any best practice to guide these basic?
Thanks.
--
Thanks!
VVThumb Microproduction
Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
No. 1 Shunhua Rd High-Tech Development Zone
Jinan, China 250101
Website: http://www.haulynjason.net/haulyn
Mobile: +86 15854103759
Haulyn Jason
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Your question is clear as mud, can you clarify at all?
Regards,
-Josh
____________________________________
Joshua Kehn | [email protected]
http://joshuakehn.com
Sorry, I mean:
In php project, I am using OOp feature, I want to know, which way the
following is better. 1, write a new class, create a new file. 2. write
all class in one php file.
Thanks.
--
Thanks!
VVThumb Microproduction
Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
No. 1 Shunhua Rd High-Tech Development Zone
Jinan, China 250101
Website: http://www.haulynjason.net/haulyn
Mobile: +86 15854103759
Haulyn Jason
--- End Message ---
--- Begin Message ---
On 08/29/2010 02:04 PM, Eric Cash wrote:
I'm out and about right
now, so I can't link you to the autoload documentation page
Thanks Eric, I have read the autoload document, but not pay attention on
it. I will search more about it now, thanks.
--
Thanks!
VVThumb Microproduction
Location:Room 807,QiLuRuanJianDaSha Qilu Software Park
No. 1 Shunhua Rd High-Tech Development Zone
Jinan, China 250101
Website: http://www.haulynjason.net/haulyn
Mobile: +86 15854103759
Haulyn Jason
--- End Message ---
--- Begin Message ---
On 29 August 2010 08:14, Haulyn Jason <[email protected]> wrote:
> On 08/29/2010 02:04 PM, Eric Cash wrote:
>>
>> I'm out and about right
>> now, so I can't link you to the autoload documentation page
>
> Thanks Eric, I have read the autoload document, but not pay attention on it.
> I will search more about it now, thanks.
>
For maintainability: 1 class, 1 file
For performance: all critical/core class in same file (i.e. the ones
you WILL load no matter what), the rest loaded as needed
It's a tradeoff. If you don't know which to pick, go with 1 class, 1 file.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>
--- End Message ---