".$lang['setup']['global_file_updated']."

"; } else { echo "

".$lang['setup']['global_unwritable_1']."

"; $globCont=""; echo "

includes".CC_DS."global.inc.php

".$lang['setup']['try_again_to_complete']."

"; $nextStep = 3; $buttonText = $lang['setup']['upgrade_try_again']; } } ## Edit config database rows to be $config = fetchDbConfig("config"); ## Fix for langs in v4 that don't exist $config['defaultLang'] = $_GET['l']; ## see if any of our required config values exist... if not the config must be 3.0 and we need to update them if( !array_key_exists('siteCountry', $config) || !array_key_exists('defaultCurrency', $config) || !array_key_exists('storeAddress', $config)) { $resultOldConfig = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_config"); if($resultOldConfig==TRUE){ for($i=0;$i $value){ ## fix for bug #147 $decodedKey = base64_decode($key); if($decodedKey=="offLineContent") { $base64Decoded[$decodedKey] = $value; } else { $base64Decoded[$decodedKey] = stripslashes(base64_decode($value)); } } $fresh = serialize($base64Decoded); $data['array'] = $db->mySQLSafe($fresh); $update = $db->update($glob['dbprefix']."CubeCart_config", $data,"name=".$db->mySQLSafe($resultOldConfig[$i]['name'])); ## Unset to stop config in config unset($date, $fresh, $base64Encoded, $base64Decoded); } } } echo "

".$lang['setup']['config_files_updated']."

"; ## unset base64 config and get nice clean one bye bye skank unset($config); $config = fetchDbConfig("config"); ## Change the skin back to KitaBlue $newConf['skinDir'] = "KitaBlue"; ## Added in 4.0.0 $newConf['cat_tree'] = '1'; $newConf['hide_prices'] = '0'; $newConf['pop_products_source'] = '0'; $newConf['cache'] = '1'; $newConf['show_empty_cat'] = 1; $newConf['disable_alert_email']=0; $newConf['latestNewsRRS'] = 'http://www.cubecart.com/site/forums/index.php?act=rssout&id=1'; $newConf['richTextEditor'] = true; $newConf['rteHeight'] = '350'; $newConf['rteHeightUnit'] = ''; $newConf['add_to_basket_act'] = '0'; $newConf['stock_warn_type'] = '0'; $newConf['stock_warn_level'] = '5'; $newConf['changeskin'] = '0'; $newConf['priceTaxDelInv'] = '0'; $newConf['currecyAuto'] = '0'; $newConf['proxy'] = '0'; $newConf['proxyHost'] = ''; $newConf['proxyPort'] = ''; $newConf['sef'] = '0'; $newConf['seftags'] = '0'; $newConf['sefprodnamefirst'] = '0'; $newConf['stock_change_time'] = '0'; $newConf['stock_replace_time'][1] = '1'; $newConf['stock_replace_time'][2] = '1'; $newConf['stock_replace_time'][3] = '1'; $newConf['stock_replace_time'][5] = '1'; $newConf['stock_replace_time'][6] = '1'; $config['orderExpire'] = '1209600'; ################################ ## Start Upload Folder SIze ################################ $dirArray = walkDir(CC_ROOT_DIR .CC_DS."images".CC_DS."uploads", true, 0, 0, false, $int = 0); $size = 0; if (is_array($dirArray)) { foreach($dirArray as $file) { if (file_exists($file)) { $size = filesize($file) + $size; } } echo "

Image upload folder size calculated.

"; } $newConf['uploadSize'] = $size; ################################ ## End Upload Folder SIze ################################ writeDbConf($newConf, 'config', $config, false); ################################ ## Start Count products in Categories ################################ ## Set the number of products in all categories to 0 $update = $db->update($glob['dbprefix'].'CubeCart_category', array('noProducts' => 0), ''); ## Get all productId's from the database $products = $db->select("SELECT productId FROM ".$glob['dbprefix']."CubeCart_inventory"); ## Get a list of all existing products from the inventory if ($products) { foreach ($products as $product) { $currentProducts[] = $product['productId']; } ## Delete all records from cats_idx where the productId is NOT in the inventory $delQuery = sprintf("DELETE FROM %sCubeCart_cats_idx WHERE productId NOT IN (%s)", $glob['dbprefix'], implode(',', $currentProducts)); $db->misc($delQuery); ## Count the number of products in the cats_idx table by category $countQuery = sprintf("SELECT COUNT(cat_id) as count, cat_id FROM %1\$sCubeCart_cats_idx WHERE cat_id IN(SELECT DISTINCT cat_id FROM %1\$sCubeCart_cats_idx WHERE 1) GROUP BY cat_id", $glob['dbprefix']); $catCount = $db->select($countQuery); foreach ($catCount as $category) { ## Set the number of products by category $db->categoryNos($category['cat_id'], '+', $category['count']); } echo "

Number of products by category counted.

"; } ## ---------------------------------------- /* ## set noProducts in all categories to 0 $record['noProducts'] = $db->mySQLSafe(0); $update = $db->update($glob['dbprefix']."CubeCart_category", $record, $where=""); unset($record); ## empty cats_idx $empty = $db->truncate($glob['dbprefix']."CubeCart_cats_idx"); ## get all products $products = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory"); ## for each product add 1 to suitable category count and add cat_idx if($products==TRUE){ for ($i=0; $imySQLSafe($products[$i]['productId']); $idx_data['cat_id'] = $db->mySQLSafe($products[$i]['cat_id']); $cat_idx = $db->insert($glob['dbprefix']."CubeCart_cats_idx", $idx_data); ## update category count $db->categoryNos($products[$i]['cat_id'], "+",1); } echo "

Number of products per category counted.

"; }*/ ################################ ## End Count products in Categories ################################ ################################ ## Start Count Orders ################################ $record['noOrders'] = $db->mySQLSafe(0); $update = $db->update($glob['dbprefix']."CubeCart_customer", $record, $where=""); unset($record); // get all customers $customers = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_customer"); if($customers==TRUE){ for ($i=0; $inumrows("SELECT * FROM ".$glob['dbprefix']."CubeCart_order_sum WHERE customer_id=".$db->mySQLSafe($customers[$i]['customer_id'])); $record['noOrders'] = $noOrders; $result = $db->update($glob['dbprefix']."CubeCart_customer", $record, "customer_id=".$db->mySQLSafe($customers[$i]['customer_id'])); } echo "

Orders recounted per customer.

"; } ################################ ## End Count Orders ################################ ## Insert hidden category $db->misc("INSERT INTO `".$glob['dbprefix']."CubeCart_category` (`cat_name`, `cat_desc`, `cat_id`, `cat_father_id`, `cat_image`, `per_ship`, `item_ship`, `item_int_ship`, `per_int_ship`, `noProducts`, `hide`, `cat_metatitle`, `cat_metadesc`, `cat_metakeywords`, `priority`) VALUES ('Imported Products', '##HIDDEN##', '', 0, '', 0.00, 0.00, 0.00, 0.00, 0, 1, '', '', '', NULL);"); } ?>