本文整理汇总了PHP中Header::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Header::error方法的具体用法?PHP Header::error怎么用?PHP Header::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Tweet
if (isset($_GET['hash'])) {
$tweet = new Tweet();
$hash = $tweet->getHash($_GET['hash']);
$check = $tweet->countHash_tweet($hash);
if ($check > 0) {
if (isset($_GET['num'])) {
if ($_GET['num'] > 0) {
$num = mysql_real_escape_string(intval($_GET['num']));
header("HTTP/1.1 200 Ok");
echo $tweet->get_output($hash, $num);
} else {
$error = new Header();
$error->error("<h2>HTTP 400 Bad Request</h2><hr/><h5><i>no of tweet asked is invalid</i></h5> ");
}
} else {
$num = 10;
header("HTTP/1.1 200 Ok");
echo $tweet->get_output($hash, $num);
}
} else {
$error = new Header();
$error->error("<h2>HTTP 400 Bad Request</h2><hr/><h5><i>hashtag asked is invalid</i></h5> ");
}
mysql_close($con);
unset($tweet);
unset($error);
} else {
$error = new Header();
$error->error("<h2>HTTP 400 Bad Request</h2><hr/><h5><i>hashtag is not given</i></h5> ");
unset($error);
}
示例2: processPage
/**
* It makes all transformation with page's DOM model in order to make
* checks, extending and including functions.
*
* If current page is not allowed to show, Header::FORBIDDEN HTTP code will be returned.
*
* While extending page, system tries to overload ascending <block>'s with
* blocks on the current page with same names. For example
* <pre><code>
* Page base.xml:
* <root>
* <block id="b1">
* <WText>Hello base.xml</WText>
* </block>
* <WText>Common text</WText>
* </root>
*
* Page derived.xml:
* <root extends="base">
* <block id="b1">
* <WText>Hello derived.xml</WText>
* </block>
* </root>
* </pre></code>
*
* Since page derived.xml is extending base.xml, system tries to find base.xml in current controller's
* directory and tries to substitute block "b1" in base.xml with derived.xml "b1".
*
* Also, <pre><code> <parent id="b1"/> </code></pre> may be used to include parent's block with id "b1".
*
* Ascending pages always checking upto ACL
*
* In case of including,
* <pre><code>
* <include src="base.xml" block="b1" allow="admin"/>
* </code></pre> syntax is used.
*
* It includes block "b1" (may be optional) from the file "base.xml" and allows it only for group
* "admin" (optional too).
*
* Triggers "BeforePageProcess", "BeforePageExtendsLookup", "BeforePageParentLookup",
* "BeforePageExtending", "BeforePageIncluding","AfterPageProcess" events.
* $this passed as 1st argument, $dom passed as 2nd parameter.
*
* @param DomDocument object to make transformation
* @return DomDocument object that have been transofrmed
* @throws ControllerException in case of unrecoverable error
* @see ACL::check
*/
protected function processPage(DomDocument $dom)
{
$this->trigger("BeforePageProcess", array($this, &$dom));
if (!$dom instanceof DOMNode || !isset($dom->firstChild)) {
throw new ControllerException("XML document not valid");
}
// check rights
$a = $dom->firstChild->getAttribute('allow');
$d = $dom->firstChild->getAttribute('deny');
if (!ACL::check($a, $d)) {
Header::error(Header::FORBIDDEN);
}
$this->trigger("BeforPageExtendsLookup", array($this, &$dom));
// extends
$adj_list = array($dom);
$included_pages = array($this->page . ".xml");
$t_dom = $dom;
while (($e_src = $t_dom->firstChild->getAttribute('extends')) != "" && !in_array($e_src, $included_pages)) {
$t_dom = new DomDocument();
try {
$t_dom->load($pp = $this->pagePath($e_src));
} catch (ControllerException $e) {
throw new ControllerException('extends page not found');
}
$_a = $t_dom->firstChild->getAttribute('allow');
$_d = $t_dom->firstChild->getAttribute('deny');
if (!ACL::check($_a, $_d)) {
Header::error(Header::FORBIDDEN);
}
array_unshift($included_pages, $e_src);
array_unshift($adj_list, $t_dom);
$this->ie_files[] = $pp;
}
$this->trigger("BeforePageParentLookup", array($this, &$dom));
// searching for <parent> blocks
for ($i = 1, $c = count($adj_list); $i < $c; $i++) {
$nl = t(new DOMXPath($adj_list[$i]))->query("//parent[@id]");
for ($j = 0, $c2 = $nl->length; $j < $c2; $j++) {
for ($k = $i - 1; $k >= 0; $k--) {
$nl2 = t(new DOMXPath($adj_list[$k]))->query("//block[@id='" . $nl->item($j)->getAttribute('id') . "']");
if (!$nl2->length) {
continue;
}
$el = $nl->item($j);
$el2 = $nl2->item(0);
$el2 = $adj_list[$i]->importNode($el2, true);
$el->parentNode->replaceChild($el2, $el);
break;
}
}
}
//.........这里部分代码省略.........