Example #1
0
function require_javascript($javascript)
{
    if ($javascript == 'javascript_swfupload' && !in_safe_mode()) {
        if (!function_exists('tacit_https') || !tacit_https()) {
            global $EXTRA_HEAD;
            $EXTRA_HEAD->attach('
				<!-- Third party script for BrowserPlus runtime (Google Gears included in Gears runtime now) -->
				<script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
			');
        }
        $javascript = 'javascript_plupload';
    }
    non_overrided__require_javascript($javascript);
}
Example #2
0
 /**
  * Show my invoices.
  *
  * @return tempcode	The interface.
  */
 function pay()
 {
     $id = get_param_integer('id');
     if (!tacit_https() && !ecommerce_test_mode()) {
         warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
     }
     $title = get_page_title('MAKE_PAYMENT');
     $post_url = build_url(array('page' => 'purchase', 'type' => 'finish'), get_module_zone('purchase'));
     $rows = $GLOBALS['SITE_DB']->query_select('invoices', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $product = $row['i_type_code'];
     $object = find_product($product);
     $products = $object->get_products(false, $product);
     $invoice_title = $products[$product][4];
     list($fields, $hidden) = get_transaction_form_fields(NULL, strval($id), $invoice_title, float_to_raw_string($row['i_amount']), NULL, '');
     $text = do_lang_tempcode('TRANSACT_INFO');
     return do_template('FORM_SCREEN', array('_GUID' => 'e90a4019b37c8bf5bcb64086416bcfb3', 'TITLE' => $title, 'SKIP_VALIDATION' => '1', 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => do_lang_tempcode('MAKE_PAYMENT')));
 }
Example #3
0
/**
 * Payment step.
 *
 * @return tempcode	The result of execution.
 */
function payment_form()
{
    require_code('ecommerce');
    $title = get_page_title('PAYMENT_HEADING');
    $cart_items = find_products_in_cart();
    $purchase_id = NULL;
    $tax_opt_out = get_order_tax_opt_out_status();
    if (count($cart_items) > 0) {
        $insert = array('c_member' => get_member(), 'session_id' => get_session_id(), 'add_date' => time(), 'tot_price' => 0, 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'cart', 'transaction_id' => '', 'tax_opted_out' => $tax_opt_out);
        if (is_null($GLOBALS['SITE_DB']->query_value_null_ok('shopping_order', 'id'))) {
            $insert['id'] = hexdec('1701D');
            // Start offset
        }
        $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', $insert, true);
    } else {
        $order_id = NULL;
    }
    $total_price = 0;
    foreach ($cart_items as $item) {
        $product = $item['product_id'];
        $hook = $item['product_type'];
        require_code('hooks/systems/ecommerce/' . filter_naughty_harsh($hook), true);
        $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
        if (is_null($object)) {
            continue;
        }
        $temp = $object->get_products(false, $product);
        if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
            continue;
        }
        //Subscription type skipped.
        $price = $temp[$product][1];
        $item_name = $temp[$product][4];
        if (method_exists($object, 'set_needed_fields')) {
            $purchase_id = $object->set_needed_fields($product);
        } else {
            $purchase_id = strval(get_member());
        }
        $length = NULL;
        $length_units = '';
        if (method_exists($object, 'calculate_product_price')) {
            $price = $object->calculate_product_price($item['price'], $item['price_pre_tax'], $item['product_weight']);
        } else {
            $price = $item['price'];
        }
        if (method_exists($object, 'calculate_tax') && $tax_opt_out == 0) {
            $tax = round($object->calculate_tax($item['price'], $item['price_pre_tax']), 2);
        } else {
            $tax = 0.0;
        }
        $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => $item['product_id'], 'p_name' => $item['product_name'], 'p_code' => $item['product_code'], 'p_type' => $item['product_type'], 'p_quantity' => $item['quantity'], 'p_price' => $price, 'included_tax' => $tax, 'order_id' => $order_id, 'dispatch_status' => ''), true);
        $total_price += $price * $item['quantity'];
    }
    $GLOBALS['SITE_DB']->query_update('shopping_order', array('tot_price' => $total_price), array('id' => $order_id), '', 1);
    if (!perform_local_payment()) {
        $result = make_cart_payment_button($order_id, get_option('currency'));
    } else {
        if (!tacit_https() && !ecommerce_test_mode()) {
            warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
        }
        if (is_null($order_id)) {
            $fields = new ocp_tempcode();
            $hidden = new ocp_tempcode();
        } else {
            list($fields, $hidden) = get_transaction_form_fields(NULL, strval($order_id), $item_name, float_to_raw_string($price), NULL, '');
        }
        /*$via	=get_option('payment_gateway');
        		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
        		$object=object_factory('Hook_'.$via);
        		$ipn_url=$object->get_ipn_url();*/
        $finish_url = build_url(array('page' => 'purchase', 'type' => 'finish'), get_module_zone('purchase'));
        $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('FIELDS' => $fields, 'HIDDEN' => $hidden));
        require_javascript('javascript_validation');
        return do_template('PURCHASE_WIZARD_SCREEN', array('TITLE' => $title, 'CONTENT' => $result, 'URL' => $finish_url));
    }
    return $result;
}
Example #4
0
 /**
  * Payment step.
  *
  * @param  tempcode	The page title.
  * @return tempcode	The result of execution.
  */
 function pay($title)
 {
     $product = get_param('product');
     $object = find_product($product);
     if (method_exists($object, 'is_available') && !$object->is_available($product, get_member())) {
         warn_exit(do_lang_tempcode('PRODUCT_UNAVAILABLE'));
     }
     $temp = $object->get_products(true, $product);
     $price = $temp[$product][1];
     $item_name = $temp[$product][4];
     if (method_exists($object, 'set_needed_fields')) {
         $purchase_id = $object->set_needed_fields($product);
     } else {
         $purchase_id = strval(get_member());
     }
     if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
         $_purchase_id = $GLOBALS['SITE_DB']->query_value_null_ok('subscriptions', 'id', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new'));
         if (is_null($_purchase_id)) {
             $purchase_id = strval($GLOBALS['SITE_DB']->query_insert('subscriptions', array('s_type_code' => $product, 's_member_id' => get_member(), 's_state' => 'new', 's_amount' => $temp[$product][1], 's_special' => $purchase_id, 's_time' => time(), 's_auto_fund_source' => '', 's_auto_fund_key' => '', 's_via' => get_option('payment_gateway')), true));
         } else {
             $purchase_id = strval($_purchase_id);
         }
         $length = array_key_exists('length', $temp[$product][3]) ? $temp[$product][3]['length'] : 1;
         $length_units = array_key_exists('length_units', $temp[$product][3]) ? $temp[$product][3]['length_units'] : 'm';
     } else {
         $length = NULL;
         $length_units = '';
         //Add cataloue item order to shopping_orders
         if (method_exists($object, 'add_purchase_order')) {
             $purchase_id = strval($object->add_purchase_order($product, $temp[$product]));
         }
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PURCHASING'))));
     if ($price == '0') {
         $payment_status = 'Completed';
         $reason_code = '';
         $pending_reason = '';
         $mc_currency = get_option('currency');
         $txn_id = 'manual-' . substr(uniqid('', true), 0, 10);
         $parent_txn_id = '';
         $memo = 'Free';
         $mc_gross = '';
         handle_confirmed_transaction($purchase_id, $item_name, $payment_status, $reason_code, $pending_reason, $memo, $mc_gross, $mc_currency, $txn_id, $parent_txn_id);
         return inform_screen($title, do_lang_tempcode('FREE_PURCHASE'));
     }
     if (!array_key_exists(4, $temp[$product])) {
         $item_name = do_lang('CUSTOM_PRODUCT_' . $product, NULL, NULL, NULL, get_site_default_lang());
     }
     if (!perform_local_payment()) {
         if ($temp[$product][0] == PRODUCT_SUBSCRIPTION) {
             $transaction_button = make_subscription_button($product, $item_name, $purchase_id, floatval($price), $length, $length_units, get_option('currency'));
         } else {
             $transaction_button = make_transaction_button($product, $item_name, $purchase_id, floatval($price), get_option('currency'));
         }
         $tpl = $temp[$product][0] == PRODUCT_SUBSCRIPTION ? 'PURCHASE_WIZARD_STAGE_SUBSCRIBE' : 'PURCHASE_WIZARD_STAGE_PAY';
         $logos = method_exists($object, 'get_logos') ? $object->get_logos() : new ocp_tempcode();
         $result = do_template($tpl, array('LOGOS' => $logos, 'TRANSACTION_BUTTON' => $transaction_button, 'CURRENCY' => get_option('currency'), 'ITEM_NAME' => $item_name, 'TITLE' => $title, 'LENGTH' => is_null($length) ? '' : strval($length), 'LENGTH_UNITS' => $length_units, 'PURCHASE_ID' => $purchase_id, 'PRICE' => float_to_raw_string(floatval($price))));
     } else {
         if (!tacit_https() && !ecommerce_test_mode()) {
             warn_exit(do_lang_tempcode('NO_SSL_SETUP'));
         }
         $fields = get_transaction_form_fields(NULL, $purchase_id, $item_name, float_to_raw_string($price), $temp[$product][0] == PRODUCT_SUBSCRIPTION ? intval($length) : NULL, $temp[$product][0] == PRODUCT_SUBSCRIPTION ? $length_units : '');
         /*$via		=	get_option('payment_gateway');
         		require_code('hooks/systems/ecommerce_via/'.filter_naughty_harsh($via));
         		$object	=	object_factory('Hook_'.$via);
         		$ipn_url	=	$object->get_ipn_url();*/
         $finish_url = build_url(array('page' => '_SELF', 'type' => 'finish'), '_SELF');
         $result = do_template('PURCHASE_WIZARD_STAGE_TRANSACT', array('_GUID' => '15cbba9733f6ff8610968418d8ab527e', 'FIELDS' => $fields));
         return $this->wrap($result, $title, $finish_url);
     }
     return $this->wrap($result, $title, NULL);
 }
Example #5
0
/**
 * Find whether the specified page is to use HTTPS (if not -- it will use HTTP).
 * All images (etc) on a HTTPS page should use HTTPS to avoid mixed-content browser notices.
 *
 * @param  ID_TEXT		The zone the page is in
 * @param  ID_TEXT		The page codename
 * @return boolean		Whether the page is to run across an HTTPS connection
 */
function is_page_https($zone, $page)
{
    if (get_option('enable_https', true) == '0') {
        return false;
    }
    if (in_safe_mode()) {
        return false;
    }
    if ($page == 'login' && get_page_name() == 'login') {
        if (tacit_https()) {
            return true;
        }
    }
    global $HTTPS_PAGES;
    if ($HTTPS_PAGES === NULL && function_exists('persistant_cache_get')) {
        $HTTPS_PAGES = persistant_cache_get('HTTPS_PAGES');
    }
    if ($HTTPS_PAGES === NULL) {
        $results = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'https_pages', NULL, NULL, true);
        if ($results === false || $results === NULL) {
            $HTTPS_PAGES = array();
            return false;
        }
        $HTTPS_PAGES = collapse_1d_complexity('https_page_name', $results);
        if (function_exists('persistant_cache_set')) {
            persistant_cache_set('HTTPS_PAGES', $HTTPS_PAGES);
        }
    }
    return in_array($zone . ':' . $page, $HTTPS_PAGES);
}
Example #6
0
/**
 * Get tempcode to tie in (to the HTML, in <head>) all the CSS files that have been required.
 *
 * @param  boolean		Force inline CSS
 * @param  boolean		Only do global CSS
 * @param  ?string		HTML context for which we filter (minimise) any CSS we spit out as inline (NULL: none)
 * @param  ?ID_TEXT		The name of the theme (NULL: current theme)
 * @return tempcode		The tempcode to tie in the CSS files
 */
function css_tempcode($inline = false, $only_global = false, $context = NULL, $theme = NULL)
{
    global $CSSS;
    $seed = '';
    if (has_specific_permission(get_member(), 'view_profiling_modes')) {
        $seed = get_param('keep_theme_seed', '');
    }
    $text_only = get_param_integer('keep_textonly', 0) == 1;
    $minify = get_param_integer('keep_no_minify', 0) == 0;
    $https = get_option('enable_https', true) == '1' && function_exists('is_page_https') && function_exists('get_zone_name') && (tacit_https() || is_page_https(get_zone_name(), get_page_name()));
    $mobile = is_mobile();
    $css = new ocp_tempcode();
    $css_need_inline = new ocp_tempcode();
    $css_to_do = $only_global ? array('global', 'no_cache') : array_keys($CSSS);
    foreach ($css_to_do as $c) {
        if (is_integer($c)) {
            $c = strval($c);
        }
        if ($seed != '') {
            $keep = symbol_tempcode('KEEP');
            $css->attach(do_template('CSS_NEED_FULL', array('URL' => find_script('themewizard') . '?type=css&show=' . $c . '.css' . $keep->evaluate()), user_lang(), false, NULL, '.tpl', 'templates', $theme));
        } elseif ($c == 'no_cache' || $inline) {
            if (!$text_only) {
                $_css = do_template($c, NULL, user_lang(), false, NULL, '.css', 'css', $theme);
                $__css = $_css->evaluate();
                if ($context !== NULL) {
                    $__css = filter_css($__css, $context);
                } else {
                    $__css = str_replace('} ', '}' . chr(10), preg_replace('#\\s+#', ' ', $__css));
                }
                if (trim($__css) != '') {
                    $css_need_inline->attach(do_template('CSS_NEED_INLINE', array('_GUID' => 'f5b225e080c633ffa033ec5af5aec866', 'CSS' => $__css), user_lang(), false, NULL, '.tpl', 'templates', $theme));
                }
            }
        } else {
            $temp = css_enforce($c, $theme);
            if (!$minify) {
                $c .= '_non_minified';
            }
            if ($https) {
                $c .= '_ssl';
            }
            if ($mobile) {
                $c .= '_mobile';
            }
            if ($temp != '') {
                $css->attach(do_template('CSS_NEED', array('_GUID' => 'ed35fac857214000f69a1551cd483096', 'CODE' => $c), user_lang(), false, NULL, '.tpl', 'templates', $theme));
            }
        }
    }
    $css_need_inline->attach($css);
    return $css_need_inline;
}