无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
<?php
class cat
{
public $data;
public function __construct()
{
@include "data.php";
$this->data = $class;
}
public function CreateSortLevel($fatherlevel)
{
if(empty($fatherlevel))
{
if(is_array($this->data))
{
$fast_level = array();
foreach($this->data as $value)
{
if(strlen($value["sortlevel"]) == 3)
{
$fast_level[] = $value["sortlevel"];
}
}
$max_fast_level = max($fast_level);
unset($fast_level);
$sub = ceil($max_fast_level) + 1;
switch(strlen($sub))
{
case 1:
return "00{$sub}";
break;
case 2:
return "0{$sub}";
break;
case 3:
return $sub;
break;
}
}
else
{
return "001";
}
}
foreach($this->data as $val)
{
if(eregi("^".$fatherlevel.".{3}$",$val["sortlevel"]))
{
$level[] = $val["sortlevel"];
}
}
if(is_array($level))
{
$max_two_level = max($level);
$sub = ceil(substr($max_two_level,-3)) + 1;
switch(strlen($sub))
{
case 1:
return substr($max_two_level,0,strlen($max_two_level)-1).$sub;
break;
case 2:
return substr($max_two_level,0,strlen($max_two_level)-2).$sub;
break;
case 3:
return substr($max_two_level,0,strlen($max_two_level)-3).$sub;
break;
}
}
else
{
return $fatherlevel."001";
}
}
public function orders()
{
$op = $this->data;
$this->array_usort($op,"sortlevel",SORT_ASC);
return $op;
}
public function add_cat($sortname,$sortlevel)
{
$data = time();
$arr = array
(
"{$data}" => array
(
"sortname" => $sortname,
"sortlevel" => $this->CreateSortLevel($sortlevel)
)
);
$rs = $this->data + $arr;
$this->add_wirte($rs);
}
private function array_usort(&$array)
{
$args = func_get_args();
for($i=1,$cmd='',$size=count($args);$i<$size;$i++)
{
$num = $i;
$order = "";
$con = "@strcmp($a['$args[$num]'],$b['$args[$num]'])";
while(++$i < $size)
{
if($args[$i] === SORT_NUMERIC)
{
$con = "($a['$args[$num]']-$b['$args[$num]'])";
}
else if($args[$i] === SORT_DESC)
{
$order = "-1*";
}
else if(is_string($args[$i]))
{
$i--;
break;
}
}
$cmd .= "if($num = $con)return $order$num;else ";
if($order != '')
{
$i++;
}
}
@usort($array,@create_function('$a,$b',"$cmd return 0;"));
}
public function wirte($sortname,$sortlevel)
{
$array = "<?phprn";
$array .= '$class = array'."rn(rn";
$array .= ' "'.time().'" => array'."rn";
$array .= ' ('."rn";
$array .= ' "sortname" => "'.$sortname.'"'.",rn";
$array .= ' "sortlevel" => "'.$this->CreateSortLevel($sortlevel).'"'."rn";
$array .= ' )'."rn";
$array .= ")rn?>";
file_put_contents("data.php",$array);
}
public function add_wirte($rs)
{
$array = "<?phprn";
$array .= '$class = array'."rn(rn";
foreach($rs as $key=>$value)
{
$array .= "rn";
$array .= ' "'.$key.'" => array'."rn";
$array .= ' ('."rn";
$array .= ' "sortname" => "'.$value["sortname"].'"'.",rn";
$array .= ' "sortlevel" => "'.$value["sortlevel"].'"'."rn";
$array .= ' ),';
}
$array = substr($array,0,-1);
$array .= "rn)rn?>";
file_put_contents("data.php",$array);
}
}
$cat = new cat();
if($_GET["action"] == "add")
{
if(strlen($_POST["sortname"]) < 2)
{
echo '<script language="JavaScript">alert("请添加分类名字")</script>';
echo '<script language="JavaScript">location.href="/cat.php?action=tpl"</script>';
exit;
}
if(file_exists("data.php"))
{
$cat->add_cat($_POST["sortname"],$_POST["sortlevel"]);
echo '<script language="JavaScript">alert("添加成功")</script>';
echo '<script language="JavaScript">location.href="/cat.php"</script>';
exit;
}
else
{
$cat->wirte($_POST["sortname"],$_POST["sortlevel"]);
echo '<script language="JavaScript">alert("添加成功")</script>';
echo '<script language="JavaScript">location.href="/cat.php"</script>';
exit;
exit;
}
}
if($_GET["action"] == "tpl")
{
echo '<form id="form1" name="form1" method="post" action="cat.php?action=add">';"rn";
echo '<select name="sortlevel">'."rn";
echo '<option value="" selected="selected">根分类</option>'."rn";
foreach($cat->orders() as $val)
{
echo '<option value="'.$val["sortlevel"].'">';
$clevel = strlen(substr($val['sortlevel'],0,-3));
for($i = 0; $i < $clevel; $i++)
{
echo "-";
}
echo $val['sortname']."</option>rn";
}
echo "</select>rn";
echo ' <input name="sortname" type="text" id="sortname" />'."rn";
echo '<input type="submit" name="Submit" value="提交" />';
echo "</form>";
exit;
}
foreach($cat->orders() as $value)
{
$level = strlen(substr($value['sortlevel'],0,-3));
for($i = 0; $i < $level; $i++)
{
echo "-";
}
echo $value["sortname"];
echo "<br>";
}
?>
<?php
class cat
{
public $data;
public function __construct()
{
@include "data.php";
$this->data = $class;
}
public function CreateSortLevel($fatherlevel)
{
if(empty($fatherlevel))
{
if(is_array($this->data))
{
$fast_level = array();
foreach($this->data as $value)
{
if(strlen($value["sortlevel"]) == 3)
{
$fast_level[] = $value["sortlevel"];
}
}
$max_fast_level = max($fast_level);
unset($fast_level);
$sub = ceil($max_fast_level) + 1;
switch(strlen($sub))
{
case 1:
return "00{$sub}";
break;
case 2:
return "0{$sub}";
break;
case 3:
return $sub;
break;
}
}
else
{
return "001";
}
}
foreach($this->data as $val)
{
if(eregi("^".$fatherlevel.".{3}$",$val["sortlevel"]))
{
$level[] = $val["sortlevel"];
}
}
if(is_array($level))
{
$max_two_level = max($level);
$sub = ceil(substr($max_two_level,-3)) + 1;
switch(strlen($sub))
{
case 1:
return substr($max_two_level,0,strlen($max_two_level)-1).$sub;
break;
case 2:
return substr($max_two_level,0,strlen($max_two_level)-2).$sub;
break;
case 3:
return substr($max_two_level,0,strlen($max_two_level)-3).$sub;
break;
}
}
else
{
return $fatherlevel."001";
}
}
public function orders()
{
$op = $this->data;
$this->array_usort($op,"sortlevel",SORT_ASC);
return $op;
}
public function add_cat($sortname,$sortlevel)
{
$data = time();
$arr = array
(
"{$data}" => array
(
"sortname" => $sortname,
"sortlevel" => $this->CreateSortLevel($sortlevel)
)
);
$rs = $this->data + $arr;
$this->add_wirte($rs);
}
private function array_usort(&$array)
{
$args = func_get_args();
for($i=1,$cmd='',$size=count($args);$i<$size;$i++)
{
$num = $i;
$order = "";
$con = "@strcmp($a['$args[$num]'],$b['$args[$num]'])";
while(++$i < $size)
{
if($args[$i] === SORT_NUMERIC)
{
$con = "($a['$args[$num]']-$b['$args[$num]'])";
}
else if($args[$i] === SORT_DESC)
{
$order = "-1*";
}
else if(is_string($args[$i]))
{
$i--;
break;
}
}
$cmd .= "if($num = $con)return $order$num;else ";
if($order != '')
{
$i++;
}
}
@usort($array,@create_function('$a,$b',"$cmd return 0;"));
}
public function wirte($sortname,$sortlevel)
{
$array = "<?phprn";
$array .= '$class = array'."rn(rn";
$array .= ' "'.time().'" => array'."rn";
$array .= ' ('."rn";
$array .= ' "sortname" => "'.$sortname.'"'.",rn";
$array .= ' "sortlevel" => "'.$this->CreateSortLevel($sortlevel).'"'."rn";
$array .= ' )'."rn";
$array .= ")rn?>";
file_put_contents("data.php",$array);
}
public function add_wirte($rs)
{
$array = "<?phprn";
$array .= '$class = array'."rn(rn";
foreach($rs as $key=>$value)
{
$array .= "rn";
$array .= ' "'.$key.'" => array'."rn";
$array .= ' ('."rn";
$array .= ' "sortname" => "'.$value["sortname"].'"'.",rn";
$array .= ' "sortlevel" => "'.$value["sortlevel"].'"'."rn";
$array .= ' ),';
}
$array = substr($array,0,-1);
$array .= "rn)rn?>";
file_put_contents("data.php",$array);
}
}
$cat = new cat();
if($_GET["action"] == "add")
{
if(strlen($_POST["sortname"]) < 2)
{
echo '<script language="JavaScript">alert("请添加分类名字")</script>';
echo '<script language="JavaScript">location.href="/cat.php?action=tpl"</script>';
exit;
}
if(file_exists("data.php"))
{
$cat->add_cat($_POST["sortname"],$_POST["sortlevel"]);
echo '<script language="JavaScript">alert("添加成功")</script>';
echo '<script language="JavaScript">location.href="/cat.php"</script>';
exit;
}
else
{
$cat->wirte($_POST["sortname"],$_POST["sortlevel"]);
echo '<script language="JavaScript">alert("添加成功")</script>';
echo '<script language="JavaScript">location.href="/cat.php"</script>';
exit;
exit;
}
}
if($_GET["action"] == "tpl")
{
echo '<form id="form1" name="form1" method="post" action="cat.php?action=add">';"rn";
echo '<select name="sortlevel">'."rn";
echo '<option value="" selected="selected">根分类</option>'."rn";
foreach($cat->orders() as $val)
{
echo '<option value="'.$val["sortlevel"].'">';
$clevel = strlen(substr($val['sortlevel'],0,-3));
for($i = 0; $i < $clevel; $i++)
{
echo "-";
}
echo $val['sortname']."</option>rn";
}
echo "</select>rn";
echo ' <input name="sortname" type="text" id="sortname" />'."rn";
echo '<input type="submit" name="Submit" value="提交" />';
echo "</form>";
exit;
}
foreach($cat->orders() as $value)
{
$level = strlen(substr($value['sortlevel'],0,-3));
for($i = 0; $i < $level; $i++)
{
echo "-";
}
echo $value["sortname"];
echo "<br>";
}
?>
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月15日
2024年11月15日
- 炉石传说月初最强卡组有哪些 2024月初最强上分卡组推荐
- 狼人杀亮相原生鸿蒙之夜 假面科技强势登陆华为生态
- 12小时光线挑战!AI画质专家才是大平层首选
- 2024游戏IP报告:1~9月规模1960亿 68%用户愿为之付费
- 群星.2024-今夜一起为爱鼓掌电视剧原声带【相信音乐】【FLAC分轨】
- BIGFOUR.2013-大家利事【寰亚】【WAV+CUE】
- 李美凤.1992-情深透全情歌集【EMI百代】【WAV+CUE】
- 田震2024-《时光音乐会》[金峰][WAV+CUE]
- 群星《监听天碟3》[LECD]限量版[WAV+CUE]
- 心妤《声如夏花HQ》头版限量编号[WAV+CUE]
- 群星《摇滚五杰》[低速原抓WAV+CUE][1.1G]
- 群星 《2024好听新歌30》十倍音质 U盘音乐 [WAV+分轨]
- 群星《试音草原·女声篇》经典蒙古民歌[WAV+CUE][1G]
- 陈慧娴《永远是你的朋友》头版限量编号MQA-UHQCD2024[低速原抓WAV+CUE]
- 曼丽·女人三十《如果·爱》限量1:1母盘直刻[低速原抓WAV+CUE]