Jump to content

Kush

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by Kush

  1. Kush

    Time Limit

    I tried making the field as TIMESTAMP, but somehow it adds an "ON UPDATE" and uses the current timestamp for that.. is there a way to disable that?
  2. Kush

    Time Limit

    I was a bit confused by his retrieve example because it's saying "timestamp > NOW()". I don't want to select the timestamp that's greater than now. I'm basically wanting to create a timer and I'll be checking my database every minute to check and see if any timers have expired. By using "timestamp > NOW()" isn't that going to select everything then since it would all be set 4 hours and 10 minutes into the future?
  3. Kush

    Time Limit

    Can people read this?
  4. Kush

    Time Limit

    Well, I plan on updating the field in certain events and with the "timestamp" field it has an on update which it does the current timestamp again. I'm creating my tables in php and just executing the query from php. How would I populate the timestamp field from a mysql query.. the same as above? For retrieving how would I pull all of the rows where the timestamp has expired? I'm trying to make a count-down timer for something (the timer lasts 4 hours and 10 minutes. I guess I was hoping for more php code instead of mysql? I'm still confused.
  5. Hi, I'm fairly new to all of this and I'm not quite sure what to do. I'm trying to create a field in my database that's 4 hours and 10 minutes into the future from the current time. What data type do I set my field as in the mysql database? How would I populate that mysql field via php.. would I use something like NOW(), or use the php date() function? Also, how would I be able to tell if my field has "expired" (the 4 hours and 10 minutes has elapsed)?
  6. Since I can't edit I tried to post a new topic explaining better and I get a warn.. awesome now site admin is mad at me. :'(
  7. Kira, storing the time in a unix_timestamp isn't possible. I can only store the timestamp using a mysql timestamp field using the NOW() function. I'm passing my timestamp to a function called isActive(). This is what I have so far.. function isActive($timestamp) { // Below is equal to the int 300 //MAX_RESPONSE_TIME }
  8. For example, my current mysql timestamp field uses the NOW() function (says so in phpmyadmin) and the current value in the field is "2011-02-22 22:25:51". Now that's going to change and I'm trying to figure out if the current time is within 300 seconds of that time. How could I do this?
  9. I don't even know where to start at..
  10. Hi, I have a timestamp mysql field that I'm trying to see if something happened within a time limit. The field is updated with the time when the action is complete so I just need to figure out how to see if it's within a time. I currently have a defined variable set titled "MAX_RESPONSE_TIME" and that's in seconds. By default "MAX_RESPONSE_TIME" is equal to 300 seconds. How can I see if a mysql timestamp field is within 300 seconds?
  11. Kush

    PHP Question

    Think it will be able to handle what I need?
  12. Kush

    PHP Question

    I'm wanting to host the clans website (current forum has 3 thousand members) and handle the statistics for 40 gameservers using hlstatsx (lots of mysql). That would be the majority of what I'm wanting to do, but there will still be personal projects that I'll eventually work on.
  13. I'm considering getting a VPS, but I'm not entirely sure what this would be able the handle. The specs doesn't look that good to me, but my friend swears it will handle running apache/php/mysql handling large websites and databases without a problem. I want to run multiple databases that just store statistics and I'm a bit worried about the RAM and the company doesn't even mention a cpu. Here's the specs: 256MB RAM 300GB HDD 10Mbps unmetered 1 IP Address My friend runs two counter-strike: source servers off his VPS (same stats).. so I'm actually considering this, but it just seems like it's not powerful enough. Oh.. forgot the most important part.. it's only $9.
  14. Hi, I'm using php to access the mysql database using mysqli and I have a field on my table called "timestamp" and it's set as a timestamp and has current_time (I think in phpmyadmin it was a tick option so I clicked it) and when I update that row in my table the field "timestamp" doesn't update with the timestamp from when it was last updated/modified. I thought the field option timestamp automatically did that? I'm guessing not.. is there a way I can update the timestamp with the current time in my query?
  15. No other way to speed it up though? :'(
  16. xylex, when reading that it made sense ( to a degree ), but that's far too advanced for me... I'm still just a beginner.
  17. What did you mean by running it in parallel?
  18. I'm trying to query my gameservers and get the map and how many players are in there. Here's the code I use to loop the game servers: foreach($serverList as $server) { $r = new rcon($server['ip'], $server['port'], $server['password']); if(!$r->isValid()) $serverInformation[$server['ip'] . ':' . $server['port']]['error'] = 'Unable to connect to server (' . $server['ip'] . ':' . $server['port'] . ')'; if(!$r->Auth()) $serverInformation[$server['ip'] . ':' . $server['port']]['error'] = 'Unable to authenticate! Wrong password?'; $status = $r->sendRconCommand("status"); $status = str_replace("\x0a", "", $status); $information = getServerInformation($status); // regex the result and return important content $serverInformation[$server['ip'] . ':' . $server['port']] = $information; // store important content in the array } Here's the rcon class too: <?php /* CS:S Rcon PHP Class - code by 1FO|zyzko 01/12/2005 www.1formatik.com - www.1fogames.com -------------------------------------------------- */ define("SERVERDATA_EXECCOMMAND", 02); define("SERVERDATA_AUTH", 03); class rcon { var $Password; var $Host; var $Port = 27015; var $_Sock = null; var $_Id = 0; var $valid = false; function __construct($Host,$Port,$Password) { return $this->init($Host,$Port,$Password); } function rcon ($Host,$Port,$Password) { return $this->init($Host,$Port,$Password); } function init($Host,$Port,$Password) { $this->Password = $Password; $this->Host = $Host; $this->Port = $Port; $this->_Sock = @fsockopen($this->Host,$this->Port, $errno, $errstr, 30);// or //die("Unable to open the port: $errstr ($errno)\n"+$this->Host+":"+$this->Port); if($this->_Sock) { $this->_Set_Timeout($this->_Sock,2,500); $this->valid = true; } } function isValid() { return $this->valid; } function Auth() { $PackID = $this->_Write(SERVERDATA_AUTH, $this->Password); $ret = $this->_PacketRead(); if ($ret[1]['ID'] == -1) { return 0; } else { return 1; } } function _Set_Timeout(&$res,$s,$m=0) { if (version_compare(phpversion(),'4.3.0','<')) { return socket_set_timeout($res,$s,$m); } return stream_set_timeout($res,$s,$m); } function _Write($cmd, $s1='', $s2='') { $id = ++$this->_Id; $data = pack("VV",$id,$cmd).$s1.chr(0).$s2.chr(0); $data = pack("V",strlen($data)).$data; fwrite($this->_Sock,$data,strlen($data)); return $id; } function _PacketRead() { $retarray = array(); while ($size = @fread($this->_Sock,4)) { $size = unpack('V1Size',$size); if ($size["Size"] > 4096) { $packet = "\x00\x00\x00\x00\x00\x00\x00\x00".fread($this->_Sock,4096); } else { $packet = fread($this->_Sock,$size["Size"]); } array_push($retarray,unpack("V1ID/V1Reponse/a*S1/a*S2",$packet)); } return $retarray; } function Read() { $Packets = $this->_PacketRead(); foreach($Packets as $pack) { if (isset($ret[$pack['ID']])) { $ret[$pack['ID']]['S1'] .= $pack['S1']; $ret[$pack['ID']]['S2'] .= $pack['S1']; } else { $ret[$pack['ID']] = array( 'Reponse' => $pack['Reponse'], 'S1' => $pack['S1'], 'S2' => $pack['S2'], ); } } return $ret; } /** * Send an rcon command the server. The command must be properly formatted before * sending to this method. This means that variables that require quotes must have * quotes put around them. * Ex. $command = "kickid ". "\"".$steamId."\" ".$banReason */ function sendRconCommand($command) { $this->_Write(SERVERDATA_EXECCOMMAND, $command, ''); $ret = $this->Read(); return $ret[$this->_Id]['S1']; } } ?> Don't get me wrong, because the code does run, but it's just really slow (4 seconds) for each loop in the foreach loop. I'm hoping there's a way to make this faster..
  19. I'm not sure what you mean. Could you please go into detail?
  20. Is it common for the socket to take 4 seconds in total for each connection? It's taking a really long time to refresh all of the content that I need.. there has to be a better and faster way. I've seen websites doing something similar and they have 40++ servers that they're pulling data from and they refresh their database every minute so it's only taking them a minute.
×
×
  • 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.