reindenting

This commit is contained in:
Usuario Moodle 2013-05-07 14:52:33 -03:00
parent 2aa9b58b07
commit b3bd6f267a
1 changed files with 69 additions and 69 deletions

138
oai2.php
View File

@ -29,7 +29,7 @@
* In common cases, you have to implement your own code to act fully and correctly. * In common cases, you have to implement your own code to act fully and correctly.
* For generic usage, you can try the ANDS_Response_XML defined in xml_creater.php. * For generic usage, you can try the ANDS_Response_XML defined in xml_creater.php.
*/ */
// Report all errors except E_NOTICE // Report all errors except E_NOTICE
// This is the default value set in php.ini // This is the default value set in php.ini
// If anything else, try them. // If anything else, try them.
@ -46,31 +46,31 @@ $errors = array();
$attribs = array ('from', 'identifier', 'metadataPrefix', 'set', 'resumptionToken', 'until'); $attribs = array ('from', 'identifier', 'metadataPrefix', 'set', 'resumptionToken', 'until');
if (in_array($_SERVER['REQUEST_METHOD'],array('GET','POST'))) { if (in_array($_SERVER['REQUEST_METHOD'],array('GET','POST'))) {
$args = $_REQUEST; $args = $_REQUEST;
} else { } else {
$errors[] = oai_error('badRequestMethod', $_SERVER['REQUEST_METHOD']); $errors[] = oai_error('badRequestMethod', $_SERVER['REQUEST_METHOD']);
} }
require_once('oaidp-util.php'); require_once('oaidp-util.php');
// Always using htmlentities() function to encodes the HTML entities submitted by others. // Always using htmlentities() function to encodes the HTML entities submitted by others.
// No one can be trusted. // No one can be trusted.
foreach ($args as $key => $val) { foreach ($args as $key => $val) {
$checking = htmlspecialchars(stripslashes($val)); $checking = htmlspecialchars(stripslashes($val));
if (!is_valid_attrb($checking)) { if (!is_valid_attrb($checking)) {
$errors[] = oai_error('badArgument', $checking); $errors[] = oai_error('badArgument', $checking);
} else {$args[$key] = $checking; } } else {$args[$key] = $checking; }
} }
if (!empty($errors)) { oai_exit(); } if (!empty($errors)) { oai_exit(); }
foreach($attribs as $val) { foreach($attribs as $val) {
unset($$val); unset($$val);
} }
require_once('oaidp-config.php'); require_once('oaidp-config.php');
// Create a PDO object // Create a PDO object
try { try {
$db = new PDO($DSN); $db = new PDO($DSN);
} catch (PDOException $e) { } catch (PDOException $e) {
exit('Connection failed: ' . $e->getMessage()); exit('Connection failed: ' . $e->getMessage());
} }
@ -83,91 +83,91 @@ require_once('ands_tpa.php');
// Default, there is no compression supported // Default, there is no compression supported
$compress = FALSE; $compress = FALSE;
if (isset($compression) && is_array($compression)) { if (isset($compression) && is_array($compression)) {
if (in_array('gzip', $compression) && ini_get('output_buffering')) { if (in_array('gzip', $compression) && ini_get('output_buffering')) {
$compress = TRUE; $compress = TRUE;
} }
} }
if (SHOW_QUERY_ERROR) { if (SHOW_QUERY_ERROR) {
echo "Args:\n"; print_r($args); echo "Args:\n"; print_r($args);
} }
if (isset($args['verb'])) { if (isset($args['verb'])) {
switch ($args['verb']) { switch ($args['verb']) {
case 'Identify': case 'Identify':
// we never use compression in Identify // we never use compression in Identify
$compress = FALSE; $compress = FALSE;
if(count($args)>1) { if(count($args)>1) {
foreach($args as $key => $val) { foreach($args as $key => $val) {
if(strcmp($key,"verb")!=0) { if(strcmp($key,"verb")!=0) {
$errors[] = oai_error('badArgument', $key, $val); $errors[] = oai_error('badArgument', $key, $val);
} }
} }
} }
if (empty($errors)) include 'identify.php'; if (empty($errors)) include 'identify.php';
break; break;
case 'ListMetadataFormats': case 'ListMetadataFormats':
$checkList = array("ops"=>array("identifier")); $checkList = array("ops"=>array("identifier"));
checkArgs($args, $checkList); checkArgs($args, $checkList);
if (empty($errors)) include 'listmetadataformats.php'; if (empty($errors)) include 'listmetadataformats.php';
break; break;
case 'ListSets': case 'ListSets':
if(isset($args['resumptionToken']) && count($args) > 2) { if(isset($args['resumptionToken']) && count($args) > 2) {
$errors[] = oai_error('exclusiveArgument'); $errors[] = oai_error('exclusiveArgument');
} }
$checkList = array("ops"=>array("resumptionToken")); $checkList = array("ops"=>array("resumptionToken"));
checkArgs($args, $checkList); checkArgs($args, $checkList);
if (empty($errors)) include 'listsets.php'; if (empty($errors)) include 'listsets.php';
break; break;
case 'GetRecord': case 'GetRecord':
$checkList = array("required"=>array("metadataPrefix","identifier")); $checkList = array("required"=>array("metadataPrefix","identifier"));
checkArgs($args, $checkList); checkArgs($args, $checkList);
if (empty($errors)) include 'getrecord.php'; if (empty($errors)) include 'getrecord.php';
break; break;
case 'ListIdentifiers': case 'ListIdentifiers':
case 'ListRecords': case 'ListRecords':
if(isset($args['resumptionToken'])) { if(isset($args['resumptionToken'])) {
if (count($args) > 2) { if (count($args) > 2) {
$errors[] = oai_error('exclusiveArgument'); $errors[] = oai_error('exclusiveArgument');
} }
$checkList = array("ops"=>array("resumptionToken")); $checkList = array("ops"=>array("resumptionToken"));
} else { } else {
$checkList = array("required"=>array("metadataPrefix"),"ops"=>array("from","until","set")); $checkList = array("required"=>array("metadataPrefix"),"ops"=>array("from","until","set"));
} }
checkArgs($args, $checkList); checkArgs($args, $checkList);
if (empty($errors)) include 'listrecords.php'; if (empty($errors)) include 'listrecords.php';
break; break;
default: default:
// we never use compression with errors // we never use compression with errors
$compress = FALSE; $compress = FALSE;
$errors[] = oai_error('badVerb', $args['verb']); $errors[] = oai_error('badVerb', $args['verb']);
} /*switch */ } /*switch */
} else { } else {
$errors[] = oai_error('noVerb'); $errors[] = oai_error('noVerb');
} }
if (!empty($errors)) { oai_exit(); } if (!empty($errors)) { oai_exit(); }
if ($compress) { if ($compress) {
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
} }
header(CONTENT_TYPE); header(CONTENT_TYPE);
if(isset($outputObj)) { if(isset($outputObj)) {
$outputObj->display(); $outputObj->display();
} else { } else {
exit("There is a bug in codes"); exit("There is a bug in codes");
} }
if ($compress) { if ($compress) {
ob_end_flush(); ob_end_flush();
} }
?> ?>