Sfoglia il codice sorgente

Ticket #553 - Corrected sql queries without prepared statements and renamed getProfileId method

AlexeyUna 9 anni fa
parent
commit
a91d1b623c

+ 3 - 1
modules/boonex/se_migration/classes/BxSEDb.php

@@ -357,7 +357,9 @@ class BxSEDb {
     }
 		
 	public function isTableExists($sTable){
-		return !empty($this -> getRow("SHOW TABLES LIKE '" . $sTable . "'"));
+		$sQuery = $this -> prepare("SHOW TABLES LIKE ?", $sTable);
+		$aResult = $this -> getRow($sQuery);
+		return !empty($aResult);
    }
 
    public function getSEParam($sTable, $sName){

+ 0 - 2
modules/boonex/se_migration/classes/BxSEMigAlertsResponse.php

@@ -23,8 +23,6 @@ class BxSEMigAlertsResponse extends BxBaseModTextAlertsResponse
 		
 		if ('system' == $oAlert->sUnit && 'encrypt_password_after' == $oAlert->sAction)
             BxDolService::call($this->MODULE, 'encrypt_password', array($oAlert));
-
-        parent::response($oAlert);
     }
 }
 

+ 2 - 2
modules/boonex/se_migration/classes/BxSEMigBlogs.php

@@ -33,7 +33,7 @@ class BxSEMigBlogs extends BxSEMigData {
 		
 		$iComments = 0;		
 		foreach($aResult as $iKey => $aValue){ 
-			$iProfileId = $this -> getProfileId((int)$aValue['owner_id']);			
+			$iProfileId = $this -> getContentId((int)$aValue['owner_id']);			
 			if (!$iProfileId || $this -> isBlogExisted($iProfileId, $aValue['title'])) continue;
 			
 			$sQuery = $this -> _oDb -> prepare( 
@@ -168,7 +168,7 @@ class BxSEMigBlogs extends BxSEMigData {
 		
 		$iComments = 0;
 		foreach($aComments as $iKey => $aComment){			
-			$iProfileId = $this -> getProfileId($aComment['poster_id']);
+			$iProfileId = $this -> getContentId($aComment['poster_id']);
 			$sQuery = $this -> _oDb -> prepare("INSERT INTO `bx_posts_cmts` SET
 										`cmt_object_id`		= ?,
 										`cmt_author_id`		= ?,

+ 6 - 5
modules/boonex/se_migration/classes/BxSEMigData.php

@@ -60,15 +60,16 @@ class BxSEMigData
 	}
 
 	/**
-	* Returns transferred Una's profile id of transferred Social Engine's member
-	* @param int $iSEId social engine's profile ID
+	* Returns content id of transferred Social Engine's member
+	* @param int $iSEId social engine's  profile ID
 	* @return Integer
 	*/           
 	
-	protected function getProfileId($iSEId){
-		return (int)$this -> _oDb -> getOne("SELECT `p`.`content_id` FROM  `sys_accounts` AS  `a` 
+	protected function getContentId($iSEId){
+		$sQuery = $this -> _oDb -> prepare("SELECT `p`.`content_id` FROM  `sys_accounts` AS  `a` 
 																	LEFT JOIN  `sys_profiles` AS  `p` ON `a`.`id` =  `p`.`account_id` 
-																	WHERE  `se_id` =  '{$iSEId}' AND  `p`.`type` =  'bx_persons' LIMIT 1");		
+																	WHERE  `se_id` =  ? AND  `p`.`type` =  'bx_persons' LIMIT 1", $iSEId);
+	    return $this -> _oDb -> getOne($sQuery);
 	}
 }
    

+ 2 - 2
modules/boonex/se_migration/classes/BxSEMigDb.php

@@ -59,12 +59,12 @@ class BxSEMigDb extends BxBaseModGeneralDb
 
                 // create new;
                 if( !$this -> getExtraParam($sName) ) {
-                    $sQuery = "INSERT INTO `{$this -> _sPrefix}config` SET `name` = '{$sName}', `value` = '{$mValue}'";
+                    $sQuery = $this -> prepare("INSERT INTO `{$this -> _sPrefix}config` SET `name` = ?, `value` = ?", $sName, $mValue);
                     $this -> query($sQuery);
                 }
                 else {
                 // update exsisting;
-                    $sQuery = "UPDATE `{$this -> _sPrefix}config` SET  `value` = '{$mValue}' WHERE `name` = '{$sName}'"; 
+                    $sQuery = $this -> prepare("UPDATE `{$this -> _sPrefix}config` SET  `value` = ? WHERE `name` = ?", $mValue, $sName);					
                     $this -> query($sQuery);
                 }
             }

+ 1 - 1
modules/boonex/se_migration/classes/BxSEMigPhotoAlbums.php

@@ -37,7 +37,7 @@ class BxSEMigPhotoAlbums extends BxSEMigData {
 		$aResult = $this -> _seDb -> getAll("SELECT * FROM `{$this -> _sEnginePrefix}album_albums` WHERE `type` = 'profile' ORDER BY `album_id`");
 		foreach($aResult as $iKey => $aValue){ 
 			
-			$iProfileId = $this -> getProfileId((int)$aValue['owner_id']);
+			$iProfileId = $this -> getContentId((int)$aValue['owner_id']);
 			if (!$iProfileId) continue;
 			
 			$sAlbumTitle = isset($aValue['title']) && $aValue['title'] ? $aValue['title'] : 'Profile Photos';

+ 1 - 1
modules/boonex/se_migration/classes/BxSEMigProfilesFields.php

@@ -134,7 +134,7 @@ class BxSEMigProfilesFields extends BxSEMigData
             $aFields = $this -> _seDb -> getAll($sQuery);	
 		
 			foreach($aFields as $iKey => $aValue){
-               if (!($iProfileId =  $this -> getProfileId($aValue['user_id']))) continue;
+               if (!($iProfileId =  $this -> getContentId($aValue['user_id']))) continue;
 			   
 			   if (!empty($aValue['wp_data'])) $aValues = @unserialize($aValue['wp_data']);