Exemple #1
0
function print_result($testResult)
{
    if ($testResult->success) {
        echo "Success";
    } else {
        print_fail($testResult->actual, $testResult->expected);
    }
    print " in " . format_duration($testResult->duration) . " ms.\n\n";
}
Exemple #2
0
function check_rrdcached()
{
    global $config;
    list($host, $port) = explode(':', $config['rrdcached']);
    if ($host == 'unix') {
        // Using socket, check that file exists
        if (!file_exists($port)) {
            print_fail("{$port} doesn't appear to exist, rrdcached test failed");
        }
    } else {
        $connection = @fsockopen($host, $port);
        if (is_resource($connection)) {
            fclose($connection);
        } else {
            print_fail('Cannot connect to rrdcached instance');
        }
    }
}
Exemple #3
0
                        fclose($connection);
                        print_ok('Connection to memcached is ok');
                    }
                }
                if (empty($config['rrdcached'])) {
                    print_fail('You have not configured $config[\'rrdcached\']');
                } elseif (empty($config['rrd_dir'])) {
                    print_fail('You have not configured $config[\'rrd_dir\']');
                } else {
                    list($host, $port) = explode(':', $config['rrdcached']);
                    $connection = @fsockopen($host, $port);
                    if (is_resource($connection)) {
                        fclose($connection);
                        print_ok('Connection to rrdcached is ok');
                    } else {
                        print_fail('Cannot connect to rrdcached instance');
                    }
                }
            }
            break;
    }
    //end switch
}
//end foreach
// End
function print_ok($msg)
{
    echo "[OK]      {$msg}\n";
}
//end print_ok()
function print_fail($msg)
Exemple #4
0
                                print_fail('You have selected smtp but not configured an smtp port');
                                $run_test = 0;
                            }
                            if ($config['email_smtp_auth'] === true && (empty($config['email_smtp_username']) || empty($config['email_smtp_password']))) {
                                print_fail('You have selected smtp but not configured a username or password');
                                $run_test = 0;
                            }
                        }
                    }
                }
                //end if
                if ($run_test == 1) {
                    if ($err = send_mail($config['alert']['default_mail'], 'Test email', 'Testing email from NMS')) {
                        print_ok('Email has been sent');
                    } else {
                        print_fail('Issue sending email to ' . $config['alert']['default_mail'] . ' with error ' . $err);
                    }
                }
            }
            //end if
            break;
    }
    //end switch
}
//end foreach
// End
function print_ok($msg)
{
    global $console_color;
    print $console_color->convert("%g[OK]%n      %W{$msg}\n");
}
Exemple #5
0
/**
* Ensures that the group data is valid
* Throws an error if it is not valid
* @param array $data array of data to validate
* @return validated data
*/
function check_group_data($data)
{
    $rs = array();
    $msg = array();
    if (empty($data['group_name'])) {
        array_push($msg, translate('Group name is required.'));
    } else {
        $rs['group_name'] = $data['group_name'];
    }
    $rs['group_admin'] = $data['group_admin'];
    if (isset($data['groupid'])) {
        $rs['groupid'] = $data['groupid'];
    }
    if (!empty($msg)) {
        print_fail($msg, $data);
    }
    return $rs;
}
Exemple #6
0
            print_fail($jieqiLang['pay']['error_ip']);
            break;
        case '3':
            print_fail($jieqiLang['pay']['error_para_format']);
            break;
        case '4':
            print_fail($jieqiLang['pay']['error_para_num']);
            break;
        case '5':
            print_fail($jieqiLang['pay']['error_md5']);
            break;
        case '6':
            print_fail($jieqiLang['pay']['error_serial_id']);
            break;
        default:
            print_fail($jieqiLang['pay']['error_unknow']);
    }
    exit;
}
if (isset($_REQUEST['egold']) && is_numeric($_REQUEST['egold']) && $_REQUEST['egold'] > 0) {
    $_REQUEST['egold'] = intval($_REQUEST['egold']);
    if (!empty($jieqiPayset[JIEQI_PAY_TYPE]['paylimit'])) {
        if (!empty($jieqiPayset[JIEQI_PAY_TYPE]['paylimit'][$_REQUEST['egold']])) {
            $money = intval($jieqiPayset[JIEQI_PAY_TYPE]['paylimit'][$_REQUEST['egold']] * 100);
        } else {
            jieqi_printfail($jieqiLang['pay']['buy_type_error']);
        }
    } else {
        $money = intval($_REQUEST['egold']);
    }
    include_once $jieqiModules['pay']['path'] . '/class/paylog.php';
Exemple #7
0
                        $run_test = 0;
                    }
                    if (empty($config['email_smtp_port'])) {
                        print_fail("You have selected smtp but not configured an smtp port");
                        $run_test = 0;
                    }
                    if ($config['email_smtp_auth'] === TRUE && (empty($config['email_smtp_username']) || empty($config['email_smtp_password']))) {
                        print_fail("You have selected smtp but not configured a username or password");
                        $run_test = 0;
                    }
                }
                if ($run_test == 1) {
                    if ($err = send_mail($config['alert']['default_mail'], 'Test email', 'Testing email from NMS')) {
                        print_ok("Email has been sent");
                    } else {
                        print_fail("Issue sending email to " . $config['alert']['default_mail'] . " with error " . $err);
                    }
                }
            }
            break;
    }
}
// End
function print_ok($msg)
{
    global $console_color;
    print $console_color->convert("%g[OK]%n      %W{$msg}\n");
}
function print_fail($msg)
{
    global $console_color;
Exemple #8
0
            $loopcount = 0;
            $screenpad = 0;
            foreach ($rrd_iterator as $filename => $file) {
                $rrd_test_result = rrdtest($filename, $output, $error);
                $loopcount++;
                if ($loopcount % 50 == 0) {
                    //This lets us update the previous status update without spamming in most consoles
                    echo "[" . $screenpad . "D";
                    $test_status = 'Status: ' . $loopcount . '/' . $rrd_total;
                    echo $test_status;
                    $screenpad = strlen($test_status);
                }
                // A non zero result means there was some kind of error
                if ($rrd_test_result > 0) {
                    echo "[" . $screenpad . "D";
                    print_fail('Error parsing "' . $filename . '" RRD ' . trim($error));
                    $screenpad = 0;
                }
            }
            echo "[" . $screenpad . "D";
            echo "Status: " . $loopcount . "/" . $rrd_total . " - Complete\n";
            break;
    }
    //end switch
}
//end foreach
// End
function print_ok($msg)
{
    echo "[OK]      {$msg}\n";
}