add option for setting score of private textures

This commit is contained in:
printempw 2016-08-13 23:25:10 +08:00
parent 497c762879
commit 76c305d8c3
5 changed files with 61 additions and 38 deletions

View File

@ -123,18 +123,21 @@ class SkinlibController extends BaseController
$t = new Texture();
$t->name = $_POST['name'];
$t->type = $_POST['type'];
$t->like = 1;
$t->hash = \Storage::upload($_FILES['file']);
$t->size = ceil($_FILES['file']['size'] / 1024);
$t->public = ($_POST['public'] == 'true') ? "1" : "0";
$t->uploader = $this->user->uid;
$t->upload_at = Utils::getTimeFormatted();
if ($this->user->getScore() / Option::get('score_per_storage') < $t->size)
$cost = $t->size * (($t->public == "1") ? Option::get('score_per_storage') : Option::get('private_score_per_storage'));
if ($this->user->getScore() < $cost)
View::json('积分不够啦', 7);
$results = Texture::where('hash', $t->hash)->get();
if (!$results->isEmpty())
{
if (!$results->isEmpty()) {
foreach ($results as $result) {
if ($result->type == $t->type) {
View::json([
@ -148,13 +151,9 @@ class SkinlibController extends BaseController
$t->save();
$this->user->setScore($t->size, 'minus');
$this->user->setScore($cost, 'minus');
if ($this->user->closet->add($t->tid, $t->name)) {
$t = Texture::find($t->tid);
$t->likes += 1;
$t->save();
View::json([
'errno' => 0,
'msg' => '材质 '.$_POST['name'].' 上传成功',

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-19 10:46:38
* @Last Modified by: printempw
* @Last Modified time: 2016-08-06 18:51:20
* @Last Modified time: 2016-08-13 23:23:14
*/
'use strict';
@ -20,6 +20,10 @@ $('#page-select').on('change', function() {
});
$('#private').on('ifToggled', function() {
$(this).prop('checked') ? $('#msg').show() : $('#msg').hide();
});
function addToCloset(tid) {
$.getJSON('../skinlib/info/'+tid, function(json) {
var dom = '<div class="form-group">'+

View File

@ -27,9 +27,10 @@
<div class="box-body">
<?php
if (isset($_POST['option']) && ($_POST['option'] == "rate")) {
Option::set('score_per_storage', $_POST['score_per_storage']);
Option::set('score_per_player', $_POST['score_per_player']);
Option::set('user_initial_score', $_POST['user_initial_score']);
foreach ($_POST as $key => $value) {
if ($key != "option" && $key != "submit")
Option::set($key, $value);
}
echo '<div class="callout callout-success">设置已保存。</div>';
} ?>
<table class="table">
@ -45,6 +46,19 @@
</td>
</tr>
<tr>
<td class="key">私密材质存储
<i class="fa fa-question-circle" title="上传私密材质将消耗更多积分" data-toggle="tooltip" data-placement="top"></i>
</td>
<td class="value">
<div class="input-group">
<input type="text" class="form-control" name="private_score_per_storage" value="{{ Option::get('private_score_per_storage') }}">
<span class="input-group-addon">积分 = 1 KB</span>
</div>
</td>
</tr>
<tr>
<td class="key">角色</td>
<td class="value">

View File

@ -41,7 +41,12 @@
<label for="file">选择文件</label>
<input id="file" type="file" data-show-upload="false" data-language="zh" class="file" accept="image/png" />
</div>
<div class="callout callout-info" id="msg" style="display: none;">
<p>私密材质将会消耗更多的积分:每 KB 存储空间 {{ Option::get('private_score_per_storage') }} 积分</p>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<label for="private" class="pull-right" title="其他人将不会在皮肤库中看到此材质" data-placement="top" data-toggle="tooltip">
<input id="private" type="checkbox"> 设置为私密材质

View File

@ -3,33 +3,34 @@
* @Author: printempw
* @Date: 2016-07-29 11:53:11
* @Last Modified by: printempw
* @Last Modified time: 2016-08-10 22:11:03
* @Last Modified time: 2016-08-13 23:02:04
*/
return [
'site_url' => '',
'site_name' => 'Blessing Skin Server',
'site_description' => '开源的 PHP Minecraft 皮肤站',
'user_can_register' => '1',
'regs_per_ip' => '3',
'api_type' => '0',
'announcement' => '欢迎使用 Blessing Skin Server {version}',
'color_scheme' => 'skin-blue',
'home_pic_url' => './assets/images/bg.jpg',
'custom_css' => '',
'custom_js' => '',
'update_url' => 'https://work.prinzeugen.net/update.json',
'allow_chinese_playername' => '1',
'show_footer_copyright' => '1',
'comment_script' => '',
'user_initial_score' => '1000',
'sign_gap_time' => '24',
'sign_score' => '10,100',
'score_per_storage' => '1',
'score_per_player' => '100',
'sign_after_zero' => '0',
'avatar_query_string' => '0',
'version' => '',
'check_update' => '1',
'update_source' => 'github'
'site_url' => '',
'site_name' => 'Blessing Skin Server',
'site_description' => '开源的 PHP Minecraft 皮肤站',
'user_can_register' => '1',
'regs_per_ip' => '3',
'api_type' => '0',
'announcement' => '欢迎使用 Blessing Skin Server {version}',
'color_scheme' => 'skin-blue',
'home_pic_url' => './assets/images/bg.jpg',
'custom_css' => '',
'custom_js' => '',
'update_url' => 'https://work.prinzeugen.net/update.json',
'allow_chinese_playername' => '1',
'show_footer_copyright' => '1',
'comment_script' => '',
'user_initial_score' => '1000',
'sign_gap_time' => '24',
'sign_score' => '10,100',
'score_per_storage' => '1',
'private_score_per_storage' => '10',
'score_per_player' => '100',
'sign_after_zero' => '0',
'avatar_query_string' => '0',
'version' => '',
'check_update' => '1',
'update_source' => 'github'
];