@ -46,8 +46,8 @@ function set_file_folder_permissions() {
*/
function fill_track_countries_table($track_countries_table) {
$file_path = dirname(__FILE__).'/'.COUNTRY_DATA_FILENAME;
$add_country_sql = "LOAD DATA INFILE '".mysql_real_ escape_string($file_path)."' INTO TABLE $track_countries_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
@ mysql_ query($add_country_sql);
$add_country_sql = "LOAD DATA INFILE '".Database:: escape_string($file_path)."' INTO TABLE $track_countries_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'';";
@ Database:: query($add_country_sql);
}
/**
@ -165,7 +165,7 @@ function load_main_database($installation_settings, $db_script = '') {
//replace symbolic parameters with user-specified values
foreach ($installation_settings as $key => $value) {
$dokeos_main_sql_file_string = str_replace($key, mysql_real_ escape_string($value), $dokeos_main_sql_file_string);
$dokeos_main_sql_file_string = str_replace($key, Database:: escape_string($value), $dokeos_main_sql_file_string);
}
//split in array of sql strings
@ -176,7 +176,7 @@ function load_main_database($installation_settings, $db_script = '') {
$count = count($sql_instructions);
for ($i = 0; $i < $count; $i++) {
$this_sql_query = $sql_instructions[$i]['query'];
mysql_ query($this_sql_query);
Database:: query($this_sql_query);
}
}
@ -195,7 +195,7 @@ function load_database_script($db_script) {
$count = count($sql_instructions);
for ($i = 0; $i < $count; $i++) {
$this_sql_query = $sql_instructions[$i]['query'];
mysql_ query($this_sql_query);
Database:: query($this_sql_query);
}
}
@ -222,8 +222,8 @@ function split_sql_file(&$ret, $sql) {
$sql_len = strlen($sql);
$char = '';
$string_start = '';
$in_string = FALSE ;
$nothing = TRUE ;
$in_string = false ;
$nothing = true ;
$time0 = time();
for ($i = 0; $i < $sql_len; ++$i) {
@ -238,21 +238,21 @@ function split_sql_file(&$ret, $sql) {
// returned array
if (!$i) {
$ret[] = $sql;
return TRUE ;
return true ;
}
// Backquotes or no backslashes before quotes: it's indeed the
// end of the string -> exit the loop
else if ($string_start == '`' || $sql[$i-1] != '\\') {
elseif ($string_start == '`' || $sql[$i - 1] != '\\') {
$string_start = '';
$in_string = FALSE ;
$in_string = false ;
break;
}
// one or more Backslashes before the presumed end of string...
else {
// ... first checks for escaped backslashes
$j = 2;
$escaped_backslash = FALSE ;
while ($i-$j > 0 & & $sql[$i-$j] == '\\') {
$escaped_backslash = false ;
while ($i - $j > 0 & & $sql[$i - $j] == '\\') {
$escaped_backslash = !$escaped_backslash;
$j++;
}
@ -260,7 +260,7 @@ function split_sql_file(&$ret, $sql) {
// string -> exit the loop
if ($escaped_backslash) {
$string_start = '';
$in_string = FALSE ;
$in_string = false ;
break;
}
// ... else loop
@ -272,39 +272,39 @@ function split_sql_file(&$ret, $sql) {
} // end if (in string)
// lets skip comments (/*, -- and #)
else if (($char == '-' & & $sql_len > $i + 2 & & $sql[$i + 1] == '-' & & $sql[$i + 2] < = ' ') || $char == '#' || ($char == '/' & & $sql_len > $i + 1 & & $sql[$i + 1] == '*')) {
elseif (($char == '-' & & $sql_len > $i + 2 & & $sql[$i + 1] == '-' & & $sql[$i + 2] < = ' ') || $char == '#' || ($char == '/' & & $sql_len > $i + 1 & & $sql[$i + 1] == '*')) {
$i = strpos($sql, $char == '/' ? '*/' : "\n", $i);
// didn't we hit end of string?
if ($i === FALSE ) {
if ($i === false ) {
break;
}
if ($char == '/') $i++;
}
// We are not in a string, first check for delimiter...
else if ($char == ';') {
elseif ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
$nothing = TRUE ;
$nothing = true ;
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
$i = -1;
} else {
// The submited statement(s) end(s) here
return TRUE ;
return true ;
}
} // end else if (is delimiter)
} // end elseif (is delimiter)
// ... then check for start of a string,...
else if (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE ;
$nothing = FALSE ;
elseif (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = true ;
$nothing = false ;
$string_start = $char;
} // end else if (is start of string)
} // end elseif (is start of string)
elseif ($nothing) {
$nothing = FALSE ;
$nothing = false ;
}
// loic1: send a fake header each 30 sec. to bypass browser timeout
@ -320,8 +320,8 @@ function split_sql_file(&$ret, $sql) {
$ret[] = array('query' => $sql, 'empty' => $nothing);
}
return TRUE ;
} // end of the 'PMA_splitSqlF ile()' function
return true ;
} // end of the 'split_sql_f ile()' function
/**
* Get an SQL file's contents
@ -367,7 +367,7 @@ function get_sql_file_contents($file, $section, $print_errors = true) {
if (substr($line, 0, 2) == '--') {
//This is a comment. Check if section name, otherwise ignore
$result = array();
if (preg_match('/^-- xx([A-Z]*)xx/', $line,$result)) { //we got a section name here
if (preg_match('/^-- xx([A-Z]*)xx/', $line, $result)) { //we got a section name here
if ($result[1] == strtoupper($section)) {
//we have the section we are looking for, start recording
$record = true;
@ -391,6 +391,29 @@ function get_sql_file_contents($file, $section, $print_errors = true) {
return $section_contents;
}
/**
* Returns a list of language directories.
*/
function get_language_folder_list() {
$result = array();
$exceptions = array('.', '..', 'CVS', '.svn');
$search = array('_latin', '_unicode', '_corporate', '_org' , '_KM', '_');
$replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
$dirname = api_get_path(SYS_LANG_PATH);
$handle = opendir($dirname);
while ($entries = readdir($handle)) {
if (in_array($entries, $exceptions)) {
continue;
}
if (is_dir($dirname.$entries)) {
$result[$entries] = ucwords(str_replace($search, $replace_with, $entries));
}
}
closedir($handle);
asort($result);
return $result;
}
// TODO: Maybe within the main API there is already a suitable function?
function my_directory_to_array($directory) {
$array_items = array();
@ -426,10 +449,10 @@ function add_document_180($_course, $path, $filetype, $filesize, $title, $commen
VALUES ('$path','$filetype','$filesize','".
Database::escape_string($title)."', '$comment')";
if (Database::query($sql)) {
//display_message("Added to database (id ".mysql_ insert_id().")!");
return mysql_ insert_id();
//display_message("Added to database (id ".Database:: insert_id().")!");
return Database:: insert_id();
} else {
//display_error("The uploaded file could not be added to the database (".mysql_ error().")!");
//display_error("The uploaded file could not be added to the database (".Database:: error().")!");
return false;
}
}