Location: PHPKode > projects > phpMyOrdering > phpMyOrdering-0.1.7-alpha/content.php
<?PHP
/*
 * phpMyPurchasing
 * Jason Gerfen [hide@address.com]
 *
 * content.php - handle content by determining active tab
 */

if(file_exists('scripts/inc.config.php')) {
 require 'scripts/inc.config.php';

 // ensure we are being called from our configured host
 if( $defined['hostname'] === $_SERVER['SERVER_NAME'] ) {

  // obtain default options
  $defined = array_merge($defined,$handles['misc']->getDefaults());
  $defined = array_merge($defined,$handles['misc']->getAuthentication());
  $accessList = $handles['misc']->getAccessList();

  // create copy of globals while filter incoming data
  $get = @array_map( $handles['val']->ValidateXSS, $_GET );
  $post = @array_map( $handles['val']->ValidateXSS, $_POST );
  $_SESSION = @array_map( $handles['val']->ValidateXSS, $_SESSION );
  $serv = @array_map( $handles['val']->ValidateXSS, $_SERVER );

  // handle logging of requests, remote data
  $handles['logs']->process($serv);

  //define the template and cache directories
  $handles['tpl']->strTemplateDir = $defined['templates'];
  $handles['tpl']->strCacheDir    = '/tmp';
  if( !empty( $post ) ) { $flag = "TRUE"; } else { $flag = "FALSE"; }

		// gather up some information for the token
		if((!isset($_SESSION['token'])) || (!is_resource($handles['session']))) {
		 $handles['session'] = new dbSession($defined['timeout']);
		}
  $_SESSION['referrer'] = $serv['HTTP_REFERER'];

  // perform authentication
  $authenticated = $handles['auth']->DecideAuth( $_SESSION['token'], $post['username'], $post['password'], $serv );
  if($authenticated===0){ $class = "good"; } else { $class= "error"; }

  // assign some vars to our main template
  $handles['tpl']->assign('TITLE',$defined['title'],NULL,NULL);
  $handles['tpl']->assign('logo',$defined['logo'],NULL,NULL);
  $handles['tpl']->assign('URL', $serv['PHP_SELF'] . '?do=' . $get['do'],NULL,NULL);
  $handles['tpl']->assign('timeout',$defined['timeout'],NULL,NULL);
  $handles['tpl']->assign('template',$defined['templates'],NULL,NULL);

  // process authentication and load appropriate template
  if($authenticated !== 0) {
   $ERROR = '<div class="'.$class.'">' . $handles['err']->detLoginErr($authenticated) . '</div>';
   $use = 'content-login.tpl';
  } else {
   // determine our template
   switch( $get['do'] ) {
    case '0x00a0':
     $use = 'content-authenticated.tpl';
     break;
    case '0x00b0':
     if( !is_resource( $handles['purchases'] ) ) { $handles['purchases'] = new purchases; }
     $vars = $handles['purchases']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-purchasing.tpl';
     break;
    case '0x00c0':
     $use = 'content-inventory.tpl';
     break;
    case '0x00d0':
     $use = 'content-reports.tpl';
     break;
    case '0x00e0':
					$use = 'content-options.tpl';
     break;
				case '0x00ea':
     if( !is_resource( $handles['groups'] ) ) { $handles['groups'] = new groups; }
     $vars = $handles['groups']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-groups.tpl';
     break;
				case '0x00eb':
     if( !is_resource( $handles['users'] ) ) { $handles['users'] = new users; }
     if( !is_resource( $handles['groups'] ) ) { $handles['groups'] = new groups; }
     $vars = $handles['users']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-users.tpl';
     break;
				case '0x00ec':
     if( !is_resource( $handles['departments'] ) ) { $handles['departments'] = new departments; }
     $vars = $handles['departments']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-departments.tpl';
     break;
				case '0x00ed':
     if( !is_resource( $handles['permissions'] ) ) { $handles['permissions'] = new permissions; }
     $vars = $handles['permissions']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-permissions.tpl';
     break;
				case '0x00ee':
     $vars = $handles['conf']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-configuration.tpl';
     break;
				case '0x00ef':
     $vars = $handles['logs']->content($serv,$defined['templates']);
     $use = 'content-options-logs.tpl';
     break;
    case '0x00eg':
     if( !is_resource( $handles['vendors'] ) ) { $handles['vendors'] = new vendors; }
     $vars = $handles['vendors']->process($_SESSION['token'],$get,$post,$serv);
     $use = 'content-options-vendors.tpl';
     break;
    case '0x00f0':
     $handles['auth']->logout($_SESSION['token'], session_id());
     $use = 'content-exit.tpl';
    default:
     $use = 'content-login.tpl';
     break;
   }
  }

  // assign our template vars
  if(count($vars)>0) {
   foreach($vars as $key => $value) {
    $handles['tpl']->assign($key,$value,NULL,NULL);
   }
  }

  $handles['tpl']->assign('ERROR',$ERROR,NULL,NULL);
  $handles['tpl']->assign('templates',$defined['templates'],NULL,NULL);
  $handles['tpl']->display($use, $flag , NULL );

 } else {
  echo "Cannot be called from anywhere other then our defined host";
 }

} else {
 echo "Configuration file not found";
}

if($defined['debug']==="TRUE"){ $handles['debug']->ShowDebug( $_GET, $_POST, $_REQUEST, $_SESSION, $handles ); }

?>
Return current item: phpMyOrdering