forked from ncs-jss/online-c-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuplcode.php~
executable file
·38 lines (37 loc) · 937 Bytes
/
uplcode.php~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
session_start();
if(!(isset($_SESSION['stuid'])))
{
header("Location: index.php");
}
if(isset($_POST))
{
if((!empty($_POST['filename']))&&(!empty($_POST['lang'])))
{
$ext = $_POST['lang'];
$data = $_POST['txtcode'];
$filnm = $_POST['filename'];
$usrname = $_SESSION['stuid'];
$file = "$filnm.$ext";
$_SESSION['afile'] = $filnm;
$_SESSION['lang'] = $ext;
$fp = fopen("$file", "w+");
fwrite($fp, $data) or die("Couldn't write values to file!");
fclose($fp);
rename("./$file", "./code_dep/$usrname/$ext/$file");
chmod("./code_dep/$usrname/$ext/$file",0755);
$_SESSION['com_resp'] = "Saved to $file successfully!";
$_SESSION['ldfile'] = "TRUE";
header("Location: jssonc_home.php");
}
else
{
$_SESSION['com_resp'] = "Please Select a language and enter a filename";
header("Location: jssonc_home.php");
}
}
else
{
header("Location: jssonc_home.php");
}
?>