示例#1
0
 function __construct($contentfield = NULL, $namefield = NULL, $mailfield = NULL, $urifield = NULL)
 {
     if ($contentfield && isset($_POST[$contentfield])) {
         $contentfield = $_POST[$contentfield];
     }
     if ($namefield && isset($_POST[$namefield])) {
         $namefield = $_POST[$namefield];
     }
     if ($mailfield && isset($_POST[$mailfield])) {
         $mailfield = $_POST[$mailfield];
     }
     if ($urifield && isset($_POST[$urifield])) {
         $urifield = $_POST[$urifield];
     }
     parent::__construct($contentfield, $namefield, $mailfield, $urifield, ServerRequest::getRequestIPs());
 }
示例#2
0
 protected function postFromRow(array $r)
 {
     d($r, 'creating new post from row');
     assert('!empty($r["id"])');
     assert('!empty($r["headers"])');
     assert('!empty($r["path"])');
     assert('!empty($r["timestamp"])');
     assert('array_key_exists("name",$r)');
     assert('isset($r["content"])');
     assert('isset($r["ip"])');
     $heads = array();
     foreach (explode("\n", $r['headers']) as $h) {
         if (preg_match("!(.*?):\\s*(.*)!", $h, $o)) {
             $heads[$o[1]] = $o[2];
         }
     }
     if (!isset($heads['HTTP_HOST'])) {
         $heads['HTTP_HOST'] = $r['host'];
     }
     if ($r['ip']) {
         $heads['REMOTE_ADDR'] = long2ip($r['ip']);
     }
     $post = new SblamBasePost($r['content'], $r['name'], $r['email'], $r['url'], ServerRequest::getRequestIPs($heads, true));
     $post->setSpamReason($r['spamreason']);
     $post->setSpamScore(array($r['spamscore'] / 100, $r['spamcert'] / 100));
     $post->setPostId($r['id']);
     $post->setHeaders($heads);
     $post->setTime($r['timestamp']);
     $post->setPath($r['path']);
     $post->setInstallId($r['serverid']);
     $post->bayesadded = $r['added'];
     $post->manualspam = $r['manualspam'];
     $post->worktime = $r['worktime'];
     $post->account = $r['account'];
     $post->profiling = $r['profiling'];
     $postarr = array();
     if ($r['post']) {
         foreach (explode("\n", $r['post']) as $pline) {
             if (preg_match("!^([^:]+): ?(.*)\$!", $pline, $out)) {
                 $postarr[$out[1]] = $out[2];
             }
         }
         $post->setPost($postarr);
     }
     return $post;
 }