<?php
$root=dirname(dirname(__FILE__));
if(!file_exists($root."/data/auth.php")){
    if($_GET[edit]=='yes'){
        if($_POST[apikey]!='' and $_POST[password]!=''){
            $txt="<?php
        date_default_timezone_set('PRC');
                define(\"APIKEY\",\"$_POST[apikey]\");
                define(\"APIPASS\",\"$_POST[password]\");
";
        $fp=fopen("../data/auth.php","w+");
        flock($fp,LOCK_EX);
        $write=fputs($fp,$txt);
        flock($fp,LOCK_UN);
        fclose($fp);
        die('Success');
        }
        else{
            die('False');
        }
    }
    else{
        header('location:authEdit.php');
    }
}
else {
    header('location:authError.php');
}
?>