<?php

if ( !isset($_COOKIE['btbImpersonate']) ) {

    $action['userId']    = $user['id'];
    $action['tokenId']   = $auth_token['id'];
    $action['action']    = $_POST['action'];
    $action['target']    = $_POST['target'];
    $action['mode']      = $_POST['mode'];
    $action['view']      = $_POST['view'];
    $action['createdAt'] = date('Y-m-d H:i:s', time());

    $db->insert('action', $action);
}