示例#1
0
 /**
  * This function will print the body of the responsemessage when the object is a graph.
  */
 public function printGraph()
 {
     set_error_header(453, "RDF not supported");
     $generator = new Generator($this->rootname . " - formatter cannot process RDF");
     $body = "";
     $body .= "<h1>Formatter doesn't support RDF</h1>";
     $body .= "<p>We don't have a triple output for this formatter yet. This is a best effort in HTML.</p>";
     $body .= "<p>There are plenty of RDF formatters which do work however. Check .ttl or .json for instance.</p>";
     $rn = $this->rootname;
     $body .= "<table border=3>";
     $body .= "<tr><td>subject</td><td>predicate</td><td>object</td></tr>";
     foreach ($this->objectToPrint->{$rn}->triples as $triple) {
         $body .= "<tr><td>" . $triple["s"] . "</td>";
         $body .= "<td>" . $triple["p"] . "</td>";
         $body .= "<td>" . $triple["o"] . "</td>";
         $body .= "</tr>";
     }
     $body .= "</table>";
     $h = headers_list();
     $i = 0;
     $matches = array();
     while ($i < sizeof($h) && !preg_match("/Link: (.+);rel=next.*/", $h[$i], $matches)) {
         $i++;
     }
     if ($i < sizeof($h)) {
         $body .= "<p class='nextpage'><a href='" . $matches[1] . "'>Next page</a></p>";
     }
     $generator->generate($body);
 }
示例#2
0
文件: bootstrap.php 项目: tdt/start
/**
 * This function is called when an unexpected error(non-exception) occurs
 * @param integer $number Number of the level of the error that's been raised.
 * @param string  $string Contains errormessage.
 * @param string  $file   Contains the filename in which the error occured.
 * @param integer $line   Represents the linenumber on which the error occured.
 * @param string  $context Context is an array that points to the active symbol table at the point the error occurred. In other words, errcontext will contain an array of every variable that existed in the scope the error was triggered in. User error handler must not modify error context.
 */
function wrapper_handler($number, $string, $file, $line, $context)
{
    global $log;
    $error_message = $string . " on line " . $line . " in file " . $file . ".";
    $log = new Logger('bootstrap');
    $log->pushHandler(new StreamHandler(app\core\Config::get("general", "logging", "path") . "/log_" . date('Y-m-d') . ".txt", Logger::ERROR));
    $log->addError($error_message);
    echo "<script>location = \"" . app\core\Config::get("general", "hostname") . app\core\Config::get("general", "subdir") . "error/critical\";</script>";
    set_error_header(500, "Internal Server Error");
    //No need to continue
    exit(0);
}
示例#3
0
文件: router.php 项目: tdt/start
    $route = preg_replace('/^' . strtoupper($_SERVER['REQUEST_METHOD']) . '(\\s|\\t)*\\|(\\s|\\t)*/', "", trim($route));
    $routes[trim($route)] = trim($controller);
}
//$log->logInfo("The routes we are working with", $routes);
try {
    // This function will do the magic.
    Glue::stick($routes);
} catch (Exception $e) {
    // Instantiate a Logger
    $log = new Logger('router');
    $log->pushHandler(new StreamHandler(app\core\Config::get("general", "logging", "path") . "/log_" . date('Y-m-d') . ".txt", Logger::ERROR));
    // Generator to generate an error page
    $generator = new Generator();
    $generator->setTitle("The DataTank");
    if ($e instanceof tdt\exceptions\TDTException) {
        // DataTank error
        $log->addError($e->getMessage());
        set_error_header($e->getCode(), $e->getShort());
        if ($e->getCode() < 500) {
            $generator->error($e->getCode(), "Sorry, but there seems to be something wrong with the call you've made", $e->getMessage());
        } else {
            $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while.");
        }
    } else {
        // General error
        $log->addCritical($e->getMessage());
        set_error_header(500, "Internal Server Error");
        $generator->error($e->getCode(), "Sorry, there seems to be something wrong with our servers", "If you're the system administrator, please check the logs. Otherwise, check back in a short while.");
    }
    exit(0);
}