-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecho.php
More file actions
101 lines (90 loc) · 2.86 KB
/
Copy pathecho.php
File metadata and controls
101 lines (90 loc) · 2.86 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/*------------------------------------------------------------------------*
* © 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');
$new_value=$_POST['value'];
$trans_unit_id=$_POST['id'];
$job_id=$_GET['jid'];
//$new_value='bunney';
//$trans_unit_id='124';//$_POST['id'];
//$job_id=$_GET['jid'];
$db = new PDO('sqlite:'.BASE_DB_URL.'locTemp.sqlite');
$res = $db->query('select * from Project where ID="'.$job_id.'"');
$c=0;
foreach($res as $row)
{
$c=$c+1;
$currentstep=(int)$row['CurrentStep'];
$finishdate=$row['FinishDate'];
$pname=$row['PName'];
$pdesc=$row['Desc'];
$out=$row['Output'];
}
if ($c>0)
{
if ($out!="" )
{
$out=trim($out);
}
} else
{
die("project ID not found");
};
$xliff = new DOMDocument();
$xliff->loadXML($out);
$xpath = new DOMXPath($xliff);
$xpath->registerNamespace('a', "urn:oasis:names:tc:xliff:document:1.2");
$query = '//a:trans-unit[@id="'.$trans_unit_id.'"]/a:target';
$tunits = $xpath->query($query);
$target=0;
foreach($tunits as $tu)
{
$target=1;
$te=$new_value;
$te=str_replace("<span class=\"red\">", "", $te);
$te=str_replace("<span class='red'>", "", $te);
$te=str_replace("</span>", "", $te);
$tu->nodeValue=$te;//setAttribute("company-name",$new_value);
}
if (!$target && $new_value!="")
{
$xpath1 = new DOMXPath($xliff);
$xpath1->registerNamespace('a', "urn:oasis:names:tc:xliff:document:1.2");
$query1 = '//a:trans-unit[@id="'.$trans_unit_id.'"]';
$tunits = $xpath1->query($query1);
foreach($tunits as $tu)
{
$te=$new_value;
$te=str_replace("<span class=\"red\">", "", $te);
$te=str_replace("<span class='red'>", "",$te);
$te=str_replace("</span>", "", $te);
$frag = $xliff->createElement("target");
$fragA = $xliff->createTextNode($te);
$frag->appendChild($fragA);
$tu->appendChild($frag);
}
}
$output=$xliff->saveXML();
$content=$output;
$content=str_replace('\'','\'\'',$content);
$content=str_replace('\"','\"\"',$content);
$pattern = '/<\?xml version.*;?>/i';
$replacement = '';
$content=preg_replace($pattern, $replacement, $content);
//open the database
try
{
$count = $db->exec("Update Project set Output='".$content."' where ID='".$job_id."'");
// close the database connection
$count = $db->exec('Update Project set FinishDate=datetime("now") where ID="'.$job_id.'"');
$db = NULL;
}
catch(PDOException $e)
{
print 'error occoured while updating target';
}
echo '<span class="red">'.$new_value.'</span>';
;?>