streams/Code/Module/Dircensor.php

46 lines
802 B
PHP
Raw Normal View History

2019-05-06 01:44:33 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Module;
2019-05-06 01:44:33 +00:00
2022-02-16 04:08:28 +00:00
use Code\Web\Controller;
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
class Dircensor extends Controller
{
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
public function get()
{
if (!is_site_admin()) {
return;
}
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
$xchan = argv(1);
if (!$xchan) {
return;
}
2019-05-06 01:44:33 +00:00
2021-12-03 03:01:39 +00:00
$r = q(
"select * from xchan where xchan_hash = '%s'",
2021-12-02 23:02:31 +00:00
dbesc($xchan)
);
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
if (!$r) {
return;
}
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
$val = (($r[0]['xchan_censored']) ? 0 : 1);
2019-05-06 01:44:33 +00:00
2021-12-03 03:01:39 +00:00
q(
"update xchan set xchan_censored = $val where xchan_hash = '%s'",
2021-12-02 23:02:31 +00:00
dbesc($xchan)
);
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
if ($val) {
info(t('Entry censored') . EOL);
} else {
info(t('Entry uncensored') . EOL);
}
2019-05-06 01:44:33 +00:00
2021-12-02 23:02:31 +00:00
goaway(z_root() . '/directory');
}
2021-12-03 03:01:39 +00:00
}