function parse_line($line) {
  // ignore nagios checks and localhost calls
  if (strpos($line, '127.' === 0) || strpos($line, 'check_http') !== FALSE)
    return;
  if (preg_match('/GET ' . str_replace('/', '\/', HTTPROOT) . '([\w\-]+)\/?( HTTP|[\w\-]+\.php)/', $line, $matches)) {
    $module = $matches[1];
    if ($module == 'home' || array_key_exists($module, Modules::full_list())) {
      preg_match('/\[(\d+\/\w+\/\d{4})/', $line, $matches);
      $day = strtotime(str_replace('/', '-', $matches[1]));
      $ua_end = strrpos($line, '"');
      $ua_start = strrpos(substr($line, 0, $ua_end), '"') + 1;
      $ua = substr($line, $ua_start, $ua_end - $ua_start);
      $request = Array('ua' => $ua, 'action' => 'classify');
      $result = json_decode(file_get_contents(MOBI_SERVICE_URL . '?' . http_build_query($request)), TRUE);
      $platform = $result['platform'];
      PageViews::increment($module, $platform, $day);
      //echo time() . ' ' . date('Y-m-d', $day) . ' ' . $module . ' ' . $platform . "\n";
    }
  }
  return;
}
Ejemplo n.º 2
0
          $parts[0] = $url_redirects[$id];
          $url = URL_PREFIX . implode("/", $parts);
        }
        header("Location: " . $url);
        exit;
      }
    }
    
    // find the page part
    if (isset($parts[1])) {
      if (strlen($parts[1])) {
        $page = basename($parts[1], '.php');
      }
      
    } else {
      // redirect with trailing slash for completeness
      header("Location: ./$id/");
      exit;
    }

    if ($module = WebModule::factory($id, $page, $args)) {
        /* log this page view */
        PageViews::increment($id, Kurogo::deviceClassifier()->getPlatform());
        
        $module->displayPage();
    } else {
        throw new Exception("Module $id cannot be loaded");
    }
}
exit;
Ejemplo n.º 3
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/counter.php";
require "data/data.inc.php";
$phone = Page::classify_phone();
$prefix = Page::$requireTable[$phone];
$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";
}
Ejemplo n.º 4
0
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");
function exception_handler($exception)
{
    if (is_a($exception, "DataServerException")) {
        $error_query = "code=data&url=" . urlencode($_SERVER['REQUEST_URI']);
    } else {
        $error_query = "code=internal";
    }
    $error_url = "../error-page/?{$error_query}";
    $recipients = array("*****@*****.**");
Ejemplo n.º 5
0
 public function output()
 {
     if (!$this->module) {
         // here is a stricter version of the overly permissive regex
         // that used to be in page_header
         $module_list = implode('|', array_keys(Modules::$module_data));
         preg_match('/\\/(' . $module_list . ')\\/[^\\/]*?$/', $_SERVER['REQUEST_URI'], $match);
         $this->module = $match[1];
     }
     PageViews::increment($this->module, $this->platform);
     foreach ($this->varnames as $varname) {
         ${$varname} = $this->{$varname};
     }
     ob_start();
     require "../{$this->branch}/base.html";
     $uncompressed_html = ob_get_clean();
     // replace large chunks of spaces with a single space
     $compressed_html = self::compress_whitespace($uncompressed_html);
     if ($this->compressed_mode) {
         echo $compressed_html;
     } else {
         echo $uncompressed_html;
     }
 }
Ejemplo n.º 6
0
/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
require "Page.php";
require "page_tools.php";
require "counter.php";
$phone = Page::classify_phone();
$page = Page::factory($phone);
$prefix = $page->requirePrefix();
preg_match('/\\/((\\w|\\-)+)\\/[^\\/]*?$/', $_SERVER['REQUEST_URI'], $match);
$content = $match[1];
PageViews::increment($content);
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");
function exception_handler($exception)
{
    if (is_a($exception, "DataServerException")) {
        $error_query = "code=data&url=" . urlencode($_SERVER['REQUEST_URI']);
    } else {
        $error_query = "code=internal";
    }
    $error_url = "../error-page/?{$error_query}";
    $recipients = array("*****@*****.**");
Ejemplo n.º 7
0
<?php

require_once "../config/mobi_web_constants.php";
require_once "Home.php";
require_once "Modules.php";
require_once WEBROOT . "page_builder/Page.php";
//require WEBROOT . "page_builder/counter.php";
require WEBROOT . "page_builder/page_tools.php";
require WEBROOT . "customize/customize_lib.php";
$page = Page::factory();
$page->module('home');
PageViews::increment('home', $page->platform);
$whats_new_count = Home::$whats_new_count;
$top_item = Home::$whats_new->getTopItemName();
Modules::init($page->branch, $page->certs, $page->platform);
$old_modules = getModuleOrder();
$moduleorder = Modules::refreshAll($old_modules, $page->branch);
setModuleOrder($moduleorder);
$modules = getActiveModules($page->branch);
$modules = Modules::refreshActive($old_modules, $modules, $page->branch);
$modules = Modules::add_required($modules, $page->branch);
setActiveModules($modules);
$all_modules = Modules::$default_order;
//$fh = fopen('/tmp/headers-' . time() . '.txt', 'w');
//fwrite($fh, str_replace('",', "\",\n", json_encode($_SERVER)) . '\n');
//fclose($fh);
$page->prevent_caching('Basic');
$page->prevent_caching('Touch');
$page->cache();
/*
function url($module) {
Ejemplo n.º 8
0
  if (array_key_exists($id, $url_redirects)) {
    if (preg_match("#^http(s)?://#", $url_redirects[$id])) {
       $url = $url_redirects[$id];
    } else {
      $parts[0] = $url_redirects[$id];
      $url = URL_PREFIX . implode("/", $parts);
    }
    header("Location: " . $url);
    exit;
  }
}

// find the page part
if (isset($parts[1])) {
  if (strlen($parts[1])) {
    $page = basename($parts[1], '.php');
  }
  
} else {
  // redirect with trailing slash for completeness
  header("Location: ./$id/");
  exit;
}

/* log this page view */
PageViews::increment($id, $GLOBALS['deviceClassifier']->getPlatform());

$module = WebModule::factory($id, $page, $args);
$module->displayPage();
exit;