Exemplo n.º 1
0
 public function recheckSpamAction()
 {
     $id = $this->intVal(3);
     if ($id == 0) {
         header("location:/homeadmin/comments/");
     }
     $newsModel = new NewsModel();
     $akismet = new Akismet();
     $akismet->key = "5a3c4dc9f909";
     $akismet->blog = "http://tiny4cocoa.org/home/";
     if (!$akismet->verifyKey()) {
         die("akismet verify error");
     }
     $comment = $newsModel->commentById($id);
     if (!$comment) {
         die("can not find comment");
     }
     $data = array('blog' => 'http://tiny4cocoa.org/home/', 'user_ip' => $comment["ip"], 'user_agent' => $comment["useragent"], 'referrer' => $comment["referrer"], 'permalink' => "http://tiny4cocoa.org/home/s/{$comment['newsid']}", 'comment_type' => 'comment', 'comment_author' => $comment["poster"], 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => $comment["content"]);
     $ret = $akismet->commentCheck($data);
     if ($ret) {
         $newsModel->markSpam($comment["id"], 1);
         //echo "comment # $comment[id] is spam!\r\n";
     } else {
         $newsModel->markSpam($comment["id"], 0);
         //echo "comment # $comment[id] is not spam.\r\n";
     }
     header("location:/homeadmin/comments/");
 }
Exemplo n.º 2
0
 /**
  * Validates the form
  *
  * @return	void
  */
 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() != BackendModel::getModuleSetting('core', 'akismet_key', null)) {
                 // load akismet
                 require_once PATH_LIBRARY . '/external/akismet.php';
                 // 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;
                 }
             }
         }
         // no errors ?
         if ($this->frm->isCorrect()) {
             // general settings
             BackendModel::setModuleSetting('core', 'site_title_' . BL::getWorkingLanguage(), $this->frm->getField('site_title')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_header', $this->frm->getField('site_html_header')->getValue());
             BackendModel::setModuleSetting('core', 'site_html_footer', $this->frm->getField('site_html_footer')->getValue());
             // facebook settings
             BackendModel::setModuleSetting('core', 'facebook_admin_ids', $this->frm->getField('facebook_admin_ids')->isFilled() ? $this->frm->getField('facebook_admin_ids')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_id', $this->frm->getField('facebook_application_id')->isFilled() ? $this->frm->getField('facebook_application_id')->getValue() : null);
             BackendModel::setModuleSetting('core', 'facebook_app_secret', $this->frm->getField('facebook_application_secret')->isFilled() ? $this->frm->getField('facebook_application_secret')->getValue() : null);
             // api keys
             BackendModel::setModuleSetting('core', 'fork_api_public_key', $this->frm->getField('fork_api_public_key')->getValue());
             BackendModel::setModuleSetting('core', 'fork_api_private_key', $this->frm->getField('fork_api_private_key')->getValue());
             if ($this->needsAkismet) {
                 BackendModel::setModuleSetting('core', 'akismet_key', $this->frm->getField('akismet_key')->getValue());
             }
             if ($this->needsGoogleMaps) {
                 BackendModel::setModuleSetting('core', 'google_maps_key', $this->frm->getField('google_maps_key')->getValue());
             }
             // date & time formats
             BackendModel::setModuleSetting('core', 'time_format', $this->frm->getField('time_format')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_short', $this->frm->getField('date_format_short')->getValue());
             BackendModel::setModuleSetting('core', 'date_format_long', $this->frm->getField('date_format_long')->getValue());
             // date & time formats
             BackendModel::setModuleSetting('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);
             // save active languages
             BackendModel::setModuleSetting('core', 'active_languages', array_unique(array_merge($languages, $this->frm->getField('active_languages')->getValue())));
             BackendModel::setModuleSetting('core', 'redirect_languages', array_unique(array_merge($languages, $this->frm->getField('redirect_languages')->getValue())));
             // 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
             BackendModel::setModuleSetting('core', 'site_domains', $siteDomains);
             // assign report
             $this->tpl->assign('report', true);
             $this->tpl->assign('reportMessage', BL::msg('Saved'));
         }
     }
 }
Exemplo n.º 3
0
 public function checkSpamAction()
 {
     $newModel = new NewsModel();
     $comments = $newModel->commentToCheck();
     if (count($comments) == 0) {
         die("no comments");
     }
     $akismet = new Akismet();
     $akismet->key = "5a3c4dc9f909";
     $akismet->blog = "http://tiny4cocoa.org/home/";
     if (!$akismet->verifyKey()) {
         die("akismet verify error");
     }
     foreach ($comments as $comment) {
         $data = array('blog' => 'http://tiny4cocoa.org/home/', 'user_ip' => $comment["ip"], 'user_agent' => $comment["useragent"], 'referrer' => $comment["referrer"], 'permalink' => "http://tiny4cocoa.org/home/s/{$comment['newsid']}", 'comment_type' => 'comment', 'comment_author' => $comment["poster"], 'comment_author_email' => '', 'comment_author_url' => '', 'comment_content' => $comment["content"]);
         //var_dump($data);
         $ret = $akismet->commentCheck($data);
         if ($ret) {
             $newModel->markSpam($comment["id"], 1);
             echo "comment # {$comment['id']} is spam!\r\n";
         } else {
             $newModel->markSpam($comment["id"], 0);
             echo "comment # {$comment['id']} is not spam.\r\n";
         }
     }
 }