View | Details | Raw Unified | Return to bug 7175
Collapse All | Expand All

(-)a/lib/pkp/classes/cliTool/CliTool.inc.php (-5 / +6 lines)
 Lines 19-33    Link Here 
19
 *  to bootstrap and route tool requests.
19
 *  to bootstrap and route tool requests.
20
 */
20
 */
21
21
22
// $Id$
23
24
25
/** Initialization code */
22
/** Initialization code */
26
define('PWD', getcwd());
23
define('INDEX_FILE_LOCATION', getcwd() . '/index.php');
27
chdir(dirname(INDEX_FILE_LOCATION)); /* Change to base directory */
24
if (!file_exists(getcwd() . '/config.TEMPLATE.inc.php')) {
25
	die("This script must be executed from the installation base directory.\n");
26
}
27
28
if (!defined('STDIN')) {
28
if (!defined('STDIN')) {
29
	define('STDIN', fopen('php://stdin','r'));
29
	define('STDIN', fopen('php://stdin','r'));
30
}
30
}
31
31
define('SESSION_DISABLE_INIT', 1);
32
define('SESSION_DISABLE_INIT', 1);
32
require('./lib/pkp/includes/bootstrap.inc.php');
33
require('./lib/pkp/includes/bootstrap.inc.php');
33
34
(-)a/lib/pkp/classes/cliTool/XmlToSqlTool.inc.php (-9 / +2 lines)
 Lines 54-69   class XmlToSqlTool extends CommandLineTool { Link Here 
54
54
55
		$this->command = $this->argv[$argOffset];
55
		$this->command = $this->argv[$argOffset];
56
56
57
		$file = isset($this->argv[$argOffset+1]) ? $this->argv[$argOffset+1] : DATABASE_XML_FILE;
57
		$this->inputFile = isset($this->argv[$argOffset+1]) ? $this->argv[$argOffset+1] : DATABASE_XML_FILE;
58
58
59
		if (!file_exists($file) && !file_exists(($file2 = PWD . '/' . $file))) {
59
		$this->outputFile = isset($this->argv[$argOffset+2]) ? $this->argv[$argOffset+2] : null;
60
			printf("Input file \"%s\" does not exist!\n", $file);
61
			exit(1);
62
		}
63
64
		$this->inputFile = isset($file2) ? $file2 : $file;
65
66
		$this->outputFile = isset($this->argv[$argOffset+2]) ? PWD . '/' . $this->argv[$argOffset+2] : null;
67
		if (in_array($this->command, array('save', 'save_upgrade')) && ($this->outputFile == null || (file_exists($this->outputFile) && (is_dir($this->outputFile) || !is_writeable($this->outputFile))) || !is_writable(dirname($this->outputFile)))) {
60
		if (in_array($this->command, array('save', 'save_upgrade')) && ($this->outputFile == null || (file_exists($this->outputFile) && (is_dir($this->outputFile) || !is_writeable($this->outputFile))) || !is_writable(dirname($this->outputFile)))) {
68
			printf("Invalid output file \"%s\"!\n", $this->outputFile);
61
			printf("Invalid output file \"%s\"!\n", $this->outputFile);
69
			exit(1);
62
			exit(1);
(-)a/lib/pkp/tests/phpunit.php (-3 / +4 lines)
 Lines 8-16    Link Here 
8
 */
8
 */
9
// Configure the index file location, assume that pkp-lib is
9
// Configure the index file location, assume that pkp-lib is
10
// included within a PKP application.
10
// included within a PKP application.
11
// FIXME: This doesn't work if lib/pkp is symlinked. realpath($_['SCRIPT_FILENAME'].'/../../index.php') could work but see http://bugs.php.net/bug.php?id=50366
11
define('INDEX_FILE_LOCATION', getcwd() . '/index.php');
12
define('INDEX_FILE_LOCATION', dirname(dirname(dirname(dirname(__FILE__)))).'/index.php');
12
if (!file_exists(getcwd() . '/config.TEMPLATE.inc.php')) {
13
chdir(dirname(INDEX_FILE_LOCATION));
13
	die("This script must be executed from the installation base directory.\n");
14
}
14
15
15
// Configure PKP error handling for tests
16
// Configure PKP error handling for tests
16
define('DONT_DIE_ON_ERROR', true);
17
define('DONT_DIE_ON_ERROR', true);
(-)a/lib/pkp/tools/phpCompat.php (-3 / +4 lines)
 Lines 40-49    Link Here 
40
 *        for information about detection accuracy.
40
 *        for information about detection accuracy.
41
 */
41
 */
42
42
43
// $Id$
43
define('INDEX_FILE_LOCATION', getcwd() . '/index.php');
44
if (!file_exists(getcwd() . '/config.TEMPLATE.inc.php')) {
45
	die("This script must be executed from the installation base directory.\n");
46
}
44
47
45
// FIXME: This doesn't work if lib/pkp is symlinked. realpath($_['SCRIPT_FILENAME'].'/../../index.php') could work but see http://bugs.php.net/bug.php?id=50366
46
define('INDEX_FILE_LOCATION', dirname(dirname(dirname(dirname(__FILE__)))) . '/index.php');
47
require_once(dirname(dirname(__FILE__)) . '/classes/cliTool/CliTool.inc.php');
48
require_once(dirname(dirname(__FILE__)) . '/classes/cliTool/CliTool.inc.php');
48
require_once('PHP/CompatInfo.php');
49
require_once('PHP/CompatInfo.php');
49
50
(-)a/plugins/importexport/native/NativeImportDom.inc.php (-25 lines)
 Lines 324-334   class NativeImportDom { Link Here 
324
			if (($href = $node->getChildByName('href'))) {
324
			if (($href = $node->getChildByName('href'))) {
325
				$url = $href->getAttribute('src');
325
				$url = $href->getAttribute('src');
326
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
326
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
327
					if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
328
						// The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
329
						$url = PWD . '/' . $url;
330
					}
331
332
					$originalName = basename($url);
327
					$originalName = basename($url);
333
					$newName .= $publicFileManager->getExtension($originalName);
328
					$newName .= $publicFileManager->getExtension($originalName);
334
					if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) {
329
					if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) {
 Lines 394-404   class NativeImportDom { Link Here 
394
			if (($href = $node->getChildByName('href'))) {
389
			if (($href = $node->getChildByName('href'))) {
395
				$url = $href->getAttribute('src');
390
				$url = $href->getAttribute('src');
396
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
391
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
397
					if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
398
						// The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
399
						$url = PWD . '/' . $url;
400
					}
401
402
					$originalName = basename($url);
392
					$originalName = basename($url);
403
					$newName .= $publicFileManager->getExtension($originalName);
393
					$newName .= $publicFileManager->getExtension($originalName);
404
					if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) {
394
					if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) {
 Lines 996-1006   class NativeImportDom { Link Here 
996
		if (($href = $node->getChildByName('href'))) {
986
		if (($href = $node->getChildByName('href'))) {
997
			$url = $href->getAttribute('src');
987
			$url = $href->getAttribute('src');
998
			if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
988
			if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
999
				if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
1000
					// The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
1001
					$url = PWD . '/' . $url;
1002
				}
1003
1004
				if (($fileId = $articleFileManager->copyPublicFile($url, $href->getAttribute('mime_type')))===false) {
989
				if (($fileId = $articleFileManager->copyPublicFile($url, $href->getAttribute('mime_type')))===false) {
1005
					$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
990
					$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
1006
					return false;
991
					return false;
 Lines 1050-1060   class NativeImportDom { Link Here 
1050
			if (($href = $node->getChildByName('href'))) {
1035
			if (($href = $node->getChildByName('href'))) {
1051
				$url = $href->getAttribute('src');
1036
				$url = $href->getAttribute('src');
1052
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
1037
				if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
1053
					if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
1054
						// The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
1055
						$url = PWD . '/' . $url;
1056
					}
1057
1058
					if (($fileId = $articleFileManager->copyPublicFile($url, $href->getAttribute('mime_type')))===false) {
1038
					if (($fileId = $articleFileManager->copyPublicFile($url, $href->getAttribute('mime_type')))===false) {
1059
						$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
1039
						$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
1060
						return false;
1040
						return false;
 Lines 1206-1216   class NativeImportDom { Link Here 
1206
		if (($href = $fileNode->getChildByName('href'))) {
1186
		if (($href = $fileNode->getChildByName('href'))) {
1207
			$url = $href->getAttribute('src');
1187
			$url = $href->getAttribute('src');
1208
			if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
1188
			if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) {
1209
				if ($isCommandLine && NativeImportDom::isRelativePath($url)) {
1210
					// The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place.
1211
					$url = PWD . '/' . $url;
1212
				}
1213
1214
				if (($fileId = $articleFileManager->copySuppFile($url, $href->getAttribute('mime_type')))===false) {
1189
				if (($fileId = $articleFileManager->copySuppFile($url, $href->getAttribute('mime_type')))===false) {
1215
					$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
1190
					$errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url));
1216
					return false;
1191
					return false;
(-)a/plugins/importexport/native/NativeImportExportPlugin.inc.php (-4 lines)
 Lines 343-352   class NativeImportExportPlugin extends ImportExportPlugin { Link Here 
343
		}
343
		}
344
344
345
		$this->import('NativeImportDom');
345
		$this->import('NativeImportDom');
346
		if ($xmlFile && NativeImportDom::isRelativePath($xmlFile)) {
347
			$xmlFile = PWD . '/' . $xmlFile;
348
		}
349
350
		switch ($command) {
346
		switch ($command) {
351
			case 'import':
347
			case 'import':
352
				$userName = array_shift($args);
348
				$userName = array_shift($args);

Return to bug 7175