コード例 #1
0
function leyka_save_settings($tab_name)
{
    $options_names = array();
    foreach (leyka_opt_alloc()->get_tab_options($tab_name) as $entry) {
        if (is_array($entry)) {
            foreach ($entry as $key => $option) {
                if ($key == 'section') {
                    $options_names = array_merge($options_names, $option['options']);
                } else {
                    $options_names[] = $option;
                }
            }
        } else {
            $options_names[] = $entry;
        }
    }
    foreach ($options_names as $name) {
        $option_type = leyka_options()->get_type_of($name);
        if ($option_type == 'checkbox') {
            leyka_options()->opt($name, isset($_POST["leyka_{$name}"]) ? 1 : 0);
        } elseif ($option_type == 'multi_checkbox') {
            if (isset($_POST["leyka_{$name}"]) && leyka_options()->opt($name) != $_POST["leyka_{$name}"]) {
                leyka_options()->opt($name, (array) $_POST["leyka_{$name}"]);
            }
        } elseif ($option_type == 'html' || $option_type == 'rich_html') {
            if (isset($_POST["leyka_{$name}"]) && leyka_options()->opt($name) != $_POST["leyka_{$name}"]) {
                leyka_options()->opt($name, esc_attr(stripslashes($_POST["leyka_{$name}"])));
            }
        } else {
            if (isset($_POST["leyka_{$name}"]) && leyka_options()->opt($name) != $_POST["leyka_{$name}"]) {
                leyka_options()->opt($name, esc_attr(stripslashes($_POST["leyka_{$name}"])));
            }
        }
    }
}
コード例 #2
0
function leyka_render_section_area($section)
{
    ?>

    <div class="leyka-options-section <?php 
    echo $section['is_default_collapsed'] ? 'collapsed' : '';
    ?>
" id="<?php 
    echo $section['name'];
    ?>
">
        <div class="header"><h3><?php 
    echo esc_attr($section['title']);
    ?>
</h3></div>
        <div class="content">
            <?php 
    foreach ($section['options'] as $option) {
        $option_info = leyka_options()->get_info_of($option);
        do_action("leyka_render_{$option_info['type']}", $option, $option_info);
    }
    ?>
        </div>
    </div>
<?php 
}
コード例 #3
0
 public function _handle_service_calls($call_type = '')
 {
     if (empty($_POST['orderId'])) {
         $message = __("This message has been sent because a call to your RBK Money callback was made without orderId parameter given. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "THEIR_POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('RBK Money - orderId missing!', 'leyka'), $message);
         status_header(200);
         die;
     }
     $donation = new Leyka_Donation((int) stripslashes($_POST['orderId']));
     if (!$donation) {
         status_header(200);
         die;
     }
     // Test for e-sign:
     if (leyka_options()->opt('rbk_use_hash')) {
         $sign = hash(leyka_options()->opt('rbk_hash_type'), implode('::', array(leyka_options()->opt('rbk_eshop_id'), $_POST['orderId'], $_POST['serviceName'], leyka_options()->opt('rbk_eshop_account'), $donation->amount, mb_strtoupper($donation->currency), $_POST['paymentStatus'], $_POST['userName'], $donation->donor_email, $_POST['paymentData'], leyka_options()->opt('rbk_secret_key'))));
         if (empty($_POST['hash']) || $sign != trim(mb_strtolower($_POST['hash']))) {
             $message = __("This message has been sent because a call to your RBK Money callback was called with wrong data hash. This could mean someone is trying to hack your payment site. The details of the call are below.", 'leyka') . "\n\r\n\r";
             $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
             $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
             $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
             wp_mail(get_option('admin_email'), __('RBK Money hash check failed!', 'leyka'), $message);
             status_header(200);
             die;
         }
     }
     // Single payment:
     switch ($_POST['paymentStatus']) {
         case 4:
             $new_status = 'failed';
             break;
         case 5:
             $new_status = 'funded';
             break;
         default:
             $new_status = 'submitted';
     }
     if ($donation->status != $new_status) {
         $donation->add_gateway_response($_POST);
         $donation->status = $new_status;
         if (!$donation->donor_email && !empty($_POST['userEmail'])) {
             $donation->donor_email = $_POST['userEmail'];
         }
         if (!$donation->donor_name && !empty($_POST['userName'])) {
             $donation->donor_name = $_POST['userName'];
         }
         Leyka_Donation_Management::send_all_emails($donation->id);
     }
     status_header(200);
     die;
 }
コード例 #4
0
function leyka_add_gateway_metabox($post, $args)
{
    // $post is always null
    /** @var Leyka_Gateway $gateway */
    $gateway = $args['args']['gateway'];
    $pm_active = leyka_options()->opt('pm_available');
    ?>


    <div>

        <?php 
    foreach ($gateway->get_payment_methods() as $pm) {
        ?>

            <div>
                <input type="checkbox" name="leyka_pm_available[]" value="<?php 
        echo $pm->full_id;
        ?>
" class="pm-active" id="<?php 
        echo $pm->full_id;
        ?>
" data-pm-label="<?php 
        echo $pm->title_backend;
        ?>
" data-pm-label-backend="<?php 
        echo $pm->label_backend;
        ?>
" <?php 
        echo in_array($pm->full_id, $pm_active) ? 'checked="checked"' : '';
        ?>
>
                <label for="<?php 
        echo $pm->full_id;
        ?>
"><?php 
        echo $pm->title_backend;
        ?>
</label>
            </div>
        <?php 
    }
    ?>


    </div>
<?php 
}
コード例 #5
0
 public function process_form($gateway_id, $pm_id, $donation_id, $form_data)
 {
     load_textdomain('leyka', LEYKA_PLUGIN_DIR . 'lang/leyka-' . get_locale() . '.mo');
     // Localize a quittance first
     header('HTTP/1.1 200 OK');
     header('Content-Type: text/html; charset=utf-8');
     $campaign = new Leyka_Campaign($form_data['leyka_campaign_id']);
     $quittance_html = str_replace(array('#BACK_TO_DONATION_FORM_TEXT#', '#PRINT_THE_QUITTANCE_TEXT#', '#QUITTANCE_RECEIVED_TEXT#', '#SUCCESS_URL#', '#PAYMENT_COMMENT#', '#PAYER_NAME#', '#RECEIVER_NAME#', '#SUM#', '#INN#', '#KPP#', '#ACC#', '#RECEIVER_BANK_NAME#', '#BIC#', '#CORR#'), array(__('Return to the donation form', 'leyka'), __('Print the quittance', 'leyka'), __("OK, I've received the quittance", 'leyka'), get_permalink(leyka_options()->opt('quittance_redirect_page')), $campaign->payment_title . " (№ {$donation_id})", $form_data['leyka_donor_name'], leyka_options()->opt('org_full_name'), (int) $form_data['leyka_donation_amount'], leyka_options()->opt('org_inn'), leyka_options()->opt('org_kpp'), leyka_options()->opt('org_bank_account'), leyka_options()->opt('org_bank_name'), leyka_options()->opt('org_bank_bic'), leyka_options()->opt('org_bank_corr_account')), $this->_payment_methods[$pm_id]->get_quittance_html());
     for ($i = 0; $i < 10; $i++) {
         $quittance_html = str_replace("#INN_{$i}#", substr(leyka_options()->opt('org_inn'), $i, 1), $quittance_html);
     }
     for ($i = 0; $i < 20; $i++) {
         $quittance_html = str_replace("#ACC_{$i}#", substr(leyka_options()->opt('org_bank_account'), $i, 1), $quittance_html);
     }
     for ($i = 0; $i < 9; $i++) {
         $quittance_html = str_replace("#BIC_{$i}#", substr(leyka_options()->opt('org_bank_bic'), $i, 1), $quittance_html);
     }
     for ($i = 0; $i < 20; $i++) {
         $quittance_html = str_replace("#CORR_{$i}#", substr(leyka_options()->opt('org_bank_corr_account'), $i, 1), $quittance_html);
     }
     die($quittance_html);
 }
コード例 #6
0
 public function _handle_service_calls($call_type = '')
 {
     error_log_yandex_phyz("\n\n---- {$call_type} ----\n\n" . print_r($_REQUEST, true));
     $donation_id = (int) @$_POST['label'];
     // Donation ID
     $amount = (int) @$_POST['withdraw_amount'];
     error_log_yandex_phyz("Label={$donation_id}\n");
     error_log_yandex_phyz("Amount={$amount}\n");
     if (!$donation_id) {
         error_log_yandex_phyz("Label is empty\n");
         return;
     }
     $donation = new Leyka_Donation($donation_id);
     error_log_yandex_phyz("Donation initialized\n");
     error_log_yandex_phyz(print_r($donation, TRUE) . "\n");
     $params_to_sha1 = implode('&', array(@$_POST['notification_type'], @$_POST['operation_id'], @$_POST['amount'], @$_POST['currency'], @$_POST['datetime'], @$_POST['sender'], @$_POST['codepro'], leyka_options()->opt('yandex_money_secret'), @$_POST['label']));
     error_log_yandex_phyz("Params_to_sha1={$params_to_sha1}\n");
     $sha1 = sha1($params_to_sha1);
     error_log_yandex_phyz("sha1={$sha1}\n");
     if ($sha1 != @$_POST['sha1_hash']) {
         error_log_yandex_phyz("Invalid response sha1_hash\n");
         $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Invalid response sha1_hash', 'leyka'));
     } elseif ($donation) {
         error_log_yandex_phyz("Donation OK\n");
         error_log_yandex_phyz('$donation->sum=' . $donation->sum . "\n");
         error_log_yandex_phyz('$donation->status=' . $donation->status . "\n");
         if ($donation->sum != $amount) {
             error_log_yandex_phyz("Donation sum is unmatched\n");
             $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Donation sum is unmatched', 'leyka'));
         } elseif ($donation->status != 'funded') {
             error_log_yandex_phyz("Donation is funded\n");
             if (!empty($_POST['notification_type'])) {
                 // Update a donation's actual PM, if needed
                 $actual_pm = $_POST['notification_type'] == 'card-incoming' ? 'yandex_phyz_card' : 'yandex_phyz_money';
                 if ($donation->pm_id != $_POST['notification_type']) {
                     $donation->pm_id = $actual_pm;
                 }
             }
             $donation->add_gateway_response($_POST);
             $donation->status = 'funded';
             Leyka_Donation_Management::send_all_emails($donation->id);
         } else {
             error_log_yandex_phyz("Already funded\n");
         }
         $this->_check_order_answer();
     } else {
         error_log_yandex_phyz("There is no donation in Leyka DB\n");
         $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Unregistered donation ID', 'leyka'));
     }
 }
コード例 #7
0
         $locale = 'en_US';
     }
     load_textdomain('leyka', LEYKA_PLUGIN_DIR . "lang/leyka-{$locale}.mo");
     do_action('leyka_init_actions');
 } else {
     //            $locale = is_admin() ? pll_default_language('locale') : pll_current_language('locale');
     if (is_admin() && !did_action('leyka_init_actions')) {
         do_action('leyka_init_actions');
         if (count(pll_languages_list()) > 1) {
             // Register user-defined strings:
             foreach (leyka_options()->get_options_names() as $option) {
                 $option_data = leyka_options()->get_info_of($option);
                 if ($option_data['type'] == 'text') {
                     pll_register_string($option_data['title'], $option_data['value'], 'leyka');
                 } elseif ($option_data['type'] == 'textarea' || $option_data['type'] == 'html' || $option_data['type'] == 'rich_html') {
                     pll_register_string($option_data['title'], leyka_options()->opt($option), 'leyka', true);
                 }
             }
         }
     }
     add_action('leyka_default_success_page_created', function ($page_id) {
         //                echo '<pre>' . print_r($page_id, 1) . '</pre>';
         //                die('<pre>' . print_r(pll_default_language(), 1) . '</pre>');
         // ... get localized strings from PL and update success page params
     });
     // leyka_donation post type must not be included - there's no need to translate it:
     $leyka_post_types = array(Leyka_Campaign_Management::$post_type);
     if ($leyka_post_types != $polylang->options['post_types']) {
         $polylang->options['post_types'] = $polylang->options['post_types'] + $leyka_post_types;
         update_option('polylang', $polylang->options);
     }
コード例 #8
0
ファイル: payment-form.php プロジェクト: Teplitsa/giger
	</div>
	
</form>
</div>
</div>
<?php 
}
//add agree modal to footer
add_action('wp_footer', function () {
    ?>
<div id="leyka-agree-text" class="leyka-oferta-text leyka-custom-modal">
	<div class="leyka-modal-close">		
			<?php 
    echo tst_material_icon('close');
    ?>
		
	</div>
	<div class="leyka-oferta-text-frame">
		<div class="leyka-oferta-text-flow">
			<?php 
    echo apply_filters('leyka_terms_of_service_text', leyka_options()->opt('terms_of_service_text'));
    ?>
		</div>
	</div>
</div>
<?php 
});
leyka_pf_footer();
?>

</div><!-- #leyka-payment-form -->
コード例 #9
0
        foreach ($icons as $i) {
            $list[] = "<li>{$i}</li>";
        }
        echo '<ul class="leyka-pm-icons cf">' . implode('', $list) . '</ul>';
    }
    ?>

	</div> <!-- .leyka-pm-fields -->	

<?php 
    echo "<div class='leyka-pm-desc'>" . apply_filters('leyka_the_content', leyka_pf_get_pm_description()) . "</div>";
    ?>


</form>
</div>
</div>
<?php 
}
?>


<?php 
if (leyka_options()->opt('show_campaign_sharing')) {
    leyka_share_campaign_block();
}
leyka_pf_footer();
?>


</div><!-- #leyka-payment-form -->
コード例 #10
0
    /** Wrapper method to answer checkOrder and paymentAviso service calls */
    private function _callback_answer($is_error = false, $callback_type = 'co', $message = '', $tech_message = '')
    {
        $is_error = !!$is_error;
        $tech_message = $tech_message ? $tech_message : $message;
        $callback_type = $callback_type == 'co' ? 'checkOrderResponse' : 'paymentAvisoResponse';
        if ($is_error) {
            die('<?xml version="1.0" encoding="UTF-8"?>
<' . $callback_type . ' performedDatetime="' . date(DATE_ATOM) . '"
code="1000" invoiceId="' . $_POST['invoiceId'] . '"
shopId="' . leyka_options()->opt('yandex_shop_id') . '"
message="' . $message . '"
techMessage="' . $tech_message . '"/>');
        }
        die('<?xml version="1.0" encoding="UTF-8"?>
<' . $callback_type . ' performedDatetime="' . date(DATE_ATOM) . '"
code="0" invoiceId="' . $_POST['invoiceId'] . '"
shopId="' . leyka_options()->opt('yandex_shop_id') . '"/>');
    }
コード例 #11
0
    /** Displaying settings **/
    public function settings_screen()
    {
        /* Capability test */
        if (!current_user_can('leyka_manage_options')) {
            wp_die(__('You do not have permissions to access this page.', 'leyka'));
        }
        $current_stage = $this->get_current_settings_tab();
        require LEYKA_PLUGIN_DIR . 'inc/settings-pages/leyka-settings-common.php';
        /* Page actions */
        do_action('leyka_pre_settings_actions', $current_stage);
        /** Process settings change */
        if (!empty($_POST["leyka_settings_{$current_stage}_submit"])) {
            do_action("leyka_settings_{$current_stage}_submit", $current_stage);
        }
        ?>


		<div class="wrap">

		<h2 class="nav-tab-wrapper"><?php 
        echo $this->settings_tabs_menu();
        ?>
</h2>

		<div id="tab-container">
			<form method="post" action="<?php 
        echo admin_url(add_query_arg('stage', $current_stage, 'admin.php?page=leyka_settings'));
        ?>
" id="leyka-settings-form">

            <?php 
        wp_nonce_field("leyka_settings_{$current_stage}", '_leyka_nonce');
        if (file_exists(LEYKA_PLUGIN_DIR . "inc/settings-pages/leyka-settings-{$current_stage}.php")) {
            require LEYKA_PLUGIN_DIR . "inc/settings-pages/leyka-settings-{$current_stage}.php";
        } else {
            do_action("leyka_settings_pre_{$current_stage}_fields");
            foreach (leyka_opt_alloc()->get_tab_options($current_stage) as $option) {
                // Render each option/section
                if (is_array($option) && !empty($option['section'])) {
                    do_action('leyka_render_section', $option['section']);
                } else {
                    // is this case possible?
                    $option_info = leyka_options()->get_info_of($option);
                    do_action("leyka_render_{$option_info['type']}", $option, $option_info);
                }
            }
            do_action("leyka_settings_post_{$current_stage}_fields");
            ?>


                <p class="submit">
                    <input type="submit" name="<?php 
            echo "leyka_settings_{$current_stage}";
            ?>
_submit" value="<?php 
            _e('Save settings', 'leyka');
            ?>
" class="button-primary" />
                </p>
            <?php 
        }
        ?>


			</form>
<!--            --><?php 
        //do_action("leyka_settings_post_{$current_stage}_form");
        ?>

		</div>

		</div><!-- close .wrap -->
	<?php 
    }
コード例 #12
0
function leyka_is_min_payment_settings_complete()
{
    $pm_list = leyka_get_pm_list(true);
    if (!$pm_list) {
        return false;
    }
    $gateway_options_valid = array();
    // Array of already validated gateways
    foreach ($pm_list as $pm) {
        /** @var $pm Leyka_Payment_Method */
        $gateway = leyka_get_gateway_by_id($pm->gateway_id);
        if (!$pm || !$gateway) {
            continue;
        }
        $min_settings_complete = true;
        foreach ($pm->get_pm_options_names() as $option_name) {
            if (!leyka_options()->is_valid($option_name)) {
                $min_settings_complete = false;
                break;
            }
        }
        if (!isset($gateway_options_valid[$gateway->id])) {
            foreach ($gateway->get_options_names() as $option_name) {
                if (!leyka_options()->is_valid($option_name)) {
                    $gateway_options_valid[$gateway->id] = false;
                    break;
                }
            }
            if (!isset($gateway_options_valid[$gateway->id])) {
                $gateway_options_valid[$gateway->id] = true;
            }
        }
        if ($min_settings_complete && !empty($gateway_options_valid[$gateway->id])) {
            return true;
        }
    }
    return false;
}
コード例 #13
0
 /**
  * Fired when the plugin is activated or when an update is needed.
  */
 public static function activate()
 {
     $leyka_last_ver = get_option('leyka_last_ver');
     if ($leyka_last_ver && $leyka_last_ver == LEYKA_VERSION) {
         // Already at last version
         return;
     }
     if (!$leyka_last_ver || $leyka_last_ver < '2.1') {
         /** Upgrade options structure in the DB */
         if (get_option('leyka_modules')) {
             delete_option('leyka_modules');
         }
         if (get_option('leyka_options_installed')) {
             delete_option('leyka_options_installed');
         }
         require_once LEYKA_PLUGIN_DIR . 'inc/leyka-options-meta.php';
         foreach (leyka_options()->get_options_names() as $name) {
             $option = get_option("leyka_{$name}");
             if (is_array($option) && isset($option['type']) && isset($option['title'])) {
                 // Update option data
                 update_option("leyka_{$name}", $option['value']);
             }
         }
         // Mostly to initialize gateways' and PM's options before updating them:
         //            if( !did_action('leyka_init_actions') )
         //                do_action('leyka_init_actions');
         /** Upgrade gateway and PM options structure in the DB */
         foreach (leyka_get_gateways() as $gateway) {
             /** @var $gateway Leyka_Gateway */
             delete_option("leyka_{$gateway->id}_payment_methods");
             foreach ($gateway->get_options_names() as $name) {
                 $option = get_option("leyka_{$name}");
                 if (is_array($option) && isset($option['type']) && isset($option['title'])) {
                     // Update option data
                     update_option("leyka_{$name}", $option['value']);
                 }
             }
             foreach ($gateway->get_payment_methods() as $pm) {
                 /** @var $pm Leyka_Payment_Method */
                 foreach ($pm->get_pm_options_names() as $name) {
                     $option = get_option("leyka_{$name}");
                     if (is_array($option) && isset($option['type']) && isset($option['title'])) {
                         // Update option data
                         update_option("leyka_{$name}", $option['value']);
                     }
                 }
             }
         }
     }
     if (!$leyka_last_ver || $leyka_last_ver <= '2.2.5') {
         // Initialize pm_order option if needed:
         if (!get_option('leyka_pm_order')) {
             $pm_order = array();
             foreach ((array) get_option('leyka_pm_available') as $pm_full_id) {
                 if ($pm_full_id) {
                     $pm_order[] = "pm_order[]={$pm_full_id}";
                 }
             }
             update_option('leyka_pm_order', implode('&', $pm_order));
         }
         // Remove an unneeded scripts for settings pages:
         $settings_pages_dir = dir(LEYKA_PLUGIN_DIR . 'inc/settings-pages/');
         while (false !== ($script = $settings_pages_dir->read())) {
             if ($script != '.' && $script != '..' && !in_array($script, array('leyka-settings-common.php', 'leyka-settings-payment.php'))) {
                 unlink(LEYKA_PLUGIN_DIR . 'inc/settings-pages/' . $script);
             }
         }
         $settings_pages_dir->close();
         // Remove an obsolete plugin options:
         $options = array(array('old' => 'chronopay_card_description', 'new' => 'chronopay-chronopay_card_description'), array('old' => 'chronopay_card_rebill_description', 'new' => 'chronopay-chronopay_card_rebill_description'), array('old' => 'bank_order_description', 'new' => 'quittance-bank_order_description'), array('old' => 'bankcard_description', 'new' => 'rbk-bankcard_description'), array('old' => 'rbkmoney_description', 'new' => 'rbk-rbkmoney_description'), array('old' => 'rbk_all_description', 'new' => 'rbk-rbk_all_description'), array('old' => 'robokassa_card_description', 'new' => 'robokassa-BANKOCEAN2_description'), array('old' => 'robokassa_yandex_money_description', 'new' => 'robokassa-YandexMerchantOcean_description'), array('old' => 'robokassa_webmoney_description', 'new' => 'robokassa-WMR_description'), array('old' => 'robokassa_qiwi_description', 'new' => 'robokassa-Qiwi30Ocean_description'), array('old' => 'robokassa_all_description', 'new' => 'robokassa-Other_description'), array('old' => 'text_box_description', 'new' => 'text-text_box_description'), array('old' => 'yandex_card_description', 'new' => 'yandex-yandex_card_description'), array('old' => 'yandex_money_description', 'new' => 'yandex-yandex_money_description'), array('old' => 'yandex_wm_description', 'new' => 'yandex-yandex_wm_description'), array('old' => 'yandex_phyz_card_description', 'new' => 'yandex_phyz-yandex_phyz_card_description'), array('old' => 'yandex_phyz_money_description', 'new' => 'yandex_phyz-yandex_phyz_money_description'));
         foreach ($options as $option) {
             $old_value = get_option("leyka_{$option['old']}");
             $new_value = get_option("leyka_{$option['new']}");
             if ($old_value && $old_value != $new_value) {
                 update_option("leyka_{$option['new']}", $old_value);
             }
             delete_option("leyka_{$option['old']}");
         }
     }
     /**
      * Fix the bug when total_funded amount of campaign was calculated incorrectly
      * if there were correctional donations for that campaign.
      */
     if ($leyka_last_ver && $leyka_last_ver >= '2.2.5' && $leyka_last_ver <= '2.2.7.2') {
         function leyka_update_campaigns_total_funded()
         {
             set_time_limit(3600);
             wp_suspend_cache_addition(true);
             $campaigns = get_posts(array('post_type' => Leyka_Campaign_Management::$post_type, 'nopaging' => true, 'post_status' => 'any'));
             foreach ($campaigns as $campaign) {
                 $campaign = new Leyka_Campaign($campaign);
                 $campaign->update_total_funded_amount();
             }
             wp_suspend_cache_addition(false);
         }
         add_action('init', 'leyka_update_campaigns_total_funded', 100);
     }
     /** Fix the typo in one option's name */
     if ($leyka_last_ver && $leyka_last_ver <= '2.2.7.2') {
         update_option('leyka_agree_to_terms_needed', get_option('leyka_argee_to_terms_needed'));
         delete_option('leyka_argee_to_terms_needed');
     }
     /** Set a flag to flush permalinks (needs to be done a bit later, than this activation itself): */
     update_option('leyka_permalinks_flushed', 0);
     update_option('leyka_last_ver', LEYKA_VERSION);
 }
コード例 #14
0
 protected function _set_dynamic_attributes()
 {
     $this->_custom_fields = array('box_details' => apply_filters('leyka_the_content', leyka_options()->opt_safe('text_box_details')));
 }
コード例 #15
0
function leyka_do_donations_export()
{
    if (empty($_GET['leyka-donations-export-csv-excel'])) {
        return;
    }
    // Just in case that export will require some time:
    ini_set('max_execution_time', 99999);
    set_time_limit(99999);
    ob_start();
    $meta_query = array('relation' => 'AND');
    if (!empty($_GET['campaign'])) {
        $meta_query[] = array('key' => 'leyka_campaign_id', 'value' => (int) $_GET['campaign']);
    }
    if (!empty($_GET['payment_type'])) {
        $meta_query[] = array('key' => 'leyka_payment_type', 'value' => $_GET['payment_type']);
    }
    if (!empty($_GET['gateway_pm'])) {
        if (strpos($_GET['gateway_pm'], 'gateway__') !== false) {
            $meta_query[] = array('key' => 'leyka_gateway', 'value' => str_replace('gateway__', '', $_GET['gateway_pm']));
        } elseif (strpos($_GET['gateway_pm'], 'pm__') !== false) {
            $meta_query[] = array('key' => 'leyka_payment_method', 'value' => str_replace('pm__', '', $_GET['gateway_pm']));
        }
    }
    $args = array('post_type' => Leyka_Donation_Management::$post_type, 'post_status' => isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys(leyka()->get_donation_statuses())) ? $_GET['post_status'] : 'any', 'm' => $_GET['month-year'], 'meta_query' => $meta_query, 'posts_per_page' => 200);
    $donations = new WP_Query(apply_filters('leyka_donations_export_query_args', $args));
    $total_pages = $donations->found_posts / 200;
    $total_pages = $total_pages - (int) $total_pages > 0 ? (int) $total_pages + 1 : $total_pages;
    $posts_page = $total_pages > 0 ? 1 : 0;
    $donations = $donations->get_posts();
    require_once LEYKA_PLUGIN_DIR . 'inc/excel-writer/SimpleExcel.php';
    $excel = new SimpleExcel('csv');
    $domain = str_replace(array('http:', 'https:'), '', home_url());
    function prep($text)
    {
        return '"' . str_replace(array(';', '"'), array('', ''), $text) . '"';
    }
    if (isset($_GET['export-tech'])) {
        // Technical export mode column headings
        $excel->writer->addRow(array('hash', 'Domain', 'Org_name', 'Timestamp', 'Date', 'Email_hash', 'Donor_name hash', 'Sum', 'Currency', 'Gateway_pm', 'Donation_status', 'Campaign_title', 'Campaign_URL', 'Payment_title', 'Target_sum', 'Campaign_target_state', 'Campaign_is_finished'));
    } else {
        // Normal export mode column headings
        $excel->writer->addRow(array(apply_filters('leyka_donations_export_headers', array('ID', 'Имя донора', 'Email', 'Тип платежа', 'Способ платежа', 'Сумма', 'Дата пожертвования', 'Статус', 'Кампания'))));
    }
    while ($posts_page && $posts_page <= $total_pages) {
        // Main loop too fill the export file
        foreach ($donations as $donation) {
            $donation = new Leyka_Donation($donation);
            $campaign = new Leyka_Campaign($donation->campaign_id);
            if (isset($_GET['export-tech'])) {
                $excel->writer->addRow(array(prep(wp_hash($domain . $donation->date_timestamp . $donation->sum . $donation->id)), prep($domain), prep(leyka_options()->opt('org_full_name')), prep($donation->date_timestamp), prep(date(get_option('date_format') . ', H:i', $donation->date_timestamp)), prep(wp_hash($donation->donor_email)), prep(wp_hash($donation->donor_name)), prep((int) $donation->sum), prep($donation->currency), $donation->payment_type == 'correction' ? prep($donation->pm_id) : prep($donation->gateway_label . '-' . $donation->pm_id), prep($donation->status), prep($campaign->title), prep($campaign->url), prep($campaign->payment_title), prep((int) $campaign->target), prep($campaign->target_state), prep((int) $campaign->is_finished)));
            } else {
                $excel->writer->addRow(apply_filters('leyka_donations_export_line', array($donation->id, $donation->donor_name, $donation->donor_email, $donation->payment_type_label, $donation->payment_method_label, $donation->sum . ' ' . $donation->currency_label, $donation->date, $donation->status_label, $campaign->title)));
            }
        }
        $posts_page++;
        $args['paged'] = $posts_page;
        $donations = get_posts(apply_filters('leyka_donations_export_query_args', $args));
        wp_cache_flush();
    }
    if (isset($_GET['export-tech'])) {
        $excel->writer->setDelimiter(';');
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-tech-' . $domain . '-' . date('d.m.Y-H.i.s') . '.csv"');
        die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=;\n" . $excel->writer->saveString()));
        //        ob_clean();
        //
        //        header('Content-type: application/vnd.ms-excel');
        //        header('Content-Transfer-Encoding: binary');
        //        header('Expires: 0');
        //        header('Pragma: no-cache');
        //        header('Content-Disposition: attachment; filename="donations-tech-'.$domain.'-'.date('d.m.Y-H.i.s').'.csv"');
        //
        //        die("sep=;\n".implode("\r\n", $file_lines));
    } else {
        $excel->writer->setDelimiter(',');
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-' . date('d.m.Y-H.i.s') . '.csv"');
        die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=,\n" . $excel->writer->saveString()));
    }
}
コード例 #16
0
function leyka_get_terms_text()
{
    return apply_filters('leyka_terms_of_service_text', leyka_options()->opt('terms_of_service_text'));
}
コード例 #17
0
function leyka_min_payment_settings_complete()
{
    $pm_list = leyka_get_pm_list(true);
    if (!$pm_list) {
        return false;
    }
    $gateway_options_valid = array();
    // Array of already validated gateways
    foreach (leyka_options()->opt('pm_available') as $pm_full_id) {
        // Full ID is "gateway_id-pm_id"
        $pm = leyka_get_pm_by_id($pm_full_id, true);
        $pm_full_id = explode('-', $pm_full_id);
        $gateway = leyka_get_gateway_by_id(reset($pm_full_id));
        if (!$pm || !$gateway) {
            return false;
        }
        foreach ($pm->get_pm_options_names() as $option_name) {
            if (!leyka_options()->is_valid($option_name)) {
                return false;
            }
        }
        if (empty($gateway_options_valid[$gateway->id])) {
            foreach ($gateway->get_options_names() as $option_name) {
                if (!leyka_options()->is_valid($option_name)) {
                    return false;
                }
            }
            $gateway_options_valid[$gateway->id] = true;
        }
    }
    return true;
}
コード例 #18
0
ファイル: leyka-class-donation.php プロジェクト: GenV/Leyka
 public function __get($field)
 {
     switch ($field) {
         case 'id':
         case 'ID':
             return $this->_id;
         case 'title':
         case 'name':
             return $this->_post_object->post_title;
         case 'purpose':
         case 'purpose_text':
         case 'payment_title':
         case 'campaign_payment_title':
             return $this->_donation_meta['payment_title'];
         case 'status':
             return $this->_post_object->post_status;
         case 'status_label':
             $stati = leyka_get_donation_status_list();
             return $stati[$this->_post_object->post_status];
         case 'status_log':
             return $this->_donation_meta['status_log'];
         case 'date':
         case 'date_label':
             $date_format = get_option('date_format');
             $time_format = get_option('time_format');
             $donation_timestamp = strtotime($this->_post_object->post_date);
             return apply_filters('leyka_admin_donation_date', date($date_format . ' ' . $time_format, $donation_timestamp), $donation_timestamp, $date_format, $time_format);
         case 'date_timestamp':
             return strtotime($this->_post_object->post_date);
         case 'date_funded':
         case 'funded_date':
             $date_funded = $this->get_funded_date();
             return $date_funded ? date(get_option('date_format'), $date_funded) : 0;
         case 'payment_method':
         case 'payment_method_id':
         case 'pm':
         case 'pm_id':
             return $this->_donation_meta['payment_method'];
         case 'gateway':
         case 'gateway_id':
         case 'gw_id':
             return $this->_donation_meta['gateway'];
         case 'gateway_label':
             $gateway = leyka_get_gateway_by_id($this->_donation_meta['gateway']);
             return $gateway ? $gateway->label : __('Unknown gateway', 'leyka');
         case 'pm_label':
         case 'payment_method_label':
             $pm = leyka_get_pm_by_id($this->_donation_meta['payment_method']);
             return $pm ? $pm->label : __('Unknown payment method', 'leyka');
         case 'currency':
             return $this->_donation_meta['currency'];
         case 'currency_label':
             return leyka_options()->opt('leyka_currency_' . $this->_donation_meta['currency'] . '_label');
         case 'sum':
         case 'amount':
             return $this->_donation_meta['amount'];
         case 'main_curr_amount':
         case 'amount_equiv':
             return $this->_donation_meta['main_curr_amount'];
         case 'donor_name':
             return $this->_donation_meta['donor_name'];
         case 'donor_email':
             return $this->_donation_meta['donor_email'];
         case 'donor_email_date':
             return $this->_donation_meta['donor_email_date'];
         case 'managers_emails_date':
             return $this->_donation_meta['managers_emails_date'];
         case 'campaign_id':
             return $this->_donation_meta['campaign_id'];
         case 'gateway_response':
             return $this->_donation_meta['gateway_response'];
         case 'gateway_response_formatted':
             return $this->gateway ? leyka_get_gateway_by_id($this->gateway)->get_gateway_response_formatted($this) : array();
         case 'type':
         case 'payment_type':
             return $this->_donation_meta['payment_type'];
         case 'type_label':
         case 'payment_type_label':
             return __($this->_donation_meta['payment_type'], 'leyka');
         case 'init_recurring_payment_id':
         case 'init_recurring_donation_id':
             return $this->_post_object->post_parent;
         case 'init_recurring_payment':
         case 'init_recurring_donation':
             return $this->_post_object->post_parent ? new Leyka_Donation($this->_post_object->post_parent) : false;
         default:
             return apply_filters('leyka_get_unknown_donation_field', null, $field, $this);
     }
 }
コード例 #19
0
 public function _handle_service_calls($call_type = '')
 {
     if (empty($_REQUEST['InvId'])) {
         $message = __("This message has been sent because a call to your Robokassa callback (Result URL) was made without InvId parameter given. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "THEIR_POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Robokassa - InvId missing!', 'leyka'), $message);
         status_header(200);
         die;
     }
     $donation = new Leyka_Donation((int) $_REQUEST['InvId']);
     // Test for e-sign. Values from Robokassa must be used:
     $sign = strtoupper(md5("{$_REQUEST['OutSum']}:{$_REQUEST['InvId']}:" . leyka_options()->opt('robokassa_shop_password2') . ":Shp_item=1"));
     if (empty($_REQUEST['SignatureValue']) || strtoupper($_REQUEST['SignatureValue']) != $sign) {
         $message = __("This message has been sent because a call to your Robokassa callback was called with wrong digital signature. This could mean someone is trying to hack your payment website. The details of the call are below:", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "Signature from request:\n\r" . print_r($_REQUEST['SignatureValue'], true) . "\n\r\n\r";
         $message .= "Signature calculated:\n\r" . print_r($sign, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Robokassa digital signature check failed!', 'leyka'), $message);
         die;
     }
     // Single payment:
     if ($donation->status != 'funded') {
         $donation->add_gateway_response($_REQUEST);
         $donation->status = 'funded';
         //            $currency_letter = substr($_REQUEST['IncCurrLabel'], -1);
         $_REQUEST['IncCurrLabel'] = empty($_REQUEST['IncCurrLabel']) ? '' : substr_replace($_REQUEST['IncCurrLabel'], '', -1);
         if ($donation->pm_id != $_REQUEST['IncCurrLabel'] && array_key_exists($_REQUEST['IncCurrLabel'], $this->_payment_methods)) {
             $donation->pm_id = $_REQUEST['IncCurrLabel'];
         }
         Leyka_Donation_Management::send_all_emails($donation->id);
         die('OK' . $_REQUEST['InvId']);
     } else {
         die;
     }
 }
コード例 #20
0
ファイル: leyka-core.php プロジェクト: slavam/adult-childhood
 /** Initialize the plugin by setting localization, filters, and administration functions. */
 private function __construct()
 {
     if (!get_option('leyka_permalinks_flushed')) {
         function leyka_flush_rewrite_rules()
         {
             flush_rewrite_rules(false);
             update_option('leyka_permalinks_flushed', 1);
         }
         add_action('init', 'leyka_flush_rewrite_rules');
     }
     // By default, we'll assume some errors in the payment form, so redirect will get us back to it:
     $this->_payment_form_redirect_url = wp_get_referer();
     // Load public-facing style sheet and JavaScript:
     add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     // Post types:
     add_action('init', array($this, 'register_post_types'), 9);
     // User roles and capabilities:
     add_action('init', array($this, 'register_user_capabilities'));
     if (!session_id()) {
         add_action('init', 'session_start', -2);
     }
     if (is_admin() && current_user_can('leyka_manage_donations')) {
         $this->admin_setup();
     }
     if (current_user_can('leyka_manage_donations')) {
         add_action('admin_bar_menu', array($this, 'leyka_add_toolbar_menu'), 999);
     }
     /** Service URLs handler: */
     add_action('parse_request', function ($request) {
         // Callback URLs are: some-website.org/leyka/service/{gateway_id}/{action_name}/
         // For ex., some-website.org/leyka/service/yandex/check_order/
         $request = $_SERVER['REQUEST_URI'];
         //$request->request;
         if (stristr($request, 'leyka/service') !== FALSE) {
             // Leyka service URL
             $request = explode('leyka/service', $_SERVER['REQUEST_URI']);
             $request = explode('/', trim($request[1], '/'));
             // $request[0] - Payment method's ID, $request[1] - service action:
             do_action('leyka_service_call-' . $request[0], $request[1]);
             exit;
         }
     });
     /** Embed campaign URL handler: */
     add_filter('template_include', function ($template) {
         if (is_main_query() && is_singular(Leyka_Campaign_Management::$post_type) && !empty($_GET['embed'])) {
             $new_template = leyka_get_current_template_data(false, 'embed_' . $_GET['embed'], true);
             if ($new_template && !empty($new_template['file'])) {
                 $template = $new_template['file'];
             }
         }
         return $template;
     }, 100);
     add_action('template_redirect', array($this, 'gateway_redirect_page'), 1, 1);
     $this->apply_formatting_filters();
     // Internal formatting filters
     //        new Non_existing_class; /** @todo  */
     /** Currency rates auto refreshment: */
     if (leyka_options()->opt('auto_refresh_currency_rates')) {
         if (!wp_next_scheduled('refresh_currencies_rates')) {
             wp_schedule_event(time(), 'daily', 'refresh_currencies_rates');
         }
         add_action('refresh_currencies_rates', array($this, 'do_currencies_rates_refresh'));
         // Just in case:
         if (!leyka_options()->opt('currency_rur2usd') || !leyka_options()->opt('currency_rur2eur')) {
             $this->do_currency_rates_refresh();
         }
     } else {
         wp_clear_scheduled_hook('refresh_currencies_rates');
     }
     do_action('leyka_initiated');
 }
コード例 #21
0
function leyka_do_donations_export()
{
    if (empty($_GET['leyka-donations-export-csv-excel'])) {
        return;
    }
    // Just in case that export will require some time:
    ini_set('max_execution_time', 99999);
    set_time_limit(99999);
    ob_start();
    $meta_query = array('relation' => 'AND');
    if (!empty($_GET['campaign'])) {
        $meta_query[] = array('key' => 'leyka_campaign_id', 'value' => (int) $_GET['campaign']);
    }
    if (!empty($_GET['payment_type'])) {
        $meta_query[] = array('key' => 'leyka_payment_type', 'value' => $_GET['payment_type']);
    }
    if (!empty($_GET['gateway_pm'])) {
        if (strpos($_GET['gateway_pm'], 'gateway__') !== false) {
            $meta_query[] = array('key' => 'leyka_gateway', 'value' => str_replace('gateway__', '', $_GET['gateway_pm']));
        } elseif (strpos($_GET['gateway_pm'], 'pm__') !== false) {
            $meta_query[] = array('key' => 'leyka_payment_method', 'value' => str_replace('pm__', '', $_GET['gateway_pm']));
        }
    }
    $args = array('post_type' => Leyka_Donation_Management::$post_type, 'post_status' => isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys(leyka()->get_donation_statuses())) ? $_GET['post_status'] : 'any', 'm' => $_GET['month-year'], 's' => $_GET['search_string'], 'meta_query' => $meta_query, 'nopaging' => true);
    $donations = get_posts(apply_filters('leyka_donations_export_query_args', $args));
    function leyka_prep($text)
    {
        return '"' . str_replace(array(';', '"'), array('', ''), $text) . '"';
    }
    if (isset($_GET['export-tech'])) {
        $domain = str_replace(array('http:', 'https:'), '', home_url());
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-tech-' . $domain . '-' . date('d.m.Y-H.i.s') . '.csv"');
        echo iconv('UTF-8', apply_filters('leyka_donations_tech_export_content_charset', 'windows-1251'), "sep=;\n" . implode(';', array('hash', 'Domain', 'Org_name', 'Timestamp', 'Date', 'Email_hash', 'Donor_name hash', 'Sum', 'Currency', 'Gateway_pm', 'Donation_status', 'Campaign_title', 'Campaign_URL', 'Payment_title', 'Target_sum', 'Campaign_target_state', 'Campaign_is_finished')));
        foreach ($donations as $donation) {
            $donation = new Leyka_Donation($donation);
            $campaign = new Leyka_Campaign($donation->campaign_id);
            // @ to avoid notices about illegal chars that happen in the line sometimes:
            echo @iconv('UTF-8', apply_filters('leyka_donations_tech_export_content_charset', 'windows-1251'), "\r\n" . implode(';', array(leyka_prep(hash('sha256', $domain . $donation->date_timestamp . $donation->sum . $donation->id)), leyka_prep($domain), leyka_prep(leyka_options()->opt('org_full_name')), leyka_prep($donation->date_timestamp), leyka_prep(date('d.m.Y H:i:s', $donation->date_timestamp)), leyka_prep(hash('sha256', $donation->donor_email)), leyka_prep(hash('sha256', $donation->donor_name)), leyka_prep((int) $donation->sum), leyka_prep($donation->currency), $donation->payment_type == 'correction' ? leyka_prep($donation->pm_id) : leyka_prep($donation->gateway_label . '-' . $donation->pm_id), leyka_prep($donation->status), leyka_prep($campaign->title), leyka_prep($campaign->url), leyka_prep($campaign->payment_title), leyka_prep((int) $campaign->target), leyka_prep($campaign->target_state), leyka_prep((int) $campaign->is_finished))));
        }
        die('');
    } else {
        function leyka_prepare_donation_data_for_export($donation_data)
        {
            foreach ($donation_data as &$data) {
                $data = leyka_prep($data);
            }
            return $donation_data;
        }
        add_filter('leyka_donations_export_line', 'leyka_prepare_donation_data_for_export');
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-' . date('d.m.Y-H.i.s') . '.csv"');
        echo iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=;\n" . implode(';', apply_filters('leyka_donations_export_headers', array('ID', 'Имя донора', 'Email', 'Тип платежа', 'Способ платежа', 'Сумма', 'Дата пожертвования', 'Статус', 'Кампания'))));
        foreach ($donations as $donation) {
            $donation = new Leyka_Donation($donation);
            $campaign = new Leyka_Campaign($donation->campaign_id);
            echo @iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "\r\n" . implode(';', apply_filters('leyka_donations_export_line', array($donation->id, $donation->donor_name, $donation->donor_email, $donation->payment_type_label, $donation->payment_method_label, $donation->sum . ' ' . $donation->currency_label, $donation->date, $donation->status_label, $campaign->title))));
        }
        die('');
    }
}
コード例 #22
0
 protected function _set_dynamic_attributes()
 {
     if (leyka_options()->opt('chronopay_card_product_id_rur')) {
         $this->_supported_currencies[] = 'rur';
     }
     if (leyka_options()->opt('chronopay_card_product_id_usd')) {
         $this->_supported_currencies[] = 'usd';
     }
     if (leyka_options()->opt('chronopay_card_product_id_eur')) {
         $this->_supported_currencies[] = 'eur';
     }
 }
コード例 #23
0
function leyka_do_donations_export()
{
    if (empty($_GET['leyka-donations-export-csv-excel'])) {
        return;
    }
    ob_start();
    $meta_query = array('relation' => 'AND');
    if (!empty($_GET['campaign'])) {
        $meta_query[] = array('key' => 'leyka_campaign_id', 'value' => (int) $_GET['campaign']);
    }
    if (!empty($_GET['payment_type'])) {
        $meta_query[] = array('key' => 'leyka_payment_type', 'value' => $_GET['payment_type']);
    }
    if (!empty($_GET['gateway_pm'])) {
        if (strpos($_GET['gateway_pm'], 'gateway__') !== false) {
            $meta_query[] = array('key' => 'leyka_gateway', 'value' => str_replace('gateway__', '', $_GET['gateway_pm']));
        } elseif (strpos($_GET['gateway_pm'], 'pm__') !== false) {
            $meta_query[] = array('key' => 'leyka_payment_method', 'value' => str_replace('pm__', '', $_GET['gateway_pm']));
        }
    }
    $args = array('post_type' => Leyka_Donation_Management::$post_type, 'post_status' => isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys(leyka()->get_donation_statuses())) ? $_GET['post_status'] : 'any', 'm' => $_GET['month-year'], 'meta_query' => $meta_query, 'nopaging' => true);
    $donations = get_posts(apply_filters('leyka_donations_export_query_args', $args));
    if (isset($_GET['export-tech'])) {
        function prep($text)
        {
            return '"' . str_replace(array(';', '"'), array('', ''), $text) . '"';
        }
        $file_lines = array(array('hash', 'Domain', 'Org_name', 'Timestamp', 'Date', 'Email_hash', 'Donor_name hash', 'Sum', 'Currency', 'Gateway_pm', 'Donation_status', 'Campaign_title', 'Campaign_URL', 'Payment_title', 'Target_sum', 'Campaign_target_state', 'Campaign_is_finished'));
        for ($i = 0; $i < count($file_lines[0]); $i++) {
            $file_lines[0][$i] = prep($file_lines[0][$i]);
        }
        $domain = str_replace(array('http:', 'https:'), '', home_url());
        foreach ($donations as $donation) {
            $donation = new Leyka_Donation($donation);
            $campaign = new Leyka_Campaign($donation->campaign_id);
            $donation_fields = array(prep(wp_hash($domain . $donation->date_timestamp . $donation->sum . $donation->id)), prep($domain), prep(leyka_options()->opt('org_full_name')), prep($donation->date_timestamp), prep(date(get_option('date_format') . ', H:i', $donation->date_timestamp)), prep(wp_hash($donation->donor_email)), prep(wp_hash($donation->donor_name)), prep((int) $donation->sum), prep($donation->currency), $donation->payment_type == 'correction' ? prep($donation->pm_id) : prep($donation->gateway_label . '-' . $donation->pm_id), prep($donation->status), prep($campaign->title), prep($campaign->url), prep($campaign->payment_title), prep((int) $campaign->target), prep($campaign->target_state), prep((int) $campaign->is_finished));
            $file_lines[] = $donation_fields;
        }
        for ($i = 0; $i < count($file_lines); $i++) {
            $file_lines[$i] = implode(';', $file_lines[$i]);
        }
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-tech-' . $domain . '-' . date('d.m.Y-H.i.s') . '.csv"');
        die("sep=;\n" . implode("\r\n", $file_lines));
    } else {
        $file_lines = array(apply_filters('leyka_donations_export_headers', array('ID', 'Имя донора', 'Email', 'Тип платежа', 'Способ платежа', 'Сумма', 'Дата пожертвования', 'Статус', 'Кампания')));
        foreach ($donations as $donation) {
            $donation = new Leyka_Donation($donation);
            $campaign = new Leyka_Campaign($donation->campaign_id);
            $donation_fields = apply_filters('leyka_donations_export_line', array($donation->id, $donation->donor_name, $donation->donor_email, $donation->payment_type_label, $donation->payment_method_label, $donation->sum . ' ' . $donation->currency_label, $donation->date, $donation->status_label, $campaign->title));
            $file_lines[] = $donation_fields;
        }
        require_once LEYKA_PLUGIN_DIR . 'inc/excel-writer/SimpleExcel.php';
        $excel = new SimpleExcel('csv');
        $excel->writer->setData($file_lines);
        $excel->writer->setDelimiter(',');
        ob_clean();
        header('Content-type: application/vnd.ms-excel');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Pragma: no-cache');
        header('Content-Disposition: attachment; filename="donations-' . date('d.m.Y-H.i.s') . '.csv"');
        // Do iconv so Excel could open it:
        die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=,\n" . $excel->writer->saveString()));
    }
}
コード例 #24
0
    public function get_agree_field()
    {
        if (!leyka_options()->opt('argee_to_terms_needed') || !$this->is_field_supported('agree')) {
            return '';
        }
        $agree_id = esc_attr(uniqid() . '-text');
        // Label for checkbox
        ob_start();
        ?>


		<div id="<?php 
        echo $agree_id;
        ?>
" class="leyka-oferta-text">
			<div class="leyka-modal-close">X</div>
			<div class="leyka-oferta-text-frame">
				<div class="leyka-oferta-text-flow"><?php 
        echo apply_filters('leyka_terms_of_service_text', leyka_options()->opt('terms_of_service_text'));
        ?>
</div>
			</div>
		</div>
		
		<label class="checkbox" for="leyka_agree">
			<input type="checkbox" name="leyka_agree" id="leyka_agree" class="leyka_agree required" value="1" />
			<a class="leyka-legal-confirmation-trigger" href="#<?php 
        echo $agree_id;
        ?>
">
                <?php 
        echo leyka_options()->opt('agree_to_terms_text');
        ?>

            </a>
		</label>
        <p class="field-error" id="leyka_agree-error"></p>

	<?php 
        $out = ob_get_contents();
        ob_end_clean();
        return leyka_field_wrap($out, 'agree');
    }
コード例 #25
0
 public function _handle_service_calls($call_type = '')
 {
     // Test for gateway's IP:
     if (leyka_options()->opt('cp_ip') && !in_array($_SERVER['REMOTE_ADDR'], explode(',', leyka_options()->opt('cp_ip')))) {
         // Security fail
         $message = __("This message has been sent because a call to your CloudPayments function was made from an IP that did not match with the one in your CloudPayments gateway setting. This could mean someone is trying to hack your payment website. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "IP:\n\r" . print_r($_SERVER['REMOTE_ADDR'], true) . "\n\r\n\r";
         $message .= "CloudPayments IP setting value:\n\r" . print_r(leyka_options()->opt('cp_ip'), true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('CloudPayments IP check failed!', 'leyka'), $message);
         status_header(200);
         die;
     }
     switch ($call_type) {
         case 'check':
             // Check if payment is correct
             // InvoiceId - leyka donation ID, SubscriptionId - CP recurring subscription ID
             if (empty($_POST['InvoiceId']) && empty($_POST['SubscriptionId'])) {
                 die(json_encode(array('code' => '10')));
             }
             if (empty($_POST['Amount']) || (double) $_POST['Amount'] <= 0 || empty($_POST['Currency'])) {
                 die(json_encode(array('code' => '11', 'reason' => sprintf('Amount or Currency in POST are empty. Amount: %s, Currency: %s', $_POST['Amount'], $_POST['Currency']))));
             }
             if (empty($_POST['InvoiceId'])) {
                 // Non-init recurring donation
                 if (!$this->get_init_recurrent_donation($_POST['SubscriptionId'])) {
                     die(json_encode(array('code' => '11', 'reason' => sprintf('Init recurring payment is not found. POST SubscriptionId: %s', $_POST['SubscriptionId']))));
                 }
             } else {
                 // Single or init recurring donation
                 $donation = new Leyka_Donation((int) $_POST['InvoiceId']);
                 $donation->add_gateway_response($_POST);
                 switch ($_POST['Currency']) {
                     case 'RUB':
                         $_POST['Currency'] = 'rur';
                         break;
                     case 'USD':
                         $_POST['Currency'] = 'usd';
                         break;
                     case 'EUR':
                         $_POST['Currency'] = 'eur';
                         break;
                     default:
                 }
                 if ($donation->sum != $_POST['Amount'] || $donation->currency != $_POST['Currency']) {
                     die(json_encode(array('code' => '11', 'reason' => sprintf('Amount of original data and POST are mismatching. Original: %.2f %s, POST: %.2f %s', $donation->sum, $donation->currency, $_POST['Amount'], $_POST['Currency']))));
                 }
             }
             die(json_encode(array('code' => '0')));
             // Payment check passed
         // Payment check passed
         case 'complete':
         case 'fail':
             // InvoiceId - leyka donation ID, SubscriptionId - CP recurring subscription ID
             if (empty($_POST['InvoiceId']) && empty($_POST['SubscriptionId'])) {
                 die(json_encode(array('code' => '10')));
             }
             if (empty($_POST['InvoiceId'])) {
                 // Non-init recurring donation
                 $donation = $this->get_donation_by_transaction_id($_POST['TransactionId']);
                 $init_recurrent_payment = $this->get_init_recurrent_donation($_POST['SubscriptionId']);
                 $donation->init_recurring_donation_id = $init_recurrent_payment->id;
                 $donation->payment_title = $init_recurrent_payment->title;
                 $donation->campaign_id = $init_recurrent_payment->campaign_id;
                 $donation->payment_method_id = $init_recurrent_payment->pm_id;
                 $donation->gateway_id = $init_recurrent_payment->gateway_id;
                 $donation->donor_name = $init_recurrent_payment->donor_name;
                 $donation->donor_email = $init_recurrent_payment->donor_email;
                 $donation->amount = $init_recurrent_payment->amount;
                 $donation->currency = $init_recurrent_payment->currency;
             } else {
                 // Single or init recurring donation
                 $donation = new Leyka_Donation((int) $_POST['InvoiceId']);
             }
             if (!empty($_POST['SubscriptionId'])) {
                 $donation->payment_type = 'rebill';
                 $donation->recurring_id = $_POST['SubscriptionId'];
             }
             $donation->add_gateway_response($_POST);
             if ($call_type == 'complete') {
                 Leyka_Donation_Management::send_all_emails($donation->id);
                 $donation->status = 'funded';
             } else {
                 $donation->status = 'failed';
             }
             die(json_encode(array('code' => '0')));
             // Payment completed / fail registered
         // Payment completed / fail registered
         default:
     }
 }
コード例 #26
0
ファイル: leyka-gateways-api.php プロジェクト: GenV/Leyka
 protected function _initialize_options()
 {
     $this->_set_options_defaults();
     $this->_add_options();
     /** PM frontend label is a special persistent option, universal for each PM */
     if (!leyka_options()->option_exists($this->full_id . '_label')) {
         leyka_options()->add_option($this->full_id . '_label', 'text', array('value' => '', 'default' => $this->_label, 'title' => __('Payment method custom label', 'leyka'), 'description' => __('A label for this payment method that will appear on all donation forms.', 'leyka'), 'required' => false, 'placeholder' => '', 'validation_rules' => array()));
     }
     $custom_label = leyka_options()->opt_safe($this->full_id . '_label');
     $this->_label = $custom_label && $custom_label != $this->_label ? $custom_label : apply_filters('leyka_get_pm_label_original', $this->_label, $this);
     $this->_active = in_array($this->full_id, leyka_options()->opt('pm_available'));
     $this->_description = leyka_options()->opt_safe($this->full_id . '_description');
     add_filter('leyka_payment_options_allocation', array($this, 'allocate_pm_options'), 10, 1);
 }
コード例 #27
0
    public function data_meta_box($post)
    {
        $campaign = new Leyka_Campaign($post);
        $cur_template = $campaign->template;
        if (empty($cur_template)) {
            $cur_template = 'default';
        }
        ?>

        <fieldset id="payment-title" class="metabox-field campaign-field campaign-purpose">
            <label for="payment_title">
                <?php 
        _e('Campaign title meant for payment system', 'leyka');
        ?>
                <br />
                <small><?php 
        echo __('If empty, main campaign title will be used', 'leyka');
        ?>
</small>
            </label>

            <input type="text" class="widefat" name="payment_title" id="payment_title" value="<?php 
        echo $campaign->payment_title ? $campaign->payment_title : $campaign->title;
        ?>
">
        </fieldset>
		
		<h4 class="metabox-field-title campaign-template"><?php 
        _e('Template settings', 'leyka');
        ?>
</h4>

		<fieldset id="campaign-template" class="metabox-field campaign-field campaign-template">
			<label for="campaign_template"><?php 
        _e('Template for payment form', 'leyka');
        ?>
</label>
			<select id="campaign_template" name="campaign_template">
				<option value="default" <?php 
        selected($cur_template, 'default');
        ?>
>
                    <?php 
        _e('Default template', 'leyka');
        ?>
                </option>

            <?php 
        $templates = leyka()->get_templates();
        if ($templates) {
            foreach ($templates as $template) {
                ?>
                <option value="<?php 
                echo esc_attr($template['id']);
                ?>
" <?php 
                selected($cur_template, $template['id']);
                ?>
>
                    <?php 
                echo esc_attr($template['name']);
                ?>
                </option>
                <?php 
            }
        }
        ?>

			</select>
		</fieldset>

		<fieldset id="ignore-global-template" class="metabox-field campaign-field campaign-ignorance">
			<label for="ignore_global_template">
			<input type="checkbox" name="ignore_global_template" id="ignore_global_template" value="1" <?php 
        checked($campaign->ignore_global_template_settings, 1);
        ?>
>&nbsp;
			<?php 
        _e('Ignore global template settings', 'leyka');
        ?>
</label>
		</fieldset>

		<h4 class="metabox-field-title campaign-target"><?php 
        _e('Campaign target', 'leyka');
        ?>
</h4>

		<fieldset id="target-amount" class="metabox-field campaign-field campaign-target">
			<label for="campaign_target">
                <?php 
        echo sprintf(__('Target (%s)', 'leyka'), leyka_options()->opt('currency_rur_label'));
        ?>
            </label>
			<input type="text" name="campaign_target" id="campaign_target" value="<?php 
        echo $campaign->target;
        ?>
" class="widefat">
		</fieldset>
		
		<fieldset id="collected-amount" class="metabox-field campaign-field campaign-target-collected">
			<label for="collected_target">
                <?php 
        echo sprintf(__('Collected (%s)', 'leyka'), leyka_get_currency_label('rur'));
        ?>
            </label>			
			<input type="text" id="collected_target" disabled="disabled" value="<?php 
        echo $campaign->total_funded;
        ?>
" class="widefat">
            <?php 
        if (get_current_screen()->action != 'add') {
            ?>
            <div class="recalculate-total-funded">
                <a href="<?php 
            echo add_query_arg(array('recalculate_total_funded' => 1));
            ?>
" id="recalculate_total_funded" data-nonce="<?php 
            echo wp_create_nonce('leyka_recalculate_total_funded_amount');
            ?>
" data-campaign-id="<?php 
            echo $campaign->id;
            ?>
"><?php 
            _e('Recalculate collected amount', 'leyka');
            ?>
</a>
                <img src="<?php 
            echo LEYKA_PLUGIN_BASE_URL . '/img/ajax-loader-h.gif';
            ?>
" id="recalculate_total_funded_loader" style="display: none;">
                <div class="message error-message" id="recalculate_message"></div>
            </div>
            <?php 
        }
        ?>
		</fieldset>

		<fieldset id="d-scale-demo" class="metabox-field campaign-field campaign-target-scale">
		<?php 
        if ($campaign->target > 0) {
            $percentage = round(100 * $campaign->total_funded / $campaign->target);
            $percentage = $percentage > 100 ? 100 : $percentage;
            ?>

			<div class="d-scale-scale">
				<div class="target">
					<div style="width:<?php 
            echo $percentage;
            ?>
%" class="collected">&nbsp;</div>
				</div>
			</div>
			
			<?php 
            if ($campaign->target_state == 'is_reached') {
                ?>
        
			<p>
				<?php 
                printf(__('Reached at: %s', 'leyka'), '<b>' . $campaign->date_target_reached . '</b>');
                ?>
			</p>            
			<?php 
            }
            ?>

		<?php 
        }
        ?>
		</fieldset>

        <?php 
        $curr_page = get_current_screen();
        if ($curr_page->action != 'add') {
            ?>

        <fieldset id="campaign-finished" class="metabox-field campaign-field campaign-finished">
            <label for="is-finished">
                <input type="checkbox" id="is-finished" name="is_finished" value="1" <?php 
            echo $campaign->is_finished ? 'checked' : '';
            ?>
 /> <?php 
            _e('Campaign is finished, donations collection is stopped', 'leyka');
            ?>
            </label>
        </fieldset>
	<?php 
        }
    }