//**** This file needs to be included from a file that has access to "wp-load.php" **** include_once('eStore_db_access.php'); include_once('eStore_debug_handler.php'); include_once('eStore_utility_functions.php'); global $wpdb; define('WP_ESTORE_PRODUCTS_TABLE_NAME', $wpdb->prefix . "wp_eStore_tbl"); define('WP_ESTORE_CUSTOMERS_TABLE_NAME', $wpdb->prefix . "wp_eStore_customer_tbl"); define('WP_ESTORE_SALES_TABLE_NAME', $wpdb->prefix . "wp_eStore_sales_tbl"); define('WP_ESTORE_PENDING_PAYMENT_TABLE_NAME', $wpdb->prefix . "wp_eStore_pending_payment_tbl"); define('WP_AFFILIATE_TABLE_NAME', $wpdb->prefix . "affiliates_tbl"); define('WP_AFFILIATE_SALES_TABLE_NAME', $wpdb->prefix . "affiliates_sales_tbl"); $products_table_name = $wpdb->prefix . "wp_eStore_tbl"; $customer_table_name = $wpdb->prefix . "wp_eStore_customer_tbl"; $sales_table_name = $wpdb->prefix . "wp_eStore_sales_tbl"; function get_custom_var($custom) { $delimiter = "&"; $customvariables = array(); $namevaluecombos = explode($delimiter, $custom); foreach ($namevaluecombos as $keyval_unparsed) { $equalsignposition = strpos($keyval_unparsed, '='); if ($equalsignposition === false) { $customvariables[$keyval_unparsed] = ''; continue; } $key = substr($keyval_unparsed, 0, $equalsignposition); $value = substr($keyval_unparsed, $equalsignposition + 1); $customvariables[$key] = $value; } return $customvariables; } function get_download_for_variation($cart_item_name,$ret_product,$script_location,$random_key,$payment_data='') { $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS; $variation_name_to_match = eStore_get_string_between($cart_item_name,"(",")"); eStore_payment_debug('Generating download link for digital variation. Variation name to match: '.$variation_name_to_match,true); $pieces = explode('|',$ret_product->variation3); for ($i=1;$i 1) { $var3 = $pieces2[0]; //$pos = strpos($cart_item_name, $var3); //if ($pos !== false) if (strcmp($variation_name_to_match, $var3) == 0) { if (is_numeric($pieces2[1])) { $url = $pieces2[2]; } else { $url = $pieces2[1]; } eStore_payment_debug('Found a match for: '.$variation_name_to_match,true); //$download = $ret_product->id.'|'.time().'|'.$url; //$download_key = eStore_generate_download_key($ret_product->id,$url); $download_key = eStore_check_stamping_flag_and_generate_download_key($ret_product,$ret_product->id,$url,$payment_data); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $output = "\n".stripslashes($cart_item_name)." - ".$encrypted_download_url; eStore_register_link_in_db('',$download_key,$output,'','','',0,$payment_data['txn_id']); return $output; } } else { $output = "Download URL was not specified for this variation"; } } return $output; } function get_download_for_variation_tx_result($cart_item_name,$ret_product,$script_location,$random_key,$payment_data='') { $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS; $variation_name_to_match = eStore_get_string_between($cart_item_name,"(",")"); $pieces = explode('|',$ret_product->variation3); for ($i=1;$i 1) { $var3 = $pieces2[0]; //$pos = strpos($cart_item_name, $var3); //if ($pos !== false) if (strcmp($variation_name_to_match, $var3) == 0) { if (is_numeric($pieces2[1])) { $url = $pieces2[2]; } else { $url = $pieces2[1]; } //$download = $ret_product->id.'|'.time().'|'.$url; //$download_key = eStore_generate_download_key($ret_product->id,$url); $download_key = eStore_check_stamping_flag_and_generate_download_key($ret_product,$ret_product->id,$url,$payment_data); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $raw_download = ''.$encrypted_download_url.''; $output = "
".$cart_item_name." - ".$raw_download; eStore_register_link_in_db('',$download_key,$encrypted_download_url,'','','',0,$payment_data['txn_id']); } } else { $output = "
Download URL was not specified for this variation"; } } return $output; } function generate_download_link_for_product($id,$name='',$payment_data='') { global $wpdb,$products_table_name; $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT); if(!empty($name)) { $output = generate_download_link($retrieved_product,$name,$payment_data); } else { $output = generate_download_link($retrieved_product,$retrieved_product->name,$payment_data); } return $output; } function generate_download_link($retrieved_product,$item_name,$payment_data='') { $time = time(); global $wpdb; global $products_table_name; $product_id = $retrieved_product->id; $script_location = get_option('eStore_download_script'); $random_key = get_option('eStore_random_code'); $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS; if(empty($retrieved_product->product_download_url)) { $download_link = "\n".$item_name . WP_ESTORE_THIS_ITEM_DOES_NOT_HAVE_DOWNLOAD; } else { if(!empty($retrieved_product->variation3)) { $download_link = get_download_for_variation($item_name,$retrieved_product,$script_location,$random_key,$payment_data); } else { $download_url_field = $retrieved_product->product_download_url; $product_ids = explode(',',$download_url_field); $package_product = eStore_is_package_product($retrieved_product); $multi_parts = false; if(sizeof($product_ids)>1 && !$package_product){ $multi_parts = true; } if($package_product) { eStore_payment_debug('Generating download link for package product.',true); //$count = 0; foreach($product_ids as $id) { $id = trim($id); $retrieved_product_for_specific_id = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT); //recursively generate the links $download_link .= generate_download_link($retrieved_product_for_specific_id,$retrieved_product_for_specific_id->name); //$download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product_for_specific_id,$retrieved_product_for_specific_id->id,'',$payment_data); //$download_item = "\n".stripslashes($retrieved_product_for_specific_id->name)." - ".$script_location.'download.php?file='.$download_key; //$download_link .= $download_item; //eStore_register_link_in_db('',$download_key,$download_item,'','','',0); } } else if($multi_parts) { eStore_payment_debug('Generating download link for multi part file.',true); $count = 1; $download_link .= "\n".stripslashes($item_name)." - "; foreach($product_ids as $id) { $id = trim($id); if(!empty($id)){ //$download = $product_id.'|'.$time.'|'.$id; //$download_key = eStore_generate_download_key($product_id,$id); $download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product,$product_id,$id,$payment_data); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $download_item = "\nPart ".$count." : ".$encrypted_download_url; $download_link .= $download_item; eStore_register_link_in_db('',$download_key,$download_item,'','','',0,$payment_data['txn_id']); $count++; } } } else { eStore_payment_debug('Generating download link for single file.',true); //$download = $product_id.'|'.$time; //$download_key = eStore_generate_download_key($product_id); $download_key = eStore_check_stamping_flag_and_generate_download_key($retrieved_product,$product_id,'',$payment_data); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $download_link = "\n".stripslashes($item_name)." - ".$encrypted_download_url; eStore_register_link_in_db('',$download_key,$download_link,'','','',0,$payment_data['txn_id']); } } } return $download_link; } function eStore_generate_download_key($product_id,$url='') { $time = time(); $random_key = get_option('eStore_random_code'); if(empty($url)) { $download = $product_id.'|'.$time; } else { $download = $product_id.'|'.$time.'|'.$url; } $download_key = rawurlencode(base64_encode(RC4Crypt::encrypt($random_key,$download))); return $download_key; } function eStore_check_stamping_flag_and_generate_download_key($retrieved_product,$product_id,$url='',$payment_data='') { if($retrieved_product->use_pdf_stamper == 1 && !empty($payment_data)) { if(!empty($url)) { $src_file = $url; } else { $src_file = $retrieved_product->product_download_url; } $txn_id = $payment_data['txn_id']; if(!empty($txn_id))//check for an already stamped copy of the file to minimize server load { eStore_payment_debug('Checking for a reference to the stamped copy of the file for this transaction before invoking another stamp request:'.$txn_id,true); $cond = " txn_id = '$txn_id'"; $result = WP_eStore_Db_Access::find(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $cond); if($result){ $download_key = $result->download_key; eStore_payment_debug('Found a reference to the stamped copy of a file. Download Key:'.$download_key,true); eStore_payment_debug('Decrypting download key to retrieve the stamped file URL ...',true); $random_key = get_option('eStore_random_code'); $decrypted_data = RC4Crypt::decrypt($random_key,base64_decode(rawurldecode($download_key))); list($product_id,$timestamp,$stamped_file_url) = explode('|',$decrypted_data); eStore_payment_debug('Decrypted data. Product ID: '.$product_id.', Stamped File URL:'.$stamped_file_url,true); $new_download_key = eStore_generate_download_key($product_id,$stamped_file_url); eStore_payment_debug('New Download Key: '.$new_download_key,true); return $new_download_key; } else{ eStore_payment_debug('Could not find a reference to the stamped copy of a file',true); } } $stamped_file_url = eStore_stamp_pdf_file($payment_data,$src_file); $download_key = eStore_generate_download_key($product_id,$stamped_file_url); } else { $download_key = eStore_generate_download_key($product_id,$url); } return $download_key; } function eStore_stamp_pdf_file($payment_data,$src_file) { eStore_payment_debug('Stamping the PDF file if WP PDF stamper plugin is installed.',true); $src_file = trim($src_file); $pdf_stamper_plugin_url = get_option('WP_PDF_STAMP_URL'); $file_type_pdf = preg_match_all('/^.*\.(pdf)$/i', $src_file, $arr, PREG_PATTERN_ORDER); eStore_payment_debug('Source file type check... is file type PDF return value: '.$file_type_pdf,true); if($file_type_pdf != 1) { eStore_payment_debug('Source file is not a PDF file so no stamping necessary for this file!', true); return $src_file; } if (!empty($pdf_stamper_plugin_url)) { if(empty($payment_data)) { eStore_payment_debug('Payment data is empty! Cannot stamp a PDF file without customer information in the payment data!',false); return "Error!"; } if(empty($src_file)) { eStore_payment_debug('Source file is empty! Cannot stamp a PDF file without source file data!',false); return "Error!"; } eStore_payment_debug("Source File URL is: ".$src_file,true); $postURL = $pdf_stamper_plugin_url."/api/stamp_api.php"; // The Secret key $secretKey = get_option('wp_pdf_stamp_secret_key'); // The site URL $domainURL = $_SERVER['SERVER_NAME']; // prepare the data $data = array (); $data['secret_key'] = $secretKey; $data['requested_domain'] = $domainURL; $data['source_file'] = $src_file; if(empty($payment_data['customer_name'])) { $data['customer_name'] = $payment_data['first_name']." ".$payment_data['last_name']; } else { $data['customer_name'] = $payment_data['customer_name']; } $data['customer_email'] = $payment_data['payer_email']; $data['customer_phone'] = $payment_data['contact_phone']; if(empty($payment_data['address'])) { $data['customer_address'] = $payment_data['address_street'].", ".$payment_data['address_city'].", ".$payment_data['address_state']." ".$payment_data['address_zip'].", ".$payment_data['address_country']; } else { $data['customer_address'] = $payment_data['address']; } $data['customer_business_name'] = $payment_data['payer_business_name']; // use the appropriate stamp API to stamp the file if(WP_PDF_STAMP_DO_NOT_USE_CURL == '0') { eStore_payment_debug("Attempting to stamp the PDF file using CURL API",true); $returnValue = eStore_post_data_using_curl($postURL,$data); } else if(function_exists('pdf_stamper_stamp_internal_file')) { eStore_payment_debug("Attempting to stamp the PDF file using the internal stamping API",true); $line_distance = ""; $line_space = ""; $footer_text = ""; $returnValue = pdf_stamper_stamp_internal_file($src_file,$data['customer_name'],$data['customer_name'],$data['customer_phone'],$data['customer_address'],$data['customer_business_name'],$line_distance,$line_space,$footer_text); } else{ eStore_payment_debug("Attempting to stamp the PDF file using CURL API",true); $returnValue = eStore_post_data_using_curl($postURL,$data); } list ($status, $value) = explode ("\n", $returnValue); $message = ""; if(strpos($status,"Success!") !== false) { $file_url = trim($value); $message .= "File stamped successfully! Stamped file URL: ".$file_url; eStore_payment_debug($message,true); } else { $message .= "An error occured while trying to stamp the file! Error details: ".$value; eStore_payment_debug($message,false); return "Error!"; } } else { eStore_payment_debug('PDF stamper plugin is not installed!',false); } return $file_url; } function eStore_get_ngg_image_url($pictureID,$item_name) { $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS; $script_location = get_option('eStore_download_script'); $image = nggdb::find_image($pictureID); $imageUrl = $image->imageURL; eStore_payment_debug('Nextgen gallery raw image URL for picture ID: '.$pictureID.' is: '.$imageUrl,true); $product_id = get_option('eStore_ngg_template_product_id'); eStore_payment_debug('Generating download key for Nextgen gallery image using product ID: '.$product_id,true); $download_key = eStore_generate_download_key($product_id,$imageUrl); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $download_link .= "\n".stripslashes($item_name)." - ".$encrypted_download_url; eStore_register_link_in_db('',$download_key,$download_link,'','','',0,''); return $download_link; } function eStore_get_ngg_image_url_html($pictureID,$item_name) { $eStore_auto_shorten_url = WP_ESTORE_AUTO_SHORTEN_DOWNLOAD_LINKS; $script_location = get_option('eStore_download_script'); $image = nggdb::find_image($pictureID); $imageUrl = $image->imageURL; $product_id = get_option('eStore_ngg_template_product_id'); eStore_payment_debug('Generating download key for Nextgen gallery image using product ID: '.$product_id,true); $download_key = eStore_generate_download_key($product_id,$imageUrl); $encrypted_download_url = $script_location.'download.php?file='.$download_key; if($eStore_auto_shorten_url){ $encrypted_download_url = wp_eStore_shorten_url($encrypted_download_url); } $raw_download = ''.$encrypted_download_url.''; $download_link = "
".$item_name." - ".$raw_download; eStore_register_link_in_db('',$download_key,$encrypted_download_url,'','','',0,''); return $download_link; } function eStore_handle_refund($payment_data) { eStore_payment_debug('Handling refund request...',false); global $wpdb,$sales_table_name,$customer_table_name; $parent_txn_id = $payment_data['parent_txn_id']; if (function_exists('wp_aff_platform_install')) { if (function_exists('wp_aff_handle_refund')) { // Check for the original transaction in the database $resultset = $wpdb->get_results("SELECT * FROM $customer_table_name WHERE txn_id = '$parent_txn_id'", OBJECT); if($resultset) { eStore_payment_debug('Found the original transation in the database. Reverse the commmission for this payment. Parent Txn ID: '.$parent_txn_id,true); wp_aff_handle_refund($parent_txn_id); } else{ eStore_payment_debug('Could not find the original transation in the database. Nothing to reverse.',true); } } } if (get_option('eStore_enable_wishlist_int')) { // Deactivate wishlist member's account wl_handle_subsc_cancel($payment_data,true); } if(get_option(eStore_auto_customer_removal)) { //$editingcustomer = $wpdb->get_row("SELECT * FROM $customer_table_name WHERE txn_id = '$parent_txn_id'", OBJECT); $updatedb = "DELETE FROM $customer_table_name WHERE txn_id='$parent_txn_id'"; $results = $wpdb->query($updatedb); } $emailaddress = $payment_data['payer_email']; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); $product_id = $payment_data['item_number']; $sale_price = $payment_data['mc_gross']; eStore_payment_debug('Updating sales database talble with the refund amount: '.$sale_price,false); $updatedb2 = "INSERT INTO $sales_table_name (cust_email, date, time, item_id, sale_price) VALUES ('$emailaddress','$clientdate','$clienttime','$product_id','$sale_price')"; $results = $wpdb->query($updatedb2); } function is_paypal_recurring_payment($payment_data) { $recurring_payment = false; global $wpdb; global $customer_table_name; $transaction_type = $payment_data['txn_type']; if ($transaction_type == "recurring_payment") { $recurring_payment = true; } else if ($transaction_type == "subscr_payment") { $email = $payment_data['payer_email']; $item_number = $payment_data['item_number']; $subscr_id = $payment_data['subscr_id']; $customer_exists = $wpdb->get_row("SELECT * FROM $customer_table_name WHERE email_address = '$email' and purchased_product_id = '$item_number'", OBJECT); if($customer_exists) { if(empty($customer_exists->subscr_id)) { $recurring_payment = true; } else if($customer_exists->subscr_id == $subscr_id) { $recurring_payment = true; } } } return $recurring_payment; } function eStore_is_package_product($retrieved_product) { $download_url_field = $retrieved_product->product_download_url; $product_ids = explode(',',$download_url_field); $package_product = false; foreach($product_ids as $id) { if(is_numeric($id)) { $package_product = true; } } return $package_product; } function eStore_is_ngg_pid_present($name) { $raw_pid_string = eStore_get_string_between($name,'[',']'); if(!empty($raw_pid_string)) { $pid_values = explode(":",$raw_pid_string); if($pid_values[0]=="pid") return $pid_values[1];//return the PID } return -1;//no PID present } function eStore_get_chimp_api() { $api_key = get_option('eStore_chimp_api_key'); if(!empty($api_key)) { $api = new MCAPI($api_key); } else { $api = new MCAPI(get_option('eStore_chimp_user_name'), get_option('eStore_chimp_pass')); } return $api; } function eStore_post_data_using_curl($postURL,$data) { if(!function_exists('curl_init')) { eStore_payment_debug('CURL library is not installed!',false); return "NO CURL"; } // send data to post URL $ch = curl_init ($postURL); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $returnValue = curl_exec ($ch); curl_close ($ch); return $returnValue; } function eStore_POST_IPN_data_to_url($data,$post_url='',$cart_items='') { //POST IPN Data to corresponding scripts if specified in the settings if(empty($post_url)) { //See if the external URL is specified in the settings $ipn_external_post_url = get_option('eStore_third_party_ipn_post_url'); } else{ $ipn_external_post_url = $post_url; } if(!empty($ipn_external_post_url)) { if(!empty($cart_items)){ //add the cart item details to the post data array $num_cart_items = count($cart_items); if($num_cart_items>1){ $i = 1; foreach ($cart_items as $current_cart_item){ $data_key = 'item_name'.$i; $data[$data_key] = trim($current_cart_item['item_name']); $i++; } } else{ $data_key = 'item_name'; $data[$data_key] = trim($cart_items[0]['item_name']); } } eStore_payment_debug('Posting IPN data to :'.$ipn_external_post_url,true); $retVal = eStore_post_data_using_curl($ipn_external_post_url, $data); if($retVal == "NO CURL") { eStore_payment_debug('Could not post IPN. CURL library is not installed on this server!',false); } else { eStore_payment_debug('IPN values posted successfully. Return value: '.$retVal,false); } } } function eStore_check_and_generate_license_key($retrieved_product,$payment_data='') { global $wpdb,$products_table_name; $product_license_data = ""; $package_product = eStore_is_package_product($retrieved_product); if($package_product) { eStore_payment_debug('Checking license key generation for package product.',true); $product_ids = explode(',',$retrieved_product->product_download_url); foreach($product_ids as $id) { $id = trim($id); $retrieved_product_for_specific_id = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT); $product_license_data .= eStore_check_licese_key_flag_and_generate_key($retrieved_product_for_specific_id,$payment_data); } } else { eStore_payment_debug('Checking license key generation for single product.',true); $product_license_data .= eStore_check_licese_key_flag_and_generate_key($retrieved_product,$payment_data); } return $product_license_data; } function eStore_check_licese_key_flag_and_generate_key($retrieved_product,$payment_data) { if($retrieved_product->create_license == 1) { $license_key = eStore_generate_license_key($payment_data); $product_license_data .= "\n".$retrieved_product->name." License Key: ".$license_key; } return $product_license_data; } function eStore_generate_license_key($payment_data='') { if(function_exists('wp_lic_manager_install')) { //Post URL $postURL = get_option('eStore_lic_mgr_post_url'); // the Secret Key $secretKey = get_option('eStore_lic_mgr_secret_word'); // prepare the data $data = array (); $data['secret_key'] = $secretKey; $data['first_name'] = $payment_data['first_name']; $data['last_name'] = $payment_data['last_name']; $data['email'] = $payment_data['payer_email']; $data['company_name'] = $payment_data['payer_business_name']; $data['txn_id'] = $payment_data['txn_id']; $returnValue = eStore_post_data_using_curl($postURL,$data); list ($status, $msg, $additionalMsg) = explode ("\n", $returnValue); $message = ""; if(strpos($status,"Success") !== false) { $license_key = trim($additionalMsg); $message .= "License Key created successfully! License Key: ".$license_key; eStore_payment_debug($message,true); return $license_key; } else { $message .= "An error occured while trying to create the license key! Error details: ".$msg; eStore_payment_debug($message,false); return "Error"; } } else { eStore_payment_debug('WP License Manager plugin is not installed!',false); return "Error"; } } function eStore_register_link_in_db($creation_time='',$download_key='',$download_item='',$download_limit_count,$download_limit_time,$download_limit_ip='',$access_count=0,$txn_id='') { if(empty($creation_time)) { $creation_time = date ("Y-m-d H:i:s");//current_time('mysql'); } if(empty($download_key)) { //Download key cannot be empty return false; } if(empty($download_limit_count)) { $download_limit_count = get_option('eStore_download_url_limit_count'); if(empty($download_limit_count)) { $download_limit_count = 999; } } if(empty($download_limit_time)) { $download_limit_time = get_option('eStore_download_url_life'); } if(empty($download_limit_ip)) { $download_limit_ip = $_SERVER['REMOTE_ADDR']; } //Add to the download link to the database global $wpdb; $download_key = rawurldecode($download_key);//str_replace('%2B','+', $download_key ); $fields = array(); $fields['creation_time'] = $creation_time; $fields['download_key'] = $download_key; $fields['download_item'] = $wpdb->escape($download_item); $fields['download_limit_count'] = $download_limit_count; $fields['download_limit_time'] = $download_limit_time; $fields['download_limit_ip'] = $download_limit_ip; $fields['access_count'] = $access_count; $fields['txn_id'] = $txn_id; $updated = WP_eStore_Db_Access::insert(WP_ESTORE_DOWNLOAD_LINKS_TABLE_NAME, $fields); return true; } function record_sales_data($payment_data,$cart_items) { eStore_payment_debug('Updating Products and Customers Database Tables with Sales Data.',true); global $wpdb; $products_table_name = WP_ESTORE_DB_PRODUCTS_TABLE_NAME; $customer_table_name = WP_ESTORE_DB_CUSTOMERS_TABLE_NAME; $sales_table_name = WP_ESTORE_DB_SALES_TABLE_NAME; $firstname = $payment_data['first_name']; $lastname = $payment_data['last_name']; $emailaddress = $payment_data['payer_email']; $transaction_id = $payment_data['txn_id']; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); $address = $wpdb->escape(stripslashes($payment_data['address'])); $phone = $payment_data['phone']; $coupon_code_used = $wpdb->escape($payment_data['coupon_used']); $eMember_username = $wpdb->escape($payment_data['eMember_userid']); $subscr_id = $payment_data['subscr_id']; $customvariables = get_custom_var($payment_data['custom']); $customer_ip = $customvariables['ip']; if(empty($customer_ip)){ $customer_ip = "No information"; } $status = "Paid"; if($payment_data['gateway']=='manual'){ $status = "Unpaid"; } $counter = 0; foreach ($cart_items as $current_cart_item) { $cart_item_data_num = $current_cart_item['item_number']; $cart_item_data_name = $current_cart_item['item_name']; $cart_item_qty = $current_cart_item['quantity']; $key=$cart_item_data_num; $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$key'", OBJECT); $current_product_id = $cart_item_data_num; if (is_numeric($retrieved_product->available_copies)) { $new_available_copies = ($retrieved_product->available_copies - $cart_item_qty); } $new_sales_count = ($retrieved_product->sales_count + $cart_item_qty); $updatedb = "UPDATE $products_table_name SET available_copies = '$new_available_copies', sales_count = '$new_sales_count' WHERE id='$current_product_id'"; $results = $wpdb->query($updatedb); // Update the Customer table $product_name = $wpdb->escape(stripslashes($cart_item_data_name)); $sale_price = $current_cart_item['mc_gross']; $updatedb = "INSERT INTO $customer_table_name (first_name, last_name, email_address, purchased_product_id,txn_id,date,sale_amount,coupon_code_used,member_username,product_name,address,phone,subscr_id,purchase_qty,ipaddress,status) VALUES ('$firstname', '$lastname','$emailaddress','$current_product_id','$transaction_id','$clientdate','$sale_price','$coupon_code_used','$eMember_username','$product_name','$address','$phone','$subscr_id','$cart_item_qty','$customer_ip','$status')"; $results = $wpdb->query($updatedb); $updatedb2 = "INSERT INTO $sales_table_name (cust_email, date, time, item_id, sale_price) VALUES ('$emailaddress','$clientdate','$clienttime','$current_product_id','$sale_price')"; $results = $wpdb->query($updatedb2); } //Update the coupons table if coupon was used $coupon_code = $customvariables['coupon']; if(!empty($coupon_code)) { $coupon_table_name = WP_ESTORE_COUPON_TABLE_NAME; $ret_coupon = $wpdb->get_row("SELECT * FROM $coupon_table_name WHERE coupon_code = '$coupon_code'", OBJECT); if ($ret_coupon) { $redemption_count = $ret_coupon->redemption_count + 1; $updatedb = "UPDATE $coupon_table_name SET redemption_count = '$redemption_count' WHERE coupon_code='$coupon_code'"; $results = $wpdb->query($updatedb); } } eStore_payment_debug('Products, Customers, Sales and Coupons Database Tables Updated.',true); } function eStore_aff_award_commission($payment_data,$cart_items,$customReferrer='') { eStore_payment_debug('===> Start of Affiliate Commission Calculation <===',true); eStore_payment_debug('Checking if the WP Affiliate Platform Plugin is installed.',true); if (function_exists('wp_aff_platform_install') || function_exists('wp_aff_award_commission')) { eStore_payment_debug('WP Affiliate Platform is installed, checking commission related details...',true); $customvariables = get_custom_var($payment_data['custom']); if(!empty($customReferrer))//Maybe the author profit sharing feature is being used { $referrer = $customReferrer; eStore_payment_debug('Revenue sharing feature is being used',true); } else { $referrer = $customvariables['ap_id']; } if (!empty($referrer)) { eStore_payment_debug('The referrer for this sale is:'.$referrer,true); $txn_id = $payment_data['txn_id']; $buyer_email = $payment_data['payer_email']; $clientip = $customvariables['ip']; //Check if using the satellite affiliate plugin is being used then direct commision there if(WP_ESTORE_REDIRECT_COMMISSION_USING_SATELLITE_AFFILIATE_PLUGIN && function_exists('satellite_aff_perform_remote_sale_tracking')) { eStore_payment_debug('Redirecting commission using the satellite affiliate plugin',true); $sale_amt = $payment_data['mc_gross']; satellite_aff_perform_remote_sale_tracking($sale_amt,$referrer,$txn_id,'',$buyer_email,$clientip); return true; } global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $affiliates_table_name = WP_AFFILIATE_TABLE_NAME; $aff_sales_table = WP_AFFILIATE_SALES_TABLE_NAME; $resultset = $wpdb->get_results("SELECT * FROM $aff_sales_table WHERE txn_id = '$txn_id'", OBJECT); if($resultset) { //Commission for this transaction has already been awarded so no need to do anything. eStore_payment_debug('The database record shows that the commission for this transaction has already been awarded so no need to do anything.',true); eStore_payment_debug('===> End Affiliate Commission Check <===',true); return; } //Check if the "DO not award commission if coupon is used" feature is in use if(get_option('eStore_aff_no_commission_if_coupon_used')!='') { $coupon = $customvariables['coupon']; if(!empty($coupon)){ eStore_payment_debug('Do Not Award Commission if Coupon Used feature is enabled. Commission will not be awarded for this transaction since a coupon code has been used. Coupon: '.$coupon,true); eStore_payment_debug('===> End Affiliate Commission Check <===',true); return; } eStore_payment_debug('No coupon used for this transaction',true); } $wp_aff_affiliates_db = $wpdb->get_row("SELECT * FROM $affiliates_table_name WHERE refid = '$referrer'", OBJECT); $commission_level = $wp_aff_affiliates_db->commissionlevel; $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); $counter = 1; $commission_amount = 0; $product_comm_amount = 0; $second_tier_commission_amount = 0; $purchased_items = ''; foreach ($cart_items as $current_cart_item) { eStore_payment_debug('Processing Commission for : '.$current_cart_item['item_name'],true); $cart_item_number = $current_cart_item['item_number']; //The total item price includes the (individual item price * quantity) $total_item_price = $current_cart_item['mc_gross'] - $current_cart_item['mc_shipping']; $item_qty = $current_cart_item['quantity']; eStore_payment_debug('Total Price of the currently processing item : '.$total_item_price,true); $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$cart_item_number'", OBJECT); if (!empty($retrieved_product->commission)) { eStore_payment_debug('Using product specific commission specified in eStore',true); if (get_option('wp_aff_use_fixed_commission')) { eStore_payment_debug('Using fixed commission rate for this product specific commission',true); //Give fixed commission from the product's specified level $product_comm_amount = $item_qty * $retrieved_product->commission; //Award fixed commission for 2nd tier from the product's specified level if (!empty($retrieved_product->tier2_commission)){ $product_second_tier_comm_amt = $item_qty * $retrieved_product->tier2_commission; } } else { eStore_payment_debug('Using % based commission rate for this product specific commission',true); //Award % commission from the product's specified level //The total item price includes the (individual item price * quantity) $product_comm_amount = ($total_item_price*$retrieved_product->commission/100); //Award % commission for 2nd tier from the product's specified level if (!empty($retrieved_product->tier2_commission)){ $product_second_tier_comm_amt = $total_item_price * ($retrieved_product->tier2_commission)/100; } } } else { if ($retrieved_product->commission == "0") { $product_comm_amount = 0; $product_second_tier_comm_amt = 0; eStore_payment_debug('This product will not generate any commission as the product specific commission for this product has been specified as 0',true); } else { eStore_payment_debug('Using commission rate from affiliate profile',true); if (get_option('wp_aff_use_fixed_commission')) { eStore_payment_debug('Using fixed commission rate for this commission. Qty:'.$item_qty.', Fixed commission level:'.$commission_level,true); //Give fixed commission from the affiliate's specified level $product_comm_amount = $item_qty * $commission_level; //Award fixed commission for 2nd tier from the affiliate's specified level $product_second_tier_comm_amt = $item_qty * $second_tier_commission_level; } else { eStore_payment_debug('Using % based commission rate for this commission. Qty:'.$item_qty.', Total price:'.$total_item_price.', Commission level:'.$commission_level,true); //The total item price includes the (individual item price * quantity) $product_comm_amount = $total_item_price * ($commission_level/100); //Award fixed commission for 2nd tier from the affiliate's specified level $product_second_tier_comm_amt = $total_item_price * (($second_tier_commission_level)/100); } } } $commission_amount = $commission_amount + $product_comm_amount; $second_tier_commission_amount = $second_tier_commission_amount + $product_second_tier_comm_amt; if($counter>1){ $purchased_items .= ", "; } $purchased_items .= $cart_item_number; $counter++; } $commission_amount = number_format($commission_amount,2); $second_tier_commission_amount = number_format($second_tier_commission_amount,2); $sale_amount = $payment_data['mc_gross']; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); $txn_id = $payment_data['txn_id']; $item_id = $purchased_items; $aff_version = get_option('wp_aff_platform_version'); // Check if the commission per transaction option is enabled if(get_option('eStore_aff_enable_commission_per_transaction')!='') { eStore_payment_debug('Commission per transaction option is enabled so the commission will be awarded for the full transaction rather than on a per item basis',true); if (get_option('wp_aff_use_fixed_commission')) { eStore_payment_debug('Using fixed commission model',true); $commission_amount = number_format($commission_level,2); $c_id = ''; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$c_id')"; $results = $wpdb->query($updatedb); eStore_payment_debug('===> End Affiliate Commission Check <===',true); return; } else{ //For percentage based commission there is not difference between per transaction commission amount and the per item commission amount } } if($aff_version>=4.7) { eStore_payment_debug("Affiliate version is greater than 4.7",true); $c_id = ''; $buyer_name = $payment_data['first_name']." ".$payment_data['last_name']; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$c_id','$buyer_name')"; } else if($aff_version>=4.4) { eStore_payment_debug("Affiliate version is greater than 4.4",true); $c_id = ''; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$c_id')"; } else if($aff_version>=1.1) { eStore_payment_debug("Affiliate version is greater than 1.1",true); $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email')"; //$updatedb = "INSERT INTO $aff_sales_table VALUES ('$referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email')"; } else { $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount) VALUES ('$referrer','$clientdate','$clienttime','','$clientip','$commission_amount','$sale_amount')"; //$updatedb = "INSERT INTO $aff_sales_table VALUES ('$referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount')"; } $results = $wpdb->query($updatedb); if(function_exists('wp_aff_send_commission_notification')){ if($commission_amount>0) { wp_aff_send_commission_notification($wp_aff_affiliates_db->email); eStore_payment_debug("Sent commission email notification request to the affiliate plugin",true); } else { eStore_payment_debug("The commission amount is 0. No need to notify the affiliate",true); } } $message = 'The sale has been registered in the WP Affiliate Platform Database for referrer: '.$referrer.' with amount: '.$commission_amount; eStore_payment_debug($message,true); //2nd tier affiliate commission if($aff_version>=1.8) { eStore_payment_debug('Awarding 2nd tier commission if applicable',true); //$result = wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email); if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $award_tier_commission = true; $duration = get_option('wp_aff_2nd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { eStore_payment_debug('Tier commission award duration expried',true); $award_tier_commission = false; } } if ($award_tier_commission) { $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$second_tier_commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email')"; //$updatedb = "INSERT INTO $aff_sales_table VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$second_tier_commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email')"; $results = $wpdb->query($updatedb); eStore_payment_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$second_tier_commission_amount,true); } } eStore_payment_debug('End of tier commission check',true); } } else { eStore_payment_debug('No Referrer Found. This is not an affiliate referred sale.',true); } } else { eStore_payment_debug('WP Affiliate Platform Plugin is not installed.',true); } eStore_payment_debug('===> End Affiliate Commission Check <===',true); } function eStore_award_author_commission($payment_data,$cart_items) { eStore_payment_debug('Checking if the Author ID field has been used in any of the purchased product for revenue sharing purpose.',true); $share_revenue = get_option('eStore_aff_enable_revenue_sharing'); if($share_revenue != '1') { eStore_payment_debug('Revenue sharing feature is not in use.',true); return; } global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $buyer_email = $payment_data['payer_email']; $txn_id = $payment_data['txn_id']; foreach ($cart_items as $current_cart_item) { $cart_item_number = $current_cart_item['item_number']; $total_item_price = $current_cart_item['mc_gross'] - $current_cart_item['mc_shipping']; $item_qty = $current_cart_item['quantity']; $retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$cart_item_number'", OBJECT); if(!empty($retrieved_product->author_id)) { //award commission for the author of this book eStore_payment_debug('Sharing Revenue.... Total Price of the currently processing item : '.$total_item_price,true); $referrer = $retrieved_product->author_id; $rev_share_commission = $retrieved_product->rev_share_commission; $sale_amount = $total_item_price; //The total item price includes the (individual item price * quantity) if(empty($rev_share_commission)){ eStore_payment_debug('Sharing Revenue with: '.$referrer,true); $result = wp_aff_award_commission($referrer,$sale_amount,$txn_id,$cart_item_number,$buyer_email); } else{ eStore_payment_debug('Sharing Revenue with: '.$referrer.' Commission Override Value: '.$rev_share_commission,true); eStore_payment_debug('WP Affiliate platform plugin version: '.WP_AFFILIATE_PLATFORM_VERSION,true); $result = wp_aff_award_commission($referrer,$sale_amount,$txn_id,$cart_item_number,$buyer_email,'',$rev_share_commission); } eStore_payment_debug(eStore_br2nl($result),true); } } } function eStore_handle_auto_affiliate_account_creation($payment_data) { if (function_exists('wp_aff_platform_install') || function_exists('wp_aff_create_affilate')) { eStore_payment_debug('Checking if auto affiliate account creation feature is active.',true); $create_auto_affiliate_account = get_option('eStore_create_auto_affiliate_account'); if($create_auto_affiliate_account) { eStore_payment_debug('Checking if an affiliate account already exists...',true); if(function_exists('wp_aff_check_if_account_exists')){ $account_exists = wp_aff_check_if_account_exists($payment_data['payer_email']); } else{ eStore_payment_debug('Error! You need to update the affiliate platform plugin to use the auto upgrade feature!',false); } if(!$account_exists) { $aff_id = uniqid(); $pwd = $aff_id;//use the affiliate ID as the password to create the account $commission_level = get_option('wp_aff_commission_level'); $date = (date ("Y-m-d")); eStore_payment_debug('Creating affiliate account with Affiliate ID:'.$aff_id,true); wp_aff_create_affilate($aff_id,$pwd,$payment_data['payer_business_name'],"",$payment_data['first_name'],$payment_data['last_name'],"",$payment_data['payer_email'],"","","","","",$payment_data['address_country'],"","",$date,$payment_data['payer_email'],$commission_level,""); wp_aff_send_sign_up_email($aff_id,$pwd,$payment_data['payer_email']); } else { eStore_payment_debug('Affiliate account already exists with this email address. No new account will be created.',true); } } } else { eStore_payment_debug('WP Affiliate Platform Plugin is not installed.',true); } } ?> // -- The Assurer, 2011-07-16. class eStore_aprtp { function shortcode_api($attributes, $content='') { // WordPress shortcode API. // This is the API for the [wp_eStore_APR] shortcode. // Usage: // [wp_eStore_APR expiry= status=] the_content [/wp_eStore_APR] // Notes: // [wp_eStore_APR status=help] will be replaced with the shortcode's help message. // -- The Assurer, 2011-07-18. // Parse attributes... extract(shortcode_atts(array( 'expiry' => 0, 'status' => 'unexpired'), $attributes)); if(!is_numeric($expiry)) return eStore_aprtp::man_page(); // $expiry must be a numeric value. switch($status) { case 'unexpired' : // APR is unexpired... if(eStore_aprtp::cookie_test($expiry)) return "$content"; else return ''; case 'expired' : // APR is expired... if(!eStore_aprtp::cookie_test($expiry)) return "$content"; else return ''; case 'help' : // Display help message. default : // Invalid $status value... return eStore_aprtp::man_page(); } } function cookie_set($cookie_name='APRcookie') { // Sets the APR cookie. // -- The Assurer, 2011-07-17. global $eStore_debug_manager; // Need access to debug manager. $random_key = get_option('eStore_random_code'); $cookie_time = (string)time(); $cookie_flavor = md5(RC4Crypt::encrypt($random_key, $cookie_name)); $cookie_dough = rawurlencode(base64_encode(RC4Crypt::encrypt($random_key, $cookie_time))); $cookie_doughmain = '.'.$_SERVER['SERVER_NAME']; if(setcookie($cookie_flavor, $cookie_dough, 0, '/', $cookie_doughmain)) $eStore_debug_manager->downloads("\$_COOKIE[$cookie_flavor] => $cookie_dough", ESTORE_LEVEL_SUCCESS); else $eStore_debug_manager->downloads("\$_COOKIE[$cookie_flavor] => $cookie_dough", ESTORE_LEVEL_FAILURE); return $retVal; } function cookie_test($cookie_timeout=0, $cookie_name='') { // Test for valid APR cookie. // Returns TRUE if a valid APR cookie, derived from $cookie_name exists. If $cookie_name is an empty string, then // $cookie_name will be assigned the URL of the current browser page. Returns FALSE if the named APR cookie does not // exist. If $cookie_timeout is greater than zero, then FALSE will be returned if the APR cookie is older than // $cookie_timeout minutes. // -- The Assurer, 2011-07-17. if($cookie_name == '') $cookie_name = eStore_aprtp::curPageURL(); // Use URL of current browser page. $random_key = get_option('eStore_random_code'); $cookie_flavor = md5(RC4Crypt::encrypt($random_key, $cookie_name)); // Derive the APR cookie name. if(!isset($_COOKIE["$cookie_flavor"])) return FALSE; // No cookie for you! if($cookie_timeout > 0) { // Test for age of APR cookie, if $cookie_timeout is at least 1 minute... $cookie_time = (int)RC4Crypt::decrypt($random_key, base64_decode(rawurldecode($_COOKIE[$cookie_flavor]))); $cookie_timeout = (int)(($cookie_timeout*60)+$cookie_time); if($cookie_timeout <= (int)time()) return FALSE; // APR cookie has expired. } return TRUE; } function curPageURL() { // Returns the URL of the current browser page. // -- The Assurer, 2011-07-17. $retVal = 'http'; // Default scheme is HTTP. if($_SERVER['HTTPS'] == 'on') {$retVal .= 's';} // Make HTTPS if necessary. $retVal .= '://'.$_SERVER['SERVER_NAME']; // Add server name. // This code is only here for hystorical purposes. Using it will break the shortcode. // if($_SERVER['SERVER_PORT'] != '80') // Test for default HTTP port number. // $retVal .= ':'.$_SERVER['SERVER_PORT']; // Specify port number if needed. $retVal .= $_SERVER['REQUEST_URI']; // Add resource path. return $retVal; } function generate_url_request($uri_in, &$url_out) { // If $uri_in is a valid Authenticated Page Redirect (APRTP) URI, $url_out is filled in with the HTTP, // or HTTPS, URL request for the page specified in the URI. // Returns -1 if $url_out is an authenticated URL request, or FALSE if a parsing or syntax error occurred. // -- The Assurer, 2011-07-16. if(!eStore_aprtp::uri_parse($uri_in, $scheme, $apr_resource)) // Parse the URI. return FALSE; // URI parsing error. $url_out = "$scheme://$apr_resource"; // Assemble the APR URL. eStore_aprtp::cookie_set($url_out); // Set page specific APR cookie. return -1; } function is_aprtp_scheme($uri_in) { // Returns TRUE if $uri_in is a qualified URI that matches the APRTP URL scheme. // To qualify, a URI must have "aprtp://" or "aprtps://" at the begining of the $uri_in string. // -- The Assurer, 2011-07-16. return (preg_match('/^aprtps?:\/\//i', $uri_in) == 1 ? TRUE : FALSE); } function man_page() { $retVal = '

Authenticated Page Redirect (APR)

APR allows WP eStore to use loadable (WordPress) browser pages (called "APR Targets"), instead of downloadable files, that contain protected content as digital products.  This is useful in cases where you want to grant secure, one-off, access to page content that would otherwise require the services of a membership plugin.  Before redirecting to an APR target, the WP eStore download manager issues an "APR Cookie" that is valid for the remainder of the current browser session.  Each APR cookie is uniquely keyed and encrypted to a specific APR target.  Using wp_eStore_APR shortcodes, APR targets can control the display of content; based upon the existence, non-existence, or age of APR cookies.

Usage:

     [[wp_eStore_APR expiry=minutes status=expiration-status] the_content [/wp_eStore_APR]]

Where:

  • minutes is a number, greater than zero, used to test the age in minutes of the APR cookie specific to the current browser page.  If minutes is less than or equal to zero, then only the existence of a page specific APR cookie will be tested.  The default value is: 0
  • expiration-status determines the condition under which the_content will be displayed.  If set to \'unexpired\' the_content will only be displayed if the page specific APR cookie exists, or if its age is less than the specified number of minutes.  If set to \'expired\' the_content will only be displayed if the page specific APR cookie is either missing or is older than the specified number of minutes.  The default value is: unexpired

Notes:

  • The shortcode [[wp_eStore_APR status=help]] will be replaced with this help message.
  • APR cookies are created by the WP eStore download manager, when it detects the URI of a digital product that has been specified using the APRTP scheme.  Under the APRTP scheme, the URI of a digital product "page" (instead of a file) is specified using the format scheme://domain/resource where scheme is either "aprtp" (for http) or "aprtps" (for https).
  • APR cookies are only valid on the first page of multi-page posts.  This is because the "nextpage" (WordPress) tag modifies the URL of second and subsequent pages, making them unrecognizable by the APR cookie testing code.

'; return $retVal; } function uri_parse($uri_in, &$scheme, &$apr_resource) { // Returns TRUE if $uri_in is a parsable APRTP URI. // A parsable URI is of the form described in RFC 3986: Scheme://Resource // Supported scheme names are: "aprtp" or "aprtps" // Resource identifies a loadable browser page. // If $uri_in is parsable, the following variables are filled in: // $scheme = Transliterated APRTP URI scheme that is supported: "aprtp" --> "http" or "aprtps" --> "https" // $apr_resource = The target browser page. // -- The Assurer, 2011-07-16. if(!eStore_aprtp::is_aprtp_scheme($uri_in)) return FALSE; // Qualify the scheme. // Parse the scheme and resource names... $uri_regex = '/^apr(.+):\/\/(.+)/i'; if(preg_match_all($uri_regex, $uri_in, $uri_matches) != 1) return FALSE; // Parse URI elements. $scheme = 'ht'.strtolower($uri_matches[1][0]); // URI scheme. $apr_resource = str_replace('%2F', '/', rawurlencode($uri_matches[2][0])); // Resource name. return TRUE; // No parsing errors occurred. } } ?> sessions | Red Deer Photographer ~ Maternity, Newborn and Baby Photography

Category Archives: sessions

More Mini Session Love ~ Red Deer Photographer

Well its crazy time for photographers right now. September and October for Alberta photographers is sort of like March and April for accountants. LOL. Here is another quick peek from a September Mini session. The light was so very wonderful for this family.

View full post »

Bring on the mini sessions! ~ Red Deer Photographer

and so we being the flood of fall family sessions! First up an awesome family that I have met via TWITTER! We had lots of giggles, and smiles as we enjoyed the wonderful warm sunshine during this session!

View full post »

Red Deer Newborn Photographer ~ Welcome Philip

Welcome to the world young Philip. Philip  means lover of horse. (Did you know that?) . yes strange that I do. Philip is the newest member of the 2012 Sprout Club. I can NOT wait to see this little man again in 6 or 7 months. His parents are some of the most fun and...

View full post »

Kelsey & Mike Get Married ~ Sept.8.2012

what a fun and crazy day we had with these two! I first met Kelsey with her wedding planner Jennie Lightle of Lucky Day Weddings I knew right off the bat that we would be an awesome fit! Kesley & Mike have been so patiently awaiting a few photos from their special day, so here...

View full post »

3 boys, 2 horses, grandparents and a full family session ~ Red_Deer_Photographer

one of the craziest sessions of 2012 so far! When I got the details of the GOALS for this session, I knew it would be crazy. 3 boys. 2 grand parents full family session and could we PLEASE add 2 horses??   The evening went off without a hitch. Yes there was some horse snot,...

View full post »

back to blogging! Red_Deer_Photographer

holy cow! its been forever! shame on ME! well hopefully I am back on the blog routine here, I have a lot of sessions over the past few months to play catch up on! Today’s featured session is a wonderful little newborn named Willow. I am so excited to have Willow join the sprout club...

Related Posts with Thumbnails

View full post »

!-- Start of HubSpot Logging Code -->
O u r   F a c e b o o k   P a g e
D e a n n a   o n   t w i t t e r

    Deanna on twitter