MOBILE enable websites - php

I have couple of websites on php. I want to mobile enable them so they can be seen from a smart phone or iphone. Is there any quick conversion tools for these.
I tried the steps in this site and got a 500 exception from hostgator.
http://www.mikeindustries.com/blog/archive/2005/07/make-your-site-mobile-friendly
I am looking for some rad techniques. my sites are not complex.
for eg. yndc.tradepeacefully.com

From hostgator support :
http://support.hostgator.com/articles/hosting-guide/hardware-software/is-php-running-as-apache-or-cgi
Now check the notes on the link you posted, especially note 3 :
In order to use auto prepending and
auto appending, you must be running
PHP as a standard Apache module and
not “as cgi”. If need be, you can run
PHP as Apache sometimes and CGI other
times by using your .htaccess file to
specify rules.
So this approach won't work on Hostgator (unless you're on dedicated hosting, see the support page), since they're running PHP as CGI...

To mobile-enable your site, you just need two things:
Detect the browser's user agent.
Forward to a mobile version of the site.
You should be able to find a htaccess file on Google that will accomplish the #1. The hard part is going to be coming up with a new layout for your site that is mobile-friendly.
That part will be mostly written from scratch.

You get the 500 error probably because your hosting provider does not support the php_value in .htaccess files.

Related

Is it possible to write PHP in an ASP.NET page [duplicate]

A portion of our site is done in PHP and a portion of our site is done in ASP.Net. We just set up a new web server with Windows Server 2008 R2 which has IIS 7.5 installed.
I understand that IIS 7+ supports PHP, but can PHP and ASP.Net run side-by-side within a single web site in IIS, or would I have to set up one web site for the PHP pages and one web site for the ASP.Net pages?
You should be able to run both in the same site, but be sure that the AppPool for the site runs a "classic" ASP.NET pool configuration. The default AppPool routes everything through ASP.NET, and you won't want that for your PHP pages.
Other than that, you should be fine. Query strings, files, and back-end databases will be the best way to share data between pages.
Yes you can use both under the same website. Since the file extensions are mapped to specific external processes, they are called independently. You can even use Asp.Net to secure .php files with FormsAuthentication by implementing wildcard mappings within IIS (I know 6/7 have this, not sure about 5). Mixing data across them is tricky because they will have separate external processes and thus separate sessions. Most cookies will be readable across both, but secured cookies will not be.
Yes you can, but watch out for this:
If you have a wordpress on your "root", and asp.net apps in folders under it
(e.g. http://root.com/aspnetapp1/),
and if you follow these suggestions about "urlrewrite" for permalinks in wordpress, you can have trouble if you try to configure "wildcard handlers" in the apsnetapp1.
To avoid issues, the web.config of the wordpress root app must also have that setting:
<location path="." inheritInChildApplications="false">
<system.webServer>
...
</system.webServer>
</location>
Or else, your wildcard handler will never raise because index.php from root will catch all your requests to url like: http://root.com/aspnetapp1/api/*
Yes, it will be not a problem. Even some Windows Shared Hosts offer PHP plans - Windows Hosting PHP.
Yes, PHP can be seamlessly implemented into ASP.NET 3.5 / 4.0
Go to http://phalanger.codeplex.com/ (or http://www.php-compiler.net/) and download the latest version of Phalanger. Install into Visual Studio and voila!
Phalanger – the PHP compiler for .NET
Welcome to Phalanger – full-featured PHP runtime & compiler for
.NET/Mono frameworks. Phalanger is modern open-source implementation
of PHP, compatible with the vast array of existing PHP code. In
addition Phalanger gives PHP-application developers lot of new
possibilities; from improving performance and using modern
environments, to taking advantage of seamless unique .NET integration.
ASP and PHP can be used on windows boxes. As long as they're completely separate and aren't dependent on each other. For example, using query strings (i.e file.php?var=1&var2=bla) things get messy when you need to transfer those variables over to the ASP file or vice versa.
So as long as the 2 systems are totally independent of each other, then it should work fine.
You may also find some incompatibility with cookies and sessions. Those too can be passed but not easily.
ASP.NET and PHP Support
Develop, deploy and easily manage Web applications using your choice
of languages. From ASP.NET to PHP, IIS7 provides a powerful and
flexible Web server environment for the world’s most popular Web
applications.
(Source: http://www.iis.net/overview/choice/aspnetandphpsupport )
I tried put a test.php file (with conent: <?php phpinfo(); ?> ) to existing ASP.NET website (use real server at https://somee.com ). I knew that ASP.NET and PHP have worked together.
Read more:
http://www.w3schools.com/aspnet/webpages_php.asp
https://technet.microsoft.com/en-us/library/hh994592.aspx
You can run both on the same site, but won't be able to talk to each other unless you setup some sort of messaging system or share storage.They are basically applications of complete different nature.
Another possibility is to call your .NET code from PHP:
A piece of code written in C# like this:
string javascript = "";
Microsoft.Ajax.Utilities.Minifier m = new Microsoft.Ajax.Utilities.Minifier();
Microsoft.Ajax.Utilities.CodeSettings settings = new Microsoft.Ajax.Utilities.CodeSettings();
settings.OutputMode = Microsoft.Ajax.Utilities.OutputMode.SingleLine;
settings.PreserveFunctionNames = false;
string minified = m.MinifyJavaScript(javascript, settings);
Will look like this on PHP:
$minifier = netMinifier::Minifier_Constructor();
$settings = netCodeSettings::CodeSettings_Constructor();
$csssettings = \ms\Microsoft\Ajax\Utilities\netCssSettings::CssSettings_Constructor();
$settings->OutputMode(\ms\Microsoft\Ajax\Utilities\netOutputMode::SingleLine());
$settings->PreserveFunctionNames(FALSE);
$settings->QuoteObjectLiteralProperties(TRUE);
$result = $minifier->MinifyStyleSheet($css, $csssettings, $settings)->Val();
From:
http://www.drupalonwindows.com/en/blog/calling-net-framework-and-net-assemblies-php

Drupal site setting `Content-Type` to `application/x-gzip` all the time

I am in the process of migrating an existing Drupal website from another provider to Bluehost.com -- while I think using Bluehost.com is not relevant in this context I thought I'd mention it anyway, in case there are indeed some particularities I'm not aware of.
The site is a Drupal 6 installation and it did work previously I am told on bluehost too so you think it shouldn't be any problems, however, having copied it over I encounter a big problem: all the responses from Drupal are sent with Content-Encoding set to application/x-gzip. This has the implication of all browser presenting a download dialog box rather than rendering the content.
I have actually curl'd the index page and ran it through gunzip and the output is the correct HTML for the site -- just that it somehow ends up being gzip'd and this mangles the content type and confuses the browsers.
Talking to previous maintainers of the site they suggested using PHP 5.4 (they were running it on php 5.5 as I understand and despite all the Drupal suggestions it was running perfectly well I'm told).
I am trying to eliminate now any type of gzip'ing that occurs here so I've got it down to a few layers which could cause it but eliminating those it still doesn't work:
SetEnv no-gzip 1 in .htaccess
zlib.output_compression = Off in php.ini
drupal had the boost module installed and some corresponding settings in .htaccess -- i've removed those from the .htaccess file as well as deleting the boost directory from sites/all/modules
The problem still stands and my files are being sent to the browser compressed. Is there any other way to disable this?
Note that this only happens for pages inside Drupal, having uploaded a simple php page and navigate to that url works fine -- which suggests therefore a drupal (rather than apache/php) problem.
I've noticed a module mimedetect which has a definition for application/x-gzip in there but not sure how could this affect it as removing this didn't render anything useful either.
Any ideas where to look and/or what might cause it?
Happy to provide any other insights that might be useful in diagnosing this.
Ok so having actually reset the database cache and with the settings above this now works. I'm trying to figure out which one of the above actually solved it.

How to create https-connections?

I have NOT done much of web-developing and I would like to learn about it: how you can create https-connections. I am currently using apache with mysql/php as software development tools.
Are the connections/ports to be used always configured from the server or do you need some scripts for it in php? and do you need to do anything else in MySQL except enable: have_ssl ?
The tutorials that I have managed to find were a bit confusing about everything and not very thorough, So I was hoping that someone here might be so kind and explain the stuff briefly or maybe give me a link to some good tutorial.
If somebody could give me a link to some "easy to read" tutorial or briefly explain how the system works.
Thank you!
You should use Apache-SSL , OR mod_ssl with-in Apache Sever
I suggest to use mod_ssl
if your are new to developing php/mysql try to use XAMPP of WAMP instead of installing apache and configuring mod_ssl manually you can easily active mod_ssl in both of them if you want to do it manually
http://tud.at/programm/apache-ssl-win32-howto.php3
if you want redirect a certain path to use https instead of http ,
for example
http ://yoursite.com/secure/ to https ://yoursite.com/secure/
Modify htaccess file and add this
RewriteRule "^(/secure/.*)" "https://%{HTTP_HOST}$1" [R=301,L]
SSL would be entirely handled by the webserver. The only thing you might do with PHP is make sure that your application is being accessed in SSL by checking if $_SERVER['HTTPS'] is set.
SSL connections to MySQL are generally not needed in a secure environment. It will add overhead to your connections that you may want to avoid.
Search for "How to configure SSL in Apache" and you will find quite a few tutorials on the subject.

Is is possible to run Coldfusion & PHP on the same server and website?

I would like to be able to port some new site pages over to PHP using the same db as in the coldfusion site. Is it possible to have PHP run pages in say other directory and go back and forth ?
Many thanks for your reply.
Terry
As others have said, yes, it is possible. Your configuration doesn't really matter, (unless you're looking for help getting it setup), because it can be done on any modern webserver (Apache, IIS, etc).
Something to think about, though, is the default document. If your web application uses urls like:
http://example.com/myApp/ (no index.cfm or index.php in the url)
Then you need to be aware of the explicit order of default documents. If you have both an index.php and an index.cfm template in the same directory, which will execute?
If your default document list is (a variation of):
index.cfm index.php default.aspx index.html
Then the ColdFusion page will be the one to execute. On the other hand, if the default document list is (a variation of):
index.php index.cfm default.aspx index.html
Then the PHP page will be the one to execute.
Yes, this is possible, I have this available on my production web server (RedHat but it shouldn't matter). If you're looking for details on configuration I couldn't help you though, I had my host set it up. I wouldn't imagine a standard install of both would conflict, just set up the proper handling for each file extension and you should be good to go, keeping them in separate directories or mixing them in one.
It is possible as long as you are running the same web server (i.e. IIS or Apache) for both ColdFusion and PHP. If you let us know what your environment is, people may be able to further assist you - but the answer to your question is yes.
Yes,
It's technically no different to Windows servers which have both PHP and .Net installed, or a Linux server with Perl and PHP.
Speaking generally, after installing the languages you're using you set up your web server to handle files of different extensions. This is done differently depending on whether you're using IIS or Apache, but you effectively say .php files should be handled by the PHP interpreter and .cfm files handled by the Coldfusion interpreter.
As others have said, its entirely possible and not hard to setup. Just watch out for Default Document as Adam Tuttle said.
I will take it a step further: you even run CF and PHP in the same application server!
Use Cauchos Resin for CF and its Quercus support for PHP:
http://quercus.caucho.com/
Of course, if your PHP app is non-trivial and/or relies on some custom extensions or extensions that Quercus doesnt support than your SOL. But might be interesting to check out.

Making a distribultable standalone program in PHP

I've decided to code some applications in PHP that are supposed to run offline in the user's machine. However, I can't seem to find an user-friendly install wizard to create a local server in where the script will run. Any ideas?
PS: Here's an example of what I want: http://www.nolapro.com
You could go to the old school route and try using PHP-GTK.
Text Tutorial here: http://www.kksou.com/php-gtk2/References/Compiling-standalone-PHP-GTK2-applications-on-windows-using-PriadoBlender.php
or you could go the route that I believe has much more promise: Adobe AIR + PHP
It has the added bonus of running on any platform!
Video tutorials here: http://www.vtc.com/products/Adobe-AIR-PHP-Development-Tutorials.htm
There's also a new player in the game, Appcelerator. It lets you write your code in whatever language you want (PHP, Ruby, Python, etc) and compile it for the platform of choice (iPhone, Android, Windows, OSX). Parts of it are still beta, but it looks unbelievably slick & cool, and there are lots of tutorial videos. http://www.appcelerator.com
I hate to advocate this, because it just feels so wrong. You would probably be better off using a language inteded for use for stand-alone applications, if you're going to be doing this often or in a production setting.
With that said, a colleague of mine used to use the Bambalam PHP to EXE Compiler for this. He actually had a profitable product built around it.
Bambalam will generate an EXE that doesn't rely on any external DLLs, based on your PHP code.
http://www.bambalam.se/bamcompile/
If you have a webapp written, you maybe want to deploy on client, a possible way is use wapache, which is a standalone apache bundled with your application, and an integrated (IE) browser control inside.
http://wapache.sourceforge.net/
A new feature of PHP 5.4 & 6 can help you, the builtin web-server.
http://php.net/manual/en/features.commandline.webserver.php
With this feature you can host locally your php app without external webserver, and access on localhost.
If you really talking about a client application you are really wrong to do this.
If you want to wrap a server + browser to deploy your web based application so it runs local you might check out three options:
1) Deploy a simple webkit browser (you can get a QT Webkit Browser in 30 lines of code) and an apache server that is installed somewhere standalone (not via the apache control script as this uses port 80 and i probably conflicts with another installed webserver.
2) Look at the Firefox PRISMA solution. I have read about this only in a news article but it wrapps the firefox around one single start URL. You have to deploy a webserver in the same way as
3) Try to wrap it as a HTA application. Search the corresponding info on MSDN.
I would prefer (1) as you can add special application interacting code as needed.

Categories