Jump to content
MakeWebGames

War_Hero

Members
  • Posts

    232
  • Joined

  • Last visited

Everything posted by War_Hero

  1. I think I'll take a look at this when it's released. I've had a gander at the demo and I like the look of it. :) Anything to get me away from V2 and into something better. I'm looking forward to some details. :)
  2. Thank you for finding that out. This isn't the part with if(get_magic_quotes_gpc() == 0) { etc, is it? Because I don't have that bit of code in my own globals.php, I don't believe...
  3. It must be something you're doing while installing it, as it works perfectly fine for me. I just don't understand why the picking of numbers doesn't work for you, or Mystical. Hmmm. ?(
  4. Can you clue the rest of us on how you got it working? Still the same for me Pick six numbers...click buy ticket...and this happens: "You either didn't select any numbers or you didn't select 6 numbers." No change.... I even used different browsers and still no luck. :( I might be able to provide some assistance if I can see the problem first hand. Because if you have copied and pasted the code as it is, which I'm assuming you have done, then there should be no problems. Just a quick question: when you press Lucky Dip, do all of the checkboxes become disabled and the Lucky Dip button become disabled?
  5. The first error is fixed. I forgot to include the VALUES before the (50,10,0). Doh. Hmm. By the sounds of it, it would seem the Javascript isn't working. You shouldn't be able to submit the ticket unless you have selected 6 numbers. It works for me. Hmm.....
  6. Thank you all for the comments. :) I hope you all like the feature. If/when one of you install it, please let me know if all the aspects of the mod work. It works on my end, I'd just like to ensure it will work elsewhere. :)
  7. Hi all! It's been ages since I last posted on here, so I thought I'd contribute a feature I've been working on. I searched for lottery mods already on here, and unless I didn't look properly, I couldn't see any free ones that actually allows the user to choose their own numbers. Description: Upon going onto lottery.php, the user will be presented with a table of checkboxes, numbered 1 to 46. The info above the table will ask them to select 6 of their own numbers or press Lucky Dip to have them randomly selected for them. This feature uses Javascript. If the user opts to select the numbers themselves, they cannot press Buy Ticket until 6 boxes have been ticked. When 6 have been ticked, all other boxes become disabled and they can buy the ticket. If a box is then unticked, the others become enabled and the Buy Ticket button becomes disabled. The Lucky Dip randomly selects 6 numbers, ticks the correct boxes and disables them, and enables the Buy Ticket button. A reset button is provided to clear any boxes ticked, whether manually or by the Lucky Dip. The price of each lottery ticked can be edited via the Staff feature I have made, so no edit in the file will be needed. Also, the ticket limit can also be altered via the staff feature. The lottery numbers are drawn (with my cron settings) every Saturday night at 20:00. If no tickets match all 6 numbers, there will be a rollover. This will continue to happen until all 6 numbers are matched. Talking of the cron, the numbers are drawn from the cron_lottery.php file. Right, time for the installation...it shouldn't be too difficult: Step 1 Run these SQLs: CREATE TABLE IF NOT EXISTS lotterytickets ( id INTEGER(11) NOT NULL AUTO_INCREMENT, userid INTEGER(11) NOT NULL, numbers TEXT NOT NULL, bought INTEGER(11) NOT NULL, luckydip TINYINT(1) NOT NULL, correct INTEGER(11) NOT NULL DEFAULT -1, PRIMARY KEY (id) ) ENGINE = MyISAM DEFAULT CHARSET = utf8; CREATE TABLE IF NOT EXISTS lotterydone ( ldID INTEGER(11) NOT NULL AUTO_INCREMENT, ldNUMBERS TEXT NOT NULL, ldZERO INTEGER(11) NOT NULL, ldONE INTEGER(11) NOT NULL, ldTWO INTEGER(11) NOT NULL, ldTHREE INTEGER(11) NOT NULL, ldFOUR INTEGER(11) NOT NULL, ldFIVE INTEGER(11) NOT NULL, ldSIX INTEGER(11) NOT NULL, ldPOT DOUBLE NOT NULL, ldPOTWIN TEXT NOT NULL, ldTIME INTEGER(11) NOT NULL, PRIMARY KEY (ldID) ) ENGINE = MyISAM DEFAULT CHARSET = utf8; CREATE TABLE IF NOT EXISTS lotteryDetails ( lotprice INTEGER(11) NOT NULL DEFAULT 50, lotlimit INTEGER(11) NOT NULL DEFAULT 10, lotjackpot DOUBLE NOT NULL ) ENGINE = MyISAM DEFAULT CHARSET = utf8; INSERT INTO lotteryDetails VALUES(50,10,0); Step 2 Create a new cron (however it is you do it, cPanel, Direct Admin, etc) with these values: Minute: 0 Hour: 20 Day of Month: * Month: * Day of Week: 6 Command: Erm, yeah! :) Step 3 Create a file called cron_lottery.php: <?php include ("./config.php"); global $_CONFIG; if($_GET['code'] != $_CONFIG['code']) { die(""); } define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; include("./global_func.php"); $lotteryDetails = mysql_query("SELECT * FROM lotteryDetails"); $ld = mysql_fetch_assoc($lotteryDetails); $winNumbers = array(); for($i = 0; $i < 6; $i++) { $num = mt_rand(1,46); if(empty($winNumbers)) { array_push($winNumbers, $num); } else { while(in_array($num, $winNumbers)) { $num = mt_rand(1,46); } array_push($winNumbers, $num); } } sort($winNumbers); $wn = implode(",", $winNumbers); $getTickets = mysql_query("SELECT * FROM lotterytickets"); $jackpot = (mysql_num_rows($getTickets) * $ld['lotprice']) + $ld['lotjackpot']; $zero = 0; $one = 0; $two = 0; $three = 0; $four = 0; $five = 0; $six = 0; $users = array(); while($gt = mysql_fetch_assoc($getTickets)) { $yourNumbers = explode(",", $gt['numbers']); sort($yourNumbers); $uID = abs(@intval($gt['userid'])); if(empty($users)) { array_push($users, $uID); } else { if(!in_array($uID, $users)) { array_push($users, $uID); } } $correct = 0; foreach($yourNumbers as $yn) { if(in_array($yn, $winNumbers)) { $correct++; } } if($correct == 0) { $zero++; } if($correct == 1) { $one++; } if($correct == 2) { $two++; } if($correct == 3) { $three++; } if($correct == 4) { $four++; } if($correct == 5) { $five++; } if($correct == 6) { $six++; } $updateTicket = ("UPDATE lotterytickets SET correct = ". abs(@intval($correct)) ." WHERE id = ". abs(@intval($gt['id'])) .""); mysql_query($updateTicket) OR die("Could not update ticket ID ". $gt['id'] .": ". mysql_error()); } $potWin = array(); $countUsers = count($users); if(!empty($users)) { for($ui = 0; $ui < $countUsers; $ui++) { $selectCorrect = mysql_query("SELECT correct, id, userid, numbers FROM lotterytickets WHERE userid = ". abs(@intval($users[$ui])) .""); $event = "[b]<u>The winning numbers are: ". $wn .".</u>[/b]"; $event .= " The results from your ". abs(@intval(mysql_num_rows($selectCorrect))) ." lottery tickets:"; $nowin = array(0,1,2); $total = 0; while($sc = mysql_fetch_assoc($selectCorrect)) { $event .= " [b]Ticket numbers: ". mysql_real_escape_string($sc['numbers']) ."[/b]"; if(in_array($sc['correct'], $nowin)) { $event .= "[i] -- ". $sc['correct'] ." matching number(s) (no winnings)[/i]"; } else { if($sc['correct'] == 3) { $winnings = ($ld['lotprice'] + (floor($ld['lotprice'] * 0.5))); } if($sc['correct'] == 4) { $winnings = ($ld['lotprice'] + (floor($ld['lotprice'] * 0.8))); } if($sc['correct'] == 5) { $winnings = ($ld['lotprice'] + (floor($ld['lotprice'] * 1.4))); } if($sc['correct'] == 6) { $winnings = ($ld['lotprice'] + (floor($jackpot/$six))); array_push($potWin, $users[$ui]); } $event .= "[i] -- ". $sc['correct'] ." matching numbers (Won \$". number_format($winnings) .")[/i]"; $total += $winnings; } } $event .= " You won a total of \$". number_format($total) .".<hr />"; $subevent = mysql_real_escape_string(trim($event)); event_add($users[$ui], $subevent); $giveWinnings = ("UPDATE users SET money = money + ". abs(@intval($total)) ." WHERE userid = ". abs(@intval($users[$ui])) .""); mysql_query($giveWinnings) OR die("Could not give userid ". $ui ." money: ". mysql_error()); } if(!empty($potWin)) { $winners = implode(",", $potWin); } elseif(empty($potWin)) { $winners = "NA"; } $insertDone = ("INSERT INTO lotterydone (ldID, ldNUMBERS, ldZERO, ldONE, ldTWO, ldTHREE, ldFOUR, ldFIVE, ldSIX, ldPOT, ldPOTWIN, ldTIME) VALUES('','". $wn ."', ". $zero .", ". $one .", ". $two .", ". $three .", ". $four .", ". $five .", ". $six .", ". $jackpot .", '". $winners ."', UNIX_TIMESTAMP())"); mysql_query($insertDone) OR die("Could not insert into lottery done: ". mysql_error()); if($six == 0) { $jp = $jackpot; } elseif($six > 0) { $jp = 0; } $updateJackpot = ("UPDATE lotteryDetails SET lotjackpot = ". abs(@intval($jp)) .""); mysql_query($updateJackpot) OR die("Could not update jackpot: ". mysql_error()); } else { event_add(1, "No lottery this week. :("); } $truncate = ("TRUNCATE TABLE lotterytickets"); mysql_query($truncate) OR die("Could not truncate: ". mysql_error()); ?> Step 4 Create a file called lottery.php: <?php include_once(DIRNAME(__FILE__) ."/globals.php"); ?> <script language = "javascript" type = "text/javascript"> var ticked = new Array(); function tickBox(val) { var theid = "id" + val; if(document.getElementById(theid).checked == true) { ticked.push(theid); } else if(document.getElementById(theid).checked == false) { for(var sp = 0; sp < ticked.length; sp++) { if(ticked[sp] == theid) { ticked.splice(sp,1); } } } if(ticked.length >= 6) { for(var count = 1; count < 47; count++) { var countID = "id" + count; if(document.getElementById(countID).checked == false) { document.getElementById(countID).disabled = true; } document.getElementById("submit").disabled = false; } } else if(ticked.length < 6) { for(var count = 1; count < 47; count++) { var countID = "id" + count; document.getElementById(countID).disabled = false; } document.getElementById("submit").disabled = true; } } function formReset() { for(var n = 1; n < 47; n++) { var id = "id" + n; document.getElementById(id).checked = false; document.getElementById(id).disabled = false; } document.getElementById("dip").disabled = false; document.getElementById("submit").disabled = true; document.getElementById("luckysub").checked = false; document.getElementById("hiddenNums").value = ""; ticked.splice(0,ticked.length); } function luckyDip() { var luckyarr = new Array(); for(var d = 1; d < 47; d++) { var did = "id" + d; document.getElementById(did).checked = false; document.getElementById(did).disabled = true; } for(var c = 1; c < 7; c++) { var box = Math.floor((46)*Math.random()) + 1; var boxid = "id" + box; if(document.getElementById(boxid).checked == false) { document.getElementById(boxid).checked = true; luckyarr.push(box); } else { box = Math.floor((46)*Math.random()) + 1; boxid = "id" + box; while(document.getElementById(boxid).checked == true) { box = Math.floor((46)*Math.random()) + 1; boxid = "id" + box; } document.getElementById(boxid).checked = true; luckyarr.push(box); } } document.getElementById("dip").disabled = true; document.getElementById("luckysub").checked = true; document.getElementById("submit").disabled = false; document.getElementById("hiddenNums").value = luckyarr; } </script> <style type = "text/css"> .lotnum { width: 100%; text-align: center; font-size: 10px; } .luckdip { background-color: #E66C2C; color: #000000; } .odd { background-color: #306EFF; } .even { background-color: #4AA02C; } #bought { font-size: 20px; font-weight: bold; font-variant: small-caps; } </style> <?php $lotteryDetails = mysql_query("SELECT * FROM lotteryDetails"); $lD = mysql_fetch_object($lotteryDetails); define('TICKETCOST', $lD->lotprice); define('LIMIT', $lD->lotlimit); if(!$_POST['submit']) { $all = mysql_query("SELECT id FROM lotterytickets"); $numall = mysql_num_rows($all); $jackpot = ($numall * TICKETCOST) + $lD->lotjackpot; $yourTicks = mysql_query("SELECT id FROM lotterytickets WHERE userid = ". abs(@intval($ir['userid'])) .""); $numYourTicks = mysql_num_rows($yourTicks); print "<div align = 'center'>"; print " It will cost you \$". number_format(TICKETCOST) ." to buy one lottery ticket, and you can only have ". number_format(LIMIT) ." tickets at any one time.</p>"; $grammar = ($numYourTicks != 1) ? "tickets" : "ticket"; print "You currently have ". number_format($numYourTicks) ." ". $grammar .".</p>"; print " The current jackpot is at \$". number_format($jackpot) .".</p>"; print " Select 6 numbers from below or click on Lucky Dip to have them randomly chosen for you!</p>"; print "<form action = 'lottery.php' method = 'POST' name = 'boxes'>"; print "<table class = 'lotnum'>"; $rows = 0; $value = 1; while($rows <= 10) { print "<tr>"; $cols = 0; while($cols <= 4) { $colclass = $cols+1; $class = ($value % 2 == 0) ? "even" : "odd"; if($value <= 46) { $id = "id".$value; print "<td class = '". $class ."'>". $value ." <input type = 'checkbox' name = 'numbers[]' id = '". $id ."' value = '". $value ."' onClick = \"tickBox(this.value);\" /></td>"; $value++; $cols++; } else { $cols++; } } print "</tr>"; $rows++; } print " <tr> <td><input type = 'button' name = 'lucky' id = 'dip' value = 'Lucky Dip' onClick = \"luckyDip();\" /></td> <td><input type = 'button' name = 'resetForm' id = 'resetForm' value = 'Reset' onClick = \"formReset();\" /></td> <td colspan = '2'><input type = 'submit' name = 'submit' id = 'submit' value = 'Buy Ticket' disabled = 'disabled' /></td> <td class = 'luckdip'>Lucky Dip<input type = 'checkbox' name = 'luckysub' value = 'lucky' id = 'luckysub' disabled = 'disabled' /></td> </tr>"; print "</table> <input type = 'hidden' id = 'hiddenNums' name = 'hiddenNums' value = '' /> </form>"; print "</div>"; } else { $tickets = mysql_query("SELECT userid FROM lotterytickets WHERE userid = ". abs(@intval($ir['userid'])) .""); if($_POST['hiddenNums'] == '') { $countNums = count($_POST['numbers']); $numbers = $_POST['numbers']; $lucky = ""; $dip = 0; } elseif($_POST['hiddenNums'] != '') { $explode = explode(",",$_POST['hiddenNums']); $countNums = count($explode); $numbers = $explode; $lucky = "Lucky Dip"; $dip = 1; } if($countNums != 6 || empty($numbers)) { print " You either didn't select any numbers or you didn't select 6 numbers.</p> <a href = 'lottery.php'>Back</a></p>"; } elseif($ir['money'] < TICKETCOST) { print " You need to have \$". number_format(TICKETCOST) ." to buy a lottery ticket.</p> <a href = 'lottery.php'>Back</a></p>"; } elseif(mysql_num_rows($tickets) >= LIMIT) { print " You can only have ". number_format(LIMIT) ." lottery tickets at once.</p> <a href = 'lottery.php'>Back</a></p>"; } else { sort($numbers); $punct = 0; $store = ""; print "<p id = 'bought'>Ticket bought!</p>"; print " Your ". $lucky ." numbers are: "; for($i = 0; $i < $countNums; $i++) { $n = abs(@intval($numbers[$i])); if($punct == 5) { $ender = "."; $store .= $n; } else { $ender = ", "; $store .= $n .","; } print $n . $ender; $punct++; } print "</p>"; print " <a href = 'lottery.php'>Back</a></p>"; $insertTicket = ("INSERT INTO lotterytickets (id, userid, numbers, bought, luckydip) VALUES('',". abs(@intval($ir['userid'])) .", '". mysql_real_escape_string($store) ."', UNIX_TIMESTAMP(), ". abs(@intval($dip)) .")"); mysql_query($insertTicket) OR die("Could not insert ticket: ". mysql_error()); $takeMoney = ("UPDATE users SET money = money - ". abs(@intval(TICKETCOST)) ." WHERE userid = ". abs(@intval($ir['userid'])) .""); mysql_query($takeMoney) OR die("Could not take money: ". mysql_error()); } } $h->endpage(); ?> Step 5 Create a file called staff_lottery.php: <?php include_once(DIRNAME(__FILE__) ."/sglobals.php"); print "<p style = 'font-size: 22px;font-weight: bold;font-variant: small-caps;'>Editing Lottery Game(s)</p> <hr />"; if($ir['user_level'] != 2) { print " You cannot access this staff feature.</p> <a href = 'staff.php'>Back</a></p>"; $h->endpage(); exit(); } switch($_GET['action']) { // I've used switch() because I'll add more to this feature in the future. :) case "view": view(); break; default: view(); break; } function view() { global $ir, $userid, $c, $h; if(!$_POST['lotcost'] && !$_POST['lotlimit']) { $lottery = mysql_query("SELECT lotprice, lotlimit FROM lotteryDetails"); $l = mysql_fetch_object($lottery); $cost = "\$". number_format($l->lotprice); print " The current lottery ticket price is \$". number_format($l->lotprice) .". To change it, edit the field below:</p> <div align = 'center'> <form action = 'staff_lottery.php?action=view' method = 'POST'> Ticket Price: <input type = 'text' name = 'lotcost' value = '". $cost ."' /> Lottery Limit: <input type = 'text' name = 'lotlimit' value = '". $l->lotlimit ."' /> <input type = 'submit' name = 'sub' value = 'Change Lottery Price' /> </form> </div>"; } else { $lotcost = $_POST['lotcost']; $lotlimit = $_POST['lotlimit']; $replaces = array(",",".","$","£","\"","'"," ","=","%","*"); foreach($replaces as $rp) { $lotcost = str_replace($rp, "", $lotcost); $lotlimit = str_replace($rp, "", $lotlimit); } $lotcost = abs(@intval($lotcost)); $lotlimit = abs(@intval($lotlimit)); if($lotcost > 0) { print "<p style = 'color: #347C17;font-weight: bold;'>You have changed the lottery ticket cost to \$". number_format($lotcost) .".</p>"; $updateCost = ("UPDATE lotteryDetails SET lotprice = ". $lotcost .""); mysql_query($updateCost) OR die("Could not update lottery price: ". mysql_error()); } else { print "<p style = 'color: #FF0000;font-weight: bold;'>The price needs to be greater than 0!</p>"; } if($lotlimit >= 5) { print "<p style = 'color: #347C17;font-weight: bold;'>You have changed the lottery ticket limit to ". number_format($lotlimit) .".</p>"; $updateLimit = ("UPDATE lotteryDetails SET lotlimit = ". $lotlimit .""); mysql_query($updateLimit) OR die("Could not update limit: ". mysql_error()); } else { print "<p style = 'color: #FF0000;font-weight: bold;'>The limit needs to be greater than 5.</p>"; } print " <a href = 'staff_lottery.php'>Back</a></p>"; } } $h->endpage(); ?> And you're done. :) I will (hopefully) be adding more to this feature, for free. I intend on improving the staff feature, creating a way in which users can see previous lottery results and also implement other games, such as the Dream Number, etc. I have tested this feature, and it works. But as always, if there are any bugs, please report them here and I will fix them (or attempt to!). And please feel free to contribute any other ideas. If you have any questions about the feature, please don't hesitate to ask. :)
  8. I've attempted to use ProcessingJS, but to no successful. I fiddled about with a few things, but couldn't for the life of me get it to work. I copied the example they provided exactly, just changed their example code with mine. I was able to get the example working perfectly, just not my program. :( My program is a 3D etch-a-sketch. I thought that it might have been the 3D aspect, so I temporarily made it 2D, but that still didn't work. So I then removed the image that first appears, and it still didn't work. Can anyone offer any advice? It will be highly appreciated. :) I can post any code, if need be.
  9. Thank you very much. I shall try that and let you know how it goes. I'll admit, probably won't get done til Sunday as I've got a busy weekend. :P Thanks again though, for the advice. :)
  10. The format is .exe :) Thanks for the link Jordan, I'll have a look at it when I can. :) Edit: Only saw the last post after I submitted mine. Thank you a_bertrand. The program was written using Processing, if that's any help. :)
  11. Hi all. A quick intro to my problem: I've got a website up and running for my University group where a 3D etch-a-sketch program can be downloaded and run. However, my group and I would also like that application to be run from the website itself....so the user can test the program out before downloading it. So my question is: how do I go about embedding the program/application into my website? I've tried doing some research, but that hasn't turned up any results. But that's probably down to me not searching for the right thing. Any help will be highly appreciated...even if it's just pointing me in the right direction and not actually telling me how it's done. :) Many thanks.
  12. I've just pre-registered! :) I must say, the login looks brilliant. It is incredibly neat and very well presented. I look forward to seeing the in-game design! Good luck with the game, I'm sure it'll all pay off. :)
  13. I've managed to get it to fade in now :thumbsup: . Only problem I have now is that the <span> that says whether or not the guess was correct (just a simple thing to test my checks) is not formatted. So, for example, if I guessed correctly, the word Correct! should appear in green with small-caps, but it doesn't. The word Correct! appears, just without styling. Any ideas why this would be happening? Thanks for the help, guys. I really appreciate it. :)
  14. Hmm, I'm not getting anywhere with this. ?( I've tried several things, and nothing is working. I'll attach the code (because every time I tried posting it, it was stretched over 2 lines! :?: ). If someone could take a look at it and see where I'm going wrong, I'd highly appreciate it if you could point me in the right direction. :)   Any help would be brilliant and much appreciated. :)
  15. OK, I'll take that into account. :) I've never used jquery before, so it'll be a case of trial and error really...until I get it right. That's gonna be fun! haha Thank you for the advice...it's made me rethink how I'm going to present the game. I can see this is going to take me a while, with familiarising myself with it all. Ohh, I see. That's handy. Thank you! :D
  16. As I'm sorta new to AJAX, I probably haven't done it in the most efficient way. :) haha At the moment (and just so you know, I haven't included many rules just yet. I wanted to get the AJAX working first. :)) the first card is shown with buttons that say Lower and Higher. When one of them is clicked, the AJAX 'kicks' in, and another card is randomly selected from my table of cards. Obviously the one that was just shown cannot be chosen. I then determine whether the drawn card is higher or lower than the previous and check which option they chose. The drawn card is displayed with the result. It is this part I'd like to fade in...when the new card and the result is shown. Just to add a nice little effect. I shall take your advice into consideration and not use jquery. I've not used it before (do you have to 'install' it before using it! lol). But yes, I would like the user to not have to refresh the page...and I seem to have that working as well, just to need to apply rules and checks. haha
  17. Hi all. I'm creating an AJAX card game (higher/lower). I've got the game itself sorted, sort of, but am more focused on the appearance of it at the moment. I'd like the next image to fade in rather than just appear. I've done some research and by what I've seen, I can use the JQUERY method fadeIn()...is this correct? I'm newish to Javascript and AJAX, and am absolutely useless when it comes to effects like these. How would I go about fading in the response text the AJAX produces? Any help will be highly appreciated. Much thanks. :) PS: if you need to see any code, etc...please say so and I'll post it up.
  18. I was able to do it. :) yay I added the $h->maincontent(); bit, and then had to edit a couple of table cells because the images were wrong. Eventually got it to work. Thank you so much for the help. :) I really appreciate it.
  19. I'll have a look when I get home, as I'm in school at the moment and can't get onto my server. Grr.   I had a thought....I created the function maincontent(). It wasn't in my old header before I tried using this template. I added $h->maincontent(); to globals.php but not to sglobals.php. Do you think that could be a possible cause to the problem?   Thank you for your help. I very much appreciate it. :)
  20. You are a star! :D Thank you so much. That solved the content bit on each page. :) How would I go about solving the layout issue with the staff page, as that is still 'squiff', as it were? Thanks again!
  21. Thanks for the advice. :) I'm sort of following what you mean. Here is my index.php <?php $housequery=1; include "globals.php"; print "<h3>General Info:</h2>"; $exp=(int)($ir['exp']/$ir['exp_needed']*100); $m=$db->query("SELECT * FROM users WHERE userid='{$ir['married']}'"); $par=$db->fetch_row($m); if($ir['married'] != 0) { $partner= "[url='viewuser.php?u={$par[']<font color=green>{$par['username']}</font>[/url] [[url='partner.php']Manage[/url]]"; } else { $partner= "<font color=red>N/A</font>"; } print "<table><tr><td>[b]Name:[/b] {$ir['username']}</td><td>[b]Race:[/b] {$ir['race']}</td></tr><tr> <td>[b]Level:[/b] {$ir['level']}</td> <td>[b]Exp:[/b] {$exp}%</td></tr><tr> <td>[b]Money:[/b] $fm</td> <td>[b]HP:[/b] {$ir['hp']}/{$ir['maxhp']}</td></tr> <tr><td>[b]Property:[/b] {$ir['hNAME']}</td></tr> <tr><td><font color=gold>[b]Golden Coins:[/b] {$cm}</font></td><td><font color=purple>[b]Rubies:[/b] {$ir['ruby']}</font></td></tr> <tr><td>[b]Crime XP:[/b] {$ir['crimexp']}</td><td /><a href = 'mywarnings.php' title = 'View your warnings' /><font color = red>[b]MY WARNINGS[/b]</font></a></td></tr><td>[b]Married:[/b] $partner</td></tr></table>"; print "<hr><h3>Stats Info:</h3>"; $ts=$ir['strength']+$ir['agility']+$ir['guard']+$ir['labour']+$ir['IQ']; $ir['strank']=get_rank($ir['strength'],'strength'); $ir['agirank']=get_rank($ir['agility'],'agility'); $ir['guarank']=get_rank($ir['guard'],'guard'); $ir['labrank']=get_rank($ir['labour'],'labour'); $ir['IQrank']=get_rank($ir['IQ'],'IQ'); $tsrank=get_rank($ts,'strength+agility+guard+labour+IQ'); $ir['strength']=number_format($ir['strength']); $ir['agility']=number_format($ir['agility']); $ir['guard']=number_format($ir['guard']); $ir['labour']=number_format($ir['labour']); $ir['IQ']=number_format($ir['IQ']); $ts=number_format($ts); print "<table><tr><td><font color=red>[b]Strength:[/b] {$ir['strength']}</font> [Ranked: {$ir['strank']}]</td><td><font color=blue>[b]Agility:[/b] {$ir['agility']}</font> [Ranked: {$ir['agirank']}]</td></tr> <tr><td><font color=green>[b]Guard:[/b] {$ir['guard']}</font> [Ranked: {$ir['guarank']}]</td><td><font color=brown>[b]Labour:[/b] {$ir['labour']}</font> [Ranked: {$ir['labrank']}]</td></tr> <tr><td><font color=white>[b]IQ: [/b] {$ir['IQ']}</font> [Ranked: {$ir['IQrank']}]</td><td>[b]Total stats:[/b] {$ts} [Ranked: $tsrank]</td></tr></table>"; if(isset($_POST['pn_update'])) { $db->query("UPDATE users SET user_notepad='{$_POST['pn_update']}' WHERE userid=$userid"); $ir['user_notepad']=stripslashes($_POST['pn_update']); print "<hr>[b]Personal Notepad Updated![/b]"; } print "<hr>Your Personal Notepad:<form action='index.php' method='post'> <textarea rows='10' cols='50' name='pn_update'>".htmlspecialchars($ir['user_notepad'])."</textarea> <input type='submit' value='Update Notes' /></form>"; $h->endpage(); ?>   And, if needed, my globals.php <?php /*--------------------------------- -- MCCodes 2.0 -- By Dabomstew ---------------------------------*/ session_start(); ob_start(); if(get_magic_quotes_gpc() == 0) { foreach($_POST as $k => $v) { $_POST[$k]=addslashes($v); } foreach($_GET as $k => $v) { $_GET[$k]=addslashes($v); } } require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.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']; } $domain=$_SERVER['HTTP_HOST']; global $jobquery, $housequery; if($jobquery) { $is=$db->query("SELECT u.*,us.*,j.*,jr.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON jr.jrID=u.jobrank WHERE u.userid=$userid"); } else if($housequery) { $is=$db->query("SELECT u.*,us.*,h.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE u.userid=$userid"); } else { $is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid"); } $ir=$db->fetch_row($is); if($ir['force_logout']) { $db->query("UPDATE users SET force_logout=0 WHERE userid=$userid"); session_unset(); session_destroy(); header("Location: login.php"); exit; } global $macropage; if($macropage && !$ir['verified'] && $set['validate_on']==1) { header("Location: macro1.php?refer=$macropage"); exit; } check_level(); $h = new headers; $h->startheaders(); $fm=money_formatter($ir['money']); $cm=money_formatter($ir['crystals'],''); $lv=date('F j, Y, g:i a',$ir['laston']); global $atkpage; if($atkpage) { $h->userdata($ir,$lv,$fm,$cm,0); } else { $h->userdata($ir,$lv,$fm,$cm); } global $menuhide; if(!$menuhide) { $h->menuarea(); } $h->maincontent(); ?>   I've probably got all of this arse-backwards. I'm calling the maincontent function in the globals, but I'm not sure if it's correct or if the index.php is correct because of the new header. Hmmm. "/
  22. Hi all. I've downloaded a theme/template based in HTML and I'm desperately trying to get it to work with my game, but I'm having no luck. The content of each page is 'outside' the actual layout. You'll probably understand more if you see a picture: The stuff above and below the actual template should be inside the template where it is Layout Info, etc. Another issue I have is with the staff page, which is completely screwed: Below is my header script: <?php class headers { function startheaders() { $key = substr($key = basename($_SERVER['PHP_SELF']), 0, strpos($key, ".")); $page = isset($table[$key]) ? $table[$key] : " "; global $ir, $set; print <<<EOF <html> <head> <title>Desert Storm V1.0 - Layout (c) senkouryu.net</title> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> <style type = 'text/css' /> <!-- body {background-color:#D4C9A8;} table, td {font-family:Verdana, Tahoma; font-size:10px; color:#382704;} a {color:#6E5D2D;} a:hover {color:#99875B;} .navhead {display:block; font-weight:bold; text-align:center; color:ccc; border:1px solid #111; background:url(Images/banner.gif);} --> </style> </head> <body bgcolor='#D4C9A8' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'> <center> <table background='Images/overall_bg.gif' id='Table_01' width='638' border='0' cellpadding='0' cellspacing='0'> EOF; } function userdata($ir,$lv,$fm,$cm,$dosessh=1) { global $db,$c,$userid, $set; $IP = $_SERVER['REMOTE_ADDR']; $db->query("UPDATE users SET laston=unix_timestamp(),lastip='$IP' WHERE userid=$userid"); if(!$ir['email']) { global $domain; die ('<body>Your Account May Be Broken. Please Contact Your E-Mail Stating Your Username And User ID.'); exit; } if($dosessh && ($_SESSION['attacking'] || $ir['attacking'])) { print "You Lost All Your EXP For Running From A Fight Like A Coward."; $db->query("UPDATE users SET exp=0,attacking=0 WHERE userid=$userid"); $_SESSION['attacking']=0; } $enperc=(int) ($ir['energy']/$ir['maxenergy']*100); $wiperc=(int) ($ir['will']/$ir['maxwill']*100); $experc=(int) ( $ir['exp']/$ir['exp_needed']*100); $brperc=(int) ($ir['brave']/$ir['maxbrave']*100); $hpperc=(int) ($ir['hp']/$ir['maxhp']*100); $enopp=100-$enperc; $wiopp=100-$wiperc; $exopp=100-$experc; $bropp=100-$brperc; $hpopp=100-$hpperc; $d=''; $_GET['ID'] = abs(@intval($_GET['ID'])); $_GET['viewforum'] = abs(@intval($_GET['viewforum'])); $_GET['viewtopic'] = abs(@intval($_GET['viewtopic'])); $stmr=''; $u=$ir['username']; if($ir['user_level'] > 1) { $stmr="[img=staffimage here]"; }; if($ir['donatordays']) { $u = "<font color=red>{$ir['username']}</font>';$d='[img=donator.gif]"; } $gn=''; global $staffpage; if($ir['fedjail']) { $q=$db->query("SELECT * FROM fedjail WHERE fed_userid=$userid"); $r=$db->fetch_row($q); die("[b]<hr /><font color=red size=+1>You Have Been Dragged Off To {$set['game_name']} Federal Prision For {$r['fed_days']} Day(s).<hr /> Reason: {$r['fed_reason']}</font>[/b]</body></html>"); } print <<<OUT <tr> <td colspan='5'> [img=Images/index_01.gif]</td> </tr> <tr> <td colspan='5'> [img=Images/banner.gif]</td> </tr> <tr> <td colspan='5'> [img=Images/index_03.gif]</td> </tr> <tr> <td colspan='4'> [img=Images/index_04.gif]</td> <td rowspan='2'> [img=Images/index_05.gif]</td> </tr> <tr> <td> [img=Images/index_06.gif]</td> <td> [img=Images/index_07.gif]</td> <td> [img=Images/index_08.gif]</td> <td> [img=Images/index_09.gif]</td> </tr> <tr> <td valign='top'> [img=Images/index_10.gif]</td> <td valign='top' background='Images/nav.gif' style='background-repeat:no-repeat;' width='127' height='23'> OUT; } function menuarea() { include "mainmenu.php"; global $ir, $c; print "<div class='navhead'>Nav Bar</div> </td> <td valign='top'> [img=Images/index_12.gif]</td> <td valign='top' background='Images/nav.gif' style='background-repeat:no-repeat;' width='127' height='23'>"; } function smenuarea() { include "smenu.php"; global $ir, $c; print "<div class='navhead'>Staff Bar</div> </td> <td valign='top' background='Images/content.gif' style='background-repeat:no-repeat;' width='443' height='23'>"; } function maincontent() { global $ir, $c, $db; print "<div class='navhead'>Layout Info</div> [b]Layout Name:[/b] Desert Storm V1 [b]Type:[/b] Tables, Div [b]Iframes:[/b] NO [b]Download Requirements:[/b] - No requirments needed. [b]Features:[/b] - A Desert theme [b]Description:[/b] This simple layout is practice for me, a practice with color combinations that I haven\'t use, like this, a yellow-brownish-sand-like, for a desert theme :) <div class='navhead'>Copyright & Final Comments</div> This layout is copyrighted by SenkouRyu, don\'t edit the copyright info anywhere! Be sure to check [url='http://www.senkouryu.net']http:\//www.senkouryu.net[/url] for more layouts like this or even better ones! </td> <td valign='top'> [img=Images/index_14.gif]</td> </tr> <tr> <td colspan='3'> [img=Images/index_17.gif]</td> <td> [img=Images/index_18.gif]</td> <td> [img=Images/index_19.gif]</td> </tr> <tr> <td> [img=Images/index_20.gif]</td> <td> [img=Images/index_21.gif]</td> <td> [img=Images/index_22.gif]</td> <td> [img=Images/index_23.gif]</td> <td> [img=Images/index_24.gif]</td> </tr>"; } function endpage() { global $db; print <<<OUT1 </table> </center> </body> </html> OUT1; } } ?> Any advice or help will be highly appreciated. I honestly have tried getting this to work, but to no avail. Layouts and templates really aren't my forte. Thank you, Emlyn
  23. Thank you guys for your help. :) I really appreciate it. I've managed to get it to work...well, sort of. The template is visible, but the content of the page is not displayed where I would like it to go. "/ This is what it looks like: I don't know how to get the info above and below main area actually into the area that says Layout Info, etc. Styling and all that is not my forte, as you can probably guess. :P So any tips, advice and/or help will be highly appreciated. Thank you, Emlyn :)
  24. Hi all. Hope you're all OK. I'm trying to get a new layout to work, and not succeeding. "/ I downloaded a new layout (legally, I might add, haha) from http://www.senkouryu.net/index.php?id=1. I then tried implementing that as my layout. I didn't know how to do properly, but gave it a go. I've not done any sort of templates, etc before, so I did it wrong. Below is the header script: EOF;}} function userdata($ir,$lv,$fm,$cm,$dosessh=1){global $db,$c,$userid, $set;$IP = ($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];$db->query("UPDATE users SET laston=unix_timestamp(),lastip='$IP' WHERE userid=$userid");if(!$ir['email']){global $domain;die ('Your Account May Be Broken. Please Contact Your E-Mail Stating Your Username And User ID.');exit;}if($dosessh && ($_SESSION['attacking'] || $ir['attacking'])){print "You Lost All Your EXP For Running From A Fight Like A Coward.";$db->query("UPDATE users SET exp=0,attacking=0 WHERE userid=$userid");$_SESSION['attacking']=0;}$enperc=(int) ($ir['energy']/$ir['maxenergy']*100);$wiperc=(int) ($ir['will']/$ir['maxwill']*100);$experc=(int) ( $ir['exp']/$ir['exp_needed']*100);$brperc=(int) ($ir['brave']/$ir['maxbrave']*100);$hpperc=(int) ($ir['hp']/$ir['maxhp']*100);$enopp=100-$enperc;$wiopp=100-$wiperc;$exopp=100-$experc;$bropp=100-$brperc;$hpopp=100-$hpperc;$d='';$_GET['ID'] = abs(@intval($_GET['ID']));$_GET['viewforum'] = abs(@intval($_GET['viewforum']));$_GET['viewtopic'] = abs(@intval($_GET['viewtopic']));$stmr='';$u=$ir['username'];if($ir['user_level'] > 1) { $stmr=""; };if($ir['donatordays']) { $u = "{$ir['username']}';$d='"; } $gn=''; global $staffpage;if($ir['fedjail']){$q=$db->query("SELECT * FROM fedjail WHERE fed_userid=$userid");$r=$db->fetch_row($q);die("You Have Been Dragged Off To {$set['game_name']} Federal Prision For {$r['fed_days']} Day(s). Reason: {$r['fed_reason']}");}print <<";} function endpage() {global $db;print < function menuarea() {include "mainmenu.php";global $ir, $c;print "Nav Bar";} function smenuarea() {include "smenu.php";global $ir, $c;print "Staff Bar";} function maincontent() {global $ir, $c, $db; print "Layout Info Layout Name: Desert Storm V1 Type: Tables, Div Iframes: NO Download Requirements: - No requirments needed. Features: - A Desert theme Description: This simple layout is practice for me, a practice with color combinations that I haven\'t use, like this, a yellow-brownish-sand-like, for a desert theme :)Copyright & Final CommentsThis layout is copyrighted by SenkouRyu, don\'t edit the copyright info anywhere! Be sure to check http:\//www.senkouryu.net for more layouts like this or even better ones! OUT1;}?> When I log into my site, I then get this error: Fatal error: Call to undefined method headers::userdata() in /usr/home/******/domains/**********/public_html/globals.php on line 86 These are the lines above and below line 86 in globals: check_level();$h = new headers;$h->startheaders();$fm=money_formatter($ir['money']);$cm=money_formatter($ir['crystals'],'');$lv=date('F j, Y, g:i a',$ir['laston']);global $atkpage;if($atkpage){$h->userdata($ir,$lv,$fm,$cm,0);}else{$h->userdata($ir,$lv,$fm,$cm);}global $menuhide;if(!$menuhide){$h->menuarea();}$h->maincontent(); ?> Could someone please explain to me why this error is occurring and how I can fix it? Any help will be highly appreciated. Thank you, Emlyn EDIT: I apologise for the way in which the code has been presented, that isn't my fault. "/
  25. Thank you. :) It's worked now. I guess that's what I get for not doing PHP for over 5 months. Need to get back up to scratch, me thinks. haha Thanks again. :)
×
×
  • Create New...