-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Parse out values in string separated by periods
requinix replied to galvin's topic in PHP Coding Help
explode()s third argument lets you limit the number of items to, say, 3, with the third having the rest of the string. -
You may need to call session_write_close() before starting another session. Also keep in mind that session_id() will cause a new session cookie to be sent, so there'll be one for the second session and another for the first session (when you switch back to it).
-
Not that I know. Try not to make a habit out of switching between sessions though.
-
Sure. Javascript is a programming language. It can do things like add two strings together. $('#popup').load("../help-file/"+ page + ".php"); // I'm guessing at the path
-
Is page a proper URL? Can you actually skip loop.php, like are the things it does not terribly important? Then sure: don't use loop.php and .load() the page directly.
-
Depends. Better way to do what, exactly?
-
Header doesn't seem to work/ Doesn't redirect
requinix replied to simeonC's topic in PHP Coding Help
You should also exit; after doing that, but no, in that tiny bit of code you posted there isn't anything obviously wrong. -
xml validation with schema failed but the xml is valid
requinix replied to zollen's topic in PHP Coding Help
Works fine for me. That's the exact code and XML you're trying? -
That [^] has the characters to allow. If you want to allow @ and . then all you have to do (at least for those two in particular) is to add them to the set.
- 1 reply
-
- 1
-
Current URL? Is this always running for a file that's in a subdirectory and not like /file.php? dirname($_SERVER["REQUEST_URI"])
-
String functions certainly could do it, though it's a little harder since you need to do error checking (eg, what if there is no "dog" or "cat", or what if "dog" comes after "cat"). The regex version would be $output = preg_replace('/dog.*cat/', 'animal', $input);
-
Everything in $_SESSION stays the same.
-
Doesn't matter because session_regenerate_id() doesn't delete the data. It's going to change the session ID, which is the entire point of session_regenerate_id(), but the data stays the same.
-
Did you check the actual values of $start and $end?
-
What's the most obvious thing to try? Have you tried it? Or what have you tried?
-
The three numbers from uptime are load, which is (more than) a measure of how active the CPUs are. Say, 0.01 per percent per CPU, so a 2-CPU machine at 100% CPU would show 2.00. But the numbers can go higher. The three correspond to the average load over the last 1, 5, and 15 minutes. if (preg_match_all('/\d+\.\d\d/', $output, $values)) { list($one, $five, $fifteen) = $values[0];With the headings, free shows total used free shared buffers cached Mem: 2040152 1926196 113956 248 26764 1724268 -/+ buffers/cache: 175164 1864988 Swap: 2093052 0 2093052The first three numbers give you everything you need (measured in KBs) and you can grab them easily with if (preg_match_all('/\d+/', $output, $values)) { list($total, $used, $free) = $values[0];
-
Is removing whitespaces is necessary for php websites?
requinix replied to seophpknow's topic in PHP Coding Help
It is not. Removing space is to help with bandwidth usage but PHP doesn't use that.- 2 replies
-
- whitespaces
- phpwebsites
-
(and 2 more)
Tagged with:
-
Ah. Shared hosting. That explains it. 1. You're using enough resources that there's a risk of the machine running out and your hosting provider isn't going to like that. There's probably wording in the ToS to that effect. 2. You can generally get information like CPU and memory usage on a machine, but it's only worth it if you can target a very specific setup - not just Windows vs Linux but which version running in what environment. And on shared hosting the tactics you can use are often unavailable as half the time they involve you running something through exec() or system(). 3. You're pushing the bounds of what shared hosting can provide. Consider upgrading to dedicated hosting. ps gives a full breakdown by process. You need overall statistics. Try uptime for load (a better indicator than CPU usage) and free for memory usage.
-
Okay, but is there an underlying problem you're trying to solve? Putting a script to sleep because of resource problems isn't always the right answer.
-
With effort, yes. What exactly are you trying to do?
-
Apparently the file isn't in the ISO 8859-1 encoding.
-
Could. But you'd still have to partition them into additional directories.It's not my first choice simply because that's generally not how I do it - I like even spreads and users don't upload evenly. 1. Perfect normalization is not always the best thing in software development. Some redundancy helps.2. It's only redundant as long as you can compute the path based on other data. If you change the naming scheme and don't move the files to match then it's no longer redundant. Another option is splitting on upload date: Y/m/d. Maybe /h too. It's less arbitrary than the hash.
-
Naturally, putting all the files in a single folder isn't that great. I'd go with more than one character from the hash. Like two. At three levels that's 16M leaf nodes, and 1M users with 500 files each is only ~31 files per leaf. Remember that you can change the folder scheme at any point too (if you don't mind leaving the files where they are now). If you store the full path to the file, rather than just the hash, then it doesn't really matter where they are.
-
Correct. But I wasn't talking about that. I was only commenting on the regex you had and how it's not very good. But then you went on to show a regex that does not do what you said. *Hashed. But no, that's not necessarily the case. Right...
-
1. It's already in one expression. 2. Those don't match with what you said you wanted to do. Here are some reasonable passwords your current regex(es) won't allow me to use, driving me away from your site: - de$traM1c - de$TR4M!C - de$7rAm!c - d3sTr4M!c - DE$tr4m1c - DE$7ram!c Not to mention that the three examples you gave don't even match...