-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchange.php
executable file
·77 lines (72 loc) · 1.76 KB
/
change.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
session_start();
include 'db/dbconnection.php';
if(isset($_SESSION["progeeks_uid"]) && $_SESSION["progeeks_uid"] !=NULL)
{
$email=$_SESSION["progeeks_uid"];
if($_SESSION['progeeks_whois'] == 'PAR')
{
$query = "SELECT * FROM question where Question_Id=(select Geek_Level from geek where Geek_Email='$email') ";
$url="geeks/".$email."/";
}
else
{
$query = "SELECT * FROM question where Question_Id=(select Geek_Level from alumni where Geek_Email='$email') ";
$url="alumni/".$email."/";
}
$res = $con->query($query);
$row=$res->fetch_assoc();
if ($_SESSION['Progeeks_Compiler']=="c++Compiler.php")
{
$file = $row['Question_Name'].".java";
if (file_exists($url.$file))
{
$_SESSION['Progeeks_Compiler']="javaCompiler.php";
$_SESSION['Progeeks_Submit']="runtestcases_java.php";
}
else
{
$_SESSION['Progeeks_Compiler']="javaCompiler.php";
$_SESSION['Progeeks_Submit']="runtestcases_java.php";
$res1 = $con->query($query);
$file = $row['Question_Name'].".java";
fopen($url.$file, 'w');
$data="import java.util.*;
class ".$row['Question_Name']."
{
public static void main(String... args)
{
//Insert Your Code
}
}"
;
file_put_contents($url .$file,$data);
}
}
else
{
$file = $row['Question_Name'].".cpp";
if (file_exists($url.$file))
{
$_SESSION['Progeeks_Compiler']="c++Compiler.php";
$_SESSION['Progeeks_Submit']="runtestcases.php";
}
else
{
$_SESSION['Progeeks_Compiler']="c++Compiler.php";
$_SESSION['Progeeks_Submit']="runtestcases.php";
$file = $row['Question_Name'].".cpp";
fopen($url.$file, 'w');
$data="#include<iostream>
using namespace std;
int main()
{
/*Code Here*/
return 0;
}";
file_put_contents($url.$file,$data);
}
}
}
header("Location: play.php");
?>