<?php
defined('ROOT_PHPLEFT') or exit(require '../404.php');
function keytb($key){
    foreach($key as $it=>$s) {
	if($s=='linkurl') $tbl.='';
	$tbl.=','.$s;
	}
	return $tbl;
}

function table_name($value){
   global $PL_CFG;
   if ($value==$PL_CFG['tb_pre'].'admin') $name = '管理员';
   if ($value==$PL_CFG['tb_pre'].'member') $name = '会员';
   if ($value==$PL_CFG['tb_pre'].'member_group') $name = '会员组';
   if ($value==$PL_CFG['tb_pre'].'menu') $name = '频道';
   if ($value==$PL_CFG['tb_pre'].'module') $name = '模型';
   if ($value==$PL_CFG['tb_pre'].'plugins') $name = '插件';
   if ($value==$PL_CFG['tb_pre'].'setting') $name = '设置';
   if ($value==$PL_CFG['tb_pre'].'sort') $name = '分类';
   if ($value==$PL_CFG['tb_pre'].'table') $name = '字段';
   $list = sql_list("table=plugins");
   foreach($list as $id=>$m) {
	if ($value==$PL_CFG['tb_pre'].$m['plugins']) $name = $m['plugins_name'];   
	   
   }
   $list = sql_list("table=menu&where=fou=1");
   foreach($list as $id=>$m) {
	if ($value==$PL_CFG['tb_pre'].$m['module'].'_'.$m['id']) $name = $m['name'];   
	   
   }


   return $name;
}

function menucode($arr,$r){
	foreach($arr as $k=>$v) {
	if ($r==$v[0]){
	$tab="_on";
	}else{
	$tab="";	
	}
	$menu.='<td id="'.$k.'" class="tab'.$tab.'"><a href="'.$v[1].'">'.$v[2].'</a></td><td class="tab_nav">&nbsp;</td>';
	}
	return $menu;
}
function msg($msg = errmsg, $forward = 'goback', $location = '0', $time = '1' ,$url = '1',$r = 'y') {
	global $PL_CFG;
	if(!$msg && $forward && $forward != 'goback') gourl($forward);
	include 'template/msg.tpl.php';
    exit;
}
function adminleve($leve){
	if ($leve==0) $lname="网站创始人";
	if ($leve==1) $lname="超级管理员";
	if ($leve==2) $lname="普通管理员";
	return $lname;
}
function inTemplate($filename){
	$filenames="template/".$filename.".tpl.php";
	return $filenames;
}
function cTemplate($filename){
	$filenames=$filename.".inc.php";
	return $filenames;
}
function FTemplate($filename){
	$filenames="template/file/".$filename.".tpl.php";
	return $filenames;
}
function PTemplate($filename){
	$filenames=PL_ROOT."plugins/".$filename.".tpl.php";
	return $filenames;
}
function MTemplate($filename,$module){
	$filenames= PL_ROOT."phpleft/".$module."/admin/".$filename.".php";
	return $filenames;
}
function plcenter($PATH){
	$line = file_get_contents($PATH);
	if(strpos($line,DMS) > 0){
    $url="";
}else{
   $url="http://www.".SOFTNAME.".com";	
}
    echo $url;
}
function deldir($dir) {
  $dh=opendir($dir);
  while ($file=readdir($dh)) {
    if($file!="." && $file!="..") {
      $fullpath=$dir."/".$file;
      if(!is_dir($fullpath)) {
          unlink($fullpath);
      } else {
          deldir($fullpath);
      }
    }
  }

  closedir($dh);
  
  if(rmdir($dir)) {
    return true;
  } else {
    return false;
  }
} 
function text_php($content){
	
	
}





function input($type = '',$key = '',$id = '',$valuet = '',$catid = '',$keyvalue = '',$add_js = '',$note = '',$inputvalue = '',$image_size = '',$menuid = '',$template = 'show'){
$image_size = $image_size ? $image_size : '200,200';
$image_size_s = explode(",", trim($image_size));

 if ($type=='select' or $type=='radio' or $type=='checkbox'){
    $valuearr = explode("\n", trim($valuet));
    foreach($valuearr as $i=>$m) { 
       $values = explode("|", trim($m));
       $valuesa[$i][] = $values[0];
       $valuesa[$i][] = $values[1];

        } 
 }
 if ($keyvalue){
 eval("\$kvalue = $keyvalue;");
 }
 $kvalue = $kvalue ? $kvalue:$keyvalue;
 $value =  $inputvalue<>'' ? $inputvalue : $kvalue;
 if ($add_js=='' and $type=='text') $add_js = 'size="30"';
 if ($key=='catid'){
 	$prints = ajax_catid_select('add[catid]', '请选择', $value, $menuid);
 }else if ($key=='template'){
 $prints = select(filetemplate(modname($menuid),$template),$value,'默认','add[template]');
 }else{
 if ($type=='text'){
 $prints = '<input name="add['.$key.']" type="text" id="'.$key.'" value="'.$value.'" '.$add_js.'>';
 }else if ($type=='textarea'){
 $prints = '<textarea name="add['.$key.']" id="'.$key.'"  '.$add_js.'>'.$value.'</textarea>';
 }else if ($type=='editor'){
 $prints = '<textarea name="add['.$key.']" id="'.$key.'"  '.$add_js.' style="width:700px;height:400px;visibility:hidden;">'.$value.'</textarea>';
 }else if ($type=='thumb'){
 $prints = '<input name="add['.$key.']" type="text" id="'.$key.'" value="'.$value.'" '.$add_js.'> <a onclick="art.dialog.open(\'phpleft.php?file=upfile&modname='.modname($menuid).'&w='.$image_size_s[0].'&h='.$image_size_s[1].'&id='.$key.'\', {title: \'上传图片\'}, false);" href="#"><img border=0 src='.PL_URL.'ico/upcoming-work.png>上传</a>';
 }else if ($type=='file'){
 $prints = '<input name="add['.$key.']" type="text" id="'.$key.'" value="'.$value.'" '.$add_js.'> <a onclick="art.dialog.open(\'phpleft.php?file=upfile&modname='.modname($menuid).'&w='.$image_size_s[0].'&h='.$image_size_s[1].'&id='.$key.'\', {title: \'上传文件\'}, false);" href="#"><img border=0 src='.PL_URL.'ico/upcoming-work.png>上传</a>';
 }else if ($type=='select'){
 $prints = add_select($valuesa,$value,'','add['.$key.']',$key,$add_js);
 }else if ($type=='radio'){
 $prints = add_radio($valuesa,$value,'','add['.$key.']',$key,$add_js);
 }else if ($type=='checkbox'){
 $prints = add_checkbox($valuesa,$value,'','add['.$key.']',$key,$add_js);
 }
 }
 return $prints;
}

?>