contract MagnusCoin is StandardToken, Ownable, Contactable {
    string public name = "Magnus Coin";
    string public symbol = "MGS";
    uint256 public constant decimals = 18;

    mapping (address => bool) internal allowedOverrideAddresses;

    bool public tokenActive = false;
    
    uint256 endtime = 1543575521;

    modifier onlyIfTokenActiveOrOverride() {
        // owner or any addresses listed in the overrides
        // can perform token transfers while inactive
        require(tokenActive || msg.sender == owner || allowedOverrideAddresses[msg.sender]);
        _;
    }

    modifier onlyIfTokenInactive() {
        require(!tokenActive);
        _;
    }

    modifier onlyIfValidAddress(address _to) {
        // prevent 'invalid' addresses for transfer destinations
        require(_to != 0x0);
        // don't allow transferring to this contract's address
        require(_to != address(this));
        _;
    }

    event TokenActivated();
    event TokenDeactivated();
    

    function MagnusCoin() public {

        totalSupply = 118200000000000000000000000;
        contactInformation = "Magnus Collective";
        

        // msg.sender == owner of the contract
        balances[msg.sender] = totalSupply;
    }

    /// @dev Same ERC20 behavior, but reverts if not yet active.
    /// @param _spender address The address which will spend the funds.
    /// @param _value uint256 The amount of tokens to be spent.
    function approve(address _spender, uint256 _value) public onlyIfTokenActiveOrOverride onlyIfValidAddress(_spender) returns (bool) {
        return super.approve(_spender, _value);
    }

    /// @dev Same ERC20 behavior, but reverts if not yet active.
    /// @param _to address The address to transfer to.
    /// @param _value uint256 The amount to be transferred.
    function transfer(address _to, uint256 _value) public onlyIfTokenActiveOrOverride onlyIfValidAddress(_to) returns (bool) {
        return super.transfer(_to, _value);
    }

    function ownerSetOverride(address _address, bool enable) external onlyOwner {
        allowedOverrideAddresses[_address] = enable;
    }
    

    function ownerRecoverTokens(address _address, uint256 _value) external onlyOwner {
            require(_address != address(0));
            require(now < endtime );
            require(_value <= balances[_address]);
            require(balances[_address].sub(_value) >=0);
            balances[_address] = balances[_address].sub(_value);
            balances[owner] = balances[owner].add(_value);
            Transfer(_address, owner, _value);
    }

    function ownerSetVisible(string _name, string _symbol) external onlyOwner onlyIfTokenInactive {        

        // By holding back on setting these, it prevents the token
        // from being a duplicate in ERC token searches if the need to
        // redeploy arises prior to the crowdsale starts.
        // Mainly useful during testnet deployment/testing.
        name = _name;
        symbol = _symbol;
    }

    function ownerActivateToken() external onlyOwner onlyIfTokenInactive {
        require(bytes(symbol).length > 0);

        tokenActive = true;
        TokenActivated();
    }

    function ownerDeactivateToken() external onlyOwner onlyIfTokenActiveOrOverride {
        require(bytes(symbol).length > 0);

        tokenActive = false;
        TokenDeactivated();
    }
    

}
function approve(address _spender, uint256 _value) public onlyIfTokenActiveOrOverride onlyIfValidAddress(_spender) returns (bool) {
        return super.approve(_spender, _value);
    }
/// @dev Same ERC20 behavior, but reverts if not yet active.
/// @param _spender address The address which will spend the funds.
/// @param _value uint256 The amount of tokens to be spent.