....................................../////.===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/loco-translate/src/fs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/t/h/i/thillelirn/www/wp-content/plugins/loco-translate/src/fs/File.php
<?php
/**
 * 
 */
class Loco_fs_File {
    
    /**
     * Write context for the current file path
     */
    private ?Loco_fs_FileWriter $w = null;

    /**
     * Path to file
     */
    private string $path = '';
    
    /**
     * Cached pathinfo() data 
     */
    private ?array $info = null;

    /**
     * Base path which path has been normalized against
     */
    private ?string $base = null;

    /**
     * Flag set when current path is relative
     */
    private bool $rel;


    /**
     * Check if a path is absolute and return fixed slashes for readability
     * @return string fixed path, or "" if not absolute
     */
    public static function abs( string $path ):string {
        if( '' !== $path ){
            $chr1 = substr($path,0,1);
            // return unmodified path if starts "/"
            if( '/' === $chr1 ){
                return $path;
            }
            // Windows drive path if "X:" or network path if "\\"
            $chr2 = (string) substr($path,1,1);
            if( '' !== $chr2 ){
                if( ':' === $chr2 ||  ( '\\' === $chr1 && '\\' === $chr2 ) ){
                    return strtoupper($chr1).$chr2.strtr( substr($path,2), '\\', '/' );
                }
            }
        }
        // else path is relative, so return falsy string
        return '';
    }


    /**
     * Test if a path looks absolute
     */
    public static function is_abs( string $path ):bool {
        return '' !== $path && ( '/' === $path[0] || preg_match('!^\\\\\\\\|.:\\\\!',$path) );
    }


    /**
     * Call PHP is_readable() but suppress E_WARNING when path is outside open_basedir.
     */
    public static function is_readable( string $path ):bool {
        if( '' === $path || '.' === $path[0] ){
            throw new InvalidArgumentException('Relative paths disallowed');
        }
        // Reduce PHP errors from is_readable to debug messages
        Loco_error_AdminNotices::capture(E_NOTICE|E_WARNING);
        $bool = is_readable($path);
        restore_error_handler();
        return $bool;
    }


    /**
     * Create file with initial, unvalidated path
     */    
    public function __construct( string $path ){
        $this->setPath( $path );
    }


    /**
     * Internally set path value and flag whether relative or absolute
     */
    private function setPath( string $path ):void {
        if( $fixed = self::abs($path) ){
            $path = $fixed;
            $this->rel = false;
        }
        else {
            $this->rel = true;
        }
        if( $path !== $this->path ){
            $this->path = $path;
            $this->info = null;
        }
    }


    /**
     * Return whether currently configure path is absolute 
     */
    public function isAbsolute(): bool {
        return ! $this->rel;
    }


    /**
     * @internal
     */
    public function __clone(){
        $this->cloneWriteContext( $this->w );
    }


    /**
     * Copy write context with our file reference
     */
    private function cloneWriteContext( ?Loco_fs_FileWriter $context = null ):void {
        if( $context ){
            $context = clone $context;
            $this->w = $context->setFile($this);
        }
    }


    /**
     * Get file system context for operations that *modify* the file system.
     * Read operations and operations that stat the file will always do so directly.
     */
    public function getWriteContext():Loco_fs_FileWriter {
        if( ! $this->w ){
            $this->w = new Loco_fs_FileWriter( $this );
        }
        return $this->w;
    }


    /**
     * @internal
     */
    private function pathinfo(){
        return is_array($this->info) ? $this->info : ( $this->info = pathinfo($this->path) );
    }


    /**
     * Checks if a file exists, and is within open_basedir restrictions.
     * This does NOT check if file permissions allow PHP to read it. Call $this->readable() or self::is_readable($path).
     */
    public function exists():bool {
        return file_exists($this->path);
    }


    /**
     * Check if file is writable by the current write context
     */
    public function writable():bool {
        return $this->getWriteContext()->writable();
    }


    /**
     * Check if the file exists and is readable by the current PHP process.
     */
    public function readable():bool {
        return self::is_readable($this->path);
    }


    /**
     * Check if file is removable by the current write context
     */
    public function deletable():bool {
        $parent = $this->getParent();
        if( $parent && $parent->writable() ){
            // sticky directory requires that either the file its parent is owned by effective user
            if( $parent->mode() & 01000 ){
                $writer = $this->getWriteContext();
                if( $writer->isDirect() && ( $uid = Loco_compat_PosixExtension::getuid() ) ){
                    return $uid === $this->uid() || $uid === $parent->uid();
                }
                // else delete operation won't be done directly, so can't preempt sticky problems
                // TODO is it worth comparing FTP username etc.. for ownership?
            }
            // defaulting to "deletable" based on fact that parent is writable.
            return true;
        }
        return false;
    }


    /**
     * Get owner uid
     * @return int|false
     */
    public function uid(){
        return fileowner($this->path);
    }


    /**
     * Get group gid
     * @return int|false
     */
    public function gid(){
        return filegroup($this->path);
    }


    /**
     * Check if file can't be overwritten when existent, nor created when non-existent
     * This does not check permissions recursively as directory trees are not built implicitly
     */
    public function locked():bool {
        if( $this->exists() ){
            return ! $this->writable();
        }
        if( $dir = $this->getParent() ){
            return ! $dir->writable();
        }
        return true;
    }


    /**
     * Check if full path can be built to non-existent file.
     */
    public function creatable():bool {
        $file = $this;
        while( $file = $file->getParent() ){
            if( $file->exists() ){
                return $file->writable();
            }
        }
        return false;
    }
    
    
    /**
     * Get directory name like dirname()
     */
    public function dirname():string{
        $info = $this->pathinfo();
        return $info['dirname'];
    }

    
    /**
     * Get base name like basenaame()
     */
    public function basename():string {
        $info = $this->pathinfo();
        return $info['basename'];
    }

    
    /**
     * Get file name without extension, like filename()
     */
    public function filename():string {
        $info = $this->pathinfo();
        return $info['filename'];
    }


    /**
     * Gets final file extension, e.g. "html" in "foo.php.html"
     */
    public function extension():string {
        $info = $this->pathinfo();
        return $info['extension'] ?? '';
    }


    /**
     * Gets full file extension after first dot separator, e.g. "php.html" in "foo.php.html"
     */
    public function fullExtension():string {
        $bits = explode('.',$this->basename(),2);
        return array_key_exists(1,$bits) ? $bits[1] : '';
    }


    /**
     * Get currently configure path, unmodified
     */
    public function getPath():string {
        return $this->path;
    }


    /**
     * Get file modification time as unix timestamp in seconds
     */
    public function modified():int {
        return filemtime($this->path) ?: 0;
    }


    /**
     * Get file size in bytes
     */
    public function size():int {
        return filesize($this->path) ?: 0;
    }


    /**
     * Get file mode as integer
     */
    public function mode():int {
        if( is_link($this->path) ){
            $stat = lstat( $this->path );
            $mode = $stat[2];
        }
        else {
            $mode = fileperms($this->path);
        }
        return $mode;
    }
    

    /**
     * Set file mode
     * @param int $mode file mode integer e.g 0664
     * @param bool $recursive whether to set recursively (directories)
     */
    public function chmod( int $mode, bool $recursive = false ):self {
        $this->getWriteContext()->chmod( $mode, $recursive );
        return $this->clearStat();
    }

    
    /**
     * Clear stat cache if any file data has changed
     */
    public function clearStat():self {
        $this->info = null;
        // PHP 5.3.0 Added optional clear_realpath_cache and filename parameters.
        if( version_compare( PHP_VERSION, '5.3.0', '>=' ) ){
            clearstatcache( true, $this->path );
        }
        // else no choice but to drop entire stat cache
        else {
            clearstatcache();
        }
        return $this;
    }

    
    /**
     * @return string
     */
    public function __toString(){
        return $this->getPath();
    }


    /**
     * Check if passed path is equal to ours
     * @param string|self $ref
     */
    public function equal( $ref ):bool {
        return $this->path === (string) $ref;
    }


    /**
     * Normalize path for string comparison, resolves redundant dots and slashes.
     * @param string $base path to prefix
     */
    public function normalize( string $base = '' ):string {
        if( $path = self::abs($base) ){
            $base = $path;
        }
        if( $base !== $this->base ){
            $path = $this->path;
            if( '' === $path ){
                $this->setPath($base);
            }
            else {
                if( ! $this->rel || ! $base ){
                    $b = [];
                }
                else {
                    $b = self::explode( $base, [] );
                }
                $b = self::explode( $path, $b );
                $this->setPath( implode('/',$b) );
            }
            $this->base = $base;
        }
        return $this->path;
    }


    /**
     * Get real path if file is real, but without altering internal path property.
     * Also skips call to realpath() when likely to raise E_WARNING due to open_basedir
     */
    public function getRealPath():string {
        if( $this->readable() ){
            $path = realpath( $this->getPath() );
            if( is_string($path) ){
                return $path;
            }
        }
        return '';
    }


    private static function explode( string $path, array $b ):array {
        $a = explode( '/', $path );
        foreach( $a as $i => $s ){
            if( '' === $s ){
                if( 0 !== $i ){
                    continue;
                }
            }
            if( '.' === $s ){
                continue;
            }
            if( '..' === $s ){
                if( array_pop($b) ){
                    continue;
                }
            }
            $b[] = $s;
        }
        return $b;
    }


    /**
     * Get path relative to given location, unless path is already relative
     * @param string $base Base path
     * @return string path relative to given base
     */
    public function getRelativePath( string $base ):string {
        $path = $this->normalize();
        if( self::abs($path) ){
            // base may require normalizing
            $file = new Loco_fs_File($base);
            $base = $file->normalize();
            $length = strlen($base)+1;
            // if we are below given base path, return ./relative
            if( substr($path,0,$length) === $base.'/' ){
                if( strlen($path) > $length ){
                    return substr( $path, $length );
                }
                // else paths were identical
                return '';
            }
            // else attempt to find nearest common root
            $i = 0;
            $source = explode('/',$base);
            $target = explode('/',$path);
            while( isset($source[$i]) && isset($target[$i]) && $source[$i] === $target[$i] ){
                $i++;
            }
            if( $i > 1 ){
                $depth = count($source) - $i;
                $build = array_merge( array_fill( 0, $depth, '..' ), array_slice( $target, $i ) );
                $path = implode( '/', $build );
            }
        }
        // else return unmodified
        return $path;
    }


    /**
     * Test if file is a directory
     */
    public function isDirectory():bool {
        if( $this->readable() ){
            return is_dir($this->path);
        }
        return '' === $this->extension();
    }



    /**
     * Load contents of file into a string
     */
    public function getContents():string {
        return file_get_contents($this->path);
    }


    /**
     * Check if path is under a theme directory 
     */
    public function underThemeDirectory():bool {
        return Loco_fs_Locations::getThemes()->check( $this->path );
    }


    /**
     * Check if path is under a plugin directory 
     */
    public function underPluginDirectory():bool {
        return Loco_fs_Locations::getPlugins()->check( $this->path );
    }


    /**
     * Check if path is under wp-content directory 
     */
    public function underContentDirectory():bool {
        return Loco_fs_Locations::getContent()->check( $this->path );
    }


    /**
     * Check if path is under WordPress root directory (ABSPATH) 
     */
    public function underWordPressDirectory():bool {
        return Loco_fs_Locations::getRoot()->check( $this->path );
    }


    /**
     * Check if path is under the global system directory 
     */
    public function underGlobalDirectory():bool {
        return Loco_fs_Locations::getLangs()->check( $this->path );
    }


    /**
     * @return Loco_fs_Directory|null
     */
    public function getParent():?Loco_fs_Directory {
        $dir = null;
        $path = $this->dirname();
        if( '.' !== $path && $this->path !== $path ){ 
            $dir = new Loco_fs_Directory( $path );
            $dir->cloneWriteContext( $this->w );
        }
        return $dir;
    }


    /**
     * Copy this file for real
     * @param string $dest new path
     * @throws Loco_error_WriteException
     * @return Loco_fs_File new file
     */
    public function copy( string $dest ):self {
        $copy = clone $this;
        $copy->path = $dest;
        $copy->clearStat();
        $this->getWriteContext()->copy($copy);
        return $copy;
    }


    /**
     * Move/rename this file for real
     * @param Loco_fs_File $dest target file with new path
     * @throws Loco_error_WriteException
     * @return self original file that should no longer exist
     */
    public function move( Loco_fs_File $dest ):self {
        $this->getWriteContext()->move($dest);
        return $this->clearStat();
    }


    /**
     * Delete this file for real
     * @throws Loco_error_WriteException
     */
    public function unlink():self {
        $recursive = $this->isDirectory();
        $this->getWriteContext()->delete( $recursive );
        return $this->clearStat();
    }


    /**
     * Copy this object with an alternative file extension
     * @param string $ext new extension
     */
    public function cloneExtension( string $ext ):self {
        return $this->cloneBasename( $this->filename().'.'.ltrim($ext,'.') );
    }


    /**
     * Copy this object with an alternative name under the same directory
     * @param string $name new name
     */
    public function cloneBasename( string $name ):self {
        $file = clone $this;
        $file->path = rtrim($file->dirname(),'/').'/'.$name;
        $file->info = null;
        return $file;
    }


    /**
     * Ensure full parent directory tree exists
     */
    public function createParent():?Loco_fs_Directory {
        $dir = $this->getParent();
        if( $dir instanceof Loco_fs_Directory && ! $dir->exists() ){
            $dir->mkdir();
        }
        return $dir;
    }


    /**
     * @param string $data file contents
     * @return int number of bytes written to file
     */
    public function putContents( string $data ):int {
        $this->getWriteContext()->putContents($data);
        $this->clearStat();
        return $this->size();
    }


    /**
     * Establish what part of the WordPress file system this is.
     * Value is that used by WP_Automatic_Updater::should_update.
     * @return string "core", "plugin", "theme" or "translation"
     */
    public function getUpdateType():string {
        // global languages directory root, and canonical subdirectories
        $dirpath = (string) ( $this->isDirectory() ? $this : $this->getParent() );
        $sub = Loco_fs_Locations::getLangs()->rel($dirpath);
        if( is_string($sub) && '' !== $sub ){
            list($root) = explode('/', $sub, 2 );
            if( '.' === $root || 'themes' === $root || 'plugins' === $root ){
                return 'translation';
            }
        }
        // theme and plugin locations can be at any depth
        else if( $this->underThemeDirectory() ){
            return 'theme';
        }
        else if( $this->underPluginDirectory() ){
            return 'plugin';
        }
        // core locations are under WordPress root, but not under wp-content
        else if( $this->underWordPressDirectory() && ! $this->underContentDirectory() ){
            return 'core';
        }
        // else not an update type
        return '';
    }


    /**
     * Get MD5 hash of file contents
     */
    public function md5():string {
        if( $this->exists() ) {
            return md5_file( $this->path );
        }
        else {
            return 'd41d8cd98f00b204e9800998ecf8427e';
        }
    } 

}

Youez - 2016 - github.com/yon3zu
LinuXploit