Repository navigation
Expand file tree
/
Copy pathsave.php
More file actions
executable file
·67 lines (56 loc) · 1.51 KB
/
Copy pathsave.php
File metadata and controls
executable file
·67 lines (56 loc) · 1.51 KB
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
//print_r($_POST);
include("func.php");
$id = $_POST['id'];
$value = $_POST['value'];
$data = explode(".",$id);
$sid = $data[0];
$pid = $data[1];
$modifiedData = $data[2];
$schedules=simplexml_load_file('bells.xml');
$suc = findSchedule($schedules,$sid);
$duc = findPeriod($suc,$pid);
//in case of modifying a dow
if(strcmp($modifiedData,"dow")==0){
$newdow=$data[3];
$olddow=explode(",",$duc->dow);
$possDOW=array("MON","TUE","WED","THU","FRI","SAT","SUN");
//insert dow
if(strcmp($value,'true')==0){
//prevents double adding of days
if(strpos($duc->dow,$newdow)==false){
$value = $duc->dow.",$newdow";
}
else $value = $duc->dow;
print("<div style=\"float:left;color:green;\">$newdow </div>");
}
//remove dow
else{
$value="";
foreach($olddow as $testdow){
if(strcmp($testdow,$newdow)==0){
$testdow='';
}
$value.=$testdow.",";
}
print("<div style=\"float:left;color:rgb(220,220,220);\">$newdow </div>");
}
}
elseif(strcmp($modifiedData,"active")==0){
$suc->active=$value;
print("<div class=\"$suc->active\">$suc->title</div>");
}
//not modifying a dow, just print the new value
else{
print($value);
}
//now save our stuff
//clean up, just in case there are some funky commmas
$value=rtrim($value,",");
$value=ltrim($value,",");
$duc->$modifiedData=$value;
//print($schedules->asXML());
$handle=fopen("bells.xml","wb");
fwrite($handle,$schedules->asXML());
fclose($handle);
?>