Пример #1
0
<?php

require_once CONFIG::get('ABSPATH') . '/src/models/person.php';
require_once CONFIG::get('ABSPATH') . '/src/models/storage.php';
$display['page_title'] = 'People';
list($display['page_error'], $errors) = post_errors();
if ($display['page_error']) {
    d_($display['page_error']);
}
if ($errors) {
    d_($errors);
}
$stored_people = Storage::read() ?? [];
if (count($stored_people)) {
    $display['stored_people'] = array_map(function ($item) {
        return htmlspecialchars("{$item}");
    }, $stored_people);
    $display['people'] = array_map(function ($item) {
        return $item->toHash();
    }, $stored_people);
} else {
    $display['stored_people'] = [];
    $display['people'][] = array('firstname' => 'Jeff', 'surname' => 'Stelling');
    $display['people'][] = array('firstname' => 'Chris', 'surname' => 'Kamara');
    $display['people'][] = array('firstname' => 'Alex', 'surname' => 'Hammond');
    $display['people'][] = array('firstname' => 'Jim', 'surname' => 'White');
    $display['people'][] = array('firstname' => 'Natalie', 'surname' => 'Sawyer');
}
$display['button_OK'] = merge_params($url_string, array('action' => 'save'));
render(CONFIG::get('ABSPATH') . '/src/views/templates/people/list.php', CONFIG::get('ABSPATH') . '/src/views/layouts/flat.php');
Пример #2
0
function global_exception_handler(Exception $e)
{
    $e_msg = $e->getMessage();
    if (is_serialized($e_msg)) {
        $tmp = unserialize($e_msg);
    } else {
        $tmp = array($e_msg);
    }
    $e_msg = call_user_func_array('x', $tmp);
    $trace = $e_msg . '<p><br/></p>' . $e->getTraceAsString();
    $msg = $e->getFile() . '(' . $e->getLine() . ')';
    d_($trace, $msg, $e);
}
Пример #3
0
<?php

error_reporting(E_ALL);
require_once dirname(__FILE__, 3) . '/src/config.php';
global $url_string, $controller, $action;
try {
    // make sure url string is canonical, including explicit index.php dy default
    if (strpos($url_string, '/index.php') !== 0) {
        $url_string = '/index.php' . $url_string;
    }
    list($controller, $action, $type) = controller_action($url_string);
    // make sure url string is canonical, including explicit index controller and action
    $url_string = merge_params($url_string, ['controller' => $controller, 'action' => $action]);
} catch (Exception $e) {
    die(d_($e));
    redirect_to('no-access.html');
}
// d_([CONFIG::$ENV, $controller, $action, $type]);
// check_login($type);
unset($type);
// include CONFIG::get('ABSPATH') . 'app/c/init.php';
forward_to($controller, $action);
Пример #4
0
<?php 
if ($display['stored_people']) {
    ?>
<h3>Stored people</h3>
<?php 
    foreach ($display['stored_people'] as $key => $value) {
        d_($value);
    }
}
?>

<h3>Edit</h3>
<form id="main_form" name="user_edit" method="POST" action="<?php 
echo $display['button_OK'];
?>
">
    <table>
        <tr>
            <th>First name</th>
            <th>Last name</th>
        </tr>
        <tr>
            <td><input type="text" name="people[0][firstname]" value="<?php 
echo $display['people'][0]['firstname'];
?>
" /></td>
            <td><input type="text" name="people[0][surname]" value="<?php 
echo $display['people'][0]['surname'];
?>
" /></td>