Location: PHPKode > scripts > Linker IMG > linker-img/manage/add_category.php
<?php

//=====================================
// LINKER Category Engine
//=====================================
// Filename : add_category.php
// Path  : Manage directory
// last update : 2002/03/13
// Desc : Add category
//=====================================

//=====================================
// File include part
//=====================================

include ("./authen.php");
include ("../function/$Sdb_type.php"); 
include ("../function/main_func.php"); 
include ("../$Slang/m_common.php"); 

$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);

//=====================================
// Print add form
//=====================================

if (!$switch) 
{

$category = view_category("sid",1);

print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
</head>

<body bgcolor="#E9E9E9">

<form method='post' action='add_category.php' method='post'>
<input type=hidden name='switch' value='1'>
<table border=0 cellpadding=0 cellspacing=1>
   
<tr>
<td colspan=2>

<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_make_cat</font></b>
</td></tr></table>

</td>	</tr>
<tr><td colspan=2>&nbsp;</td>	</tr>

<tr>
<td bgcolor='#E0E0E0' colspan=2 height=24 align=center width=500>
<font size='2'>&nbsp; $l_addcat_head </font></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120"><font size='2'>&nbsp;$l_title *</font></td>
<td bgcolor="#F6F6F6"><input type='text' name='title' size='20' style="width:300px"></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120"><font size='2'>&nbsp;$l_cat *</font></td>
<td bgcolor="#F6F6F6"><font size=2><select name='parent'>
$category
</select></font></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_relate_cat</font></td>
<td bgcolor="#F6F6F6"><font size=2><select name='relate'>
<option value=''>$l_relate_no</option>
$category</select></font></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_sub_type</font></td>
<td bgcolor="#F6F6F6"><font size=2><select name='catsub'>
<option value='0'>$l_sub_no</option>
<option value='1'>$l_sub_cat</option>
<option value='2'>$l_sub_desc</option>
</select></font></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_permit_link</font></td>
<td bgcolor="#F6F6F6"><font size=2><select name='check_link'>
<option value='1'>$l_permit_yes</option>
<option value='0'>$l_permit_no</option>
</select></font></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_meta</font></td>
<td bgcolor="#F6F6F6"><input type='text' size='20' maxlength='50' name='meta' style="width:300px"></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_cat_desc</font></td>
<td bgcolor="#F6F6F6"><input type='text' size='20' maxlength='250' name='desc' style="width:300px"></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_head</font></td>
<td bgcolor="#F6F6F6"><textarea area rows='5' cols='30' name='header' style="width:400px"></textarea></td>
</tr>

<tr>
<td bgcolor='#F6F6F6' width="120" height='24'><font size='2'>&nbsp;$l_foot</font></td>
<td bgcolor="#F6F6F6"><textarea area rows='5' cols='30' name='footer' style="width:400px"></textarea></td>
</tr>
<tr>
<td colspan='2' align='center' bgcolor="#E0E0E0"><font size=2>
<input type='submit' value='  $l_submit  ' class=cinput>
<input type='reset' value='  $l_reset  ' class=cinput></font>
</td>
</tr>

</table>
</form>

EOF;
exit;
}

//=====================================
// Insert part
//=====================================


if (!$title)  errmsg ($l_error_nocat);

$maxnum = maxnum("LINKER_CAT","sid");

$db->query("select path,parent, pathtxt from LINKER_CAT where sid = '$parent' limit 1");

$path_row = $db->nrecord();
$path_txt = addslashes($path_row[pathtxt] . $Ssepchar . $title); // for extra chars
$path = $path_row[path] . "/" . $maxnum;
$pparent = $path_row[parent];
$time = time();

// duplicate links check
$db->query("select count(*) as total from LINKER_CAT where pathtxt = '$path_txt'");
$row = $db->nrecord();
if ($row[total]>0) errmsg($l_error_dupcat);

 // plus sub_cat num
 $db->query("update LINKER_CAT set sub_cat = sub_cat+1 where sid='$parent'");


$insert_que = "insert into LINKER_CAT set 
sid = '$maxnum',
parent = '$parent',
pparent = '$pparent',
title = '$title',
relate = '$relate',
path = '$path',
descript = '$desc',
uptime = '$time',
lasttime = '$time',
pathtxt = '$path_txt',
c_link = '$check_link',
c_sub = '$catsub',
meta_key = '$meta',
header = '$header',
footer = '$footer'
";

$db->query($insert_que);

//=====================================
// Print result
//=====================================


$result_patxt  = str_replace($Ssepchar, $Sarrow,$path_row[pathtxt]);

switch ($catsub) 
{
    case 1: $result_c_sub = $l_sub_cat;	break;
    case 2: $result_c_sub = $l_sub_desc; 	break;
    default: $reslut_c_sub = $l_sub_no;
}

$result_c_link = ($check_link) ? $l_permit_yes : $l_permit_no ;


print <<<EOF
<html>
<head>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<meta http-equiv='refresh' content='2; url=add_category.php'>
</head>

<body bgcolor="#E9E9E9">
<table border=0 cellpadding=0 cellspacing=1 width=500>
   
<tr>
<td colspan=2>

<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_added_cat</font></b>
</td></tr></table>

</td>	</tr>
<tr><td colspan=2>&nbsp;</td>	</tr>


<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_title</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$title</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_cat</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$result_patxt</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_relate_cat</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$relate</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_sub_type</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$result_c_sub</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_permit_link</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$result_c_link </font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_meta</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$meta</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_cat_desc</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$desc</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_head</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$header</font></td>
</tr>

<tr>
<td height='24' width='100' bgcolor='#F6F6F6'><font  size='2'>&nbsp;$l_foot</font></td>
<td width='400' bgcolor='#F6F6F6' ><font  size='2'>&nbsp;$footer</font></td>
</tr>

</table>

EOF;


?>
Return current item: Linker IMG