
Floydian
Members-
Posts
900 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Events
Everything posted by Floydian
-
Re: Getting logged out It's definitely not the cron then. This page defines some session ini setting -> http://www.php.net/manual/en/session.configuration.php#ini.session.auto-start Settings you'll want to take a look at are: session.gc_probability session.gc_divisor session.gc_maxlifetime Run a <?php echo phpinfo(); script
-
Re: Getting logged out Just as a general debug step, have you disabled the five minute cron to see if folks still get logged out? If they don't, run the cron manually. Then see what happens. If they still get logged out, without the cron running, then it's not the cron. ;)
-
Re: Filtering out PHP code You can post the code if you want. I'm back to my not understanding what it is that you want to achieve now though. Making a templating script I understand, but what you're doing seems to be outside the realm of just a templating script. Normally a template script doesn't care what php code is going to be run, it just does it's job dispassionately.
-
Re: Filtering out PHP code Check out this PHP function Zeggy -> http://us2.php.net/file_get_contents With that, you read an entire file into a string instead of the file being "included as code". You will be able to easily manipulate that file to your hearts content, and then just save it, perhaps using file_put_contents(). That last function can be read about here -> http://us2.php.net/manual/en/function.file-put-contents.php And if all else fails, ask mdshare to link you to a post he made somewhere. I don't know exactly where it is, but he posted about using file_get_contents() as part of a lite php template system. ;)
-
Re: Filtering out PHP code I don't understand what you're trying to achieve here. You have a file that you know contains php and html, but you don't know what php it contains. That means you simply can't trust the contents of that file. Now, a question in my mind is, do you know what html is supposed to be in that file? If so, why not make an html file to include? Another question is, do you intend to ever use the php code in that include file?
-
Re: Query Error - Email Validation I counted 5 ( and 4 ) You need 5 of each ;)
-
Re: Anybody use lite version? Seems like stripping mccodes lite just to get something good out of it would be more work than making a new engine. I could be wrong though ;)
-
Re: V2 Code Help Good deal. You might want to note that in the first post, you had a database query after the die. die(" You have over done it and need to spend some time in hospital"); $db->query("UPDATE users SET hp=1,hospital=$hosptime,hospreason='over cooking it' WHERE userid=$userid"); That query wouldn't ever run since it's right after the die. ;)
-
Re: criminal.php Have you actually made any crimes yet?
-
Re: Primary and Secondary Weapon You could adjust exp gains based on whether or not the loser had a weapon equipped. Like, if they didn't have a weapon equipped, drop the exp gain by 50%. And if they didn't have armor equipped, drop it another 50%. If they didn't have either equipped, the total drop in exp gain would be 75%. Does that work for you?
-
Re: [uPDATED!] Basic ajax is easy Here's the last part of this series. We'll build on what we have so far, and add to it the use of JSON. We'll use JSON in order to allow our PHP script to communicate back to the javascript script in a more sophisticated way. JSON gives us a way for the javascript to parse the PHP response and create variables, arrays, and objects that were sent as a JSON encoded string. Make sure to view the source code of the ajax3.html file as it has been updated and contains more javascript code and more comments. Since the PHP script will respond back to us indicating if we logged in or if we filled in the form wrong, we want to be able to indicate to the javascript script which result we got so that the javascript can take appropriate action. The last example can be found here: http://www.phphorizons.com/forum/exampl ... ajax3.html The code for the ajax3.php file is: <?php // This script will validate the login credentials. It outputs a JSON object // which can be interpreted by our javascript script. // This array will be used as a mock database of names and passwords that are // acceptable for use in the login. $users = array( 'John' => 'aaaaaaaa', 'Jane' => 'bbbbbbbb', 'Jim' => 'cccccccc', 'Janet' => 'dddddddd' ); // Check if POST['name'] and POST['pass'] has been submitted. if (isset($_POST['name'], $_POST['pass']) and strlen($_POST['name']) > 0 and strlen($_POST['pass']) > 0) { // Check if the $users array contains the name/pass combination submitted. if (isset($users[$_POST['name']]) and $users[$_POST['name']] === $_POST['pass']) { // If we made it here, the login is good and we will use a JSON object // which will help the javascript script know that the login was good. echo json_encode(array( 'auth' => true, 'text' => 'You have successfully logged in.' )); } else { // The login credentials submitted were no good and we'll indicate that using our JSON object. echo json_encode(array( 'auth' => false, 'text' => 'Invalid login credentials...' )); } } else { // One part of the form or more was not submitted. We will send back an indication // of this error, again, using a JSON object. echo json_encode(array( 'auth' => false, 'text' => 'Please fill in all form fields.' )); } ?>
-
Re: Crons VS. Time Stamp For things like updating a user's energy or health, I'm not a big fan of using timestamps for that. Suppose a user's health goes down to 0, and they don't log in for a day, their health will stay low and they would not be attackable for a long time. If everytime a user tries to attack someone, you're performing calculations to determine if they need a health update, that could result in more cpu usage than just updating everyone at five minute intervals (which is one query vs however many get run using the timestamp method there) IMHO, getting rid of the one minute cron is highly essential, 5 minute crons and up, the returns on that might not be worth it. It could be, but it also might not be worth it, so blind guesses here just don't cut it. Hence, if you're going to worry about it, then you should be running some tests to see what the differences are.
-
Re: Gym Help Please Glad that works for ya. ;)
-
Re: Gym Help Please // Convert number to % where there is a minimum and maximum number function to_percent($min, $max) { if (is_null($min)) { echo "<h3>Please contact the site administration. Error Code: Division by zero.</h3>"; global $userid; if ($userid < 1) { unset($_SESSION['user_id']); session_write_close(); exit; } return; } return $percent = $min * 100 / $max; } My bad. There's the function that the range_to_percent() function is dependant on. How's that workin for ya?
-
Re: [uPDATED!] Basic ajax is easy Part 2 as promised takes the example from the first post and adds in a php script to handle the form data. To keep things simple, I'm just going to take the entire POST array and display it back to the user. The point of doing this is to show that all of the fields in the form did get submitted intact. Here's the second example: http://www.phphorizons.com/forum/exampl ... ajax2.html The php script looks like this: <?php // This script takes the POST array and displays the entire thing to the user. // The purpose of this is to show that all the data from the FORM // was sent in the ajax request. You're forms could have // lots more form fields and they would all get passed // on to the page your ajax script connects with. echo '<pre>' . print_r($_POST, 1) . '</pre>'; ?>
-
For those that have read my "Basic ajax is easy" post, you'll notice a major difference in how I do ajax these days. I've learned a lot, and I know how to make it even easier than ever! If you haven't read the other forum thread, don't worry! The admin should delete it! It works, but it's no where near as good as this, and it's no where near as easy either. To begin, some ground work needs to be laid. We're going to be using Yahoo's YUI library for this. Okay, scarryyyyy! Well, it was for me anyways. I though using a javascript library would be hard, but it turns out that it makes things way easier. After all, haven't most of us used mccodes because it made getting started with a browser game much easier? Well, if you haven't used mccodes, then kudos to you! Let's dig in. The first example can be found at this link on the next line. http://www.phphorizons.com/forum/examples/javascript/ajax/ajax1.html This example demonstrates the most basic parts of using the YUI Connection Utility. The source code is heavily commented so that you get the line by line commentary on what's happening. The premise is we have a login form. This login form will pass a login name and a password to a php page that will validate the login credentials and report back the results. The second premise is that debugging the script should be easy. Therefore, we haven't even implemented the validation for the login. All that we have, is a login form and a javascript script that attempts to make an ajax request. The theory here is that we all make mistakes, and it's likely that most of us will make mistakes the first time we work with ajax. So let's see how this script handles a missing file. I.e., the file we're trying to connect to doesn't exist. Once you load the page, type in whatever you want into the form (don't type your CE login name and passsword...). Click the submit button and the javascript will attempt to connect to the ajax1.php page. Since that page doesn't exist, we'll get an error message with a 404 error (we've all seen those before lol) In the next post, I'll demonstrate what happens when the page we're connecting to does exist.
-
Re: Gym Help Please Put this in your global functions file: // submit a numeric value, and find a percent of where in the range that number is. function range_to_percent($low, $high, $value) { $range = $high - $low; $target = to_percent($value - $low, $range); return $target; } Before the for loop in the gym, put this: $will_mod = (100 - range_to_percent(100, 15000, $ir['maxwill']) * .5) * .01 ; Now change this: $ir['will']-=rand(1,3); To this: $ir['will']-=rand(1,3) * $will_mod; Does that help?
-
Re: Gym Help Please I'm not sure I understand your question. I get that you want to understand the equation better. But what are you trying to accomplish here? Are people gaining more stats than you want them to gain? Are they not gaining enough?
-
Re: Time Timezone setting is a php ini setting believe it or not. And if you don't have that php ini setting set (ie, you're depending on the servers time zone) then everytime you use a time/date function, you're getting E_NOTICE errors in PHP >= 5 (It might be like this in PHP 4, but don't quote me on that). Here's how you set the time zone programatically: // Time zone is set here. date_default_timezone_set('America/New_York');
-
Re: Auto Fed Url links in mail Makes me think of CE's word filter that clobbers words like --- analyze and grape a-n-a-l-y-z-e g-r-a-p-e
-
Re: New Website Alrighty, xhtml and css means that you could do any type of website in the world and learn those two things. Take your pick ;) Perhaps make a home page for yourself.
-
Re: URGENT HELP!! Setup Game Saint, there's a couple things here you might want to note. Number one, no one offering free support is going to be impressed by things like "Urgent" in bold and red text. Your problem, if it was that urgent, would necessitate spending some cash to purchase immediate support. Number two, you didn't outline what your problem is. Most people offering free support are there because they enjoy offering free support. We aren't here because we want to chat on msn. By not outlining your problem, you virtually eliminate any chances of getting free support. Third, you want folks to post, then you provide them with your msn and they have to contact you. You are the one seeking free support. To assume that folks are going to take all these extra steps for free is pretentious at the least. You'll find lots of free help here, but the manner in which the help is sought out always determines the chances of actually getting free help. Hope that helps.
-
Re: McCodes in one Nice one AlabamaHit. You could add in a bit more "protection" by checking if the database class exists as well. globals.php isn't quite as obscure as I'd like it to be if I were counting on someone not having made a file named that on a vs1 game. The database class files though are a bit more obscure and would give extra protection.
-
Re: McCodes in one This part of the forum is -> + Webdev and programming (Non Game related) Specifically, that means that if there is a sub forum relating to a particular game engine already, then the post should go there. Thanks What's your reasoning behind wanting to do what you're trying to do?
-
Re: Hacker That's how I win, massive posts ;) :P