0) { $file = $_SESSION['get_language'][count($_SESSION['get_language']) - 1]; $call = '?a=get_language_file&v=' . $version . '&l=' . $languageToLoad ; $call .= '&f=' . $file; $fileData = getFileDataFromURL($updateUrl . $call); if (false === $fileData || $fileData == '') { $msg = 'Fatal error: error downloading file \'' . $file . '\'!'; $msg .= ' Please try again.'; $message[] = Html::getErrorMsg($msg); } else { // save file to disk $file = $path . '/' . $file . '.php'; $fp = @fopen($file, 'wb'); if ($fp) { fwrite($fp, $fileData); fclose($fp); if (!File::isWritable($file, 0644)) { File::isWritable($file, 0777); } $msg = ' File \'' . $file . '\' saved succesfully.'; $message[] = Html::getOkMsg($msg); // remove file from todo list $fileIndex = count($_SESSION['get_language']) - 1; unset($_SESSION['get_language'][$fileIndex]); } else { $msg = 'Fatal error: couldn\'t write file \'' . $file; $msg .= '\' to \'' . $path . '\''; $message[] = Html::getErrorMsg($msg); } } } else { $inProgress = 0; $msg = 'Finished installing language \'' . $languageToLoad; $msg .= '\' successfully.'; $message[] = Html::getOkMsg($msg); } } $json = new Services_JSON(); $r = array(); $r['in_progress'] = $inProgress; // finished? 0=no $r['error'] = 0; if ($error) { if (!empty($_SESSION['get_language'])) { $msg = 'Incomplete installation of language pack: '; $msg .= 'removing incomplete files.'; $message[] = Html::getErrorMsg($msg); // now we need to delete the language files foreach ($filesToLoad as $file) { if (file_exists($path . '/' . $file . '.php')) { if (@unlink($path . '/' . $file . '.php')) { $msg = 'Deleted file \'' . $file . '\' successfully.'; $message[] = Html::getOkMsg($msg); } else { $msg = 'Error deleting file \'' . $file; $msg .= '\'! Remove it using your FTP-Programm!'; $message[] = Html::getErrorMsg($msg); } } } if (!in_array($languageToLoad, array('en', 'de'))) { if (@rmdir($path)) { $msg = 'Directory \'' . $languageToLoad; $msg .= '\' deleted successfully.'; $message[] = Html::getOkMsg($msg); } else { $msg = 'Error deleting directory \'' . $path . '\'!'; $message[] = Html::getErrorMsg($msg); } } } $r['error'] = 1; // inidcate that an error occured to stop further actions $r['in_progress'] = 0; } $r['message'] = implode('', $message); if ($r['in_progress'] == 0) { unset($_SESSION['get_language']); } echo $json->encode($r);