Beispiel #1
0
 function post_index()
 {
     $sblam = $this->getSblam();
     $bayes = new SblamTestBayes(array(), $this->services);
     $spamverts = new SblamTestSpamvertises(array(), $this->services);
     $isspam = NULL;
     if (!empty($_POST['ham'])) {
         $isspam = false;
     } else {
         if (!empty($_POST['spam'])) {
             $isspam = true;
         }
     }
     $addtext = empty($_POST['nowords']);
     $linkstoadd = array();
     $spamvertresult = NULL;
     $bayesresult = NULL;
     if (!empty($_POST['stuff']) && NULL !== $isspam) {
         if ($addtext) {
             $bayes->addText($_POST['stuff'], $isspam, (int) $_POST['howmuch']);
         }
         if (preg_match_all('@(?:https?://|www\\.)([a-z0-9.-]+\\.[a-z]{2,4}(?:/[^\\s]{1,15})?)@', $_POST['stuff'], $links)) {
             foreach ($links[0] as &$l) {
                 if (!preg_match('@^https?://@', $l)) {
                     $l = 'http://' . $l;
                 }
             }
             $spamverts->addURIs($links[0], $isspam, (int) $_POST['howmuch']);
             $spamvertresult = $spamverts->testURIs($links[0]);
         } else {
             d("no links found");
         }
     }
     if (isset($_POST['stuff']) && $addtext) {
         $bayesresult = $bayes->testText($_POST['stuff']);
     } else {
         $bayesresult = NULL;
     }
     return array('title' => 'Added to bayes base', 'isspam' => $isspam, 'addtext' => $addtext, 'linksadded' => $linkstoadd, 'spamvertresult' => $spamvertresult, 'bayesresult' => $bayesresult);
 }
Beispiel #2
0
 function kill($url)
 {
     if (!preg_match('!^(https?:)?//!i', $url)) {
         $url = 'http://' . $url;
     }
     // MESS
     $this->getSblam();
     // init tlds
     $spamverts = new SblamTestSpamvertises(array(), $this->services);
     $linkstoadd = array();
     if (false !== strpos($url, '@')) {
         d('adding email');
         $spamverts->addEmail($linkstoadd, $url);
     } else {
         $spamverts->addURI($linkstoadd, new SblamURI($url), '');
         // split subdomains, etc.
     }
     $linkstoadd = array_keys($linkstoadd);
     $bayesbase = $this->getBayesStats();
     $res = array('title' => 'Banned domains', 'result' => $bayesbase->banWords($linkstoadd), 'linksadded' => $linkstoadd);
     return $res;
 }