pretty function name

This commit is contained in:
printempw 2016-02-04 18:35:14 +08:00
parent a0cd174682
commit f113876f1b
3 changed files with 40 additions and 41 deletions

View File

@ -3,13 +3,12 @@
* @Author: prpr
* @Date: 2016-02-03 14:39:50
* @Last Modified by: prpr
* @Last Modified time: 2016-02-04 18:08:41
* @Last Modified time: 2016-02-04 18:34:32
*/
session_start();
$dir = dirname(dirname(__FILE__));
require "$dir/includes/autoload.inc.php";
require "$dir/config.php";
if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
$_SESSION['uname'] = $_COOKIE['uname'];
@ -88,14 +87,14 @@ if (isset($_SESSION['uname'])) {
<?php echo '<img id="'.$row['username'].'_cape" width="64" '.(($row['cape_hash'] == "") ? '' : 'src="../cape/'.$row['username'].'.png"').'/>'; ?>
</td>
<td>
<a href="javascript:showUpload('<?php echo $row['username']; ?>', 'skin');" class="pure-button pure-button-primary">Skin</a>
<a href="javascript:showUpload('<?php echo $row['username']; ?>', 'cape');" class="pure-button pure-button-primary">Cape</a>
<a href="javascript:showModel('<?php echo $row['username']; ?>', 'cape');" class="pure-button pure-button-default">Model</a>
<a href="javascript:uploadTexture('<?php echo $row['username']; ?>', 'skin');" class="pure-button pure-button-primary">Skin</a>
<a href="javascript:uploadTexture('<?php echo $row['username']; ?>', 'cape');" class="pure-button pure-button-primary">Cape</a>
<a href="javascript:changeModel('<?php echo $row['username']; ?>', 'cape');" class="pure-button pure-button-default">Model</a>
<span>(<?php echo $row['preference']; ?>)</span>
</td>
<td>
<a href="javascript:showChange('<?php echo $row['username'] ?>');" class="pure-button pure-button-default">Password</a>
<a href="javascript:showDelete('<?php echo $row['username'] ?>');" class="pure-button pure-button-error">Delete</a>
<a href="javascript:changePasswd('<?php echo $row['username'] ?>');" class="pure-button pure-button-default">Password</a>
<a href="javascript:deleteAccount('<?php echo $row['username'] ?>');" class="pure-button pure-button-error">Delete</a>
</td>
</tr>
<?php } ?>
@ -103,10 +102,6 @@ if (isset($_SESSION['uname'])) {
</table>
</div>
<div class="footer">
&copy; <a class="copy" href="https://prinzeugen.net">Blessing Studio</a> 2016
</div>
</body>
<script type="text/javascript" src="../libs/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../libs/ply/ply.min.js"></script>

View File

@ -2,44 +2,47 @@
* @Author: prpr
* @Date: 2016-02-04 16:48:42
* @Last Modified by: prpr
* @Last Modified time: 2016-02-04 18:18:02
* @Last Modified time: 2016-02-04 18:27:44
*/
'use strict';
function showUpload(uname, type) {
function uploadTexture(uname, type) {
var ply = new Ply({
el: '<h2>Upload new '+type+':</h2><input type="file" id="file" accept="image/png"><button id="upload" class="pure-button pure-button-primary fw">Upload</button>',
el: '<h2>Upload new '+type+':</h2>'+
'<input type="file" id="file" accept="image/png">'+
'<button id="upload" class="pure-button pure-button-primary fw">Upload</button>',
effect: "fade",
onaction: function(){ upload(uname, type, $('#file').get(0).files[0]); },
onaction: function(){
var form_data = new FormData();
var file = $('#file').get(0).files[0];
if (file) {
form_data.append('file', file);
$.ajax({
type: 'POST',
contentType: false,
url: 'admin_ajax.php?action=upload&type='+type+'&uname='+uname,
dataType: "json",
data: form_data,
processData: false,
success: function(json) {
if (json.errno == 0) {
showAlert("Successfully uploaded.", function(){
location.reload();
});
} else {
showAlert("Error when uploading cape:\n" + json.msg);
}
}
});
}
},
});
ply.open();
}
function upload(uname, type, file){
var form_data = new FormData();
if (file) {
form_data.append('file', file);
$.ajax({
type: 'POST',
contentType: false,
url: 'admin_ajax.php?action=upload&type='+type+'&uname='+uname,
dataType: "json",
data: form_data,
processData: false,
success: function(json) {
if (json.errno == 0) {
showAlert("Successfully uploaded.");
$('#'+uname+'_'+type).attr('src', 'http://skin.fuck.io/'+type+'/'+uname+'.png?t='+Math.random());
} else {
showAlert("Error when uploading cape:\n" + json.msg);
}
}
});
}
}
function showChange(uname) {
function changePasswd(uname) {
Ply.dialog("prompt", {
title: "Type in "+uname+"'s new password",
form: { passwd: "New Password" }
@ -61,7 +64,7 @@ function showChange(uname) {
});
}
function showDelete(uname) {
function deleteAccount(uname) {
Ply.dialog("prompt", {
title: "Are you sure to delete "+uname+"?",
}).done(function(ui){
@ -82,7 +85,7 @@ function showDelete(uname) {
});
}
function showModel(uname) {
function changeModel(uname) {
Ply.dialog("prompt", {
title: "Change "+uname+"'s model prefrence:",
form: { text: "Type in `slim` or `default`" }

View File

@ -3,7 +3,7 @@
* @Author: prpr
* @Date: 2016-02-02 21:17:59
* @Last Modified by: prpr
* @Last Modified time: 2016-02-02 21:19:31
* @Last Modified time: 2016-02-04 18:34:34
*/
function __autoload($classname) {
@ -11,3 +11,4 @@ function __autoload($classname) {
$filename = "$dir/includes/".$classname.".class.php";
include_once($filename);
}
require "$dir/config.php";