<?

if (isset($_GET['s'])) highlight_file(__FILE__);

function ElKuld($szoveg,$akcio,$target=FALSE,$validate=FALSE,$del=FALSE,$submit=FALSE) {
    $params=json_encode($akcio);
    $params=str_replace('"',"'",$params);
    if ($submit) {
        $id=sha1(microtime());
        ?><input type="submit" id="<?=$id?>" value="<?=htmlspecialchars($szoveg)?>" class="submit"/><script type="text/javascript">$('#<?=$id?>').closest('form').submit(function(){ElKuld($('#<?=$id?>'),<?=$params?>,<?=$target?$target:'null'?>,<?=$validate?$validate:'false'?>);return false})</script><?
    } else {
        ?><input type="button" value="<?=htmlspecialchars($szoveg)?>" onclick="ElKuld(this,<?=$params?>,<?=$target?$target:'null'?>,<?=$validate?$validate:'false'?>)" class="<?=$del?'delete':'button'?>"/><?
    }
}

function HTML_Response($html=FALSE,$upload=FALSE) {
    header('Content-Type: text/html; charset=utf-8');
    if ($html!==FALSE) {
        $oldkhtml=stristr($_SERVER['HTTP_USER_AGENT'],'khtml')&&!stristr($_SERVER['HTTP_USER_AGENT'],'Version/5')&&!stristr($_SERVER['HTTP_USER_AGENT'],'Chrome/5');
        if ($upload) echo '<textarea>';
        if (file_exists($html)) {
            extract($GLOBALS);
            if ($upload) {
                ob_start();
                include $html;
                $data=ob_get_clean();
                if ($oldkhtml) {
                    echo htmlspecialchars(htmlspecialchars($data));
                } else {
                    echo htmlspecialchars($data);
                }
            } else {
                include $html;
            }
        } else {
            if ($upload) {
                if ($oldkhtml) {
                    echo htmlspecialchars(htmlspecialchars($html));
                } else {
                    echo htmlspecialchars($html);
                }
            } else {
                echo $html;
            }
        }
        if ($upload) echo '</textarea>';
        exit;
    }
}

function JS_Response($js=FALSE) {
    header('Content-Type: text/javascript; charset=utf-8');
    if ($js!==FALSE) die($js);
}

function JS_EnCode($txt) {
    $txt=str_replace('\\','\\\\',$txt);
    $txt=str_replace(chr(10),'\n',$txt);
    $txt=str_replace("'","\'",$txt);
    return($txt);
}

?>