In light of religious terrorist attacks in Paris, please see Category:blasphemy!

Freedom Porn:free technology/massmail

From Freedom Porn
Jump to: navigation, search

massmail is a PHP script that plugs into the MediaWiki database using configuration from LocalSettings.php and uses it to send e-mails to all the people with accounts. It does not use Special:Contact and is overall a separate entity that just gets information from the database directly.

Licence

Available under the terms of GNU General Public License 3.0

Produced in the year 2010.
GPLv3
For more information please see Freedom Porn:copyrights.


Known issues

  • There is no authentication at this time, so for now it is being uploaded to the site and is deleted right after the legitimate use. Otherwise some attacker could use it to send out a lot of spam.

Code

<html>
<head>
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
  <title>Freedom Porn mass mailer</title>
</head>
<body lang='en'>
 
<?php
 
if(isset($_POST['subject']) and isset($_POST['body']))
{
  define('MEDIAWIKI', true);
  define('MEDIAWIKI_HELPER', true);
  require_once("smut/LocalSettings.php");
 
  $charset="utf8";
 
  $db=mysqli_connect($wgDBserver,$wgDBuser,$wgDBpassword,$wgDBname);
  if($db->connect_error) die("<pre>Unable to set {$charset}\r{$db->error}</pre>");
 
  $db->set_charset($charset) or die("<pre>Unable to set {$charset}\r{$db->error}</pre>");
 
  $query="SELECT fp_user.user_email AS email FROM fp_user WHERE LENGTH(IFNULL(user_email,''))>0;";
  $result=$db->query($query);
  if($result===false)
  {
    die("<pre>Error while executing '{$query}'\r{$db->error}</pre>");
  }
 
  $total_addresses=$result->num_rows;
  $successful_addresses=0;
  if($result->num_rows>0)
  {
    while($row=$result->fetch_assoc())
    {
      $mail_to=$row['email'];
      $mail_subject='=?UTF-8?B?'.base64_encode($_POST['subject']).'?=';
      $mail_from="FreedomPorn@whengendarmesleeps.org";
      $mail_replyto=$from;
      $mail_xmailer="FreedomPorn.org massmailer running on PHP/".phpversion();
      $mail_body=$_POST['body'];
      $mail_headers = "From: {$mail_from}\r\n";
      $mail_headers.= "Reply-To: {$mail_replyto}\r\n";
      $mail_headers.= "MIME-Version: 1.0\r\n";
      $mail_headers.= "Content-type: text/plain; charset=utf-8\r\n";
      $mail_headers.="Content-Transfer-Encoding: 8bit\r\n";
      $mail_headers.= "X-Mailer: {$mail_xmailer}";
 
      if(mail($mail_to, $mail_subject, $mail_body, $mail_headers))
      {
        echo "<strong>{$mail_to}</strong><br/>";
        $successful_addresses++;
      }
      else
      {
        echo "<strike>{$mail_to}</strike><br/>";
      }
    }
  }
?>
<p>Statistics:<br/>
Total addresses: <?php echo $total_addresses; ?><br/>
Successful addresses: <?php echo $successful_addresses; ?></br/>
</p>
<?php
  $result->close();
 
  $db->close();
}
else // no form submission
{
?>
<form action='<?php echo htmlentities($_SERVER['PHP_SELF']); ?>' method='POST' enctype='multipart/form-data'>
  Subject: <input type='text' name='subject' /><br/>
  <textarea tabindex='1' cols='80' rows='25' style='width: 100%' name='body'></textarea><br/>
  <input type='submit' value='Send' />
</form>
<?php
}
?>
</body>
</html>