Example #1
0
function checkSketch($sketch)
{
    global $par;
    $res = 0;
    $user = $par['user'];
    $sketch_name_ok = NO;
    $board_type_ok = NO;
    $no_system_calls = YES;
    $no_script = YES;
    $no_php = YES;
    if (!$sketch) {
        vikingWarning("checkSketch: no file ({$file})");
        return;
    }
    $in = fopen($sketch, "r");
    if ($in) {
        while (!feof($in)) {
            $row = fgets($in);
            if (strstr($row, "SKETCH_NAME:")) {
                $sketch_name_ok = YES;
            }
            if (strstr($row, "BOARD_TYPE:")) {
                $board_type_ok = YES;
            }
            if (strstr($row, "system")) {
                $no_system_calls = NO;
            }
            if (strstr($row, "script")) {
                $no_script = NO;
            }
            if (strstr($row, "<?")) {
                $no_php = NO;
            }
            if (strstr($row, "?>")) {
                $no_php = NO;
            }
        }
        fclose($in);
        if ($sketch_name_ok == NO) {
            vikingWarning("Add to sketch: // SKETCH_NAME: your_name");
            $res = 0;
        }
        if ($board_type_ok == NO) {
            vikingWarning("Default Board Type is UNO. Add to sketch: // BOARD_TYPE: UNO");
            $res = 0;
        }
        if ($no_system_calls == NO) {
            vikingError("No system calls allowed");
            $res = 1;
        }
        if ($no_script == NO) {
            vikingError("No script allowed");
            $res = 1;
        }
        if ($no_php == NO) {
            vikingError("No php allowed");
            $res = 1;
        }
    } else {
        vikingError("checkSketch: Fail to open {$file}");
        $res = 1;
    }
    return $res;
}
Example #2
0
function loginGlobalLog($action)
{
    global $par;
    $user = $par['user'];
    if ($user) {
        $out = fopen('login.log', "a");
        if ($out) {
            $date = date("Y-m-d H:i:s");
            $temp = $date . " " . $user . " " . $action . "\n";
            fwrite($out, $temp);
        }
        fclose($out);
    } else {
        vikingError("Login logg entry without username");
    }
}
Example #3
0
     $newName = $_POST['new_scenario_name'];
     $dest = $upload . $newName;
     if (!copy($temp, $dest)) {
         vikingError("Failed to copy ({$temp} -> {$dest})");
     } else {
         $par['a7_sel_scenario'] = $dest;
         $selSource = $par['a7_sel_scenario'];
     }
 }
 if ($action == 'copy_file' && $user != 'guest') {
     $temp = $_POST['copy_source'];
     $newName = $_POST['copy_file_name'];
     $dest = $upload . $newName;
     $temp = $upload . $temp;
     if (!copy($temp, $dest)) {
         vikingError("Failed to copy ({$temp} -> {$dest})");
     }
 }
 if ($action == 'manage_sketch') {
     $selSource = $_POST['sketch'];
     $par['a7_sel_source'] = $selSource;
     $curEditFlag = 1;
 }
 if ($action == 'manage_scenario') {
     $selScenario = $_POST['scenario'];
     $par['a7_sel_scenario'] = $selScenario;
     $curEditFlag = 1;
 }
 if ($action == 'set_load') {
     $selSource = $_POST['sketch'];
     $selScenario = $_POST['scenario'];