Dotclear


Ignore:
Timestamp:
08/16/12 14:13:27 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
sexy
Message:

Entries passwords will be a dedicated plugin.

Location:
plugins/pages
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/pages/_public.php

    r727 r877  
    6161               { 
    6262                    $post_id = $_ctx->posts->post_id; 
    63                     $post_password = $_ctx->posts->post_password; 
    64                      
    65                     # Password protected entry 
    66                     if ($post_password != '' && !$_ctx->preview) 
    67                     { 
    68                          # Get passwords cookie 
    69                          if (isset($_COOKIE['dc_passwd'])) { 
    70                               $pwd_cookie = unserialize($_COOKIE['dc_passwd']); 
    71                          } else { 
    72                               $pwd_cookie = array(); 
    73                          } 
    74                           
    75                          # Check for match 
    76                          if ((!empty($_POST['password']) && $_POST['password'] == $post_password) 
    77                          || (isset($pwd_cookie[$post_id]) && $pwd_cookie[$post_id] == $post_password)) 
    78                          { 
    79                               $pwd_cookie[$post_id] = $post_password; 
    80                               setcookie('dc_passwd',serialize($pwd_cookie),0,'/'); 
    81                          } 
    82                          else 
    83                          { 
    84                               self::serveDocument('password-form.html','text/html',false); 
    85                               return; 
    86                          } 
    87                     } 
    88                      
    89                     $post_comment = 
    90                          isset($_POST['c_name']) && isset($_POST['c_mail']) && 
    91                          isset($_POST['c_site']) && isset($_POST['c_content']) && 
    92                          $_ctx->posts->commentsActive(); 
    93                      
    94                     # Posting a comment 
    95                     if ($post_comment) 
    96                     { 
    97                          # Spam trap 
    98                          if (!empty($_POST['f_mail'])) { 
    99                               http::head(412,'Precondition Failed'); 
    100                               header('Content-Type: text/plain'); 
    101                               echo "So Long, and Thanks For All the Fish"; 
    102                               # Exits immediately the application to preserve the server. 
    103                               exit; 
    104                          } 
    105                           
    106                          $name = $_POST['c_name']; 
    107                          $mail = $_POST['c_mail']; 
    108                          $site = $_POST['c_site']; 
    109                          $content = $_POST['c_content']; 
    110                          $preview = !empty($_POST['preview']); 
    111                           
    112                          if ($content != '') 
    113                          { 
    114                               if ($core->blog->settings->system->wiki_comments) { 
    115                                    $core->initWikiComment(); 
    116                               } else { 
    117                                    $core->initWikiSimpleComment(); 
    118                               } 
    119                               $content = $core->wikiTransform($content); 
    120                               $content = $core->HTMLfilter($content); 
    121                          } 
    122                           
    123                          $_ctx->comment_preview['content'] = $content; 
    124                          $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; 
    125                          $_ctx->comment_preview['name'] = $name; 
    126                          $_ctx->comment_preview['mail'] = $mail; 
    127                          $_ctx->comment_preview['site'] = $site; 
    128                           
    129                          if ($preview) 
    130                          { 
    131                               # --BEHAVIOR-- publicBeforeCommentPreview 
    132                               $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 
    133                                
    134                               $_ctx->comment_preview['preview'] = true; 
    135                          } 
    136                          else 
    137                          { 
    138                               # Post the comment 
    139                               $cur = $core->con->openCursor($core->prefix.'comment'); 
    140                               $cur->comment_author = $name; 
    141                               $cur->comment_site = html::clean($site); 
    142                               $cur->comment_email = html::clean($mail); 
    143                               $cur->comment_content = $content; 
    144                               $cur->post_id = $_ctx->posts->post_id; 
    145                               $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 
    146                               $cur->comment_ip = http::realIP(); 
    147                                
    148                               $redir = $_ctx->posts->getURL(); 
    149                               $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; 
    150                                
    151                               try 
    152                               { 
    153                                    if (!text::isEmail($cur->comment_email)) { 
    154                                         throw new Exception(__('You must provide a valid email address.')); 
    155                                    } 
    156                                     
    157                                    # --BEHAVIOR-- publicBeforeCommentCreate 
    158                                    $core->callBehavior('publicBeforeCommentCreate',$cur); 
    159                                    if ($cur->post_id) {                          
    160                                         $comment_id = $core->blog->addComment($cur); 
    161                                     
    162                                         # --BEHAVIOR-- publicAfterCommentCreate 
    163                                         $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 
    164                                    } 
    165                                     
    166                                    if ($cur->comment_status == 1) { 
    167                                         $redir_arg = 'pub=1'; 
    168                                    } else { 
    169                                         $redir_arg = 'pub=0'; 
    170                                    } 
    171                                     
    172                                    header('Location: '.$redir.$redir_arg); 
    173                               } 
    174                               catch (Exception $e) 
    175                               { 
    176                                    $_ctx->form_error = $e->getMessage(); 
    177                                    $_ctx->form_error; 
    178                               } 
    179                          } 
    180                     } 
    181                      
    18263                    # The entry 
    18364                    $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates'); 
  • plugins/pages/list.php

    r578 r877  
    7979          } 
    8080           
    81           $protected = ''; 
    82           if ($this->rs->post_password) { 
    83                $protected = sprintf($img,__('protected'),'locker.png'); 
    84           } 
    85            
    8681          $selected = ''; 
    8782          if ($this->rs->post_selected) { 
     
    109104          '<td class="nowrap">'.$this->rs->nb_comment.'</td>'. 
    110105          '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'. 
    111           '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'. 
     106          '<td class="nowrap status">'.$img_status.' '.$selected.' '.$attach.'</td>'. 
    112107          '</tr>'; 
    113108           
  • plugins/pages/page.php

    r854 r877  
    1818$post_dt = ''; 
    1919$post_format = $core->auth->getOption('post_format'); 
    20 $post_password = ''; 
    2120$post_url = ''; 
    2221$post_lang = $core->auth->getInfo('user_lang'); 
     
    9594          $post_dt = date('Y-m-d H:i',strtotime($post->post_dt)); 
    9695          $post_format = $post->post_format; 
    97           $post_password = $post->post_password; 
    9896          $post_url = $post->post_url; 
    9997          $post_lang = $post->post_lang; 
     
    161159     $post_open_tb = !empty($_POST['post_open_tb']); 
    162160     $post_lang = $_POST['post_lang']; 
    163      $post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null; 
    164161     $post_position = (integer) $_POST['post_position']; 
    165162      
     
    188185     $cur->post_dt = $post_dt ? date('Y-m-d H:i:00',strtotime($post_dt)) : ''; 
    189186     $cur->post_format = $post_format; 
    190      $cur->post_password = $post_password; 
    191187     $cur->post_lang = $post_lang; 
    192188     $cur->post_title = $post_title; 
     
    433429     form::combo('post_lang',$lang_combo,$post_lang).'</label></p>'. 
    434430      
    435      '<p><label for="post_password">'.__('Page password:'). 
    436      form::field('post_password',10,32,html::escapeHTML($post_password),'maximal'). 
    437      '</label></p>'. 
    438       
    439431     '<div class="lockable">'. 
    440432     '<p><label for="post_url">'.__('Basename:'). 
Note: See TracChangeset for help on using the changeset viewer.

Sites map