Jump to content

Monkuar

Members
  • Posts

    987
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Monkuar

  1. Good explanation. Thank you. Now help me stress test this bad boy on my main server at home to see what kind of server I'll need. Ram/CPU/Bandwidth... Is it possible? Or should I just buy a cheap VPS for a couple bucks and do it there? Problem is even if I were to buy a server, how the hell do I stress test concurrent users when I'm only a 1 man show? These are very important factors that need to be considered before launch. I'm very skeptical.
  2. Oh. Wow. I am dumb. I meant memory usage. For cpu usage, I will check the other tab in the task manager. I'm just trying to figure out what kind of server I will need. The websocket server is essentially being run in a while loop 24/7 right? Why isn't it taking it's toll on the cpu yet? If you do a while loop iteration function on the web browser, the script will halt and eventually crash. Why doesn't this happen for the php websocket server?
  3. How is that possible though, when there is a closing bracket? Edit: Oh, because he didn't assign the B, KB, MB, GB, TB to an array variable, he used an inline array? I think I'm getting it lol. So brackets like that are always shorthand for $array[$value] And $array can be an inline array like what req used. ["hello", "cupcake"][$value] Correct?
  4. This code is too beast, it even breaks PHP (and my site) and still works. But, I've never seen this type of usage before: ["B", "KB", "MB", "GB", "TB"][$log]This part: I'm assuming is a shorthand property to merge those 2 arrays correct? Err.. Not 2 arrays, because $log isn't, the ][ is used to merge a string into an array then, correct?
  5. Yeah, I've been around linux VPS's and an active member of LowEndTalk. I have a small bash script I made that installs the basic php/mysql stack on debian 64's. I use basic iptables and nginx rate limiting as well and citadel to mitigate script kiddy flooders. (Although, a real DDOS is still dangerous). I've been doing some testing with my php websocket server though. With my game server, let me show you an example: How does php.exe (the web socket game server) only use around 4kilobytes of cpu power? That doesn't make sense. Is it only because there is 2 concurrent users? I'm only assuming the cpu power wont be the issue, but the bandwidth will be, fair assumption?
  6. Monkuar

    Hi

    Welcome to the ad infested free help forum
  7. Yeah, I just got some false positives. I would have to switch back to != if they were integers right? Anyways, I'm not going to array map them, as this a very strict match. No need I just find it sad I spent like 1 hour trying to figure this out, I feel like absolute shit and should be ashamed.
  8. BOOM if($value !== "0" AND $value !== "1"){ $errors[] = 'Invalid option chosen'; }Got it now. So the word 'strict' is what I was looking for, thank you scootstah! Now these values HAVE TO BE 1 or 0, no matter what. No injection, nothing is possible. Thank you. Going to array map intval these too just in case.
  9. if($value != "0"){ $errors[] = 'Invalid option chosen'; } $value is a string. IF $value equals '00', it doesn't work why? It does not equal 0? I'm trying to check if a value equalis 1 or 0. LITERALLY the string has to be 1 or 0, if not I need to error out. Why is this so difficult? How does 2 zero's (00) = 0? Doesn't make sense. Especially when it's matching 2 STRINGs.. If it were a numeric value I could see PHP saying 00 might equal 0. But how does 00 and 0 equal the same thing? makes no sense.
  10. Yeah, the user has been authenticated. But, the user an option to be 'logged in forever'. This means the system will not delete the users cookies (essentially) so whenever that user logs in, he will stay authenticated forever if he pressed that button. Then upon any refresh, the system will authenticate him. So I can just check if the user submitted an ajax request, and if the user is not logged in, just do a simple refresh, or check if he has the correct cookies and send out the data right? So you're saying have a fallback method when the user checks it via ajax request, if his session has expired. (How long do PHP's sessions last) Edit: Looks like I checked here: http://stackoverflow.com/questions/8311320/how-to-change-the-session-timeout-in-php and they say around 1 hour. I could edit that and make it longer though, but wouldn't that be a toll on the server? In any event. I'm just worried about these damn sessions because I heard there is a lot of fwrite and fopening functions happening in the /tmp/folder when updating/reading the sessions as compared to just selecting the data from MYSQL. I am very, VERY on edge and OCD about it. I have rate limiting with iptables and nginx, all set up but I'm just feeling a weird vibe with sessions.
  11. function forum_number_format($number, $decimals = 0) { global $lang_common; $x = round($number); $x_number_format = number_format($x); $x_array = explode(',', $x_number_format); $x_parts = array('k', 'm', 'b', 't'); $x_count_parts = count($x_array) - 1; $x_display = $x; $x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : ''); $x_display .= $x_parts[$x_count_parts - 1]; return $x_display; //return is_numeric($number) ? number_format($number, $decimals, $lang_common['lang_decimal_point'], $lang_common['lang_thousands_sep']) : $number; } Let's take a look at this code. This is VERY, VERY hard for me to understand. But it's essentially converting numbers to their kilobyte equivalent. (For example: 1000 = 1k. 25000 = 25k 15000 = 15k My issue is.. What happens when the number is 1321 This will output 1.3k Why? Because it's using the round function on line 4. But, I'm trying to get it to display 1.32k Any idea how to do this? I've been trying: $x = round($number, 1);and other methods but with no luck.
  12. No, not on every ajax request but on each manual page refresh. That's where I'm getting it! I don't want it to do that per ajax request, but to just use the $_SESSION['user_id'] instead, will that be okay? How do I go about the session expiration and stuff? What if the session expires, and they call the ajax request.... It won't expire if I set the $_SESSION['user_id'] to the users real id per page refresh, but I don't want to do that per refresh if that helps
  13. From the cookies. (fluxBB) forum software. It checks the users cookie per each request to the users table to authenticate. My question is why do I need to do this PER each request when I can just store the user id in a session and use that to stuff (INSERT, UPDATE) for that user? (For ajax updates)
  14. But how is updating session variables as compared to updating a field in MYSQL? (Same for reading and writing), which way is faster, and has better performance? It's dependent on how the data is being used and what it is being stored correct? When you're updating a Session Variable is it essentially doing a fwrite to a file inside the tmp folder correct? ..And when you're calling a session variable, it's essentially being read (fopen) function per request right?
  15. Let's say I grab all the user's information from the users table. It's stored into a variable as an array: $pun_user. Now, to get access this user data, it selects all the data each refresh and sets it to $pun_user for extraction later. My idea: Create a $_SESSION['user_id'] = $pun_user['user_id'] And then when using updating stuff via ajax requests, I can just do SELECT blah from users where where user_id = $_SESSION['user_id'] instead of: calling the main query to enter all the data into $pun_user, then do that query AGAIN and do SELECT blah from users where user_id = $pun_user['user_id'] Is the $_SESSION way going to take a performance hit on the server? Or is the MYSQL way a more detrimental approach? Which way is faster, and less intrusive on the server?
  16. http://forums.phpfreaks.com/user/131346-christian-f/ I remember from the old days on the SMF forum boards, he would post and help all the time. Everyday. I miss him so much, where is he? Does any of the mods/admins know whif anything happened to him? Last activity was almost 2 years ago.
  17. Awesome. Totally forgot about preg_match_all, thank you for the explanation.
  18. Yeah, but Anonymous functions exist inside objective orientated programming right?
  19. Also, when using this I get: Catchable fatal error: Object of class Closure could not be converted to string in C:\WT-NMP\WWW\header.php on line 364Yeah, no idea. Never seen this error. I have a feeling I can only use the object orientated functions inside a Class right? If so, nevermind my question -.-
  20. This is object programming right? Is there a performance issue with this? for example: $notfications = ( blah blah ) ? : ''; then if ($notificatiosn != blabla){ echo 'hey'; } or.... $notifications = function(){ do my stuff here then return 'hey'; } Which way is faster or slower? Reason I Ask this is because I've been doing some object orientated programming in javascript, and didn't know you could do it in php. I'd rather do the objective way so I don't have to use so many freaking variables above the regular way, lol.
  21. For example: $text = preg_replace_callback( "/([@][a-zA-Z-0-9]+)/" , "umentions", $text, 1); That 1 parameter means the maximum times it will iterate right? So If I'm doing: @Nexus @Cupcake @George it will return: My problem is. I only want it to iterate over the last match in my function: function umentions($matches){ vdump($matches); return "(here you would replace: ".$matches[0]." with something)"; }How is it possible to use limit, and only iterate the last match not the first?
  22. I'd recommend interactJS for drag and drop functionality. Only if you don't want to use bloated jquery/jquiery ui. It's an absolute monster.
  23. I have a javascript code that displays a monster hitting my character via client side only. It runs every 2 seconds via a setTimeout function. My problem is... A user could just disable javascript all together, or craft their own code to disable the monster attack function. I want to detect serverside if anything is being altered. If that makes sense. This is EXTREMELY hard for me to explain, I have no idea but my game is essentially turn based at this point. THE MONSTER ONLY DOES DMG if a player HITS IT. That way, I can safely, and change the values serverside with MYSQL. What I want is the monster to attack the player every 2 seconds or so (Which I have javascript code for already), but a user could just manipulate that code and then attack the mob and receive only that damage. I want it to be more of an action attack game, where the monster's attack automatically, but securely... If that makes sense, any idea? Would I have to implement some type of timing mechanism or something serverside? Or once the player spawned that mob..? Not sure. (You only have XX Seconds to kill!), but that doesn't really fix the problem.. TLDR: Autoattack mob system serverside.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.