iphone WD app...

Hello traj…

Yes I did see your php5 page also for this, but it was showing some errors. If the php4 page is working why not just leave it as is? or is there a special reason you need the php5 version working?

on another totally unrelated to iphone.php note…I just visited your homepage and came across some errors there. see the included attachment of this message to view the screenshot I took of them.

After doing a google search I came across this solution for that problem…hope this helps you out in some way:

Solution:
allow_url_fopen should be ON in PHP configuration (php.ini). Probably, you don


Traj…

to get your mesoscale script working on your homepage…did you try changing this:

(include_path=‘.:/usr/lib/php5’)

to this:

(include_path=‘.:/usr/lib/php4’)

where the 5 is changed to a 4 at the end.

because your mesoscale test page does work here:

http://woonsocketweather.com/rss-mesoscale-test.php4

…chris

Just to do it. No other reason.

What file is it in? I’ve looked around for it and can’t seem to find it.

Hello traj…

I am assuming since you included on your homepage…it would be the include path in your index.php that needs the editing.

from Kens instructions below…

To show the summary on your homepage and the details in a separate page on your website, you include this in your homepage: <?php include("http://your.website/rss-mesoscale-test.php?summary=Y&inc=Y"); ?> and on the details page on your website, just have <?php include("http://your.website.rss-mesoscale-test.php?&inc=Y"); ?> and the details will be displayed with the look/feel of your website.

I am assuming if you changed in your index.php file this code from this:

<?php include("http://your.website/rss-mesoscale-test.php?summary=Y&inc=Y"); ?>

to this:

<?php include("http://your.website/rss-mesoscale-test.php4?summary=Y&inc=Y"); ?>

basically by adding the “4” at the end of the “php” line

It should work. Give it a try and let me know…Chris

Chris,

I tried what you suggested. I still had the problem. It just isn’t worth it with php5, so I removed the line from my .htaccess file which brought everything back to 4. Now it seems to be working ok.

Thanks for your help (again).

Traj

Hello Traj…

Looks better at least for now and until you get the php4- php5 problems figured out.

I am surprised if they told you to add that line to your htacess file, for it to use php5 instead of php4…that it didnt work. Perhaps contact them directly and make sure you did exactly as instructed to make it work. Just an Idea.

There are a few other people within the forums here that also use 1and1 as their host, and maybe they have some better answers on this. I am using E-rice since starting out 2 years ago and havent had many problems with them.

did you get the email I sent you? I sent it directly from your website contact us email link. please reply back to that email directly.

…Chris

Hello again Traj…

according to the FAQ Section of your web host 1and1 …here is instructions for using php5 on you server:

With 1&1 Linux hosting packages you have the choice between PHP 4 and
PHP 5. To distinguish a script as PHP 5, simply name the script with the file
extension .php5.

While the PHP developers have done their utmost to ensure compatibility, we cannot
guarantee that PHP 4 scripts will function 100% correctly under PHP 5.

Please note that in contrast to PHP 4, the default for the variable RegisterGlobals and allow_url_fopen is “off”.

By default Apache uses PHP 4 for .php extension. If you don’t want to rename all your
scripts to .php5 you can do the following:
Create a .htaccess file and place the following line AddType x-mapp-php5 .php in it.

This will tell Apache to use PHP 5 instead of PHP 4 for the extension .php in the
directory the .htaccess is placed and all sub-directories under it.

when you created the httaccess file did you use the following line exactly as this:

AddType x-mapp-php5 .php

with the spaces where they are shown in the line above?

may want to try again and see what happens…just copy and paste the line above into your .httaccess file and see what happens 2nd time around.

they also note that “allow_url_fopen is “off”.” is OFF…and that I believe should be “ON”, So ask them how this is also accomplished…as that is one of the errors you were receiving earlier and could be part of the problem.

if it still doesnt work…I would call them directly and ask them what else if anything must be done.

since they say on their site it should support php5…then it should work some how.

always worth a 2nd try…Chris

here’s another link about the allow url open…

http://faq.1and1.com/scripting_languages_supported/malware/20.html

I think you had everything correct before, but most likely had the allow url open…set to OFF…When it should have be set to ON.

…chris

You may have received my email that I placed the file you sent. As you can see, when I add that line to .htaccess, it goes to php5 and I have problems. When I go back to php4, they disappear.

Traj

Hello traj…

YES …I got your email and sent you another one.

Let me know if that helps…Chris

[quote author=gateway2capecod link=topic=40827.msg339021#msg339021 date=1251047418]
Solution:
allow_url_fopen should be ON in PHP configuration (php.ini). Probably, you don

1and1 does let you use allow_url_fopen with PHP5 … it just needs

allow_url_fopen = on

in a php.ini file in the document root directory. I had the same issue with PHP4->PHP5 conversion of my site, and the php.ini change fixed it right up :slight_smile:

Hi Ken…

should he have “register_globals” …Off Or On?

I dont understand why 1and1 just doesnt make the total switch over to all php5 instead of trying to use both php4 and php5. it would make you guys life easier.

…Chris

He should leave register_globals = off (which is the default for PHP5) … what that does is to take any argument on the URL and turn it into a php variable with the contents of whatever is after the equal sign. Not a good idea, and most PHP coders didn’t rely on that to fetch the arguments from the URL. So… leave it off in PHP5.

Some things work differently in PHP5 than PHP4, and I suppose that’s 1and1’s rationale for offering PHP4 as the default, but it’s an easy change to use PHP5 (and fix any things that break with the upgrade) at the webmaster’s discretion.

I’ve slowly been going through my scripts to make the PHP4/PHP5 compatible (mostly having to do with no putenv(“TZ=…”) and setting $PHP_SELF if it’s missing). I’ve (so far) avoided any PHP5-specific functions (like sunrise/sunset) so the scripts will work in either environment.

Best regards,
Ken

Hello Kevin and Ken…

Thanks for your input and replies on this…much appreciate the help.

everything seems to be working with his php4 pages at the moment so if it was me I would just leave it be.

…Chris

Thanks all. Like Chris says, it’s working so I’m not gonna mess with it right now. I have a few other tweaks I want to try.

Traj

This is a real nice iphone page, looks alot like http://i.wund.com/ without the forecast, has anyone added the forecast to this?

Here is my page now. http://www.rdoghouse.org/homewx/iphone.php

Don’t mean to revive an old topic but I want to say thanks for a great mobile template. I implemented it and also hashed together some code to check for a mobile browser and auto-redirect to the mobile page, with the option to return to the desktop version, if desired.

The code to perform the checking is done in php and was found on the net at http://detectmobilebrowsers.mobi/ This site offers code at no cost for non-commercial use.

Additional code to create and test for cookies was then added to check to see if the mobile visitor had already been to the site and requested to use the desktop version rather than the mobile version.

So, how do you do it?

  1. First, create your mobile.php file using the information in this thread (or use any mobile page you want!). Once you have the mobile page working to your satisfaction you can move on to the next step. I renamed iphone.php to mobile.php because I use it for all smartphone and mobile browsers.

  2. Next, add the code from detectmobilebrowsers.mobi to your main entry web page, or better yet, to the top of every page (very easy if you have a template that every page uses). Here is how every page on my site begins:

<?php
include('mobile_device_detect.php');
if (isset($_COOKIE["DWCmobile"]))
  echo "";
else
mobile_device_detect(true,true,true,true,true,true,'http://deltaweathercam.com/mobile.php',false);
?>

Note that the code for which devices are selected as mobile can be changed by altering the ‘true’ values. See the .mobi site for details, its easy. Mine is set to route all mobiles to the mobile page.

Also note that the mobile detection only gets invoked in the absence of a cookie which is set when a visitor hits the mobile page. This results in all mobile visitors going to the mobile page first, but then allows them to ask for the desktop version from there if desired. The cookie allows them to bypass the mobile check but it expires in an hour which means the next visit they start again at the mobile page. For the purists, the echo “” is a leftover from some testing, and is there in the event you want to send a blurb to mobile users.

  1. The mobile page also needs some code to create the cookie. This is at the top of my mobile.php page:
<?php
setcookie("DWCmobile", "Been There", time()+3600);
?>

The cookie name DWCmobile should be changed to something relevant to your site, but also remember to change the cookie reference in the code at the top of each page in previous code callout! The text Been There is not significant, it is just what the cookie contains. You can also change the expiration time which is currently set to the current time plus 3600 seconds (1 hour).

  1. Finally, I added a small link at the very top left corner of my desktop page that links to the mobile page, and a link on the mobile page that goes to the desktop. You can see these links at http://deltaweathercam.com/index.php and http://deltaweathercam.com/mobile.php. Don’t be fooled by the width of the mobile page, it is elastic and will shrink in width as needed.

The most common problem encountered after implementing this type of check for the user agent is a message similar to:

Warning: Cannot modify header information - headers already sent by (output started at /path/to/yourfilename.php:#) in /path/to/mobile_device_detect.php on line x

This is because your page is sending ‘something’ before calling the file. There are several solutions but one of the easiest is to configure your php to enable output buffering. Normally, session, cookie or HTTP header data in a PHP script must be sent before any output is generated by the script. If this is not possible in your application, you can enable what PHP calls output buffering, with the output_buffering variable. With output buffering on, PHP stores the output of your script in a special memory buffer and sends it only when explicitly told to do so. This allows you to send special HTTP headers and cookie data even in the middle or at the end of your script. Use of output buffering can slightly degrade performance but only on a very busy site. The setting in php.ini is: output_buffering = Off

That’s about all there is to it. I’d love to see of the experts here make some changes and improvements. Perhaps add an option for a mobile visitor to set a permanent cookie so they never go to the mobile page, or even a configurable one.

I had to make some adjustments to my web site because the iPad is detected and treated as an iPhone/iPod by many site detection checkers, including this one. Seems that although it specifically says iPad, it still contains the word ‘mobile’.

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

The solution isn’t especially hard to code, but I suspect it will be overlooked by many sites for a while. My feeling is that is should NOT be treated as a mobile device since most sites render better in full mode. I have made additions to my checking algorithm to specifically use the standard mode unless mobile/iPhone rendering is manually requested.

I added the an additional ‘case’ code as the first check in mobile_device_detect.php:


... function mobile_device_detect($iphone=true,$android=true,$opera=true,$blackberry=true,$palm=true,$windows=true,$mobileredirect=false,$desktopredirect=false){

$mobile_browser = false; // set mobile browser as false till we can prove otherwise
$user_agent = $_SERVER[‘HTTP_USER_AGENT’]; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed
$accept = $_SERVER[‘HTTP_ACCEPT’]; // get the content accept value - this should be cleaned to ensure no nefarious input gets executed

switch(true){ // using a switch against the following statements which could return true is more efficient than the previous method of using if statements

case (eregi(‘ipad’,$user_agent)); // we find the words ipad in the user agent
$mobile_browser = false; // set mobile browser to false
break; // break out and skip the rest if we’ve had a match on the ipad

case (eregi(‘ipod’,$user_agent)||eregi(‘iphone’,$user_agent)); // we find the words iphone or ipod in the user agent
$mobile_browser = $iphone; // mobile browser is either true or false depending on the setting of iphone when calling the function
if(substr($iphone,0,4)==‘http’){ // does the value of iphone resemble a url
$mobileredirect = $iphone; // set the mobile redirect url to the url value stored in the iphone value
} // ends the if for iphone being a url
break; // break out and skip the rest if we’ve had a match on the iphone or ipod


After using the iPad for a few weeks now I am convinced that there is no reason to treat it as a mobile browser, despite the fact that it contains the word mobile in its user agent string.