Location: PHPKode > projects > phpMyOrdering > phpMyOrdering-0.1.7-alpha/phpMyPurchasing-0.1.2-alpha/formAdvPermissionsSearch.php
<?PHP
/*
 * phpMyPurchasing
 * Jason Gerfen [hide@address.com]
 *
 * formAdvPermissionsSearch.php - Advanced permissions search
 */

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();

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

  // initialize a db connection handle
  $dbconn = $handles['db']->dbConnect( $defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname'] );

  //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['user'], $post['pass'], $serv );

  // process authentication and load appropriate template
  if($authenticated !== 0) {
   $ERROR = '<div class="error">' . $handles['err']->detLoginErr($authenticated) . '</div>';
   $use = 'content-login.tpl';
  } else {
   $ERROR = '<div class="error">' . $handles['err']->GenerateErrorLink( 'help.html', '#email', $defined['good'], 'Email has been sent', '800', '800' ) . '</div>';
   $use = 'form-resources.tpl';
  }
  $handles['tpl']->assign('TITLE',$defined['title'],NULL,NULL);
  $handles['tpl']->assign('URL',$serv['PHP_SELF'],NULL,NULL);
  $handles['tpl']->assign('template',$defined['templates'],NULL,NULL);
  $handles['tpl']->assign('ERROR',$ERROR,NULL,NULL);
  if(count($post)>0) {
   foreach($post as $key => $value) {
    $handles['tpl']->assign($key,$value,NULL,NULL);
   }
  }
  return $handles['tpl']->display($use,$flag,NULL);

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

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

?>
Return current item: phpMyOrdering