/** * @brief Output the robots.txt file to the browser */ function output() { response::contentType('text/plain'); foreach ($this->_rules as $agent => $ruleset) { printf("User-Agent: %s\n", $agent); foreach ((array) $ruleset['allow'] as $rule) { printf("Allow: %s\n", $rule); } foreach ((array) $ruleset['disallow'] as $rule) { printf("Disallow: %s\n", $rule); } } }
/** * Outputs the sitemap to the client. Sets the appropriate content * type before sending. */ function output() { $doc = new DOMDocument('1.0', 'UTF-8'); $nod = $doc->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); foreach ($this->locations as $loc) { $url = $doc->createElement('url'); $url->appendChild($doc->createElement('loc', $loc['url'])); if ($loc['changefreq']) { $url->appendChild($doc->createElement('changefreq', $loc['changefreq'])); } if ($loc['lastmod']) { $url->appendChild($doc->createElement('lastmod', $loc['lastmod'])); } $url->appendChild($doc->createElement('priority', $loc['priority'])); $nod->appendChild($url); } $doc->appendChild($nod); response::contentType('text/xml'); echo $doc->saveXML(); }
/** * Checks the cache for the item with the specific hash, if it exists * it will be sent to the client using the content type that was * attached to the set() call. * * @param string $name The name of the object * @return boolean True if the object was returned from the cache */ function get($name) { $hash = md5($name); $base = config::get('lepton.fscache.path', 'cache'); $db = DBX::getInstance(DBX); $db->getSchemaManager()->checkSchema('fscache'); $rs = $db->getSingleRow("SELECT contenttype,expires FROM fscache WHERE hash='%s'", $hash); if ($rs) { if (!file_exists($base . '/' . $hash) || time() > $rs['expires']) { @unlink($base . '/' . $hash); $db->updateRow("DELETE FROM fscache WHERE hash='%s'", $hash); return false; } else { response::contentType($rs['contenttype']); response::sendFile($base . '/' . $hash); return true; } } else { return false; } }
/** * Construct and send error response. * * @param int $code The error code * @param string $reason The error reason */ function sendError($code, $reason) { // Create an empty DOM document for the error message $x = new DOMDocument('1.0', 'utf-8'); $root = $x->createElement('methodResponse'); $fault = $x->createElement('fault'); $val = $x->createElement('value'); $str = $x->createElement('struct'); // Compile the fault code node $m1 = $x->createElement('member'); $m1n = $x->createElement('name', 'faultCode'); $m1v = $x->createElement('value'); $m1va = $x->createElement('i4', $code); $m1v->appendChild($m1va); $m1->appendChild($m1n); $m1->appendChild($m1v); // Compile the fault string node $m2 = $x->createElement('member'); $m2n = $x->createElement('name', 'faultString'); $m2v = $x->createElement('value'); $m2va = $x->createElement('string', $reason); $m2v->appendChild($m2va); $m2->appendChild($m2n); $m2->appendChild($m2v); $str->appendChild($m1); $str->appendChild($m2); $val->appendChild($str); $fault->appendChild($val); $root->appendChild($fault); $x->appendChild($root); // Send the response to the client response::contentType('text/xml'); echo $x->saveXML(); }
/** * @brief Outputs the content to the client after setting the appropriate * content-type. * * @param string $contenttype The content type of the output * @param integer $qualitycompression Quality/Compression (in percent) * @param boolean $return If true return data rather than output */ function output($contenttype = 'image/png', $qualitycompression = 75, $return = false) { $this->checkImage(); if ($this->savealpha) { $s = $this->alphablending; $this->alphablending = false; } if (!$return) { response::contentType($contenttype); } else { response::buffer(true); } switch ($contenttype) { case 'image/png': imagesavealpha($this->himage, true); $compression = floor($qualitycompression / 100 * 9); imagepng($this->himage, null, $compression); break; case 'image/jpeg': case 'image/jpg': $quality = $qualitycompression; imagejpeg($this->himage, null, $quality); break; } if ($this->savealpha) { $this->alphablending = $s; } if ($return) { $img = response::getBuffer(); return $img; } }
/** * @brief Load and display a view * * */ static function load($view, $ctl = null) { if (!headers_sent()) { response::contentType("text/html; charset=utf-8"); } if (!self::$_primaryview) { if (config::get(self::KEY_EMBED_EXCEPTION, false) == true) { ob_start(); } self::$_primaryview = $view; } // Go over the registered handlers and see which one match the file name foreach ((array) View::$_handlers as $handler => $match) { if (preg_match('%' . $match . '%', $view)) { $vc = new $handler(); // If controller is specified, get its state if ($ctl && count($ctl->getState()) > 0) { $vc->setViewData($ctl->getState()); } $vc->setViewData(View::$_viewdata); $vc->loadView($view); $vc->display(); return true; } } // If we end up here, no handler could be found. throw new ViewHandlerNotFoundException("No matching handler found for requested view"); }
/** * @brief Output the entire stylesheet */ function output() { response::contentType('text/css'); echo $this->__toString(); }
function setEncoding($enc) { response::contentType('text/html; charset=' . $enc); }