hey guy, i was fail to update the title and content using php code below, can anyone help me check what is the problem. Thanks.
<?php
if ( !defined( "ROOT_PATH" ) )
{
exit( "Forbidden" );
}
if ( "0" < $userdb['sellerid'] && !$_S['ifsell'] )
{
message( "group_ifsell" );
}
require_once( ROOT_PATH."require/ubbcode.func.php" );
require_once( ROOT_PATH."require/post.func.php" );
include_once( DATA_PATH."cache/category.php" );
$dirs = NULL;
list( , , $subject_max, $subject_min, $content_max ) = $deposit_a = explode( "\t", $db_deposit );
checkint( $_S['shopwindow'], 0 );
$userdb['shopwindow'] = $userdb['grooms'] ? count( explode( ",", $userdb['grooms'] ) ) : 0;
initgp( array( "type", "step" ) );
$replacedb = $teamprice = array( );
$PS_url = $db_shopurl;
$nopic = goodspic( );
if ( $db_shopcheck == "2" )
{
if ( $userdb['certificate_1'] == "-1" )
{
message( "wait_certificate" );
}
else if ( $userdb['certificate_1'] != "1" )
{
message( "certificate_1" );
}
}
if ( $db_shopcheck == "3" )
{
if ( $userdb['certificate_2'] == "-1" )
{
message( "wait_certificate" );
}
else if ( $userdb['certificate_2'] != "1" )
{
message( "certificate_2" );
}
}
if ( $db_shopcheck == "4" )
{
if ( $userdb['certificate_1'] == "-1" || $userdb['certificate_2'] == "-1" )
{
message( "wait_certificate" );
}
else if ( $userdb['certificate_1'] != "1" || $userdb['certificate_2'] != "1" )
{
message( "certificate" );
}
}
if ( empty( $action ) )
{
$gonext = $userdb['sellerid'] < 1 ? "attestation" : "goods";
require_once( template( "goods" ) );
footer( );
}
else if ( $action == "attestation" )
{
require_once( template( "goods" ) );
footer( );
}
else if ( $action == "goods" )
{
if ( empty( $step ) )
{
$jscate = "";
$cidlog = explode( ",", getcookie( "cidlog" ) );
$jstype = $cidlist = array( );
foreach ( $_Category as $key => $value )
{
if ( $value['type'] == 0 )
{
$jscate .= "'{$key}' : '{$value['name']}',";
}
else if ( $value['cup'] )
{
$jstype[$value['cup']] .= "'{$key}' : '{$value['name']}',";
}
if ( in_array( $key, $cidlog ) )
{
$cidlist[$key] = $value['name'];
}
}
$jscate = substr( $jscate, 0, 0 - 1 );
$jscode = "";
foreach ( $jstype as $key => $value )
{
$value = substr( $value, 0, 0 - 1 );
$jscode .= "jstype[{$key}] = {{$value}};\r\n";
}
require_once( template( "goods" ) );
footer( );
}
else if ( $step == 1 )
{
if ( !( $_S['ifsell'] & pow( 2, $type - 1 ) ) )
{
message( "goods_itemtype" );
}
if ( $userdb['shopdata'] )
{
$shopdata = unserialize( $userdb['shopdata'] );
if ( $shopdata['catedir'] )
{
$catedirdb = $shopdata['catedir'];
foreach ( $catedirdb as $k => $val )
{
$dirs .= "<option value='{$k}'>{$val}</option>";
}
}
}
$attachs = array( );
$catename = $_Category[$cid]['name'];
$cup = $cid;
while ( $_Category[$cup]['cup'] )
{
$cup = $_Category[$cup]['cup'];
$catename = $_Category[$cup]['name']." » ".$catename;
}
$carriage_2 = $saletime_1 = $degree_1 = $goodpic_1 = $addtype_0 = ${ "saletype_".$type } = "checked";
$addprice_Y = "disabled";
$carriage = 2;
$subject_maxlength = floor( $subject_max / 2 );
$rt = $db->getone( "SELECT identity FROM {$PS}category WHERE cid='{$cid}'" );
$identity = $rt['identity'] ? unserialize( $rt['identity'] ) : array( );
$property = $carriagedb = $area = array( );
$ifshopwindow = $userdb['shopwindow'] < $_S['shopwindow'] ? "" : "disabled";
$query = $db->query( "SELECT cid,type,carriage FROM {$PS}carry WHERE uid='{$user_uid}'" );
while ( $rt = $db->fetch_array( $query ) )
{
$carriagedb[$rt['cid']] = $rt;
}
$cupid = 0;
if ( $userdb['area'] )
{
$area = $db->getone( "SELECT pid,cup,name,cupname FROM {$PS}area WHERE pid='{$userdb['area']}'" );
$cupid = $area['cup'];
}
require_once( template( "goods" ) );
footer( );
}
else if ( $_POST['step'] == "2" )
{
initgp( array( "saletype", "dirid", "degree", "itemnum", "subject", "httppic", "price", "carriage", "carriagedbs", "saletime", "shopwindow", "tags", "goodpic", "pnum", "identity", "extra", "deposit", "city" ) );
if ( !( $_S['ifsell'] & pow( 2, $saletype - 1 ) ) )
{
message( "goods_itemtype" );
}
list( $atc_title, $atc_content, $ifconvert ) = $atc_title;
if ( $tags )
{
$tags = check_tag( $tags );
}
cidlog( $cid );
if ( !is_numeric( $price ) || $price <= 0 )
{
message( "price_error" );
}
switch ( $saletype )
{
case 1 :
$priceinfo = "";
$costprice = 0;
break;
case 2 :
initgp( array( "addtype", "addprice" ) );
$addprice = ( integer )$addprice;
if ( $addtype && $addprice < 1 )
{
message( "addprice_error" );
}
$priceinfo = serialize( array(
"addtype" => $addtype ? 1 : 0,
"addprice" => $addprice
) );
$costprice = $price;
break;
case 3 :
initgp( array( "groupprice", "groupnum" ) );
checkint( $groupnum, 2 );
$priceinfo = serialize( array(
"groupprice" => $groupprice,
"groupnum" => $groupnum,
"buynum" => 0
) );
$costprice = $price;
break;
default :
message( "operate_undefine" );
}
if ( !is_numeric( $itemnum ) || $itemnum < 1 )
{
message( "itemnum_error" );
}
$ifcheck = $db_goodscheck && $_S['goods_check'] ? 0 : 1;
if ( $ifcheck && 0 < $_S['goodsnums'] )
{
$rt = $db->getone( "SELECT COUNT(*) AS sum FROM {$PS}items WHERE uid='{$user_uid}'" );
if ( $_S['goodsnums'] <= $rt['sum'] )
{
message( "group_itemnum_limit" );
}
}
if ( $saletime == 1 )
{
$ifcheck |= 2;
}
$city = ( integer )$city;
if ( $shopwindow && $userdb['shopwindow'] < $_S['shopwindow'] )
{
$shopwindow = 1;
}
else
{
$shopwindow = 0;
}
if ( 0 < $deposit && $deposit_a[0] & pow( 2, $saletype - 1 ) )
{
$deposit = ( integer )$deposit;
if ( $deposit_a[2] < $deposit )
{
$deposit = $deposit_a[2];
}
}
else
{
$deposit = 0;
}
$degree = $degree ? $degree : "1";
if ( $carriage == "2" && is_array( $carriagedbs ) )
{
$carriagedb = array( );
$query = $db->query( "SELECT cid,type,carriage FROM {$PS}carry WHERE uid='{$user_uid}'" );
while ( $rt = $db->fetch_array( $query ) )
{
if ( 0 <= $carriagedbs[$rt['cid']] )
{
$rt['carriage'] = $carriagedbs[$rt['cid']];
}
$carriagedb[$rt['cid']] = $rt;
}
$carriage = $carriagedb ? addslashes( serialize( $carriagedb ) ) : "";
$extra = ( integer )$extra <= 0 ? "" : ( integer )$extra;
}
else
{
$carriage = $extra = "";
}
require_once( ROOT_PATH."require/upload.inc.php" );
if ( $goodpic == "2" )
{
if ( !ereg( "^http://", $httppic ) )
{
message( "httppic_error" );
}
$httppic = html( $httppic );
}
else
{
$httppic = isset( $attachs[0] ) ? $attachs[0]['attachurl'] : "";
}
$attachs = $attachs ? addslashes( serialize( $attachs ) ) : "";
$identity = $identity ? addslashes( serialize( $identity ) ) : "";
$db->update( "INSERT INTO {$PS}items (cid,ucid,uid,seller,itemtype,subject,postdate,itemnum,ifcheck,degree,itemprice,costprice,deposit,httppic,ifgroom,area) VALUES ('{$cid}','{$dirid}','{$user_uid}','".addslashes( $user_name )."','{$saletype}', '{$atc_title}','{$timestamp}','{$itemnum}','{$ifcheck}','{$degree}','{$price}','{$costprice}','{$deposit}','{$httppic}','{$shopwindow}','{$city}')" );
$tid = mysql_insert_id( );
$db->update( "INSERT INTO {$PS}iteminfo (tid,property,priceinfo,attach,carriage,extra,content,ifconvert,tags) VALUES ('{$tid}','{$identity}','".addslashes( $priceinfo )."','{$attachs}','{$carriage}','{$extra}','{$atc_content}', '{$ifconvert}','{$tags}')" );
if ( $tags )
{
insert_tag( $tid, $tags );
}
$sql = "";
if ( $ifcheck == 3 )
{
$db->update( "UPDATE {$PS}sysinfo SET totalitem=totalitem+1 WHERE id='1'" );
additemindex( array(
$tid => $cid
), $timestamp );
$sql .= "goodsnum=goodsnum+1";
}
if ( $shopwindow == "1" )
{
$userdb['grooms'] .= ( $userdb['grooms'] ? "," : "" ).$tid;
$sql .= ( $sql ? "," : "" )."grooms='{$userdb['grooms']}'";
}
if ( $sql )
{
$db->update( "UPDATE {$PS}shopset SET {$sql} WHERE uid='{$user_uid}'" );
}
setuserdata( $user_uid, $db_creditset['goods'] );
message( "operate_success", $basename );
}
}
else if ( $action == "modify" )
{
$manager_edit = false;
$rt = $db->getone( "SELECT * FROM {$PS}items i LEFT JOIN {$PS}iteminfo ii USING(tid) WHERE i.tid='{$tid}'" );
if ( empty( $rt ) )
{
message( "modify_error" );
}
if ( $rt['uid'] != $user_uid )
{
if ( $groupid != "3" )
{
message( "modify_error" );
}
$userdb = $db->getone( "SELECT s.uid,s.username,s.groupid,s.sellerid,ss.shopdata,ss.grooms FROM {$PS}items i LEFT JOIN {$PS}shopper s ON i.uid=s.uid LEFT JOIN {$PS}shopset ss ON s.uid=ss.uid WHERE i.tid='{$tid}'" );
$user_uid = $userdb['uid'];
if ( $userdb['sellerid'] < "1" )
{
message( "not_seller" );
}
if ( $userdb['groupid'] != "-1" && file_exists( DATA_PATH."groupdb/group_{$userdb['groupid']}.php" ) )
{
include_once( DATA_PATH."groupdb/group_{$userdb['groupid']}.php" );
}
else
{
include_once( DATA_PATH."groupdb/group_{$userdb['sellerid']}.php" );
}
$userdb['shopwindow'] = $userdb['grooms'] ? count( explode( ",", $userdb['grooms'] ) ) : 0;
$manager_edit = true;
}
if ( empty( $cid ) )
{
$cid = $rt['cid'];
}
if ( empty( $step ) )
{
$type = $rt['itemtype'];
$jscate = "";
$cidlog = explode( ",", getcookie( "cidlog" ) );
$jstype = $cidlist = array( );
foreach ( $_Category as $key => $value )
{
if ( $value['type'] == 0 )
{
$jscate .= "'{$key}' : '{$value['name']}',";
}
else if ( $value['cup'] )
{
$jstype[$value['cup']] .= "'{$key}' : '{$value['name']}',";
}
if ( in_array( $key, $cidlog ) )
{
$cidlist[$key] = $value['name'];
}
}
$jscate = substr( $jscate, 0, 0 - 1 );
$jscode = "";
foreach ( $jstype as $key => $value )
{
$value = substr( $value, 0, 0 - 1 );
$jscode .= "jstype[{$key}] = {{$value}};\r\n";
}
require_once( template( "goods" ) );
footer( );
}
else if ( $step == 1 )
{
if ( $userdb['shopdata'] )
{
$shopdata = unserialize( $userdb['shopdata'] );
if ( $shopdata['catedir'] )
{
$catedirdb = $shopdata['catedir'];
foreach ( $catedirdb as $k => $val )
{
if ( $k == $rt['ucid'] )
{
$dirs .= "<option value='{$k}' selected>{$val}</option>";
}
else
{
$dirs .= "<option value='{$k}'>{$val}</option>";
}
}
}
}
$catename = $_Category[$cid]['name'];
$cup = $cid;
while ( $_Category[$cup]['cup'] )
{
$cup = $_Category[$cup]['cup'];
$catename = $_Category[$cup]['name']." » ".$catename;
}
$type = $rt['itemtype'];
${ "saletype_".$type } = "checked";
${ "degree_".$rt['degree'] } = "checked";
$atc_content = $rt['content'];
$htmcheck = $rt['ifconvert'] & 2 ? "checked" : "";
$addtype_0 = "checked";
$addprice_Y = "disabled";
$priceinfo = array( );
switch ( $type )
{
case 2 :
$priceinfo = unserialize( $rt['priceinfo'] );
if ( $priceinfo['addtype'] )
{
$addtype_0 = $addprice_Y = "";
$addtype_1 = "checked";
}
break;
case 3 :
$priceinfo = unserialize( $rt['priceinfo'] );
break;
}
if ( $rt['carriage'] == "" )
{
$carriagedb = array( );
$query = $db->query( "SELECT cid,type,carriage FROM {$PS}carry WHERE uid='{$user_uid}'" );
while ( $rs = $db->fetch_array( $query ) )
{
$carriagedb[$rs['cid']] = $rs;
}
$carriage = 1;
$carriage_1 = "checked";
}
else
{
$carriagedb = unserialize( $rt['carriage'] );
$carriage_2 = "checked";
$carriage = 2;
}
${ "saletime_".( $rt['ifcheck'] & 2 ? 1 : 2 ) } = "checked";
$ifshopwindow = $rt['ifgroom'] ? "checked" : $_S['shopwindow'] <= $userdb['shopwindow'] ? "disabled" : "";
$attachs = array( );
if ( $rt['attach'] )
{
$attachs = unserialize( stripslashes( $rt['attach'] ) );
}
$display_1 = $display_2 = "";
$goodpicname = "attachment_0";
$rt['httppic'] = goodspic( $rt['httppic'] );
if ( strpos( $rt['httppic'], "http://" ) !== false )
{
$httppic = $rt['httppic'];
$goodpic_2 = "checked";
$display_1 = "none";
}
else
{
if ( $attachs[0] )
{
$goodpicname = "replace_0";
}
$httppic = "";
$display_2 = "none";
$goodpic_1 = "checked";
}
unset( $attachs[0] );
$rc = $db->getone( "SELECT identity FROM {$PS}category WHERE cid='{$cid}'" );
$identity = $rc['identity'] ? unserialize( $rc['identity'] ) : array( );
$property = $rt['property'] ? unserialize( $rt['property'] ) : array( );
$cupid = 0;
if ( $rt['area'] )
{
$area = $db->getone( "SELECT pid,cup,name,cupname FROM {$PS}area WHERE pid='{$rt['area']}'" );
$cupid = $area['cup'];
}
require_once( template( "goods" ) );
footer( );
}
else if ( $_POST['step'] == 2 )
{
initgp( array( "saletype", "dirid", "degree", "itemnum", "subject", "httppic", "price", "carriage", "carriagedbs", "saletime", "shopwindow", "tags", "goodpic", "keep", "pnum", "identity", "extra", "deposit", "city" ) );
if ( !( $_S['ifsell'] & pow( 2, $saletype - 1 ) ) )
{
message( "goods_itemtype" );
}
list( $atc_title, $atc_content, $ifconvert ) = $atc_title;
if ( $tags )
{
$tags = check_tag( $tags );
}
cidlog( $cid );
if ( !is_numeric( $price ) || $price <= 0 )
{
message( "price_error" );
}
$sql = "";
if ( 0 < $deposit && $deposit_a[0] & pow( 2, $saletype - 1 ) )
{
$deposit = ( integer )$deposit;
if ( $deposit_a[2] < $deposit )
{
$deposit = $deposit_a[2];
}
}
else
{
$deposit = 0;
}
switch ( $saletype )
{
case 1 :
if ( $price != $rt['itemprice'] || $deposit != $rt['deposit'] )
{
$re = $db->getone( "SELECT COUNT(*) AS sum FROM {$PS}order WHERE tid='{$tid}'" );
if ( 0 < $re['sum'] )
{
message( "goods_not_modify" );
}
}
$priceinfo = "";
break;
case 2 :
initgp( array( "addtype", "addprice" ) );
$addprice = ( integer )$addprice;
if ( $addtype && $addprice < 1 )
{
message( "addprice_error" );
}
if ( $price != $rt['costprice'] || $deposit != $rt['deposit'] )
{
$re = $db->getone( "SELECT COUNT(*) AS sum FROM {$PS}auction WHERE tid='{$tid}'" );
if ( 0 < $re['sum'] )
{
message( "goods_not_modify" );
}
}
$priceinfo = serialize( array(
"addtype" => $addtype ? 1 : 0,
"addprice" => $addprice
) );
$sql .= ",costprice='{$price}'";
break;
case 3 :
initgp( array( "groupprice", "groupnum" ) );
checkint( $groupnum, 2 );
$pf = unserialize( $rt['priceinfo'] );
if ( $price != $rt['costprice'] || $groupprice != $pf['groupprice'] || $deposit != $rt['deposit'] )
{
$re = $db->getone( "SELECT COUNT(*) AS sum FROM {$PS}groupbuy WHERE tid='{$tid}'" );
if ( 0 < $re['sum'] )
{
message( "goods_not_modify" );
}
}
$priceinfo = serialize( array(
"groupprice" => $groupprice,
"groupnum" => 0 < $pf['buynum'] ? $pf['groupnum'] : $groupnum,
"buynum" => $pf['buynum']
) );
$sql .= ",costprice='{$price}'";
break;
default :
message( "operate_undefine" );
}
if ( !is_numeric( $itemnum ) || $itemnum < 1 )
{
message( "itemnum_error" );
}
$city = ( integer )$city;
if ( $goodpic == "2" )
{
if ( !ereg( "^http://", $httppic ) )
{
message( "httppic_error" );
}
unset( $_FILES['attachment_0'] );
unset( $_FILES['replace_0'] );
}
else
{
$keep[] = 0;
}
$shopwindow = $shopwindow ? 1 : 0;
if ( $shopwindow != $rt['ifgroom'] && ( $userdb['shopwindow'] < $_S['shopwindow'] || !$shopwindow ) )
{
if ( $shopwindow && $userdb['shopwindow'] < $_S['shopwindow'] )
{
$userdb['grooms'] .= ( $userdb['grooms'] ? "," : "" ).$tid;
}
else
{
$userdb['grooms'] = substr( str_replace( ",{$tid},", ",", ",{$userdb['grooms']}," ), 1, 0 - 1 );
}
$db->update( "UPDATE {$PS}shopset SET grooms='{$userdb['grooms']}' WHERE uid='{$user_uid}'" );
$sql .= ",ifgroom='{$shopwindow}'";
}
$ifcheck = $rt['ifcheck'] & 1;
if ( $saletime == 1 )
{
$ifcheck |= 2;
}
$degree = $degree ? $degree : "1";
if ( $carriage == "2" )
{
$postdb = array( );
$query = $db->query( "SELECT cid,type,carriage FROM {$PS}carry WHERE uid='{$user_uid}'" );
while ( $rs = $db->fetch_array( $query ) )
{
if ( 0 <= $carriagedbs[$rs['cid']] )
{
$rs['carriage'] = $carriagedbs[$rs['cid']];
}
$postdb[$rs['cid']] = $rs;
}
$carriage = $postdb ? addslashes( serialize( $postdb ) ) : "";
$extra = ( integer )$extra <= 0 ? "" : ( integer )$extra;
}
else
{
$carriage = $extra = "";
}
$oldattach = array( );
if ( $rt['attach'] )
{
$oldattach = unserialize( stripslashes( $rt['attach'] ) );
foreach ( $oldattach as $key => $value )
{
if ( !in_array( $key, $keep ) )
{
psunlink( "{$attachdir}/{$value['attachurl']}" );
if ( $value['ifthumb'] )
{
psunlink( "{$attachdir}/thumb/{$value['attachurl']}" );
}
$db->update( "DELETE FROM {$PS}upload WHERE aid='{$value['aid']}'" );
unset( $oldattach[$key] );
}
else if ( array_key_exists( "replace_".$key, $_FILES ) )
{
$db_attachnum++;
$replacedb[$key] = $oldattach[$key];
}
}
}
require_once( ROOT_PATH."require/upload.inc.php" );
if ( empty( $oldattach ) )
{
$oldattach = $attachs;
}
else if ( $attachs )
{
foreach ( $attachs as $key => $value )
{
if ( $key === 0 && !isset( $oldattach[0] ) )
{
$oldattach[0] = $value;
}
else
{
$oldattach[] = $value;
}
}
}
$httppic = $goodpic == "2" ? html( $httppic ) : isset( $oldattach[0] ) ? $oldattach[0]['attachurl'] : "";
$oldattach = $oldattach ? addslashes( serialize( $oldattach ) ) : "";
$identity = $identity ? addslashes( serialize( $identity ) ) : "";
if ( $rt['tags'] != $tags )
{
update_tag( $tid, $tags );
}
if ( $rt['ifcheck'] != $ifcheck )
{
if ( $ifcheck == "3" )
{
$db->update( "UPDATE {$PS}sysinfo SET totalitem=totalitem+1 WHERE id='1'" );
additemindex( array(
$tid => $cid
), $timestamp );
}
else if ( $rt['ifcheck'] == "3" )
{
$db->update( "UPDATE {$PS}sysinfo SET totalitem=totalitem-1 WHERE id='1'" );
$db->update( "DELETE FROM {$PS}itemindex WHERE tid='{$tid}'" );
}
}
$db->update( "UPDATE {$PS}items SET cid='{$cid}',ucid='{$dirid}',itemtype='{$saletype}',subject='{$atc_title}', itemnum='{$itemnum}',ifcheck='{$ifcheck}',degree='{$degree}',itemprice='{$price}',deposit='{$deposit}',httppic='{$httppic}',area='{$city}'{$sql} WHERE tid='{$tid}'" );
$db->update( "UPDATE {$PS}iteminfo SET property='{$identity}',attach='{$oldattach}',carriage='{$carriage}',extra='{$extra}',content='{$atc_content}',ifconvert='{$ifconvert}',tags='{$tags}',priceinfo='".addslashes( $priceinfo )."' WHERE tid='{$tid}'" );
$basename = "{$user_file}?userjob=goods&action=modify&tid={$tid}&cid={$cid}&type={$saletype}";
message( "operate_success", $basename );
}
}
?>