コード例 #1
0
ファイル: post.php プロジェクト: BackupTheBerlios/haxoo-svn
    if (!empty($_POST["attachments_tmp"])) {
        $attachments_tmp = unserialize(base64_decode($_POST["attachments_tmp"]));
        if (isset($_POST["delete_tmp"]) && count($_POST["delete_tmp"])) {
            foreach ($_POST["delete_tmp"] as $key) {
                unlink(XOOPS_CACHE_PATH . $attachments_tmp[$key][0]);
                unset($attachments_tmp[$key]);
            }
        }
    }
    $error_upload = '';
    if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != '') {
        $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024;
        $uploaddir = XOOPS_CACHE_PATH;
        require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar("dirname", "n") . '/class/uploader.php';
        $uploader = new newbb_uploader($uploaddir, $forum_obj->getVar('attach_ext'), $maxfilesize, 2400, 1800);
        $uploader->setCheckMediaTypeByExt();
        if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
            $prefix = is_object($xoopsUser) ? strval($xoopsUser->uid()) . '_' : 'newbb_';
            $uploader->setPrefix($prefix);
            if (!$uploader->upload()) {
                $error_message[] = $error_upload = $uploader->getErrors();
            } else {
                if (is_file($uploader->getSavedDestination())) {
                    $attachments_tmp[strval(time())] = array($uploader->getSavedFileName(), $uploader->getMediaName(), $uploader->getMediaType());
                }
            }
        } else {
            $error_message[] = $error_upload = $uploader->getErrors();
        }
    }
}