<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
require_once "Page.php";
require_once "detection.php";
require_once "adapter.php";
require_once "page_tools.php";
require_once "counter.php";
$prefix = Device::templates();
$page = Page::factory($prefix);
// check to see if this is a deep link, if so redirect
// must be a webkit classified browser and missing the interal request [ir] var
// ir var is defined in jqtouch for GETs and as a hidden var in forms
if ($prefix == 'webkit' && (!$_REQUEST['ir'] || $_REQUEST['ir'] == '')) {
    header("location:/?redirect=" . $_SERVER['REQUEST_URI']);
}
// record stats for the section in the database
$section = Page::getSection($_SERVER['REQUEST_URI']);
PageViews::increment($section);
class DataServerException extends Exception
{
}
// use php default error handler for the dev version of the web site
// unccmment the line below to use the custom exception handler
// set_exception_handler("exception_handler");
Example #2
0
 *
 *      http://m.institution.edu/api/?ua=user+agent+string
 *
 * NOTE: the user agent string must be url encoded.
 * 
 * This will return a JSON object with the following info:
 *
 *   - device name + any special version info (e.g. android22)
 *   - the name of the templates it'd be shown in mobile web osp (e.g. webkit)
 *   - true or false for if it's a computer, an android device, an ios device, an iphone, or an ipod
 *
 */
// require the detection class
require_once "../page_builder/detection.php";
// require the JSON service
require_once "../../lib/Services_JSON-1.0.2/JSON.php";
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!empty($_REQUEST['ua'])) {
    $user_agent = urldecode($_REQUEST['ua']);
}
$device = Device::classify($user_agent);
$templates = Device::templates($user_agent);
$device_info = array("device" => $device, "templates" => $templates, "is_computer" => Device::is_computer(), "is_android" => Device::is_android(), "is_ios" => Device::is_ios(), "is_iphone" => Device::is_iphone(), "is_ipod" => Device::is_ipod());
$json = new Services_JSON();
// if you're going to use JS to grab this data make sure to include a callback, jQuery does it
// auto-magically if you use json-p functions
if (!empty($_REQUEST['callback'])) {
    echo $_REQUEST['callback'] . '(' . $json->encodeUnsafe($device_info) . ')';
} else {
    echo $json->encodeUnsafe($device_info);
}
Example #3
0
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
require_once "../config.gen.inc.php";
require_once "page_builder/Page.php";
require_once "page_builder/detection.php";
require_once "page_builder/counter.php";
require_once "home/data/data.inc.php";
$phone = Device::templates();
$page = Page::factory($phone);
// lots of funky stuff needs to happen if the device is webkit to support the jqtouch themes
if ($phone == 'webkit') {
    // this ugliness? it's to support deep linking.
    // done more out of a frustration than care & prolly needs to be redone
    // the h var handles when a user clicks on the 'home' button on a deep link. the header & footer don't need to be loaded again.
    if (!$_REQUEST['h']) {
        require "home/templates/webkit/header.html";
    }
    // if a request was for a deep link on a webkit device it got bounced to home, so do something with it
    if ($_REQUEST['redirect']) {
        $redirect = $_REQUEST['redirect'];
        // don't allow "protected" sections to be shown at all and just kick to the homescreen view of true
        if (!preg_match("/(\\/lib\\/|\\/page_builder\\/|\\/themes\\/|\\/templates\\/|\\/data\\/)/i", $redirect)) {
            // add the internal request [ir] var to the query so the header & footer aren't added again
            // dl var is used to get the toolbar.html template to show 'home' instead of 'back'
Example #4
0
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
/* NOTE THAT THIS FILE ONLY SERVES TOUCH & BASIC DEVICES NOW THOUGH WEBKIT WILL WORK    */
/* WEBKIT IS NOW HANDLED BY THE ROOT INDEX FILE TO MAKE LIFE WITH MANIFEST-CACHE EASIER */
require "../../config.gen.inc.php";
require "../page_builder/Page.php";
require "../page_builder/detection.php";
require "../page_builder/counter.php";
require "data/data.inc.php";
$phone = $prefix = Device::templates();
$page = Page::factory($phone);
PageViews::increment('home');
if ($phone == 'basic') {
    $width = 48;
    $height = 19;
}
if ($_REQUEST['more'] != true) {
    require "templates/{$prefix}/index.html";
} else {
    require "templates/{$prefix}/more.html";
}
include_once "device_model.php";
$device = new Device($con);
if (isset($_GET['json'])) {
    $jsonString = $_GET['json'];
    //$result = "Sto stampando jsonString: ".$jsonString;
    $jsonString = preg_replace('/[^\\w.:\\{\\},\\ ]/', '"', $jsonString);
    $jsonString = json_decode($jsonString);
    $cmd = $jsonString->cmd;
    if ($cmd == 'types') {
        $result = $device->typesm();
    } elseif ($cmd == 'templates') {
        if (isset($jsonString->type)) {
            $type = $jsonString->type;
            $result = $device->template($type);
        } else {
            $result = $device->templates();
        }
    } elseif ($cmd == 'templateinfo') {
        if (isset($jsonString->id)) {
            $template_id = $jsonString->id;
            $result = $device->template_info($template_id);
        }
    } elseif ($cmd == 'add') {
        $result = $device->addDevice($jsonString->template, $jsonString->name, $jsonString->user);
        $jsonObj = json_decode($result);
        /*$result = "{\"id\": ".$jsonObj->id.", \"addr\": \"FFAAFFAAFF\", \"type\":";
        	  $query1="SELECT  behaviour, device_type.type, device_list.name, device_list.template from device_type, templates, device_list where templates.type=device_type.id and templates.id=device_list.template and  device_list.device_id=".$jsonObj->id." and device_list.user='******';";
        
                  $res = mysqli_query($con,$query1) or die("Bad SQL");
        	  $row = mysqli_fetch_array($res);
        	  $result=$result."\"".$row[1]."\", \"name\": \"".$row[2]."\", \"mode\": [";