-
Notifications
You must be signed in to change notification settings - Fork 5
/
save.php
executable file
·67 lines (60 loc) · 2.13 KB
/
save.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
<?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
$nid=$_POST["nid"];
if($nid>-1){
$node = node_load($nid);
$node->field_modeldata[0]['value'] = $_POST["data"];
$node->changed = time();
$node->title = $_POST["title"];
$node->body = $_POST["description"];
if (node_access("update",$node)) {
$node->revision = 1;
node_save($node);
insightica_set_tags_csv($node->nid,$_POST["tags"]);
}
echo $node->nid;
}else{
$node = new stdClass();
$node->title = $_POST["title"];
$node->body = $_POST["description"];
$node->type = "insight";
$node->uid = $user->uid;
$node->teaser = "";
$node->filter = 1;
$node->status = 1;
$node->comment = 2;
$node->created = time();
$node->changed = time();
$node->field_modeldata[0]['value'] = $_POST["data"];
$now = microtime(true);
if (node_access("create",$node)) {
node_save($node);
insightica_set_tags_csv($node->nid,$_POST["tags"]);
}
echo $node->nid;
}
?>