<?php
require_once('../wu_init.php');
include('../wu-functions/wu_functions.php');
include('wu_checkadmin.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }

//Соханение в лог
if($_POST['tolog'] == 'true'){
$qr = mysqli_query($connect_db, "SELECT id,usr,ty,msg,dt,log FROM `".DB_PREFIX."_adm_act` INNER JOIN ".DB_PREFIX."_users ON ".DB_PREFIX."_adm_act.usr = ".DB_PREFIX."_users.uid ORDER BY id ASC");
if (mysqli_num_rows($qr) > 0) {
$history = '';
while($row = mysqli_fetch_assoc($qr)) {
$ty = $row['ty'];
if($ty == 0) { $st = 'Успех'; } if($ty == 1) { $st = 'Предупреждение'; } if($ty == 2) { $st = 'Ошибка'; }
$history .= wudatenorm($row['dt']).' | '.$row['log'].' | '.$st.' | '.$row['msg']."\r\n";
}
$filename = '../wu-logs/log_activity.txt';
$fh = fopen($filename, 'a+');
fwrite($fh, $history);
fclose($fh);
}
}

//Очистка активности
mysqli_query($connect_db, "DELETE FROM `".DB_PREFIX."_adm_act`");
exit('1');
?>