ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ.. /** * This file contains the class moodle_google_curlio. * * @package core_google * @copyright 2013 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir . '/filelib.php'); /** * Class moodle_google_curlio. * * The initial purpose of this class is to add support for our * class curl in Google_IO_Curl. It mostly entirely overrides it. * * @package core_google * @copyright 2013 Frédéric Massart * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class moodle_google_curlio extends Google_IO_Curl { /** @var array associate array of constant value and their name. */ private static $constants = null; /** @var array options. */ private $options = array(); /** * Send the request via our curl object. * * @param curl $curl prepared curl object. * @param Google_HttpRequest $request The request. * @return string result of the request. */ private function do_request($curl, $request) { $url = $request->getUrl(); $method = $request->getRequestMethod(); switch (strtoupper($method)) { case 'POST': $ret = $curl->post($url, $request->getPostBody()); break; case 'GET': $ret = $curl->get($url); break; case 'HEAD': $ret = $curl->head($url); break; case 'PUT': $ret = $curl->put($url); break; default: throw new coding_exception('Unknown request type: ' . $method); break; } return $ret; } /** * Execute an API request. * * This is a copy/paste from the parent class that uses Moodle's implementation * of curl. Portions have been removed or altered. * * @param Google_Http_Request $request the http request to be executed * @return Google_Http_Request http request with the response http code, response * headers and response body filled in * @throws Google_IO_Exception on curl or IO error */ public function executeRequest(Google_Http_Request $request) { $curl = new curl(); if ($request->getPostBody()) { $curl->setopt(array('CURLOPT_POSTFIELDS' => $request->getPostBody())); } $requestHeaders = $request->getRequestHeaders(); if ($requestHeaders && is_array($requestHeaders)) { $curlHeaders = array(); foreach ($requestHeaders as $k => $v) { $curlHeaders[] = "$k: $v"; } $curl->setopt(array('CURLOPT_HTTPHEADER' => $curlHeaders)); } $curl->setopt(array('CURLOPT_URL' => $request->getUrl())); $curl->setopt(array('CURLOPT_CUSTOMREQUEST' => $request->getRequestMethod())); $curl->setopt(array('CURLOPT_USERAGENT' => $request->getUserAgent())); $curl->setopt(array('CURLOPT_FOLLOWLOCATION' => false)); $curl->setopt(array('CURLOPT_SSL_VERIFYPEER' => true)); $curl->setopt(array('CURLOPT_RETURNTRANSFER' => true)); $curl->setopt(array('CURLOPT_HEADER' => true)); if ($request->canGzip()) { $curl->setopt(array('CURLOPT_ENCODING' => 'gzip,deflate')); } $curl->setopt($this->options); $respdata = $this->do_request($curl, $request); $infos = $curl->get_info(); $respheadersize = $infos['header_size']; $resphttpcode = (int) $infos['http_code']; $curlerrornum = $curl->get_errno(); $curlerror = $curl->error; if ($curlerrornum != CURLE_OK) { throw new Google_IO_Exception($curlerror); } list($responseHeaders, $responseBody) = $this->parseHttpResponse($respdata, $respheadersize); return array($responseBody, $responseHeaders, $resphttpcode); } /** * Set curl options. * * We overwrite this method to ensure that the data passed meets * the requirement of our curl implementation and so that the keys * are strings, and not curl constants. * * @param array $optparams Multiple options used by a cURL session. * @return void */ public function setOptions($optparams) { $safeparams = array(); foreach ($optparams as $name => $value) { if (!is_string($name)) { $name = $this->get_option_name_from_constant($name); } $safeparams[$name] = $value; } $this->options = $options + $this->options; } /** * Set the maximum request time in seconds. * * Overridden to use the right option key. * * @param $timeout in seconds */ public function setTimeout($timeout) { // Since this timeout is really for putting a bound on the time // we'll set them both to the same. If you need to specify a longer // CURLOPT_TIMEOUT, or a tigher CONNECTTIMEOUT, the best thing to // do is use the setOptions method for the values individually. $this->options['CURLOPT_CONNECTTIMEOUT'] = $timeout; $this->options['CURLOPT_TIMEOUT'] = $timeout; } /** * Get the maximum request time in seconds. * * Overridden to use the right option key. * * @return timeout in seconds. */ public function getTimeout() { return $this->options['CURLOPT_TIMEOUT']; } /** * Return the name of an option based on the constant value. * * @param int $constant value of a CURL constant. * @return string name of the constant if found, or throws exception. * @throws coding_exception when the constant is not found. * @since Moodle 2.5 */ public function get_option_name_from_constant($constant) { if (is_null(self::$constants)) { $constants = get_defined_constants(true); $constants = isset($constants['curl']) ? $constants['curl'] : array(); $constants = array_flip($constants); self::$constants = $constants; } if (isset(self::$constants[$constant])) { return self::$constants[$constant]; } throw new coding_exception('Unknown curl constant value: ' . $constant); } }