Exemplo n.º 1
0
 public function init()
 {
     if (!$this->_akismet instanceof AkismetAPI) {
         $akismet = new AkismetAPI($this->apiKey, Url::base(true));
         if (!$akismet->verifyKey()) {
             throw new \yii\base\InvalidConfigException('Invalid Akismet API key.');
         }
         $this->_akismet = $akismet;
     }
 }
Exemplo n.º 2
0
 /**
  * Validates the form
  */
 private function validateForm()
 {
     // is the form submitted?
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $this->frm->getField('site_title')->isFilled(BL::err('FieldIsRequired'));
         // date & time
         $this->frm->getField('time_format')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_short')->isFilled(BL::err('FieldIsRequired'));
         $this->frm->getField('date_format_long')->isFilled(BL::err('FieldIsRequired'));
         // number
         $this->frm->getField('number_format')->isFilled(BL::err('FieldIsRequired'));
         // akismet key may be filled in
         if ($this->needsAkismet && $this->frm->getField('akismet_key')->isFilled()) {
             // key has changed
             if ($this->frm->getField('akismet_key')->getValue() != $this->get('fork.settings')->get('Core', 'akismet_key', null)) {
                 // create instance
                 $akismet = new Akismet($this->frm->getField('akismet_key')->getValue(), SITE_URL);
                 // invalid key
                 if (!$akismet->verifyKey()) {
                     $this->frm->getField('akismet_key')->setError(BL::err('InvalidAPIKey'));
                 }
             }
         }
         // domains filled in
         if ($this->frm->getField('site_domains')->isFilled()) {
             // split on newlines
             $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
             // loop domains
             foreach ($domains as $domain) {
                 // strip funky stuff
                 $domain = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 // invalid URL
                 if (!\SpoonFilter::isURL('http://' . $domain)) {
                     // set error
                     $this->frm->getField('site_domains')->setError(BL::err('InvalidDomain'));
                     // stop looping domains
                     break;
                 }
             }
         }
         if ($this->frm->getField('ckfinder_image_max_width')->isFilled()) {
             $this->frm->getField('ckfinder_image_max_width')->isInteger(BL::err('InvalidInteger'));
         }
         if ($this->frm->getField('ckfinder_image_max_height')->isFilled()) {
             $this->frm->getField('ckfinder_image_max_height')->isInteger(BL::err('InvalidInteger'));
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             $this->get('fork.settings')->set('Core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             $this->get('fork.settings')->set('Core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             $this->get('fork.settings')->set('Core', 'site_start_of_body_scripts', $this->frm->getField('site_start_of_body_scripts')->getValue());
             $this->get('fork.settings')->set('Core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             $this->get('fork.settings')->set('Core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // twitter settings
             /** @var \SpoonFormText $txtTwitterSiteName */
             $txtTwitterSiteName = $this->frm->getField('twitter_site_name');
             if ($txtTwitterSiteName->isFilled()) {
                 $this->get('fork.settings')->set('Core', 'twitter_site_name', '@' . ltrim($txtTwitterSiteName->getValue(), '@'));
             }
             // ckfinder settings
             $this->get('fork.settings')->set('Core', 'ckfinder_license_name', $this->frm->getField('ckfinder_license_name')->isFilled() ? $this->frm->getField('ckfinder_license_name')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'ckfinder_license_key', $this->frm->getField('ckfinder_license_key')->isFilled() ? $this->frm->getField('ckfinder_license_key')->getValue() : null);
             $this->get('fork.settings')->set('Core', 'ckfinder_image_max_width', $this->frm->getField('ckfinder_image_max_width')->isFilled() ? $this->frm->getField('ckfinder_image_max_width')->getValue() : 1600);
             $this->get('fork.settings')->set('Core', 'ckfinder_image_max_height', $this->frm->getField('ckfinder_image_max_height')->isFilled() ? $this->frm->getField('ckfinder_image_max_height')->getValue() : 1200);
             // api keys
             $this->get('fork.settings')->set('Core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             $this->get('fork.settings')->set('Core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 $this->get('fork.settings')->set('Core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 $this->get('fork.settings')->set('Core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             $this->get('fork.settings')->set('Core', 'time_format', $this->frm->getField('time_format')->getValue());
             $this->get('fork.settings')->set('Core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             $this->get('fork.settings')->set('Core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             $this->get('fork.settings')->set('Core', 'number_format', $this->frm->getField('number_format')->getValue());
             // before we save the languages, we need to ensure that each language actually exists and may be chosen.
             $languages = array(SITE_DEFAULT_LANGUAGE);
             $activeLanguages = array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue()));
             $redirectLanguages = array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue()));
             // cleanup redirect-languages, by removing the values that aren't present in the active languages
             $redirectLanguages = array_intersect($redirectLanguages, $activeLanguages);
             // save active languages
             $this->get('fork.settings')->set('Core', 'active_languages', $activeLanguages);
             $this->get('fork.settings')->set('Core', 'redirect_languages', $redirectLanguages);
             // domains may not contain www, http or https. Therefor we must loop and create the list of domains.
             $siteDomains = array();
             // domains filled in
             if ($this->frm->getField('site_domains')->isFilled()) {
                 // split on newlines
                 $domains = explode("\n", trim($this->frm->getField('site_domains')->getValue()));
                 // loop domains
                 foreach ($domains as $domain) {
                     // strip funky stuff
                     $siteDomains[] = trim(str_replace(array('www.', 'http://', 'https://'), '', $domain));
                 }
             }
             // save domains
             $this->get('fork.settings')->set('Core', 'site_domains', $siteDomains);
             $this->get('fork.settings')->set('Core', 'show_cookie_bar', $this->frm->getField('show_cookie_bar')->getChecked());
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
Exemplo n.º 3
0
<?php

//require
require_once '../../../autoload.php';
require_once 'config.php';
use TijsVerkoyen\Akismet\Akismet;
// create instance
$akismet = new Akismet(APIKEY, URL);
$response = $akismet->verifyKey();
//$response = $akismet->isSpam('Nice one. Thanks', 'Joris', '*****@*****.**', '', null, 'comment');
//$response = $akismet->submitHam(
//	'Great portal! <a href="http://key-west-florida-fishing-charters.6xyotd.us/ " rel="nofollow">Key west florida fishing charters</a><a href="http://kates-playground-videos.6xyotd.us/ " rel="nofollow">Kates playground videos</a><a href="http://karaoke-norah-jones.6xyotd.us/ " rel="nofollow">Karaoke norah jones</a><a href="http://kiera-knightly-naked.6xyotd.us/ " rel="nofollow">Kiera knightly naked</a><a href="http://kelli-fox.6xyotd.us/ " rel="nofollow">Kelli fox</a><a href="http://ky-farm-bureau.6xyotd.us/ " rel="nofollow">Ky farm bureau</a><a href="http://kari-gold.6xyotd.us/ " rel="nofollow">Kari gold</a><a href="http://julie-gibson-diaspora.6xyotd.us/ " rel="nofollow">Julie gibson diaspora</a><a href="http://keely-net.6xyotd.us/ " rel="nofollow">Keely net</a><a href="http://kellie-pickler-t**s.6xyotd.us/ " rel="nofollow">Kellie pickler t**s</a><a href="http://korean-central-news-agency.6xyotd.us/ " rel="nofollow">Korean central news agency</a><a href="http://kings-quest-3-walkthru.6xyotd.us/ " rel="nofollow">King&#8217;s quest 3 walkthru</a><a href="http://kennels-in-hilton-head.6xyotd.us/ " rel="nofollow">Kennels in hilton head</a><a href="http://kentucky-tv-stations.6xyotd.us/ " rel="nofollow">Kentucky tv stations</a><a href="http://kauffman-foundation.6xyotd.us/ " rel="nofollow">Kauffman foundation</a><a href="http://jungle-diaper-cakes.6xyotd.us/ " rel="nofollow">Jungle diaper cakes</a><a href="http://kimba-the-white-lion.6xyotd.us/ " rel="nofollow">Kimba the white lion</a><a href="http://julie-harris.6xyotd.us/ " rel="nofollow">Julie harris</a><a href="http://kona-hi.6xyotd.us/ " rel="nofollow">Kona hi</a><a href="http://kids-cowboy-boots.6xyotd.us/ " rel="nofollow">Kids cowboy boots</a><a href="http://kimora-simmons.6xyotd.us/ " rel="nofollow">Kimora simmons</a><a href="http://kermit-the-frog.6xyotd.us/ " rel="nofollow">Kermit the frog</a><a href="http://justin-nozuka.6xyotd.us/ " rel="nofollow">Justin nozuka</a><a href="http://katie-james-actress.6xyotd.us/ " rel="nofollow">Katie james actress</a><a href="http://king-neptune.6xyotd.us/ " rel="nofollow">King neptune</a> yefvo',
//	'ofqqn',
//	'*****@*****.**'
//);
//output
ob_start();
var_dump($response);