CodeCanyon integration fix

This commit is contained in:
Ibnu Maksum 2024-01-18 17:24:21 +07:00
parent d81ba5d5fb
commit 7046aa5ed1
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
3 changed files with 35 additions and 25 deletions

View file

@ -5,7 +5,7 @@
**/
_admin();
$ui->assign('_title', $_L['Code Canyon']);
$ui->assign('_title', 'CodeCanyon.net');
$ui->assign('_system_menu', 'settings');
$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json';
@ -43,12 +43,13 @@ switch ($action) {
r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']);
}
$file = File::pathFixer('system/cache/codecanyon/');
if(!file_exists($file)){
if (!file_exists($file)) {
mkdir($file);
}
$file .= $item_id . '.zip';
if (file_exists($file))
unlink($file);
//download
$fp = fopen($file, 'w+');
$ch = curl_init($json['download_url']);
curl_setopt($ch, CURLOPT_POST, 0);
@ -60,13 +61,25 @@ switch ($action) {
curl_exec($ch);
curl_close($ch);
fclose($fp);
//extract
$target = File::pathFixer('system/cache/codecanyon/' . $item_id . '/');
$zip = new ZipArchive();
$zip->open($file);
$zip->extractTo(File::pathFixer('system/cache/codecanyon/'));
$zip->extractTo($target);
$zip->close();
die($json['download_url']);
//moving
if (file_exists($target . 'plugin')) {
File::copyFolder($target, File::pathFixer('system/plugin/'), ['license.txt', 'changelog.txt', 'install.txt']);
} else if (file_exists($target . 'paymentgateway')) {
File::copyFolder($target, File::pathFixer('system/plugin/'), ['license.txt', 'changelog.txt', 'install.txt']);
}
//Cleaning
File::deleteFolder($target);
unlink($file);
r2(U . "codecanyon", 's', 'Installation success');
case 'reload':
if (file_exists($cache)) unlink($cache);
if (file_exists($cache))
unlink($cache);
default:
if (class_exists('ZipArchive')) {
$zipExt = true;
@ -78,7 +91,7 @@ switch ($action) {
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
$txt = file_get_contents($cache);
$plugins = json_decode($txt, true);
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache)+(24 * 60 * 60)));
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
if (count($plugins) == 0) {
unlink($cache);
r2(U . 'codecanyon');
@ -92,25 +105,18 @@ switch ($action) {
if ($items && count($items['results']) > 0) {
foreach ($items['results'] as $item) {
$name = strtolower($item['item']['name']);
//if(strpos($name,'phpnuxbill') !== false){
if (strpos($name, 'wordpress') !== false) {
//if(strpos($name,'plugin') !== false){
if (strpos($name, 'theme') !== false) {
$item['type'] = '1';
} else if (strpos($name, 'payment gateway') !== false) {
$item['type'] = '2';
}
if (in_array($item['type'], [1, 2])) {
if (strpos($name, 'phpnuxbill') !== false) {
$plugins[] = $item;
}
}
}
$page++;
goto back;
}
if (count($plugins) > 0) {
file_put_contents($cache, json_encode($plugins));
if (file_exists($cache)){
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache)+(24 * 60 * 60)));
if (file_exists($cache)) {
$ui->assign('chached_until', date($config['date_format'] . ' H:i', filemtime($cache) + (24 * 60 * 60)));
}
}
}
$ui->assign('plugins', $plugins);

View file

@ -5,7 +5,7 @@
**/
_admin();
$ui->assign('_title', $_L['Plugin Manager']);
$ui->assign('_title', 'Plugin Manager');
$ui->assign('_system_menu', 'settings');
$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json';

View file

@ -4,7 +4,8 @@
<div class="panel panel-primary panel-hovered">
<div class="panel-heading">
<div class="btn-group pull-right">
<a class="btn btn-danger btn-xs" href="https://codecanyon.net/category/php-scripts?term=phpnuxbill" target="_blank">Buy Plugin</a>
<a class="btn btn-danger btn-xs" href="https://codecanyon.net/category/php-scripts?term=phpnuxbill"
target="_blank">Buy Plugin</a>
</div>
Plugin Purcashed
</div>
@ -24,7 +25,7 @@
class="ion ion-chatboxes"></i> Author</a>
<a href="{$plugin['item']['url']}" target="_blank" class="btn btn-success"><i
class="ion ion-chatboxes"></i> Product</a>
<a {if $zipExt } href="{$_url}codecanyon/install/{$plugin['item']['id']}/{$plugin['type']}"
<a {if $zipExt } href="{$_url}codecanyon/install/{$plugin['item']['id']}"
onclick="return confirm('Installing plugin will take some time to complete, do not close the page while it loading to install the plugin')"
{else} href="#" onclick="alert('PHP ZIP extension is not available')"
{/if}
@ -43,7 +44,10 @@
{/if}
</div>
<div class="panel-footer">
Cached Until {$chached_until} <a href="{$_url}codecanyon/reload">Force reload</a>
{if $chached_until}Cached Until {$chached_until} <a href="{$_url}codecanyon/reload">Force reload</a>
&bull; {/if}<a
href="https://github.com/hotspotbilling/phpnuxbill/wiki/Selling-Paid-Plugin-or-Payment-Gateway"
target="_blank">Want to sell?</a>
</div>
</div>
</div>