*/
use Friendica\App;
+use Friendica\BaseModule;
use Friendica\Content\Text\Markdown;
-use Friendica\Core\Addon;
use Friendica\Core\Cache;
+use Friendica\Core\Hook;
use Friendica\Core\L10n;
-use Friendica\Core\System;
+use Friendica\Core\Logger;
+use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\Model\Item;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\ExpressionLanguage;
-require_once 'boot.php';
-require_once 'include/conversation.php';
-require_once 'include/dba.php';
-require_once 'include/security.php';
-
require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
-function advancedcontentfilter_install()
+function advancedcontentfilter_install(App $a)
{
- Addon::registerHook('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
- Addon::registerHook('prepare_body_content_filter', __FILE__, 'advancedcontentfilter_prepare_body_content_filter');
- Addon::registerHook('addon_settings' , __FILE__, 'advancedcontentfilter_addon_settings');
+ Hook::register('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
+ Hook::register('prepare_body_content_filter', __FILE__, 'advancedcontentfilter_prepare_body_content_filter');
+ Hook::register('addon_settings' , __FILE__, 'advancedcontentfilter_addon_settings');
- DBStructure::update(false, true);
+ DBStructure::update($a->getBasePath(), false, true);
- logger("installed advancedcontentfilter");
+ Logger::log("installed advancedcontentfilter");
}
function advancedcontentfilter_uninstall()
{
- Addon::unregisterHook('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
- Addon::unregisterHook('prepare_body_content_filter', __FILE__, 'advancedcontentfilter_prepare_body_content_filter');
- Addon::unregisterHook('addon_settings' , __FILE__, 'advancedcontentfilter_addon_settings');
+ Hook::unregister('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
+ Hook::unregister('prepare_body_content_filter', __FILE__, 'advancedcontentfilter_prepare_body_content_filter');
+ Hook::unregister('addon_settings' , __FILE__, 'advancedcontentfilter_addon_settings');
}
/*
"expression" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Expression text"],
"serialized" => ["type" => "mediumtext" , "not null" => "1", "comment" => "Serialized parsed expression"],
"active" => ["type" => "boolean" , "not null" => "1", "default" => "1", "comment" => "Whether the rule is active or not"],
- "created" => ["type" => "datetime" , "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
+ "created" => ["type" => "datetime" , "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Creation date"],
],
"indexes" => [
"PRIMARY" => ["id"],
$rule['serialized']
);
- $found = (bool) $expressionLanguage->evaluate($serializedParsedExpression, $vars);
+ // The error suppression operator is used because of potentially broken user-supplied regular expressions
+ $found = (bool) @$expressionLanguage->evaluate($serializedParsedExpression, $vars);
} catch (Exception $e) {
$found = false;
}
return $html;
} else {
- $t = get_markup_template('settings.tpl', 'addon/advancedcontentfilter/');
- return replace_macros($t, [
+ $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/advancedcontentfilter/');
+ return Renderer::replaceMacros($t, [
'$messages' => [
'backtosettings' => L10n::t('Back to Addon Settings'),
'title' => L10n::t('Advanced Content Filter'),
],
'$current_theme' => $a->getCurrentTheme(),
'$rules' => advancedcontentfilter_get_rules(),
- '$form_security_token' => get_form_security_token()
+ '$form_security_token' => BaseModule::getFormSecurityToken()
]);
}
}
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
}
- if (!check_form_security_token()) {
+ if (!BaseModule::checkFormSecurityToken()) {
throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.'));
}
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
}
- if (!check_form_security_token()) {
+ if (!BaseModule::checkFormSecurityToken()) {
throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.'));
}
throw new HTTPException\UnauthorizedException(L10n::t('You must be logged in to use this method'));
}
- if (!check_form_security_token()) {
+ if (!BaseModule::checkFormSecurityToken()) {
throw new HTTPException\BadRequestException(L10n::t('Invalid form security token, please refresh the page.'));
}