
 <?php
 $cusresult = getarr_block($pidname);
  // pre($cusresult);
if($cusresult['datares']=='yes'){
 
   // $sqlall="select * from ".TABLE_BLOCK." where pidname='$pidname'  ".ANDLANGBH."  order by id desc limit 1";
    //echo $sqlall;
   
        $blockimg=$blockimg2=$blockimg3=$blockimg4=$bkbz1=$bkbz2=$bkbz3=$cssname= $namefront=$blockid=$nodebtnmore='';
        $bgcolor=$bgimg=$cssstyle= $videosrc= $videotext = $bgtmd = '';
        $bgrepeat= 'no-repeat';
        $bgposi= 'center center';
        $bgsize= 'cover';
        $bgattach = '';
        $stylev=$linkurl=$linktitle='';

        $cus_columns = 2;$cus_substrnum=0;
         $maxline=1;
//-----------------
  $v = $cusresult['data'];
  //pre($v);

   
      foreach ($v['arrcan'] as   $key=>$value) { 
                 $bsccc = $key;
                 $$bsccc=$value;
             }

   
     $tid = $v['id']; $pid = $v['pid'];
     $ppid = $v['pidstylebh'];
     $blockimg = $v['img'];
     $blockimg2 = $v['blockimg2'];
     $blockimg3 = $v['blockimg3'];
     $blockimg4 = $v['blockimg4'];
     $blockimg5 = '';

     $name = $v['name']; //namefront is in can 
      $typecolumn = $v['typecolumn'];
      $template = $v['template']; 
      $pidcate = $v['pidcate'];     


     $cus_columnsv = ' '.cus_columnsfun($cus_columns);
     $cus_columnsv_bt = ' '.cus_columnsfun_bt($cus_columns);


     $dhtrigger = 'jsdh'.rand(1000,9999).'d'.rand(11111,99999);

       $bgvideo= 'n';
     if(is_int(strpos($cssname,'bgvideo'))) $bgvideo= 'y';



    $linkurlv ='';


    $despjj =  $v['despjj'];
    $desp =  $despv = $v['desp'];

    //----------
    if($cssstyle<>'' || $bgcolor<>'' || $bgimg<>''){
     $stylebg = regionbg($bgcolor,$bgimg,$bgrepeat,$bgposi,$bgsize,$bgattach);
    
     if($cssstyle=='')   $stylev =  'style = "'.$stylebg.'"';
      else {
         
              $stylev =  'style = "'.$stylebg.' '.$cssstyle.'"';
          }
    }
    if($bgimg<>'') $cssname = $cssname.' dmbgimg';

    //------------

     if($typecolumn=='column'){
        // echo  $template;
         //$reqfile = BLOCKROOT.$template.'.php';
         $reqfile = SYSBLOCKROOT.'default_column.php';
     }
     else{
           $ppid7 = substr($ppid,0,7);

           // if($ppid=='common')  $reqfile =  SYSBLOCKROOT.$pid.'/'.$template;
           // else if($ppid4=='styl')  $reqfile =  TPLCURROOT.'/selfblock/'.$pid.'/'.$template;
           // else if($ppid4=='vipb')  $reqfile =  BLOCKROOT.'vipblock/'.$pid.'/'.$template;
          //  else if($ppid4=='jtef')  $reqfile =  BLOCKROOT.'jteffect/'.$ppid.'/'.$template;
       if($ppid7=='jthome_')  $reqfile =  BLOCKROOT.'jthome/'.$ppid.'/'.$template;
       else if($ppid7=='jteffec')  $reqfile =  BLOCKROOT.'jteffect/'.$ppid.'/'.$template;
       else if($ppid7=='mbhome_')  $reqfile =  TPLCURROOT.'selfblock/mbhome/'.$ppid.'/'.$template;
       else {
          if(substr($template,0,5)=='comm_')  $reqfile =  BLOCKROOT.'jtblock/jtblock_common/'.$template;
          else if(substr($template,0,5)=='self_')  $reqfile = TPLCURROOT.'selfblock/'.$pid.'/'.$template;
          else  if(substr($template,0,7)=='bknode_')  $reqfile =  BLOCKROOT.'jtblock/jtblock_bknode/'.$template;
          else if(substr($template,0,5)=='bkdh_')  $reqfile =  BLOCKROOT.'jtblock/jtblock_bkdh/'.$template;
          else   $reqfile =   BLOCKROOT.'jtblock/'.$ppid.'/'.$template;

        }




    if($pid=='bknode' || $pid=='bkblockdh'){

             //------------------
          if($pid=='bknode'){ 
              edit_fenode($pidcate);//用来在前台编辑后台。
              if(substr($pidcate, 0,4)=='cate') $pidcatemain = $pidcate;
              else $pidcatemain = get_field(TABLE_CATE,'ppid',$pidcate,'pidname');

                $sqlwhere = wherecatev($pidcatemain,$pidcate);
                $orderv = " order by pos desc,dateedit desc ";
              }
             else { 
             // $sqlwhere = " pid='$pidcate' and modtype='blockdh' ";
              $orderv = " order by pos desc,id ";
               edit_fenode_blockdh($pidcate);//用来在前台编辑后台。
             }

             if(is_int(strpos($cssname,'nodetj'))) $wheretj= " and sta_tj='y' ";
             else $wheretj='';
             if(is_int(strpos($cssname,'nodenew'))) $wherenew= " and sta_new='y' ";
             else $wherenew='';


            //$sqlnode="select * from ".TABLE_NODE." where  $sqlwhere and sta_visible='y' $wheretj $wherenew ".ANDLANGBH." $orderv limit 0,$maxline";
               //echo $sqlnode;
           // $fenum = getnum($sqlnode);
            //if($fenum==0) {

              //if($pidcate<>'nocate') {  //when member node,then not notice error.
                 //  if(!is_int(strpos($pidcate,'|')))  echo '没有node记录  in vblock.php';
              //}

              // $result = array();
            //}
           // else  $result = getall($sqlnode);

               $sqlarr = array( 
                'excerpt'=>$cus_substrnum,
                'start'=>0,
                'maxline'=>$maxline,
                'order'=>'','where'=>$wheretj.$wherenew
                );
               //pre($sqlarr);
              $result = getarr_node($pidcate,$sqlarr);

             //pre($result);

          //--------------
         }
  }


  if(checkfile($reqfile))   require $reqfile;


}
else {
  echo errorhtml($cusresult['error']);
}

?>
