
Floydian
Members-
Posts
900 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Events
Everything posted by Floydian
-
Re: That's assuming your code can fail :p And if mine can, I wanna know about it. Sometimes I login and see a hundred mails waiting for me, and I fix the problem making 100% sure it can never happen again.
-
Re: Need help with creating a php/mysql powered page. What database are you using? The PHP version you are using may be helpful as well. Can you connect to your database at all? I.e., do you have code ready to go that connects you to the database or do you need that as well?
-
Re: No Crons You need to get real good at using time stamps. if (jailtime > time()) then you're in jail that negates the need to do a minute cron updating jail time follow that mold and you'll likely be able to eliminate most of the crons It's my opinion that some things are best left to crons. If you want something updated once per day, for all users, and it's something that if you performed a check to see if that update was necessary on every page load, it'd consume far more resources than just doing a daily cron. On Tycoon Rats, I use a cron for updating user bars, and a daily cron. That's it. there is no minute cron, or five minute cron. Just a 10 minute and a daily. I prefer to update user bars with crons because I want players that log off to be able to come back to a full bar, instead of requiring activity on their part. If you want their bars fully updated, then there's some math involved, and it has to be performed regularly, say something like: if last update > time() - 60 * 10 THEN do an update, but there's more how many updates did we miss? missed updates = ((time() - 60 * 10) - last update) / 10 now multiply the amount you update by the "missed updates" amount all of this should be self explanatory, if it isn't, then you need to practice with time stamps or you'll muck it up.
-
Re: I do something similar, except I only display the error to high level staff. Any one else gets a generic error message. Regardless of which of the above happens, it then mails me the error. Simple and effective.
-
Re: [FAQ] sprintf - no, it's not a phone company Thanks Akash! :D
-
Re: Forum Design Sweet :D At this point, my main concern is the announcements forum. I'll do some experimenting and see what happens. Thanks for the suggestion Nyna ;)
-
Does anyone know where I might find some information on designing forum code? Specifically, the problem I'm having is in keeping track of read and unread threads. If I make a log table, that notes every thread a person goes to, then the number of rows required in that log that would be needed to have every thread marked for every user would blow up exponentially as time went on. I've tried to come up with some sort of compromise where I log things based on a date. If the forum is marked read, update the date in the users table. But then, if someone posts a post, and another person posts a post in a different thread. You can't just update that date in the users table when they've read one of the posts. So I'm thinking a combination of a date in the users table as a sort of a marker of how far back to go for "unread" threads, and then a log for threads read after that marker is set. I still haven't gotten it working though. If someone knows of something somewhere that I can read and learn about this, it'd be greatly appreciated. Or if you've done this sort of thing, and are kind enough to give me some pointers, that'd be great as well.
-
Re: Sql Injections? I hear where you're coming from ;) Of course if you wanted to know if the page is a .php page, you can regex that after using the filter to validate the url as a valid url ;)
-
Re: Crazzy Arrazy Yeah, I guess I should go that route. Thanks for the push ;)
-
Alrighty, here's a little something that is holding me up and I'm pretty stumped trying to find a way to do this that isn't completely wasteful of resources and time. Here's the deal, each player in my game has a column in the users table for crime stats. This crime stats column is a text column that stores a serialized array. The array is formatted as follows: $crime_stats[$category_id][$crime_id] = array('total' => 0, 'successes' => 0, 'failures' => 0); Of course there are multiples crime categories, and many different crimes in those categories. I would like to find a way to figure out who has the most successes (top 5) for each crime whilst also adding up the total successes for each crime over all players together. What I've done is query the crime stats array from the users table and store them in an array with the userid as the key and the crime stats for each player as the value, so we end up with a massive array. (Naturally this code will only be executed once per day, possibly only once per week if it really becomes an issue...) Then I've got a set of three foreach loops, and after that, I begin to lose it lol. I haven't even run this code, number one because it's not complete, and number two because even if it were complete I know it wouldn't work. foreach ($crime_stats as $them_id => $them_data) { foreach ($them_data as $crime_category => $category_data) { foreach ($category_data as $crime_id => $data) { if (!isset($crime_total[$crime_category][$crime_id])) { $crime_total[$crime_category][$crime_id]['total'] = 0; $crime_total[$crime_category][$crime_id]['successes'] = 0; $crime_total[$crime_category][$crime_id]['failures'] = 0; } if (isset($data['total'])) { $crime_total[$crime_category][$crime_id]['total'] += $data['total']; $total_20[$them_id] } if (isset($data['successes'])) { $crime_total[$crime_category][$crime_id]['successes'] += $data['successes']; } if (isset($data['failures'])) { $crime_total[$crime_category][$crime_id]['failures'] += $data['failures']; } } } } I'm not so much looking for someone to write this code for me, but I would greatly appreciate a helpful push in the direction I should be going in. Of course if you feel so inclined to write something up, I won't stop you! But seriously, I think I just need to get my perspective on this, and then from there I'll be able to handle it. Thanks in advance for your help. :D
-
Re: Sql Injections? Interesting. Is that really an invalid http address? I've seen firefox return error messages along the lines of "this url cannot be resolved" or something to that effect, but with that, I just get the "server not found" error page. I'm prolly wrong, but it seems firefox has no problem with the syntax of that url.
-
Re: Security Alert I don't disagree with you at all. I'm wondering though, when generating a timestamp, it seems to me that it's "timezoneless". As in, it's going to tell you the number of seconds from the unix epoch no matter what timezone you're in. I could be wrong. But I know for a fact that my web host is in a New Zealand time zone, and the PHP script is set to a USA time zone, and the timestamps generated in that test script still came out the same. I could be wrong about the timestamp, but as far as I can tell, it genuinely does seem to be "timezoneless".
-
Re: Security Alert I ran a little test $time = mysql_query('select unix_timestamp()'); list($time1) = mysql_fetch_array($time); echo dayz($time1) . "<hr>" . dayz(time()); dayz() is a custom function that uses the date() function to return a formated time. The web server is in new zealand time, and the php code has a time zone set to USA eastern time. Both times came out the same. Considering the test, I dun see any problem using the mysql unix_timestamp() function vs inserting a php generated time()
-
Re: Security Alert Glad you mentioned that. I've been using the mysql UNIX_TIMESTAMP more and more instead of inserting a php generated timestamp which would cause interesting problems assuming it's using a New zealand time instead of the usa eastern time as I have php set to. there's gotta be a way to tell MySQL what time zone to use, no?
-
I want to make/own my own game, please help
Floydian replied to NickH440's topic in Other Programming
Re: I want to make/own my own game, please help Simple answer to how hard is it to get a game up and running is: It's not that hard. Slightly longer answer: Since your goal is to make something for you and your friends to play, and you're not trying to make 500k bucks the first year, you don't have to do anything but get a web host, and install a game engine. You'll have a game ready to go right there. Now, taking it to the next level and making it a phat game, that requires magic. Lots of time, energy, inspiration, knowledge. Knowledge can be replaced with money if you have lots of that. -
Re: Drugs Error That means $q doesn't contain query results. Most likely this is due to an error in the query that is used to store a query result in the variable named $q
-
Re: Security Alert I recommend using a time stamp in an integer field. It might not be as fast as using a date field, and the value stored won't be "human readable" but it's super simple to ensure there is absolutely no possibility of injections. Again, this is my personal recommendation coming from a person who is largely self taught, and has no specific credentials given by MySQL in the form of diplomas, degrees, or anything like that, but has studied hard and learned a lot.
-
Re: Stylesheet Switcher That's phat ;) It'd be interesting to save a player's stylesheet pick in a cookie, and have the javascript put in the steelsheet using that :D
-
Re: Basic Ajax is easy I can certainly agree with you in that, if it isn't broke, don't fix it. That maxim has saved many a person many a gray hair. I have gone back to some older scripts of mine and added in ajax functionality to them with success though. I would definitely recommend getting experience writing simple ajax scripts first though, before really getting into it.
-
Re: Basic Ajax is easy I've had to come up with several interesting methods of working around some of the quirks of asynchronous javascript requests. Most of the times I load up my main ajax function with about 5 or 6 arguments, and pass 0's to them in the event that later on down the road, I might need the extra space, and editing every function call to add in the arguments is a pain. So, each function call would be something like this: javascript:self.ajax_function('id name of the output', 'switch: what function do we want the file to run?', 'parameter 1', 'parameter 2', 'parameter 3', 'paremeter 4') And I can easily have a container page, and a function page, loading all my dynamic content anywhere on the container screen I want. No JSON required for this. Of course, each call to the ajax function will fill only one "portal". And if I want more portals at once, I might do like I did with my russian roulette script that updates 4 portals at once every second. Yes this means four scripts being called, but it's a pretty lean script, and it'll be cached on the server, so it runs very smooth. Just ask the folks on coveofpirates.com and aeonsea.com where this russian roulette script resides. No this script isn't for sale lol. function multi_loader() { // note that I forget the exact syntax here (I copy a lot of javascript function names) set_time_out('blah1', 1000) set_time_out('blah2', 1000) set_time_out('blah3', 1000) set_time_out('blah4', 1000) } Now, I can have four things on a page updating every second. Doing this has it's limitations. the functions are called with no arguments. so you have to make a function for each one. okay, that's not too hard. but this also means it's only good for making something update, which in russian roullete, we want to see who comes into the room, who is playing a game, and what round/ who's turn, and the status of those games. The actual game play is handled through links like the one above. ;) This is all based on the functions I've pasted in the first post. It's difficult to choreograph all that crap, but I'm suggesting that the basics of ajax are simple, and easy to do.
-
Re: Sql Injections? Nothing wrong with that. We'll flesh them out for you ;) Or I will if no one else will lol.
-
Re: Basic Ajax is easy I have to disagree with you on some of that. You talk about static pages with one ajax object as if that's entirely limiting. You're so wrong about that. I've done numerous pages with ajax, and one can do all sorts of things with that one object. Consider a hall of fame. With the script I've made, each of those links could be one hall of fame list. the list would then pop up super fast with no page loads. I can think of many places where ajax is useful. Less than 25% of my game uses ajax though, and that's because it's not the end all be all. But you're simply not accurate at all about the one object being limiting. If you pass a id field to the ajax object, you can nest ajax objects with ease. Just thing, click on link 1, it presents you with options for link a, b and c, and also outputs an empty span with a new id, "ajax_output2" You then click on link b, and it outputs the ajax results into that new span. All this is done with one ajax creation function, one ajax object request function, and one ajax return function. you could easily nest these ad infinitum. Of course, if one doesn't explore this functionality, one will never discover the depth of what can be done. I set up that simple script in two minutes, maybe one. It's so easy, how could people not use it?
-
Re: Sql Injections? That's part of the point of me saying that all these huge custom validation functions are most of the times pointless. Especially when they are meant to act globally, i.e., filtering the get and post array on every page load. How terribly inefficient lol. And yes, PHP has some excellent built in functions. ctype functions are excellent at picking out certain data types, there are number "is_[type]" functions where type could be, null, integer, float, array, and so on. isset() is one I use A LOTTTT. Especially with if (!isset()) because then I know the variable isn't set. It does make a big deal. beginning in php 5.2, the filter library is part of the default php code. filter is extremely powerful. imagine validating email without the need for regex functions lol the same can be done for urls and much more. PHP is very powerful on it's own, and making it more complicated than it has to be is just silly. And Nyna knows I don't like to do that lol
-
Re: Voting Site Script [Question] Sounds like a job for a Bill Gates takeover, or maybe a Google buyout lol
-
Re: Voting Site Script [Question] When I set up my voting for my game, I'll only be using voting sites that allow me to know if the vote was actually counted. Just lettin ya know. I know other games don't do that, or don't care, or don't know how to work that, but that's how it is. lol No sense in giving out benefits to those whose votes didn't count. Most of the times, they vote for one game, then vote on another, and by the time they vote from your game, their vote won't be counted. so that's my two cents :D