Eventuell kann das jemand brauchen. Mit dem folgenden PHP Script kann man Werte aus der Datenbank von mailformplus zu powermail 1.x Werten konvertieren.
Das Ganze ist von mir ungetestet und dient nur als einmal auszuführendes Script weswegen der Autor vermutlich auch nicht die Coding Guidelines angewendet oder gleich eine Extension daraus gemacht hat.
Thx goes to Florian P.
<?php
// require_once('login_config.php');
/*
README:
This script is a little helper, to migrate database records being generated by the
mailformplus extension to the powermail database structure.
(tx_thmailformplus_log --> tx_powermail_mails)
All available data from the mailformplus database is copied into the powermail database plus
the information being provided by the manual configuration below. Without the manual configuration,
no proper powermail database records can be generated.
HOW TO USE:
Adapt the configuration block below to your needs, copy the script somewhere to your server and
execute it ones. That's it.
POSSIBLE PROBLEMS:
Due to a different configuration of your Mailformplus-Extension, the data structure may be different
from mine. So the array positions in the content may be not correct. Just adapt them too.
And I had some encoding problems too. But this is configuration dependent again.
ATTENTION/SECURITY RISK:
Using this script without any protection, the whole world can read the username and password of
your database. So before copying it to your server, create a protected folder, so that only you have
access to this script. Or store the configuration within another file, that cannot be accessed by
the whole world. See example below.
*/
// ################################################################################################
// Configuration block - only edit this block unless you know what you are doing :-)
// don't forget the ticks around the text variables
// --> the database-host to connect to
//$typo_db_host = 'your database host';
// --> the database to connect to
//$typo_db = 'your database';
// --> the database-user to connect with
//$typo_db_username = 'your username';
//--> the password of the database user
//$typo_db_password = 'password of db user';
// --> the pageId of the Sysfolder in which powermail safes the emails
$pageId = 99;
// --> the id of the content element/the powermail form
$formId = 465;
// --> the address of the recipient of the mails
$recipient = "'test@test.de'";
// --> the subject of the recipient mails
$subject_r = "'[Contact]: ###UID1### - ###UID3###'";
// --> the useragent of the senders browser; here for example the one from IE7
$userAgent = "'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'";
// --> the referer/the site the mail was sent from
$referer = "'http://www.mydomain.com/mailformular.123.html'";
$uidName = "uid1";
$uidMailaddress = "uid2";
$uidSubject = "uid3";
$uidContent = "uid4";
$uidCaptcha = "uid6";
// ################################################################################################
mysql_connect($typo_db_host, $typo_db_username, $typo_db_password)
or die ("No connection possible.");
mysql_select_db($typo_db)
or die ("Specified database does not exist.");
$result = mysql_query("SELECT uid, pid, submittedfields, logdate FROM tx_thmailformplus_log ORDER BY uid");
echo "Number of rows read: ".mysql_num_rows($result)."<br/>";
$index = 0;
while($row = mysql_fetch_object($result))
{
$uid = $row->uid;
$pid = 99;
$logdate = $row->logdate;
$cleanContent = str_replace("~","",$row->submittedfields);
$contents = split(";", $cleanContent, 20);
// sometimes the PHPSESSID is saved by mailformplus, so we have to adapt our array positions
if ($contents[0] == "PHPSESSID")
$adjustment = 2;
else
$adjustment = 0;
$tstamp = $logdate;
$crdate = $logdate;
$userid = 0;
$deleted = 0;
$hidden = 0;
$sender = "'".$contents[13+$adjustment]."'";
// replace ticks, prevent invalid SQL-Syntax
$payload = str_replace("'","",$contents[15+$adjustment]);
// replace the linefeeds with the correct one for powermail
$payload = str_replace("\r\n","<br/>", $payload);
$content = "'<p class=\"bodytext\">".$payload."</p>'";
$piVars = "'<piVars>\n <".$uidName.">".str_replace("'","",$contents[12+$adjustment])."</".$uidName.">\n <".$uidMailaddress.">".str_replace("'","",$contents[13+$adjustment])."</".$uidMailaddress.">\n <".$uidSubject.">".str_replace("'","",$contents[14+$adjustment])."</".$uidSubject.">\n <".$uidContent.">".str_replace("<br/>","",$payload)."</".$uidContent.">\n <".$uidCaptcha.">".$contents[16+$adjustment]."</".$uidCaptcha.">\n</piVars>'";
$feuser = 0;
$senderip = "'0.0.0.0'";
$sptz = "''";
$additional = "''";
$sql = "INSERT INTO tx_powermail_mails (uid, pid, tstamp, crdate, cruser_id, deleted, hidden, formid, recipient, subject_r, sender, content, piVars, feuser, senderIP, UserAgent, Referer, SP_TZ, Additional) VALUES
($uid, $pid, $tstamp, $crdate, $userid, $deleted, $hidden, $formId, $recipient, $subject_r, $sender, $content, $piVars, $feuser, $senderip, $userAgent, $referer, $sptz, $additional)";
if (!mysql_query($sql))
{
echo "UID: " . $uid . "<br/>";
echo "Content: " . $content . "<br/>";
die("Error: ". mysql_error()."<br/>");
}
$index++;
}
echo "Skript finished. Copied ". $index ." records.";
/**
*################################################
* Skript start
*
* // put this into the first line of migrator.php
* require_once('<name of this script>');
*
*
* <?php
* if (eregi("<name of this script>", $_SERVER['PHP_SELF'])) die("No Access");
*
* $typo_db_username = 'your username';
* $typo_db = 'your database';
* $typo_db_password = 'password of database user';
* $typo_db_host = 'database hostname';
*
* ?>
**/
?>
Viel Spaß,
Grüße, Alex