'._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 {
?>
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 '