Ejemplo n.º 1
0
 static function onAPIEditBeforeSave(&$EditPage, $text, &$resultArr)
 {
     global $wgUser, $wgMollomwMWAPIAcceptPolicy;
     if ($wgUser->isAllowed('mollommw-no-check')) {
         return true;
     }
     // check the actual content
     try {
         $response = MollomClient::checkContent(null, $EditPage->mTitle, $text);
         wfDebugLog('MollomMW', 'Mollom Response: ' . var_export($response, true));
         switch ($response['spam']) {
             case MOLLOM_SPAM:
                 $resultArr[] = wfMsg('mollom-spam');
                 return false;
             case MOLLOM_HAM:
             default:
                 /* 'unsure' or any other value */
                 return true;
         }
     } catch (Exception $e) {
         wfDebugLog('MollomMW', 'Exception while checking content: ' . $e->getMessage());
         return $wgMollomMWAPIAcceptPolicy;
     }
 }
Ejemplo n.º 2
0
global $wgMollomPublicKey;
global $wgMollomPrivateKey;
global $wgMollomServerList;
global $wgMollomReverseProxyAddresses;
global $wgMollomMWAcceptPolicy;
global $wgMollomMWAPIAcceptPolicy;
/* Setup the Mollom configuration */
Mollom::setUserAgent(MOLLOMMW_NAME . '/' . MOLLOMMW_VERSION);
if (isset($wgMollomDebug) && $wgMollomDebug) {
    $wgDebugLogGroups['MollomMW'] = dirname(__FILE__) . '/debug.log';
}
if (isset($wgMollomReverseProxyAddresses) && is_array($wgMollomReverseProxyAddresses)) {
    MollomClient::setAllowedReverseProxyAddresses($wgMollomReverseProxyAddresses);
}
if (isset($wgMollomRunsOnClusterSetup)) {
    MollomClient::setUsesServerSetup($wgMollomRunsOnClusterSetup);
}
if (!isset($wgMollomMWAcceptPolicy) && !is_bool($wgMollomMWAcceptPolicy)) {
    $wgMollomMWAPIAcceptPolicy = true;
}
if (!isset($wgMollomMWAPIAcceptPolicy) && !is_bool($wgMollomMWAPIAcceptPolicy)) {
    $wgMollomMWAPIAcceptPolicy = false;
}
Mollom::setPublicKey($wgMollomPublicKey);
Mollom::setPrivateKey($wgMollomPrivateKey);
/* Connect the hooks for the mollom filters */
global $wgHooks;
$wgHooks['EditFilter'][] = 'MollomSpamFilter::onEditFilter';
$wgHooks['APIEditBeforeSave'][] = 'MollomSpamFilter::onAPIEditBeforeSave';
/**
 * Extension initialisation function, used to set up special pages.
Ejemplo n.º 3
0
    public function execute()
    {
        global $wgOut, $wgUser, $wgScriptPath;
        /* check for user permissions */
        if (!$this->userCanExecute($wgUser)) {
            $this->displayRestrictionError();
            return;
        }
        try {
            if (!Mollom::verifyKey()) {
                $wgOut->addWikiText("'''" . wfMsg('mollommw-key-validation-failure') . "'''");
                return;
            }
        } catch (Exception $e) {
            $this->exceptionOccured($e);
            return;
        }
        if (isset($_POST['add']) && isset($_POST['url'])) {
            MollomClient::addBlacklistURL($_POST['url']);
        }
        if (isset($_POST['remove']) && isset($_POST['url'])) {
            MollomClient::removeBlacklistURL($_POST['url']);
        }
        if (isset($_POST['add']) && isset($_POST['text']) && isset($_POST['context']) && isset($_POST['reason'])) {
            MollomClient::addBlacklistText($_POST['text'], $_POST['context'], $_POST['reason']);
        }
        if (isset($_POST['remove']) && isset($_POST['text']) && isset($_POST['context']) && isset($_POST['reason'])) {
            MollomClient::removeBlacklistText($_POST['text'], $_POST['context'], $_POST['reason']);
        }
        $wgOut->addExtensionStyle($wgScriptPath . '/extensions/mollommw/skins/mollommw.css');
        $wgOut->setPageTitle(wfMsg('mollommw-blacklists'));
        $wgOut->addWikiText('== ' . wfMsg('mollommw-blacklist-url-title') . ' ==');
        try {
            $urls = MollomClient::listBlacklistURL();
            $wgOut->addHtml('<table class="blacklist">');
            foreach ($urls as $url) {
                $wgOut->addHtml('<tr>');
                $wgOut->addHtml('	<td style="padding-right: 100px;">' . wfMsg('mollommw-blacklist-addedon', $url['url'], date('d-m-Y H:i', strtotime($url['created']))) . '</td>');
                $wgOut->addHtml('
					<td><form method="post">
						<input type="hidden" name="url" value="' . $url['url'] . '">
						<input type="submit" name="remove" value="' . wfMsg('mollommw-blacklist-url-remove') . '">
					</form></td>');
                $wgOut->addHtml('</tr>');
            }
            $wgOut->addHtml('<tr>
				<form method="post">
					<td><input type="text" name="url"></td>
					<td><input type="submit" name="add" value="' . wfMsg('mollommw-blacklist-url-add') . '"></td>
				</form>');
            $wgOut->addHtml('</table><br>');
        } catch (Exception $e) {
            $this->exceptionOccured($e);
            return;
        }
        $wgOut->addWikiText('== ' . wfMsg('mollommw-blacklist-text-title') . ' ==');
        try {
            $entries = MollomClient::listBlacklistText();
            $wgOut->addHtml('<table>
				<thead>
					<tr>
						<td>' . wfMsg('mollommw-blacklist-text') . '</td>
						<td>' . wfMsg('mollommw-blacklist-context') . '</td>
						<td>' . wfMsg('mollommw-blacklist-reason') . '</td>
						<td></td>
					</tr>
				</thead>
			');
            foreach ($entries as $entry) {
                $wgOut->addHtml('<tr>');
                $wgOut->addHtml('	<td>' . wfMsg('mollommw-blacklist-addedon', $entry['text'], date('d-m-Y H:i', strtotime($entry['created']))) . '</td>');
                $wgOut->addHtml('	<td>' . wfMsg('mollommw-blacklist-context-' . $entry['context']) . '</td>');
                $wgOut->addHtml('	<td>' . wfMsg('mollommw-blacklist-reason-' . $entry['reason']) . '</td>');
                $wgOut->addHtml('
					<td><form method="post">
						<input type="hidden" name="text" value="' . $entry['text'] . '">
						<input type="hidden" name="context" value="' . $entry['context'] . '">
						<input type="hidden" name="reason" value="' . $entry['reason'] . '">
						<input type="submit" name="remove" value="' . wfMsg('mollommw-blacklist-text-remove') . '">
					</form></td>');
                $wgOut->addHtml('</tr>');
            }
            $wgOut->addHtml('<tr>');
            $wgOut->addHtml('	<form method="post">');
            $wgOut->addHtml('		<td><input type="text" name="text"></td>');
            $wgOut->addHtml('		<td>');
            $wgOut->addHtml('			<select name="context">');
            $wgOut->addHtml('				<option value="everything">' . wfMsg('mollommw-blacklist-context-everything') . '</option>');
            $wgOut->addHtml('				<option value="links">' . wfMsg('mollommw-blacklist-context-links') . '</option>');
            $wgOut->addHtml('				<option value="author">' . wfMsg('mollommw-blacklist-context-author') . '</option>');
            $wgOut->addHtml('			</select>');
            $wgOut->addHtml('		</td>');
            $wgOut->addHtml('		<td>');
            $wgOut->addHtml('			<select name="reason">');
            $wgOut->addHtml('				<option value="spam">' . wfMsg('mollommw-blacklist-reason-spam') . '</option>');
            $wgOut->addHtml('				<option value="profanity">' . wfMsg('mollommw-blacklist-reason-profanity') . '</option>');
            $wgOut->addHtml('				<option value="low-quality">' . wfMsg('mollommw-blacklist-reason-low-quality') . '</option>');
            $wgOut->addHtml('				<option value="unwanted">' . wfMsg('mollommw-blacklist-reason-unwanted') . '</option>');
            $wgOut->addHtml('			</select>');
            $wgOut->addHtml('		</td>');
            $wgOut->addHtml('		<td><input type="submit" name="add" value="' . wfMsg('mollommw-blacklist-text-add') . '"></td>');
            $wgOut->addHtml('	</form>');
            $wgOut->addHtml('</tr></table>');
        } catch (Exception $e) {
            $this->exceptionOccured($e);
            return;
        }
    }