📄 insert.php
字号:
<?php
function getfuncidofsysmenu( )
{
global $connection;
$sql = "\r\n\t\t\tSELECT MAX(FUNC_ID) as cnt FROM sys_function \r\n\t\t\t\tWHERE FUNC_ID>=1000 \r\n\t\t\t";
$rs = exequery( $connection, $sql );
$row = mysql_fetch_array( $rs );
$func_id = $row['cnt'];
if ( $func_id < 1000 )
{
$func_id = 1000;
}
else if ( 2000 < $func_id )
{
$sql = "\r\n\t\t SELECT MENU_ID \r\n\t\t FROM sys_function \r\n\t\t\t\t\tWHERE LENGTH(MENU_ID)=2\r\n\t\t\t\t";
$rs = exequery( $connection, $sql );
while ( $row = mysql_fetch_array( $rs ) )
{
$needle[] = $row['MENU_ID'];
}
if ( is_array( $needle ) )
{
$i = 1000;
for ( ; $i < 2000; ++$i )
{
if ( !( in_array( $i, $needle ) == false ) )
{
continue;
}
$func_id = $i;
}
}
}
else
{
$func_id = $func_id + 1;
}
return $func_id;
}
function getmenuidofsysmenu( $parent_menuid = "" )
{
global $connection;
$menu_length = strlen( $parent_menuid );
$menu_pos = strlen( $parent_menuid ) + 1;
$sql = ( " \r\n\t SELECT MAX(SUBSTRING(MENU_ID,{$menu_pos},2)) AS cnt FROM sys_function \r\n\t\t\t\t WHERE LENGTH(MENU_ID)=".( $menu_length + 2 ) )."\r\n\t\t\t ";
if ( 0 < $parent_menuid )
{
$sql .= " AND LEFT(MENU_ID,{$menu_length})={$parent_menuid}";
}
$rs = exequery( $connection, $sql );
$row = mysql_fetch_array( $rs );
$max_menu_id = $row['cnt'];
if ( $max_menu_id == "" )
{
$part_menu_id = 1;
}
else
{
$part_menu_id = abs( substr( $max_menu_id, -2 ) ) + 1;
}
if ( 99 < $part_menu_id )
{
$sql = ( "\r\n\t\t SELECT SUBSTRING(MENU_ID,{$menu_pos},2) as cnt \r\n\t\t FROM sys_function \r\n\t\t\t\t\tWHERE LENGTH(MENU_ID)=".( $menu_length + 2 ) )."\r\n\t\t\t\t\r\n\t\t\t\t";
if ( 0 < $parent_menuid )
{
$sql .= " AND LEFT(MENU_ID,{$menu_length})={$parent_menuid}";
}
$rs = exequery( $connection, $sql );
while ( $row = mysql_fetch_array( $rs ) )
{
$needle[] = $row['cnt'];
}
if ( is_array( $needle ) )
{
$i = 0;
for ( ; $i < 100; ++$i )
{
if ( in_array( $i, $needle ) == false )
{
$part_menu_id = $i;
}
}
}
}
if ( $parent_menuid == "" && ( $part_menu_id < 80 || 89 < $part_menu_id ) )
{
$sql = "\r\n\t\tSELECT LEFT(MENU_ID,2) as cnt \r\n\t\t FROM sys_function \r\n\t\t\tWHERE LENGTH(MENU_ID)=2\r\n\t\t";
$rs = exequery( $connection, $sql );
unset( $needle );
while ( $row = mysql_fetch_array( $rs ) )
{
$needle[] = $row['cnt'];
}
if ( is_array( $needle ) )
{
$i = 80;
for ( ; $i < 89; ++$i )
{
if ( in_array( $i, $needle ) == false )
{
$part_menu_id = $i;
}
}
}
else
{
$part_menu_id = 80;
}
if ( $part_menu_id < 80 || 89 < $part_menu_id )
{
return false;
}
}
if ( $part_menu_id <= 0 || 99 < $part_menu_id )
{
return false;
}
else
{
$part_menu_id = formatnumt( $part_menu_id );
$menu_id = $parent_menuid.$part_menu_id;
return $menu_id;
}
}
function getorderidofusermenu( $parent_menuid )
{
global $connection;
$menu_length = strlen( $parent_menuid );
$menu_pos = strlen( $parent_menuid ) + 1;
$sql = ( "\r\n\t\t\tSELECT MAX(ORDER_ID) as cnt \r\n\t\t\t FROM user_menu \r\n\t\t\t\tWHERE USER_ID='".$_SESSION['LOGIN_USER_ID']."' \r\n\t\t\t\tAND LENGTH(MENU_ID)=".( $menu_length + 2 ) )."\r\n\t\t\t\r\n\t\t\t";
if ( 0 < $parent_menuid )
{
$sql .= " AND LEFT(MENU_ID,{$menu_length})={$parent_menuid}";
}
$rs = exequery( $connection, $sql );
$row = mysql_fetch_array( $rs );
$order_id = $row['cnt'] + 1;
return $order_id;
}
function formatnumt( $n )
{
$length = strlen( $n );
if ( $length == 1 )
{
$n = "0".$n;
}
return $n;
}
include_once( "inc/auth.php" );
echo "\r\n<html>\r\n<head>\r\n<title>增加菜单</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n</head>\r\n\r\n<body class=\"bodycolor\" topmargin=\"5\">\r\n\r\n";
$connection = openconnection( );
$FUNC_ID1 = getfuncidofsysmenu( );
$MENU_ID = getmenuidofsysmenu( $_REQUEST['CLASS_ONE_MENU_ID'] );
$query = "insert into SYS_FUNCTION(FUNC_ID,MENU_ID,FUNC_NAME,FUNC_CODE) VALUES ({$FUNC_ID1},'{$MENU_ID}','{$FUNC_NAME}','{$FUNC_CODE1}')";
exequery( $connection, $query );
$sql = "SELECT USER_ID FROM user";
$rs = exequery( $connection, $sql );
while ( $row = mysql_fetch_array( $rs ) )
{
$user_id = $row['USER_ID'];
$func_id = $FUNC_ID1;
$menu_id = $MENU_ID;
$order_id = 0;
$func_isshow = 1;
$func_issys = 1;
$func_name = $FUNC_NAME;
$func_code = $FUNC_CODE1;
$func_follow = 0;
$func_type = 0;
$func_type_id = 0;
$sql_u = "INSERT INTO user_menu VALUES (\r\n\t\t\t'{$user_id}',\r\n\t\t\t{$func_id},\r\n\t\t\t'{$menu_id}',\r\n\t\t\t{$order_id},\r\n\t\t\t{$func_isshow},\r\n\t\t\t{$func_issys},\r\n\t\t\t'{$func_name}',\r\n\t\t\t'{$func_code}',\r\n\t\t\t{$func_follow},\r\n\t\t\t\t{$func_type},\r\n\t\t\t\t'{$func_type_id}'\r\n\t\t\t)";
exequery( $connection, $sql_u );
}
if ( strlen( $CLASS_ONE_MENU_ID ) == 4 )
{
$menuid_temp = substr( $CLASS_ONE_MENU_ID, 0, 2 );
}
else
{
$menuid_temp = $CLASS_ONE_MENU_ID;
}
header( "location:index.php?MENU_ID=".$menuid_temp );
echo "\r\n";
echo "<s";
echo "cript>\r\n//parent.menu_list.location.reload();\r\n</script>\r\n\r\n\r\n</body>\r\n</html>\r\n";
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -