Ejemplo n.º 1
0
    $user = get_login_user();
    switch ($module) {
        case 'EventCalendarModule':
            $obj->assoc_type = 'user';
            $obj->assoc_id = (int) $_SESSION['user']['id'];
            $obj->may_edit = true;
            // user may edit own events, right? ;)
            $obj->assoc_title = $user->login_name;
            break;
    }
    $obj->mode = PUB;
}
$page = new PageRenderer("setup_module", PAGE_CALENDAR, "Calendar - PeopleAggregator", "container_one_column.tpl", "header_user.tpl", NULL, PRI, $network_info);
$theme_details = get_user_theme($login_uid);
if (is_array($theme_details['css_files'])) {
    foreach ($theme_details['css_files'] as $key => $value) {
        $page->add_header_css($value);
    }
}
$css_path = $current_theme_path . '/calendar.css';
$page->add_header_css($css_path);
$page->add_header_html(js_includes('calendar.js'));
if (!empty($msg)) {
    $msg_tpl =& new Template(CURRENT_THEME_FSPATH . "/display_message.tpl");
    $msg_tpl->set('message', $msg);
    $page->add_module("middle", "top", $msg_tpl->fetch());
}
$page->add_header_html($parameter);
// uihelper_get_group_style($gid);
echo $page->render();
Ejemplo n.º 2
0
function exception_handler($exception)
{
    global $current_theme_path;
    // clean out any buffering so we can write straight to the client
    while (@ob_end_clean()) {
    }
    try {
        while ($exception->getCode() == 100 && strpos($exception->getMessage(), "no such table") != -1) {
            // See if the database hasn't been populated.
            // (Note: we use 'while' here rather than 'if' so we can use break
            // to avoid this turning into a mess of nested blocks).
            // First, make sure we have a working database connection.
            try {
                $sth = Dal::query("SHOW TABLES");
            } catch (PAException $e) {
                // The database connection isn't working - so fall through to
                // the normal error handler.
                break;
            }
            // Now run through the results and see if we can find a familiar
            // table.
            $found = 0;
            while ($r = $sth->fetchRow()) {
                if ($r[0] == "page_settings") {
                    $found = 1;
                    break;
                }
            }
            if ($found) {
                // ok, the db *has* been populated - fall through
                break;
            }
            // If we get this far, it means that the DB isn't populated, so we
            // show a message to the user (who is presumably an admin,
            // installing the system).
            global $path_prefix;
            ?>

    <h1>Database not populated</h1>

    <p>Before you can run PeopleAggregator, you need to populate the database by running the script <code><?php 
            echo $path_prefix;
            ?>
/db/PeepAgg.mysql</code> on your database.  You can do it in the MySQL console like this:</p>

    <pre><i>user</i>@<i>server</i>:<?php 
            echo $path_prefix;
            ?>
$ <b>mysql -u <i>username</i> -p</b>
Enter password: <b><i>password</i></b>

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 63048 to server version: 4.1.14-Debian_6-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> <b>use paalpha</b>
Database changed
mysql> <b>source <?php 
            echo $path_prefix;
            ?>
/db/PeepAgg.mysql</b></pre>

      <?php 
            exit;
        }
        // render an error message
        $code_esc = intval($exception->getCode());
        $msg_esc = htmlspecialchars($exception->getMessage());
        $page = new PageRenderer(NULL, NULL, "Error {$code_esc}: {$msg_esc}", "container_one_column.tpl");
        $msg_tpl =& new Template(CURRENT_THEME_FSPATH . "/error_middle.tpl");
        $msg_tpl->set('code', $code_esc);
        $msg_tpl->set('msg', $msg_esc);
        $page->add_module("middle", "top", $msg_tpl->fetch());
        $css_path = $current_theme_path . '/layout.css';
        $page->add_header_css($css_path);
        $css_path = $current_theme_path . '/network_skin.css';
        $page->add_header_css($css_path);
        $page->header->set('navigation_links', null);
        //setting the links to null
        echo $page->render();
        // write a copy into the log
        Logger::log("An exception occurred: code " . $exception->getCode() . ", message " . $exception->getMessage() . "\n" . $exception->getTraceAsString(), LOGGER_ERROR);
    } catch (Exception $e) {
        // If an error occurred in PageRenderer or something, present a much plainer screen with both errors:
        echo "<h1>Lots of errors occurred!</h1>\n<p>An error occurred, then the error handler crashed while trying to handle the error.  Whoops!</p>\n<p><b>Here are the details of the original error:</b></p>\n<p>" . $exception->getMessage() . "</p>\n<pre>" . $exception->getTraceAsString() . "</pre>\n<p><b>Here are the details of the second error:</b></p>\n<p>" . $e->getMessage() . "</p>\n<pre>" . $e->getTraceAsString() . "</pre>";
    }
    exit;
}