droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007 Eclipse Foundation and others. |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Eclipse Foundation - Initial API and implementation |
| 11 | *******************************************************************************/ |
droy | 5c123fc | 2008-02-01 21:56:40 +0000 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * @deprecated - need to tie to project/versions |
| 15 | */ |
| 16 | |
| 17 | exit; |
| 18 | |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 19 | include("global.php"); |
| 20 | InitPage("login"); |
| 21 | |
droy | 8da30b3 | 2007-11-29 21:00:26 +0000 | [diff] [blame] | 22 | global $User; |
| 23 | if(!$User->is_committer) { |
droy | aa626d0 | 2007-11-29 21:03:17 +0000 | [diff] [blame] | 24 | exitTo("error.php?errNo=3214","error: 3214 - you must be an Eclipse committer to access this page."); |
droy | 8da30b3 | 2007-11-29 21:00:26 +0000 | [diff] [blame] | 25 | } |
| 26 | |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 27 | require(dirname(__FILE__) . "/../classes/file/file.class.php"); |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 28 | |
| 29 | |
| 30 | $pageTitle = "Babel - Import file"; |
| 31 | $pageKeywords = "import,properties,translation,language,nlpack,pack,eclipse,babel"; |
| 32 | |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 33 | $FILE_ID = getHTTPParameter("file_id"); |
| 34 | $PROJECT_ID = getHTTPParameter("project_id"); |
| 35 | $FULLPATH = getHTTPParameter("fullpath"); |
| 36 | $SUBMIT = getHTTPParameter("submit"); |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 37 | $strings = ""; |
| 38 | |
| 39 | if($SUBMIT == "Import") { |
| 40 | # Scanned document details |
| 41 | if(isset($_FILES) |
| 42 | && $_FILES['name']['size'] > 0 |
| 43 | && $_FILES['name']['size'] < 16777216) { |
| 44 | |
| 45 | $File = new File(); |
| 46 | $File->project_id = $PROJECT_ID; |
| 47 | $File->name = $FULLPATH; |
| 48 | if(!$File->save()) { |
| 49 | $GLOBALS['g_ERRSTRS'][0] = "An error occurred while saving the file."; |
| 50 | } |
| 51 | else { |
| 52 | # Start importing the strings! |
| 53 | $fh = fopen($_FILES['name']['tmp_name'], 'r'); |
| 54 | $size = filesize($_FILES['name']['tmp_name']); |
| 55 | |
| 56 | $content = fread($fh, $size); |
| 57 | fclose($fh); |
| 58 | |
| 59 | $filename = $_FILES['name']['name']; |
| 60 | if(stristr($filename, ".properties")) { |
| 61 | $strings = $File->parseProperties($content); |
| 62 | $aStrings = explode(",", $strings); |
| 63 | $FULLPATH = ""; |
| 64 | } |
| 65 | } |
| 66 | $filename = $_FILES['name']['name']; |
atoulme | 3e5e934 | 2009-01-23 17:34:30 +0000 | [diff] [blame] | 67 | $fullpath = getHTTPParameter("fullpath", "POST"); |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 68 | |
| 69 | if(!get_magic_quotes_gpc()){ |
| 70 | $filename = addslashes($filename); |
| 71 | } |
| 72 | $content = addslashes($content); |
| 73 | } |
| 74 | else { |
| 75 | $GLOBALS['g_ERRSTRS'][0] = "You must specify a file to import."; |
| 76 | } |
| 77 | } |
| 78 | |
atoulme | a4adf8e | 2009-01-27 19:01:35 +0000 | [diff] [blame] | 79 | global $addon; |
| 80 | $addon->callHook("head"); |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 81 | |
| 82 | include("content/en_import.php"); |
| 83 | |
atoulme | a4adf8e | 2009-01-27 19:01:35 +0000 | [diff] [blame] | 84 | global $addon; |
| 85 | $addon->callHook("footer"); |
droy | 8177747 | 2007-11-28 21:35:58 +0000 | [diff] [blame] | 86 | |
| 87 | ?> |