-
Posts
2,124 -
Joined
-
Last visited
-
Days Won
144
Content Type
Profiles
Forums
Events
Everything posted by Magictallguy
-
mccode-v2 Updated Newspaper - more than one page
Magictallguy replied to Magictallguy's topic in Free Modifications
Re: Updated Newspaper - more than one page I thought the pic would be funny too so yea :P -
Last updated: 30/06/20 Note: This is untested and was (re)written on no sleep. Please post any bugs below and I will repair. I'm sure this has been made before, and may have even been posted (unsure as to where) but I thought I'd post my version For this, you will need to overwrite your newspaper.php, edit staff_special.php, and run an SQL command. SQL Command Use the same naming scheme to add more pages: page#_content (where # is a unique page number) ALTER TABLE papercontent CHANGE content page1_content LONGTEXT NULL, ADD page2_content LONGTEXT NULL, ADD page3_content LONGTEXT NULL; INSERT INTO settings (conf_name, conf_value) VALUES ('newspaper_page_count', 3); newspaper.php <?php /* MC Codes v2 newspaper.php Multi-page newspaper with administrative extension Original code under MCC license Edits under DBAD: https://dbad-license.org/ */ require_once __DIR__ . '/globals.php'; $_GET['page'] = array_key_exists('page', $_GET) && is_numeric($_GET['page']) ? (int)$_GET['page'] : 1; /** * @param database $db the database wrapper object * @param array $set the game's settings * @param int $page the active page number * * @return string|null */ function get_page($db, $set, $page) { if ($page > $set['newspaper_page_count']) { return null; } $col = 'page' . $page . '_content'; $result = $db->query('SELECT ' . $col . ' FROM papercontent LIMIT 1'); if (!$db->num_rows($result)) { return null; } $content = $db->fetch_single($result); if (!$content) { return null; } return stripslashes(htmlspecialchars($content)); } ?> <h3 id="newspaper-title">The Newspaper - Page <?php echo $_GET['page']; ?></h3> <table class="table" style="width:75%;border-spacing:1px;" aria-describedby="newspaper-title"> <tr> <td><a href="job.php">Your Job</a></td> <td><a href="gym.php">Local Gym</a></td> <td><a href="halloffame.php">Hall of Fame</a></td> </tr> <tr> <th scope="col"><a href="newspaper.php?page=1">Page 1</a></th> <th scope="col"><a href="newspaper.php?page=2">Page 2</a></th> <th scope="col"><a href="newspaper.php?page=3">Page 3</a></th> </tr> <tr> <td colspan="3"><?php echo get_page($db, $set, $_GET['page']); ?></td> </tr> </table> <?php $h->endpage(); Administrative update Open: staff_special.php Find this function newspaper_form() { global $db,$ir,$c,$h,$userid; $q=$db->query("SELECT * FROM papercontent LIMIT 1"); $news=$db->fetch_single($q); print "<h3>Editing Newspaper</h3><form action='staff_special.php?action=subnews' method='post'> <textarea rows='7' cols='35' name='newspaper'>$news</textarea> <input type='submit' value='Change' /></form>"; } function newspaper_submit() { global $db,$ir,$c,$h,$userid; $news=$_POST['newspaper']; $db->query("UPDATE papercontent SET content='$news'"); print "Newspaper updated!"; stafflog_add("Updated game newspaper"); } And replace with /** * @param database $db * @return array|null */ function get_pages($db) { $data = []; $result = $db->query('SELECT * FROM papercontent'); $row = $db->fetch_row($result); foreach ($row as $key => $value) { $smolKey = str_replace('_content', '', $key); $data[$smolKey] = $value; } return !empty($data) ? $data : null; } /** * @param database $db * @param array $set * @return void */ function newspaper_form($db, $set) { $pages = get_pages($db); if (array_key_exists('submit', $_POST)) { $query = ''; $updated = []; for ($i = 1; $i <= $set['newspaper_page_count']; ++$i) { $page = 'page_' . $i; $_POST[$page] = array_key_exists($page, $_POST) && is_string($_POST[$page]) ? $_POST[$page] : ''; if ($_POST[$page] !== $pages[$page]) { $query .= ', ' . $page . '_content = \'' . $db->escape($_POST[$page]) . '\''; $updated[] = $i; } } if ($query !== '') { $count = count($updated); $query = substr($query, 2); $db->query('UPDATE papercontent SET ' . $query); stafflog_add('Updated game newspaper; ' . ($count === 1 ? 'page ' . $updated[0] : 'pages ' . implode(', ', $updated))); $pages = get_pages($db); } } ?> <h3 id="newspaper-title-edit">Editing Newspaper</h3> <form action="staff_special.php?action=editnews" method="post"> <?php for ($i = 1; $i <= $set['newspaper_page_count']; ++$i) { $content = stripslashes($pages['page' . $i]); $key = 'page' . $i; ?> <div> <label for="<?php echo $key; ?>">Page <?php echo $i; ?></label> <textarea name="<?php echo $key; ?>" id="<?php echo $key; ?>" rows="5" class="w-100" style="width:100%;"><?php echo $content; ?></textarea> </div> <?php } ?> <button type="submit" name="submit"> Update </button> </form> <?php }
-
Re: mccodes v2 i need serious help You do realise he's posted an unedited header.php xD
-
Re: y isnt der a jail in v1 That may also enunciated as "Indeed, it is" with or without the comma. Blimmin' 'ell, tha' was 'ard to type..
-
Re: v3 game engine Getting back to the topic's title.. [ul] v3 should be coming out sometime before this Christmas (2008) It will be coming with a licencing kit that's been encoded. All copyrights will be reserved and handled officially. It will be the most secure Game Engine created [/ul] (Nyna will have a lot of fun with this one...) It's uses the default mysql_query in some places and sprintf in others :) You've still got a little work to do but it uses advanced (AND CLEAN!!) code!
-
Re: Arsons City Owning Mod As I've already said in one of my other posts: Since when was this a flaming forum? - You want to flame? Do it in the right place. I seriously don't care what you think about other people, you're entitled to your opinion. But who said we wanted to hear it too?!
-
i better warn all game owners here
Magictallguy replied to Solid Snake's topic in General Discussion
Re: i better warn all game owners here Since when was CE a flaming board? People! I have a message for you... GROW UP! I'm 16 and I can treat people with respect. Why can't you? -
Re: Stats hack? I'll help you - free too :)
-
Re: MCcodes Needs Protection V3 is coming with an encoded licencing kit. Not telling you which code but 'tis a fun one. If the licence is an invalid one, it will delete all v3 files from your website. Dabomstew was feeling a little evil when he thought of that ;)
-
[mccode] NEW USERS IMAGE GALLERY FREE!!!!!
Magictallguy replied to canibalstew's topic in Free Modifications
Re: NEW USERS IMAGE GALLERY FREE!!!!! Look on Torn City (sorry for swearing ;)) too.. -
Re: An introduction to security Why are you escaping the maxbrave and stuff? Is that necessary? As for: UPDATE users SET `%s` = `%s` Does that SQL actually work? As you're not defining which row you're updating.. This should help in some way
-
Re: Need help with creating a php/mysql powered page. And back to the phpinfo() page...You've still yet to password protect/delete that..
-
Re: Simple CSS menu If you're using MC Codes v2 <?php include(dirname(__FILE__) . '/globals.php'); ?> <style type="text/css"> body {font-family:Arial, Helvetica, sans-serif, Tahoma; font-size:12px;} #vertmenu { font-family: Arial, Helvetica, sans-serif, Tahoma; font-size: 100%; width: 160px; padding: 0px; margin: 0px; } #vertmenu h1 { display: block; background-color:#FF9900; font-size: 100%; padding: 3px 0 5px 3px; border: 1px solid #000000; color: #333333; margin: 0px; width:159px; } #vertmenu ul { list-style: none; margin: 0px; padding: 0px; border: none; } #vertmenu ul li { margin: 0px; padding: 0px; } #vertmenu ul li a { font-size: 100%; display: block; border-bottom: 1px dashed #C39C4E; padding: 5px 0px 2px 4px; text-decoration: none; color: #666666; width:160px; } #vertmenu ul li a:hover, #vertmenu ul li a:focus { color: #000000; background-color: #eeeeee; } </style> </head> <body> <div id="vertmenu"> <h1>Menu items</h1> <ul> [*][url="#"]Item 1[/url] [*][url="#"]Item 2[/url] [*][url="#"]Item 3[/url] [*][url="#"]Item 4[/url] [*][url="#"]Item 5[/url] [*][url="#"]Item 6[/url] [/list] <ul> <? if($ir['donatordays > 0) { echo ' [*][url="#"]Donator 1[/url] [*][url="#"]Donator 2[/url] [*][url="#"]Donator 3[/url]'; } if($ir['user_level'] > 1) { echo ' [*][url="#"]Staff 1[/url] [*][url="#"]Staff 2[/url] [*][url="#"]Staff 3[/url] '; } ?> [*][url="#"]Item 7[/url] [/list] </div> And so on :P It's actually quite simple.. You must experiment! Experiment I tell you!
-
Re: Free 2 - Icons I feel I must agree with Saiyan!
-
Re: Free 2 - Icons This is true. Everyone give Nyna a break! She has a lot to do now!
-
Re: y isnt der a jail in v1 You say "i" instead of "I"! HA! xD
-
I want to make/own my own game, please help
Magictallguy replied to NickH440's topic in Other Programming
Re: I want to make/own my own game, please help Somebody shout me? :D -
Re: When is it ok to lie? Not necessarily - what if it was to save your life? xD
-
Re: login.php help! As it loads it's fine - all tables/pictures/whatnot are fine as they are joined together. But when the loading has finished, then it breaks up.. There's a problem between the communication from the login file (most likely the HTML) to the users browser itself
-
Re: Free 2 - Icons Because it's your mod? xD [me=Magictallguy]hides behind the nearest e-rock[/me]
-
Re: y isnt der a jail in v1 I can speak/type properly and I'm only 16!
-
Re: Staff Passwords. I have no comment - though if you could see my face, that would say it all...
-
Re: This arrray work? Nyna to the rescue! :P
-
Re: Free 2 - Icons Create one :P - Or use the donator.gif icon. Stick this with the other icon codes if ($do = $u['donatordays']) { $z = sprintf("%u Donator Days%s", $do, $do == 1 ? "" : "s"); $i[] = sprintf(" [url='donator.php'][img=FOLDERNAME/donator.png][/url] |", $z, $z); } And that should work untested though so if you get any error - which chances are you will :P - just say here and I'll actually test it next time :D
-
Re: Free 2 - Icons Works fine for me... I tested it on a v1 side folder of mine (for testing purposes only..) Works fine with me!