Exemplo n.º 1
0
function test_dir($dir)
{
    $fs_objs = scandir($dir);
    foreach ($fs_objs as $fs_obj) {
        if ($fs_obj != '.' && $fs_obj != '..' && substr_compare($fs_obj, '.parsed', -7, 7, true) != 0) {
            if (filetype($dir . '/' . $fs_obj) == "dir") {
                test_dir($dir . '/' . $fs_obj);
            } else {
                test_file($dir . '/' . $fs_obj);
            }
        }
    }
}
Exemplo n.º 2
0
        if (!is_dir($_POST['open'])) {
            $fil = file($_POST['open']);
            echo "<textarea cols=100 rows=20 name=edit>";
            foreach ($fil as $vv) {
                echo htmlspecialchars($vv);
            }
            echo "</textarea><br>" . font('green', "FILE : " . $_POST['open'], 3);
            if (is_writable($_POST['open']) == 1) {
                echo w(2) . font('green', 'ACCESS GRANTED');
                echo "<input type=submit name=save value=save><input type=hidden value=" . $_POST['open'] . " name=sv>";
            }
        } else {
            $error = font('red', e(2));
        }
    } else {
        $error = test_file($_POST['open']);
    }
}
if (isset($_POST['save'])) {
    $fr = fopen($_POST['sv'], "w");
    $out = $_POST['edit'];
    fputs($fr, $out);
    fclose($fr);
}
#
#CREATE FILE
if (isset($_POST['cr']) && $_POST['new'] != '') {
    if (is_writable(dirname($_POST['new']))) {
        echo font('green', "Create new file : " . $_POST['new'], 3) . "<br><textarea name=newf cols=100 rows=20></textarea>\n<input type=submit name=cre value=create>\n<input type=hidden value=" . $_POST['new'] . "  name=nf>";
    } else {
        echo "<br>" . font('red', e(2) . "<br>");
Exemplo n.º 3
0
        $md5 = get_par('md5');
        echo json_encode(get_test_case($cate, $md5));
    } elseif ($type == 'retest') {
        $md5 = get_par('md5');
        print_r(retest_case($cate, $md5));
    } elseif ($type == 'welefen') {
        foreach ($list as $cate => $class) {
            $file = dirname(__FILE__) . '/Case/' . $cate . '.json';
            if (file_exists($file)) {
                $content = file_get_contents($file);
                $content = json_decode($content, true);
                $result = array();
                foreach ($content as $item) {
                    $item['text'] = trim($item['text']);
                    $result[md5($item['text'])] = $item;
                }
                file_put_contents($file, json_encode($result));
            }
        }
    } else {
        $class = $list[$cate];
        $result = test_file($cate, $class);
        echo json_encode($result);
    }
} catch (Fl_Exception $e) {
    if (isLocal()) {
        print_r($e);
    } else {
        echo "Fatal Error: " . $e->message;
    }
}
Exemplo n.º 4
0
{
    global $status;
    return ($status & $mask) == $mask;
}
//тестируем запрос клиента
$status += test_post(HAS_REQUEST_PAGE, 'user_page');
$status += test_post(HAS_LOGIN, 'user_login');
$status += test_post(HAS_PASSWORD, 'user_pass');
$status += test_post(HAS_HASH, 'user_code');
$status += test_post(HAS_REQUEST_ID, 'user_file');
$status += test_http(HAS_AJAX, 'HTTP_X_REQUESTED_WITH', 'xmlhttprequest');
$status += test_http(HAS_ADDRESS, 'REMOTE_ADDR', 0);
$status += test_file(HAS_NAME, 'file_name', 'name');
$status += test_file(HAS_TMP_NAME, 'file_name', 'tmp_name');
$status += test_file(HAS_SIZE, 'file_name', 'size');
$status += test_file(HAS_ERROR, 'file_name', 'error');
//проверяем корректность формата
if (test(HAS_LOGIN) && preg_match("/^[0-9a-zA-Z\\._-]+@[0-9a-zA-Z\\._-]+\\.[a-zA-Z]{2,4}\$/", $_POST['user_login'])) {
    $status += ACCESS_LOGIN;
}
if (test(HAS_PASSWORD) && preg_match("/^.{8,50}\$/", $_POST['user_pass'])) {
    $status += ACCESS_PASSWORD;
}
if (test(HAS_REQUEST_PAGE) && preg_match("/^\\d{1,3}\$/", $_POST['user_page'])) {
    $status += ACCESS_PAGE;
}
//всеряем логин и пароль по БД
if (test(ACCESS_LOGIN) && (test(ACCESS_PASSWORD) || test(HAS_HASH))) {
    //поиск клиента в БД
    $response = mysql_query("SELECT * FROM `" . MYSQL_USER_TBL . "` WHERE `mail`='" . $_POST['user_login'] . "'  LIMIT 1");
    if ($response) {
Exemplo n.º 5
0
function main()
{
    $result = true;
    $testfiles = array('local_tests.json', 'json-patch-tests/tests.json', 'json-patch-tests/spec_tests.json');
    foreach ($testfiles as $testfile) {
        if (!test_file($testfile)) {
            $result = false;
        }
    }
    if (!test_file('simplexml_tests.json', true)) {
        $result = false;
    }
    return $result;
}
    }
    function readf($file)
    {
        clearstatcache();
        $f = fopen($file, "r");
        $contents = fread($f, filesize($file));
        fclose($f);
        return htmlspecialchars($contents);
    }
    if (@$_POST['save']) {
        writef($file, $_POST['data']);
    }
    if (@$_POST['create']) {
        writef($file, "");
    }
    $test = test_file($file);
    if ($test == 1) {
        $content .= "<form method=\"POST\">\n\t<input type=\"hidden\" name=\"action\" value=\"editor\">\n\tFile name:<input type=\"text\" name=\"file\" value=\"" . $file . "\" size=\"50\"><br>\n\t<input type=\"submit\" name=\"create\" value=\"Create new file with this name?\">\n\t<input type=\"reset\" value=\"No\"></form>";
    }
    if ($test > 2) {
        $content .= "<form method=\"POST\">\n\t<input type=\"hidden\" name=\"action\" value=\"editor\">\n\t<input type=\"hidden\" name=\"file\" value=\"" . $file . "\">\n\t<textarea name=\"data\" rows=\"30\" cols=\"180\">" . @readf($file) . "</textarea><br>\n\t<input type=\"submit\" name=\"save\" value=\"save\"><input type=\"reset\" value=\"reset\"></form>";
    }
}
//viewer
if ($action == 'viewer') {
    $content .= "<table cellSpacing=0 border=2 style=\"border-color:black;\" cellPadding=0 width=\"100%\">";
    $content .= "<tr><td><form method=POST><br>Open directory:  <input type=text name=dir value=\"" . $dir . "\" size=50><input type=submit value=\">>\"></form>";
    if (is_dir($dir)) {
        if (@($dh = opendir($dir))) {
            while (($file = readdir($dh)) !== false) {
                if (filetype($dir . $file) == 'dir') {