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

require 'libraries/start.php';
// create app
$app = new App();
$app->setAllowedObjects('invoices', 'payments');
$app->setAllowedActions('create', 'edit', 'validate', 'view', 'publish');
// routing
try {
    $object = Routing::getToken('object');
} catch (Exception $e) {
    $object = 'home';
}
// show home page
if ($object == 'home') {
    $t = new Template('templates/base.html');
    $t->replace('base_url', Configuration::get('base_url'));
    $t->replaceFromFile('content', 'templates/home.html');
    $t->replaceFromPHPFile('invoice-list', 'templates/invoice-list.php');
    $t->display();
    exit;
}
// allowed input
if ($object == 'payments') {
    $app->setOutputFormat('PaymentHtml');
} elseif ($object == 'invoices') {
    $app->setOutputFormat('InvoiceHtml');
} else {
    $app->setOutputFormat('AppFormatHtml');
}
$app->setInputFormat('Html');
Пример #2
0
<?php

require 'libraries/start.php';
function errorHtml($e)
{
    require 'classes/InvoiceHtml.php';
    $html = new InvoiceHtml();
    $html->setData($e);
    $html->error();
    exit;
}
// error check
try {
    $object = Routing::getToken('object');
    $id = Routing::getToken('id');
    $action = Routing::getToken('action');
    pr(Routing::parse());
    if ($object != 'invoices' && $object != 'payments') {
        throw new Exception('Invalid URL', 400);
    }
    if (!is_numeric($id)) {
        throw new Exception('Invalid ID supplied in URL', 400);
    }
    if ($action != 'view') {
        throw new Exception('Invalid action supplied in URL', 400);
    }
} catch (Exception $e) {
    errorHtml($e);
}
// find wkhtml; change value below for Windows/Linux path differences
$os = 'windows';
Пример #3
0
<?php

require 'libraries/start.php';
// get token
try {
    $page = Routing::getToken('object');
} catch (Exception $e) {
    Http::setCode(400);
    echo "NO PAGE GIVEN";
    exit;
}
// check if valid
$valid_pages = array('entry-edit.php');
if (!in_array($page, $valid_pages)) {
    Http::setCode(400);
    echo "INVALID PAGE";
    exit;
}
// get page
$file = Configuration::get('base_dir') . DS . 'templates' . DS . $page;
if (!is_file($file)) {
    Http::setCode(404);
    echo "COULD NOT FIND PAGE";
    exit;
}
// put page
Http::setCode(200);
echo include $file;