-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
The / are part of the traditional syntax for it. They don't actually contribute anything to the regular expression itself, but they can be useful to separate the expression part from any flags you might want to apply. Since Javascript's RegExp separates the expression from the flags, and since it needs the expression as a string, there's no point in requiring the slashes. But if you write a regex literal, so not using the RegExp class directly, then you have to use the slashes because (a) that's the syntax so Javascript knows it's a regular expression and (b) you also have to specify flags at the same time and the slashes can separate them. /foo/i <=> RegExp("foo", "i") https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
-
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
Only a Sith deals in absolutes. There's a very basic principle to consider: cost versus benefit. The issue here is whether to invest some undetermined amount of effort into making sure a theoretical attack on your voucher codes isn't possible. The cost is moderately high and the benefit, assuming we're not talking about vouchers worth thousands or millions of dollars, is negligible. It's not worth worrying about. -
You did start a new topic. But given how it's very closely related to this one, and how you didn't really include any information besides "I TRIED /FRENCH/ AND IT ISN'T WORKING HALP", I figured I''d save everyone (including myself) the headache of having to pull some more teeth by just bringing everyone back in here.
-
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
It's not that simple. People can't simply look at a number X and say "oh, now the next number will by Y". What they do is generate tons and tons of X values, analyze the patterns, and then predict what the next few Ys could be. That kind of thing is just not something most developers have to worry about. It's the realm of governments and banks. -
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
rand() wasn't very good until PHP 7.1 when they made it be the same thing as mt_rand(). Is it cryptographically secure? No. Is that relevant to what 99.9% of people need it for, including you? Also no. Create an "alphabet" of the characters you want to support in the password, which I say because omitting ones like O/0 is reasonable, then write a simple for loop that creates a password of whatever length you want by drawing from that alphabet. Also, creating passwords like this is typically wrong. -
Merged. I lost track of whether this was pointed out, let alone resolved, but are your regular expression strings including the / delimiters too? Because they should not do that.
-
Probably? Consider that we have absolutely no idea who you are, what you're working with, or what kind of problem you're facing - except for what you tell us. Things like "news posts" and "header images" and "events banners" mean nothing to us unless you can describe what they are.
-
And I want a $500k/year job. What you and I have in common is that asking people on the internet to give us what we want isn't going to work. How about providing a lot of detail about whatever you're trying to do and including one or two specific questions with it?
-
I guess I'm saying you've got three solutions in this thread that all work, so if whatever you're doing isn't, you've got a different problem.
-
-
Take your pick. I think VS Code and PhpStorm are the top two right now.
-
Your query binds a parameter it doesn't use, you loop on whether it rows thus it'll either loop forever or not at all, and you're attempting to shuffle a number. I was hoping you would pay more attention to the part of my post where I said "likely the wrong solution" and less so on the "will not work as is".
-
Putting aside that your code will not work as it is, and that this is very likely the wrong solution for what you're trying to do, You're dealing with numbers up to 17 digits long. Unless you're generating millions of these, you're not realistically going to get a duplicate. Put it into a loop and it'll work.
-
What are the exact contents of config_data.excludes and item.title?
-
I don't see how those two are related. Are you able to write a function that can copy just the files in a directory?
-
/.../ is a RegExp. You only need to deal with the class if you want to create a regex from a string. And it's also not actually a function but a class, however you can invoke it like a function and get an instance in return. .test is a function on re, which is one of the regular expressions in the array. The whole point of Array.some is that it executes some function for every item in the array until it finds one that passes (the function returned truthy), in which case it returns true itself. "Are there some items in the array which meet some criteria?"
-
Well there has to be a loop somewhere, question is whether you write it yourself or not. Array.some const regexes = [/a/, /b/, /c/, /d/, /e/]; const input = "something"; const any = regexes.some(re => re.test(input));
-
Just writing "navbar.html" is a relative URL which means that where the URL actually goes depends on what page you're using it in. It'll always be in the current "directory", so to speak. And whether that URL is in a link or a stylesheet or some Javascript doesn't matter because they all work the same way. "../navbar.html" is also relative, except it means "go up a directory and then look for navbar.html". What you want is an absolute URL. It starts with a slash and always starts from the root of your website: "/navbar.html". Which isn't the right path, of course - apparently you need "/TestDash/navbar.html".
-
Correct. That is what's throwing off the layout. Check your notification settings - specifically, "Change how the notification is sent".
-
(psst I already know the answer) Don't worry about what "static" means. That's not the issue here. Look at your CSS rules. If you provide that position:static then that takes effect. If you don't provide that position:static then what else will take effect?
-
need help to make links hidden if not admin
requinix replied to alexandre's topic in PHP Coding Help
// Store the result so we can check if the account exists in the database. $admin = mysqli_query($con, $stmt); Are you sure you want to do that? -
This has nothing to do with static and everything to do with CSS rules. Just because you have media queries in one place does not mean that rules defined elsewhere without media queries are never applied. So: what other CSS do you have being applied to things like .dropdowns?
-
Yeah. Otherwise it's just a string.
-
upgraded php version will not run phpmyadmin
requinix replied to garyed's topic in PHP Installation and Configuration
Do you have server and/or PHP error logs being recorded somewhere? -
Your site does not work by turning off errors. The problems are there and need to be fixed regardless of whether you can see error messages about it or not. The only thing that the PHP 8 upgrade did was change error display settings. These problems, like "trying to access array offset on value of type null" and "undefined variable", have been there for a while. You just didn't know about it until now. Frankly, "thousands of lines of code" is not that much. Each error message tells you where the problem is - all you have to do is go to the code on that line and, most likely, make a small change.