<?php
/*	欢迎使用DM企业建站系统，本系统由www.demososo.com开发。
*/
require_once '../config_a/common.inc2010.php';

$switchlanglink = 'mod_style/mod_style.php?';

//
 if($act <> "pos") zb_insert($_POST);
 
 if($pidname<>'') {
  ifhaspidname(TABLE_STYLE,$pidname);
 
}

 
//ifhaspidname(TABLE_NODE,$pid);
//ifhaspidname(TABLE_CATE,$catpid);
ifhave_lang(LANG);//TEST if have lang,if no ,then jump

 $leftsidecollapsed='-y';//not del


$jumpv='mod_style_daoregion.php?lang='.LANG;
 
//----
$submenu='basic';
$title = '模板管理';


 $filedir = TPLCURROOT.'block/home/';
 $arr = getFile($filedir); 
 if(count($arr)==0){

    echo 'there is no file in block/home';
    exit;
 }


 
if($act == "dao")
{ 
   

    $sql = "SELECT * from ".TABLE_REGION." where pidname = '$abc1'   $andlangbh order by pos desc,id desc";
    if(getnum($sql)==0){
       echo 'region pidname is error...';
       exit;
    }

    
    foreach ($arr as $k => $v) {
            
            $blockid = HTMLDIR.'/block/home/'.substr($v,0,-4);

           $ss = "SELECT * from ".TABLE_REGION." where pid = '$abc1' and blockid = '$blockid'  $andlangbh order by pos desc,id desc";
          // echo $ss.'<br />';
               if(getnum($ss)==0){


         
           $i=$k+10;
          $pidnamesub='sreg'.$bshou.$i;
          

         $arr_cfg = 'reganchor:##==#==cssname:##==#==cssstyle:##==#==linktitle:##==#==linkurl:##==#==titlefg:##notitle==#==sta_width_title:##y==#==sta_width_cnt:##y==#==dmpadT:##==#==dmpadB:##==#==titleimg:##==#==titlestyle:##==#==titlestylesub:##==#==titlelineshort:##==#==titlelinelong:##==#==bgcolor:##==#==bgimg:##==#==bgposi:##center center==#==bgattach:##fixed==#==bgrepeat:##no-repeat==#==bgsize:##cover';

       $ss = "insert into ".TABLE_REGION." (pid,blockid,pidname,pbh,name,lang,arr_cfg) values ('$abc1','$blockid','$pidnamesub','$user2510','$v','".LANG."','$arr_cfg')";
     //echo $ss;exit;
       //  echo $ss.'<Br />';
           iquery($ss);  
          }
       
          
    }
     jump($jumpv.'&act=ok'); 



}
else{



 

require_once HERE_ROOT.'mod_common/tpl_header.php'; 

?>
<div class="page-title-box">
 <h4 class="page-title">把block/home里的文件 导入到 页面区域    </h4>

<div class="clearfix"></div>
  </div>

 <div class="row">
      <div class="col-md-12">
        <div class="white-box">

<?php 
    if($act=='ok'){
      echo '导入成功。请前往 页面区域 查看。';
    }
    else {
?>


  <form   onsubmit="javascript:return checkhere(this)" action="<?php echo $jumpv;?>&act=dao" method="post">
  <table class="formtab">

      <tr>
      <td width="20%" class="tr"> block/home下的文件： </td>
      <td width="78%">

          <?php 
          
          pre($arr);
 

 ?> 
</td></tr>

    <tr>
      <td width="20%" class="tr"> 选择页面区域： </td>
      <td width="78%">

 <div style="padding:20px 0">
 
    <?php
     $sql = "SELECT * from ".TABLE_REGION." where pid = '0' and ( pidstylebh='common' or pidstylebh ='$curstyle')   $andlangbh order by pos desc,id desc";
//and  (pidstylebh='y' or pidstylebh='$curstyle')
  // echo $sql;
if(getnum($sql)>0){

  $rowlist = getall($sql);
   // pre($rowlist);
  echo '<select name="region"><option value="">请选择</option>';
    foreach($rowlist as $vcat){
       $name=$vcat['name'];

       $sta_visible=$vcat['sta_visible'];
     
       $pidname=$vcat['pidname']; 

       $sta_visiblev=$sta_visible<>'y'?'[隐藏]':'';

        echo '<option value="'.$pidname.'">'.$name.$sta_visiblev.'</option>';


   }
   echo '</select>';


}

?>

 </div>

 
 </td>
    </tr>

<tr>
      <td></td>
      <td>
      <input  class="mysubmit" type="submit" name="Submit" value="导入到页面区域"></td>
    </tr>


 
  </table>
</form>
<?php 
}
?>


        </div>
        </div>
        </div>  
<script>
function checkhere(thisForm) {
   if ($.trim(thisForm.region.value)==""){
    alert("请选择页面区域");
    thisForm.region.focus();
    return (false);
  }
 

 
   // return;

}
 

 </script>

 
<?php
require_once HERE_ROOT.'mod_common/tpl_footer.php';

}
?>



 