예제 #1
0
function magic_buy_get($magic)
{
    global $_SGLOBAL, $space;
    //购买
    if (!$magic) {
        showmessage('unknown_magic');
        //请选择道具
    } else {
        $mid = $magic['mid'];
    }
    $blacklist = array('coupon');
    //道具商店屏蔽购买的道具
    if (in_array($mid, $blacklist)) {
        showmessage('magic_not_for_sale');
        //此道具不能通过购买获得
    }
    if (!checkperm('allowmagic')) {
        ckspacelog();
        showmessage('magic_groupid_not_allowed');
        //您所在的用户组被禁止使用道具
    }
    //用户组限制
    if ($magic['forbiddengid'] && in_array($space['groupid'], $magic['forbiddengid'])) {
        showmessage('magic_groupid_limit');
    }
    $setarr = array('mid' => $mid, 'storage' => $magic['providecount'], 'lastprovide' => $_SGLOBAL['timestamp']);
    $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('magicstore') . " WHERE mid = '{$mid}'");
    $magicstore = $_SGLOBAL['db']->fetch_array($query);
    if (!$magicstore) {
        inserttable('magicstore', $setarr);
        $magicstore['storage'] = $magic['providecount'];
    } elseif ($magicstore['storage'] < $magic['providecount'] && $magicstore['lastprovide'] + $magic['provideperoid'] < $_SGLOBAL['timestamp']) {
        unset($setarr['mid']);
        updatetable('magicstore', $setarr, array('mid' => $mid));
        $magicstore['storage'] = $magic['providecount'];
    }
    if ($magicstore['storage'] < 1) {
        $nexttime = sgmdate('m-d H:i', $magicstore['lastprovide'] + $magic['provideperoid']);
        showmessage('not_enough_storage', '', '', array($nexttime));
        //库存不足
    }
    //折扣
    $discount = checkperm('magicdiscount');
    $charge = $magic['charge'];
    if ($discount > 0) {
        $charge = intval($magic['charge'] * $discount / 10);
        if ($charge < 1) {
            $charge = 1;
        }
    } elseif ($discount < 0) {
        $charge = 0;
    }
    //最多可以购买数
    $magicstore['maxbuy'] = $charge ? min($magicstore['storage'], floor($space['credit'] / $charge)) : $magicstore['storage'];
    //代金券
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname("usermagic") . " WHERE uid='{$_SGLOBAL['supe_uid']}' AND mid = 'coupon'");
    $coupon = $_SGLOBAL['db']->fetch_array($query);
    return array('magicstore' => $magicstore, 'coupon' => $coupon, 'discount' => $discount, 'charge' => $charge);
}
예제 #2
0
function pic_save($FILE, $albumid, $title, $topicid=0) {
	global $_SGLOBAL, $_SCONFIG, $space, $_SC;

	if($albumid<0) $albumid = 0;
	
	//允许上传类型
	$allowpictype = array('jpg','jpeg','gif','png');

	//检查
	$FILE['size'] = intval($FILE['size']);
	if(empty($FILE['size']) || empty($FILE['tmp_name']) || !empty($FILE['error'])) {
		return cplang('lack_of_access_to_upload_file_size');
	}

	//判断后缀
	$fileext = fileext($FILE['name']);
	if(!in_array($fileext, $allowpictype)) {
		return cplang('only_allows_upload_file_types');
	}

	//获取目录
	if(!$filepath = getfilepath($fileext, true)) {
		return cplang('unable_to_create_upload_directory_server');
	}

	//检查空间大小
	if(empty($space)) {
		$space = getspace($_SGLOBAL['supe_uid']);
	}
	
	//用户组
	if(!checkperm('allowupload')) {
		ckspacelog();
		return cplang('inadequate_capacity_space');
	}
	
	//实名认证
	if(!ckrealname('album', 1)) {
		return cplang('inadequate_capacity_space');
	}
	
	//视频认证
	if(!ckvideophoto('album', array(), 1)) {
		return cplang('inadequate_capacity_space');
	}
	
	//新用户见习
	if(!cknewuser(1)) {
		return cplang('inadequate_capacity_space');
	}

	$maxattachsize = checkperm('maxattachsize');//单位MB
	if($maxattachsize) {//0为不限制
		if($space['attachsize'] + $FILE['size'] > $maxattachsize + $space['addsize']) {
			return cplang('inadequate_capacity_space');
		}
	}

	//相册选择
	$showtip = true;
	$albumfriend = 0;
	if($albumid) {
		preg_match("/^new\:(.+)$/i", $albumid, $matchs);
		if(!empty($matchs[1])) {
			$albumname = shtmlspecialchars(trim($matchs[1]));
			if(empty($albumname)) $albumname = sgmdate('Ymd');
			$albumid = album_creat(array('albumname' => $albumname));
		} else {
			$albumid = intval($albumid);
			if($albumid) {
				$query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM ".tname('album')." WHERE albumid='$albumid' AND uid='$_SGLOBAL[supe_uid]'");
				if($value = $_SGLOBAL['db']->fetch_array($query)) {
					$albumname = addslashes($value['albumname']);
					$albumfriend = $value['friend'];
				} else {
					$albumname = sgmdate('Ymd');
					$albumid = album_creat(array('albumname' => $albumname));
				}
			}
		}
	} else {
		$albumid = 0;
		$showtip = false;
	}

	//本地上传
	$new_name = $_SC['attachdir'].'./'.$filepath;
	$tmp_name = $FILE['tmp_name'];
	if(@copy($tmp_name, $new_name)) {
		@unlink($tmp_name);
	} elseif((function_exists('move_uploaded_file') && @move_uploaded_file($tmp_name, $new_name))) {
	} elseif(@rename($tmp_name, $new_name)) {
	} else {
		return cplang('mobile_picture_temporary_failure');
	}
	
	//检查是否图片
	if(function_exists('getimagesize')) {
		$tmp_imagesize = @getimagesize($new_name);
		list($tmp_width, $tmp_height, $tmp_type) = (array)$tmp_imagesize;
		$tmp_size = $tmp_width * $tmp_height;
		if($tmp_size > 16777216 || $tmp_size < 4 || empty($tmp_type) || strpos($tmp_imagesize['mime'], 'flash') > 0) {
			@unlink($new_name);
			return cplang('only_allows_upload_file_types');
		}
	}

	//缩略图
	include_once(S_ROOT.'./source/function_image.php');
	$thumbpath = makethumb($new_name);
	$thumb = empty($thumbpath)?0:1;

	//是否压缩
	//获取上传后图片大小
	if(@$newfilesize = filesize($new_name)) {
		$FILE['size'] = $newfilesize;
	}

	//水印
	if($_SCONFIG['allowwatermark']) {
		makewatermark($new_name);
	}

	//进行ftp上传
	if($_SCONFIG['allowftp']) {
		include_once(S_ROOT.'./source/function_ftp.php');
		if(ftpupload($new_name, $filepath)) {
			$pic_remote = 1;
			$album_picflag = 2;
		} else {
			@unlink($new_name);
			@unlink($new_name.'.thumb.jpg');
			runlog('ftp', 'Ftp Upload '.$new_name.' failed.');
			return cplang('ftp_upload_file_size');
		}
	} else {
		$pic_remote = 0;
		$album_picflag = 1;
	}
	
	//入库
	$title = getstr($title, 200, 1, 1, 1);

	//入库
	$setarr = array(
		'albumid' => $albumid,
		'uid' => $_SGLOBAL['supe_uid'],
		'username' => $_SGLOBAL['supe_username'],
		'dateline' => $_SGLOBAL['timestamp'],
		'filename' => addslashes($FILE['name']),
		'postip' => getonlineip(),
		'title' => $title,
		'type' => addslashes($FILE['type']),
		'size' => $FILE['size'],
		'filepath' => $filepath,
		'thumb' => $thumb,
		'remote' => $pic_remote,
		'topicid' => $topicid
	);
	$setarr['picid'] = inserttable('pic', $setarr, 1);

	//更新附件大小
	//积分
	$setsql = '';
	if($showtip) {
		$reward = getreward('uploadimage', 0);
		if($reward['credit']) {
			$setsql = ",credit=credit+$reward[credit]";
		}
		if($reward['experience']) {
			$setsql .= ",experience=experience+$reward[experience]";
		}
	}
	$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET attachsize=attachsize+'$FILE[size]', updatetime='$_SGLOBAL[timestamp]' $setsql WHERE uid='$_SGLOBAL[supe_uid]'");

	//相册更新
	if($albumid) {
		$file = $filepath.($thumb?'.thumb.jpg':'');
		$_SGLOBAL['db']->query("UPDATE ".tname('album')."
			SET picnum=picnum+1, updatetime='$_SGLOBAL[timestamp]', pic='$file', picflag='$album_picflag'
			WHERE albumid='$albumid'");
	}
	
	//统计
	updatestat('pic');

	return $setarr;
}
예제 #3
0
    }
    //接收外部标题
    $blog['subject'] = empty($_GET['subject']) ? '' : getstr($_GET['subject'], 80, 1, 0);
    $blog['message'] = empty($_GET['message']) ? '' : getstr($_GET['message'], 5000, 1, 0);
} else {
    if ($_SGLOBAL['supe_uid'] != $blog['uid'] && !checkperm('manageblog')) {
        showmessage('no_authority_operation_of_the_log');
    }
}
//添加编辑操作
if (submitcheck('blogsubmit')) {
    if (empty($blog['blogid'])) {
        $blog = array();
    } else {
        if (!checkperm('allowblog')) {
            ckspacelog();
            showmessage('no_authority_to_add_log');
        }
    }
    //验证码
    if (checkperm('seccode') && !ckseccode($_POST['seccode'])) {
        showmessage('incorrect_code');
    }
    include_once S_ROOT . './source/function_blog.php';
    if ($newblog = blog_post($_POST, $blog)) {
        if (empty($blog) && $newblog['topicid']) {
            $url = 'space.php?do=topic&topicid=' . $newblog['topicid'] . '&view=blog';
        } else {
            $url = 'space.php?uid=' . $newblog['uid'] . '&do=blog&id=' . $newblog['blogid'];
        }
        showmessage('do_success', $url, 0);
예제 #4
0
function video_save($FILE, $title, $desc, $tovideoid = 0, $albumid)
{
    global $_SGLOBAL, $_SCONFIG, $space, $_SC;
    //允许上传类型
    $allowpictype = array('flv');
    //检查
    $FILE['size'] = intval($FILE['size']);
    if (empty($FILE['size']) || empty($FILE['tmp_name']) || !empty($FILE['error'])) {
        return cplang('lack_of_access_to_upload_file_size');
    }
    //判断后缀
    $fileext = fileext($FILE['name']);
    if (!in_array($fileext, $allowpictype)) {
        return cplang('only_allows_upload_file_types');
    }
    //获取目录
    if (!($filepath = getfilepath($fileext, true))) {
        return cplang('unable_to_create_upload_directory_server');
    }
    //检查空间大小
    if (empty($space)) {
        $space = getspace($_SGLOBAL['supe_uid']);
    }
    //用户组
    if (!checkperm('allowupload')) {
        ckspacelog();
        return cplang('inadequate_capacity_space');
    }
    //实名认证
    if (!ckrealname('album', 1)) {
        return cplang('inadequate_capacity_space');
    }
    //视频认证
    if (!ckvideophoto('album', array(), 1)) {
        return cplang('inadequate_capacity_space');
    }
    //新用户见习
    if (!cknewuser(1)) {
        return cplang('inadequate_capacity_space');
    }
    $maxattachsize = checkperm('maxattachsize');
    //单位MB
    if ($maxattachsize) {
        //0为不限制
        if ($space['attachsize'] + $FILE['size'] > $maxattachsize + $space['addsize']) {
            return cplang('inadequate_capacity_space');
        }
    }
    if ($albumid < 0) {
        $albumid = 0;
    }
    $showtip = true;
    $albumfriend = 0;
    if ($albumid) {
        preg_match("/^new\\:(.+)\$/i", $albumid, $matchs);
        if (!empty($matchs[1])) {
            $albumname = shtmlspecialchars(trim($matchs[1]));
            if (empty($albumname)) {
                $albumname = sgmdate('Ymd');
            }
            $albumid = album_creat(array('albumname' => $albumname));
        } else {
            $albumid = intval($albumid);
            if ($albumid) {
                $query = $_SGLOBAL['db']->query("SELECT albumname,friend FROM " . tname('album') . " WHERE albumid='{$albumid}' AND uid='{$_SGLOBAL['supe_uid']}'");
                if ($value = $_SGLOBAL['db']->fetch_array($query)) {
                    $albumname = addslashes($value['albumname']);
                    $albumfriend = $value['friend'];
                } else {
                    $albumname = sgmdate('Ymd');
                    $albumid = album_creat(array('albumname' => $albumname));
                }
            }
        }
    } else {
        $albumid = 0;
        $showtip = false;
    }
    //本地上传
    $new_name = $_SC['attachdir'] . './' . $filepath;
    $tmp_name = $FILE['tmp_name'];
    if (@copy($tmp_name, $new_name)) {
        @unlink($tmp_name);
    } elseif (function_exists('move_uploaded_file') && @move_uploaded_file($tmp_name, $new_name)) {
    } elseif (@rename($tmp_name, $new_name)) {
    } else {
        return cplang('mobile_picture_temporary_failure');
    }
    //入库
    $setarr = array('albumid' => $albumid, 'uid' => $_SGLOBAL['supe_uid'], 'username' => $_SGLOBAL['supe_username'], 'dateline' => $_SGLOBAL['timestamp'], 'postip' => getonlineip(), 'filename' => addslashes($FILE['name']), 'title' => $title, 'desc' => $desc, 'size' => $FILE['size'], 'filepath' => $filepath);
    $setarr['id'] = inserttable('video', $setarr, 1);
    $setsql = '';
    if ($showtip) {
        $reward = getreward('uploadimage', 0);
        if ($reward['credit']) {
            $setsql = ",credit=credit+{$reward['credit']}";
        }
        if ($reward['experience']) {
            $setsql .= ",experience=experience+{$reward['experience']}";
        }
    }
    $_SGLOBAL['db']->query("UPDATE " . tname('space') . " SET attachsize=attachsize+'{$FILE['size']}', updatetime='{$_SGLOBAL['timestamp']}' {$setsql} WHERE uid='{$_SGLOBAL['supe_uid']}'");
    updatestat('video');
    return $setarr;
}