html5 offline caching with php driven sites - php

I have a simple php driven website running and I'm trying to figure out how it treats php pages. Some of my php documents are routing logic and some just includes for individual pages. How do i go about making this work offline?
What I though was that I'd have to re-create the routing logic in javascript. Is that my only option? In that case, is it even possible to have the site be driven by php while online and switch to JS offline? I can't make sense of it.

If your site is fairly static, HTML5's cache manifest may get you most of the way there. Have PHP output a cache.manifest file in the correct format with all your routing system's URLs and those URLs will be stored locally in a compliant browser. Attempting to access them will pull them out of the cache if possible.
If you're looking for something more dynamic, though, you're going to have to do more legwork.
Here's some good info on offline caching.

It is important to remember that PHP is processed on the server. The result of your PHP code is all that is sent to your browser. Your browser has absolutely no knowledge that PHP was even used to make the page!
If you have some dynamic code that must run offline, then you must use Javascript. If this is just for testing on your own machine, put a web server running PHP on your dev machine and acccess it via http://localhost.

HTML5 offline caching does not work to make your pages interact; it works only to make a particular page available offline. Basically, it works on a URL-by-URL basis. If you absolutely need offline functionality, you will be forced to make it work in JS.
Also, make sure your manifest includes all resources used by all pages.
Hope this helps!

It seems obvious not to use any server side scripting language file while caching it in your browser. PHP/JSP/ASP etc all are server side language we cant fulfill the request forwarded by client that need to be generated dynamically and most importantly there is no server running on client side. SO , i think we should go for JS whenever we want to do such things.

Related

GUI That Runs PHP Files

I have created a html page which sends custom data to a php file which then processes and evaluates it.
My next task is to make this into a GUI with the requirements:
1. A box for a custom search with button (it then posts this into the
php)
2. A box where xml/json request can be seen
3. A box where the xml/json response can be seen
4. A box where the parsed version is translated and made to look pretty.
***MUST CONNECT TO INTERNET, PHP ESTABLISHES CONNECTION BUT DO NOT WANT A GUI ISSUE
Any suggestions on programs or languages etc which can help me communicate with PHP in GUI form. It needs to be able to access the internet!
I was thinking perhaps Visual Basic as that's the only one I've ever used that really uses GUI's but I'm wondering what you all think!
Thanks!
Basically, what you're asking for is a web browser, with a very simple little HTML/Javascript front-end web page to make the PHP calls and display the results. I'm not entirely sure what it is about a browser environment that makes you think it's unsuitable, but it's basically exactly what you're asking for.
If a full-blown web browser really isn't suitable, you could try using a web browser control inside a simple GUI app. This would still work exactly the same, but would be without the browser controls, such as the URL bar.
Just use a browser.
If you don't want to do that -- build a browser.
If you are just looking for basically a web-based REST testing tool, try the Firefox RESTClient plug-in.
Why don't you use a framework ?
You may take a look here:
AppJS for Linux, Windows and Mac using HTML, CSS and Javascript
Adobe AIR : cross-platform using ActionScript/FLEX or HTML/Javascript
Titanium : HTML/CSS (no support anymore)
PhoneGap : mainly used for cross-phone-platform, but here's an Windows implementation of it (you should read the README.md ...)
You may also check this from Mozilla

jsp + php + asp.net + python in one site?

I have a question: can I mix jsp, php, asp.net and python in one site?
For example:
www.mysite.com/customer.html <-- this page is written by jsp
www.mysite.com/mycart.html <-- this page is written by php
www.mysite.com/login.html <-- this page is written by asp.net
www.mysite.com/admin.html <-- this page is written by python
I use ".html" as I don't want other know what technology I am using.
I am facing some problems:
What web server can hold all these technologies?
How can they share session?
Or just simply tell me this is impossible...
Thanks
You cannot share a session unless there is one module (for apache or something) that encompasses all of these technologies properly.
If this doesn't bother you, then, just configure your webserver to handle all of the file endings and such.
Speaking from my experience, I suppose all web servers supports these languages. You just have to install their parsers/modules and configure your web server to use them. You'd have to give your pages different suffixes though, so that your web server will know what to do with the files.
www.mysite.com/customer.jsp
www.mysite.com/mycart.php
www.mysite.com/login.aspx
www.mysite.com/admin.py
You can always generate a random key like a234feg321de32 for the session, store it into your db for each user, and send it in the GET or POST variables, then check it with a select query. This would work even if you pushed your test further and switched from one server to another.
I like your idea. With nginx you can easily redirect requests to the different applications in whatever way you prefer. When it comes to session sharing (and all kinds of data sharing) the easiest and safest way would be to communicate via a database. Problem is, you would have to implement your own session management solution in all different systems.

How to create a web page which seamlessly hosts a script on another webserver?

I have written a DNS security testing tool in PHP which relies on the webserver having BIND installed locally. I need to add this tool to our existing website however it's against policy to have BIND on the main web server. I have been allocated a new server if I need it and I'm trying to find the best solution to make this tool appear to be part of the main website (i.e. under the same domain e.g. domain.com/tool)
My first thought was to make a page on the main web server and host the tool within an iframe. This way, the tool can fit seamlessly into the existing site without having to recreate and maintain the sites themes and templates on the second server (header, footer etc). However, the script relies on being able to do a meta refresh redirect to a 2nd script which displays the results (the redirect is required to give time for the security tool to run). Im not sure if this can be done all within an iFrame. Any suggestions or methods that might be better than using an iframe?
Just as an idea: Your tool could generate a JSON response, and then you could use padded JSON to get it. With a little bit of work, you could do all the things you want using XMLHTTPRequests.

How can I cache my dynamic iPhone webapp for working offline?

I am having an iPhone web app written in PHP and using the WebApp.Net framework. I would like to make this application work offline as well. As I understood I can not use the manifest tag of HTML5 because my files are PHP and not html. Or at least it didn't work with it and I don't know if I am in the right direction.
Does anyone have any idea for how can I do it?
Thanks
You can cache any static file, no matter how it is generated. You must cache via manifest all your html, javascript and css (and graphics also, if they are small). Use LocalStorage to store JSON requests needed in offline mode. Use online mode to synchronize data you work on into LocalStorage.
You haven't stated what is your application for and what should be done in offline mode, but generally the only way I see as for now is to fully AJAXise all functionality that will work in offline.
You can browse StackOverflow for tags html5+javascript for general discrussions, or html+javascript+mobile for more specific.

Easiest way to execute local file from Firefox?

I am developing a web application.
I would like to extend my error messages (and their backtraces) so that I can click on the mentioned file, and have it opened automatically in my PHP IDE.
I would like to make this a easy-to-activate feature so that whoever works on the web application, can easily map the error message to point to their local copy of the site, and open their IDE.
What - short of developing a custom FF extension - is the simplest way you can think of to execute a local command (a batch file that calls the IDE) on click in Firefox on Windows(7)?
I have looked for extensions but had no luck. Maybe using another extension like Firebug or Greasemonkey?
Security is not an issue, as this is supposed to work on the developer's workstation only and I can change my local Firefox's settings.
You can add a new protocol (like "edit://") to windows (http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx) and write a small handler program that picks a filename from the "edit://" url and passes that file to the editor. This way i taught windows to understand txmt links (http://blog.macromates.com/2007/the-textmate-url-scheme/) in the way my mac does.
There's not a way to do this with javascript. But it looks possible with a firefox addon. Have a look at this.
http://mozex.mozdev.org/
MozEX is an extension which allows the user to use external programs for these actions:
* edit content of textareas (possibly utilizing a spell-checker, color syntax etc.)
* view page source
* handle mailto, news, telnet and FTP links
* download files
* ... and many more :)
The universal handler lets you enter a list of protocol schemes, e.g., "abc://,def://" and a
command to handle them. So you just have your application generate a url that begins with
your chosen (made up) protocol, and mozex will intercept a click on the url and send the
url to your chosen command as a paramater.
I think this is exactly what you want.
I think that the closest you can get to this, is by having the configuration of the web browser associate a particular mime type with a given "helper application" (here the IDE program), and to have the HTTP server return such a file.
Otherwise, security concerns dictate that browser would not run any "abritrary" program/logic on the client.
Pekka,
After reading the thread so far, it seems that you want to build an application that somehow authenticates with the server--i.e.: the "average user" wouldn't have access to it. If this were the case, then delivering it through the browser is an impossibility without writing a custom extension.
Running authentication through GreaseMonkey is difficult, but once the client is authenticated, there is no real way to "run" the trace.
If the server generates a batch file or some kind of instruction set (script, shortcut, etc.), you can simply configure the browser (or have the local instance of your app configure the browser) to run the file. The problem here is that you have no way to automatically authenticate!
The only other way I can imagine that you could get this to work is via a Java applet, which would only be cumbersome and require Java to initialize every time you wanted to import a trace.
The problem you have is that the browser is inherently secure. It's designed to protect the computer from malware, rogue websites, etc etc., and so without developing a custom extension for the browser, there's no way to make the hop to any applications that run in tandem with the browser.
So on that note, I'll suggest that you reconsider writing a Firefox XUL extension as mentioned above. You'll probably need to implement some XPCOM code to make it work, too. Here are some resources that will help get you started:
https://developer.mozilla.org/en/xpcom
https://developer.mozilla.org/En/XUL
http://ted.mielczarek.org/code/mozilla/extensiondev/
https://developer.mozilla.org/en/XUL_Tutorial/Introduction
I don't know which IDE you're using, but in for example Eclipse you can also use the built-in webbrowser to test your webapp and the exceptions/traces in the Eclipse console log already have links to the source code in question. Easy as that. See if your IDE provides something similar.

Categories