Example #1
0
function showError($strMessage)
{
    iniTable();
    echo "<h1>File not Created!</h1>";
    badData($strMessage);
    endTable();
    echo "<br>";
}
Example #2
0
echoStyle();
if (isset($_POST['strLine'], $_POST['intLine'], $_POST['fileName'])) {
    doPost($_POST['strLine'], $_POST['intLine'], $_POST['fileName']);
} elseif (isset($_GET['lang'])) {
    $filename = strtolower($_GET['lang']);
    if ($filename != "") {
        if (in_array($filename, getLangFiles())) {
            showEdit($filename);
        } else {
            badData("LANGUAGE FILE (" . $filename . ") NOT FOUND");
        }
    } else {
        badData("NO LANGUAGE FILE ENTERED");
    }
} else {
    badData("NO LANGUAGE FILE ENTERED");
}
function doPost($strLine, $intLine, $fileName)
{
    $strLine = str_replace("\\", "", $strLine);
    if (substr($strLine, 0, 1) != '"' or substr($strLine, -2) != '";') {
        showError('All lines must start with " and end with "; ', $strLine);
    } else {
        $flines = file($fileName);
        //Update the line
        $flines[$intLine] = substr($flines[$intLine], 0, 40) . $strLine . "\n";
        //reWrite the file
        $fh = fopen($fileName, 'w');
        while (1) {
            if (flock($fh, LOCK_EX)) {
                fwrite($fh, implode("", $flines));