| 1 |
yamaji |
1.1 |
<?php |
| 2 |
|
|
// $Revision: 1.7 $ // |
| 3 |
|
|
// ------------------------------------------------------------------------ // |
| 4 |
|
|
// // |
| 5 |
|
|
// OAI-PMH based Institutional Repository Introduction Module // |
| 6 |
|
|
// Copyright (C) 2005 Kazutsuna YAMAJI. All rights reserved. // |
| 7 |
|
|
// // |
| 8 |
|
|
// ------------------------------------------------------------------------ // |
| 9 |
|
|
// This program is free software; you can redistribute it and/or modify // |
| 10 |
|
|
// it under the terms of the GNU General Public License as published by // |
| 11 |
|
|
// the Free Software Foundation; either version 2 of the License, or // |
| 12 |
|
|
// (at your option) any later version. // |
| 13 |
|
|
// // |
| 14 |
|
|
// You may not change or alter any portion of this comment or credits // |
| 15 |
|
|
// of supporting developers from this source code or any supporting // |
| 16 |
|
|
// source code which is considered copyrighted (c) material of the // |
| 17 |
|
|
// original comment or credit authors. // |
| 18 |
|
|
// // |
| 19 |
|
|
// This program is distributed in the hope that it will be useful, // |
| 20 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
| 21 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
| 22 |
|
|
// GNU General Public License for more details. // |
| 23 |
|
|
// // |
| 24 |
|
|
// You should have received a copy of the GNU General Public License // |
| 25 |
|
|
// along with this program; if not, write to the Free Software // |
| 26 |
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
| 27 |
|
|
// ------------------------------------------------------------------------ // |
| 28 |
|
|
|
| 29 |
|
|
$xoopsOption['pagetype'] = 'user'; |
| 30 |
|
|
include_once "../../mainfile.php"; |
| 31 |
|
|
include_once XOOPS_ROOT_PATH.'/class/logger.php'; |
| 32 |
|
|
include_once XOOPS_ROOT_PATH.'/include/functions.php'; |
| 33 |
|
|
|
| 34 |
|
|
include_once XOOPS_ROOT_PATH.'/class/database/databasefactory.php'; |
| 35 |
|
|
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
| 36 |
|
|
|
| 37 |
|
|
include_once XOOPS_ROOT_PATH.'/kernel/object.php'; |
| 38 |
|
|
include_once XOOPS_ROOT_PATH.'/class/criteria.php'; |
| 39 |
|
|
include_once XOOPS_ROOT_PATH."/class/module.textsanitizer.php"; |
| 40 |
|
|
|
| 41 |
|
|
$config_handler =& xoops_gethandler('config'); |
| 42 |
|
|
$xoopsConfig =& $config_handler->getConfigsByCat(XOOPS_CONF); |
| 43 |
|
|
|
| 44 |
|
|
$language = $xoopsConfig['language']; |
| 45 |
|
|
if ( file_exists("./language/$language/main.php") ) { |
| 46 |
|
|
include_once "./language/$language/main.php"; |
| 47 |
|
|
} else { |
| 48 |
|
|
include_once "./language/english/main.php"; |
| 49 |
|
|
} |
| 50 |
|
|
|
| 51 |
|
|
include_once 'oaiclass.php'; |
| 52 |
|
|
|
| 53 |
|
|
// Output the result by HTML format $mode='html' |
| 54 |
|
|
// Output the result by TEXT format $mode='text' |
| 55 |
|
|
$mode = 'text'; |
| 56 |
|
|
|
| 57 |
|
|
// If the $xoopsUser is undefined -> ask ID and Password |
| 58 |
|
|
// login to XOOPS by obtained ID and Password |
| 59 |
|
|
// Fail to login -> BYE |
| 60 |
|
|
if ( !$xoopsUser ) { |
| 61 |
|
|
if (!isset($_SERVER['PHP_AUTH_USER'])) { |
| 62 |
|
|
header("WWW-Authenticate: Basic realm=\"IRview harvesting\""); |
| 63 |
|
|
header("HTTP/1.0 401 Unauthorized"); |
| 64 |
|
|
echo "Unauthorized your access\n"; |
| 65 |
|
|
exit; |
| 66 |
|
|
} else { |
| 67 |
|
|
$uname = $_SERVER['PHP_AUTH_USER']; |
| 68 |
|
|
$pass = $_SERVER['PHP_AUTH_PW']; |
| 69 |
|
|
$member_handler =& xoops_gethandler('member'); |
| 70 |
|
|
$myts =& MyTextsanitizer::getInstance(); |
| 71 |
|
|
$xoopsUser =& $member_handler->loginUser(addslashes($myts->stripSlashesGPC($uname)), addslashes($myts->stripSlashesGPC($pass))); |
| 72 |
|
|
if( !$xoopsUser ){ |
| 73 |
|
|
echo "Unauthorized your account"; |
| 74 |
|
|
exit; |
| 75 |
|
|
} |
| 76 |
|
|
$uid = $xoopsUser -> getVar( 'uid' ); |
| 77 |
|
|
} |
| 78 |
|
|
$mode='text'; |
| 79 |
|
|
}else{ |
| 80 |
|
|
$uid = $_SESSION['xoopsUserId']; |
| 81 |
|
|
$mode='html'; |
| 82 |
|
|
} |
| 83 |
|
|
// Only the XOOPS Admin can execute this PHP |
| 84 |
|
|
global $xoopsDB, $xoopsModule; |
| 85 |
|
|
if( !$xoopsUser->isAdmin( $xoopsModule->getVar( 'mid' ) ) ) { |
| 86 |
|
|
redirect_header( XOOPS_URL.'/index.php', 3, _MD_IRVIEW_ACCESS_FORBIDDEN); |
| 87 |
|
|
} |
| 88 |
|
|
|
| 89 |
|
|
if( $mode == 'html' ){ |
| 90 |
|
|
include XOOPS_ROOT_PATH.'/header.php'; |
| 91 |
|
|
echo "<p>\n"; |
| 92 |
|
|
echo "<h3>"._MD_IRVIEW_OAIPMH_HARVEST_RESULT."</h3>\n"; |
| 93 |
|
|
echo "</p>\n"; |
| 94 |
|
|
echo "<a href='admin/oaipmh.php'>"._MD_IRVIEW_BACK_TO_OAIPMH_CONFIGURATION."</a><br />"; |
| 95 |
|
|
echo "<p>\n"; |
| 96 |
|
|
}else if( $mode == 'text' ) |
| 97 |
|
|
header( "Content-type: text/plain" ); |
| 98 |
|
|
|
| 99 |
|
|
$result = $xoopsDB -> query( "SELECT URL FROM ".$xoopsDB -> prefix( 'irview_repositories' )." WHERE enabled=1 AND deleted!=1 ORDER BY sort" ); |
| 100 |
|
|
// commented out for the safe mode server |
| 101 |
|
|
set_time_limit( 0 ); |
| 102 |
|
|
while( list( $url ) = $xoopsDB -> fetchRow( $result ) ){ |
| 103 |
|
|
echo "Trying\t$url"; |
| 104 |
|
|
if( $mode == 'html' ) echo "<br />\n"; |
| 105 |
|
|
else if( $mode == 'text' ) echo "\n"; |
| 106 |
|
|
$h = new OAIPMHHarvester( $url ); |
| 107 |
|
|
if( !$h -> harvest() ){ |
| 108 |
|
|
echo 'ERROR:'.$h -> last_error( ); |
| 109 |
|
|
}else{ |
| 110 |
|
|
echo "Succeed\t${url}"; |
| 111 |
|
|
} |
| 112 |
|
|
if( $mode == 'html' ) echo "<br />\n"; |
| 113 |
|
|
else if( $mode == 'text' ) echo "\n"; |
| 114 |
|
|
} |
| 115 |
|
|
|
| 116 |
|
|
if( $mode == 'html' ){ |
| 117 |
|
|
echo "</p>\n"; |
| 118 |
|
|
echo "<a href='admin/oaipmh.php'>"._MD_IRVIEW_BACK_TO_OAIPMH_CONFIGURATION."</a><br />"; |
| 119 |
|
|
include XOOPS_ROOT_PATH.'/footer.php'; |
| 120 |
|
|
} |
| 121 |
|
|
|
| 122 |
|
|
// |
| 123 |
|
|
// Write the repository records graph from the harvested data |
| 124 |
|
|
// |
| 125 |
|
|
include 'graph-write.php'; |
| 126 |
|
|
|
| 127 |
|
|
?> |