-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
My regex validation for mobile phone numbers failing
requinix replied to terungwa's topic in Regex Help
Threads merged and moved to Regex. terungwa, as Jacques said the regex works in PHP, while you need a pattern that works with Javascript's regular expressions (which is what the "pattern" is). There are big differences between the two. (?:\+?234|0)?(?:704|702|803|806|703|706|813|816|810|814|903|802|708|808|812|701|902|809|817|818|909|908|805|705|815|807|811|905)\d{7}- \A and \z anchors are not supported - use ^ and $. However the "pattern" is already implicitly anchored so you don't need them. - Remove the extra backslashes, which were being used for escaping within PHP strings Be sure to do the same validation in PHP (with the other regex) because this validation in HTML can by easily bypassed. -
Why can't you just authenticate once for the entire duration of the script? Why does each function have to perform the same check every time?
-
Accessing google one drive on website server side
requinix replied to EricBeaudoin's topic in PHP Coding Help
If it needs to be private then why are you hosting the content in Google? You have a web server, possibly even a database too, so that's where it should be managed. Almost. What I'm saying is that the server cannot log into someone else's Google account. I don't think there would be a problem if the server did stuff on behalf of the owner's own Google account, but that doesn't necessarily mean there's an actual method you can use in code to login in with an email address and password. If you want the server to use your account then I suggest taking the OAuth approach too, then storing the tokens in a special "these are the owner's tokens" area (so they are not confused with those of a regular user). You'd only have to sign in once. -
After you put the file someplace not accessible over the web (outside the web root is easiest, otherwise use a .htaccess with appropriate directives to deny access), make a PHP script with <?php /* do whatever you want to log access */ $file = "/path/to/file"; header("Content-Type: application/pdf"); header("Content-Length: " . filesize($file)); readfile($file);and embed the URL to that instead.
-
Accessing google one drive on website server side
requinix replied to EricBeaudoin's topic in PHP Coding Help
Which is another way of saying "I want the server to collect information from my Google account so it can put that information in another Google account". Either way you're trying to impersonate a user, and that's a no-no. It actually used to be a thing a while back, but they discontinued that method around... June 2014 I think? I remember that because it broke an application we were using at work and nobody knew it was coming (despite being deprecated for at least a couple years). Having the web server log in... with someone else's account. The client (user) wills in a form... containing their Google credentials. It's not an issue of being a server/client thing. It's a question of who is able to authenticate using whose account, and the answer is "only the person who owns the account". All that said, it's possible I'm misunderstanding what you're trying to do. But whatever it is, if you need to get to something in someone's Google account then you must use the OAuth process for it. -
Accessing google one drive on website server side
requinix replied to EricBeaudoin's topic in PHP Coding Help
Nothing quite says "farming for answers" like copying and pasting a question from another site and not noticing it includes some of their markup. As far as I know, Google does not provide you a way to collect someone's Google account information and log into the services on their behalf. You need to use OAuth by, yes, redirecting the user to Google to approve of whatever permissions you need to do whatever actions you want. It can be a one-time action if you need access more than once, though it doesn't sound like you need that. -
Scrolling in topics referred by an email
requinix replied to ginerjm's topic in PHPFreaks.com Website Feedback
Does sound like a lack of focus on the application. If you use the email link then click within the page in the browser, does scrolling work? -
As they said, we don't like to delete accounts around here. While you may no longer need your account, content you've contributed to the forum could be useful for other people browsing around or searching for a solution to their own problem. All you need to do is... just not use your account. No one will be offended.
-
Scrolling in topics referred by an email
requinix replied to ginerjm's topic in PHPFreaks.com Website Feedback
I don't know. The server neither knows nor cares how the URL gets into your browser, so if you can copy/paste the URL and get different behavior then there's something wrong with your browser. -
Scrolling in topics referred by an email
requinix replied to ginerjm's topic in PHPFreaks.com Website Feedback
Literally nothing has changed with the software in the last... well, certainly more than a few days. Anything changed on your end? Browser? It's cliche but have you tried restarting your computer? -
Better approach to extending a class?
requinix replied to NotionCommotion's topic in PHP Coding Help
Ah, yeah, I misread. I was thinking curl -i -X PUT -H "Content-Type:application/json" http://localhost:8888/charts/1 -d '{"title":"My Title","xAxis":"My X Axis Title"}'or I suppose curl -i -X PUT -H "Content-Type:application/json" http://localhost:8888/charts/1 -d '{{"name":"title","value":"My Title"},{"name":"xAxis","value":"My X Axis Title"}}'I would suggest that first one: it is more typical to represent an object with key/value pairs than with a {key,value} set, and generally means less processing involved for both the client and server. -
Better approach to extending a class?
requinix replied to NotionCommotion's topic in PHP Coding Help
The first one is better. Note there's no particular reason why you couldn't have it support updating just one field at a time. -
Better approach to extending a class?
requinix replied to NotionCommotion's topic in PHP Coding Help
If I need to do a code search for anything that calls the updateName() method then the IDE won't show me that getAllowedUpdateMethods() - because "updateName" is just a string value. It doesn't know it's a method name too. Which is why PHP could benefit from a sort of ::function token like it did with ::class. -
You're only checking once per day? That doesn't sound right.
-
"Really simple and optimized" isn't going to do it there. Uptime for a particular service (like a web server) is measured by when the service is accessible. To monitor the service yourself you're going to need something that can evaluate the status of the service. For example, with a web server you'll need something to "ping" the server periodically. Such as a cron job on a one minute timer. When it connects successfully the service is "up", and when it does not the service is "down". Recording that information could go any number of ways. Times 100-200 is not going to be simple, because connecting to that many services could easily take more time than you have between measurements. So that means either multiple "machines" measuring uptime or relaxing your measurement interval. Off hand, one way to store the results is to stick a record in the database per service per minute indicating whether it's online, then using a periodic (daily, weekly) job to summarize that information. Such as calculating uptime for a particular interval, and probably removing the individual measurements for the sake of storage. Or another method would be to say that each per-minute online measurement affords 1 units of uptime (and each day is, eg, 1440 units long), and you can simply accumulate units for each interval: INSERT INTO uptime (machine, service, day, uptime) VALUES (DATE(), 1) ON DUPLICATE KEYS UPDATE uptime = uptime + 1(where the machine+service+day is a unique key and you count uptime as 1=online and 0=offline)
-
It may be because I'm drunk ( ) but I don't understand what you're asking. Do you want to chart the server's uptime over a period of a week? Does the output from `uptime` help?
-
Your new server doesn't have short_open_tag enabled. Best practice is to use the full "<?php" so the changes you made were a good thing.
-
Better approach to extending a class?
requinix replied to NotionCommotion's topic in PHP Coding Help
I'm not a fan of putting function or method names in strings (IDEs can't recognize them). And I'm not a fan of conventions like calling "update"+Name methods (too magical for my tastes). I'd still go with the "configuration"-type approach. Unanswered question that would help to be answered: What ways of handling values are there? For example, there's those three types from earlier: #1 was updating a column in a table, don't know about #2 and #3. I ask because my next thought is abstract class Chart { private $fields; public function __construct() { $this->fields = $this->getFields(); } protected function getFields() { return array( "name" => new UpdateType1("name", $this->id, $this->account->id), "title" => new UpdateType2(...), "subtitle" => new UpdateType2(...) ); } public function set($name, $value) { if (isset($this->fields[$name])) { $this->fields[$name]->update($value); } else { error } } } class BarChart extends Chart { protected function getFields() { return array_merge(parent::getFields(), array( "xAxis" => new UpdateType3(...), "yAxis" => new UpdateType3(...) )); } } interface IUpdateType { public function update($value); } class UpdateType1 implements IUpdateType { private $field; private $id; private $accountid; public function __construct($field, $id, $accountid) { $this->field = $field; $this->id = $id; $this->accountid = $accountid; } public function update($value) { // update database } } I forget the name of this design pattern. It's similar to Command. -
Better approach to extending a class?
requinix replied to NotionCommotion's topic in PHP Coding Help
Do you have to use subclasses? class Chart { private $type; private static $CHARTS = array( "bar" => array("xAxis", "yAxis"), "pie" => array(/* what do you need in a pie chart? */) ); public function set($name, $value) { if ($name == "name") { // all charts have a name // update database } else if ($name == "title" || $name == "subtitle") { // all charts have a title and subtitle // ??? } else if (in_array($name, self::$CHARTS[$this->type])) { // ??? ] } } $chart = new Chart(whatever, "bar"); $chart->set($_POST["attrName"], $_POST["value"]); Sure, you could go the OOP route, but it's making this unnecessarily complicated when all the subclasses do (?) is indicate available field names. -
$e = array((poisson($x+1,2.5) * poisson(0,3.5))*100);That puts one value into an array and assigns it to $e. Over and over and over again. What it does not do is append the value into the array that is already in $e. While you could fix the code to append to arrays properly, don't. Wouldn't it be much simpler to just sum the values as you go? Set $e to 0 before the loop, then inside the loop add each value to it.
-
Have you checked the rest of the documentation? There might be something in there that's relevant. Or you might have to make it force validation on a field (or whatever) manually onblur.
-
Yeah, the debugger works on one single process - when you start the second script it won't follow along. If you had Xdebug then you could launch that second PHP with the right options to automatically start debugging, implying that you were not debugging the first script, but now it's starting to get complicated. Are you sure you need php://input to work? Would you be able to hack it such that it uses a different path, like "php-dynamic://input", then register your own php-dynamic stream that wraps php normally and your testing library stuff when... testing? That sounds like something I would look into myself.
-
-- universally(ish) means to stop processing command line arguments and treat the rest as literals. If you did php -f file.php -hthen PHP would think you wanted to see its help. If you did php -f file.php -- -hthen PHP would run file.php and pass it "-h" in $argv[1]. If you used -f with the command then you would need --, but without -f PHP implicitly stops parsing arguments after the filename. php filename args... php -f filename -- args... And no, I don't know why PHP_BINARY doesn't have a value. Are you calling the first script from the command line?
-
You mean the one that doesn't exist anymore? The one that's been replaced with "FormValidation"? The one that doesn't seem to have any documentation preserved? Fortunately archive.org has a copy from back in September 2014. You know, when the version you're using is from. Try calling revalidateField on "street" and "place" when they get (re?)added to the form.
-
Which "Bootstrap Validator" are you using?