--- library/filerepository/backend/FileRepository_Backend_MySQL.class.php.old Sat Feb 23 00:06:10 2008 UTC +++ library/filerepository/backend/FileRepository_Backend_MySQL.class.php Sat Feb 23 00:15:59 2008 UTC @@ -88,7 +88,7 @@ } // if $files_table = $this->getFilesTableName(); - $escaped_id = mysql_real_escape_string($file_id); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); if ($result = mysql_query("SELECT `content` FROM $files_table WHERE `id` = '$escaped_id'", $this->db_link)) { if ($row = mysql_fetch_assoc($result)) { return $row['content']; @@ -111,7 +111,7 @@ } // if $attributes_table = $this->getAttributesTableName(); - $escaped_id = mysql_real_escape_string($file_id); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); if ($result = mysql_query("SELECT `attribute`, `value` FROM $attributes_table WHERE `id` = '$escaped_id'", $this->db_link)) { $attributes = array(); while ($row = mysql_fetch_assoc($result)) { @@ -137,8 +137,8 @@ } // if $attributes_table = $this->getAttributesTableName(); - $escaped_id = mysql_real_escape_string($file_id); - $escaped_attribute = mysql_real_escape_string($attribute_name); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); + $escaped_attribute = mysql_real_escape_string($attribute_name, $this->db_link); if ($result = mysql_query("SELECT `value` FROM $attributes_table WHERE `id` = '$escaped_id' AND `attribute` = '$escaped_attribute'", $this->db_link)) { if ($row = mysql_fetch_assoc($result)) { return eval($row['value']); @@ -167,9 +167,9 @@ } // if $attributes_table = $this->getAttributesTableName(); - $escaped_id = mysql_real_escape_string($file_id); - $escaped_attribute = mysql_real_escape_string($attribute_name); - $escaped_value = mysql_real_escape_string('return ' . var_export($attribute_value, true) . ';'); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); + $escaped_attribute = mysql_real_escape_string($attribute_name, $this->db_link); + $escaped_value = mysql_real_escape_string('return ' . var_export($attribute_value, true) . ';', $this->db_link); if ($result = mysql_query("SELECT `value` FROM $attributes_table WHERE `id` = '$escaped_id' AND `attribute` = '$escaped_attribute'", $this->db_link)) { if (mysql_num_rows($result) == 0) { @@ -197,9 +197,9 @@ $file_id = $this->getUniqueId(); $files_table = $this->getFilesTableName(); - $escaped_id = mysql_real_escape_string($file_id); - $escaped_content = mysql_real_escape_string(file_get_contents($source)); - $escaped_order = mysql_real_escape_string($this->getNextOrder()); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); + $escaped_content = mysql_real_escape_string(file_get_contents($source), $this->db_link); + $escaped_order = mysql_real_escape_string($this->getNextOrder(), $this->db_link); if (mysql_query("INSERT INTO $files_table (`id`, `content`, `order`) VALUES ('$escaped_id', '$escaped_content', '$escaped_order')", $this->db_link)) { @@ -235,8 +235,8 @@ } // if $files_table = $this->getFilesTableName(); - $escaped_id = mysql_real_escape_string($file_id); - $escaped_content = mysql_real_escape_string(file_get_contents($source)); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); + $escaped_content = mysql_real_escape_string(file_get_contents($source), $this->db_link); if (mysql_query("UPDATE $files_table SET `content` = '$escaped_content' WHERE `id` = '$escaped_id'", $this->db_link)) { return true; @@ -260,7 +260,7 @@ $files_table = $this->getFilesTableName(); $attributes_table = $this->getAttributesTableName(); - $escaped_id = mysql_real_escape_string($file_id); + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); mysql_query("BEGIN WORK", $this->db_link); if (!mysql_query("DELETE FROM $files_table WHERE `id` = '$escaped_id'", $this->db_link)) { @@ -268,11 +268,11 @@ } // if if (!mysql_query("DELETE FROM $attributes_table WHERE `id` = '$escaped_id'", $this->db_link)) { - mysql_query('ROLLBACK'); + mysql_query('ROLLBACK', $this->db_link); throw new FileRepositoryDeleteError($file); } // if - return mysql_query("COMMIT"); + return mysql_query("COMMIT", $this->db_link); } // deleteFile /** @@ -288,7 +288,7 @@ mysql_query("BEGIN WORK", $this->db_link); mysql_query("DELETE FROM $files_table", $this->db_link); mysql_query("DELETE FROM $attributes_table", $this->db_link); - mysql_query("COMMIT"); + mysql_query("COMMIT", $this->db_link); } // cleanUp /** @@ -299,8 +299,8 @@ */ function isInRepository($file_id) { $files_table = $this->getFilesTableName(); - $escaped_id = mysql_real_escape_string($file_id); - if ($result = mysql_query("SELECT COUNT(`id`) AS 'row_count' FROM $files_table WHERE `id` = '$escaped_id'")) { + $escaped_id = mysql_real_escape_string($file_id, $this->db_link); + if ($result = mysql_query("SELECT COUNT(`id`) AS 'row_count' FROM $files_table WHERE `id` = '$escaped_id'", $this->db_link)) { if ($row = mysql_fetch_assoc($result)) { return (boolean) $row['row_count']; } // if @@ -344,7 +344,7 @@ $files_table = $this->getFilesTableName(); do { $id = sha1(uniqid(rand(), true)); - $escaped_id = mysql_real_escape_string($id); + $escaped_id = mysql_real_escape_string($id, $this->db_link); if ($result = mysql_query("SELECT COUNT(`id`) AS 'row_count' FROM $files_table WHERE `id` = '$escaped_id'", $this->db_link)) { $row = mysql_fetch_assoc($result); if (!is_array($row) || !isset($row['row_count'])) $row['row_count'] = 0;