File manager - Edit - /home/newsbmcs.com/public_html/play1/content/themes/arcade-two/options.php
Back
<?php if (!has_admin_access()) { exit; } $allow_mobile_version = get_option('arcade-two-mobile-version'); $allow_mobile_version = is_null($allow_mobile_version) ? true : ($allow_mobile_version === 'true'); if (isset($_POST['action'])) { switch ($_POST['action']) { case 'update-icons-data': file_put_contents(ABSPATH . TEMPLATE_PATH . '/includes/category-icons.json', $_POST['data']); show_alert('SAVED!', 'success'); break; case 'update-allow-mobile': $allow_mobile_version = isset($_POST['mobile-version']); update_option('arcade-two-mobile-version', $allow_mobile_version ? 'true' : 'false'); show_alert('SAVED!', 'success'); break; case 'update-background': update_option('arcade-two-background', $_POST['background']); show_alert('SAVED!', 'success'); break; case 'upload-frame': $targetDir = ABSPATH . TEMPLATE_PATH . '/images/frame/'; // Ensure the directory exists if (!file_exists($targetDir)) { mkdir($targetDir, 0777, true); } $file = $_FILES['frame_file']; if ($file['error'] === UPLOAD_ERR_OK) { $fileName = basename($file['name']); $targetFilePath = $targetDir . $fileName; $fileType = strtolower(pathinfo($targetFilePath, PATHINFO_EXTENSION)); $allowedTypes = ['jpg', 'jpeg', 'png', 'svg']; if (in_array($fileType, $allowedTypes)) { if (move_uploaded_file($file['tmp_name'], $targetFilePath)) { update_option('arcade-two-frame-image', TEMPLATE_PATH . '/images/frame/' . $fileName); show_alert('File uploaded successfully!', 'success'); } else { show_alert('Failed to move the file.', 'danger'); } } else { show_alert('Invalid file type. Allowed types: JPG, JPEG, PNG, SVG.', 'danger'); } } else { show_alert('Upload error code: ' . $file['error'], 'danger'); } break; } } $current_frame_image = get_option('arcade-two-frame-image'); ?> <br> <!-- Frame Upload --> <h4>Frame Upload</h4> <div class="mb-3"> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="upload-frame" /> <div class="form-group"> <label for="frameFile">Upload Frame File:</label> <input type="file" class="form-control" id="frameFile" name="frame_file" accept=".png,.jpg,.jpeg,.svg" required onchange="previewImage(event)"> </div> <div id="preview-container" style="margin-top: 10px;"> <img id="framePreview" src="" alt="Preview" style="display: none; width: 150px; height: 150px; border: 1px solid #ccc;"> </div> <button type="submit" class="btn btn-primary btn-md">Upload</button> </form> </div> <br> <!-- Existing Frame Image --> <!-- <div class="frame-image-container"> <h5>Current Frame Image:</h5> <img src="<?php echo $current_frame_image; ?>" alt="Frame Image" style="width: 150px; height: 150px; border: 1px solid #ccc;"> </div> --> <!-- JavaScript for image preview --> <script> function previewImage(event) { const file = event.target.files[0]; const reader = new FileReader(); reader.onload = function() { const preview = document.getElementById('framePreview'); preview.style.display = 'block'; preview.src = reader.result; }; if (file) { reader.readAsDataURL(file); } } </script> <br> <?php $category_icons = json_decode(file_get_contents(ABSPATH . TEMPLATE_PATH . '/includes/category-icons.json'), true); echo '<h4>'._t('Allow mobile version').'</h4>'; echo '<br>'; echo '<form method="post">'; echo '<input type="hidden" name="action" value="update-allow-mobile"/>'; $checked = ''; if($allow_mobile_version){ $checked = 'checked'; } ?> <div class="form-check"> <input type="checkbox" class="form-check-input" name="mobile-version" id="check1" <?php echo $checked ?>> <label class="form-check-label" for="check1"><?php _e('Allow mobile version') ?></label> </div> <?php echo '<br>'; echo '<button type="submit" class="btn btn-primary btn-md">'._t('SAVE').'</button>'; echo '</form>'; ?> <br> <!-- Background --> <div class="mb-3"> <h4>Background</h4> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="update-background"> <div class="mb-3"> <select class="form-select" name="background"> <?php $bg_list = array( 'Background 1' => 'background1.png', 'Background 2' => 'background2.png', 'None' => '' ); $selected_bg = get_option('arcade-two-background'); if(is_null($selected_bg)){ $selected_bg = reset($bg_list); } foreach ($bg_list as $key => $value) { $selected = ''; if($selected_bg == $value){ $selected = 'selected'; } echo '<option value="'.$value.'" '.$selected.'>'.$key.'</option>'; } ?> </select> </div> <button id="save-background-conf" class="btn btn-primary btn-md">Save</button> </form> </div> <br> <!-- Category --> <div class="mb-3"> <h4>Category Icons</h4> <form method="post" id="form-icons"> <input type="hidden" name="action" value="update-icons-data" /> <input type="hidden" id="data-target" name="data" value="" /> <div class="row"> <div class="col"> <label>ID:</label> </div> <div class="col"> <label>Category Slug (separated by comma):</label> </div> </div> <?php foreach ($category_icons as $key => $value) { ?> <div class="row"> <img src="<?php echo get_template_path(); ?>/images/icon/<?php echo $key; ?>.svg"> <div class="form-group col"> <input type="text" class="form-control t-key" name="val" value="<?php echo $key ?>" readonly required> </div> <div class="form-group col"> <input type="text" class="form-control t-value" name="val" value="<?php echo implode(',', $value); ?>" required> </div> </div> <?php } ?> </form> <button id="save-icon-conf" class="btn btn-primary btn-md">Save</button> </div> <!-- js --> <script type="text/javascript"> $(document).ready(()=>{ $('#save-icon-conf').click(()=>{ if(true){ let res = '{'; let error; let t1 = $('.t-key').serializeArray(); let t2 = $('.t-value').serializeArray(); let total = t1.length; for(let i=0; i<total; i++){ if(t1[i].value && t2[i].value){ res += '"'+t1[i].value+'"'+': '+JSON.stringify(t2[i].value.split(','))+','; } } if(res.slice(-1) === ','){ res = res.slice(0, -1); } res += '}'; let x = JSON.parse(res); if(res != '{}'){ $('#data-target').val(res); $('form#form-icons').submit(); } } }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 8.2.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings