189. 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.

189.1 Files compared

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

189.2 Comparison summary

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

189.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

189.4 Active regular expressions

No regular expressions were active.

189.5 Comparison detail

    1   <?php
    2  
    3   /*
    4  
    5   CREATE TAB LE IF NOT  EXISTS `Cm tsProfile`  (
    6     `cmt_id`  int(11) N OT NULL au to_increme nt,
    7     `cmt_par ent_id` in t(11) NOT  NULL,
    8     `cmt_obj ect_id` in t(11) NOT  NULL,
    9     `cmt_aut hor_id` in t(10) unsi gned NOT N ULL,
    10     `cmt_tex t` text co llate utf8 _unicode_c i NOT NULL ,
    11     `cmt_rat e` int(11)  NOT NULL,
    12     `cmt_rat e_count` i nt(11) NOT  NULL,
    13     `cmt_tim e` datetim e NOT NULL ,
    14     `cmt_rep lies` int( 11) NOT NU LL,
    15     PRIMARY  KEY  (`cmt _id`),
    16     KEY `cmt _object_id ` (`cmt_ob ject_id`,` cmt_parent _id`)
    17   ) ENGINE=M yISAM  DEF AULT CHARS ET=utf8 CO LLATE=utf8 _unicode_c i AUTO_INC REMENT=3 ;
    18  
    19   INSERT INT O `CmtsPro file` (`cm t_id`, `cm t_parent_i d`, `cmt_o bject_id`,  `cmt_auth or_id`, `c mt_text`,  `cmt_rate` , `cmt_rat e_count`,  `cmt_time` , `cmt_rep lies`) VAL UES
    20   (1, 0, 1,  1, 'verty  firts comm ent', 0, 0 , '2008-03 -26 17:36: 28', 0),
    21   (2, 0, 1,  1, 'very s econt comm ent', 0, 0 , '2008-03 -26 17:36: 28', 0);
    22  
    23   */
    24  
    25  
    26   require_on ce (BX_DIR ECTORY_PAT H_CLASSES  . 'BxDolDb .php');
    27  
    28   class BxDo lCmtsQuery  extends B xDolDb
    29   {
    30       var $_ aSystem; / / current  voting sys tem
    31       var $_ sTable;
    32       var $_ sTableTrac k;
    33  
    34       functi on BxDolCm tsQuery(&$ aSystem)
    35       {
    36           $t his->_aSys tem = &$aS ystem;
    37           $t his->_sTab le = $this ->_aSystem ['table_cm ts'];
    38           $t his->_sTab leTrack =  $this->_aS ystem['tab le_track'] ;
    39           pa rent::BxDo lDb();
    40       }
    41  
    42       functi on getTabl eName ()
    43       {
    44           re turn $this ->_sTable;
    45       }
    46  
    47       functi on getComm ents ($iId , $iCmtPar entId = 0,  $iAuthorI d = 0)
    48       {
    49           $s Fields = " '' AS `cmt _rated`,";
    50           $s Join = '';
    51           if  ($iAuthor Id)
    52           {
    53                $sFields  = '`r`.`c mt_rate` A S `cmt_rat ed`,';
    54                $sJoin =  "LEFT JOI N {$this-> _sTableTra ck} AS `r`  ON (`r`.` cmt_system _id` = ".$ this->_aSy stem['syst em_id']."  AND `r`.`c mt_id` = ` c`.`cmt_id ` AND `r`. `cmt_rate_ author_id`  = $iAutho rId)";
    55           }        
    56                    
    57           $a  = $this-> getAll("SE LECT 
    58                    $sFi elds
    59                    `c`. `cmt_id`, 
    60                    `c`. `cmt_paren t_id`, 
    61                    `c`. `cmt_objec t_id`, 
    62                    `c`. `cmt_autho r_id`, 
    63                    `c`. `cmt_text`
    64                    `c`. `cmt_rate`
    65                    `c`. `cmt_rate_ count`, 
    66                    `c`. `cmt_repli es`, 
    67                    (UNI X_TIMESTAM P() - UNIX _TIMESTAMP (`c`.`cmt_ time`)) AS  `cmt_secs _ago`,
    68                    `p`. `NickName`  AS `cmt_a uthor_name `,
    69                    `m`. `med_file`  AS `cmt_a uthor_icon `
    70                FROM {$t his->_sTab le} AS `c`
    71                LEFT JOI N `Profile s` AS `p`  ON (`p`.`I D` = `c`.` cmt_author _id`)
    72                LEFT JOI N `media`  AS `m` ON  (`m`.`med_ id` = `p`. `PrimPhoto ` AND `m`. `med_statu s` = 'acti ve')
    73                $sJoin
    74                WHERE `c `.`cmt_obj ect_id` =  '$iId' AND  `c`.`cmt_ parent_id`  = '$iCmtP arentId'
    75                ORDER BY  `c`.`cmt_ time` ASC" );
    76           
    77           fo r(reset($a ) ; list ( $k) = each  ($a) ; )
    78                $a[$k][' cmt_ago']  = _format_ when ($a[$ k]['cmt_se cs_ago']);
    79                
    80           re turn $a;
    81       }
    82  
    83       functi on getComm ent ($iId,  $iCmtId,  $iAuthorId  = 0)
    84       {
    85           $s Fields = " '' AS `cmt _rated`,";
    86           $s Join = '';
    87           if  ($iAuthor Id)
    88           {
    89                $sFields  = '`r`.`c mt_rate` A S `cmt_rat ed`,';
    90                $sJoin =  "LEFT JOI N {$this-> _sTableTra ck} AS `r`  ON (`r`.` cmt_system _id` = ".$ this->_aSy stem['syst em_id']."  AND `r`.`c mt_id` = ` c`.`cmt_id ` AND `r`. `cmt_rate_ author_id`  = $iAutho rId)";
    91           }        
    92                    
    93           re turn $this ->getRow(" SELECT 
    94                    $sFi elds
    95                    `c`. `cmt_id`, 
    96                    `c`. `cmt_paren t_id`, 
    97                    `c`. `cmt_objec t_id`, 
    98                    `c`. `cmt_autho r_id`, 
    99                    `c`. `cmt_text`
    100                    `c`. `cmt_rate`
    101                    `c`. `cmt_rate_ count`, 
    102                    `c`. `cmt_repli es`, 
    103                    (UNI X_TIMESTAM P() - UNIX _TIMESTAMP (`c`.`cmt_ time`)) AS  `cmt_secs _ago`,
    104                    `p`. `NickName`  AS `cmt_a uthor_name `,
    105                    `m`. `med_file`  AS `cmt_a uthor_icon `
    106                FROM {$t his->_sTab le} AS `c`
    107                LEFT JOI N `Profile s` AS `p`  ON (`p`.`I D` = `c`.` cmt_author _id`)
    108                LEFT JOI N `media`  AS `m` ON  (`m`.`med_ id` = `p`. `PrimPhoto ` AND `m`. `med_statu s` = 'acti ve')
    109                $sJoin
    110                WHERE `c `.`cmt_obj ect_id` =  '$iId' AND  `c`.`cmt_ id` = '$iC mtId' 
    111                LIMIT 1" );
    112       }
    113       
    114       functi on getComm entSimple  ($iId, $iC mtId)
    115       {
    116           re turn $this ->getRow("
    117                SELECT 
    118                    *, ( UNIX_TIMES TAMP() - U NIX_TIMEST AMP(`c`.`c mt_time`))  AS `cmt_s ecs_ago`
    119                FROM {$t his->_sTab le} AS `c`
    120                WHERE `c mt_object_ id` = '$iI d' AND `cm t_id` = '$ iCmtId' 
    121                LIMIT 1" );
    122       }
    123           
    124       functi on addComm ent ($iId,  $iCmtPare ntId, $iAu thorId, $s Text)   
    125       {
    126           if  (!$this-> query("INS ERT INTO { $this->_sT able} SET 
    127                `cmt_par ent_id` =  '$iCmtPare ntId',
    128                `cmt_obj ect_id` =  '$iId',
    129                `cmt_aut hor_id` =  '$iAuthorI d',
    130                `cmt_tex t` = '$sTe xt',
    131                `cmt_tim e` = NOW() "))
    132           {
    133                return f alse;
    134           }
    135           
    136           $i Ret = $thi s->lastId( );
    137           
    138           if  ($iCmtPar entId)
    139                $this->q uery ("UPD ATE {$this ->_sTable}  SET `cmt_ replies` =  `cmt_repl ies` + 1 W HERE `cmt_ id` = '$iC mtParentId ' LIMIT 1" );
    140           
    141           re turn $iRet ;
    142       }
    143       
    144       functi on removeC omment ($i Id, $iCmtI d, $iCmtPa rentId)   
    145       {
    146           if  (!$this-> query("DEL ETE FROM { $this->_sT able} WHER E `cmt_obj ect_id` =  '$iId' AND  `cmt_id`  = '$iCmtId ' LIMIT 1" ))
    147                return f alse;
    148                
    149           $t his->query  ("UPDATE  {$this->_s Table} SET  `cmt_repl ies` = `cm t_replies`  - 1 WHERE  `cmt_id`  = '$iCmtPa rentId' LI MIT 1");
    150           
    151           re turn true;
    152       }
    153       
    154       functi on updateC omment ($i Id, $iCmtI d, $sText)
    155       {
    156           re turn $this ->query("U PDATE {$th is->_sTabl e} SET `cm t_text` =  '$sText' W HERE `cmt_ object_id`  = '$iId'  AND `cmt_i d` = '$iCm tId' LIMIT  1");
    157       }
    158       
    159       functi on rateCom ment ($iSy stemId, $i CmtId, $iR ate, $iAut horId, $sA uthorIp)
    160       {
    161           if  ($this->q uery("INSE RT IGNORE  INTO {$thi s->_sTable Track} SET  
    162                `cmt_sys tem_id` =  '$iSystemI d',
    163                `cmt_id`  = '$iCmtI d',
    164                `cmt_rat e` = '$iRa te',
    165                `cmt_rat e_author_i d` = '$iAu thorId',
    166                `cmt_rat e_author_n ip` = INET _ATON('$sA uthorIp'),
    167                `cmt_rat e_ts` = UN IX_TIMESTA MP()"))
    168           {
    169                $this->q uery("UPDA TE {$this- >_sTable}  SET `cmt_r ate` = `cm t_rate` +  $iRate, `c mt_rate_co unt` = `cm t_rate_cou nt` + 1 WH ERE `cmt_i d` = '$iCm tId' LIMIT  1");
    170                return t rue;
    171           }
    172           
    173           re turn false ;
    174       }
    175  
    176       functi on deleteA uthorComme nts ($iAut horId)
    177       {
    178           $i sDelOccure d = 0;
    179           $a  = $this-> getAll ("S ELECT `cmt _id`, `cmt _parent_id ` FROM {$t his->_sTab le} WHERE  `cmt_autho r_id` = '$ iAuthorId'  AND `cmt_ replies` =  0");
    180           fo r ( reset( $a) ; list  (, $r) =  each ($a)  ; )
    181           {              
    182                $this->q uery ("DEL ETE FROM { $this->_sT able} WHER E `cmt_id`  = '{$r['c mt_id']}'" );
    183                $this->q uery ("UPD ATE {$this ->_sTable}  SET `cmt_ replies` =  `cmt_repl ies` - 1 W HERE `cmt_ id` = '{$r ['cmt_pare nt_id']}'" );
    184                $isDelOc cured = 1;
    185           }
    186           $t his->query  ("UPDATE  {$this->_s Table} SET  `cmt_auth or_id` = 0  WHERE `cm t_author_i d` = '$iAu thorId' AN D `cmt_rep lies` != 0 ");
    187           if  ($isDelOc cured)
    188                $this->q uery ("OPT IMIZE TABL E {$this-> _sTable}") ;
    189       }
    190  
    191       functi on deleteO bjectComme nts ($iObj ectId)
    192       {
    193           $t his->query  ("DELETE  FROM {$thi s->_sTable } WHERE `c mt_object_ id` = '$iO bjectId'") ;
    194           $t his->query  ("OPTIMIZ E TABLE {$ this->_sTa ble}");
    195       }    
    196  
    197       functi on getObje ctComments Count ($iO bjectId)
    198       {
    199           re turn $this ->getOne ( "SELECT CO UNT(*) FRO M {$this-> _sTable} W HERE `cmt_ object_id`  = '$iObje ctId'");
    200       }
    201   }
    202  
    203  
    204   ?>