contract ARKController_1_00 {
    /* Constructor */
    ARK Ark;

    event CoinSent(uint indexed id,address from,string name);

    address owner;
    address Source;

    mapping(address => bool)administrator;
    mapping(address => bool)module;
    mapping(address => string)adminName;

    mapping(uint => bool)restore;

////////////////////////////////////////////////
    log[] logs;

    struct log{
    address admin;
    string what;
    uint id;
    address a;
    }
////////////////////////////////////////////////
    
    function ARKController_1_00() {
    owner=msg.sender;
    }

    function setOwner(address a,string name) {
    if(msg.sender==owner)owner=a;
    }

    function ban(address a) returns(bool){
    return false;
    }

    function setAdministrator(address a,string name,bool yesno) {
    if(isModule(msg.sender)){
    administrator[a]=yesno;
    adminName[a]=name;
    
    if(msg.sender==owner)logs.push(log(msg.sender,"setAdmin",0,a));
    if(msg.sender!=owner)logs.push(log(msg.sender,"moduleSetAdmin",0,a));
    
    }
    }

    function setModule(address a,bool yesno) {
    if(!isModule(msg.sender))throw;
    module[a]=yesno;
    logs.push(log(owner,"setModule",0,a));

    }

    function setPrice(uint i,uint j){
    if((!isModule(msg.sender))||(i>6))throw;
    Ark.setPrice(i,j);
    logs.push(log(msg.sender,"setPrice",i,msg.sender));
    }

    function setTOS(address a,bool b){
    if(!isModule(msg.sender))throw;
    Ark.acceptTOS(a,b);
    }

    
    function setSource(address a) {
    if(msg.sender!=owner)throw;
    Ark=ARK(a);    
    Source=a;
    logs.push(log(msg.sender,"setSource",0,a));
    }

    function setARKowner(address a) {
    if(msg.sender!=owner)throw;
    Ark.initStats("",a,333);
    logs.push(log(msg.sender,"setARKowner",0,0x0));
    }

    function restoreItem(uint i){
    if(isAdmin(msg.sender)||isModule(msg.sender)){
    Ark.censorship(i,false,false);
    logs.push(log(msg.sender,"restore",i,0x0));
    }
    }

    function applyCensorship(uint i){
    if(!isAdmin(msg.sender))throw;
    Ark.censorship(i,true,false);
    logs.push(log(msg.sender,"censor",i,0x0));
    }

    function deleteCoin(uint i){
    if(!isModule(msg.sender))throw;
    Ark.censorship(i,true,true);
    logs.push(log(msg.sender,"censor",i,0x0));
    }

    function registerExternalBill(uint bi,address sellsNow,address buyerwallet,uint tipo,uint sell,uint c) private{
    if(!isModule(msg.sender))throw;
    Ark.registerExternalBill(bi,sellsNow,buyerwallet,tipo,sell,c);
    }

    function pushCoin(uint i,address a,string s) returns(bool){
    if(msg.sender!=Source)throw;
    CoinSent(i,a,s);
    return true;
    }

    function isAdmin(address a)constant returns(bool){
    bool b=false;
    if((a==owner)||(administrator[a]))b=true;
    return b;
    }

    function isModule(address a)constant returns(bool){
    bool b=false;
    if((a==owner)||(module[a]))b=true;
    return b;
    }

    function getAdminName(address a)constant returns(string){
    return adminName[a];
    }

    function getSource()constant returns(address){
    return Source;
    }

    function readLog(uint i)constant returns(string,address,string,uint,address){
    log l=logs[i];
    return(getAdminName(l.admin),l.admin,l.what,l.id,l.a);
    }
    

}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ARKController_1_00() {
    owner=msg.sender;
    }
////////////////////////////////////////////////