Esempio n. 1
0
        $posts .= phtml('post', ['post' => unserialize(trim($post))], false);
    }
    print phtml('index', ['posts' => $posts]);
});
# show a post
map('GET', '/posts/<id>', function ($args, $db) {
    foreach (file($db) as $post) {
        $post = unserialize($post);
        if ($post['id'] != $args['id']) {
            continue;
        }
        print phtml('post', ['post' => $post]);
    }
});
# new post form
map('GET', '/submit', function () {
    print phtml('submit', blanks('title', 'body'));
});
# create a new post
map('POST', '/create', function ($db) {
    $post = $_POST['post'];
    $post['id'] = time();
    file_put_contents($db, serialize($post) . "\n", FILE_APPEND);
    return redirect('/index');
});
# load contents of config.ini
config(parse_ini_file(__DIR__ . '/config.ini'));
# prep the db
!file_exists($db = __DIR__ . '/posts.txt') && touch($db);
# pass along our data store
dispatch($db);
	}
	/**
	 * add baseline HCV RNA
	 */
	if (isset($hcvrna_data[$subject_id])) {
		foreach ($hcvrna_data[$subject_id] AS $hcvrna_event) {
			if ($hcvrna_event['hcv_lbblfl'] == 'Y') {
				d($hcvrna_event);
				$data_row['Baseline ' . get_element_label('hcv_lbstresn')] = $hcvrna_event['hcv_lbstresn'] != '' ? quote_wrap($hcvrna_event['hcv_lbstresn']) : blanks();
			} elseif ($hcvrna_event['hcv_im_lbblfl'] == 'Y') {
				d($hcvrna_event);
				$data_row['Baseline ' . get_element_label('hcv_lbstresn')] = $hcvrna_event['hcv_im_lbstresn'] != '' ? quote_wrap($hcvrna_event['hcv_im_lbstresn']) : blanks();
			}
		}
	} else {
		$data_row['Baseline ' . get_element_label('hcv_lbstresn')] = blanks();
	}
	/**
	 * create csv row from $data_row and add to $table_csv
	 */
	$table_csv .= implode(',', $data_row) . "\n";
}
$headers = implode(',', $header_array) . "\n";
d($headers);
d($table_csv);
if (!$debug) {
	create_download($lang, $app_title, $userid, $headers, $user_rights, $table_csv, '', $parent_chkd_flds, $project_id, $export_filename, $debug);
} else {
	$timer['main_end'] = microtime(true);
	$init_time = benchmark_timing($timer);
	echo $init_time;
	if (isset($egfr_data[$subject_id])) {
		foreach ($egfr_data[$subject_id] AS $egfr_event) {
			if ($egfr_event['egfr_lbblfl'] == 'Y') {
				if ($subjects != '') {
					d($egfr_event);
				}
				$data_row['Baseline ' . get_element_label('egfr_lborres')] = $egfr_event['egfr_lborres'] != '' ? quote_wrap($egfr_event['egfr_lborres']) : blanks();
			} elseif ($egfr_event['egfr_im_lbblfl'] == 'Y') {
				if ($subjects != '') {
					d($egfr_event);
				}
				$data_row['Baseline ' . get_element_label('egfr_lborres')] = $egfr_event['egfr_im_lborres'] != '' ? quote_wrap($egfr_event['egfr_im_lborres']) : blanks();
			}
		}
	} else {
		$data_row['Baseline ' . get_element_label('egfr_lborres')] = blanks();
	}
	/**
	 * create csv row from $data_row and add to $table_csv
	 */
	$table_csv .= implode(',', $data_row) . "\n";
}
$headers = implode(',', $header_array) . "\n";
d($headers);
d($table_csv);
if (!$debug) {
	create_download($lang, $app_title, $userid, $headers, $user_rights, $table_csv, '', $parent_chkd_flds, $project_id, $export_filename, $debug);
} else {
	$timer['main_end'] = microtime(true);
	$init_time = benchmark_timing($timer);
	echo $init_time;
Esempio n. 4
0
try {
    config(require __DIR__ . '/fixtures/settings-invalid.php');
} catch (Exception $e) {
    assert($e instanceof InvalidArgumentException);
}
# ent() and url()
assert(ent('john & marsha') === 'john &amp; marsha');
assert(url('=') === '%3D');
# bare phtml()
assert('<h1>dispatch</h1>' === trim(phtml(__DIR__ . '/fixtures/template', ['name' => 'dispatch'], null)));
# load views config
config(parse_ini_file(__DIR__ . '/fixtures/templates.ini'));
# test page rendering using layout and dispatch.views
assert('<h1>dispatch</h1>' === trim(phtml('template', ['name' => 'dispatch'])));
# form blanks
assert(['name' => '', 'email' => ''] === blanks('name', 'email'));
# ip() - least priority first
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
assert(ip() === $_SERVER['REMOTE_ADDR']);
$_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.2';
assert(ip() === $_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.3';
assert(ip() === $_SERVER['HTTP_CLIENT_IP']);
# stash tests
stash('name', 'dispatch');
assert(stash('name') === 'dispatch');
stash('name', null);
assert(stash('name') === null);
stash('name', 'dispatch');
stash();
assert(stash('name') === null);