Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. There are other problematic file types too, like DOCX and its siblings will be reported as application/zip. (Which is actually what they are.) Use MIME detection for many things, MIME + file extensions for the exceptions.
  2. If something changed then your machines had to download and apply them. So I ask you: what happened in the last couple days? Don't use false. The value is supposed to be an integer: 0 to disable, 1 to partially enable (and only works for libcurl
  3. The recommended way of setting up PHP in Apache is with <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>To include .htm/l files you can modify that to <FilesMatch \.(html?|php)$> SetHandler application/x-httpd-php </FilesMatch>Remember to restart Apache if you're putting this in the global server configuration (which you should).
  4. By removing that part. Literally. Not sure why you didn't consider that. e.preventDefault();is what would have done the job if e was the event for the button click and not from the document.onready. So $(document).ready(function() { $('#email-submit').click(function(e) {And really, this code should be executing on the form submission, not on the button click. $(document).ready(function() { $('some selector for your form').submit(function(e) {
  5. .msg and .doc and others all use the Compound File Binary File Format. They all have that same 9 byte header. To properly detect each type within you'll have to parse the file and look for identifying information. For example, it seems .doc files can be identified by a 0xA5EC at a certain location I've yet to pinpoint since it probably requires knowing more about the CFB format.
  6. What you do depends on the server configuration. Have you asked your hosting provider yet? And a correction: What it tells you is that PHP is not executing that file. Says nothing about whether PHP is "on and working" or whether it is "parsing HTML" (whatever that means). The actual reason is generally (a) PHP isn't installed or (b) PHP isn't set up to execute files with that extension.
  7. A few tactics. My favorite method is SELECT column_two FROM table WHERE column_three = 3 OR column_three = 12 GROUP BY column_two HAVING COUNT(1) = 2Assuming no duplicate rows, it will find all matching rows, group by the user, then filter out the groups that don't have two (ie, the number of different matching services) rows.Only works if you can use just the user ID, though you could use this as a subquery and then JOIN against something else. For a limited number of services, the "normal" way is to do a JOIN SELECT a.column_two, a.<other columns>, b.<other columns> FROM table AS a JOIN table AS b ON a.column_two = b.column_two WHERE a.column_three = 3 AND b.column_three = 12The inner JOIN is what restricts the results to users with records for both services; a LEFT or RIGHT JOIN would return those with one or both.
  8. RedirectMatch (not Redirect) can do it, and is what I would use. RedirectMatch ^/article/ /index.phpRewriteRule can too, of course. Basically the same thing as above. RewriteEngine on RewriteRule ^/?article/ /index.php [L]
  9. There's no way to get one regex to do that because (1) can't match more than one thing in a collection of other things, and (2) can't get array keys like that. imperimus's solution is basically how you have to do it, though there's flexibility on exactly how of course: 1. Match all the OBJECTSTART to OBJECTEND "tags" and loop over each 2. Match all key=>value pairs inside each tag and loop over each 3. Add to an array
  10. I'm actually going to add another process into the mix. With that in mind, here's what I was trying to describe: - There is more than one process [1] running, each one having its own dedicated purpose - Each client that connects gets its own process that is oriented towards supporting communication with the client - There is a "socket server" that monitors each client process; it is the process that has the original socket that people connect to, but when they connect it creates a child to handle it rather than do the work by itself - The socket server will often relay messages to and from a client process - There is a process for each thing ("handler") that needs to run on ticks, and it can communicate with its managing process - There is a "tick server" process that monitors each tick handler: it counts out the ticks and tells each child when a tick happens - Likewise, the tick server will often relay messages to and from a tick handler - (New) There is a "game server" process that deals with the game itself, and is what people would generally call "the server" when they're talking about this game - The three server processes can communicate with each other Here's an example of how it all works together. Let's take an MMO as an example: - Game server starts and does whatever it needs to do (eg, initialize state, set up environments, whatever) - Socket server starts and waits for connections - Tick server starts and launches processes for all the tick handlers it has - Tick handler #1: deals with the time of day, like it tracks when "day" and "night" happen: 1. When it starts it queries the game server for state and is told it is daytime - or is told the in-game time, or whatever 2. It runs, sleeps, runs, sleeps, and so on, waiting... - Tick handler #2: resources regenerate 1 unit per 120 ticks (60s) 1. When it starts it sets a counter to 0 2. Every tick the counter increments 3. When the counter reaches 120 the process issues an update [2] and resets the counter to 0 - Now, a user connects: 1. They connect to the socket server 2. The socket server accepts the connection, spawns a child process for the client, and goes back to waiting for connections 3. The child process has the user authenticate and whatever, and informs the game server (via the socket server) 4. The game server sends information back about the client, blah blah blah - As the user acts, the client processes sends information to the game server, which acts accordingly - Meanwhile the tick handler has been executing, however it's currently daytime (as it was told by the game server) and nighttime hasn't come yet - Eventually the tick handler detects a change to nighttime: 1. It sends a message to the game server (via the tick server) regarding the change 2. The game server updates itself 3. It then sends a "broadcast" message to the socket server to inform all clients of the change (by basically just passing the same message along to everyone) - The user doesn't like playing during the dark and rage-quits: 1. The client process discovers the connection died 2. It passes a message to the game server (via the socket server) that the user disconnected 3. Game server updates accordingly However as I explain this I realize I'm not a fan of ticks. Personally I would go for an event-based system since ticks can be simulated through sleeping: - Daytime tick handler sleeps for however long day-/nighttime is, wakes, sends an event to update, and goes back to sleep - Resources tick handler sleeps for a minute at a time So questions for you: 1. Have more details about what this game (I presume) system is for and what it does? 2. What do you need ticks for? And disclaimer: I know enough about socket programming and multi-threading/-processing to think I know what I'm talking about. You should also look for resources written by professionals. [1] Again, because forking is easier to explain. The threading model is similar enough. [2] Few possibilities. My first thought would be, essentially, executing an UPDATE query on a database, then informing the game server that resources have expired. This is slow. Faster would be having everything in memory, but I'm not knowledgeable enough to know how to pull that off well. (Shared memory, maybe?)
  11. As you should be able to see in the error message, you aren't actually specifying a username or password. You need to do that.
  12. Right, a server. (Using forking terminology because that's easier to explain with:) The server shouldn't be doing any actual work. It just spawns children and tracks ticks. I'd use two servers for that, actually, and a master daemon that creates and monitors those two. Master daemon forks and monitors socket server process; if running in the background, the initial process forks and dies and the child becomes this master daemon Socket server sets up listening socket and waits for children Upon connection, server forks and monitors a child process for that connectionChild process communicates with the client Master daemon forks and monitors tick server process Tick server forks and monitors tick handler processes for each thing that has a tick action Tick handlers sleep while they wait for a tick When they wake, perform action, then go back to sleep Tick server sleeps for ticks, wakes children (via socket or signal) when a tick happens There's a socket pair between: - Socket server and tick server - Socket server and each client child - Tick server and each handler child Follow so far? As for threads, if you can then that's better than forking processes. Overall scheme is still the same but the technical details, like forking and socket pairs, are different. Threads are also quite a bit different to manage so you should read up on threading and (presumably) PHP's pthreads before you start trying to add it to your code.
  13. Please don't. usleep. $start = microtime(true); while(true) { // stuff $end = microtime(true); $remaining = 0.5 - ($end - $start)); if ($remaining > 0) usleep($remaining * 1e6); $start = $end; }
  14. That's the idea, but a JSON string like that is annoying. Instead do curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array( "t" => // timestamp, "secret" => // secret, "total_quantity" => // amount, "price" => // price )); It's for arbitrary headers. Said headers can be used for (some types of) authentication. You're supposed to take the request body (the json_encode()d stuff, from the code I just wrote), your private key, and run them through the "HMAC256". Unfortunately there is no such thing. I think they mean HMAC with SHA-256. hash_hmac("sha256", /* the request body */, /* your private key */)
  15. You don't reset _bind after the first query, thus the ->execute() branch in run() gets executed again. I suggest resetting (to false) in prepare().
  16. Can't use header() if there's been any output. The error message tells you where the output happened. You have to decide whether that output should be moved (and if so, where to), or whether there's a bug and your code wasn't supposed to header() at all, or something else.
  17. The logs aren't in MySQL... If you're going to administer a server then you need to learn how to administer a server, and one of the very first things you should learn is where log files are and how to read them. Familiarize yourself with the files in /var/log. And yes, Amazon RDS. It's their cloud database service. So you don't have to manage your own MySQL server.
  18. Have you tried to figure out why the service stopped in the first place? Checked MySQL and system error logs? Any reason you aren't using RDS?
  19. The harder way is restructuring your tables. Without knowing, well, anything about your application, my first thought would be Three tables. One of the user information: name, email, and password. And an ID, naturally. Then another table that has the user ID and potentially other things that may be useful and particularly pertinent. "Pertinent to what?" This table tells you which users are these "warehouse" people or whatever that's supposed to be. The third table is the same thing but for the "event host" people or whatever. Or maybe, The user table from before with an enum field of "warehouse" and "eventhost", like `type` ENUM("warehouse", "eventhost") NOT NULL,That way every user is definitely one thing or the other. Or you can use a SET to allow more than one. Or maybe, If there's a chance of having more than just "eventhost" and "warehouse" then maybe you need something where you won't have to change the schema. That tends to mean two or three tables. One table for users, no surprise. The second table relates a user (by ID) to a thing. That thing could be a string, like "eventhost", or it could be an ID to a third table which lists the different types (and would only have 1,warehouse and 2,eventhost to start).
  20. A blank screen (aka the White Screen of Death) is typically caused by a syntax error. Check your code to see if there are any mistakes. Such as missing a . concatenation.
  21. What exactly is "issues"? You get a line at the top of the table? The first image is in the right column instead of the left?
  22. "Typically"? Take the easy (easier) way out of this: do one query against eventhost, then if they're not there do a second query against wharehouse.
  23. The else is attached to the second if, and only that. Since $keyword doesn't contain "mickey", it executes. You need an else if: <?php $keyword=$_GET['show']; if (strpos($keyword,'house') !== false) { $image="housewives.jpg"; } else if (strpos($keyword,'mickey') !== false) { $image="mickey.jpg"; } else { $image = "default.jpg"; } ?>
  24. Thought so... When you do a UNION, you only get the column names from the first row. That means the ID from the wharehouse table looks like "hostId" and not "whId". As such you can't tell which table a row came from. A question before we continue: what should happen if an email address is present in both tables?
  25. The two lists: there are a few places you could store that information but the most appropriate is probably a database. Then you can add, change, or remove items at will without having to change any code. The looping: two loops, one on the outside counting the first half of the phrase and one on the inside counting the second half of the phrase. Or vice versa, it doesn't matter. The "wrapper": Google has an API you should use for that. I think they consider it part of the "custom search engine" stuff, but IIRC you can fiddle with it so that it acts like a regular search. The results: also go in the database.
×
×
  • 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.