Exemplo n.º 1
0
function walk(&$a)
{
    foreach ($a as $i => $v) {
        if (is_array($v) && array_values($v) !== $v) {
            walk($a[$i]);
        } else {
            // Get type
            $t = gettype($v);
            // Parse type name
            $t = str_replace(array('boolean', 'double'), array('bool', 'float'), $t);
            // Check date type
            if (Toml::isISODate($v)) {
                $t = 'datetime';
            }
            // Fix double vs integer type
            if ($t == 'float' && $v == intval($v)) {
                $t = 'integer';
            }
            // Parse array type
            if ($t == 'array') {
                walk($v);
            } else {
                $v = "{$v}";
            }
            $a[$i] = array('type' => $t, 'value' => $v);
        }
    }
}
Exemplo n.º 2
0
function walk($dir)
{
    global $tpls;
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file[0] != '.') {
                if (is_file("{$dir}/{$file}")) {
                    $tpls[] = "{$dir}/{$file}";
                }
                if (is_dir("{$dir}/{$file}")) {
                    walk("{$dir}/{$file}");
                }
            }
        }
    }
}
Exemplo n.º 3
0
function walk(&$data, $pad)
{
    global $out;
    foreach ($data as $f) {
        if (isset($f['realpath'])) {
            if (!empty($f['child'])) {
                fwrite($out, $pad . '<dir name="' . $f['name'] . '" path="' . $f['path'] . '" realpath="' . $f['realpath'] . '">' . "\n");
                walk($f['child'], $pad . '  ');
                fwrite($out, $pad . "</dir>\n");
            } else {
                fwrite($out, $pad . '<dir name="' . $f['name'] . '" path="' . $f['path'] . '" realpath="' . $f['realpath'] . '" />' . "\n");
            }
        } else {
            fwrite($out, $pad . '<file name="' . $f['name'] . '" path="' . $f['path'] . '" />' . "\n");
        }
    }
}
Exemplo n.º 4
0
function walk($cwd = '.')
{
    $data = array();
    $files = scandir($cwd);
    while (list(, $file) = each($files)) {
        if (preg_match('/^\\..*/', $file)) {
            continue;
        }
        $path = $cwd . '/' . $file;
        if (is_dir($path)) {
            $data = array_merge($data, walk($path));
        }
        if (preg_match('/\\.(html|wma)$/', $path)) {
            $data[] = $path;
        }
    }
    return $data;
}
Exemplo n.º 5
0
function hostapd_addbridge($action)
{
    $hostapdconfig = parse_ini_file("/etc/hostapd/hostapd.conf");
    switch ($action) {
        case "enable":
            if (!walk($hostapdconfig, 'bridge')) {
                $hostapdconfig['bridge'] = "br0";
            }
            write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
            break;
        case "disable":
            if (walk($hostapdconfig, 'bridge')) {
                unset($hostapdconfig['bridge']);
            }
            write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
            break;
    }
}
Exemplo n.º 6
0
function walk_dir($path, $filter)
{
    if (preg_match('/\\/language\\/(.*)$/', $path, $matches)) {
        if (strpos($path, $filter) === false) {
            return;
        }
        $locale = $matches[1];
        //$locale = 'is_is';
        add2database($locale, $path);
    } else {
        if ($dh = opendir($path)) {
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..') {
                    walk($path . '/' . $file, $filter);
                }
            }
            closedir($dh);
        }
    }
}
Exemplo n.º 7
0
                //var_dump($lines);
                while (count($lines) > 1) {
                    $line = chop(array_shift($lines));
                    doadid($line, $func);
                }
                $line = array_shift($lines);
                if (substr($line, strlen($line) - 1, 1) == "\n") {
                    doadid($line, $func);
                    $_buff = '';
                } else {
                    $_buff = $line;
                }
                sleep(1);
            }
        }
    }
    fclose($f);
}
function doadid($line, $func)
{
    if ("{$line}" == ":quit") {
        echo ts() . " - bye\n";
        exit;
    } else {
        $func($line);
    }
}
$filename = $argv[1];
walk($filename, function ($buff) {
    echo ts() . " - {$buff}\n";
});
Exemplo n.º 8
0
<?php 
if (is_uploaded_file($usrfl['tmp_name'])) {
    oos_get_copy_uploaded_file($usrfl, OOS_UPDATE_PATH);
    echo "<p class=smallText>";
    echo 'File uploaded<br />';
    echo 'Temporary filename:: ' . $usrfl['tmp_name'] . '<br />';
    echo 'User filename: ' . $usrfl['name'] . '<br />';
    echo 'Size: ' . $usrfl['size'] . '<br />';
    echo '<br><br>';
    echo '<br>products_id | products_model | products_name | products_tax_class_id | products_status | products_price';
    echo '<br><br>';
    // get the entire file into an array
    $readed = file(OOS_UPDATE_PATH . $usrfl['name']);
    foreach ($readed as $arr) {
        walk($arr);
        $Counter++;
    }
    echo '<br><br>';
    echo "Total Records inserted......" . $Counter . "<br>";
}
?>

<?php 
echo oos_draw_form('update_product', $aFilename['import_excel'], '&split=0', 'post', 'enctype="multipart/form-data"');
?>

              <p>
                <div align = "left">
                <p><b>Upload Produkt-Datei</b></p>
                <p>
             if (strpos($key, 'wep_default_key') !== FALSE) {
                 unset($hostapdconfig[$key]);
             }
             if (strpos($key, 'wpa') !== FALSE) {
                 unset($hostapdconfig[$key]);
             }
         }
         break;
     case "WEP":
         if (!walk($hostapdconfig, 'wep_default_key')) {
             $hostapdconfig["wep_default_key"] = "0";
             $hostapdconfig["wep_key0"] = $configurationsettings['wifiwepkey'];
         }
         break;
     case "WPA":
         if (!walk($hostapdconfig, 'wpa')) {
             $hostapdconfig["wpa"] = "3";
             $hostapdconfig["wpa_passphrase"] = $configurationsettings['wifiwpapassword'];
         }
         break;
 }
 //var_dump($hostapdconfig);
 write_hostapd_conf($hostapdconfig, "/etc/hostapd/hostapd.conf");
 switch ($configurationsettings['wifi']) {
     case "enabled":
         logmessage("Enabling Wireless Radio ...");
         logmessage("Scheduling hostapd to start at boot.");
         shell_exec("sudo update-rc.d hostapd defaults 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         logmessage("Starting hostapd.");
         shell_exec("sudo service hostapd restart 2>&1 | sudo tee --append /var/log/raspberrywap.log");
         echo "<script>ReturnReadyOperation();</script>";
Exemplo n.º 10
0
}
$arNumbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
walk($arNumbers, function ($value) {
    return pow($value, 2);
});
var_dump($arNumbers);
$arNumbers1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
walk($arNumbers1, function ($value) {
    return pow($value, 3);
});
var_dump($arNumbers1);
$arNumbers2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
walk($arNumbers2, function ($value) {
    return $value + 1;
});
var_dump($arNumbers2);
$arNumbers2 = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
function increment($value)
{
    return $value + 1;
}
walk($arNumbers2, 'increment');
var_dump($arNumbers2);
/*echo "<br>------------------------------------------------------<br>";
function($a, $b){
    if($a < $b){
        return -1;
    }else{
        return 1;
    }
}*/
Exemplo n.º 11
0
      <tr>
        <td align="right">Wireless Mode:</td>
        <td><?php 
echo $hostapdconf['hw_mode'];
?>
</td>
      </tr>
      <tr>
        <td align="right">Wireless Security:</td>
        <td>
        <?php 
if (walk($hostapdconf, "wep_default_key") || walk($hostapdconf, "wpa")) {
    if (walk($hostapdconf, "wep_default_key")) {
        echo "Wep";
    }
    if (walk($hostapdconf, "wpa")) {
        if ($hostapdconf['wpa'] == 1) {
            echo "Wpa";
        } else {
            if ($hostapdconf['wpa'] == 2) {
                echo "Wpa2";
            } else {
                if ($hostapdconf['wpa'] == 3) {
                    echo "Wpa/Wpa2";
                }
            }
        }
    }
} else {
    echo "Disabled (open)";
}
Exemplo n.º 12
0
function walkStar($v, $s)
{
    $v = walk($v, $s);
    if (isVariable($v)) {
        return $v;
    } elseif (isPair($v)) {
        return cons(walkStar(car($v), $s), walkStar(cdr($v), $s));
    } else {
        return $v;
    }
}