Beispiel #1
0
function pistachio_init()
{
    global $log;
    session_start();
    //Setup logger
    $log = new Logger('app');
    $log->pushHandler(new StreamHandler(ROOT . '/app.log', Logger::DEBUG));
    parse_input();
    minify();
    if (!insertView(PATH)) {
        err_404();
    }
}
Beispiel #2
0
<?php

require_once 'inc/_include_all.php';
$input = file('input.txt', FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
$info = parse_input($input);
$infoMap = [];
$uniques = [];
foreach ($info as $piece) {
    $uniques[$piece->getSubject()] = true;
    if (!isset($infoMap[$piece->getSubject()])) {
        $infoMap[$piece->getSubject()] = [];
    }
    $infoMap[$piece->getSubject()][$piece->getObject()] = $piece->getHappinessDelta();
}
$uniques = array_keys($uniques);
$allorders = generate_all_orders($uniques);
$maxArrangement = null;
$maxHappiness = 0;
foreach ($allorders as $order) {
    $happiness = calculate_total_happiness($order, $infoMap);
    if ($happiness > $maxHappiness) {
        $maxHappiness = $happiness;
        $maxArrangement = $order;
    }
}
var_dump($maxArrangement);
echo PHP_EOL, "Happiness: ", $maxHappiness, PHP_EOL;
Beispiel #3
0
$strings_h .= "// You can re-generate this file using the tool in tools/i18n\n";
$strings_h .= "\n";
foreach ($base as $idx => $info) {
    $strings_h .= '#define STRING_' . $info[0] . ' ' . $idx . "\n";
}
// Create/Update only if necessary to not trigger compiler
$dest = 'src/i18n/strings.h';
if (!file_exists($dest) || sha1_file($dest) != sha1($strings_h)) {
    echo "Updated strings.h file\n";
    file_put_contents($dest, $strings_h);
} else {
    echo "No changes to strings.h required\n";
}
// Create a data file for each language
foreach ($languages as $lang) {
    $table = parse_input($lang, $keys);
    foreach ($base as $idx => $info) {
        if (empty($table[$idx])) {
            $table[$idx] = $info;
        }
    }
    ksort($table);
    $out = '';
    foreach ($table as $idx => $info) {
        unset($info[0]);
        $out .= $idx . "\t" . implode("\t", $info) . "\n";
    }
    file_put_contents('data/i18n/' . $lang . '.txt', $out);
    echo "Saved language pack {$lang}\n";
    unset($out);
}
Beispiel #4
0
<?php

include 'parseInput.php';
include 'testInput.php';
include 'contactForm.php';
include 'permissionForm.php';
include 'mailMessage.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $postdata = file_get_contents("php://input");
    $clean_key_value_pairs = parse_input($postdata);
    $email_to1 = "*****@*****.**";
    $email_to = "";
    $email_subject = "";
    $email_message = "";
    $email_addresses = array();
    if ($clean_key_value_pairs['form_type'] == 'permission_slip') {
        $error = permission_form_message($clean_key_value_pairs, $email_to, $email_subject, $email_message);
        array_push($email_addresses, $email_to);
        array_push($email_addresses, $email_to1);
    } else {
        $error = contact_form_message($clean_key_value_pairs, $email_to, $email_subject, $email_message);
        array_push($email_addresses, $email_to);
    }
    if (empty($error)) {
        //$jasonStrResponse .= mail_message($email_to1, $clean_key_value_pairs['subject'], $email_message);
        //$jasonStrResponse .= mail_message($email_to, $clean_key_value_pairs['subject'], $email_message);
        //$jasonStrResponse .= mail_message($email_to1, $email_subject, $email_message);
        //$jasonStrResponse .= mail_message($email_to, $email_subject, $email_message);
        error_log("About to send the message. email_addresses = " . print_r($email_address, 1), 0);
        foreach ($email_addresses as $email_address) {
            error_log("About to send the message. email_address = " . $email_address, 0);