addBreadCrumb(['link' => ADMIN.'administrators.php'.fusion_get_aidlink(), 'title' => $locale['UL_001']]); if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; } // Set default values $dbOrder = "ORDER BY userlog_timestamp DESC"; $dbWhere = ""; $dbWhereCount = ""; $getString = $aidlink; $orderby = "userlog_timestamp"; $expr = "DESC"; $user = ""; $userField = ""; $orderbyArray = [ 'userlog_timestamp' => $locale['UL_002'], 'user_name' => $locale['UL_003'], 'userlog_field' => $locale['UL_004'] ]; $exprArray = ["DESC" => $locale['UL_019'], "ASC" => $locale['UL_018']]; if (isset($_POST) && !empty($_POST)) { if (isset($_POST['orderby']) && in_array($_POST['orderby'], $orderbyArray)) { $orderby = form_sanitizer($_POST['orderby'], 'DESC', 'orderby'); $dbOrder = "ORDER BY ".$orderby; if (isset($_POST['expr']) && in_array($_POST['expr'], $exprArray)) { $expr = form_sanitizer($_POST['expr'], '', 'expr'); $dbOrder .= " ".$expr; } } if (isset($_POST['user'])) { $user = form_sanitizer($_POST['user'], '', 'user'); if (isnum($user)) { $dbWhere = "userlog_user_id='".$user."'"; } else if ($_POST['user'] != "") { $user = trim(stripinput($user)); $dbWhere = "user_name LIKE '".$user."%'"; } } if (isset($_POST['userField']) && $_POST['userField'] != "---" && $_POST['userField'] != "") { $userField = trim(stripinput($_POST['userField'])); $dbWhere .= ($dbWhere != "" ? " AND userlog_field='".$userField."'" : "userlog_field='".$userField."'"); } $dbWhereCount = $dbWhere; $dbWhere = ($dbWhere != "" ? "WHERE ".$dbWhere : ""); // build get string $getString .= "&orderby=".$orderby."&expr=".$expr."&user=".$user."&userField=".$userField; } // End $_GET Vars if (isset($_POST['log_id'])) { if (isset($_POST['table_action']) && isset($_POST['log_id'])) { $input = (isset($_POST['log_id'])) ? explode(",", form_sanitizer($_POST['log_id'], "", "log_id")) : ""; if (!empty($input)) { foreach ($input as $log_id) { dbquery("DELETE FROM ".DB_USER_LOG." WHERE userlog_id=:logid", [':logid' => $log_id]); } } } addNotice('info', $locale['UL_006']); redirect(clean_request('', ['delete'], FALSE)); } if (isset($_POST['daydelete']) && isnum($_POST['daydelete'])) { $delete = form_sanitizer($_POST['daydelete'], 0, 'daydelete'); $bind = [ ':time' => time() - $delete * 24 * 60 * 60, ]; $result = dbquery("DELETE FROM ".DB_USER_LOG." WHERE userlog_timestamp<:time", $bind); addNotice('info', sprintf($locale['UL_005'], $delete)); redirect(clean_request('', ['delete'], FALSE)); } if (isset($_GET['delete']) && isnum($_GET['delete'])) { $delete = form_sanitizer($_GET['delete'], 0, 'delete'); $result = dbquery("DELETE FROM ".DB_USER_LOG." WHERE userlog_id=:delete", [':delete' => $delete]); addNotice('info', $locale['UL_006']); redirect(clean_request('', ['delete'], FALSE)); } function userFieldOptions() { $locale = fusion_get_locale(); $options['user_name'] = $locale['UL_003']; $options['user_email'] = $locale['UL_007']; $result = dbquery("SELECT field_name, field_title FROM ".DB_USER_FIELDS." WHERE field_log='1'"); if (dbrows($result)) { while ($data = dbarray($result)) { $options[$data['field_name']] = $data['field_title']; } } return $options; } opentable($locale['UL_001']); openside(); echo openform('userlog_search', 'post', FUSION_REQUEST); echo form_hidden('aid', '', iAUTH); echo form_select('orderby', $locale['UL_008'], $orderby, [ 'options' => $orderbyArray, 'placholder' => $locale['choose'], 'inline' => TRUE ]); echo form_select('expr', ' ', $orderby, [ 'options' => $exprArray, 'placholder' => $locale['choose'], 'inline' => TRUE ]); echo form_user_select("user", $locale['UL_009'], '', [ 'max_select' => 1, 'inline' => TRUE, 'inner_width' => '100%', 'width' => '100%', 'allow_self' => TRUE, ]); echo form_select('userField', $locale['UL_010'], $userField, [ 'options' => userFieldOptions(), 'placeholder' => $locale['choose'], 'allowclear' => 1, 'inline' => TRUE ]); echo form_button('submit', $locale['UL_011'], $locale['UL_011'], ['class' => 'btn-primary']); echo closeform(); closeside(); // at least validate token. if (!defined('FUSION_NULL')) { $result = dbquery("SELECT SQL_CALC_FOUND_ROWS userlog_id, userlog_user_id, userlog_field, userlog_value_old, userlog_value_new, userlog_timestamp, user_name, user_status FROM ".DB_USER_LOG." LEFT JOIN ".DB_USERS." ON userlog_user_id=user_id ".$dbWhere." ".$dbOrder." LIMIT ".$_GET['rowstart'].",20"); $rows = dbresult(dbquery("SELECT FOUND_ROWS()"), 0); if (dbrows($result)) { echo "
\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo openform('userlog_table', 'post', FUSION_REQUEST); echo form_hidden('table_action', '', ''); while ($data = dbarray($result)) { echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "
".$locale['UL_002']."".$locale['UL_003']."".$locale['UL_004']."".$locale['UL_012']."".$locale['UL_013']."".$locale['UL_014']."
".form_checkbox("log_id[]", "", "", ["value" => $data['userlog_id'], "class" => "m-0"])."".showdate("shortdate", $data['userlog_timestamp'])."".profile_link($data['userlog_user_id'], $data['user_name'], $data['user_status'])."".$data['userlog_field']."".trimlink($data['userlog_value_old'], 100)."".trimlink($data['userlog_value_new'], 100)."".$locale['delete']."
\n
"; echo "
\n"; echo "
".form_checkbox('check_all', $locale['UL_020'], '', ['class' => 'm-b-0', 'reverse_label' => TRUE])."
"; echo "
".$locale['delete']."
"; echo "
\n"; echo closeform(); add_to_jquery(" $('#check_all').bind('click', function() { if ($(this).is(':checked')) { $('input[name^=log_id]:checkbox').prop('checked', true); $('#log-table tbody tr').addClass('active'); } else { $('input[name^=log_id]:checkbox').prop('checked', false); $('#log-table tbody tr').removeClass('active'); } }); "); } else { echo "
".$locale['UL_015']."
\n"; } if ($rows > 20) { echo "
\n".makepagenav($_GET['rowstart'], 20, $rows, 3, FUSION_SELF.$getString."&")."\n
\n"; } } openside('', 'm-t-20'); echo openform('userlog_delete', 'post', FUSION_REQUEST); echo form_text('daydelete', $locale['UL_016'], '', [ 'max_length' => 3, 'type' => 'number', 'placeholder' => $locale['UL_017'], 'inline' => TRUE ]); echo form_button('submit', $locale['UL_011'], $locale['UL_011'], ['class' => 'btn-primary']); echo closeform(); closeside(); closetable(); require_once THEMES.'templates/footer.php';