function http_put($url, $bytes, $headers = array(), $more = array())
{
    $ch = _http_curl_handle($url, $headers, $more);
    # See the monster you've created, Roy? See???!?!?!!
    if (isset($more['donotsend_transfer_encoding'])) {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    } else {
        curl_setopt($ch, CURLOPT_PUT, true);
    }
    curl_setopt($ch, CURLOPT_POSTFIELDS, $bytes);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    # TODO: sort out PUT-ing files
    # curl_setopt($ch, CURLOPT_INFILE, $bytes);
    # curl_setopt($ch, CURLOPT_INFILESIZE, strlen($bytes));
    if ($more['return_curl_handle']) {
        return $ch;
    }
    return _http_request($ch, $url, $more);
}
Example #2
0
/**
 * Check if the current installation is up to date
 * The code is borrowed from phpBB and slighlty modified
 * @author The phpBB Group <*****@*****.**> (the code)
 * @author Patrick Cool <*****@*****.**>, Ghent University (the modifications)
 * @author Yannick Warnier <*****@*****.**> for the move to HTTP request
 * @copyright (C) 2001 The phpBB Group
 * @return string language string with some layout (color)
 */
function check_system_version()
{
    global $_configuration;
    $system_version = trim($_configuration['system_version']);
    // the chamilo version of your installation
    if (ini_get('allow_url_fopen') == 1) {
        // The number of courses
        $number_of_courses = Statistics::countCourses();
        // The number of users
        $number_of_users = Statistics::countUsers();
        $number_of_active_users = Statistics::countUsers(null, null, null, true);
        // The number of sessions
        $number_of_sessions = Statistics::countSessions();
        $data = array('url' => api_get_path(WEB_PATH), 'campus' => api_get_setting('platform.site_name'), 'contact' => api_get_setting('admin.administrator_email'), 'version' => $system_version, 'numberofcourses' => $number_of_courses, 'numberofusers' => $number_of_users, 'numberofactiveusers' => $number_of_active_users, 'numberofsessions' => $number_of_sessions, 'donotlistcampus' => api_get_setting('platform.donotlistcampus'), 'organisation' => api_get_setting('platform.institution'), 'language' => api_get_setting('language.platform_language'), 'adminname' => api_get_setting('admin.administrator_name') . ' ' . api_get_setting('admin.administrator_surname'), 'ip' => $_SERVER['REMOTE_ADDR']);
        $version = null;
        // version.php has been updated to include the version in an HTTP header
        // called "X-Chamilo-Version", so that we don't have to worry about
        // issues with the content not being returned by fread for some reason
        $res = _http_request('version.chamilo.org', 80, '/version.php', $data, 5, null, true);
        $lines = preg_split('/\\r\\n/', $res);
        foreach ($lines as $line) {
            $elements = preg_split('/:/', $line);
            // extract the X-Chamilo-Version header from the version.php response
            if (strcmp(trim($elements[0]), 'X-Chamilo-Version') === 0) {
                $version = trim($elements[1]);
            }
        }
        if (substr($res, 0, 5) != 'Error') {
            if (empty($version)) {
                $version_info = $res;
            } else {
                $version_info = $version;
            }
            if ($system_version != $version_info) {
                $output = '<br /><span style="color:red">' . get_lang('YourVersionNotUpToDate') . '. ' . get_lang('LatestVersionIs') . ' <b>Chamilo ' . $version_info . '</b>. ' . get_lang('YourVersionIs') . ' <b>Chamilo ' . $system_version . '</b>. ' . str_replace('http://www.chamilo.org', '<a href="http://www.chamilo.org">http://www.chamilo.org</a>', get_lang('PleaseVisitOurWebsite')) . '</span>';
            } else {
                $output = '<br /><span style="color:green">' . get_lang('VersionUpToDate') . ': Chamilo ' . $version_info . '</span>';
            }
        } else {
            $output = '<span style="color:red">' . get_lang('ImpossibleToContactVersionServerPleaseTryAgain') . '</span>';
        }
    } else {
        $output = '<span style="color:red">' . get_lang('AllowurlfopenIsSetToOff') . '</span>';
    }
    return $output;
}
Example #3
0
<?php

session_start();
require_once "OAuth.php";
require_once "config.php";
$offset = readGetParam('page', 0) - 1;
$meetup_url = 'https://api.meetup.com/2/members?group_id=' . $_REQUEST['group_id'] . '&page=' . readGetParam('limit', 20) . "&offset=" . $offset;
$signature = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer($key, $secret, NULL);
$token = new OAuthConsumer($oauth_token_per, $oauth_token_secret_per, 1);
$request = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", $meetup_url);
$request->sign_request($signature, $consumer, $token);
$header = $request->to_header("https://api.meetup.com");
error_log('2_members_URL:' . $meetup_url);
$meetup_response = _http_request($meetup_url, $header);
jsonEcho($meetup_response);
Example #4
0
<?php

session_start();
require_once "OAuth.php";
require_once "config.php";
if (!empty($_REQUEST) && is_array($_REQUEST)) {
    $fields_string_arr = array();
    foreach ($_REQUEST as $key => $value) {
        if (preg_match('/^answer\\_/', $key)) {
            $fields_string_arr[$key] = $value;
        }
    }
    $fields_string_arr['group_id'] = $_REQUEST['group_id'];
    $fields_string_arr['group_urlname'] = $_REQUEST['group_urlname'];
    $fields_string_arr['intro'] = 'hello';
    //Join Group URL
    $url_join_group = 'https://api.meetup.com/2/profile';
    $signature = new OAuthSignatureMethod_HMAC_SHA1();
    $consumer = new OAuthConsumer($key, $secret, NULL);
    $token = new OAuthConsumer($oauth_token_per, $oauth_token_secret_per, 1);
    $request = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url_join_group);
    $request->sign_request($signature, $consumer, $token);
    $header = $request->to_header();
    error_log('2_rsvps_URL:' . $meetup_url . ' , group_id:' . $fields_string_arr['group_id'] . " , member_id:" . $member_id);
    $response_join = _http_request($url_join_group, $header, $fields_string_arr, 'POST');
    jsonEcho($response_join);
}
<?php

session_start();
require_once "OAuth.php";
require_once "config.php";
$fields_string_arr['event_id'] = $_REQUEST['event_id'];
$fields_string_arr['comment'] = $_REQUEST['comment'];
//Join Group URL
$meetup_url = 'https://api.meetup.com/2/event_comment';
$signature = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer($key, $secret, NULL);
$token = new OAuthConsumer($oauth_token_per, $oauth_token_secret_per, 1);
$request = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $meetup_url);
$request->sign_request($signature, $consumer, $token);
$header = $request->to_header();
error_log('2_event_comment_URL:' . $meetup_url . " event_id:" . $fields_string_arr['event_id'] . " , comment:" . $fields_string_arr['comment']);
$meetup_response = _http_request($meetup_url, $header, $fields_string_arr, 'POST');
jsonEcho($meetup_response);
Example #6
0
$consumer = new OAuthConsumer($key, $secret, NULL);
$token = new OAuthConsumer($_REQUEST['oauth_token'], $db_oauth_token_secret, 1);
$signature = new OAuthSignatureMethod_HMAC_SHA1();
$request = OAuthRequest::from_consumer_and_token($consumer, $token, "POST", $url);
$request->set_parameter("oauth_verifier", $_REQUEST['oauth_verifier']);
$request->sign_request($signature, $consumer, $token);
$header = $request->to_header("https://api.meetup.com");
$response = _http_request($url, $header, 'token_request');
parse_str($response, $tokens_per);
$oauth_token_per = $tokens_per['oauth_token'];
$oauth_token_secret_per = $tokens_per['oauth_token_secret'];
$member_id = $tokens_per['member_id'];
$_SESSION['active_tokens'] = $tokens_per;
$url_self = 'https://api.meetup.com/members.json/?relation=self';
$signature = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer($key, $secret, NULL);
$token = new OAuthConsumer($oauth_token_per, $oauth_token_secret_per, 1);
$request = OAuthRequest::from_consumer_and_token($consumer, $token, "GET", $url_self);
$request->sign_request($signature, $consumer, $token);
$header = $request->to_header("https://api.meetup.com");
$response = _http_request($url_self, $header);
$_SESSION['member_info'] = $response;
error_log('$tokens_per:' . $tokens_per);
error_log('reeesponse:' . $response);
$thirtydays = time() + 60 * 60 * 24 * 30;
setcookie('oauth_token', $oauth_token_per, $thirtydays, '/');
setcookie('oauth_token_secret', $oauth_token_secret_per, $thirtydays, '/');
setcookie('member_id', $member_id, $thirtydays, '/');
// Meetcha
$destination_with_param = $destination;
Header("Location: {$destination_with_param}");