188. File Comparison Report

Produced on Mon May 12 13:05:03 2008 UTC. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Firefox or Internet Explorer. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

188.1 Files compared

# Location File Last Modified
1 Mon May 12 13:05:03 2008 UTC
2 Dolphin-v.6.1.0\inc\classes BxDolCmts.php Sat Apr 19 12:05:00 2008 UTC

188.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 465
Removed 0 0

188.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

188.4 Active regular expressions

No regular expressions were active.

188.5 Comparison detail

    1   <?
    2  
    3   require_on ce( BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolCm tsQuery.ph p' );
    4   require_on ce( BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolMi stake.php'  );
    5  
    6   class BxDo lCmts exte nds BxDolM istake
    7   {
    8       var $_ iId = 0;   // obect i d to be co mmented
    9  
    10       var $_ sSystem =  'profile';   // curre nt comment  system na me  
    11  
    12       var $_ aSystem =  array ();    // curre nt comment s system a rray
    13  
    14       var $_ aSystems =  array (     // array  of suppor ted commen t systems
    15  
    16           'p rofile' =>  array (
    17                'system_ id' => 1,                              // t his system  id
    18                'table_c mts' => 'C mtsProfile ',               // t able with  comments
    19                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    20                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    21                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    22                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    23                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    24                'is_rata ble' => 1,                             // a llow rate  comments o r not
    25                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    26                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    27                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    28                'is_on'  => 1                                   // i s voting e nabled or  not
    29           ),
    30           
    31           's haredPhoto ' => array  (
    32                'system_ id' => 2,                              // t his system  id
    33                'table_c mts' => 'C mtsSharedP hoto',           // t able with  comments
    34                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    35                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    36                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    37                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    38                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    39                'is_rata ble' => 1,                             // a llow rate  comments o r not
    40                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    41                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    42                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    43                'is_on'  => 1                                   // i s voting e nabled or  not
    44           ),
    45                
    46           's haredMusic ' => array  (
    47                'system_ id' => 3,                              // t his system  id
    48                'table_c mts' => 'C mtsSharedM usic',           // t able with  comments
    49                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    50                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    51                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    52                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    53                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    54                'is_rata ble' => 1,                             // a llow rate  comments o r not
    55                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    56                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    57                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    58                'is_on'  => 1                                   // i s voting e nabled or  not
    59           ),
    60           
    61           's haredVideo ' => array  (
    62                'system_ id' => 4,                              // t his system  id
    63                'table_c mts' => 'C mtsSharedV ideo',           // t able with  comments
    64                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    65                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    66                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    67                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    68                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    69                'is_rata ble' => 1,                             // a llow rate  comments o r not
    70                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    71                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    72                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    73                'is_on'  => 1                                   // i s voting e nabled or  not
    74           ),
    75           
    76           'c lassifieds ' => array  (
    77                'system_ id' => 5,                              // t his system  id
    78                'table_c mts' => 'C mtsClassif ieds',           // t able with  comments
    79                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    80                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    81                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    82                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    83                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    84                'is_rata ble' => 1,                             // a llow rate  comments o r not
    85                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    86                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    87                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    88                'is_on'  => 1                                   // i s voting e nabled or  not
    89           ),
    90           
    91           'b logposts'  => array (
    92                'system_ id' => 6,                              // t his system  id
    93                'table_c mts' => 'C mtsBlogPos ts',             // t able with  comments
    94                'table_t rack' => ' CmtsTrack' ,                // t able to tr ack duplic ate rating s
    95                'allow_t ags' => 0,                             // a llow tags  in comment s or not
    96                'nl2br'  => 1,                                  // c onvert all  new line  caracters  to <br />  tags
    97                'sec_to_ edit' => 9 0,                          // n umber of s econds to  allow edit  comment a fter submi t, 0 - do  not allow  edit
    98                'per_vie w' => 5,                               // c omments pe r view, li ke paginat e
    99                'is_rata ble' => 1,                             // a llow rate  comments o r not
    100                'viewing _threshold ' => -3,                    // b elow this  value comm ent is hid den by def ault
    101                'animati on_effect'  => 'slide ',               // a nimation e ffect : sl ide, fade  or default
    102                'animati on_speed'  => '2000',                  // s peed of an imation ef fect in ms  (1000 ==  1 second)
    103                'is_on'  => 1                                   // i s voting e nabled or  not
    104           ),
    105       );
    106  
    107       var $_ aCmtElemen ts = array  (
    108           'C mtParent'  => array (  'reg' =>  '/^[0-9]+$ /', 'msg'  => 'bad co mment pare nt id' ),
    109           'C mtText'    => array (  'reg' =>  '/^.{3,204 8}$/m', 'm sg' => 'Pl ease enter  3-2048 ch aracters'  ),
    110       );
    111       
    112       var $_ oQuery = n ull;
    113  
    114       /**
    115        * Con structor
    116        * $sS ystem - co mments sys tem name
    117        * $iI d - obect  id to be c ommented
    118        */
    119       functi on BxDolCm ts( $sSyst em, $iId,  $iInit = 1 )
    120       {
    121           $t his->_sSys tem = $sSy stem;
    122           if  (isset($t his->_aSys tems[$sSys tem]))
    123                $this->_ aSystem =  $this->_aS ystems[$sS ystem];
    124           el se
    125                return;
    126  
    127           $t his->_oQue ry = new B xDolCmtsQu ery($this- >_aSystem) ;
    128  
    129           if  ($iInit) 
    130                $this->i nit($iId);
    131       }
    132  
    133       functi on init ($ iId)
    134       {
    135           if  (!$this-> isEnabled( )) return;
    136  
    137           if  (!$this-> iId && $iI d)
    138           {    
    139                $this->s etId($iId) ;         
    140           }
    141  
    142       }
    143           
    144       /**
    145        * che ck if user  can post/ edit or de lete own c omments
    146        */ 
    147       functi on checkAc tion ($iAc tion)
    148       {                
    149           $i Id = $this ->_getAuth orId();
    150           $c heck_res =  checkActi on( $iId,  $iAction ) ;
    151           re turn $chec k_res[CHEC K_ACTION_R ESULT] ==  CHECK_ACTI ON_RESULT_ ALLOWED;
    152       }
    153  
    154       functi on getId ( )
    155       {
    156           re turn $this ->_iId;
    157       }
    158  
    159       functi on isEnabl ed ()
    160       {
    161           re turn $this ->_aSystem ['is_on'];
    162       }
    163  
    164       functi on getSyst emName()
    165       {
    166           re turn $this ->_sSystem ;
    167       }
    168  
    169       /**
    170        * set  id to ope rate with  votes
    171        */
    172       functi on setId ( $iId)
    173       {
    174           if  ($iId ==  $this->get Id()) retu rn;
    175           $t his->_iId  = $iId;
    176       }
    177  
    178       functi on isValid System ($s System)
    179       {
    180           re turn isset ($this->_a Systems[$s System]);
    181       }
    182       
    183       functi on isTagsA llowed ()
    184       {
    185           re turn $this ->_aSystem ['allow_ta gs'];
    186       }
    187           
    188       functi on isNl2br  ()
    189       {
    190           re turn $this ->_aSystem ['nl2br'];
    191       }
    192        
    193       functi on isRatab le ()
    194       {
    195           re turn $this ->_aSystem ['is_ratab le'];
    196       }
    197           
    198       functi on getAllo wedEditTim e ()
    199       {
    200           re turn $this ->_aSystem ['sec_to_e dit'];
    201       }
    202          
    203       functi on getPerV iew ()
    204       {
    205           re turn $this ->_aSystem ['per_view '];
    206       }
    207           
    208       functi on getSyst emId ()
    209       {
    210           re turn $this ->_aSystem ['system_i d'];
    211       }
    212  
    213       
    214       /** co mments fun ctions
    215       ****** ********** ********** ********** *********/
    216           
    217       functi on getComm entsArray  ($iCmtPare ntId)
    218       {
    219           re turn $this ->_oQuery- >getCommen ts ($this- >getId(),  $iCmtParen tId, $this ->_getAuth orId());
    220       }
    221  
    222       functi on getComm entRow ($i CmtId)
    223       {
    224           re turn $this ->_oQuery- >getCommen t ($this-> getId(), $ iCmtId, $t his->_getA uthorId()) ;
    225       }
    226  
    227       functi on onObjec tDelete ($ iObjectId  = 0)
    228       {
    229           re turn $this ->_oQuery- >deleteObj ectComment s ($iObjec tId ? $iOb jectId : $ this->getI d());
    230       }
    231  
    232       // del ete all pr ofiles com ments in a ll systems , if some  replies ex ist, set t his commen t to anony mous
    233       functi on onAutho rDelete ($ iAuthorId)
    234       {
    235           fo r ( reset( $this->_aS ystems) ;  list ($sSy stem, $aSy stem) = ea ch ($this- >_aSystems ) ; )
    236           {
    237                $oQuery  = new BxDo lCmtsQuery ($aSystem) ;
    238                $oQuery- >deleteAut horComment s ($iAutho rId);
    239           }
    240           re turn true;
    241       }
    242  
    243       functi on getComm entsTableN ame ()
    244       {
    245           re turn $this ->_oQuery- >getTableN ame ();   
    246       }
    247  
    248       functi on getObje ctComments Count ($iO bjectId =  0)
    249       {
    250           re turn $this ->_oQuery- >getObject CommentsCo unt ($iObj ectId ? $i ObjectId :  $this->ge tId());
    251       }
    252  
    253       /** pe rmissions  functions
    254       ****** ********** ********** ********** *********/
    255  
    256       // is  rate comme nt allowed
    257       functi on isRateA llowed () 
    258       {
    259           if  ($this->_ sSystem ==  'blogpost s') 
    260                return $ this->_che ckBlogPerm ission(ACT ION_ID_COM MENTS_VOTE );
    261  
    262           re turn $this ->checkAct ion (ACTIO N_ID_COMME NTS_VOTE);
    263       }
    264  
    265       // is  post comme nt allowed
    266       functi on isPostR eplyAllowe d () 
    267       {
    268           if  ($this->_ sSystem ==  'blogpost s') 
    269                return $ this->_che ckBlogPerm ission(ACT ION_ID_COM MENTS_POST );
    270  
    271           re turn $this ->checkAct ion (ACTIO N_ID_COMME NTS_POST);
    272       }
    273  
    274       functi on _checkB logPermiss ion ($iAct ion)
    275       {         
    276           $i PostID = $ this->getI d();
    277           $s BlogPostFr  = db_valu e("SELECT  `PostComme ntPermissi on` FROM ` BlogPosts`  WHERE `Bl ogPosts`.` PostID` =  '{$iPostID }'");
    278           if  ($sBlogPo stFr == 'f riends') 
    279           {
    280                $iOwnerI D = db_val ue("SELECT  `BlogCate gories`.`O wnerID` FR OM `BlogPo sts` INNER  JOIN `Blo gCategorie s` ON `Blo gCategorie s`.`Catego ryID` = `B logPosts`. `CategoryI D` WHERE ` BlogPosts` .`PostID`  = '{$iPost ID}'");
    281                return i s_friends(  $this->_g etAuthorId (), $iOwne rID );
    282           }
    283           re turn $this ->checkAct ion ($iAct ion);
    284       }
    285  
    286       // is  edit own c omment all owed
    287       functi on isEditA llowed ()
    288       {
    289           if (getParam( "free_mode ") == "on" ) return f alse;
    290           re turn $this ->checkAct ion (ACTIO N_ID_COMME NTS_EDIT_O WN);
    291       }
    292  
    293       // is  removing o wn comment  allowed
    294       functi on isRemov eAllowed ( )
    295       {
    296           if (getParam( "free_mode ") == "on" ) return f alse;
    297           re turn $this ->checkAct ion (ACTIO N_ID_COMME NTS_REMOVE _OWN);
    298       }
    299  
    300       // is  edit any c omment all owed
    301       functi on isEditA llowedAll  ()
    302       {
    303           gl obal $logg ed;
    304           re turn $logg ed['admin' ] ? true :  false;
    305       }
    306  
    307       // is  removing a ny comment  allowed
    308       functi on isRemov eAllowedAl l ()
    309       {
    310           gl obal $logg ed;
    311           re turn $logg ed['admin' ] ? true :  false;
    312       }   
    313           
    314       /** ac tions func tions
    315       ****** ********** ********** ********** *********/
    316  
    317       functi on actionC mtsGet ()
    318       {
    319           if  (!$this-> isEnabled( )) return  '';
    320           $i CmtParentI d = (int)$ _GET['CmtP arent'];
    321           re turn $this ->getComme nts ($iCmt ParentId);
    322       }
    323       
    324       functi on actionC mtGet ()
    325       {
    326           if  (!$this-> isEnabled( )) return  '';
    327           $i CmtId = (i nt)$_GET[' Cmt'];
    328           re turn $this ->getComme nt ($iCmtI d);
    329       }
    330           
    331       functi on actionC mtPost ()
    332       {        
    333           if  (!$this-> isEnabled( )) return  '';
    334           
    335           if  (!$this-> isPostRepl yAllowed ( )) return  '';
    336           
    337           $i CmtParentI d = (int)$ _REQUEST[' CmtParent' ];
    338           $s Text = pro cess_db_in put($_REQU EST['CmtTe xt'], !$th is->isTags Allowed()) ;
    339  
    340           if  ($this->i sNl2br())
    341                $sText =  nl2br($sT ext);
    342           
    343           $i CmtNewId =  $this->_o Query->add Comment ($ this->getI d(), $iCmt ParentId,  $this->_ge tAuthorId( ), $sText) ;
    344           if (false ===  $iCmtNewI d)
    345                return ' ';
    346           
    347           re turn $iCmt NewId;
    348       }
    349  
    350       // ret urns error  string on  error, or  empty str ing on suc cess
    351       functi on actionC mtRemove ( )
    352       {
    353           if  (!$this-> isEnabled( )) return  '';
    354           
    355           $i CmtId = (i nt)$_REQUE ST['Cmt'];
    356           
    357           $a Cmt = $thi s->_oQuery ->getComme ntSimple ( $this->get Id(), $iCm tId);
    358           if  (!$aCmt)
    359                return _ t('_No suc h comment' );      
    360                
    361           if  ($aCmt['c mt_replies '] > 0)
    362                return _ t('_Can no t delete c omments wi th replies ');
    363                        
    364           $i sRemoveAll owed = $th is->isRemo veAllowedA ll() || ($ aCmt['cmt_ author_id' ] == $this ->_getAuth orId() &&  $this->isR emoveAllow ed());
    365           if  (!$isRemo veAllowed  && $aCmt[' cmt_secs_a go'] > ($t his->getAl lowedEditT ime()+20))
    366                return _ t('_Access  denied');
    367                
    368           if  (!$this-> _oQuery->r emoveComme nt ($this- >getId(),  $aCmt['cmt _id'], $aC mt['cmt_pa rent_id']) )
    369                return _ t('_Databa se Error') ;
    370                
    371           re turn '';
    372       }
    373       
    374       // ret urns strin g with "er r" prefix  on error,  or string  with html  form on su ccess
    375       functi on actionC mtEdit ()
    376       {
    377           if  (!$this-> isEnabled( )) return  '';
    378           
    379           $i CmtId = (i nt)$_REQUE ST['Cmt'];
    380                    
    381           $a Cmt = $thi s->_oQuery ->getComme ntSimple ( $this->get Id(), $iCm tId);
    382           if  (!$aCmt)
    383                return ' err'._t('_ No such co mment');
    384                        
    385           $i sEditAllow ed = $this ->isEditAl lowedAll()  || ($aCmt ['cmt_auth or_id'] ==  $this->_g etAuthorId () && $thi s->isEditA llowed());
    386           if  (!$isEdit Allowed &&  $aCmt['cm t_secs_ago '] > ($thi s->getAllo wedEditTim e()+20))
    387                return ' err'._t('_ Access den ied');
    388                
    389           re turn $this ->_getForm Box ($this ->_prepare TextForEdi t($aCmt['c mt_text']) , 0, 'upda teComment( this, \''. $iCmtId.'\ ')');
    390       }
    391       
    392       
    393       functi on actionC mtEditSubm it ()
    394       {
    395           if  (!$this-> isEnabled( )) return  '';
    396           
    397           $i CmtId = (i nt)$_REQUE ST['Cmt'];
    398           $s Text = pro cess_db_in put($_REQU EST['CmtTe xt'], !$th is->isTags Allowed()) ;
    399           if  ($this->i sNl2br())
    400                $sText =  nl2br($sT ext);     
    401           $s TextRet =  stripslash es($sText) ;
    402                        
    403           $a Cmt = $thi s->_oQuery ->getComme ntSimple ( $this->get Id(), $iCm tId);
    404           if  (!$aCmt)
    405                return ' ';
    406                        
    407           $i sEditAllow ed = $this ->isEditAl lowedAll()  || ($aCmt ['cmt_auth or_id'] ==  $this->_g etAuthorId () && $thi s->isEditA llowed());
    408           if  (!$isEdit Allowed &&  $aCmt['cm t_secs_ago '] > ($thi s->getAllo wedEditTim e()+20))
    409                return ' ';      
    410                
    411           if  ($sTextRe t == $aCmt ['cmt_text ']) 
    412                return $ sTextRet;
    413                
    414           if  (!$this-> _oQuery->u pdateComme nt ($this- >getId(),  $aCmt['cmt _id'], $sT ext))
    415                return ' ';
    416                
    417           re turn $sTex tRet;
    418       }
    419  
    420       functi on actionC mtRate ()
    421       {
    422           if  (!$this-> isEnabled( )) return  _t('_Error  occured') ;
    423           if  (!$this-> isRatable( )) return  _t('_Error  occured') ;
    424           if  (!$this-> isRateAllo wed()) ret urn _t('_A ccess deni ed');
    425           
    426           $i CmtId = (i nt)$_REQUE ST['Cmt'];         
    427           $i Rate = (in t)$_REQUES T['Rate'];
    428           
    429           if  ($iRate > = 1) 
    430                $iRate =  1;
    431           el seif ($iRa te <= -1) 
    432                $iRate =  -1;
    433           el se
    434                return _ t('_Error  occured');
    435                    
    436           if  (!$this-> _oQuery->r ateComment  ($this->g etSystemId (), $iCmtI d, $iRate,  $this->_g etAuthorId (), $this- >_getAutho rIp()))
    437                return _ t('_Duplic ate vote') ;
    438           
    439           re turn '';
    440       }
    441       
    442       /** pr ivate func tions
    443       ****** ********** ********** ********** *********/
    444       
    445       functi on _getAut horId ()
    446       {
    447           gl obal $logg ed;
    448           if  (!$logged ['member'] ) return 0 ;
    449           re turn $_COO KIE['membe rID'];
    450       }
    451       
    452       functi on _getAut horIp ()
    453       {
    454           re turn $_SER VER['REMOT E_ADDR'];
    455       }
    456           
    457       functi on _prepar eTextForEd it ($s)
    458       {
    459           if  ($this->i sNl2br())
    460                return s tr_replace ('<br />',  "", $s);
    461           re turn $s;       
    462       }   
    463   }
    464  
    465   ?>