function ResetStartingOrderNumber() { $StartingOrderNumber = GetOrderTableAutoIncrement(); $StartingOrderNumber_config = GetConfig('StartingOrderNumber'); $HighestOrderNumber = GetHighestOrderNumber(); $return = $StartingOrderNumber; if($StartingOrderNumber <= $StartingOrderNumber_config) { // mysql was probably reset (InnoDB tables don't save auto_increment to disk) // or the auto increment value is lower than our saved config value $return = $StartingOrderNumber_config; // set the database to be inline with our config UpdateOrderTableAutoIncrement($StartingOrderNumber_config); } else if ($StartingOrderNumber <= 1 && $StartingOrderNumber_config <= 1 && $HighestOrderNumber >= 1) { // if mysql was reset and we've never had a config start number set but have orders, we want to use the highest order number + 1 as our auto increment $HighestOrderNumber++; $return = $HighestOrderNumber; UpdateOrderTableAutoIncrement($HighestOrderNumber); } return $return; }
private function SaveUpdatedSettings() { if($_SERVER['REQUEST_METHOD'] != 'POST') { $this->ManageSettings(); return; } $boolean = array ( 'UseWYSIWYG', 'AllowPurchasing', 'ShowInventory', 'ShowPreOrderInventory', 'ShowThumbsInControlPanel', 'TagCloudsEnabled', 'ShowAddToCartQtyBox', 'CaptchaEnabled', 'ShowCartSuggestions', 'ShowThumbsInCart', 'AutoApproveReviews', 'SearchSuggest', 'QuickSearch', 'RSSNewProducts', 'RSSPopularProducts', 'RSSFeaturedProducts', 'RSSCategories', 'RSSProductSearches', 'RSSLatestBlogEntries', 'RSSSyndicationIcons', 'StoreDSTCorrection', 'SystemLogging', 'AdministratorLogging', 'DebugMode', 'EnableWishlist', 'EnableAccountCreation', 'EnableProductComparisons', 'ShowProductPrice', 'ShowProductSKU', 'ShowProductWeight', 'ShowProductBrand', 'ShowProductShipping', 'ShowProductRating', 'HidePHPErrors', 'HTTPSSLVerifyPeer', 'ShowAddToCartLink', 'ShowAddThisLink', 'BulkDiscountEnabled', 'EnableProductTabs', 'ForceControlPanelSSL', 'ProductImagesTinyThumbnailsEnabled', 'ProductImagesImageZoomEnabled', 'DownForMaintenance', 'EnableCustomersAlsoViewed', 'FacebookLikeButtonEnabled', 'FacebookLikeButtonShowFaces', 'categoryFlyoutDropShadow', ); foreach ($boolean as $var) { if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) { $GLOBALS['ISC_NEW_CFG'][$var] = 1; } else { $GLOBALS['ISC_NEW_CFG'][$var] = 0; } } $positive_ints = array ( 'HomeFeaturedProducts', 'HomeNewProducts', 'HomeBlogPosts', 'CategoryProductsPerPage', 'CategoryListDepth', 'ProductReviewsPerPage', 'RSSItemsLimit', 'RSSCacheTime', 'EnableSEOUrls', 'SystemLogMaxLength', 'AdministratorLogMaxLength', 'GuestCustomerGroup', 'CategoryPerRow', 'CategoryImageWidth', 'CategoryImageHeight', 'BrandPerRow', 'BrandImageWidth', 'BrandImageHeight', 'TagCloudMinSize', 'TagCloudMaxSize', 'SearchResultsPerPage', 'ProductImagesStorewideThumbnail_width', 'ProductImagesStorewideThumbnail_height', 'ProductImagesProductPageImage_width', 'ProductImagesProductPageImage_height', 'ProductImagesGalleryThumbnail_width', 'ProductImagesGalleryThumbnail_height', 'ProductImagesZoomImage_width', 'ProductImagesZoomImage_height', 'StartingOrderNumber', 'CustomersAlsoViewedCount', 'PCIPasswordMinLen', 'PCIPasswordHistoryCount', 'PCIPasswordExpiryTimeDay', 'PCILoginAttemptCount', 'PCILoginLockoutTimeMin', 'PCILoginIdleTimeMin', 'PCILoginInactiveTimeDay', ); foreach ($positive_ints as $var) { if (isset($_POST[$var]) && (int)$_POST[$var] > 0) { $GLOBALS['ISC_NEW_CFG'][$var] = (int)$_POST[$var]; } else { $GLOBALS['ISC_NEW_CFG'][$var] = 0; } } $floats = array( 'categoryFlyoutMouseOutDelay', ); foreach ($floats as $var) { if (!isset($_POST[$var])) { $GLOBALS['ISC_NEW_CFG'][$var] = 0; } $GLOBALS['ISC_NEW_CFG'][$var] = (float)$_POST[$var]; } $_SESSION['RunImageResize'] = 'no'; if(isset($_POST['AutoResizeImages']) && $_POST['AutoResizeImages'] == 'yes') { $_SESSION['RunImageResize'] = 'yes'; } // check the starting order number $currentAutoIncrement = (int)GetOrderTableAutoIncrement(); $newAutoIncrement = (int)$_POST['StartingOrderNumber']; if($currentAutoIncrement != $newAutoIncrement) { // they've changed the starting order number // we need to make sure that it is not lower than any current order's ID tho $highestOrderId = GetHighestOrderNumber(); if($newAutoIncrement <= $highestOrderId) { // new starting ID is too low $message = GetLang('StartingOrderNumberTooLow', array( 'currentHighest' => $highestOrderId, 'lowestPossible' => ($highestOrderId+1), )); FlashMessage($message, MSG_ERROR, 'index.php?ToDo=viewSettings¤tTab='.((int) $_POST['currentTab'])); die(); } if(!UpdateOrderTableAutoIncrement($newAutoIncrement)) { FlashMessage(GetLang('StartingOrderNumberAlterFailed'), MSG_ERROR, 'index.php?ToDo=viewSettings¤tTab='.((int) $_POST['currentTab'])); die(); } } // check image size limits and cap them, check for invalid sizes and set them as defaults $imageSizes = array( 'StorewideThumbnail' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL, 'ProductPageImage' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD, 'GalleryThumbnail' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY, 'ZoomImage' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM, ); foreach ($imageSizes as $imageSizeKey => $imageSizeDefault) { $widthKey = 'ProductImages' . $imageSizeKey . '_width'; $heightKey = 'ProductImages' . $imageSizeKey . '_height'; if ($GLOBALS['ISC_NEW_CFG'][$widthKey] > ISC_PRODUCT_IMAGE_MAXLONGEDGE) { $GLOBALS['ISC_NEW_CFG'][$widthKey] = ISC_PRODUCT_IMAGE_MAXLONGEDGE; } else if ($GLOBALS['ISC_NEW_CFG'][$widthKey] < 1) { $GLOBALS['ISC_NEW_CFG'][$widthKey] = $imageSizeDefault; } if ($GLOBALS['ISC_NEW_CFG'][$heightKey] > ISC_PRODUCT_IMAGE_MAXLONGEDGE) { $GLOBALS['ISC_NEW_CFG'][$heightKey] = ISC_PRODUCT_IMAGE_MAXLONGEDGE; } else if ($GLOBALS['ISC_NEW_CFG'][$heightKey] < 1) { $GLOBALS['ISC_NEW_CFG'][$heightKey] = $imageSizeDefault; } } // Have there been any changes to the image sizes? // If there were no changes, don't even touch the images database $imageSizes = array( ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL => array( 'ProductImagesStorewideThumbnail_width', 'ProductImagesStorewideThumbnail_height', ), ISC_PRODUCT_IMAGE_SIZE_STANDARD => array( 'ProductImagesProductPageImage_width', 'ProductImagesProductPageImage_height', ), ISC_PRODUCT_IMAGE_SIZE_TINY => array( 'ProductImagesGalleryThumbnail_width', 'ProductImagesGalleryThumbnail_height', ), ISC_PRODUCT_IMAGE_SIZE_ZOOM => array( 'ProductImagesZoomImage_width', 'ProductImagesZoomImage_height', ), ); // hacky :/ $imageTimeChangedKeys = array( ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL => 'ProductImagesStorewideThumbnail_timeChanged', ISC_PRODUCT_IMAGE_SIZE_STANDARD => 'ProductImagesProductPageImage_timeChanged', ISC_PRODUCT_IMAGE_SIZE_TINY => 'ProductImagesGalleryThumbnail_timeChanged', ISC_PRODUCT_IMAGE_SIZE_ZOOM => 'ProductImagesZoomImage_timeChanged', ); $changedDimensions = array(); foreach($imageSizes as $size => $dimensionSettings) { foreach($dimensionSettings as $dimension) { if($GLOBALS['ISC_NEW_CFG'][$dimension] != $GLOBALS['ISC_CFG'][$dimension]) { $changedDimensions[$size] = $size; $GLOBALS['ISC_NEW_CFG'][$imageTimeChangedKeys[$size]] = time(); } } } // product images used to be deleted here if the dimensions changed but this is now inside the image class // and is based off the _timeChanged above // check if the down for maintenance message is the same as the language pack if(Store_DownForMaintenance::getDownForMaintenanceMessage(true) == $_POST['DownForMaintenanceMessage'] || empty($_POST['DownForMaintenanceMessage'])) { $GLOBALS['ISC_NEW_CFG']['DownForMaintenanceMessage'] = ''; } else if ($GLOBALS['ISC_NEW_CFG']['DownForMaintenance'] == 1) { $GLOBALS['ISC_NEW_CFG']['DownForMaintenanceMessage'] = $_POST['DownForMaintenanceMessage']; } // Normalize the shop path based on users redirect to www/no-www setting $shopPath = $_POST['ShopPath']; GetLib('class.redirects'); $shopPath = ISC_REDIRECTS::normalizeShopPath($shopPath, (int)$_POST['RedirectWWW']); $GLOBALS['ISC_NEW_CFG']['ShopPath'] = $shopPath; $strings = array ( 'SharedSSLPath', 'SubdomainSSLPath', 'StoreName', 'StoreAddress', 'serverStamp', 'DownloadDirectory', 'ImageDirectory', 'HomePagePageTitle', 'MetaKeywords', 'MetaDesc', 'AdminEmail', 'OrderEmail', 'DisplayDateFormat', 'ExportDateFormat', 'ExtendedDisplayDateFormat', 'GoogleMapsAPIKey', 'ForwardInvoiceEmails', 'HTTPProxyPort', 'HTTPProxyServer', 'DimensionsDecimalToken', 'DimensionsThousandsToken', 'DimensionsDecimalPlaces', 'SessionSavePath', 'DefaultPreOrderMessage', 'FacebookLikeButtonAdminIds', 'CategoryListStyle', ); // ignore this setting if it's posted by the client but should be hidden, otherwise process it if (!GetConfig('HideDeletedOrdersActionSetting')) { $strings[] = 'DeletedOrdersAction'; } foreach ($strings as $var) { if (isset($_POST[$var]) && is_string($_POST[$var])) { $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var]; } } $enums = array ( 'UseSSL' => array(SSL_NONE, SSL_NORMAL, SSL_SHARED, SSL_SUBDOMAIN), 'WeightMeasurement' => array ('LBS', 'KGS', 'Ounces', 'Grams', 'Tonnes'), 'LengthMeasurement' => array ('Inches', 'Centimeters'), 'StoreTimeZone' => array_keys($this->timezones), 'Language' => $this->GetAvailableLanguagesArray(), 'TagCartQuantityBoxes' => array ('dropdown', 'textbox'), 'FastCartAction' => array('popup', 'cart'), 'ProductImageMode' => array ('popup', 'lightbox'), 'ProductBreadcrumbs' => array('showall', 'showone', 'shownone'), 'CategoryListingMode' => array('single', 'emptychildren', 'children'), 'CategoryDisplayMode' => array('grid', 'list'), 'ShippingFactoringDimension' => array('depth', 'height', 'width'), 'SearchDefaultProductSort' => array('relevance', 'alphaasc', 'alphadesc', 'featured', 'newest', 'bestselling', 'avgcustomerreview', 'priceasc', 'pricedesc'), 'SearchDefaultContentSort' => array('relevance', 'alphaasc', 'alphadesc'), 'SearchProductDisplayMode' => array('grid', 'list'), 'SearchOptimisation' => array('fulltext', 'like', 'both'), 'CharacterSet' => $this->validCharacterSets, 'AbandonOrderLifetime' => array(1, 7, 14, 21, 30, 60, 90, 120, 150, 180), 'RedirectWWW' => array(REDIRECT_NO_PREFERENCE, REDIRECT_TO_WWW, REDIRECT_TO_NO_WWW), 'FacebookLikeButtonStyle' => array('standard', 'countonly'), 'FacebookLikeButtonPosition' => array('above', 'below'), 'FacebookLikeButtonVerb' => array('like', 'recommend'), ); foreach ($enums as $var => $possible_vals) { if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) { $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var]; } else { $GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0]; } } $uploads = array( 'CategoryDefaultImage', 'BrandDefaultImage', ); if($_POST['DefaultProductImage'] == 'custom') { $uploads[] = 'DefaultProductImageCustom'; } foreach ($uploads as $var) { $imageLocation = GetConfig($var); if (array_key_exists($var, $_FILES) && file_exists($_FILES[$var]['tmp_name'])) { $ext = GetFileExtension($_FILES[$var]['name']); $imageLocation = GetConfig('ImageDirectory').'/' . $var . '.' . $ext; move_uploaded_file($_FILES[$var]['tmp_name'], ISC_BASE_PATH . '/'.$imageLocation); // Attempt to change the permissions on the file isc_chmod(ISC_BASE_PATH . '/'.$imageLocation, ISC_WRITEABLE_FILE_PERM); } if (array_key_exists('Del' . $var, $_REQUEST) && $_REQUEST['Del' . $var]) { @unlink(ISC_BASE_PATH . GetConfig($var)); $imageLocation = ''; } $GLOBALS['ISC_NEW_CFG'][$var] = $imageLocation; } switch($_POST['DefaultProductImage']) { case 'custom': if ($GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom'] != '') { $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = $GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom']; } unset($GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom']); break; case 'template': $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = 'template'; break; default: $GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = ''; } // Backup Settings if (gzte11(ISC_MEDIUMPRINT)) { $boolean = array ( 'BackupsLocal', 'BackupsRemoteFTP', 'BackupsAutomatic', 'BackupsAutomaticDatabase', 'BackupsAutomaticImages', 'BackupsAutomaticDownloads', ); foreach ($boolean as $var) { if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) { $GLOBALS['ISC_NEW_CFG'][$var] = 1; } else { $GLOBALS['ISC_NEW_CFG'][$var] = 0; } } $strings = array ( 'BackupsRemoteFTPHost', 'BackupsRemoteFTPUser', 'BackupsRemoteFTPPass', 'BackupsRemoteFTPPath', ); foreach ($strings as $var) { if (isset($_POST[$var]) && is_string($_POST[$var])) { $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var]; } } $enums = array ( 'BackupsAutomaticMethod' => array ('ftp', 'local'), ); foreach ($enums as $var => $possible_vals) { if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) { $GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var]; } else { $GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0]; } } } // Newsletter Settings if (isset($_POST['SystemLogTypes'])) { $GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = implode(",", $_POST['SystemLogTypes']); } else { $GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = ''; } if (isset($_POST['SystemLogSeverity'])) { $GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = implode(",", $_POST['SystemLogSeverity']); } else { $GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = ''; } if(isset($_POST['LowInventoryEmails']) && $_POST['LowInventoryEmails'] == 1) { $GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = $_POST['LowInventoryNotificationAddress']; } else { $GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = ''; } if(isset($_POST['ForwardInvoiceEmailsCheck']) && $_POST['ForwardInvoiceEmailsCheck'] == 1) { $GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = $_POST['ForwardInvoiceEmails']; } else { $GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = ''; } // Email Server Settings $GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 0; $GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = ''; $GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = ''; $GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = ''; $GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = ''; if(isset($_POST['MailUseSMTP']) && $_POST['MailUseSMTP'] == 1) { $GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 1; $GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = $_POST['MailSMTPServer']; if(isset($_POST['MailSMTPUsername'])) { $GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = $_POST['MailSMTPUsername']; } if(isset($_POST['MailSMTPPassword'])) { $GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = $_POST['MailSMTPPassword']; } if(isset($_POST['MailSMTPPort'])) { $GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = $_POST['MailSMTPPort']; } } if(isset($_POST['VendorPhotoUploading'])) { $GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = (int)$_POST['VendorPhotoSizeW'].'x'.(int)$_POST['VendorPhotoSizeH']; } else { $GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = ''; } if(isset($_POST['VendorLogoUploading'])) { $GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = (int)$_POST['VendorLogoSizeW'].'x'.(int)$_POST['VendorLogoSizeH']; } else { $GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = ''; } // Remove any settings that have been disabled so they can't be adjusted by the end user $disabledFields = array( 'DisableLicenseKeyField' => array( 'serverStamp' ), 'DisableStoreUrlField' => array( 'ShopPath' ), 'DisablePathFields' => array( 'DownloadDirectory', 'ImageDirectory' ), 'DisableLoggingSettingsTab' => array( 'SystemLogging', 'HidePHPErrors', 'SystemLogTypes', 'SystemLogSeverity', 'SystemLogMaxLength', 'AdministratorLogging', 'AdministratorLogMaxLength' ), 'DisableProxyFields' => array( 'HTTPProxyServer', 'HTTPProxyPort', 'HTTPSSLVerifyPeer' ), 'DisableBackupSettings' => array( 'BackupsLocal', 'BackupsRemoteFTP', 'BackupsRemoteFTPHost', 'BackupsRemoteFTPUser', 'BackupsRemoteFTPPass', 'BackupsRemoteFTPPath', 'BackupsAutomatic', 'BackupsAutomaticMethod', 'BackupsAutomaticDatabase', 'BackupsAutomaticImages', 'BackupsAutomaticDownloads' ), 'HidePCISettings' => array( 'PCIPasswordMinLen', 'PCIPasswordHistoryCount', 'PCIPasswordExpiryTimeDay', 'PCILoginAttemptCount', 'PCILoginLockoutTimeMin', 'PCILoginIdleTimeMin', 'PCILoginInactiveTimeDay' ) ); foreach($disabledFields as $setting => $fields) { if(GetConfig($setting) == true) { foreach($fields as $field) { unset($GLOBALS['ISC_NEW_CFG'][$field]); } } } $messages = array(); if ($this->CommitSettings($messages)) { $redirectUrl = 'index.php?ToDo=viewSettings¤tTab='.(int)$_POST['currentTab']; // Mark this step as complete in getting started if(GetClass('ISC_ADMIN_ENGINE')->MarkGettingStartedComplete('settings')) { $redirectUrl = 'index.php'; } // Log this action $GLOBALS['ISC_CLASS_LOG']->LogAdminAction(); FlashMessage(GetLang('SettingsSavedSuccessfully'), MSG_SUCCESS, $redirectUrl); } else { FlashMessage(sprintf(GetLang('SettingsNotSaved'), $messages), MSG_ERROR, 'index.php?ToDo=viewSettings¤tTab='.((int) $_POST['currentTab'])); } }