Title: <?php
1lt?php //yum install php-pgsql.x86_64 use \PDO cl
ass Connection protected dbh function __const
ruct() global dbh try dbh new PDO("
pgsqlhostlocalhostport5432dbnamedspace","dsp
ace","dspace") catch(PDOException e)
//die("Error connecting to the database. Error is
").e-gterrorInfo echo e-gtgetMessage()
protected function error(e,sql) die("Databa
se Error.ltbrgtSQL was 'sql'ltbrgtError was
".e-gtgetMessage()) global dbh dbcon ne
w Connection() uri _SERVER'REQUEST_URI' ec
ho "Initial request uri is ".uri."ltbrgt"
sql "select text_value from metadatavalue
where metadata_field_id 25 and resource_id
(select resource_id from metadatavalue where
metadata_field_id 72 and text_value ?)"
uri "http//upetd.up.ac.za".uri
if(substr(uri,-1) ! "/") uri . "/" echo "
Rebuilt uri used for query is ".uri."ltbrgt"
data array(uri) sth dbh-gtprepare(sql) t
ry sth-gtexecute(data) row sth-gtfetch()
sth-gtcloseCursor() catch (PDOException e)
die(e-gtgetMessage()) newuri row0 ech
o "newuri newuri" if(newuri "") newuri
"https//repository.up.ac.za"
else newuri substr(newuri, 21) newuri
"https//repository.up.ac.za/handle".newuri
dbcon null echo "Redirecting to ".newuri h
eader("location".newuri) ?gt