Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Tuesday, August 20, 2013

Redirect Mobile Devices Using PHP

Hi everyone!

Today, I want to share this useful article with you. This article is going to be about redirecting mobile devices with PHP programming language. I am sure that you will need it.
If you have your own web site or something else, It means that you have members, users or followers on your site. Sure, we should remember that most of people uses mobile devices. Internet, social media, game or some applications etc, and we know that they visit your web site from their mobile devices. For that reason if we put this special feature on, we get more quality site of course.
As I said the title, I am doing this using PHP. So, let me show you:
//just define user's agents (iphone or android)
$iphoneDevice  =  strpos($_SERVER['HTTP_USER_AGENT'], "iPhone");
$androidDevice =  strpos($_SERVER['HTTP_USER_AGENT'], "Android");

if($iphoneDevice) {
    print "Your device is iphone!";
}

if($androidDevice) {
    print "Your device is android, you can download Fast Boy Game 
Application from Play Google
"; print " FAST BOY"; }

That's it. If the user use iphone, will see "Your device is iphone!" message on the screen, if use android device,
Your device is android, you can download Fast Boy Game 
Application from Play Google
FAST BOY (clickable)

If you want to put more features on your web site, for example blackberry, webos or ipod, you can use already.
$webOSDevice      = strpos($_SERVER['HTTP_USER_AGENT'], "webOS");
$BlackBerryDevice = strpos($_SERVER['HTTP_USER_AGENT'], "BlackBerry");
$ipodDevice       = strpos($_SERVER['HTTP_USER_AGENT'], "iPod");
The code given above shows us other devices and brands.
We will see you next article!

Monday, November 14, 2011

A Nokia application for system room temperature controlling.

One of the our previous article ( http://stdioe.blogspot.com/2011/10/checking-system-room-temperature-with.html ) was explaining how to get temperature information from some devices. We showed that related scripts saves the temperature value to a MySQL table. In this article, we are explaining publishing only the current temperature value on a public web page. The Nokia application will read that value to generate alarms when the value exceeds a critical value. The Nokia application is written by jbytecode to follow up via cell phones. If system room temperature reaches a predefined critical value, your mobile cell phone will create an alarm sound. Therefore you will be informed where ever you are.

The mobile phone application is an open source project and is being hosted on Google Code web site. You can access .jar and .jad files and source code on http://code.google.com/p/atlantis-networking-utilities web page address.Note that we call that "Nokia Application" because we only tested it with a Nokia E-72. Of course it is generally a Midlet application which can run in any supported device.

You can start the application by simply clicking the icon,

You have to define a temperature reader url on that program. If you need, you can change the checking period of system room temperature and define a critical temperature value,

After editing the configuration you can start the application,


The application needs internet connectivity. When it starts, it will show a confirmation alert and wait your response. Allow it.


Finally, it will start to read the current temperature value for the given time period. Received temperature values are logged in a text box.


This application is in its early stages. If you need extra features etc. let us know please. It's already an open-source project on code.google.com site. Every body can help to develop it or write to us ...


The current temperature publishing page is like following: You need to replace some parts on the code. MySQL server, user and password,DB_name, table_name and "temp" field names should be changed manually.

Also you may want to sort the historical values by date, so I am adding a date field on the sample db.


<?php
$link = mysql_connect("MySQL_Server","MySQL_User","MySQL_Password") or die("Error message");

mysql_select_db("DB_Name") or die("Error message");

$query = "SELECT * FROM `table_name ORDER by `date` DESC";
$result = mysql_query($query);
$line = mysql_fetch_array($result);
$temp = $line["temp"];
print $temp;
mysql_close($link);
?>

You will get only the curreny temperature value as a plain text whenever the page is accessed by the TempAlarmer. Please let us know your comments to develop it more.

Have Fun!