public function glmMembersAdminAjax()
{
+ $this->logUserActions();
+
if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
trigger_error(
glmAssociateMemoryUsage() . " - Start AJAX Controller",
$returnOutput = false, $forceAction = false)
{
- // TODO: setup audit logging for users
- // $errorLogTime = date( 'Y-m-d H:i:s' );
- // if ( !empty( $_POST ) ) {
- // error_log( $errorLogTime . " POST: " . serialize( $_POST ) . "\n", 3, '/var/www/develop/wp-content/error.log' );
- // }
- // if ( !empty( $_GET ) ) {
- // error_log( $errorLogTime . " GET: " . serialize( $_GET ). "\n", 3, '/var/www/develop/wp-content/error.log' );
- // }
+ $this->logUserActions();
if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) {
trigger_error(
}
+ public function logUserActions()
+ {
+ $logFile = WP_CONTENT_DIR . '/user.log';
+ $timeZone = get_option( 'timezone_string' );
+ $cTimezone = date_default_timezone_get();
+ date_default_timezone_set( $timeZone );
+
+ $errorLogTime = date( 'j-M-Y H:i:s e' );
+ $user_id = get_current_user_id();
+ if ( !empty( $_POST ) ) {
+ error_log( "[{$errorLogTime}] USER: " . $user_id . " POST: " . serialize( $_POST ) . "\n", 3, $logFile );
+ }
+ if ( !empty( $_GET ) ) {
+ error_log( "[{$errorLogTime}] USER: " . $user_id . " GET: " . serialize( $_GET ). "\n", 3, $logFile );
+ }
+ date_default_timezone_set( $cTimezone );
+ }
+
+
}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Data Import
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Logs" menu
+ * option.
+ *
+ */
+class GlmMembersAdmin_logs_index
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /**
+ * Constructor
+ *
+ * This contractor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ( $wpdb, $config )
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /**
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successful and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the controller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ($actionData = false)
+ {
+ // Set the view file
+ $view = 'index.html';
+ $fileData = false;
+ $logFile = WP_CONTENT_DIR . '/user.log';
+
+ if ( isset( $_REQUEST['option'] ) ) {
+ $option = filter_var( $_REQUEST['option'] );
+ }
+
+ switch( $option ) {
+
+ default:
+ // get the log file contents
+ $fileData = file_get_contents( $logFile );
+
+ break;
+
+ }
+
+ // Setup the template data array
+ $templateData = array(
+ 'fileData' => $fileData,
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => true,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/logs/' . $view,
+ 'data' => $templateData,
+ );
+
+ }
+
+
+}