Changeset 529 for trunk

Show
Ignore:
Timestamp:
04/22/08 13:25:21 (8 months ago)
Author:
sidtheduck
Message:

Ran into troubles with mod_rewrite paths and regular expressions with characters matching regex metacharacters in filenames. Changed to a LIKE MySQL search (escaping the wildcards '%' and '_' for LIKE expressions in filenames).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plog-functions.php

    r528 r529  
    989989                if (!$picture) { 
    990990                        $filepath = join("/",$names); 
     991                        $like_match = array("_", "%"); 
     992                        $like_replace = array("\_", "\%"); 
     993                        $esc_filepath = str_replace($like_match, $like_replace, $filepath); 
    991994                        $sql = "SELECT * 
    992995                                FROM `".TABLE_PREFIX."pictures` 
    993                                 WHERE `path` RLIKE '^" . mysql_real_escape_string($filepath)."\..{3}$' 
     996                                WHERE `path` LIKE '" . mysql_real_escape_string($esc_filepath)."____' 
    994997                                        AND `parent_album`=".intval($album["id"]); 
    995998                        $result = run_query($sql);