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

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

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

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

if (!isset($update)) errmsg($l_error_nosid);
$db = new DB_Sql($Sdb_host,$Sdb_user,$Sdb_pass,$Sselect_db);

//=====================================
// Print edit from 
//=====================================

if (!$switch)  {

$db->query("select * from LINKER_CAT where sid='$update'");;
$row=$db->nrecord();

while(list($key, $val) = each ($row))
$row[$key] =  htmlspecialchars(stripslashes(trim($val)));

$opcat = view_category("sid",0,$row[relate]);


switch ($row[c_sub]) 
{
    case 1: $ch1 = "selected";	break;
    case 2: $ch2 = "selected";	break;
    default: $ch3 = "selected";
}

$c_sub = "
<option value=0 $ch3>$l_sub_no</option>
<option value=1 $ch1>$l_sub_desc</option>
<option value=2 $ch2>$l_sub_cat</option>
";

switch ($row[c_link]) 
{
    case 1: $cl1 = "selected";	break;
    case 0: $cl2 = "selected";	break;
    default: $cl1 = "selected";
}

$c_link = "
<option value='1' $cl1>$l_permit_yes</option>
<option value='0' $cl2>$l_permit_no</option>
";

$po_pathtxt = str_replace($Ssepchar, $Sarrow, $row[pathtxt]);

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 action='edit_category.php' method='post'>
 <input type='hidden' name='switch' value='up'>
 <input type='hidden' name='update' value='$row[sid]'>

<div align='left'>

<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">$row[title] $l_cat_info</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_cat_head </font></td>
</tr>

<tr>
<td width="120" height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_sid</font></td>
<td  bgcolor='#F6F6F6'><font size='2'>&nbsp;$row[sid]</font></td>
</tr>

<tr>
<td width="120" height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_cat</font></td>
<td  bgcolor='#F6F6F6'>&nbsp;<font size='2'>$po_pathtxt</font></td>
</tr>

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

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

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

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

<tr>
<td width="120" height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_count</font></td>
<td  bgcolor='#F6F6F6'><input name='count' size=10 value='$row[count]'></td>
</tr>

<tr>
<td width="120" height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_permit_link</font></td>
<td  bgcolor='#F6F6F6'><font size=2><select name='c_link'>$c_link</select></font></td>
</tr>

<tr>
<td width="120" height=24 bgcolor='#F6F6F6'><font size='2'>&nbsp;$l_sub_type</font></td>
<td  bgcolor='#F6F6F6'><font size=2><select name='c_sub'>$c_sub</select></font></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:350px">$row[header]</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:350px">$row[footer]</textarea></td>
</tr>


<tr><td colspan=2 align=center bgcolor="#E0E0E0"><input type='submit' value='  $l_edit  ' class=cinput>&nbsp;<input type='reset' 
value='  $l_reset  ' class=cinput></td></tr>
</table></div></form>
EOF;

exit;
}

//=====================================
// Edit part
//=====================================


$time = time();
$db->query("select title,pathtxt from LINKER_CAT where sid='$update'");
$row = $db->nrecord();
$old_title = stripslashes(trim($row[title]));
$old_pathtxt = stripslashes(trim($row[pathtxt]));

//---------------------------
// Modify pathtxt
//---------------------------

if ($old_title <> $title) {

// change sub category
$slash_pathtxt = $old_pathtxt . $Ssepchar;
$temp_que = strrpos($old_pathtxt,$Ssepchar);
$set_position = ($temp_que) ? $temp_que+1 : 0;
$target_pathtxt = substr($old_pathtxt,0,$set_position).$title.$Ssepchar;
$this_pathtxt = substr($old_pathtxt,0,$set_position).$title;

$db->query("update LINKER_CAT set pathtxt=REPLACE(pathtxt,'$slash_pathtxt','$target_pathtxt') where pathtxt like '$slash_pathtxt%'");
$db->query("update LINKER_LINK set pathtxt=REPLACE(pathtxt,'$slash_pathtxt','$target_pathtxt') where pathtxt like '$slash_pathtxt%'");


$add_query = "
title='$title',
pathtxt='$this_pathtxt',
";

// chanag this link
$db->query("update LINKER_LINK set pathtxt='$this_pathtxt' where parent = '$update' ");

}

// change this category..

$db->query("
update LINKER_CAT set 
$add_query
c_link = '$c_link',
c_sub = '$c_sub',
relate='$relate',
meta_key='$meta_key',
descript = '$descript',
header = '$header',
footer = '$footer',
lasttime = '$time',
count = '$count'
where sid='$update'
");

print <<<EOF
<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=./view_category.php?type=update'>
</head>

<body bgcolor="#E9E9E9">
<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<font color="white" size="2"><b>$update $l_cat_result</b></font>
</td></tr></table>

EOF;

?>
Return current item: Linker IMG