Beispiel #1
0
function convertFile($sourceFile, $sourcePath, $destPath, $frame, $lang)
{
    // Tag traducted are :
    // <convert>#label=000<convert>
    // Where 000 is the id of the label in T_label table
    $mainSeparator = "<convert>";
    $secSeparator = "#label=";
    // Preparing for live label translation ... in further version ... "translation.php" is located in "html/source/essais" folder
    $secSeparatorT = "#trslb=";
    $startPsn = strlen($secSeparator);
    $destFile = getFileName($sourceFile) . "_" . $lang . "." . getFileExtension($sourceFile);
    //If the destination file dose not exists or is outdated
    /*echo $sourcePath."/".$sourceFile."<br />";
      echo $destPath."/".$destFile."<br />";*/
    if (!fileExists($destPath . "/" . $destFile, "r") || fileExists($destPath . "/" . $destFile, "r") && getFilemtime($sourcePath . "/" . $sourceFile) >= getFilemtime($destPath . "/" . $destFile)) {
        echo start_comment . $destFile . " refreshed" . end_comment . "\n";
        //get the labels array
        $labelArray = getLabelArray($frame, $lang);
        //Create or replace the destination file
        $handleW = @fopen($destPath . "/" . $destFile, "w");
        $handleR = @fopen($sourcePath . "/" . $sourceFile, "r");
        if ($handleR && $handleW) {
            while (!feof($handleR)) {
                $buffer = fgets($handleR, 4096);
                //If there is something to convert
                if (strpos($buffer, $mainSeparator) !== false) {
                    //Get the elements
                    $data = explode($mainSeparator, $buffer);
                    $buffer = "";
                    for ($i = 0; $i < count($data); $i++) {
                        //for ($i=0;$i<=count($data);$i++) {
                        //If there is a label code
                        if (strpos($data[$i], $secSeparator) !== false || strpos($data[$i], $secSeparatorT) !== false) {
                            $translation_supported = strpos($data[$i], $secSeparatorT) !== false;
                            //Get the label code and replace it
                            $data[$i] = substr($data[$i], $startPsn, strlen($data[$i]) - $startPsn);
                            if ($translation_supported) {
                                $data[$i] = "<?php if (allowAccess(translation_view_all)) { ?" . "><span onclick=\"JavaScript:openWindow('translation_" . $lang . ".php?id=" . $data[$i] . "', '', 800, 600);\" class=\"translation_label\"><?php } ?" . ">" . $labelArray[$data[$i]] . "<?php if (allowAccess(translation_view_all)) { ?" . "></span><?php } ?" . ">";
                            } else {
                                $data[$i] = isset($labelArray[$data[$i]]) ? $labelArray[$data[$i]] : null;
                            }
                        }
                        //Fill the buffer
                        $buffer .= $data[$i];
                    }
                }
                //Write the result into the destination file
                fwrite($handleW, $buffer);
            }
            fclose($handleR);
            fclose($handleW);
        } else {
            echo "error yiyi8797";
        }
    }
}
    //<br /><br />Work in progress, please come back later...<br />Estimated time for reopening :
    //$_SESSION['Application_message'] = $_SESSION['Application_title']."<convert>#label=581<convert> :<br />"."<a href=\"http://www.grottocenter.org\" title=\"GrottoCenter\">www.grottocenter.org</a><br />"."<convert>#label=582<convert>.<br /><a href=\"JavaScript:window.top.location='".$_SESSION['Application_url']."/index.php?logout=true';\"><convert>#label=334<convert> <!--Raffraichir la page--></a>";
    $_SESSION['Application_revision'] = $app_prop['Revision'];
    $_SESSION['Application_creation'] = $app_prop['Creation'];
    $_SESSION['Application_authors'] = $app_prop['Authors'];
    $_SESSION['Application_copyright'] = $app_prop['Copyright'];
    $_SESSION['Application_authors_contact'] = $app_prop['Authors_contact'];
    $_SESSION['Application_thanks'] = $app_prop['Thanks'];
    $_SESSION['Application_noframe'] = "<convert>#label=157<convert>";
    //Frames are not supported !
    $_SESSION['Application_data_set'] = True;
    if (allowAccess(keep_connected)) {
        $_SESSION['Application_availability'] = 1;
    } else {
        if ($_SESSION['Application_availability'] != 1) {
            $labels = getLabelArray("general", $_SESSION['language']);
            $script = '<script type="text/javascript" charset="UTF-8">';
            $script .= getCDataTag(true);
            $script .= 'alert("<convert>#label=158<convert> ' . $_SESSION['Application_timer'] . ' <convert>#label=159<convert> ' . $_SESSION['Application_title'] . ' <convert>#label=160<convert>");';
            //Vous allez \352tre d\351connect\351 dans //minutes car //va entrer en mode de maintenance.\nVeuillez validez votre travail en cours.
            $script .= 'mySite.setLogOff(' . $_SESSION['Application_timer'] . ',"<convert>#label=161<convert> ' . $_SESSION['Application_title'] . ' <convert>#label=162<convert>");';
            //Vous allez \352tre d\351connect\351 car //est en cours de maintenance.\nVeuillez nous en excuser.
            $script .= getCDataTag(false);
            $script .= '</script>';
            echo $script;
        }
    }
}
if ($_SESSION['Update_application_noframe'] == "True") {
    $_SESSION['Application_noframe'] = "<convert>#label=157<convert>";
    //Frames are not supported !
--Check:
SELECT DISTINCT T_entry.Id, T_entry.Has_contributions
FROM V_contributions
LEFT OUTER JOIN T_entry ON V_contributions.Id_entry = T_entry.Id
WHERE (V_contributions.Id IS NULL AND T_entry.Has_contributions = 'YES') OR (V_contributions.Id IS NOT NULL AND T_entry.Has_contributions = 'NO')
*/
$_GET['lang'] = "En";
header("Content-type: text/plain");
include "../conf/config.php";
include "../func/function.php";
include "declaration.php";
$languagesArray = getAvailableLanguages();
$app_prop = appProp();
$today = date("D, d M Y H:i:s +0100");
foreach ($languagesArray as $shortLang => $largeLang) {
    $labelArray = getLabelArray("home", $shortLang);
    $feedFileName = $app_prop['Url'] . "/html/rss_" . $shortLang . ".xml";
    //header rss 2.0
    $xml = '<?xml version="1.0" encoding="UTF-8"?' . '><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
    $xml .= '<channel>';
    $xml .= '<title>' . $app_prop['Name'] . ' ' . $app_prop['Version'] . '</title>';
    $xml .= '<link>' . $app_prop['Url'] . '</link>';
    $xml .= '<description>' . $labelArray[729] . '</description>';
    $xml .= '<copyright>' . $app_prop['Authors'] . '</copyright>';
    $xml .= '<language>' . strtolower($shortLang) . '</language>';
    $xml .= '<image>';
    $xml .= '<title>' . $app_prop['Name'] . ' ' . $app_prop['Version'] . '</title>';
    $xml .= '<url>' . $app_prop['Url'] . '/favicon.png</url>';
    $xml .= '<link>' . $app_prop['Url'] . '</link>';
    $xml .= '</image>';
    $xml .= '<pubDate>' . $today . '</pubDate>';