//插入數據庫失敗則刪除文件 @unlink(A_DIR . '/' . $attach['attachment']); } $updatesql = array(); if ($photoid) { $updatesql[] = " `picnum`=`picnum`+1 "; } if (empty($albumimg) && $photoid) { //相冊無封面圖片時設置封面圖片 $updatesql[] = " `subjectimage`='{$attach['attachment']}' "; } if ($updatesql) { DB::query('UPDATE ' . tname('albumitems') . ' SET ' . implode(', ', $updatesql) . " WHERE itemid='{$albumid}'"); if (!empty($albumid)) { require_once B_ROOT . './api/bbs_syncpost.php'; syncalbum($albumid); } } } else { $attach['name'] = 'UPLOAD Denied'; } } if (!empty($photoid) && $photoid > 0) { $_BCACHE->deltype('storelist', 'photo', $shopid, $albumid); $xmlstatus = 'success'; $fileurl = getattachurl($attach['attachment']); } else { $xmlstatus = 'failure'; } //返回XML $returnxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t\t<uploadResponse>\n\t\t\t<message>" . ($xmlstatus == 'success' ? $slang['done'] : $attach) . "</message>\n\t\t\t<status>{$xmlstatus}</status>\n\t\t\t<albumid>{$albumid}</albumid>\n\t\t\t<picid>{$photoid}</picid>\n\t\t\t<proid></proid>\n\t\t\t<filepath>{$fileurl}</filepath>\n\t\t</uploadResponse>";
function syncpost($itemid, $mname) { if (!in_array($mname, array('album', 'good', 'notice', 'consume', 'groupbuy'))) { if ($mname == 'album') { syncalbum($itmeid); return false; } } global $_G, $_SC, $_SGLOBAL; $bbs_dbpre = $_SC['bbs_dbpre']; $db = new db_mysql(array(1 => array('tablepre' => $_SC['bbs_dbpre'], 'dbcharset' => $_SC['bbs_dbcharset'], 'dbhost' => $_SC['bbs_dbhost'], 'dbuser' => $_SC['bbs_dbuser'], 'dbpw' => $_SC['bbs_dbpw'], 'dbname' => $_SC['bbs_dbname'], 'silent' => true))); $db->connect(); $item = DB::fetch_first("SELECT i.*, m.* FROM " . DB::table($mname . "items") . " i LEFT JOIN " . DB::table($mname . "message") . " m ON i.itemid = m.itemid WHERE i.itemid = '{$itemid}' AND i.grade = 3"); if (empty($item)) { $db->close(); unset($db); return false; } getpanelinfo($item['shopid']); $fid = $_SGLOBAL['panelinfo']['syncfid']; if (!checkbbsfid($fid)) { $db->close(); unset($db); return false; } //插入主題信息 $author = $_SGLOBAL['panelinfo']['username']; $authorid = $_SGLOBAL['panelinfo']['uid']; $subject = "[" . b_lang($mname) . "]" . $item['subject']; $message = postformat($mname, $item); $posttable_info = $db->result_first("SELECT svalue FROM {$bbs_dbpre}common_setting WHERE skey = 'posttable_info'"); $posttableid = 0; if (!empty($posttable_info)) { $posttable_info = unserialize($posttable_info); if (is_array($posttable_info)) { foreach ($posttable_info as $key => $info) { if ($info['type'] == 'primary') { $posttableid = $key; } } } } if (!$posttableid) { $tablename = 'forum_post'; } else { $tablename = "forum_post_{$posttableid}"; } if (empty($item['bbstid'])) { $db->query("INSERT INTO {$bbs_dbpre}forum_thread (fid, posttableid, author, authorid, subject, dateline, lastpost, lastposter)\n VALUES ('{$fid}', '{$posttableid}', '{$author}', '{$authorid}', '{$subject}', '{$_G['timestamp']}', '{$_G['timestamp']}', '{$author}')"); $tid = $db->insert_id(); $db->query("UPDATE {$bbs_dbpre}common_member_field_home SET recentnote = '{$subject}' WHERE uid = '{$authorid}'"); $db->query("INSERT INTO {$bbs_dbpre}forum_post_tableid (pid) values (null)"); $pid = $db->insert_id(); if ($pid % 1024 == 0) { $db->query("DELETE FROM {$bbs_dbpre}forum_post_tableid WHERE pid<{$pid}"); } $db->query("REPLACE INTO {$bbs_dbpre}common_syscache (cname, ctype, dateline, data) VALUES ('max_post_id', '0', '{$_G['timestamp']}', '{$pid}')"); if (!$posttableid) { $tablename = 'forum_post'; } else { $tablename = "forum_post_{$posttableid}"; } $db->query("INSERT INTO {$bbs_dbpre}{$tablename} SET `fid`='{$fid}',`tid`='{$tid}',`first`='1',`author`='{$author}',`authorid`='{$authorid}',`subject`='{$subject}',`dateline`='{$_G['timestamp']}',`message`='{$message} ',`useip`='unknown',`invisible`='0',`anonymous`='0',`usesig`='1',`htmlon`='0',`bbcodeoff`='0',`smileyoff`='-1',`parseurloff`='',`attachment`='0',`tags`='',`pid`='{$pid}'"); $db->query("UPDATE {$bbs_dbpre}forum_forum SET lastpost='{$tid} {$subject} {$_G[timestamp]} {$author}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$fid}'"); $db->query("UPDATE {$bbs_dbpre}common_stat SET `thread`=`thread`+1 WHERE daytime='" . date("Ymd", $_G[timestamp]) . "'"); updatetable($mname . 'items', array('bbstid' => $tid), array('itemid' => $item['itemid'])); } else { $tid = $item['bbstid']; $db->query("UPDATE {$bbs_dbpre}forum_thread SET subject='" . $subject . "' WHERE tid='{$tid}'"); $pid = $db->result_first("SELECT pid FROM {$bbs_dbpre}{$tablename} WHERE tid = '{$tid}' AND first = 1"); $db->query("UPDATE {$bbs_dbpre}{$tablename} SET message='{$message}' WHERE pid='{$pid}' AND tid = '{$tid}' AND first = 1"); } }
* * $Id: ajax.inc.php 4446 2010-09-14 11:35:06Z xuhui $ */ if (!defined('IN_STORE')) { exit('Acess Denied'); } $opt = $_GET['opt']; if ($opt == "edit_album_subject") { $album_id = intval($_GET['album_id']); $subject = biconv(trim($_GET['subject']), 'UTF-8', $_G['charset']); $subject_old = DB::result_first("select subject from " . tname('albumitems') . " where uid=" . $_G['uid'] . " and itemid=" . $album_id); if ($subject_old != $subject) { DB::query('update ' . tname('albumitems') . ' set subject=\'' . $subject . '\' where uid=' . $_G['uid'] . ' and itemid=' . $album_id); if (!empty($album_id)) { require_once B_ROOT . './api/bbs_syncpost.php'; syncalbum($album_id); } die('OK'); } else { die('NO-MODIFY'); } exit; } elseif ($opt == "edit_photo_subject") { $photo_id = intval($_GET['photo_id']); $subject = biconv(trim($_GET['subject']), 'UTF-8', $_G['charset']); $subject_old = DB::result_first("select subject from " . tname('photoitems') . " where itemid=" . $photo_id); if ($subject_old != $subject) { DB::query('update ' . tname('photoitems') . ' set subject=\'' . $subject . '\' where itemid=' . $photo_id); die('OK'); } else { die('NO-MODIFY');
function delmitems($wheresql = '', $type = 'shop') { global $_G, $_SGLOBAL, $itemarr, $mname, $_BCACHE; if (!empty($wheresql)) { $thissql = str_replace(' itemid IN', ' i.itemid IN', $wheresql); $itemidsql = $relatedidsql = ''; if ($mname != 'shop') { $itemidsql = 'itemid'; $relatedidsql = 'relatedid'; } if ($type == 'shop') { $subsql = str_replace(' itemid IN', ' shopid IN', $wheresql); if ($_POST['opdelete']) { //遞歸刪除所有店舖的子元素 delmitems($subsql, 'good'); delmitems($subsql, 'consume'); delmitems($subsql, 'notice'); delmitems($subsql, 'photo'); delmitems($subsql, 'album'); $commquery = DB::query("SELECT cid FROM " . tname("spacecomments") . " WHERE {$wheresql}"); while ($res = DB::fetch($commquery)) { deletecomment($res['cid']); } $shop_related_sql = str_replace(' itemid IN', ' shopid IN', $wheresql); DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE " . $shop_related_sql); } $selectsql = ' i.itemid, i.subject, m.banner, m.windowsimg '; $joinsql = tname('shopitems') . ' i INNER JOIN ' . tname('shopmessage') . ' m ON i.itemid=m.itemid '; } elseif ($type == 'album') { $subsql = str_replace(' itemid IN', ' i.albumid IN', $wheresql); delmitems($subsql, 'photo'); $selectsql = ' i.itemid, i.subjectimage '; $joinsql = tname($type . 'items') . ' i'; // 刪除關聯信息 $related_sql = str_replace(' itemid IN', ' IN', $wheresql); DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE relatedtype = 'album' AND {$relatedid} " . $related_sql); } elseif ($type == 'photo') { $selectsql = ' i.itemid, i.albumid, i.subjectimage '; $joinsql = tname($type . 'items') . ' i'; } else { $selectsql = ' i.itemid, i.subjectimage '; $joinsql = tname($type . 'items') . ' i'; $related_sql = str_replace(' itemid IN', ' IN', $wheresql); if ($type == 'good' || $type == 'groupbuy') { DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE type = '" . $type . "' AND {$itemidsql} " . $related_sql); } DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE relatedtype = '" . $type . "' AND {$relatedid} " . $related_sql); } $thisalbumid = 0; $query = DB::query('SELECT ' . $selectsql . ' FROM ' . $joinsql . ' WHERE ' . $thissql); $filefields = array('subjectimage', 'banner', 'windowsimg'); //刪除圖片 while ($value = DB::fetch($query)) { foreach ($filefields as $v) { if (!empty($value[$v]) && strstr($value[$v], '.jpg')) { @unlink(A_DIR . '/' . $value[$v]); @unlink(A_DIR . '/' . substr($value[$v], 0, -4) . '.thumb.jpg'); } } $thisalbumid = $value['albumid']; } if (in_array($type, array('album', 'photo'))) { $query = DB::query('DELETE i FROM ' . tname($type . 'items') . ' i WHERE ' . $thissql); //刪除相冊和圖片信息,只有item表 if ($type == 'photo' && $thisalbumid > 0) { $picnums = DB::affected_rows($query); $query = DB::query('UPDATE ' . tname('albumitems') . " SET `picnum`=`picnum`-{$picnums} WHERE itemid='{$thisalbumid}'"); //刪除相冊和圖片信息,只有item表 if (!empty($thisalbumid)) { require_once B_ROOT . './api/bbs_syncpost.php'; syncalbum($thisalbumid); } if ($_SGLOBAL['panelinfo']['group']['verifyalbum']) { $thisalbumgrade = DB::result_first('SELECT grade FROM ' . tname('albumitems') . ' WHERE itemid=\'' . $thisalbumid . '\''); if ($thisalbumgrade == 1) { DB::query("UPDATE " . tname('albumitems') . " SET grade = 0 WHERE itemid = '{$thisalbumid}'"); } } } } elseif ($type == 'shop') { foreach ($itemarr as $itemid) { updatemyshopid($itemid); deletetable('shopitems', array('itemid' => $itemid)); deletetable('shopmessage', array('itemid' => $itemid)); } } else { $query = DB::query('DELETE i, m FROM ' . tname($type . 'items') . ' i INNER JOIN ' . tname($type . 'message') . ' m ON i.itemid=m.itemid WHERE ' . $thissql); //刪除信息 } } }