....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 51.91.236.193  /  Your IP : 216.73.216.177
Web Server : Apache
System : Linux webm019.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : thillelirn ( 8290)
PHP Version : 8.0.30
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/t/h/i/thillelirn/www/wp-content/plugins/imagify/inc/classes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/t/h/i/thillelirn/www/wp-content/plugins/imagify/inc/classes//class-imagify-files-scan.php
<?php
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );

/**
 * Class handling everything that is related to "custom folders optimization".
 *
 * @since  1.7
 * @author Grégory Viguier
 */
class Imagify_Files_Scan {

	/**
	 * Class version.
	 *
	 * @var    string
	 * @since  1.7
	 * @author Grégory Viguier
	 */
	const VERSION = '1.1.1';

	/**
	 * Get files (optimizable by Imagify) recursively from a specific folder.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $folder An absolute path to a folder.
	 * @return array|object   An array of absolute paths. A WP_Error object on error.
	 */
	public static function get_files_from_folder( $folder ) {
		$filesystem = imagify_get_filesystem();

		// Formate and validate the folder path.
		if ( ! is_string( $folder ) ) {
			return new WP_Error( 'invalid_folder', __( 'Invalid folder.', 'imagify' ) );
		}

		$folder = realpath( $folder );

		if ( ! $folder ) {
			return new WP_Error( 'folder_not_exists', __( 'This folder does not exist.', 'imagify' ) );
		}

		if ( ! $filesystem->is_dir( $folder ) ) {
			return new WP_Error( 'not_a_folder', __( 'This file is not a folder.', 'imagify' ) );
		}

		if ( self::is_path_forbidden( trailingslashit( $folder ) ) ) {
			return new WP_Error( 'folder_forbidden', __( 'This folder is not allowed.', 'imagify' ) );
		}

		// Finally we made all our validations.
		if ( $filesystem->is_site_root( $folder ) ) {
			// For the site's root, we don't look in sub-folders.
			$dir    = new DirectoryIterator( $folder );
			$dir    = new Imagify_Files_Iterator( $dir, false );
			$images = array();

			foreach ( new IteratorIterator( $dir ) as $file ) {
				$images[] = $file->getPathname();
			}

			return $images;
		}

		/**
		 * 4096 stands for FilesystemIterator::SKIP_DOTS, which was introduced in php 5.3.0.
		 * 8192 stands for FilesystemIterator::UNIX_PATHS, which was introduced in php 5.3.0.
		 */
		$dir    = new RecursiveDirectoryIterator( $folder, 4096 | 8192 );
		$dir    = new Imagify_Files_Recursive_Iterator( $dir );
		$images = new RecursiveIteratorIterator( $dir );
		$images = array_keys( iterator_to_array( $images ) );

		return $images;
	}


	/** ----------------------------------------------------------------------------------------- */
	/** FORBIDDEN FOLDERS AND FILES ============================================================= */
	/** ----------------------------------------------------------------------------------------- */

	/**
	 * Tell if a path is autorized.
	 * When testing a folder, the path MUST have a trailing slash.
	 *
	 * @since  1.7.1
	 * @since  1.8 The path must have a trailing slash if for a folder.
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path A file or folder absolute path.
	 * @return bool
	 */
	public static function is_path_autorized( $file_path ) {
		return ! self::is_path_forbidden( $file_path );
	}

	/**
	 * Tell if a path is forbidden.
	 * When testing a folder, the path MUST have a trailing slash.
	 *
	 * @since  1.7
	 * @since  1.8 The path must have a trailing slash if  for a folder.
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path A file or folder absolute path.
	 * @return bool
	 */
	public static function is_path_forbidden( $file_path ) {
		static $folders;

		$filesystem = imagify_get_filesystem();

		if ( self::is_filename_forbidden( $filesystem->file_name( $file_path ) ) ) {
			return true;
		}

		if ( $filesystem->is_symlinked( $file_path ) ) {
			// Files outside the site's folder are forbidden.
			return true;
		}

		if ( ! isset( $folders ) ) {
			$folders = self::get_forbidden_folders();
			$folders = array_map( 'strtolower', $folders );
			$folders = array_flip( $folders );
		}

		$file_path = self::normalize_path_for_comparison( $file_path );

		if ( isset( $folders[ $file_path ] ) ) {
			return true;
		}

		$delim = Imagify_Filesystem::PATTERN_DELIMITER;

		foreach ( self::get_forbidden_folder_patterns() as $pattern ) {
			if ( preg_match( $delim . '^' . $pattern . $delim, $file_path ) ) {
				return true;
			}
		}

		foreach ( $folders as $folder => $i ) {
			if ( strpos( $file_path, $folder ) === 0 ) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Get the list of folders where Imagify won't look for files to optimize.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return array A list of absolute paths.
	 */
	public static function get_forbidden_folders() {
		static $folders;

		if ( isset( $folders ) ) {
			return $folders;
		}

		$filesystem = imagify_get_filesystem();
		$site_root  = $filesystem->get_site_root();
		$abspath    = $filesystem->get_abspath();
		$folders    = array(
			// Server.
			$site_root . 'cgi-bin',                        // `cgi-bin`
			// WordPress.
			$abspath . 'wp-admin',                         // `wp-admin`
			$abspath . WPINC,                              // `wp-includes`
			WP_CONTENT_DIR . '/mu-plugins',                // MU plugins.
			WP_CONTENT_DIR . '/upgrade',                   // Upgrade.
			// Plugins.
			WP_CONTENT_DIR . '/bps-backup',                // BulletProof Security.
			self::get_ewww_tools_path(),                   // EWWW: /wp-content/ewww.
			WP_CONTENT_DIR . '/ngg',                       // NextGen Gallery.
			WP_CONTENT_DIR . '/ngg_styles',                // NextGen Gallery.
			WP_CONTENT_DIR . '/w3tc-config',               // W3 Total Cache.
			WP_CONTENT_DIR . '/wfcache',                   // WP Fastest Cache.
			WP_CONTENT_DIR . '/wp-rocket-config',          // WP Rocket.
			Imagify_Custom_Folders::get_backup_dir_path(), // Imagify "Custom folders" backup: /imagify-backup.
			IMAGIFY_PATH,                                  // Imagify plugin: /wp-content/plugins/imagify.
			self::get_shortpixel_path(),                   // ShortPixel: /wp-content/uploads/ShortpixelBackups.
		);

		if ( ! is_multisite() ) {
			$uploads_dir   = $filesystem->get_upload_basedir( true );
			$ngg_galleries = self::get_ngg_galleries_path();

			if ( $ngg_galleries ) {
				$folders[] = $ngg_galleries;                   // NextGen Gallery: /wp-content/gallery.
			}

			$folders[] = $uploads_dir . 'formidable';          // Formidable Forms: /wp-content/uploads/formidable.
			$folders[] = get_imagify_backup_dir_path( true );  // Imagify Media Library backup: /wp-content/uploads/backup.
			$folders[] = self::get_wc_logs_path();             // WooCommerce Logs: /wp-content/uploads/wc-logs.
			$folders[] = $uploads_dir . 'woocommerce_uploads'; // WooCommerce uploads: /wp-content/uploads/woocommerce_uploads.
		}

		$folders = array_map( array( $filesystem, 'normalize_dir_path' ), $folders );

		/**
		 * Add folders to the list of forbidden ones.
		 *
		 * @since  1.7
		 * @author Grégory Viguier
		 *
		 * @param array $added_folders List of absolute paths.
		 * @param array $folders       List of folders already forbidden.
		 */
		$added_folders = apply_filters( 'imagify_add_forbidden_folders', array(), $folders );
		$added_folders = array_filter( (array) $added_folders );
		$added_folders = array_filter( $added_folders, 'is_string' );

		if ( ! $added_folders ) {
			return $folders;
		}

		$added_folders = array_map( array( $filesystem, 'normalize_dir_path' ), $added_folders );

		$folders = array_merge( $folders, $added_folders );
		$folders = array_flip( array_flip( $folders ) );

		return $folders;
	}

	/**
	 * Get the list of folder patterns where Imagify won't look for files to optimize. This is meant for paths that are dynamic.
	 * `^` will be prepended to each pattern (aka, the pattern must match an absolute path).
	 * Pattern delimiter is `Imagify_Filesystem::PATTERN_DELIMITER`.
	 * Paths tested against these patterns are lower-cased.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return array A list of regex patterns.
	 */
	public static function get_forbidden_folder_patterns() {
		static $folders;

		if ( isset( $folders ) ) {
			return $folders;
		}

		$folders = array();

		// Media Library: /wp\-content/uploads/(sites/\d+/)?\d{4}/\d{2}/.
		$folders[] = self::get_media_library_pattern();

		if ( is_multisite() ) {
			/**
			 * On multisite we can't exclude Imagify's library backup folders, or any other folder located in the uploads folders (created by other plugins): there are too many ways it can fail.
			 * Only exception we're aware of so far is NextGen Gallery, because it provides a clear pattern to use.
			 */
			$ngg_galleries = self::get_ngg_galleries_multisite_pattern();

			if ( $ngg_galleries ) {
				// NextGen Gallery: /wp\-content/uploads/sites/\d+/nggallery/.
				$folders[] = $ngg_galleries;
			}
		}

		/**
		 * Add folder patterns to the list of forbidden ones.
		 * Don't forget to use `Imagify_Files_Scan::normalize_path_for_regex( $path )`!
		 *
		 * @since  1.7
		 * @author Grégory Viguier
		 *
		 * @param array $added_folders List of patterns.
		 * @param array $folders       List of patterns already forbidden.
		 */
		$added_folders = apply_filters( 'imagify_add_forbidden_folder_patterns', array(), $folders );
		$added_folders = array_filter( (array) $added_folders );
		$added_folders = array_filter( $added_folders, 'is_string' );

		if ( ! $added_folders ) {
			return $folders;
		}

		$folders = array_merge( $folders, $added_folders );
		$folders = array_flip( array_flip( $folders ) );

		return $folders;
	}

	/**
	 * Tell if a file/folder name is forbidden.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_name A file or folder name.
	 * @return bool
	 */
	public static function is_filename_forbidden( $file_name ) {
		static $file_names;

		if ( ! isset( $file_names ) ) {
			$file_names = array_flip( self::get_forbidden_file_names() );
		}

		return isset( $file_names[ strtolower( $file_name ) ] );
	}

	/**
	 * Get the list of file names that Imagify won't optimize.
	 * It can contain folder names. Names are case-lowered.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return array A list of file names
	 */
	public static function get_forbidden_file_names() {
		static $file_names;

		if ( isset( $file_names ) ) {
			return $file_names;
		}

		$file_names = array(
			'.',
			'..',
			'.DS_Store',
			'.git',
			'.svn',
			'backup',
			'backups',
			'cache',
			'lang',
			'langs',
			'languages',
			'node_modules',
			'Thumbs.db',
		);
		$file_names = array_map( 'strtolower', $file_names );

		/**
		 * Add file names to the list of forbidden ones.
		 *
		 * @since  1.7
		 * @author Grégory Viguier
		 *
		 * @param array $added_file_names List of file names.
		 * @param array $file_names       List of file names already forbidden.
		 */
		$added_file_names = apply_filters( 'imagify_add_forbidden_file_names', array(), $file_names );

		if ( ! $added_file_names || ! is_array( $added_file_names ) ) {
			return $file_names;
		}

		$added_file_names = array_filter( $added_file_names, 'is_string' );
		$added_file_names = array_map( 'strtolower', $added_file_names );

		$file_names = array_merge( $file_names, $added_file_names );
		$file_names = array_flip( array_flip( $file_names ) );

		return $file_names;
	}


	/** ----------------------------------------------------------------------------------------- */
	/** PLACEHOLDERS ============================================================================ */
	/** ----------------------------------------------------------------------------------------- */

	/**
	 * Add a placeholder to a path.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path An absolute path.
	 * @return string            A "placeholdered" path.
	 */
	public static function add_placeholder( $file_path ) {
		$file_path = wp_normalize_path( $file_path );
		$locations = self::get_placeholder_paths();

		foreach ( $locations as $placeholder => $location_path ) {
			if ( strpos( $file_path, $location_path ) === 0 ) {
				return preg_replace( '@^' . preg_quote( $location_path, '@' ) . '@', $placeholder, $file_path );
			}
		}

		// Should not happen.
		return $file_path;
	}

	/**
	 * Change a path with a placeholder into a real path or URL.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path A path with a placeholder.
	 * @param  string $type      What to return: 'path' or 'url'.
	 * @return string            An absolute path or a URL.
	 */
	public static function remove_placeholder( $file_path, $type = 'path' ) {
		if ( 'path' === $type ) {
			$locations = self::get_placeholder_paths();
		} else {
			$locations = self::get_placeholder_urls();
		}

		foreach ( $locations as $placeholder => $location_path ) {
			if ( strpos( $file_path, $placeholder ) === 0 ) {
				return preg_replace( '@^' . preg_quote( $placeholder, '@' ) . '@', $location_path, $file_path );
			}
		}

		// Should not happen.
		return $file_path;
	}

	/**
	 * Get array of pairs of placeholder => corresponding path.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return array
	 */
	public static function get_placeholder_paths() {
		static $replacements;

		if ( isset( $replacements ) ) {
			return $replacements;
		}

		$filesystem   = imagify_get_filesystem();
		$replacements = array(
			'{{PLUGINS}}/'    => WP_PLUGIN_DIR,
			'{{MU_PLUGINS}}/' => WPMU_PLUGIN_DIR,
			'{{THEMES}}/'     => WP_CONTENT_DIR . '/themes',
			'{{UPLOADS}}/'    => $filesystem->get_main_upload_basedir(),
			'{{CONTENT}}/'    => WP_CONTENT_DIR,
			'{{ROOT}}/'       => $filesystem->get_site_root(),
		);
		$replacements = array_map( array( $filesystem, 'normalize_dir_path' ), $replacements );

		return $replacements;
	}

	/**
	 * Get array of pairs of placeholder => corresponding URL.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return array
	 */
	public static function get_placeholder_urls() {
		static $replacements;

		if ( isset( $replacements ) ) {
			return $replacements;
		}

		$filesystem   = imagify_get_filesystem();
		$replacements = array(
			'{{PLUGINS}}/'    => plugins_url( '/' ),
			'{{MU_PLUGINS}}/' => plugins_url( '/', WPMU_PLUGIN_DIR . '/.' ),
			'{{THEMES}}/'     => content_url( 'themes/' ),
			'{{UPLOADS}}/'    => $filesystem->get_main_upload_baseurl(),
			'{{CONTENT}}/'    => content_url( '/' ),
			'{{ROOT}}/'       => $filesystem->get_site_root_url(),
		);

		return $replacements;
	}

	/**
	 * A file_exists() for paths with a placeholder.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path The file path.
	 * @return bool
	 */
	public static function placeholder_path_exists( $file_path ) {
		return imagify_get_filesystem()->is_readable( self::remove_placeholder( $file_path ) );
	}


	/** ----------------------------------------------------------------------------------------- */
	/** PATHS =================================================================================== */
	/** ----------------------------------------------------------------------------------------- */

	/**
	 * Get the path to NextGen galleries on monosites.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string|bool An absolute path. False if it can't be retrieved.
	 */
	public static function get_ngg_galleries_path() {
		$galleries_path = get_site_option( 'ngg_options' );

		if ( empty( $galleries_path['gallerypath'] ) ) {
			return false;
		}

		$filesystem     = imagify_get_filesystem();
		$galleries_path = $filesystem->normalize_dir_path( $galleries_path['gallerypath'] );
		$galleries_path = trim( $galleries_path, '/' ); // Something like `wp-content/gallery`.

		$ngg_root = defined( 'NGG_GALLERY_ROOT_TYPE' ) ? NGG_GALLERY_ROOT_TYPE : 'site';

		if ( $galleries_path && 'content' === $ngg_root ) {
			$ngg_root = $filesystem->normalize_dir_path( WP_CONTENT_DIR );
			$ngg_root = trim( $ngg_root, '/' ); // Something like `abs-path/to/wp-content`.

			$exploded_root      = explode( '/', $ngg_root );
			$exploded_galleries = explode( '/', $galleries_path );
			$first_gallery_dirname = reset( $exploded_galleries );
			$last_root_dirname     = end( $exploded_root );

			if ( $last_root_dirname === $first_gallery_dirname ) {
				array_shift( $exploded_galleries );
				$galleries_path = implode( '/', $exploded_galleries );
			}
		}

		if ( 'content' === $ngg_root ) {
			$ngg_root = $filesystem->normalize_dir_path( WP_CONTENT_DIR );
		} else {
			$ngg_root = $filesystem->get_abspath();
		}

		if ( strpos( $galleries_path, $ngg_root ) !== 0 ) {
			$galleries_path = $ngg_root . $galleries_path;
		}

		return $galleries_path . '/';
	}

	/**
	 * Get the path to WooCommerce logs on monosites.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string An absolute path.
	 */
	public static function get_wc_logs_path() {
		if ( defined( 'WC_LOG_DIR' ) ) {
			return WC_LOG_DIR;
		}

		return imagify_get_filesystem()->get_upload_basedir( true ) . 'wc-logs/';
	}

	/**
	 * Get the path to EWWW optimization tools.
	 * It is the same for all sites on multisite.
	 *
	 * @since  1.7
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string An absolute path.
	 */
	public static function get_ewww_tools_path() {
		if ( defined( 'EWWW_IMAGE_OPTIMIZER_TOOL_PATH' ) ) {
			return EWWW_IMAGE_OPTIMIZER_TOOL_PATH;
		}

		return WP_CONTENT_DIR . '/ewww/';
	}

	/**
	 * Get the path to ShortPixel backup folder.
	 * It is the same for all sites on multisite (and yes, you'll get a surprise if your upload base dir -aka uploads/sites/12/- is not 2 folders deeper than theuploads folder).
	 *
	 * @since  1.8
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string An absolute path.
	 */
	public static function get_shortpixel_path() {
		if ( defined( 'SHORTPIXEL_BACKUP_FOLDER' ) ) {
			return trailingslashit( SHORTPIXEL_BACKUP_FOLDER );
		}

		$filesystem = imagify_get_filesystem();
		$path       = $filesystem->get_upload_basedir( true );
		$path       = is_main_site() ? $path : $filesystem->dir_path( $filesystem->dir_path( $path ) );

		return $path . 'ShortpixelBackups/';
	}


	/** ----------------------------------------------------------------------------------------- */
	/** REGEX PATTERNS ========================================================================== */
	/** ----------------------------------------------------------------------------------------- */

	/**
	 * Get the regex pattern used to match the paths to the media library.
	 * Pattern delimiter is `Imagify_Filesystem::PATTERN_DELIMITER`.
	 * Paths tested against these patterns are lower-cased.
	 *
	 * @since  1.8
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string Something like `/wp\-content/uploads/(sites/\d+/)?\d{4}/\d{2}/`.
	 */
	public static function get_media_library_pattern() {
		$filesystem  = imagify_get_filesystem();
		$uploads_dir = self::normalize_path_for_regex( $filesystem->get_main_upload_basedir() );

		if ( ! is_multisite() ) {
			if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
				// In year/month folders.
				return $uploads_dir . '\d{4}/\d{2}/';
			}

			// Not in year/month folders.
			return $uploads_dir . '[^/]+$';
		}

		$pattern = $filesystem->get_multisite_uploads_subdir_pattern();

		if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
			// In year/month folders.
			return $uploads_dir . '(' . $pattern . ')?\d{4}/\d{2}/';
		}

		// Not in year/month folders.
		return $uploads_dir . '(' . $pattern . ')?[^/]+$';
	}

	/**
	 * Get the regex pattern used to match the paths to NextGen galleries on multisite.
	 * Pattern delimiter is `Imagify_Filesystem::PATTERN_DELIMITER`.
	 * Paths tested against these patterns are lower-cased.
	 *
	 * @since  1.8
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @return string|bool Something like `/wp-content/uploads/sites/\d+/nggallery/`. False if it can't be retrieved.
	 */
	public static function get_ngg_galleries_multisite_pattern() {
		$galleries_path = self::get_ngg_galleries_path(); // Something like `wp-content/uploads/sites/%BLOG_ID%/nggallery/`.

		if ( ! $galleries_path ) {
			return false;
		}

		$galleries_path = self::normalize_path_for_regex( $galleries_path );
		$galleries_path = str_replace( array( '%blog_name%', '%blog_id%' ), array( '.+', '\d+' ), $galleries_path );

		return $galleries_path;
	}


	/** ----------------------------------------------------------------------------------------- */
	/** NORMALIZATION TOOLS ===================================================================== */
	/** ----------------------------------------------------------------------------------------- */

	/**
	 * Normalize a file path, aiming for path comparison.
	 * The path is normalized and case-lowered.
	 *
	 * @since  1.7
	 * @since  1.8 No trailing slash anymore, because it can be used for files.
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path The file path.
	 * @return string            The normalized file path.
	 */
	public static function normalize_path_for_comparison( $file_path ) {
		return strtolower( wp_normalize_path( $file_path ) );
	}

	/**
	 * Normalize a file path, aiming for use in a regex pattern.
	 * The path is normalized, case-lowered, and escaped.
	 *
	 * @since  1.8
	 * @access public
	 * @author Grégory Viguier
	 *
	 * @param  string $file_path The file path.
	 * @return string            The normalized file path.
	 */
	public static function normalize_path_for_regex( $file_path ) {
		return preg_quote( imagify_get_filesystem()->normalize_path_for_comparison( $file_path ), Imagify_Filesystem::PATTERN_DELIMITER );
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit