-
Notifications
You must be signed in to change notification settings - Fork 0
/
receive.php
53 lines (39 loc) · 1013 Bytes
/
receive.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
<?php
include_once "config.php";
//this file is the receiver of somemone submitting the translation form
$xml;
//open xml
if (file_exists(TEXTFILE))
{
$xml = simplexml_load_file(TEXTFILE) or die("error loading xml");
}
else //this shouldn't happen
{
$xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>' . PHP_EOL . '<I18>' . PHP_EOL . PHP_EOL . '</I18>');
}
$worked = false;
if (isset ($_POST['to']))
{
$to = $_POST['to'];
//making a foreach( as $indice =>) would set every $indice to "text"
$indice = 0;
foreach ($xml->text as $text)
{
//if the translator entered text last page we take it
//else we don't change/add anything
//and the website will take a default value
if (!empty($_POST[$indice]))
{
if (isset ($text->{$to}))
{
unset ($text->{$to});
}
$text->addChild($to, htmlspecialchars($_POST[$indice]));
}
$indice++;
}
$xml->asXML(TEXTFILE);
$worked = true;
}
header('Location: translate.php?worked=' . $worked);
?>