public function save()
	{
		parent::validate('');
		Mollom::setPublicKey($this->publicKey);
		Mollom::setPrivateKey($this->privateKey);
		Mollom::setServerList(CoOrg::config()->get('mollom/serverlist'));
		try
		{
			if (!Mollom::verifyKey())
			{
				$this->publicKey_error = t('Invalid keys');
				throw new ValidationException($this);
			}
		}
		catch (ServerListException $e)
		{
			CoOrg::config()->set('mollom/serverlist', Mollom::getServerList());
			try
			{
				if (!Mollom::verifyKey())
				{
					$this->publicKey_error = t('Invalid keys');
					CoOrg::config()->save(); // Save the new serverlist
					throw new ValidationException($this);
				}
			}
			catch (InternalException $e)
			{
				
			}
			catch (ServerListException $e)
			{
			}
		}
		CoOrg::config()->set('mollom/public', $this->publicKey);
		CoOrg::config()->set('mollom/private', $this->privateKey);
		CoOrg::config()->save();
	}
Beispiel #2
0
    public function execute($par)
    {
        global $wgOut, $wgUser;
        /* check for user permissions */
        if (!$this->userCanExecute($wgUser)) {
            $this->displayRestrictionError();
            return;
        }
        $wgOut->setPageTitle(wfMsg('mollommw-statistics'));
        try {
            $validKeys = Mollom::verifyKey();
            if ($validKeys) {
                $wgOut->addHtml('<embed src="http://mollom.com/statistics.swf?key=' . Mollom::getPublicKey() . '"
				quality="high" width="500" height="480" name="Mollom" align="middle" play="true" loop="false" allowScriptAccess="sameDomain"
				type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"></embed>');
            } else {
                $wgOut->addWikiText("'''" . wfMsg('mollommw-key-validation-failure') . "'''");
            }
        } catch (Exception $e) {
            wfDebugLog('MollomMW', 'Exception on statistics page: ' . $e->getMessage());
            $wgOut->addWikiText("'''" . wfMsg('mollommw-mollom-error') . "'''");
        }
    }
Beispiel #3
0
 public function validate_private_key($key, FormControl $control, FormUI $form)
 {
     Mollom::setPrivateKey($key);
     try {
         $servers = Mollom::getServerList();
         Options::set('mollom__servers', $servers);
         Mollom::setServerList($servers);
     } catch (Exception $e) {
         EventLog::log($e->getMessage(), 'notice', 'comment', 'Mollom');
         return array(_t('Sorry, the Mollom servers seem to be down.', 'mollom'));
     }
     try {
         if (!Mollom::verifyKey()) {
             return array(sprintf(_t('Sorry, the Mollom API keys %s and %s are <b>invalid</b>. Please check to make sure the keys are entered correctly and are <b>registered for this site (%s)</b>.', 'mollom'), $key, $form->public_key->value, Site::get_url('habari')));
         }
     } catch (Exception $e) {
         return array(_t('Sorry, the Mollom servers seem to be down.', 'mollom'));
     }
     return array();
 }
    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;
        }
    }