<?php
/*
   This file is the property of Teapplix. Use of this file is 
   restricted to Teapplix customers and governed by
   Teapplix's Terms and Conditions from the following url:

   http://www.teapplix.com/terms.html

   You can only use this file in conjunction with your Teapplix
   account. You agree not to redistribute this file or reverse 
   engineer its contents. You agree to destroy all copies of this 
   file when you terminate your Teapplix subscription.

   Copyright 2008-2011 Teapplix. All rights reserved.

   http://www.teapplix.com
*/
 /* 
   the following funciton can be customized if you do not want to 
   grant admin account access to Teapplix.

   You can customize this function to return 1 for the correct 
   \"username password\" combination, 0 otherwise, and setup 
   Teapplix to use the special username and password to 
   download your orders.
*/
 
function DoAuthCustom($username$password
{
/*
 if ($username == "teapplix" && $password="changeme123") {
   return 1;
 }
*/
return 0;
}
define('IS_ADMIN_FLAG'true);
define('C6f3fd73d''action');
define('Cb607377c''id');
define('C5c230cee''start');
define('C5c6ebc9f''end');
define('C3265be4c''maxcount');
define('C1c5c6c0f''status_code');
define('Cb06f7f88''comments');
define('C38313e08''verbose');
define('C373bc43f''debug');
define('Cf422dd8b''username');
define('Ccd3e077a''password');
function 
Fc866a26d($V3cb8eb17) {
 return 
date("Y-m-d H:i:s"$V3cb8eb17);
}
function 
F31c02eee($Vb098c59a)
{
 
$V240bf022 "/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/i";
if (
preg_match($V240bf022$Vb098c59a$V3017d911))
 {
 
$V19769ecc mktime($V3017d911[4], $V3017d911[5], $V3017d911[6], $V3017d911[2], $V3017d911[3], $V3017d911[1]);
return 
gmdate(DATE_ATOM$V19769ecc);
}
return 
$Vb098c59a;
}
function 
Ffdb73c67() {
 global 
$_REQUEST;
global 
$V418c5509$Vea2b2676$V7f021a14$Vad42f669$V2c7aea42$V7d47c917$Vbd7ead44;
$V418c5509 = (isset($_REQUEST[C6f3fd73d]) ? $_REQUEST[C6f3fd73d] : '');
$Vea2b2676 = (isset($_REQUEST[C5c230cee]) ? $_REQUEST[C5c230cee] : '');
$Vea2b2676 = ($Vea2b2676 0) ? $Vea2b2676 0;
$Vea2b2676 Fc866a26d($Vea2b2676);
$V7f021a14 = (isset($_REQUEST[C5c6ebc9f]) ? $_REQUEST[C5c6ebc9f] : '');
$V7f021a14 = ($V7f021a14 0) ? $V7f021a14 0;
$V7f021a14 Fc866a26d($V7f021a14);
$V7d47c917 $_REQUEST[C3265be4c];
$V7d47c917 = ($V7d47c917 0) ? $V7d47c917 200;
$Vbd7ead44 $_REQUEST[C1c5c6c0f];
$Vbd7ead44 = ($Vbd7ead44 0) ? $Vbd7ead44 0;
$Vad42f669 = (isset($_REQUEST[C373bc43f]) ? $_REQUEST[C373bc43f] : '');
$V2c7aea42 = (isset($_REQUEST[C38313e08]) ? $_REQUEST[C38313e08] : '');
}
function 
F30df7f62($Vb45cffe0)
{
 return 
iconv("ISO-8859-1""UTF-8//TRANSLIT"$Vb45cffe0);
}

function 
F5dbc98dc($Ve4d23e84$V736b9175 null) {
 echo 
'<' $Ve4d23e84;
if (
is_array($V736b9175)) {
 foreach (
$V736b9175 as $Vb068931c => $V3345dbcd)
 {
 echo 
' ' $Vb068931c'="'htmlspecialchars($V3345dbcd). '"';
}
}
echo 
'>';
}
function 
F3a3ea00c($Ve4d23e84) {
 echo 
'</' $Ve4d23e84 ">\n";
}
function 
Fb9ece18c($Ve4d23e84$V2063c160$V736b9175 null) {
 
F5dbc98dc($Ve4d23e84$V736b9175);
echo 
htmlspecialchars($V2063c160);
F3a3ea00c($Ve4d23e84);
}
function 
Fdabd9ff9($Ve4d23e84$V2063c160$V736b9175)
{
 echo 
toUtf8('<'$Ve4d23e84' ');

 echo 
'>';
echo 
toUtf8(htmlspecialchars($V2063c160));
F3a3ea00c($Ve4d23e84);
}

function 
F3501bb09() {
 echo 
"<?xml version=\"1.0\"?>";
}
function 
F8cd2119e($Vcb5e100e=""$V67daf92c="")
{
 
F5dbc98dc("Header");
Fb9ece18c("DocumentVersion""1.01");
global 
$V418c5509$Vea2b2676$V7f021a14$Vad42f669$V2c7aea42$V7d47c917$Vbd7ead44;
if (
$Vcb5e100e) {
 
$V2c7aea42 0;
$Vad42f669 1;
}
if (
$V2c7aea42) {
 
F54013ba6();
}
if (
$Vad42f669) {
 
F5dbc98dc("Debug");
Fb9ece18c("Action"$V418c5509);
Fb9ece18c("Start"$Vea2b2676);
Fb9ece18c("End"$V7f021a14);
Fb9ece18c("MaxCount"$V7d47c917);
Fb9ece18c("StatusCode"$Vbd7ead44);
F3a3ea00c("Debug");
}
if (
$Vcb5e100e) {
 
F5dbc98dc("Fault");
Fb9ece18c("Code"$Vcb5e100e);
Fb9ece18c("Description"$V67daf92c);
F3a3ea00c("Fault");
}
F3a3ea00c("Header");
}
function 
F2be1259a() {
 global 
$V418c5509$Vea2b2676$V7f021a14$Vad42f669$V2c7aea42$V7d47c917$Vbd7ead44;
header('Content-Type: text/xml');
Ffdb73c67();
F3501bb09();
F5dbc98dc("TeapplixEnvelope");
if (!
F07962d8c($_REQUEST[Cf422dd8b], $_REQUEST[Ccd3e077a])) {
 if (!
DoAuthCustom($_REQUEST[Cf422dd8b], $_REQUEST[Ccd3e077a])) {
 
F8cd2119e(401'username and password not correct');
F3a3ea00c("TeapplixEnvelope");
return;
}
}
if (
$V418c5509)
 {
 switch (
strtolower($V418c5509)) {
 case 
'download':
 
F00d1ec58();
break;
case 
'update':
 
F588d2181();
break;
}
}
F3a3ea00c("TeapplixEnvelope");
}
function 
Fcbcfa970() {
    
// Prepare language 
 
require_once(DIR_WS_CLASSES 'language.php');
$V8b8a2268 = new language();
$V8b8a2268->get_browser_language();
$V8512ae7d $V8b8a2268->V8512ae7d['directory'];
$Vd21dc9dc $V8b8a2268->V8512ae7d['id'];

}
function 
Ffad58de7() {
 
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); 
 
header("Content-Type: text/xml; charset=utf-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false); 
 
header("Pragma: no-cache"); 
 require(
'includes/configure.php');
require(
DIR_WS_INCLUDES 'database_tables.php');
require(
DIR_WS_CLASSES 'order.php');
require(
DIR_WS_FUNCTIONS 'database.php');
require(
DIR_WS_FUNCTIONS 'general.php');

 
$V1c0b76fc = (getenv('HTTPS') == 'on'); 
 if (!
$V1c0b76fc && REQUIRE_SECURE && 0)
 {
 
F5dbc98dc("TeapplixEnvelope");
F8cd2119e(401'https url required. http url not allowed.');
F3a3ea00c("TeapplixEnvelope");
return;
}
if (!
tep_db_connect()) {
 
F5dbc98dc("TeapplixEnvelope");
F8cd2119e(500'Unable to connect to database.');
F3a3ea00c("TeapplixEnvelope");
return;
}
if (!
function_exists("tep_get_orders_status")) {
 
F5dbc98dc("TeapplixEnvelope");
F8cd2119e(500,
 
"Unable to get tep_get_orders_status function. " .
 
"This may be because the module is not installed in the 'admin' directory of your store.");
F3a3ea00c("TeapplixEnvelope");
return;
}
Fcbcfa970(); 
 
$V3527aca3 tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' TABLE_CONFIGURATION);
while (
$Vccd10663 tep_db_fetch_array($V3527aca3)) 
 {
 
define($Vccd10663['cfgKey'], $Vccd10663['cfgValue']);
}
F2be1259a(); 
 return;
}  
function 
F07962d8c($V14c4b06b$V5f4dcc3b) {
 if (
function_exists("tep_admin_check_login")) {  
 require_once(
DIR_WS_FUNCTIONS 'password_funcs.php');

 
$Vb4326656 false;

 if (isset(
$V14c4b06b) && isset($V5f4dcc3b)) {
 
$Vb5e0aaf3 tep_db_prepare_input($V14c4b06b);
$V5f4dcc3b tep_db_prepare_input($V5f4dcc3b);

 
$Vb2e430d9 tep_db_query(
 
"select admin_id as login_id, admin_password as login_password " 
 
" from " TABLE_ADMIN 
 
" where admin_email_address = '" tep_db_input($Vb5e0aaf3) . "'");

 if (
tep_db_num_rows($Vb2e430d9)) {
 
$Vbedd5858 tep_db_fetch_array($Vb2e430d9); 
 if (
tep_validate_password($V5f4dcc3b$Vbedd5858['login_password'])) {
 
$Vb4326656 true;
}
}

 if (!
$Vb4326656) {
 
F8cd2119e(401"The username or password is incorrect.");
}
} else {
 
F8cd2119e(401"The username and password was not supplied.");
}
return 
$Vb4326656;
} else {
 return 
false;
}
}

function 
Fc2282187()
{
 
Fcbcfa970();
$V76034a9f tep_get_orders_status();
reset($V76034a9f);
while (list(
$V3c6e0b8a$V3a6d0284) = each($V76034a9f))
 {
 
F5dbc98dc("OrderStatus");
Fb9ece18c("Code"$V3a6d0284['id']);
Fb9ece18c("Name"$V3a6d0284['text']);
F3a3ea00c("OrderStatus");
}
}

function 
F54013ba6()
{
 
F5dbc98dc("Cart");
Fb9ece18c("Name"STORE_NAME);
Fb9ece18c("CompanyOrOwner"STORE_OWNER);
Fb9ece18c("Email"STORE_OWNER_EMAIL_ADDRESS);
Fb9ece18c("State"tep_get_zone_code(STORE_COUNTRYSTORE_ZONE"AL"));
Fb9ece18c("Country"F49c0bbe2(STORE_COUNTRY));
Fb9ece18c("Website"HTTP_CATALOG_SERVER);
Fb9ece18c("Now"gmdate(DATE_ATOM));
Fc2282187();
F3a3ea00c("Cart");

function 
F00d1ec58()
{
 global 
$_REQUEST$db;
global 
$V418c5509$Vea2b2676$V7f021a14$Vad42f669$V2c7aea42$V7d47c917$Vbd7ead44;
F8cd2119e();
$V09eff75b tep_db_query(
 
"select * ,ifnull(o.last_modified, o.date_purchased) as Modified" .
 
" from " TABLE_ORDERS " o, " TABLE_ORDERS_TOTAL " ot " .
 
" where ot.orders_id = o.orders_id " .
 
" and ot.class = 'ot_total' " 
 
" and o.orders_status = '$Vbd7ead44' " .
 
" having Modified > '$Vea2b2676' " .
 
" and Modified <= '$V7f021a14' " .
 
" order by Modified asc " .
 
" limit 0, " $V7d47c917);

 
$Ve2942a04 1;
Fb9ece18c("MessageType""OrderReport");
while (
$Vf1965a85 tep_db_fetch_array($V09eff75b)) 
 {
 
Ff1862177($Vf1965a85$Ve2942a04);
$Ve2942a04++;
}
}

function 
F726ecbcc($V03163a43$V718a2edd$V4c9184f3)
{
 if (
strlen($V03163a43) > 0)
 {
 
$V736b9175 = array("public" => $V4c9184f3 "true" "false",
 
"date" => F31c02eee($V718a2edd));

 
Fdabd9ff9("Note"$V03163a43$V736b9175);
}
}

function 
Ff1862177($Vf1965a85$Ve2942a04)

 
$V153efb17 = (int) $Vf1965a85['currency_value'];

 
$V09f3846b tep_db_query("select title from " TABLE_ORDERS_TOTAL " where orders_id = '" . (int)$Vf1965a85['orders_id'] . "' and class = 'ot_shipping'");
$Vcc51e870 tep_db_fetch_array($V09f3846b);
$Vcc51e870 = ((substr($Vcc51e870['title'], -1) == ':') ? substr(strip_tags($Vcc51e870['title']), 0, -1) : strip_tags($Vcc51e870['title'])); 
 
$Vd764d0c8 tep_db_query(
 
"select comments, date_added from " TABLE_ORDERS_STATUS_HISTORY .
 
" where orders_id = " $Vf1965a85['orders_id'] . " " .
 
" order by date_added asc " .
 
" limit 0, 1" );
$Vfe0276f8 tep_db_fetch_array($Vd764d0c8);

 
F5dbc98dc("Message");
Fb9ece18c("MessageID"$Ve2942a04);
F5dbc98dc("OrderReport");

 
Fb9ece18c("OrderID"$Vf1965a85['orders_id']);
Fb9ece18c("OrderDate"F31c02eee($Vf1965a85['date_purchased']));
Fb9ece18c("OrderPostedDate"F31c02eee($Vf1965a85['Modified']));
F5dbc98dc("CustomerOrderInfo");
Fb9ece18c("Type""CustomerComment");
Fb9ece18c("Value"$Vfe0276f8['comments']);
F3a3ea00c("CustomerOrderInfo");

 
F5dbc98dc("CustomerOrderInfo");
Fb9ece18c("Type""StatusCode");
Fb9ece18c("Value"$Vf1965a85['orders_status']);
F3a3ea00c("CustomerOrderInfo");

 
 
$Vb97523e7 $Vf1965a85['customers_email_address'];
$Vc68d852c $Vf1965a85['customers_telephone'];
$V2586be6e "";
$Vf222bf2e "";

 if (
$Vf1965a85['delivery_name'] == $Vf1965a85['billing_name'] &&
 
$Vf1965a85['delivery_street_address'] == $Vf1965a85['billing_street_address'] &&
 
$Vf1965a85['delivery_postcode'] == $Vf1965a85['billing_postcode'])
 {
 
$V2586be6e $Vb97523e7;
$Vf222bf2e $Vc68d852c
 }

 
F5dbc98dc("BillingData");
Fb9ece18c("BuyerEmailAddress"$Vf1965a85['customers_email_address']);
Fb9ece18c("BuyerName"$Vf1965a85['billing_name']);
Fb9ece18c("BuyerPhoneNumber"$Vf1965a85['customers_telephone']);
F3a3ea00c("BillingData");
F5dbc98dc("FulfillmentData");
Fb9ece18c("FulfillmentMethod""Ship");
Fb9ece18c("FulfillmentServiceLevel"$Vcc51e870);
F5dbc98dc("Address");
Fb9ece18c("Name"$Vf1965a85['delivery_name']);
Fb9ece18c("Company"$Vf1965a85['delivery_company']);
Fb9ece18c("AddressFieldOne"$Vf1965a85['delivery_street_address']);
Fb9ece18c("AddressFieldTwo"$Vf1965a85['delivery_suburb']);
Fb9ece18c("City"$Vf1965a85['delivery_city']);
Fb9ece18c("StateOrRegion"$Vf1965a85['delivery_state']);
Fb9ece18c("PostalCode"$Vf1965a85['delivery_postcode']);
Fb9ece18c("CountryCode"$Vf1965a85['delivery_country']);
Fb9ece18c("PhoneNumber"$Vf1965a85['customers_telephone']);
F3a3ea00c("Address");
F3a3ea00c("FulfillmentData");
Fb7990dae($Vf1965a85['orders_id'], $V153efb17);
Fc6c824d9($Vf1965a85['orders_id'], $V153efb17);
F3a3ea00c("OrderReport");
F3a3ea00c("Message");

function 
Fb7990dae($Vde4690b3$V153efb17)
{
 global 
$V3555b98c$Vf1aca6b7;
$V2455ea35 HTTP_CATALOG_SERVER DIR_WS_CATALOG DIR_WS_IMAGES;

 
$Vd0a6dab9 tep_db_query(
 
"select * from " TABLE_ORDERS_PRODUCTS 
 
" where orders_id = " $Vde4690b3);

 while(
$V447b7147 tep_db_fetch_array($Vd0a6dab9))
 { 
 
$Vc0ccae59 tep_db_query(
 
"select * from " TABLE_PRODUCTS .
 
" where products_id = " $V447b7147['products_id']);

 
$Vf5bf48aa tep_db_fetch_array($Vc0ccae59); 
 
$V28b569d3 $Vf5bf48aa['products_image'];
if (isset(
$V28b569d3) and strlen($V28b569d3) > 0)
 {
 
$V28b569d3 $V2455ea35 $V28b569d3;
}

 
F5dbc98dc("Item");
Fb9ece18c("OrderItemCode"$V447b7147['orders_products_id']);
Fb9ece18c("ProductID"$V447b7147['products_id']);
Fb9ece18c("SKU"$V447b7147['products_model']);
Fb9ece18c("Title"$V447b7147['products_name']);
F2c6422ba($V447b7147['orders_products_id'], $V153efb17);
Fb9ece18c("Quantity"$V447b7147['products_quantity']);
F5dbc98dc("ItemPrice");
F5dbc98dc("Component");
Fb9ece18c("Type""Principal");
Fb9ece18c("Amount", ($V447b7147['products_price'] + $Vf1aca6b7) * $V153efb17);
F3a3ea00c("Component");
F3a3ea00c("ItemPrice");
Fb9ece18c("Image"$V28b569d3);
Fb9ece18c("ItemWeight"$Vf5bf48aa['products_weight'] + $V3555b98c);
F3a3ea00c("Item");
}

function 
F2c6422ba($Vdd663f36$V153efb17)
{
 global 
$V3555b98c$Vf1aca6b7;
$V30d7a2d4 tep_db_query(
 
"select * from " TABLE_ORDERS_PRODUCTS_ATTRIBUTES 
 
" where orders_products_id = " $Vdd663f36);

 
$Vf1aca6b7 0;
$V3555b98c 0;

 while(
$V65db43f2 tep_db_fetch_array($V30d7a2d4))
 {
 
$V3555b98c += $V65db43f2['products_attributes_weight'];

 
$V78a5eb43 $V65db43f2['options_values_price'];

 if (
$V65db43f2['price_prefix'] == '-') {
 
$Vf1aca6b7 -= $V65db43f2['options_values_price'];
} else {
 
$Vf1aca6b7 += $V65db43f2['options_values_price'];
}

 
F5dbc98dc("CustomizationInfo");
Fb9ece18c("Type"$V65db43f2['products_options'] );
Fb9ece18c("Data"$V65db43f2['products_options_values']);
F3a3ea00c("CustomizationInfo");
}

function 
Fc6c824d9($Vde4690b3$V153efb17)
{
 
$V9d5c0533 tep_db_query(
 
"select * from " TABLE_ORDERS_TOTAL 
 
" where orders_id = " $Vde4690b3);

 
F5dbc98dc("Totals");

 
$Ve2dc6c48 0;
while(
$Vfbb44b44 tep_db_fetch_array($V9d5c0533))
 {
 
$V2063c160 $Vfbb44b44['value'];
$Va2f2ed4f $Vfbb44b44['class'];
if (
$Va2f2ed4f == "ot_shipping") {
 
Fb9ece18c("Shipping"$V2063c160 $V153efb17);
}
if (
$Va2f2ed4f == "ot_tax") {
 
Fb9ece18c("Tax"$V2063c160 $V153efb17);
}
if (
$Va2f2ed4f == "ot_total") {
 
Fb9ece18c("Total"$V2063c160 $V153efb17);
}  
 if (
$Va2f2ed4f == "ot_coupon" ||
 
$Va2f2ed4f == "ot_gv" ||
 
$Va2f2ed4f == "ot_lev_discount" ||
 
$Va2f2ed4f == "ot_qty_discount" ||
 
$Va2f2ed4f == "ot_redemptions")
 {
 
$Ve2dc6c48 += $V2063c160;
}
}
if (
$Ve2dc6c48 != 0) {
 
Fb9ece18c("Discount"$Ve2dc6c48 currencyFactor);
}
F3a3ea00c("Totals");
}
function 
F588d2181()

 global 
$db$Vbd7ead44;
if ((!isset(
$_POST[Cb607377c])) || ($Vbd7ead44 == "") || (!isset($_REQUEST[Cb06f7f88])))
 {
 
F8cd2119e(10"Not all parameters supplied.");
return;
} else {
 
F8cd2119e();
}

 
$Va5d49106 mysql_escape_string($_REQUEST[Cb06f7f88]);
$Ve2942a04 0;
foreach (
$_POST[Cb607377c] as $Vb80bb774) {
 
tep_db_query(
 
"insert into " TABLE_ORDERS_STATUS_HISTORY 
 
" (orders_id, orders_status_id, date_added, customer_notified, comments) " .
 
" values (" $Vde4690b3 ", " $Vc1336794 ", now(), 0, '" $Va5d49106 "')");

 
tep_db_query(
 
"update " TABLE_ORDERS .
 
" set orders_status = " $Vc1336794 " " 
 
" where orders_id = " $Vde4690b3);
$Ve2942a04++;
}
Fb9ece18c("MessageType""UpdateStatusCount");
F5dbc98dc("Message");
Fb9ece18c("UpdateCount"$Ve2942a04);
F3a3ea00c("Message");
}

function 
F49c0bbe2($V93bfec8a
{
 
$V1ed6d4fd tep_db_query("select countries_iso_code_2 from " TABLE_COUNTRIES " where countries_id = '" . (int)$V93bfec8a "'");
if (!
tep_db_num_rows($V1ed6d4fd)) {
 return 
$V93bfec8a;
} else {
 
$Ve909c2d7 tep_db_fetch_array($V1ed6d4fd);
return 
$Ve909c2d7['countries_iso_code_2'];
}
}
Ffad58de7();
?>