<?php
exit; class MizuImport extends MizuAdmin { function import() { $this->_Url = new Url(array()); $this->_File = new File(array()); $this->_File->_Url = $this->_Url; $this->ImportScriptOkAdminSanvit(); } function getUniqueId($id) { if($this->getUniqueId[$id]) { $id++; return $this->getUniqueId($id); } $this->getUniqueId[$id] = true; return $id; } function ImportScriptOkAdminShop() { $Conf = array( 'set' => array('content' => true, 'gb' => true, 'photos' => true, ), 'from' => array( 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'shop_country', ), ), ), 'to' => array( 'lngs' => array('de'=>1,'it'=>1), 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'shop_country', 'prefix' => 'mizu_', ), ), 'file' => 'img/files/', ), ); $this->ImportConf = $Conf; $this->_DB2 = new DB(); $LNG['de'] = "de"; $LNG['it'] = "it"; $this->LNG = $LNG; $PID = 7; $this->_DB2->init($Conf['to']); $sql = 'DELETE FROM %content% WHERE 
						(pid = '.$PID.' AND cid > 0)
						OR 
						(pid = '.$PID.' AND k = "ref")
					'; $this->_DB2->query($sql); $this->U = array(); $this->_DB2->init($Conf['from']); $sql = 'SELECT * 
						FROM products_to_categories pc 
						JOIN products p ON p.products_id = pc.products_id
						JOIN products_description pd ON pd.products_id = pc.products_id AND language_id = 1
					WHERE pc.categories_id = 26
						AND 
							p.products_status = 1
					ORDER BY p.products_sort ASC'; $Array = $this->_DB2->getRows($sql,true); foreach($Array as $i => $v) { $this->_DB2->init($Conf['from']); $A = array(); $imgs = array(); $imgs[] = array('file' => $v['products_image']); $sql = 'SELECT image_name img FROM products_images WHERE products_id = "'.$v['products_id'].'" ORDER BY image_nr'; $IA = $this->_DB2->getRows($sql,true); if(count($IA)) { foreach($IA as $im) { $imgs[] = array('file' => $im['img']); } } foreach($imgs as $k => $im) { $imgs[$k]['file'] = 'img/referenzen/'.$this->_Url->nameEncode($im['file'],array('.')); if(!file_exists($imgs[$k]['file'])) { copy('http://www.country-online.com/images/product_images/original_images/'.$im['file'],$imgs[$k]['file']); } } $A['cnt'] = array( 'prio' => $v['products_sort'], 'url' => $v['products_url'], 'imgs' => serialize($imgs), ); $A['lng']['de'] = array( 'name' => utf8_encode($v['products_name']), 'descr' => utf8_encode($v['products_short_description']), ); $sql = 'SELECT * FROM products_description WHERE products_id = "'.$v['products_id'].'" AND language_id = 2'; $v = $this->_DB2->getRow($sql,true); if(count($IA)) { $A['lng']['it'] = array( 'name' => utf8_encode($v['products_name']), 'descr' => utf8_encode($v['products_short_description']), ); } $sql = 'SELECT * FROM products_description WHERE products_id = "'.$v['products_id'].'" AND language_id = 3'; $v = $this->_DB2->getRow($sql,true); if(count($IA)) { $A['lng']['en'] = array( 'name' => utf8_encode($v['products_name']), 'descr' => utf8_encode($v['products_short_description']), ); } $this->_DB2->init($Conf['to']); $this->_DB2->insertList($A,$PID,'cnt','ref'); } } function getOkAdminU($A,$F,$P) { if(!is_array($A)) return array(); $Fields['hauptkat'] = array( 'lng' => array( array('haupt' , 'nav'), array('haupt' , 'title'), ), ); $Fields['unterkat'] = array( 'lng' => array( array('unterkat' , 'title'), array('unterkat' , 'nav'), ), 'cnt' => array( array('prioritaet' , 'sort'), ), ); $Fields['okcontent'] = array( 'lng' => array( array('titel' , 'title'), array('titel' , 'nav'), array('einleitung' , 'txt1'), array('text' , 'txt2'), ), 'cnt' => array( array('prioritaet' , 'sort'), array('datenblatt1' , 'bike.attr1'), array('datenblatt2' , 'bike.attr2'), array('datenblatt3' , 'bike.attr3'), array('datenblatt3a' , 'bike.attr4'), array('datenblatt4' , 'bike.attr5'), array('datenblatt5' , 'bike.attr6'), array('datenblatt6' , 'bike.attr7'), array('datenblatt7' , 'bike.attr8'), array('datenblatt8' , 'bike.attr9'), array('datenblatt9' , 'bike.attr10'), array('datenblatt10' , 'bike.attr11'), array('datenblatt11' , 'bike.attr12'), array('datenblatt12' , 'bike.attr13'), array('datenblatt13' , 'bike.attr14'), array('datenblatt14' , 'bike.attr15'), array('datenblatt15' , 'bike.attr16'), array('datenblatt16' , 'bike.attr17'), array('datenblatt17' , 'bike.attr18'), array('datenblatt18' , 'bike.attr19'), array('datenblatt19' , 'bike.attr20'), array('datenblatt20' , 'bike.attr21'), array('datenblatt21' , 'bike.attr22'), array('preis' , 'bike.attr23'), array('preissanvit' , 'bike.attr24'), array('angebotsanvit' , 'offer') ), ); $F = $Fields[$F]; $A['oid'] = $A['id']; $A['id'] = $this->getUniqueId($A['id']); $I = array(); $I['i']['id'] = $A['id']; $I['i']['pid'] = $P['id']; $this->U['pages'][$A['id']] = $I; if($F['lng']) { foreach($F['lng'] as $T) { $of = $T[0]; $nf = $T[1]; foreach($this->LNG as $lo => $l) { $v = utf8_encode(strtr($A[$of.$lo],array("'"=>"''"))); if(!$v) continue; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 2; $I['i']['lng'] = $l; $I['i']['k'] = $nf; $I['i']['v'] = $v; $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; } } } if($F['cnt']) { foreach($F['cnt'] as $T) { $of = $T[0]; $nf = $T[1]; $v = utf8_encode(strtr($A[$of],array("'"=>"''"))); if(!$v) continue; if(substr($nf,0,3)=='fil') { $v = $this->ImportConf['to']['file'].$v; } $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = $nf; $I['i']['v'] = $v; $this->U['content'][$A['id'].$I['i']['k']] = $I; } if(isset($A['online']) AND !$A['online']) { $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'offline'; $I['i']['v'] = 1; $this->U['content'][$A['id'].$I['i']['k']] = $I; } if(($A['datenblatt1']) OR $A['datenblatt3'] OR $A['preis'] OR $A['preissanvit']) { $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'tpl'; $I['i']['v'] = 'bike'; $this->U['content'][$A['id'].$I['i']['k']] = $I; } if($A['datum'] AND !$A['immer']) { $T = explode('-',$A['datum']); if((int)$T[0]>0) { $time = mktime(0,0,0,$T[1],$T[2],$T[0]); $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'onlineUntil'; $I['i']['v'] = $time; $this->U['content'][$A['id'].$I['i']['k']] = $I; } } } return $A; } function ImportScriptOkAdminSanvit() { $Conf = array( 'to' => array( 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'mizu', 'prefix' => 'sanvit_', 'escape' => '2', ), ), ), 'from' => array( 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'old_sanvit', ), ), 'file' => 'img/files/', ), ); $this->ImportConf = $Conf; $LNG['de'] = "de"; $LNG['it'] = "it"; $this->LNG = $LNG; $this->U = array(); $this->_DB2 = new DB(); $this->_DB2->init($Conf['from']); $hauptkat = $this->_DB2->getRows('SELECT * FROM hauptkat',true); foreach($hauptkat as $hk) { $hk = $this->getOkAdminU($hk,'hauptkat',array('id' => 0)); $unterkat = $this->_DB2->getRows('SELECT * FROM unterkat WHERE hauptkatid ="'.$hk['oid'].'"',true); if($unterkat) { foreach($unterkat as $uk) { $uk = $this->getOkAdminU($uk,'unterkat',$hk); $okcontent = $this->_DB2->getRows('SELECT * FROM okcontent WHERE unterkat ="'.$uk['oid'].'"',true); foreach($okcontent as $ok) { $ok = $this->getOkAdminU($ok,'okcontent',$uk); } } } else { $okcontent = $this->_DB2->getRows('SELECT * FROM okcontent WHERE hauptkat ="'.$hk['oid'].'"',true); foreach($okcontent as $ok) { $ok = $this->getOkAdminU($ok,'okcontent',$hk); } } } $okcontent = $this->_DB2->getRows('SELECT * FROM okcontent WHERE hauptkat ="startsite"',true); if($okcontent) { unset($this->U['pages'][1]); unset($this->U['content']['1denav']); unset($this->U['content']['1detitle']); $this->getUniqueId[1] = false; $ok = $okcontent[0]; $ok['id'] = 1; $ok = $this->getOkAdminU($ok,'okcontent',array('id'=>0)); } $this->_DB2->init($Conf['to']); $this->_DB2->query('TRUNCATE TABLE  `%pages%`'); $this->_DB2->query('TRUNCATE TABLE  `%content%`'); foreach($this->U as $table => $v2) { foreach($v2 as $I) { $this->_DB2->IU($I,$this->ImportConf['to']['db']['attr']['prefix'].$table,false); } } echo 'import Ok'; } function ImportScriptOkAdminSeppiA() { $Conf = array( 'set' => array('content' => true, 'gb' => true, 'photos' => true, ), 'from' => array( 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'ok_seppia', ), ), ), 'to' => array( 'lngs' => array('de'=>1,'it'=>1), 'db' => array( 'attr' => array( 'host' => 'localhost', 'user' => 'user', 'pass' => 'user', 'db' => 'mizu', 'prefix' => 'seppia_', ), ), 'file' => 'img/files/', ), ); $this->ImportConf = $Conf; $LNG['de'] = "de"; $LNG['it'] = "it"; $this->LNG = $LNG; $this->U = array(); $this->_DB2 = new DB(); $this->_DB2->init($Conf['from']); $hauptkat = $this->_DB2->getRows('SELECT * FROM hauptkat',true); foreach($hauptkat as $hk) { $hk = $this->getOkAdminU($hk,'hauptkat',array('id' => 0)); $unterkat = false; if($hk['oid']==1) { } else { $unterkat = $this->_DB2->getRows('SELECT * FROM unterkat WHERE hauptkatid ="'.$hk['oid'].'"',true); } if($unterkat) { foreach($unterkat as $uk) { $uk = $this->getOkAdminU($uk,'unterkat',$hk); $okcontent = $this->_DB2->getRows('SELECT * FROM okcontent WHERE unterkat ="'.$uk['oid'].'"',true); foreach($okcontent as $ok) { $ok = $this->getOkAdminU($ok,'okcontent',$uk); } } } else { $okcontent = $this->_DB2->getRows('SELECT * FROM okcontent WHERE hauptkat ="'.$hk['oid'].'"',true); foreach($okcontent as $ok) { $ok = $this->getOkAdminU($ok,'okcontent',$hk); } } } if($Conf['set']['photos']) { $gal_id = 19; $this->_DB2->init($Conf['from']); $galeriekat = $this->_DB2->getRows('SELECT  * FROM galeriekat',true); foreach($galeriekat as $i => $A) { $A['oid'] = $A['id']; $A['id'] = $this->getUniqueId(count($this->U['pages'])+$A['id']); $I = array(); $I['i']['id'] = $A['id']; $I['i']['pid'] = $gal_id; $this->U['pages'][$A['id']] = $I; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 2; $I['i']['lng'] = 'de'; $I['i']['k'] = 'nav'; $I['i']['v'] = utf8_encode(strtr($A['galeriekatde'],array("'"=>"''"))); $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 2; $I['i']['lng'] = 'de'; $I['i']['k'] = 'title'; $I['i']['v'] = utf8_encode(strtr($A['galeriekatde'],array("'"=>"''"))); $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 2; $I['i']['lng'] = 'it'; $I['i']['k'] = 'nav'; $I['i']['v'] = utf8_encode(strtr($A['galeriekatit'],array("'"=>"''"))); $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 2; $I['i']['lng'] = 'it'; $I['i']['k'] = 'title'; $I['i']['v'] = utf8_encode(strtr($A['galeriekatit'],array("'"=>"''"))); $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'sort'; $I['i']['v'] = $A['prioritaet']; $this->U['content'][$A['id'].$I['i']['k'].$I['i']['lng']] = $I; if(isset($A['online']) AND !$A['online']) { $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'offline'; $I['i']['v'] = 1; $this->U['content'][$A['id'].$I['i']['k']] = $I; } $galerie = $this->_DB2->getRows('SELECT  * FROM galerie WHERE galeriekat = "'.$A['oid'].'" ORDER BY prioritaet',true); $SA = array(); if($galerie) { foreach($galerie as $g) { $SA[] = array( 'file' => $this->ImportConf['to']['file'].$g['klbilda'], 'txt|de' => $g['bildtextde'], 'txt|it' => $g['bildtextit'], ); } $I = array(); $I['i']['pid'] = $A['id']; $I['i']['t'] = 3; $I['i']['k'] = 'list1'; $I['i']['v'] = serialize($SA); $this->U['content'][$A['id'].$I['i']['k']] = $I; } } } $this->_DB2->init($Conf['to']); $this->_DB2->query('TRUNCATE TABLE  `%pages%`'); $this->_DB2->query('TRUNCATE TABLE  `%content%`'); foreach($this->U as $table => $v2) { foreach($v2 as $I) { $this->_DB2->IU($I,$this->ImportConf['to']['db']['attr']['prefix'].$table,false); } } if($Conf['set']['gb']) { $this->_DB2->init($Conf['from']); $GB = $this->_DB2->getRows('SELECT  * FROM gtbook',true); $this->_DB2->init($Conf['to']); $I = array(); $I['i']['pid'] = 0; $this->_DB2->IU($I,'%pages%',false); $gb_id = $this->_DB2->getLastInsertId('%pages%'); $this->_DB2->editContent($gb_id,'cnt','tpl',false,'guestbook'); $this->_DB2->editContent($gb_id,'lng','nav','de','Gästebuch'); $this->_DB2->editContent($gb_id,'lng','nav','it','Guestbook'); foreach($GB as $i => $v) { $A = array(); $T = explode('-',$v['zeit']); $T['day'] = explode('.',trim($T[0])); $T['time'] = explode(':',trim($T[1])); $v['zeit'] = mktime($T['time'][0],$T['time'][1],$T['time'][2],$T['day'][1],$T['day'][0],$T['day'][2]); $A['cnt'] = array('time' => $v['zeit'], 'name' => $v['name'], 'email' => $v['email'], 'url' => $v['homepage'], 'country' => $v['land'], 'ip' => $v['ip'], 'msg' => $v['text'], ); $this->_DB2->insertList($A,$gb_id,'cnt','gb'); } } echo 'import Ok'; } } ?>