$item) { if(get_class($item) == "__PHP_Incomplete_Class") { $_SESSION['nzshpcrt_cart'] = unserialize($_SESSION['nzshpcrt_serialized_cart']); } } } else { if(isset($_SESSION['nzshpcrt_cart'])) { $_SESSION['nzshpcrt_cart'] = unserialize($_SESSION['nzshpcrt_serialized_cart']); } } if(is_numeric($_GET['sessionid'])) { $sessionid = $_GET['sessionid']; $cart_log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid`= ".$sessionid." LIMIT 1"); if(is_numeric($cart_log_id)) { $_SESSION['nzshpcrt_cart'] = null; $_SESSION['nzshpcrt_serialized_cart'] = null; } } $GLOBALS['nzshpcrt_imagesize_info'] = TXT_WPSC_IMAGESIZEINFO; $nzshpcrt_log_states[0]['name'] = TXT_WPSC_RECEIVED; $nzshpcrt_log_states[1]['name'] = TXT_WPSC_PROCESSING; $nzshpcrt_log_states[2]['name'] = TXT_WPSC_PROCESSED; function nzshpcrt_style() { global $wpdb,$wp_query; return; if(function_exists('xili_display4mobile')) { //check for the function before using it if (xili_display4mobile() === true) { // instead of wrapping the whole block of code in brackets, resulting in mysterious brackets, simply break out of the function here. return null; } } if(is_numeric($_GET['category']) || is_numeric($wp_query->query_vars['product_category']) || is_numeric(get_option('wpsc_default_category'))) { if(is_numeric($wp_query->query_vars['product_category'])) { $category_id = $wp_query->query_vars['product_category']; } else if(is_numeric($_GET['category'])) { $category_id = $_GET['category']; } else { $category_id = get_option('wpsc_default_category'); } } $category_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_CATEGORIES."` WHERE `id`='{$category_id}' LIMIT 1",ARRAY_A); if($category_data['display_type'] != '') { $display_type = $category_data['display_type']; } else { $display_type = get_option('product_view'); } ?> ' rel="stylesheet" type="text/css" /> '.print_r($_SERVER, true).''); if($_SERVER['REQUEST_URI'] == ''){ $site_request_uri = $_SERVER['ORIG_PATH_INFO'].$_SERVER['QUERY_STRING']; }else{ $site_request_uri = $_SERVER['REQUEST_URI']; } if((strpos($_SERVER['REQUEST_URI'], WPSC_DIR_NAME) !== false) || ($_GET['mass_upload'] == 'true') || ((strpos($_SERVER['REQUEST_URI'], 'wp-admin/admin.php') !== false) && !isset($_GET['page']))) { if(function_exists('add_object_page')) { echo ""; } else { echo ""; } ?> product_id; // if is an AJAX request, cruddy code, could be done better but getting approval would be impossible if(($_POST['ajax'] == "true") || ($_GET['ajax'] == "true")) { if ($_POST['metabox'] == 'true') { $output .= "
"; exit($output); } if ($_POST['submittogoogle']) { $newvalue=$_POST['value']; $amount=$_POST['amount']; $reason=$_POST['reason']; $comment=$_POST['comment']; $message=$_POST['message']; $amount=number_format($amount, 2, '.', ''); $log_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '".$_POST['id']."' LIMIT 1",ARRAY_A); if (($newvalue==2) && function_exists('wpsc_member_activate_subscriptions')){ wpsc_member_activate_subscriptions($_POST['id']); } $google_status = unserialize($log_data['google_status']); switch($newvalue) { case "Charge": if ($google_status[0]!='CANCELLED_BY_GOOGLE') { if ($amount=='') { $google_status['0']='Partially Charged'; } else { $google_status['0']='CHARGED'; $google_status['partial_charge_amount']=$amount; } } break; case "Cancel": if ($google_status[0]!='CANCELLED_BY_GOOGLE') $google_status[0]='CANCELLED'; if ($google_status[1]!='DELIVERED') $google_status[1]='WILL_NOT_DELIVER'; break; case "Refund": if ($amount=='') { $google_status['0']='Partially Refund'; } else { $google_status['0']='REFUND'; $google_status['partial_refund_amount']=$amount; } break; case "Ship": if ($google_status[1]!='WILL_NOT_DELIVER') $google_status[1]='DELIVERED'; break; case "Archive": $google_status[1]='ARCHIVED'; break; } $google_status_sql="UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET google_status='".serialize($google_status)."' WHERE `id` = '".$_POST['id']."' LIMIT 1"; $wpdb->query($google_status_sql); $merchant_id = get_option('google_id'); $merchant_key = get_option('google_key'); $server_type = get_option('google_server_type'); $currency = get_option('google_cur'); $Grequest = new GoogleRequest($merchant_id, $merchant_key, $server_type,$currency); $google_order_number=$wpdb->get_var("SELECT google_order_number FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `id` = '".$_POST['id']."' LIMIT 1"); switch ($newvalue) { case 'Charge': $Grequest->SendChargeOrder($google_order_number,$amount); break; case 'Ship': $Grequest->SendDeliverOrder($google_order_number); break; case 'Archive': $Grequest->SendArchiveOrder($google_order_number); break; case 'Refund': $Grequest->SendRefundOrder($google_order_number,$amount,$reason); break; case 'Cancel': $Grequest->SendCancelOrder($google_order_number,$reason,$comment); break; case 'Send Message': $Grequest->SendBuyerMessage($google_order_number,$message); break; } $newvalue++; $update_sql = "UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '".$newvalue."' WHERE `id` = '".$_POST['id']."' LIMIT 1"; //$wpdb->query($update_sql); exit(); } /* if(($_GET['user'] == "true") && is_numeric($_POST['prodid'])) { if(function_exists('wpsc_members_init')) { $memberstatus = get_product_meta($_POST['prodid'],'is_membership',true); } if(($memberstatus=='1') && ($_SESSION['nzshopcrt_cart']!=NULL)){ } else{ $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$_POST['prodid']."' LIMIT 1"; $item_data = $wpdb->get_results($sql,ARRAY_A); if ($_POST['quantity']!='') { $add_quantity = $_POST['quantity']; } $item_quantity = 0; if($_SESSION['nzshpcrt_cart'] != null) { foreach($_SESSION['nzshpcrt_cart'] as $cart_key => $cart_item) { if (($memberstatus[0]!='1')&&($_SESSION['nzshpcrt_cart']!=NULL)){ if($cart_item->product_id == $_POST['prodid']) { if(($_SESSION['nzshpcrt_cart'][$cart_key]->product_variations === $_POST['variation'])&&($_SESSION['nzshpcrt_cart'][$cart_key]->extras === $_POST['extras'])) { $item_quantity += $_SESSION['nzshpcrt_cart'][$cart_key]->quantity; $item_variations = $_SESSION['nzshpcrt_cart'][$cart_key]->product_variations; } } } } } $item_stock = null; $variation_count = count($_POST['variation']); if($variation_count >= 1) { foreach($_POST['variation'] as $value_id) { if(is_numeric($value_id)) { $value_ids[] = (int)$value_id; } } if(count($value_ids) > 0) { $variation_ids = $wpdb->get_col("SELECT `variation_id` FROM `".WPSC_TABLE_VARIATION_VALUES."` WHERE `id` IN ('".implode("','",$value_ids)."')"); asort($variation_ids); $all_variation_ids = implode(",", $variation_ids); $priceandstock_id = $wpdb->get_var("SELECT `priceandstock_id` FROM `".WPSC_TABLE_VARIATION_COMBINATIONS."` WHERE `product_id` = '".(int)$_POST['prodid']."' AND `value_id` IN ( '".implode("', '",$value_ids )."' ) AND `all_variation_ids` IN('$all_variation_ids') GROUP BY `priceandstock_id` HAVING COUNT( `priceandstock_id` ) = '".count($value_ids)."' LIMIT 1"); $variation_stock_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_VARIATION_PROPERTIES."` WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A); $item_stock = $variation_stock_data['stock']; } } if($item_stock === null) { $item_stock = $item_data[0]['quantity']; } if((($item_data[0]['quantity_limited'] == 1) && ($item_stock > 0) && ($item_stock > $item_quantity)) || ($item_data[0]['quantity_limited'] == 0)) { $cartcount = count($_SESSION['nzshpcrt_cart']); if(is_array($_POST['variation'])) { $variations = $_POST['variation']; } else { $variations = null; } //if(is_array($_POST['extras'])) { $extras = $_POST['extras']; } else { $extras = null; } $updated_quantity = false; if($_SESSION['nzshpcrt_cart'] != null) { foreach($_SESSION['nzshpcrt_cart'] as $cart_key => $cart_item) { if ((!($memberstatus[0]=='1')&&(count($_SESSION['nzshpcrt_cart'])>0))) { if((int)$cart_item->product_id === (int)$_POST['prodid']) { // force both to integer before testing for identicality if(($_SESSION['nzshpcrt_cart'][$cart_key]->extras === $extras)&&($_SESSION['nzshpcrt_cart'][$cart_key]->product_variations === $variations) && ((int)$_SESSION['nzshpcrt_cart'][$cart_key]->donation_price == (int)$_POST['donation_price'])) { if ($_POST['quantity'] != ''){ if(is_array($_POST['quantity'])) { foreach ((array)$_POST['quantity'] as $qty) { $_SESSION['nzshpcrt_cart'][$cart_key]->quantity += (int)$qty; } } else { $_SESSION['nzshpcrt_cart'][$cart_key]->quantity += (int)$_POST['quantity']; } } else { $_SESSION['nzshpcrt_cart'][$cart_key]->quantity++; } $_SESSION['nzshpcrt_cart'][$cart_key]->comment = $_POST['comment']; foreach((array)$_POST['label'] as $key => $label) { if ($label != '') { if (array_key_exists($label, $_SESSION['nzshpcrt_cart'][$cart_key]->meta)) { $_SESSION['nzshpcrt_cart'][$cart_key]->meta[$label]+=(int)$_POST['quantity'][$key]; $_SESSION['nzshpcrt_cart'][$cart_key]->time_requested[$label] = $_POST['time_requested'][$key]; } else { $_SESSION['nzshpcrt_cart'][$cart_key]->meta[$label] = $_POST['quantity'][$key]; $_SESSION['nzshpcrt_cart'][$cart_key]->time_requested[$label] = $_POST['time_requested'][$key]; } } } $updated_quantity = true; } } } } } if($item_data[0]['donation'] == 1) { $donation = $_POST['donation_price']; } else { $donation = false; } if(!(($memberstatus=='1')&&(count($_SESSION['nzshpcrt_cart'])>0))){ $status = get_product_meta($cartt1, 'is_membership', true); if (function_exists('wpsc_members_init') && ( $status=='1')){ exit(); } $parameters = array(); if($updated_quantity === false) { $parameters['variation_values'] = $variations; $parameters['provided_price'] = $donation; $parameters['meta']=null; if($_POST['quantity'] != '') { $total_qty = 0; foreach ($_POST['quantity'] as $key=>$qty) { $total_qty+=$qty; $label[$_POST['label'][$key]] = $qty; $time_requested[$_POST['label'][$key]] = $_POST['time_requested'][$key]; } $parameters['quantity'] = $total_qty; //$new_cart_item = new wpsc_cart_item($_POST['prodid'],$variations,$total_qty, $donation,$_POST['comment'],$time_requested,$label); } else { $parameters['quantity'] = 1; } //mail('tom@instinct.co.nz', 'stuff', print_r($parameters,true)); $new_cart_item = new wpsc_cart_item($_POST['prodid'],$parameters); $_SESSION['nzshpcrt_cart'][] = $new_cart_item; } } } else { $quantity_limit = true; } $cart = $_SESSION['nzshpcrt_cart']; if (($memberstatus[0]=='1')&&(count($cart)>1)) { } else { $status = get_product_meta($cartt1, 'is_membership', true); if (function_exists('wpsc_members_init') && ( $status=='1')){ exit('st'); } //require_once(WPSC_FILE_PATH."/shopping_cart_functions.php"); echo "if(document.getElementById('shoppingcartcontents') != null) { document.getElementById('shoppingcartcontents').innerHTML = \"".str_replace(Array("\n","\r") , "",addslashes(nzshpcrt_shopping_basket_internals($cart,$quantity_limit))). "\"; } "; if($_SESSION['slider_state'] == 0) { //echo 'jQuery("#sliding_cart").css({ display: "none"});'."\n\r"; } else { //echo 'jQuery("#sliding_cart").css({ display: "block"});'."\n\r"; } } } exit(); } else if(($_POST['user'] == "true") && ($_POST['emptycart'] == "true")) { $_SESSION['nzshpcrt_cart'] = ''; $_SESSION['nzshpcrt_cart'] = Array(); echo "if(document.getElementById('shoppingcartcontents') != null) { document.getElementById('shoppingcartcontents').innerHTML = \"".str_replace(Array("\n","\r") , "", addslashes(nzshpcrt_shopping_basket_internals($cart))). "\"; }\n\r"; if($_POST['current_page'] == get_option('shopping_cart_url')) { echo "window.location = '".get_option('shopping_cart_url')."';\n\r"; // if we are on the checkout page, redirect back to it to clear the non-ajax cart too } exit(); }*/ if ($_POST['store_list']=="true") { $map_data['address'] = $_POST['addr']; $map_data['city'] = $_POST['city']; $map_data['country'] = 'US'; $map_data['zipcode']=''; $map_data['radius'] = '50000'; $map_data['state'] = ''; $map_data['submit'] = 'Find Store'; $stores = getdistance($map_data); $i=0; while($rows = mysql_fetch_array($stores)) { //echo "".print_r($rows,1).""; if ($i==0) { $closest_store = $rows[5]; } $i++; $store_list[$i] = $rows[5]; } foreach ($store_list as $store){ $output.=""; } echo $output; exit(); } if(is_numeric($_POST['currencyid'])){ $currency_data = $wpdb->get_results("SELECT `symbol`,`symbol_html`,`code` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$_POST['currencyid']."' LIMIT 1",ARRAY_A) ; $price_out = null; if($currency_data[0]['symbol'] != '') { $currency_sign = $currency_data[0]['symbol_html']; } else { $currency_sign = $currency_data[0]['code']; } echo $currency_sign; exit(); } if($_POST['buynow'] == "true") { if(is_numeric($_REQUEST['product_id']) && is_numeric($_REQUEST['price'])) { $id = $wpdb->escape((int)$_REQUEST['product_id']); $price = $wpdb->escape((float)$_REQUEST['price']); $downloads = get_option('max_downloads'); $product_info = $wpdb->get_row("SELECT * FROM ".WPSC_TABLE_PRODUCT_LIST." WHERE id = ".$id." LIMIT 1", ARRAY_A); if(count($product_info) > 0) { $sessionid = (mt_rand(100,999).time()); $sql = "INSERT INTO `".WPSC_TABLE_PURCHASE_LOGS."` ( `totalprice` , `sessionid` , `date`, `billing_country`, `shipping_country`,`shipping_region`, `user_ID`, `discount_value` ) VALUES ( '".$price."', '".$sessionid."', '".time()."', 'BuyNow', 'BuyNow', 'BuyNow' , NULL , 0)"; $wpdb->query($sql) ; $log_id = $wpdb->get_var("SELECT `id` FROM `".WPSC_TABLE_PURCHASE_LOGS."` WHERE `sessionid` IN('".$sessionid."') LIMIT 1") ; $cartsql = "INSERT INTO `".WPSC_TABLE_CART_CONTENTS."` ( `prodid` , `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `donation`, `no_shipping` ) VALUES ('".$id."', '".$log_id."','".$price."','0', '0','1', '".$donation."', '1')"; $wpdb->query($cartsql); $wpdb->query("INSERT INTO `".WPSC_TABLE_DOWNLOAD_STATUS."` ( `fileid` , `purchid` , `downloads` , `active` , `datetime` ) VALUES ( '".$product_info['file']."', '".$log_id."', '$downloads', '0', NOW( ));"); } } exit(); } /* rate item */ if(($_POST['rate_item'] == "true") && is_numeric($_POST['product_id']) && is_numeric($_POST['rating'])) { $nowtime = time(); $prodid = $_POST['product_id']; $ip_number = $_SERVER['REMOTE_ADDR']; $rating = $_POST['rating']; $cookie_data = explode(",",$_COOKIE['voting_cookie'][$prodid]); if(is_numeric($cookie_data[0]) && ($cookie_data[0] > 0)) { $vote_id = $cookie_data[0]; $wpdb->query("UPDATE `".WPSC_TABLE_PRODUCT_RATING."` SET `rated` = '".$rating."' WHERE `id` ='".$vote_id."' LIMIT 1 ;"); } else { $insert_sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_RATING."` ( `ipnum` , `productid` , `rated`, `time`) VALUES ( '".$ip_number."', '".$prodid."', '".$rating."', '".$nowtime."');"; $wpdb->query($insert_sql); $data = $wpdb->get_results("SELECT `id`,`rated` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `ipnum`='".$ip_number."' AND `productid` = '".$prodid."' AND `rated` = '".$rating."' AND `time` = '".$nowtime."' ORDER BY `id` DESC LIMIT 1",ARRAY_A) ; $vote_id = $data[0]['id']; setcookie("voting_cookie[$prodid]", ($vote_id.",".$rating),time()+(60*60*24*360)); } $output[1]= $prodid; $output[2]= $rating; echo $output[1].",".$output[2]; exit(); } //written by allen if ($_REQUEST['save_tracking_id'] == "true"){ $id = $_POST['id']; $value = $_POST['value']; $update_sql = "UPDATE ".WPSC_TABLE_PURCHASE_LOGS." SET track_id = '".$value."' WHERE id=$id"; $wpdb->query($update_sql); exit(); } if(($_POST['get_updated_price'] == "true") && is_numeric($_POST['product_id'])) { $notax = $wpdb->get_var("SELECT `notax` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` IN('".$_POST['product_id']."') LIMIT 1"); foreach((array)$_POST['variation'] as $variation) { if(is_numeric($variation)) { $variations[] = (int)$variation; } } $pm=$_POST['pm']; echo "product_id=".(int)$_POST['product_id'].";\n"; echo "price=\"".nzshpcrt_currency_display(calculate_product_price((int)$_POST['product_id'], $variations,'stay',$extras), $notax, true)."\";\n"; echo "numeric_price=\"".number_format(calculate_product_price((int)$_POST['product_id'], $variations,'stay',$extras), 2)."\";\n"; //exit(print_r($extras,1)); exit(" "); } // if(($_POST['redisplay_variation_values'] == "true")) { // $variation_processor = new nzshpcrt_variations(); // $variations_selected = array_values(array_unique(array_merge((array)$_POST['new_variation_id'], (array)$_POST['variation_id']))); // foreach($variations_selected as $variation_id) { // // cast everything to integer to make sure nothing nasty gets in. // $variation_list[] = (int)$variation_id; // } // echo $variation_processor->variations_add_grid_view((array)$variation_list); // //echo "/*\n\r".print_r(array_values(array_unique($_POST['variation_id'])),true)."\n\r*/"; // exit(); // } // /* * function for handling the checkout billing address */ if(preg_match("/[a-zA-Z]{2,4}/", $_POST['billing_country'])) { if($_SESSION['selected_country'] == $_POST['billing_country']) { $do_not_refresh_regions = true; } else { $do_not_refresh_regions = false; $_SESSION['selected_country'] = $_POST['billing_country']; } if(is_numeric($_POST['form_id'])) { $form_id = $_POST['form_id']; $html_form_id = "region_country_form_$form_id"; } else { $html_form_id = 'region_country_form'; } if(is_numeric($_POST['billing_region'])) { $_SESSION['selected_region'] = $_POST['billing_region']; } $cart =& $_SESSION['nzshpcrt_cart']; if (($memberstatus[0]=='1')&&(count($cart)>0)){ echo "\n\r"; } else { if ($status[0]=='1'){ exit(); } echo "if(document.getElementById('shoppingcartcontents') != null) { document.getElementById('shoppingcartcontents').innerHTML = \"".str_replace(Array("\n","\r") , "",addslashes(nzshpcrt_shopping_basket_internals($cart,$quantity_limit))). "\"; }\n\r"; if($do_not_refresh_regions == false) { $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".$_POST['billing_country']."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ; if($region_list != null) { $output .= ""; echo "if(document.getElementById('region_select_$form_id') != null) { document.getElementById('region_select_$form_id').innerHTML = \"".$output."\"; }\n\r"; } else { echo "if(document.getElementById('region_select_$form_id') != null) { document.getElementById('region_select_$form_id').innerHTML = \"\"; }\n\r"; } } } if ($_POST['changetax'] == "true") { if (isset($_POST['billing_region'])){ $billing_region=$_POST['billing_region']; } else { $billing_region=$_SESSION['selected_region']; } $billing_country=$_POST['billing_country']; $price = 0; $tax = 0; foreach((array)$cart as $cart_item) { $product_id = $cart_item->product_id; $quantity = $cart_item->quantity; //echo("
".print_r($cart_item->product_variations,true).""); $product = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1",ARRAY_A); if($product['donation'] == 1) { $price += $quantity * $cart_item->donation_price; } else { $product_price = $quantity * calculate_product_price($product_id, $cart_item->product_variations); if($product['notax'] != 1) { $tax += nzshpcrt_calculate_tax($product_price, $billing_country, $billing_region) - $product_price; } $price += $product_price; $all_donations = false; } if($_SESSION['delivery_country'] != null) { $total_shipping += nzshpcrt_determine_item_shipping($product['id'], $quantity, $_SESSION['delivery_country']); } } $total_shipping += nzshpcrt_determine_base_shipping(0, $_SESSION['delivery_country']); $total = number_format(($tax+$price+$total_shipping), 2); if($tax > 0) { echo "jQuery(\"tr.total_tax td\").show();\n\r"; } else { echo "jQuery(\"tr.total_tax td\").hide();\n\r"; } $tax = number_format($tax,2); echo "jQuery('#checkout_tax').html(\"\${$tax}\");\n\r"; echo "jQuery('#checkout_total').html(\"\${$total}\");\n\r"; } exit(); } if(($_POST['get_country_tax'] == "true") && preg_match("/[a-zA-Z]{2,4}/",$_POST['country_id'])) { $country_id = $_POST['country_id']; $region_list = $wpdb->get_results("SELECT `".WPSC_TABLE_REGION_TAX."`.* FROM `".WPSC_TABLE_REGION_TAX."`, `".WPSC_TABLE_CURRENCY_LIST."` WHERE `".WPSC_TABLE_CURRENCY_LIST."`.`isocode` IN('".$country_id."') AND `".WPSC_TABLE_CURRENCY_LIST."`.`id` = `".WPSC_TABLE_REGION_TAX."`.`country_id`",ARRAY_A) ; if($region_list != null) { echo "\n\r"; } else { echo " "; } exit(); } /* fill product form */ if(($_POST['set_slider'] == "true") && is_numeric($_POST['state'])) { $_SESSION['slider_state'] = $_POST['state']; exit(); } /* fill category form */ if($_GET['action'] == "register") { $siteurl = get_option('siteurl'); require_once( ABSPATH . WPINC . '/registration-functions.php'); if(($_POST['action']=='register') && get_settings('users_can_register')) { //exit("fail for testing purposes"); $user_login = sanitize_user( $_POST['user_login'] ); $user_email = $_POST['user_email']; $errors = array(); if ( $user_login == '' ) exit($errors['user_login'] = __('ERROR: Please enter a username.')); /* checking e-mail address */ if ($user_email == '') { exit(__('ERROR: Please type your e-mail address.')); } else if (!is_email($user_email)) { exit( __('ERROR: The email address isn’t correct.')); $user_email = ''; } if ( ! validate_username($user_login) ) { $errors['user_login'] = __('ERROR: This username is invalid. Please enter a valid username.'); $user_login = ''; } if ( username_exists( $user_login ) ) exit( __('ERROR: This username is already registered, please choose another one.')); /* checking the email isn't already used by another user */ $email_exists = $wpdb->get_row("SELECT user_email FROM $wpdb->users WHERE user_email = '$user_email'"); if ( $email_exists) die (__('ERROR: This email address is already registered, please supply another.')); if ( 0 == count($errors) ) { $password = substr( md5( uniqid( microtime() ) ), 0, 7); //xit('there?'); $user_id = wp_create_user( $user_login, $password, $user_email ); if ( !$user_id ) { exit(sprintf(__('ERROR: Couldn’t register you... please contact the webmaster !'), get_settings('admin_email'))); } else { wp_new_user_notification($user_id, $password); ?>
" . wp_specialchars($user_login) . "") ?>
' . __('emailed to you') . '') ?>
" . wp_specialchars($user_email) . "") ?>
".print_r($download_data,true).""); if($download_data != null) { if($download_data['product_id'] > 0) { $product_file_id = $wpdb->get_var("SELECT `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$download_data['product_id']."' LIMIT 1"); $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_file_id."' LIMIT 1", ARRAY_A); } else { $old_file_data = $wpdb->get_row("SELECT `product_id` FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$download_data['fileid']."' LIMIT 1", ARRAY_A); $product_file_id = $wpdb->get_var("SELECT `file` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='".$old_file_data['product_id']."' LIMIT 1"); $file_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_file_id."' LIMIT 1", ARRAY_A); } if((int)$download_data['downloads'] >= 1) { $download_count = (int)$download_data['downloads'] - 1; } else { $download_count = 0; } $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `downloads` = '{$download_count}' WHERE `id` = '{$download_data['id']}' LIMIT 1"); $cart_contents = $wpdb->get_results('SELECT `'.WPSC_TABLE_CART_CONTENTS.'`.*,`'.WPSC_TABLE_PRODUCT_LIST.'`.`file` FROM `'.WPSC_TABLE_CART_CONTENTS.'` LEFT JOIN `'.WPSC_TABLE_PRODUCT_LIST.'` ON `'.WPSC_TABLE_CART_CONTENTS.'`.`prodid`= `'.WPSC_TABLE_PRODUCT_LIST.'`.`id` WHERE `purchaseid` ='.$download_data['purchid'], ARRAY_A); $dl = 0; foreach($cart_contents as $cart_content){ if($cart_content['file'] == 1){ $dl++; } } if(count($cart_contents) == $dl){ // exit('called'); $wpdb->query("UPDATE `".WPSC_TABLE_PURCHASE_LOGS."` SET `processed` = '4' WHERE `id` = '".$download_data['purchid']."' LIMIT 1"); } //exit('
'.print_r($cart_contents,true).''); if(is_file(WPSC_FILE_DIR.$file_data['idhash'])) { header('Content-Type: '.$file_data['mimetype']); header('Content-Length: '.filesize(WPSC_FILE_DIR.$file_data['idhash'])); header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="'.stripslashes($file_data['filename']).'"'); if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) { /* There is a bug in how IE handles downloads from servers using HTTPS, this is part of the fix, you may also need: session_cache_limiter('public'); session_cache_expire(30); At the start of your index.php file or before the session is started */ header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); } else { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); } $filename = WPSC_FILE_DIR.$file_data['idhash']; // destroy the session to allow the file to be downloaded on some buggy browsers and webservers session_destroy(); readfile_chunked($filename); exit(); } } else { exit(WPSC_DOWNLOAD_INVALID); } } else { if(($_GET['admin_preview'] == "true") && is_numeric($_GET['product_id']) && current_user_can('edit_plugins')) { $product_id = $_GET['product_id']; $product_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id` = '$product_id' LIMIT 1",ARRAY_A); if(is_numeric($product_data[0]['file']) && ($product_data[0]['file'] > 0)) { $file_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_FILES."` WHERE `id`='".$product_data[0]['file']."' LIMIT 1",ARRAY_A) ; $file_data = $file_data[0]; if(is_file(WPSC_FILE_DIR.$file_data['idhash'])) { header('Content-Type: '.$file_data['mimetype']); header('Content-Length: '.filesize(WPSC_FILE_DIR.$file_data['idhash'])); header('Content-Transfer-Encoding: binary'); if($_GET['preview_track'] != 'true') { header('Content-Disposition: attachment; filename="'.$file_data['filename'].'"'); } else { header('Content-Disposition: inline; filename="'.$file_data['filename'].'"'); } if(isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != '')) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); } else { header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); } $filename = WPSC_FILE_DIR.$file_data['idhash']; session_destroy(); readfile_chunked($filename); exit(); } } } } } function nzshpcrt_product_rating($prodid) { global $wpdb; $get_average = $wpdb->get_results("SELECT AVG(`rated`) AS `average`, COUNT(*) AS `count` FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `productid`='".$prodid."'",ARRAY_A); $average = floor($get_average[0]['average']); $count = $get_average[0]['count']; $output .= " "; for($l=1; $l<=$average; ++$l) { $output .= ""; } $remainder = 5 - $average; for($l=1; $l<=$remainder; ++$l) { $output .= ""; } $output .= " (".$count.") \r\n"; $output .= " \r\n"; return $output; } // this appears to have some star rating code in it function nzshpcrt_product_vote($prodid, $starcontainer_attributes = '') { global $wpdb; $output = null; $useragent = $_SERVER['HTTP_USER_AGENT']; $visibility = "style='display: none;'"; preg_match("/(?<=Mozilla\/)[\d]*\.[\d]*/", $useragent,$rawmozversion ); $mozversion = $rawmozversion[0]; if(stristr($useragent,"opera")) { $firstregexp = "Opera[\s\/]{1}\d\.[\d]+"; } else { $firstregexp = "MSIE\s\d\.\d"; } preg_match("/$firstregexp|Firefox\/\d\.\d\.\d|Netscape\/\d\.\d\.\d|Safari\/[\d\.]+/", $useragent,$rawbrowserinfo); $browserinfo = preg_split("/[\/\s]{1}/",$rawbrowserinfo[0]); $browsername = $browserinfo[0]; $browserversion = $browserinfo[1]; //exit($browsername . " " . $browserversion); if(($browsername == 'MSIE') && ($browserversion < 7.0)) { $starimg = ''. get_option('siteurl').'/wp-content/plugins/'.WPSC_DIR_NAME.'/images/star.gif'; $ie_javascript_hack = "onmouseover='ie_rating_rollover(this.id,1)' onmouseout='ie_rating_rollover(this.id,0)'"; } else { $starimg = ''. get_option('siteurl').'/wp-content/plugins/'.WPSC_DIR_NAME.'/images/24bit-star.png'; $ie_javascript_hack = ''; } $cookie_data = explode(",",$_COOKIE['voting_cookie'][$prodid]); if(is_numeric($cookie_data[0])) { $vote_id = $cookie_data[0]; } $chkrate = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_PRODUCT_RATING."` WHERE `id`='".$vote_id."' LIMIT 1",ARRAY_A); //$output .= "
".print_r($chkrate,true).""; if($chkrate[0]['rated'] > 0) { $rating = $chkrate[0]['rated']; $type = 'voted'; } else { $rating = 0; $type = 'voting'; } //$output .= "
".print_r($rating,true).""; $output .= "
".$votestr."
$voted
$othervotes
".TXT_WPSC_NO_DEFAULT_PRODUCTS."
"; echo "".print_r($option->response[ $this_plugin ],true).""; if( isset($option->response[ $this_plugin ]) ) { $option->response[ $this_plugin ]->package = ''; } return $option; } */ // if(get_option('cat_brand_loc') != 0) { // add_action('wp_list_pages', 'show_cats_brands'); // } // }.pe add_action('plugins_loaded', 'widget_wp_shopping_cart_init', 10); // refresh page urls when permalinks are turned on or altered add_filter('mod_rewrite_rules', 'wpsc_refresh_page_urls'); // refresh the page URL's when permalinks are turned off // the plugin hook used just above doesnt run when they are turned off // if(stristr($_POST['_wp_http_referer'], 'options-permalink.php')) { // add_filter('admin_head', 'wpsc_refresh_page_urls'); // } if(strpos($_SERVER['SCRIPT_NAME'], "wp-admin") === false) { //wp_enqueue_script( 'jQuery', WPSC_URL.'/js/jquery.js', false, '1.2.3'); //wp_enqueue_script('ngg-thickbox',WPSC_URL.'/js/thickbox.js', 'jQuery', 'Instinct_e-commerce'); } else { //wp_enqueue_script('thickbox'); if(function_exists('wp_enqueue_style')) { // DO NOT ALTER THIS!! This function is not present on older versions of wordpress // wp_enqueue_style( 'thickbox' ); } // wp_enqueue_script('jEditable',WPSC_URL.'/js/jquery.jeditable.pack.js', array('jquery'), '2.7.4'); } if(strpos($_SERVER['REQUEST_URI'], WPSC_DIR_NAME.'') !== false) { if($_GET['page'] == 'wpsc-edit-products') { } } switch(get_option('cart_location')) { case 1: add_action('wp_list_pages','nzshpcrt_shopping_basket'); break; case 2: add_action('the_content', 'nzshpcrt_shopping_basket' , 14); break; case 4: break; case 5: break; case 3: //add_action('the_content', 'nzshpcrt_shopping_basket'); // break; default: add_action('the_content', 'nzshpcrt_shopping_basket', 14); break; } function thickbox_variation() { global $wpdb, $wpsc_siteurl; $variations_processor = new nzshpcrt_variations; echo ""; echo " "; echo ""; echo " "; echo ""; echo ""; echo ""; echo ""; echo ""; if($_POST){ if($_POST['submit_action'] == "add") { //exit("
".print_r($_POST,true).""); $variation_sql = "INSERT INTO `".WPSC_TABLE_PRODUCT_VARIATIONS."` (`name`, `variation_association`) VALUES ( '".$_POST['name']."', 0);"; if($wpdb->query($variation_sql)) { $variation_id = $wpdb->get_results("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_PRODUCT_VARIATIONS."` LIMIT 1",ARRAY_A); $variation_id = $variation_id[0]['id']; $variation_values = $_POST['variation_values']; $variation_value_sql ="INSERT INTO `".WPSC_TABLE_VARIATION_VALUES."` ( `name` , `variation_id` ) VALUES "; $num = 0; foreach($variation_values as $variation_value) { switch($num) { case 0: $comma = ''; break; default: $comma = ', '; break; } $variation_value_sql .= "$comma( '".$wpdb->escape(trim($variation_value))."', '".$variation_id."')"; $num++; } $variation_value_sql .= ";"; $wpdb->query($variation_value_sql); echo ""; echo " "; echo ""; echo "
".TXT_WPSC_ITEMHASBEENADDED."
".TXT_WPSC_ITEMHASNOTBEENADDED."
\n\r";
echo " ";
echo " ";
?>
\n\r";
echo " ".TXT_WPSC_EDITVARIATION."\n\r";
echo " \n\r";
echo "";
echo " |