insert_data($themedata); } } } //关闭 closedir($dh); } } function readthemedata($xmlpath){ $importtxt = @implode('',file($xmlpath)); $data = xml2array($importtxt,FALSE,'UTF-8'); $_attributes=xmlattribute($importtxt,'UTF-8'); //item 属性获取 $themearr = [ 'themename'=>$data['themename'], 'themetag'=>isset($data['templatetag']) ? serialize($data['templatetag']):'' ]; if(isset($data['singlepage'])){ $singlepagedata = []; foreach($data['singlepage'] as $k=>$v){ if(isset($_attributes['singlepage'][$k]['_attributes']['priority'])){ $singlepagedata[$k]['disp'] = $_attributes['singlepage'][$k]['_attributes']['priority']; }else{ $singlepagedata[$k]['disp'] = 0; } $singlepagedata[$k]['name'] = $v; } $themearr['templates'] = serialize($singlepagedata); } if(isset($data['colors'])){ $themearr['colors'] = $data['colors']['colorlist']; $themearr['selcolor'] = $data['colors']['defaultcolor']; } return $themearr; } exit('success');