[PHP] Server Side Include translator as PHP functions
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 <--- -- 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:36 AM, Complex 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
Re: [PHP] Server Side Include translator as PHP functions
On Sat, Oct 8, 2011 at 8:36 AM, Complex 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
Re: [PHP] Server Side Include translator as PHP functions
My apologies I was multitasking some heavy applications/tests and had a huge spike in CPUs utilization and I accidentally clicked on send x2.
[PHP] files outside of documentRoot
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!!! -- Ricardo ___ IT Architect website: http://www.pulsarinara.com
[PHP] Re: files outside of documentRoot
"Access files" for use in the running script? Or "access files" meaning executing a script? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: files outside of documentRoot
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 -- 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 1:09 PM, Tommy Pham wrote: > 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 > Tommy, Last question first: yes, using SSI limits the full potential of the PHP being used, but the point of this exercise is to continue using the existing SSI includes for this small subsection of the larger website, and to not recode the larger whole to benefit the smaller piece. Make whatever Star Trekism of that you will; we simply don't have time or resources to use PHP everywhere as we should. I do not understand your question about criteria; the only criteria for these Apache Server Side Includes is the relative (or relative-to-root) filepath: If you mean, which server variables am I accessing with SSI and now need to access with PHP, I'm primarily concerned with the current filepath. "SSI include file B" is, in this case, the contents of an HTML webpage's HEAD block. The PHP-based CMS can fill the HEAD with some useful info unique to the current page. If I can achieve the _actual problem_ of translating the SSI commands into PHP, it would be a simple matter for me to insert some additional material into the middle of the original. The only reason I even mention this simple problem is because it explains why I"m bothering to do this at all. If all I wanted was to get the unaltered output of the SSI includes, I'd just continue doing and be on my way. All I want to know is if someone has already written a set of functions to translate some if not all SSI commands into PHP. e.g. becomes becomes . Otherwise, I have to write those functions myself and, inevitably, spend time I don't have getting it right. I've searched, but I may easily have missed or not recognized the functions that I need. -- --> CC <--- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Download Of Application Question?
Gentle People: 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 -- 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 2:31 PM, Complex wrote: > On Sat, Oct 8, 2011 at 1:09 PM, Tommy Pham wrote: > > > 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 > > > > Tommy, > Last question first: yes, using SSI limits the full potential of the > PHP being used, but the point of this exercise is to continue using > the existing SSI includes for this small subsection of the larger > website, and to not recode the larger whole to benefit the smaller > piece. Make whatever Star Trekism of that you will; we simply don't > have time or resources to use PHP everywhere as we should. > > Then you should seriously consider the site's function and features and see if the current application fits that model. Doing little patchwork here and there may end up costing a lot more time and resources than just rewriting the application in PHP, IMO, not to mention losing customer/clients because of buggy application due to patchworks. I'm sure some experienced folks here have been through that at some point, myself included - which is why I stop using ASP and SSI and moved on to OOP over 10 years ago. I do not understand your question about criteria; the only criteria > for these Apache Server Side Includes is the relative (or > relative-to-root) filepath: > > If you mean, which server variables am I accessing with SSI and now > need to access with PHP, I'm primarily concerned with the current > filepath. > > "SSI include file B" is, in this case, the contents of an HTML > webpage's HEAD block. The PHP-based CMS can fill the HEAD with some > useful info unique to the current page. If I can achieve the _actual > problem_ of translating the SSI commands into PHP, it would be a > simple matter for me to insert some additional material into the > middle of the original. The only reason I even mention this simple > problem is because it explains why I"m bothering to do this at all. If > all I wanted was to get the unaltered output of the SSI includes, I'd > just continue doing > and be on my way. > > All I want to know is if someone has already written a set of > functions to translate some if not all SSI commands into PHP. > e.g. > becomes >becomes foo = "bar"; ?> > . > > Otherwise, I have to write those functions myself and, inevitably, > spend time I don't have getting it right. I've searched, but I may > easily have missed or not recognized the functions that I need. > > > -- > --> CC <--- > * Case 1 of always include and always replace (and not modifying headers): change to * Anything else, if I'm reading it correctly: Incoming request -> static HTML file -> SSI mechanism (included some files) change the above flow to (there by passing SSI mechanism) Incoming request -> PHP file index.php (include some files, execute PHP scripts as needed and change the httpd configurations accordingly) or Incoming request -> SSI mechanism (included some files) change the above flow to (there by passing SSI mechanism) or just remove the SSI mechanism altogether and have a index.php file doing all the work and thus reducing the complex configuration and application flow, and server overhead. (Migrating the SSI configurations in httpd to PHP codes shouldn't take that long unless you're new to PHP.) --- the file handlingRequests.php or index.php would look something akin to below.
Re: [PHP] Server Side Include translator as PHP functions
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. -- 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
Oh, and on our servers you can't call PHP commands from SSI includes. I'm not certain if that's true from all servers, but it's certainly the case that on some servers the PHP runs first and then the server side commands. So doesn't work. Gods I wish it did, then I'd simply have rewritten the structural parts of my site in PHP years ago, and been able to use that from my many legacy SHTML files. And thanks for going to all that trouble, Tommy, but I'm looking for existing functions -- to avoid trying to use something just written and then debugging. -- 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 5:33 PM, Complex 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
Re: [PHP] PHP Download Of Application Question?
On Sat, Oct 8, 2011 at 6:53 PM, Thomas Dineen wrote: > Gentle People: > >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 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Well, you seem to want to enter the world of DRM. That's an odd subject for a PHP list, but here goes. PHP is a server-side language. In fact, for your circumstances, PHP would be of little use. All you need is a web server to serve the file. Unfortunately, there is no real way for a webserver to tell a client how to handle the file it sends. All it does is pipe data over the wire. What you want would have to be a function of the browser/downloader and AFAIK, no browsers support anything like that. Plus, if you're sending someone an EXE file, there's very little you can do to stop them from keeping a copy of it. You would have to implement some sort of authorization system within the C code to only allow access to the users you want (or whatever other arbitrary restrictions you wish to impose). This question would be much better suited for a C mailing list. Again, PHP == server side. It has NO control over anything client-side. -- --Zootboy Sent from my PC.