php-general Digest 9 Oct 2011 13:52:53 -0000 Issue 7511
php-general Digest 9 Oct 2011 13:52:53 - Issue 7511 Topics (messages 315171 through 315185): Re: Server Side Include translator as PHP functions 315171 by: Tommy Pham 315172 by: Tommy Pham 315173 by: Tommy Pham 315174 by: Tommy Pham 315178 by: Complex 315180 by: Tommy Pham 315181 by: Complex 315182 by: Complex 315183 by: Tommy Pham files outside of documentRoot 315175 by: Ricardo Martinez 315176 by: Jim Giner 315177 by: Shawn McKenzie 315185 by: Ricardo Martinez PHP Download Of Application Question? 315179 by: Thomas Dineen 315184 by: Sean Greenslade Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Sat, Oct 8, 2011 at 8:36 AM, Complex complex.confus...@gmail.com wrote: Hello, Can you please tell me if there's already a set of PHP functions for translating SSI commands to PHP? I'm looking to do two things -- one difficult, one easy -- using PHP on a hosted server. My client has web pages that use Server Side Includes, and one sub-site that uses PHP. The task is to make the PHP sub-site use the same SSI includes as the rest of the site to maintain a consistent code structure. I can simply use include_once() to include each SSI include; that works fine. However, I'd like to recognize and replace one of the SSI instructions with a more nuanced PHP instruction that will insert dynamic information from the sub-site's environment. 1. include SSI files A 2. include SSI file B, Recognize B and replace it with some PHP code 3. include SSI file C and i can't actually do that b/c PHP gets run first and then SSI instructions. So the difficult thing I want to do is to read the SSI files (literally, using fread or similar), translate them to PHP ('include virtual' -- include(), set var=foo value=bar -- var foo = bar, etc), and then execute them. Then the simple thing I want to do will be recognizing the commands I want to replace or modify and doing so. Since this is a hosted solution, I don't believe I can install any PHP modules, and I'll have to use some functions instead. Does that already exist, please? -- -- CC --- I think you didn't provide enough details to get a more accurate suggestion of a solution, but here goes... Is 'include SSI file B' always included and always need to be replaced? If so, that's a very apparent solution. If not, what are criterias? URL? Query parameter(s) and/or value(s)? Certain user(s)? Certain group(s) of users? Certain hour of the day? Certain user agent(s)? etc... Regardless of how dynamic any site is, there's a always some kind of pattern. What you need to do is identify that pattern and do what you need accordingly. What about having PHP read those files to be included and output without having to rely on SSI mechanisms? I'm just curious... since PHP is OOP and, IIRC of SSI, the use of SSI limits the full potential of OOP and PHP. Is the control of the application and configurations beyond yours? Regards, Tommy ---End Message--- ---BeginMessage--- On Sat, Oct 8, 2011 at 8:36 AM, Complex complex.confus...@gmail.com wrote: Hello, Can you please tell me if there's already a set of PHP functions for translating SSI commands to PHP? I'm looking to do two things -- one difficult, one easy -- using PHP on a hosted server. My client has web pages that use Server Side Includes, and one sub-site that uses PHP. The task is to make the PHP sub-site use the same SSI includes as the rest of the site to maintain a consistent code structure. I can simply use include_once() to include each SSI include; that works fine. However, I'd like to recognize and replace one of the SSI instructions with a more nuanced PHP instruction that will insert dynamic information from the sub-site's environment. 1. include SSI files A 2. include SSI file B, Recognize B and replace it with some PHP code 3. include SSI file C and i can't actually do that b/c PHP gets run first and then SSI instructions. So the difficult thing I want to do is to read the SSI files (literally, using fread or similar), translate them to PHP ('include virtual' -- include(), set var=foo value=bar -- var foo = bar, etc), and then execute them. Then the simple thing I want to do will be recognizing the commands I want to replace or modify and doing so. Since this is a hosted solution, I don't believe I can install any PHP modules, and I'll have to use some functions instead. Does that already exist, please? -- -- CC --- I think you didn't provide enough details to get a more accurate suggestion of a solution, but here
[PHP] Re: files outside of documentRoot
The files are, png, pdf and flv. Only users login can see or download it. thx ; On Sat, Oct 8, 2011 at 11:16 PM, Shawn McKenzie nos...@mckenzies.netwrote: On 10/08/2011 03:40 PM, Ricardo Martinez wrote: Hi List! I need to access files outside the DocumentRoot. I've been looking for info and documentation, and I've read that it can be done using symbolic links and another way is by using headers. I want to know, what do you think, what is the best way, and if anyone knows a good doc about of it. Thanks!!! It depends on what you mean by files. Are they PHP files that need to be run, or images, or files that need to be downloaded by the user? For PHP, you would add the external dir to your include path. For images you can use a php file as the img src and that file sets the appropriate headers and uses readfile() to get and echo the image data: getimage.php?image=someimage.gif For download files you would do it in the same manner as for images: download.php?file=somefile.zip -- Thanks! -Shawn http://www.spidean.com -- Ricardo ___ IT Architect website: http://www.pulsarinara.com
Re: [PHP] Server Side Include translator as PHP functions
On Oct 8, 2011, at 8:48 PM, Tommy Pham wrote: On Sat, Oct 8, 2011 at 5:33 PM, Complex complex.confus...@gmail.com wrote: Thanks for the advice, I'm aware of all that, but I'm looking for a specific PHP solution at the moment. Unless you have advice on how I can update the SSI includes on the larger website *without* having to also update the PHP includes for this smaller website? I take it that you don't know of such a function; do you have a recommendation for a good function or program repository I could search? The couple that I was looking at (such as http://php.resourceindex.com/) don't look like they've received a whole lot of attention lately, and may not be the best sources. Did you look at my suggestion as work around such as replacing the SSI mechanism for a particular path/URL with PHP? Use of 'Conditional expressions' [1] maybe necessary which is beyond the scope of this list. What are SSI? SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program, or other dynamic technology. The decision of when to use SSI, and when to have your page entirely generated by some program, is usually a matter of how much of the page is static, and how much needs to be recalculated every time the page is served. SSI is a great way to add small pieces of information, such as the current time. But if a majority of your page is being generated at the time that it is served, you need to look for some other solution. [1] Last time I checked, SSI, either on httpd or IIS, doesn't have any means to do dynamically, including generating headers, as you intended. Regards, Tommy My question is: Why SSI? I used SSI circa 1990's (before PHP) to include common code. However, it required me to also have .shtml suffixes on the files that used them. Since PHP, it's simple to use PHP include statements to accomplish the same thing. So, I see no reason to use SSI's at all. What am I not understanding in this problem? Cheers, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server Side Include translator as PHP functions
Tedd, The crucial detail you're lookign for is my lack of choice or control in the matter, for all sorts of reasons that are actually quite stupid but not possible for *me* to change, and not possible for anyone else to change quickly. Thus I am looking for a solution to the problem at hand, instead of a suggestion for what the entire org should be doing instead. I know what they should be doing instead, but that's not my decision. It's not like I'm building a new website this way; I'm trying to move forwards with an existing and large website. The more different code-bases we have for different parts of the site, the harder it will be to actually change to something else (PHP-based, I pray). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server Side Include translator as PHP functions
On Sat, Oct 8, 2011 at 8:48 PM, Tommy Pham tommy...@gmail.com wrote: On Sat, Oct 8, 2011 at 5:33 PM, Complex complex.confus...@gmail.com wrote: Thanks for the advice, I'm aware of all that, but I'm looking for a specific PHP solution at the moment. Unless you have advice on how I can update the SSI includes on the larger website *without* having to also update the PHP includes for this smaller website? I take it that you don't know of such a function; do you have a recommendation for a good function or program repository I could search? The couple that I was looking at (such as http://php.resourceindex.com/) don't look like they've received a whole lot of attention lately, and may not be the best sources. Did you look at my suggestion as work around such as replacing the SSI mechanism for a particular path/URL with PHP? Use of 'Conditional expressions' [1] maybe necessary which is beyond the scope of this list. What are SSI? SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program, or other dynamic technology. The decision of when to use SSI, and when to have your page entirely generated by some program, is usually a matter of how much of the page is static, and how much needs to be recalculated every time the page is served. SSI is a great way to add small pieces of information, such as the current time. But if a majority of your page is being generated at the time that it is served, you need to look for some other solution. [1] Last time I checked, SSI, either on httpd or IIS, doesn't have any means to do dynamically, including generating headers, as you intended. Regards, Tommy [1] http://httpd.apache.org/docs/current/howto/ssi.html Tommy, Yes, thanks, I did see that: change !--#include virtual=/includes/old/file/B.inc -- to !--#include virtual=/path/to/php/code2exec.php -- !--#include virtual=/path/to/php/code2exec.php -- does not work on our servers. (I hesitate to say that it doesn't work anywhere; I don't have enough experience with that.) What happened when I tried this is that the page displays the raw PHP instead of the results of the PHP. The server executes the PHP first, and then executes the SSI instructions, such that the following *does* work. ?php include('/path/to/php/code2exec.php'); ? (mind you, I've seen plenty of notes that you should/have to use virtual() instead) Regarding SSI not doing anything dynamic: Yes, that's mostly true. The only dynamism you can get is using if/elsif/else statements while checkign things like the current URL path, which are ridiculously clunky. So the point of this question was to find an *existing and tested* non-module set of functions that I could employ to translate a particular include into a set of PHP commands, and then use PHP to add some dynamic content. And do you see my main point here, please? I'd use PHP to add some dynamic content WITHOUT CHANGING THE MAIN CODEBASE that is unfortunately but definitely stuck in SSI. I'll probably have to skip that idea, but I'll try to look elsewhere for such a set of functions. I'd like to write them in the future, but that's not going to happen within the next couple days. And if anyone is still scraping their brow at the absolute HORROR that we are using SSI instead of the PHP that we should be using, please note that the whole point of keeping the codebase the same everywhere is to move everything into a new, modern codebase *real soon*. -- -- CC --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: files outside of documentRoot
On Sun, Oct 9, 2011 at 9:52 AM, Ricardo Martinez harisel...@gmail.comwrote: The files are, png, pdf and flv. Only users login can see or download it. thx ; On Sat, Oct 8, 2011 at 11:16 PM, Shawn McKenzie nos...@mckenzies.net wrote: On 10/08/2011 03:40 PM, Ricardo Martinez wrote: Hi List! I need to access files outside the DocumentRoot. I've been looking for info and documentation, and I've read that it can be done using symbolic links and another way is by using headers. I want to know, what do you think, what is the best way, and if anyone knows a good doc about of it. Thanks!!! It depends on what you mean by files. Are they PHP files that need to be run, or images, or files that need to be downloaded by the user? For PHP, you would add the external dir to your include path. For images you can use a php file as the img src and that file sets the appropriate headers and uses readfile() to get and echo the image data: getimage.php?image=someimage.gif For download files you would do it in the same manner as for images: download.php?file=somefile.zip -- Thanks! -Shawn http://www.spidean.com -- Ricardo ___ IT Architect website: http://www.pulsarinara.com Sounds like the downloader php script would be perfect (what Shawn suggested). Have the script check the login status, then (if valid) send the proper headers for the file and read out the data with the script. -- --Zootboy Sent from my PC.
Re: [PHP] Server Side Include translator as PHP functions
On Oct 9, 2011, at 11:41 AM, Complex wrote: Tedd, The crucial detail you're lookign for is my lack of choice or control in the matter, for all sorts of reasons that are actually quite stupid but not possible for *me* to change, and not possible for anyone else to change quickly. Thus I am looking for a solution to the problem at hand, instead of a suggestion for what the entire org should be doing instead. I know what they should be doing instead, but that's not my decision. It's not like I'm building a new website this way; I'm trying to move forwards with an existing and large website. The more different code-bases we have for different parts of the site, the harder it will be to actually change to something else (PHP-based, I pray). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Without debating the question of choice, if I was confronted with a large web site that used SSI, I would inform the client of such and put together a bid as to my time to bring the site up to date. If not, then I think I would pass on working the site. In my experience, it's not worth my additional time to try to work around out of date technologies. It is also been my experience that when I am confronted with something large scale, and when approved by the client, I simply do a site-wide find and replace (namely change !--#include to ?php include) and then evaluate all occurrences prior to changing. That usually gives me a good idea of the breath of the problem. In addition, considering the !--#include has basically the same purpose as ?php include, while it may be a wide-spread problem, I do not see it as a serious problem to address. Certainly, when including files that have a different suffix .shtml as compared to .php you will find that the Server will treat them differently but that's pretty easy to fix -- just change the files suffix or possibility write code in a .httacess file that would cause the interpreter to consider shtml files the same a php. Of course, I may not fully understand the problem. Good luck, tedd _ t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server Side Include translator as PHP functions
On Sun, Oct 9, 2011 at 8:41 AM, Complex complex.confus...@gmail.com wrote: Tedd, The crucial detail you're lookign for is my lack of choice or control in the matter, for all sorts of reasons that are actually quite stupid but not possible for *me* to change, and not possible for anyone else to change quickly. Thus I am looking for a solution to the problem at hand, instead of a suggestion for what the entire org should be doing instead. I know what they should be doing instead, but that's not my decision. It's not like I'm building a new website this way; I'm trying to move forwards with an existing and large website. The more different code-bases we have for different parts of the site, the harder it will be to actually change to something else (PHP-based, I pray). At the time when I was working with ASP and SSI, I suggested my client to better rewrite the application in OOP language then do patchworks. But he _insisted_ on keeping existing code base. So I did patchworks here and there. It got to the point where he finally wanted some additional features much later that it was impossible to do with ASP and SSI. It was then that he finally decided to go with my suggestions, which is months later. During that time, I could have easily rewritten the application in PHP. That's why I suggested you to consider the site's function and features. It maybe just one thing that the client/boss wants now, then another, and another... etc... Eventually, you're going to through the same thing I did. Good luck, Tommy
[PHP] Re: PHP Download Of Application Question?
I am looking for a way to download a C based application binary, from an Apache / PHP server, via a client side Web Browser, and execute it seamlessly on the client side PC without storing it permanently on the client side hard disk drive. Temporary storage would be ok. I know this can be done because I have observed it operation in various applications. This concept allows a authorized customer to have the use of an application via the web without being able to keep or share the application binary. I am open to other approaches beyond Apache and PHP. So any ideas out there? Thanks for the help Thomas Dineen That sounds like the kind of thing Java Web Start does. There's lots on Google about it. http://download.oracle.com/javase/6/docs/technotes/guides/javaws/ -Alex
[PHP] Need help Wth PHP
I have a hosting account and am trying to get a friend's website up and running. We downloaded his existing site from his current host and uploaded it to my host. It is currently under a subdomain, www.egypt.aragren.com http://www.egypt.aragren.com/ . When I go there, I get an error message that says, Error establishing a database connection. What causes this and how can I fix it? Sensei Rod Lindgren Sent from my Gateway computer
Re: [PHP] Need help Wth PHP
On 10/09/2011 08:41 PM, Rod Lindgren wrote: I have a hosting account and am trying to get a friend's website up and running. We downloaded his existing site from his current host and uploaded it to my host. It is currently under a subdomain, www.egypt.aragren.com http://www.egypt.aragren.com/ . When I go there, I get an error message that says, Error establishing a database connection. What causes this and how can I fix it? Sensei Rod Lindgren Sent from my Gateway computer This issue isn't related to PHP but the cause of the error is due to the scripts' inability to make a connection to the database. The error looks like it's coming from WordPress, I could be wrong but if that's the case then you need to update the wp-config.php file to reflect the proper credentials to log into the database. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Need help Wth PHP
Interesting. The wp-config.php file only contains the following: html head meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /head body br /body /html Not sure where to go from here. Thanks for the input. Any more input is appreciated. Rod -Original Message- From: James Yerge [mailto:ja...@nixsecurity.org] Sent: Sunday, October 09, 2011 5:46 PM To: r...@okinawa-te.info Cc: php-general@lists.php.net Subject: Re: [PHP] Need help Wth PHP On 10/09/2011 08:41 PM, Rod Lindgren wrote: I have a hosting account and am trying to get a friend's website up and running. We downloaded his existing site from his current host and uploaded it to my host. It is currently under a subdomain, www.egypt.aragren.com http://www.egypt.aragren.com/ . When I go there, I get an error message that says, Error establishing a database connection. What causes this and how can I fix it? Sensei Rod Lindgren Sent from my Gateway computer This issue isn't related to PHP but the cause of the error is due to the scripts' inability to make a connection to the database. The error looks like it's coming from WordPress, I could be wrong but if that's the case then you need to update the wp-config.php file to reflect the proper credentials to log into the database. - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1410 / Virus Database: 1520/3943 - Release Date: 10/07/11 - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1410 / Virus Database: 1520/3943 - Release Date: 10/07/11 - No virus found in this message. Checked by AVG - www.avg.com Version: 10.0.1410 / Virus Database: 1520/3943 - Release Date: 10/07/11 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php