4875: Use HTTPRequest class for importing IMS Common Cartridges
authorTJ <acontent@iam.tj>
Thu, 6 Oct 2011 11:29:37 +0000 (12:29 +0100)
committerTJ <acontent@iam.tj>
Fri, 21 Oct 2011 15:08:42 +0000 (16:08 +0100)
home/ims/ims_import.php

index 57ba69c..a1cd1e3 100644 (file)
@@ -70,6 +70,7 @@ require_once(TR_INCLUDE_PATH.'classes/DAO/ContentDAO.class.php');
 require_once(TR_INCLUDE_PATH.'classes/DAO/TestsQuestionsAssocDAO.class.php');
 require_once(TR_INCLUDE_PATH.'classes/DAO/ContentTestsAssocDAO.class.php');
 require_once(TR_INCLUDE_PATH.'classes/FileUtility.class.php'); /* for clr_dir() and preImportCallBack and dirsize() */
+require_once(TR_INCLUDE_PATH.'classes/HTTPRequest.class.php'); /* for importing from remote servers that use Cookies and/or redirection */
 
 require_once(TR_INCLUDE_PATH.'lib/pclzip.lib.php');
 require_once(TR_INCLUDE_PATH.'lib/pclzip_callback.lib.php');
@@ -808,7 +809,8 @@ if(isset($_POST['ignore_validation']) && $_POST['ignore_validation']==1) {
 }
 
 if (isset($_REQUEST['url']) && ($_REQUEST['url'] != 'http://') ) {
-       if ($content = @file_get_contents($_REQUEST['url'])) {
+       $http_req = new HTTPRequest($_REQUEST['url'], array());
+       if ($content = $http_req->DownloadToString()) {
                $filename = substr(time(), -6). '.zip';
                $full_filename = TR_CONTENT_DIR . $filename;
 
@@ -1445,4 +1447,4 @@ if ($oauth_import) {
 }
 exit;
 
-?>
\ No newline at end of file
+?>