-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
And the question is...?
-
Move the file.
-
So you're using sessions that you've come up with yourself instead of PHP's sessions? Doing so makes it not redundant. Having to check every time does. If the password is broken then the user account is lost. There's nothing you can do about that besides try to help the original user deal with the fallout (like issue refunds for fraudulent purchases). Well, you can use two-factor authentication, like an answer to a security question alongside the password, which would make it harder to "hack" into someone's account, but my point is if that important information is compromised then it's all over. Session hijacking is a problem with cookies, not just with sessions. Your system of reauthenticating is even more vulnerable because there's no way for you to know if a request was hijacked - you don't store any information associated with the "session", like user agent or IP address, to use to verify the request. So regardless of the exact mechanism, be it no session or a custom session mechanism or PHP's sessions, if you use cookies then you have to take precautions against hijacking. As long as you're not storing lots and lots of data in the session, no there'd be no meaningful difference.
-
Thread on the internals mailing list
-
Without the session cookie (that is, without sessions at all) you'd have to reauthenticate the user every single time they visit a page. That's generally unnecessary overhead. Without sessions you can't securely store any information without having to retrieve it from the database every time. But how would you know which information to get? What if the user is logged in on two machines - that should be two separate contexts with two (at least partially) separate sets of information. So now you need a unique identifier to tell what to retrieve. And now you've reimplemented sessions.
-
No .htaccess, or other means of affected Apache, means your URLs all have to point to an actual PHP file. However you can basically treat one like a directory and it will still work. For example, /blog/post.php/2013/10/blah-blah-blahwill execute the blog/post.php script (if it exists), and from there you can look in $_SERVER at either a) the REQUEST_URI to give you the whole path and query string ("/blog/post.php/2013/10/blah-blah-blah"), or b) the PATH_INFO to get everything after the filename ("/2013/10/blah-blah-blah")
-
You'll end up tweaking things to be sure, but it sounds like all you need to do is reduce the problems to equations. You have five variables (quality, base time, computed time, base cost, additional cost) but you'll have values for all but one. Like the computed time: the base time and cost are predefined according to the building while the quality and additional cost are provided by the user. q = Quality (0-100%) t0 = Base time t = Computed time c0 = Base cost c = Total cost // example t = t0 * (1 - 0.08 * c / c0) * (q / 100) = 60 * (1 - 0.08 * 200 / 100) * (100 / 100) = 50.4You can even leave one of the inputs undefined and create a true equation. t = 60 * (1 - 0.08 * c / 100) * (100 / 100) And maybe graph it, giving a clearer view of how you can vary one value (here, cost) to affect the build time.
-
"and game_date = '$date' and team1_result 'Win'"$date is a DateTime object, not a string. You need to do the same kind of thing you did with $newtime: format() the time to get the Y-m-d value and use that in your query instead. $newdate = $date->format('Y-m-d'); "and game_date = '$newdate' and team1_result 'Win'"
-
Take what you find at w3schools.com with a grain of salt: some of their information is good but some of it is not, and if you're new to PHP you might not be able to tell which is which. The problem is in if ((($_FILES["file"]["type"] == "doc") || ($_FILES["file"]["type"] == "pdf") || ($_FILES["file"]["type"] == "dotx") || ($_FILES["file"]["type"] == "rtf") || ($_FILES["file"]["type"] == "txt")) && ($_FILES["file"]["size"] < 5242880) && in_array($extension, $allowedExts)) {The "type" will actually be something like "application/pdf" or "text/plain" - not the file extension. And in fact you can't even rely on those values either: they're provided by the browser (not PHP) and it can claim the file is any type it wants. Ideally you should be checking the type of file yourself. I don't mean the extension (which is important) but looking at the contents of the file to determine what it is. You don't have to do that yourself manually though (unless you wanted to) so it's not so bad. But since this project is just for your own sake of learning, I'd say just keep that fact in mind and not worry about it for now. Just check the file size and extension. if (($_FILES["file"]["size"] < 5242880) && in_array($extension, $allowedExts)) {
-
Those four names are inherited from C/C++ and general Linux programming. [edit] If you're going to have a hard time with things like differing function names then consider learning a different language.
-
Use URL rewriting so you don't have to do this work yourself. For example, with Apache, mod_rewrite, and a .htaccess you do RewriteEngine on RewriteRule ^articles/(\d+)$ articles.php?id=$1 [L,QSA]Then make articles.php use $_GET["id"] to decide what article to show.
-
Uncaught TypeError: Cannot set property 'innerHTML' of null
requinix replied to NOurDeSiGNer's topic in Javascript Help
Congratulations, you figured out how to post the error message a second time. Copy and paste is amazing, isn't it? I asked a question. Will you be answering it? -
You're also using smart quotes (around the "Order processed" message). Don't. Just regular "s and 's.
-
per se Bayesian filtering is the first place to start your quest. It can actually be very powerful once educated properly. Not that I've ever heard of. Wrong tool for the job. If some software supported "hooks" then you could probably use a PHP script for that part, but for the actual email server itself no.
-
Probably.
-
And what's the code that sets $user_data? Also, user_data() won't return anything if you don't pass it the fields you want returned. If a function returns a value then it should always return a value. Maybe you can assume a default of getting all the fields?
-
str_replace() will replace every instance of the string, not just one. You need a narrower setup like with strpos and substr_replace. $pos = strpos($initialSent, $sentArray[$counter]); $newSent = substr_replace($initialSent, $nounArray[$nounCounter], $pos, strlen($sentArray[$counter]));(untested but looks right) After this you'll have to modify the code so that it doesn't keep trying to replace in the initial string ($initialSent) every time but can continue from where the previous replacement happened ($newSent).
-
Uncaught TypeError: Cannot set property 'innerHTML' of null
requinix replied to NOurDeSiGNer's topic in Javascript Help
Is it actually called "nonotifications"? -
Or maybe you're asking for <?php print insert_proplayer( array(), // wpsc_the_custom_fields( 'slug=url-movie') ); ?>which isn't easy because apparently wpsc_the_custom_fields() outputs information instead of returning it. Which is one of the reasons why every good developer I know personally loathes WordPress. You'd have to do stupid crap with output buffering <?php ob_start(); wpsc_the_custom_fields( 'slug=url-movie'); print insert_proplayer( array(), ob_get_clean() ); ?>Can you modify insert_proplayer() to not need that wpsc_the_custom_fields() as an argument? It's all getting printed anyways.
-
Not really? The string is parsed the same way strtotime() does it.
-
try { $invoice_date_o = new DateTime($invoice_date_s); $due_date_o = new DateTime($due_date_entry); } catch (Exception $e) { $message = 'Both dates must be in a valid format. Please check both dates and try again.'; break; }An Exception is being thrown. What is it? If it has something to do with date.timezone then you need to set that value in your php.ini or call date_default_timezone_set in your code somewhere beforehand.
-
1. foreach ($array as $key => $value) { $object->$key = $value; }2. A separate function where you pass, as arguments to the function, the values you got from the database and the object you want to set those values on. function set_variables($object, array $data) { foreach ($data as $key => $value) { $object->$key = $value; } }3. Based on the whole "make a function where you tell it what data to use", I thought you might ask "well why not just do all that work in the find_by_id() method and save myself another function call?" The problem is separation of concerns: that find_by_id() should be a small method that does only what it actually needs to do, and that is to get an array of data from the database. In this particular situation you want to put that data on an object, but maybe somewhere else you don't want to do that. Maybe you do want just the array. Or maybe you do need to put it in an object but there's special logic you have to follow, or maybe you only want some of the data in the object, or maybe something else.
-
What you posted looks fine (honestly, I would have said something if it didn't) so if there's a problem then it must be with what you haven't posted. So how about showing us the rest of your code?
-
It may sound like a silly question, but does it work and update the fields the way you want it to?
-
Did you change all the others too? It's a stupid question but I feel compelled to ask.