Dotclear

Changeset 626


Ignore:
Timestamp:
01/01/09 15:41:31 (14 years ago)
Author:
Moe
Message:

Subscribe to comments 1.3-alpha1 :

  • added import and export behaviors
  • escaped input values in database
  • fixed typo
Location:
plugins/subscribeToComments
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/subscribeToComments/_admin.php

    r489 r626  
    4343} 
    4444 
     45# import/Export 
     46 
     47$core->addBehavior('exportFull', 
     48     array('subscribeToCommentsAdmin','exportFull')); 
     49$core->addBehavior('exportSingle', 
     50     array('subscribeToCommentsAdmin','exportSingle')); 
     51$core->addBehavior('importInit', 
     52     array('subscribeToCommentsAdmin','importInit')); 
     53$core->addBehavior('importSingle', 
     54     array('subscribeToCommentsAdmin','importSingle')); 
     55$core->addBehavior('importFull', 
     56     array('subscribeToCommentsAdmin','importFull')); 
     57 
     58/** 
     59@ingroup Subscribe to comments 
     60@brief Admin 
     61*/ 
     62class subscribeToCommentsAdmin 
     63{ 
     64     public static function exportFull(&$core,&$exp) 
     65     { 
     66          $exp->exportTable('comment_subscriber'); 
     67     } 
     68      
     69     public static function exportSingle(&$core,&$exp,$blog_id) 
     70     { 
     71          $exp->export('comment_subscriber', 
     72               'SELECT id, email, user_key, temp_key, temp_expire, status '. 
     73               'FROM '.$core->prefix.'comment_subscriber'); 
     74     } 
     75      
     76     public static function importInit(&$bk,&$core) 
     77     { 
     78          $bk->cur_comment_subscriber = $core->con->openCursor($core->prefix.'comment_subscriber'); 
     79     } 
     80      
     81     public static function importFull(&$line,&$bk,&$core) 
     82     { 
     83          if ($line->__name == 'comment_subscriber') 
     84          { 
     85               $bk->cur_comment_subscriber->clean(); 
     86                
     87               $bk->cur_comment_subscriber->id = (integer) $line->id; 
     88                
     89               $bk->cur_comment_subscriber->email = (string) $line->email; 
     90               $bk->cur_comment_subscriber->user_key = (string) $line->user_key; 
     91               $bk->cur_comment_subscriber->temp_key = (string) $line->temp_key; 
     92               $bk->cur_comment_subscriber->temp_expire = (string) $line->temp_expire; 
     93                
     94               $bk->cur_comment_subscriber->status = (integer) $line->status; 
     95                
     96               $rs = $core->con->select('SELECT id FROM '. 
     97                    $core->prefix.'comment_subscriber WHERE (id = \''.$line->id.'\');'); 
     98               if ($rs->isEmpty()) 
     99               { 
     100                    $bk->cur_comment_subscriber->insert(); 
     101               } 
     102               else 
     103               { 
     104                    $bk->cur_comment_subscriber->update('WHERE (id = '.$core->con->escape($line->id).')'); 
     105               } 
     106          } 
     107     } 
     108      
     109     public static function importSingle(&$line,&$bk,&$core) 
     110     { 
     111          if ($line->__name == 'comment_subscriber') 
     112          { 
     113               $cur = $core->con->openCursor($core->prefix.'comment_subscriber'); 
     114               $cur->id = $line->id; 
     115               $cur->email = $line->email; 
     116               $cur->user_key = $line->user_key; 
     117               $cur->temp_key = $line->temp_key; 
     118               $cur->temp_expire = $line->temp_expire; 
     119               $cur->status = $line->status; 
     120                
     121               $rs = $core->con->select('SELECT id FROM '. 
     122                    $core->prefix.'comment_subscriber WHERE (id = \''.$line->id.'\');'); 
     123               if ($rs->isEmpty()) 
     124               { 
     125                    $cur->insert(); 
     126               } 
     127               else 
     128               { 
     129                    $cur->update('WHERE (id = '.$core->con->escape($line->id).')'); 
     130               } 
     131          } 
     132     } 
     133} 
    45134?> 
  • plugins/subscribeToComments/_define.php

    r608 r626  
    3030     /* Description*/                "Subscribe to comments", 
    3131     /* Author */                    "Moe (http://gniark.net/)", 
    32      /* Version */                   '1.2.6-beta2', 
     32     /* Version */                   '1.3-alpha1', 
    3333     /* Permissions */               'admin' 
    3434); 
  • plugins/subscribeToComments/class.subscriber.php

    r534 r626  
    5656 
    5757          $rs = $core->con->select('SELECT user_key FROM '.$core->prefix. 
    58                'comment_subscriber WHERE (id = '.$this->id.') AND '. 
    59                '(email = \''.$this->email.'\');'); 
     58               'comment_subscriber WHERE (id = '.$core->con->escape($this->id).') AND '. 
     59               '(email = \''.$core->con->escape($this->email).'\');'); 
    6060          if ($rs->isEmpty()) 
    6161          { 
     
    8181 
    8282          $rs = $core->con->select('SELECT id FROM '. 
    83                $core->prefix.'comment_subscriber WHERE (email = \''.$email.'\');'); 
     83               $core->prefix.'comment_subscriber '. 
     84               'WHERE (email = \''.$core->con->escape($email).'\');'); 
    8485          if ($rs->isEmpty()) 
    8586          { 
     
    191192 
    192193          $rs = $core->con->select('SELECT id FROM '.$core->prefix.'comment_subscriber '. 
    193                'WHERE (email = \''.$new_email.'\') LIMIT 1;'); 
     194               'WHERE (email = \''.$core->con->escape($new_email).'\') LIMIT 1;'); 
    194195          if (!$rs->isEmpty()) 
    195196          { 
     
    204205          $cur->temp_key = $key; 
    205206          $cur->temp_expire = date('Y-m-d H:i:s',strtotime('+1 day')); 
    206           $cur->update('WHERE (id = \''.$this->id.'\') '. 
    207           'AND (user_key = \''.$this->key.'\');'); 
     207          $cur->update('WHERE (id = \''.$core->con->escape($this->id).'\') '. 
     208          'AND (user_key = \''.$core->con->escape($this->key).'\');'); 
    208209 
    209210          $url = subscribeToComments::url(). 
     
    235236                    { 
    236237                         $core->con->execute('DELETE FROM '.$core->prefix.'meta WHERE '. 
    237                               '(post_id = '.$v.') AND (meta_type = \'subscriber\') AND '. 
    238                               '(meta_id = \''.$this->id.'\');'); 
     238                              '(post_id = '.$core->con->escape($v).') '. 
     239                              'AND (meta_type = \'subscriber\') AND '. 
     240                              '(meta_id = \''.$core->con->escape($this->id).'\');'); 
    239241                    } 
    240242               } 
     
    252254          $core->con->execute('DELETE FROM '.$core->prefix.'meta WHERE '. 
    253255               '(meta_type = \'subscriber\') '. 
    254                'AND (meta_id = \''.$this->id.'\');'); 
     256               'AND (meta_id = \''.$core->con->escape($this->id).'\');'); 
    255257          # delete subscriber 
    256258          $core->con->execute('DELETE FROM '.$core->prefix.'comment_subscriber '. 
    257                'WHERE (id = \''.$this->id.'\') AND (user_key = \''.$this->key.'\');'); 
     259               'WHERE (id = \''.$core->con->escape($this->id).'\') '. 
     260               'AND (user_key = \''.$core->con->escape($this->key).'\');'); 
    258261          self::logout(); 
    259262     } 
     
    270273          $cur = $core->con->openCursor($core->prefix.'comment_subscriber'); 
    271274          $cur->status = (($block) ? -1 : 1); 
    272           $cur->update('WHERE (id = \''.$this->id.'\') '. 
    273                'AND (user_key = \''.$this->key.'\');'); 
     275          $cur->update('WHERE (id = \''.$core->con->escape($this->id).'\') '. 
     276               'AND (user_key = \''.$core->con->escape($this->key).'\');'); 
    274277     } 
    275278 
     
    302305 
    303306          $rs = $core->con->select('SELECT id, user_key FROM '. 
    304                $core->prefix.'comment_subscriber WHERE (email = \''.$email.'\')'. 
    305                ' AND (user_key = \''.$key.'\');'); 
     307               $core->prefix.'comment_subscriber '. 
     308               ' WHERE (email = \''.$core->con->escape($email).'\')'. 
     309               ' AND (user_key = \''.$core->con->escape($key).'\');'); 
    306310          if ($rs->isEmpty()) 
    307311          { 
     
    325329 
    326330          $rs = $core->con->select('SELECT id, email, user_key FROM '. 
    327                $core->prefix.'comment_subscriber WHERE (email = \''.$email.'\')'. 
     331               $core->prefix.'comment_subscriber '. 
     332               ' WHERE (email = \''.$core->con->escape($email).'\')'. 
    328333               ' AND (status = \'1\');'); 
    329334          if (!$rs->isEmpty()) 
     
    361366          $rs = $core->con->select('SELECT user_key FROM '. 
    362367               $core->prefix.'comment_subscriber '. 
    363                'WHERE (id = \''.$id.'\') AND (user_key = \''.$key.'\');'); 
     368               'WHERE (id = \''.$core->con->escape($id).'\') '. 
     369               'AND (user_key = \''.$core->con->escape($key).'\');'); 
    364370          if ($rs->isEmpty()) 
    365371          { 
     
    402408          $rs = $core->con->select('SELECT status FROM '. 
    403409               $core->prefix.'comment_subscriber '. 
    404                'WHERE (id = \''.$id.'\') AND (user_key = \''.$key.'\');'); 
     410               'WHERE (id = \''.$core->con->escape($id).'\') '. 
     411               'AND (user_key = \''.$core->con->escape($key).'\');'); 
    405412          if ($rs->isEmpty()) 
    406413          { 
     
    455462 
    456463               $rs = $core->con->select('SELECT email FROM '. 
    457                     $core->prefix.'comment_subscriber WHERE (id = \''.$id.'\');'); 
     464                    $core->prefix.'comment_subscriber '. 
     465                    'WHERE (id = \''.$core->con->escape($id).'\');'); 
    458466 
    459467               if ($rs->isEmpty()) 
     
    477485          $rs = $core->con->select('SELECT id, email, temp_expire FROM '. 
    478486               $core->prefix.'comment_subscriber '. 
    479                'WHERE (temp_key = \''.$temp_key.'\') LIMIT 1;'); 
     487               'WHERE (temp_key = \''.$core->con->escape($temp_key).'\') LIMIT 1;'); 
    480488          if ($rs->isEmpty()) {throw new Exception(__('Invalid key.'));} 
    481           $rs_new_email = $core->con->select('SELECT id FROM '.$core->prefix.'comment_subscriber '. 
    482                'WHERE (email = \''.$new_email.'\') LIMIT 1;'); 
     489          $rs_new_email = $core->con->select( 
     490               'SELECT id FROM '.$core->prefix.'comment_subscriber '. 
     491               'WHERE (email = \''.$core->con->escape($new_email).'\') LIMIT 1;'); 
     492           
    483493          if (!$rs_new_email->isEmpty()) 
    484494          { 
     
    499509          $cur->temp_key = null; 
    500510          $cur->temp_expire = null; 
    501           $cur->update('WHERE (id = '.$rs->id.') AND (temp_key = \''.$temp_key.'\');'); 
     511          $cur->update('WHERE (id = '.$core->con->escape($rs->id).') '. 
     512          'AND (temp_key = \''.$core->con->escape($temp_key).'\');'); 
    502513 
    503514          $subject = sprintf(subscribeToComments::getSetting('account_subject'), 
  • plugins/subscribeToComments/index.php

    r608 r626  
    550550                    </p> 
    551551                    <p><?php printf(__('The code will appear after the %s tag.'), 
    552                          '<code>&lt;tpl EntryIf comments_active="1"&gt;</code>');</p> 
     552                         '<code>&lt;tpl:EntryIf comments_active="1"&gt;</code>'); ?></p> 
    553553                    <div class="code" id="code_tpl_link"> 
    554554                         <h4><?php echo(__('or')); ?></h4> 
  • plugins/subscribeToComments/lib.subscribeToComments.php

    r600 r626  
    289289          $rs = $core->con->select('SELECT post_type AS type '. 
    290290          'FROM '.$core->prefix.'post '. 
    291           (($blog) ? 'WHERE blog_id = \''.$core->blog->id.'\' ' : ''). 
     291          (($blog) 
     292               ?    'WHERE blog_id = \''.$core->con->escape($core->blog->id).'\' ' 
     293               : ''). 
    292294          'GROUP BY type ORDER BY type ASC;'); 
    293295 
     
    366368          $rs = $core->con->select( 
    367369               'SELECT notification_sent FROM '.$core->prefix.'comment '. 
    368                'WHERE (comment_id = '.$rs->comment_id.') AND (notification_sent = 1);' 
     370               'WHERE (comment_id = '.$core->con->escape($rs->comment_id).') '. 
     371               'AND (notification_sent = 1);' 
    369372          ); 
    370373          if ($rs->isEmpty()) 
     
    399402          $rs = $core->con->select( 
    400403               'SELECT notification_sent FROM '.$core->prefix.'comment '. 
    401                'WHERE (comment_id = '.$comment_id.') AND (notification_sent = 1);' 
     404               'WHERE (comment_id = '.$core->con->escape($comment_id).') '. 
     405               'AND (notification_sent = 1);' 
    402406          ); 
    403407 
     
    422426               $cur_sent = $core->con->openCursor($core->prefix.'comment'); 
    423427               $cur_sent->notification_sent = 1; 
    424                $cur_sent->update('WHERE comment_id = '.$comment_id.';'); 
     428               $cur_sent->update('WHERE comment_id = '. 
     429                    $core->con->escape($comment_id).';'); 
    425430 
    426431               if (!$rs->isEmpty()) 
Note: See TracChangeset for help on using the changeset viewer.

Sites map