Файловый менеджер - Редактировать - /home/u711349237/domains/mosogames.online/public_html/static/img/logo/onlineingame.online.zip
�азад
PK E��Z�hP�O O public_html/site-settings.phpnu W+A�� <?php require( 'includes/load-settings.php' ); define( "SITE_TITLE", SETTINGS['site_title']['value'] ); define( "SITE_DESCRIPTION", SETTINGS['site_description']['value'] ); define( "META_DESCRIPTION", SETTINGS['meta_description']['value'] ); define( "SITE_LOGO", SETTINGS['site_logo']['value'] ); define( "THEME_NAME", $options['theme_name'] ); define( "TEMPLATE_PATH", "content/themes/".THEME_NAME ); define( "IMPORT_THUMB", filter_var(SETTINGS['import_thumb']['value'], FILTER_VALIDATE_BOOLEAN) ); define( "COMPRESSION_LEVEL", 95 ); define( "CUSTOM_SLUG", filter_var(SETTINGS['custom_slug']['value'], FILTER_VALIDATE_BOOLEAN) ); define( "UNICODE_SLUG", filter_var(SETTINGS['unicode_slug']['value'], FILTER_VALIDATE_BOOLEAN) ); define( "SMALL_THUMB", filter_var(SETTINGS['small_thumb']['value'], FILTER_VALIDATE_BOOLEAN) ); ?>PK E��Z�2�V V public_html/admin.phpnu W+A�� <?php session_start(); require( "config.php" ); require( "init.php" ); require( 'includes/plugin.php' ); $action = isset( $_GET['action'] ) ? $_GET['action'] : ""; $username = isset( $_SESSION['username'] ) ? $_SESSION['username'] : ""; if ( $action != "logout" && !$username ) { require("includes/page-login.php" ); exit; } switch ( $action ) { case 'logout': logout(); break; default: header( "Location: admin/dashboard.php" ); } function logout() { CA_Auth::delete(); unset( $_SESSION['username'] ); header( "Location: ".DOMAIN ); return; } ?>PK E��Z)� � public_html/connect.phpnu �[��� <?php define( "DB_DSN", "mysql:host=localhost;dbname=u711349237_onlineingame" ); define( "DB_USERNAME", 'u711349237_onlineingame' ); define( "DB_PASSWORD", '1.Lahorepakistan' ); ?>PK E��ZՐ%u4% 4% public_html/admin/dashboard.phpnu W+A�� <?php session_start(); $action = isset( $_POST['action'] ) ? $_POST['action'] : ""; require "../config.php"; require "../init.php"; require "admin-functions.php"; if ( !$login_user ) { header('Location: '. get_permalink('login')); return; } if(!USER_ADMIN){ exit('Access forbidden!'); } load_language('admin'); require( "../includes/plugin.php" ); if(count($plugin_list) > 0){ load_admin_hooks(); } $update_availabe = get_pref('updates'); if(is_null($update_availabe)){ $update_availabe = []; } else { $update_availabe = json_decode($update_availabe, true); } $available_plugin_updates = get_pref('available_plugin_updates'); if(is_null($available_plugin_updates)){ $available_plugin_updates = []; } else { $available_plugin_updates = json_decode($available_plugin_updates, true); } $pages = array ( array(_t('Dashboard'), 'dashboard', 'home'), array(_t('Game list'), 'gamelist', 'gamepad'), array(_t('Add game'), 'addgame', 'plus-circle'), array(_t('Categories'), 'categories', 'th-large'), array(_t('Collections'), 'collections', 'th-list'), array(_t('Pages'), 'pages', 'book'), array(_t('Themes'), 'themes', 'palette'), array(_t('Plugins'), 'plugin', 'plug'), array(_t('Layout'), 'layout', 'columns'), array(_t('Settings'), 'settings', 'cog'), array(_t('Updater'), 'update', 'sync-alt'), ); if(file_exists( ABSPATH . TEMPLATE_PATH . '/options.php' )){ // Find the index of 'Themes' and insert 'Theme Options' after it $theme_index = array_search('themes', array_column($pages, 1)); if ($theme_index !== false) { array_splice($pages, $theme_index + 1, 0, array(array(_t('Theme Options'), 'theme-options', 'paint-brush'))); } } $page_name = 'Dashboard'; $page_slug = 'dashboard'; $page_icon = null; if(isset($_GET['viewpage'])){ $page_slug = htmlspecialchars($_GET['viewpage']); } if(!check_purchase_code()){ if($page_slug != 'settings'){ header('Location: dashboard.php?viewpage=settings', true); exit(); } for ($i=count($pages)-1; $i >= 0 ; $i--) { if($pages[$i][1] != 'settings'){ array_splice($pages, $i, 1); } } } foreach ($pages as $item) { $active = ''; if($item[1] == $page_slug){ $page_name = _t(esc_string($item[0])); $page_slug = esc_string($item[1]); $page_icon = $item[2]; $active = 'active'; } } if(is_null($page_icon)){ $page_icon = 'exclamation'; } ?> <!DOCTYPE html> <html lang="en" class="<?php echo isset($_SESSION['admin_theme']) ? $_SESSION['admin_theme'] : 'theme-light' ?>"> <head> <meta charset="utf-8"> <title>Admin | <?php echo $page_name . ' - ' . SITE_TITLE ?></title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="../vendor/bootstrap5/css/bootstrap.min.css" /> <!-- Font Awesome icons (free version)--> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" crossorigin="anonymous" defer> <link rel="stylesheet" type="text/css" href="style/admin.css?v=<?php echo VERSION ?>"> <?php if($page_slug == 'layout'){ echo '<link rel="stylesheet" type="text/css" href="style/jquery.nestable.css?v='.VERSION.'">'; } if ($page_slug == 'layout' || $page_slug == 'theme-options'){ echo '<link rel="stylesheet" type="text/css" href="style/menus.css?v='.VERSION.'">'; } ?> <script type="text/javascript" src="../js/jquery-3.6.2.min.js"></script> <script type="text/javascript" src="../js/jquery-ui.min.js"></script> <script type="text/javascript" src="../vendor/bootstrap5/js/bootstrap.bundle.min.js"></script> <script type="text/javascript" src="../js/chart/utils.js"></script> <script type="text/javascript" src="../js/chart/Chart.min.js"></script> </head> <body> <div class="main-header"> <nav class="navbar navbar-expand-lg navbar-light top-nav" id="mainNav"> <div class="container-fluid"> <button class="sidebar-toggler" type="button" onclick="openSidebar()"> <span class="navbar-toggler-icon"></span> </button> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#quickLinks" aria-controls="quickLinks" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse justify-content-end" id="quickLinks"> <div class="quicklinks"> <a href="<?php echo DOMAIN ?>admin.php?action=logout" class="btn btn-sm btn-danger"> <i class="fas fa-sign-out-alt"></i> </a> <a href="<?php echo DOMAIN ?>" target="_blank" class="btn btn-sm btn-primary"> <i class="fas fa-external-link-alt"></i> <?php _e('VISIT SITE') ?> </a> </div> </div> </div> </nav> </div> <div class="admin-container"> <div class="sidebar" id="sidebar"> <a class="navbar-brand" href="#"> <img src="../images/logo-horizontal.png" class="logo" alt="Logo"> </a> <div class="admin-menu"> <ul id="menu-list"> <?php $i = 0; foreach ($pages as $item) { $active = ''; if($item[1] == $page_slug){ //$page_name = _t(esc_string($item[0])); //$page_slug = esc_string($item[1]); $active = 'active'; } if($item[1] == 'plugin'){ //Dropdown echo '<li class="'.$active.'">'; ?> <div class="li-list dropdown-btn"> <i class="fa fa-<?php echo $item[2] ?>" aria-hidden="true"></i> <?php echo esc_string($item[0]); ?> <?php if(!is_null($available_plugin_updates) && count($available_plugin_updates)){ echo '<i class="fa fa-exclamation-circle has-update-icon -u-plugin"></i>'; } else { echo '<i class="fa fa-caret-down"></i>'; } ?> </div> <?php echo '</li>'; ?> <div class="dropdown-container <?php echo $active ?> installed-plugin-list"> <a href="?viewpage=<?php echo $item[1] ?>"> <?php $selected_plugin = ''; $active_child = ''; if(isset($_GET['name'])){ $selected_plugin = $_GET['name']; } else { $active_child = 'active'; } ?> <div class="dropdown-list <?php echo $active_child ?>"> <?php _e('Manage Plugins') ?> <?php if(!is_null($available_plugin_updates) && count($available_plugin_updates)){ echo '<i class="fa fa-exclamation-circle has-update-icon -u-plugin"></i>'; } ?> </div> </a> <?php foreach ($plugin_list as $plugin) { if(substr($plugin['dir_name'], 0, 1) != '_'){ $active_child = ''; if($selected_plugin == $plugin['dir_name']){ $active_child = 'active'; } ?> <a href="?viewpage=<?php echo $item[1] ?>&name=<?php echo $plugin['dir_name'] ?>"> <div class="dropdown-list <?php echo $active_child ?>"> <?php _e($plugin['name']) ?> <?php if(!is_null($available_plugin_updates) && count($available_plugin_updates)){ if(in_array($plugin['dir_name'], $available_plugin_updates)){ echo '<i class="fa fa-exclamation-circle has-update-icon"></i>'; } } ?> </div> </a> <?php } } ?> </div> <?php } else { //Regular menu echo '<li class="'.$active.'">'; echo '<a href="?viewpage='.$item[1].'">'; echo '<div class="li-list" name="dashboard"><i class="fa fa-'.$item[2].'" aria-hidden="true"></i>'; echo esc_string($item[0]); if($item[1] == 'themes' || $item[1] == 'update'){ if(isset($update_availabe[$item[1]])){ echo '<i class="fa fa-exclamation-circle has-update-icon -u-'.$item[1].'"></i>'; } } echo '</div></a>'; echo '</li>'; } $i++; } ?> </ul> <div class="form-check custom-switch" style="margin-left: 20px;"> <input type="checkbox" class="form-check-input" id="darkSwitch" onclick="toggleTheme()"> <label class="form-check-label" for="darkSwitch"><?php _e('Dark Mode') ?></label> </div> <div class="cms justify-content-center" style="display: flex;"> <a href="http://cloudarcade.net" target="_blank" style="margin-right: 10px">Cloud Arcade</a> v<?php echo VERSION ?> </div> </div> </div> <div class="content" id="content"> <div id="page-slug-<?php echo $page_slug ?>"></div> <?php if( ADMIN_DEMO ){ show_alert('(Admin Demo) All actions are not saved.', 'warning'); } ?> <h3 class="page-title"><i class="fa fa-<?php echo $page_icon ?>"></i> <?php echo esc_string($page_name); ?></h3> <?php include 'core/'.$page_slug.'.php'; ?> </div> <span id="cms-version" style="display: none;"><?php echo VERSION ?></span> </div> <script type="text/javascript" src="../js/script.js?v=<?php echo VERSION ?>"></script> <?php if ($page_slug == 'dashboard'){ echo '<script type="text/javascript" src="../js/chart/stats.js?v='.VERSION.'"></script>'; } elseif ($page_slug == 'layout'){ echo '<script type="text/javascript" src="../js/jquery.nestable.js"></script>'; echo '<script type="text/javascript" src="../js/menu.js?v='.VERSION.'"></script>'; } ?> </body> </html>PK E��Z # public_html/admin/backups/index.phpnu W+A�� PK E��Z���p� � public_html/admin/upload.phpnu W+A�� <?php session_start(); require_once('../config.php'); require_once('../init.php'); $action = isset( $_POST['action'] ) ? $_POST['action'] : ""; $username = isset( $_SESSION['username'] ) ? $_SESSION['username'] : ""; if ( $action != "login" && $action != "logout" && !$username ) { exit('logout'); } if( !USER_ADMIN ){ exit('p'); } if( ADMIN_DEMO ){ header('Location: dashboard.php?viewpage=addgame'); exit(); } if( !has_admin_access() ){ exit('x'); } if (!file_exists('tmp')) { mkdir('tmp', 0755, true); } if (!file_exists('../games')) { mkdir('../games', 0755, true); } $target_dir = "tmp/"; $target_file = $target_dir . strtolower(str_replace(' ', '-', basename($_FILES["gamefile"]["name"]))); $folder_name = 0; if(isset($_POST['slug'])){ $_POST['slug'] = esc_slug($_POST['slug']); $folder_name = $_POST['slug']; } else { $folder_name = esc_slug($_POST['title']); } $uploadOk = 1; $error = array(); if (isset($_SERVER['CONTENT_LENGTH'])) { if($_SERVER['CONTENT_LENGTH'] > convert_to_bytes(ini_get('upload_max_filesize'))){ $uploadOk = 0; $error['err'] = 'You file size is too large, your php.ini upload_max_filesize is '.ini_get('upload_max_filesize'); } } function convert_to_bytes($val) { $val = trim($val); $last = strtolower($val[strlen($val)-1]); $val = (int)$val; switch($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; case 'k': $val *= 1024; } return $val; } $fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); if($fileType != 'zip'){ $uploadOk = 0; } $have_icon_512 = false; //Used for Construct 3 game $generate_thumbnail = false; if ($uploadOk == 0) { //echo "error1"; } else { if (move_uploaded_file($_FILES["gamefile"]["tmp_name"], $target_file)) { $check = array(); $check['index'] = 'false'; $check['thumb_1'] = false; $check['thumb_2'] = false; //uploaded $za = new ZipArchive(); $za->open($target_file); for( $i = 0; $i < $za->numFiles; $i++ ){ $stat = $za->statIndex( $i ); $name = $stat['name']; if($name == 'index.html'){ $check['index'] = $name; } if($name == 'thumb_1.png' || $name == 'thumb_1.jpg' || $name == 'thumb_1.jpeg' || $name == 'thumb_1.PNG' || $name == 'thumb_1.JPG'){ if(!$check['thumb_1']){ $check['thumb_1'] = $name; } } if($name == 'thumb_2.png' || $name == 'thumb_2.jpg' || $name == 'thumb_2.jpeg' || $name == 'thumb_2.PNG' || $name == 'thumb_2.JPG'){ if(!$check['thumb_2']){ $check['thumb_2'] = $name; } } if($name == 'icons/icon-512.png'){ $have_icon_512 = true; } } if(!$check['thumb_1'] && !$check['thumb_2'] && $have_icon_512){ $check['thumb_1'] = 'thumb_1.png'; $check['thumb_2'] = 'thumb_2.png'; $generate_thumbnail = true; } $za->close(); } else { echo "error2"; } } // Check if user chose to upload separate thumbnails $thumb_method = $_POST['thumb_method'] ?? 'zip'; if ($thumb_method == 'upload') { // Validate and handle custom thumbnail uploads // Validate thumb_upload_1 if (isset($_FILES['thumb_upload_1']) && $_FILES['thumb_upload_1']['error'] == UPLOAD_ERR_OK) { $thumb_upload_1_size = $_FILES['thumb_upload_1']['size']; // File size in bytes $thumb_upload_1_type = mime_content_type($_FILES['thumb_upload_1']['tmp_name']); // File type // Check file size (1MB = 1048576 bytes) if ($thumb_upload_1_size > 1048576) { $uploadOk = 0; $error['thumb_1_size'] = 'thumb_1 exceeds the 1MB file size limit.'; } elseif (in_array($thumb_upload_1_type, ['image/jpeg', 'image/png'])) { // Move the uploaded file to the appropriate folder $thumb_1_target = '../games/' . $folder_name . '/thumb_1.' . pathinfo($_FILES['thumb_upload_1']['name'], PATHINFO_EXTENSION); move_uploaded_file($_FILES['thumb_upload_1']['tmp_name'], $thumb_1_target); $_POST['thumb_1'] = '/games/'.$folder_name.'/'.basename($thumb_1_target); } else { $uploadOk = 0; $error['thumb_1_invalid'] = 'Invalid thumb_1 file type. Must be JPG or PNG.'; } } else { $uploadOk = 0; $error['thumb_1_missing'] = 'thumb_1 upload failed.'; } // Validate thumb_upload_2 if (isset($_FILES['thumb_upload_2']) && $_FILES['thumb_upload_2']['error'] == UPLOAD_ERR_OK) { $thumb_upload_2_size = $_FILES['thumb_upload_2']['size']; // File size in bytes $thumb_upload_2_type = mime_content_type($_FILES['thumb_upload_2']['tmp_name']); // File type // Check file size (1MB = 1048576 bytes) if ($thumb_upload_2_size > 1048576) { $uploadOk = 0; $error['thumb_2_size'] = 'thumb_2 exceeds the 1MB file size limit.'; } elseif (in_array($thumb_upload_2_type, ['image/jpeg', 'image/png'])) { // Move the uploaded file to the appropriate folder $thumb_2_target = '../games/' . $folder_name . '/thumb_2.' . pathinfo($_FILES['thumb_upload_2']['name'], PATHINFO_EXTENSION); move_uploaded_file($_FILES['thumb_upload_2']['tmp_name'], $thumb_2_target); $_POST['thumb_2'] = '/games/'.$folder_name.'/'.basename($thumb_2_target); } else { $uploadOk = 0; $error['thumb_2_invalid'] = 'Invalid thumb_2 file type. Must be JPG or PNG.'; } } else { $uploadOk = 0; $error['thumb_2_missing'] = 'thumb_2 upload failed.'; } } if ($thumb_method == 'zip') { // Use thumbnails from zip if user didn't choose separate upload if ($uploadOk == 1) { if (!$check['index']) { $error['err1'] = 'No index.html on root detected!'; $uploadOk = 0; } if (!$check['thumb_1']) { $error['err2'] = 'No thumb_1.jpg/png on root detected!'; $uploadOk = 0; } if (!$check['thumb_2']) { $error['err3'] = 'No thumb_2.jpg/png on root detected!'; $uploadOk = 0; } } } if ($uploadOk == 0) { $error['err0'] = 'Upload failed!'; unlink($target_file); // Store current fields $keys = ['title', 'slug', 'description', 'instructions', 'width', 'height', 'category', 'thumb_1', 'thumb_2', 'url', 'tags']; foreach ($keys as $item) { $_SESSION[$item] = (isset($_POST[$item])) ? $_POST[$item] : null; } header('Location: dashboard.php?viewpage=addgame&status=error&error-data='.json_encode($error)); } else { $zip = new ZipArchive; $res = $zip->open($target_file); if ($res === TRUE) { $zip->extractTo('../games/'.$folder_name.'/'); $zip->close(); } else { echo 'doh!'; } unlink($target_file); if($generate_thumbnail){ require_once('../includes/commons.php'); // Begin generate thumbnail try { $target_img = '../games/'.$folder_name.'/icons/icon-512.png'; if(file_exists($target_img)){ imgCopy($target_img, '../games/'.$folder_name.'/thumb_1.png', 512, 384); imgCopy($target_img, '../games/'.$folder_name.'/thumb_2.png', 512, 512); } } catch(Exception $e) { var_dump($e); } } $cats = ''; $i = 0; $total = count($_POST['category']); foreach ($_POST['category'] as $key) { $cats = $cats.$key; if($i < $total-1){ $cats = $cats.','; } $i++; } $_POST['ref'] = 'upload'; $_POST['action'] = 'addGame'; $_POST['category'] = $cats; $_POST['url'] = '/games/'.$folder_name.'/'; // Only set thumb_1 and thumb_2 from the zip if no separate upload was used if ($thumb_method == 'zip') { $_POST['thumb_1'] = '/games/'.$folder_name.'/'.$check['thumb_1']; $_POST['thumb_2'] = '/games/'.$folder_name.'/'.$check['thumb_2']; } if( SMALL_THUMB ){ $output = pathinfo($_POST['thumb_2']); $_POST['thumb_small'] = '/games/'.$folder_name.'/'.$folder_name.'_small.'.$output['extension']; imgResize('..'.$_POST['thumb_2'], 160, 160, $folder_name); } // $_POST['redirect'] = 'dashboard.php?viewpage=addgame&status=uploaded'; require 'request.php'; } ?>PK E��Z��4��B �B % public_html/admin/admin-functions.phpnu W+A�� <?php // Functions for Admin Panel if(!USER_ADMIN){ die('Forbidden'); } define( "SKIP_QUERY_CACHE", true ); $admin_hooks = []; // Function to register admin hook function add_admin_hook($hook_name, $callback, $priority = 10) { global $admin_hooks; if (!isset($admin_hooks[$hook_name])) { $admin_hooks[$hook_name] = []; } if (!isset($admin_hooks[$hook_name][$priority])) { $admin_hooks[$hook_name][$priority] = []; } $admin_hooks[$hook_name][$priority][] = $callback; } // Function to execute admin hooks function do_admin_hook($hook_name, ...$args) { global $admin_hooks; if (!isset($admin_hooks[$hook_name])) { return; } ksort($admin_hooks[$hook_name]); // Sort by priority foreach ($admin_hooks[$hook_name] as $priority => $callbacks) { foreach ($callbacks as $callback) { call_user_func_array($callback, $args); } } } function get_setting_group($category){ // $conn = open_connection(); // $sql = "SELECT * FROM settings WHERE category = :category"; // $st = $conn->prepare($sql); // $st->bindValue('category', $category, PDO::PARAM_STR); // $st->execute(); // $rows = $st->fetchAll(PDO::FETCH_ASSOC); // return $rows; $group = []; foreach (SETTINGS as $item) { if($item['category'] == $category){ $group[] = $item; } } return $group; } function update_setting($name, $value){ // Migrated, replacing update_settings() $this_setting = get_setting($name); // Validating data type if($this_setting['type'] == 'bool'){ if($value == 1 || $value == 0){ // } else { die('Type not valid'); } } else if($this_setting['type'] == 'number'){ if(!is_numeric($value)){ die('Type not valid'); } } $conn = open_connection(); $sql = "UPDATE settings SET value = :value WHERE name = :name LIMIT 1"; $st = $conn->prepare($sql); $st->bindValue(":name", $name, PDO::PARAM_STR); $st->bindValue(":value", $value, PDO::PARAM_STR); $st->execute(); } function to_numeric_version($str_version){ // Used to convert "1.5.0" to int 150 return (int)str_replace('.', '', $str_version); } function curl_request($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); $response = curl_exec($ch); if (curl_errno($ch)) { // If an error occured during the request, print the error echo 'Error:' . curl_error($ch); return false; } curl_close($ch); return $response; } function generate_small_thumbnail($path, $slug){ // $path == $game->thumb_2 // This function only works if thumb 2 is already stored locally $parent_dir = dirname(__FILE__) . '/../'; // CloudArcade root / installation folder if(!file_exists($parent_dir.$path)){ echo 'error 910: img file not found!'; return; } // $use_webp = get_setting_value('webp_thumbnail'); $path_info = pathinfo(strtok($path, '?')); $root_folder = explode("/", $path); $output = "thumbs/" . $slug . "_small." . $path_info['extension']; if($path_info['extension'] == 'webp'){ // WEBP thumbnail $file_extension = pathinfo(strtok($path, '?'), PATHINFO_EXTENSION); $output = str_replace('.'.$file_extension, '.webp', $output); $_img = getimagesize($parent_dir.$path); $width = $_img[0]; $height = $_img[1]; $img = imagecreatefromwebp($parent_dir.$path); $new_img = imagecreatetruecolor(160, 160); imagecopyresampled($new_img, $img, 0, 0, 0, 0, 160, 160, $width, $height); // Output imagewebp($new_img, $parent_dir.$output, 100); // Best quality imagedestroy($img); imagedestroy($new_img); } else { // PNG, JPG, GIF $x = getimagesize($parent_dir.$path); $width = $x[0]; $height = $x[1]; switch ($x['mime']) { case "image/gif": $img = imagecreatefromgif($parent_dir.$path); break; case "image/jpg": case "image/jpeg": $img = imagecreatefromjpeg($parent_dir.$path); break; case "image/png": $img = imagecreatefrompng($parent_dir.$path); break; } $img_base = imagecreatetruecolor(160, 160); if($x['mime'] == "image/png"){ imagealphablending($img_base, false); imagesavealpha($img_base, true); } imagecopyresampled($img_base, $img, 0, 0, 0, 0, 160, 160, $width, $height); $path_info = pathinfo($parent_dir.$path); switch ($path_info['extension']) { case "gif": imagegif($img_base, $parent_dir.$output); // No compression break; case "jpg": case "jpeg": imagejpeg($img_base, $parent_dir.$output, 100); // Best quality break; case "png": imagepng($img_base, $parent_dir.$output, 6); // Balance compression break; } imagedestroy($img); imagedestroy($img_base); } } function import_thumbnail($url, $game_slug, $index = null){ // import_thumb() replacement from request.php // Used to import thumb_1 and thumb_2 from remote source $parent_dir = dirname(__FILE__) . '/../'; // CloudArcade root / installation folder if($url) { if (!file_exists($parent_dir.'thumbs')) { mkdir($parent_dir.'thumbs', 0777, true); } $extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION); $identifier = ''; if(!is_null($index)){ $identifier = '_'.$index; } $new = $parent_dir.'thumbs/'.$game_slug.$identifier.'.'.$extension; if( get_setting_value('webp_thumbnail') ){ // Using WEBP format $file_extension = pathinfo(strtok($url, '?'), PATHINFO_EXTENSION); $new = str_replace('.'.$file_extension, '.webp', $new); // Create a cURL resource $ch = curl_init(); // Set cURL options for retrieving the remote image file curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); // Retrieve the remote image and save it to a local file $remoteImage = curl_exec($ch); if($remoteImage !== false){ $localFile = fopen($new, 'w'); if($localFile){ fwrite($localFile, $remoteImage); fclose($localFile); } else { echo 'Could not create local file'; } } else { echo 'Could not download remote image'; } // Close the cURL resource curl_close($ch); image_to_webp($new, 100, $new); } else { // Using JPG/PNG/GIF format save_remote_thumbnail($url, $new); } } } function save_remote_thumbnail($source, $destination, $quality = 100) { // compressImage() replacement from request.php // Create a cURL resource $ch = curl_init(); // Set cURL options for retrieving the remote image file curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); // Retrieve the remote image $remoteImage = curl_exec($ch); // Close the cURL resource curl_close($ch); if ($remoteImage !== false) { $image = imagecreatefromstring($remoteImage); if ($image !== false) { $info = getimagesizefromstring($remoteImage); switch ($info['mime']) { case 'image/png': imagealphablending($image, false); imagesavealpha($image, true); imagepng($image, $destination, 6); // Compression level from 0 (no compression) to 9 break; case 'image/jpeg': case 'image/jpg': imagejpeg($image, $destination, $quality); // Quality level from 0 (worst) to 100 (best) break; case 'image/gif': imagegif($image, $destination); break; default: echo 'Unsupported image format: ' . $info['mime']; imagedestroy($image); return false; } imagedestroy($image); } else { echo 'Could not create image resource'; return false; } } else { echo 'Could not download remote image'; return false; } return true; } function update_content_translation($content_type, $content_id, $language, $field_data) { // Sample usage = // Single : update_content_translation('game', 1, 'en', ['title' => 'New Title']); // Multiple : update_content_translation('game', 1, 'en', ['title' => 'New Title', 'description' => 'New Description']); if (ADMIN_DEMO || !USER_ADMIN) { die('ERR 918'); } $conn = open_connection(); try { $conn->beginTransaction(); foreach ($field_data as $field => $translation) { $checkSql = "SELECT COUNT(*) FROM translations WHERE content_type = :content_type AND content_id = :content_id AND language = :language AND field = :field"; $checkStmt = $conn->prepare($checkSql); $checkStmt->bindParam(':content_type', $content_type, PDO::PARAM_STR); $checkStmt->bindParam(':content_id', $content_id, PDO::PARAM_INT); $checkStmt->bindParam(':language', $language, PDO::PARAM_STR); $checkStmt->bindParam(':field', $field, PDO::PARAM_STR); $checkStmt->execute(); if ($checkStmt->fetchColumn() > 0) { $sql = "UPDATE translations SET translation = :translation WHERE content_type = :content_type AND content_id = :content_id AND language = :language AND field = :field"; } else { $sql = "INSERT INTO translations (content_type, content_id, language, field, translation) VALUES (:content_type, :content_id, :language, :field, :translation)"; } $stmt = $conn->prepare($sql); $stmt->bindParam(':content_type', $content_type, PDO::PARAM_STR); $stmt->bindParam(':content_id', $content_id, PDO::PARAM_INT); $stmt->bindParam(':language', $language, PDO::PARAM_STR); $stmt->bindParam(':field', $field, PDO::PARAM_STR); $stmt->bindParam(':translation', $translation, PDO::PARAM_STR); $stmt->execute(); } $conn->commit(); return true; } catch (Exception $e) { $conn->rollback(); return false; } } function delete_content_translation($content_type, $content_id, $language = null, $field = null) { if (ADMIN_DEMO || !USER_ADMIN) { die('ERR 237'); } $conn = open_connection(); $sql = "DELETE FROM translations WHERE content_type = :content_type AND content_id = :content_id"; if ($language !== null) { $sql .= " AND language = :language"; } if ($field !== null) { $sql .= " AND field = :field"; } $stmt = $conn->prepare($sql); $stmt->bindParam(':content_type', $content_type, PDO::PARAM_STR); $stmt->bindParam(':content_id', $content_id, PDO::PARAM_INT); if ($language !== null) { $stmt->bindParam(':language', $language, PDO::PARAM_STR); } if ($field !== null) { $stmt->bindParam(':field', $field, PDO::PARAM_STR); } return $stmt->execute(); } function get_extra_fields($content_type) { $conn = open_connection(); $sql = "SELECT * FROM extra_fields WHERE content_type = :content_type"; $st = $conn->prepare($sql); $st->bindValue(':content_type', $content_type, PDO::PARAM_STR); $st->execute(); $rows = $st->fetchAll(PDO::FETCH_ASSOC); return $rows; } function get_extra_field_by_id($id) { $conn = open_connection(); $sql = "SELECT * FROM extra_fields WHERE id = :id LIMIT 1"; $st = $conn->prepare($sql); $st->bindValue(':id', $id, PDO::PARAM_INT); $st->execute(); $row = $st->fetch(PDO::FETCH_ASSOC); return $row; } function get_extra_field_by_key($field_key, $content_type = null) { $allowed_types = ['game', 'category', 'page', 'post']; $including_type = false; if(!is_null($content_type)){ if(in_array($content_type, $allowed_types)){ $including_type = true; } } $conn = open_connection(); $sql = "SELECT * FROM extra_fields WHERE field_key = :field_key"; if ($including_type) { $sql .= " AND content_type = :content_type"; } $sql .= " LIMIT 1"; $st = $conn->prepare($sql); $st->bindValue(':field_key', $field_key, PDO::PARAM_STR); if ($including_type) { $st->bindValue(':content_type', $content_type, PDO::PARAM_STR); } $st->execute(); $row = $st->fetch(PDO::FETCH_ASSOC); return $row; } function backup_cms($root_path, $backup_type = 'part'){ // Backup directory and file name if (extension_loaded('zip') && is_login() && USER_ADMIN && !ADMIN_DEMO) { $backup_dir = $root_path.'/admin/backups'; if (!file_exists($backup_dir)) { mkdir($backup_dir, 0755, true); } if (!file_exists($backup_dir.'/index.php')) { file_put_contents($backup_dir.'/index.php', ''); } $backup_file = $_SESSION['username'].'-cloudarcade-backup-'.$backup_type.'-'.VERSION.'-'.time().'-'.generate_random_strings().'.zip'; $allowed_folders = []; $allowed_extensions = []; if($backup_type == 'part'){ $allowed_folders = ['admin', 'classes', 'db', 'includes', 'js', 'locales']; // 'images' $allowed_extensions = ['php', 'js', 'html', 'xml', 'json', 'css', 'htaccess', 'ico', 'png', 'jpg', 'jpeg', 'gif', 'webp', 'svg']; } $options = [ 'allowed_folders' => $allowed_folders, // root 'ignore_folders' => ['cloudarcade', 'private', 'cache', 'temp', 'backups'], // also applied on sub-folder 'ignore_extensions' => ['zip', 'rar', '7z'], 'whitelisted_files' => [], 'allowed_extensions' => $allowed_extensions, 'ignore_files' => [] ]; if($backup_type == 'part'){ $options['whitelisted_files'] = ['content/themes/theme-functions.php']; $options['ignore_files'] = ['connect.php']; } zip_files_recursive( $root_path, ABSPATH . 'admin/backups/'.$backup_file, $options ); } } function zip_files_recursive($source, $destination, $options = []) { $allowedFolders = isset($options['allowed_folders']) ? $options['allowed_folders'] : []; $ignoreFolders = isset($options['ignore_folders']) ? $options['ignore_folders'] : []; $ignoreExtensions = isset($options['ignore_extensions']) ? $options['ignore_extensions'] : []; $whitelistedFiles = isset($options['whitelisted_files']) ? $options['whitelisted_files'] : []; $ignoreFiles = isset($options['ignore_files']) ? $options['ignore_files'] : []; $allowedExtensions = isset($options['allowed_extensions']) ? $options['allowed_extensions'] : []; if (!extension_loaded('zip') || !is_login()) { return false; } if (file_exists($source)) { $zip = new ZipArchive(); if ($zip->open($destination, ZIPARCHIVE::CREATE)) { $maxSize = 20 * 1024 * 1024; // 20 MB if (is_dir($source)) { $iterators = []; if (!empty($allowedFolders)) { foreach ($allowedFolders as $allowedFolder) { $folderPath = $source . $allowedFolder . '/'; if (file_exists($folderPath)) { $iterators[] = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folderPath, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); } } $root_files = scandir($source); $_root_files = []; foreach ($root_files as $file) { if ($file == '.' || $file == '..') { continue; } $filePath = $source . $file; if (is_file($filePath)) { $_root_files[] = new SplFileInfo($filePath); } } $iterators[] = $_root_files; } else { $iterators[] = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST); } foreach ($iterators as $files) { foreach ($files as $file) { if (count($allowedExtensions) > 0 && !in_array(pathinfo($file, PATHINFO_EXTENSION), $allowedExtensions)) { continue; } $ignored = false; foreach ($ignoreFolders as $ignore) { if (stripos($file, $ignore) !== false) { $ignored = true; break; } } if ($ignored) { continue; } $relativePath = $file->getPathname() === $source ? $file->getFilename() : str_replace('\\', '/', str_replace($source . DIRECTORY_SEPARATOR, '', $file->getPathname())); $thePath = str_replace($source, '', $relativePath); // Check if the folder is allowed $folderName = explode('/', $thePath)[0]; $isDir = false; if (is_dir($source . '/' . $folderName) && strpos($folderName, '.') === false) { $isDir = true; } if(in_array($thePath, $ignoreFiles)){ continue; } if (is_dir($file)) { if (count(glob("$file/*")) > 0) { //If folder not empty $zip->addEmptyDir($relativePath . '/'); } } else if (is_file($file)) { // Ignore files larger than 20 MB if (filesize($file) > $maxSize) { continue; } // Ignore archive files $ext = pathinfo($file, PATHINFO_EXTENSION); if (in_array($ext, $ignoreExtensions)) { continue; } $zip->addFromString($relativePath, file_get_contents($file)); } } } } else if (is_file($source)) { // Add single file } return $zip->close(); } } return false; } ?>PK E��ZjY� i>