Autor | Zpráva | ||
---|---|---|---|
Dautfg Profil * |
#1 · Zasláno: 29. 4. 2010, 18:57:06
Pěkný den, prosím o pomoc s přepsáním kousku kódu, kde je použita v PHP 5.3 nepodporovaná funkce ereg. Jsem trubka a podle manuálnu jsem to prostě nedal. Jedná se o SPMG galerii zatím není fix a já bych ptřeboval rozchodit tuto galerii na serveru s PHP 5.3 Původní kód je tento:
################################################################################ # Checks if the filname exists, refers to a picture associated to a thumbnail # and is granted the necessary access rigths function spgm_IsPicture($strPictureFileName, $strGalleryId) { global $spgm_cfg; $strPicturePath = DIR_GAL.$strGalleryId.'/'.$strPictureFileName; $strThumbnailPath = DIR_GAL.$strGalleryId.'/'.PREF_THUMB.$strPictureFileName; if ( defined('DIR_THUMBS') ) { $strThumbnailPath = DIR_GAL.$strGalleryId.'/'.DIR_THUMBS.PREF_THUMB.$strPictureFileName; } spgm_Trace( '<p>function spgm_IsPicture</p>'."\n" .'strPictureFileName: '.$strPictureFileName.'<br />'."\n" .'strGalleryId: '.$strGalleryId.'<br />'."\n" .'strPicturePath: '.$strPicturePath.'<br />'."\n" .'strThumbnailPath: '.$strThumbnailPath.'<br />'."\n" ); // check filename patterns if ( PREF_THUMB != '' AND eregi('^'.PREF_THUMB.'*', $strPictureFileName) ) return false; $validated = false; $extnb = count($spgm_cfg['global']['supportedExtensions']); for ($i=0; $i<$extnb; $i++) { if ( eregi($spgm_cfg['global']['supportedExtensions'][$i].'$', $strPictureFileName) ) { $validated = true; break; } } if (! $validated) return false; // does it exist, is it a regular file and does it have the expected permissions ? if (! spgm_CheckPerms($strPicturePath) ) { return false; } // an associated thumbnail is required... same job again ! if (! spgm_CheckPerms($strThumbnailPath) ) { spgm_Warning( $strPicturePath.': '.WARNMSG_THUMBNAIL_UNREADABLE.'<br />' ); return false; } return true; } ############################################################################## # Checks if the directory corresponding the gallery is well-formed, exists # and is granted the necessary access rights # $galid can be empty function spgm_IsGallery($strGalleryId) { global $spgm_cfg; $strPathToPictures = DIR_GAL.$strGalleryId; spgm_Trace( '<p>function spgm_IsGallery</p>'."\n" .'strGalleryId: '.$strGalleryId.'<br />'."\n" .'strPathToPictures: '.$strPathToPictures.'<br />'."\n" ); // searching for hazardous patterns if ( ereg('^/', $strGalleryId) || ereg('\.\.', $strGalleryId) || ereg('/$', $strGalleryId) ) { return false; } } Předem děkuji za pomoc. |
||
bohyn Profil |
#2 · Zasláno: 29. 4. 2010, 19:08:09 · Upravil/a: bohyn
Dautfg:
Většinou stačí jen ereg výraz zabalit do "oddělovačů" (třeba ~). ereg('\.\.', $strGalleryId); preg_match('~\.\.~', $strGalleryId); // case sensitive preg_match('~\.\.~i', $strGalleryId); // case insensitive Pokud něco přestane fungovat tak pošli konkrétní dotaz. |
||
Dautfg Profil * |
#3 · Zasláno: 29. 4. 2010, 19:33:43
bohyn:Díky to jsem udělal, vyhazuje to už jen chybu :Warning: preg_match() [function.preg-match]: No ending delimiter '.' found in C:\wamp\www\mce\galerie\spgm.php on line 410
je to tento řádek když to zkusím nějak"obalit" háže to parse error if ( preg_match($spgm_cfg['global']['supportedExtensions'][$i].'$', $strPictureFileName) ) { |
||
bohyn Profil |
#4 · Zasláno: 29. 4. 2010, 19:57:50
Dautfg:
Musíš přídat ty oddělovače. A v původním kódu bylo eregi tak za ukončovací ~ přidej ještě i (tedy ~i). if ( preg_match('~'.$spgm_cfg['global']['supportedExtensions'][$i].'$~i', $strPictureFileName) ) { |
||
Dautfg Profil * |
#5 · Zasláno: 29. 4. 2010, 20:04:34
Děkuji ó mocný :-) Vše funguje perfektně.
|
||
Časová prodleva: 14 let
|
0