charset($Config['Database']['Charset']); /* $SQL = 'ALTER TABLE `TableName` DROP `ItemId`, DROP `Author`, DROP `ValidTimeFrom`, DROP `ValidTimeTo`, DROP `CreationTime`, DROP `DeletionTime`;'; $SystemList = new ListSystemList(); $SystemList->ApplySQLToItems($SQL); die(); */ echo("Import users to Subject\n"); $Database->query('TRUNCATE TABLE Subject'); $DbResult = $Database2->select(array('Database' => 'is', 'Table' => 'old_users')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'Subject'), array('Id' => $DbRow['id'], 'Name' => $DbRow['subject_name'], 'AddressStreet' => $DbRow['street'], 'AddressTown' => $DbRow['town'], 'AddressZIP' => $DbRow['psc'], 'IC' => $DbRow['ico'], 'DIC' => $DbRow['dic'])); //echo($Database->LastQuery."\n"); } } echo("Import users to Users\n"); $Database->query('TRUNCATE TABLE User'); $DbResult = $Database2->select(array('Table' => 'old_users')); while($DbRow = $DbResult->fetch_array()) { { $PermissionGroup = 0; if($DbRow['nick'] == 'chronos') $PermissionGroup = 1; $Database->insert(array('Table' => 'User'), array('Id' => $DbRow['id'], 'UserName' => $DbRow['nick'], 'Password' => sha1($DbRow['password']), 'FirstName' => $DbRow['first_name'], 'SecondName' => $DbRow['second_name'], 'Email' => $DbRow['email'], 'Phone' => $DbRow['phone'], 'ICQ' => $DbRow['icq'], 'Member' => $DbRow['id'], 'RegistrationTime' => $DbRow['membership_date'], 'LastLoginTime' => $DbRow['lastlogin'], 'PermissionGroup' => $PermissionGroup)); //echo($Database->LastQuery."\n"); } } echo("Import hosts to Host\n"); $Database->query('TRUNCATE TABLE Host'); $DbResult = $Database2->select(array('Table' => 'hosts')); while($DbRow = $DbResult->fetch_array()) { $Database->insert(array('Table' => 'Host'), array('Id' => $DbRow['id'], 'DomainName' => strtolower($DbRow['name']), 'LocalIPAddress' => $DbRow['IP'], 'PublicIPAddress' => $DbRow['external_ip'], 'ParentHost' => $DbRow['parent'])); } echo("Import users to Member\n"); $Database->query('TRUNCATE TABLE Member'); $DbResult = $Database2->select(array('Table' => 'old_users')); while($DbRow = $DbResult->fetch_array()) { if($DbRow['role'] == 2) { $Database->insert(array('Table' => 'Member'), array('Id' => $DbRow['id'], 'Subject' => $DbRow['id'], 'ResponsibleUser' => $DbRow['id'], 'FamilyMemberCount' => $DbRow['family'], 'MembershipDate' => $DbRow['membership_date'], 'Tariff' => $DbRow['inet_tarif_now'], 'MemberState' => 2)); //echo($Database->LastQuery."\n"); } } echo("Import network_segments to NetworkSegment\n"); $Database->query('TRUNCATE TABLE NetworkSegment'); $DbResult = $Database2->select(array('Table' => 'network_segments')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'NetworkSegment'), array('Id' => $DbRow['id'], 'Name' => $DbRow['name'], 'TotalAssetCost' => $DbRow['price'], 'MemberCount' => $DbRow['users'], 'ParentSegment' => $DbRow['parent'])); //echo($Database->LastQuery."\n"); } } echo("Import network_devices to StockCard\n"); $Database->query('TRUNCATE TABLE StockCard'); $DbResult = $Database2->query('SELECT consumption,name FROM `network_devices` GROUP BY name'); //echo($Database2->LastQuery."\n"); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'StockCard'), array('Name' => $DbRow['name'], 'Consumption' => $DbRow['consumption'])); //echo($Database->LastQuery."\n"); } } echo("Import network_devices to Asset\n"); $Database->query('TRUNCATE TABLE Asset'); $DbResult = $Database2->query('SELECT `is`.`network_devices`.*, (SELECT `webis_centrala`.`StockCard`.`Id` FROM `webis_centrala`.`StockCard` WHERE `webis_centrala`.`StockCard`.`Name` LIKE `network_devices`.`name`) AS `StockCard` FROM `is`.`network_devices`'); //echo($Database2->LastQuery."\n"); while($DbRow = $DbResult->fetch_array()) { if($DbRow['used'] == 0) $State = 4; else if($DbRow['used'] == 1) $State = 2; else if($DbRow['used'] == 2) $State = 1; $Database->insert(array('Table' => 'Asset'), array('Id' => $DbRow['id'], 'StockCard' => $DbRow['StockCard'], 'Price' => $DbRow['price'], 'SerialNumber' => $DbRow['device_id'], 'PurcheasedFrom' => $DbRow['shop'], 'TimeEnlistment' => $DbRow['TimeEnlistment'], 'TimeElimination' => $DbRow['TimeElimination'], 'State' => $State, 'MemberLocation' => $DbRow['user'])); //echo($Database->LastQuery."\n"); } echo("Import news_category to NewsGroup\n"); $Database->query('TRUNCATE TABLE NewsGroup'); $DbResult = $Database2->select(array('Table' => 'news_category')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'NewsGroup'), array('Id' => $DbRow['id'], 'Name' => $DbRow['caption'])); //echo($Database->LastQuery."\n"); } } echo("Import news to NewsItem\n"); $Database->query('TRUNCATE TABLE NewsItem'); $DbResult = $Database2->select(array('Table' => 'news')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'NewsItem'), array('Id' => $DbRow['id'], 'Title' => $Database->real_escape_string($DbRow['title']), 'Content' => $Database->real_escape_string($DbRow['content']), 'NewsGroup' => $DbRow['category'], 'TargetTime' => $DbRow['date'])); //echo($Database->LastQuery."\n"); } } echo("Import Meals to EatingPlaceMenu\n"); $Database->query('TRUNCATE TABLE EatingPlaceMenu'); $DbResult = $Database2->select(array('Table' => 'Meals'), '*'); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'EatingPlaceMenu'), array('Day' => $DbRow['Date'], 'Soup' => $DbRow['Soup'], 'Meal' => $DbRow['Meal'], 'Status' => $DbRow['Status'])); //echo($Database->LastQuery."\n"); } } echo("Import network_dns_alias to DNSAlias\n"); $Database->query('TRUNCATE TABLE DNSAlias'); $DbResult = $Database2->query('SELECT *, (SELECT id FROM hosts WHERE lower(hosts.name) = network_dns_alias.target) as host FROM network_dns_alias'); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'DNSAlias'), array('Name' => $DbRow['name'], 'Host' => $DbRow['host'])); //echo($Database->LastQuery."\n"); } } /*echo("Import ChatHistory to ChatHistory\n"); $Database->query('TRUNCATE TABLE ChatHistory'); $DbResult = $Database2->select(array('Table' => 'ChatHistory')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'ChatHistory'), array('Id' => $DbRow['Id'], 'Nick' => $Database->real_escape_string($DbRow['Nick']), 'Message' => $Database->real_escape_string($DbRow['Text']), 'RoomName' => $DbRow['RoomName'], 'RoomType' => $DbRow['RoomType'], 'Color' => $DbRow['Color'], 'HostAddress' => $DbRow['Host'])); //echo($Database->LastQuery."\n"); } }*/ echo("Import finance_monthly_overall to FinanceMonthlyOverall\n"); $Database->query('TRUNCATE TABLE FinanceMonthlyOverall'); $DbResult = $Database2->select(array('Table' => 'finance_monthly_overall')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'FinanceMonthlyOverall'), array('TotalPaid' => $DbRow['total_paid'], 'MemberCount' => $DbRow['member_count'], 'TotalConsumption' => $DbRow['consumption_total'], 'TotalAdministration' => $DbRow['administration_total'], 'PricePerKWh' => $DbRow['kWh'], 'Date' => $DbRow['date'], 'Administration' => $DbRow['administration'], 'Internet' => $DbRow['money'])); //echo($Database->LastQuery."\n"); } } echo("Import finance_tariffs to Tariff\n"); $Database->query('TRUNCATE TABLE Tariff'); $DbResult = $Database2->select(array('Table' => 'finance_tariffs')); while($DbRow = $DbResult->fetch_array()) { { if($DbRow['group_id'] != 2) $DbRow['price'] = 50 + 140 * $DbRow['price_units']; if($DbRow['group_id'] == 1) { $DbRow['min_speed'] = 32 * $DbRow['speed_factor']; $DbRow['max_speed'] = 512 * $DbRow['speed_factor']; } $Database->insert(array('Table' => 'Tariff'), array('Name' => $DbRow['name'], 'Price' => $DbRow['price'], 'MinUploadSpeed' => $DbRow['min_speed'], 'MaxUploadSpeed' => $DbRow['max_speed'], 'MinDownloadSpeed' => $DbRow['min_speed'], 'MaxDownloadSpeed' => $DbRow['max_speed'], 'MonthPeriod' => $DbRow['period'])); //echo($Database->LastQuery."\n"); } } echo("Import SubjectOpenTimeInterval to SubjectOpenTime\n"); $Database->query('TRUNCATE TABLE SubjectOpenTime'); $DbResult = $Database2->select(array('Table' => 'SubjectOpenTimeInterval')); while($DbRow = $DbResult->fetch_array()) { { $Database->insert(array('Table' => 'SubjectOpenTime'), array('Subject' => $DbRow['Subject'], 'Id' => $DbRow['Id'], 'OpenTime' => $DbRow['OpenTime'], 'CloseTime' => $DbRow['CloseTime'])); //echo($Database->LastQuery."\n"); } } ?>