Jump to content
MakeWebGames

corruptcity || skalman

Members
  • Posts

    358
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by corruptcity || skalman

  1. No I forgot to include the database table for it in OP
  2. cheers MTG, not sure how I manage to forget the table then 🤦‍♂️have now got an export of the table or just copy/ paste above post. loan_shark(1).sql
  3. Hey sorry not sure how I missed your reply back back then. I have to give Peter credit for using w3.css, if I'm honest I hadn't heard of it until I was looking at his source code but we'll keep that on the down low lol. 🤫 switching to using PDO is something I want add to my game in the future, just haven't had the time to sit down and learn how it works and how to implement it. yeah the js might not be the most eloquient or how it would be written today either, I had created this about 10 years ago originally and well it didn't really stand the test of time and with abit of help from chatGPT managed to get it working. thanks and yeah my 1st try was just full of lots of if statements if I'm honet 🙄
  4. Hi, to carry on into the new year here is another mod that I am giving out for free for any one to use. Like the other mods I'm again using w3.css which you can find by googling it. This mode lets you borrow money from a loan shark there is no limit of how much you borrow from him. each new loan will have a random interest % and daily payment due, with interest being between 15 - 30 and daily % being from 5 - 15. when a loan is taken out the interest amount due will be added to the top and the daily payment will come from that. If you don't have enough money to pay each day you will get your legs broken and spend time in hospital, you are able to pay the loan back early from within the mod. I have also included a photo of what it lookslike within game loanshark.php <?php require_once('globals.php'); echo"<h3>Loan Shark</h3> <hr />"; $_POST['amount'] = (isset($_POST['amount']) && is_numeric($_POST['amount'])) ? abs(intval($_POST['amount'])) : '0'; $_GET['debt'] = (isset($_GET['debt']) && is_numeric($_GET['debt'])) ? abs(intval($_GET['debt'])) : '0'; if(!isset($_GET['action'])) { $_GET['action'] = ''; } switch($_GET['action']) { case "loan": loan_newLoan(); break; case "payback": loan_payback(); break; default: index(); break; } function index() { global $db, $ir, $c, $userid, $h; echo" <div class='w3-container'> <div class='w3-row w3-border w3-border-black w3-round-medium w3-theme-d2'> <div class='w3-quarter'> <img src='img/traders/loanshark.png' alt='Loan Shark' width='175' height='175' class='w3-image'> </div> <div class='w3-threequarter w3-left'> <p class='w3-large w3-center'>Loan Shark</p> <p class='w3-medium w3-left-align w3-padding'> CREATE YOUR OWN BACKSTORY HERE OR W/E </p> </div>"; echo"</div> </div><br />"; echo" <div class='w3-container'> <div class='w3-row w3-border w3-border-black w3-round-medium w3-theme-d2 w3-padding'> <div class='w3-half'> <p class='w3-large w3-center w3-padding'>New Loan</p>"; $interest = rand(15, 30); $daily = rand(5, 15); echo"<form action='?action=loan' method='post'> <input type='text' name='amount' value=''/><br /> Interest: ".number_formatter($interest)."%<br /> Daily Payment: ".number_formatter($daily)."%<br /> <input type='submit' name='submit' value='Borrow' /> <input type='hidden' name='interest' value='{$interest}' /> <input type='hidden' name='daily' value='{$daily}' /> </form> </div> <div class='w3-half'> <p class='w3-large w3-center w3-padding'>Loan History</p>"; $query = $db->query("SELECT * FROM loan_shark WHERE ls_userid = {$ir['userid']}"); if($db->num_rows($query) == 0) { echo"You have no loans."; } else { echo"<hr/>"; while($r = $db->fetch_row($query)) { $date = date('F j ', $r['ls_time']); $dailyPayment = $r['ls_daily']; echo"{$date}: ".money_formatter($r['ls_amount']).". <br/> Remaining: ".money_formatter($r['ls_remaining']).",<br/> ".money_formatter($dailyPayment)." daily [<a href='?action=payback&debt={$r['ls_id']}'>Payback</a>]<hr />"; } } echo"</div> </div> </div>"; } function loan_newLoan() { global $db, $ir, $c, $userid, $h; echo" <div class='w3-container'> <div class='w3-row w3-border w3-border-black w3-round-medium w3-theme-d2 w3-padding'>"; if(!isset($_POST['submit'])) { echo"You must submit a loan request."; } else { $amount = abs(intval($_POST['amount'])); $interest = abs(intval($_POST['interest'])); $daily = abs(intval($_POST['daily'])); $remaining = $amount + ($amount * ($interest / 100)); $dailyPayment = $remaining * ($daily / 100); $time = time(); $db->query("UPDATE `users` SET `money` = `money` - {$amount} WHERE `userid` = {$ir['userid']}"); $db->query("INSERT INTO `loan_shark` (ls_id, `ls_userid`, `ls_amount`, `ls_interest`, ls_daily, `ls_remaining`, `ls_time`) VALUES ('', {$ir['userid']}, {$amount}, {$interest}, {$dailyPayment}, {$remaining}, {$time})"); echo"You have borrowed ".money_formatter($amount)." from Dominic \"The Collector\" DeLuca.<br /> Interest: ".number_formatter($interest)."%, taking the total to ".money_formatter($remaining).".<br /> Daily Payment: ".number_formatter($daily)."%, Your daily payment is ".money_formatter($dailyPayment).".<br /> if you don't have enough to make the daily payment, each day you will be in minus figures and will be hospitalized each time.<br /> So take this as your one and only warning.<br /> [<a href='loanshark.php'>Go Back</a>]"; } echo"</div> </div>"; } function loan_payback() { global $db, $ir, $c, $userid, $h; echo" <div class='w3-container'> <div class='w3-row w3-border w3-border-black w3-round-medium w3-theme-d2'>"; if(!isset($_GET['debt']) && $_GET['debt'] == 0) { ErrorText("You must select a debt to payback.<br />[<a href='loanshark.php'>Go Back</a>]"); } else { $debt = abs(intval($_GET['debt'])); $query = $db->query("SELECT * FROM loan_shark WHERE ls_id = {$debt} AND ls_userid = {$ir['userid']}"); if($db->num_rows($query) == 0) { ErrorText("You do not own this debt.<br />[<a href='loanshark.php'>Go Back</a>]"); } else { $r = $db->fetch_row($query); if($r['ls_remaining'] > $ir['money']) { ErrorText("You do not have enough money to payback this debt.<br />[<a href='loanshark.php'>Go Back</a>]"); } else { $db->query("UPDATE `users` SET `money` = `money` - {$r['ls_remaining']} WHERE `userid` = {$ir['userid']}"); $db->query("DELETE FROM `loan_shark` WHERE `ls_id` = {$debt} AND `ls_userid` = {$ir['userid']}"); echo"You have paid back ".money_formatter($r['ls_remaining'])." to Dominic \"The Collector\" DeLuca.<br /> [<a href='loanshark.php'>Go Back</a>]"; } } } echo"</div> </div>"; } ?> cron_day.php - add this anywhere $loanshark = $db->query("SELECT ls_id, ls_userid, ls_remaining, ls_daily FROM loan_shark WHERE ls_remaining > 0"); while($r = $db->fetch_row($loanshark)) { $db->query("UPDATE users SET money = money - {$r['ls_daily']} WHERE userid = {$r['ls_userid']}"); $moneyCheck = $db->fetch_single($db->query("SELECT money FROM users WHERE userid = {$r['ls_userid']}")); if($moneyCheck < 0) { $hospTime = (int) rand(30, 900); $reason = "Failed to pay their debt to The Collector!"; $db->query("UPDATE users SET hospital = {$hospTime}, hospreason = '{$reason}' WHERE userid = {$r['ls_userid']}"); } $db->query("UPDATE loan_shark SET ls_remaining = ls_remaining - {$r['ls_daily']} WHERE ls_id = {$r['ls_id']}"); if($r['ls_remaining'] <= 0) { $db->query("DELETE FROM loan_shark WHERE ls_id = {$r['ls_id']}"); } }
  5. I asked chatgpt and it came back with this Your code appears mostly fine, but there are a few points to consider and improve: SQL Injection Vulnerability: You should avoid directly inserting user inputs into SQL queries to prevent SQL injection attacks. Instead, use prepared statements or at least sanitize the inputs. Error Handling: It's good practice to include error handling in your database operations to catch and handle any potential errors that may occur during execution. Here's an updated version of your code with these improvements: function add_degree() { global $db, $ir, $h; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $count = 0; // Use prepared statements to prevent SQL injection $stmt = $db->prepare("INSERT INTO `edu_degrees` VALUES('',?,?,?,?)"); foreach ($_POST['city'] as $cities) { // Sanitize inputs before using in the query $name = $db->escape($_POST['name']); $desc = $db->escape($_POST['desc']); $unlocks = $db->escape($_POST['unlocks']); // Bind parameters and execute the statement $stmt->bind_param('ssss', $name, $desc, $cities, $unlocks); $stmt->execute(); $count++; } // Close the prepared statement $stmt->close(); echo htmlspecialchars($_POST['name']) . " added to " . number_format($count) . " cities."; } else { echo "<center>Add A Degree</center><br><form action='staff_school.php?action=add-degree' method='POST'> <table> <tr> <td> <b>Name</b>: </td> <td> <input type='text' name='name'> </td> </tr> <tr> <td> <b>Description</b>: </td> <td> <textarea name='desc' rows='4' cols='50'></textarea> </td> </tr> <tr> <td> <b>Available At</b>: </td> <td> <select name='city[]' multiple>"; $get_cities = $db->query("SELECT `cityname`,`cityid` FROM `cities` ORDER BY `cityname` ASC"); while ($cities = $db->fetch_row($get_cities)) { $city_id = $cities['cityid']; echo "<option value='$city_id'>{$cities['cityname']}</option>"; } echo "</select> </td> </tr> <tr> <td> <b>Unlocks</b>: </td> <td> <input type='text' name='unlocks'> </td> </tr> </table> <button type='submit'>Add</button> </form>"; } } Please note that I assumed your $db object provides methods like prepare, bind_param, execute, escape, etc. If not, you may need to adapt those parts according to your specific database library.
  6. Hi While I was working on Roulette page I decided to give it a refresh and add some new features. Added the ability to pick a random number each time or stick with the same number and added a session profit and loss tracking and colour coded it green with your in profit and red when in a loss. I have also made it responsive using w3.css. <?php require_once('globals.php'); $tresder = (int) (rand(100, 999)); $maxbet = $ir['level'] * 150; $_GET['tresde'] = (isset($_GET['tresde']) && is_numeric($_GET['tresde'])) ? abs(intval($_GET['tresde'])) : 0; if(!isset($_SESSION['tresde'])) { $_SESSION['tresde'] = 0; } if(($_SESSION['tresde'] == $_GET['tresde']) || $_GET['tresde'] < 100) { die("Error, you cannot refresh or go back on the slots, please use a side link to go somewhere else.<br /> [<a href='roulette.php?tresde=$tresder'>Go Back</a>]"); } $_SESSION['tresde'] = $_GET['tresde']; echo"<h3>Roulette</h3> <hr/>"; echo" <div class='w3-container'> <div class='w3-row w3-border w3-border-black w3-round-medium w3-theme-d2'>"; $spent = 0; $won = 0; $turns = 0; if(isset($_POST['bet']) && is_numeric($_POST['bet'])) { $pick = isset($_POST['pick']) ? $_POST['pick'] : 0; $bet = $_POST['bet']; $random = isset($_POST['random']) ? $_POST['random'] : 0; $spent = isset($_POST['spent']) ? $_POST['spent'] : 0; $won = isset($_POST['won']) ? $_POST['won'] : 0; $turns = isset($_POST['turns']) ? $_POST['turns'] : 0; if(isset($_POST['random']) && $_POST['random'] > 0) { $pick = (int) (rand(0, 36)); } if($bet > $ir['money']) { echo"You are trying to bet more than you have.<br />[<a href='roulette.php?tresde=$tresder'>Go Back</a>]"; exit; } if($bet > $maxbet) { echo"You are trying to bet more than your level allows.<br />[<a href='roulette.php?tresde=$tresder'>Go Back</a>]"; exit; } if($pick > 36 or $pick < 0) { echo"Invalid number.<br />[<a href='roulette.php?tresde=$tresder'>Go Back</a>]"; exit; } $outcome = (int) (rand(0, 36)); if($outcome != $pick) { echo"You place ".money_formatter($bet)." into the machine and pull the lever.<br /> You picked the number: <b>$pick</b><br /> You see the machine stop on number: <b>$outcome</b><br /> You bet ".money_formatter($bet)." and lost it."; $db->query("UPDATE `users` SET `money` = `money` - {$bet} WHERE `userid` = {$ir['userid']}"); $ir['money'] -= $bet; $tresder = (int) (rand(100, 999)); $spent += $bet; $won -= $bet; $turns++; } else { echo"You place ".money_formatter($bet)." into the machine and pull the lever.<br /> You picked the number: <b>$pick</b><br /> You see the machine stop on number: <b>$outcome</b><br /> You bet ".money_formatter($bet)." and won ".money_formatter($bet * 36)." by matching the numbers, pocketing you ".money_formatter($bet * 35)." extra."; $gain = $bet * 36; $db->query("UPDATE `users` SET `money` = `money` + ({$gain}) WHERE `userid` = {$ir['userid']}"); $ir['money'] += $gain; $spent += $bet; $won += $gain; $turns++; $tresder = (int) (rand(100, 999)); } echo "<br /> <form action='roulette.php?tresde={$tresder}' method='post'> <input type='hidden' name='bet' value='{$_POST['bet']}' /> <input type='hidden' name='pick' value='{$_POST['pick']}' /> <input type='hidden' name='spent' value='{$spent}' /> <input type='hidden' name='won' value='{$won}' /> <input type='submit' value='Same Number, Same Bet' /> <input type='submit' name='random' value='Random Number' /> </form> [<a href='roulette.php?tresde=$tresder'>change bet.</a>]<br /> Stats:<br /> Turns: {$turns}<br /> Spent: ".money_formatter($spent)." - Won: <span style='color: " . ($won >= 0 ? 'green' : 'red') . ";'>" . money_formatter($won) . "</span><br /> [<a href='explore.php'>Go Back</a>]"; } else { echo"<p class='w3-large'>Roulette</p> <p class='w3-medium'>Ready to try your luck? Play today<br/> Your max bet is ".money_formatter($maxbet).".</p> <form action='roulette.php?tresde={$tresder}' method='POST'> Bet: \$<input type='text' name='bet' value='5' /><br /> Pick (0-36): <input type='text' name='pick' value='18' /><br /> <input type='submit' value='Play!' /> or <input type='submit' name='random' value='Random Number' /> </form> [<a href='explore.php'>Go Back</a>]"; } echo"</div> </div>"; $h->endpage(); ?>
  7. Managed to fix this but had to do some jankiness to get it working and used something I've never used before or even was a thing. I had to use output buffering for globals.php then in globals_nonauth put an if statement in so that it doesn't duplicate what was in globals, also had to add a shit ton of isset() into the header page before I managed to get it to work. I will now Include the working code in case it helps one else in the future Blog.php <?php #set_error_handler('error_php'); if (strpos($_SERVER['PHP_SELF'], "globals_nonauth.php") !== false) { exit; } if ($_SERVER['PHP_SELF'] !== '/blog.php') { session_name('MCCSID2'); @session_start(); if (!isset($_SESSION['started'])) { session_regenerate_id(); $_SESSION['started'] = true; } ob_start(); require "lib/basic_error_handler.php"; set_error_handler('error_php'); include "config.php"; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; require_once('global_func.php'); $db = new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c = $db->connection_id; $set = array(); $settq = $db->query("SELECT * FROM `settings`"); while ($r = $db->fetch_row($settq)) { $set[$r['conf_name']] = $r['conf_value']; } } ?> globals_nonauth.php <?php // Include your global settings for logged-in users ob_start(); require_once("globals.php"); $output = ob_get_contents(); ob_end_clean(); if(isset($_SESSION['userid']) && $_SESSION['userid'] > 0) { echo"Hello {$ir['username']}<br />"; echo "Welcome user"; $loggedIn = true; // Add code here to display blog posts for logged-in users } else { // Include only the specific data you need for non-logged-in users require_once("globals_nonauth.php"); $loggedIn = false; // Display a welcome message for guests echo "Welcome Guest <br />"; // Here, you can use $nonLoggedInData to display blog posts for non-logged-in users // Replace the following line with your actual code to display blog posts. echo "Display Blog Posts Here"; } ?> Also would like to say thanks to adam for his assistance
  8. yeah that was the first thing I tried would work fine when logged in but got the session error when not logged in but couldn't get around that even with chatgpt help
  9. Hi I'm looking for help, adivce or suggestion on how I could fix my problem I've got. So I have made this blog mod for my website to the I can post about the roadmap, game info etc that can be viewed either logged in or out but was after ideas on how I could make this working using only one page as I currently have blogs and blogsnl (blogs Non Logged) on serperate scripts. when I first did create this I did have it on one page but I couldn't find a way for the script to determine if you were logged in or not and pick the right globals file either the globals or globals_nonauth without causing other problems or errors due to the wrong globals called, so I split up the file into two just going for the easy fix right now I will include what I have don sofar but bare in mind this isn't the finished mod and will be recoded if I can fix the problem cheers. ps if anyone wants to use my codes as a starting point for their own blog feel free to. Blog.php <?php require_once("globals.php"); echo' <style> .blog-container{ max-width: 30vw; border: 5px solid black; border-radius: 5px; margin: 0 auto; background-color: #1F2324; color: #ADD8E6; } .blog-grid { display: grid; grid-template-columns: repeat(1, 1fr); grid-gap: 20px; max-width: 30vw; text-align: center; z-index: 2; margin: 0 auto; border: 0px solid blue; } .blog-heading{ grid-column: span 1; padding-top: 5px; padding-left: 10px; font-size: 1.1rem; border: 0px solid green; text-align: center; } .blog-item{ grid-column: span 1; padding-top: 5px; padding-left: 10px; font-size: 1.2rem; border: 0px solid pink; } .content-area-grid{ display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 5px; max-width: 30vw; margin: 0 auto; border: 0px solid blue; padding-left: 10px; text-align: center; } .ca-grid-heading{ grid-column: span 4; padding-top: 10px; padding-left: 5px; font-size: 1.1rem; justify-items: left; border: 0px solid pink; } .ca-grid-item{ grid-column: span 1; padding-top: 10px; padding-left: 5px; background-repeat: no-repeat; border: 5px solid black; border-radius: 5px; text-align: left; background-color: #1F2324; } </style>'; if(!isset($_GET['action'])) { $_GET['action'] = ''; } switch($_GET['action']) { case "view": view(); case "comment": comment(); break; case "likecomment": likecomment(); break; case "dislikecomment": dislikecomment(); break; case "editcomment": editcomment(); break; case "deletecomment": deletecomment(); break; case "likeblog": likeblog(); break; case "dislikeblog": dislikeblog(); break; default: index(); break; } function index() { global $ir, $db; echo" <div class='content-area-grid'> <div class='ca-grid-heading'> <h3>Blog</h3> <hr/> </div>"; $query = $db->query("SELECT * FROM blog ORDER BY b_id DESC"); if($db->num_rows($query) == 0) { echo"<div class='ca-grid-heading'> No blog posts found. </div>"; } else { while($r = $db->fetch_row($query)) { $text = substr($r['b_text'], 0, 100); echo"<div class='ca-grid-item'> ".stripText($r['b_title'])."<br/> ".stripText($text)."<br/> Date: ".date('F j, y, g:i:s a', $r['b_time'])."<br/> Views: ".number_formatter($r['b_views'])."<br/> <a href='blog.php?action=view&id={$r['b_id']}'>Read More</a> </div>"; } } echo" </div>"; } function view() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); echo" <div class='blog-container'> <div class='blog-grid'>"; $query = $db->query("SELECT * FROM blog WHERE b_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { echo" <div class='blog-heading'> <h3>No blog post found.</h3> </div>"; } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog SET b_views = b_views + 1 WHERE b_id = {$_GET['id']}"); echo" <div class='blog-heading'> <h3>".stripText($r['b_title'])."</h3> </div> <div class='blog-item'> ".htmlspecialchars_decode($r['b_text'])." </div> <div class='blog-heading'> Date: ".date('F j, y, g:i:s a', $r['b_time'])." - Views: ".number_formatter($r['b_views'])." - ".number_formatter($r['b_likes'])." Likes [<a href='blog.php?action=likeblog&id={$r['b_id']}'>Like</a>] - ".number_formatter($r['b_dislikes'])." Dislikes [<a href='blog.php?action=dislikeblog&id={$r['b_id']}'>Dislike</a>] </div> </div>"; } echo"</div> <span style='text-align: center;'><h3>Comments</h3></span> <hr/>"; $query = $db->query("SELECT * FROM blog_comments WHERE bc_blog = {$_GET['id']} ORDER BY bc_id DESC"); if($db->num_rows($query) == 0) { echo" <div class='blog-heading'> <h3>No Comments.</h3> </div>"; } else { while($r = $db->fetch_row($query)) { echo" <div class='blog-container'> <div class='blog-grid'> <div class='blog-item'> ".stripText($r['bc_text'])." - Date: ".date('F j, y, g:i:s a', $r['bc_time'])."<br/>"; if(isset($_SESSION['userid'])) { echo" [<a href='blog.php?action=likecomment&id={$r['bc_id']}'>Like</a>] - [<a href='blog.php?action=dislikecomment&id={$r['bc_id']}'>Dislike</a>] - -"; if( $ir['userid'] == $r['bc_user']) { echo"[<a href='blog.php?action=editcomment&id={$r['bc_id']}'>Edit</a>] "; } if($ir['user_level'] > 2 || $ir['userid'] == $r['bc_user']) { echo"- [<a href='blog.php?action=deletecomment&id={$r['bc_id']}'>Delete</a>]"; } } echo"</div> </div> </div>"; } } echo"<br/>"; if(isset($_SESSION['userid'])) { echo" <div class='blog-container'> <div class='blog-grid'> <div class='blog-heading'> <h3>Post Comment</h3> </div> <div class='blog-item'> <form action='blog.php?action=comment&id={$_GET['id']}' method='post'> Text: <textarea name='text'></textarea><br/> <input type='submit' value='Post Comment' /> </form> </div> </div> </div>"; } } function comment() { global $ir, $db; if(isset($_SESSION['userid']) && (isset($_GET['id']) && isset($_POST['text']))) { $_GET['id'] = abs((int) $_GET['id']); #$_POST['text'] = stripText($_POST['text']); if(isset($_GET['id']) && $_POST['text']) { if(empty($_POST['text'])) { ErrorText("You must enter text to post a comment."); } $time = time(); $db->query("INSERT INTO blog_comments (bc_id, bc_blog, bc_user, bc_time, bc_text) VALUES ('', {$_GET['id']}, {$ir['userid']}, {$time}, '{$_POST['text']}')"); echo"Comment Added."; echo"<br/> [<a href='blog.php?view&id={$_GET['id']}'>Back</a>]"; } } } function likecomment() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No comment found."); } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog_comments SET bc_likes = bc_likes + 1 WHERE bc_id = {$_GET['id']}"); echo"Comment Liked."; echo"<br/> [<a href='blog.php?view&id={$r['bc_blog']}'>Back</a>]"; } } function dislikecomment() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No comment found."); } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog_comments SET bc_dislikes = bc_dislikes + 1 WHERE bc_id = {$_GET['id']}"); echo"Comment Disliked."; echo"<br/> [<a href='blog.php?view&id={$r['bc_blog']}'>Back</a>]"; } } function editcomment() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); if(isset($_GET['id'])) { if($_POST['submit']) { $_POST['text'] = $db->escape(stripslashes($_POST['text'])); if(empty($_POST['text'])) { ErrorText("You must enter text to edit a comment."); } $db->query("UPDATE blog_comments SET bc_text = '{$_POST['text']}' WHERE bc_id = {$_GET['id']}"); echo"Comment Edited."; echo"<br/> [<a href='blog.php?view&id={$_GET['id']}'>Back</a>]"; } else { $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No comment found."); } else { $r = $db->fetch_row($query); $db->free_result($query); if($ir['user_level'] > 2 || $ir['userid'] == $r['bc_user']) { echo" <form action='blog.php?action=editcomment&id={$_GET['id']}' method='post'> Text: <textarea name='text'>{$r['bc_text']}</textarea><br/> <input type='submit' name='submit' value='Edit Comment' /> </form>"; } else { ErrorText("You do not have permission to edit this comment."); } } } } } function deletecomment() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No comment found."); } else { $r = $db->fetch_row($query); $db->free_result($query); if($ir['user_level'] > 2 || $ir['userid'] == $r['bc_user']) { $db->query("DELETE FROM blog_comments WHERE bc_id = {$_GET['id']}"); echo"Comment Deleted."; echo"<br/> [<a href='blog.php?view&id={$r['bc_blog']}'>Back</a>]"; } else { ErrorText("You do not have permission to delete this comment."); } } } function likeblog() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog WHERE b_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No blog found."); } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog SET b_likes = b_likes + 1 WHERE b_id = {$_GET['id']}"); echo"Blog Liked."; echo"<br/> [<a href='blog.php?view&id={$_GET['id']}'>Back</a>]"; } } function dislikeblog() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog WHERE b_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { ErrorText("No blog found."); } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog SET b_dislikes = b_dislikes + 1 WHERE b_id = {$_GET['id']}"); echo"Blog Disliked."; echo"<br/> [<a href='blog.php?view&id={$_GET['id']}'>Back</a>]"; } } $h->endpage(); ?> blogsnl.php <?php require_once('globals_nonauth.php'); $login_csrf = request_csrf_code('login'); print <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>{$set['game_name']}</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="js/login.js"></script> <link rel="icon" type="image/x-icon" href="/img/favicon.ico"> <link href="css/login.css" type="text/css" rel="stylesheet" /> <link href="css/blog.css" type="text/css" rel="stylesheet" /> </head> <body onload="getme();"> <div class="login-container"> <div class="login-banner"> </div> <div class="login-spacer"> </div> <div class="login-menu"> <div class="menu-grid"> <div class="menu-home"> <a href='login.php'>Home</a> </div> <div class="menu-register"> <a href='register.php'>Register</a> </div> <div class="menu-blog"> <a href='blogsnl.php'>Blog</a> </div> <div class="menu-support"> <a href='contactus.php'>Support</a> </div> </div> </div> <div class="login-form"> <form action="authenticate.php" method="post"> <div class="login-flex"> <div class="login-remember"> Remember me?<br /> <input type='radio' value='ON' name='save' checked='checked'/> Yes <input type='radio' value='OFF' name='save' /> No </div> <div class="login-username"> <input type='text' name='username' class="textbox"/><br /> </div> <div class="login-password"> <input type='password' name='password' class="textbox" /> </div> <div class="login-submit"> <input type='hidden' name='verf' value='{$login_csrf}' /> <input type='submit' name='submit' value='Submit'><br /> <a href="#">Reset Password</a> </div> </div> </form> </div> <div class="login-content"> EOF; if(!isset($_GET['action'])) { $_GET['action'] = ''; } switch($_GET['action']) { case "view": view(); case "likecomment": likecomment(); break; case "dislikecomment": dislikecomment(); break; case "likeblog": likeblog(); break; case "dislikeblog": dislikeblog(); break; default: index(); break; } function index() { global $db; echo" <div class='content-area-grid'> <div class='ca-grid-heading'> <h3>Blog</h3> <hr/> </div>"; $query = $db->query("SELECT * FROM blog ORDER BY b_id DESC"); if($db->num_rows($query) == 0) { echo"<div class='ca-grid-heading'> No blog posts found. </div>"; } else { while($r = $db->fetch_row($query)) { $text = substr($r['b_text'], 0, 100); echo"<div class='ca-grid-item'> ".stripText($r['b_title'])."<br/> ".stripText($text)."<br/> Date: ".date('F j, y, g:i:s a', $r['b_time'])."<br/> Views: ".number_formatter($r['b_views'])."<br/> <a href='blogsnl.php?action=view&id={$r['b_id']}'>Read More</a> </div>"; } } echo" </div>"; } function view() { global $db; echo" <div class='blog-container'> <div class='blog-grid'>"; $query = $db->query("SELECT * FROM blog WHERE b_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { echo" <div class='blog-heading'> <h3>No blog post found.</h3> </div>"; } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog SET b_views = b_views + 1 WHERE b_id = {$_GET['id']}"); echo" <div class='blog-heading'> <h3>".stripText($r['b_title'])."</h3> </div> <div class='blog-item'> ".htmlspecialchars_decode($r['b_text'])." </div> <div class='blog-heading'> Date: ".date('F j, y, g:i:s a', $r['b_time'])." - Views: ".number_formatter($r['b_views'])." - ".number_formatter($r['b_likes'])." Likes [<a href='blogsnl.php?action=likeblog&id={$r['b_id']}'>Like</a>] - ".number_formatter($r['b_dislikes'])." Dislikes [<a href='blogsnl.php?action=dislikeblog&id={$r['b_id']}'>Dislike</a>] </div> </div>"; } echo"</div> <span style='text-align: center;'><h3>Comments</h3></span> <hr/>"; $query = $db->query("SELECT * FROM blog_comments WHERE bc_blog = {$_GET['id']} ORDER BY bc_id DESC"); if($db->num_rows($query) == 0) { echo" <div class='blog-heading'> <h3>No Comments.</h3> </div>"; exit; } else { while($r = $db->fetch_row($query)) { echo" <div class='blog-container'> <div class='blog-grid'> <div class='blog-item'> ".stripText($r['bc_text'])." - Date: ".date('F j, y, g:i:s a', $r['bc_time'])."<br/>"; if(isset($_SESSION['userid'])) { echo" [<a href='blogsnl.php?action=likecomment&id={$r['bc_id']}'>Like</a>] - [<a href='blogsnl.php?action=dislikecomment&id={$r['bc_id']}'>Dislike</a>] - -"; } echo"</div> </div> </div>"; } } } function likecomment() { global $ir, $db, $h; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { echo("No comment found."); exit; } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog_comments SET bc_likes = bc_likes + 1 WHERE bc_id = {$_GET['id']}"); echo"Comment Liked."; echo"<br/> [<a href='blogsnl.php?view&id={$r['bc_blog']}'>Back</a>]"; } } function dislikecomment() { global $ir, $db; $_GET['id'] = abs((int) $_GET['id']); $query = $db->query("SELECT * FROM blog_comments WHERE bc_id = {$_GET['id']}"); if($db->num_rows($query) == 0) { echo"No comment found."; exit; } else { $r = $db->fetch_row($query); $db->free_result($query); $db->query("UPDATE blog_comments SET bc_dislikes = bc_dislikes + 1 WHERE bc_id = {$_GET['id']}"); echo"Comment Disliked."; echo"<br/> [<a href='blogsnl.php?view&id={$r['bc_blog']}'>Back</a>]"; } } echo" </div> </div> </div> </div> <div class='footer'> &nbsp; </div> </div>"; ?>
  10. Yeah I'd also pick vscode couldn't live without it now that I'm used to it and that I've got github copilot. for years I used to use dreamweaver cs6, no hate please lol. Still use it to this day but only because of one feature, it's so easy to upload files to my web server without much hassle
  11. I think @KyleMassacre was referring to this echo '' <tr> <td>' . $r['userid'] . '</td> <td><a href="viewuser.php?u=' . $r['userid'] . '">' . $r['gangPREF'] . ' ' . $r['username'] . '</a></td> <td>' . $r['level'] . '</td> <td>' . (($r['laston'] >= $_SERVER['REQUEST_TIME'] - 15 * 60) ? '<span style='color: green; font-weight:bold;'>Online</span>' : '<span style='color: red; font-weight:bold;'>Offline</span>') . ' </td> </tr> ';
  12. start small then get more ambitious as you get more knowledgeable, comfortable with it then take it from there. Also try to pick one engine that you like the most and stick with it. you'll learn far more and quickly if you stopped picking a different engine each week. finaly chatGPT is a good tool to help you fix your problems or issues aswell
  13. Kyle is trying to nudge you into giving it ago yourself first. And you will gain much more by trying it yourself first, then when you fail or get stuck etc and you recieve help. than just Kyle or whoever just doing it for you.
  14. yeah just as bad as running windows xp in this day and age lol
  15. you don't need to do that in v2 as they have a mysql and a mysqli db connection file and in the config/global file you just add the i to the require_once to call the right file. mccodes v1 doesn't have that from what I've seen looking through the git repo for it
  16. no mysql support within newer php version has been long dropped and now you either use mysqli or PDO. if you've used v2 aswell you would of done the same thing. basically you replace all mysql_whatever with mysqli_whatever
  17. yeah you need to use mysqli
  18. have you updated the cron links in the cronjob tab in cpanel?
  19. sorry my mistake, I thought you was asking if I could add it then lol not just asking if it was possible to add it
  20. as it is it couldn't but can edit the code so that it could do that. Easiest way would be to create a new table that has a timestamp of when it starts and end and change the code that within an if statement checks the date or current timestamp is greater than the start and less than end time. Prob could do this for you tomorrow and add that code to this to
  21. As a player I would like the ability to buy points/tokens etc and do what I want to do with them weather using them myself of selling some to other players. But as a game owner I've decided that donating will be instead like a Subscription like fallout 1st thye get all the usual stuff except money but I have given them the ability to exchange the given diamonds for in game cash or for account extras. In regards of items all my items have 2 refresh qtys, a global and personal qty which both reset every hour. i.e let's say I have an M4 with a global qty of 100 and a personal qty of 10 every hour. all items also have either a use limit or a hp limit, made sure weapons have a min and max level to use them but if your level is below you can still use but it's not effective. also withing the level I have a zone where you gain extra skill points for the weapon level type. i.e my M4 is between level 1 and 5 with the skill increase range between 2 and 3. so the user are always encouraged to keep buying new weapons, but if they didnt want to do the grind the could just pick one weapon and stay with that all the way through. To help with reducing the number of weapons in supply when you fight if you lose you will drop some/all weapons or the other player get some/all weapons any uninsured items not claimed by the other player goes back on sale in the condition it's in with a shop that specializes with that. any insured items not taken by the other player has a chance to be returned to that player once the claim has been handled. I have 4 speed: slow, normal fast and ASAP Slow costing .5 * of the item's cond and ASAP costing 2.5 * of the item's cond. With a time limit of between 1 - 3 hours for ASAP and 15 - 18 for Slow. Also I have been pondering if it would be worth having a central big pot of money, so that when money is generated in game it comes out of there and when the players buy properties, weapons, taxes etc it refills the pot. so that ther should only be a set amount in the economy but then doing this to also has it's own problems and pitfalls aswell. or the other end of this you implement some sort of gold linked or backed currency where your ingame points, diamonds etc is linked to a certain amount of currency so 1 point is always $1000 or something. but then this same it's problems and pitfalls to. just my 2 cents.
  22. Hi, I have just created a mod for my site where you can enable double exp gain for all players and have decided to release it for free to the community. any other game engines i.e Dayo want to use this with the game or add it to their engines feel free. /* add this to global_functions.php and any pages that give XP to the player replace that with this function call and remove queries from said pages I.e Attack outcome pages and crime completed */ function expGain($exp) { global $db, $ir, $set, $userid; ($set['double_xp'] == 'on') ? $exp *= 2 : $exp; $db->query("UPDATE users SET exp = exp + {$exp} WHERE userid = $userid"); } here is the function that needs to be added to staff main. I have made it that you can either add a time duration or set it to perma double XP. it will also send out an announcement to all player everytime double XP is activated and deactivated. Forgot to put in code block below you need to add case 'doublexp' doublexp(); break to the switch for action on main.php page /* Will need to change user_level to whatever number you have highest or use for admin/owners unless you want all staff to be able to activate it */ function doublexp() { global $db, $ir, $c, $h, $userid, $set; if ($ir['user_level'] < 5) { ErrorText("You cannot access this area.<br />[<a href='main.php'>Go Back</a>]"); } if(isset($_POST['submit'])) { if($_POST['status'] == 'on') { $_POST['time'] = abs((int) $_POST['time']); $db->query("UPDATE settings SET conf_value = 'on' WHERE conf_name = 'double_xp'"); if($_POST['time'] > 0) { $db->query("UPDATE settings SET conf_value = '{$_POST['time']}' WHERE conf_name = 'double_xp_time'"); $text = "Double XP has been enabled for the next {$_POST['time']} hours! Make sure you take advantage of it!"; } else { $db->query("UPDATE settings SET conf_value = '9999' WHERE conf_name = 'double_xp_time'"); $text = "Double XP has been enabled! Make sure you take advantage of it!"; } $db->query("INSERT INTO `announcements` VALUES('{$text}', unix_timestamp())"); $db->query("UPDATE `users` SET `new_announcements` = `new_announcements` + 1"); echo ' Double XP Enabled!<br /> <a href="main.php">Back</a>'; stafflog_add("Enabled double XP"); } else { $db->query("UPDATE settings SET conf_value = 'off' WHERE conf_name = 'double_xp'"); $text = "Double XP has now been disabled!"; $db->query("INSERT INTO `announcements` VALUES('{$text}', unix_timestamp())"); $db->query("UPDATE `users` SET `new_announcements` = `new_announcements` + 1"); echo ' Double XP Disabled!<br /> <a href="main.php">Back</a>'; stafflog_add("Disabled double XP"); } } else { echo"Double XP is currently ".($set['double_xp'] == 'on' ? 'on' : 'off')."<br /> Double XP time remaining: ".($set['double_xp_time'] > 0 ? ''.$set['double_xp_time'].' hours' : 'Forever')."<br />"; if($set['double_xp'] == 'on') { echo" <form action='?action=doublexp' method='post'> <input type='hidden' name='status' value='off' /> <input type='submit' name='submit' value='Disable Double XP' /> </form>"; } else { echo" <form action='?action=doublexp' method='post'> How long do you want to enable double XP for?<br/> leave blank if you have it run for as long as you want it to.<br /> <input type='hidden' name='status' value='on' /> Time hours:<input type='text' name='time' value=''/><br /> <input type='submit' name='submit' value='Enable Double XP' /> </form>"; } } } on either mainmenu where I have mine placed or you can place it on the header or whatever file you use for the template /* Don't forget to change div class to whatever you use */ if($set['double_xp'] == 'on') { echo' <div class="link"> <span style="color: red;">Double XP Active</span> </div>'; } Add this code to the hour cron /* in V1.0 $set['double_xp_time'] that equals 9999 is for when perma xp enabled will update in a never version that handles this another way */ if($set['double_xp'] == 'on' && $set['double_xp_time'] != 9999) { $db->query("UPDATE users SET double_xp_time = double_xp_time - 1 WHERE double_xp_time != 9999"); $db->query("UPDATE users SET double_xp = 'off' WHERE double_xp_time = 0"); }
  23. hey welcome to the club
×
×
  • Create New...