php-general Digest 28 Aug 2010 19:18:32 -0000 Issue 6915
php-general Digest 28 Aug 2010 19:18:32 - Issue 6915 Topics (messages 307722 through 307725): Re: Making multiple RSS feeds for the blog website 307722 by: Jason Pruim displaying constants 307723 by: David McGlone 307724 by: Daniel P. Brown Questions about $_SERVER 307725 by: tedd Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Aug 27, 2010, at 5:55 AM, Andre Polykanine wrote: 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)? thanks! Andre... What I did when I created my RSS feed is I went and read the RSS spec and found out what it needed to create it.[1] Read through that and it should get you started. If your competent with PHP then all you would need to do is loop through your result set to display the results. If you're not quite sure if you know how to do it though... I as well as many other people on the list I'm sure are available to hire to get it done :) [1] http://cyber.law.harvard.edu/rss/rss.html ---End Message--- ---BeginMessage--- 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. -- Blessings, David M. ---End Message--- ---BeginMessage--- On Sat, Aug 28, 2010 at 10:58, David McGlone da...@dmcentral.net 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. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ ---End Message--- ---BeginMessage--- 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. As such, you can enter the IP of either into a browser and see that specific domain. 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? Thanks, Cheers, tedd -- --- http://sperling.com/ ---End Message---
Re: [PHP] Re: Making multiple RSS feeds for the blog website
On Aug 27, 2010, at 5:55 AM, Andre Polykanine wrote: 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)? thanks! Andre... What I did when I created my RSS feed is I went and read the RSS spec and found out what it needed to create it.[1] Read through that and it should get you started. If your competent with PHP then all you would need to do is loop through your result set to display the results. If you're not quite sure if you know how to do it though... I as well as many other people on the list I'm sure are available to hire to get it done :) [1] http://cyber.law.harvard.edu/rss/rss.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] displaying constants
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. -- Blessings, David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying constants
On Sat, Aug 28, 2010 at 10:58, David McGlone da...@dmcentral.net 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. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Questions about $_SERVER
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. As such, you can enter the IP of either into a browser and see that specific domain. 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? Thanks, Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about $_SERVER
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) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about $_SERVER
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about $_SERVER
On 28 August 2010 23:45, tedd tedd.sperl...@gmail.com 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about $_SERVER
At 12:15 AM +0200 8/29/10, Peter Lind wrote: On 28 August 2010 23:45, tedd tedd.sperl...@gmail.com 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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Re: Making multiple RSS feeds for the blog website
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 titlePHP Website/title linkhttp://www.php.net//link descriptionGreat programmers Website, where you an find nice peoples on the mailinglist, which explain how RSS is working./description guid isPermaLink=truehttp://blog.pnp.net/items/1258834764.html/guid pubDateSat, 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 titlePHP Superhere PHP RSS Feed/title linkhttp://www.php.net//link descriptionPHP RSS Feed Overview/description languageen/language copyrightCopyright 2010, Michelle Konzack/copyright lastBuildDateSun, 29 Aug 2010 04:13:17 +0200/lastBuildDate docshttp://www.php.net/michelles_php_rss_feed//docs managingEditorlinux4miche...@tamay-dogan.net/managingEditor webMasterwebmas...@php.net/webMaster ttl10/ttl image titlePHP Website/title urlhttp://www.php.net/logo.png/url linkwww.php.net/link width120/width height160/height descriptionPHP 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 KonzackOwner 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 linux4miche...@jabber.ccc.de ICQ#328449886 Linux-User #280138 with the Linux Counter, http://counter.li.org/ signature.pgp Description: Digital signature
Re: [PHP] displaying constants
On Sat, 2010-08-28 at 11:13 -0400, Daniel P. Brown wrote: On Sat, Aug 28, 2010 at 10:58, David McGlone da...@dmcentral.net 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_walk_recursive pass by reference
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions about $_SERVER
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Put all class in one file or different files
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
Re: [PHP] Put all class in one file or different files
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 | josh.k...@gmail.com 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php