コード例 #1
0
<?php

/**
 * This page should handle all of the print requests.
 *
 * @package Business-Card-Generator
 */
global $http, $html, $app;
if (!defined('ROOT')) {
    define('ROOT', dirname(__FILE__));
}
require_once ROOT . '/m.inc.php';
tryDef('CURRENT_PAGE_NAME', false);
if (!isset($html)) {
    $html = new html();
}
tryReq('app.inc.php');
if (!isset($app)) {
    $app = new App();
}
// print requests can now be handled.
$html->code('<!doctype html><html><head><meta charset="uft-8"><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">' . "<link href='http://fonts.googleapis.com/css?family=" . GOOGLE_FONTS . "' rel='stylesheet' type='text/css'>" . '<style type="text/css">');
$html->code('#front,#back{width: 200mm;height: 257mm;page-break-before:always}#front div,#back div{margin:2mm;height:51mm;width:89mm;-moz-border-radius:5px;-o-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}#front div p,#back p{font-family:\'Lato\', sans-serif;font-size:15px;margin:0;padding:0;line-height:100%;letter-spacing:0');
$html->code('</style></head><body><div id="front">');
$app->card($_GET, 1, 10, true);
$html->code('</div><div id="back">');
$app->card($_GET, 2, 10, true);
$html->code('</div><script type="text/javascript">javascript:window.print()</script></body></html>');
$html->dump();
コード例 #2
0
     * @since 0.1
     * @uses ROOT as the default prefix
     *
     * @param string $file
     * @param bool|string $prefix Optional. Either false for ROOT or a string ending with a slash (/)
     * @return bool False means that the file could not be read. True means that the file could be read and was retrieved.
     */
    function tryReq($file, $prefix = false)
    {
        if (is_readable(($prefix ? $prefix : ROOT . '/') . $file)) {
            require_once ($prefix ? $prefix : ROOT . '/') . $file;
        } else {
            return false;
        }
        // File isn't readable, so return FALSE.
        return true;
        // We can read the file, and we already have by the time we get here, so we should return TRUE.
    }
}
if (!defined('HAS_M_INC_PHP')) {
    tryDef('HAS_M_INC_PHP', true);
    if (!defined('NO_PRELOAD')) {
        tryReq('callbacks.inc.php');
        tryReq('config.inc.php');
        tryReq('talk.inc.php');
        tryReq('basic-security.inc.php');
        tryReq('http.inc.php');
        tryReq('html.inc.php');
        hook('ready');
    }
}
コード例 #3
0
if ((isset($_FILES['json']) ? !($_FILES['json']['error'] > 0) : false) && $_FILES['json']['size'] < MAX_IMPORT_SIZE) {
    // Someone has uploaded their json business card, and they want us to import it.
    $fname = $http->where('imports', true) . '/' . $_FILES['json']['name'] . '-' . mt_rand(1, 9999);
    move_uploaded_file($_FILES['json']['tmp_name'], $fname);
    // First let's read this file.
    $jsonh = fopen($fname, 'r');
    $config = json_decode(preg_replace('/,\\s*([\\]}])/m', '$1', utf8_encode(fread($jsonh, filesize($fname)))), true);
    // Now we've read the file.
    fclose($jsonh);
    $jsonh = null;
    $jsonh = fopen($fname, 'w');
    fwrite($jsonh, null);
    fclose($jsonh);
    $jsonh = null;
    unlink($fname);
    // We have just deleted the json file, because we already have read it.
    $url = $http->where('create') . '?';
    while (count($config) >= 1) {
        $url .= key($config) . '=' . urlencode(current($config)) . '&';
        array_shift($config);
    }
    $http->header('Location', $url . 'import');
    exit;
}
if (!isset($html)) {
    $html = new html();
}
tryReq('top.inc.php');
$html->row(array('width' => '12', 'title' => 31, 'p' => false, 'vanilla' => '<form action="' . $http->where('import') . '" enctype="multipart/form-data" method="post"><label for="json">' . __(32) . '</label><input type="file" id="json" name="json" /><div><input type="submit" class="btn-primary btn-large" value="Submit" /></div></form>'));
tryReq('bottom.inc.php');
コード例 #4
0
<?php

/**
 * The actual application
 *
 * @package Business-Card-Generator
 */
global $http, $html, $cardnames;
if (!defined('ROOT')) {
    define('ROOT', dirname(__FILE__));
}
require_once ROOT . '/m.inc.php';
tryReq('cards.inc.php');
if (!class_exists('App')) {
    /**
     * The actual application's class
     *
     * @since 0.11
     * @package Business-Card-Generator
     */
    class App
    {
        /**
         *  Current Version
         *  @var string
         */
        public static $version = '1';
        /**
         *  Default Settings
         *  @var array
         */