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(); _admin();
$ui->assign('_title', $_L['Code Canyon']); $ui->assign('_title', 'CodeCanyon.net');
$ui->assign('_system_menu', 'settings'); $ui->assign('_system_menu', 'settings');
$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json'; $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']); r2(U . 'codecanyon', 'e', 'Failed to get download url. ' . $json['description']);
} }
$file = File::pathFixer('system/cache/codecanyon/'); $file = File::pathFixer('system/cache/codecanyon/');
if(!file_exists($file)){ if (!file_exists($file)) {
mkdir($file); mkdir($file);
} }
$file .= $item_id . '.zip'; $file .= $item_id . '.zip';
if (file_exists($file)) if (file_exists($file))
unlink($file); unlink($file);
//download
$fp = fopen($file, 'w+'); $fp = fopen($file, 'w+');
$ch = curl_init($json['download_url']); $ch = curl_init($json['download_url']);
curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_POST, 0);
@ -60,13 +61,25 @@ switch ($action) {
curl_exec($ch); curl_exec($ch);
curl_close($ch); curl_close($ch);
fclose($fp); fclose($fp);
//extract
$target = File::pathFixer('system/cache/codecanyon/' . $item_id . '/');
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($file); $zip->open($file);
$zip->extractTo(File::pathFixer('system/cache/codecanyon/')); $zip->extractTo($target);
$zip->close(); $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': case 'reload':
if (file_exists($cache)) unlink($cache); if (file_exists($cache))
unlink($cache);
default: default:
if (class_exists('ZipArchive')) { if (class_exists('ZipArchive')) {
$zipExt = true; $zipExt = true;
@ -78,7 +91,7 @@ switch ($action) {
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
$txt = file_get_contents($cache); $txt = file_get_contents($cache);
$plugins = json_decode($txt, true); $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) { if (count($plugins) == 0) {
unlink($cache); unlink($cache);
r2(U . 'codecanyon'); r2(U . 'codecanyon');
@ -92,25 +105,18 @@ switch ($action) {
if ($items && count($items['results']) > 0) { if ($items && count($items['results']) > 0) {
foreach ($items['results'] as $item) { foreach ($items['results'] as $item) {
$name = strtolower($item['item']['name']); $name = strtolower($item['item']['name']);
//if(strpos($name,'phpnuxbill') !== false){ if (strpos($name, 'phpnuxbill') !== false) {
if (strpos($name, 'wordpress') !== false) { $plugins[] = $item;
//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])) {
$plugins[] = $item;
}
} }
} }
$page++; $page++;
goto back; goto back;
} }
file_put_contents($cache, json_encode($plugins)); if (count($plugins) > 0) {
if (file_exists($cache)){ file_put_contents($cache, json_encode($plugins));
$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); $ui->assign('plugins', $plugins);

View File

@ -5,7 +5,7 @@
**/ **/
_admin(); _admin();
$ui->assign('_title', $_L['Plugin Manager']); $ui->assign('_title', 'Plugin Manager');
$ui->assign('_system_menu', 'settings'); $ui->assign('_system_menu', 'settings');
$plugin_repository = 'https://hotspotbilling.github.io/Plugin-Repository/repository.json'; $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 panel-primary panel-hovered">
<div class="panel-heading"> <div class="panel-heading">
<div class="btn-group pull-right"> <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> </div>
Plugin Purcashed Plugin Purcashed
</div> </div>
@ -24,9 +25,9 @@
class="ion ion-chatboxes"></i> Author</a> class="ion ion-chatboxes"></i> Author</a>
<a href="{$plugin['item']['url']}" target="_blank" class="btn btn-success"><i <a href="{$plugin['item']['url']}" target="_blank" class="btn btn-success"><i
class="ion ion-chatboxes"></i> Product</a> 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')" 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')" {else} href="#" onclick="alert('PHP ZIP extension is not available')"
{/if} {/if}
class="btn btn-danger"><i class="ion ion-chatboxes"></i> Install</a> class="btn btn-danger"><i class="ion ion-chatboxes"></i> Install</a>
</div> </div>
@ -43,7 +44,10 @@
{/if} {/if}
</div> </div>
<div class="panel-footer"> <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> </div>
</div> </div>