4 * http://opencaps.atrc.utoronto.ca
6 * Copyright 2010 Heidi Hazelton
7 * Adaptive Technology Resource Centre, University of Toronto
9 * Licensed under the Educational Community License (ECL), Version 2.0.
10 * You may not use this file except in compliance with this License.
11 * http://www.opensource.org/licenses/ecl2.php
15 if (!defined('INCLUDE_PATH')) {
16 define('INCLUDE_PATH', 'include/');
21 function matterhornAuth($rid, $uri, $content='') {
22 global $remote_systems, $this_proj;
24 $username = $remote_systems[$rid]['username'];
25 $password = $remote_systems[$rid]['password'];
28 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
30 curl_setopt($ch, CURLOPT_URL, $remote_systems[$rid]['url'].$uri);
31 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
32 curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
33 curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-Auth: Digest"));
35 if ($content == "media") {
36 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
38 $temp_file = 'projects/'.$this_proj->id.'/media'; //use tempname();
39 $fh = fopen($temp_file, 'w');
40 curl_setopt($ch, CURLOPT_FILE, $fh);
46 } else if (!empty($content)) {
47 curl_setopt($ch, CURLOPT_POST, 1);
48 curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
51 $response = curl_exec($ch);
52 $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);