-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
84 lines (78 loc) · 3.22 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//error_reporting(-1);
set_time_limit(0);
date_default_timezone_set('UTC');
ini_set('memory_limit', '258M');
header('Content-type: application/xml');
include_once('cls_oai.php');
/*$loghandle=fopen('log.txt','a');
fwrite($loghandle,date('c').' '.$_SERVER[REQUEST_URI]."\r\n");
fclose($loghandle);*/
$possibleverbs=array('Identify','ListRecords','ListMetadataFormats','ListSets','ListIdentifiers');
$possiblearguments=array('verb','metadataPrefix','identifier','from','until','set','resumptionToken','setSpec');
$setspec=false;
if(isset($_REQUEST['set'])){
$repositoryname=rawurlencode($_REQUEST['set']);
$setspec=true;
}
if(isset($_REQUEST['from']))
$from=$_REQUEST['from'];
if(isset($_REQUEST['until']))
$until=$_REQUEST['until'];
if(isset($_REQUEST['resumptionToken']))
$resumptiontoken=$_REQUEST['resumptionToken'];
$oai=new oai($from,$until);
$oai->setspec=$setspec;
#print_r($oai->repositories);
foreach ($_REQUEST as $argname => $argval){
if(!in_array($argname,$possiblearguments)){
$oai->getError('badArgument','Illegal argument passed');
exit;
}
}
if(isset($_REQUEST['verb'])){
$verb=$_REQUEST['verb'];
#$updates=GetModifiedDates($gatewayfolder.'/'.$repositoryname);
if(in_array($verb, $possibleverbs)){
if(isset($repositoryname)){
$validset=false;
#if(in_array($repositoryname,$oai->repositories)) echo 'FOUND';
#print_r($oai->repositories);
foreach($oai->repositories as $set){
#echo('#'.$set.'#'.$repositoryname.'#'."\r\n");
if($repositoryname==$set) $validset=true;
}
if($validset===false){
$oai->getError('badArgument','Unknown Set: '.$repositoryname);
}
else {
$oai->repositoryname=$repositoryname;
unset($oai->repositories);
$oai->repositories[0]=$repositoryname;
}
}else {
$oai->repositoryname=$oai->repositories[0];
}
$oai->getProviderInfo();
#echo $oai->repositoryname;
if(!$oai->error){
if($verb=='Identify') {echo $oai->Identify();}
elseif($verb=='ListSets') {echo $oai->ListSets();}
elseif($verb=='ListRecords') {
if(!isset($_REQUEST['metadataPrefix'])&&!isset($resumptiontoken))
$oai->getError('badArgument','metadataPrefix argument missing');
elseif(!in_array($_REQUEST['metadataPrefix'],$oai->allowedprefixes)&&!isset($resumptiontoken))
$oai->getError('cannotDisseminateFormat');
else {
$oai->ListRecords($resumptiontoken,$from,$until);
}
}
elseif($verb=='ListIdentifiers') {
$oai->ListIdentifiers($resumptiontoken,$from,$until);
}
elseif($verb=='ListMetadataFormats') {echo $oai->ListMetadataFormats();}
else {$oai->getError('badVerb','Function not implemented');}
}
}else $oai->getError('badVerb');
}else $oai->getError('badVerb','verb argument required');