Example #1
0
 public static function GetDBName($DBName)
 {
     $DBName = strtolower($DBName);
     $dbObject = Registry::getDB($DBName);
     $NoUTF8 = FALSE;
     if (is_null($dbObject)) {
         switch ($DBName) {
             case self::DATABASE_MYDB:
                 $database = self::DATABASE_MYDB;
                 $user = self::DATABASE_MYDB_USER;
                 $password = self::DATABASE_MYDB_PASSWORD;
                 break;
             case self::DATABASE_OFBIZ:
                 $database = self::DATABASE_OFBIZ;
                 $user = self::OFBIZ_USER;
                 $password = self::OFBIZ_PASSWORD;
                 break;
             case self::DATABASE_OFBIZ2:
                 // Allow second open
                 $database = self::DATABASE_OFBIZ;
                 $user = self::OFBIZ_USER;
                 $password = self::OFBIZ_PASSWORD;
                 break;
             case self::DATABASE_OFBIZ_REPLICATED:
                 $database = self::DATABASE_OFBIZ;
                 $user = self::NEOBITS_USER;
                 $password = self::NEOBITS_PASSWORD;
                 break;
             case self::DATABASE_OFBIZ_FED:
                 $database = self::DATABASE_OFBIZ_FED;
                 $user = self::OFBIZ_USER;
                 $password = self::OFBIZ_PASSWORD;
                 break;
             case self::DATABASE_OFBIZWORK:
                 $database = self::DATABASE_OFBIZWORK;
                 $user = self::OFBIZWORK_USER;
                 $password = self::OFBIZWORK_PASSWORD;
                 break;
             case self::DATABASE_OFBIZEXTRA:
                 $database = self::DATABASE_OFBIZEXTRA;
                 $user = self::OFBIZEXTRA_USER;
                 $password = self::OFBIZEXTRA_PASSWORD;
                 break;
             case self::DATABASE_OFBIZNICK:
                 $database = self::DATABASE_OFBIZNICK;
                 $user = self::OFBIZNICK_USER;
                 $password = self::OFBIZNICK_PASSWORD;
                 break;
                 // We use root user for replicated so we can do function CopyTableAcrossSevers
                 // This requires creating a temporary table on read only MySQL, which is ok
                 // But it won't allow adding of records due to MySQL bug.
                 // Replicated copy is read-only, and, ofbiz user does not have SUPER
             // We use root user for replicated so we can do function CopyTableAcrossSevers
             // This requires creating a temporary table on read only MySQL, which is ok
             // But it won't allow adding of records due to MySQL bug.
             // Replicated copy is read-only, and, ofbiz user does not have SUPER
             case self::DATABASE_OFBIZEXTRA_REPLICATED:
                 $database = self::DATABASE_OFBIZEXTRA;
                 $user = self::NEOBITS_USER;
                 $password = self::NEOBITS_PASSWORD;
                 break;
             case self::DATABASE_SCREENS:
                 $database = self::DATABASE_SCREENS;
                 $user = self::SCREENS_USER;
                 $password = self::SCREENS_PASSWORD;
                 break;
             case self::DATABASE_SESSIONS:
                 $database = self::DATABASE_SCREENS;
                 $user = self::SCREENS_USER;
                 $password = self::SCREENS_PASSWORD;
                 break;
             case self::DATABASE_FEEDS:
                 $database = self::DATABASE_FEEDS;
                 $user = self::FEEDS_USER;
                 $password = self::FEEDS_PASSWORD;
                 break;
             case self::DATABASE_FEEDS2:
                 // Allow second open of Feeds database
                 $database = self::DATABASE_FEEDS;
                 $user = self::FEEDS_USER;
                 $password = self::FEEDS_PASSWORD;
                 break;
             case self::DATABASE_FEEDS_FED:
                 $database = self::DATABASE_FEEDS_FED;
                 $user = self::FEEDS_USER;
                 $password = self::FEEDS_PASSWORD;
                 break;
             case self::DATABASE_ETILIZE:
                 $database = self::DATABASE_ETILIZE;
                 $user = self::ETILIZE_USER;
                 $password = self::ETILIZE_PASSWORD;
                 break;
             case self::DATABASE_POWERSYSTEMS:
                 $database = self::DATABASE_POWERSYSTEMS;
                 $user = self::POWERSYSTEMS_USER;
                 $password = self::POWERSYSTEMS_PASSWORD;
                 $NoUTF8 = TRUE;
                 break;
             case self::DATABASE_POWERSYSTEMSZEN:
                 $database = self::DATABASE_POWERSYSTEMSZEN;
                 $user = self::POWERSYSTEMS_USER;
                 $password = self::POWERSYSTEMS_PASSWORD;
                 break;
             case self::DATABASE_SOHOPBXWORLD:
                 $database = self::DATABASE_SOHOPBXWORLD;
                 $user = self::SOHOPBXWORLD_USER;
                 $password = self::SOHOPBXWORLD_PASSWORD;
                 break;
             case self::DATABASE_VARSCAPE:
                 $database = self::DATABASE_VARSCAPE;
                 $user = self::VARSCAPE_USER;
                 $password = self::VARSCAPE_PASSWORD;
                 break;
             case self::DATABASE_PHPLISTVARSCAPE:
                 $database = self::DATABASE_PHPLISTVARSCAPE;
                 $user = self::VARSCAPE_USER;
                 $password = self::VARSCAPE_PASSWORD;
                 break;
             case self::DATABASE_STOREFEED:
                 $database = self::DATABASE_STOREFEED;
                 $user = self::STOREFEED_USER;
                 $password = self::STOREFEED_PASSWORD;
                 break;
             case self::DATABASE_NEOBITS:
                 $database = self::DATABASE_NEOBITS;
                 $user = self::NEOBITS_USER;
                 $password = self::NEOBITS_PASSWORD;
                 break;
             case self::DATABASE_CONSULTING:
                 $database = self::DATABASE_CONSULTING;
                 $user = self::CONSULTING_USER;
                 $password = self::CONSULTING_PASSWORD;
                 break;
             case self::DATABASE_EXTRACTION:
                 $database = self::DATABASE_EXTRACTION;
                 $user = self::EXTRACTION_USER;
                 $password = self::EXTRACTION_PASSWORD;
                 break;
             case self::DATABASE_SHIPPING:
                 $database = self::DATABASE_SHIPPING;
                 $user = self::SHIPPING_USER;
                 $password = self::SHIPPING_PASSWORD;
                 break;
             default:
                 trigger_error("Database {$DBName} not configured in Config class, please fix", E_USER_ERROR);
         }
         $port = NULL;
         $socket = NULL;
         $dbFlags = NULL;
         if (self::$IsWeb) {
             if (isset($_SERVER["DEFAULT_HOST"])) {
                 $host = $_SERVER["DEFAULT_HOST"];
             }
             if (isset($_SERVER["DEFAULT_PORT"])) {
                 $port = $_SERVER["DEFAULT_PORT"];
             }
             if (isset($_SERVER["DEFAULT_DBFLAGS"])) {
                 $dbFlags = $_SERVER["DEFAULT_DBFLAGS"];
             }
         } else {
             if (getenv("DEFAULT_HOST") !== FALSE) {
                 $host = getenv("DEFAULT_HOST");
             }
             if (getenv("DEFAULT_PORT") !== FALSE) {
                 $port = getenv("DEFAULT_PORT");
             }
             if (getenv("DEFAULT_DBFLAGS") !== FALSE) {
                 $dbFlags = getenv("DEFAULT_DBFLAGS");
             }
         }
         if (self::$IsWeb) {
             if (isset($_SERVER["DEFAULT_HOST"])) {
                 $host = $_SERVER["DEFAULT_HOST"];
             }
             if (isset($_SERVER["{$DBName}_HOST"])) {
                 $host = $_SERVER["{$DBName}_HOST"];
             }
             if (isset($_SERVER["DEFAULT_PORT"])) {
                 $port = $_SERVER["DEFAULT_PORT"];
             }
             if (isset($_SERVER["{$DBName}_PORT"])) {
                 $port = $_SERVER["{$DBName}_PORT"];
             }
             if (isset($_SERVER["{$DBName}_SOCKET"])) {
                 $socket = $_SERVER["{$DBName}_SOCKET"];
             }
             if (isset($_SERVER["DEFAULT_DBFLAGS"])) {
                 $dbFlags = $_SERVER["DEFAULT_DBFLAGS"];
             }
             if (isset($_SERVER["{$DBName}_DBFLAGS"])) {
                 $dbFlags = $_SERVER["{$DBName}_DBFLAGS"];
             }
         } else {
             if (getenv("DEFAULT_HOST") !== FALSE) {
                 $host = getenv("DEFAULT_HOST");
             }
             if (getenv("{$DBName}_HOST") !== FALSE) {
                 $host = getenv("{$DBName}_HOST");
             }
             if (getenv("DEFAULT_PORT") !== FALSE) {
                 $port = getenv("DEFAULT_PORT");
             }
             if (getenv("{$DBName}_PORT") !== FALSE) {
                 $port = getenv("{$DBName}_PORT");
             }
             if (getenv("{$DBName}_SOCKET") !== FALSE) {
                 $socket = getenv("{$DBName}_SOCKET");
             }
             if (getenv("DEFAULT_DBFLAGS") !== FALSE) {
                 $dbFlags = getenv("DEFAULT_DBFLAGS");
             }
             if (getenv("{$DBName}_DBFLAGS") !== FALSE) {
                 $dbFlags = getenv("{$DBName}_DBFLAGS");
             }
         }
         if (!empty(self::$ScreenEnvironment)) {
             if (self::$ScreenEnvironment->{"{$DBName}_HOST"}) {
                 $host = trim((string) self::$ScreenEnvironment->{"{$DBName}_HOST"});
             }
             if (self::$ScreenEnvironment->{"{$DBName}_PORT"}) {
                 $port = trim((string) self::$ScreenEnvironment->{"{$DBName}_PORT"});
             }
             if (self::$ScreenEnvironment->{"{$DBName}_SOCKET"}) {
                 $socket = trim((string) self::$ScreenEnvironment->{"{$DBName}_SOCKET"});
             }
             if (self::$ScreenEnvironment->{"{$DBName}_DBFLAGS"}) {
                 $dbFlags = trim((string) self::$ScreenEnvironment->{"{$DBName}_DBFLAGS"});
             }
         }
         if (!isset($host)) {
             $host = self::$Host;
         }
         $dbObject = new Database($database, $host, $user, $password, $port, $socket, $dbFlags, $NoUTF8);
         Registry::set($DBName, $dbObject);
     }
     return $dbObject;
 }
 public function __construct($options = array())
 {
     if (!empty($options['URL'])) {
         $this->URL = $options['URL'];
     }
     if (!empty($options['Name'])) {
         $this->Name = $options['Name'];
     }
     if (!empty($options['Type'])) {
         $this->Type = $options['Type'];
     }
     if (!empty($options['Status'])) {
         $this->Status = $options['Status'];
     }
     if (!empty($options['Script'])) {
         $this->Script = $options['Script'];
     }
     if (!empty($options['Server'])) {
         $this->Server = $options['Server'];
     }
     if (!empty($options['Frequency'])) {
         $this->Frequency = $options['Frequency'];
     }
     if (!empty($options['Manufacturer_ID'])) {
         $this->Manufacturer_ID = $options['Manufacturer_ID'];
     }
     $this->Status = 'ok';
     // Setup db object for using class on host8
     #$this->dbObject = Config::GetDBName(Config::DATABASE_MYDB);
     // Setup db object for using class on scrape servers
     $dbObject = Registry::getDB('additional_content');
     $NoUTF8 = FALSE;
     $port = NULL;
     $socket = NULL;
     $dbFlags = NULL;
     $host = 'localhost';
     $database = 'additional_content';
     $user = 'root';
     $password = 'root';
     $this->dbObject = new Database($database, $host, $user, $password, $port, $socket, $dbFlags, $NoUTF8);
     Registry::set('additional_content', $this->dbObject);
     // Check if Source is already defined in our db
     $sqlStmt = "SELECT Source_ID FROM Additional_Content_Sources WHERE Name = '{$this->Name}'";
     $results = $this->dbObject->SelectAndReturnRow($sqlStmt, true);
     if (empty($results["Source_ID"])) {
         // Insert new source
         $sqlStmt = "INSERT INTO Additional_Content_Sources (Manufacturer_ID, URL, Name, Type, Status, Script, Server, Frequency) VALUES ('{$this->Manufacturer_ID}', '{$this->URL}', '{$this->Name}', '{$this->Type}', '{$this->Status}', '{$this->Script}', '{$this->Server}', '{$this->Frequency}')";
         $this->Content_Source_ID = $this->dbObject->InsertRow($sqlStmt, true);
     } else {
         $this->Content_Source_ID = $results["Source_ID"];
     }
     $list = array('SKU', 'UPC', 'GTIN', 'Manufacturer', 'Name', 'MarketingDescr', 'Manufacturer_ID', 'TechnicalDescr', 'MAP', 'Weight', 'MSRP', 'MainCategory', 'Categories', 'Warranty', 'SubCategory', 'SubCategory2', 'SubCategory3', 'Length', 'Width', 'Height', 'length', 'width', 'height', 'MainImage', 'Product_ID', 'Ofbiz_Mfr_ID', 'MD5', 'Content_Source_ID', 'CREATED_DATE', 'UPDATED_DATE', 'manufacturer', 'title', 'description', 'technical', 'mincategory', 'subcategory', 'subcategory2', 'subcategory3', 'mainimage', 'weight');
     // Get all additional fields that are already in db
     $sqlStmt = "SELECT Field_Name FROM Additional_Content_Fields";
     $results = $this->dbObject->SelectAndReturnAllRows($sqlStmt, true);
     $additional_fields_list = array();
     // Add additional fields we have into list array
     foreach ($results as $result) {
         $list[] = $result['Field_Name'];
         $additional_fields_list[] = $result['Field_Name'];
     }
     $this->fields = $list;
     $this->additional_fields = $additional_fields_list;
 }