示例#1
0
function process_array($input, $echo = false)
{
    global $result;
    if (is_array($input) || is_object($input)) {
        foreach ($input as $k => $d) {
            process_array($d);
        }
    } elseif (is_numeric($input)) {
        $result += $input;
        if ($echo) {
            echo $result . '<br>';
        }
    }
}
示例#2
0
文件: daemon.php 项目: sskaje/diff
<?php

require __DIR__ . '/lib.php';
$c = 0;
do {
    $data = read_queue();
    if ($data) {
        define('SAVE_DIRNAME', $data);
        $lpath = build_data_path($data, 'input_left');
        $rpath = build_data_path($data, 'input_right');
        $left = read_as_array($lpath, true);
        $right = read_as_array($rpath, true);
        $left = process_array($left);
        $right = process_array($right);
        $type_list = array(TYPE_SAME, TYPE_DIFFERENT, TYPE_LEFT_ONLY, TYPE_RIGHT_ONLY);
        foreach ($type_list as $type) {
            $result = compare($type, $left, $right);
            save_result($type, $result);
        }
    } else {
        usleep(100);
    }
} while (++$c < 10000);
示例#3
0
function print_values($array)
{
    echo '<table  class="" style = "border: 1px solid black; width: 98%; margin: 0 auto; font-family: monospace; border-collapse: collapse;">' . PHP_EOL;
    if (defined('SORT_NATURAL') && defined('SORT_FLAG_CASE')) {
        ksort($array, SORT_NATURAL | SORT_FLAG_CASE);
    } else {
        ksort($array);
    }
    foreach ($array as $key => $value) {
        echo '<tr style = "border: solid 1px; "><td style="border-right: solid 1px; ">' . $key . '</td><td style="text-align: left;">';
        if (is_array($value)) {
            process_array($value);
        } elseif ($value === '') {
            echo $value;
        } elseif ($value === '0' || $value === '1') {
            echo $value;
        } elseif ($value === false) {
            echo 'false';
        } elseif ($value === true) {
            echo 'true';
        } else {
            $from = array('&', ' ');
            $to = array('&amp', '&nbsp;');
            echo "'" . str_replace($from, $to, $value) . "'";
        }
    }
    echo '</table>' . PHP_EOL;
}
示例#4
0
    if (!isset($session_data['notifys'])) {
        $session_data['notifys'] = array();
    }
    $account_id = phpgw::get_var('account_id', 'int', 'POST');
    if (is_admin() && $account_id) {
        $GLOBALS['phpgw']->preferences->set_account_id($account_id, true);
    }
    /* Don't use a switch here, we need to check some permissions durring the ifs */
    if ($GLOBALS['type'] == 'user' || !$GLOBALS['type']) {
        $error = process_array($GLOBALS['phpgw']->preferences->user, $user, $session_data['notifys'], $prefix);
    }
    if ($GLOBALS['type'] == 'default' && is_admin()) {
        $error = process_array($GLOBALS['phpgw']->preferences->default, $default, $session_data['notifys']);
    }
    if ($GLOBALS['type'] == 'forced' && is_admin()) {
        $error = process_array($GLOBALS['phpgw']->preferences->forced, $forced, $session_data['notifys']);
    }
    if (is_admin() && $account_id) {
        $GLOBALS['phpgw']->preferences->set_account_id($GLOBALS['phpgw_info']['user']['account_id'], true);
    }
    if (!is_admin() || $error) {
        $GLOBALS['phpgw']->redirect_link('/preferences/index.php');
    }
    if ($GLOBALS['type'] == 'user' && $appname == 'preferences' && (isset($user['show_help']) && $user['show_help'] != '')) {
        $show_help = $user['show_help'];
        // use it, if admin changes his help-prefs
    }
}
$GLOBALS['phpgw']->session->appsession('session_data', 'preferences', array('type' => $GLOBALS['type'], 'show_help' => $show_help, 'prefix' => $prefix, 'appname' => $appname));
// changes for the admin itself, should have immediate feedback ==> redirect
if (!$error && phpgw::get_var('submit', 'bool', 'POST') && $GLOBALS['type'] == 'user' && $appname == 'preferences') {