Beispiel #1
0
/**
 * 創建相冊
 * @param
 * @return 相冊id
 */
function createalbum($shopid = 0, $catid = 0, $uid = 0, $username = '', $subject = '', $description = '')
{
    global $_G, $_SGLOBAL;
    $arr_data = array();
    //id
    foreach (array('shopid', 'catid', 'uid') as $value) {
        ${$value} = intval(${$value});
    }
    //字符串
    foreach (array('subject', 'description') as $value) {
        ${$value} = trim(strip_tags(${$value}));
    }
    //判斷必填,設置插入數據庫的數據
    foreach (array('shopid', 'catid', 'uid', 'username', 'subject') as $value) {
        if (empty(${$value})) {
            cpmsg($value . '_not_selected', '', '', '', true, true);
        }
        $arr_data[$value] = ${$value};
    }
    $arr_data['description'] = $description;
    if ($_SGLOBAL['panelinfo']['group']['verifyalbum'] && !pkperm('isadmin')) {
        $arr_data['grade'] = 0;
    } else {
        $arr_data['grade'] = 3;
    }
    $arr_data['dateline'] = $_G['timestamp'];
    $albumid = inserttable('albumitems', $arr_data, 1);
    if (!$albumid) {
        cpmsg('album_creat_error', '', '', '', true, true);
    }
    //相冊屬性
    if (!empty($_POST['attr_ids'])) {
        require_once B_ROOT . "./batch.attribute.php";
        setattributesettings($catid, $albumid, $_POST['attr_ids']);
    }
    return $albumid;
}
Beispiel #2
0
         }
     }
     $ucdata = uc_get_user($ucid, 1);
     list($ucid, $ucname, $ucemail) = $ucdata;
     //unset所有uc註冊變量
     $ucarr = array('ucreg_username', 'ucreg_password', 'ucreg_rtpassword', 'ucreg_email');
     foreach ($ucarr as $value) {
         unset($_POST[$value]);
     }
 }
 //提交了數據
 if ($itemid = pkpost($cacheinfo)) {
     if (in_array($mname, array('good', 'notice', 'consume', 'album', 'groupbuy'))) {
         if (!empty($_POST['attr_ids'])) {
             require_once B_ROOT . '/batch.attribute.php';
             setattributesettings($_POST['catid'], $itemid, $_POST['attr_ids']);
         }
         if ($mname == 'good' || $mname == 'groupbuy') {
             DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE itemid='{$itemid}' AND type='{$mname}'");
             if (!empty($_POST['relatedobject'])) {
                 $relatedidarr = $relatedinfoarr = array();
                 $relatedidstr = '';
                 $relatedidstr = explode(',', trim($_POST['relatedobject']));
                 foreach ($relatedidstr as $related) {
                     $related = explode('@', $related);
                     $relatedtype = trim($related[0]);
                     $relatedid = intval($related[1]);
                     if (DB::result_first("SELECT itemid FROM " . tname($relatedtype . "items") . " WHERE itemid='{$relatedid}'")) {
                         $relatedidarr[$relatedid] = $relatedtype;
                     }
                 }
Beispiel #3
0
/**
 * 批准店舖、商品、消費券、公告、相冊、的更新內容
 *return
 */
function pkupdate($cacheinfo, $update)
{
    global $_G, $_SGLOBAL, $theurl, $mname;
    $_POST = $update;
    $itemid = $_POST['itemid'];
    $resultitems = $resultmessage = $resultimage = $updateitem = array();
    $modelsinfoarr = $cacheinfo['models'];
    $columnsinfoarr = $cacheinfo['columns'];
    foreach ($columnsinfoarr as $result) {
        if ($result['isfixed'] == 1) {
            $resultitems[] = $result;
        } else {
            $resultmessage[] = $result;
        }
        if ($result['isimage'] == 1) {
            $resultimage[] = $result;
        }
    }
    //構建數據
    $setsqlarr = $setitemsqlarr = array();
    $setsqlarr = getsetsqlarr($resultitems);
    $setsqlarr['subjectimage'] = isset($_POST['subjectimage']) ? $_POST['subjectimage'] : '';
    $setsqlarr['updateverify'] = 0;
    $setsqlarr['catid'] = $_POST['catid'];
    $setsqlarr['subject'] = $_POST['subject'];
    $setsqlarr['grade'] = $_POST['grade'];
    unset($setsqlarr['grade']);
    $query = DB::query('SELECT * FROM ' . tname($modelsinfoarr['modelname'] . 'items') . ' WHERE itemid = \'' . $itemid . '\'');
    $defaultmessage = DB::fetch($query);
    $ext = fileext($defaultmessage['subjectimage']);
    if ($defaultmessage['subjectimage'] != $setsqlarr['subjectimage']) {
        if (in_array($ext, array('jpg', 'jpeg', 'png'))) {
            @unlink(A_DIR . '/' . substr($defaultmessage['subjectimage'], 0, strrpos($defaultmessage['subjectimage'], '.')) . '.thumb.jpg');
        }
        @unlink(A_DIR . '/' . $defaultmessage['subjectimage']);
    }
    updatetable($modelsinfoarr['modelname'] . 'items', $setsqlarr, array('itemid' => $itemid));
    //權限限制
    $setsqlarr = getsetsqlarr($resultmessage);
    $setsqlarr['message'] = $_POST['message'];
    if ($modelsinfoarr['modelname'] == 'shop') {
        $setsqlarr['banner'] = isset($_POST['banner']) ? $_POST['banner'] : '';
        $setsqlarr['windowsimg'] = isset($_POST['windowsimg']) ? $_POST['windowsimg'] : '';
        $query = DB::query('SELECT * FROM ' . tname($modelsinfoarr['modelname'] . 'message') . ' WHERE itemid = \'' . $itemid . '\'');
        $defaultmessage = DB::fetch($query);
        foreach ($resultimage as $ext_img) {
            $ext = fileext($defaultmessage[$ext_img['fieldname']]);
            if ($defaultmessage[$ext_img['fieldname']] != $setsqlarr[$ext_img['fieldname']]) {
                if (in_array($ext, array('jpg', 'jpeg', 'png'))) {
                    @unlink(A_DIR . '/' . substr($defaultmessage[$ext_img['fieldname']], 0, strrpos($defaultmessage[$ext_img['fieldname']], '.')) . '.thumb.jpg');
                }
                @unlink(A_DIR . '/' . $defaultmessage[$ext_img['fieldname']]);
            }
        }
    } elseif ($modelsinfoarr['modelname'] == 'consume') {
        $setsqlarr['exception'] = $_POST['exception'];
    }
    if ($setsqlarr) {
        updatetable($modelsinfoarr['modelname'] . 'message', $setsqlarr, array('itemid' => $itemid));
        //權限限制
    }
    if (!empty($_POST['relatedidstr'])) {
        $shopid = $_POST['shopid'];
        foreach ($_POST['relatedidstr'] as $related) {
            $related = explode('@', $related);
            $relatedtype = trim($related[0]);
            $relatedid = intval($related[1]);
            if (DB::result_first("SELECT itemid FROM " . tname($relatedtype . "items") . " WHERE itemid='{$relatedid}'")) {
                $relatedidarr[$relatedid] = $relatedtype;
            }
        }
        foreach ($relatedidarr as $relatedid => $relatedtype) {
            $goodrelatedarr[] = '(\'' . $itemid . '\', \'good\', \'' . $relatedid . '\', \'' . $relatedtype . '\', \'' . $shopid . '\')';
        }
        DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE itemid='{$itemid}' AND type='good'");
        DB::query("REPLACE INTO " . tname('relatedinfo') . " (`itemid`, `type`, `relatedid`, relatedtype, `shopid`) VALUES " . implode(",", $goodrelatedarr) . " ");
    } elseif ($modelsinfoarr['modelname'] == 'good') {
        DB::query("DELETE FROM " . tname('relatedinfo') . " WHERE itemid='{$itemid}' AND type='good'");
    }
    if (!empty($_POST['attr_ids'])) {
        require_once B_ROOT . '/batch.attribute.php';
        setattributesettings($_POST['catid'], $itemid, $_POST['attr_ids']);
    }
    DB::query("DELETE FROM " . tname('itemupdates') . " WHERE `type` = '{$modelsinfoarr['modelname']}' AND itemid='{$itemid}'");
    require_once B_ROOT . './api/bbs_syncpost.php';
    syncpost($itemid, $mname);
}
Beispiel #4
0
         $update['itemid'] = $itemid;
         if ($mname == 'album') {
             foreach ($update as $k => $v) {
                 if (in_array($k, array('subject', 'catid'))) {
                     $setsqlarr[$k] = $v;
                 }
             }
             if ($setsqlarr) {
                 $setsqlarr['updateverify'] = 0;
                 updatetable($mname . 'items', $setsqlarr, array('itemid' => $itemid));
                 //權限限制
                 DB::query("UPDATE " . tname("photoitems") . " SET `grade` = 3 WHERE grade = 0 AND albumid = '{$itemid}'");
                 if (!empty($update['attr_ids'])) {
                     DB::query("DELETE FROM " . tname('itemattribute') . " WHERE itemid='{$itemid}'");
                     require_once B_ROOT . './batch.attribute.php';
                     setattributesettings($update['catid'], $itemid, $update['attr_ids']);
                 }
             }
             DB::query("DELETE FROM " . tname('itemupdates') . " WHERE `type` = 'album' AND itemid='{$itemid}'");
         } else {
             pkupdate($cacheinfo, $update);
         }
         unset($update, $setsqlarr, $updateser);
     }
 } else {
     $opcheck = 2;
     $pmtitle = lang('mod_updatetitle_fail');
     DB::query("UPDATE " . tname($mname . 'items') . " SET `updateverify` = 0 WHERE itemid IN ({$items})");
     DB::query("DELETE FROM " . tname('itemupdates') . " WHERE `type` = '{$modelname}' AND itemid IN ({$items})");
 }
 if ($modelname != 'shop') {
Beispiel #5
0
function album_movecat_panel($wheresql)
{
    global $_G, $_SGLOBAL, $cookie_referer;
    require_once B_ROOT . './batch.attribute.php';
    $num_ok = $num_error = 0;
    $itemarr = $gradearr = array();
    //驗證catid
    $catid = $_POST['catid'] = DB::result_first('SELECT catid FROM ' . tname('categories') . " WHERE catid='{$_POST['catid']}' AND `type`='album'");
    if ($_SGLOBAL['panelinfo']['group']['album_field'] != 'all' && !in_array($catid, explode(",", $_SGLOBAL['panelinfo']['group']['album_field']))) {
        cpmsg('no_perm', $cookie_referer);
    }
    $query = DB::query('SELECT itemid, grade FROM ' . tname('albumitems') . " WHERE {$wheresql}");
    while ($result = DB::fetch($query)) {
        $itemarr[$result['itemid']] = $result['itemid'];
        $gradearr[$result['itemid']] = $result['grade'];
    }
    if ($catid && $itemarr) {
        if ($_SGLOBAL['panelinfo']['group']['verifyalbum']) {
            foreach ($itemarr as $itemid) {
                if ($gradearr[$itemid] > 1) {
                    $query = DB::query('SELECT * FROM ' . tname('albumitems') . " WHERE itemid='{$itemid}' AND shopid='{$_G['myshopid']}' LIMIT 1");
                    $update = DB::fetch($query);
                    $update['catid'] = $catid;
                    $update['attr_ids'] = $_POST['attr_ids'];
                    $update = serialize($update);
                    DB::query("REPLACE INTO " . tname("itemupdates") . " (`itemid`, `type`, `updatestatus`, `update`) VALUES ({$itemid}, 'album', '1', '{$update}');");
                    DB::query("UPDATE " . tname("albumitems") . " SET updateverify = 1 WHERE itemid = '{$itemid}' ;");
                    $num_ok++;
                } elseif ($gradearr[$itemid] == 1) {
                    DB::query("UPDATE " . tname("albumitems") . " SET grade = 0 WHERE itemid = '{$itemid}' ;");
                    $num_error++;
                }
            }
            cpmsg(lang('mod_album_success1') . $num_ok . lang('mod_album_success2') . $num_error . lang('mod_album_success3') . lang('mod_album_success4'), $cookie_referer);
        } else {
            foreach ($itemarr as $itemid) {
                DB::query('UPDATE ' . tname('albumitems') . " SET catid='{$catid}' WHERE itemid='{$itemid}' AND shopid='{$_G['myshopid']}'");
                if (DB::affected_rows()) {
                    DB::query('DELETE FROM ' . tname('itemattribute') . " WHERE itemid='{$itemid}'");
                    setattributesettings($_POST['catid'], $itemid, $_POST['attr_ids']);
                    $num_ok++;
                } else {
                    $num_error++;
                }
            }
            cpmsg(lang('mod_album_success1') . $num_ok . lang('mod_album_success2') . $num_error . lang('mod_album_success3'), $cookie_referer);
        }
    }
    cpmsg('no_operation');
}