/
translate_ajaxselect.php
executable file
·112 lines (101 loc) · 3.81 KB
/
translate_ajaxselect.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
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
102
103
104
105
106
107
108
109
110
111
112
<?php
include('includes/includes.php');
include('translate_fns.php');
$id = $_GET['id'];
$fversion = $_GET['fversion'];
$langto = $_GET['langto'];
$langfrom = $_GET['langfrom'];
$seq = $_GET['seq'];
$userID = $_SESSION['userID'];
$query = "select count(*) from translating where subID=$id and fversion=$fversion and lang_id=$langto";
$result = mysql_query($query);
$count = mysql_result($result, 0);
if ($count==0)
{
$query = "select count(*) from testing where subID=$id and fversion=$fversion and lang_id=$langto";
$result = mysql_query($query);
$count = mysql_result($result, 0);
if ($count<1)
{
$total = bd_langVersion0Count($id,$langfrom, $fversion);
tn_check($id, $fversion, $langfrom, $langto);
$cstate = bd_getLangState($id, $langto, $fversion);
echo "This subtitles has been tested.<br />Current state:$cstate</b> If it is not completed, please <b>reload</b> this page and fill the gaps.";
if ($cstate=="$wikilang_completed")
{
$query = "select count(*) from lasttranslated where subID=$id and fversion=$fversion and lang_id=$langto";
$result = mysql_query($query);
$count = mysql_result($result, 0);
if ($count<1)
{
$query = "insert into lasttranslated(subID,fversion,lang_id,date) values($id,$fversion,$langto, NOW())";
mysql_query($query);
}
}
}
else
echo "Current subtitle is being tested. Please check its state in a few seconds";
}
else
{
$query = "select count(*) from translating where subID=$id and fversion=$fversion and lang_id=$langto and tokened=0";
$result = mysql_query($query);
$count = mysql_result($result, 0);
if ($count == 0)
{
$query = "update translating set tokened=0 where subID=$id and fversion=$fversion and lang_id=$langto";
mysql_query($query);
}
$query = "select tokened,userID from translating where subID=$id and fversion=$fversion and lang_id=$langto and sequence=$seq";
$result = mysql_query($query);
$num = mysql_affected_rows();
//ya esta editada
if ($num==0)
{
$query = "select text from subs where subID=$id and fversion=$fversion and lang_id=$langto and sequence=$seq and last=1";
$result = mysql_query($query);
$text = stripslashes(mysql_result($result,0));
echo "<form method=\"post\" onsubmit=\"return update('o', '$seq');\" id=\"of$seq\">";
hidden("id", $id);
hidden("fversion", $fversion);
hidden("langto", $langto);
hidden("langfrom",$langfrom);
hidden("seq", $seq);
echo "<textarea name=\"ttext\" cols=\"60\">";
echo $text;
echo "</textarea>";
echo '<input name="Save" type="submit" class="coolBoton" value="'.$wikilang_save.'" />';
echo '</form>';
}
else
{
$row = mysql_fetch_assoc($result);
$tokened = $row['tokened'];
$tokened_user = $row['userID'];
if (!$tokened || ($tokened_user==$_SESSION['userID']))
{
//set token
$query = "update translating set tokened=1,userID=$userID where subID=$id and fversion=$fversion and lang_id=$langto and sequence=$seq";
mysql_query($query);
echo "<form method=\"post\" onsubmit=\"return update('o', '$seq');\" id=\"of$seq\">";
hidden("id", $id);
hidden("fversion", $fversion);
hidden("langto", $langto);
hidden("langfrom",$langfrom);
hidden("seq", $seq);
echo '<input type="hidden" name="Cancel" id="Cancel'.$seq.'" value="false">';
echo "<textarea name=\"ttext\" cols=\"60\">";
echo "</textarea>";
echo '<input name="Save" type="submit" class="coolBoton" value="'.$wikilang_save.'" />';
echo '<input name="Cancel" type="submit" class="coolBoton" value="'.$wikilang_cancel.'" onclick="setCancel('."'$seq'".')"/>';
echo '</form>';
}
else
{
$myuser = bd_getUsername($tokened_user);
echo "<a href=\"/user/$myuserID\">$myuser</a> $wikilang_currently_translating";
}
}
}
bbdd_close();
?>