'._t('Going to install theme file').'
'; if (!file_exists('tmp')) { mkdir('tmp', 0755, true); } if(file_exists('tmp/tmp_theme')){ delete_files('tmp/tmp_theme/'); } if (!file_exists('tmp/tmp_theme')) { mkdir('tmp/tmp_theme', 0755, true); } if (!file_exists('tmp/tmp_theme/files')) { mkdir('tmp/tmp_theme/files', 0755, true); } $enter_epc = false; $target_dir = "tmp/tmp_theme/"; $extract_dir = "tmp/tmp_theme/files/"; $target_file = $target_dir . strtolower(str_replace(' ', '-', basename($_FILES["theme_file"]["name"]))); $theme_dir = str_replace('.zip', '', basename($_FILES["theme_file"]["name"])); $uploadOk = 1; $error = []; $warning = []; $json; $fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); if($fileType != 'zip'){ $uploadOk = 0; $error[] = 'File format must be zip!'; } if($uploadOk) { if (move_uploaded_file($_FILES["theme_file"]["tmp_name"], $target_file)) { $zip = new ZipArchive; $res = $zip->open($target_file); if ($res === TRUE) { $zip->extractTo($extract_dir); $zip->close(); if(file_exists(ABSPATH . 'content/themes/' . $theme_dir)){ $warning[] = 'Theme folder for this theme is already exist'; $warning[] = 'Existing theme folder will be overriden'; } if(!file_exists( $extract_dir . 'info.json' )){ $error[] = 'Theme info (info.json) doesn\'t exist'; } else { $json = json_decode(file_get_contents($extract_dir . 'info.json'), true); } if(!file_exists( $extract_dir . 'home.php' )){ $error[] = 'home.php doesn\'t exist'; } if(!file_exists( $extract_dir . 'page.php' )){ $error[] = 'page.php doesn\'t exist'; } if(!file_exists( $extract_dir . 'game.php' )){ $error[] = 'game.php doesn\'t exist'; } if(!file_exists( $extract_dir . 'archive.php' )){ $error[] = 'archive.php doesn\'t exist'; } if(!file_exists( $extract_dir . 'search.php' )){ $error[] = 'search.php doesn\'t exist'; } if(file_exists( $extract_dir . 'css/epc.css' )){ $enter_epc = true; } } else { echo 'doh!'; } } } if(count($error)){ foreach ($error as $value) { show_alert($value, 'danger'); } } else { if(count($warning)){ foreach ($warning as $value) { show_alert($value, 'warning'); } } echo '
Theme name: '.$json['name']; echo '
Version: '.$json['version']; echo '
Author: '.$json['author']; echo '
Website: '.$json['website'].''; echo '
Description: '.$json['description']; echo '

This theme is targeted for CloudArcade v'.$json['target_version'].' or newer.
'; if(to_numeric_version(VERSION) < to_numeric_version($json['target_version'])){ show_alert('You\'re using older version of CloudArcade, update your CMS to meet the requirement.', 'warning'); } else { ?>
'._t('Installing theme').'
'; $target_file = 'tmp/tmp_theme/'.$_POST['file_name'].'.zip'; if(file_exists($target_file)){ $zip = new ZipArchive; $res = $zip->open($target_file); if ($res === TRUE) { $zip->extractTo('../content/themes/'.$_POST['file_name']); $zip->close(); show_alert('Theme installed', 'success'); delete_files('tmp/tmp_theme/'); echo '
'; } else { echo 'doh!'; } } else { show_alert('Theme file is missing', 'danger'); } } } else if($_POST['action'] == 'update'){ echo '

'._t('Update theme').'

'; // $url = 'https://api.cloudarcade.net/themes/fetch.php?action=info&code='. check_purchase_code(); $url .= '&name='.$_POST['theme']; $url .= '&ref='.DOMAIN.'&theme-version='.$_POST['version'].'&v='.VERSION; $curl = curl_request($url); if($curl != ''){ $json = json_decode($curl, true); echo '
Theme name: '.$json['name']; echo '
Version: '.$json['version']; echo '
Author: '.$json['author']; echo '
Website: '.$json['website']; echo '
Description: '.$json['description']; if(isset($json['release_date'])){ echo '
Release date: '.$json['release_date']; } echo '
Changelog: '.$json['changelog']; if(isset($json['html'])){ echo $json['html']; } echo '

This theme is targeted for CloudArcade v'.$json['target_version'].' or newer.

'; if(to_numeric_version(VERSION) < to_numeric_version($json['target_version'])){ show_alert('You\'re using older version of CloudArcade, update your CMS to meet the requirement.', 'warning'); } else { ?>
open($target); for( $i = 0; $i < $zip->numFiles; $i++ ){ $stat = $zip->statIndex( $i ); $name = basename( $stat['name'] ); if(strpos($name, '.') !== false) { $affected_files[] = $name; } } if ($res === TRUE) { $zip->extractTo('../content/themes/'.$_POST['theme'].'/'); $zip->close(); } else { echo 'doh!'; } unlink($target); show_alert('Theme updated!', 'success'); show_alert('You can roll back to previous version if something happened.', 'info'); echo '
'; echo '

'._t('Affected files').'

'; echo '
    '; foreach ($affected_files as $key) { echo '
  1. '.$key.'
  2. '; } echo '
'; echo ''._t('Back to themes').''; } } else { echo 'Could not create local file'; } } else { echo 'Could not download remote file'; } // Close the cURL resource curl_close($ch); } else if($_POST['action'] == 'duplicate'){ $json = []; $json_path = ABSPATH . 'content/themes/' . $_POST['theme'] . '/info.json'; if(file_exists( $json_path )){ $json = json_decode(file_get_contents( $json_path ), true); } echo '

'._t('Duplicate theme').'

'; echo '

Duplicated themes (Or custom themes) can\'t receive any updates and safe from overwritten update files.

'; ?>
'._t('Are you sure want to delete %a theme?', $_POST['theme-name']).''; ?>

This action can't be undone

'._t('Back to themes').''; } else if($_POST['action'] == 'begin-install-with-code'){ $curl = curl_request('https://api.cloudarcade.net/themes/install.php?code='.get_setting_value('purchase_code').'&ref='.DOMAIN.'&v='.VERSION.'&action=install&validate&email='.$_POST['email'].'&pcode='.$_POST['pcode']); if(is_valid_json($curl)){ $json = json_decode($curl, true); if($json['status'] == 'valid'){ $status = 'warning'; $message = 'Null'; $continue = true; if(file_exists('../content/themes/'.$json['name'])){ show_alert('Failed to install!', 'warning'); $status = 'warning'; $message = 'Theme folder '.$json['name'].' already exist!'; $continue = false; } else { mkdir('../content/themes/'.$json['name'], 0755, true); } if($continue){ $target = '../the-file.zip'; $_ch = curl_init(); curl_setopt($_ch, CURLOPT_URL, $json['link']); curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($_ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($_ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); $remoteFile = curl_exec($_ch); if($remoteFile !== false){ $localFile = fopen($target, 'w'); if($localFile){ fwrite($localFile, $remoteFile); fclose($localFile); if(file_exists($target)){ $zip = new ZipArchive; $res = $zip->open($target); if ($res === TRUE) { $zip->extractTo('../content/themes/'.$json['name']); $zip->close(); $status = 'success'; $message = 'Theme installed!'; } else { echo 'doh!'; } unlink($target); } } } curl_close($_ch); } show_alert($message, $status); echo '
'; echo ''._t('Back to themes').''; } else { show_alert($json['message'], 'danger'); } } else { show_alert('Server error!', 'danger'); } } } else if(isset($_GET['action'])){ if( ADMIN_DEMO ){ echo 'Restricted for DEMO mode'; return; } $action = $_GET['action']; if($action == 'details'){ if(isset($_GET['theme'])){ $json_path = ABSPATH . 'content/themes/' . $_GET['theme'] . '/info.json'; if(file_exists( $json_path )){ $json = json_decode(file_get_contents( $json_path ), true); echo '
Theme name: '.$json['name']; echo '
Version: '.$json['version']; echo '
Author: '.$json['author']; echo '
Website: '.$json['website'].''; if(isset($json['documentation'])){ echo '
Documentation: '.$json['documentation'].''; } echo '
Description: '.$json['description']; if(isset($json['release_date'])){ echo '
Release date: '.$json['release_date']; } if(check_purchase_code()){ ?>
If you've already purchased a theme, you can submit your purchase code here to install the theme.
Make sure you're uploading a theme file from a source you trust; otherwise, your theme file may contain malware or a backdoor that can harm your site.
to_numeric_version(VERSION)){ show_alert('Failed to activate!', 'warning'); echo '
'._t('This theme require CloudArcade v%a or newer.', $theme['target_version']).'
'; echo ''._t('Back to themes').''; } else { // Theme activated update_setting('theme_name', $_POST['theme_dir']); show_alert('Theme activated!', 'success'); echo ''._t('Back to themes').''; } } } } } else { $dirs = scan_folder('content/themes/'); $update_availabe = get_pref('updates'); if(is_null($update_availabe)){ $update_availabe = []; } else { $update_availabe = json_decode($update_availabe, true); if(!isset($update_availabe['themes'])){ $update_availabe['themes'] = []; } } foreach ($dirs as $dir) { $json_path = ABSPATH . 'content/themes/' . $dir . '/info.json'; if(file_exists( $json_path )){ $theme = json_decode(file_get_contents( $json_path ), true); $disabled = ''; $btn_label = _t('Activate'); $thumb; if( THEME_NAME == $dir){ $disabled = _t('disabled'); $btn_label = _t('Activated'); } if(is_theme_has_thumbail($dir)){ $thumb = DOMAIN . 'content/themes/' . $dir . '/thumbnail.png'; } else { $thumb = DOMAIN . 'images/theme-no-thumb.png'; } ?>
>
:
v