/** * * Save proxy settings * * @access public * */ public function saveProxyObject() { global $tpl, $ilAccess, $ilSetting, $lng; if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) { $this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE); } require_once './Services/Http/classes/class.ilProxySettings.php'; $this->initProxyForm(); $isFormValid = $this->form->checkInput(); ilProxySettings::_getInstance()->isActive((int) $this->form->getInput('proxy_status'))->setHost(trim($this->form->getInput('proxy_host')))->setPort(trim($this->form->getInput('proxy_port'))); if ($isFormValid) { if (ilProxySettings::_getInstance()->isActive()) { if (!strlen(ilProxySettings::_getInstance()->getHost())) { $isFormValid = false; $this->form->getItemByPostVar('proxy_host')->setAlert($lng->txt('msg_input_is_required')); } if (!strlen(ilProxySettings::_getInstance()->getPort())) { $isFormValid = false; $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('msg_input_is_required')); } if (!preg_match('/[0-9]{1,}/', ilProxySettings::_getInstance()->getPort()) || ilProxySettings::_getInstance()->getPort() < 0 || ilProxySettings::_getInstance()->getPort() > 65535) { $isFormValid = false; $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('proxy_port_numeric')); } } if ($isFormValid) { ilProxySettings::_getInstance()->save(); ilUtil::sendSuccess($lng->txt('saved_successfully')); if (ilProxySettings::_getInstance()->isActive()) { $this->printProxyStatus(); } } else { ilUtil::sendFailure($lng->txt('form_input_not_valid')); } } $this->form->setValuesByPost(); $tpl->setContent($this->form->getHTML()); }
function __validateLinks($a_links) { global $tree; if (!@(include_once 'HTTP/Request.php')) { $this->__appendLogMessage('LinkChecker: Pear HTTP_Request is not installed. Aborting'); return array(); } foreach ($a_links as $link) { // #10091 - internal if ($link['scheme'] == 'internal') { $obj_id = ilObject::_lookupObjId($link['ref_id']); if (!$obj_id || ilObject::_lookupType($obj_id) != $link['obj_type'] || $tree->isDeleted($link['ref_id'])) { $invalid[] = $link; } } else { if (gethostbyname($link['host']) == $link['host']) { $invalid[] = $link; continue; } if ($link['scheme'] !== 'http' and $link['scheme'] !== 'https') { continue; } require_once './Services/Http/classes/class.ilProxySettings.php'; if (ilProxySettings::_getInstance()->isActive()) { $options = array('proxy_host' => ilProxySettings::_getInstance()->getHost(), 'proxy_port' => ilProxySettings::_getInstance()->getPort()); } else { $options = array(); } $req = new HTTP_Request($link['complete'], $options); $req->sendRequest(); switch ($req->getResponseCode()) { // EVERYTHING OK case '200': // In the moment 301 will be handled as ok // In the moment 301 will be handled as ok case '301': case '302': break; default: $link['http_status_code'] = $req->getResponseCode(); $invalid[] = $link; break; } } } return $invalid ? $invalid : array(); }
/** * Determine Feed Url * * @param $a_url URL that */ static function _determineFeedUrl($a_url) { if (!defined('IL_FEED_PROXY_HOST')) { if (ilProxySettings::_getInstance()->isActive()) { define('IL_FEED_PROXY_HOST', ilProxySettings::_getInstance()->getHost()); define('IL_FEED_PROXY_PORT', ilProxySettings::_getInstance()->getPort()); } else { define('IL_FEED_PROXY_HOST', ""); define('IL_FEED_PROXY_PORT', ""); } } $res = @fopen($a_url, "r"); if (!$res) { return ""; } $contents = ''; while (!feof($res)) { $contents .= fread($res, 8192); } fclose($res); return ilExternalFeed::_getRSSLocation($contents, $a_url); }