HomeHelpTrac

Ignore:
Timestamp:
03/20/10 04:28:57 (2 years ago)
Author:
Alexander Ermashev
Message:

fix possible mysql injections in spy module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/boonex/spy/classes/BxSpyDb.php

    r12399 r13812  
    5858        function getActivityCount($sType = '') 
    5959        { 
     60            $sType = $this -> escape($sType); 
     61 
    6062            $sWhere = null; 
    6163            if($sType && $sType != 'all'){ 
     
    7779        function getLastActivityId($sType = '') 
    7880        { 
     81            $sType = $this -> escape($sType); 
    7982            $sWhere     = null; 
    8083 
     
    98101        function getLastFriendsActivityId($iProfileId, $sType = '') 
    99102        { 
     103            $iProfileId = (int) $iProfileId; 
     104            $sType = $this -> escape($sType); 
     105 
    100106            $sWhere = null; 
    101107 
     
    136142        function getFriendsActivityCount($iProfileId, $sType = '') 
    137143        { 
     144            $iProfileId = (int) $iProfileId; 
     145            $sType = $this -> escape($sType); 
     146 
    138147            $sWhere = null; 
    139148 
     
    170179        function getSettingsCategory($sValueName) 
    171180        { 
     181            $sValueName = process_db_input($sValueName, BX_TAGS_STRIP); 
    172182            return $this -> getOne('SELECT `kateg` FROM `sys_options` WHERE `Name` = "' . $sValueName . '"'); 
    173183        } 
     
    181191        function setViewed($iActivityId) 
    182192        { 
     193            $iActivityId = (int) $iActivityId; 
    183194            $sQuery = "UPDATE `{$this->sTablePrefix}data` SET `viewed` = 1"; 
    184195            $this -> query($sQuery); 
     
    193204        function setViewedProfileActivity($iProfileId) 
    194205        { 
     206            $iProfileId = (int) $iProfileId; 
    195207            $sQuery = "UPDATE `{$this->sTablePrefix}data` SET `viewed` = 1 WHERE `recipient_id` = {$iProfileId}"; 
    196208            $this -> query($sQuery); 
     
    201213            //--- Update Spy Handlers ---// 
    202214            foreach($aData['handlers'] as $aHandler) 
    203             {           
     215            { 
     216                $aHandler['alert_unit']     = process_db_input($aHandler['alert_unit'], BX_TAGS_STRIP); 
     217                $aHandler['alert_action']   = process_db_input($aHandler['alert_action'], BX_TAGS_STRIP); 
     218                $aHandler['module_uri']     = process_db_input($aHandler['module_uri'], BX_TAGS_STRIP); 
     219                $aHandler['module_class']   = process_db_input($aHandler['module_class'], BX_TAGS_STRIP); 
     220                $aHandler['module_method']  = process_db_input($aHandler['module_method'], BX_TAGS_STRIP); 
     221 
    204222                $sQuery =  
    205223                " 
     
    217235            } 
    218236 
    219             $sAlertName = $this -> _oConfig -> getAlertSystemName(); 
     237            $sAlertName = $this -> escape($this -> _oConfig -> getAlertSystemName()); 
    220238 
    221239            //--- Update System Alerts ---// 
     
    235253            foreach($aData['alerts'] as $aAlert)  
    236254            { 
     255                $aAlert['unit']     = process_db_input($aAlert['unit'], BX_TAGS_STRIP); 
     256                $aAlert['action']   = process_db_input($aAlert['action'], BX_TAGS_STRIP); 
     257 
    237258                $sQuery =  
    238259                " 
     
    252273        { 
    253274            //--- Update Wall Handlers ---// 
    254             foreach($aData['handlers'] as $aHandler) { 
     275            foreach($aData['handlers'] as $aHandler)  
     276            { 
     277                $aHandler['alert_unit']     = process_db_input($aHandler['alert_unit'], BX_TAGS_STRIP); 
     278                $aHandler['alert_action']   = process_db_input($aHandler['alert_action'], BX_TAGS_STRIP); 
     279                $aHandler['module_uri']     = process_db_input($aHandler['module_uri'], BX_TAGS_STRIP); 
     280                $aHandler['module_class']   = process_db_input($aHandler['module_class'], BX_TAGS_STRIP); 
     281                $aHandler['module_method']  = process_db_input($aHandler['module_method'], BX_TAGS_STRIP); 
     282 
    255283                $sQuery =  
    256284                " 
     
    274302 
    275303            // define system alert name; 
    276             $sAlertName = $this -> _oConfig -> getAlertSystemName(); 
     304            $sAlertName = $this -> escape($this -> _oConfig -> getAlertSystemName()); 
    277305 
    278306            //--- Update System Alerts ---// 
     
    291319            foreach($aData['alerts'] as $aAlert)  
    292320            { 
     321                $aAlert['unit']     = process_db_input($aAlert['unit'], BX_TAGS_STRIP); 
     322                $aAlert['action']   = process_db_input($aAlert['action'], BX_TAGS_STRIP); 
     323 
    293324                $sQuery =  
    294325                " 
     
    321352        function createActivity($iSenderId, $iRecipientId, $aActivityInfo) 
    322353        { 
     354            $iSenderId = (int) $iSenderId; 
     355            $iRecipientId = (int) $iRecipientId; 
     356 
    323357            // -- procces recived parameters -- // 
    324             $aParameters = $this->escape(serialize($aActivityInfo['params'])); 
     358            $aParameters = isset($aActivityInfo['params']) 
     359                ?  process_db_input(serialize($aActivityInfo['params']), BX_TAGS_STRIP) 
     360                : ''; 
    325361 
    326362            // if isset activity's types will uset it; 
     
    328364                ? $aActivityInfo['spy_type'] 
    329365                : 'content_activity'; 
     366 
     367            //procces activity data 
     368            foreach($aActivityInfo as $sKey => $sValue) 
     369            { 
     370                $aActivityInfo[$sKey] = process_db_input($sValue, BX_TAGS_STRIP); 
     371            } 
    330372 
    331373            // execute query; 
     
    358400        function attachFriendEvent($iEventId, $iSenderId, $iFriendId) 
    359401        { 
    360             $sQuery =  
     402            $iEventId  = (int) $iEventId; 
     403            $iSenderId = (int) $iSenderId; 
     404            $iFriendId = (int) $iFriendId; 
     405 
     406            $sQuery =  
    361407            " 
    362408                INSERT INTO  
     
    379425        function deleteUselessData($iCount = 0)  
    380426        { 
     427            $iCount = (int) $iCount; 
     428 
    381429            $sQuery = "SELECT `id` FROM `{$this->sTablePrefix}data` ORDER BY `date` LIMIT {$iCount}"; 
    382430            $aRows  = $this -> getAll($sQuery); 
Note: See TracChangeset for help on using the changeset viewer.