Skip to content

Commit b5dd6c0

Browse files
committed
added reduce path function
1 parent 1a32b71 commit b5dd6c0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

system/library/functions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ function upload_image( $file, $thumb_prefix = null, $max_width = 128, $max_heigh
517517

518518

519519

520+
function reduce_path( $path ){
521+
$path = str_replace( "://", "@not_replace@", $path );
522+
$path = preg_replace( "#(/+)#", "/", $path );
523+
$path = preg_replace( "#(/\./+)#", "/", $path );
524+
$path = str_replace( "@not_replace@", "://", $path );
525+
526+
while( preg_match( '#\.\./#', $path ) ){
527+
$path = preg_replace('#\w+/\.\./#', '', $path );
528+
}
529+
return $path;
530+
}
531+
520532

521533
//-------------------------------------------------------------
522534
//

0 commit comments

Comments
 (0)