コード例 #1
0
ファイル: resource.php プロジェクト: peppy/pTransl
<?
$resourceId = $_REQUEST[r];
$resourceId = (int)2;

$languageCode = sqlstr($_REQUEST[l]);
//must check this is a valid language

$languages = $conn->queryAll("SELECT l.*, (select count(distinct translation_id) FROM translations WHERE variable_id in (select variable_id from variables where resource_id = $resourceId) AND language_code = l.code) as complete FROM languages l");

$languageFound = in_array_column($languageCode,'code',$languages);

if (!$languageFound)
	$languageCode = "";
else
{
	switch ($_REQUEST[a])
	{
		case "update":
			$variableId = (int)$_REQUEST[id];
			
			$text = sqlstr(str_replace('\\','\\\\',$_REQUEST[content]));
			
			$existing = $conn->queryAll("SELECT * FROM translations WHERE variable_id = $variableId AND user_id = $userId AND language_code = '$languageCode'");
			
			if (sizeof($existing) == 0)
			{
				$conn->exec("INSERT INTO translations (user_id, variable_id, language_code, text) VALUES ($userId, $variableId, '$languageCode', '$text')");
			}
			else
			{
				$conn->exec("UPDATE translations SET text = '$text', last_update = CURRENT_TIMESTAMP WHERE user_id = $userId AND language_code = '$languageCode' AND variable_id = $variableId");
コード例 #2
0
 public static function checkFile($file, IssuesBank $issues)
 {
     $source = file_get_contents($file);
     $tokens = token_get_all($source);
     // cut off heredoc, comments
     while (in_array_column($tokens, T_START_HEREDOC, 0)) {
         $start = array_search_column($tokens, T_START_HEREDOC, 0);
         $end = array_search_column($tokens, T_END_HEREDOC, 0);
         array_splice($tokens, $start, $end - $start + 1);
     }
     // find for deprecated functions
     $deprecated_functions = $issues->getAll('functions');
     $used_functions = array_filter_by_column($tokens, T_STRING, 0);
     foreach ($used_functions as $used_function) {
         if (isset($deprecated_functions[$used_function[1]])) {
             $function = $deprecated_functions[$used_function[1]];
             fwrite(STDERR, '[' . $function[1] . '] Function ' . $used_function[1] . ' is deprecated in file ' . $file . '[' . $used_function[2] . ']. ');
             if ($function[0] != $used_function[1]) {
                 fwrite(STDERR, 'Consider using ' . $function[0] . ' instead.');
             }
             fwrite(STDERR, PHP_EOL);
         }
     }
     // find for deprecated ini settings
     $deprecated_ini_settings = $issues->getAll('ini_settings');
     foreach ($tokens as $i => $token) {
         if ($token[0] == T_STRING && in_array($token[1], array('ini_alter', 'ini_set', 'ini_​get', 'ini_restore'))) {
             // syntax structure check
             if ($tokens[$i + 1] == '(' && is_array($tokens[$i + 2]) && $tokens[$i + 2][0] == T_CONSTANT_ENCAPSED_STRING) {
                 $ini_setting = $tokens[$i + 2];
                 // ('ini_setting'
                 $ini_setting[1] = trim($ini_setting[1], '\'"');
                 if (isset($deprecated_ini_settings[$ini_setting[1]])) {
                     $deprecated_setting = $deprecated_ini_settings[$ini_setting[1]];
                     fwrite(STDERR, '[' . $deprecated_setting[1] . '] Ini setting ' . $ini_setting[1] . ' is deprecated in file ' . $file . '[' . $ini_setting[2] . ']. ');
                     if ($deprecated_setting[0] != $ini_setting[1]) {
                         fwrite(STDERR, 'Consider using ' . $deprecated_setting[0] . ' instead.');
                     }
                     fwrite(STDERR, PHP_EOL);
                 }
             }
         }
     }
     // find for deprecated functions usage
     $deprecated_functions_usage = $issues->getAll('functions_usage');
     foreach ($tokens as $i => $token) {
         if ($token[0] != T_STRING) {
             continue;
         }
         if (!isset($deprecated_functions_usage[$token[1]])) {
             continue;
         }
         // get func arguments
         $function = array($token);
         $k = $i + 2;
         $braces = 1;
         while ($braces > 0 && isset($tokens[$k])) {
             $function[] = $tokens[$k];
             if ($tokens[$k] == ')') {
                 /*var_dump($tokens[$k]);*/
                 $braces--;
             } else {
                 if ($tokens[$k] == '(') {
                     /*var_dump($tokens[$k]);*/
                     $braces++;
                 }
             }
             // var_dump($braces);
             $k++;
         }
         //$function[] = $tokens[$k];
         $fixer = ltrim($deprecated_functions_usage[$token[1]][0], '@');
         require_once dirname(dirname(__FILE__)) . '/data/' . $fixer . '.php';
         $fixer = __NAMESPACE__ . '\\' . $fixer;
         $result = $fixer($function);
         if ($result) {
             fwrite(STDERR, '[' . $deprecated_functions_usage[$token[1]][1] . '] Function ' . $token[1] . ' usage is deprecated (' . $deprecated_functions_usage[$token[1]][0] . ') in file ' . $file . '[' . $token[2] . '].' . PHP_EOL);
         }
     }
     // find for deprecated variables
     $deprecated_varibales = $issues->getAll('variables');
     $used_variables = array_filter_by_column($tokens, T_VARIABLE, 0);
     foreach ($used_variables as $used_variable) {
         if (isset($deprecated_varibales[$used_variable[1]])) {
             $variable = $deprecated_varibales[$used_variable[1]];
             fwrite(STDERR, '[' . $variable[1] . '] Variable ' . $used_variable[1] . ' is deprecated in file ' . $file . '[' . $used_variable[2] . ']. ');
             if ($variable[0] != $used_variable[1]) {
                 fwrite(STDERR, 'Consider using ' . $variable[0] . ' instead.');
             }
             fwrite(STDERR, PHP_EOL);
         }
     }
     // find for methods naming deprecations
     $methods_naming = $issues->getAll('methods_naming');
     if (!empty($methods_naming)) {
         while (in_array_column($tokens, T_CLASS, 0)) {
             $total = count($tokens);
             $i = array_search_column($tokens, T_CLASS, 0);
             $class_start = $i;
             $class_name = $tokens[$i + 2][1];
             $braces = 1;
             $i += 5;
             while ($braces > 0 && $i + 1 <= $total) {
                 if ($tokens[$i] == '{') {
                     $braces++;
                     /*echo '++';*/
                 } else {
                     if ($tokens[$i] == '}') {
                         $braces--;
                         /*echo '--';*/
                     } else {
                         if (is_array($tokens[$i]) && $tokens[$i][0] == T_FUNCTION) {
                             $function_name = $tokens[$i + 2][1];
                             foreach ($methods_naming as $methods_naming_checker) {
                                 $checker = ltrim($methods_naming_checker[0], '@');
                                 require_once dirname(dirname(__FILE__)) . '/data/' . $checker . '.php';
                                 $checker = __NAMESPACE__ . '\\' . $checker;
                                 $result = $checker($class_name, $function_name);
                                 if ($result) {
                                     fwrite(STDERR, '[' . $methods_naming_checker[1] . '] Method name "' . $function_name . '" in class "' . $class_name . '" is deprecated (' . $methods_naming_checker[0] . ') in file ' . $file . '[' . $tokens[$i][2] . '].' . PHP_EOL);
                                 }
                             }
                         }
                     }
                 }
                 $i++;
             }
             array_splice($tokens, $class_start, $i - $class_start);
         }
     }
 }
コード例 #3
0
echo $lib_update_reference_bille_145;
?>
					<?php 
$mesSynonymes = get_billes_apparentees_by_id($sql_get_billes_apparentees, $id);
?>
								<select multiple data-placeholder="<?php 
echo $lib_div_1000;
?>
" class="MyList" name="input_synonyme[]" id="input_synonyme" style="width:100%">
									<?php 
$mesbilles = get_option_billes();
?>
									<?php 
foreach ($mesbilles as $mabille) {
    echo '<option';
    if (in_array_column($mabille['val'], 'NOM', $mesSynonymes)) {
        echo ' selected ';
    }
    echo '>' . $mabille['val'] . '</option>';
}
?>
								</select>
				</label>
				<label class="full-line"><?php 
echo $lib_update_reference_bille_400;
?>
					<input type="checkbox" id="input_base_frittee" name="input_base_frittee" value="true" <?php 
if ($bille['BASE_FRITTEE'] == '1') {
    echo 'checked = "checked"';
} else {
    echo '';