Skip to content

Commit

Permalink
Merge branch 'fix_1440' into development
Browse files Browse the repository at this point in the history
# Conflicts:
#	sources/identify.php
  • Loading branch information
nilsteampassnet committed Sep 11, 2016
2 parents 5eb1856 + 0ce4c8d commit 46ff64d
Show file tree
Hide file tree
Showing 365 changed files with 998,047 additions and 2,638 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
*.bak
.idea
49 changes: 49 additions & 0 deletions _utils/_utils_convert.php
@@ -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
}
119 changes: 119 additions & 0 deletions _utils/_utils_tool.php
@@ -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 ( " &copy;", "(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 "&nbsp;&nbsp;&nbsp;> " . $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;
*/
}
}
}

?>
1 change: 1 addition & 0 deletions _utils/db/meekrodb-master/meekrodb-master/.gitignore
@@ -0,0 +1 @@
simpletest/test_setup.php

0 comments on commit 46ff64d

Please sign in to comment.