\n"; @unlink( $fn); } } } closedir($dh); } } function get_token() { list($usec, $sec) = explode(" ", microtime()); return ((int)($usec*1000) + (int)($sec*1000)); } function oai_error($code, $argument='', $value='') { global $request; global $request_err; switch ($code) { case 'badArgument' : $text = "The argument '$argument' (value='$value') included in the request is not valid."; break; case 'badGranularity' : $text = "The value '$value' of the argument '$argument' is not valid."; $code = 'badArgument'; break; case 'badResumptionToken' : $text = "The resumptionToken '$value' does not exist or has already expired."; break; case 'badRequestMethod' : $text = "The request method '$argument' is unknown."; $code = 'badVerb'; break; case 'badVerb' : $text = "The verb '$argument' provided in the request is illegal."; break; case 'cannotDisseminateFormat' : $text = "The metadata format '$value' given by $argument is not supported by this repository."; break; case 'exclusiveArgument' : $text = 'The usage of resumptionToken as an argument allows no other arguments.'; $code = 'badArgument'; case 'idDoesNotExist' : $text = "The value '$value' of the identifier is illegal for this repository."; break; case 'missingArgument' : $text = "The required argument '$argument' is missing in the request."; $code = 'badArgument'; break; case 'noRecordsMatch' : $text = 'The combination of the given values results in an empty list.'; break; case 'noMetadataFormats' : $text = 'There are no metadata formats available for the specified item.'; break; case 'noVerb' : $text = 'The request does not provide any verb.'; $code = 'badVerb'; break; case 'noSetHierarchy' : $text = 'This repository does not support sets.'; break; case 'sameArgument' : $text = 'Do not use them same argument more than once.'; $code = 'badArgument'; break; case 'sameVerb' : $text = 'Do not use verb more than once.'; $code = 'badVerb'; break; default: $text = "Unknown error: code: '$code', argument: '$argument', value: '$value'"; $code = 'badArgument'; } if ($code == 'badVerb' || $code == 'badArgument') { $request = $request_err; } $error .= ' '.xmlstr($text, 'iso8859-1', false)."\n"; return $error; } function xmlstr( $string) { #print "string= $string
\n"; $string= str_replace( "&", "&", $string); $string= str_replace( "'", "'", $string); $string= str_replace( '"', """, $string); $string= str_replace( "<", "<", $string); $string= str_replace( '>', ">", $string); // just remove invalid characters $pattern ="/[\x-\x8\xb-\xc\xe-\x1f]/"; $string = preg_replace($pattern,'',$string); return $string; } // will split a string into elements and return XML // supposed to print values from database function xmlrecord( $sqlrecord, $element, $indent = 0) { global $SQL; #print "$element= $sqlrecord
\n"; $str = ''; if ($sqlrecord != '') { if (isset($SQL['split'])) { $temparr = explode($SQL['split'], $sqlrecord); foreach ($temparr as $val) { $str .= str_pad('', $indent).'<'.$element.'>'.xmlstr( $val).'\n"; } return $str; } else { $str= str_pad('', $indent).'<'.$element.'>'.xmlstr( $sqlrecord).'\n"; #print "str= $str
\n"; return $str; } } else { return ''; } } // takes either an array or a string and outputs them as XML entities // this function assumes that the strings are written in iso8859-1 and have // not been escaped yet. function xmlformat($record, $element, $indent = 0) { $str = ''; if (is_array($record)) { foreach ($record as $val) { $str .= str_pad('', $indent).'<'.$element.'>'.xmlstr($val, 'iso8859-1', false).'\n"; } return $str; } elseif ($record != '') { return str_pad('', $indent).'<'.$element.'>'.xmlstr($record, 'iso8859-1', false).'\n"; } else { return ''; } } function date2UTCdatestamp($date) { global $granularity; switch ($granularity) { case 'YYYY-MM-DDThh:mm:ssZ': // we assume common date ("YYYY-MM-DD") or // datetime format ("YYYY-MM-DD hh:mm:ss") // in the database if (strstr($date, ' ')) { // date is datetime format return str_replace(' ', 'T', $date).'Z'; } else { // date is date format // granularity 'YYYY-MM-DD' should be used... return $date.'T00:00:00Z'; } break; case 'YYYY-MM-DD': if (strstr($date, ' ')) { // date is datetime format list($date, $time) = explode(" ", $date); return $date; } else { return $date; } break; default: die("Unknown granularity!"); } } function checkDateFormat($date) { global $granularity; global $message; if ($granularity == 'YYYY-MM-DDThh:mm:ssZ') { $checkstr = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$'; } else { $checkstr = '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}$)'; } if (ereg($checkstr, $date, $regs)) { if (checkdate($regs[2], $regs[3], $regs[1])) { return 1; } else { $message = "Invalid Date: $date is not a valid date."; return 0; } } else { $message = "Invalid Date Format: $date does not comply to the date format $granularity."; return 0; } } function formatDatestamp($datestamp) { global $granularity; $datestamp= substr( $datestamp, 0, 10). 'T' . substr( $datestamp, 11, 8). 'Z'; if (!checkDateFormat($datestamp)) { if ($granularity == 'YYYY-MM-DD') { return '2002-01-01'; } else { return '2002-01-01T00:00:00Z'; } } else { return $datestamp; } } function oai_close() { global $compress; echo "\n"; if ($compress) { ob_end_flush(); } } function oai_exit() { global $CONTENT_TYPE; global $xmlheader; global $request; global $errors; header( $CONTENT_TYPE); echo $xmlheader; echo $request; echo $errors; oai_close(); exit(); } function php_is_at_least($version) { list($c_r, $c_mj, $c_mn) = explode('.', phpversion()); list($v_r, $v_mj, $v_mn) = explode('.', $version); if ($c_r >= $v_r && $c_mj >= $v_mj && $c_mn >= $v_mn) return TRUE; else return FALSE; } function metadataHeader($prefix) { global $METADATAFORMATS; global $XMLSCHEMA; $myformat = $METADATAFORMATS[$prefix]; $str = ' <'.$prefix; if ($myformat['record_prefix']) { $str .= ':'.$myformat['record_prefix']; } $str .= "\n". ' xmlns:'.$prefix.'="'.$myformat['metadataNamespace'].'"'."\n"; if ($myformat['record_prefix'] && $myformat['record_namespace']) { $str .= ' xmlns:'.$myformat['record_prefix'].'="'.$myformat['record_namespace'].'"'."\n"; } $str .= ' xmlns:xsi="'.$XMLSCHEMA.'"'."\n". ' xsi:schemaLocation="'.$myformat['metadataNamespace']."\n". ' '.$myformat['schema'].'">'."\n"; return $str; } ?> /", "\n", $str); return $str; } $formats= array( ); $formats[ 'ez']= 'application/andrew-inset'; $formats[ 'csm']= 'application/cu-seeme'; $formats[ 'cu']= 'application/cu-seeme'; $formats[ 'tsp']= 'application/dsptype'; $formats[ 'spl']= 'application/x-futuresplash '; $formats[ 'cpt']= 'image/x-corelphotopaint'; $formats[ 'hqx']= 'application/mac-binhex40'; $formats[ 'nb']= 'application/mathematica'; $formats[ 'mdb']= 'application/msaccess'; $formats[ 'doc']= 'application/msword'; $formats[ 'dot']= 'application/msword'; $formats[ 'bin']= 'application/octet-stream'; $formats[ 'oda']= 'application/oda'; $formats[ 'pdf']= 'application/pdf'; $formats[ 'pgp']= 'application/pgp-signature'; $formats[ 'ps']= 'application/postscript'; $formats[ 'ai']= 'application/postscript'; $formats[ 'eps']= 'application/postscript'; $formats[ 'rtf']= 'text/rtf'; $formats[ 'smi']= 'application/smil'; $formats[ 'smil']= 'application/smil'; $formats[ 'xls']= 'application/vnd.ms-excel'; $formats[ 'xlb']= 'application/vnd.ms-excel'; $formats[ 'ppt']= 'application/vnd.ms-powerpoint'; $formats[ 'pps']= 'application/vnd.ms-powerpoint'; $formats[ 'pot']= 'application/vnd.ms-powerpoint'; $formats[ 'sdw']= 'application/vnd.stardivision.writer'; $formats[ 'sgl']= 'application/vnd.stardivision.writer-global'; $formats[ 'vor']= 'application/vnd.stardivision.writer'; $formats[ 'sdc']= 'application/vnd.stardivision.calc'; $formats[ 'sda']= 'application/vnd.stardivision.draw'; $formats[ 'sdd']= 'application/vnd.stardivision.impress'; $formats[ 'sdp']= 'application/vnd.stardivision.impress-packed'; $formats[ 'smf']= 'application/vnd.stardivision.math'; $formats[ 'sds']= 'application/vnd.stardivision.chart'; $formats[ 'smd']= 'application/vnd.stardivision.mail'; $formats[ 'wbxml']= 'application/vnd.wap.wbxml '; $formats[ 'wmlc']= 'application/vnd.wap.wmlc'; $formats[ 'wmlsc']= 'application/vnd.wap.wmlscriptc'; $formats[ 'wp5']= 'application/wordperfect5.1'; $formats[ 'zip']= 'application/zip'; $formats[ 'wk']= 'application/x-123'; $formats[ 'bcpio']= 'application/x-bcpio'; $formats[ 'vcd']= 'application/x-cdlink '; $formats[ 'pgn']= 'application/x-chess-pgn'; $formats[ 'cpio']= 'application/x-cpio'; $formats[ 'csh']= 'text/x-csh'; $formats[ 'deb']= 'application/x-debian-package'; $formats[ 'dcr']= 'application/x-director'; $formats[ 'dir']= 'application/x-director'; $formats[ 'dxr']= 'application/x-director'; $formats[ 'wad']= 'application/x-doom'; $formats[ 'dms']= 'application/x-dms'; $formats[ 'dvi']= 'application/x-dvi'; $formats[ 'pfa']= 'application/x-font'; $formats[ 'pfb']= 'application/x-font'; $formats[ 'gsf']= 'application/x-font'; $formats[ 'pcf']= 'application/x-font'; $formats[ 'pcf.Z']= 'application/x-font'; $formats[ 'gnumeric']= 'application/x-gnumeric'; $formats[ 'gtar']= 'application/x-gtar'; $formats[ 'tgz']= 'application/x-gtar'; $formats[ 'taz']= 'application/x-gtar'; $formats[ 'hdf']= 'application/x-hdf'; $formats[ 'phtml']= 'application/x-httpd-php'; $formats[ 'pht']= 'application/x-httpd-php'; $formats[ 'php']= 'application/x-httpd-php'; $formats[ 'phps']= 'application/x-httpd-php-source'; $formats[ 'php3']= 'application/x-httpd-php3'; $formats[ 'php3p']= 'application/x-httpd-php3-preprocessed '; $formats[ 'php4']= 'application/x-httpd-php4'; $formats[ 'ica']= 'application/x-ica'; $formats[ 'jar']= 'application/x-java-archive'; $formats[ 'jnlp']= 'application/x-java-jnlp-file'; $formats[ 'ser']= 'application/x-java-serialized-object'; $formats[ 'class']= 'application/x-java-vm'; $formats[ 'js']= 'application/x-javascript'; $formats[ 'chrt']= 'application/x-kchart'; $formats[ 'kil']= 'application/x-killustrator'; $formats[ 'kpr']= 'application/x-kpresenter'; $formats[ 'kpt']= 'application/x-kpresenter'; $formats[ 'skp']= 'application/x-koan '; $formats[ 'skd']= 'application/x-koan '; $formats[ 'skt']= 'application/x-koan '; $formats[ 'skm']= 'application/x-koan '; $formats[ 'ksp']= 'application/x-kspread'; $formats[ 'kwd']= 'application/x-kword'; $formats[ 'kwt']= 'application/x-kword'; $formats[ 'latex']= 'application/x-latex'; $formats[ 'lha']= 'application/x-lha'; $formats[ 'lzh']= 'application/x-lzh'; $formats[ 'lzx']= 'application/x-lzx'; $formats[ 'frm']= 'application/x-maker'; $formats[ 'maker']= 'application/x-maker'; $formats[ 'frame']= 'application/x-maker'; $formats[ 'fm']= 'application/x-maker'; $formats[ 'fb']= 'application/x-maker'; $formats[ 'book']= 'application/x-maker'; $formats[ 'fbdoc']= 'application/x-maker'; $formats[ 'mif']= 'application/x-mif'; $formats[ 'com']= 'application/x-msdos-program'; $formats[ 'exe']= 'application/x-msdos-program'; $formats[ 'bat']= 'application/x-msdos-program'; $formats[ 'dll']= 'application/x-msdos-program'; $formats[ 'msi']= 'application/x-msi'; $formats[ 'nc']= 'application/x-netcdf'; $formats[ 'cdf']= 'application/x-netcdf'; $formats[ 'pac']= 'application/x-ns-proxy-autoconfig'; $formats[ 'o']= 'application/x-object'; $formats[ 'ogg']= 'application/x-ogg'; $formats[ 'oza']= 'application/x-oz-application'; $formats[ 'pl']= 'application/x-perl'; $formats[ 'pm']= 'application/x-perl'; $formats[ 'crl']= 'application/x-pkcs7-crl'; $formats[ 'rpm']= 'audio/x-pn-realaudio-plugin '; $formats[ 'shar']= 'application/x-shar'; $formats[ 'swf']= 'application/x-shockwave-flash'; $formats[ 'swfl']= 'application/x-shockwave-flash'; $formats[ 'sh']= 'text/x-sh'; $formats[ 'sit']= 'application/x-stuffit'; $formats[ 'sv4cpio']= 'application/x-sv4cpio'; $formats[ 'sv4crc']= 'application/x-sv4crc'; $formats[ 'tar']= 'application/x-tar'; $formats[ 'tcl']= 'text/x-tcl'; $formats[ 'tex']= 'text/x-tex'; $formats[ 'gf']= 'application/x-tex-gf'; $formats[ 'pk']= 'application/x-tex-pk'; $formats[ 'texinfo']= 'application/x-texinfo'; $formats[ 'texi']= 'application/x-texinfo'; $formats[ '~']= 'application/x-trash'; $formats[ '%']= 'application/x-trash'; $formats[ 'bak']= 'application/x-trash'; $formats[ 'old']= 'application/x-trash'; $formats[ 'sik']= 'application/x-trash'; $formats[ 't']= 'application/x-troff'; $formats[ 'tr']= 'application/x-troff'; $formats[ 'roff']= 'application/x-troff'; $formats[ 'man']= 'application/x-troff-man'; $formats[ 'me']= 'application/x-troff-me'; $formats[ 'ms']= 'application/x-troff-ms'; $formats[ 'ustar']= 'application/x-ustar'; $formats[ 'src']= 'application/x-wais-source'; $formats[ 'wz']= 'application/x-wingz'; $formats[ 'crt']= 'application/x-x509-ca-cert'; $formats[ 'fig']= 'application/x-xfig'; $formats[ 'au']= 'audio/basic'; $formats[ 'snd']= 'audio/basic'; $formats[ 'mid']= 'audio/midi'; $formats[ 'midi']= 'audio/midi'; $formats[ 'kar']= 'audio/midi'; $formats[ 'mpga']= 'audio/mpeg'; $formats[ 'mpega']= 'audio/mpeg'; $formats[ 'mp2']= 'audio/mpeg'; $formats[ 'mp3']= 'audio/mpeg'; $formats[ 'm3u']= 'audio/x-mpegurl'; $formats[ 'sid']= 'audio/prs.sid'; $formats[ 'aif']= 'audio/x-aiff'; $formats[ 'aiff']= 'audio/x-aiff'; $formats[ 'aifc']= 'audio/x-aiff'; $formats[ 'gsm']= 'audio/x-gsm'; $formats[ 'ra']= 'audio/x-realaudio '; $formats[ 'rm']= 'audio/x-pn-realaudio'; $formats[ 'ram']= 'audio/x-pn-realaudio'; $formats[ 'pls']= 'audio/x-scpls'; $formats[ 'wav']= 'audio/x-wav'; $formats[ 'pdb']= 'chemical/x-pdb'; $formats[ 'xyz']= 'chemical/x-xyz '; $formats[ 'bmp']= 'image/x-ms-bmp'; $formats[ 'gif']= 'image/gif'; $formats[ 'ief']= 'image/ief'; $formats[ 'jpeg']= 'image/jpeg'; $formats[ 'jpg']= 'image/jpeg'; $formats[ 'jpe']= 'image/jpeg'; $formats[ 'pcx']= 'image/pcx'; $formats[ 'png']= 'image/png'; $formats[ 'svg']= 'image/svg+xml'; $formats[ 'svgz']= 'image/svg+xml'; $formats[ 'tiff']= 'image/tiff'; $formats[ 'tif']= 'image/tiff'; $formats[ 'wbmp']= 'image/vnd.wap.wbmp'; $formats[ 'ras']= 'image/x-cmu-raster'; $formats[ 'cdr']= 'image/x-coreldraw'; $formats[ 'pat']= 'image/x-coreldrawpattern'; $formats[ 'cdt']= 'image/x-coreldrawtemplate'; $formats[ 'djvu']= 'image/x-djvu'; $formats[ 'djv']= 'image/x-djvu'; $formats[ 'jng']= 'image/x-jng'; $formats[ 'pnm']= 'image/x-portable-anymap'; $formats[ 'pbm']= 'image/x-portable-bitmap'; $formats[ 'pgm']= 'image/x-portable-graymap'; $formats[ 'ppm']= 'image/x-portable-pixmap'; $formats[ 'rgb']= 'image/x-rgb'; $formats[ 'xbm']= 'image/x-xbitmap'; $formats[ 'xpm']= 'image/x-xpixmap'; $formats[ 'xwd']= 'image/x-xwindowdump'; $formats[ 'igs']= 'model/iges'; $formats[ 'iges']= 'model/iges'; $formats[ 'msh']= 'model/mesh'; $formats[ 'mesh']= 'model/mesh'; $formats[ 'silo']= 'model/mesh'; $formats[ 'wrl']= 'x-world/x-vrml'; $formats[ 'vrml']= 'x-world/x-vrml'; $formats[ 'csv']= 'text/comma-separated-values'; $formats[ 'css']= 'text/css'; $formats[ 'htm']= 'text/html'; $formats[ 'html']= 'text/html'; $formats[ 'xhtml']= 'text/html'; $formats[ 'mml']= 'text/mathml'; $formats[ 'asc']= 'text/plain'; $formats[ 'txt']= 'text/plain'; $formats[ 'text']= 'text/plain'; $formats[ 'diff']= 'text/plain'; $formats[ 'rtx']= 'text/richtext'; $formats[ 'tsv']= 'text/tab-separated-values'; $formats[ 'wml']= 'text/vnd.wap.wml'; $formats[ 'wmls']= 'text/vnd.wap.wmlscript'; $formats[ 'xml']= 'text/xml'; $formats[ 'xsl']= 'text/xml'; $formats[ 'h++']= 'text/x-c++hdr'; $formats[ 'hpp']= 'text/x-c++hdr'; $formats[ 'hxx']= 'text/x-c++hdr'; $formats[ 'hh']= 'text/x-c++hdr'; $formats[ 'c++']= 'text/x-c++src'; $formats[ 'cpp']= 'text/x-c++src'; $formats[ 'cxx']= 'text/x-c++src'; $formats[ 'cc']= 'text/x-c++src'; $formats[ 'h']= 'text/x-chdr'; $formats[ 'c']= 'text/x-csrc'; $formats[ 'java']= 'text/x-java'; $formats[ 'moc']= 'text/x-moc'; $formats[ 'p']= 'text/x-pascal'; $formats[ 'pas']= 'text/x-pascal'; $formats[ 'etx']= 'text/x-setext'; $formats[ 'tk']= 'text/x-tcl'; $formats[ 'ltx']= 'text/x-tex'; $formats[ 'sty']= 'text/x-tex'; $formats[ 'cls']= 'text/x-tex'; $formats[ 'vcs']= 'text/x-vcalendar'; $formats[ 'vcf']= 'text/x-vcard'; $formats[ 'dl']= 'video/dl'; $formats[ 'fli']= 'video/fli'; $formats[ 'gl']= 'video/gl'; $formats[ 'mpeg']= 'video/mpeg'; $formats[ 'mpg']= 'video/mpeg'; $formats[ 'mpe']= 'video/mpeg'; $formats[ 'qt']= 'video/quicktime'; $formats[ 'mov']= 'video/quicktime'; $formats[ 'mxu']= 'video/vnd.mpegurl'; $formats[ 'mng']= 'video/x-mng'; $formats[ 'asf']= 'video/x-ms-asf'; $formats[ 'asx']= 'video/x-ms-asf'; $formats[ 'avi']= 'video/x-msvideo'; $formats[ 'movie']= 'video/x-sgi-movie'; $formats[ 'ice']= 'x-conference/x-cooltalk'; $formats[ 'vrm']= 'x-world/x-vrml'; $formats[ '']= ''; $home_files= $gConfig[ 'weburl']. $gConfig[ 'filesroot']; // if there are problems with unknown 'numrows', then make sure // to upgrade to a decent PEAR version. require_once('DB.php'); // do not change $MY_URI = 'http://'.$_SERVER['SERVER_NAME']. '/oai/'; // MUST (only one) // please adjust $repositoryName = $gConfig[ 'title_en']; //##$baseURL = $MY_URI; // You can use a static URI as well. $baseURL = $gConfig[ 'weburl']; $subdirFiles = $gConfig[ 'filesroot']; // do not change $protocolVersion = '2.0'; // How your repository handles deletions // no: The repository does not maintain status about deletions. // It MUST NOT reveal a deleted status. // persistent: The repository persistently keeps track about deletions // with no time limit. It MUST consistently reveal the status // of a deleted record over time. // transient: The repository does not guarantee that a list of deletions is // maintained. It MAY reveal a deleted status for records. // // If your database keeps track of deleted records change accordingly. // Currently if $record['deleted'] is set to 'true', $status_deleted is set. // Some lines in listidentifiers.php, listrecords.php, getrecords.php // must be changed to fit the condition for your database. $deletedRecord = 'no'; // MAY (only one) //granularity is days //$granularity = 'YYYY-MM-DD'; // granularity is seconds $granularity = 'YYYY-MM-DDThh:mm:ssZ'; // MUST (only one) // the earliest datestamp in your repository, // please adjust $sql= "SELECT MIN( `lastmodified`) FROM Metadata_Directory"; $result = $gDB->query( $sql); list( $lastmodified)= $result->fetchRow(); $earliestDatestamp= formatDatestamp( $lastmodified); // MUST (multiple) // please adjust $adminEmail = $gConfig[ 'e-mails']; //## // MAY (multiple) // Comment out, if you do not want to use it. // Currently only gzip is supported (you need output buffering turned on, // and php compiled with libgz). // The client MUST send "Accept-Encoding: gzip" to actually receive // compressed output. $compression = array( 'gzip'); // MUST (only one) // should not be changed $delimiter = ':'; // MUST (only one) // You may choose any name, but for repositories to comply with the oai // format for unique identifiers for items records. // see: http://www.openarchives.org/OAI/2.0/guidelines-oai-identifier.htm // Basically use domainname-word.domainname // please adjust $repositoryIdentifier = $gConfig[ 'repository_identifier']; //## // description is defined in identify.php $show_identifier = TRUE; // You may include details about your community and friends (other // data-providers). // Please check identify.php for other possible containers // in the Identify response // maximum mumber of the records to deliver // (verb is ListRecords) // If there are more records to deliver // a ResumptionToken will be generated. $MAXRECORDS = 50; // maximum mumber of identifiers to deliver // (verb is ListIdentifiers) // If there are more identifiers to deliver // a ResumptionToken will be generated. $MAXIDS = 200; // After 24 hours resumptionTokens become invalid. $tokenValid = 24*3600; $expirationdatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$tokenValid); // use this for testing purposes //$CONTENT_TYPE = 'Content-Type: text/plain'; // use this for production purposes $CONTENT_TYPE = 'Content-Type: text/xml; charset=utf-8'; // define all supported metadata formats // // myhandler is the name of the file that handles the request for the // specific metadata format. // [record_prefix] describes an optional prefix for the metadata // [record_namespace] describe the namespace for this prefix $METADATAFORMATS = array ( 'oai_dc' => array('metadataPrefix'=>'oai_dc', 'schema'=>'http://www.openarchives.org/OAI/2.0/oai_dc.xsd', 'metadataNamespace'=>'http://www.openarchives.org/OAI/2.0/oai_dc/', 'myhandler'=>'record_dc.php', 'record_prefix'=>'dc', 'record_namespace' => 'http://purl.org/dc/elements/1.1/' ), /* 'oai_ubwp' => array('metadataPrefix'=>'oai_ubwp', 'schema'=>'http://ir.ub.rug.nl/xsd/ubwp/1.0/oai_ubwp.xsd', 'metadataNamespace'=>'http://ir.ub.rug.nl/xsd/ubwp/1.0/', 'myhandler'=>'record_ubwp.php', 'record_prefix'=>'ubwp', 'record_namespace' => 'http://ir.ub.rug.nl/xsd/ubwp/1.0/elements/' ),*/ 'mepadb' => array('metadataPrefix'=>'mepadb', 'schema'=>'http://ir.ub.rug.nl/xsd/mepa/1.0/mepadb.xsd', 'metadataNamespace'=>'http://ir.ub.rug.nl/xsd/mepa/1.0/mepadb/', 'myhandler'=>'record_mepadb.php', 'record_prefix'=>'mr', 'record_namespace' => 'http://ir.ub.rug.nl/xsd/mepa/1.0/' ), 'rugdb' => array('metadataPrefix'=>'rugdb', 'schema'=>'http://ir.ub.rug.nl/xsd/1.0/rugdb.xsd', 'metadataNamespace'=>'http://ir.ub.rug.nl/xsd/1.0/rugdb/', 'myhandler'=>'record_rugdb.php', 'record_prefix'=>'record', 'record_namespace' => 'http://ir.ub.rug.nl/xsd/1.0/' ) //, //array('metadataPrefix'=>'olac', // 'schema'=>'http://www.language-archives.org/OLAC/olac-2.0.xsd', // 'metadataNamespace'=>'http://www.openarchives.org/OLAC/0.2/', // 'handler'=>'record_olac.php' //) ); // // DATABASE SETUP // // Data Source Name: This is the universal connection string // if you use something other than mysql edit accordingly. // Example for MySQL $DSN = "mysql://$cfg_usr:$cfg_password@$cfg_server/$cfg_database"; // Example for Oracle // $DSN = "oci8://$cfg_usr:$cfg_password@$cfg_database"; // We store multiple entries for one element in a single row // in the database. SQL['split'] ist the delimiter for these entries. // If you do not do this, do not define $SQL['split'] //##$SQL['split'] = ';'; // the name of the tables where your store your metadata $SQL[ 'directory']= 'Metadata_Directory'; $SQL[ 'file']= 'Metadata_File'; foreach( $gConfig[ 'oai_records'] as $oai_record) $SQL[ 'oai_records'][] = 'Metadata_'. $gConfig[ 'oai_records']; // the name of the column where you store your sequence // (or autoincrement values). $SQL['id_column'] = 'id'; // the name of the column where you store the unique identifiers // pointing to your item. // this is your internal identifier for the item $SQL['identifier'] = 'dbi'; // If you want to expand the internal identifier in some way // use this (but not for OAI stuff, see next line) $idPrefix = 'dbi/'; // this is your external (OAI) identifier for the item // this will be expanded to // oai:$repositoryIdentifier:$idPrefix$SQL['identifier'] // should not be changed $oaiprefix = "oai".$delimiter.$repositoryIdentifier.$delimiter.$idPrefix; // adjust anIdentifier with sample contents an identifier $sampleIdentifier = $oaiprefix.'43565cc053ba2'; // the name of the column where you store your datestamps $SQL[ 'datestamp'] = 'lastmodified'; #Datum $SQL[ 'created'] = 'created'; // the name of the column where you store information whether // a record has been deleted. Leave it as it is if you do not use // this feature. $SQL['deleted'] = ''; // Here are a couple of queries which might need to be adjusted to // your needs. Normally, if you have correctly named the columns above, // this does not need to be done. // this function should generate a query which will return // all records // the useless condition id_column = id_column is just there to ease // further extensions to the query, please leave it as it is. function selectallQuery( $id = '') { global $SQL; $query = 'SELECT * FROM '. $SQL[ 'directory'].' WHERE '; if ($id == '') { $query .= '1'; #$query .= $SQL['id_column'].' = '.$SQL['id_column']; } else { $query .= $SQL['identifier']." ='$id'"; } $query.= " AND `oai_record` LIKE '_%' AND publish= 'yes'"; return $query; } // this function will return identifier and datestamp for all records function idQuery( $id = '') { global $SQL, $sets; //print_r( $SQL); $query = 'select '.$SQL['identifier'].','.$SQL['datestamp']; $query .= ' FROM '. $SQL['table'].' WHERE '; if ($id == '') { $query .= '1'; #$query .= $SQL['id_column'].' = '.$SQL['id_column']; } else { $query .= $SQL['identifier']." = '$id'"; } $query.= " AND oairecord= 'yes' AND publish= 'yes'"; if( $SQL['set']) { if( $sets[ $SQL['set']]) { $query .= ' AND '. $sets[ $SQL['set']][ 'where']; } else { $query .= ' AND 0'; } } return $query; } // filter for until function untilQuery($until) { global $SQL; $query= ' and '.$SQL['datestamp']." <= '$until'"; return $query; } // filter for from function fromQuery($from) { global $SQL; return ' and '.$SQL[ 'datestamp']." >= '$from'"; } // filter for sets function setQuery($set) { global $SQL, $sets; #return ' and '.$SQL['set']." LIKE '%$set%'"; if( $sets[ $set]) { return ' and '. $sets[ $set][ 'where']; } else { return ' and 0'; } } // There is no need to change anything below. // Current Date $datetime = gmstrftime('%Y-%m-%dT%T'); $responseDate = $datetime.'Z'; // do not change $XMLHEADER = ' '."\n"; $xmlheader .= $XMLHEADER . ' '.$responseDate."\n"; // the xml schema namespace, do not change this $XMLSCHEMA = 'http://www.w3.org/2001/XMLSchema-instance'; ?>