<HTML>

<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Dolphin Techs Mass Mail Installer for dolphin 8.0.X</TITLE>
</HEAD>

<BODY BGCOLOR="#000000">

<DIV ALIGN="center">
	<TABLE CELLPADDING="10" CELLSPACING="0" WIDTH="546" BGCOLOR="#FFFFFF">
		<TR>
			<TD HEIGHT="585">
			
<?
require_once( '../../../inc/header.inc.php' );
require_once( '../../../inc/classes/BxDolDb.php' );
require_once( '../../../inc/utils.inc.php' );

echo "Creating config file.....";

//read the entire string
$str=implode(file('config.php'));

$fp=fopen('config.php','w') or die ("<font size='4' color='red'><br>Could not open config.php in mail directory, please make sure it is set to permission 666!</font>");
//replace something in the file string - this is a VERY simple example
$str=str_replace('##database',BX_DATABASE_NAME,$str);
$str=str_replace('##dbpassword',BX_DATABASE_PASS,$str);
$str=str_replace('##dbuser',BX_DATABASE_USER,$str);
$str=str_replace('##dbhost',BX_DATABASE_HOST,$str);
//now, TOTALLY rewrite the file
if (strlen($str) >= 1)
  fwrite($fp,$str,strlen($str));
echo "<font color='green'>Complete!</font><br><br>";




echo "Trying to get admin info from database.......";
//$passw = getFirstRow("SELECT password FROM sys_accounts WHERE role =3") or die(mysql_error("<font size='4' color='red'><br>Could Not Retrieve Dolphin Admin Password!</font>"));
//$passw = $passw['password'];
//$admin = getFirstRow("SELECT name FROM sys_accounts WHERE role =3") or die(mysql_error("<font size='4' color='red'><br>Cound Not Retrieve Dolphin Admin Name!</font>"));
$admin = $admin['name'];
$email = $site['email'];
$sitename = $site['title'];
$siteurl = BX_DOL_URL_ROOT;
echo "<font color='green'>Complete!</font><br><br>";
$listname = $sitename . " mailing list";
echo "Creating mailing list tables......";
mysql_query("CREATE TABLE `pommo_config` (
  `config_name` varchar(64) NOT NULL default '',
  `config_value` text NOT NULL,
  `config_description` tinytext NOT NULL,
  `autoload` enum('on','off') NOT NULL default 'on',
  `user_change` enum('on','off') NOT NULL default 'on',
  PRIMARY KEY  (`config_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1");


mysql_query("INSERT INTO `pommo_config` VALUES('admin_username', 'jason', 'Username', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('admin_password', '726db167d332584d54193b581e57fb9a' , 'Password', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('admin_email', '$email' , 'Administrator Email', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('site_name', '$sitename' , 'Website Name', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('site_url', '$siteurl' , 'Website URL', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('site_success', '', 'Signup Success URL', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('site_confirm', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_name', '$listname', 'List Name', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_fromname', 'The Webmaster', 'From Name', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_fromemail', '$email' , 'From Email', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_frombounce', '$email' , 'Bounces', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_exchanger', 'sendmail', 'List Exchanger', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_confirm', 'off', 'Confirmation Messages', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_charset', 'UTF-8', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('list_wysiwyg', 'on', '', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('maxRuntime', '80', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('messages', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('notices', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('demo_mode', 'off', 'Demonstration Mode', 'on', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('smtp_1', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('smtp_2', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('smtp_3', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('smtp_4', '', '', 'off', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_DBPP', '0', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_DP', '10', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_DMPP', '0', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_BPS', '0', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_MPS', '3', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('throttle_SMTP', 'individual', '', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('public_history', 'off', 'Public Mailing History', 'off', 'on')");
mysql_query("INSERT INTO `pommo_config` VALUES('version', 'Aardvark PR16', 'poMMo Version', 'on', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('key', '529736', 'Unique Identifier', 'on', 'off')");
mysql_query("INSERT INTO `pommo_config` VALUES('revision', '41', 'Internal Revision', 'on', 'off')");



mysql_query("CREATE TABLE `pommo_fields` (
  `field_id` smallint(5) unsigned NOT NULL auto_increment,
  `field_active` enum('on','off') NOT NULL default 'off',
  `field_ordering` smallint(5) unsigned NOT NULL default '0',
  `field_name` varchar(60) default NULL,
  `field_prompt` varchar(60) default NULL,
  `field_normally` varchar(60) default NULL,
  `field_array` text,
  `field_required` enum('on','off') NOT NULL default 'off',
  `field_type` enum('checkbox','multiple','text','date','number','comment') default NULL,
  PRIMARY KEY  (`field_id`),
  KEY `active` (`field_active`,`field_ordering`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");

mysql_query("CREATE TABLE `pommo_groups` (
  `group_id` smallint(5) unsigned NOT NULL auto_increment,
  `group_name` tinytext NOT NULL,
  PRIMARY KEY  (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");


mysql_query("CREATE TABLE `pommo_group_rules` (
  `rule_id` int(10) unsigned NOT NULL auto_increment,
  `group_id` int(10) unsigned NOT NULL default '0',
  `field_id` tinyint(3) unsigned NOT NULL default '0',
  `type` tinyint(1) NOT NULL default '0' COMMENT '0: OFF, (and), 1: ON (or)',
  `logic` enum('is','not','greater','less','true','false','is_in','not_in') NOT NULL default 'is',
  `value` text,
  PRIMARY KEY  (`rule_id`),
  KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");


mysql_query("CREATE TABLE `pommo_mailings` (
  `mailing_id` int(10) unsigned NOT NULL auto_increment,
  `fromname` varchar(60) NOT NULL default '',
  `fromemail` varchar(60) NOT NULL default '',
  `frombounce` varchar(60) NOT NULL default '',
  `subject` varchar(60) NOT NULL default '',
  `body` mediumtext NOT NULL,
  `altbody` mediumtext,
  `ishtml` enum('on','off') NOT NULL default 'off',
  `mailgroup` varchar(60) NOT NULL default 'Unknown',
  `subscriberCount` int(10) unsigned NOT NULL default '0',
  `started` datetime NOT NULL default '0000-00-00 00:00:00',
  `finished` datetime default NULL,
  `sent` int(10) unsigned NOT NULL default '0',
  `charset` varchar(15) NOT NULL default 'UTF-8',
  `status` tinyint(1) NOT NULL default '1' COMMENT '0: finished, 1: processing, 2: cancelled',
  PRIMARY KEY  (`mailing_id`),
  KEY `status` (`status`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");


mysql_query("CREATE TABLE `pommo_mailing_current` (
  `current_id` int(10) unsigned NOT NULL default '0',
  `command` enum('none','restart','stop','cancel') NOT NULL default 'none',
  `serial` int(10) unsigned default NULL,
  `securityCode` varchar(32) default NULL,
  `notices` longtext,
  `current_status` enum('started','stopped') NOT NULL default 'stopped',
  `touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`current_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1");


mysql_query("CREATE TABLE `pommo_mailing_notices` (
  `mailing_id` int(10) unsigned NOT NULL default '0',
  `notice` varchar(255) NOT NULL default '',
  `touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `id` smallint(5) unsigned NOT NULL default '0',
  KEY `mailing_id` (`mailing_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1");


mysql_query("CREATE TABLE `pommo_queue` (
  `subscriber_id` int(10) unsigned NOT NULL default '0',
  `status` tinyint(1) NOT NULL default '0' COMMENT '0: unsent, 1: sent, 2: failed',
  `smtp` tinyint(1) NOT NULL default '0' COMMENT '0: none, 1-4: Designated to SMTP relay #',
  PRIMARY KEY  (`subscriber_id`),
  KEY `status` (`status`,`smtp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1");



mysql_query("CREATE TABLE `pommo_scratch` (
  `scratch_id` int(10) unsigned NOT NULL auto_increment,
  `time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `type` smallint(5) unsigned NOT NULL default '0' COMMENT 'Used to identify row type. 0 = undifined, 1 = ',
  `int` bigint(20) default NULL,
  `str` text,
  PRIMARY KEY  (`scratch_id`),
  KEY `type` (`type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='General Purpose Table for caches, counts, etc.' AUTO_INCREMENT=1");

mysql_query("CREATE TABLE `pommo_templates` (
  `template_id` smallint(5) unsigned NOT NULL auto_increment,
  `name` varchar(60) NOT NULL default 'name',
  `description` varchar(255) default NULL,
  `body` mediumtext,
  `altbody` mediumtext,
  PRIMARY KEY  (`template_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2");

mysql_query("INSERT INTO `pommo_templates` VALUES (1,'CSS Example','poMMo default, featuring a plain CSS based HTML design. Includes a weblink (to view online) in the header, and a unsubscribe link in the footer.','<style type=\"text/css\" media=\"all\">\r\n\r\n/* base styling */\r\n\r\ndiv.pommoMailing {\r\n\r\n  background-color: white; /* background color */\r\n  color: #333; /* text color */\r\n  width: 100%;\r\n  padding: 6px;\r\n\r\n}\r\n\r\ndiv.pommoMailing a, div.pommoMailing a:visited {\r\n\r\n  text-decoration: none;\r\n  color: #0067ff; /* link & visited link color */\r\n\r\n}\r\n\r\n/* header styling */\r\n\r\ndiv.pommoMailing div.pommoHeader {\r\n  \r\n  border: 1px solid black;\r\n  padding: 6px;\r\n  background-color: #DDF0BD; /* light green */\r\n  color: green;\r\n  width: 100%;\r\n  text-align: center;\r\n}\r\n\r\n/* footer styling */\r\n\r\ndiv.pommoMailing div.pommoFooter {\r\n  width: 100%;\r\n  padding: 5px 12px;\r\n  background-color: black;\r\n  color: #DDD;\r\n}\r\n\r\ndiv.pommoMailing p.smaller {\r\n  font-size: 80%;\r\n}\r\n\r\n\r\n</style>\r\n\r\n<div class=\"pommoMailing\">\r\n\r\n  <div class=\"pommoHeader\">\r\n  </div>\r\n\r\n  <h2>Bonjour!</h2>\r\n  <br />\r\n \r\n  <p>\r\n  Aliquam tempor erat eu sapien. Proin nisl lorem, hendrerit ut, venenatis vel, consequat in, est. In hac habitasse platea dictumst. Praesent malesuada tristique massa. Donec nec dui. Nulla at ligula quis diam auctor vulputate. Sed ligula ligula, elementum ac, tincidunt nec, accumsan non, risus. Aliquam convallis blandit tortor. In porta nisi interdum ante. Maecenas sem. Maecenas at felis ac massa dictum malesuada. Maecenas quis lectus. In hac habitasse platea dictumst. Ut sit amet nunc. Donec non lacus. Nulla facilisi. Vestibulum molestie. Aenean at enim sit amet augue auctor bibendum. Duis in ipsum.\r\n  </p>\r\n\r\n  <div class=\"pommoFooter\">\r\n  </div>\r\n\r\n  <p class=\"smaller\">\r\n    Message sent with <a href=\"http://www.pommo.org/\">poMMo</a>.\r\n  </p>\r\n\r\n</div>',NULL)");

mysql_query("CREATE TABLE `pommo_subscribers` (
  `subscriber_id` int(10) unsigned NOT NULL auto_increment,
  `email` char(60) NOT NULL default '',
  `name` char(60) NOT NULL default '',
  `time_touched` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `added` datetime NOT NULL default '0000-00-00 00:00:00',
  `flag` tinyint(1) NOT NULL default '0' COMMENT '0: NULL, 1-8: REMOVE, 9: UPDATE',
  `ip` int(10) unsigned default NULL COMMENT 'Stored with INET_ATON(), Fetched with INET_NTOA()',
  `status` tinyint(1) NOT NULL default '2' COMMENT '0: Inactive, 1: Active, 2: Pending',
  PRIMARY KEY  (`subscriber_id`),
  KEY `status` (`status`,`subscriber_id`),
  KEY `status_2` (`status`,`email`),
  KEY `status_3` (`status`,`name`),
  KEY `status_4` (`status`,`time_touched`),
  KEY `status_5` (`status`,`added`),
  KEY `status_6` (`status`,`ip`),
  KEY `flag` (`flag`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");


mysql_query("CREATE TABLE `pommo_subscriber_data` (
  `data_id` bigint(20) unsigned NOT NULL auto_increment,
  `field_id` int(10) unsigned NOT NULL default '0',
  `subscriber_id` int(10) unsigned NOT NULL default '0',
  `value` char(60) NOT NULL default '',
  PRIMARY KEY  (`data_id`),
  KEY `subscriber_id` (`subscriber_id`,`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");


mysql_query("CREATE TABLE `pommo_subscriber_pending` (
  `pending_id` int(10) unsigned NOT NULL auto_increment,
  `subscriber_id` int(10) unsigned NOT NULL default '0',
  `pending_code` varchar(32) NOT NULL default '',
  `pending_type` enum('add','del','change','password') default NULL,
  `pending_array` text,
  PRIMARY KEY  (`pending_id`),
  KEY `code` (`pending_code`),
  KEY `subscriber_id` (`subscriber_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");

mysql_query("CREATE TABLE `pommo_updates` (
  `serial` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`serial`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1");

echo "<font color='green'>Complete!</font><br><br>";

mysql_query("INSERT INTO `sys_std_widgets` VALUES('100', '100', 'DT Mass Mailer', '../modules/dolphintechs/mail/', '', 'wi-bld-navigation.png', 'Mass Mailer', '', '', '' )");

mysql_query("INSERT INTO `sys_std_pages_widgets` VALUES('100', '1', '100', '100' )");

mysql_query("INSERT INTO `sys_std_pages` VALUES('DT Mass Mailer', 'DT Mass Mailer', 'DT Mass Mailer', '' )");

echo "Moving current persons to mass mailer...";
$result = mysql_query("SELECT * FROM sys_accounts") or die('Error: ' . mysql_error());


while ($row = mysql_fetch_array($result))
{
$subscriber_id = $row['id'];
$email = $row['email'];
$name = $row['name'];
$added = $row['added'];
$timetouched = $row['logged'];

mysql_query("INSERT INTO `pommo_subscribers` VALUES('', '$email', '$name', '$added', '$timetouched','000-000-000', '', '1')") or die (mysql_error());
}
mysql_free_result($result);
echo "<font color='green'>Complete!</font><br><br>";
echo "<font size='5'>DONE!</font><br><br>";
echo "Please do not forget to:<br>";
echo "1. Change the permission of config.php to 644 if your server runs on 666 and 777 permissions<br>";
echo "2. Delete mailinstall.php from modules/dolphintechs/mail/<br>";
echo "To access the mailer just click your new icon in the main studio menu<br>";
echo "that says DT Mass Mailer..... the username and<br>";
echo "The password to the mass mailer is dolphintechs.<br>";
echo "make sure you change the password in setup - configure - users<br><br>";
echo "<br><br>";

?>
		<P><A HREF="index.php"><FONT SIZE="5">Check out the mass mailer now!!</FONT></A></P>	
			</TD>
		</TR>
	</TABLE>
</DIV>

</BODY>

</HTML>


