Browse Source

?/users (user list)

pull/40/head
Michael Save 12 years ago
parent
commit
761cb4feab
  1. 45
      inc/lib/Twig/Extensions/Extension/Tinyboard.php
  2. 12
      inc/mod/pages.php
  3. 4
      mod.php
  4. 12
      templates/mod/log.html

45
inc/lib/Twig/Extensions/Extension/Tinyboard.php

@ -10,19 +10,21 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
public function getFilters() public function getFilters()
{ {
return Array( return Array(
'filesize' => new Twig_Filter_Function('format_bytes', Array('needs_environment' => false)), 'filesize' => new Twig_Filter_Function('format_bytes'),
'truncate' => new Twig_Filter_Function('twig_truncate_filter', array('needs_environment' => false)), 'truncate' => new Twig_Filter_Function('twig_truncate_filter'),
'truncate_body' => new Twig_Filter_Function('truncate', array('needs_environment' => false)), 'truncate_body' => new Twig_Filter_Function('truncate'),
'extension' => new Twig_Filter_Function('twig_extension_filter', array('needs_environment' => false)), 'extension' => new Twig_Filter_Function('twig_extension_filter'),
'sprintf' => new Twig_Filter_Function('sprintf', array('needs_environment' => false)), 'sprintf' => new Twig_Filter_Function('sprintf'),
'capcode' => new Twig_Filter_Function('capcode', array('needs_environment' => false)), 'capcode' => new Twig_Filter_Function('capcode'),
'hasPermission' => new Twig_Filter_Function('twig_hasPermission_filter', array('needs_environment' => false)), 'hasPermission' => new Twig_Filter_Function('twig_hasPermission_filter'),
'date' => new Twig_Filter_Function('twig_date_filter', array('needs_environment' => false)), 'date' => new Twig_Filter_Function('twig_date_filter'),
'poster_id' => new Twig_Filter_Function('poster_id', array('needs_environment' => false)), 'poster_id' => new Twig_Filter_Function('poster_id'),
'remove_whitespace' => new Twig_Filter_Function('twig_remove_whitespace_filter', array('needs_environment' => false)), 'remove_whitespace' => new Twig_Filter_Function('twig_remove_whitespace_filter'),
'count' => new Twig_Filter_Function('count', array('needs_environment' => false)), 'count' => new Twig_Filter_Function('count'),
'ago' => new Twig_Filter_Function('ago', array('needs_environment' => false)), 'ago' => new Twig_Filter_Function('ago'),
'until' => new Twig_Filter_Function('until', array('needs_environment' => false)) 'until' => new Twig_Filter_Function('until'),
'split' => new Twig_Filter_Function('twig_split_filter'),
'push' => new Twig_Filter_Function('twig_push_filter'),
); );
} }
@ -34,10 +36,10 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
public function getFunctions() public function getFunctions()
{ {
return Array( return Array(
'time' => new Twig_Filter_Function('time', array('needs_environment' => false)), 'time' => new Twig_Filter_Function('time'),
'timezone' => new Twig_Filter_Function('twig_timezone_function', array('needs_environment' => false)), 'timezone' => new Twig_Filter_Function('twig_timezone_function'),
'hiddenInputs' => new Twig_Filter_Function('hiddenInputs', array('needs_environment' => false)), 'hiddenInputs' => new Twig_Filter_Function('hiddenInputs'),
'hiddenInputsHash' => new Twig_Filter_Function('hiddenInputsHash', array('needs_environment' => false)) 'hiddenInputsHash' => new Twig_Filter_Function('hiddenInputsHash'),
); );
} }
@ -57,6 +59,15 @@ function twig_timezone_function() {
return sprintf("%s%02d", ($hr = (int)floor(($tz = date('Z')) / 3600)) > 0 ? '+' : '-', abs($hr)) . ':' . sprintf("%02d", (($tz / 3600) - $hr) * 60); return sprintf("%s%02d", ($hr = (int)floor(($tz = date('Z')) / 3600)) > 0 ? '+' : '-', abs($hr)) . ':' . sprintf("%02d", (($tz / 3600) - $hr) * 60);
} }
function twig_split_filter($str, $delim) {
return explode($delim, $str);
}
function twig_push_filter($array, $value) {
array_push($array, $value);
return $array;
}
function twig_remove_whitespace_filter($data) { function twig_remove_whitespace_filter($data) {
return preg_replace('/[\t\r\n]/', '', $data); return preg_replace('/[\t\r\n]/', '', $data);
} }

12
inc/mod/pages.php

@ -250,3 +250,15 @@ function mod_delete($board, $post) {
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
} }
function mod_users() {
global $config;
if(!hasPermission($config['mod']['manageusers']))
error($config['error']['noaccess']);
$args = array();
$query = query("SELECT *, (SELECT `time` FROM `modlogs` WHERE `mod` = `id` ORDER BY `time` DESC LIMIT 1) AS `last`, (SELECT `text` FROM `modlogs` WHERE `mod` = `id` ORDER BY `time` DESC LIMIT 1) AS `action` FROM `mods` ORDER BY `type` DESC,`id`") or error(db_error());
$args['users'] = $query->fetchAll(PDO::FETCH_ASSOC);
mod_page("Manage users", 'mod/users.html', $args);
}

4
mod.php

@ -23,10 +23,12 @@ $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
$pages = array( $pages = array(
'!^$!' => ':?/', // redirect to dashboard '!^$!' => ':?/', // redirect to dashboard
'!^/$!' => 'dashboard', // dashboard '!^/$!' => 'dashboard', // dashboard
'!^/confirm/(.+)$!' => 'confirm', // confirm action (if javascript didn't work)
'!^/log$!' => 'log', // modlog '!^/log$!' => 'log', // modlog
'!^/log/(\d+)$!' => 'log', // modlog '!^/log/(\d+)$!' => 'log', // modlog
'!^/users$!' => 'users', // manage users
'!^/confirm/(.+)$!' => 'confirm', // confirm action (if javascript didn't work)
'!^/ban$!' => 'ban', // new ban '!^/ban$!' => 'ban', // new ban
'!^/IP/([\w.:]+)$!' => 'ip', // view ip address '!^/IP/([\w.:]+)$!' => 'ip', // view ip address

12
templates/mod/log.html

@ -31,9 +31,11 @@
{% endfor %} {% endfor %}
</table> </table>
<p class="unimportant" style="text-align:center;word-wrap:break-word"> {% if count > logs|count %}
{% for i in range(0, count / config.mod.modlog_page) %} <p class="unimportant" style="text-align:center;word-wrap:break-word">
<a href="?/log/{{ i + 1 }}">[{{ i + 1 }}]</a> {% for i in range(0, count / config.mod.modlog_page) %}
{% endfor %} <a href="?/log/{{ i + 1 }}">[{{ i + 1 }}]</a>
</p> {% endfor %}
</p>
{% endif %}

Loading…
Cancel
Save