File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/includes.zip
Back
PK �X�Z����{ { function_general.phpnu �[��� <?php require_once '../app/includes/constant.php'; require_once '../config.php'; require_once '../app/includes/app_start.php'; // Getting All User Data this Function echo Data function User_Data($column) { global $socket; $current_user = $_SESSION['Loggedin_user_id']; $sql = "select * from zon_users where id=$current_user"; $run = mysqli_query($socket, $sql); $row = mysqli_fetch_assoc($run); echo $row[$column]; } // Getting All User Data this Function return Data function User_Data_Two($column) { global $socket; if (isset($_SESSION['Loggedin_user'])) { $current_user = $_SESSION['Loggedin_user_id']; $sql = "select * from zon_users where id=$current_user"; $row = mysqli_fetch_assoc(mysqli_query($socket, $sql)); return $row[$column]; } } // Getting user Data by column name and condition function User_Data_By_Cond($column, $cond) { global $socket; $sql = "select * from zon_users where $cond"; $row = mysqli_fetch_assoc(mysqli_query($socket, $sql)); return $row[$column]; } // Getting All Game Data this Function print Data function Game_Data($id, $data) { global $socket; $query = "SELECT * from zon_games where id=$id"; $row = mysqli_fetch_assoc(mysqli_query($socket, $query)); echo $row[$data]; } // Getting All Game Data this Function return data function Game_Data_Two($id, $data) { global $socket; $query = "SELECT * from zon_games where id=$id"; $row = mysqli_fetch_assoc(mysqli_query($socket, $query)); return $row[$data]; } // Secure Data function Secure_DATA($d) { global $socket; return htmlspecialchars(mysqli_real_escape_string($socket, $d)); } // Checking Data From Databse exist or not function Exist_Data($table, $condition) { global $socket; $query = "select * from $table where $condition"; return mysqli_num_rows(mysqli_query($socket, $query)); } // Getting Game Likes function Game_Likes($data, $condition) { global $socket; $query = "select * from zon_likes where $condition"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); return $row[$data]; } // Getting All Configuraton Data of Site function Zon_Config($data) { global $socket; $query = "select * from zon_config"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); return $row[$data]; } // Play Newest function AutoPlays() { global $socket; global $site_url; $query = "select * from zon_games order by id desc limit 1"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); echo $site_url . "single/" . $row['id'] . "/" . $row['game_name']; } // Getting Category Data function Category_Data($data, $condition) { global $socket; $query = "select * from zon_category where $condition"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); if (!empty($row[$data])) { return $row[$data]; } else { return false; } } // Getting Likes Data function Game_likes_data($data) { global $socket; $current_user = User_Data_Two('id'); $query = "select * from zon_likes where user_id=$current_user"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); return $row[$data]; } // Getting Total Numbers of Rows of Games function Total_Games() { global $socket; $query = "select * from zon_games"; return mysqli_num_rows(mysqli_query($socket, $query)); } // Getting Total Numbers of Rows By Table Name function Total_Items ($table) { global $socket; $query = "select * from $table"; return mysqli_num_rows(mysqli_query($socket, $query)); } // check user is in database or not function ValidateFields($field, $var) { global $socket; $Validate = "select * from zon_users where $field='$var'"; return mysqli_num_rows(mysqli_query($socket, $Validate)); } // Getting Page Data From Database function page_data ($id, $data) { global $socket; $query = "select * from zon_pages where id=$id"; $run = mysqli_query($socket, $query); $row = mysqli_fetch_assoc($run); return $row[$data]; }PK �X�Z�I�)-: -: app_start.phpnu �[��� <?php session_start(); try { $socket = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); $con = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); if ($socket) { # empty code; } else { # error if connection is not established } } catch (Exeception $error) { if ($error) { echo 'Connection is not establish'; } } function LoadFile($name) { global $zon; $theme = $zon['config']['theme']; $path = "themes/$theme/layout/" . $name . ".phtml"; if (file_exists($path)) { ob_start(); require ($path); $content = ob_get_contents(); ob_end_clean(); return $content; } else { echo 'file not exists.' . $path . '\n'; } } function LoadFile2($name) { global $zon; $theme = $zon['config']['theme']; $path = $name; if (file_exists($path)) { ob_start(); require ($path); $content = ob_get_contents(); ob_end_clean(); return $content; } else { echo 'file not exists.' . $path . '\n'; } } function ZonConfig() { global $socket; $sql = $socket->query('SELECT * FROM ' . T_ZON_CONFIG); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function HomeFeedGames() { global $socket; $data = []; $s = "SELECT * FROM zon_games ORDER BY id DESC"; $q = $socket->query($s); while ($game = $q->fetch_assoc()) { if (count($data) != 201) { if ($game['is_featured'] == 1) { $data[] = $game; } if ($game['is_featured'] == 0) { $data[] = $game; } } // if (count($data) != 130) { // $data[] = $game; // } else { // if ($game['is_featured'] == 1) { // $data[] = $game; // die(); // } // } // if (count($data) != 170) { // $data[] = $game; // } else { // if ($game['is_featured'] == 1) { // $data[] = $game; // die(); // } // } // if (count($data) != 200) { // $data[] = $game; // } } return $data; } $zon = []; $zon['url'] = $_GET['url'] ?? ''; $zon['page'] = explode("/", $_GET['url'] ?? ''); $zon['config'] = ZonConfig(); $zon['user'] = getLoggedinUser(); // if (isset($_GET) && isset($_GET['theme'])) { // if ($_GET['theme'] === 'garud' || $_GET['theme'] === 'zontal') { // $_SESSION['theme'] = $_GET['theme']; // if (isset($_SESSION) && isset($_SESSION['theme'])) { // $zon['config']['theme'] = $_SESSION['theme']; // header("Location: ?"); // } // } // } // $zon['config']['theme'] = $_SESSION['theme'] ?? 'garud'; if (isset($_SESSION['Loggedin'])) { define("IsLoggedin", true); } else { define("IsLoggedin", false); } if (isset($_SESSION['is_admin_Loggedin'])) { define("IsAdmin", true); } else { define("IsAdmin", false); } function getLoggedinUser() { global $socket; if (isset($_SESSION['Loggedin']) && isset($_SESSION['Loggedin_user'])) { $user_i = $_SESSION['Loggedin_user']; $sql = "SELECT * FROM " . T_ZON_USERS . " WHERE username='$user_i' OR email='$user_i' "; $runned = mysqli_query($socket, $sql); $data = []; while ($row = $runned->fetch_assoc()) { $data = $row; } return $data; } } function DynamicSection() { global $socket; $sql = $socket->query('SELECT * FROM ' . T_ZON_SEC); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function GameByCategoryName($id, $limit) { global $socket; $name = getCategoryNameById($id); if ($limit !== '') { $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE game_category='$name' LIMIT $limit "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } } function GameByCategoryWise($name, $limit = 0) { global $socket; if ($limit !== 0) { $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE game_category='$name' LIMIT $limit "); } else { $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE game_category='$name'"); } $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getGame($limit) { global $socket; if ($limit !== '') { $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " ORDER BY id DESC LIMIT $limit "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } } function getCategoryNameById($id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_CATEGORY . " WHERE id=$id "); $data = $row = $sql->fetch_assoc(); return $data['name']; } function getFeaturedGames() { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_F_GAMES); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getGamesById($game_id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE id=$game_id "); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function getCategory($limit = 0) { global $socket; if ($limit !== 0) { $sql = $socket->query("SELECT * FROM " . T_ZON_CATEGORY . " LIMIT $limit "); } else { $sql = $socket->query("SELECT * FROM " . T_ZON_CATEGORY); } $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function num_rows($table, $con) { global $socket; $sql = $socket->query("SELECT * FROM $table WHERE $con ORDER BY id DESC "); $count = 0; while ($row = $sql->fetch_assoc()) { $count++; } return $count; } function getGamesByPopular($limit) { global $socket; $sql = $socket->query("SELECT MAX( game_played ) FROM " . T_ZON_GAMES . " $limit "); $s = $socket->query("SELECT * FROM " . T_ZON_GAMES . " $limit "); $data = []; $count = 0; while ($row = $sql->fetch_assoc()) { $data[] = $row; $count++; } $data2 = []; if ($count <= 4) { while ($r = $s->fetch_assoc()) { $data2[] = $r; } } return $data2; } function getBlogs() { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_BLOGS . " ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function tabActivation($page, $class) { global $zon; if (isset($zon['page'][0]) && $zon['page'][0] == $page) { echo $class; } } function AutoPlay() { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " ORDER BY id DESC "); $game_len = count(mysqli_fetch_all($sql)); $game_id = rand(1, $game_len); if (num_rows(T_ZON_GAMES, "id=$game_id") > 0) { $game_id = rand(1, $game_len); } $game_sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE id=$game_id ORDER BY id DESC "); $data = []; while ($row = $game_sql->fetch_assoc()) { $data = $row; } return $data; } function getAd($offset, $d) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_ADS . " LIMIT $offset "); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data[$d]; } function getAdById($id, $d) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_ADS . " WHERE id=$id ORDER BY id DESC"); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data[$d]; } function makeSlug($v) { $e = strtolower($v); $e = str_replace(" ", "-", $e); $e = urlencode($e); return $e; } function blogById($id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_BLOGS . " WHERE id=$id ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function IsGame($slug) { $game_name = urldecode(str_replace("-", " ", $zon['page'][1])); $data = dataBy("SELECT * FROM zon_games WHERE game_name='$game_name'"); if(count($data) > 0) { return true; } else { return false; } } function getTitle() { global $zon; if ($zon['page'][0] == 'autoplay') { echo "AutoPlay - Play Random Games"; } else if ($zon['page'][0] == 'games') { echo $zon['config']['games_title']; } else if ($zon['page'][0] == 'all-games') { echo $zon['config']['games_title']; } else if ($zon['page'][0] == 'popular-games' || ($zon['page'][0] == 'archive' && $zon['page'][1] == 'popular')) { echo $zon['config']['games_title']; } else if (isCategory($zon['page'][0])) { // for category $category_name = str_replace("-", " ", trim(urldecode($zon['page'][0]))); $data = dataBy("SELECT * FROM zon_category WHERE name='$category_name'")[0]; $category_title = $zon['config']['category_title']; $title = str_replace("[name]", $data['name'], $category_title); echo $title; } else if ($zon['page'][0] == 'blogs') { echo "Blogs"; } else if ($zon['page'][0] == 'g' && count($zon['page']) == 2) { $play_title = $zon['config']['play_title']; $game_name = str_replace("-", " ", $zon['page'][1]); $game = dataBy("SELECT * FROM zon_games WHERE game_name='$game_name'")[0]; $title = str_replace("[name]", $game['game_name'], $play_title); echo $title; } else if ($zon['page'][0] == 'blog') { $blog = blogById($zon['page'][2]); echo $blog['blog_title']; } else if ($zon['page'][0] == 'login') { echo "Login"; } else if ($zon['page'][0] == 'register') { echo "Register"; } else if ($zon['page'][0] == 'c') { $slug = str_replace("-", " ", $zon['page'][1]); $page = getPageBySlug(urldecode($slug)); echo $page['title']; } else if ($zon['page'][0] == '') { echo $zon['config']['site_title']; } else if (isset($zon['page'][0]) && num_rows(T_ZON_USERS, "username='" . $zon['page'][0] . "'")) { $username = $zon['user']['username']; $pro_title = $zon['config']['profile_title']; $title = str_replace("[name]", $username, $pro_title); echo $title; } else { echo "404 Page Not Found"; } } function getPages() { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_PAGES . " ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getPageById($id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_PAGES . " WHERE id=$id ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function getPageBySlug($slug) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_PAGES . " WHERE title='$slug' ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function getGamesByQuery($query, $limit) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_GAMES . " WHERE game_name LIKE '%$query%' LIMIT $limit "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getCommentsByGameId($id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_COMMENTS . " WHERE game_id=$id ORDER BY id DESC "); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getUserDataById($id) { global $socket; $sql = $socket->query("SELECT * FROM " . T_ZON_USERS . " WHERE id=$id"); $data = []; while ($row = $sql->fetch_assoc()) { $data = $row; } return $data; } function redirect($path, $full = 0) { global $site_url; $p = $path; if ($full == 1) { $p = $site_url . $path; } else { $p = $path; return $p; } echo "<script>window.location.href = '$p'</script>"; } function getUserGame($user_id) { global $socket; $sql = $socket->query("SELECT *, zon_games.id FROM zon_games LEFT JOIN zon_likes ON zon_games.id=zon_likes.game_id WHERE zon_likes.user_id=$user_id"); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function getUserComments($user_id) { global $socket; $sql = $socket->query("SELECT *, zon_comments.id FROM zon_comments LEFT JOIN zon_users ON zon_users.id=zon_comments.user_id WHERE zon_comments.user_id=$user_id"); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function add_views($game_id) { global $socket; mysqli_query($socket, "UPDATE " . T_ZON_GAMES . " SET game_played=game_played+1 WHERE id=$game_id"); } function dataBy($query) { global $socket; $sql = $socket->query($query); $data = []; while ($row = $sql->fetch_assoc()) { $data[] = $row; } return $data; } function formatNumber($num) { if ($num >= 1000000) { return number_format($num / 1000000, 1) . 'm'; } elseif ($num >= 1000) { return number_format($num / 1000, 1) . 'k'; } else { return $num; } } function isCategory($name) { $n = str_replace("-", " ", urldecode($name)); if (num_rows(T_ZON_CATEGORY, "name='$n'")) { return true; } else { return false; } } function clearText($value) { $v = str_replace(":", "", $value); $v = str_replace("'", "", $v); $v = str_replace(",", "", $v); $v = str_replace('"', "", $v); $v = str_replace(';', "", $v); $v = str_replace('-', "", $v); $v = str_replace('_', "", $v); return $v; }PK �X�Z�� constant.phpnu �[��� <?php define('T_ZON_SEC', 'zon_section'); define('T_ZON_CONFIG', 'zon_config'); define('T_ZON_GAMES', 'zon_games'); define('T_ZON_CATEGORY', 'zon_category'); define('T_ZON_F_GAMES', 'zon_featured_games'); define('T_ZON_BLOGS', 'zon_blog'); define('T_ZON_ADS', 'zon_ads'); define('T_ZON_PAGES', 'zon_pages'); define('T_ZON_COMMENTS', 'zon_comments'); define('T_ZON_USERS', 'zon_users'); define('T_ZON_LIKES', 'zon_likes'); define('T_ZON_REPORTS', 'zon_report'); define("T_ZON_DISLIKES", "zon_unlikes");PK PZ�Z%\�, , header.phpnu �[��� <?php // session_start(); ?> <!DOCTYPE html> <html lang="en" class="dark:bg-zinc-800"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="robots" content="noindex, nofollow"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php if (!empty($page)) { ?> <title> <?php echo $page ?> </title> <?php } else { ?> <title> <?php echo Zon_Config('site_name') ?> </title> <?php } ?> <link rel="stylesheet" href="<?php echo $site_url ?>admin/assets/css/bootstrap.min.css"> <link rel="stylesheet" href="<?php echo $site_url ?>admin/assets/css/style.css"> <link rel="stylesheet" href="<?php echo $site_url ?>admin/assets/css/rte_theme_default.css"> <link rel="stylesheet" href="<?php echo $site_url ?>admin/assets/vendor/bootstrap-icons/bootstrap-icons.css"> <link rel="shortcut icon" href="<?php echo $site_url ?>static/img/logo/<?php echo Zon_Config('site_favicon') ?>" type="image/x-icon"> <script src="<?php echo $site_url ?>js/tailwind.js"></script> <script src="https://cdn.ckeditor.com/ckeditor5/37.0.1/classic/ckeditor.js"></script> <script src="<?php echo $site_url ?>admin/assets/js/rte.js"></script> </head> <div class="mx-2"> <div class="container"> <?php if (Zon_Config('auto_fetch_all_games_fetched') == 1) { ?> <div id="fetched_alert" class="bg-blue-200 relative text-xs capitalize flex gap-4 rounded-md text-blue-400 font-bold py-2.5 px-4 mt-2"> <i class="bi bi-info-circle-fill"></i> All games have been fetched from your ( <?php echo Zon_Config('auto_fetch_game_publisher') ?> ) <button onclick="this.parentNode.classList.add('hidden'), localStorage.setItem('fetched_alert', 1)" class="close-button font-bold text-lg top-[4px] absolute px-1 right-[20px]">×</button> </div> <?php } ?> <?php if (is_dir("../install")) { ?> <div class="bg-red-200 text-xs capitalize flex gap-4 rounded-md text-red-500 font-bold py-2.5 px-4 mt-4"> <i class="bi bi-info-circle-fill"></i> Please delete (./install) folder for security reason. </div> <?php } ?> </div> <script> if (localStorage.getItem('fetched_alert') == 1) { document.getElementById("fetched_alert").classList.add("hidden"); } </script> </div>PK PZ�Z����� � sidebar.phpnu �[��� <?php // session_start(); if (!isset($_SESSION['admin-Loggedin']) && !isset($_SESSION['is_admin_Loggedin'])) { @header("location: ../login"); // echo "<script>window.location.href='./login.php';</script>"; } ///include("config.php"); ?> <div class="sidebar sticky w-[350px] h-[100vh]"> <style> .sidebar { position: sticky; top: 0; } .colorpick-eyedropper-input-trigger { display: none; } /* .main { max-width: 400px !important; } */ body { max-width: 1000px; margin: auto; } .container { max-width: 1000px; margin: auto; } .sidebar a { white-space: nowrap; } </style> <!-- <div class="logo px-4 py-6"> --> <!-- <a href="<?php echo $site_url ?>"> <h3 class="fw-bold text-2xl dark:text-gray-100 text-center uppercase text-gray-600 "><?php echo Zon_Config('site_name') ?></h3> </a> --> <!-- </div> --> <?php $zon['page'][0] = explode("/", $_SERVER['PHP_SELF'])[2] ?? 'index.php'; ?> <ul class="list px-4 mt-2"> <li class="<?php if($zon['page'][0] === 'index.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="index.php"><span class="bi-speedometer2 mr-2"></span> Dashboard</a></li> <li class="text-gray-500 hover:text-gray-700 my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="/" target="_blank"><span class="bi-house mr-2"></span> Home</a></li> <li class="<?php if($zon['page'][0] === 'games.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="games.php"><span class="bi-controller mr-2"></span> Games</a></li> <li class="<?php if($zon['page'][0] === 'featured_games.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="featured_games.php"><span class="bi-stickies mr-2"></span> Featured Games</a></li> <li class="<?php if($zon['page'][0] === 'categories.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="categories.php"><span class="bi-columns-gap mr-2"></span> Categories</a></li> <li class="<?php if($zon['page'][0] === 'users.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="users.php"><span class="bi-person mr-2"></span> Users</a></li> <!-- <li class="<?php if($zon['page'][0] === 'comments.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="comments.php"><span class="bi-chat-square-text mr-2"></span> Comments</a></li> --> <li class="<?php if($zon['page'][0] === 'pages.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="pages.php"><span class="bi-collection mr-2"></span> Pages</a></li> <!-- <li class="<?php if($zon['page'][0] === 'blog.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="blog.php"><span class="bi-clipboard mr-2"></span> Blog</a></li> --> <li class="<?php if($zon['page'][0] === 'reports.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="reports.php"><span class="bi-bug mr-2"></span> Reports</a></li> <!-- <li class="<?php if($zon['page'][0] === 'auto-fetch.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="auto-fetch.php"><span class="bi-arrow-repeat mr-2"></span> Auto Fetching</a></li> --> <!-- <li class="<?php if($zon['page'][0] === 'section.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="section.php"><span class="bi-grip-horizontal mr-2"></span> Sections</a></li> --> <!-- <li class="<?php if($zon['page'][0] === 'themes.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="themes.php"><span class="bi-palette mr-2"></span> Themes</a></li> --> <li class="<?php if($zon['page'][0] === 'customize.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="customize.php"><span class="bi-palette2 mr-2"></span> Customize</a></li> <li class="<?php if($zon['page'][0] === 'tools.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="tools.php"><span class="bi-tools mr-2"></span> Tools</a></li> <li class="<?php if($zon['page'][0] === 'advertisement.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="advertisement.php"><span class="bi-tv mr-2"></span> Advertisement</a></li> <li class="<?php if($zon['page'][0] === 'settings.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="settings.php"><span class="bi-gear mr-2"></span> Settings</a></li> <!-- <li class="<?php if($zon['page'][0] === 'update-script.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="update-script.php"><span class="bi-pause-fill mr-2"></span> Update</a></li> --> <li class="<?php if($zon['page'][0] === 'delete-games.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="delete-games.php"><span class="bi-trash mr-2"></span> Delete All Games</a></li> <li class="<?php if($zon['page'][0] === 'logout.php') { echo "bg-blue-600 text-white hover:text-white"; } else { ?> text-gray-500 hover:text-gray-700 <?php } ?> my-1 px-3 list-style-none"><a class="text-docoration-none py-2 block text-[13px] " href="logout.php"><span class="bi-door-open mr-2"></span> logout</a></li> </ul> </div>PK PZ�Z!.h� � ajax/gamesbyquery.phpnu �[��� <?php include ('../../../config.php'); include ('../../../app/includes/constant.php'); include ('../../../app/includes/app_start.php'); $message = ''; if (isset ($_POST) && !empty ($_POST)) { $query = $_POST['query']; $sql = "SELECT * FROM zon_games WHERE game_name LIKE '%$query%' LIMIT 20 "; $run = mysqli_query($socket, $sql); while ($row = mysqli_fetch_assoc($run)) { if ($row) { // if ($row['game_banner_url'] !== '') { ?> <div class="game-box"> <div class="flex items-center justify-between"> <div class="flex items-center gap-3"> <img class="h-10 w-10 rounded-md" src="<?= $row['game_image_url'] ?>" /> <div class="details"> <span class="text-lg font-bold "> <?= $row['game_name'] ?> </span> <br> <span class="text-gray-400 text-sm "> <?= $row['game_category'] ?> </span> </div> </div> <input type="checkbox" value="<?= $row['id'] ?>" class="h-7 outline-auto focus:outline-blue-500 rounded-lg w-7" name="game_id[]" /> </div> </div> <?php // } else { // $message = 'game not able to add in featured game.'; // } } else { echo 'game not found'; } } } else { echo "Search your game"; } echo $message; ?>PK PZ�Z6s^�, , config.phpnu �[��� <?php require '../config.php'; // $host_name = 'localhost'; // $sql_db_user = 'root'; // $sql_db_pass = ''; // $sql_db_name = 'zontal'; // $con = mysqli_connect($host_name, $sql_db_user, $sql_db_pass, $sql_db_name); // $site_url = "http://localhost/Zontal/"; ?>PK PZ�Z��y[� � footer.phpnu �[��� <script src="<?php echo $site_url?>admin/assets/js/main.js"></script> <script> const DROP_BUTTON=document.querySelectorAll(".drop_btn");null!==DROP_BUTTON&&DROP_BUTTON.forEach(e=>{e.addEventListener("click",()=>{let t=e.getAttribute("data-target");document.querySelector(t).classList.toggle("show")})});const TAB_BUTTON=document.querySelectorAll(".tab-button"),TAB=document.querySelectorAll(".tab");function ActiveButton(){TAB_BUTTON.forEach(e=>{e.classList.remove("bg-blue-500"),e.classList.remove("text-gray-100"),e.classList.add("text-gray-500")}),this.classList.add("bg-blue-500"),this.classList.replace("text-gray-500","text-gray-100")}null!==TAB_BUTTON&&TAB_BUTTON.forEach(e=>{e.addEventListener("click",t=>{TAB.forEach(e=>{e.classList.add("hidden"),e.classList.remove("show")});let l=e.getAttribute("data-target");document.querySelector(l).classList.remove("hidden"),document.querySelector(l).classList.toggle("block")})}),null!==TAB_BUTTON&&TAB_BUTTON.forEach(e=>{e.addEventListener("click",ActiveButton)});const USER_PROFILE_UPLOAD_IMAGE_BUTTON=document.getElementById("pic_upload_button");null!==USER_PROFILE_UPLOAD_IMAGE_BUTTON&&USER_PROFILE_UPLOAD_IMAGE_BUTTON.addEventListener("click",()=>{document.getElementById("user_profile_pic").click()});const FILE_TYPE=document.getElementById("File_Type");null!==FILE_TYPE&&(FILE_TYPE.addEventListener("change",()=>{("File"===FILE_TYPE.value||"URL"===FILE_TYPE.value)&&"null"!==FILE_TYPE.value&&(console.warn(FILE_TYPE.value),"File"===FILE_TYPE.value?document.getElementById("FILE_IMAGE").classList.remove("hidden"):document.getElementById("FILE_IMAGE").classList.add("hidden"),"URL"===FILE_TYPE.value?document.getElementById("URL_IMAGE").classList.remove("hidden"):document.getElementById("URL_IMAGE").classList.add("hidden"))}),window.addEventListener("load",()=>{null!==FILE_TYPE&&("File"===FILE_TYPE.value||"URL"===FILE_TYPE.value)&&"null"!==FILE_TYPE.value&&(console.warn(FILE_TYPE.value),"File"===FILE_TYPE.value?document.getElementById("FILE_IMAGE").classList.remove("hidden"):document.getElementById("FILE_IMAGE").classList.add("hidden"),"URL"===FILE_TYPE.value?document.getElementById("URL_IMAGE").classList.remove("hidden"):document.getElementById("URL_IMAGE").classList.add("hidden"))}));const CATEGORY_INPUT=document.getElementById("category_name");null!==CATEGORY_INPUT&&CATEGORY_INPUT.addEventListener("keyup",e=>{var t=e.target.value;document.getElementById("category_slug").innerHTML=t}); console.log(CATEGORY_INPUT) </script> <script> document.querySelectorAll("body").forEach((e) => { e.classList.add("dark:bg-[#121317]"); }); document.querySelectorAll("input, select").forEach((e) => { e.classList.add("dark:bg-zinc-900"); }); </script>PK �[�Z�KH�) ) game_list.phpnu �[��� <?php // Deprecated since v1.6.4 replaced with theme-functions.php // However, this script maybe still used in admin area function get_game_list($type, $amount=12, $page=0, $count=true){ if($type == 'new'){ $data = Game::getList( $amount, 'id DESC', $page, $count ); return $data; } elseif($type == 'random'){ $data = Game::getList( $amount, 'RAND()', $page, $count ); return $data; } elseif($type == 'popular'){ $data = Game::getList( $amount, 'views DESC', $page, $count ); return $data; } elseif($type == 'likes'){ $data = Game::getList( $amount, 'upvote DESC', $page, $count ); return $data; } elseif($type == 'trending'){ // Last 7 days trending $data = []; $conn = open_connection(); $date = new \DateTime('now'); // Get last 7 days $date->sub(new DateInterval('P7D')); $sql = "SELECT * FROM trends WHERE created >= '{$date->format('Y-m-d')}'"; $st = $conn->prepare($sql); $st->execute(); $row = $st->fetchAll(PDO::FETCH_ASSOC); $list = array(); if(count($row)){ foreach ($row as $item) { if(isset($list[$item['slug']])){ $list[$item['slug']] += (int)$item['views']; } else { $list[$item['slug']] = (int)$item['views']; } } arsort($list); $i = 0; foreach ($list as $slug => $views) { if($i < $amount){ $game = Game::getBySlug($slug); if($game){ $data[] = $game; } } $i++; } } return (array( "results" => $data, "totalRows" => count($list), "totalPages" => 1 )); } } function get_collection($name, $amount = 12){ $data = Collection::getListByCollection( $name, $amount ); return $data; } function get_game_list_category($cat_name, $amount, $page=0){ $cat_id = Category::getIdByName( $cat_name ); $data = Category::getListByCategory( $cat_id, $amount, $page ); return $data; } function get_game_list_category_id($cat_id, $amount, $page=0){ $data = Category::getListByCategory( $cat_id, $amount, $page ); return $data; } function get_game_list_categories($arr, $amount, $page=0, $random = true){ $ids = array(); foreach ($arr as $cat_name) { $cat_id = Category::getIdByName( $cat_name ); array_push($ids, $cat_id); } $data = Category::getListByCategories( $ids, $amount, $page, $random ); return $data; } ?>PK �[�Z��y y page-post.phpnu �[��� <?php defined('POST_ACTIVE') or die('Posts plugin not installed.'); require_once( TEMPLATE_PATH . '/functions.php' ); $post = null; if ( isset($_GET['slug']) ) { $_GET['slug'] = htmlspecialchars($_GET['slug']); if(strlen($_GET['slug']) >= 2){ $post = Post::getBySlug( $_GET['slug'] ); } } function _is_post_page_valid(){ // Used to validate the pagination // Set to 404 if current page is not exist // This script is inefficient, reason: Similar code is also executed in theme post-list.php (Double call) // But at least all themes is applied this rules instead of update all themes or possibly unsupported method for old theme global $url_params; $cur_page = 1; if(isset($url_params[1])){ $_GET['page'] = $url_params[1]; if(!is_numeric($_GET['page'])){ $_GET['page'] = 1; } } if(isset($_GET['page'])){ $cur_page = htmlspecialchars($_GET['page']); if(!is_numeric($cur_page)){ $cur_page = 1; } } $items_per_page = get_setting_value('post_results_per_page'); $data = Post::getList($items_per_page, 'created_date DESC', $items_per_page*($cur_page-1)); $total_posts = $data['totalRows']; $total_page = $data['totalPages']; $posts = $data['results']; if(count($posts) >= 1){ return true; } else { return false; } } if($post){ if(PRETTY_URL){ if(count($url_params) >= 3){ // Post page only contains 3 parameter max // Show 404 screen require( ABSPATH . 'includes/page-404.php' ); return; } } if($lang_code != 'en'){ // If use translation (localization) // Begin translate the content if has translation $translated_fields = get_content_translation('post', $post->id, $lang_code, 'all'); if(!is_null($translated_fields)){ $post->title = isset($translated_fields['title']) ? $translated_fields['title'] : $post->title; $post->content = isset($translated_fields['content']) ? $translated_fields['content'] : $post->content; } } $page_title = $post->title . ' | '.SITE_TITLE; $meta_description = str_replace(array('"', "'"), "", strip_tags($post->content)); require( TEMPLATE_PATH . '/post.php' ); } else { if(file_exists( TEMPLATE_PATH . '/post-list.php' )){ if(PRETTY_URL){ if(count($url_params) > 2){ // Post list page can contains 3 parameter max // Show 404 screen require( ABSPATH . 'includes/page-404.php' ); return; } if(isset($url_params[1]) && !is_numeric($url_params[1])){ // Page number should be a number // Show 404 screen require( ABSPATH . 'includes/page-404.php' ); return; } } if(_is_post_page_valid()){ $page_title = _t('Posts') . ' | '.SITE_TITLE; $meta_description = _t('Posts') .' | '.SITE_DESCRIPTION; require( TEMPLATE_PATH . '/post-list.php' ); } else { require( ABSPATH . 'includes/page-404.php' ); } } else { require( ABSPATH . 'includes/page-404.php' ); } } ?>PK �[�Z�NY�j j user.phpnu �[��� <?php require('../config.php'); require('../init.php'); if($login_user){ if(isset($_POST['action'])){ if(ADMIN_DEMO && $login_user->role == 'admin'){ $status = 'error'; $info = 'Demo mode! Can\'t change Admin user profile'; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect'].'&status='.$status.'&info='.$info); } return; } if($_POST['action'] == 'upload_avatar'){ if(!verify_csrf_token()) die('ERR CSRF'); $status = ''; $message = ''; if(isset($_FILES["avatar"])){ if(!file_exists(ABSPATH . 'images/avatar')){ mkdir('../images/avatar', 755, true); } $uploadOk = 1; $fileType = strtolower(pathinfo(basename($_FILES["avatar"]["name"]),PATHINFO_EXTENSION)); $target_file = ABSPATH . 'images/avatar/'.$login_user->username.'.png'; $check = getimagesize($_FILES["avatar"]["tmp_name"]); if($check) { //echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { //echo "File is not an image."; $uploadOk = 0; } if ($uploadOk && $_FILES["avatar"]["size"] > 500000) { //echo "Sorry, your file is too large. max 500kb"; $uploadOk = 0; } if($fileType != "jpg" && $fileType != "png" && $fileType != "jpeg") { //echo "Sorry, only JPG, JPEG, PNG files are allowed."; $uploadOk = 0; } if ($uploadOk == 0) { //echo "Sorry, your file was not uploaded."; } else { //Convert to PNG $conver_image = $_FILES['avatar']['tmp_name']; switch ($fileType) { case 'jpg': case 'jpeg': $set_image = imagecreatefromjpeg($conver_image); break; case 'gif': $set_image = imagecreatefromgif($conver_image); break; case 'png': $set_image = imagecreatefrompng($conver_image); break; } imagepng($set_image, $conver_image); if (move_uploaded_file($_FILES["avatar"]["tmp_name"], $target_file)) { //echo "The file ". basename( $_FILES["avatar"]["name"]). " has been uploaded."; resize_avatar($target_file); $status = 'success'; } else { echo "Sorry, there was an error uploading your file."; } } } if(!$uploadOk){ $status = 'error'; $message = 'Upload failed!'; } else { $status = 'success'; $message = 'Avatar uploaded!'; } $_SESSION['alert'] = [ 'status' => $status, 'message' => $message ]; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect']); } } elseif($_POST['action'] == 'edit_profile'){ if(!verify_csrf_token()) die('ERR CSRF'); $status = ''; $message = ''; $error = false; if($_POST['email']){ if( $_POST['email'] != $login_user->email){ if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $error = true; $status = 'error'; $message = 'Email not valid!'; } else { if(User::getByEmail($_POST['email'])){ $error = true; $status = 'error'; $message = 'Email already exist!'; } } } } $login_user->bio = esc_string($_POST['bio']); if(!$error){ $login_user->birth_date = $_POST['birth_date']; $login_user->gender = $_POST['gender']; $login_user->email = $_POST['email']; $login_user->update(); $status = 'success'; $message = 'Profile updated!'; } $_SESSION['alert'] = [ 'status' => $status, 'message' => $message ]; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect']); } } elseif($_POST['action'] == 'change_password'){ if(!verify_csrf_token()) die('ERR CSRF'); $status = ''; $message = ''; $error = false; $new_password = str_replace(' ','',$_POST['new_password']); if($new_password != $_POST['new_password']){ $error = true; $status = 'error'; $message = 'Password must not contain any space!'; } if(!$error){ if(!password_verify($_POST['cur_password'], get_current_user_hash())){ $error = true; $status = 'error'; $message = 'Incorrect password!'; } } if(!$error){ $login_user->password = password_hash($_POST['new_password'], PASSWORD_DEFAULT); $login_user->update(); $status = 'success'; $message = 'Password updated!'; } $_SESSION['alert'] = [ 'status' => $status, 'message' => $message ]; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect']); } } elseif($_POST['action'] == 'choose_avatar'){ if(!verify_csrf_token()) die('ERR CSRF'); $status = ''; $message = ''; $error = false; if(file_exists(ABSPATH.'images/avatar/default/'.$_POST['avatar'].'.png')){ $login_user->avatar = $_POST['avatar']; $login_user->update(); if(file_exists(ABSPATH.'images/avatar/'.$login_user->username.'.png')){ unlink('../images/avatar/'.$login_user->username.'.png'); } } else { $status = 'error'; $message = 'Failed!'; $error = true; } if(!$error){ $status = 'success'; $message = 'Avatar updated!'; } $_SESSION['alert'] = [ 'status' => $status, 'message' => $message ]; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect']); } } elseif($_POST['action'] == 'delete_account'){ if(!verify_csrf_token()) die('ERR CSRF'); $status = ''; $message = ''; $error = false; $cur_password = str_replace(' ','',$_POST['cur_password']); if($cur_password != $_POST['cur_password']){ $error = true; $status = 'error'; $message = 'Password must not contain any "space"!'; } if(!$error){ if(!password_verify($_POST['cur_password'], get_current_user_hash())){ $error = true; $status = 'error'; $message = 'Incorrect password!'; } } if(!$error){ $login_user->delete( $_POST['cur_password'] ); CA_Auth::delete(); unset( $_SESSION['username'] ); header('Location: '.DOMAIN); return; } if($error){ $_SESSION['alert'] = [ 'status' => $status, 'message' => $message ]; if(isset($_POST['redirect'])){ header('Location: '.$_POST['redirect']); } } } } } function resize_avatar($path, $rs_width=100, $rs_height=100){ if(file_exists($path)){ $x = getimagesize($path); $width = $x['0']; $height = $x['1']; $img = imagecreatefrompng($path); $img_base = imagecreatetruecolor($rs_width, $rs_height); imagecopyresampled($img_base, $img, 0, 0, 0, 0, $rs_width, $rs_height, $width, $height); imagepng($img_base, $path, 9); } } ?>PK �[�Zjr�|1 |1 cron.phpnu �[��� <?php if(!defined('CRON')){ die('p'); } $data = get_pref('cron-job'); define("LIMIT", 3); $game_count = 0; $log_txt = ""; if(!is_null($data)){ $data = json_decode($data, true); if(isset($data['auto-post'])){ $task_date = $data['auto-post']['date']; $cur_date = date("Y-m-d H:i:s"); if($cur_date >= $task_date){ $datetime1 = date_create($cur_date); $datetime2 = date_create($task_date); $interval = date_diff($datetime1, $datetime2); $diff = $interval->format('%d'); if($diff < 4){ $new_task_date = date('Y-m-d H:i:s', strtotime('+8 hours', strtotime(date('Y-m-d H:i:s')))); $data['auto-post']['date'] = $new_task_date; update_option('cron-job', json_encode($data)); auto_add_games($data); } else { //More than 4 days inactive echo 'remove'; unset($data['auto-post']); update_option('cron-job', json_encode($data)); } } else { if(!defined('CRON')){ echo 'on the way'; } } } else { //Inactive } } function auto_add_games($data){ if(!ADMIN_DEMO){ add_to_log(); $data['auto-post']['last-status'] = 'null'; $url = 'https://api.cloudarcade.net/fetch-auto.php?action=fetch&code='. check_purchase_code(); $url .= '&data='.json_encode($data['auto-post']['list']); $url .= '&ref='.DOMAIN.'&v='.VERSION; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $curl = curl_exec($ch); curl_close($ch); $game_data = json_decode($curl, true); if(isset($game_data['error'])){ add_to_log('Failed auto add games: '.$curl); } else if($game_data){ foreach ($game_data as $a => $b) { foreach ($b as $item) { $item['tags'] = ''; x_add_game2($item); } } } else { add_to_log('Failed auto add games. Null'); } write_log(); } } function x_add_game2($data){ $_POST = $data; // Copied from request.php add_game() $ref = ''; if(isset($_POST['ref'])) $ref = $_POST['ref']; $_POST['description'] = html_purify($_POST['description']); $_POST['instructions'] = html_purify($_POST['instructions']); if($_POST['source'] == 'self' || $_POST['source'] == 'remote'){ if(!isset($_POST['published'])){ $_POST['published'] = false; } } if(!isset($_POST['is_mobile'])){ $_POST['is_mobile'] = false; } $redirect = 0; if(isset($_POST['redirect'])){ $redirect = $_POST['redirect']; } if(isset($_POST['slug'])){ $slug = esc_slug($_POST['slug']); } else { $slug = esc_slug(strtolower(str_replace(' ', '-', $_POST["title"]))); } $slug = preg_replace('/-{2,}/', '-', $slug); $slug = trim($slug, '-'); $_POST['slug'] = $slug; if(is_array($_POST['category'])){ // Array category is not allowed // Convert to string $cats = ''; $i = 0; $total = count($_POST['category']); foreach ($_POST['category'] as $key) { $cats = $cats.$key; if($i < $total-1){ $cats = $cats.','; } $i++; } $_POST['category'] = $cats; } if($_POST['category'] == '' || $_POST['category'] == ' '){ $_POST['category'] = 'Other'; } // Begin category filter if(file_exists(ABSPATH."content/plugins/category-filter")){ // Plugin exist $cats = ''; $categories = commas_to_array($_POST['category']); $i = 0; $total = count($categories); foreach ($categories as $key) { $cats = $cats.category_name_filtering($key); if($i < $total-1){ $cats = $cats.','; } $i++; } $_POST['category'] = $cats; } $game = new Game; $check=$game->getBySlug($slug); $status='failed'; if(is_null($check)){ if($ref != 'upload'){ // Come from fetch games if(IMPORT_THUMB){ // Check if webp is activated $use_webp = get_setting_value('webp_thumbnail'); import_thumbnail($_POST['thumb_2'], $slug, 2); $name = basename($_POST['thumb_2']); $extension = pathinfo($_POST['thumb_2'], PATHINFO_EXTENSION); $_POST['thumb_2'] = '/thumbs/'.$slug.'_2.'.$extension; if($use_webp){ $file_extension = pathinfo($_POST['thumb_2'], PATHINFO_EXTENSION); $_POST['thumb_2'] = str_replace('.'.$file_extension, '.webp', $_POST['thumb_2']); } // import_thumbnail($_POST['thumb_1'], $slug, 1); $name = basename($_POST['thumb_1']); $extension = pathinfo($_POST['thumb_1'], PATHINFO_EXTENSION); $_POST['thumb_1'] = '/thumbs/'.$slug.'_1.'.$extension; if($use_webp){ $file_extension = pathinfo($_POST['thumb_1'], PATHINFO_EXTENSION); $_POST['thumb_1'] = str_replace('.'.$file_extension, '.webp', $_POST['thumb_1']); } if( SMALL_THUMB ){ $output = pathinfo($_POST['thumb_2']); $_POST['thumb_small'] = '/thumbs/'.$slug.'_small.'.$output['extension']; if($use_webp){ $file_extension = pathinfo($_POST['thumb_2'], PATHINFO_EXTENSION); $_POST['thumb_small'] = str_replace('.'.$file_extension, '.webp', $_POST['thumb_small']); generate_small_thumbnail($_POST['thumb_2'], $slug); } else { generate_small_thumbnail($_POST['thumb_2'], $slug); } } } } $game->storeFormValues( $_POST ); $game->insert(); $status='added'; // $cats = commas_to_array($_POST['category']); if(is_array($cats)){ //Add new category if not exist $length = count($cats); for($i = 0; $i < $length; $i++){ $_POST['name'] = $cats[$i]; $category = new Category; $exist = $category->isCategoryExist($_POST['name']); if($exist){ // } else { unset($_POST['slug']); $_POST['description'] = ''; $category->storeFormValues( $_POST ); $category->insert(); } $category->addToCategory($game->id, $category->id); } } } else{ $status='exist'; } $keys =['title', 'slug', 'description', 'instructions', 'width', 'height', 'category', 'thumb_1', 'thumb_2', 'url', 'tags']; if($status != 'added'){ if($_POST['source'] == 'self' || $_POST['source'] == 'remote'){ // Store current fields foreach ($keys as $item) { $_SESSION[$item] = (isset($_POST[$item])) ? $_POST[$item] : null; } } } else { // Successfully added // Clear last fields if(isset($_SESSION['title'])){ foreach ($keys as $item) { if(isset($_SESSION[$item])){ unset($_SESSION[$item]); } } } add_to_log('Game added - '.$_POST['source'].' - '.$slug); } if($status == 'exist'){ add_to_log('Game alredy exist - '.$_POST['source'].' - '.$slug); $status='exist'; } } function category_name_filtering($category_name){ // Specific function for "Category Filter" plugin if(true){ $json = get_pref("category-filter"); if($json){ $data = json_decode($json, true); foreach ($data as $key => $value) { if($key == $category_name){ return $value; } } } } return $category_name; } function generate_small_thumbnail($path, $slug){ // copied from admin-functions.php $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($path); $root_folder = explode ("/", $path); $output = "thumbs/" . $slug . "_small." . $path_info['extension']; if($path_info['extension'] == 'webp'){ // WEBP thumbnail $file_extension = pathinfo($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); imagecopyresized($new_img, $img, 0, 0, 0, 0, 160, 160, $width, $height); //output imagewebp($new_img, $parent_dir.$output, -1); // No compression } 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); // No compression 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){ // copied from admin-functions.php $parent_dir = dirname(__FILE__) . '/../'; // CloudArcade root / installation folder if($url) { if (!file_exists($parent_dir.'thumbs')) { mkdir($parent_dir.'thumbs', 0777, true); } $extension = pathinfo($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($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) { // copied from admin-functions.php $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 and create an image resource from it $remoteImage = curl_exec($ch); if($remoteImage !== false){ $image = imagecreatefromstring($remoteImage); if($image !== false){ $info = getimagesizefromstring($remoteImage); if ($info['mime'] == 'image/png'){ imageAlphaBlending($image, true); imageSaveAlpha($image, true); imagepng($image, $destination, 6); } else if($info['mime'] == 'image/jpg' || $info['mime'] == 'image/jpeg') { imagejpeg($image, $destination, 100); // No compression } else if($info['mime'] == 'image/gif') { imagegif($image, $destination); } imagedestroy($image); } else { echo 'Could not create image resource'; } } else { echo 'Could not download remote image'; } // Close the cURL resource curl_close($ch); } function add_to_log($msg = ""){ global $log_txt; if($msg == ""){ $log_txt .= "---- Executed - ".date('Y-m-d H:i:s'); } else { $log_txt .= $msg; } $log_txt .= PHP_EOL; } function write_log(){ global $log_txt; if($log_txt != ""){ $path = ABSPATH . PLUGIN_PATH . '/auto-publish'; if(file_exists($path . '/log.txt')){ $filesizeKB = filesize($path . '/log.txt') / 1024; if($filesizeKB >= 50){ file_put_contents($path . '/log_prev.txt', file_get_contents($path . '/log.txt')); unlink($path . '/log.txt'); } } if(file_exists($path)){ $full_log = ""; if(file_exists($path . '/log.txt')){ $full_log = file_get_contents($path . '/log.txt'); } $full_log = $log_txt.$full_log; file_put_contents($path . '/log.txt', $full_log); } } } ?>PK �[�Z�4fh� � page-game.phpnu �[��� <?php require_once( TEMPLATE_PATH . '/functions.php' ); // if ( !isset($_GET['slug']) || !$_GET['slug'] ) { // require( ABSPATH . 'includes/page-homepage.php' ); // return; // } if(count($url_params) != 2){ // The number of parameter is not match require( ABSPATH . 'includes/page-404.php' ); return; } $_GET['slug'] = htmlspecialchars($_GET['slug']); Game::update_views( $_GET['slug'] ); $game = Game::getBySlug( $_GET['slug'] ); if($game && !$game->published){ // This game is drafted if(is_login() && USER_ADMIN){ // Show message for admin user echo '<div class="alert alert-warning alert-draft" style="z-index: 1000;">The game has not been published yet and is currently in draft mode.</div>'; } else { $game = null; // Show 404 page for visitor } } if($game){ if($lang_code != 'en'){ // If use translation (localization) // Begin translate the content if has translation $translated_fields = get_content_translation('game', $game->id, $lang_code, 'all'); if(!is_null($translated_fields)){ $game->title = isset($translated_fields['title']) ? $translated_fields['title'] : $game->title; $game->description = isset($translated_fields['description']) ? $translated_fields['description'] : $game->description; $game->instructions = isset($translated_fields['instructions']) ? $translated_fields['instructions'] : $game->instructions; } } $page_title = $game->title . ' | '.SITE_DESCRIPTION; $meta_description = str_replace(array('"', "'"), "", strip_tags($game->description)); require( TEMPLATE_PATH . '/game.php' ); } else { require( ABSPATH . 'includes/page-404.php' ); } ?>PK �[�Z��u�Q Q load-class.phpnu �[��� <?php require_once( ABSPATH . CLASS_PATH . "/Page.php" ); require_once( ABSPATH . CLASS_PATH . "/Category.php" ); require_once( ABSPATH . CLASS_PATH . "/Game.php" ); require_once( ABSPATH . CLASS_PATH . "/User.php" ); require_once( ABSPATH . CLASS_PATH . "/Auth.php" ); require_once( ABSPATH . CLASS_PATH . "/Widget.php" ); ?>PK �[�Z-_ɦ � page-search.phpnu �[��� <?php require_once( TEMPLATE_PATH . '/functions.php' ); if(PRETTY_URL){ if(count($url_params) > 3 || count($url_params) < 2){ // Search page only contains 3 parameter max, // If more than that or less than 2, the url is not valid // Show 404 screen require( ABSPATH . 'includes/page-404.php' ); return; } if(isset($url_params[2]) && !is_numeric($url_params[2])){ // Page number should be a number // Show 404 screen require( ABSPATH . 'includes/page-404.php' ); return; } } $_GET['slug'] = htmlspecialchars(str_replace('-', ' ', $_GET['slug'])); $cur_page = 1; if(isset($url_params[2])){ $cur_page = (int)$url_params[2]; } $items_per_page = get_setting_value('search_results_per_page'); $data = Game::searchGame($_GET['slug'], $items_per_page, $items_per_page*($cur_page-1)); $games = $data['results']; $total_games = $data['totalRows']; $total_page = $data['totalPages']; $meta_description = _t('Search %a Games', $_GET['slug']).' | '.SITE_DESCRIPTION; $archive_title = _t('Search %a', $_GET['slug']); $page_title = _t('Search %a Games', $_GET['slug']).' | '.SITE_DESCRIPTION; require( TEMPLATE_PATH . '/search.php' ); ?>PK �[�Z�q�3 3 vote.phpnu �[��� <?php require( '../config.php' ); require( '../init.php' ); if(isset($_POST['vote']) && isset($_POST['action']) && isset($_POST['id'])){ $ip_address = getIpAddr(); $conn = open_connection(); $sql = "SELECT * FROM votelogs WHERE ip = :ip AND game_id = :game_id AND action = :action"; $st = $conn->prepare($sql); $st->bindValue(":ip", $ip_address, PDO::PARAM_STR); $st->bindValue(":game_id", $_POST['id'], PDO::PARAM_INT); $st->bindValue(":action", $_POST['action'], PDO::PARAM_STR); $st->execute(); $row = $st->fetch(PDO::FETCH_ASSOC); if(!$row){ if($_POST['action'] == 'upvote'){ Game::upvote($_POST['id']); if($login_user){ $login_user->like($_POST['id']); } } elseif ($_POST['action'] == 'downvote') { Game::downvote($_POST['id']); if($login_user){ $login_user->dislike($_POST['id']); } } // $sql = "INSERT INTO votelogs(ip,game_id,action) VALUES(:ip_address, :game_id, :action)"; $st = $conn->prepare($sql); $st->bindValue(":ip_address", $ip_address, PDO::PARAM_STR); $st->bindValue(":game_id", $_POST['id'], PDO::PARAM_INT); $st->bindValue(":action", $_POST['action'], PDO::PARAM_STR); $st->execute(); //Check count $sql = "SELECT * FROM votelogs"; $st = $conn->prepare($sql); $st->execute(); $count = $st->rowCount(); if($count > 120){ $sql = "DELETE FROM votelogs ORDER BY id ASC LIMIT 20"; $st = $conn->prepare($sql); $st->execute(); } } else { echo(' exist'); } } if(isset($_POST['favorite']) && isset($_POST['action']) && isset($_POST['id'])){ if($login_user){ $conn = open_connection(); $sql = "SELECT * FROM favorites WHERE user_id = :user_id AND game_id = :game_id LIMIT 1"; $st = $conn->prepare($sql); $st->bindValue(":user_id", $login_user->id, PDO::PARAM_INT); $st->bindValue(":game_id", $_POST['id'], PDO::PARAM_INT); $st->execute(); $row = $st->fetch(PDO::FETCH_ASSOC); if($row){ // Remove from favorite $sql = "DELETE FROM favorites WHERE user_id = :user_id AND game_id = :game_id LIMIT 1"; $st = $conn->prepare($sql); $st->bindValue(":user_id", $login_user->id, PDO::PARAM_INT); $st->bindValue(":game_id", $_POST['id'], PDO::PARAM_INT); $st->execute(); echo 'rm-favorite'; } else { // Add to favorite $sql = "INSERT INTO favorites(game_id,user_id) VALUES(:game_id, :user_id)"; $st = $conn->prepare($sql); $st->bindValue(":user_id", $login_user->id, PDO::PARAM_INT); $st->bindValue(":game_id", $_POST['id'], PDO::PARAM_INT); $st->execute(); echo 'add-favorite'; } } } ?>PK �[�Z�qX�� � page-user.phpnu �[��� <?php if(isset($url_params[1]) && $url_params[1] != ''){ $url_params[1] = htmlspecialchars($url_params[1]); } else { header( "Location: /" ); return; } $rank; if(file_exists(ABSPATH.'includes/rank.json')){ $rank = json_decode(file_get_contents(ABSPATH.'includes/rank.json'), true); $rank_values = array_values($rank); } $page_title = $url_params[1]; $meta_description = SITE_DESCRIPTION; require_once( TEMPLATE_PATH . '/functions.php' ); if(file_exists(TEMPLATE_PATH.'/user.php')){ require(TEMPLATE_PATH.'/user.php'); return; } //Start page require( TEMPLATE_PATH.'/includes/header.php' ); $is_visitor = true; $cur_user = null; if($login_user && $login_user->username === $url_params[1]){ $is_visitor = false; $cur_user = $login_user; } else { $cur_user = User::getByUsername(strtolower($url_params[1])); } if(isset($url_params[2]) && $url_params[2] == 'edit'){ $_GET['edit'] = true; } if($cur_user){ if(isset($_GET['edit']) && !$is_visitor){ //Edit user profile require( ABSPATH . 'includes/page-user-edit.php' ); } else { //User profile page require( ABSPATH . 'includes/page-user-profile.php' ); } } else { //User is not exist ?> <div class="container"> <p> <h2 class="text-center"><?php _e('User does not exist!') ?></h2> </p> </div> <?php } require( TEMPLATE_PATH.'/includes/footer.php' ); //End page ?>PK �[�Z��n: : banned-username.jsonnu �[��� ["admin","login","demo","administrator","super","default"]PK �[�Z̼��, , version.phpnu �[��� <?php define( "VERSION", "1.9.6" ); ?>PK �[�ZJSA� banned-words-comment.jsonnu �[��� ["just_sample","another_sample"]PK �[�ZJSA� banned-words.jsonnu �[��� ["just_sample","another_sample"]PK �[�ZF1U1�! �! api.phpnu �[��� <?php if (session_status() == PHP_SESSION_NONE) { session_start(); } require( '../config.php' ); require( '../init.php' ); if(isset($_POST['action'])){ $score = null; if($_POST['action'] === 'submit'){ if($login_user){ //Only logged in user $user_id = $login_user->id; if(isset($_POST['value']) && isset($_POST['ref'])){ $score = $_POST['value']; $score = base64_decode($score); $score = $score*1.33; if (strpos($score, '.')) { //invalid } else { $game = Game::getBySlug($_POST['ref']); if($game){ $game_id = $game->id; $conn = open_connection(); $sql = 'SELECT score FROM scores WHERE user_id = :user_id AND game_id = :game_id LIMIT 1'; $st = $conn->prepare($sql); $st->bindValue(":game_id", $game_id, PDO::PARAM_INT); $st->bindValue(":user_id", $user_id, PDO::PARAM_INT); $st->execute(); $row = $st->fetch(); if($row){ //Update existing data if($row['score'] < $score){ $sql = 'UPDATE scores SET score = :score WHERE user_id = :user_id AND game_id = :game_id LIMIT 1'; $st = $conn->prepare($sql); $st->bindValue(":game_id", $game_id, PDO::PARAM_INT); $st->bindValue(":user_id", $user_id, PDO::PARAM_INT); $st->bindValue(":score", $score, PDO::PARAM_INT); $st->execute(); } } else { $sql = 'INSERT INTO scores (game_id, user_id, score) VALUES ( :game_id, :user_id, :score)'; $st = $conn->prepare($sql); $st->bindValue(":game_id", $game_id, PDO::PARAM_INT); $st->bindValue(":user_id", $user_id, PDO::PARAM_INT); $st->bindValue(":score", $score, PDO::PARAM_INT); $st->execute(); } // $login_user->xp += 10; $login_user->update_xp(); // echo 'ok'; } } } else { die('x'); } } } elseif ($_POST['action'] === 'get_current_user'){ if($login_user){ $user = array(); $user['username'] = $login_user->username; $user['id'] = $login_user->id; $user['gender'] = $login_user->gender; $user['join_date'] = $login_user->join_date; $user['birth_date'] = $login_user->birth_date; echo json_encode($user); } } elseif ($_POST['action'] === 'get_user_score'){ //Get current user score if($login_user){ $user_id = $login_user->id; $game = Game::getBySlug($_POST['ref']); if(!$game){ die(); } $game_id = $game->id; $sql = "SELECT score FROM scores WHERE user_id = :user_id AND game_id = :game_id LIMIT 1"; $conn = open_connection(); $st = $conn->prepare($sql); $st->bindValue(":user_id", $user_id, PDO::PARAM_INT); $st->bindValue(":game_id", $game_id, PDO::PARAM_INT); $st->execute(); $res = $st->fetch(); if($res){ echo $res['score']; } else { echo 0; } } } elseif ($_POST['action'] === 'get_score_rank'){ //Get current user score rank if($login_user){ $user_id = $login_user->id; $game = Game::getBySlug($_POST['ref']); if(!$game){ die(); } $game_id = $game->id; $sql = "SELECT * FROM scores WHERE game_id = :game_id ORDER by score DESC LIMIT 5000"; $conn = open_connection(); $st = $conn->prepare($sql); $st->bindValue(":game_id", $game_id, PDO::PARAM_INT); $st->execute(); $row = $st->fetchAll(PDO::FETCH_ASSOC); if(count($row)){ $i = 0; foreach ($row as $item) { $i++; if($item['user_id'] == $user_id){ echo $i; return; } } } echo 0; } } elseif ($_POST['action'] === 'get_scoreboard'){ if(isset($_POST['conf'])){ $config = json_decode($_POST['conf'], true); $type = $config['type']; $amount = 10; if(isset($config['amount'])){ $amount = $config['amount']; } $sql = null; $game = null; $game_id = null; if(isset($_POST['ref'])){ //Old method $game = Game::getBySlug($_POST['ref']); if($game){ $game_id = $game->id; } } elseif(isset($_POST['game-id'])){ //New preferred method $game_id = (int)$_POST['game-id']; } if(!$game_id){ die(); } if($type === 'top-all'){ $sql = "SELECT * FROM scores ORDER by score DESC, created_date ASC LIMIT ".$amount; } elseif($type === 'top-all-day'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 DAY) ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top-all-week'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top-all-month'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 MONTH) ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top'){ $sql = "SELECT * FROM scores WHERE game_id = ".$game_id." ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top-day'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 DAY) AND game_id = ".$game_id." ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top-week'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND game_id = ".$game_id." ORDER by score DESC LIMIT ".$amount; } elseif($type === 'top-month'){ $sql = "SELECT * FROM scores WHERE created_date > DATE_SUB(NOW(), INTERVAL 1 MONTH) AND game_id = ".$game_id." ORDER by score DESC LIMIT ".$amount; } if($sql){ $conn = open_connection(); $st = $conn->prepare($sql); $st->execute(); // $row = $st->fetchAll(PDO::FETCH_ASSOC); $list = []; foreach($row as $item){ $item['game_title'] = Game::getById($item['game_id'])->title; $item['username'] = User::getById($item['user_id'])->username; array_push($list, $item); } echo json_encode($list); } } } elseif ($_POST['action'] === 'load_ad'){ if(isset($_POST['value'])){ $tags = get_pref('ads-manager'); if($tags){ $tags = json_decode($tags, true); $selected = null; foreach ($tags as $tag => $item) { if(strtolower($_POST['value']) == strtolower($tag)){ $selected = $item; $selected['type'] = strtolower($tag); break; } } if(!$selected){ foreach ($tags as $tag => $item) { if($item['default']){ $selected = $item; $selected['type'] = strtolower($tag); break; } } } if($selected['type'] == 'banner'){ if($selected['selected'] == 'random'){ if(isset($selected['data']) && $selected['data']){ $picked_banner = $selected['data'][rand(0, count($selected['data'])-1)]; $selected['value'] = $picked_banner['image']; $selected['url'] = $picked_banner['url']; $selected['name'] = $picked_banner['name']; //Add show stats $ad_stats = get_pref('ads-manager-stats'); if($ad_stats){ $ad_stats = json_decode($ad_stats, true); } else { $ad_stats = array(); } if(!isset($ad_stats[$picked_banner['name']])){ $ad_stats[$picked_banner['name']] = array(); $ad_stats[$picked_banner['name']]['views'] = 0; $ad_stats[$picked_banner['name']]['clicks'] = 0; } $ad_stats[$picked_banner['name']]['views']++; update_option('ads-manager-stats', json_encode($ad_stats)); //End } } $selected['delay'] = 5; } echo json_encode($selected); } else { echo '{"error": "Ads Manager plugin not installed."}'; } } } elseif ($_POST['action'] === 'ad_clicked'){ if(isset($_POST['value'])){ //Add click stats $name = $_POST['value']; $ad_stats = get_pref('ads-manager-stats'); if($ad_stats){ $ad_stats = json_decode($ad_stats, true); } else { $ad_stats = array(); } if(!isset($ad_stats[$name])){ $ad_stats[$name] = array(); $ad_stats[$name]['views'] = 0; $ad_stats[$name]['clicks'] = 0; } $ad_stats[$name]['clicks']++; update_option('ads-manager-stats', json_encode($ad_stats)); //End } } elseif ($_POST['action'] === 'get_ad_config'){ if(get_pref_bool('ads-manager-active')){ $result = array( 'status' => 'active', 'h5_client_id' => get_pref('ads-manager-h5-clientID') ); echo json_encode($result); } else { $result = array( 'status' => 'inactive', 'h5_client_id' => '' ); echo json_encode($result); } } } ?>PK �[�Z��(��/ �/ statistics.phpnu �[��� <?php if (session_status() == PHP_SESSION_NONE) { session_start(); } require_once( dirname(__FILE__)."/../config.php" ); class Stats { public static $debug = false; public static function debug() { if ( self::$debug ) : $bt = debug_backtrace(); $caller = array_shift($bt); ?> <pre class='__debug'><?php print_r([ "file" => $caller["file"], "line" => $caller["line"], "args" => func_get_args() ]); ?> </pre> <?php endif; } public static function migration_db() { // create table stats try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $table_db_stats = 'statistics'; $sql = "CREATE TABLE IF NOT EXISTS `".$table_db_stats."` ( `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, `created_date` DATE, `page_views` VARCHAR(255), `unique_visitor` VARCHAR(255), `data` MEDIUMTEXT, )"; $pdo->exec($sql); self::debug("Table ".$table_db_stats." created successfully<br>"); } catch(PDOException $e) { self::debug($sql . "<br>" . $e->getMessage()); } // create table stats_ip_address try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $table_db_stats_ip_address = 'stats_ip_address'; $sql = "CREATE TABLE IF NOT EXISTS `".$table_db_stats_ip_address."` ( `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, `ip_address` VARCHAR(255), `created_date` DATE )"; $pdo->exec($sql); self::debug("Table ".$table_db_stats_ip_address." created successfully<br>"); } catch(PDOException $e) { self::debug($sql . "<br>" . $e->getMessage()); } } public static function create_stats( $page_views = 0, $unique_visitor = 0, $data = '' ){ try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $ip_address = get_visitor_ip(); $created_date = date('Y-m-d'); $sql = "INSERT INTO `statistics` (page_views,unique_visitor,created_date,data) VALUES ('$page_views','$unique_visitor','$created_date','$data')"; $pdo->exec($sql); //self::debug("New record created successfully in stats"); } catch( PDOException $e ) { self::debug($sql . "<br>" . $e->getMessage()); } } public static function update_stats( $page_views = 0, $unique_visitor = 0, $data = '' ) { try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $ip_address = get_visitor_ip(); $created_date = date('Y-m-d'); $sql = "UPDATE `statistics` SET page_views='$page_views',unique_visitor='$unique_visitor',data='$data' WHERE `created_date` = '$created_date'"; $pdo->exec($sql); self::debug("New record update successfully in stats"); } catch( PDOException $e ) { self::debug($sql . "<br>" . $e->getMessage()); } } public static function create_stats_ip($ip_address = null, $conn = null) { if(!$ip_address){ $ip_address = self::get_visitor_ip(); } try { $close_conn = false; if($conn){ $close_conn = true; $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } $created_date = date('Y-m-d'); $sql = "INSERT INTO `stats_ip_address` (ip_address,created_date) VALUES ('$ip_address','$created_date')"; $conn->exec($sql); if($close_conn){ $conn = null; } //self::debug("New record created successfully in stats_ip_address"); } catch( PDOException $e ) { //self::debug($sql . "<br>" . $e->getMessage()); } } public static function delete_stats_ip() { try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $created_date = date('Y-m-d'); $sql = "DELETE FROM stats_ip_address"; $pdo->exec($sql); //self::debug("Record deleted successfully in stats_ip_address"); } catch( PDOException $e ) { self::debug($sql . "<br>" . $e->getMessage()); } } public static function get_stats_ip( $args = [] ) { $stats_ip = []; try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $ip_address = self::get_visitor_ip(); $created_date = date('Y-m-d'); $sql = "SELECT * FROM `stats_ip_address` WHERE `ip_address` = '$ip_address'"; $created_date = ''; if ( isset( $args['created_date']) && !empty( $args['created_date'] ) ) : $created_date = $args['created_date']; endif; if ( $created_date ) : $sql .= " AND `created_date` = '$created_date'"; endif; if ( empty($created_date) ) : $created_date_before = ''; if ( isset( $args['created_date_before']) && !empty( $args['created_date_before'] ) ) : $created_date_before = $args['created_date_before']; endif; if ( $created_date_before ) : $sql .= " AND `created_date` < '$created_date_before'"; endif; endif; $limit = -1; $offset = 0; if ( isset( $args['limit'] ) && !empty( $args['limit'] ) ) : $limit = intval($args['limit']); endif; if ( isset( $args['offset'] ) && !empty( $args['offset'] ) ) : $offset = intval($args['offset']); endif; if ( !empty($limit) && $limit != -1 ) : $sql .= " LIMIT ".$limit." OFFSET ".$offset.""; endif; $stmt = $pdo->prepare($sql); $stmt->execute(); // set the resulting array to associative $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $stats_ip = $stmt->fetchAll(); } catch(PDOException $e) { self::migration_db(); self::debug("Error: " . $e->getMessage()); } return $stats_ip; } public static function is_unique_visitor($ip, $conn = null) { $close_conn = false; if(!$conn){ $close_conn = true; $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } $sql = 'SELECT * FROM stats_ip_address WHERE ip_address = :ip'; $st = $conn->prepare($sql); $st->bindValue(":ip", $ip, PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); if($close_conn){ $conn = null; } if($row){ return false; } else { return true; } } public static function update_data($data = []) { $ip_address = self::get_visitor_ip(); $date_time = date('Y-m-d'); $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT data FROM statistics WHERE created_date = :date_time'; $st = $conn->prepare($sql); $st->bindValue(":date_time", $date_time, PDO::PARAM_STR); $st->execute(); $row = $st->fetch(); if($row){ $row = json_decode($row['data'], true); $json_data = ''; $unique_visitor = 0; if(self::is_unique_visitor($ip_address, $conn)){ $unique_visitor = 1; self::create_stats_ip($ip_address, $conn); foreach ($data as $item => $value) { if(isset($row[$item][$value])){ $row[$item][$value]++; } else { $row[$item][$value] = 1; } } $json_data = json_encode($row); } else { if($row === ''){ $json_data = json_encode($data); } else { $json_data = json_encode($row); } } $sql = 'UPDATE statistics SET page_views = page_views + 1, unique_visitor = unique_visitor + :uv, data = :data WHERE created_date = :date_time'; $st = $conn->prepare($sql); $st->bindValue(":date_time", $date_time, PDO::PARAM_STR); $st->bindValue(":uv", $unique_visitor, PDO::PARAM_INT); $st->bindValue(":data", $json_data, PDO::PARAM_STR); $st->execute(); } else { self::delete_stats_ip(); self::create_stats(1,1, json_encode(self::convert_array_data($data))); } $conn = null; } public static function convert_array_data( $data = [] ) { $array = []; foreach ($data as $item => $value) { $array[$item][$value] = 1; } return $array; } public static function get_data( $args = [] ) { $stats = []; try { $pdo = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $start_date = ''; $end_date = ''; if ( isset( $args['start_date']) && !empty( $args['start_date'] ) ) : $start_date = $args['start_date']; endif; if ( isset( $args['end_date']) && !empty( $args['end_date'] ) ) : $end_date = $args['end_date']; endif; $sql = "SELECT * FROM `statistics`"; if ( $start_date && $end_date ) : $sql .= " WHERE `created_date` BETWEEN '$start_date' AND '$end_date'"; endif; $limit = -1; $offset = 0; if ( isset( $args['limit'] ) && !empty( $args['limit'] ) ) : $limit = intval($args['limit']); endif; if ( isset( $args['offset'] ) && !empty( $args['offset'] ) ) : $offset = intval($args['offset']); endif; if ( !empty($limit) && $limit != -1 ) : $sql .= " LIMIT ".$limit." OFFSET ".$offset.""; endif; $stmt = $pdo->prepare($sql); $stmt->execute(); // set the resulting array to associative $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); $stats = $stmt->fetchAll(); } catch(PDOException $e) { self::migration_db(); self::debug("Error: " . $e->getMessage()); } return $stats; } public static function get_data_range( $data ) { $args = array( 'limit' => $data['limit'], 'offset' => $data['offset'], 'start_date' => date("Y-m-d", strtotime($data['sub']." days")), 'end_date' => date('Y-m-d'), ); $result = self::get_data($args); $conv_result = []; foreach($result as $item){ $conv_result[$item['created_date']] = array('page_views'=>$item['page_views'], 'unique_visitor'=>$item['unique_visitor']); } $begin = new DateTime( $args['start_date'] ); $end = new DateTime( $args['end_date'] ); $end = $end->modify( '+1 day' ); $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval ,$end); $final_result = []; foreach($daterange as $date){ $time = $date->format("Y-m-d"); if(isset($conv_result[$time])){ array_push($final_result, array( 'page_views' => $conv_result[$time]['page_views'], 'unique_visitor' => $conv_result[$time]['unique_visitor'], 'date' => $time, )); } else { array_push($final_result, array( 'page_views' => 0, 'unique_visitor' => 0, 'date' => $time, )); } } return $final_result; } public static function get_visitor_ip() { if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $ipAddr = $_SERVER["HTTP_CF_CONNECTING_IP"]; } elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ipAddr = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ipAddr = strtok($_SERVER['HTTP_X_FORWARDED_FOR'], ','); } else { $ipAddr = $_SERVER['REMOTE_ADDR']; } return $ipAddr; } public static function init() { self::migration_db(); self::update_data(); $args = [ 'limit'=>-1, 'offset'=>0, // 'start_date'=>date('Y-m-d'), // 'end_date'=>date('Y-m-d'), ]; //$stats = Stats::get_data($args); //echo '<pre>'.print_r($stats,1).'</pre>'; } } if(isset($_POST['action'])){ if($_POST['action'] === 'update'){ if(isset($_POST['data'])){ $data = json_decode($_POST['data'], true); Stats::update_data($data); } } } if( isset($_GET['data']) ){ //- Any login users can get the data, even it's not Admin user $username = isset( $_SESSION['username'] ) ? $_SESSION['username'] : ""; if ( !$username ) { exit('logout'); } if(isset($_POST['limit']) && isset($_POST['offset']) && isset($_POST['sub'])){ $data = array( 'limit' => (int)$_POST['limit'], 'offset' => (int)$_POST['offset'], 'sub' => (int)$_POST['sub'] ); echo json_encode(Stats::get_data_range($data)); } } ?>PK �[�Z�j9� � widgets.phpnu �[��� <?php class Widget_HTML extends Widget { function __construct() { $this->name = 'HTML'; $this->id_base = 'html'; $this->description = 'Show HTML / TEXT'; } public function widget( $instance, $args = array() ){ echo $instance['text']; } public function form( $instance = array() ){ if(!isset( $instance['text'] )){ $instance['text'] = ''; } ?> <div class="mb-3"> <label class="form-label">HTML / TEXT:</label> <textarea class="form-control" rows="5" name="text"><?php echo $instance['text'] ?></textarea> </div> <?php } } register_widget( 'Widget_HTML' ); class Widget_Paragraph extends Widget { function __construct() { $this->name = 'Paragraph'; $this->id_base = 'paragraph'; $this->description = 'Show text paragraph (HTML not allowed)'; } public function widget( $instance, $args = array() ){ if(!isset( $instance['text'] )){ $instance['text'] = ''; } if(!isset( $instance['align'] )){ $instance['align'] = 'none'; } $align_class = null; if($instance['align'] != 'none'){ if($instance['align'] == 'left'){ $align_class = 'text-start text-left'; } else if($instance['align'] == 'center'){ $align_class = 'text-center'; } else if($instance['align'] == 'right'){ $align_class = 'text-end text-right'; } } echo '<p'.($align_class ? ' class="' . $align_class . '"' : '').'>'; echo htmlentities(nl2br($instance['text'])); echo '</p>'; } public function form( $instance = array() ){ if(!isset( $instance['text'] )){ $instance['text'] = ''; } if(!isset( $instance['align'] )){ $instance['align'] = 'none'; } ?> <div class="mb-3"> <label class="form-label">TEXT:</label> <textarea class="form-control" rows="5" name="text"><?php echo $instance['text'] ?></textarea> </div> <div class="mb-3"> <label class="form-label"><?php _e('Align') ?>:</label> <select class="form-control" name="align"> <?php $opts = array( 'none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right' ); foreach ($opts as $key => $value) { $selected = ''; if($key == $instance['align']){ $selected = 'selected'; } echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <?php } } register_widget( 'Widget_Paragraph' ); class Widget_Heading extends Widget { function __construct() { $this->name = 'Heading'; $this->id_base = 'heading'; $this->description = 'Heading typography, can be used as widget title or label.'; } public function widget( $instance, $args = array() ){ if(!isset( $instance['tag'] )){ $instance['tag'] = 'h3'; } if(!isset( $instance['class'] )){ $instance['class'] = ''; } if(!isset( $instance['text'] )){ $instance['text'] = ''; } echo '<'.$instance['tag'].' class="'.$instance['class'].'">'; echo htmlentities($instance['text']); echo '</'.$instance['tag'].'>'; } public function form( $instance = array() ){ if(!isset( $instance['tag'] )){ $instance['tag'] = 'h3'; } if(!isset( $instance['class'] )){ $instance['class'] = ''; } if(!isset( $instance['text'] )){ $instance['text'] = ''; } ?> <div class="mb-3"> <label class="form-label"><?php _e('Heading tag') ?>:</label> <select class="form-control" name="tag"> <?php $opts = array( 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'div' => 'div', ); foreach ($opts as $key => $value) { $selected = ''; if($key == $instance['tag']){ $selected = 'selected'; } echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>'; } ?> </select> </div> <div class="mb-3"> <label class="form-label">TEXT:</label> <textarea class="form-control" rows="5" name="text"><?php echo $instance['text'] ?></textarea> </div> <div class="mb-3"> <label class="form-label"><?php _e('Div class (Optional)') ?>:</label> <input type="text" class="form-control" name="class" placeholder="widget" value="<?php echo $instance['class'] ?>"> </div> <?php } } register_widget( 'Widget_Heading' ); class Widget_Banner extends Widget { function __construct() { $this->name = 'Banner Ad'; $this->id_base = 'banner_ad'; $this->description = 'Show banner advertisement'; } public function widget( $instance, $args = array() ){ echo '<div class="banner-ad-wrapper"><div class="banner-ad-content" style="padding: 20px 0; text-align: center;">'; echo $instance['text']; echo '</div></div>'; } public function form( $instance = array() ){ if(!isset( $instance['text'] )){ $instance['text'] = ''; } ?> <p>This widget is similar to HTML widget, the difference is that it comes with a banner div to fit the theme style. You can also style it on theme style.css</p> <div class="mb-3"> <label class="form-label">HTML / TEXT:</label> <textarea class="form-control" rows="5" name="text"><?php echo $instance['text'] ?></textarea> </div> <?php } } register_widget( 'Widget_Banner' ); ?>PK �[�Z�9W�&