Re: [PHP] URL Rewriting
Studying archaeology now, Tam? ;-P On Sat, Jun 1, 2013 at 8:22 PM, Tamara Temple tamouse.li...@gmail.com wrote: Silvio Siefke li...@silvio-siefke.de wrote: On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote: Has someone a Link with Tutorials or other Information? Not entirely sure what you're asking here, or how you (or the nginx folks) expect it to relate to PHP. Do you mean that you want to use PHP to have theme2.php act as if it was called as theme.php?id=2 ? I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2 through 16 at moment. And for google and other Search Engines not good the links, better where i can rewrite to a fix link, and when someone use the link, php write to correct url. Common SEO mythology is that you need pretty human-understandable links. (In point of fact, the search engines care not in the least.) However, human-understandable URLs are a benefit to users when they want to understand what they're linking to or clicking on. A human-understandable link is more like: http://www.example.com/blog/2013-05-a-day-in-the-life-of-my-dog not: http://www.example.com/blog/2 as that really does not provide any more information than: http://www.example.com/blog.php?id=2 Otherwise, Daniel's solution below should do the trick. Sorry my english not perfect on earth. If so, it's not redirect or rewrite, and it's extremely hacky, but this is the only real way PHP could achieve the desired result: ?php // dynamictheme.php if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) { $_GET['id'] = $match[1]; include dirname(__FILE__).'/theme.php'; } ? Then just symlink dynamictheme.php to your various themes like so: ln -s dynamictheme.php theme2.php ln -s dynamictheme.php theme301.php ln -s dynamictheme.php theme18447.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
Daniel Brown danbr...@php.net wrote: Studying archaeology now, Tam? ;-P Always been a huge fan. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
Silvio Siefke li...@silvio-siefke.de wrote: On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote: Has someone a Link with Tutorials or other Information? Not entirely sure what you're asking here, or how you (or the nginx folks) expect it to relate to PHP. Do you mean that you want to use PHP to have theme2.php act as if it was called as theme.php?id=2 ? I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2 through 16 at moment. And for google and other Search Engines not good the links, better where i can rewrite to a fix link, and when someone use the link, php write to correct url. Common SEO mythology is that you need pretty human-understandable links. (In point of fact, the search engines care not in the least.) However, human-understandable URLs are a benefit to users when they want to understand what they're linking to or clicking on. A human-understandable link is more like: http://www.example.com/blog/2013-05-a-day-in-the-life-of-my-dog not: http://www.example.com/blog/2 as that really does not provide any more information than: http://www.example.com/blog.php?id=2 Otherwise, Daniel's solution below should do the trick. Sorry my english not perfect on earth. If so, it's not redirect or rewrite, and it's extremely hacky, but this is the only real way PHP could achieve the desired result: ?php // dynamictheme.php if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) { $_GET['id'] = $match[1]; include dirname(__FILE__).'/theme.php'; } ? Then just symlink dynamictheme.php to your various themes like so: ln -s dynamictheme.php theme2.php ln -s dynamictheme.php theme301.php ln -s dynamictheme.php theme18447.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas stu...@3ft9.com wrote: On 26 Apr 2012, at 18:37, Jim Giner wrote: Im no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. A query string has nothing to do with databases. -Stuart I still haven't been able to find a solution. Is there anyone out there that knows how to keep the query string intact? Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On 04/27/2012 10:56 AM, Chris Stinemetz wrote: I still haven't been able to find a solution. Is there anyone out there that knows how to keep the query string intact? Thank you, Chris urlencode($storerow['store_subject']) -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On 27 Apr 2012 at 16:56, Chris Stinemetz chrisstinem...@gmail.com wrote: On Thu, Apr 26, 2012 at 12:58 PM, Stuart Dallas stu...@3ft9.com wrote: On 26 Apr 2012, at 18:37, Jim Giner wrote: Im no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. A query string has nothing to do with databases. I still haven't been able to find a solution. Is there anyone out there that knows how to keep the query string intact? As was posted previously, you need to encode the query string. If you have: http://westeng/forum/store.php?id=Wiser Communication, LLC - - Sprague Ave that is going to be split in two unless you encode the Wiser Communication, LLC - - Sprague Ave portion. I would do that with JavaScript on the html page. This is not a PHP question. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On Fri, Apr 27, 2012 at 11:09 AM, Shawn McKenzie nos...@mckenzies.net wrote: On 04/27/2012 10:56 AM, Chris Stinemetz wrote: I still haven't been able to find a solution. Is there anyone out there that knows how to keep the query string intact? Thank you, Chris urlencode($storerow['store_subject']) -- Thanks! -Shawn http://www.spidean.com Thank you. That is what I was looking for. -Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On 26 April 2012 22:27, Chris Stinemetz chrisstinem...@gmail.com wrote: Hello list, I'm trying to pass a query string through $_GET but for some reason the array is being split on ''. How may I avoid this so it stays intacted? user selection portion: while($storerow = mysql_fetch_assoc($storesresult)) echo 'h4a href=store.php?id=' . $storerow['store_subject'] . '' . $storerow['store_subject'] . '/a/h4 at ' . date('m-d-Y h:i:s A', strtotime($storerow['real_time_date'])); produces url string: http://westeng/forum/store.php?id=Wiser Communication, LLC - - Sprague Ave print(pre.print_r($_GET,true)./pre); ## results below Array ( [id] = Wiser Communication, LLC - [-_Sprague_Ave] = ) How do I make it so the string isn't split into two elements in the array? I want it to stay instact. You should urlencode the query parameter. Thank you, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
Im no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url string being split
On 26 Apr 2012, at 18:37, Jim Giner wrote: Im no expert, but why would you expose a query to the world thru the use of a GET? Why not just collect the params and build the string in your code? That is how people hack into your database - via a re-formed query. You're giving someone an open invitation. A query string has nothing to do with databases. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
Silvio Siefke li...@silvio-siefke.de wrote: On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote: Has someone a Link with Tutorials or other Information? Not entirely sure what you're asking here, or how you (or the nginx folks) expect it to relate to PHP. Do you mean that you want to use PHP to have theme2.php act as if it was called as theme.php?id=2 ? I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2 through 16 at moment. And for google and other Search Engines not good the links, better where i can rewrite to a fix link, and when someone use the link, php write to correct url. Sorry my english not perfect on earth. I've not yet seen any evidence yet that pretty URLs actually benefit SEO. I regularly search for answers to problems online, and mostly I get forums as the results, all of which have URLs like showthread.php?t=1234567 I see that url rewriting is always suggested on SEO checklists, but with no evidence. The best evidence I could find was out of date by about a decade, so not that useful here and today. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
try RewriteEngine on RewriteRule ^theme([0-9]+).php$ /index.php?theme=$1 [L] On Wed, Jun 22, 2011 at 11:22 PM, Silvio Siefke li...@silvio-siefke.dewrote: Hello, is there a chance with php to use rewriting? Like Example: mysite.com/theme.php?id=1 to theme.php theme2.php etc. I have ask on the nginx list, but there they say i should use the power language php. When i search in google for Examples or Tutorials i only found mod_rewriting. Has someone a Link with Tutorials or other Information? Thank you. Nice Day. Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
On Wed, Jun 22, 2011 at 17:32, Fatih P. fatihpirist...@gmail.com wrote: try RewriteEngine on RewriteRule ^theme([0-9]+).php$ /index.php?theme=$1 [L] That's neither nginx nor PHP, so it's not really relevant to the OP's questions. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
On Wed, Jun 22, 2011 at 17:22, Silvio Siefke li...@silvio-siefke.de wrote: Hello, is there a chance with php to use rewriting? Like Example: mysite.com/theme.php?id=1 to theme.php theme2.php etc. I have ask on the nginx list, but there they say i should use the power language php. When i search in google for Examples or Tutorials i only found mod_rewriting. Has someone a Link with Tutorials or other Information? Not entirely sure what you're asking here, or how you (or the nginx folks) expect it to relate to PHP. Do you mean that you want to use PHP to have theme2.php act as if it was called as theme.php?id=2 ? If so, it's not redirect or rewrite, and it's extremely hacky, but this is the only real way PHP could achieve the desired result: ?php // dynamictheme.php if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) { $_GET['id'] = $match[1]; include dirname(__FILE__).'/theme.php'; } ? Then just symlink dynamictheme.php to your various themes like so: ln -s dynamictheme.php theme2.php ln -s dynamictheme.php theme301.php ln -s dynamictheme.php theme18447.php -- /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
Re: [PHP] URL Rewriting
On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote: Has someone a Link with Tutorials or other Information? Not entirely sure what you're asking here, or how you (or the nginx folks) expect it to relate to PHP. Do you mean that you want to use PHP to have theme2.php act as if it was called as theme.php?id=2 ? I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2 through 16 at moment. And for google and other Search Engines not good the links, better where i can rewrite to a fix link, and when someone use the link, php write to correct url. Sorry my english not perfect on earth. If so, it's not redirect or rewrite, and it's extremely hacky, but this is the only real way PHP could achieve the desired result: ?php // dynamictheme.php if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) { $_GET['id'] = $match[1]; include dirname(__FILE__).'/theme.php'; } ? Then just symlink dynamictheme.php to your various themes like so: ln -s dynamictheme.php theme2.php ln -s dynamictheme.php theme301.php ln -s dynamictheme.php theme18447.php Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewriting
On Wed, 22 Jun 2011 23:32:10 +0200 Fatih P. wrote: try RewriteEngine on RewriteRule ^theme([0-9]+).php$ /index.php?theme=$1 [L] That is rule for Apache i think. I have nginx, and there i have try much rules but nothing want work. And on the list from nginx the maintainer write, i should use the power language php. Regards Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL injection
https://www.xxx.co.uk/register.php;| grep 123 I wonder what kind of browser could make this, probably a hacker-made one! This URL will have to be translated into its equivalent URI, if using GET the HTTP message's start line would look like: GET /register.php| grep 123 HTTP/1.1 First of all, the HTTP protocol states that the start line should contain: METHOD one or more spaces URI one or more spaces HTTP/1.1 So, this is clearly violated as there are two spaces surrounding grep, i believe if the server has trouble with this request, it's not yet at the PHP level... it's an HTTP issue, clearly server related. You wont detect this with PHP, and if you do detect anything, it means your server has modified it so you could... for example, in this case it might convert the whole | grep 123 into a single get argument's name, it could be simply removed/ignored, the server could try to see if there is a file named `/register.php| grep 123` and returns a 404... but the only acceptable behavior in this case is for the server to return 400 (read http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1). Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL injection
2009/6/4 Morris morris...@gmail.com: Hi Can anyone help me handel this URL injection ? https://www.xxx.co.uk/register.php;| grep 123 I want to detect it and header back to my index page. It's quite urgent What the smeg is register.php doing that makes it execute that?? Show us the code. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL injection
Hi The register.php has only a form ?php form name=registerUser action=register.php method=post input type=text name=username size=10 / input type=submit value=send / /form ? Does this help ? Thanks for reply 2009/6/4 Stuart stut...@gmail.com 2009/6/4 Morris morris...@gmail.com: Hi Can anyone help me handel this URL injection ? https://www.xxx.co.uk/register.php;| grep 123 I want to detect it and header back to my index page. It's quite urgent What the smeg is register.php doing that makes it execute that?? Show us the code. -Stuart -- http://stut.net/
Re: [PHP] URL injection
2009/6/4 Morris morris...@gmail.com: Hi The register.php has only a form ?php form name=registerUser action=register.php method=post input type=text name=username size=10 / input type=submit value=send / /form ? Does this help ? 1) That is not valid PHP code. 2) Even if it were there's nothing in there that would be exploitable through the URL you sent in your first email. -Stuart -- http://stut.net/ 2009/6/4 Stuart stut...@gmail.com 2009/6/4 Morris morris...@gmail.com: Hi Can anyone help me handel this URL injection ? https://www.xxx.co.uk/register.php;| grep 123 I want to detect it and header back to my index page. It's quite urgent What the smeg is register.php doing that makes it execute that?? Show us the code. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL injection
Is there more to the register.php file that we're not seeing? It has to have some sort of action... On Thu, Jun 4, 2009 at 3:28 PM, Stuart stut...@gmail.com wrote: 2009/6/4 Morris morris...@gmail.com: Hi The register.php has only a form ?php form name=registerUser action=register.php method=post input type=text name=username size=10 / input type=submit value=send / /form ? Does this help ? 1) That is not valid PHP code. 2) Even if it were there's nothing in there that would be exploitable through the URL you sent in your first email. -Stuart -- http://stut.net/ 2009/6/4 Stuart stut...@gmail.com 2009/6/4 Morris morris...@gmail.com: Hi Can anyone help me handel this URL injection ? https://www.xxx.co.uk/register.php;| grep 123 I want to detect it and header back to my index page. It's quite urgent What the smeg is register.php doing that makes it execute that?? Show us the code. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL data decoding problem
On Tue, 2009-04-21 at 08:39 +0200, Anders Norrbring wrote: I'm working on a PayPal IPN module, and PayPal returns a lot of data in a GET call. The problem is that international characters entered by a user on the PayPal site gets encoded really weird, and I don't see an obvious way to decode them, can someone please assist? My website is running utf-8 all over. The URL contains this variable: memo=Pr%EF%BF%BDvar It should translate into memo=Prövar I've run out of ideas on this really.. PayPal say the reply is encoded in windows-1252. Thanks, Anders. You can use urldecode() to decode the %xx characters to their actual character. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
Don Don wrote: Hi all, I've set up a url rewrite code below. Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 It only works when I type in this url http://www.example.com/profiles/profile/username/baller/ If i do not then the normal url http://www.example.com/profiles/profile.php?username=baller is displayed. I just want the new url to show when ever I trype in the old url. Ah, you want an external redirect then. It's really a case of RTFM, but just add '[r]' to the end of your RewriteRule. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
Hi Per, changed the rewrite to this Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 [r] but sill does not work the way i want. Entering this url http://example.com/profiles/profile.php?username=baller does not cnage to http://localhost/profiles/profile/username/baller --- On Fri, 7/25/08, Per Jessen [EMAIL PROTECTED] wrote: From: Per Jessen [EMAIL PROTECTED] Subject: Re: [PHP] URL Rewrite not working for me To: php-general@lists.php.net Date: Friday, July 25, 2008, 3:15 AM Don Don wrote: Hi all, I've set up a url rewrite code below. Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 It only works when I type in this url http://www.example.com/profiles/profile/username/baller/ If i do not then the normal url http://www.example.com/profiles/profile.php?username=baller is displayed. I just want the new url to show when ever I trype in the old url. Ah, you want an external redirect then. It's really a case of RTFM, but just add '[r]' to the end of your RewriteRule. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
Hi!! For Internal redirection: RewriteRule profile/username/([^/]+) profile.php?username=$1 [PT] On Fri, Jul 25, 2008 at 3:00 AM, Don Don [EMAIL PROTECTED] wrote: Hi all, I've set up a url rewrite code below. Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 It only works when I type in this url http://www.example.com/profiles/profile/username/baller/ If i do not then the normal url http://www.example.com/profiles/profile.php?username=baller is displayed. I just want the new url to show when ever I trype in the old url. Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.kingzones.org/
Re: [PHP] URL Rewrite not working for me
Don Don wrote: Hi Per, changed the rewrite to this Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 [r] but sill does not work the way i want. Entering this url http://example.com/profiles/profile.php?username=baller does not cnage to http://localhost/profiles/profile/username/baller Ah, you want it the other way round then. The rewriterule is: rewriterule frompattern to /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
On Fri, Jul 25, 2008 at 6:00 AM, Don Don [EMAIL PROTECTED] wrote: Hi all, I've set up a url rewrite code below. Options +FollowSymLinks RewriteEngine on RewriteRule profile/username/(.*) profile.php?username=$1 It only works when I type in this url http://www.example.com/profiles/profile/username/baller/ If i do not then the normal url http://www.example.com/profiles/profile.php?username=baller is displayed. Per's answer is probably exactly what you're looking for, Don. Keep in mind, though, that this isn't a PHP question. Future questions of this nature would be better suited for the Apache list. You may find sometimes that asking a question on the wrong list will be ignored. Not because people don't want to help, just because they may read it and skip over it. -- /Daniel P. Brown Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
Daniel Brown wrote: Per's answer is probably exactly what you're looking for, Don. Keep in mind, though, that this isn't a PHP question. Future questions of this nature would be better suited for the Apache list. Couldn't agree more. You may find sometimes that asking a question on the wrong list will be ignored. Not because people don't want to help, just because they may read it and skip over it. Couldn't agree more. However, Don's question was of the kind that is easily overlooked on the apache list, where topics tend to be a little less basic. I tend to think that basic apache/php questions are sometimes better asked here, even if they are really off-topic. It doesn't hurt anyone, and the poster is actually likely to get a decent/useful answer fairly quickly - due to the amount of plain user/developer experience that is available here. I could easily have waved Don away with a plain RTFM, but I saw no real reason. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite not working for me
On Fri, Jul 25, 2008 at 3:59 PM, Per Jessen [EMAIL PROTECTED] wrote: However, Don's question was of the kind that is easily overlooked on the apache list, where topics tend to be a little less basic. I tend to think that basic apache/php questions are sometimes better asked here, even if they are really off-topic. It doesn't hurt anyone, and the poster is actually likely to get a decent/useful answer fairly quickly - due to the amount of plain user/developer experience that is available here. And I agree with you on these points, but at the same time, by not recommending that the question be asked on the appropriate list first, we're not only encouraging misplaced posts, but also cheating the poster themselves. They may not even be aware that there are separate lists; a couple of times from the top of my head, responses have been, I wasn't aware there was a list for [insert project name here]. I could easily have waved Don away with a plain RTFM, but I saw no real reason. Yes, but that's you it's because you're a nice guy. And what do you expect from someone who lives in a city frequently rated as best quality of life in the world? -- /Daniel P. Brown Better prices on dedicated servers: Intel 2.4GHz/60GB/512MB/2TB $49.99/mo. Intel 3.06GHz/80GB/1GB/2TB $59.99/mo. Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite
Look at http://framework.zend.com/manual/en/zend.controller.router.html Apache configuration et framework methods to rout your files are there. Subhranil [EMAIL PROTECTED] a écrit dans le message de news:[EMAIL PROTECTED] Hi All, I want to show one URL at browser and content of different URL. Like user can see the URL at address bar like http://localhost/test/home/ or http://localhost/test/tech/php/but content of page will be http://localhost/test/index.php The URL of the address bar will never change to http://localhost/test/index.php Still a newbie! Thanks, Subhranild. -- View this message in context: http://www.nabble.com/URL-Rewrite-tp18233803p18233803.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite
Subhranil wrote: Hi All, I want to show one URL at browser and content of different URL. Take a look at apache url rewriting. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Rewrite
On Wed, Jul 2, 2008 at 6:33 AM, Per Jessen [EMAIL PROTECTED] wrote: Subhranil wrote: Hi All, I want to show one URL at browser and content of different URL. Take a look at apache url rewriting. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could look at using an iframe or frames in general, or ajax call into a div -- Bastien Cat, the other other white meat
Re: [PHP] URL Rewrite
On Wednesday 02 July 2008 13:34:32 Bastien Koert wrote: On Wed, Jul 2, 2008 at 6:33 AM, Per Jessen [EMAIL PROTECTED] wrote: Subhranil wrote: Hi All, I want to show one URL at browser and content of different URL. Take a look at apache url rewriting. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You could look at using an iframe or frames in general, or ajax call into a div that suggestion is wrong on so many levels. using a hack to manage something ment to be handled before page is sent. I lean toward the apache rewritemod -- --- Børge Holen http://www.arivene.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
At 4:46 PM + 2/25/08, Nathan Rixham wrote: It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be found and thus the rules won't apply: follow? No, I don't. Please explain. Sounds cool. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
tedd wrote: At 4:46 PM + 2/25/08, Nathan Rixham wrote: It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be found and thus the rules won't apply: follow? No, I don't. Please explain. Sounds cool. Hi, As far as I can follow, this looks much like a 404 redirect trick which captures all not found files/paths. Based on the extension, you can still do fun or cool stuff and get more control about virtual paths etc. As always: TIMTOWTDI, so I'm gonna play with this .htaccess rule and see if this is better than a 404 handler. Aschwin Wesselius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes [EMAIL PROTECTED] wrote: You could also forego the Files bit if you're willing to accept URLs like this: /rental.php/property/23425 I was waiting to see if anyone made mention of that while reading through the thread. I think this is a highly underused built-in feature. PHP is already, out-of-the-box, ready for search-engine-friendly URLs. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Daniel Brown wrote: On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes [EMAIL PROTECTED] wrote: You could also forego the Files bit if you're willing to accept URLs like this: /rental.php/property/23425 I was waiting to see if anyone made mention of that while reading through the thread. I think this is a highly underused built-in feature. PHP is already, out-of-the-box, ready for search-engine-friendly URLs. It may be a good time to throw in this .htaccess which just palms eveything [not found] off to php [.htaccess] RewriteEngine On RewriteBase / DirectoryIndex handle.urls.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /handle.urls.php [L] [/.htaccess] I use this for everything nowadays, in terms of security it also allows me to keep every script out of the web root; and joy of joys don't need to change any rules for static files, as they will always be found and thus the rules won't apply: follow? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
-Original Message- From: Daniel Brown [mailto:[EMAIL PROTECTED] Sent: Monday, February 25, 2008 11:37 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; php-general@lists.php.net Subject: Re: [PHP] URL modification On Sat, Feb 23, 2008 at 6:27 AM, Richard Heyes [EMAIL PROTECTED] wrote: You could also forego the Files bit if you're willing to accept URLs like this: /rental.php/property/23425 I was waiting to see if anyone made mention of that while reading through the thread. I think this is a highly underused built-in feature. PHP is already, out-of-the-box, ready for search-engine-friendly URLs. -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? Yeap, PHP rocks! I mentioned it in the first reply, only that it was not rental.php, but index.php. Many if not all MVC frameworks support this kind of routing which doesn't require mod_rewrite. However, I prefer mod_rewrite if it's available, for crawlers it is not the same /index.php/my-keywrod than /my-keyword alone. But I must admit that there are a hundred other factors that can have much more weight for generating SEO problems than having index.php everywhere. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
I think this is a highly underused built-in feature. Agreed. I started to use it on my blog instead of a query string and pages reported by Google went up. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
thnks Xavier Please consider the environment before printing this mail note. -Original Message- From: Nathan Rixham [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 18:58 To: php-general@lists.php.net Subject: Re: [PHP] URL modification Richard Heyes wrote: H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? On IIS I belive the default document is default.htm Though you should be able to modify this to whatever you please. On Apache it is index.html or index.php (for example). Regardless you want this to be parsed by PHP, and then you can stick the following in it: ?php header('http://www.example.com/login.php'); ? Place this file in your login directory and then you'll be able to publish URLs such as http://www.example.com/login The trailing slash is not necessary if login is a directory. For example: http://www.websupportsolutions.co.uk/demo To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. The first and simplest is to simply save your login.php as /login/index.php to use this approach you need to ensure that index.php is listed as a default page. In IIS you can set the default page(s) to be whatever you like: - Open IIS Manager - Server - Websites - Right Click [properties] - select Documents tab - ensure Enable default content page is ticked - ensure index.php is listed - if not then click [add] and enter index.php - continue to add any other default pages [index.html, index.shtml etc] The second common solution [and I'd advise to get used to it asap] is to use URL rewriting. In short url rewriting involves defining rules which the web server uses to direct http requests to resources on the server. eg: direct domain.com/all_our_news to /index.php?newsitem=all a quick intro guide can be found here: http://www.sitepoint.com/article/guide-url-rewriting For URL rewriting in IIS use ISAPI Rewrite - http://www.isapirewrite.com/ in apache use mod_rewrite [apache1.3] httpd.apache.org/docs/1.3/mod/mod_rewrite.html [apache2.0] httpd.apache.org/docs/2.0/mod/mod_rewrite.html Both are pretty much identical when it comes to the end rewrite rules. Hope that helps a little Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Let's say we've got 2.5 million users :: weight up 2.5 million files vs 1 rewrite rule map: /rental/property/23425 to: /index.php?mod=propertysection=rentalspropertyid=23425 You never mentioned this many users. Hence you're moving the boundaries somewhat. finally, do you honestly not use mod_rewrite in anything you've made? No. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
/rental/property/23425 to: /index.php?mod=propertysection=rentalspropertyid=23425 Thinking about this a little, you still don't need mod_rewrite. rental could be a PHP script, forced through PHP with: Files rental ForceType application/x-httpd-php /Files In either a .htaccess file or, if performance is an absolute necessity, your httpd.conf file (ie .htaccess files are turned off). In your rental PHP script you simply look at the REQUEST_URI $_SERVER variable to determine the correct data to show. You could also forego the Files bit if you're willing to accept URLs like this: /rental.php/property/23425 -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
Thnks, H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? Regards, Xavier de Lapeyre Web Developer Enterprise Data Services 24, Dr Roux Street, Rose Hill Office: (230) 465 17 00 Fax: (230) 465 29 00 Site: www.eds.mu Email: [EMAIL PROTECTED] Please consider the environment before printing this mail note. -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 11:48 To: php-general@lists.php.net Subject: RE: [PHP] URL modification -Original Message- From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:09 AM To: php-general@lists.php.net Subject: [PHP] URL modification Importance: High Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre That's called URI/URL Routing and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
Quoting Xavier de Lapeyre [EMAIL PROTECTED]: Thnks, H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? Regards, Xavier de Lapeyre Web Developer Enterprise Data Services 24, Dr Roux Street, Rose Hill Office: (230) 465 17 00 Fax: (230) 465 29 00 Site: www.eds.mu Email: [EMAIL PROTECTED] Please consider the environment before printing this mail note. -Original Message- From: Andrés Robinet [mailto:[EMAIL PROTECTED] Sent: vendredi 22 février 2008 11:48 To: php-general@lists.php.net Subject: RE: [PHP] URL modification -Original Message- From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:09 AM To: php-general@lists.php.net Subject: [PHP] URL modification Importance: High Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre That's called URI/URL Routing and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com There are rewrite modules for IIS also. Just google for IIS rewrite. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? On IIS I belive the default document is default.htm Though you should be able to modify this to whatever you please. On Apache it is index.html or index.php (for example). Regardless you want this to be parsed by PHP, and then you can stick the following in it: ?php header('http://www.example.com/login.php'); ? Place this file in your login directory and then you'll be able to publish URLs such as http://www.example.com/login The trailing slash is not necessary if login is a directory. For example: http://www.websupportsolutions.co.uk/demo -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Xavier de Lapeyre wrote: Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? It could be apache content negotiation that does it. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Feb 22, 2008, at 2:09 AM, Xavier de Lapeyre wrote: Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? I do a version of this simply by creating a directory and then put a default file in... I have Apache set to recognize index.php, index.shtml, index.html etc. etc. etc. as default files, so when someone goes to www.raoset.com/contact/ the page that loads is: www.raoset.com/contact/index.shtml For my purposes it works great :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Richard Heyes wrote: H... made a quick look into it. Seems to be apache compatible. I'm designing a site to be hosted on an IIS Server. Does it still works there? On IIS I belive the default document is default.htm Though you should be able to modify this to whatever you please. On Apache it is index.html or index.php (for example). Regardless you want this to be parsed by PHP, and then you can stick the following in it: ?php header('http://www.example.com/login.php'); ? Place this file in your login directory and then you'll be able to publish URLs such as http://www.example.com/login The trailing slash is not necessary if login is a directory. For example: http://www.websupportsolutions.co.uk/demo To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. The first and simplest is to simply save your login.php as /login/index.php to use this approach you need to ensure that index.php is listed as a default page. In IIS you can set the default page(s) to be whatever you like: - Open IIS Manager - Server - Websites - Right Click [properties] - select Documents tab - ensure Enable default content page is ticked - ensure index.php is listed - if not then click [add] and enter index.php - continue to add any other default pages [index.html, index.shtml etc] The second common solution [and I'd advise to get used to it asap] is to use URL rewriting. In short url rewriting involves defining rules which the web server uses to direct http requests to resources on the server. eg: direct domain.com/all_our_news to /index.php?newsitem=all a quick intro guide can be found here: http://www.sitepoint.com/article/guide-url-rewriting For URL rewriting in IIS use ISAPI Rewrite - http://www.isapirewrite.com/ in apache use mod_rewrite [apache1.3] httpd.apache.org/docs/1.3/mod/mod_rewrite.html [apache2.0] httpd.apache.org/docs/2.0/mod/mod_rewrite.html Both are pretty much identical when it comes to the end rewrite rules. Hope that helps a little Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Nathan Rixham wrote: To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. [big snip] Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen [EMAIL PROTECTED] wrote: Nathan Rixham wrote: To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. [big snip] Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. Yes it does but the OP is using IIS. ;-P -- /Dan Daniel P. Brown Senior Unix Geek ? while(1) { $me = $mind--; sleep(86400); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Daniel Brown wrote: On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen [EMAIL PROTECTED] wrote: Nathan Rixham wrote: To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. [big snip] Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. Yes it does but the OP is using IIS. ;-P Oops, I missed that completely. Sorry. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Per Jessen wrote: Daniel Brown wrote: On Fri, Feb 22, 2008 at 10:53 AM, Per Jessen [EMAIL PROTECTED] wrote: Nathan Rixham wrote: To use url's like http://domain.com/login/ as opposed to http://domain.com/login.php you can take multiple approaches. [big snip] Seriously, this is all overkill. Apache content negotiation does it all automagically and with minimal effort. Yes it does but the OP is using IIS. ;-P Oops, I missed that completely. Sorry. /Per Jessen, Zürich + rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: how can i make /profile/adam instead of profile.php?user=adam :) happy friday all -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
+ rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: how can i make /profile/adam instead of profile.php?user=adam Have a directory in your htdocs called /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite. Unless of course you want the url to remain in the addressbar, but personally I don't think that is as important as what the user has to type in initially. -- Richard Heyes http://www.phpguru.org Free PHP and Javascript code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Richard Heyes wrote: + rewrite is overkill for this, but long term it's worth implementing and getting used to - think of the post as a pre-emptive strike on the inevitable question in a couple of weeks: how can i make /profile/adam instead of profile.php?user=adam Have a directory in your htdocs called /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite. Unless of course you want the url to remain in the addressbar, but personally I don't think that is as important as what the user has to type in initially. Never thought I'd have to find a way to explain the benefits of url re-writing. [snip] /profile/adam and in that place a default document redirecting. Still no need for mod_rewrite [/snip] Let's say we've got 2.5 million users :: weight up 2.5 million files vs 1 rewrite rule map: /rental/property/23425 to: /index.php?mod=propertysection=rentalspropertyid=23425 SEO :: not even going in to this one finally, do you honestly not use mod_rewrite in anything you've made? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL modification
Nathan Rixham wrote: + rewrite is overkill for this, but long term it's worth implementing and getting used to Completely agree. You've got to get to know url rewriting. I don't know how you can manage without it, even if it's far from always the right answer. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL modification
-Original Message- From: Xavier de Lapeyre [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:09 AM To: php-general@lists.php.net Subject: [PHP] URL modification Importance: High Hi all, I saw on some websites that modifies the links to access the webpages. Something like: http://www.example.com/login/ instead of http://www.example.com/login.php Does anyone knows how this works or how its call / which PHP library performs this action? Xavier de Lapeyre That's called URI/URL Routing and it's usually performed as part of every MVC Framework I know of (CodeIgniter, CakePHP, Symfony, Zend Framework... just to name a few). It's usually implemented through Apache's mod_rewrite module, but you can get close without that module, if you allow for something like: http://www.example.com/index.php/myaccount/profile (that is, you don't need mod_rewrite unless you want to remove the index.php part of the URI path) However, if you have an existing website, migrating it to use one of the MVC frameworks (or just using a stand-alone URI Routing class) may not be the path you want to follow. Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Chris wrote: Richard Heyes wrote: well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? How does this: /\.cfm$/ take into account that? $ in regex's means 'end of string' - so it will only match .cfm at the very end of the string. Indeed, so how does the regex take into account .cfm.php? It doesn't. If it doesn't have a .cfm extension, it won't match. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Richard Heyes wrote: Chris wrote: Richard Heyes wrote: well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? How does this: /\.cfm$/ take into account that? $ in regex's means 'end of string' - so it will only match .cfm at the very end of the string. Indeed, so how does the regex take into account .cfm.php? It doesn't. If it doesn't have a .cfm extension, it won't match. because the question was I want to replace the extension '.cfm' with '-meta.cfm', which I assumed meant the OP didn't want 'my.cfm.php' to become 'my-meta.cfm.php' and a str_replace('.cfm', '-meta.cfm', $foo) would not be correct in that situation. hopefully now the use of preg_replace() in my example makes sense. oh and I forget to add delimeters to the regexps in my examples, which was a stupid oversight. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
one of these should give you something to go on: echo preg_replace('\.cfm$', '-meta.cfm', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']), \n; Anything would be helpful. :) You don't need the overhead of PCRE, though it is the fastest to write, since it's already above for you... Or parse_url(). basename(__FILE__) will get you the filename. -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Richard Heyes wrote: one of these should give you something to go on: echo preg_replace('\.cfm$', '-meta.cfm', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']), \n; Anything would be helpful. :) You don't need the overhead of PCRE, though it is the fastest to write, since it's already above for you... well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? Or parse_url(). basename(__FILE__) will get you the filename. ah yes basename() - I forgot to put use that in the examples, good catch. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? How does this: /\.cfm$/ take into account that? -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Richard Heyes wrote: well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? How does this: /\.cfm$/ take into account that? WTF -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Richard Heyes wrote: well if you take a string (filename) and wish to change the end of it somone then I don't think str_replace() is the correct function. what's to say a script doesn't exist called 'my.cfm.php'? How does this: /\.cfm$/ take into account that? $ in regex's means 'end of string' - so it will only match .cfm at the very end of the string. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
At 12:18 PM -0600 11/24/07, Amanda Loucks wrote: Hi, I'm working on redesigning the backend of the website for work. It was originally done in ColdFusion, but I'm switching it over to PHP - probably going to transfer the website from where it's currently hosted to something a lot cheaper, too, hence the switching to PHP. Anyway. Because we are a manufacturing company, we have a few different lines of products. Currently, each different product line has it's own page (and own meta tags). The current set up has ColdFusion grabbing the current page from the URL stripping off the '.cfm' extension and adding '-meta.cfm' before including it in the header. I'm sure there is a way to do this in PHP, but I'm out of shape enough with using PHP that I can't remember, and I can't seem to find anything that will work for me. I just want to be able to pull whatever address is in the URL, get the file name, and go from there. Any ideas? Anything would be helpful. :) Thanks, Amanda From what I've read recently about meta tags, why? Most SE's have dropped their dependance on meta tags because of their abuse. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Parsing...
Amanda Loucks wrote: Hi, I'm working on redesigning the backend of the website for work. It was originally done in ColdFusion, but I'm switching it over to PHP - probably going to transfer the website from where it's currently hosted to something a lot cheaper, too, hence the switching to PHP. Anyway. Because we are a manufacturing company, we have a few different lines of products. Currently, each different product line has it's own page (and own meta tags). The current set up has ColdFusion grabbing the current page from the URL stripping off the '.cfm' extension and adding '-meta.cfm' before including it in the header. I'm sure there is a way to do this in PHP, but I'm out of shape enough with using PHP that I can't remember, and I can't seem to find anything that will work for me. I just want to be able to pull whatever address is in the URL, get the file name, and go from there. Any ideas? one of these should give you something to go on: echo preg_replace('\.cfm$', '-meta.cfm', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['PATH_TRANSLATED']), \n; echo preg_replace('\.cfm$', '-meta.cfm', $_SERVER['SCRIPT_FILENAME']), \n; Anything would be helpful. :) Thanks, Amanda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [URL file-access is disabled]
On 6/9/07, Dave Howard Schiff [EMAIL PROTECTED] wrote: Hello everyone, I have a problem, that I hope you can help me to solve: I'm writing a very simple PHP script to list a directory contents based on a 'user' variable given by a login/password script. The problem is, the webhosting i'm using don't allow the so called URL file-access ( i'm using PANDELA.COM ). It's a great hosting but this feature is breaking my legs: When the user put his name/passwrod, the script will check of course his information and then will allow the user to access his directory information, and then the url variable will look like this. $username= $_GET['logininfo']; include /bd/userdirs/$username/listdir.php; Ok, I know that the hosting don't allow that kind of include. But, is there a workaround for that? I mean, every user has their own folder, and every folder has a default script called listdir.php - all that this script does is to list all files avaiable to him. But then, I get this error message below. Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/users/b9/myhost/www/myhost.pandela.org/bd/loginuser.php on line 41 Any help would be very appreciated. Best Regards, Dave Howard Schiff. URL include is when you include files from http://www.domain.com/file.php, that shouldn't be this... But keep in mind that the directory you log into with FTP isn't / Try this include: What if you do this: include /home/users/b9/myhost/www/myhost.pandela.org/bd/userdirs/$username/listdir.php; Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [URL file-access is disabled]
On Sat, June 9, 2007 12:14 pm, Dave Howard Schiff wrote: I have a problem, that I hope you can help me to solve: I'm writing a very simple PHP script to list a directory contents based on a 'user' variable given by a login/password script. The problem is, the webhosting i'm using don't allow the so called URL file-access ( i'm using PANDELA.COM ). It's a great hosting but this feature is breaking my legs: When the user put his name/passwrod, the script will check of course his information and then will allow the user to access his directory information, and then the url variable will look like this. $username= $_GET['logininfo']; include /bd/userdirs/$username/listdir.php; This is not a URL file access. If it's not working, you may be falling under an open_basedir restricition, but not allow_url_fopen as you seem to think. Have you tried it yet? Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/users/b9/myhost/www/myhost.pandela.org/bd/loginuser.php on line 41 Ah. The problem is that you are confusing DocumentRoot with Server root. You will need to add all the /home/users/b9/myhost/www/myhost.pandela.org/ in front of your current /bd to work. As it stands now, you are trying to include something from a directory that is parallel to (a sibling of) /home: In other words, what you typed would work if you had this: / . .. /home/users/b9/myhost/www/myhost.pandela.org/ /bd/userdirs/whatever/listdir.php But you don't have that. You have this: / . .. /home/users/b9/myhost/www/myhost.pandela.org/bd/userdirs/whatever/listdir.php [that last one is supposed to be all one line...] I dunno why it's complaining about URL-file-access though... Seems pretty weird to me... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url fopen() failed to open stream
On 3/9/07, Michael Clayfield [EMAIL PROTECTED] wrote: when i open up a url with fopen(), i get this error message:* Warning*: fopen(http://sumurlhere.whatever/index.html) [function.fopen http://127.0.0.1/bots2/function.fopen]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in *C:\xampp\htdocs\bots2\main.php* on line *4 * i believe this could because i am behind a proxy server, would someone be able to confirm this? also if this is the problem, where would i set the proxy server to be used?* * Maybe you could post your code, let's say line 1-5 I don't know a lot about proxy, but you might want to take a look at the curl documentation, I don't know what your exactly gonna retrieve from the server, but i think curl could do it. curl documentation: www.php.net/curl Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url obfuscation
On Fri, July 7, 2006 10:56 pm, Anas Mughal wrote: My URLs are constant. They are not changing. All my dynamic pages are indexed nicely on Google. I agree that a computerized screen scrapper could still screen scrap most of my site. However, a simple script that attempts to bump up the identifier of a resource in a URL, would not work. Here is example: http://mydomain.com/view_resource.php?id=1 http://mydomain.com/view_resource.php?id=2 http://mydomain.com/view_resource.php?id=3 http://mydomain.com/view_resource.php?id=4 That would not work because my IDs are not sequential. Any thoughts... Do your other pages link to the pages? Because I don't need to PREDICT the URLs, just follow them from page to page. That's pretty much how a search engine works. If you really want to stop a web-scraper, you pretty much have to accept that you'll not be listed in Google (et al) as well. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url obfuscation
For me it doesnt matter I dont want Google in the section that I'm obfuscation. On 7/13/06, Richard Lynch [EMAIL PROTECTED] wrote: On Fri, July 7, 2006 10:56 pm, Anas Mughal wrote: My URLs are constant. They are not changing. All my dynamic pages are indexed nicely on Google. I agree that a computerized screen scrapper could still screen scrap most of my site. However, a simple script that attempts to bump up the identifier of a resource in a URL, would not work. Here is example: http://mydomain.com/view_resource.php?id=1 http://mydomain.com/view_resource.php?id=2 http://mydomain.com/view_resource.php?id=3 http://mydomain.com/view_resource.php?id=4 That would not work because my IDs are not sequential. Any thoughts... Do your other pages link to the pages? Because I don't need to PREDICT the URLs, just follow them from page to page. That's pretty much how a search engine works. If you really want to stop a web-scraper, you pretty much have to accept that you'll not be listed in Google (et al) as well. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url obfuscation
On Thu, July 6, 2006 11:49 am, Dan McCullough wrote: Looking for a good way to obfuscation the name value pairs in a URL, so it might be something like http://www.domain.com/page=fjdsaflkjdsafkfjdsakfjdsalkfjsda983dsf or something like that, I was looking at base64_encode, but was wondering what others might do or use. It doesnt have to be super secure, but I would still like the information to not be really visable. Bad Idea. Your URLs will get much too long, and GET data can be limited, and you'll hit that limit if you keep this up... If the data shouldn't be visible, put it in $_SESSION -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url obfuscation
On Thu, July 6, 2006 12:00 pm, Anas Mughal wrote: I have encrypted the values -- not the keys. With this approach, I presume I have made it harder for anyone trying to screen scrap my data. (It is not possible to write a script that would loop over my pages.) Unless you are using an always-changing value for the value, then the screen-scraper doesn't really give a damn whether the value is: 2 avpu8e9hgre98gh9erhb549hgt2395tybnsdibnusreiobnwre9pg8h25490t8 It's all the same to a computer. If you ARE using always-changing URLs, then the search engines are never gonna find your pages, which seems like an odd goal to me. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url obfuscation
My URLs are constant. They are not changing. All my dynamic pages are indexed nicely on Google. I agree that a computerized screen scrapper could still screen scrap most of my site. However, a simple script that attempts to bump up the identifier of a resource in a URL, would not work. Here is example: http://mydomain.com/view_resource.php?id=1 http://mydomain.com/view_resource.php?id=2 http://mydomain.com/view_resource.php?id=3 http://mydomain.com/view_resource.php?id=4 That would not work because my IDs are not sequential. Any thoughts... On 7/7/06, Richard Lynch [EMAIL PROTECTED] wrote: On Thu, July 6, 2006 12:00 pm, Anas Mughal wrote: I have encrypted the values -- not the keys. With this approach, I presume I have made it harder for anyone trying to screen scrap my data. (It is not possible to write a script that would loop over my pages.) Unless you are using an always-changing value for the value, then the screen-scraper doesn't really give a damn whether the value is: 2 avpu8e9hgre98gh9erhb549hgt2395tybnsdibnusreiobnwre9pg8h25490t8 It's all the same to a computer. If you ARE using always-changing URLs, then the search engines are never gonna find your pages, which seems like an odd goal to me. -- Like Music? http://l-i-e.com/artists.htm -- Anas Mughal
Re: [PHP] url obfuscation
I have encrypted the values -- not the keys. With this approach, I presume I have made it harder for anyone trying to screen scrap my data. (It is not possible to write a script that would loop over my pages.) Why do you need to encrypt the keys? -- Anas Mughal On 7/6/06, Dan McCullough [EMAIL PROTECTED] wrote: Looking for a good way to obfuscation the name value pairs in a URL, so it might be something like http://www.domain.com/page=fjdsaflkjdsafkfjdsakfjdsalkfjsda983dsf or something like that, I was looking at base64_encode, but was wondering what others might do or use. It doesnt have to be super secure, but I would still like the information to not be really visable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anas Mughal
Re: [PHP] URL Rewrite???
Keith wrote: Hi all Not really a php issue per se - sorry. But I'm sure someone here is bound to know the answer. :-) I have a main site that is accessible at say http://www.somedomain.com/somedir/; but I want visitors to be able to access the site using simply http://www.somedomain.com; AND for the resulting URL displayed to STILL say http://www.somedomain.com; and not http://www.somedomain.com/somedir/;. Should this be possible using the .htaccess file and some mod_rewrite rule? Toyed around with that but couldn't get it to work. when you finished toying did you take time to read the Apache docs on mod_rewrite? you need *something like*: RewriteRule ^/(.*)$ /somedir/$1 [L] ANY help would be greatly appreciated, thanks P.S. Platform: Linux RedHat (running Apache) scorpy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL output query
Chris wrote: Greetings PHP folks, Which PHP function do I use if I want to achieve the following : http://www.somesite.com/gallery/pics.php is the url...how do I get it to read only http://www.somesite.com in the browser address bar without the rest of the directory and filename appearing ? If you're using php through a webserver then you might find it in one of the $_SERVER variables (create a phpinfo page). If you're not, then probably use parse_url: http://www.php.net/parse_url The second way is probably better and more reliable. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] URL problem
If you are in a *nix environment, make a symlink from site_folder/index.php - site_folder/example_folder/index.php and that should do it. Shaunak Kashyap Senior Web Developer WPT Enterprises, Inc. 5700 Wilshire Blvd., Suite 350 Los Angeles, CA 90036 Main: 323.330.9900 www.worldpokertour.com Confidentiality Notice: This e-mail transmission (and/or the attachments accompanying) it may contain confidential information belonging to the sender which is protected. The information is intended only for the use of the intended recipient. If your are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking of any action in reliance on the contents of this information is prohibited. If you have received this transmission in error, please notify the sender by reply e-mail and destroy all copies of this transmission. -Original Message- From: Jesús Alain Rodríguez Santos [mailto:[EMAIL PROTECTED] Sent: Friday, February 17, 2006 2:49 PM To: php-general@lists.php.net Subject: [PHP] URL problem I have a following directory: - folder (site) index.php - folder (example) index.php the url to this directory will be: http://www.example.com/site/index.php but I need redirect with: header() function to the index.php inside the folder example without the url change I mean, I want to keep the same url but diferent directory -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
I think you need to create a stream context resource with: http://www.php.net/manual/en/function.stream-context-create.php set the options you need on it with: http://www.php.net/manual/en/function.stream-context-set-option.php then pass the resource as the 4th arg to fopen() (rather passing in an array) ...i think Richard Lynch wrote: On Thu, January 19, 2006 4:08 pm, Geoff wrote: I honestly have no idea if this would work, but maybe fopen supports non-blocking connections? Not as far as I can tell... You can call stream_set_blocking after it's open, but that doesn't help a slow connection in the first place. Or creation of context-based connections (for which you can use stream_set_blocking). Unless I'm seriously mis-reading docs, stream_set_blocking can only be called on an already-open stream, not on the soon-to-be-opened stream. fopen() in PHP5 does take a context, and if I could figure out how to embed the concepts of do not block and timeout in $x seconds within a context from the docs, and if fopen() would still handle all the details of the various protocols, I'd be all set... That's sort of what I was asking for in the original email, but... It seems like you have to specify the 'scheme' as the key in the context array. So, I guess, I could, in theory, find a listing of all the schemes fopen() supports, which might even be in a function, iterate over all of those, and do something like: $schemes = function_that_returns_all_schemes_fopen_supports(); $opts = array(); foreach($schemes as $scheme){ $opts[$scheme]['some_magic_undocumented_thing'] = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT ; } $foo = fopen($url, 'r', false, $opts); if ($foo == false) $errors[] = $url timed out; Only problem is, these constants are documented ONLY to work with: http://www.php.net/manual/en/function.stream-socket-client.php and that pretty clearly is working at a much lower-level than fopen (and friends) as the very first example shows using TCP as a protocol, and then you have to send the GET and any other headers, which is exactly what I'm trying to avoid having to re-code in the first place. So I'm back to square one, as far as I can see from the docs... It's possible (still) that I'm just mis-reading docs, or am continually skipping over the one new page in 'streams' that is making everybody think this should be so simple, but I don't think so, since I've read EVERY page in the new streams section several times now. I'm not claiming 100% comprehension of every implication on every page, mind you :-) If so, you could take a stamp of the current time plus a timeout value, make the fopen call (which would return immediately) then wait politely (I mean that from a CPU perspective) in a loop until you have data, or the current time goes past your time stamp. Yes -- if I could compose a stream_context doohickey that convinced fopen() to use a time-out... Another avenue for investigation might be to try file_get_contents to see if it's connection timeout can be controlled. It seems to work in a similar way to fopen, in terms of having wrappers that are aware of multiple resource types. file_get_contents() seems to suffer from the exact same limitations of file() I get the simplicity of fopen() with no control over connection timeout. Maybe there is some underlying voodoo going on in the PHP internals that some makes it crystal-clear why that has to be, but to this naive user, if fsockopen can have a timeout, fopen and friends out to be able to also, at least for schemes that support such a thing. Obviously SOME kind of timeout is involved somewhere in fopen() because it WILL timeout on some sites sometimes, even though experimentation has shown that had it waited, it would have gotten data eventually. It might also be worth taking a look at cURL or similar libraries that are also multi-resource aware, but give you greater control of connections parameters and timeouts. Maybe I've been mis-using cURL all these years, but it doesn't seem to be anywhere near as simple as the mythical function I've described, and really not much better than a giant switch for fsockopen to duplicate all that code that's gotta be down in the guts of fopen (and friends) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
On Thu, January 19, 2006 6:49 pm, Geoff wrote: Richard, have you seen this: http://bugs.php.net/bug.php?id=5153edit=1 This bug goes back to June 2000. And it's closed even though it is clearly not fixed. Doesn't seem like they'll get to it anytime soon. You might have to do it the long way, building your own protocol handlers. Or, you might want to look into a 3rd party library, or a command line option like lynx -dump -connect_timeout=n uri which is multi-resource aware. The comment in that bug report, and similar comments all over the 'net by PHP Dev Team, are what led me on this quest in the first place... Alas, the reality falls far short of what I had hoped was promised. I *CAN* control the timeout, if I'm wiling to re-invent the wheel and duplicate a ton of code that's built into fopen. I *THOUGHT* from the comments that the new streams would have something like fopen, with a configurable timeout, but with the streams library handling all the minutia of different protocols. As far as I can find, that's not the case. Here is a crude version of what I would like to be able to type: $url = 'https://example.com'; $stream_context = array('connection_timeout'=4', 'url'=$url); $stream = new stream($stream_context); if ($stream === false) die(Connection timed out.); stream_set_blocking($stream, false); $start = time(); //Never ask the user to wait more than 5 seconds for a web page: $data = ''; while ((time() = $start + 5) !feof($stream)){ $data .= fread($stream, 2048); } if (!feof($stream)){ //load obsolete data from cache, rather than incomplete data we just got: $data = load_cache($url); } Instead, I have to know the ins and outs of all the different protocols to even begin to use the new streams stuff. Richard unwillling Lynch :-^ -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
On Fri, January 20, 2006 7:10 am, Jochem Maas wrote: I think you need to create a stream context resource with: http://www.php.net/manual/en/function.stream-context-create.php set the options you need on it with: http://www.php.net/manual/en/function.stream-context-set-option.php then pass the resource as the 4th arg to fopen() (rather passing in an array) ...i think My whole entire point is this: I have no idea what all the options are that I would need to duplicate the code that is built-in to http://php.net/fopen I really don't want to re-invent the wheel of figuring out all those options when they are already coded in fopen. The examples of HTTP and FTP are all very nice, but I'd have to code for SSL and files and all manner of other protocols to come anywhere close to the functionality of fopen. Alas, with fopen, there is no control over connection timeout. Everybody experienced in PHP keeps talking about the new streams stuff as if it's a Magic Bullet that will make this all better. It's not. It adds layer upon layer of complication to application code, and I'm sure it's wondeful if one wants the fine-grained control over a zillion things I don't understand, and I don't WANT to understand -- at leat not at the expense it would take to gain an understanding necessary to use stream-contexts. What 99% of developers want, however, is to ignore all the gory details of all the different schemes and protocols, and get their data. $file = fopen($any_url_in_any_protocol); A large proportion of those developers also want to have a site that does not seem slow if it's stuck waiting for some resource. So they want fopen() to have a developer-configurable timeout. Does not exist. The only way you can get developer-configurable timeout is to use fsockopen or the new stream-context stuff, both of which require a Ph.D. in eleventeen different scheme/protocol technologies to get the kind of functionality you get with fopen. I hope I'm making sense here, and clearly laying out the issue, because apparently it hasn't gotten through to most readers in previous messages. Currently in PHP you have two options: Use fopen, keep life simple, but have an infinitely slow response when your application depends on a dodgy remote server over which you have no control. Use fsockopen or streams and spend the next 4 years coding your application to understand all the ins and outs of protocols you really don't WANT to understand the details of that should be a black box to your application. Do you REALLY want to try to figure out what kind of an array you need to build and what data you have to send/recieve/parse and act upon to get an HTTPS feed? With fopen() it's just taken care of. With stream-context, you're going to have to actually understand all that SSL stuff before you can get your data. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
Richard Lynch wrote: So I've been poring over the docs for the new stream stuff, and it looks pretty nifty, except... I'd really like to be able to just hand a URL to PHP like: http://php.net/manual/en/ref.stream.php er you can if allow_url_fopen ini setting is set to 1 (can't you?) $fh = fopen('http://php.net/'); for other kinds of streams (e.g. ftp?) you can write a userland wrapper and register it so that you can use those kinds (e.g. ftp) of urls with fopen et al: http://www.php.net/manual/en/function.stream-wrapper-register.php And let PHP figure out how to create a stream context out of that, and which port to use, and how to do the GET to start things off, so I can just read my data. In other words, I'm greedy, and I want *BOTH* the simplicity of fopen() *and* the flexiblity of adding filters and all the fun new stuff. well the manual (http://php.net/fopen) says: $handle = fopen(/home/rasmus/file.txt, r); $handle = fopen(/home/rasmus/file.gif, wb); $handle = fopen(http://www.example.com/;, r); $handle = fopen(ftp://user:[EMAIL PROTECTED]/somefile.txt, w); I don't want to have to tear apart the URL myself and mess with sending 'GET ...' and 'host: ...' Did I miss a stream_url_to_context() function somewhere?... Not just parse_url() -- That will tear apart the URL, but then I have to do all the work that's buried in fopen() Bigger Picture: I have an old class that will take an array of HTTP URLs, and fsockopen them, set them non-blocking, and then fread() each in turn, and gather an array of results. The class has a 'timeout' parameter that limits how long it will wait for all this to happen. Each result set is marked as complete or incomplete. Complete results may be cached, for however long you choose in another setting. If results are incomplete, the cached version is used, no matter how obsolete. (This is for a search engine.) Blah, blah, blah. Anyway, I'd *LIKE* to be able to just allow *ANY* URL to be passed in, and have some nifty stream function, not unlike fopen(), that will take care of the grotty details of doing whatever it takes to get the data, but let me set the socket non-blocking and read them asynchronously. I feel like I must be missing something fundamentally simple here in all this stream stuff, but it's sure not obvious what I'm missing in the docs. and maybe I'm completely misunderstanding you ;-/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
On Thu, January 19, 2006 5:17 am, Jochem Maas wrote: Richard Lynch wrote: So I've been poring over the docs for the new stream stuff, and it looks pretty nifty, except... I'd really like to be able to just hand a URL to PHP like: http://php.net/manual/en/ref.stream.php er you can if allow_url_fopen ini setting is set to 1 (can't you?) $fh = fopen('http://php.net/'); The crucial point buried too far into my initial post (sorry): I NEED to specify a timeout for the initial CONNECTION to acquire the data. fopen does not allow this. fsockopen does, but then I'm stuck with re-inventing the wheel on handling dozens of different protocols to initiate the process to get the data rolling. For HTTP, you have to send GET $path HTTP/1.0\n For FTP, you have to send GET $path\n For a file, you don't send anything . . . So to get all the functionality of fopen() I'd need a monster long switch statement with a bunch of protocols about which I know almost nothing, including some rather complex stuff I can guarantee is over my head for ssl:// https:// ftps:// and friends. I really do not want to re-code all that, when I know it's down in the guts of 'fopen' In other words, I need an additional 'timeout' argument to fopen() that works when url_wrappers is on, or a function to set the default timeout for fopen() to wait. PLEASE don't refer me to stream_set_timeout. THAT only applies to how long to wait for data AFTER the stream is open and you are reading data. I'm asking for: The convenience of fopen() that knows about dozens of protocols and takes care of the grotty details so I can just start reading data. The power of fsockopen() that allows one to specify how long to wait for a slow source feed. What I was hoping for, then, was that I could call this mythical function url2context() that would convert *any* URL into an appropriate stream context. Then I thought I would be able to use that contact for fsockopen() with a timeout for connection. I now see that fsockopen() does not even take a stream_context, but that fopen() now does, and none of this would do me any good at all... I guess I was thinking that the magic of fopen() being able to handle all those protocols had been bundled into the streams code, and that I ought to be able to utilize that somehow WITH a timeout on the connection. I guess I'm stuck with re-coding all the stuff from fopen() in a giant PHP switch and using my old-school fsockopen, just so I can have control over connection timeout. :-( And it looks like all the new streams stuff is very nifty for some things, but rather useless for the feature that I believe quite a few users have been asking for: Gimme fopen() with control over timeout, so I can ignore all the minutia of what kind of file/stream/URL/whatever I'm reading, but not have my application waiting for 2 minutes when somebody else's server goes down. I tried to open a Feature Request to this, but it's already been closed as Bogus wherein I was told to rtfm. I've re-opened it, but based on my past mixed experience with the people behind bugs.php.net, I figure I've only got a 50/50 chance of somebody who actually reads and comprehends what I typed seeing it before it gets closed again and ignored. :-( Don't get me wrong -- I know what a monumental task they face, and am aware that there are certain Pavlovian automatic reactions, and that's how it is when they see the keywords embedded in my Change Request, so I'm not dis-ing them... It's just Reality that a worthy feature worth considering is probably going to get buried in the Bogus pile. [shrug] If anybody reading this actually agrees with me, feel free to vote here: http://bugs.php.net/bug.php?id=36072 If you think I'm an idiot, by all means vote against the feature request. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
3 suggestions: I honestly have no idea if this would work, but maybe fopen supports non-blocking connections? Or creation of context-based connections (for which you can use stream_set_blocking). If so, you could take a stamp of the current time plus a timeout value, make the fopen call (which would return immediately) then wait politely (I mean that from a CPU perspective) in a loop until you have data, or the current time goes past your time stamp. Another avenue for investigation might be to try file_get_contents to see if it's connection timeout can be controlled. It seems to work in a similar way to fopen, in terms of having wrappers that are aware of multiple resource types. It might also be worth taking a look at cURL or similar libraries that are also multi-resource aware, but give you greater control of connections parameters and timeouts. Geoff. On 19 Jan 2006 at 14:49, Richard Lynch wrote: On Thu, January 19, 2006 5:17 am, Jochem Maas wrote: Richard Lynch wrote: So I've been poring over the docs for the new stream stuff, and it looks pretty nifty, except... I'd really like to be able to just hand a URL to PHP like: http://php.net/manual/en/ref.stream.php er you can if allow_url_fopen ini setting is set to 1 (can't you?) $fh = fopen('http://php.net/'); The crucial point buried too far into my initial post (sorry): I NEED to specify a timeout for the initial CONNECTION to acquire the data. fopen does not allow this. fsockopen does, but then I'm stuck with re-inventing the wheel on handling dozens of different protocols to initiate the process to get the data rolling. For HTTP, you have to send GET $path HTTP/1.0\n For FTP, you have to send GET $path\n For a file, you don't send anything .. .. .. So to get all the functionality of fopen() I'd need a monster long switch statement with a bunch of protocols about which I know almost nothing, including some rather complex stuff I can guarantee is over my head for ssl:// https:// ftps:// and friends. I really do not want to re-code all that, when I know it's down in the guts of 'fopen' In other words, I need an additional 'timeout' argument to fopen() that works when url_wrappers is on, or a function to set the default timeout for fopen() to wait. PLEASE don't refer me to stream_set_timeout. THAT only applies to how long to wait for data AFTER the stream is open and you are reading data. I'm asking for: The convenience of fopen() that knows about dozens of protocols and takes care of the grotty details so I can just start reading data. The power of fsockopen() that allows one to specify how long to wait for a slow source feed. What I was hoping for, then, was that I could call this mythical function url2context() that would convert *any* URL into an appropriate stream context. Then I thought I would be able to use that contact for fsockopen() with a timeout for connection. I now see that fsockopen() does not even take a stream_context, but that fopen() now does, and none of this would do me any good at all... I guess I was thinking that the magic of fopen() being able to handle all those protocols had been bundled into the streams code, and that I ought to be able to utilize that somehow WITH a timeout on the connection. I guess I'm stuck with re-coding all the stuff from fopen() in a giant PHP switch and using my old-school fsockopen, just so I can have control over connection timeout. :-( And it looks like all the new streams stuff is very nifty for some things, but rather useless for the feature that I believe quite a few users have been asking for: Gimme fopen() with control over timeout, so I can ignore all the minutia of what kind of file/stream/URL/whatever I'm reading, but not have my application waiting for 2 minutes when somebody else's server goes down. I tried to open a Feature Request to this, but it's already been closed as Bogus wherein I was told to rtfm. I've re-opened it, but based on my past mixed experience with the people behind bugs.php.net, I figure I've only got a 50/50 chance of somebody who actually reads and comprehends what I typed seeing it before it gets closed again and ignored. :-( Don't get me wrong -- I know what a monumental task they face, and am aware that there are certain Pavlovian automatic reactions, and that's how it is when they see the keywords embedded in my Change Request, so I'm not dis-ing them... It's just Reality that a worthy feature worth considering is probably going to get buried in the Bogus pile. [shrug] If anybody reading this actually agrees with me, feel free to vote here: http://bugs.php.net/bug.php?id=36072 If you think I'm an idiot, by all means vote against the feature request. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
On Thu, January 19, 2006 4:08 pm, Geoff wrote: I honestly have no idea if this would work, but maybe fopen supports non-blocking connections? Not as far as I can tell... You can call stream_set_blocking after it's open, but that doesn't help a slow connection in the first place. Or creation of context-based connections (for which you can use stream_set_blocking). Unless I'm seriously mis-reading docs, stream_set_blocking can only be called on an already-open stream, not on the soon-to-be-opened stream. fopen() in PHP5 does take a context, and if I could figure out how to embed the concepts of do not block and timeout in $x seconds within a context from the docs, and if fopen() would still handle all the details of the various protocols, I'd be all set... That's sort of what I was asking for in the original email, but... It seems like you have to specify the 'scheme' as the key in the context array. So, I guess, I could, in theory, find a listing of all the schemes fopen() supports, which might even be in a function, iterate over all of those, and do something like: $schemes = function_that_returns_all_schemes_fopen_supports(); $opts = array(); foreach($schemes as $scheme){ $opts[$scheme]['some_magic_undocumented_thing'] = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT ; } $foo = fopen($url, 'r', false, $opts); if ($foo == false) $errors[] = $url timed out; Only problem is, these constants are documented ONLY to work with: http://www.php.net/manual/en/function.stream-socket-client.php and that pretty clearly is working at a much lower-level than fopen (and friends) as the very first example shows using TCP as a protocol, and then you have to send the GET and any other headers, which is exactly what I'm trying to avoid having to re-code in the first place. So I'm back to square one, as far as I can see from the docs... It's possible (still) that I'm just mis-reading docs, or am continually skipping over the one new page in 'streams' that is making everybody think this should be so simple, but I don't think so, since I've read EVERY page in the new streams section several times now. I'm not claiming 100% comprehension of every implication on every page, mind you :-) If so, you could take a stamp of the current time plus a timeout value, make the fopen call (which would return immediately) then wait politely (I mean that from a CPU perspective) in a loop until you have data, or the current time goes past your time stamp. Yes -- if I could compose a stream_context doohickey that convinced fopen() to use a time-out... Another avenue for investigation might be to try file_get_contents to see if it's connection timeout can be controlled. It seems to work in a similar way to fopen, in terms of having wrappers that are aware of multiple resource types. file_get_contents() seems to suffer from the exact same limitations of file() I get the simplicity of fopen() with no control over connection timeout. Maybe there is some underlying voodoo going on in the PHP internals that some makes it crystal-clear why that has to be, but to this naive user, if fsockopen can have a timeout, fopen and friends out to be able to also, at least for schemes that support such a thing. Obviously SOME kind of timeout is involved somewhere in fopen() because it WILL timeout on some sites sometimes, even though experimentation has shown that had it waited, it would have gotten data eventually. It might also be worth taking a look at cURL or similar libraries that are also multi-resource aware, but give you greater control of connections parameters and timeouts. Maybe I've been mis-using cURL all these years, but it doesn't seem to be anywhere near as simple as the mythical function I've described, and really not much better than a giant switch for fsockopen to duplicate all that code that's gotta be down in the guts of fopen (and friends) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL - stream context
Richard, have you seen this: http://bugs.php.net/bug.php?id=5153edit=1 This bug goes back to June 2000. And it's closed even though it is clearly not fixed. Doesn't seem like they'll get to it anytime soon. You might have to do it the long way, building your own protocol handlers. Or, you might want to look into a 3rd party library, or a command line option like lynx -dump -connect_timeout=n uri which is multi-resource aware. Geoff. On 19 Jan 2006 at 17:28, Richard Lynch wrote: On Thu, January 19, 2006 4:08 pm, Geoff wrote: I honestly have no idea if this would work, but maybe fopen supports non-blocking connections? Not as far as I can tell... You can call stream_set_blocking after it's open, but that doesn't help a slow connection in the first place. Or creation of context-based connections (for which you can use stream_set_blocking). Unless I'm seriously mis-reading docs, stream_set_blocking can only be called on an already-open stream, not on the soon-to-be-opened stream. fopen() in PHP5 does take a context, and if I could figure out how to embed the concepts of do not block and timeout in $x seconds within a context from the docs, and if fopen() would still handle all the details of the various protocols, I'd be all set... That's sort of what I was asking for in the original email, but... It seems like you have to specify the 'scheme' as the key in the context array. So, I guess, I could, in theory, find a listing of all the schemes fopen() supports, which might even be in a function, iterate over all of those, and do something like: $schemes = function_that_returns_all_schemes_fopen_supports(); $opts = array(); foreach($schemes as $scheme){ $opts[$scheme]['some_magic_undocumented_thing'] = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT ; } $foo = fopen($url, 'r', false, $opts); if ($foo == false) $errors[] = $url timed out; Only problem is, these constants are documented ONLY to work with: http://www.php.net/manual/en/function.stream-socket-client.php and that pretty clearly is working at a much lower-level than fopen (and friends) as the very first example shows using TCP as a protocol, and then you have to send the GET and any other headers, which is exactly what I'm trying to avoid having to re-code in the first place. So I'm back to square one, as far as I can see from the docs... It's possible (still) that I'm just mis-reading docs, or am continually skipping over the one new page in 'streams' that is making everybody think this should be so simple, but I don't think so, since I've read EVERY page in the new streams section several times now. I'm not claiming 100% comprehension of every implication on every page, mind you :-) If so, you could take a stamp of the current time plus a timeout value, make the fopen call (which would return immediately) then wait politely (I mean that from a CPU perspective) in a loop until you have data, or the current time goes past your time stamp. Yes -- if I could compose a stream_context doohickey that convinced fopen() to use a time-out... Another avenue for investigation might be to try file_get_contents to see if it's connection timeout can be controlled. It seems to work in a similar way to fopen, in terms of having wrappers that are aware of multiple resource types. file_get_contents() seems to suffer from the exact same limitations of file() I get the simplicity of fopen() with no control over connection timeout. Maybe there is some underlying voodoo going on in the PHP internals that some makes it crystal-clear why that has to be, but to this naive user, if fsockopen can have a timeout, fopen and friends out to be able to also, at least for schemes that support such a thing. Obviously SOME kind of timeout is involved somewhere in fopen() because it WILL timeout on some sites sometimes, even though experimentation has shown that had it waited, it would have gotten data eventually. It might also be worth taking a look at cURL or similar libraries that are also multi-resource aware, but give you greater control of connections parameters and timeouts. Maybe I've been mis-using cURL all these years, but it doesn't seem to be anywhere near as simple as the mythical function I've described, and really not much better than a giant switch for fsockopen to duplicate all that code that's gotta be down in the guts of fopen (and friends) -- Like Music? http://l-i-e.com/artists.htm !DSPAM:43d02ead91711894325842! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url vs dirname(__FILE__)
Chris wrote: I trying to create an absolute path to include scripts and images in another directory. These are two different things, but there is a relationship in the sense that URLs are translated to filesystem paths using document root: http://host/path/to/script.php = [document root]/path/to/script.php I think it's pretty important to understand the difference as well as the relationship. Once you do, your question might go away. Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url query problem
On Fri, November 11, 2005 9:12 pm, Imroz wrote: Hi PHP Gurus Am new to the php world, I need help to do something. PlZz help I have this link HYPERLINK http://www.taximauritius.mu/link1.phphttp://www.taximauritius.mu/link1 ..php. What I want to do : When clicking on the link above, that would bring me to a page HYPERLINK http://www.taximauritius.mu/reservation.php?client=apartment1http://ww w.taximauritius.mu/reservation.php?client=apartment1, and in this URL, as can be seen, there is a variable called apartment1. I want to get the name of this variable + other form fields in my email message when the form is sent. Actually I do get the other form fields in my email message. I just dont get the variable (client=apartment1) Am attaching the codes, It would really be grateful if you could plzzz help me. Read the PHP FAQ on http://php.net/faq about processing all POST values. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url query problem
You've tried accessing $_GET in reservation.php? Like $_GET['client'] would return apartment1 in reservation.php if you clicked on http://www.taximauritius.mu/reservation.php?client=apartment1 -Minuk Imroz wrote: Hi PHP Gurus Am new to the php world, I need help to do something. PlZz help I have this link http://www.taximauritius.mu/link1.php. What I want to do : When clicking on the link above, that would bring me to a page http://www.taximauritius.mu/reservation.php?client=apartment1, and in this URL, as can be seen, there is a variable called apartment1. I want to get the name of this variable + other form fields in my email message when the form is sent. Actually I do get the other form fields in my email message. I just don’t get the variable (client=apartment1) Am attaching the codes, It would really be grateful if you could plzzz help me. Thanks a lot for helping Imrose -- Outgoing mail is certified Virus Free. Checked by AVG Anti-Virus (http://www.grisoft.com). Version: 7.0.269 / Virus Database: 264.8.0 - Release Date: 9/6/2004 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Referral Tracking with AIM
Havn't done it myself, but why not try pasting a link in IM and have it go to a php script that does a var_dump (or print_r) of $_SERVER. Think that's where the referrer data is. It may not show any referrer information since it's coming from an IM, but who knows.. would be interesting to try out. Thanks for bringing this up, now I have something to play with later. hah Second though is that even though you might not get any referrer data, there may be some other data in the server variables that could be telling. Unfortunately, since this is going to spawn an instance of IE or Firefox or something to actually load the page, you'll most likely get the info from the browser with zero info regarding the app (AIM, Yahoo, etc) that it spawned from. Some IM's, like AIM, allow you to put in variables though, like %s I think it is for 'screenname' in AIM so if you hand out a URL like http://www.domain.com/script.php?aim=%s as long as the %s part is pasted each time, it MAY substitute that person's screen name. If it's sent to me and I see: http://www.domain.com/script.php?aim=tgryffyn then copy/paste that (with the tgryffyn instead of %s) then obviously other people using it will get logged as me, and not them. Just some quick thoughts off the top of my head. Let us know if you come up with anything good and I'll write later if I get a chance to play with this. -TG = = = Original message = = = I know that referrer is an ENV variable carried by web browsers but I am wondering if any of you guru's have figured out a way to track any referrer al information from a link pasted into an instant messenger (AIM) window. Anyone have any ideas on this? Much Thanks, Mike D ... Mike Dunlop Director of Technology Development [ e ] [EMAIL PROTECTED] [ p ] 323.644.7808 1-800-Help-Now | http://www.redcross.org ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL Referral Tracking with AIM
Thanks for the thoughts -- some good points! I will let you know if I come up with anything that works, please let me you know if you do the same :) Best, Mike D ... Mike Dunlop Director of Technology Development [ e ] [EMAIL PROTECTED] [ p ] 323.644.7808 1-800-Help-Now | http://www.redcross.org On Sep 27, 2005, at 11:10 AM, [EMAIL PROTECTED] tg- [EMAIL PROTECTED] wrote: Havn't done it myself, but why not try pasting a link in IM and have it go to a php script that does a var_dump (or print_r) of $_SERVER. Think that's where the referrer data is. It may not show any referrer information since it's coming from an IM, but who knows.. would be interesting to try out. Thanks for bringing this up, now I have something to play with later. hah Second though is that even though you might not get any referrer data, there may be some other data in the server variables that could be telling. Unfortunately, since this is going to spawn an instance of IE or Firefox or something to actually load the page, you'll most likely get the info from the browser with zero info regarding the app (AIM, Yahoo, etc) that it spawned from. Some IM's, like AIM, allow you to put in variables though, like %s I think it is for 'screenname' in AIM so if you hand out a URL like http://www.domain.com/script.php?aim=%s as long as the %s part is pasted each time, it MAY substitute that person's screen name. If it's sent to me and I see: http://www.domain.com/script.php? aim=tgryffyn then copy/paste that (with the tgryffyn instead of % s) then obviously other people using it will get logged as me, and not them. Just some quick thoughts off the top of my head. Let us know if you come up with anything good and I'll write later if I get a chance to play with this. -TG = = = Original message = = = I know that referrer is an ENV variable carried by web browsers but I am wondering if any of you guru's have figured out a way to track any referrer al information from a link pasted into an instant messenger (AIM) window. Anyone have any ideas on this? Much Thanks, Mike D ... Mike Dunlop Director of Technology Development [ e ] [EMAIL PROTECTED] [ p ] 323.644.7808 1-800-Help-Now | http://www.redcross.org ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com.
Re: [PHP] url reload
On Thu, July 7, 2005 6:40 pm, timothy johnson said: This should be pretty simple but I cant find any info on it at the site. I am writing a function that will create a anchor, but I want it to call the same page it is on. Is there a way to get the current php page I am on so that when I output my anchor for that correct page. so if I call it from index.php the link will say: index.php?var=data but if I can the same function from say photos.php then the link would be: photos.php?var=data.. It's pretty rare that you REALLY want to blindly copy ALL $_GET arguments, but you can: $get = ''; reset($_GET); while (list($k, $v) = each($_GET)){ $get .= k= . urlencode($v); } $get[0] = '?'; But you should *PROBABLY* be checking for specific values in $_GET, making sure they are clean and passing on only those values. $kosher = '[^A-Za-z0-9\'\\. ,-]'; $name = $_GET['name']; $zip = $_GET['zip']; $zip = (int) $zip; //Assuming only 5-digit zip code will ever be used in this application $zip = sprintf(%05s, $zip); $name = preg_replace($kosher, '', $name); $url = ?name= . urlencode($name) . zip=$zip; -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL decode
Mario netMines wrote: I have a value like: %u0394%u0397%u03A4%u039C%u039B Is there a way to decode to normal characters (like javascript's unescape() function) I think you might want to try mb_parse_str(), although I can't run a quick test for you, because I don't have the multibyte extension enabled in my current build. I would try something like this: ?php $foo = '%u0394%u0397%u03A4%u039C%u039B'; $bar = array(); mb_parse_string($foo, $bar); print_r($bar); ? Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] url by mail
$lines = file('http://www.example.com/'); foreach ($lines as $line) { echo $line . \n; } This ought to do it. Try it and see. But be aware that if the allow_url_fopen was not enable at the compile time, this won't work. Mark Cain - Original Message - From: vlad georgescu [EMAIL PROTECTED] To: php-general php-general@lists.php.net Sent: Saturday, June 04, 2005 1:54 PM Subject: [PHP] url by mail how can i send a webpage by mail ? i'v tryed something like that $fd = fopen ($url, r); $contents = fread($fd, 102400); print $contents; fclose ($fd); mail($adr,$url,$contents); but the message is blank :( what's the problem ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL file-access disabled
$image_dir is an url (begins with http:// or similar) and allow_url_fopen is off on your BSD. Do you need to access it using url wrappers? If the images are local you can access them using plain filesystem access Jackson Linux wrote: Hi, ho, I have a problem; something which works locally is complaining on the BSD Unix server I use: The Code: (somewhere else I define $image_dir) !-- If there's an image, get it, get its height and width and slap it into an image tag, otherwise, move on -- ?php if (!empty($article['image'])) { $image = ($article['image']); $size1 = getimagesize($image_dir.$image); $width1 = $size1[0]; $height1 = $size1[1]; include_once(INCLUDES . 'image.include.php'); } ? The Include: img class='right-float' src='?php echo $image_dir.$image ?' width='?php echo $width1 ?' height='?php echo $height1 ?' alt='?php echo $image ?' border='0' / The Error: Warning: getimagesize(): URL file-access is disabled in the server configuration in /usr/www/users/user/articles/technology/index.htm on line 180 Warning: getimagesize(http://www.domain.com/images/combination_device.jpg): failed to open stream: no suitable wrapper could be found in /usr/www/users/user/articles/technology/index.htm on line 180 The Question: Anything I can do within .htaccess to make this not happen? I don't have root access or access to php.ini, and they're loathe to change the configuration on a shared servcer. Thanks in advance, Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL file-access disabled
My provider has provided me the solution: adding php_flag allow_url_fopen on to the .htaccess Apologies to the list for wasting time and bandwidth. Jack On 31 Mar 2005, at 17:47, Jackson Linux wrote: Hi, ho, I have a problem; something which works locally is complaining on the BSD Unix server I use: The Code: (somewhere else I define $image_dir) !-- If there's an image, get it, get its height and width and slap it into an image tag, otherwise, move on -- ?php if (!empty($article['image'])) { $image = ($article['image']); $size1 = getimagesize($image_dir.$image); $width1 = $size1[0]; $height1 = $size1[1]; include_once(INCLUDES . 'image.include.php'); } ? The Include: img class='right-float' src='?php echo $image_dir.$image ?' width='?php echo $width1 ?' height='?php echo $height1 ?' alt='?php echo $image ?' border='0' / The Error: Warning: getimagesize(): URL file-access is disabled in the server configuration in /usr/www/users/user/articles/technology/index.htm on line 180 Warning: getimagesize(http://www.domain.com/images/combination_device.jpg): failed to open stream: no suitable wrapper could be found in /usr/www/users/user/articles/technology/index.htm on line 180 The Question: Anything I can do within .htaccess to make this not happen? I don't have root access or access to php.ini, and they're loathe to change the configuration on a shared servcer. Thanks in advance, Jack -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL restriction on XML file
That's because the character data is split on the borders of the entities, so for http://feeds.example.com/?rid=318045f7e13e0b66amp;cat=48cba686fe041718amp;f=1 characterData() will be called 5 times: http://feeds.example.com/?rid=318045f7e13e0b66 cat=48cba686fe041718 f=1 Solution is inlined below Roger Thomas wrote: I have a short script to parse my XML file. The parsing produces no error and all output looks good EXCEPT url-links were truncated IF it contain the 'amp;' characters. My XML file looks like this: --- start of XML --- ?xml version=1.0 encoding=iso-8859-1? rss version=2.0 channel titleTest News .Net - Newspapers on the Net/title copyrightSmall News Network.com/copyright linkhttp://www.example.com//link descriptionContinuously updating Example News./description languageen-us/language pubDateTue, 29 Mar 2005 18:01:01 -0600/pubDate lastBuildDateTue, 29 Mar 2005 18:01:01 -0600/lastBuildDate ttl30/ttl item titleGroup buys SunGard for US$10.4bil/title linkhttp://feeds.example.com/?rid=318045f7e13e0b66amp;cat=48cba686fe041718amp;f=1/link descriptionNEW YORK: A group of seven private equity investment firms agreed yesterday to buy financial technology company SunGard Data Systems Inc in a deal worth US$10.4bil plus debt, making it the biggest lev.../description source url=http://biz.theexample.com/;The Paper/source /item item titleStrong quake hits Indonesia coast/title linkhttp://feeds.example.com/news/world/quake.html/link descriptiona quot;widely destructive tsunamiquot; and the quake was felt as far away as Malaysia./description source url=http://biz.theexample.com.net/;The Paper/source /item item titleFinal News/title linkhttp://feeds.example.com/?id=abcdefamp;cat=somecat/link descriptionWe are going to expect something new this weekend .../description source url=http://biz.theexample.com/;The Paper/source /item /channel /rss --- end of XML --- For the sake of testing, my script only print out the url-link to those news above. I got these: f=1 http://feeds.example.com/news/world/quake.html cat=somecat The output for line 1 is truncated to 'f=1' and the output of line 3 is truncated to 'cat=somecat'. ie, the script only took the last parameter of the url-link. The output for line 2 is correct since it has NO parameters. I am not sure what I have done wrong in my script. Is it bcos the RSS spec says that you cannot have parameters in URL ? Please advise. -- start of script -- ? $file = test.xml; $currentTag = ; function startElement($parser, $name, $attrs) { global $currentTag; $currentTag = $name; } function endElement($parser, $name) { global $currentTag, $TITLE, $URL, $start; switch ($currentTag) { case ITEM: $start = 0; case LINK: if ($start == 1) #print A HREF = \.$URL.\$TITLE/ABR; print $URL.BR; break; } $currentTag = ; // Reset also other variables: $URL = ''; $TITLE = ''; } function characterData($parser, $data) { global $currentTag, $TITLE, $URL, $start; switch ($currentTag) { case ITEM: $start = 1; case TITLE: $TITLE = $data; // append instead: $TITLE .= $data; break; case LINK: $URL = $data; // append instead: $URL .= $data; // Warning: entities are decoded at this point, you will receive , not amp; break; } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, startElement, endElement); xml_set_character_data_handler($xml_parser, characterData); if (!($fp = fopen($file, r))) { die(Cannot locate XML data file: $file); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf(XML error: %s at line %d, xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); ? -- end of script -- TIA. Roger --- Sign Up for free Email at http://ureg.home.net.my/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL restriction on XML file
Hi Marek, Thank you for the solution. -- Roger Quoting Marek Kilimajer [EMAIL PROTECTED]: That's because the character data is split on the borders of the entities, so for http://feeds.example.com/?rid=318045f7e13e0b66amp;cat=48cba686fe041718amp;f=1 characterData() will be called 5 times: http://feeds.example.com/?rid=318045f7e13e0b66 cat=48cba686fe041718 f=1 Solution is inlined below Roger Thomas wrote: I have a short script to parse my XML file. The parsing produces no error and all output looks good EXCEPT url-links were truncated IF it contain the 'amp;' characters. My XML file looks like this: --- start of XML --- ?xml version=1.0 encoding=iso-8859-1? rss version=2.0 channel titleTest News .Net - Newspapers on the Net/title copyrightSmall News Network.com/copyright linkhttp://www.example.com//link descriptionContinuously updating Example News./description languageen-us/language pubDateTue, 29 Mar 2005 18:01:01 -0600/pubDate lastBuildDateTue, 29 Mar 2005 18:01:01 -0600/lastBuildDate ttl30/ttl item titleGroup buys SunGard for US$10.4bil/title linkhttp://feeds.example.com/?rid=318045f7e13e0b66amp;cat=48cba686fe041718amp;f=1/link descriptionNEW YORK: A group of seven private equity investment firms agreed yesterday to buy financial technology company SunGard Data Systems Inc in a deal worth US$10.4bil plus debt, making it the biggest lev.../description source url=http://biz.theexample.com/;The Paper/source /item item titleStrong quake hits Indonesia coast/title linkhttp://feeds.example.com/news/world/quake.html/link descriptiona quot;widely destructive tsunamiquot; and the quake was felt as far away as Malaysia./description source url=http://biz.theexample.com.net/;The Paper/source /item item titleFinal News/title linkhttp://feeds.example.com/?id=abcdefamp;cat=somecat/link descriptionWe are going to expect something new this weekend .../description source url=http://biz.theexample.com/;The Paper/source /item /channel /rss --- end of XML --- For the sake of testing, my script only print out the url-link to those news above. I got these: f=1 http://feeds.example.com/news/world/quake.html cat=somecat The output for line 1 is truncated to 'f=1' and the output of line 3 is truncated to 'cat=somecat'. ie, the script only took the last parameter of the url-link. The output for line 2 is correct since it has NO parameters. I am not sure what I have done wrong in my script. Is it bcos the RSS spec says that you cannot have parameters in URL ? Please advise. -- start of script -- ? $file = test.xml; $currentTag = ; function startElement($parser, $name, $attrs) { global $currentTag; $currentTag = $name; } function endElement($parser, $name) { global $currentTag, $TITLE, $URL, $start; switch ($currentTag) { case ITEM: $start = 0; case LINK: if ($start == 1) #print A HREF = \.$URL.\$TITLE/ABR; print $URL.BR; break; } $currentTag = ; // Reset also other variables: $URL = ''; $TITLE = ''; } function characterData($parser, $data) { global $currentTag, $TITLE, $URL, $start; switch ($currentTag) { case ITEM: $start = 1; case TITLE: $TITLE = $data; // append instead: $TITLE .= $data; break; case LINK: $URL = $data; // append instead: $URL .= $data; // Warning: entities are decoded at this point, you will receive , not amp; break; } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, startElement, endElement); xml_set_character_data_handler($xml_parser, characterData); if (!($fp = fopen($file, r))) { die(Cannot locate XML data file: $file); } while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprintf(XML error: %s at line %d, xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } xml_parser_free($xml_parser); ? -- end of script -- TIA. Roger --- Sign Up for free Email at http://ureg.home.net.my/ --- --- Sign Up for free Email at http://ureg.home.net.my/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL encode
Bruno Santos wrote: Hello. Im having some trouble when getting a query from a $_GET method the problem is, when using $_GET, i get some charaters decoded as html entities. if i submit the word %sara% (example), is ok but, if i submi the word %carlos%, i get Êrlos, witch is the translation of html entity %ca so a user is entering '%carlos%'? firstly it _looks_ like you are adding the '%' signs in order to have this affect the way a search query is performed - if this is the case maybe you should consider wrapping the search term on the server side _after_ you have recieved the string? also if you run the following: echo urlencode(%carlos%); you will see that in order to pass the '%' sign in a url it will need to be encoded as '%25'; if you create the string '%carlos%' on the server then you can perform urlencode() on it before outputting the url and it should come back as you expect... if on the otherhand this is user entered info then you may need to use javascript to encode the string before the forms values are submitted. how can i can resolve it ?? ive tryed with htmlentities, urlencode, urldecode, etc... you don't need to run any function over the incoming value - the webserver will urldecode what ever GET string is incoming... if the string is not properly encoded in the first place (i.e. before it is used as a request to the webserver) then there is no proper way of retrieving the original value AFAICS help ? cheers Bruno Santos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL encode
Bruno Santos wrote: Hello. Im having some trouble when getting a query from a $_GET method the problem is, when using $_GET, i get some charaters decoded as html entities. if i submit the word %sara% (example), is ok but, if i submi the word %carlos%, i get Êrlos, witch is the translation of html entity %ca You probably *THINK* you are getting that, because when you print it out in your browser as part of the URL, you print out: %carlos Some really stupid browsers (Microsoft IE) will assume you forgot the ; at the end of %ca; and turn that into the html entity. But that's just the browser being stupid, not your data being wrong. Use View Source in your browser to see what's really in your output. how can i can resolve it ?? ive tryed with htmlentities, urlencode, urldecode, etc... Most likely, there is nothing to solve, and none of those are needed. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] URL-funtion - returnvalue into variable...?
u can try fopen On Wed, 12 Jan 2005 09:40:26 +0100, Wiberg [EMAIL PROTECTED] wrote: Hi there! I'm a total newbie at connecting to diffrent servers, and b2b and such stuff , so I guess this is a simple question for you guys... Another company wants me to access their productinfo thorugh URL, something like this: https://www.anothercompany.com/returnValueOfProductID=1043 If I access this site, the value of product that has ID 1043 will be returned. How do I get this returnvalue into a variable? /G @varupiraten.se -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 2005-01-10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php