コード例 #1
0
ファイル: pdoconnect.class.php プロジェクト: ajiwo/xibo-cms
 public static function init()
 {
     if (!self::$conn) {
         self::$conn = PDOConnect::newConnection();
     }
     return self::$conn;
 }
コード例 #2
0
ファイル: Log.php プロジェクト: fignew/xibo-cms
 /**
  * Audit Log
  * @param string $entity
  * @param int $entityId
  * @param string $message
  * @param string|object|array $object
  */
 public static function audit($entity, $entityId, $message, $object)
 {
     \Debug::Audit(sprintf('Audit Trail message recorded for %s with id %d. Message: %s', $entity, $entityId, $message));
     if (self::$_auditLogStatement == null) {
         $dbh = \PDOConnect::newConnection();
         self::$_auditLogStatement = $dbh->prepare('
             INSERT INTO `auditlog` (logDate, userId, entity, message, entityId, objectAfter)
               VALUES (:logDate, :userId, :entity, :message, :entityId, :objectAfter)
         ');
     }
     // If we aren't a string then encode
     if (!is_string($object)) {
         $object = json_encode($object);
     }
     self::$_auditLogStatement->execute(array('logDate' => time(), 'userId' => \Kit::GetParam('userid', _SESSION, _INT, 0), 'entity' => $entity, 'message' => $message, 'entityId' => $entityId, 'objectAfter' => $object));
 }
コード例 #3
0
ファイル: debug.class.php プロジェクト: fignew/xibo-cms
 /**
  * Log
  * @param string $type
  * @param string $message
  * @param string $page[Optional]
  * @param string $function[Optional]
  * @param string $logDate[Optional]
  * @param int $displayId[Optional]
  * @param int $scheduleId[Optional]
  * @param int $layoutId[Optional]
  * @param string $mediaId[Optional]
  */
 public static function log($type, $message, $page = null, $function = null, $logDate = null, $displayId = 0, $scheduleId = 0, $layoutId = 0, $mediaId = null)
 {
     if (self::$pdo == NULL) {
         self::$pdo = PDOConnect::newConnection();
     }
     $currentDate = date("Y-m-d H:i:s");
     $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied');
     $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied');
     $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied');
     $requestUserAgent = substr($requestUserAgent, 0, 253);
     $userId = Kit::GetParam('userid', _SESSION, _INT, 0);
     $message = Kit::ValidateParam($message, _HTMLSTRING);
     // Prepare the variables
     if ($logDate == null) {
         $logDate = $currentDate;
     }
     if ($page == null) {
         $page = Kit::GetParam('p', _GET, _WORD);
     }
     // Insert into the DB
     try {
         $dbh = self::$pdo;
         $SQL = 'INSERT INTO log (logdate, type, page, function, message, requesturi, remoteaddr, useragent, userid, displayid, scheduleid, layoutid, mediaid)
                   VALUES (:logdate, :type, :page, :function, :message, :requesturi, :remoteaddr, :useragent, :userid, :displayid, :scheduleid, :layoutid, :mediaid) ';
         $sth = $dbh->prepare($SQL);
         $params = array('logdate' => $logDate, 'type' => $type, 'page' => $page, 'function' => $function, 'message' => $message, 'requesturi' => $requestUri, 'remoteaddr' => $requestIp, 'useragent' => $requestUserAgent, 'userid' => $userId, 'displayid' => Kit::ValidateParam($displayId, _INT), 'scheduleid' => Kit::ValidateParam($scheduleId, _INT), 'layoutid' => Kit::ValidateParam($layoutId, _INT), 'mediaid' => Kit::ValidateParam($mediaId, _INT));
         $sth->execute($params);
     } catch (PDOException $e) {
         // In this case just silently log the error
         error_log($message . '\\n\\n', 3, './err_log.xml');
         error_log($e->getMessage() . '\\n\\n', 3, './err_log.xml');
     }
 }