-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun.php
executable file
·49 lines (42 loc) · 1.77 KB
/
run.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
<?php
/**
* In which we jump through some hoops to make Drupal treat
* profiles/scf/switch.php just like the root-level index.php or update.php
*/
// remove '/profiles/scf' from current working directory and set our directory
$base_dir = substr(getcwd(), 0, -8); //xxx 8 is the lengt
chdir($base_dir);
// ini_set('include_path', '.:' . $base_dir); - use of ./ makes this not work
global $base_url;
// duplicated from bootstrap.inc conf_init().
// Create base URL
$base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
// As $_SERVER['HTTP_HOST'] is user input, ensure it only contains
// characters allowed in hostnames.
$base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
// $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
// be modified by a visitor.
if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
$base_path = "/$dir";
$base_url .= $base_path;
}
$base_url = substr($base_url, 0, -8); //XXX 8 is the length
require_once './includes/bootstrap.inc';
// we need the $user variable, theming... i think we have to go all the way
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // DRUPAL_BOOTSTRAP_CONFIGURATION
//print_r($user);
if(in_array("authenticated user", $user->roles) || in_array("unsecure", $user->roles) ){
watchdog("insight", "User ran model", array($user->uid), WATCHDOG_INFO );
$modelData=rawurldecode($_POST["code"]);
$modelData=str_replace("\\'","'",str_replace("\\\"",'"',$modelData));
chdir("./builder");
require("./GraphToIntermediate.php");
#print("test1");
exec("bin/Simgua run.smr Model \"".$modelData."\"", $output);
#print("test2");
echo join("\n",$output)."\n";
#print("test3");
}else{
?>ACCESS DENIED<?php
}
?>