Esempio n. 1
0
 function check_dir_exists($type = '', $sub1 = '', $sub2 = '')
 {
     $type = discuz_upload::check_dir_type($type);
     $basedir = !getglobal('setting/attachdir') ? DISCUZ_ROOT . './data/attachment' : getglobal('setting/attachdir');
     $typedir = $type ? $basedir . '/' . $type : '';
     $subdir1 = $type && $sub1 !== '' ? $typedir . '/' . $sub1 : '';
     $subdir2 = $sub1 && $sub2 !== '' ? $subdir1 . '/' . $sub2 : '';
     $res = $subdir2 ? is_dir($subdir2) : ($subdir1 ? is_dir($subdir1) : is_dir($typedir));
     if (!$res) {
         $res = $typedir && discuz_upload::make_dir($typedir);
         $res && $subdir1 && ($res = discuz_upload::make_dir($subdir1));
         $res && $subdir1 && $subdir2 && ($res = discuz_upload::make_dir($subdir2));
     }
     return $res;
 }
Esempio n. 2
0
function setattachment($bid, $caid, $tid, $pid)
{
    global $_G;
    $attachment = C::t('#sanree_brand#sanree_brand_attachment')->fetch_firstbyaid($caid);
    if ($attachment) {
        $aid = getattachnewaid($attachment['uid']);
        $insert = array('aid' => $aid, 'tid' => $tid, 'pid' => $pid, 'dateline' => $attachment['dateline'], 'filename' => $attachment['filename'], 'filesize' => $attachment['filesize'], 'attachment' => $attachment['attachment'], 'isimage' => $attachment['isimage'], 'uid' => $attachment['uid'], 'thumb' => $attachment['thumb'], 'remote' => $attachment['remote'], 'width' => $attachment['width']);
        $target = getglobal('setting/attachdir') . './forum/' . $attachment['attachment'];
        list($one, $tow) = explode("/", $attachment['attachment']);
        $appVer = $_G['setting']['version'];
        if ($appVer == 'X2') {
            require_once libfile('class/upload');
        }
        discuz_upload::make_dir(getglobal('setting/attachdir') . './forum/' . $one);
        discuz_upload::make_dir(getglobal('setting/attachdir') . './forum/' . $one . '/' . $tow);
        $source = getglobal('setting/attachdir') . './category/' . $attachment['attachment'];
        !file_exists($target) && @copy($source, $target);
        $tableid = getattachtableid($tid);
        DB::update('forum_attachment_' . $tableid, array('tid' => 0, 'pid' => 0), "tid=" . $tid);
        DB::update('forum_attachment', array('tid' => 0, 'pid' => 0), "tid=" . $tid);
        C::t('#sanree_brand#forum_attachment_n')->insert($tableid, $insert);
        DB::update('forum_attachment', array('tid' => $tid, 'pid' => $pid, 'uid' => $attachment['uid'], 'tableid' => $tableid), "aid=" . $aid);
        C::t('#sanree_brand#sanree_brand_businesses')->update($bid, array('aid' => $aid));
        $tidata = C::t('#sanree_brand#forum_post')->fetch_threadpost_by_tid_invisible($tid);
        $message = $tidata['message'];
        $message = preg_replace('/\\[poster\\]/is', '[attach]' . $aid . '[/attach]', $message);
        C::t('#sanree_brand#forum_post')->update(0, $pid, array('message' => $message, 'attachment' => 1), TRUE);
        $data = array('tid' => $tid, 'attachment' => $attachment['attachment'], 'remote' => 0);
        C::t('#sanree_brand#forum_threadimage')->delete($tid);
        C::t('#sanree_brand#forum_threadimage')->insert($data);
    }
}