Example #1
0
 /**
  * function storeAudit($saveParams = array()):
  * This method is (optional) will be called automatically by MatchaCUP
  * to store the event log into the database.
  *
  * Basically when MatchaCUP->save or MatchaCUP->destroy is used it will look
  * for this method and execute it and pass all the SQL statement and
  * other parameters into a array to this method. Here you can execute the MatchaAudit
  * class to save the event log or anything you want.
  *
  * The method should be established PUBLIC STATIC, this way it will not take more
  * memory.
  * @param array $saveParams
  */
 public static function storeAudit($saveParams = [])
 {
     // get pid...
     if (isset($saveParams['data']['pid'])) {
         $pid = $saveParams['data']['pid'];
     } else {
         $match = [];
         preg_match('/`pid`.*:W(\\d*)/', $saveParams['sql'], $match);
         if (!empty($match)) {
             preg_match('/:W(\\d*)/', $match[0], $match);
             $pid = $saveParams['data'][$match[0]];
         } else {
             $pid = '0';
         }
     }
     // get eid...
     if (isset($saveParams['data']['eid'])) {
         $eid = $saveParams['data']['eid'];
     } else {
         $match = [];
         preg_match('/`eid`.*:W(\\d*)/', $saveParams['sql'], $match);
         if (!empty($match)) {
             preg_match('/:W(\\d*)/', $match[0], $match);
             $eid = $saveParams['data'][$match[0]];
         } else {
             $eid = '0';
         }
     }
     $uid = isset($_SESSION['user']['id']) ? $_SESSION['user']['id'] : '0';
     $fid = isset($_SESSION['user']['facility']) ? $_SESSION['user']['facility'] : '0';
     $date = Time::getLocalTime('Y-m-d H:i:s');
     $table = isset($saveParams['table']) ? $saveParams['table'] : '';
     $sql = isset($saveParams['sql']) ? $saveParams['sql'] : '';
     $data = isset($saveParams['data']) ? serialize($saveParams['data']) : '';
     MatchaAudit::$eventLogData = ['date' => $date, 'pid' => $pid, 'eid' => $eid, 'uid' => $uid, 'fid' => $fid, 'event' => $saveParams['event'], 'table_name' => $table, 'sql_string' => $sql, 'data' => $data, 'ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0', 'checksum' => crc32($uid . $fid . $date . $table . $sql . $data)];
     MatchaAudit::auditSaveLog();
 }
Example #2
0
 /**
  * @param bool $pause True to pause the audit log
  * @return bool
  */
 public static function pauseLog($pause)
 {
     return MatchaAudit::$__audit = !$pause;
 }
Example #3
0
 /**
  * function storeAudit($saveParams = array()):
  * This method is (optional) will be called automatically by MatchaCUP
  * to store the event log into the database.
  *
  * Basically when MatchaCUP->save or MatchaCUP->destroy is used it will look
  * for this method and execute it and pass all the SQL statement and
  * other parameters into a array to this method. Here you can execute the MatchaAudit
  * class to save the event log or anything you want.
  *
  * The method should be established PUBLIC STATIC, this way it will not take more
  * memory.
  */
 public static function storeAudit($saveParams = array())
 {
     if ($saveParams['event'] != 'SELECT') {
         MatchaAudit::$eventLogData = array('date' => Time::getLocalTime('Y-m-d H:i:s'), 'pid' => isset($saveParams['data']['pid']) ? $saveParams['data']['pid'] : '0', 'eid' => isset($saveParams['data']['eid']) ? $saveParams['data']['eid'] : '0', 'uid' => isset($_SESSION['user']['id']) ? $_SESSION['user']['id'] : '0', 'fid' => isset($_SESSION['user']['facility']) ? $_SESSION['user']['facility'] : '0', 'event' => $saveParams['event'], 'table_name' => isset($saveParams['table']) ? $saveParams['table'] : '', 'sql_string' => isset($saveParams['sql']) ? $saveParams['sql'] : '', 'data' => isset($saveParams['data']) ? serialize($saveParams['data']) : '', 'ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0', 'checksum' => $saveParams['crc32']);
         MatchaAudit::auditSaveLog();
     }
 }
Example #4
0
 /**
  * function audit($logModelArray = array(), $methodCall = NULL, $idColumn = 'id', $logTable = 'log', $classCall = NULL)
  * Method to enable the audit log process.
  * This will write a log every time it INSERT, UPDATE, DELETE a record.
  */
 public static function audit($logModelArray = array(), $methodCall = NULL, $idColumn = 'id', $logTable = 'log', $classCall = NULL)
 {
     self::$__audit = true;
     self::$hookTable = $logTable;
     MatchaModel::$tableId = $idColumn;
     if ($classCall == NULL) {
         self::$hookClass = get_called_class();
     } else {
         self::$hookClass = $classCall;
     }
     self::$hookMethod = $methodCall;
     self::defineLogModel($logModelArray);
 }
Example #5
0
    session_start();
    session_cache_limiter('private');
    define('_UntuEXEC', 1);
}
include_once '../registry.php';
include_once '../sites/default/conf.php';
include_once ROOT . '/classes/MatchaHelper.php';
$db = new MatchaHelper();
//echo MatchaUtils::Carbon()->now();
//$firephp = FirePHP::getInstance(true);
//$var = array('i'=>10, 'j'=>20);
//$firephp->log($var, 'Iterators');
// Enable the audit feature in Matcha::connect
MatchaAudit::audit(array(array('name' => 'eid', 'type' => 'int'), array('name' => 'date', 'type' => 'date'), array('name' => 'user', 'type' => 'string'), array('name' => 'user_id', 'type' => 'int'), array('name' => 'event', 'type' => 'string'), array('name' => 'patient_id', 'type' => 'int'), array('name' => 'facility_id', 'type' => 'int')), NULL, 'id', 'encounter_history');
MatchaAudit::$eventLogData = array('date' => Time::getLocalTime('Y-m-d H:i:s'), 'eid' => 1, 'user' => 'Mr. Gino Rivera', 'facility_id' => 2, 'patient_id' => 0, 'event' => 'Immunisation View');
MatchaAudit::auditSaveLog();
//$data = (object)array(
//    'name' => 'Test',
//    'active' => true,
//    'phone' => '787-360-3150',
//    'fax' => '787-360-3150',
//    'street' => 'Meaow'
//);
//$Facilities->save($data);
//$array = array(
//    'model' => "App.model.patient.Patient",
//    'field' => array(
//        'name' => 'test',
//        'type' => 'string'
//    )
//);