Make WordPress Core

Changeset 323


Ignore:
Timestamp:
08/20/2003 10:59:20 PM (23 years ago)
Author:
saxmatt
Message:

Password protected posts!

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2template.functions.php

    r308 r323  
    523523        global $id, $post;
    524524        $output = stripslashes($post->post_title);
    525         return($output);
     525        if (!empty($post->post_password)) { // if there's a password
     526                $output = 'Protected: ' . $output;
     527        }
     528        return $output;
    526529}
    527530
     
    581584function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
    582585        global $id, $post, $more, $c, $withcomments, $page, $pages, $multipage, $numpages;
    583         global $HTTP_SERVER_VARS, $preview;
     586        global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview;
    584587        global $querystring_start, $querystring_equal, $querystring_separator;
    585588    global $pagenow;
    586589        $output = '';
     590       
     591        if (!empty($post->post_password)) { // if there's a password
     592                if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie
     593                        $output = "<form action='$siteurl/wp-pass.php' method='post'>
     594                        <p>This post is password protected. To view it please enter your password below:</p>
     595                        <p><label>Password: <input name='post_password' type='text' size='20' /></label> <input type='submit' name='Submit' value='Submit' /></p>
     596                        </form>
     597                        ";
     598                        return $output;
     599                }
     600        }
     601
    587602        if ($more_file != '') {
    588603                $file = $more_file;
     
    667682function get_the_excerpt($fakeit = false) {
    668683        global $id, $post;
    669         global $HTTP_SERVER_VARS, $preview;
     684        global $HTTP_SERVER_VARS, $HTTP_COOKIE_VARS, $preview;
    670685        $output = '';
    671686        $output = $post->post_excerpt;
     687        if (!empty($post->post_password)) { // if there's a password
     688                if ($HTTP_COOKIE_VARS['wp-postpass'] != $post->post_password) {  // and it doesn't match the cookie
     689                        $output = "There is no excerpt because this is a protected post.";
     690                        return $output;
     691                }
     692        }
    672693    //if we haven't got an excerpt, make one in the style of the rss ones
    673694    if (($output == '') && $fakeit) {
Note: See TracChangeset for help on using the changeset viewer.