-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b9689
commit 9df2b77
Showing
9 changed files
with
205 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 61 additions & 61 deletions
122
quizzes/lib/com/wiris/system/service/HttpRequest.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
|
||
class com_wiris_system_service_HttpRequest { | ||
public $extraParams; | ||
private $wrap; | ||
|
||
public function __construct() { | ||
if(!php_Boot::$skip_constructor) { | ||
$this->extraParams = new Hash(); | ||
$this->wrap = com_wiris_system_CallWrapper::getInstance(); | ||
}} | ||
|
||
public function setParameter($key, $value) { | ||
$this->extraParams->set($key, $value); | ||
} | ||
public function getParameterNames() { | ||
// At this point we need to access directly to $_GET and $_POST variables because | ||
// we don't know what params are sended via POST or GET. | ||
// For security reasons this method only returns the params names. | ||
// To get the param value optional_param method. | ||
$param = new _hx_array(array()); | ||
$key = ""; | ||
foreach ($_GET as $key => $value) { | ||
$param->insert(0, $key); | ||
} | ||
foreach ($_POST as $key => $value) { | ||
$param->insert(0, $key); | ||
} | ||
return $param; | ||
} | ||
|
||
public function getContextURL() { | ||
return ""; | ||
} | ||
|
||
public function getParameter($key) { | ||
$this->wrap->stop(); | ||
$parameter = null; | ||
if (optional_param($key, null, PARAM_RAW) != null) { | ||
$parameter = optional_param($key, null, PARAM_RAW); | ||
} else { | ||
if ($this->extraParams->exists($key)) { | ||
$parameter = $this->extraParams->get($key); | ||
} | ||
} | ||
$this->wrap->start(); | ||
return $parameter; | ||
} | ||
|
||
public function __construct() { | ||
if(!php_Boot::$skip_constructor) { | ||
$this->extraParams = new Hash(); | ||
$this->headers = new Hash(); | ||
$this->setHeaders(); | ||
}} | ||
public function getHeader($key) { | ||
$httpKey = null; | ||
$httpKey = "HTTP_" . $this->headers->get($key); | ||
$header = null; | ||
$header = isset($_SERVER[$httpKey]) ? $_SERVER[$httpKey] : ''; | ||
return $header; | ||
} | ||
public function setParameter($key, $value) { | ||
$this->extraParams->set($key, $value); | ||
} | ||
public function getParameterNames() { | ||
$param = new _hx_array(array()); | ||
$key = ""; | ||
foreach ($_GET as $key => $value) { | ||
$param->insert(0, $key); | ||
} | ||
foreach ($_POST as $key => $value) { | ||
$param->insert(0, $key); | ||
} | ||
return $param; | ||
} | ||
public function getContextURL() { | ||
return ""; | ||
} | ||
public function getParameter($key) { | ||
$param = null; | ||
if(isset($_POST[$key])) { | ||
$param = $_POST[$key]; | ||
} else { | ||
if(isset($_GET[$key])) { | ||
$param = $_GET[$key]; | ||
} else { | ||
if($this->extraParams->exists($key)) { | ||
return $this->extraParams->get($key); | ||
} | ||
} | ||
} | ||
return $param; | ||
} | ||
public function setHeaders() { | ||
$this->headers->set("User-Agent", "USER_AGENT"); | ||
} | ||
public $headers; | ||
public $extraParams; | ||
public function __call($m, $a) { | ||
if(isset($this->$m) && is_callable($this->$m)) | ||
return call_user_func_array($this->$m, $a); | ||
else if(isset($this->»dynamics[$m]) && is_callable($this->»dynamics[$m])) | ||
return call_user_func_array($this->»dynamics[$m], $a); | ||
else if('toString' == $m) | ||
return $this->__toString(); | ||
else | ||
throw new HException('Unable to call «'.$m.'»'); | ||
} | ||
function __toString() { return 'com.wiris.system.service.HttpRequest'; } | ||
} |
Oops, something went wrong.