Location: PHPKode > projects > Polaring > polaring.php
<?php 
// vim: sw=4:ts=4
/**
* @version 00.04.09
* @package polaring
* @license This component in released under the GNU/GPL License
*
* Package is based upon `Polar Hrm Webbased Application',
* found at http://users.pandora.be/oppiekes/polar/
*
* File: polar.php
* Role: The spider in the web; the file that ties it all together
*
**/

/////////////////////////////////////
// INCREASE ALLOWED MEMORY
//   in case you run out of memory --- which easily happens
//   due to my sloppy coding in the GARMIN and XML sections,
//   uncomment the following to allow more memory to be used.
//   Increase number according to need. (Ie, until you stop
//   getting "Allowed memory size"-errors.)
//ini_set("memory_limit", "512M");


/////////////////////////////////////
// SESSION start
//   used for instance to transfer settings
//   across functions
/////////////////////////////////////

session_name("polarsession");
session_start("polarsession");


/////////////////////////////////////
// Read required files.
// Note: more files are read by 'functions/general.php'
//  and view/general.php'.
/////////////////////////////////////

require('./configuration.php');
require('./functions/general.php');
require('./view/general.php');
require('./functions/initialize.php');


/////////////////////////////////////
// - Look at what's to be done ($_GET section,
//   mission, and, in the case of graphs, gtyp.
//   (switch)
// - Do the assigned task
/////////////////////////////////////


// If we're to load a graph, don't insert HTML
// (like html-head, package title, and so on).
if ( $_GET['mission'] != "graf" && $_GET['tool'] != "sqltoxml" ) {
	visa::startHtml();
}

// If we don't want to show home, and section isn't set
// go to workouts.
if ( !checkHomeShow() && !$_GET['section'] ) {
    $_GET['section'] = "polar";
    $_GET['mission'] = "months";
}

switch( $_GET['section'] ) {
    //TOOLS
case 'tools':
    if ( ! user::validateIP($_SESSION['validIp']['tools']) ) {
	errorReport::notValidIp(user::giveIP());
	die();
    }
    if ( isset($_GET['tool']) ) {
	$tool = $_GET['tool'];
	switch ( $tool ) {
	case 'sqltoxml':
	    require_once('functions/sqltoxml.php');
	    sqltoxml::getit();
	    break;
	}
    }
    require_once 'view/tools.php';
    tools::viewTools();
    break;      
    // KONFIGURATION
case 'setup':
    if ( ! user::validateIP($_SESSION['validIp']['settings']) ) {
	errorReport::notValidIp(user::giveIP());
	die();
    }
    require('view/configuration.php');
    switch( $_GET['mission'] ) {
    case 'write':
	setup::writeSettings();
	break;
    case 'read':
	setup::giveSettings();
	break;
    default:
	setup::giveSettings();
	break;
    }
    break;       
default:
    // Load frontpage (some information about the package?, etc)
    framsidan::frontpage();
    break;
    // DIARY
case 'dagbok':
    if ( ! user::validateIP($_SESSION['validIp']['diary']) ) {
	errorReport::notValidIp(user::giveIP());
	die();
    }
    switch( $_GET['mission'] ) {
    case 'dagbok':
	require 'functions/diary.php';
	require 'view/diary.php';
	$val = navigation::geVal();
	switch ( $val ) {
	case 'idag':
	    // Check if day exists. If it does, show what has been
	    // written; if no entry can be found, show 
	    // `insert-data'-dialogue. 
	    infout::kolladag($info);
	    break;
	case 'las':
	    if ( empty($_GET['dag']) ) {
		show_diary::nodaychosen();
	    } else {
		infout::kolladag($datum);
	    }
	    break;
	case 'lagra':
	    echo "<h2>".strings::expression("diary", "thediary").
		"</h2>";
	    infin::lagra();
	    break;
	case 'jumpto':
	    $datum = $_POST['ar']."-".$_POST['month']."-"
		.$_POST['dag'];
	    $_GET['ar'] = $_POST['ar'];
	    $_GET['month'] = $_POST['month'];
	    $_GET['dag'] = $_POST['dag'];
	    infout::kolladag($datum);
	    empty($HTTP_POST_VARS);
	    break;
	default:
	    framsidan::dagbok();
	    break;
	}
	break;
    default:
	require_once 'view/frontpage.php';
	framsidan::dagbok();
	break;
    }
    break;
    // EXERCISES (polar)
case 'polar':
    // check if exercise-dir exists
    errorCheck::dirExists($_SESSION['dirTrFiles'], 
	strings::expression("setup", "dirWorkouts"));
    switch($_GET['mission']) {
    case 'months':
	require_once 'view/months.php';
	visaMonths($_GET['yearShow']);
	break;
    case 'monthen':
	require_once 'view/month.php';
	visaMonthen($_GET['year'], $_GET['month']);
	break;
    case 'day':
	require_once 'view/day.php';
	$dateTime = $_GET['dateTime'];
	showDay($dateTime);
	break;
	// GRAPHS
    case 'graf':
	require 'images/graph.php';
	$gtyp = $_REQUEST['gtyp'];
	if ( isset($_REQUEST['dateTime']) ) {
	    call_user_func($gtyp, $_REQUEST['dateTime']);
	    break;
	} elseif ( isset($_REQUEST['m']) ) {
	    call_user_func($gtyp, $_REQUEST['m'], $_REQUEST['y']);
	    break;
	} else {
	    call_user_func($gtyp);
	    break;
	}
    case 'samples':
	require('view/samples.php');
	viewSamples($_GET['dateTime']);
	break;
    default:
	require_once 'view/months.php';
	visaMonths();
	break;
    }
    break;
case 'uploadWorkout':
    require_once('./view/upload.php');
    if ( isset($_POST['submit']) ) {
	uploadWorkout::storeFile($_POST, $_FILES);
    } else {
	uploadWorkout::showUploadDialogue();
    }
    break;
}

// If we're to load a graph, don't insert HTML
if ( $_GET['mission'] != "graf" 
    && $_GET['tool'] != "sqltoxml" ) {
	visa::endHtml();
    }


?>
Return current item: Polaring