Viewing 11 replies - 1 through 11 (of 11 total)
  • I don’t know anything about the plugin, but could you not just paste the code for the plugin into a WordPress ‘Page’? This would keep all your blog’s css styling.

    @jpettit,
    I don’t think so. It has to be some mess with the installation of the plugin or with the settings, because normally thesubscribe.php page picks up the header and the footer of the blog, keeping all the styling.

    Thread Starter adeco2

    (@adeco2)

    I reinstalled the plugin and I get the same crxp.

    the subscribe.php starts like this:

    require_once(a€?./wp-blog-header.phpa€?);
    $admin = get_userdata(1);

    $s2 = get_option(a€?s2_optionsa€?);

    // the database table to use
    $s2_table = $table_prefix . a€?subscribe2a€3;

    I’m not sure wp-header.php is the header being used with my theme. But I changed it, and it gets worse. Then it says that the new header has bad calls.

    Still trying to figure out what’s going on

    Wp-blog-header.php (not wp-header.php) is different, completely different, from the header.php used in themes.

    Your subscribe.php page is missing the beginning and end, namely <html>, <head> (which includes the path to the stylesheet…), <body> and the closing tags (after footer).

    Undo (or start over) whatever you did with wp-blog-header.php. I’d be interested to see the page before it “got worse” as you said.

    Thread Starter adeco2

    (@adeco2)

    Well, I must point out that I did not edit ‘wp-blog-header.php’. I edited ‘subscribe.php’ to point to a different file, namely
    ‘/wp-content/themes/connections/header.php’,
    which is the theme header.

    What you can see here:
    [Link removed by request]

    is the best I’ve seen.

    I tried at some point to include a reference to the stylesheet in ‘subscribe.php’, but it wasn’t successful.

    If the file is the following,
    wp-content/themes/connections/style.css
    how would you add it to the file.

    The whole “subscribe.php” reads as follows:

    <?php

    // Subscribe2
    // Copyright 2004 Scott Merrill [email protected]
    // Distributed under the terms of the GNU Public License
    // https://www.gnu.org/copyleft/gpl.html

    require_once (‘./wp-blog-header.php’);
    $admin = get_userdata(1);

    $s2 = get_option(‘s2_options’);

    // the database table to use
    $s2_table = $table_prefix . “subscribe2”;

    $email = (isset($_POST[’email’])) ? $_POST[’email’] : ”;
    $action = (isset($_POST[‘action’])) ? $_POST[‘action’] : ”;
    $hash = (isset($_GET[‘x’])) ? $_GET[‘x’] : ”;

    if (” != $hash) {
    $foo = explode(‘x’, $hash);
    $action = $foo[0];
    $id = $foo[2];
    $sql = “SELECT email FROM ” . $s2_table . ” WHERE id='” . $id . “‘”;
    $email = $wpdb->get_var($sql);
    if (” == $email) {
    main(‘invalid’);
    }
    if (‘a’ == $action) {
    if (‘2’ == s2_check($email)) {
    s2_confirm($email);
    main(‘added’);
    } else {
    main(‘already_there’);
    }
    } elseif (‘d’ == $action) {
    s2_delete($email);
    main(‘deleted’);
    } else {
    // safety valve
    main();
    }
    }

    if ( (” != $action) && ( (” == $email) || (! is_email($email)) )) {
    main(‘invalid’);
    }

    if ( strtolower($admin->user_email) == strtolower($email) ) {
    main(‘self’);
    }

    if (‘add’ == $action) {
    if (‘0’ !== s2_check($email)) {
    main(‘already_there’);
    }
    s2_add($email);
    s2_send_confirmation ($email, ‘add’);
    main(‘add_confirm’);
    }elseif (‘delete’ == $action) {
    if (‘0’ === s2_check($email)) {
    main(‘not_there’);
    }
    s2_send_confirmation ($email, ‘delete’);
    main(‘delete_confirm’);
    } else {
    main();
    }

    /////////////////
    // *** main() ***
    // display the main page
    /////////////////
    function main($doing = ”) {
    global $s2;

    // Display the page
    get_header();
    get_sidebar();
    // display a message, depending on what was passed to main()
    if (” == $doing) {
    $doing = ‘welcome’;
    }
    echo “<div id=’content’ class=’narrowcolumn’><div class=’post’>” . stripslashes($s2[“s2_$doing”]) . “”;
    if ( (‘not_there’ == $doing) || (‘already_there’ == $doing) || (‘self’ == $doing) || (‘invalid’ == $doing) || (‘welcome’ == $doing) ) {
    ?>
    <form method=”post”>
    El vostre e-mail: <input type=”text” name=”email” value=”” size=”20″ /> 
    <input type=”radio” name=”action” value=”add” checked=”checked” />Donar-lo d’alta
    <input type=”radio” name=”action” value=”delete” />Donar-lo de baixa 
    <input type=”submit” value=”Enviar!” />
    </form>

    <?php
    }
    echo “Nota: ” . get_settings(‘blogname’). ” valora la privacitat personal.
    “;
    echo “Aquesta utilitat ??s nom??s per a informar els subscriptors de les actualitzacions de la p??gina.
    “;
    echo “La vostra adre?§a de correu electr?2nic no es compartir?? amb ning?o ni ser?? utilitzada per res m??s.”;
    echo “Tornar a ” . get_settings(‘blogname’) . “\n\n”;
    ?>
    </div>
    </div>
    <?php
    get_footer();
    die;
    } // main()

    ////////////////////
    // *** s2_check() ***
    // check whether an email address exists in the database
    // return values:
    // 0 == not present
    // 1 == present, and confirmed
    // 2 == present, and not confirmed
    ////////////////////
    function s2_check ($email = ”) {
    global $wpdb, $s2_table;

    if ( (” == $email) || (! is_email($email)) ) {
    // no valid email, so bail out
    return ‘0’;
    }
    $query = “SELECT * FROM ” . $s2_table . ” WHERE email='” . $email . “‘”;
    $foo = $wpdb->get_row($query);

    if (‘1’ === $foo->active) {
    return ‘1’;
    } elseif (‘0’ === $foo->active) {
    return ‘2’;
    } else {
    return ‘0’;
    }
    } // s2_check

    ///////////////////
    // *** s2_add() ***
    // add an email address to the database with a status of “0” (unconfirmed)
    ///////////////////
    function s2_add ($email = ”) {
    global $wpdb, $s2_table;
    if ( (” == $email) || (! is_email($email)) ) {
    // no valid email, so bail out
    return;
    }
    // check to make sure the address isn’t already there
    if (‘0’ != s2_check($email)) {
    // user exists, so bail out
    return ‘1’;
    }
    $sql = “INSERT INTO ” . $s2_table . ” (email, active) VALUES (‘” . $email . “‘, ‘0’)”;
    $result = $wpdb->query($sql);
    } // s2_add

    ///////////////////////
    // *** s2_confirm() ***
    // change the status of an email address in the database to “1” (confirmed)
    ///////////////////////
    function s2_confirm ($email = ”) {
    global $s2, $wpdb, $s2_table;

    if ( (” == $email) || (! is_email($email)) ) {
    // no valid email, so bail out
    return;
    }

    $admin = get_userdata(1);

    if (‘2’ == s2_check($email)) {
    $sql = “UPDATE ” . $s2_table . ” SET active = ‘1’ WHERE email = ‘” . $email . “‘”;
    $result = $wpdb->query($sql);
    $mailtext = “The following email address has successfully subscribed to your blog:\n\n $email\n”;
    $mailheaders = “From: $admin->user_nickname <$admin->user_email>”;
    mail($admin->user_email, stripslashes($s2[‘s2_subscribed_admin_subject’]), $mailtext, $mailheaders);
    }
    } // s2_confirm

    //////////////////////
    // *** s2_delete() ***
    // remove an email address from the database
    //////////////////////
    function s2_delete ($email = ”) {
    global $s2, $wpdb, $s2_table;

    if ( (” == $email) || (! is_email($email)) ) {
    // no valid email, so bail out
    return;
    }
    if (‘0’ === s2_check($email)) {
    // user does not exist, bail out
    return;
    }
    $sql = “DELETE FROM ” . $s2_table . ” WHERE email = ‘” . $email . “‘”;
    $result = $wpdb->query($sql);

    $admin = get_userdata(1);

    $mailtext = “The following email address has successfully unsubscribed from your blog:\n\n $email\n”;
    $mailheaders = “From: $admin->user_nickname <$admin->user_email>”;
    mail($admin->user_email, $s2[‘s2_unsubscribed_admin_subject’], $mailtext, $mailheaders);
    } // s2_delete

    ///////////////////////////
    // *** s2_send_confirmaion() ***
    // send a confirmation email to an address
    ///////////////////////////
    function s2_send_confirmation ($email = ”, $action = ”) {
    global $wpdb, $s2_table, $s2;

    if ( (” == $email) || (! is_email($email)) || (” == $action) ) {
    // no valid email or action, so bail out
    return;
    }

    $sql = “SELECT id FROM ” . $s2_table . ” WHERE email = ‘” . $email . “‘”;
    $id = $wpdb->get_var($sql);

    if (‘add’ == $action) {
    // link to confirm their address
    $link = get_settings(‘siteurl’) . “/” . basename($_SERVER[‘PHP_SELF’]) . “?x=ax” . md5($email) . “x” . $id;
    } elseif (‘delete’ == $action) {
    // link to confirm their address
    $link = get_settings(‘siteurl’) . “/” . basename($_SERVER[‘PHP_SELF’]) . “?x=dx” . md5($email) . “x” . $id;
    }

    $admin = get_userdata(1);

    $body = stripslashes(str_replace(“LINK”, $link, $s2[‘s2_confirm_email’]));
    $body = str_replace(“BLOGNAME”, get_settings(‘blogname’), $body);
    $body = str_replace(“MYNAME”, $admin->user_nickname, $body);
    $body = str_replace(“EMAIL”, $admin->user_email, $body);

    $subject = stripslashes(str_replace(“BLOGNAME”, get_settings(‘blogname’), $s2[‘s2_confirm_subject’]));
    $subject = str_replace(“MYNAME”, $admin->user_nickname, $subject);
    $subject = str_replace(“EMAIL”, $admin->user_email, $subject);

    $mailheaders = “From: $admin->user_nickname <$admin->user_email>”;
    mail ($email, $subject, $body, $mailheaders);
    } // s2_send_confirmation()

    ?>

    Thread Starter adeco2

    (@adeco2)

    sorry double post

    Thread Starter adeco2

    (@adeco2)

    Sorry for this massive post.

    My typicall stylesheet call reads as follows.

    <style type=”text/css” media=”screen”>
    @import url( <?php bloginfo(‘stylesheet_url’); ?> );

    But if pasted into the subscribe.php template, then all is $”%?·(%$ up and the only thing I see is an error message.

    OK, the problem is that Connections uses an unusual template structure. Usually the header.php includes everything before the content (including doctype, html, head, body tags) and everything after the sidebar/content (including closing tags for several divs, body and html).

    So now you’d need to get everything before get_header(); and after get_footer(); from index.php to subscribe.php. You can add it in the PHP code (in subscribe.php) but if you’re not familiar with the syntax and what you’d need to change to get it working I suggest you copy the codes to two files and add include("name-of-the-file-where-doctype-etc-is"); right before get_header(); in the subscribe.php code (below the block *** main() ***) and the same thing with the file where the footer stuff (see index.php after get_footer()) is — although that is easy to just add directly right after get_footer() (again, in subscribe.php):
    echo "</div> </div> </body> </html>";

    If that sounds bad and I’m sure it does because I’m explaining it badly ?? , I (for instance) can integrate the code bits you need in the subscribe.php. But not right this minute.

    As I was waiting for the bus I started thinking… maybe you could add the necessary code pretty easily in the middle of the PHP code, like this
    /////////////////
    // *** main() ***
    // display the main page
    /////////////////
    function main($doing = '') {
    global $s2;
    ?> <-- add that
    DOCTYPE ETC HERE
    <?php //subscribe.php continues
    // Display the page
    get_header();
    get_sidebar();


    and then
    <?php
    get_footer();
    echo "</div> </div> </body> </html>";
    die;
    } // main()

    Ah well, just rambling.

    Thread Starter adeco2

    (@adeco2)

    Thanks Minna, I got substantial improvement, as you can see.

    [Link removed by request]

    Another question. I may seem trivial, but can’t get it done.

    How do I pull down the text and the form, so it’s not attached to the headder.

    include(‘./conn-head.php’);
    get_header();

    // display a message, depending on what was passed to main()
    if (” == $doing) {
    $doing = ‘welcome’;
    }

    echo “<div class=’post’>” . stripslashes($s2[“s2_$doing”]) . “”;
    if ( (‘not_there’ == $doing) || (‘already_there’ == $doing) || (‘self’ == $doing) || (‘invalid’ == $doing) || (‘welcome’ == $doing) ) {
    ?>
    <form method=”post”>
    El vostre e-mail: <input type=”text” name=”email” value=”” size=”20″ /> 

    I’d imagine you want to do the changes only on this page, so editing the stylesheet would affect the entire site. So, you could put a style attribute to the <div class="post"> tag that is around the “La subscripci?3…”, so it would be something like <div class="post" style="padding-top:20px;">, with whichever amount of pixels you find appropriate.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Screwed header’ is closed to new replies.