Enable upgrading number of files quota
This commit is contained in:
@ -125,11 +125,13 @@ const ACCOUNT_UPGRADES = [
|
|||||||
'5g_quota' => ['name' => '+5GB disk Quota', 'usd_price' => 20],
|
'5g_quota' => ['name' => '+5GB disk Quota', 'usd_price' => 20],
|
||||||
'10g_quota' => ['name' => '+10GB disk Quota', 'usd_price' => 30],
|
'10g_quota' => ['name' => '+10GB disk Quota', 'usd_price' => 30],
|
||||||
'20g_quota' => ['name' => '+20GB disk Quota', 'usd_price' => 40],
|
'20g_quota' => ['name' => '+20GB disk Quota', 'usd_price' => 40],
|
||||||
|
'100k_files_quota' => ['name' => '+100k files Quota', 'usd_price' => 10],
|
||||||
];
|
];
|
||||||
const COINPAYMENTS_PRIVATE = 'COINPAYMENTS_PRIVATE_API_KEY';
|
const COINPAYMENTS_PRIVATE = 'COINPAYMENTS_PRIVATE'; //Coinpayments private API key
|
||||||
const COINPAYMENTS_PUBLIC = 'COINPAYMENTS_PUBLIC_API_KEY';
|
const COINPAYMENTS_PUBLIC = 'COINPAYMENTS_PUBLIC'; //Coinpayments public API key
|
||||||
const COINPAYMENTS_MERCHANT_ID = 'COINPAYMENTS_MERCHANT_ID';
|
const COINPAYMENTS_MERCHANT_ID = 'COINPAYMENTS_MERCHANT_ID'; //Coinpayments merchant ID
|
||||||
const COINPAYMENTS_IPN_SECRET = 'COINPAYMENTS_IPN_SECRET';
|
const COINPAYMENTS_IPN_SECRET = 'COINPAYMENTS_IPN_SECRET'; //Coinpayments IPN secret
|
||||||
|
const COINPAYMENTS_FAKE_BUYER_EMAIL = 'daniel@danwin1210.me'; //fixed email used for the required buyer email field
|
||||||
|
|
||||||
function get_onion_v2($pkey) : string {
|
function get_onion_v2($pkey) : string {
|
||||||
$keyData = openssl_pkey_get_details($pkey);
|
$keyData = openssl_pkey_get_details($pkey);
|
||||||
@ -768,7 +770,7 @@ function coinpayments_create_transaction(string $currency, int $price, string $p
|
|||||||
$query['currency1'] = 'USD';
|
$query['currency1'] = 'USD';
|
||||||
$query['currency2'] = $currency;
|
$query['currency2'] = $currency;
|
||||||
$query['amount'] = $price;
|
$query['amount'] = $price;
|
||||||
$query['buyer_email'] = 'daniel@danwin1210.me';
|
$query['buyer_email'] = COINPAYMENTS_FAKE_BUYER_EMAIL;
|
||||||
$query['version'] = '1';
|
$query['version'] = '1';
|
||||||
$query['cmd'] = 'create_transaction';
|
$query['cmd'] = 'create_transaction';
|
||||||
$query['key'] = COINPAYMENTS_PUBLIC;
|
$query['key'] = COINPAYMENTS_PUBLIC;
|
||||||
@ -847,6 +849,9 @@ function payment_status_update(string $txid){
|
|||||||
case '20g_quota':
|
case '20g_quota':
|
||||||
add_disk_quota($tmp['user_id'], 20 * 1024 * 1024);
|
add_disk_quota($tmp['user_id'], 20 * 1024 * 1024);
|
||||||
break;
|
break;
|
||||||
|
case '100k_files_quota':
|
||||||
|
add_files_quota($tmp['user_id'], 100000);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -862,3 +867,22 @@ function add_disk_quota(int $user_id, int $kb){
|
|||||||
$stmt = $db->prepare('UPDATE disk_quota SET quota_size = ?, updated = 1 WHERE user_id = ?;');
|
$stmt = $db->prepare('UPDATE disk_quota SET quota_size = ?, updated = 1 WHERE user_id = ?;');
|
||||||
$stmt->execute([$tmp['quota_size'] + $kb, $user_id]);
|
$stmt->execute([$tmp['quota_size'] + $kb, $user_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function add_files_quota(int $user_id, int $number){
|
||||||
|
$db = get_db_instance();
|
||||||
|
$stmt = $db->prepare('SELECT quota_files FROM disk_quota WHERE user_id = ?;');
|
||||||
|
$stmt->execute([$user_id]);
|
||||||
|
$tmp = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$stmt = $db->prepare('UPDATE disk_quota SET quota_files = ?, updated = 1 WHERE user_id = ?;');
|
||||||
|
$stmt->execute([$tmp['quota_files'] + $number, $user_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bytes_to_human_readable(int $bytes) : string {
|
||||||
|
$suffix = ['B', 'KiB', 'MiB', 'GiB', 'TiB'];
|
||||||
|
$size_class=(int) log($bytes, 1024);
|
||||||
|
if($size_class!==0){
|
||||||
|
return sprintf('%1.1f', $bytes / pow(1024, $size_class)) . $suffix[$size_class];
|
||||||
|
}else{
|
||||||
|
return $bytes . $suffix[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,7 +16,6 @@ if(@!ftp_login($ftp, $user[system_account], $_SESSION['ftp_pass'])){
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
//prepare reusable data
|
//prepare reusable data
|
||||||
const SUFFIX=['B', 'KiB', 'MiB', 'GiB'];
|
|
||||||
const TYPES=[
|
const TYPES=[
|
||||||
'jpg'=>'img',
|
'jpg'=>'img',
|
||||||
'psd'=>'img',
|
'psd'=>'img',
|
||||||
@ -372,12 +371,7 @@ function get_properties($name, &$icon, &$size){
|
|||||||
}else{
|
}else{
|
||||||
$icon='ukwn';
|
$icon='ukwn';
|
||||||
}
|
}
|
||||||
$class=(int) log($size, 1024);
|
$size = bytes_to_human_readable($size);
|
||||||
if($class!==0){
|
|
||||||
$size=sprintf('%1.1f', $size / pow(1024, $class)) . SUFFIX[$class];
|
|
||||||
}else{
|
|
||||||
$size.=SUFFIX[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,12 +317,16 @@ foreach(SERVERS as $server=>$tmp){
|
|||||||
<p><a href="password.php?type=sys">Change system account password</a></p>
|
<p><a href="password.php?type=sys">Change system account password</a></p>
|
||||||
<p>You can use the <a target="_blank" href="files.php">FileManager</a> for web based file management.</p>
|
<p>You can use the <a target="_blank" href="files.php">FileManager</a> for web based file management.</p>
|
||||||
<?php
|
<?php
|
||||||
$stmt = $db->prepare('SELECT quota_size, quota_size_used FROM disk_quota WHERE user_id = ?;');
|
$stmt = $db->prepare('SELECT quota_size, quota_size_used, quota_files, quota_files_used FROM disk_quota WHERE user_id = ?;');
|
||||||
$stmt->execute([$user['id']]);
|
$stmt->execute([$user['id']]);
|
||||||
$quota = $stmt->fetch(PDO::FETCH_ASSOC);
|
$quota = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$quota_usage = $quota['quota_size_used'] / $quota['quota_size'];
|
$quota_usage = $quota['quota_size_used'] / $quota['quota_size'];
|
||||||
|
$quota_files_usage = $quota['quota_files_used'] / $quota['quota_files'];
|
||||||
|
$usage_text = bytes_to_human_readable($quota['quota_size_used'] * 1024) . ' of ' . bytes_to_human_readable($quota['quota_size'] * 1024) . ' - ' . round($quota_usage * 100, 2).'%';
|
||||||
|
$usage_files_text = "$quota[quota_files_used] of $quota[quota_files] - " . round($quota_files_usage * 100, 2).'%';
|
||||||
?>
|
?>
|
||||||
<p>Your disk usage: <meter value="<?php echo round($quota_usage, 2); ?>"><?php echo round($quota_usage * 100); ?>%</meter> - <?php echo round($quota_usage * 100, 2); ?>% (updated hourly) <a href="upgrade.php">Upgrade</a></p>
|
<p>Your disk usage: <meter value="<?php echo round($quota_usage, 2); ?>"><?php echo $usage_text; ?></meter> - <?php echo $usage_text; ?> (updated hourly) <a href="upgrade.php?upgrade=1g_quota">Upgrade</a></p>
|
||||||
|
<p>Your file number usage: <meter value="<?php echo round($quota_file_usage, 2); ?>"><?php echo $usage_files_text; ?></meter> - <?php echo $usage_files_text; ?> (updated hourly) <a href="upgrade.php?upgrade=100k_files_quota">Upgrade</a></p>
|
||||||
<h3>Logs</h3>
|
<h3>Logs</h3>
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<tr><th>Date</th><th>access.log</th><th>error.log</th></tr>
|
<tr><th>Date</th><th>access.log</th><th>error.log</th></tr>
|
||||||
|
Reference in New Issue
Block a user