Refactor "URL" to "domain" for blocklist
- Add slash trimming to domain - Reformatted mod/friendica
This commit is contained in:
parent
0b8f80c747
commit
7d9d22914f
3 changed files with 76 additions and 71 deletions
|
@ -272,13 +272,14 @@ function admin_content(App $a) {
|
||||||
*/
|
*/
|
||||||
function admin_page_blocklist(App $a) {
|
function admin_page_blocklist(App $a) {
|
||||||
$blocklist = Config::get('system', 'blocklist');
|
$blocklist = Config::get('system', 'blocklist');
|
||||||
|
var_dump($blocklist);
|
||||||
$blocklistform = array();
|
$blocklistform = array();
|
||||||
if (is_array($blocklist)) {
|
if (is_array($blocklist)) {
|
||||||
foreach($blocklist as $id => $b) {
|
foreach($blocklist as $id => $b) {
|
||||||
$blocklistform[] = array(
|
$blocklistform[] = array(
|
||||||
'url' => array("url[$id]", t('Blocked URL'), $b['URL'], '', t('The blocked URL'), 'required', '', ''),
|
'domain' => array("domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''),
|
||||||
'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this URL.').'('.$b['URL'].')', 'required', '', ''),
|
'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.').'('.$b['domain'].')', 'required', '', ''),
|
||||||
'delete' => array("delete[$id]", t("Delete UFL").' ('.$b['URL'].')', False , "Check to delete this entry from the blocklist")
|
'delete' => array("delete[$id]", t("Delete domain").' ('.$b['domain'].')', False , "Check to delete this entry from the blocklist")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,15 +287,15 @@ function admin_page_blocklist(App $a) {
|
||||||
return replace_macros($t, array(
|
return replace_macros($t, array(
|
||||||
'$title' => t('Administration'),
|
'$title' => t('Administration'),
|
||||||
'$page' => t('Server Blocklist'),
|
'$page' => t('Server Blocklist'),
|
||||||
'$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered URLs you should also give a reason, why you have blocked the remote server.'),
|
'$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'),
|
||||||
'$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'),
|
'$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'),
|
||||||
'$addtitle' => t('Add new entry to block list'),
|
'$addtitle' => t('Add new entry to block list'),
|
||||||
'$newurl' => array('newentry_url', t('Server URL'), '', t('The URL of the new server to add to the block list. Do not include the protocol to the URL.'), 'required', '', ''),
|
'$newdomain' => array('newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''),
|
||||||
'$newreason' => array('newentry_reason', t('Block reason'), '', t('The reason why you blocked this URL.'), 'required', '', ''),
|
'$newreason' => array('newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''),
|
||||||
'$submit' => t('Add Entry'),
|
'$submit' => t('Add Entry'),
|
||||||
'$savechanges' => t('Save changes to the blocklist'),
|
'$savechanges' => t('Save changes to the blocklist'),
|
||||||
'$currenttitle' => t('Current Entries in the Blocklist'),
|
'$currenttitle' => t('Current Entries in the Blocklist'),
|
||||||
'$thurl' => t('Blocked URL'),
|
'$thurl' => t('Blocked domain'),
|
||||||
'$threason' => t('Reason for the block'),
|
'$threason' => t('Reason for the block'),
|
||||||
'$delentry' => t('Delete entry from blocklist'),
|
'$delentry' => t('Delete entry from blocklist'),
|
||||||
'$entries' => $blocklistform,
|
'$entries' => $blocklistform,
|
||||||
|
@ -320,7 +321,7 @@ function admin_page_blocklist_post(App $a) {
|
||||||
// Add new item to blocklist
|
// Add new item to blocklist
|
||||||
$blocklist = get_config('system', 'blocklist');
|
$blocklist = get_config('system', 'blocklist');
|
||||||
$blocklist[] = array(
|
$blocklist[] = array(
|
||||||
'URL' => notags(trim($_POST['newentry_url'])),
|
'domain' => notags(trim($_POST['newentry_domain'])),
|
||||||
'reason' => notags(trim($_POST['newentry_reason']))
|
'reason' => notags(trim($_POST['newentry_reason']))
|
||||||
);
|
);
|
||||||
Config::set('system', 'blocklist', $blocklist);
|
Config::set('system', 'blocklist', $blocklist);
|
||||||
|
@ -328,12 +329,13 @@ function admin_page_blocklist_post(App $a) {
|
||||||
} else {
|
} else {
|
||||||
// Edit the entries from blocklist
|
// Edit the entries from blocklist
|
||||||
$blocklist = array();
|
$blocklist = array();
|
||||||
foreach ($_POST['url'] as $id => $URL) {
|
foreach ($_POST['domain'] as $id => $domain) {
|
||||||
$URL = notags(trim($URL));
|
// Trimming whitespaces as well as any lingering slashes
|
||||||
|
$domain = notags(trim($domain, "\x00..\x1F/"));
|
||||||
$reason = notags(trim($_POST['reason'][$id]));
|
$reason = notags(trim($_POST['reason'][$id]));
|
||||||
if (!x($_POST['delete'][$id])) {
|
if (!x($_POST['delete'][$id])) {
|
||||||
$blocklist[] = array(
|
$blocklist[] = array(
|
||||||
'URL' => $URL,
|
'domain' => $domain,
|
||||||
'reason' => $reason
|
'reason' => $reason
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,12 @@ function friendica_init(App $a) {
|
||||||
|
|
||||||
$sql_extra = '';
|
$sql_extra = '';
|
||||||
if (x($a->config,'admin_nickname')) {
|
if (x($a->config,'admin_nickname')) {
|
||||||
$sql_extra = sprintf(" AND nickname = '%s' ",dbesc($a->config['admin_nickname']));
|
$sql_extra = sprintf(" AND `nickname` = '%s' ", dbesc($a->config['admin_nickname']));
|
||||||
}
|
}
|
||||||
if (isset($a->config['admin_email']) && $a->config['admin_email']!='') {
|
if (isset($a->config['admin_email']) && $a->config['admin_email']!='') {
|
||||||
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
|
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
|
||||||
|
|
||||||
//$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($a->config['admin_email']));
|
$r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0]));
|
||||||
$r = q("SELECT username, nickname FROM user WHERE email='%s' $sql_extra", dbesc($adminlist[0]));
|
|
||||||
$admin = array(
|
$admin = array(
|
||||||
'name' => $r[0]['username'],
|
'name' => $r[0]['username'],
|
||||||
'profile'=> App::get_baseurl() . '/profile/' . $r[0]['nickname'],
|
'profile'=> App::get_baseurl() . '/profile/' . $r[0]['nickname'],
|
||||||
|
@ -25,18 +24,22 @@ function friendica_init(App $a) {
|
||||||
|
|
||||||
$visible_plugins = array();
|
$visible_plugins = array();
|
||||||
if (is_array($a->plugins) && count($a->plugins)) {
|
if (is_array($a->plugins) && count($a->plugins)) {
|
||||||
$r = q("select * from addon where hidden = 0");
|
$r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r)) {
|
||||||
foreach($r as $rr)
|
foreach($r as $rr) {
|
||||||
$visible_plugins[] = $rr['name'];
|
$visible_plugins[] = $rr['name'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Config::load('feature_lock');
|
Config::load('feature_lock');
|
||||||
$locked_features = array();
|
$locked_features = array();
|
||||||
if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
|
if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
|
||||||
foreach ($a->config['feature_lock'] as $k => $v) {
|
foreach ($a->config['feature_lock'] as $k => $v) {
|
||||||
if($k === 'config_loaded')
|
if ($k === 'config_loaded') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$locked_features[$k] = intval($v);
|
$locked_features[$k] = intval($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,63 +62,63 @@ function friendica_init(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function friendica_content(App $a) {
|
function friendica_content(App $a) {
|
||||||
|
$o = '<h1>Friendica</h1>' . PHP_EOL;
|
||||||
|
$o .= '<p>';
|
||||||
|
$o .= t('This is Friendica, version') . ' <strong>' . FRIENDICA_VERSION . '</strong> ';
|
||||||
|
$o .= t('running at web location') . ' ' . z_root();
|
||||||
|
$o .= '</p>' . PHP_EOL;
|
||||||
|
|
||||||
$o = '';
|
$o .= '<p>';
|
||||||
$o .= '<h3>Friendica</h3>';
|
$o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . PHP_EOL;
|
||||||
|
$o .= '</p>' . PHP_EOL;
|
||||||
|
|
||||||
|
$o .= '<p>';
|
||||||
$o .= '<p></p><p>';
|
$o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.t('the bugtracker at github').'</a>';
|
||||||
|
$o .= '</p>' . PHP_EOL;
|
||||||
$o .= t('This is Friendica, version') . ' ' . FRIENDICA_VERSION . ' ';
|
$o .= '<p>';
|
||||||
$o .= t('running at web location') . ' ' . z_root() . '</p><p>';
|
$o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com');
|
||||||
|
$o .= '</p>' . PHP_EOL;
|
||||||
$o .= t('Please visit <a href="http://friendica.com">Friendica.com</a> to learn more about the Friendica project.') . '</p><p>';
|
|
||||||
|
|
||||||
$o .= t('Bug reports and issues: please visit') . ' ' . '<a href="https://github.com/friendica/friendica/issues?state=open">'.t('the bugtracker at github').'</a></p><p>';
|
|
||||||
$o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com') . '</p>';
|
|
||||||
|
|
||||||
$o .= '<p></p>';
|
|
||||||
|
|
||||||
$visible_plugins = array();
|
$visible_plugins = array();
|
||||||
if (is_array($a->plugins) && count($a->plugins)) {
|
if (is_array($a->plugins) && count($a->plugins)) {
|
||||||
$r = q("select * from addon where hidden = 0");
|
$r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
|
||||||
if (dbm::is_result($r))
|
if (dbm::is_result($r)) {
|
||||||
foreach($r as $rr)
|
foreach($r as $rr) {
|
||||||
$visible_plugins[] = $rr['name'];
|
$visible_plugins[] = $rr['name'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count($visible_plugins)) {
|
if (count($visible_plugins)) {
|
||||||
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>';
|
$o .= '<p>' . t('Installed plugins/addons/apps:') . '</p>' . PHP_EOL;
|
||||||
$sorted = $visible_plugins;
|
$sorted = $visible_plugins;
|
||||||
$s = '';
|
$s = '';
|
||||||
sort($sorted);
|
sort($sorted);
|
||||||
foreach ($sorted as $p) {
|
foreach ($sorted as $p) {
|
||||||
if (strlen($p)) {
|
if (strlen($p)) {
|
||||||
if(strlen($s)) $s .= ', ';
|
if (strlen($s)) {
|
||||||
|
$s .= ', ';
|
||||||
|
}
|
||||||
$s .= $p;
|
$s .= $p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$o .= '<div style="margin-left: 25px; margin-right: 25px;">' . $s . '</div>';
|
$o .= '<div style="margin-left: 25px; margin-right: 25px;">' . $s . '</div>' . PHP_EOL;
|
||||||
|
} else {
|
||||||
|
$o .= '<p>' . t('No installed plugins/addons/apps') . '</p>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$o .= '<p>' . t('No installed plugins/addons/apps') . '</p>';
|
|
||||||
|
|
||||||
$blocklist = Config::get('system', 'blocklist');
|
$blocklist = Config::get('system', 'blocklist');
|
||||||
if (count($blocklist)) {
|
if (count($blocklist)) {
|
||||||
$o .= '<div id="about_blocklist"><p>'. t('On this server the following remote servers are blocked.') .'</p>';
|
$o .= '<div id="about_blocklist"><p>' . t('On this server the following remote servers are blocked.') . '</p>' . PHP_EOL;
|
||||||
$o .= '<table><thead><tr><th>'. t('Blocked URL') .'</th><th>'. t('Reason for the block') .'</th></thead><tbody>';
|
$o .= '<table class="table"><thead><tr><th>' . t('Blocked domain') . '</th><th>' . t('Reason for the block') . '</th></thead><tbody>' . PHP_EOL;
|
||||||
foreach ($blocklist as $b) {
|
foreach ($blocklist as $b) {
|
||||||
$o .= '<tr><td>'. $b['URL'] .'</td><td>'. $b['reason'] .'</td></tr>';
|
$o .= '<tr><td>' . $b['domain'] .'</td><td>' . $b['reason'] . '</td></tr>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
$o .= '</tbody></table></div>';
|
$o .= '</tbody></table></div>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
call_hooks('about_hook', $o);
|
call_hooks('about_hook', $o);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<h2>{{$addtitle}}</h2>
|
<h2>{{$addtitle}}</h2>
|
||||||
<form action="{{$baseurl}}/admin/blocklist" method="post">
|
<form action="{{$baseurl}}/admin/blocklist" method="post">
|
||||||
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
{{include file="field_input.tpl" field=$newurl}}
|
{{include file="field_input.tpl" field=$newdomain}}
|
||||||
{{include file="field_input.tpl" field=$newreason}}
|
{{include file="field_input.tpl" field=$newreason}}
|
||||||
<div class="submit"><input type="submit" name="page_blocklist_save" value="{{$submit}}" /></div>
|
<div class="submit"><input type="submit" name="page_blocklist_save" value="{{$submit}}" /></div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<form action="{{$baseurl}}/admin/blocklist" method="post">
|
<form action="{{$baseurl}}/admin/blocklist" method="post">
|
||||||
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
{{foreach $entries as $e}}
|
{{foreach $entries as $e}}
|
||||||
{{include file="field_input.tpl" field=$e.url}}
|
{{include file="field_input.tpl" field=$e.domain}}
|
||||||
{{include file="field_input.tpl" field=$e.reason}}
|
{{include file="field_input.tpl" field=$e.reason}}
|
||||||
{{include file="field_checkbox.tpl" field=$e.delete}}
|
{{include file="field_checkbox.tpl" field=$e.delete}}
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
Loading…
Reference in a new issue