File "edit.php"
Full Path: /home/analogde/www/filetypes/pxl/edit.php
File size: 11.65 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/***************************************************************
* Copyright notice
*
* (c) 2003-2004 Tobias Bender (tobias@phpXplorer.org)
* All rights reserved
*
* This script is part of the phpXplorer project. The phpXplorer project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt distributed with these scripts.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$acronym = basename(dirname(__FILE__));
require(dirname(__FILE__) . "/../defaultActionHead.php");
if(file_exists($currentDir . "/keywords.php")){
require($currentDir . "/keywords.php");
}else{
die($PXP_languages[$PXP_language]['onlyInPXLF']);
}
require($PXP_dir . "/lang.pxlf/" . $PXP_system_language . "_languageCodes.php");
asort($lngCodes);
asort($PXP_languageKeywords);
$lng_id = getRequestVar("lng_id");
$ref_lng_id = getRequestVar("ref_lng_id");
$only_new_keywords = getRequestVar("only_new_keywords");
$fileName = getRequestVar("fileName");
$submitAction = getRequestVar("submitAction");
if(!(strpos($fileName, "..") === FALSE))
die($PXP_languages[$PXP_language]['accessDenied'] . " (804)");
$pInfo = checkFilePermissions($fileName, false);
if(!$pInfo["allowOpen"] or !$pInfo["allowEdit"])
die($PXP_languages[$PXP_language]["accessDenied"] . " (809)");
if($lng_id == ""){
$arr = explode(".", $fileName);
$lng_id = strToLower($arr[0]);
}
if($ref_lng_id == "")
$ref_lng_id = "en";
$PXP_languages = Array();
$PXP_languages[$lng_id] = Array();
$PXP_languages[$ref_lng_id] = Array();
$PXP_languages[$PXP_language] = Array();
if($currentDir != $PXP_dir . "/lang.pxlf" or ($PXP_language != $lng_id and $PXP_language != $ref_lng_id))
require($PXP_dir . "/lang.pxlf/" . $PXP_language . ".pxl.php");
if(!file_exists($currentDir . "/" . $lng_id . ".pxl.php")){
$PXP_languages[$lng_id] = Array();
}else{
require($currentDir . "/" . $lng_id . ".pxl.php");
}
if(file_exists($currentDir . "/" . $ref_lng_id . ".pxl.php"))
require($currentDir . "/" . $ref_lng_id . ".pxl.php");
if($submitAction != ""){
$senderInfo = "";
$senderInfo .= "Name: " . $HTTP_POST_VARS["submit_frm_name"] ."\n";
$senderInfo .= "Email: " . $HTTP_POST_VARS["submit_frm_email"] ."\n";
$senderInfo .= "Comment: " . $HTTP_POST_VARS["submit_frm_comment"] ."\n";
$senderInfo .= "Agree: " . $HTTP_POST_VARS["submit_frm_agree"] ."\n";
$senderInfo .= "Location: " . $currentDir ."\n";
$senderInfo .= "Language: " . $lng_id ."\n\n";
$translationText .= '';
$translationText .= '<?php' . "\n\n";
$translationText .= "# This translation was made by " . $HTTP_POST_VARS["submit_frm_name"] . " (" . $HTTP_POST_VARS["submit_frm_email"] . ") on " . date("d.m.y - H:i:s") . "\n\n";
$translationText .= implode("", file($PXP_dir . "/copyrightNotice.txt")) . "\n";
$translationText .= '$PXP_languages["' . $lng_id . '"] = array_merge($PXP_languages["' . $lng_id . '"], Array(' . "\n";
foreach($PXP_languageKeywords as $index => $item){
$key = $item->group != "" ? $item->group . "." . $item->keyword : $item->keyword;
$request_key = $item->group != "" ? $item->group . "_" . $item->keyword : $item->keyword;
$translationText .= " '" . $key . "' => '" . (isset($HTTP_POST_VARS[$request_key]) ? $HTTP_POST_VARS[$request_key] : $PXP_languages[$lng_id][$key]) . "',\n";
}
$translationText = substr($translationText, 0, strlen($translationText) - 2);
$translationText .= "\n));\n\n";
$translationText .= '?>';
$mailText = "";
$mailText .= "Hello " . $HTTP_POST_VARS["submit_frm_name"] . ",\n";
$mailText .= "thank you for supporting phpXplorer!\n\n";
$mailText .= "Save the following PHP code to a file called '" . $lng_id . ".pxl.php', and copy it to the '.../phpXplorer/system/lang.pxlf' folder. Then you can set the new language in phpXplorer user editor.\n";
$mailText .= "Here is the source code of the new translation file:\n\n";
$mailText .= $translationText;
if($HTTP_POST_VARS["submit_frm_copy_to_tobias"] == "true")
mail("tobias@phpxplorer.org", "phpXplorer translation", $senderInfo . $mailText);
# if($HTTP_POST_VARS["submit_frm"] == "mail"){
# if(!@mail($HTTP_POST_VARS["submit_frm_email"], "phpXplorer translation", $mailText)){
# echo '<b style="color:red">Mail could not be send! Please check you mail address!</b><br><br>';
# }else{
# echo '<b style="color:red">Mail send successfully!</b><br><br>';
# }
# }
$handle = fopen($currentDir . "/" . $lng_id . ".pxl.php", "w");
fwrite($handle, $translationText);
fclose($handle);
}
?>
<html>
<head><title><?php echo $PXP_languages[$PXP_language]['editProperties'] ?>: <?php echo $fileName ?> (<?php echo $PXP_languages[$PXP_language]['filetype.' . $pInfo["extKey"]] ?>)</title>
<style type="text/css">
<!--
body{
color: #003366;
font-size: 12px;
font-family: Verdana
}
td{
font-family: Verdana;
font-size: 12px;
}
input{
font-family: Verdana;
font-size: 12px;
color: #003366
}
textarea{
font-size: 11px;
color: #003366
}
select{
font-family: Verdana;
font-size: 12px
}
td.title{
font-weight: bold;
color: #888888
}
td.head{
font-weight: bold;
color: #666666
}
-->
</style>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
function send(a){
var f = document.frm1
if(f.submit_frm_name.value == ""){
f.submit_frm_name.focus()
alert("<?php echo $PXP_languages[$PXP_language]['pleaseInsertValue'] ?>!")
return
}
if(f.submit_frm_email.value == ""){
f.submit_frm_email.focus()
alert("<?php echo $PXP_languages[$PXP_language]['pleaseInsertValue'] ?>!")
return
}
f.submitAction.value = a
f.submit()
}
function init(){
<?php
switch($submitAction){
case "save":
echo "opener.refreshDir()\r\n";
break;
case "saveAndExit":
echo "opener.refreshDir()\r\n";
echo "window.close()\r\n";
break;
}
?>
}
//]]>
</script>
</head>
<body onLoad="init()">
<form name="frm1" action="./edit.php" method="post" ttarget="frmSave">
<?php echo $PXP_languages[$PXP_language]["language"] ?>
<select size="1" name="lng_id" onChange="if(confirm('<?php echo $PXP_languages[$PXP_language]['changesWouldBeLost'] ?>!'))location.href='./edit.php?currentDir=<?php echo $currentDir ?>&fileName=' + this.options[this.selectedIndex].value + '.pxl.php&shareId=<?php echo $shareId ?>&lng_id=' + this.options[this.selectedIndex].value">
<?php
foreach($lngCodes as $index => $value)
echo '<option value="' . $index . '"' . ($index == $lng_id ? ' selected="selected"' : '') . '>' . $value . '</option>';
?>
</select>
<br><br>
<table style="border:1px solid #cccccc">
<tr>
<td>
<table>
<tr>
<td class="head"><?php echo $PXP_languages[$PXP_language]["group"] ?> </td>
<td class="head"><?php echo $PXP_languages[$PXP_language]["keyword"] ?> </td>
<td class="head"><?php echo $lngCodes[$lng_id] ?> </td>
<td class="head"><?php echo $PXP_languages[$PXP_language]["referenceLanguage"] ?> </td>
<td class="head"><?php echo $PXP_languages[$PXP_language]["description"] ?> </td>
<td></td>
</tr>
<tr>
<td> </td>
<td><input type="checkbox" name="only_new_keywords" value="true" onClick="if(this.checked){if(confirm('<?php echo $PXP_languages[$PXP_language]['changesWouldBeLost'] ?>!')){document.frm1.submit()}else{this.checked=!this.checked}}else{document.frm1.submit()}"<?php echo ($only_new_keywords == "true" ? ' checked="checked"' : '') ?>> <?php echo $PXP_languages[$PXP_language]['missingOnly'] ?></td>
<td> </td>
<td>
<select size="1" name="ref_lng_id" onChange="document.frm1.submit()">
<?php
foreach($lngCodes as $index => $value)
echo '<option value="' . $index . '"' . ($index == $ref_lng_id ? ' selected="selected"' : '') . '>' . $value . '</option>';
?>
</select>
</td>
<td> </td>
<td></td>
</tr>
<tr><td colspan="5" class="title"><br><?php echo $PXP_languages[$PXP_language]['common'] ?></td></tr>
<tr><td colspan="5" bgcolor="#cccccc" height="3"></td></tr>
<?php
$actGroup = "";
foreach($PXP_languageKeywords as $index => $item){
if($actGroup != $item->group){
echo '<tr><td colspan="5" class="title"><br><br>' . $item->group . ' <span style="font-weight:normal;color:#cccccc">(' . $PXP_groupExplanations[$item->group] . ')</span></td></tr>';
echo '<tr><td colspan="5" bgcolor="#cccccc" height="3"></td></tr>';
$actGroup = $item->group;
}
$key = $item->group != "" ? $item->group . "." . $item->keyword : $item->keyword;
$request_key = $item->group != "" ? $item->group . "_" . $item->keyword : $item->keyword;
if($only_new_keywords == "true" and $PXP_languages[$lng_id][$key] != "")
continue;
echo '<tr>';
echo '<td> </td>';
echo '<td>' . $item->keyword . ' </td>';
echo '<td><input type="text" name="' . $request_key . '" value="' . (isset($HTTP_POST_VARS[$request_key]) ? $HTTP_POST_VARS[$request_key] : $PXP_languages[$lng_id][$key]) . '" size="35"></td>';
echo '<td><input type="text" style="color:#aaaaaa" value="' . $PXP_languages[$ref_lng_id][$key] . '" size="35"></td>';
echo '<td>' . $item->description . '</td>';
echo '</tr>';
}
?>
</table>
</td>
</tr>
</table>
<br><br>
<table style="border:1px solid #cccccc" cellspacing="5">
<tr>
<td><?php echo $PXP_languages[$PXP_language]['name'] ?></td>
<td><input type="text" name="submit_frm_name" size="30" value="<?php echo $HTTP_POST_VARS['submit_frm_name'] != "" ? $HTTP_POST_VARS['submit_frm_name'] : $PXP_firstname . " " . $PXP_name ?>"></td>
</tr>
<tr>
<td><?php echo $PXP_languages[$PXP_language]['email'] ?></td>
<td><input type="text" name="submit_frm_email" size="30" value="<?php echo $HTTP_POST_VARS['submit_frm_email'] != "" ? $HTTP_POST_VARS['submit_frm_email'] : $PXP_email ?>"></td>
</tr>
<tr>
<td valign="top"> </td>
<td><input type="checkbox" name="submit_frm_copy_to_tobias" value="true" checked="checked"> <span style="cursor:pointer" onClick="this.parentNode.firstChild.checked=!this.parentNode.firstChild.checked"><?php echo $PXP_languages[$PXP_language]['sendCopyToTobias'] ?></span></td>
</tr>
<tr>
<td valign="top"><?php echo $PXP_languages[$PXP_language]['comment'] ?></td>
<td><textarea cols="40" rows="8" name="submit_frm_comment"><?php echo $HTTP_POST_VARS["submit_frm_comment"] ?></textarea></td>
</tr>
<tr>
<td valign="top"> </td>
<td><input type="checkbox" name="submit_frm_agree" value="true" checked="checked"> <span style="cursor:pointer" onClick="this.parentNode.firstChild.checked=!this.parentNode.firstChild.checked"><?php echo $PXP_languages[$PXP_language]['askForFurtherTranslation'] ?></span></td>
</tr>
<tr>
<td> </td>
<td align="right">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['save'] ?>" onClick="send('save')">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['saveAndExit'] ?>" onClick="send('saveAndExit')">
<input type="button" value="<?php echo $PXP_languages[$PXP_language]['cancel'] ?>" onClick="window.close()">
</td>
</tr>
</table>
<input type="hidden" name="submitAction" value="">
<input type="hidden" name="currentDir" value="<?php echo $currentDir ?>">
<input type="hidden" name="shareId" value="<?php echo $shareId ?>">
<input type="hidden" name="fileName" value="<?php echo $fileName ?>">
</form>
</body>
</html>