....................................../////.===Hehe-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 : 172.67.169.23  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.3
System : Linux 4e27b89abc44 6.8.0-147-generic #147-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 24 11:33:16 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /sites/xo-fab.com/www/graphmailerwp/wp-content/plugins/wpo365-msgraphmailer/Core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /sites/xo-fab.com/www/graphmailerwp/wp-content/plugins/wpo365-msgraphmailer/Core/Url_Helpers.php
<?php

namespace Wpo\Core;

use \Wpo\Core\WordPress_Helpers;
use \Wpo\Services\Authentication_Service;
use \Wpo\Services\Error_Service;
use \Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;
use Wpo\Services\Request_Service;

// Prevent public access to this script
defined('ABSPATH') or die();

if (!class_exists('\Wpo\Core\Url_Helpers')) {

    class Url_Helpers
    {

        /**
         * Helper method to (try) help ensure that the path segment given ends with a trailing slash.
         * 
         * @since 1.0
         * 
         * @param $url string Path that should end with a slash
         * @return string Path with trailing slash if appropriate
         */
        public static function ensure_trailing_slash_path($path)
        {
            $path = WordPress_Helpers::trim($path, '/');
            $path_segments = explode('/', $path);
            $segments_count = count($path_segments);
            if ($segments_count > 0 && false === WordPress_Helpers::stripos($path_segments[$segments_count - 1], '.')) {
                $is_root = empty($path);
                return $is_root
                    ? '/'
                    : '/' . implode('/', $path_segments) . '/';
            }
            return '/' . $path;
        }

        /**
         * Helper method to (try) help ensure that the url given ends with a trailing slash.
         * 
         * @since 1.0
         * 
         * @param $url string Url that should end with a slash
         * @return string Url with trailing slash if appropriate
         */
        public static function ensure_trailing_slash_url($url)
        {

            if (empty($url) || !is_string($url)) {
                return null;
            }

            $parsed_url = parse_url($url);
            $resulting_url = '';

            if (!empty($parsed_url['scheme'])) {
                $resulting_url .= $parsed_url['scheme'];
            } else {
                return null;
            }

            $resulting_url .= ('://');

            if (!empty($parsed_url['user']) && !empty($parsed_url['pass'])) {
                $resulting_url .= ($parsed_url['user'] . ':' . $parsed_url['pass'] . '@');
            }

            if (!empty($parsed_url['host'])) {
                $resulting_url .= $parsed_url['host'];
            } else {
                return null;
            }

            if (!empty($parsed_url['port'])) {
                $resulting_url .= (':' . $parsed_url['port']);
            }

            if (!empty($parsed_url['path'])) {
                $resulting_url .= self::ensure_trailing_slash_path($parsed_url['path']);
            } else {
                $resulting_url .= '/';
            }

            if (!empty($parsed_url['query'])) {
                $resulting_url .= ('?' . $parsed_url['query']);
            }

            if (!empty($parsed_url['fragment'])) {
                $resulting_url .= ('#' . $parsed_url['fragment']);
            }

            return $resulting_url;
        }

        /**
         * Helper method to determine whether the current URL is the WP REST API.
         * 
         * @since 7.12
         *
         * @return boolean true if the current URL is for the WP REST API otherwise false.
         */
        public static function is_wp_rest_api()
        {
            $rest_url = \get_rest_url();
            $rest_url_wo_protocol = \substr($rest_url, WordPress_Helpers::stripos($rest_url, '://') + 3);

            $current_url = $GLOBALS['WPO_CONFIG']['url_info']['current_url'];
            $current_url_wo_protocol = \substr($current_url, WordPress_Helpers::stripos($current_url, '://') + 3);

            if (WordPress_Helpers::stripos($current_url_wo_protocol, $rest_url_wo_protocol) === 0) {
                return true;
            }

            return false;
        }

        /**
         * Will check whether request is for WP REST API and if yes
         * if a basic authentication header is present (without proofing it).
         * 
         * @since 7.12
         * 
         * @return boolean true if found, otherwise false
         */
        public static function is_basic_auth_api_request()
        {

            if (false === self::is_wp_rest_api()) {
                return false;
            }

            $headers = getallheaders();
            $headers_to_lower = array_change_key_case($headers, CASE_LOWER);

            return (isset($headers_to_lower['authorization']) && WordPress_Helpers::stripos($headers_to_lower['authorization'], 'basic') === 0);
        }

        /**
         * Adds custom wp query vars
         * 
         * @since 3.6
         * 
         * @param Array $vars existing wp query vars
         * @return Array updated $vars that now includes custom wp query vars
         */
        public static function add_query_vars_filter($vars)
        {

            $vars[] = 'login_errors';
            $vars[] = 'stnu'; // show table new users
            $vars[] = 'stne'; // show table existing users
            $vars[] = 'stou'; // show table old users
            $vars[] = 'sjs';  // sync job status
            $vars[] = 'redirect_to';  // redirect to after successfull authentication
            return $vars;
        }

        /**
         * Get's WordPress default (and possibly custom) login URLs.
         * 
         * @since 7.17
         * 
         * @return array Assoc. array with custom login url (possibly empty string) and default login url. 
         */
        public static function get_login_urls()
        {
            $default_login_url = \wp_login_url();
            $custom_login_url = Options_Service::get_global_string_var('custom_login_url');

            // Custom login url must be an absolute URL
            if (WordPress_Helpers::stripos($custom_login_url, 'http') !== 0) {

                return array(
                    'custom_login_url' => '',
                    'default_login_url' => $default_login_url,
                );
            }

            // Custom login url should not accept a query string
            if (false !== WordPress_Helpers::stripos($custom_login_url, '?')) {
                $custom_login_url_arr = explode('?', $custom_login_url);
                $custom_login_url = $custom_login_url_arr[0];
            }

            // Custom login url should not accept a hash
            if (false !== WordPress_Helpers::stripos($custom_login_url, '#')) {
                $custom_login_url_arr = explode($custom_login_url, '#');
                $custom_login_url = $custom_login_url_arr[0];
            }

            $custom_login_url = self::ensure_trailing_slash_url($custom_login_url);

            return array(
                'custom_login_url' => $custom_login_url,
                'default_login_url' => $default_login_url,
            );
        }

        /**
         * Gets the custom login url if configured and otherwise the default login URL is returned.
         * 
         * @since 7.17
         * 
         * @return string Returns custom login url if configured and otherwise the default login URL.
         */
        public static function get_preferred_login_url()
        {
            $login_urls = self::get_login_urls();

            return !empty($login_urls['custom_login_url'])
                ? $login_urls['custom_login_url']
                : $login_urls['default_login_url'];
        }

        /**
         * Helper method to determine whether the current URL is the login form.
         * 
         * @since 7.11
         * 
         * @return boolean true if the current form is the wp login form.
         */
        public static function is_wp_login($uri = NULL)
        {

            if (empty($uri)) {
                $uri = $GLOBALS['WPO_CONFIG']['url_info']['request_uri'];
            }

            $login_urls = self::get_login_urls();

            array_walk($login_urls, function (&$value, $key) {
                WordPress_Helpers::rtrim($value, '/');
            });

            $custom_login_url_path = !empty($login_urls['custom_login_url'])
                ? parse_url($login_urls['custom_login_url'], PHP_URL_PATH)
                : '';
            $custom_login_url_detected = !empty($custom_login_url_path)
                && false !== WordPress_Helpers::stripos($uri,  $custom_login_url_path);

            $default_login_url_path = parse_url($login_urls['default_login_url'], PHP_URL_PATH);
            $default_login_url_detected = !empty($default_login_url_path) && false !== WordPress_Helpers::stripos($uri,  $default_login_url_path);

            return ($custom_login_url_detected || $default_login_url_detected);
        }

        /**
         * Checks whether headers are sent before trying to redirect and if sent falls
         * back to an alternative method
         * 
         * @since 4.3
         * 
         * @param string $url URL to redirect to
         * @return void
         */
        public static function force_redirect($url)
        {
            Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);

            $location = wp_sanitize_redirect($url);

            if (false === WordPress_Helpers::strpos($location, '?') && false === WordPress_Helpers::strpos($location, '#')) {
                $location = self::ensure_trailing_slash_url($location);
            }

            Log_Service::write_log('DEBUG', __METHOD__ . ' -> Redirecting to ' . $location);

            if (headers_sent()) {
                Log_Service::write_log('DEBUG', __METHOD__ . ' -> Headers sent when trying to redirect user to ' . $url);
                echo '<script type="text/javascript">';
                echo 'window.location.href="' . $location . '";';
                echo '</script>';
                echo '<noscript>';
                echo '<meta http-equiv="refresh" content="0;url=' . $location . '" />';
                echo '</noscript>';
                exit();
            }

            wp_redirect($url); // Will call wp_sanitize_redirect
            exit();
        }

        /**
         * Helper method to determine the redirect URL which can either be the last page
         * the user visited before authentication stored in the posted state property, or
         * if configured the goto_after_signon_url or in case none of these apply the WordPress
         * home URL. This method can be called from the wpo_redirect_url filter.
         * 
         * @since 7.1
         * 
         * @return string URL to send the user once authentication completed
         */
        public static function get_redirect_url($site_url)
        {
            Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);

            $request_service = Request_Service::get_instance();
            $request = $request_service->get_request($GLOBALS['WPO_CONFIG']['request_id']);

            // Initially set to state but make sure it's not the login URL and if it is then 
            // take the goto_after_signon_url if configured at all

            $state_url = $request->get_item('state');
            $relay_state_url = $request->get_item('relay_state');
            $goto_after_signon_url = Options_Service::get_global_string_var('goto_after_signon_url');

            if (!empty($state_url)) {
                $redirect_url = false === self::is_wp_login($state_url)
                    ? $state_url
                    : (
                        (!empty($goto_after_signon_url)
                            ? $goto_after_signon_url
                            : $site_url)
                    );
            } elseif (!empty($relay_state_url)) {
                $redirect_url = false === self::is_wp_login($relay_state_url)
                    ? $relay_state_url
                    : (
                        (!empty($goto_after_signon_url)
                            ? $goto_after_signon_url
                            : $site_url)
                    );
            } else {
                $redirect_url = $site_url;
            }

            return $redirect_url;
        }

        public static function goto_after($wpo_usr)
        {
            Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);

            // Get URL and redirect user (default is the WordPress homepage)
            $redirect_url = $GLOBALS['WPO_CONFIG']['url_info']['wp_site_url'];

            if (\class_exists('\Wpo\Services\Redirect_Service') && \method_exists('\Wpo\Services\Redirect_Service', 'get_redirect_url')) {
                $redirect_url = \Wpo\Services\Redirect_Service::get_redirect_url($redirect_url, $wpo_usr->groups, $wpo_usr->created);
            } else {
                $redirect_url = self::get_redirect_url($redirect_url);
            }

            /**
             * @since 32.0  Add support for login_redirect filter
             */

            $wp_usr = wp_get_current_user();
            $redirect_url = apply_filters('login_redirect', $redirect_url, $redirect_url, $wp_usr);

            /**
             * @since 24.0 Filters the necessity of conducting the URL check below.
             */

            if (true === apply_filters('wpo365/url_check/skip', false)) {
                self::force_redirect($redirect_url);
            }

            $aad_redirect_uri = Options_Service::get_aad_option('redirect_url');
            $aad_redirect_url = Options_Service::get_global_boolean_var('use_saml')
                ? Options_Service::get_aad_option('saml_sp_acs_url')
                : $aad_redirect_uri;

            /**
             * @since 24.0 Filters the AAD Redirect URI e.g. to set it dynamically to the current host.
             */

            $aad_redirect_url = apply_filters('wpo365/aad/redirect_uri', $aad_redirect_url);

            if (WordPress_Helpers::stripos($aad_redirect_url, 'https://') !== false && WordPress_Helpers::stripos($redirect_url, 'http://') === 0) {
                Log_Service::write_log('WARN', __METHOD__ . ' -> Please update your htaccess or similar and ensure that users can only access your website via https:// (URL requested by the user: ' . $redirect_url . ').');
                $redirect_url = str_replace('http://', 'https://', $redirect_url);
            }

            /**
             * @since 33.0 Use WordPress' builtin API to validate the Redirect URL.
             */

            $cookie_domain_host = defined('COOKIE_DOMAIN') && false !== COOKIE_DOMAIN ? WordPress_Helpers::ltrim(COOKIE_DOMAIN, '.') : null;

            if (!empty($cookie_domain_host)) {
                add_filter('allowed_redirect_hosts', function ($hosts, $host) use ($cookie_domain_host) {
                    $hosts[] = $cookie_domain_host;
                    return $hosts;
                }, 10, 2);
            }

            $goto_after = wp_validate_redirect($redirect_url, $aad_redirect_url);

            // Check whether WordPress is installed in subdirectory

            if (!empty($GLOBALS['WPO_CONFIG']['url_info']['wp_site_path'])) {

                if (false === WordPress_Helpers::stripos($goto_after, $GLOBALS['WPO_CONFIG']['url_info']['wp_site_path'])) {
                    $goto_after = $aad_redirect_url;
                }
            }

            if (!0 === strcasecmp(rtrim($goto_after, '/'), rtrim($redirect_url, '/'))) {
                Log_Service::write_log('ERROR', sprintf(
                    '%s -> WPO365 has prevented to redirect a user (that just successfully signed in with Microsoft) to an invalid URL [%s]. The user will instead remain at the Entra Redirect URI [%s].',
                    __METHOD__,
                    $redirect_url,
                    $aad_redirect_url
                ));
            }

            Url_Helpers::force_redirect($goto_after);
        }

        /**
         * Ensures that the input string starts with a leading forward slash "/".
         * 
         * @since 14.0
         * 
         * @param string $string Input string that will be returned with a leading slash.
         * @return string Input string with a leading slash.
         */
        public static function leadingslashit($str)
        {
            return '/' . WordPress_Helpers::ltrim($str, '/');
        }

        /**
         * Remove the protocol and www from a URL e.g. https://www.your-site.com/ becomes
         * ://your-site.com/
         */
        public static function remove_protocol_and_www($url)
        {
            $wo_https = \str_replace('https', '', $url);
            $wo_http = \str_replace('http', '', $wo_https);
            return \str_replace('www.', '', $wo_http);
        }

        /**
         * Helper to make it easier to compare URLs.
         * 
         * @param mixed $url 
         * @return string 
         */
        public static function undress_url($url)
        {
            $url = strtok($url, '?');
            $url = untrailingslashit($url);
            $url = str_replace('https://', '', $url);
            $url = str_replace('http://', '', $url);
            return $url;
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit