function onedit() { $gid = intval($this->get[2]) ? $this->get[2] : $this->post['id']; if (isset($this->post['submit'])) { $title = $this->post['giftname']; $desrc = $this->post['giftdesrc']; $credit = intval($this->post['giftprice']); $imgname = strtolower($_FILES['imgurl']['name']); if ('' == $title || !$credit) { $message = '请正确填写礼品相关信息'; $type = 'errormsg'; include template('addgift', 'admin'); exit; } $type = substr(strrchr($imgname, '.'), 1); if (!empty($_FILES['imgurl']['tmp_name']) && !isimage($type)) { $message = '图片格式不支持,目前仅支持jpg、gif、png格式!'; $type = 'errormsg'; include template('addgift', 'admin'); exit; } $filepath = '/data/attach/giftimg/gift' . random(6, 0) . '.' . $type; forcemkdir(TIPASK_ROOT . '/data/attach/giftimg'); if (!empty($_FILES['imgurl']['tmp_name']) && !move_uploaded_file($_FILES['imgurl']['tmp_name'], TIPASK_ROOT . $filepath)) { $message = '服务器忙,请稍后再试!'; $type = 'errormsg'; include template('addgift', 'admin'); exit; } empty($_FILES['imgurl']['tmp_name']) && ($filepath = $this->post['imgpath']); $_ENV['gift']->update($title, $desrc, $filepath, $credit, $gid); $message = "修改成功!"; } $gift = $_ENV['gift']->get($gid); include template('addgift', 'admin'); }
/** * 后台修改专题 */ function onedit() { if (isset($this->post['submit'])) { $title = $this->post['title']; $desrc = $this->post['desc']; $tid = intval($this->post['id']); $imgname = strtolower($_FILES['image']['name']); if ('' == $title || '' == $desrc) { $this->ondefault('请完整填写专题相关参数!', 'errormsg'); exit; } if ($imgname) { $type = substr(strrchr($imgname, '.'), 1); if (!isimage($type)) { $this->ondefault('当前图片图片格式不支持,目前仅支持jpg、gif、png格式!', 'errormsg'); exit; } $filepath = '/data/attach/topic/topic' . random(6, 0) . '.' . $type; $upload_tmp_file = TIPASK_ROOT . '/data/tmp/topic_' . random(6, 0) . '.' . $type; forcemkdir(TIPASK_ROOT . '/data/attach/topic'); if (move_uploaded_file($_FILES['image']['tmp_name'], $upload_tmp_file)) { image_resize($upload_tmp_file, TIPASK_ROOT . $filepath, 270, 220); $_ENV['topic']->update($tid, $title, $desrc, $filepath); $this->ondefault('专题修改成功!'); } else { $this->ondefault('服务器忙,请稍后再试!'); } } else { $_ENV['topic']->update($tid, $title, $desrc); $this->ondefault('专题修改成功!'); } } else { $topic = $_ENV['topic']->get(intval($this->get[2])); include template("addtopic", 'admin'); } }
function renderdir($rootdir, $dir) { global $ignore; $ret = ''; $r = $fnlist = $dirlist = array(); $r['index'] = null; if (($dir = safepath($rootdir, $dir)) === false) { redirect('index.php'); } $r['dir'] = $dir; $list = (array) uscandir(pathjoin($rootdir, $dir)); if ($list === false) { redirect('index.php?base=' . $_GET['base']); } foreach ($list as $e) { if ($e == '.' || $e == '..' || in_array(strtolower($e), $ignore)) { continue; } if (uis_dir(pathjoin($rootdir, $dir, $e))) { $dirlist[] = $e; } else { $fnlist[] = $e; } } $index_file = tryindex($fnlist, $dir); if (!empty($index_file)) { $r['index'] = pathjoin($rootdir, $dir, $index_file); } natsort($dirlist); natsort($fnlist); foreach ($dirlist as $e) { $cfg = loadcfg(pathjoin($rootdir, $dir, $e)); if (isset($cfg['index'])) { $idx = pathjoin($dir, $e, upath($cfg['index'])); $ahref = urlenc(pathjoin($rootdir, $idx)); $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode($idx); } else { $ahref = 'index.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)); $img = 'images/dir.gif'; } if (isset($cfg['icon'])) { $img = 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e, upath($cfg['icon']))); } $ret .= mkitem($e, $e, $e, '<a href="' . $ahref . '"' . ($cfg['target'] == '_blank' ? ' target="_blank"' : '') . '>', $img, istoday(pathjoin($rootdir, $dir, $e)), ($dz = udirsize(pathjoin($rootdir, $dir, $e))) > 0 ? '<br /><a name="pack" style="visibility: hidden; float:right;" href="pack.php?base=' . $_GET['base'] . '&dir=' . urlencode(pathjoin($dir, $e)) . '"><img alt="Download" title="Download - ' . fsize($dz) . '" src="images/pack.gif" /></a>' : ''); } foreach ($fnlist as $e) { if (isvideo($e) || isaudio($e)) { $ahref = '<a href="flowplayer.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isimage($e)) { $ahref = '<a href="image.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (isweb($e)) { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } elseif (isdocument($e)) { $ahref = '<a href="document.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } elseif (iscode($e)) { $ahref = '<a href="code.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)) . '">'; } else { $ahref = '<a href="' . urlenc(pathjoin($rootdir, $dir, $e)) . '">'; } # echo $dir.$e."\t".urlencode($dir.$e)."\n"; $ret .= mkitem($e, $e, $e . ' - (' . fsize(ufilesize(pathjoin($rootdir, $dir, $e))) . ')', $ahref, 'thumb.php?base=' . $_GET['base'] . '&file=' . urlencode(pathjoin($dir, $e)), istoday(pathjoin($rootdir, $dir, $e)), null); } $r['html'] = $ret; return $r; }
function thumb_able($file) { return isvideo($file) || isimage($file) || isdocument($file) || isweb($file); }
function oneditimg() { if (isset($_FILES["userimage"])) { $uid = intval($this->get[2]); $avatardir = "/data/avatar/"; $extname = extname($_FILES["userimage"]["name"]); if (!isimage($extname)) { exit('type_error'); } $upload_tmp_file = TIPASK_ROOT . '/data/tmp/user_avatar_' . $uid . '.' . $extname; $uid = abs($uid); $uid = sprintf("%09d", $uid); $dir1 = $avatardir . substr($uid, 0, 3); $dir2 = $dir1 . '/' . substr($uid, 3, 2); $dir3 = $dir2 . '/' . substr($uid, 5, 2); !is_dir(TIPASK_ROOT . $dir1) && forcemkdir(TIPASK_ROOT . $dir1); !is_dir(TIPASK_ROOT . $dir2) && forcemkdir(TIPASK_ROOT . $dir2); !is_dir(TIPASK_ROOT . $dir3) && forcemkdir(TIPASK_ROOT . $dir3); $smallimg = $dir3 . "/small_" . $uid . '.' . $extname; if (move_uploaded_file($_FILES["userimage"]["tmp_name"], $upload_tmp_file)) { $avatar_dir = glob(TIPASK_ROOT . $dir3 . "/small_{$uid}.*"); foreach ($avatar_dir as $imgfile) { if (strtolower($extname) != extname($imgfile)) { unlink($imgfile); } } if (image_resize($upload_tmp_file, TIPASK_ROOT . $smallimg, 80, 80)) { echo 'ok'; } } } else { if ($this->setting["ucenter_open"]) { $this->load('ucenter'); $imgstr = $_ENV['ucenter']->set_avatar($this->user['uid']); } include template("editimg"); } }
if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '.mp3')) { mylock($thash) || exit; if (ismidi($file)) { $cmd = $CFG['timidity'] . ' -Ow -o ' . escapeshellarg(r($CFG['tempdir'] . $thash . '.wav')) . ' ' . escapeshellarg(r($rootdir . $file)); exe($cmd); $cmd = $CFG['ffmpeg'] . ' -y -i ' . escapeshellarg(r($CFG['tempdir'] . $thash . '.wav')) . ' -b 96k ' . escapeshellarg($CFG['cachedir'] . $hash . '.mp3'); exe($cmd); uunlink($CFG['tempdir'] . $thash . '.wav'); } else { $cmd = $CFG['ffmpeg'] . ' -y -i ' . escapeshellarg(r($rootdir . $file)) . ' ' . escapeshellarg($CFG['cachedir'] . $hash . '.mp3'); exe($cmd); } touch($CFG['cachedir'] . $hash . '.mp3', ufiletime($rootdir . $file), $_now); myunlock($thash); } } elseif (isimage($file)) { if (newer($rootdir . $file, $CFG['cachedir'] . $hash . '_' . $size . '.jpg')) { mylock($thash) || exit; if (!ufile_exists($CFG['tempdir'] . $thash . '.jpg') && !ufile_exists($CFG['tempdir'] . $thash . '-0.jpg')) { $cmd = $CFG['imagemagick_convert'] . ' -quality 70 -geometry ' . $size . ' ' . escapeshellarg(r($rootdir . $file)) . ' ' . escapeshellarg($CFG['tempdir'] . $thash . '.jpg'); exe($cmd); } if (ufile_exists($CFG['tempdir'] . $thash . '.jpg')) { ucopy($CFG['tempdir'] . $thash . '.jpg', $CFG['cachedir'] . $hash . '_' . $size . '.jpg'); uunlink($CFG['tempdir'] . $thash . '.jpg'); } elseif (ufile_exists($CFG['tempdir'] . $thash . '-0.jpg')) { ucopy($CFG['tempdir'] . $thash . '-0.jpg', $CFG['cachedir'] . $hash . '_' . $size . '.jpg'); $i = 0; while (ufile_exists($CFG['tempdir'] . $thash . '-' . $i . '.jpg')) { unlink($CFG['tempdir'] . $thash . '-' . $i . '.jpg'); ++$i;
$rootdir = getbase($b); $fp = pathjoin($rootdir, $p); if (uis_dir($fp)) { $fs = uscandir($fp); foreach ($fs as $f) { if ($f == '.' || $f == '..') { continue; } $todo[] = array($b, pathjoin($p, $f)); } continue; } $hash = mkhash($fp); $hash = $b . '/' . $hash; $size = $CFG['thumb_size']; if (isimage($fp)) { $t1 = $CFG['cachedir'] . $hash . '_' . $size . '.jpg'; if (!newer($fp, $t1)) { touch($t1, filemtime($t1), $_now); continue; } } elseif (isvideo($fp)) { $t1 = $CFG['cachedir'] . $hash . '.mp4'; $t2 = $CFG['cachedir'] . $hash . '_L.jpg'; $t3 = $CFG['cachedir'] . $hash . '_' . $size . '.jpg'; if (!(newer($fp, $t1) || newer($fp, $t2) || newer($fp, $t3))) { touch($t1, filemtime($t1), $_now); touch($t2, filemtime($t2), $_now); touch($t3, filemtime($t3), $_now); continue; }