-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_feedback.php
More file actions
57 lines (50 loc) · 1.96 KB
/
send_feedback.php
File metadata and controls
57 lines (50 loc) · 1.96 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
<?php
header("Content-Type:text/xml; charset=utf-8");
/*------------------------------------------------------------------------*
* © 2010 University of Limerick. All rights reserved. This material may *
* not be reproduced, displayed, modified or distributed without the *
* express prior written permission of the copyright holder. *
*------------------------------------------------------------------------*/
require_once('./conf.php');
function sendFeedback($id, $com, $msg)
{
$error_occured=0;
$response='';
try
{
//open the database
$db = new PDO('sqlite:'.BASE_DB_URL.'locTemp.sqlite');
$res = $db->query('SELECT CurrentStep FROM Project where ID="'.$id.'"');
$data=(int) $res->fetchColumn();
$step=(string)$data;
$count = $db->exec("Update Demo set Feedback='".$msg."' where Job='".$id."' and Com='".strtoupper($com)."' and WOrder=".$step);
$count = $db->exec('Update Demo set UpdatedDate=datetime("now") where Job="'.$id.'" and Com="'.strtoupper($com).'" and WOrder='.$step);
// close the database connection
$db = NULL;
}
catch(PDOException $e)
{
//print 'Exception : '.$e->getMessage();
$response="<error><msg>".$e->getMessage()."</msg></error>";
}
if ($count>0) $response="<response><msg>Feedback Updated</msg></response>";
else $response="<error><msg> Feedback was not updated. Ensure job id:".$id." is correct and component:".$com." has been assigned that job.</msg></error>";
return $response;
}
$id=$_GET["id"];
$com=$_GET["com"];
$msg=$_GET["msg"];
$msg=urldecode($msg);
if (strlen($msg)>250) $msg=substr($msg,0,250).'..';
$msg=stripslashes($msg);
$content=$msg;
$content=str_replace('\'','\'\'',$content);
$content=str_replace('\"','\"\"',$content);
$pattern = '/<\?xml version.*;?>/i';
$replacement = '';
$content=preg_replace($pattern, $replacement, $content);
//echo "id:".$id."<br/>";
//echo "com:".$com."<br/>";
//echo "msg:".$msg."<br/>";
echo sendFeedback($id,$com,$content);
;?>