Created
October 13, 2010 19:15
-
-
Save dkobia/624677 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
function update_translations($lang,$file,$translations){ | |
global $USERID; | |
foreach($translations as $key => $string){ | |
// First find out if we need to do an update. | |
// This helps us create a history entry if there's a change | |
$query = 'SELECT `'.mysql_escape_string($lang).'` FROM `base` WHERE CONVERT( `file` USING utf8 ) = \''.mysql_escape_string($file).'\' AND CONVERT( `key` USING utf8 ) = \''.mysql_escape_string($key).'\' LIMIT 1'; | |
$result = mysql_query($query); | |
$current_string = @mysql_result($result,0,''.mysql_escape_string($lang).''); | |
if($string != $current_string){ | |
// Make the update | |
$query = 'UPDATE `base` SET `'.mysql_escape_string($lang).'` = \''.mysql_escape_string($string).'\' WHERE CONVERT( `file` USING utf8 ) = \''.mysql_escape_string($file).'\' AND CONVERT( `key` USING utf8 ) = \''.mysql_escape_string($key).'\' LIMIT 1 ;'; | |
mysql_query($query); | |
// Create log history | |
$query = 'INSERT INTO `history` (`id` ,`user_id` ,`time` ,`lang` ,`file` ,`key` ,`from` ,`to` | |
)VALUES ( | |
NULL , \''.mysql_escape_string($USERID).'\', CURRENT_TIMESTAMP , \''.mysql_escape_string($lang).'\', | |
\''.mysql_escape_string($file).'\', \''.mysql_escape_string($key).'\', | |
\''.mysql_escape_string($current_string).'\', \''.mysql_escape_string($string).'\');'; | |
mysql_query($query); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment