Repository navigation
Expand file tree
/
Copy pathsave.php
More file actions
60 lines (42 loc) · 1.53 KB
/
Copy pathsave.php
File metadata and controls
60 lines (42 loc) · 1.53 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
<?php
session_start();
$template_id = $_SESSION['template_id'];
//hack to let the list be alphabetized.
$collate = explode(".",$_SESSION['sid']);
$sid = $collate[1];
$id = $_REQUEST['id'];
$value = $_REQUEST['value'];
//blahrgh
include("data.php");
$dsn = $DatabaseType.":host=".$DatabaseServer.";dbname=".$ELDatabaseName;
$dbh = new PDO($dsn, "$DatabaseUsername", "$DatabasePassword");
$dbh->query('SET NAMES utf8');
if(strcmp($id, "sid")==0){
$_SESSION['sid'] = $value;
//$value = "just entered SID ".$value;
}
else if(strlen($id)>2){
$term = substr($id,0,2); //S1 or S2
$type = substr($id,2,1); //Grade or Effort or Comment
$topic_id = substr($id,3); //Topic ID (number, or E/K)
$sql = "INSERT INTO el_grades (template_id, topic_id, student_id, term, type, value)
VALUES ('$template_id', '$topic_id', '$sid', '$term', '$type', '$value')
ON DUPLICATE KEY UPDATE value='$value'";
$query = $dbh->prepare($sql);
$query->execute();
if(strcmp($value,"Ch") == 0) $value = "<img src = \"img\check.png\">";
}
else{
$comment_id = substr($id,1);
//process comment to get rid of bad things like single quotes and make line breaks htmlified.
$cleanvalue = str_replace("\\n","<br>",$dbh->quote($value));
// we're getting a comment!
$sql = "INSERT INTO el_comments (template_id, student_id, comment_id, comment)
VALUES ('$template_id', '$sid', '$comment_id', $cleanvalue)
ON DUPLICATE KEY UPDATE comment=$cleanvalue";
$query = $dbh->prepare($sql);
$query->execute();
}
print("$value");
//print($_REQUEST['value']);
?>