Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix_1440' into development
# Conflicts: # sources/identify.php
- Loading branch information
Showing
365 changed files
with
998,047 additions
and
2,638 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.bak | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
include "english.php"; | ||
|
||
$myFile = "testFile.txt"; | ||
$fh = fopen($myFile, 'w') or die("can't open file"); | ||
fwrite($fh, array2json($LANG)); | ||
fclose($fh); | ||
|
||
function array2json($arr) { | ||
if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality. | ||
$parts = array(); | ||
$is_list = false; | ||
|
||
//Find out if the given array is a numerical array | ||
$keys = array_keys($arr); | ||
$max_length = count($arr)-1; | ||
if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1 | ||
$is_list = true; | ||
for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position | ||
if($i != $keys[$i]) { //A key fails at position check. | ||
$is_list = false; //It is an associative array. | ||
break; | ||
} | ||
} | ||
} | ||
|
||
foreach($arr as $key=>$value) { | ||
if(is_array($value)) { //Custom handling for arrays | ||
if($is_list) $parts[] = array2json($value); /* :RECURSION: */ | ||
else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */ | ||
} else { | ||
$str = ''; | ||
if(!$is_list) $str = '"' . $key . '":'; | ||
|
||
//Custom handling for multiple data types | ||
if(is_numeric($value)) $str .= $value; //Numbers | ||
elseif($value === false) $str .= 'false'; //The booleans | ||
elseif($value === true) $str .= 'true'; | ||
else $str .= '"' . addslashes($value) . '"'; //All other things | ||
// :TODO: Is there any more datatype we should be in the lookout for? (Object?) | ||
|
||
$parts[] = $str; | ||
} | ||
} | ||
$json = implode(',',$parts); | ||
|
||
if($is_list) return '[' . $json . ']';//Return numerical JSON | ||
return '{' . $json . '}';//Return associative JSON | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
header ( "Content-type: text/html; charset==utf-8" ); | ||
$path_to_poeditor = "./poeditor/"; | ||
// $path_to_languages = "../includes/language/"; | ||
$path_to_languages = "./"; | ||
function prepareFile($fichier, $path_to_languages, $path_to_poeditor) { | ||
echo "----<br>Fichier traité : " . $fichier . "<br>"; | ||
if ($fichier != "Teampass_English.php") { | ||
include "english.php"; | ||
} | ||
|
||
include "../includes/include.php"; | ||
$fp = fopen ( $path_to_languages . strtolower ( substr ( $fichier, 9 ) ), "w" ); | ||
fputs ( $fp, "<?php | ||
/** | ||
* | ||
* @file " . strtolower ( substr ( $fichier, 9 ) ) . " | ||
* @author Nils Laumaillé | ||
* @version " . $k ['version'] . " | ||
* @copyright " . str_replace ( " ©", "(c)", $k ['copyright'] ) . " Nils Laumaillé | ||
* @licensing GNU AFFERO GPL 3.0 | ||
* @link http://www.teampass.net | ||
* | ||
* This library 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. | ||
*/ | ||
global \$LANG; | ||
\$LANG = array (" ); | ||
$nb = 0; | ||
$lines = file ( $path_to_poeditor . $fichier ); | ||
foreach ( $lines as $linenumber => $linecontent ) { | ||
if (strpos ( $linecontent, "'term' => " ) > 0) { | ||
$term = substr ( $linecontent, 15, strlen ( $linecontent ) - 18 ); | ||
} | ||
if (strpos ( $linecontent, "'definition' => " ) > 0) { | ||
if (trim ( $linecontent ) == "'definition' => NULL,") { | ||
// rechercher la phrase en Anglais | ||
$definition = addslashes ( $LANG [$term] ); | ||
} else { | ||
$definition = substr ( $linecontent, 21, strlen ( $linecontent ) - 24 ); | ||
} | ||
} | ||
|
||
if (! empty ( $term ) && ! empty ( $definition )) { | ||
fputs ( $fp, " | ||
'" . $term . "' => '" . $definition . "'," ); | ||
$term = ""; | ||
$definition = ""; | ||
$nb ++; | ||
} | ||
} | ||
fputs ( $fp, " | ||
'' => '' | ||
);" ); | ||
fclose ( $fp ); | ||
echo " > " . $nb . " terms.<br><br>"; | ||
} | ||
|
||
echo '<html> | ||
<body> | ||
<form method="POST"> | ||
<input type="submit" value="LANGUES" id="lang" name="lang" /> | ||
<br /><br /> | ||
<input type="text" name="new_version" /> <input type="submit" value="CHANGE VERSION" id="version" name="version" /> | ||
</form> | ||
</body> | ||
</html>'; | ||
|
||
if (isset ( $_POST ['lang'] )) { | ||
if ($dossier = opendir ( $path_to_poeditor )) { | ||
// traiter le cas English | ||
prepareFile ( "Teampass_English.php", $path_to_languages, $path_to_poeditor ); | ||
|
||
// faire les autres fichiers | ||
while ( false !== ($fichier = readdir ( $dossier )) ) { | ||
if (substr ( $fichier, strlen ( $fichier ) - 4 ) == ".php" && $fichier != "Teampass_English.php") { | ||
prepareFile ( $fichier, $path_to_languages, $path_to_poeditor ); | ||
} | ||
} | ||
} else { | ||
echo "Pas de répertoire '" . $path_to_poeditor . "'"; | ||
} | ||
} else if (isset ( $_POST ['version'] ) && isset ( $_POST ['new_version'] )) { | ||
$di = new RecursiveDirectoryIterator ( "../", RecursiveDirectoryIterator::SKIP_DOTS ); | ||
$it = new RecursiveIteratorIterator ( $di ); | ||
foreach ( $it as $file ) { | ||
if (pathinfo ( $file, PATHINFO_EXTENSION ) == "php" && strpos ( pathinfo ( $file, PATHINFO_DIRNAME ), "_utils" ) == false) { | ||
// echo $file, PHP_EOL; | ||
$handle = fopen ( $file, "r" ); | ||
if ($handle) { | ||
while ( ! feof ( $handle ) ) { | ||
$buffer = fgets ( $handle ); | ||
if (strpos ( $buffer, " * @version " ) > 0) { | ||
|
||
echo $file . " " . pathinfo ( $file, PATHINFO_DIRNAME ) . "<br>"; | ||
break; | ||
} | ||
} | ||
} | ||
/* | ||
* $data = file($file); | ||
* $searchId = ' * @version'; | ||
* $c = count($data); | ||
* for($i = 0; $i < $c; $i++) { | ||
* if(strpos($data[$i], $searchId) == 0) { | ||
* unset($data[$i]); | ||
* break; | ||
* } | ||
* } | ||
* file_put_contents($file, " * @version 2.1.23"); | ||
* fclose($file); | ||
* break; | ||
*/ | ||
} | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
simpletest/test_setup.php |
Oops, something went wrong.