function setDic($str1, $str2)
 {
     $result = dictionary($str1, $str2);
     $this->str1 = $str1;
     $this->str2 = $str2;
     return $result;
 }
function sortAscending(array $arr)
{
    $length = count($arr);
    for ($i = 0; $i < $length; $i++) {
        for ($j = $i; $j < $length; $j++) {
            $str1 = "";
            $str2 = "";
            if (dictionary($arr[$i], $arr[$j]) == 1) {
                $temp = $arr[$i];
                $arr[$i] = $arr[$j];
                $arr[$j] = $temp;
            }
        }
    }
    return $arr;
}
<html>
<?php 
include "up_to_low.php";
if (isset($_GET['string1']) && isset($_GET['string2'])) {
    $string1 = $_GET['string1'];
    $string2 = $_GET['string2'];
    $str1 = myChangeCase($string1);
    $str2 = myChangeCase($string2);
    $result = dictionary($str1, $str2);
    echo $result;
}
function dictionary($str1, $str2)
{
    $dic = "";
    $length1 = strlen($str1);
    $length2 = strlen($str2);
    if ($length1 <= $length2) {
        $len = $length1;
    } else {
        $len = $length2;
    }
    for ($i = 0; $i < $len; $i++) {
        if ($str1[$i] == $str2[$i]) {
            $dic .= $str1[$i];
            continue;
        } elseif ($str1[$i] != $str2[$i]) {
            if ($str1[$i] < $str2[$i]) {
                return $str1;
            } else {
                return $str2;
            }
示例#4
0
文件: hw3.php 项目: jinfu8898/php254
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta name="author" content="NTU CSIE Information System Training Course">
	<meta name="keywords" content="Keyword 1,Keyword 2">
	<meta name="description" content="description">
	<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
	<link rel="apple-touch-icon" href="/favicon.png">
	<title>hw3</title>
</head>
<body>
<h1>簡易字典查詢系統</h1>
<form action="hw3.php" method="post">
	請輸入想要查的英文單字:<input type="text" name="words">
	<input type="submit">
</form>
<?php 
dictionary(@$_POST['words']);
function dictionary($words)
{
    if ($words) {
        switch ($words) {
            case 'apple':
                find($words, '蘋果');
                break;
            case 'orange':
                find($words, '橘子');
                break;
            case 'watermelon':
                find($words, '西瓜');
                break;
            case 'strawberry':
                find($words, '草莓');
示例#5
0
function build()
{
    $unix = new unix();
    $sock = new sockets();
    $checkrad = $unix->find_program("checkrad");
    $EnableMikrotik = $sock->GET_INFO("EnableMikrotik");
    echo "Starting FreeRadius.............: checkrad: `{$checkrad}`\n";
    $ListenIP = $sock->GET_INFO("FreeRadiusListenIP");
    $FreeRadiusListenPort = $sock->GET_INFO("FreeRadiusListenPort");
    if ($ListenIP == null) {
        $ListenIP = "*";
    }
    if (!is_numeric($FreeRadiusListenPort)) {
        $FreeRadiusListenPort = 1812;
    }
    echo "Starting FreeRadius.............: Listen addr: `{$ListenIP}:{$FreeRadiusListenPort}`\n";
    $IsMySQL = IsMySQL();
    $UseMySQL = false;
    if ($IsMySQL > 0) {
        $UseMySQL = true;
    }
    $f[] = "prefix = /usr";
    $f[] = "exec_prefix = /usr";
    $f[] = "sysconfdir = /etc";
    $f[] = "localstatedir = /var";
    $f[] = "sbindir = \${exec_prefix}/sbin";
    $f[] = "logdir = /var/log/freeradius";
    $f[] = "raddbdir = /etc/freeradius";
    $f[] = "radacctdir = \${logdir}/radacct";
    $f[] = "name = freeradius";
    $f[] = "confdir = \${raddbdir}";
    $f[] = "run_dir = \${localstatedir}/run/\${name}";
    $f[] = "db_dir = \${raddbdir}";
    $f[] = "libdir = /usr/lib/freeradius";
    $f[] = "pidfile = /var/run/freeradius/freeradius.pid";
    $f[] = "user = root";
    $f[] = "group = root";
    $f[] = "max_request_time = 30";
    $f[] = "cleanup_delay = 5";
    $f[] = "max_requests = {$FreeRadiusListenPort}";
    $f[] = "listen {";
    $f[] = "\ttype = auth";
    $f[] = "\tport = 1812";
    $f[] = "\tipaddr = {$ListenIP}";
    $f[] = "#\tclients = per_socket_clients";
    $f[] = "}";
    $f[] = "";
    $f[] = "";
    $f[] = "listen {";
    $f[] = "\tport = 0";
    $f[] = "\ttype = acct";
    $f[] = "\tipaddr = {$ListenIP}";
    $f[] = "#\tinterface = eth0";
    $f[] = "#\tclients = per_socket_clients";
    $f[] = "}";
    $f[] = "";
    $f[] = "";
    $f[] = "hostname_lookups = no";
    $f[] = "allow_core_dumps = no";
    $f[] = "regular_expressions\t= yes";
    $f[] = "extended_expressions\t= yes";
    $f[] = "";
    $f[] = "log {";
    $f[] = "\tdestination = syslog";
    $f[] = "\tfile = \${logdir}/radius.log";
    $f[] = "\tsyslog_facility = daemon";
    $f[] = "\tstripped_names = no";
    $f[] = "\tauth = yes";
    $f[] = "\tauth_badpass = yes";
    $f[] = "\tauth_goodpass = no";
    $f[] = "}";
    $f[] = "";
    $f[] = "checkrad = {$checkrad}";
    $f[] = "";
    $f[] = "security {";
    $f[] = "\tmax_attributes = 200";
    $f[] = "\treject_delay = 1";
    $f[] = "\tstatus_server = yes";
    $f[] = "}";
    $f[] = "";
    $f[] = "proxy_requests  = yes";
    $f[] = "\$INCLUDE proxy.conf";
    $f[] = "\$INCLUDE clients.conf";
    $f[] = "";
    $f[] = "thread pool {";
    $f[] = "\tstart_servers = 5";
    $f[] = "\tmax_servers = 32";
    $f[] = "\tmin_spare_servers = 3";
    $f[] = "\tmax_spare_servers = 10";
    $f[] = "\tmax_requests_per_server = 0";
    $f[] = "}";
    $f[] = "pap {";
    $f[] = "\tencryption_scheme = clear";
    $f[] = "}";
    $f[] = "";
    $f[] = "modules {";
    $f[] = "\t\$INCLUDE \${confdir}/modules/";
    $f[] = "\t\$INCLUDE eap.conf";
    if ($UseMySQL) {
        $f[] = "\t\$INCLUDE sql.conf";
    }
    $f[] = "#\t\$INCLUDE sql/mysql/counter.conf";
    $f[] = "#\t\$INCLUDE sqlippool.conf";
    $f[] = "}";
    $f[] = "";
    $f[] = "";
    $f[] = "instantiate {";
    $f[] = "\texpr";
    $f[] = "#\tdaily";
    $f[] = "\texpiration";
    $f[] = "\tlogintime";
    $f[] = "}";
    $f[] = "";
    $f[] = "\$INCLUDE policy.conf";
    $f[] = "\$INCLUDE sites-enabled/";
    //$f[]="\$INCLUDE dictionary";
    dictionary();
    echo "Starting FreeRadius.............: /etc/freeradius/radiusd.conf done...\n";
    @mkdir("/etc/freeradius", 0755, true);
    @file_put_contents("/etc/freeradius/radiusd.conf", @implode("\n", $f));
    attrs_access_reject();
    eap();
    pap();
    proxy();
    ntlm_auth();
    build_sql_connections();
    module_ldap();
    inner_tunnel();
    site_default();
    confusers();
    clients();
    mschap();
    microtik();
}