Example #1
0
 //           echo " <td>";
 //           echo $collected_data['value'];
 //           echo " </td>\n\r";
 //           }
 echo " <td>";
 if ($purchase['shipping_country'] != '') {
     $billing_country = $purchase['billing_country'];
     $shipping_country = $purchase['shipping_country'];
 } else {
     $country_sql = "SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1";
     $country_data = $wpdb->get_results($country_sql, ARRAY_A);
     $billing_country = $country_data[0]['value'];
     $shipping_country = $country_data[0]['value'];
 }
 echo nzshpcrt_currency_display(nzshpcrt_find_total_price($purchase['id'], $shipping_country), 1);
 $subtotal += nzshpcrt_find_total_price($purchase['id'], $shipping_country);
 echo " </td>\n\r";
 if (get_option('payment_method') == 2) {
     echo " <td>";
     $gateway_name = '';
     foreach ((array) $GLOBALS['nzshpcrt_gateways'] as $gateway) {
         if ($purchase['gateway'] != 'testmode') {
             if ($gateway['internalname'] == $purchase['gateway']) {
                 $gateway_name = $gateway['name'];
             }
         } else {
             $gateway_name = "Manual Payment";
         }
     }
     echo $gateway_name;
     echo " </td>\n\r";
Example #2
0
function admin_display_total_price($start_timestamp = '', $end_timestamp = '')
{
    global $wpdb;
    if ($start_timestamp != '' && $end_timestamp != '') {
        $sql = "SELECT * FROM `" . $wpdb->prefix . "purchase_logs` WHERE `processed` > '1' AND `date` BETWEEN '{$start_timestamp}' AND '{$end_timestamp}' ORDER BY `date` DESC";
    } else {
        $sql = "SELECT * FROM `" . $wpdb->prefix . "purchase_logs` WHERE `processed` > '1' AND `date` != ''";
    }
    $purchase_log = $wpdb->get_results($sql, ARRAY_A);
    $total = 0;
    if ($purchase_log != null) {
        foreach ($purchase_log as $purchase) {
            $country_sql = "SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1";
            $country_data = $wpdb->get_results($country_sql, ARRAY_A);
            $country = $country_data[0]['value'];
            $total += nzshpcrt_find_total_price($purchase['id'], $country);
        }
    }
    return $total;
}
Example #3
0
function nzshpcrt_submit_ajax()
{
    global $wpdb, $user_level, $wp_rewrite;
    get_currentuserinfo();
    if (get_option('permalink_structure') != '') {
        $seperator = "?";
    } else {
        $seperator = "&";
    }
    /* update shopping cart*/
    if (isset($_GET['ajax']) and $_GET['ajax'] == "true" && $_GET['user'] == "true" && is_numeric($_POST['prodid'])) {
        $sql = "SELECT * FROM `wp_product_list` WHERE `id`='" . $_POST['prodid'] . "' LIMIT 1";
        $item_data = $wpdb->get_results($sql, ARRAY_A);
        $item_quantity = 0;
        if (isset($_SESSION['nzshpcrt_cart']) and $_SESSION['nzshpcrt_cart'] != null) {
            foreach ($_SESSION['nzshpcrt_cart'] as $cart_key => $cart_item) {
                if ($cart_item->product_id == $_POST['prodid']) {
                    $item_quantity += $_SESSION['nzshpcrt_cart'][$cart_key]->quantity;
                } else {
                    $item_quantity += 0;
                }
            }
        } else {
            // set new session for cart
            $_SESSION['nzshpcrt_cart'] = array();
        }
        if (isset($_SESSION['nzshpcrt_cart'])) {
            $cartcount = count($_SESSION['nzshpcrt_cart']);
            //echo "cartcount: ".$cartcount;
            if (isset($_POST['variation']) && is_array($_POST['variation'])) {
                $variations = $_POST['variation'];
            } else {
                $variations = null;
            }
            $updated_quantity = false;
            if ($_SESSION['nzshpcrt_cart'] != null) {
                foreach ($_SESSION['nzshpcrt_cart'] as $cart_key => $cart_item) {
                    if ($cart_item->product_id == $_POST['prodid']) {
                        //ales
                        if (isset($_POST['license'])) {
                            $_SESSION['nzshpcrt_cart'][$cart_key]->license = $_POST['license'];
                        } else {
                            $_SESSION['nzshpcrt_cart'][$cart_key]->license = 'l1_price';
                        }
                        if (isset($brand_id)) {
                            $_SESSION['nzshpcrt_cart'][$cart_key]->author = get_brand($brand_id);
                        }
                        if ($_SESSION['nzshpcrt_cart'][$cart_key]->product_variations === $variations) {
                            $_SESSION['nzshpcrt_cart'][$cart_key]->quantity = 1;
                            $updated_quantity = true;
                        }
                    }
                }
            }
            if ($updated_quantity === false) {
                if (isset($_POST['quantity']) && is_numeric($_POST['quantity'])) {
                    if ($_POST['quantity'] > 0) {
                        $new_cart_item = new cart_item($_POST['prodid'], $variations, $_POST['quantity']);
                    }
                } else {
                    $new_cart_item = new cart_item($_POST['prodid'], $variations);
                }
                $_SESSION['nzshpcrt_cart'][$cartcount + 1] = $new_cart_item;
            }
        }
        $quantity_limit = false;
        if (isset($_SESSION['nzshpcrt_cart'])) {
            $cart = $_SESSION['nzshpcrt_cart'];
        } else {
            $cart = null;
        }
        echo nzshpcrt_shopping_basket_internals($cart, $quantity_limit);
        exit;
    } else {
        if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && (isset($_POST['user']) and $_POST['user'] == "true") && $_POST['emptycart'] == "true") {
            $_SESSION['nzshpcrt_cart'] = array();
            $cart = $_SESSION['nzshpcrt_cart'];
            //ales cart
            //echo nzshpcrt_shopping_basket_internals($cart);
            exit;
        }
    }
    /* fill product form */
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['admin'] == "true" && isset($_POST['prodid']) && is_numeric($_POST['prodid'])) {
        if ($_POST['prodid'] == '000') {
            echo "<h3>Нет картинки с таким номером</h3>";
            exit;
        }
        echo nzshpcrt_getproductform($_POST['prodid']);
        exit;
    } else {
        if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['admin'] == "true" && isset($_POST['catid']) && is_numeric($_POST['catid'])) {
            echo nzshpcrt_getcategoryform($_POST['catid']);
            exit;
        } else {
            if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['admin'] == "true" && is_numeric($_POST['brandid'])) {
                echo nzshpcrt_getbrandsform($_POST['brandid']);
                exit;
            } else {
                if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['admin'] == "true" && is_numeric($_POST['variation_id'])) {
                    echo nzshpcrt_getvariationform($_POST['variation_id']);
                    exit;
                }
            }
        }
    }
    /* rate item */
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_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 `wp_product_rating` SET `rated` = '" . $rating . "' WHERE `id` ='" . $vote_id . "' LIMIT 1 ;");
        } else {
            $insert_sql = "INSERT INTO `wp_product_rating` ( `id` , `ipnum`  , `productid` , `rated`, `time`) VALUES ( '', '" . $ip_number . "', '" . $prodid . "', '" . $rating . "', '" . $nowtime . "');";
            $wpdb->query($insert_sql);
            $data = $wpdb->get_results("SELECT `id`,`rated` FROM `wp_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;
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['get_rating_count'] == "true" && is_numeric($_POST['product_id'])) {
        $prodid = $_POST['product_id'];
        $data = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM `wp_product_rating` WHERE `productid` = '" . $prodid . "'", ARRAY_A);
        echo $data[0]['count'] . "," . $prodid;
        exit;
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['remove_variation_value'] == "true" && is_numeric($_POST['variation_value_id'])) {
        if ($user_level >= 7) {
            $wpdb->query("DELETE FROM `wp_variation_values_associations` WHERE `value_id` = '" . $_POST['variation_value_id'] . "'");
            $wpdb->query("DELETE FROM `wp_variation_values` WHERE `id` = '" . $_POST['variation_value_id'] . "' LIMIT 1");
            exit;
        }
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['list_variation_values'] == "true" && is_numeric($_POST['variation_id'])) {
        if ($user_level >= 7) {
            $variation_processor = new nzshpcrt_variations();
            //product_variations_"+(parseInt(child_element_count)+1)
            echo "variation_value_id = \"" . $_POST['variation_id'] . "\";\n";
            echo "variation_value_html = \"" . $variation_processor->display_variation_values($_POST['prefix'], $_POST['variation_id']) . "\";\n";
            exit;
        }
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['remove_form_field'] == "true" && is_numeric($_POST['form_id'])) {
        if ($user_level >= 7) {
            $wpdb->query("UPDATE `wp_collect_data_forms` SET `active` = '0' WHERE `id` ='" . $_POST['form_id'] . "' LIMIT 1 ;");
            exit;
        }
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['remove_form_field'] == "true" && is_numeric($_POST['form_id'])) {
        if ($user_level >= 7) {
            $wpdb->query("UPDATE `wp_collect_data_forms` SET `active` = '0' WHERE `id` ='" . $_POST['form_id'] . "' LIMIT 1 ;");
            exit;
        }
    }
    if (isset($_POST['ajax']) and $_POST['ajax'] == "true" && $_POST['user'] == "true" && $_POST['drag_and_drop_cart'] == "true") {
        drag_and_drop_cart_contents();
        exit;
    }
    if (isset($_POST['language_setting']) && ($_GET['page'] = 'wp-shopping-cart/options.php')) {
        if ($user_level >= 7) {
            update_option('language_setting', $_POST['language_setting']);
        }
    }
    if (isset($_POST['language_setting']) && ($_GET['page'] = 'wp-shopping-cart/options.php')) {
        if ($user_level >= 7) {
            update_option('language_setting', $_POST['language_setting']);
        }
    }
    if (isset($_GET['rss']) and $_GET['rss'] == "true" && $_GET['action'] == "product_list") {
        $sql = "SELECT id, name, description, image FROM `wp_product_list` WHERE active='1' and approved='1' and visible='1' Order by id DESC LIMIT 40";
        $product_list = $wpdb->get_results($sql, ARRAY_A);
        header("Content-Type: application/xml; charset=utf-8");
        header('Content-Disposition: inline; filename="cartoonbank.rss"');
        $output = '';
        $output .= "<?xml version='1.0'?>\n\r";
        $output .= "<rss version='2.0'>\n\r";
        $output .= "xmlns:content='http://purl.org/rss/1.0/modules/content/'\n\r";
        $output .= "xmlns:wfw='http://wellformedweb.org/CommentAPI/'\n\r";
        $output .= "xmlns:dc='http://purl.org/dc/elements/1.1/'\n\r";
        $output .= "xmlns:atom='http://www.w3.org/2005/Atom'\n\r";
        $output .= "xmlns:sy='http://purl.org/rss/1.0/modules/syndication/'\n\r";
        $output .= "xmlns:slash='http://purl.org/rss/1.0/modules/slash/'\n\r";
        $output .= "xmlns:georss='http://www.georss.org/georss' xmlns:geo='http://www.w3.org/2003/01/geo/wgs84_pos#' xmlns:media='http://search.yahoo.com/mrss/'>\n\r";
        $output .= "  <channel>\n\r";
        $output .= "    <title>Cartoonbank new images</title>\n\r";
        $output .= "    <link>" . SITEURL . "</link>\n\r";
        $output .= "    <description>This is the Russian Cartoon Bank RSS feed</description>\n\r";
        $output .= "    <generator>Cartoonbank.ru</generator>\n\r";
        foreach ($product_list as $product) {
            $purchase_link = get_option('product_list_url') . "&cartoonid=" . stripslashes($product['id']);
            $output .= "    <item>\n\r";
            $output .= "      <title>" . stripslashes($product['name']) . "</title>\n\r";
            $output .= "      <link>" . SITEURL . "?page_id=29&amp;cartoonid=" . stripslashes($product['id']) . "</link>\n\r";
            $output .= "      <description>" . stripslashes($product['description']) . "<![CDATA[<a href='" . SITEURL . "?page_id=29&amp;cartoonid=" . stripslashes($product['id']) . "'><br /><img title='" . stripslashes($product['name']) . "' src='http://sl.cartoonbank.ru/" . stripslashes($product['image']) . "' alt='" . stripslashes($product['name']) . "' /></a>]]></description>\n\r";
            $output .= "      <pubDate>" . date("r") . "</pubDate>\n\r";
            $output .= "      <guid>" . SITEURL . "?page_id=29&amp;cartoonid=" . stripslashes($product['id']) . "</guid>\n\r";
            $output .= '    ';
            $output .= "    </item>\n\r";
        }
        $output .= "  </channel>\n\r";
        $output .= "</rss>";
        echo $output;
        exit;
    }
    if (isset($_GET['purchase_log_csv']) and $_GET['purchase_log_csv'] == "true" && $_GET['rss_key'] == 'key' && is_numeric($_GET['start_timestamp']) && is_numeric($_GET['end_timestamp'])) {
        $form_sql = "SELECT * FROM `wp_collect_data_forms` WHERE `active` = '1' AND `display_log` = '1';";
        $form_data = $wpdb->get_results($form_sql, ARRAY_A);
        $start_timestamp = $_GET['start_timestamp'];
        $end_timestamp = $_GET['end_timestamp'];
        $data = $wpdb->get_results("SELECT * FROM `wp_purchase_logs` WHERE `date` BETWEEN '{$start_timestamp}' AND '{$end_timestamp}' ORDER BY `date` DESC", ARRAY_A);
        header('Content-Type: text/csv');
        header('Content-Disposition: inline; filename="Purchase Log ' . date("M-d-Y", $start_timestamp) . ' to ' . date("M-d-Y", $end_timestamp) . '.csv"');
        $output .= "\"" . TXT_WPSC_PRICE . "\",";
        foreach ($form_data as $form_field) {
            $output .= "\"" . $form_field['name'] . "\",";
        }
        if (get_option('payment_method') == 2) {
            $output .= "\"" . TXT_WPSC_PAYMENT_METHOD . "\",";
        }
        $output .= "\"" . TXT_WPSC_STATUS . "\",";
        $output .= "\"" . TXT_WPSC_DATE . "\"\n";
        foreach ($data as $purchase) {
            $country_sql = "SELECT * FROM `wp_submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1";
            $country_data = '';
            //$wpdb->get_results($country_sql,ARRAY_A);
            $country = $country_data[0]['value'];
            $output .= "\"" . nzshpcrt_find_total_price($purchase['id'], $country) . "\",";
            foreach ($form_data as $form_field) {
                $collected_data_sql = "SELECT * FROM `wp_submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
                $collected_data = $wpdb->get_results($collected_data_sql, ARRAY_A);
                $collected_data = $collected_data[0];
                $output .= "\"" . $collected_data['value'] . "\",";
            }
            if (get_option('payment_method') == 2) {
                $gateway_name = '';
                foreach ($GLOBALS['nzshpcrt_gateways'] as $gateway) {
                    if ($purchase['gateway'] != 'testmode') {
                        if ($gateway['internalname'] == $purchase['gateway']) {
                            $gateway_name = $gateway['name'];
                        }
                    } else {
                        $gateway_name = "Manual Payment";
                    }
                }
                $output .= "\"" . $gateway_name . "\",";
            }
            if ($purchase['processed'] < 1) {
                $purchase['processed'] = 1;
            }
            $stage_sql = "SELECT * FROM `wp_purchase_statuses` WHERE `id`='" . $purchase['processed'] . "' AND `active`='1' LIMIT 1";
            $stage_data = $wpdb->get_results($stage_sql, ARRAY_A);
            $output .= "\"" . $stage_data[0]['name'] . "\",";
            $output .= "\"" . date("jS M Y", $purchase['date']) . "\"\n";
        }
        echo $output;
        exit;
    }
    if (isset($_GET['remove']) and is_numeric($_GET['remove']) && $_SESSION['nzshpcrt_cart'] != null) {
        $key = $_GET['remove'];
        if (isset($_SESSION['nzshpcrt_cart'][$key]) && is_object($_SESSION['nzshpcrt_cart'][$key])) {
            $_SESSION['nzshpcrt_cart'][$key]->empty_item();
        }
        unset($_SESSION['nzshpcrt_cart'][$key]);
    }
    if (isset($_GET['cart']) and $_GET['cart'] == 'empty') {
        $_SESSION['nzshpcrt_cart'] = '';
        $_SESSION['nzshpcrt_cart'] = array();
    }
    if (isset($_POST['quantity']) and is_numeric($_POST['quantity']) && is_numeric($_POST['key'])) {
        $quantity = $_POST['quantity'];
        $key = $_POST['key'];
        if (is_object($_SESSION['nzshpcrt_cart'][$key])) {
            if ($quantity > 0) {
                $_SESSION['nzshpcrt_cart'][$key]->quantity = $quantity;
            } else {
                $_SESSION['nzshpcrt_cart'][$key]->empty_item();
                unset($_SESSION['nzshpcrt_cart'][$key]);
            }
        }
    }
}
Example #4
0
/* 
 * and ends here
 */
if ($_GET['purchase_log_csv'] == "true" && $_GET['rss_key'] == 'key' && is_numeric($_GET['start_timestamp']) && is_numeric($_GET['end_timestamp'])) {
    $form_sql = "SELECT * FROM `" . $wpdb->prefix . "collect_data_forms` WHERE `active` = '1' AND `display_log` = '1';";
    $form_data = $wpdb->get_results($form_sql, ARRAY_A);
    $start_timestamp = $_GET['start_timestamp'];
    $end_timestamp = $_GET['end_timestamp'];
    $data = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "purchase_logs` WHERE `date` BETWEEN '{$start_timestamp}' AND '{$end_timestamp}' ORDER BY `date` DESC", ARRAY_A);
    header('Content-Type: text/csv');
    header('Content-Disposition: inline; filename="Purchase Log ' . date("M-d-Y", $start_timestamp) . ' to ' . date("M-d-Y", $end_timestamp) . '.csv"');
    foreach ($data as $purchase) {
        $country_sql = "SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . get_option('country_form_field') . "' LIMIT 1";
        $country_data = $wpdb->get_results($country_sql, ARRAY_A);
        $country = $country_data[0]['value'];
        $output .= "\"" . nzshpcrt_find_total_price($purchase['id'], $country) . "\",";
        foreach ($form_data as $form_field) {
            $collected_data_sql = "SELECT * FROM `" . $wpdb->prefix . "submited_form_data` WHERE `log_id` = '" . $purchase['id'] . "' AND `form_id` = '" . $form_field['id'] . "' LIMIT 1";
            $collected_data = $wpdb->get_results($collected_data_sql, ARRAY_A);
            $collected_data = $collected_data[0];
            $output .= "\"" . $collected_data['value'] . "\",";
        }
        if (get_option('payment_method') == 2) {
            $gateway_name = '';
            foreach ($GLOBALS['nzshpcrt_gateways'] as $gateway) {
                if ($purchase['gateway'] != 'testmode') {
                    if ($gateway['internalname'] == $purchase['gateway']) {
                        $gateway_name = $gateway['name'];
                    }
                } else {
                    $gateway_name = "Manual Payment";