Esempio n. 1
4
    }
    if (count($scores) > 10) {
        $junk = array_pop($scores);
    }
    $fh = fopen($inf, 'w') or die("0");
    if (flock($fh, LOCK_EX)) {
        // do an exclusive lock
        foreach ($scores as $item) {
            fwrite($fh, "{$item}\n");
        }
        flock($fh, LOCK_UN);
        // release the lock
    } else {
        die("2");
    }
    fclose($fh);
}
if (isset($_POST['ts']) && isset($_COOKIE['token']) && $_COOKIE['token'] == md5('j c tunnel' . $_POST['ts']) && isset($_POST['name'])) {
    $playerName = htmlspecialchars($_POST['name']);
    $playerScore = htmlspecialchars($_POST['highscore']);
    addScore($playerName, $playerScore);
    echo "1";
} else {
    if (isset($_POST['score'])) {
        $playerScore = htmlspecialchars($_POST['score']);
        $result = checkScore($playerScore);
        echo "{$result}";
    } else {
        showScores();
    }
}
Esempio n. 2
0
function goAction($act, $category_id, $course_id, $courses, $exercises)
{
    if (!$act || $act == null) {
        $act = "default";
    }
    switch ($act) {
        case 'default':
            showPage();
            break;
        case 'getCategory':
            showCategories();
            break;
        case 'getCategoryJson':
            showCategoryTree();
            break;
        case 'getCourses':
            showCourses($category_id);
            break;
        case 'getTracks':
            showTracks($category_id, $course_id);
            break;
        case 'getScores':
            showScores($category_id, $course_id);
            break;
        case 'getSummary':
            showSummary($category_id, $courses, $exercises);
            break;
        case 'getExcel':
            showExcel($category_id, $courses, $exercises);
            break;
        case 'getCfgs':
            showConfig($category_id, $course_id);
            break;
        case 'saveCfgs':
            $count = $_GET['count'];
            $configs = $_GET['config'];
            setConfig($category_id, $course_id, $count, $configs);
            break;
        case 'createCfgs':
            $quiz_count = @$_GET['count'];
            if (!isset($quiz_count) || $quiz_count == null || $quiz_count <= 0) {
                drawConfigPanel($category_id, $course_id);
            } else {
                drawConfigPanel($category_id, $course_id, $quiz_count);
            }
            break;
        case 'removeCfgs':
            removeConfig($category_id, $course_id);
            break;
        case 'getStudents':
            showStudentConfigs();
            break;
        case 'saveStudents':
            $students = $_GET['s'];
            saveStudentConfigs($students);
            break;
    }
}