ÿØÿà JFIF      ÿÛ „ 	 ( %!1"%)+...383-7(-.+



-%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ               ÿÄ @       !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ             ÿÄ '        1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ï
-3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéß¦$$½—šÙÜCC¯¶è8Î²–Åkèwx
LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2Þ¿Ø¯­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÃ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’×©T]
ªb—ÊîKC^×M“xùäñz¬zJ×{4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi
[0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú	Ò˜Æ}2VE•Ð€p¡Ô3Úº …h³^Ç‡ºçì¥Ánó|˜ÖˆÎˆ+«¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<Ì‰Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈÀá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ
ƒÜÒ?	:õdsÀ–3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LÇÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl
Í›G¹ÀPá¼Nc¡šÒ…ÙWÍ³œ±vÊáÐ„×9‹P‰cEØ‘™›µŸP<×g1
º©Ø¬wiÁ^l5×I/';Ë+´Z‡ÓÄFÕp[Èð’
HÄ	ó
9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ
QãñQtIeórVB,ÏÂf‹4#Îœc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ
÷jsÏ‚Ò’KÈcø(é›;k(’#ôŒQ
™C>
õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~È¦—’-$fe«"FâUˆÊwµPÏu
w+"åÉoÌ¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ÉdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt
·K¢ÅÅ·¥RÄÊÉbKn
N­R2g$VµÕó
Qr#–ÓZUÏð0ÎtÙÀœz
ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Î”â‘ËØ´IˆÓ°Ë‰ÞM<J•›C=ìu*Ü§„Ã¤GËŠô;5ŒÁ£ñùä¬6Ì2¦‘žh¸Rº<Õš%÷ …Ç	‚g‡.
>3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z
à¾]
üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.Å¾„æ“I[ª+·zÐÒÚ,½Ð»¶€C›7jk$à¹–€Ž¾ÅÙpp¶ÍþéÎ¤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ä†f× æ¢Æ±qWÄ±[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGŽ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ Æˆæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„
g01¬„åEMè›‡Ã\6µE›‘fÙO	k÷CºnÓ1`iîÒ²áÂ!ÑLÄÿ 
³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#»
Ç\……ßïIœÉ$¸ÎñÍ®ÔHÃ‡	Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡	—JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ	5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*ç¦ŒÉù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnÝ³vðÖKE¼‚ »mà ÷f®:Ë™–4rð¡4` Ü¹çž~‹C=œ…¾Ïj|VDtK.ƒ"9	Ï
­–éXá³6WÒïIL-Ð‡
Ç
PK     ä‹U]*¤	Õ        public/index.phpnu „[µü¤        <?php // Silence is goldenPK     ä‹U]¿¤V;  ;  -  public/class-email-before-download-public.phpnu „[µü¤        <?php

/**
 * The public-facing functionality of the plugin.
 *
 * Defines the plugin name, version, and hooks.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/public
 * @author     M & S Consulting
 */
class Email_Before_Download_Public
{

    private $plugin_name;
    private $version;

    public function __construct($plugin_name, $version)
    {

        $this->plugin_name = $plugin_name;
        $this->version = $version;

    }

    public function enqueue_styles()
    {
        wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/email-before-download-public.css', array(), $this->version, 'all');

    }

    public function enqueue_scripts()
    {
            wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/email-before-download-public.js', array('jquery'), $this->version, true);
            wp_localize_script($this->plugin_name, 'ebd_inline', array('ajaxurl' => admin_url('admin-ajax.php'), 'ajax_nonce' => wp_create_nonce('ebd'),));
    }
    public function shortcode_cleanup($content)
    {
        $shortcodes = array(
            'email-download', 'emailreq'
        );
        foreach ($shortcodes as $shortcode){
            if (strpos($content, $shortcode))
            {
                $search = array(
                    '"','’','‘','“','”','"');

                $replace = "'";

                $content =  str_replace($search, $replace, $content);
            }
        }

        return $content;
    }

    public function ebd_ajax()
    {
        check_ajax_referer('ebd', 'security');
        $postData = sanitize_post($_POST);
        $data = array();
        $htmlBefore = get_option('email_before_download_html_before');
        $htmlAfter = get_option('email_before_download_html_after');
        $linkCSS = get_option('email_before_download_link_css');
        $db = new Email_Before_Download_DB();
        $links = array();
        $linksHTML = "";
        if(!is_array($postData['downloads'])){
            $downloads = array($postData['downloads']);
        }else {
            $downloads = $postData['downloads'];
        }
        if(!is_array($postData['settings'])){
            $postSettings = array($postData['settings']);
        }else {
            $postSettings = $postData['settings'];
        }
        foreach($downloads as $download){
            $tmp = explode('|', $download);
            $links[$tmp[0]]['title'] = $tmp[1];
        }
        foreach ($postSettings as $item){
            $tmp = explode('|',$item);
            $settings[$tmp[0]] = $tmp[1];
        }
        if(strtolower($settings['delivered_as']) == 'send email') {
            echo json_encode('email sent');
            exit();
        }
        $DBLinks = $db->get_ajax_links($postData['email']);
        if (count($DBLinks) == 0) exit();

        if((count($DBLinks) == 1 ) && ( isset($settings['force_download']) ) ){
            $data['download'] = 'yes';

            $generated_link = '';
            if($link->expire_time > 0)
                $generated_link =home_url().'?ebddl='.$DBLinks[0]->uid;
            else{
                $generated_link = do_shortcode("[download_data id=\"".$DBLinks[0]->selected_id."\" data=\"download_link\"]");
                $parsed_link = parse_url($generated_link);
                if(isset($parsed_link['query'])){ // The link already has URL parameters being set
                  $generated_link = $generated_link.'&ebduid='.$link->uid;
                }else{ // This is the first URL parameter in the link
                  $generated_link = $generated_link.'?ebduid='.$link->uid;
                }
            }
            $data['url'] = $generated_link; //do_shortcode("[download_data id=\"".$DBLinks[0]->selected_id."\" data=\"download_link\"]").$spacer.$DBLinks[0]->uid;
            echo json_encode($data);
            exit();
        }

        foreach ($DBLinks as $link){

            $generated_link = '';
            if($link->expire_time > 0)
                $generated_link =home_url().'?ebddl='.$link->uid;
            else{
                $generated_link =do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");
                $parsed_link = parse_url($generated_link);
                if(isset($parsed_link['query'])){ // The link already has URL parameters being set
                  $generated_link = $generated_link.'&ebduid='.$link->uid;
                }else{ // This is the first URL parameter in the link
                  $generated_link = $generated_link.'?ebduid='.$link->uid;
                }
            }

            $shortCode = $generated_link;
            $fileIcon = '';
            if(strtolower($settings['file_thumbnail']) == 'yes') {
                $fileIcon = do_shortcode("[download_data id=\"$link->selected_id\" data=\"thumbnail\"]");                
            }
            $titleTMP = $links[$link->selected_id]['title'];
            $linksHTML .= "<a class=\"ebd_link $linkCSS\" href=\"".$shortCode."\" target=\"" .$settings['link_format']. "\" ><div style=\"height:40px;display:flex;\">".$fileIcon."".$titleTMP."</div></a></br>" ;
        }
        if(isset($links)){
            $data['html'] =  "<div class=\"ebd_results\">".$htmlBefore.$linksHTML.$htmlAfter."</div>";
        }else{
            $data['error'] =  'no data found';
        }
            echo json_encode($data);
        exit();
    }
public function record($allowed, $download){

        $permalink = get_option('permalink_structure');
        if($permalink != ""){
            $downloadID = $download->post->ID;
        }else {
            $downloadID = sanitize_key($_GET['download']);

        }
        $db = new Email_Before_Download_DB();
        
            if(isset($_GET['ebduid'])) {
                $link = $db->select_link('uid', sanitize_key($_GET['ebduid']));
                if (!$link)
                    wp_die(__('Invalid UID Please fill out a new form to generate a new link.', 'email-before-download'));

                if ($this->expired($link))
                    wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));

                $db->mark_downloaded($link->id);
            }


    return $allowed;
}
public function ebd_the_download($content){
        
        if(isset($_GET['ebddl'])) {

            $db = new Email_Before_Download_DB();

            $link = $db->select_link('uid', sanitize_key($_GET['ebddl']));
            if ($this->expired($link))
                wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));


            $url = do_shortcode("[download_data id=\"".$link->selected_id."\" data=\"download_link\"]");
            $parsed_link = parse_url($url);
            if(isset($parsed_link['query'])){ // The link already has URL parameters being set
              $url = $url.'&ebduid='.$link->uid;
            }else{ // This is the first URL parameter in the link
              $url = $url.'?ebduid='.$link->uid;
            }

            if ( ! function_exists( 'wp_redirect' ) ) {
                return $content;
            }
            wp_redirect( $url );
            exit;
        }


    return $content;
}
    public function expired($link)
    {
        if ($link->expire_time)
            if ($link->expire_time < time()) return true;
        return false;
    }
}
PK     ä‹U]^Š´:  :  )  public/js/email-before-download-public.jsnu „[µü¤        jQuery( document ).ready(function() {
    document.addEventListener('wpcf7mailsent', function (event) {
        var inputs = event.detail.inputs;
        var downloads = [];
        var settings = [];
        for ( var i = 0; i < inputs.length; i++ ) {
            if ( 'your-email' === inputs[i].name ) {
                var email = inputs[i].value ;
            }
            if("ebd_downloads[]" === inputs[i].name){
                downloads.push(inputs[i].value);
            }
            if('ebd_settings[]' === inputs[i].name){
                settings.push(inputs[i].value);
            }
        }
        var id = event.detail.id;
        if(id)
            id = '#' + id;
        else
            id = event.detail.apiResponse.into;

        var data = {
            action: 'ebd_inline_links',
            email: email,
            downloads: downloads,
            settings: settings,
            security: ebd_inline.ajax_nonce
        };
        jQuery.post(ebd_inline.ajaxurl, data, function (data) {
            data = JSON.parse(data);
                if(data.download){
                    window.location.href = data.url;
                }else{
                   jQuery('.wpcf7-response-output').show();
                    jQuery(id).append(data.html);
                }

            }
        );
    }, false);
});PK     ä‹U]½žjêy   y   +  public/css/email-before-download-public.cssnu „[µü¤        .ebd_input {
    display: block;
}
.ebd_link img{
	height:40px !important;
	width: 40px !important;
	margin-right: 5px;
}PK     ä‹U]Äξ§û   û     uninstall.phpnu „[µü¤        <?php

/**
 * Fired when the plugin is uninstalled.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @author     M & S Consulting
 */

// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )exit;
PK     ä‹U]Ò|qþð  ð    assets/group3.svgnu „[µü¤        <svg width="70" height="71" viewBox="0 0 70 71" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M35 56.0002L28.4 51.7002L4 71.0002H65.6L41.4 51.8002L35 56.0002Z" fill="black"/>
<path d="M70 68.1002V33.2002L45.8 49.0002L70 68.1002Z" fill="black"/>
<path d="M0 22.7V27.3L35 50L70 27.3V22.7L35 0L0 22.7ZM37.5 31L43.2 25.3L46.7 28.8L35 40.5L23.2 28.8L23.3 28.7L26.8 25.2L32.5 30.9V10H37.5V31V31Z" fill="black"/>
<path d="M0 33.2002V67.8002L24 48.8002L0 33.2002Z" fill="black"/>
</svg>
PK     ä‹U]*¤	Õ      	  index.phpnu „[µü¤        <?php // Silence is goldenPK     ä‹U]΅M«F  «F    LICENSE.txtnu „[µü¤                            GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.PK     ä‹U]˜qg*    +  admin/class-email-before-download-table.phpnu „[µü¤        <?php
/**
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/admin
 * @author     M & S Consulting
 */
if (!class_exists('WP_List_Table')) {
    require_once(ABSPATH . 'wp-admin/includes/screen.php');
    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}

class Email_Before_download_Table extends WP_List_Table
{

    public $atts;
    public $db;

    function __construct()
    {
        parent::__construct(array(
            'singular' => 'ebd_download',
            'plural' => 'ebd_downloads',
            'ajax' => false
        ));
        global $wpdb;
        $this->db = $wpdb;
    }

    function get_columns()
    {
        return $this->atts['columns'];
    }

    public function get_sortable_columns()
    {
        return $this->atts['sortable'];
    }


    function prepare_items()
    {
        global $_wp_column_headers;
        $table = $this->atts['table'];
        $existing_columns = $this->db->get_col("DESC {$table}", 0);
        $screen = get_current_screen();
        $query = "SELECT * FROM $table";
        $orderby = !empty($_GET["orderby"]) ? sanitize_key($_GET["orderby"]) : '';        
        $order = !empty($_GET["order"]) ? sanitize_key($_GET["order"]) : '';
        //remoove unwanted parameters
        $order = strcasecmp($order, "desc") == 0 || strcasecmp($order, "asc") == 0 ? $order : '';

        $is_inarray = false;
        foreach ($existing_columns as $colname) {
            if(strcasecmp($orderby, $colname) == 0){
                $is_inarray = true;
                break;
            }
        }
        if(!$is_inarray){
            $orderby = '';
        }
        
        if (!empty($orderby) & !empty($order)) {
            $query .= ' ORDER BY ' . $orderby . ' ' . $order;
        }else {
            $query .= " ORDER BY time_requested DESC";
        }

        $totalitems = $this->db->query($query);
        $perpage = 25;
        $paged = !empty($_GET["paged"]) ? sanitize_key(($_GET["paged"])) : '';
        if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
            $paged = 1;
        }
        $totalpages = ceil($totalitems / $perpage);
        if (!empty($paged) && !empty($perpage)) {
            $offset = ($paged - 1) * $perpage;
            $query .= ' LIMIT ' . (int)$offset . ',' . (int)$perpage;
            $this->set_pagination_args(array(
                "total_items" => $totalitems,
                "total_pages" => $totalpages,
                "per_page" => $perpage,
            ));
            $columns = $this->get_columns();
            $_wp_column_headers[$screen->id] = $columns;
            $this->_column_headers = array(
                $this->get_columns(),
                array(),
                $this->get_sortable_columns(),
            );
            $this->items = $this->db->get_results($query);
        }
    }

    function display_rows()
    {
        $records = $this->items;
        list($columns, $hidden) = $this->get_column_info();
        if (!empty($records)) {
            foreach ($records as $rec) {
                if (isset($rec->id)) {
                    echo '<tr id="record_' . esc_attr($rec->id) . '">';
                } else {
                    echo '<tr class="record">';
                }
                foreach ($columns as $column_name => $column_display_name) {
                    //Style attributes for each col
                    $class = "class='$column_name column-$column_name'";
                    $style = "";
                    if (in_array($column_name, $hidden)) $style = ' style="display:none;"';
                    $attributes = $class . $style;
                    if ($column_name == "is_downloaded") {
                        $rec->$column_name = ($rec->$column_name < 1 ? 'No' : 'Yes');
                    } elseif ($column_name == "expire_time") {
                        $rec->$column_name = ($rec->$column_name ? $rec->$column_name : "Doesn't Expire");
                        if ($rec->$column_name != "Doesn't Expire") {
                            if (time()  > $rec->$column_name) {
                                $rec->$column_name = "<span style='color:red'>".date('Y-m-d H:i:s', stripslashes($rec->$column_name))."</span>";
                            }
                        }
                    } elseif ($column_name == "posted_data") {
                        $rec->$column_name = "<div class='ebd_xml'>" . htmlentities($rec->$column_name) . "</div>";
                    }
                    if ($this->isValidTimeStamp($rec->$column_name)) {
                        echo '<td ' . $attributes . '>' . esc_html(date('Y-m-d H:i:s', stripslashes($rec->$column_name))) . '</td>';
                    } else {
                        echo '<td ' . $attributes . '>' . esc_html(stripslashes($rec->$column_name)) . '</td>';
                    }
                }
                echo '</tr>';
            }
        }
    }

    public function set_table($table)
    {
        if ($table == 'links') {
            $this->atts = array(
                'table' => $this->db->prefix . "ebd_link",
                'columns' => array(
                    'email' => __('Email'),
                    'is_downloaded' => __('Downloaded'),
                    'time_requested' => __('Time Requested'),
                    'delivered_as' => __('Delivered As'),
                    'expire_time' => "Expires"
                ),
                'sortable' => array(
                    'email' => array('email', true),
                    'is_downloaded' => array('is_downloaded', true),
                    'time_requested' => array('time_requested', true),
                    'delivered_as' => array('delivered_as', true),
                    'expire_time' => array('expire_time', true),
                ),
                'purge_text' => __("Purge Expired Links",'email-before-download')
            );
        } else {
            $this->atts = array(
                'table' => $this->db->prefix . "ebd_posted_data",
                'columns' => array(
                    'email' => __('Email'),
                    'user_name' => __('Name'),
                    'time_requested' => __('Time Requested'),
                    'posted_data' => "XML Data"
                ),
                'sortable' => array(
                    'email' => array('email', true),
                    'is_downloaded' => array('is_downloaded', true),
                    'time_requested' => array('time_requested', true),
                ),
                'purge_text' => __("Purge Logs",'email-before-download')
            );
        }

    }

    public function isValidTimeStamp($timestamp)
    {
        return ((string)(int)$timestamp === $timestamp)
            && ($timestamp <= PHP_INT_MAX)
            && ($timestamp >= ~PHP_INT_MAX)
            && (strlen($timestamp) > 9);
    }
}
PK     ä‹U]	¤ߝ‘f  ‘f  +  admin/class-email-before-download-admin.phpnu „[µü¤        <?php


/**
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/admin
 * @author     M & S Consulting
 */
class Email_Before_Download_Admin
{

    private $plugin_name;
    private $version;
    private $option_name = 'email_before_download';
    private  $page_title = "Email Before Download";
    private $db;
    private $options  = array(
        array('name' => '_support', 'type' => 'section','label' => "Support Links"),
        array('name' => '_general', 'type' => 'section','label' => "General Settings"),
        array('name' => '_delivery_format', 'type' => 'setting', 'label' => "Default Delivery Format", 'section' => '_general', 'default' => "inline link"),
        array('name' => '_expire', 'type' => 'setting', 'label' => "Default Link Expiration Time", 'section' => '_general', 'default' => "0"),
        array('name' => '_forbidden', 'type' => 'setting', 'label' => "Forbidden Domains", 'section' => '_general'),
        array('name' => '_inline', 'type' => 'section','label' => "Inline Link Settings"),
        array('name' => '_link_format', 'type' => 'setting', 'label' => "Default Link Target", 'section' => '_inline', 'default' => "_self"),
        array('name' => '_link_css', 'type' => 'setting', 'label' => "Custom CSS", 'section' => '_inline'),
        array('name' => '_html_before', 'type' => 'setting', 'label' => "HTML Before Link", 'section' => '_inline'),
        array('name' => '_html_after', 'type' => 'setting', 'label' => "HTML After Link", 'section' => '_inline'),
        array('name' => '_email', 'type' => 'section','label' => "Email Settings"),
        array('name' => '_single_email', 'type' => 'setting', 'label' => "Single URL Template", 'section' => '_email'),
        array('name' => '_multi_email', 'type' => 'setting', 'label' => "Multiple URL Template", 'section' => '_email'),
        array('name' => '_attachment', 'type' => 'setting', 'label' => "Default Attachment", 'section' => '_email'),
        array('name' => '_subject', 'type' => 'setting', 'label' => "From Email Subject", 'section' => '_email', 'default' => "Your Requested File(s)"),
        array('name' => '_from_name', 'type' => 'setting', 'label' => "From Email Name", 'section' => '_email'),
        array('name' => '_email_from', 'type' => 'setting', 'label' => "From Email", 'section' => '_email'),
        array('name' => '_other', 'type' => 'section','label' => "Additional Settings"),
        array('name' => '_default_cf7', 'type' => 'setting', 'label' => "Default CF7 Form ID", 'section' => '_other'),
        array('name' =>  '_multi_check', 'type' => 'setting', 'label' => "Default Checkbox State", 'section' => '_other', 'default' => " "),
        array('name' => '_hidden_form', 'type' => 'setting', 'label' => "Default Hide Form", 'section' => '_other', 'default' => "no"),
        array('name' => '_radio', 'type' => 'setting', 'label' => "Default Radio Buttons", 'section' => '_other', 'default' => "no"),
        array('name' => '_file_thumbnail', 'type' => 'setting', 'label' => "Default Display File Thumbnail", 'section' => '_other', 'default' => "no")

    );

    public function __construct($plugin_name, $version)
    {
        $this->plugin_name = $plugin_name;
        $this->version = $version;
        $this->db = new Email_Before_Download_DB();
    }

    public function enqueue_styles()
    {
        wp_enqueue_style($this->plugin_name,
            plugin_dir_url(__FILE__) . 'css/email-before-download-admin.css', array(),
            $this->version,
            'all');
    }

    public function enqueue_scripts()
    {
        wp_enqueue_script($this->plugin_name,
            plugin_dir_url(__FILE__) . 'js/email-before-download-admin.js',
            array('jquery'),
            $this->version,
            true);
    }
    public function flush_api(){
        flush_rewrite_rules();
    }
    public function add_options_page()
    {
            $main_page = add_menu_page(
                __( 'Email Before Download', 'email-before-download' ),
                __( 'Email Before Download', 'email-before-download' ),
                'manage_options',
                'email-before-download',
                array(
                    $this,
                    'display_options_page'
                ),
                //'data:image/svg+xml;base64,'.base64_encode(file_get_contents(plugin_dir_url( dirname( __FILE__ ) ) . 'assets/group3.svg')),
                'data:image/svg+xml;base64,'.base64_encode(
                    '<svg width="70" height="71" viewBox="0 0 70 71" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M35 56.0002L28.4 51.7002L4 71.0002H65.6L41.4 51.8002L35 56.0002Z" fill="black"/>
<path d="M70 68.1002V33.2002L45.8 49.0002L70 68.1002Z" fill="black"/>
<path d="M0 22.7V27.3L35 50L70 27.3V22.7L35 0L0 22.7ZM37.5 31L43.2 25.3L46.7 28.8L35 40.5L23.2 28.8L23.3 28.7L26.8 25.2L32.5 30.9V10H37.5V31V31Z" fill="black"/>
<path d="M0 33.2002V67.8002L24 48.8002L0 33.2002Z" fill="black"/>
</svg>'),
                30
            );

            // add_action('admin_menu', 'wpcf7cf_admin_add_page');
            add_submenu_page( 'email-before-download',
                'Submenu Page Title',
                __( 'Options', 'email-before-download' ),
                'manage_options',
                'email-before-download',
                array(
                    $this,
                    'display_options_page'
                )   
            );
        add_submenu_page(
            'email-before-download',
            'Email Before Download Links',
            'Email Before Download Links',
            'administrator',
            $this->plugin_name.'-links',
            array($this,'display_links_page'));
        
        add_submenu_page(
            null,
            'Email Before Download Links',
            'Email Before Download Links',
            'administrator',
            $this->plugin_name.'-links',
            array($this,'display_links_page'));


        add_submenu_page(
            'email-before-download',
            'Email Before Download Logs',
            'Email Before Download Logs',
            'administrator',
            $this->plugin_name.'-logs',
            array($this,'display_logs_page'));
        
        add_submenu_page(
            null,
            'Email Before Download Logs',
            'Email Before Download Logs',
            'administrator',
            $this->plugin_name.'-logs',
            array($this,'display_logs_page'));
    }

    public function display_options_page()
    {

        include_once 'partials/email-before-download-admin-display.php';
    }
    public function display_links_page()
    {
        $wp_table = new Email_Before_download_Table();
        $wp_table->set_table('links');
        $wp_table->prepare_items();
        $title = $this->page_title. " Links";
            include_once 'partials/email-before-download-admin-table.php';
    }
    public function display_logs_page()
    {
        $wp_table = new Email_Before_download_Table();
        $wp_table->set_table('logs');
        $wp_table->prepare_items();
        $title = $this->page_title. " Logs";
        include_once 'partials/email-before-download-admin-table.php';
    }
    function print_csv()
    {
        if ( ! current_user_can( 'manage_options' ) )
            return;
        if(isset($_GET['table'])){
            $table = sanitize_key($_GET['table']);
            global $wpdb;
            $valid_tables = array($wpdb->prefix . "ebd_link" , $wpdb->prefix . "ebd_posted_data");
            if (!in_array($table, $valid_tables)) {
                wp_die(__('This table doesnot exists.' ));
            }            
            $csv = $this->db->export($table);
            $filename = $table.'-'.date('Y-m-d H:i:s',time()).'.csv';
            header('Content-Type: application/csv');
            header('Content-Disposition: attachment; filename='.$filename);
            header('Pragma: no-cache');
            echo $csv;
        }

        return;

    }
    public function purge_data()
    {
        if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ 'dopurge' ] ) ), 'dopurge_nonce' ) ) {
          die( __( 'Security check', 'textdomain' ) ); 
        }
        if ( ! current_user_can( 'manage_options' ) )
            return;
        if(isset($_GET['table'])) {
            $table = sanitize_key($_GET['table']);
            global $wpdb;
            $valid_tables = array($wpdb->prefix . "ebd_link" , $wpdb->prefix . "ebd_posted_data");
            if (!in_array($table, $valid_tables)) {
                wp_die(__('This table doesnot exists.' ));
            }            
            $this->db->clean_up($table);
        }
        return;

    }
    public function build_settings()
    {

        foreach ($this->options as $option){
            if($option['type'] == 'section'){
                add_settings_section(
                        $this->option_name . $option['name'],
                        $option['label'],
                        array($this, $this->option_name . $option['name'].'_cb'),
                        $this->plugin_name
                );
            }else{
                add_settings_field(
                    $this->option_name . $option['name'],
                    $option['label'],
                    array($this, $this->option_name . $option['name'].'_cb'),
                    $this->plugin_name,
                    $this->option_name . $option['section'],
                    array('label_for' => $this->option_name . $option['name'])
                );
            }
        }

    }

    public function register_settings()
    {
        foreach ($this->options as $option){
            if($option['type'] == 'setting')
                register_setting(
                        $this->plugin_name,
                        $this->option_name . $option['name'],
                        'string'
                );

        }
    }
    public function set_option_defaults(){

    }


    public function email_before_download_inline_cb()
    {
        echo '<div class="ebd_section_description">' . __('The following settings apply if you selected "Inline Link" or "Both" as the Delivery Format ', 'email-before-download') . '</div>';
    }

    public function email_before_download_email_cb()
    {
        echo '<div class="ebd_section_description">' . __('The following settings apply if you selected "Email" or "Both" as the Delivery Format ', 'email-before-download') . '</div>';
    }
    public function email_before_download_general_cb()
    {
        echo '<div class="ebd_section_description">' . __('General plugin settings ', 'email-before-download') . '</div>';
    }
    public function email_before_download_support_cb()
    {
        echo "<span class='ebd_subtitle'>". __('Email Before Download started as a plugin we developed for personal in-house needs. We realized this could be useful to other WordPress users. At that point, we made the decision to release the plugin for anyone to use. We apologize if we cannot provide support to you on an individual or timely basis. However, please feel free to post in the WordPress forums where we hope your questions can be answered by the WordPress community.', 'email-before-download')."</span>";
        echo "<span class='ebd_subtitle'><b><a href=\"https://wordpress.org/support/topic/email-before-download-pro-beta-testers-needed/\" target=\"_blank\">FREE Early Access to EBD Pro Version! </a></b></span>";

        echo "<ul>
            <li><a href=\"https://www.mandsconsulting.com/products/wp-email-before-download\" target=\"_blank\">".__('Plugin Homepage at M&amp;S Consulting with Live Demos and Test Download','email-before-download')."</a></li>
            <li><a href=\"https://wordpress.org/plugins/email-before-download/V\" target=\"_blank\">". __('Plugin Homepage at WordPress', 'email-before-download')."</a></li>
            <li><a href=\"https://wordpress.org/plugins/email-before-download/#changelog\" target=\"_blank\">".__('Plugin Changelog: Current and Past Releases','email-before-download')."</a></li>
            <li><a href=\"https://wordpress.org/support/topic-tag/email-before-download/?forum_id=10\" target=\"_blank\">".__('Plugin Support Forums','email-before-download')."</a></li>
        </ul>";

    }

    public function email_before_download_delivery_format_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_delivery_format' ?>">
            <option value="inline link" <?php if (get_option($this->option_name . '_delivery_format') == 'inline link') echo 'selected="selected"'; ?> >
                <?php _e('Inline Link','email-before-download'); ?>
            </option>
            <option value="send email" <?php if (get_option($this->option_name . '_delivery_format') == 'send email') echo 'selected="selected"'; ?> >
                <?php _e('Send Email','email-before-download'); ?>
            </option>
            <option value="both" <?php if (get_option($this->option_name . '_delivery_format') == 'both') echo 'selected="selected"'; ?> >
                <?php _e('Both','email-before-download'); ?>
            </option>
        </select>
        <span class="ebd_subtitle"> <?php _e('Can be overridden in the shortcode with: delivered_as="inline link/send email/both" ','email-before-downlaod'); ?></span>

        <?php
    }



    public function email_before_download_expire_cb()
    {
        ?>
        <select class="ebd_input" id="<?php echo esc_attr($this->option_name) . '_expire' ?>"
                name="<?php echo esc_attr($this->option_name) . '_expire' ?>">
            <option value="0" <?php if (get_option($this->option_name . '_expire') == '0') echo 'selected="selected"'; ?> >
                Never
            </option>
            <option value="1 minute" <?php if (get_option($this->option_name . '_expire') == '1 minute') echo 'selected="selected"'; ?> >
                1 min
            </option>
            <option value="3 minute" <?php if (get_option($this->option_name . '_expire') == '3 minute') echo 'selected="selected"'; ?> >
                3 min
            </option>
            <option value="10 minute" <?php if (get_option($this->option_name . '_expire') == '10 minute') echo 'selected="selected"'; ?> >
                10 min
            </option>
            <option value="30 minute" <?php if (get_option($this->option_name . '_expire') == '30 minute') echo 'selected="selected"'; ?> >
                30 min
            </option>
            <option value="1 hour" <?php if (get_option($this->option_name . '_expire') == '1 hour') echo 'selected="selected"'; ?> >
                1 hr
            </option>
            <option value="12 hour" <?php if (get_option($this->option_name . '_expire') == '12 hour') echo 'selected="selected"'; ?> >
                12 hr
            </option>
            <option value="1 day" <?php if (get_option($this->option_name . '_expire') == '1 day') echo 'selected="selected"'; ?> >
                1 day
            </option>
            <option value="1 week" <?php if (get_option($this->option_name . '_expire') == '1 week') echo 'selected="selected"'; ?> >
                1 week
            </option>
        </select>
        <span class="ebd_subtitle"> <?php _e('This option expires the link after a set period of time. <br>It can be overridden in the shortcode with: expire_time="X minute/hour/day/week".','email-before-downlaod'); ?></span>
        <?php
    }

    public function email_before_download_forbidden_cb()
    {
        ?>
        <textarea class="ebd_input" cols="40" rows="10"
                  name="<?php echo esc_attr($this->option_name) . '_forbidden' ?>"><?php echo esc_textarea(get_option($this->option_name . '_forbidden')); ?></textarea>
        <span class="ebd_subtitle"><?php _e('A comma separated list of the forbidden domains','email-before-download'); ?></span>
        <?php
    }

    public function email_before_download_link_format_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_link_format' ?>">
            <option value="_blank" <?php if (get_option($this->option_name . '_link_format') == '_blank') echo 'selected="selected"'; ?> >
                _blank
            </option>
            <option value="_self" <?php if (get_option($this->option_name . '_link_format') == '_self') echo 'selected="selected"'; ?> >
                _self
            </option>
        </select>
        <span class="ebd_subtitle"><i> <?php _e('This option can be overridden in the shortcode with: link_format="_self/_blank"','email-before-download'); ?></i></span>
        <?php
    }

    public function email_before_download_link_css_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_link_css' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_link_css')); ?>"/>
        <span class="ebd_subtitle"> <?php _e('CSS class used to render the div and the link','email-before-download'); ?></span>
        <?php
    }

    public function email_before_download_html_before_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_html_before' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_html_before')); ?>"/>
        <span class="ebd_subtitle"> <?php _e('HTML you want to be added before the link','email-before-dowjnload'); ?></span>
        <?php
    }

    public function email_before_download_html_after_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_html_after' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_html_after')); ?>"/>
        <span class="ebd_subtitle"> <?php _e('HTML you want to be added after the link','email-before-download'); ?> </span>
        <?php
    }

    public function email_before_download_single_email_cb()
    {
        ?>
        <textarea class="ebd_input" cols="40" rows="10"
                  name="<?php echo esc_attr($this->option_name) . '_single_email' ?>"><?php echo esc_textarea(get_option($this->option_name . '_single_email')); ?></textarea>
        <span class="ebd_subtitle"> <?php _e("[file_name] and [file_url] are specific placeholders for Email Before Download. Placeholders from Contact Form 7 can be used as long as your form has the same fields.  If a placeholder is used with no corresponding form field, it will be ignored.",'email-before-download'); ?><br>
          <br><?php _e('Note.  If you leave this field empty, The default template will be used.','email-before-download'); ?>
            <p><?php _e("The Default template is:<br><strong> Here is the download for",'email-before-download');  echo htmlentities('<a href="[file_url]">[file_name]</a>'); _e("that you requested.</strong>",'email-before-download'); ?>
            </p></span>
        <?php
    }

    public function email_before_download_multi_email_cb()
    {
        ?>
        <textarea class="ebd_input" cols="40" rows="10"
                  name="<?php echo esc_attr($this->option_name) . '_multi_email' ?>"><?php echo esc_textarea(get_option($this->option_name . '_multi_email')); ?></textarea>
        <span class="ebd_subtitle"><?php _e('The same rules apply to this template as the single URL template. <br>Use the following placeholder for multiple urls: [file_urls]</br> If this is left blank, a list of URLs will be sent.','email-before-download'); ?>  </span>
        <?php
    }

    public function email_before_download_attachment_cb()
    {
        ?>
        <input type="checkbox" size="40" id="<?php echo esc_attr($this->option_name) . '_attachment' ?>"
               name="<?php echo esc_attr($this->option_name) . '_attachment' ?>"
               value="1" <?php if (get_option($this->option_name . '_attachment')) echo 'checked="checked"'; ?> />
        <span class="ebd_subtitle"><?php _e('This can only be applied to the files uploaded using Download Monitor plugin.<br> This option can be overridden in the shorcode with: attachment="yes/no"','email-before-download');?></span>
        <?php
    }

    public function email_before_download_subject_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_subject' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_subject')); ?>"/>
        <span class="ebd_subtitle"><?php _e('If this field is left blank, the default subject is: "Your requested file(s)".','email-before-download');?></span>
        <?php
    }
    public function email_before_download_email_from_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_email_from' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_email_from')); ?>"/>
        <span class="ebd_subtitle"><?php _e('Email address used to deliver the download links. If this field is left blank, the default wordpress email will be used..','email-before-download');?></span>
        <?php
    }
    public function email_before_download_from_name_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_from_name' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_from_name')); ?>"/>
        <span class="ebd_subtitle"><?php _e('Name used to deliver the download links. If this field is left blank, the default wordpress email name will be used..','email-before-download');?></span>
        <?php
    }

    public function email_before_download_other_cb()
    {
        echo '<div class="ebd_section_description">' . __('The following settings only apply if you have multiple urls in you shortcode ', 'email-before-download') . '</div>';
    }
    public function email_before_download_default_cf7_cb()
    {
        ?>
        <input type="text" size="40" name="<?php echo esc_attr($this->option_name) . '_default_cf7' ?>"
               value="<?php echo esc_attr(get_option($this->option_name . '_default_cf7')); ?>"/>
        <span class="ebd_subtitle"> <?php _e('If you want to use the same form for all your downloads.</br> This can be overwritten in the shortcode with: contact-form-id="X"  ','email-before-download'); ?></span>
        <?php
    }

    public function email_before_download_multi_check_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_multi_check' ?>">
            <option value="checked" <?php if (get_option($this->option_name . '_multi_check') == 'checked') echo 'selected="selected"'; ?> >
                Checked
            </option>
            <option value="" <?php if ((get_option($this->option_name . '_multi_check') == '') || (!get_option($this->option_name . '_multi_check'))) echo 'selected="selected"'; ?> >
                Unchecked
            </option>
        </select>
        <span class="ebd_subtitle"><?php _e('The default state of the Multiple Checkboxes.<br> This can be overridden in the shortcode with: checked="yes/no"','email-before-download'); ?></span>
        <?php
    }

    public function email_before_download_hidden_form_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_hidden_form' ?>">
            <option value="yes" <?php if (get_option($this->option_name . '_hidden_form') == 'yes') echo 'selected="selected"'; ?> >
                <?php _e('Yes','email-before-download'); ?>
            </option>
            <option value="no" <?php if ((get_option($this->option_name . '_hidden_form')) == 'no'||(!get_option($this->option_name . '_hidden_form'))) echo 'selected="selected"'; ?> >
                <?php _e('No','email-before-download'); ?>
            </option>
        </select>
        <span class="ebd_subtitle"> <?php _e('Hide the form until user selects a download. <br> This can be overriden in the shortcode with hide_form="yes/no"','email-before-download'); ?></span>
        <?php
    }

    public function email_before_download_radio_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_radio' ?>">
            <option value="yes" <?php if (get_option($this->option_name . '_radio') == 'yes') echo 'selected="selected"'; ?> >
                <?php _e('Yes','email-before-download'); ?>
            </option>
            <option value="no" <?php if ((get_option($this->option_name . '_radio') == 'no') || (!get_option($this->option_name . '_radio'))) echo 'selected="selected"'; ?> >
                <?php _e('No','email-before-download'); ?>
            </option>
        </select>
        <span class="ebd_subtitle"><?php _e('Radio buttons instead of checkboxes.<br> This can be overridden in the shortcode with: radio="yes/no"','email-before-download'); ?></span>
        <?php
    }
    
    public function email_before_download_file_thumbnail_cb()
    {
        ?>
        <select class="ebd_input" name="<?php echo esc_attr($this->option_name) . '_file_thumbnail' ?>">
            <option value="yes" <?php if (get_option($this->option_name . '_file_thumbnail') == 'yes') echo 'selected="selected"'; ?> >
                <?php _e('Yes','email-before-download'); ?>
            </option>
            <option value="no" <?php if ((get_option($this->option_name . '_file_thumbnail') == 'no') || (!get_option($this->option_name . '_file_thumbnail'))) echo 'selected="selected"'; ?> >
                <?php _e('No','email-before-download'); ?>
            </option>
        </select>
        <span class="ebd_subtitle"><?php _e('Display thumbnail (aka "Featured Image") of your Download Monitor Files along with the file\'s title. This can be overridden in the shortcode with: file_thumbnail="yes/no". If "yes", the thumbnail will display to the left file title at dimensions of 40px by 40px. If file thumbnail is not specified in Download Monitor, a default thumbnail is displayed.','email-before-download'); ?></span>
        <?php
    }

}PK     ä‹U]*¤	Õ        admin/index.phpnu „[µü¤        <?php // Silence is goldenPK     ä‹U]:•Ԁ  €  6  admin/partials/email-before-download-admin-display.phpnu „[µü¤        <?php

/**
 * Provide a admin area view for the plugin
 *
 * This file is used to markup the admin-facing aspects of the plugin.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/admin/partials
 * @author     M & S Consulting
 */
?>

<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<div class="wrap">
    <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
    <div class="buttons">
        <a href="<?php echo admin_url( "options-general.php?page=email-before-download-links" ); ?>" class="button button-primary">
            <?php _e('View Download Links','email-before-download'); ?></a>
        <a href="<?php echo admin_url( "options-general.php?page=email-before-download-logs" ); ?>" class="button button-primary">
            <?php _e('View Submission Logs','email-before-download'); ?></a>
    </div>
    <div style="float:right">
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
        <input type="hidden" name="cmd" value="_s-xclick" />
        <input type="hidden" name="hosted_button_id" value="47FLSBA363KAU" />
        <input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" alt="PayPal - The safer, easier way to pay online!" />
        <img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" />
    </form>
    </div>
    <form action="options.php" method="post">
        <?php
        settings_fields( $this->plugin_name );
        do_settings_sections( $this->plugin_name );
        submit_button();
        ?>
    </form>
</div>PK     ä‹U]Žð+-  -  4  admin/partials/email-before-download-admin-table.phpnu „[µü¤        <?php

/**
 * Provide a admin area view for the plugin
 *
 * This file is used to markup the admin-facing log views of the plugin.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/admin/partials
 * @author     M & S Consulting
 */
$message = "";
if( isset($_SESSION['success']) ) {
    $message = "<div id=\"setting-error-settings_updated\" class=\"updated settings-error notice is-dismissible\">
        <p><strong>". esc_html($_SESSION['success'])."</strong></p><button type=\"button\" class=\"notice-dismiss\"><span class=\"screen-reader-text\">Dismiss this notice.</span></button></div>";
    unset($_SESSION['success']);
}
?>

<!-- This file should primarily consist of HTML with a little bit of PHP. -->
<div class="wrap">
    <?php echo wp_kses_post($message) ?>
    <h2><?php echo esc_html($title) ?></h2>
    <div class="buttons">
        <a href="<?php echo admin_url( "admin-post.php?action=ebd.csv&table=".$wp_table->atts['table'] ); ?>" class="button button-primary">Export as CSV</a>

        <a href="<?php echo admin_url( "admin-post.php?action=ebd.purge&table=".$wp_table->atts['table']."&dopurge=".wp_create_nonce( 'dopurge_nonce' ) ); ?>" class="button button-secondary" onclick="if(confirm('Are you sure you want to purge data?.')) return true; return false"><?php echo $wp_table->atts['purge_text']; ?></a>
        <a href="<?php echo admin_url( "options-general.php?page=email-before-download"); ?>" class="right button button-primary">Back to Settings</a>
    </div>
    <?php $wp_table->display();  ?>
</div>PK     ä‹U]YWs^  ^  )  admin/css/email-before-download-admin.cssnu „[µü¤        /**
 * All of the CSS for your admin-specific functionality should be
 * included in this file.
 */

.ebd_section_description {
    background: #fff;
    border-left: 4px solid #fff;
    box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    margin: 5px 15px 2px;
    padding: 1px 12px;
}
.form-table tr {
    border-bottom: 1px solid #ddd;
}
span.ebd_subtitle {
    float: right;
    width: 50%;
}
.ebd_input {
    min-width: 300px;
}
.ebd_xml {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ebd_xml:hover {
    cursor: pointer;
    overflow: auto;
}PK     ä‹U]Ška=I  =I  
  readme.txtnu „[µü¤        === Plugin Name ===
Contributors: mandsconsulting
Donate link: http://www.mandsconsulting.com/
Tags: email, download
Requires at least: 5.x
Tested up to: 6.9.8
Stable tag: 6.9.8

Email Before Download (EBD) presents your users with a form where they submit information, like their name and email address, prior to receiving a download.

Plugin homepage: http://www.mandsconsulting.com/products/wp-email-before-download

== Description ==

------------
6.x Release is Here!
After a hiatus from EBD development, a community member has reached out and partnered with us to breathe life back into EBD! We have recently made updates to fix issues and enhance capabilities of EBD. Stay tuned for more to come in EBD v6.x and above!
-------------

Email Before Download (EBD) presents your users with a form where they submit information, like their name and email address, prior to receiving a download. This plugin integrates with the popular [Contact Form 7](http://bit.ly/dNzVJd) and [WordPress Download Monitor](http://bit.ly/ifff4y) plugins, allowing you to create any form you like and manage/monitor your file downloads.  You can also EXPORT a list of users that have downloaded files from the plug-in's settings page.  Prior to installing Email Before Download, please confirm each of the dependent plugins is already installed and working independently.

As an option, you can configure Email Before Download to:

1. Display a link to your file directly under the contact form once it is submitted.  This happens dynamically, inline of your post/page.
1. Send the user an email with a link and/or attachment to download your file.
1. Both #1 and #2

[Plugin Homepage with Live Demos and Test Download](http://www.mandsconsulting.com/products/wp-email-before-download) | [Support Forums](http://bit.ly/lU7Tdt) | [Customer Feedback Page](https://www.mandsconsulting.com/wordpress-email-before-download-customer-feedback/)


Usage

Note: You can see screenshots at [http://wordpress.org/extend/plugins/email-before-download/screenshots/](http://bit.ly/g4r1w2)

1. Create a contact form used by Email Before Download using Contact Form 7 and note the Contact Form ID
1. Upload a file using Download Monitor and note the Download ID
1. Navigate to the Post (or Page) you wish to include
1. Add the following short code using the IDs collected in the first two steps
   [email-download download_id="X" contact_form_id="Y"]



Plugin Homepage with Live Demos and Test Download: [http://www.mandsconsulting.com/products/wp-email-before-download](http://www.mandsconsulting.com/products/wp-email-before-download)

Please use the [Support Forums](http://bit.ly/lU7Tdt) for any questions and issues. Sometimes other users can help you as well.


== Installation ==

1. Download from [http://wordpress.org/extend/plugins/email-before-download/](http://bit.ly/dF9AxV)
1. Upload the entire email-before-download folder to the /wp-content/plugins/ directory.
1. Activate the plugin through the "Plugins" menu in WordPress.
1. Locate the "Email Before Download" menu item in your WordPress Admin panel under "Settings" to configure.


== Frequently Asked Questions ==

= Can I see a list of download requests people have made? =

Yes.  We store a log of the form submissions and generated links. You can view and export a CSV file of them from the Email Before Download settings page in your admin screens.

= What if I don't use the Contact Form 7 and/or Download Monitor Plugins? =

You will not be able to use this version of Email Before Download without these dependent plugins.  If you have specific reasons to avoid using the dependent plugins, please contact us and let us know the reason so we can take it into consideration.

= Anything special I need to do with my contact form? =

If you decide to configure the Email Before Download option to send the user an email with a link to the download, then you will want to name the email field "your-email" as shown in the example screenshots.  Outside of that, nothing special.

= What happens after the user completes the form? =

By default, the user is presented with a link or links to download their file(s).  There is also an option to email the user (with a link to the file and/or attachment) if you choose that route.  You can even provide both the inline link as well as the email if you choose.

= Are you changing any of my file or directory permissions? =

WordPress allows direct access to files in your upload directories using a direct URL and we do not change those permissions.  We do provide an option to mask the URL to your downloads if you have cURL enabled.

= What are the available shortcode options? =

This is the list of all short code attributes that can be used.   Some of them override the global admin settings.

* download_id - either one single download id from Wordpress Download Monitor, or a comma separated list of such ids, eg. '1,2,3'
* contact_form_id - Contact Form 7 ID. Overrides default contact for id from settings if used.
* title - this attribute overrides the  title from Download Monitor. if multiple, put them in a comma separated list in the same order as your download_ids.
* file  - use to point to external url
* delivered_as - possible values: "Send Email", "Both", "Inline Link"
* attachment  - "yes", "no" Attachments only work if files were uploaded with Download Monitor.
* force_download - any value that is passed considered as "yes" (we don't have a global menu item for that) only works with a single download_id.
* checked -  Loads form with item checked. If you are using checkboxes and have multiple items, the will all be checked,  Accepts "no", any other value is "yes"
* hide_form - "yes", "no"
* radio - "yes", "no"
* from_email - valid email address
* from_name - any alphanumeric string


== Screenshots ==

1. Note the ID of a file you have uploaded to Download Monitor.
2. Note the ID of a contact form you have created using Contact Form 7.
3. Use the following shortcode in your page or post: [email-download download_id="X" contact_form_id="Y"].
4. Upon installation and use of the plugin on a post/page, an end-user will see your contact form.
5. User will be required to enter valid data in accordance with Contact Form 7 validation rules.
6. Upon submission, user will either see a direct link below the form.  (Note: there is also an option to only email the link to the user.)
7. Example Contact Form 7 form code, including tag required to display multiple download selection checkboxes.


== Changelog ==
=6.9.8=
* Resolved security incident reported from Wordpress. Updated nonce validation to meet security needs. 

=6.9.7=
* Fixed issues with new PHP version and download monitor

=6.9.6=
*Changed the link appearance for the multiple downloads

=6.9.5=
* Fixed issue causing From Name to be translated to lowercase.

=6.9.4=
* Added checking if the current environment is admin
* Security fix

=6.9.3=
* Updated delivery format instructions on admin screen to show how to properly override the delivery format in shortcode
* Added hook to make sure that the dependencies are loaded
* Fix to expirated links, changed function to home_url

=6.9.2=
* Fix to expirated links, changed function to grab home_url instead of The WordPress Address URL.

=6.9.1=
* Fixed crashing issue on link expiration related to filter conflict 

=6.9=
* Fixed site crashing issue 

=6.8=
* Updated GET request security.
* Reviewed WP changes and more data sanitized, escaped, and validated 

=6.7=
* Updated GET request security.
* Updated Link Expiration Time bug to properly expire after selected time. 

=6.6=
* Updated readme to link to customer feedback page
* Updated delivery format instructions on admin screen to show how to properly override the delivery format in shortcode. 

=6.5=
* Updated readme screenshots

=6.4=
* Fix issue related to file_get_contents() function

=6.3=
* Update for support of CF7 latest release
* Enhancements to help with support for non-English websites

=6.7=
* Updated GET request security.
* Updated Link Expiration Time bug to properly expire after selected time. 

=6.6=
* Updated readme to link to customer feedback page
* Updated delivery format instructions on admin screen to show how to properly override the delivery format in shortcode. 

=6.5=
* Updated readme screenshots

=6.4=
* Fix issue related to file_get_contents() function

=6.3=
* Update for support of CF7 latest release
* Enhancements to help with support for non-English websites

=6.2=
* Moved EBD to own menu in preparation for more robust administration capabilities in upcoming releases

=6.1=
* Updated PHP session to resolve health check warning

=6.0=
* Display Download Monitor file thumbnails (optionally) by default for all files or on a case-by-case basis via shortcode override

=5.4=
* Multiple file download checkboxes were displaying a script, which is now hidden

=5.3=
* Download filenames were lowercased, but with with this release, they are no longer lowercased

=5.2=
* Fixed issue that will help support compatibility with latest versions of WP/PHP

=5.1.9=
* Changed the way DOMDocument removes wrappers to be compatible with older versions of PHP
=5.1.8=
* Fixed issue with some browsers not showing UTC-8 characters properly
* cleaned up some code to remove PHP warnings
=5.1.7=
* Fixed issue with some malformed HTML being created by DOMDocument()
=5.1.6=
* fixed issue where some people weren't getting ajaxed links
=5.1.5=
* fixed issue with false positives on invalid uids
=5.1.4=
* minor bugfixes
=5.1.3=
* fixed issue with link displaying when email only selected.
=5.1.2=
* Simplified use of PHPDomDocument to better function with older versions of PHP
* Let Javascript do more of the work for hiding/showing forms
* Removed custom API endpoint that was giving issue for some users
* Using Download Monitor hook to serve files

=5.1.1=
* Fixed issue where some instances wouldn't activate after update
* Fixed issue where some servers wouldn't set session variables
* Added css class to download selectors for easier formatting
* Fixed issue where some settings would be reset to default on update
* Fixed issue with older versions of PHP not liking HTML5 tags

=5.1.0=
* Added compatibility with version 5.0 of Contact Form 7
* Fixed issue where blacklist wasn't parsing correctly for some people
* Fixed issue with response box showing for some people

=5.0.9=
* Fixed issue with character encoding when building form

=5.0.8=
* Fixed issue with older versions of PHP giving parse errors.
* Added banner and icons for plugin.

=5.0.7=
* Fixed issue with [your-message] not being parsed properly
* Fixed downloaded files not showing in admin email
* Fixed issue where some people couldn't activate the plugin
* Fixed issue where form reloaded the page on submit for some people

=5.0.6=
* Fixed issue where pages with multiple forms weren't displaying inline links properly
* Fixed issee with link_format not working

=5.0.5=
* Fixed issue with some servers not attaching files to emails
* Fixed issue with malformed email headers if from_name was left blank
* Fixed issue with some multiple download forms
* Fixed issue with smart quotes being used in shortcode by third party content editors
* Removed some default styling that was conflicting with some custom styles
* Fixed issue with non standard upload folder names

=5.0.4=
* Fixed emails not being sent for some people
* Fixed display issues with colons in download titles
* Modified settings so EBD stays compatible with Custom Sender plugin.
* Added shortcode attributes for from_email and from_name.

=5.0.3=
* Fixed issue with form not displaying for some people

=5.0.2=
* Fixed issue with admin tables not showing.

=5.0.1=
* Bug fixes

=5.0=
* Complete tear down and rewrite of entire EBD plugin.
* Better integration with Wordpress.
* Added admin view, export, and purge of download links and posted data.
* Added better integration with Contact Form 7 and Download Monitor.
* Removed masked option from settings as this is pretty much done by default now.
* Added option for default contact form id.
* Added some CSS to the generated inline links to make them look a little better by default. Can be overwritten easily if needed.
* generates shorter URLs.
* More settings available in shortcode.
* Can override multiple titles now, as long as they are in the same order as the download ids.

=4.1=
* Made a few more modifications at the request of email from "plugins@wordpress.org".

=4.0=
* Made modifications to address items requested by "plugins@wordpress.org" such as ensuring further sanitization of email addresses and database inserts. Also, removed ability to access files directly from within the plugin folder. Finally, while making these changes, changed the URL for downloads to use "ebd_dl" instead of "dl" just in case another plugin were to begin using the "dl" parameter in order to prevent possible conflicts. Due to these changes, download links from prior to EBD v4.0 will no longer work with EBD v4.0+.
=3.6=
* Made modifications to shorten the download URL and potentially improve email deliverability by removing "download.php" from the download link

=3.5=
* Made minor changes to support PHP 7.

=3.4.2=
* Fixed issue regarding the download button on some themes where download button would display in wrong format.

=3.4.1=
* Fixed issue related to SQL functions used in code.

=3.4=
* Updated deprecated WPDB escape functionality to new one.

=3.3=
* Updated to be compatible with Contact Form Version 3.9

= 3.2.9 =
* Fixed issues related to a recent release of Contact Form 7 version 3.9

= 3.2.8 =
* Fixed the issue with multiple download ids checkboxes when user selects hidden contact form option.
The checkbox can now be to the left or right, depending on the custom tag (<ebd /> or <ebd left/>)"

= 3.2.7 =
* Fixed the issue with loading contact form as XML to DOM parser, when html entities were breaking the validity of XML.

= 3.2.6 =
* Added new option that allows user to hide contact form until user selects at least one downloads (for multiple download ids )
* Added option that turns checkboxes to radio buttons (for multiple download ids)

= 3.2.5 =
* Fixed bug with single quotes that led to javascript error.

= 3.2.4 =
* Added support to new version of the Download monitor
* Modified download logic: If the masked option is turned on and Internet Explorer is detected, download will be forced.

= 3.2.3 =
* Two new fields added to the plugin: user_name and email
* CSV export now includes new fields
* Added checks for the existence of the new fields, adds them if needed
* In admin settings, added new option that changes Multiple Checkboxes' default state
* Added new short code attribute that overrides admin settings for Multiple Checkboxes' default state

= 3.2.2 =
* Removed extra spacing in multiple download output

= 3.2.1 =
* Create table SQL script updated (now the title column has utf8 character set and utf8_unicode_ci collation)
* Added a patch that checks this specific column and alters it if needed

= 3.2 =
* Fixed bug related to logging multiple downloads correctly
* Added field to CSV export
* Added PayPal button in Admin Panel
* Added character encoding in case it helps to support languages other than English


= 3.1.7 =
* Default multiple file downloads to pre-selected (checked) by default

= 3.1.6 =
* Minor fix for various multi-file issues and logging

= 3.1.5 =
* fixed event handling
* stubbed email_from, though it is not active

= 3.1 =
* New modification to help support for Contact Form 7 v3.0+

= 3.0 =
* Modification to help support for Contact Form 7 v3.0+
* Added ability to force a file download using attribute in shortcode [email-download download_id="X" contact_form_id="Y" force-download="true"]; Download Monitor Force Download Option is recommended for files stored in Download Monitor
* Added option in admin panel to clear Email Before Download log entries
* Minor fomatting updates to admin panel
* Updates to allow Download Monitor to track clicks/downloads of files accessed using various scenarios of the Email Before Download plugin; Download Monitor still does not track clicks when using the masked URL option of Email Before Download, but the Email Before Download log does track these

= 2.6 =
* Bigger export link
* Support for special characters in filenames like "&"
* Fix for empty page interaction
* Change of function name to avoid conflict with other plugins
* Support for left checkboxes on multiple file download form using "&lt;ebd_left /&gt;"

= 2.5.1 =
* Minor cleanup of admin panel

= 2.5 =
* Added ability to prevent specific domain names
* Fixed download filename issue for .zip files


= 2.0 =
* Support multiple download selection (within shortcut code, use comma-separated list of download IDs: download_id="1,2,3" -- within the contact form 7 form used for multiple download selection, ensure you place the tag "&lt;ebd /&gt;" where you want to checkbox list to be generated) as shown in [screenshot 7](http://wordpress.org/extend/plugins/email-before-download/screenshots/)
* Add more information in the download history EXPORT .csv file
* Added support for Download Monitor format code for the inline link that is displayed (within shortcut code, specify the format code: format="1")
* Allow overriding the default settings with the shortcode (i.e. within shortcode, use delivered_as="Inline Link" even though the general setting in admin panel is setup for "Both" -- options are "Inline Link", "Send Email", "Both")
* Updates to avoid potential conflicts with other plugins
* Added ability to customize subject line when emailing file download

= 1.0 =
* Added ability to export log in CSV format from admin settings page.
* Added ability to mask download file's URL if cURL is enabled.
* Added ability to expire the download link after a given timeframe.
* In addition to emailing a link to the file, added ability to email the file as an attachment.
* Added ability to download files outside of Download Monitor (within shortcode, use file="http://mydomain.com/file.pdf" -- no need to include download_id="X" in this case).

= 0.5 =
* First release.

== Upgrade Notice ==

= 1.0 =
Automatically upgrade the plugin and all previous settings should remain intact.

= 0.5 =
First release.
PK     ä‹U]«š�¤  ¤  2  includes/class-email-before-download-shortcode.phpnu „[µü¤        <?php
/**
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */

class Email_Before_Download_Shortcode {

    private $plugin_name;
    private $version;
    private $option_name = 'email_before_download';
    private $db;

    public function __construct( $plugin_name, $version ) {
        global $wpdb;
        $this->plugin_name = $plugin_name;
        $this->version = $version;
        $this->db = $wpdb;

    }
public function init_shortcode($user_atts = array(), $content = null, $tag = 'email-download')
{
    if(isset($user_atts['title']))
        $tmpTitle = $user_atts['title'];

    $user_atts = array_change_key_case((array)$user_atts, CASE_LOWER);

    if(isset($tmpTitle))
        $user_atts['title'] = $tmpTitle;

    if(isset($user_atts['checked'])){
        if($user_atts['checked'] == 'no'){
            $user_atts['checked'] = '';
        }else{
            $user_atts['checked'] = 'checked';
        }
    }
    if(isset($user_atts['title'])){

    }
    $user_atts['download_id'] = str_replace(' ', '', $user_atts['download_id']);

    $default_titles = $this->generate_dl_title($user_atts['download_id']);
    $default_atts = array(
        'download_id'       => NULL,
        'contact_form_id'   => get_option($this->option_name.'_default_cf7'),
        'title'             => $default_titles,
        'file'              => NULL,
        'delivered_as'      => get_option($this->option_name.'_delivery_format'),
        'attachment'        => get_option($this->option_name.'_attachment'),
        'force_download'    => '0',
        'checked'           => get_option($this->option_name.'_multi_check','no'),
        'hide_form'         => get_option($this->option_name.'_hidden_form','yes'),
        'radio'             => get_option($this->option_name.'_radio','no'),
        'expire_time'       => get_option($this->option_name.'_expire'),
        'from_email'       => get_option($this->option_name.'_email_from'),
        'from_name'        => get_option($this->option_name.'_from_name'," "),
        'link_format'      => get_option($this->option_name.'_link_format'),
        'file_thumbnail'      => get_option($this->option_name.'_file_thumbnail','no')
    );
    $atts = shortcode_atts($default_atts, $user_atts, $tag);

    $atts['item_id'] = $this->add_item($atts);
    $form = new Email_Before_Download_Form($atts);
    $this->cf7_check();
    $content = $form->html();
    return $content;
}
private function add_item($atts)
{

    $db = new Email_Before_Download_DB();
    return $db->create_item($atts);
}

private function generate_dl_title($data){
        $title ="";
        if(strpos($data,',')){
            $ids = explode(',',$data);
        }else{
            $ids[] = $data;
        }
        foreach ($ids as $id){
            $title .= do_shortcode("[download_data id=\"$id\" data=\"title\"]"). ",";
        }
    $title = substr($title,0,-1);
        return $title;

}

private function cf7_check() {
    if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
        wpcf7_enqueue_scripts();
    }

    if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
        wpcf7_enqueue_styles();
    }
}



}
PK     ä‹U]ƒB`è  è  (  includes/class-email-before-download.phpnu „[µü¤        <?php
/**
 * The core plugin class.
 *
 * This is used to define internationalization, admin-specific hooks,
 * public-facing site hooks, and processing hooks.
 *
 * Also maintains the unique identifier of this plugin as well as the current
 * version of the plugin.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */
class Email_Before_Download {

	protected $loader;
	protected $plugin_name;
	protected $version;

	public function __construct() {
	    $this->version = EMAIL_BEFORE_DOWNLOAD_VERSION;
		$this->plugin_name = 'email-before-download';
		$this->load_dependencies();
		$this->set_locale();
		$this->define_admin_hooks();
		$this->define_public_hooks();
		$this->define_process_hooks();
		$this->build_shortcode();
	}

	private function load_dependencies() {
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-loader.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-i18n.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-email-before-download-admin.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-email-before-download-table.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-email-before-download-public.php';
        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-shortcode.php';
        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-downloader.php';
        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-process.php';
        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-form.php';
        require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-email-before-download-db.php';
		$this->loader = new Email_Before_Download_Loader();

	}
	private function set_locale() {
		$plugin_i18n = new Email_Before_Download_i18n();
		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
	}
	private function define_admin_hooks() {
		$plugin_admin = new Email_Before_Download_Admin( $this->get_plugin_name(), $this->get_version() );
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
        $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_options_page' );
        $this->loader->add_action( 'admin_init', $plugin_admin, 'build_settings' );
        $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
        $this->loader->add_action( 'admin_post_ebd.csv',$plugin_admin, 'print_csv' );
        $this->loader->add_action( 'admin_post_ebd.purge',$plugin_admin, 'purge_data' );
    }

	private function define_public_hooks() {

		$plugin_public = new Email_Before_Download_Public( $this->get_plugin_name(), $this->get_version() );
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
        $this->loader->add_filter( 'the_content', $plugin_public,'shortcode_cleanup');
        $this->loader->add_action('wp_ajax_ebd_inline_links', $plugin_public, 'ebd_ajax');
        $this->loader->add_action('wp_ajax_nopriv_ebd_inline_links', $plugin_public, 'ebd_ajax');
        $this->loader->add_filter('dlm_can_download', $plugin_public, 'record',10,2);
        if(!is_admin())
        	$this->loader->add_filter( 'pre_kses', $plugin_public, 'ebd_the_download' ,10,2);

    }
    private function define_process_hooks(){
        $plugin_process = new Email_Before_Download_Process( $this->get_plugin_name(), $this->get_version() );
        $this->loader->add_action( 'wpcf7_before_send_mail',$plugin_process, 'process_cf7',10,3 );
        $this->loader->add_filter('wpcf7_validate', $plugin_process, 'check_blacklist',10,2);
    }

    public function build_shortcode(){
        add_shortcode('email-download' ,array( new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version() ),'init_shortcode') );
        add_shortcode('emailreq' ,array( new Email_Before_Download_Shortcode( $this->get_plugin_name(), $this->get_version() ),'init_shortcode') );
    }

	public function run() {
		$this->loader->run();
	}

    public function get_plugin_name() {
		return $this->plugin_name;
	}

	public function get_loader() {
		return $this->loader;
	}

	public function get_version() {
		return $this->version;
	}

    public function run_download($data) {
        $downloader = new Email_Before_download_Downloader( $this->get_plugin_name(), $this->get_version() );
        $downloader->serve_file($data['uid']);
        exit();

    }


}
PK     ä‹U]Ö\¥Ï/  Ï/  0  includes/class-email-before-download-process.phpnu „[µü¤        <?php
/**
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */

class Email_Before_Download_Process
{

    private $plugin_name;
    private $version;
    private $db;

    public function __construct($plugin_name, $version)
    {
        $this->plugin_name = $plugin_name;
        $this->version = $version;
        $this->db = new Email_Before_Download_DB();
    }

    public function process_cf7($form_obj, $abort, $submission)
    {
        if (!isset($_POST['ebd_settings'])) {
            return $form_obj;  // make sure this only fires when there is EBD info
        }
        $post_data = $submission->get_posted_data();
        $user_input = array();
        $settings = $this->parse_post_array($post_data['ebd_settings']);
        $downloads = $this->parse_post_array($post_data['ebd_downloads'], false);
        foreach ($post_data as $key => $value) {
            if (!is_array($value))
                $user_input[$key] = $value;
        }
        $this->log($post_data, $user_input);
        $links = $this->generate_links($downloads, $settings, $user_input);

        if (($settings['delivered_as'] == 'send email') || ($settings['delivered_as'] == 'both')) {
            $this->send_email($user_input, $links, $settings);
        }
        $mail = $form_obj->prop('mail');
        $newMail = $this->reply($mail,$links);
        $form_obj->set_properties(array('mail' => $newMail));
        return $form_obj;
    }

    private function reply($mail,$links){
        $message = "The downloaded file name(s): ";
        foreach ($links as $link){
            $message .= " ".$link->title.",";
        }
        $message = rtrim($message, ',');
        if(stripos($mail['body'],"[your-message]")){
            $mail['body'] = str_replace("[your-message]", $message, $mail['body']);
            }else{
            $mail['body'] .= $message;
        }
        return $mail;
    }
    private function parse_post_array($post_array, $tolowercase = true)
    {
        $new_array = array();
        $delimiter = "|";
        foreach ($post_array as $item) {
            if (strpos($item, '|')) {
                $delimiter = "|";
            }
            $tmp = explode($delimiter, $item);
            if($tolowercase == true && $tmp[0] != 'from_name')
                $new_array[$tmp[0]] = strtolower($tmp[1]);
            else
                $new_array[$tmp[0]] = $tmp[1];
        }
        return $new_array;
    }
    private function generate_email($body, $data, $links, $settings = null)
    {
        //build email to send to user
        $files = $this->email_links($links);
        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $tagToReplace = "[$key]";
                $body = str_replace($tagToReplace, $value, $body);
            }
        }
        $urls = "";
        foreach ($files as $file) {
            if (count($files) == 1) {
                if(isset($settings['file'])){
                    $file['url'] = $settings['file'];
                }
                $body = str_replace('[file_url]', $file['url'], $body);
                $body = str_replace('[file_name]', $file['title'], $body);
            } else {
                $urls .= "<a href='".$file['url'] . "'>".$file['title']."</a><br/>\r\n";
            }
        }
        $body = str_replace('[file_urls]', $urls, $body);


        return $body;
    }


    private function send_email($user_input, $links, $settings)
    {
        $headers = "Content-Type: text/html; charset=UTF-8\r\n";
        if(isset($settings['from_name']))  $name = $settings['from_name'] ;
        if(isset($settings['from_email']))  $from = $settings['from_email'] ;
        if( (isset($from) ) && ( is_email($from) ) ){
            $from = sanitize_email($from);
            if( (isset($name) ) && ( $name != "" ) ){
                $headers .= "From: $name <$from>\r\n";
            }else {
                $headers .= "From: $from\r\n";
            }
        }
        $headers = rtrim($headers);
        $attachments = array();
        if (count($links) > 1) {
            $template = get_option("email_before_download_multi_email");
            if (!$template) $template = "[file_urls]";
        } else {
            $template = get_option("email_before_download_single_email");
            if (!$template) $template = __("Here is the download for <a href=\"[file_url]\">[file_name]</a> that you requested.",'email-before-download');

        }
        $subject = get_option("email_before_download_subject");
        if (!$subject) $subject = __("Your Requested File(s)", 'email-before-download');
            $subject = $this->generate_email($subject, $user_input, $links);
            $body = $this->generate_email($template, $user_input, $links,$settings);
        if ( (isset($settings['attachment']) ) && ($settings['attachment'] != 'no') ) {
            $attachments = $this->email_attachments($links);
        }
        wp_mail($user_input['your-email'], $subject, $body, $headers, $attachments);
        return true;
    }


    private function generate_links($downloads, $settings, $user_input)
    {

        $links = array();
        $default_link_data = array(
            "expire_time" => "",
            "delivered_as" => "",
            "force_download" => ""
        );
        $settings = array_merge($default_link_data, $settings);

        foreach ($downloads as $id => $title) {
            $linkdata = array(
                "item_id" => $settings['item_id'],
                "selected_id" => $id,
                "is_force_download" => $settings['force_download'],
                "email" => sanitize_email($user_input['your-email']),
                "delivered_as" => $settings['delivered_as'],
                'uid' => substr(md5(uniqid(mt_rand(), true)), 0, 10),
                'time_requested' => time(),

            );

            $linkdata = array_filter($linkdata);
            $linkdata["expire_time"] = get_option('email_before_download_expire',"");
            $link = $this->db->create_link($linkdata);
            $link->title = $title;
            $links[$link->id] = $link;
        }
        return $links;
    }

//This function is obsolete, deprecated and is no longer being used.
    // private function inline_links($links, $form_obj, $settings)
    // {

    //     $htmlBefore = get_option('email_before_download_html_before');
    //     $htmlAfter  = get_option('email_before_download_html_after');
    //     $htmlBefore = isset($htmlBefore) ? $htmlBefore : "";
    //     $htmlAfter = isset($htmlAfter) ? $htmlAfter : "";
    //     $linkHTML = "<div>" .$htmlBefore ;
    //     $form_id = $settings['form_id'];
    //     foreach ($links as $link) {
    //         if(isset($settings['file'])){
    //             $downloadURL = $settings['file'];
    //         }else{
    //             $downloadURL = $this->link_url($link);
    //         }
    //         $linkCSS = get_option('email_before_download_link_css');
    //         $linkCSS = isset($linkCSS) ? $linkCSS : "";
    //         $target = $settings['link_format'];
    //         $html = "<a href=\"$downloadURL\" class=\"ebd_link $linkCSS\" target=\"$target\">";
    //             if(isset($link->title)){
    //                 $html .= $link->title;
    //             }else {
    //                 $html .= do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");

    //             }
    //         $html .= "</a></br>";
    //         $linkHTML .= $html;
    //     }
    //     $linkHTML .= $htmlAfter. "</div>";
    //         $additional_settings = $form_obj->prop('additional_settings');
    //         $hideOnSubmit = "jQuery('.ebd_input').hide();jQuery('.cf7_input').hide(); ";
    //         $additional_settings .= "\n" . "on_sent_ok: \" jQuery('#$form_id').append('$linkHTML'); \"";
    //         $form_obj->set_properties(array('additional_settings' => $additional_settings));

    //     return $form_obj;
    // }
    private function email_links($links)
    {
        $files = array();
        foreach ($links as $link) {
            if(isset($link->title)){
                $title = $link->title;
            }else{
                $title = do_shortcode("[download_data id=\"$link->selected_id\" data=\"title\"]");

            }

                $files[] = array('title' => $title,'url' => $this->link_url($link));


        }
        return $files;
    }
    private function email_attachments($links)
    {

        $filePaths = array();
        foreach ($links as $link) {
            $fileName = do_shortcode("[download_data id=\"$link->selected_id\" data=\"filename\"]");

            $uploadsetting = get_option('uploads_use_yearmonth_folders');
            $uploadsetting = isset($uploadsetting) ? $uploadsetting : 0;
            $directory = wp_upload_dir();
            if($uploadsetting == 1){
                $fileDate = do_shortcode("[download_data id=\"$link->selected_id\" data=\"file_date\"]");
                $fileDate = date('Y/m', strtotime($fileDate));
                $filePaths[] =  $directory['basedir']. "/dlm_uploads/$fileDate/$fileName";
            }else{
                $filePaths[] = $directory['basedir'] . "/dlm_uploads/$fileName";
            }

        }

        return $filePaths;
    }

    public function check_blacklist($result, $tag)
    {
        if (!isset($_POST['ebd_settings'])) {
            return $result;  // make sure this is an EBD form
        }
        $email = strtolower(sanitize_email($_POST['your-email']));
        if ($this->blacklist($email)) {
            $result->invalidate('your-email', __('addresses from this domain are not allowed.', 'email-before-download'));
        }
        return $result;
    }

    public function blacklist($email)
    {
        $blacklist = strtolower(get_option('email_before_download_forbidden',""));
        if ($blacklist == "") return false;
        $blacklist = str_replace(array("\r", "\n",'@',' '), '', $blacklist);
        $email = explode('@', $email);
        $domain = $email[1];
        if (strpos($blacklist, ',')) {
            $blacklist = explode(',', $blacklist);
            // file_put_contents('blacklinst.txt', var_export($blacklist, true),true);
            if (in_array($domain, $blacklist))
                return true;
        } else {
            if ($domain == $blacklist) return true;
        }

        return false;
    }

    public function link_url($link)
    {
        $generated_link = '';
        if($link->expire_time > 0)
            $generated_link =home_url().'?ebddl='.$link->uid;
        else{
            $generated_link =do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");
            // .$spacer.$link->uid;
            $parsed_link = parse_url($generated_link);
            if(isset($parsed_link['query'])){ // The link already has URL parameters being set
              $generated_link = $generated_link.'&ebduid='.$link->uid;
            }else{ // This is the first URL parameter in the link
              $generated_link = $generated_link.'?ebduid='.$link->uid;
            }
        }
       return $generated_link;
    }

    public function log($post_data, $user_data)
    {
        $xml = $this->xml($post_data);
        $data = array(
            'email' => sanitize_email($user_data['your-email']),
            'user_name' => sanitize_text_field($user_data['your-name']),
            'posted_data' => $xml,
            'time_requested' => time()
        );

        return $this->db->create_log($data);
    }

    public function xml($data)
    {
        $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><posted_data>";
        foreach ($data as $key => $value) {
            $xml .= "<$key>";
            if (is_array($value)) {
                foreach ($value as $key2 => $item) {
                    $xml .= "<item-$key2>";
                    $xml .= $item;
                    $xml .= "</item-$key2>";
                }
            } else {
                $xml .= $value;
            }
            $xml .= "</$key>";
        }

        $xml .= "</posted_data>";
        return $xml;
    }

}
PK     ä‹U]*¤	Õ        includes/index.phpnu „[µü¤        <?php // Silence is goldenPK     ä‹U]c¤  ­  -  includes/class-email-before-download-i18n.phpnu „[µü¤        <?php

/**
 * Define the internationalization functionality
 *
 * Loads and defines the internationalization files for this plugin
 * so that it is ready for translation.
 *
 * @link       mandsconsulting.com
 * @since      1.0.0
 *
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 */

/**
 * Define the internationalization functionality.
 *
 * Loads and defines the internationalization files for this plugin
 * so that it is ready for translation.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */
class Email_Before_Download_i18n {


	/**
	 * Load the plugin text domain for translation.
	 *
	 * @since    1.0.0
	 */
	public function load_plugin_textdomain() {

		load_plugin_textdomain(
			'email-before-download',
			false,
			dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
		);

	}



}
PK     ä‹U]™ëbv~  ~  3  includes/class-email-before-download-downloader.phpnu „[µü¤        <?php
/**
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */

class Email_Before_download_Downloader
{
    private $plugin_name;
    private $version;

    public function __construct($plugin_name, $version)
    {

        $this->plugin_name = $plugin_name;
        $this->version = $version;

    }
    public function serve_file($uid)
    {

        $db = new Email_Before_Download_DB();
        $link = $db->select_link('uid', $uid);
        if ($this->expired($link)) {
            wp_die(__('This download has expired. Please fill out a new form to generate a new link.', 'email-before-download'));
        }
        if(isset($link->file)){
            $file = $link->file;
        }else{
            $file = do_shortcode("[download_data id=\"$link->selected_id\" data=\"download_link\"]");

        }
        $db->mark_downloaded($link->id);
         wp_redirect($file);
         exit();
    }

    public function expired($link)
    {
        if ($link->expire_time)
            if ($link->expire_time < time()) return true;
        return false;
    }
}PK     ä‹U]Oºäl  l  -  includes/class-email-before-download-form.phpnu „[µü¤        <?php
/**
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */

class Email_Before_Download_Form
{
    public $form_id;
    public $download_id;
    public $titles;
    public $atts;

    public function __construct($atts)
    {
        $this->atts = $atts;
        $this->form_id = $atts['contact_form_id'];
        $this->download_id = $this->att_to_array($atts['download_id']);
        $this->titles = $this->att_to_array($atts['title']);
        unset($this->atts['contact_form_id']);
        unset($this->atts['download_id']);
    }

    public function html()
    {
        if(is_admin()) return '';
        $raw = do_shortcode("[contact-form-7 id=\"$this->form_id\" ]");
        $remove = array('<ebd />','<ebd/>','<ebd_left />','<ebd_left/>');
        $raw = str_replace($remove, "", $raw);
        $form = new DOMDocument;
        libxml_use_internal_errors(true);
        $form->formatOutput = true;
        $form->loadHTML(mb_convert_encoding($raw, 'HTML-ENTITIES', 'UTF-8'));
        $form->removeChild($form->doctype);
        $form->replaceChild($form->firstChild->firstChild->firstChild, $form->firstChild);
        $parent = $form->getElementsByTagName('form')->item(0);
        $formID = $parent->getAttribute('action');
        $tmp = explode('#', $formID);
        $this->atts['form_id'] = $tmp[1];
        $paragraph = $parent->getElementsByTagName('div')->item(0);

        foreach ($this->download_id as $key => $id) {
            if(count($this->download_id) == 1) {
                $item = $this->hide_download_dom_obj($id, $key);
            }else{
                $item = $this->download_dom_obj($id, $key);
            }
            $item = $form->importNode($item, true);
            $paragraph->parentNode->insertBefore($item, $paragraph);
        }

        foreach ($this->atts as $name => $value) {
            if($value){
                $item = $this->hidden_dom_obj($name,$value);
                $item = $form->importNode($item, true);
                $paragraph->parentNode->insertBefore($item, $paragraph);
            }
        }
        if($this->atts['hide_form'] == 'yes'){
            $script = $this->jquery_dom_obj();
            $item = $form->importNode($script, true);
            $parent->appendChild($item);
        }
        libxml_clear_errors();
        return $form->saveHTML();
    }

    private function download_dom_obj($id, $key){

        $formObject = new DOMDocument();
        $formObject->formatOutput = true;
            $title = mb_convert_encoding($this->titles[$key], 'HTML-ENTITIES', 'UTF-8');
        $isChecked = get_option('email_before_download_multi_check');
        $isRadio = $this->atts['radio'];
        if ($isRadio != "yes" ) {
            $input = 'checkbox';
        } else {
            $input = 'radio';
        }
        $formObject->loadHTML("<label class='ebd_input'><input type=\"$input\" $isChecked name=\"ebd_downloads[]\" value=\"$id|$title\"> $title</label>");
        $node = $formObject->getElementsByTagName("label");
        return $node->item(0);
    }
    private function hide_download_dom_obj($id, $key){

        $formObject = new DOMDocument();
        $formObject->formatOutput = true;
        $title = mb_convert_encoding($this->titles[$key], 'HTML-ENTITIES', 'UTF-8');
        $formObject->loadHTML("<label class='ebd_input'><input type=\"hidden\"  name=\"ebd_downloads[]\" value=\"$id|$title\"> </label>");
        $node = $formObject->getElementsByTagName("label");
        return $node->item(0);
    }
    private function hidden_dom_obj($name, $value){
        $formObject = new DOMDocument();
        $formObject->formatOutput = true;
        $formObject->loadHTML("<input type=\"hidden\" class=\"ebd_setting\" name =\"ebd_settings[]\" value=\"$name|$value\">");
        $node = $formObject->getElementsByTagName("input");
        return $node->item(0);
    }
    private function jquery_dom_obj(){
            $hide = "";
        $formObject = new DOMDocument();
        $formID = $this->atts['form_id'];
        $formSelector = str_replace('-','',$formID);
        $formObject->formatOutput = true;
        if(($this->atts['hide_form'] == 'yes') && ($this->atts['checked'] == '') && (count($this->download_id) > 1) )
            $hide = "jQuery(\"div#$formID form \").children().not('.ebd_input').not('.wpcf7-response-output').hide();";

        $script = "<script> var ". $formSelector. "selectors = \"div#$formID > form > .ebd_input > input\";
        $hide
        jQuery( ". $formSelector. "selectors ).on( \"click\", function () {
            var ". $formSelector. "n = jQuery( ". $formSelector. "selectors+\":checked\" ).length;
            
            if(". $formSelector. "n > 0) jQuery(\"div#$formID form \").children().not('.ebd_input').not('.wpcf7-response-output').not('script').show();
            else jQuery(\"div#$formID form \").children().not('.ebd_input').not('.wpcf7-response-output').not('script').hide();
        } );    jQuery('.wpcf7-response-output').hide();
</script>";
        $formObject->loadHTML($script);
        $node = $formObject->getElementsByTagName("script");
        return $node->item(0);

    }
    private function att_to_array($data){
        $formatted = array();
        if (stripos($data, ',')) {
            $formatted = explode(',', $data);
        } else {
            $formatted[] = $data;
        }
        return $formatted;
    }

}PK     ä‹U]p¸ùA­  ­  +  includes/class-email-before-download-db.phpnu „[µü¤        <?php
/**
 * Used for plugin specific database actions.
 *
 * This class defines most code necessary to read and write
 * links, items, and logs to the database.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */

class Email_Before_Download_DB
{
    private $db;
    private $item_table;
    private $link_table;
    private $posted_table;

    public function __construct()
    {
        global $wpdb;
        $this->db = $wpdb;
        $this->item_table = $this->db->prefix . "ebd_item";
        $this->link_table = $this->db->prefix . "ebd_link";
        $this->posted_table = $this->db->prefix . "ebd_posted_data";
    }

    public function select_item($data)
    {
        return $this->db->get_row("SELECT  * FROM $this->item_table WHERE download_id = '$data'");
    }

    public function create_item($atts)
    {
        $item = $this->item_exists($atts);
        if ($item) {
            return $item;
        } else {
            $this->db->insert($this->item_table,
                array(
                    'download_id' => $atts['download_id'],
                    'title' => sanitize_text_field($atts['title']),
                    'file' => esc_url($atts['file'])
                ));
            return $this->db->insert_id;
        }
    }

    public function item_exists($data)
    {

        //check if item exists and if it needs updated
        $query = $this->db->get_row("SELECT  * FROM $this->item_table WHERE download_id = '" . $data['download_id'] . "'");
        if (isset($query)) {
            if ($query->file != $data['file']) {
                $this->db->update($this->item_table,
                    array('file' => $data['file']),
                    array('id' => $query->id)
                );
            }
            if ($query->title != $data['title']) {
                $this->db->update($this->item_table,
                    array('title' => $data['title']),
                    array('id' => $query->id)
            );
            }
            return $query->id;
        }
        return false;

    }

    public function create_link($data)
    {
        $data['expire_time'] = $this->expired($data['expire_time']);
        $this->db->insert($this->link_table, $data);
        $id = $this->db->insert_id;
        $link = $this->db->get_row("SELECT  * FROM $this->link_table WHERE id = '$id'");
        return $link;
    }

    public function select_link($column, $data)
    {
        $data = esc_sql($data);
        $query = $this->db->get_row("SELECT  * FROM $this->link_table WHERE $column = '$data'");
        return $query;
    }

    public function mark_downloaded($id)
    {

        return $this->db->update(
            $this->link_table,
            array('is_downloaded' => 1),
            array('ID' => $id)
        );

    }

    public function create_log($data)
    {
        return $this->db->insert($this->posted_table, $data);

    }

    public function expired($option)
    {
        if ($option != 0) {
            $duration = array(
                'minute' => 60,
                'hour' => 3600,
                'day' => 172800,
                'week' => 604800
            );

            $expired = explode(" ", $option);
            $expiration = (int)$expired[0] * (int)$duration[$expired[1]];
            $option = time() + $expiration;
        }
        return $option;
    }

    public function clean_up($table)
    {

        if ($table == $this->db->prefix . "ebd_link") {
            $now = time();
            $query = "DELETE FROM $table WHERE expire_time < $now";
            $page = 'links';
        } else {
            $query = "DELETE FROM $table";
            $page = "logs";
        }
        $this->db->query($query);
        session_start();
        $_SESSION['success'] = "$page have been purged.";
        wp_redirect(admin_url("/options-general.php?page=email-before-download-$page"));

    }
    public function export($table){
        $csv = "";
        foreach ( $this->db->get_col( "DESC " . $table, 0 ) as $column_name ) {
            $csv .= esc_html($column_name).",";
        }
        $csv =  substr($csv, 0, -1). "\n";
        foreach( $this->db->get_results("SELECT * FROM $table") as $key => $row) {
            foreach ($row as $key2 => $value){
                $csv .= $value. ",";
            }
            $csv =  substr($csv, 0, -1). "\n";
        }
        return $csv;
    }
    public function get_ajax_links($email){
        $time = time() - 30;

        $linkQuery = "
	SELECT uid, selected_id, expire_time
	FROM $this->link_table
	WHERE email = '$email' 
		AND time_requested > $time
	";
        $links = $this->db->get_results($linkQuery);

        return $links;
    }
    public function skip_check($downloadID) {
            $sql = "
                SELECT * 
                FROM $this->item_table 
                WHERE download_id = $downloadID 
                OR download_id LIKE ',$downloadID'
                OR download_id LIKE '$downloadID,' 
                OR download_id LIKE ',$downloadID,'";

            $query = $this->db->get_results($sql);

            if(count($query) < 1){
                return false;
            }
            return true;
        }

}
PK     ä‹U]ë—l  l  /  includes/class-email-before-download-loader.phpnu „[µü¤        <?php

/**
 * Register all actions and filters for the plugin
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */
class Email_Before_Download_Loader {

	/**
	 * The array of actions registered with WordPress.
	 *
	 * @since    1.0.0
	 * @access   protected
	 * @var      array    $actions    The actions registered with WordPress to fire when the plugin loads.
	 */
	protected $actions;

	/**
	 * The array of filters registered with WordPress.
	 *
	 * @since    1.0.0
	 * @access   protected
	 * @var      array    $filters    The filters registered with WordPress to fire when the plugin loads.
	 */
	protected $filters;

	public function __construct() {

		$this->actions = array();
		$this->filters = array();

	}

	public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
		$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
	}

	public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
		$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
	}

	private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {

		$hooks[] = array(
			'hook'          => $hook,
			'component'     => $component,
			'callback'      => $callback,
			'priority'      => $priority,
			'accepted_args' => $accepted_args
		);

		return $hooks;

	}

	public function run() {

		foreach ( $this->filters as $hook ) {
			add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
		}

		foreach ( $this->actions as $hook ) {
			add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
		}

	}

}
PK     ä‹U]-h"[1
  1
  2  includes/class-email-before-download-activator.phpnu „[µü¤        <?php
/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      5.0.0
 * @package    Email_Before_Download
 * @subpackage Email_Before_Download/includes
 * @author     M & S Consulting
 */
class Email_Before_Download_Activator
{

    public static function activate()
    {
        $plugins = array();
        if (!is_plugin_active('download-monitor/download-monitor.php'))
            $plugins[] = "Download Monitor";
        if (!is_plugin_active('contact-form-7/wp-contact-form-7.php'))
            $plugins[] = "Contact Form 7";

        if (!empty($plugins)) {
            echo("Missing the following plugin(s):<br>");
            foreach ($plugins as $plugin) {
                echo("<strong>". esc_html($plugin). "</strong><br>");
            }
            @trigger_error('missing dependencies', E_USER_ERROR);
        }
        global $wpdb;

            $tables = array(
                "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_item (
			  `id` int(11) NOT NULL auto_increment,
			  `download_id` varchar(128) NULL,
			  `file` varchar(255) NULL,
			  `title` varchar(255) NULL,
			  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
			  PRIMARY KEY  (`id`)
			);",
                "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_link (
             `id` mediumint(9) NOT NULL AUTO_INCREMENT,
             `item_id` int(11) NOT NULL,
             `is_downloaded` smallint(3) NOT NULL DEFAULT '0',
             `email` varchar(128) NOT NULL,
             `expire_time` bigint(11) DEFAULT NULL,
             `time_requested` bigint(11) DEFAULT NULL,
             `uid` varchar(255) NOT NULL,
             `selected_id` bigint(20) NOT NULL,
             `delivered_as` varchar(255) DEFAULT NULL,
             `is_masked` varchar(4) DEFAULT NULL,
             `is_force_download` varchar(4) DEFAULT NULL,
             UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8
			;",
                "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "ebd_posted_data (
			time_requested bigint(20),
			email VARCHAR(128) NULL,
			user_name VARCHAR(128)CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL,
            posted_data text(2000) NOT NULL,
			UNIQUE KEY id (time_requested)
			);",

            );
            $charset_collate = $wpdb->get_charset_collate();
            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
            foreach ($tables as $table) {
                dbDelta($table . $charset_collate);
            }
    }

}
PK     ä‹U]OEÅB      email-before-download.phpnu „[µü¤        <?php

/**
 * The plugin bootstrap file
 *
 *
 * @link              mandsconsulting.com
 * @since             6.0.0
 * @package           Email_Before_Download
 *
 * @wordpress-plugin
 * Plugin Name:       Email Before Download
 * Plugin URI:        mandsconsulting.com
 * Description:       Email Before Download (EBD) presents your users with a form where they submit information, like their name and email address, prior to receiving a download.
 * Version:           6.9.8
 * Author:            M&S Consulting
 * Author URI:        mandsconsulting.com
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       email-before-download
 * Domain Path:       /languages
 */

if ( ! defined( 'WPINC' ) ) {
	die;
}

define( 'EMAIL_BEFORE_DOWNLOAD_VERSION', '6.9.8' );

function activate_email_before_download() {
	require_once plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download-activator.php';
	Email_Before_Download_Activator::activate();
}

register_activation_hook( __FILE__, 'activate_email_before_download' );
require plugin_dir_path( __FILE__ ) . 'includes/class-email-before-download.php';

function run_email_before_download() {

  $plugin = new Email_Before_Download();
  $plugin->run();

}
// run_email_before_download();
add_action('plugins_loaded', 'run_email_before_download');
PK       ä‹U]*¤	Õ                      public/index.phpnu „[µü¤        PK       ä‹U]¿¤V;  ;  -            Z   public/class-email-before-download-public.phpnu „[µü¤        PK       ä‹U]^Š´:  :  )            ò  public/js/email-before-download-public.jsnu „[µü¤        PK       ä‹U]½žjêy   y   +            …#  public/css/email-before-download-public.cssnu „[µü¤        PK       ä‹U]Äξ§û   û               Y$  uninstall.phpnu „[µü¤        PK       ä‹U]Ò|qþð  ð              ‘%  assets/group3.svgnu „[µü¤        PK       ä‹U]*¤	Õ      	            Â'  index.phpnu „[µü¤        PK       ä‹U]΅M«F  «F              (  LICENSE.txtnu „[µü¤        PK       ä‹U]˜qg*    +            ûn  admin/class-email-before-download-table.phpnu „[µü¤        PK       ä‹U]	¤ߝ‘f  ‘f  +            XŠ  admin/class-email-before-download-admin.phpnu „[µü¤        PK       ä‹U]*¤	Õ                  Dñ  admin/index.phpnu „[µü¤        PK       ä‹U]:•Ԁ  €  6            �ñ  admin/partials/email-before-download-admin-display.phpnu „[µü¤        PK       ä‹U]Žð+-  -  4            ƒø  admin/partials/email-before-download-admin-table.phpnu „[µü¤        PK       ä‹U]YWs^  ^  )            ÿ  admin/css/email-before-download-admin.cssnu „[µü¤        PK       ä‹U]Ška=I  =I  
            Ë readme.txtnu „[µü¤        PK       ä‹U]«š�¤  ¤  2            BK includes/class-email-before-download-shortcode.phpnu „[µü¤        PK       ä‹U]ƒB`è  è  (            HX includes/class-email-before-download.phpnu „[µü¤        PK       ä‹U]Ö\¥Ï/  Ï/  0            ˆk includes/class-email-before-download-process.phpnu „[µü¤        PK       ä‹U]*¤	Õ                  ·› includes/index.phpnu „[µü¤        PK       ä‹U]c¤  ­  -            œ includes/class-email-before-download-i18n.phpnu „[µü¤        PK       ä‹U]™ëbv~  ~  3              includes/class-email-before-download-downloader.phpnu „[µü¤        PK       ä‹U]Oºäl  l  -            þ¤ includes/class-email-before-download-form.phpnu „[µü¤        PK       ä‹U]p¸ùA­  ­  +            Ǻ includes/class-email-before-download-db.phpnu „[µü¤        PK       ä‹U]ë—l  l  /            ÏÏ includes/class-email-before-download-loader.phpnu „[µü¤        PK       ä‹U]-h"[1
  1
  2            š× includes/class-email-before-download-activator.phpnu „[µü¤        PK       ä‹U]OEÅB                -â email-before-download.phpnu „[µü¤        PK      
  õç   