Hallo zusammen!
Ich erlaube mir mal ganz frech :wink: mit meinem ersten Forumsbeitrag einen etwas älteren Beitrag aus der Versenkung zu holen.
Ich habe die Betreuung eine wordpress-Seite übernommen, bin aber leider (noch)nicht soooo fit, was php angeht bzw dessen Aufbau.
Ich versuche gerade eine Newsletter mit dem Plugin "mailing-list" zum Laufen zu bekommen.
Leider wird das ganze so http://www.stuv-mannheim.de/subscribe.php angezeigt. Bei Firefox kommt oben noch ein "Balken" hinzu, der sich über die komplette Seitenbreite zieht.
Ich ahne, dass das Problem wieder mit Seitenaufteilung zu tun hat, weiß aber nicht wie ich es beheben kann.
Wer hilft?
Vielen Dank im Voraus
Gruß vG
Quelltext der subsribe.php:
PHP
<?php
require_once('./wp-blog-header.php');
get_header();
?>
<style type="text/css">
.error {border: 1px solid #ff0000; margin: 10px auto;}
.result {border: 1px solid #6699cc; margin: 10px auto;}
.error p, .result p {text-align: center;}
#subscribe {margin: 20px auto;}
#subscribeform {margin: 20px auto;}
input.subscribe {width: 170px;}
</style>
<?php
$confirmation = '';
if(isset($_POST['confirmation'])) {
$confirmation = $_POST['confirmation'];
}
if ($confirmation == 'check') {
ml_confirmation($action);
}
$subscribe_cache = 'subscribe';
//----------------------------------------< Action Program >----------------------------------------//
switch ($action) {
case 'subscribe':
$result = __("[b]ERROR[/b]: ").__("Couldn't register you!", "mailing-list")."
\n";
$result .= __("Please try later to subscribe.", "mailing-list");
if (!isset($_GET['user'])) {
ml_check_form();
is_email($mluser_email);
$result = ml_check_user($mluser_email);
}
else {
$file = $subscribe_cache.'/'.$_SERVER['REMOTE_ADDR'].'.ml.php';
if (is_file($file)) {
include($file);
if ($pass == substr($_GET['user'], 0, 8)) {
$result = $wpdb->query("INSERT INTO $wpdb->mailinglist
(mluser_firstname, mluser_lastname, mluser_address, mluser_email, mluser_phone, mluser_newsletter)
VALUES
('$mluser_firstname', '$mluser_lastname', '$mluser_address', '$mluser_email', '$mluser_phone', '1')");
if ($result != false) {
$result = __("Welcome to the mailing-list! You have been successfully subscribed.", "mailing-list")."
\n";
$result .= __("You will now receive email notifications whenever new posts are added.", "mailing-list");
}
}
}
}
ml_subscribe_page();
break;
case 'newsletter':
if (isset($_GET['user'])) {
$mluser_email = substr($_GET['user'], 8);
$emailthere = $wpdb->get_var("SELECT ID FROM $wpdb->mailinglist WHERE mluser_email='$mluser_email'");
$pass = strrev(substr(md5($emailthere), 2,8));
if ($pass == substr($_GET['user'], 0, 8)) {
$result = $wpdb->query("UPDATE $wpdb->mailinglist SET mluser_newsletter=1 WHERE ID=$emailthere");
if ($result != false) {
$result = __("You have enable the newsletter.", "mailing-list").' ';
$result .= __("You will now receive email notifications whenever new posts are added.", "mailing-list");
}
if ($result == false) {
$result = $wpdb->query("UPDATE $wpdb->mailinglist SET mluser_newsletter=0 WHERE ID=$emailthere");
if ($result != false) {
$result = __("You have disable the newsletter.", "mailing-list").' ';
$result .= __("You won't receive email notifications whenever new posts are added but you can receive admin notifications.", "mailing-list");
}
}
}
if ($result == false) {$result = __("[b]ERROR[/b]: ").__("Submit form to receive another confirmation email.", "mailing-list");}
}
ml_check_page($action);
break;
case 'unsubscribe':
if (isset($_GET['user'])) {
$mluser_email = substr($_GET['user'], 8);
$emailthere = $wpdb->get_var("SELECT ID FROM $wpdb->mailinglist WHERE mluser_email='$mluser_email'");
$pass = strrev(substr(md5($emailthere), 2,8));
if ($pass == substr($_GET['user'], 0, 8)) {
$result = $wpdb->query("DELETE FROM $wpdb->mailinglist WHERE ID=$emailthere");
if ($result != false) {$result = __("You have been unsubscribed", "mailing-list");}
}
if ($result == false) {$result = __("[b]ERROR[/b]: ").__("Submit form to receive another confirmation email.", "mailing-list");}
}
$result = ml_check_page($action);
break;
default:
ml_subscribe_page();
break;
}
get_sidebar();
get_footer();
//------------------------------------------- End of Action Program ------------------------------------//
//----------------------------------------< Main Page >---------------------------------------------//
function ml_subscribe_page() {
global $result;
ml_subscribe_result($result);
?>
<div id="subscribe">
<h2>Subscribe to Mailing-List</h2>
<form action="subscribe.php" method="post" name="subscribeform" id="subscribeform">
<input type="hidden" name="action" value="subscribe" />
<table cellspacing="2" cellpadding="5">
<tr>
<th scope="row" width="33%"><?php _e("First Name", "mailing-list") ?></th>
<td><input class="subscribe" name="firstname" type="text" id="firstname" /></td>
</tr>
<tr>
<th scope="row"><?php _e("Last Name", "mailing-list") ?></th>
<td><input class="subscribe" name="lastname" type="text" id="lastname" /></td>
</tr>
<tr>
<th scope="row"><?php _e("Address", "mailing-list") ?></th>
<td><input class="subscribe" name="address" type="text" id="address" /></td>
</tr>
<tr>
<th scope="row"><?php _e("E-mail", "mailing-list") ?></th>
<td><input class="subscribe" name="email" type="text" id="email" /></td>
</tr>
<tr>
<th scope="row"><?php _e("Phone", "mailing-list") ?></th>
<td><input class="subscribe" name="phone" type="text" id="phone" /></td>
</tr>
<tr>
<th></th>
<td align="right">
<input name="submit_user" type="submit" id="submit_user" value="<?php _e("Subscribe", "mailing-list")?>" />
</td>
</tr>
</table>
</form>
<?php
$note = __("[b]Note:[/b] This mailing-list is only...", "mailing-list");
$note .= get_settings('blogname').".
\n";
$note .= __("Your email address will not be shared with any other party.", "mailing-list");
echo '
'.$note."</p>\n";
?>
</div>
<?php
}
//------------------------------------------- End of Main Page -----------------------------------------//
//----------------------------------------< Newsletter Page >---------------------------------------//
function ml_check_page($action) {
global $result;
ml_subscribe_result($result);
?>
<div id="subscribe">
<?php _e("You can disable the newsletter and receive only admin notifications or you can unsubscribe from the mailing-list and receive no more notifications from ", "mailing-list");
echo get_settings('blogname') ?></p>
<form action="subscribe.php" method="post" name="subscribeform" id="subscribeform">
<input type="hidden" name="confirmation" value="check" />
<table cellspacing="2" cellpadding="5">
<tr>
<th scope="row"><?php _e("E-mail", "mailing-list") ?></th>
<td><input class="subscribe" name="email" type="text" id="email" /></td>
</tr>
<tr>
<th></th>
<td>
<label><input name="action" value="newsletter" type="radio"<?php if ($action == 'newsletter') echo ' checked="checked"';?> /><?php _e("Enable/Disable the newsletter", "mailing-list") ?>
</label>
<label><input name="action" value="unsubscribe" type="radio"<?php if ($action == 'unsubscribe') echo ' checked="checked"';?> /><?php _e("Unsubscribe", "mailing-list") ?></label>
</td>
</tr>
</table>
<p class="submit">
<input name="adduser" type="submit" id="check" value="<?php _e("Send Confirmation Mail", "mailing-list")?>" />
</p>
</form>
<?php
$note = __("[b]Note:[/b] This mailing-list is only used to inform you when new posts are added and to send you admin notifications about ", "mailing-list");
$note .= get_settings('blogname').".
\n";
$note .= __("Your email address will not be shared with any other party.", "mailing-list");
echo '
'.$note."</p>\n";
?>
</div>
<?php
}
//------------------------------------------- End of Newsletter Page ------------------------------------//
//------------------------------< function confirmation >-----------------------//
function ml_confirmation($action) {
global $wpdb, $result;
$mluser_email = wp_specialchars(trim($_POST['email']));
if (!is_email($mluser_email)) {
$result = __("[b]ERROR[/b]: ").__("the email address isn't correct!", "mailing-list");
return;
}
else {
$confirmation_data = $wpdb->get_results("SELECT ID, mluser_newsletter FROM $wpdb->mailinglist WHERE mluser_email='$mluser_email'");
if ($confirmation_data[0]->ID == 0) {
$result = __("[b]ERROR[/b]: ").__("This email is not in the mailing-list!", "mailing-list");
return;
}
}
$pass = strrev(substr(md5($confirmation_data[0]->ID), 2,8));
$link = get_settings('siteurl').'/subscribe.php?action='.$action.'&user='.$pass.$mluser_email;
$title = __("Confirmation email: ", "mailing-list");
$format = get_option('ml_sending_format');
if ($action == 'unsubscribe') {
$title .= __("Unsubscribe", "mailing-list");
$content = __("You have requested to be unsubscribed from the mailing-list and receive no more notifications from ", "mailing-list");
}
elseif ($confirmation_data[0]->mluser_newsletter) {
$title .= __("Disable the newsletter", "mailing-list");
$content = __("You have requested to disable the newsletter and receive no more new posts notifications from ", "mailing-list");
}
else {
$title .= __("Enable the newsletter", "mailing-list");
$content = __("You have requested to enable the newsletter and receive new posts notifications from ", "mailing-list");
}
$content .= get_settings('blogname').'. ';
$content .= __("Please visit the URL below to confirm. Thanks!", "mailing-list")."\n\n";
if ($format) {
$content .= '[url="'.$link.'"]'.__("Confirmation link", "mailing-list").'[/url]';
}
else {
$content .= $link;
}
$content .= "\n\n";
$content .= __("If you did not ask this, you can safely disregard this message.", "mailing-list")."\n";
$content .= __("We apologize for your trouble.", "mailing-list");
if ($format) {$content = ereg_replace("\n", "
" ,$content);}
$admin = get_userdata(1);
$result = ml_send_mail($admin->user_email, $mluser_email, '', '', $title, $content, $format);
if ($result == true) {
$result = __("A confirmation email has been sent to you.", "mailing-list");
}
else {
$result = __("[b]ERROR[/b]: ").__("Couldn't send you the confirmation email!", "mailing-list");
}
return;
}
//------------------------------- End of function confirmation ---------------------//
//------------------------------< function check user >-------------------------//
function ml_check_user($mluser_email) {
global $wpdb, $mluser_firstname, $mluser_lastname, $mluser_address, $mluser_email, $mluser_phone, $subscribe_cache, $result;
$emailthere = $wpdb->get_var("SELECT ID FROM $wpdb->mailinglist WHERE mluser_email='$mluser_email'");
if ($emailthere != 0) {
$result = __("[b]ERROR[/b]: ").__("This email is already in te mailing-list!", "mailing-list");
return $result;
}
$pass = substr(md5(rand(10000, 99999)), 2,8);
$userfile = $subscribe_cache.'/'.$_SERVER['REMOTE_ADDR'].'.ml.php';
$files = glob($subscribe_cache.'/*'.'.ml.php');
if (!empty($files)) {
foreach ($files as $file) {
if (date('U', filemtime($file)) + 300 < time()) {
unlink($file);
}
}
}
if (is_file($userfile)) {
$result = __("A confirmation email has been already sent to you!", "mailing-list")."
\n";
$result .= __("Please try later to subscribe.", "mailing-list");
return $result;
}
$file_content = '<?php'."\n";
$file_content .= '$pass = \''.$pass."';\n";
$file_content .= '$mluser_firstname = \''.$mluser_firstname."';\n";
$file_content .= '$mluser_lastname = \''.$mluser_lastname."';\n";
$file_content .= '$mluser_address = \''.$mluser_address."';\n";
$file_content .= '$mluser_email = \''.$mluser_email."';\n";
$file_content .= '$mluser_phone = \''.$mluser_phone."';\n";
$file_content .= '?>';
if (!is_dir($subscribe_cache)) { mkdir($subscribe_cache, 0777); }
$fp = fopen($userfile,'w+');
fwrite($fp, $file_content);
fclose($fp);
$link = get_settings('siteurl').'/subscribe.php?action=subscribe&user='.$pass.$_SERVER['REMOTE_ADDR'];
$title = __("Confirmation email: ", "mailing-list").__("Subscribe", "mailing-list");
$format = get_option('ml_sending_format');
$content = __("You have requested to be subscribed to the mailing-list to receive notifications from ", "mailing-list");
$content .= get_settings('blogname').".\n";
$content .= __("Please visit the URL below to confirm. Thanks!", "mailing-list")."\n\n";
if ($format) {
$content .= '[url="'.$link.'"]'.__("Confirmation link", "mailing-list").'[/url]';
}
else {
$content .= $link;
}
$content .= "\n\n";
$content .= __("If you did not ask this, you can safely disregard this message.", "mailing-list")."\n";
$content .= __("We apologize for your trouble.", "mailing-list");
$admin = get_userdata(1);
$result = ml_send_mail($admin->user_email, $mluser_email, '', '', $title, $content, $format);
if ($result == true) {
$result = __("A confirmation email has been sent to you.", "mailing-list");
}
else {
$result = __("[b]ERROR[/b]: ").__("Couldn't send you the confirmation email!", "mailing-list");
unlink($userfile);
}
return $result;
}
//------------------------------- End of function check user -----------------------//
//------------------------------< function action result >----------------------//
function ml_subscribe_result($result) {
if ($result) {
if(substr($result, 0, 11) == '[b]ERR') {
echo '<div class="error">
'.$result.'</p></div>';
}
else {
echo '<div class="result">
'.$result.'</p></div>';
}
}
}
//------------------------------- End of function action result --------------------//
?>
Alles anzeigen