allow download from private/paid repository

This commit is contained in:
Ibnu Maksum 2024-07-25 10:59:23 +07:00
parent 1697f18986
commit 20f98ab066
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
5 changed files with 46 additions and 24 deletions

View File

@ -81,6 +81,9 @@ switch ($action) {
r2(U . "pluginmanager", 's', 'Installation success'); r2(U . "pluginmanager", 's', 'Installation success');
} else if (_post('gh_url', '') != '') { } else if (_post('gh_url', '') != '') {
$ghUrl = _post('gh_url', ''); $ghUrl = _post('gh_url', '');
if(!empty($config['github_token']) && !empty($config['github_username'])) {
$ghUrl = str_replace('https://github.com', 'https://'.$config['github_username'].':'.$config['github_token'].'@github.com', $ghUrl);
}
$plugin = basename($ghUrl); $plugin = basename($ghUrl);
$file = $cache . $plugin . '.zip'; $file = $cache . $plugin . '.zip';
$fp = fopen($file, 'w+'); $fp = fopen($file, 'w+');
@ -132,6 +135,9 @@ switch ($action) {
if ($tipe == 'plugin') { if ($tipe == 'plugin') {
foreach ($json['plugins'] as $plg) { foreach ($json['plugins'] as $plg) {
if ($plg['id'] == $plugin) { if ($plg['id'] == $plugin) {
if(!empty($config['github_token']) && !empty($config['github_username'])) {
$plg['github'] = str_replace('https://github.com', 'https://'.$config['github_username'].':'.$config['github_token'].'@github.com', $plg['github']);
}
$fp = fopen($file, 'w+'); $fp = fopen($file, 'w+');
$ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip'); $ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip');
curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POST, 0);
@ -180,6 +186,9 @@ switch ($action) {
if ($tipe == 'plugin') { if ($tipe == 'plugin') {
foreach ($json['plugins'] as $plg) { foreach ($json['plugins'] as $plg) {
if ($plg['id'] == $plugin) { if ($plg['id'] == $plugin) {
if(!empty($config['github_token']) && !empty($config['github_username'])) {
$plg['github'] = str_replace('https://github.com', 'https://'.$config['github_username'].':'.$config['github_token'].'@github.com', $plg['github']);
}
$fp = fopen($file, 'w+'); $fp = fopen($file, 'w+');
$ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip'); $ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip');
curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POST, 0);
@ -214,6 +223,9 @@ switch ($action) {
} else if ($tipe == 'payment') { } else if ($tipe == 'payment') {
foreach ($json['payment_gateway'] as $plg) { foreach ($json['payment_gateway'] as $plg) {
if ($plg['id'] == $plugin) { if ($plg['id'] == $plugin) {
if(!empty($config['github_token']) && !empty($config['github_username'])) {
$plg['github'] = str_replace('https://github.com', 'https://'.$config['github_username'].':'.$config['github_token'].'@github.com', $plg['github']);
}
$fp = fopen($file, 'w+'); $fp = fopen($file, 'w+');
$ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip'); $ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip');
curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POST, 0);

View File

@ -659,9 +659,7 @@
"Voucher_invalid": "Voucher invalid", "Voucher_invalid": "Voucher invalid",
"Account_Not_Found": "Account Not Found", "Account_Not_Found": "Account Not Found",
"Internet_Voucher_Expired": "Internet Voucher Expired", "Internet_Voucher_Expired": "Internet Voucher Expired",
"": "",
"Additional_Billing": "Additional Billing", "Additional_Billing": "Additional Billing",
"_": "-",
"Used_Date": "Used Date", "Used_Date": "Used Date",
"Filter": "Filter", "Filter": "Filter",
"Start_time": "Start time", "Start_time": "Start time",
@ -672,5 +670,8 @@
"balance": "balance", "balance": "balance",
"radius": "radius", "radius": "radius",
"Start_Date": "Start Date", "Start_Date": "Start Date",
"End_Date": "End Date" "End_Date": "End Date",
"New_Version_Notification": "New Version Notification",
"Enabled": "Enabled",
"This_is_to_notify_you_when_new_updates_is_available": "This is to notify you when new updates is available"
} }

View File

@ -590,13 +590,16 @@
<label class="col-md-2 control-label">{Lang::T('New Version Notification')}</label> <label class="col-md-2 control-label">{Lang::T('New Version Notification')}</label>
<div class="col-md-6"> <div class="col-md-6">
<select name="new_version_notify" id="new_version_notify" class="form-control"> <select name="new_version_notify" id="new_version_notify" class="form-control">
<option value="enable" {if $_c['new_version_notify']=='enable' }selected="selected" {/if}>{Lang::T('Enabled')} <option value="enable" {if $_c['new_version_notify']=='enable' }selected="selected"
{/if}>{Lang::T('Enabled')}
</option> </option>
<option value="disable" {if $_c['new_version_notify']=='disable' }selected="selected" {/if}>{Lang::T('Disabled')} <option value="disable" {if $_c['new_version_notify']=='disable' }selected="selected"
{/if}>{Lang::T('Disabled')}
</option> </option>
</select> </select>
</div> </div>
<p class="help-block col-md-4">{Lang::T('This is to notify you when new updates is available')}</p> <p class="help-block col-md-4">{Lang::T('This is to notify you when new updates is available')}
</p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">{Lang::T('OTP Required')}</label> <label class="col-md-2 control-label">{Lang::T('OTP Required')}</label>
@ -722,35 +725,39 @@
<p class="help-block col-md-4">{Lang::T('Enter the custom tax rate (e.g., 3.75 for 3.75%)')}</p> <p class="help-block col-md-4">{Lang::T('Enter the custom tax rate (e.g., 3.75 for 3.75%)')}</p>
</div> </div>
</div> </div>
<div class="panel-heading" id="Github_Authentication">
{* <div class="panel-heading" id="envato">
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button class="btn btn-primary btn-xs" title="save" type="submit"><span <button class="btn btn-primary btn-xs" title="save" type="submit"><span
class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button> class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></button>
</div> </div>
Envato / Codecanyon Github Authentication
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">Envato Personal Token</label> <label class="col-md-2 control-label">Github Username</label>
<div class="col-md-6"> <div class="col-md-6">
<input type="password" class="form-control" id="envato_token" name="envato_token" <div class="input-group">
value="{$_c['envato_token']}" placeholder="BldWuBsxxxxxxxxxxxPDzPozHAPui"> <span class="input-group-addon">https://github.com/</span>
<input type="text" class="form-control" id="github_username" name="github_username"
value="{$_c['github_username']}" placeholder="ibnux">
</div>
</div> </div>
<span class="help-block col-md-4"><a href="https://build.envato.com/create-token/"
target="_blank">Create Token</a></span>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-md-offset-2 col-md-8" style="text-align: left;">Envato <label class="col-md-2 control-label">Github Token</label>
Permission<br> <div class="col-md-6">
- View and search Envato sites<br> <input type="password" class="form-control" id="github_token" name="github_token"
- Download the user's purchased items<br> value="{$_c['github_token']}" placeholder="ghp_........">
- List purchases the user has made<br><br> </div>
<a href="https://codecanyon.net/category/php-scripts?term=phpnuxbill" target="_blank" <span class="help-block col-md-4"><a href="https://github.com/settings/tokens/new"
class="btn btn-xs btn-primary">View MarketPlace</a> target="_blank">Create GitHub personal access token (classic)</a>, only need repo scope</span>
</label>
</div> </div>
</div> *} <div class="form-group">
<label class="control-label col-md-offset-2 col-md-8" style="text-align: left;">This will allow
you to download
plugin from private/paid repository</label>
</div>
</div>
</div> </div>
<div class="panel-body"> <div class="panel-body">

View File

@ -30,6 +30,8 @@
</div> </div>
</form> </form>
<p class="help-block">To download from private/paid repository, <a href="{$_url}settings/app#Github_Authentication">Set your Github Authentication first</a></p>
<div class="panel panel-primary panel-hovered"> <div class="panel panel-primary panel-hovered">
<div class="panel-heading">{Lang::T('Plugin')} <div class="panel-heading">{Lang::T('Plugin')}
<div class="btn-group pull-right"> <div class="btn-group pull-right">

View File

@ -457,7 +457,7 @@
{$_MENU_SETTINGS} {$_MENU_SETTINGS}
<li {if $_routes[0] eq 'pluginmanager' }class="active" {/if}> <li {if $_routes[0] eq 'pluginmanager' }class="active" {/if}>
<a href="{$_url}pluginmanager"><i class="glyphicon glyphicon-tasks"></i> <a href="{$_url}pluginmanager"><i class="glyphicon glyphicon-tasks"></i>
{Lang::T('Plugin Manager')} <small class="label pull-right">Free</small></a> {Lang::T('Plugin Manager')}</a>
</li> </li>
{/if} {/if}
</ul> </ul>