« first day (1645 days earlier)      last day (3296 days later) » 

7:00 PM
I don't care
just ranting
 
That's because you've been looking at the PHP questions?
 
Hi! Could someone please check on this question? Probably even with moderator privileges?
http://stackoverflow.com/questions/29719177/php-convert-large-decimal-number-to-hexadecimal

I answered it, the OP accepted my answer. Just after that a user showed up and decided that the OP surely wanted to ask something different, therefore he edited the question's title and tags. He gave another answer which is cool in general, but is really bad for the concrete question. Now he is stating that SO should not be about concrete questions, rather about general solutions. Did I misunderstood how SO wor
 
The edited title seems to be what OP actually is asking?
 
There's a pending edit that is bogus.
 
Yeah that is @CMate trying to revert
 
7:09 PM
The OP was using phpseclib and could not fetch the hexadecimal value out of it.
There is now conversion required, as phpseclib supports it.
 
The title edit was just fine. The removal of the phpseclib tag is what is problematic
 
Now it seems the question is about dec-hex converting and bcmath. However, no converting or using bcmath is required.
 
Guys, I was debugging this: $router->parse('/Users/{username}/{id}');
 
Even phpseclib, the most closely related tag was removed.
 
public function parse($uri)
{
    if(preg_match_all('/{([a-zA-Z0-9])}/U', $uri, $matches, PREG_SET_ORDER)) {
        echo "hi";
    }
}
But, I don't seem to see the 'hi' message in the screen.
 
7:10 PM
@CMate Yeah that is somewhat problemtic
 
I believe my regex is wrong.
What I tried to match: The value between every { } in the $uri string
Where, the value between curly braces maybe both uppercase and lowercase alpabets and numbers
 
It is fine for me, this guy just really got on my nerves with his personal insults, etc.
 
@CMate Where did he insult you?
Did I miss some deleted comments?
 
I already flagged that comment for moderation attention. That comment has been deleted since as I see.
 
@CMate I don't think you're wrong, but maybe you could just go have a beer and not worry too much about someone on the internet being a little bit rude.
 
7:21 PM
@HassanAlthaf maybe output buffer?
 
@MarcelBurkhard what do you mean?
 
Well, I'm not used to it on SO from higher rep. people to reflect with insults about arguing on programming topics :) Anyway, thank you guys @PeeHaa, @Danack for your attention. Probably you are right and I should just let it go :)
 
@MarcelBurkhard I believe my regex is wrong. :/
 
what were you trying to achieve with it ?
 
I am trying to
 
7:23 PM
Now I want need to open a beer... @Danack @CMate
 
@HassanAltha I thought you were stepping through your code and didn't see the "hi" in the browser :P
 
I was debugging this: $router->parse('/Users/{username}/{id}');
public function parse($uri)
{
    if(preg_match_all('/{([a-zA-Z0-9])}/U', $uri, $matches, PREG_SET_ORDER)) {
        echo "hi";
    }
}
That is the method I am calling.
According to what I tried to achieve, it should echo hi
What I tried to achieve is,
 
@MarcelBurkhard it's seems like you are going the wrong way around this
 
To get the string inside the curly braces everytime a string is covered by curly braces
 
@tereško I figured ^^
 
7:25 PM
But, the string inside cannot be anything other than alphanumeric stuff
 
@HassanAlthaf '/Users/{username}/{id}' looks like a route notation, which should be CONVERTED into a regular expression. Then you take this regexp, apply it to your incoming URI and extract the values.
 
And I need the string inside them as well.
 
"notation" as in: simplified definition
 
@tereško Mind re-wording the second sentence? I can't undersand.
 
fuck
 
7:26 PM
it doesn't make sense. :/
Yeah, exactly @tereško
 
@HassanAlthaf yeah , sorry, it looks like I lost my train of thought half way through
 
Happens.
Please correct my logic if I am wrong:
What I tried to do is, check if the stuff inside the braces is alphanumeric
 
lemme see, what I can do, gimme a minute or four
 
And if so, accept it and take the values inside all curly brace occurences
and like return what parameters are expected from the URI
 
.. this actually might take about 10 min for me to write a working solutions .. if I find where to actually run it
 
7:30 PM
And then, once a user with similar format, it extracts the values from the URI and passes them to the route handler
 
@tereško "Where to run it?" Meaning you have only installed games on your new machine and not even php?
 
@HassanAlthaf I suspect just borrowing the code from github.com/guzzle/guzzle/blob/… might be easier.
 
morning
 
I think it does the same as what you want to do do.
 
Morning @Leri
 
7:31 PM
@PeeHaa I am visiting parents this week ... deep in the countryside
 
@Danack I could even borrow code from Niki-C's fast-route but I don't want to do so. I wanna learn.
 
Just recovered from awful project with the worst front-end dev I have ever worked. yay
 
@tereško ah sounds like "fun" :P
@Leri \o/
 
yeah .. access to "stuff" is reaaaaaaaly limited
 
plops open a beer
 
7:32 PM
@HassanAlthaf ....you could look at that code to see how it works, and apply the same techniques to your own code.
 
@Danack Oh i see.
I thought you meant rip some code.
 
He did not even use loaders when I was processing 10 million items in db on the backend assuming user should be sitting in front of the monitor wondering 4-5 seconds. :D
 
oh hell
I will have to use vim
 
holy crap.
 
@PeeHaa hehe, thanks. ;)
 
7:34 PM
Array ( [0] => Array ( [0] => {username} [1] => {id} ) [1] => Array ( [0] => me [1] => id ) )
Sorta managed to find a working regex from googling around
'/\{([a-zA-Z][a-zA-Z0-9_])*\}/'
However, it returns 'me' as a match for 'username' but does it fine for {id}
 
basically, your first step would be turn turn 'test/{id}' into #^test/(?P<id>[^/\\\\.,;?\n]+)$#
 
Any solutions?
wait sir, that is greek
 
lol
 
you must be a legend to even think of it
thereby, i address you as sir
 
gimme some time to set up the development environment on this box, and I will write a sample code for this
.. I am downloading PHP now
 
7:37 PM
@bwoebi yeah, even though I was told by Pierre that being diplomatic doesn't work
he can have his belives, I'm okay with having the results. :)
 
@Tyrael That's the right attitude :-)
 
yeah, there was a time, when I was really focused on trying to convince/change some people about their pov and that almost made me to leave the project
since then I only try to focus on the issues at hand and that seems to be working better for me
 
You can try. But don't force. But yes, good attitude :-)
 
:-)
 
7:54 PM
So, fortunately it seems you cannot call functions or methods in case statements.
Wait, I lied.
You can.
:(
I should propose deprecating that in PHP 8.
 
Why?
 
no
dont
 
Or do you mean in the actual case foo(): ?
 
Perhaps you didn't understand what I meant:
function foo() {
        return true;
}

switch ($a = 10) {
        case foo():
                echo $a;
        break;
}
^ that works.
 
Yeah that is bad
 
7:56 PM
ohh
Do it!! :D
 
I know some people rely on stuff like this though:
switch (true) {
        case $obj instanceof DateTime:
                echo "DateTime";
                break;
        case $obj instanceof StdClass:
                echo 'StdClass';
                break;
}
I'd prefer to not allow expressions in them.
 
you mean switch(true) ?
 
Yeah
I would love to hear someone defend this pattern, honestly.
 
@LeviMorrison you can include any expression in a case.
Methods/func calls just are side effects here
 
@bwoebi This is not true; you cannot use list() =
 
8:00 PM
who wants to fund me a Intel Xeon E5-2699v3 ? :P
 
But nearly any expression, yeah.
 
Actually you "can": switch (true) { case ($get == 'items' || $get == 'severalitems'): } but yeah don't ;) — PeeHaa Apr 10 at 19:36
 
And every time I see someone do this kind of thing I cringe in pain.
 
I don't think having switch/case/default and if/elseif/else be the same thing with different syntax really helps anything.
 
8:02 PM
@LeviMorrison well… but it is that?
 
@LeviMorrison you can use a list assignment expression, sure
 
that's the definition of a switch.
 
@NikiC Maybe I just did it incorrectly; I remember trying this in the past.
 
@LeviMorrison maybe you tried a raw list(), which is not an expression
 
Maybe.
 
8:03 PM
@HassanAlthaf it should also work with other simple patterns
like '{controller}/{action}/{id}
 
@LeviMorrison But there exist situations where you compare one method call against multiple other method calls. Then you can use a switch/case.
 
and you can extend the $map to add more behaviour:
 
// It's basically the alternative to
$val = val();
do {
    if ($val == foo()) {/* ...*/ break; }
    if ($val == bar()) {/* ...*/ break; }
    /* default ...*/
} while (0);
@LeviMorrison which may make perfect sense. [I haven't a concrete example ready] But I've already seen such code.
 
    $map = [
        '{' => '(?P<',
        '}' => '>[^/\\\\.,;?\n]+)',
        '[' => '(?P<',
        ']' => '>[0-9]+)',
    ];
@HassanAlthaf this would let you use [] to define "numeric only", like: users/{username}/[id]
 
That switches only allow constant values in e.g. C is rather a technical restriction for better compile-time optimizing.
[I guess]
 
8:08 PM
@bwoebi Other languages use advanced pattern matching in switch statements.
So you can do things like:
switch productBarcode {
case .UPCA(let numberSystem, let manufacturer, let product, let check):
    println("UPC-A: \(numberSystem), \(manufacturer), \(product), \(check).")
case .QRCode(let productCode):
    println("QR code: \(productCode).")
}
 
That's the swift example, right?
 
Yeah; I knew I could find it quickly.
It's not the only language that does this.
But we can't easily do something like this in PHP because we currently allow method/function calls. We have to introduce new syntax of some kind to disambiguate.
But in my opinion I'd rather just disallow expressions, hence the rant ^^
 
maybe… but now I'm too tired to argue debate discuss.
 
Rust has both switch and match, so it's not unprecedented to use alternative syntax either.
 
Switch ($foo) { match [int $a, int $b]: return $a +$b; }
 
8:22 PM
@teresko Thats amazing! Thanks a lot man!
 
8:52 PM
   if (getenv('HTTP_CLIENT_IP')){
     return getenv('HTTP_CLIENT_IP');
  } else if (getenv('HTTP_X_FORWARDED_FOR')){
     return getenv('HTTP_X_FORWARDED_FOR');
  } else if (getenv('HTTP_X_FORWARDED')){
     return getenv('HTTP_X_FORWARDED');
  } else if (getenv('HTTP_FORWARDED_FOR')){
     return getenv('HTTP_FORWARDED_FOR');
  } else if (getenv('HTTP_FORWARDED')){
     return getenv('HTTP_FORWARDED');
  } else if (getenv('REMOTE_ADDR')){
     return getenv('REMOTE_ADDR');
  }
Which is more reliable?
 
neither
you cannot trust the IP that you see from the user
 
@VeeeneX Only REMOTE_ADDR should be used
 
Yes, I can't trust browser, cookies, evercookie, browserfingerprint nothing
@PeeHaa It's cannot be replaced with custom header?
 
No it can not
 
Ohh yes!
 
8:56 PM
Everything else should be thrown away
 
And there is no way how to get client machine mac or its name?
 
You mean the machine behind the router?
 
only thing that you can do is make sure that the cookies that you get have been issued by you (by adding a signature and timestamp to the cookie value
 
Yes, in local network
 
No not with php
 
8:58 PM
Only with ActiveObject?
 
what are you trying to do ?
 
Or something else that runs on the client
Also really what @tereško just asked
 
tereško, but i need a ban system too so I need to store client's ips
 
.. and if something runs on client, it cannot be trusted, because it is controlled by the client
 
Anonymous website for commenting posting voting and so on...
Yes, that's another problem
 
9:00 PM
then you can only ban values of the REMOTE_ADDR
that's about it
and even that will probably do more harm than good
 
@tereško Then I should ignore that client from accessing the functions of the website
 
you cannot control the access to a completely anonymous point of entry
 
I can't rely on anything :D
 
Happy wekend everyone =]
 
Ronni!
 
9:09 PM
Pieter!
 
How are you today?
 
Drinking whiskey =] so good .. how about you?
 
@RonniSkansing Let me make a pic
 
yea [=
 
9:14 PM
@ircmaxell why do I get the sudden urge to punch this person >
 
wow that took way larger then needed. Next one goes over google hangouts session. Moving images from phone to pc is hard
then / than?
I think than
But it looks stupid
 
@ircmaxell yeah .. the urge intensifies
 
dude, it's all satire
 
eih .. I have heard way too many of those from management
those are basically real quotes .. the attribution is just wrong
 
9:26 PM
 
=] @PeeHaa beer or whiskey?
 
whiskey o/
 
o/ nice!
heres one back at ya
 
lol @ the cat rosie :D
 
9:43 PM
my gf is in love with the cat.. the site is like a cat orphan site
 
/me is having a tea and cake
 
sounds good @tereško
 
I presume they're just people who login to their server to deploy new versions of software. And that I don't want to hear any more of their wisdom.
 
Apparently it works, but is there a better way to "identify" a closure on subsequent usages? 3v4l.org/iGQti
 
21
A: Determining, if a variable is a valid closure in PHP

marioThe most deterministic way to check if a callback is an actual closure is: function is_closure($t) { return is_object($t) && ($t instanceof Closure); } All anonymous functions are represented as objects of the type Closure in PHP. (Which, coming back to above comment, happen to implement t...

 
I know that I'll receive a closure, I just want to know if I already performed the operation (as I could then return a cached resultset).
But that approach fails as soon as the same closure is defined in two different places.
 
10:27 PM
@Rangad If you're tired maybe go to sleep?
 
Maybe it's better to just add a note that the part is slow and the user is responsible for not recalling it, if not required, no hacky solutions required.
@Danack I need to finish this to have a clean conscience (don't want to work on sundays"
 
@Rangad Well it sounds like you're trying to solve the wrong problem. If you need to have some information only created in a once, you need to have a single place in the code responsible for managing it, rather than trying to detect duplication elsewhere.
 
10:45 PM
Probably. If only I would ever use this I had no problem. But I'm thinking to much of others. I'll wrap the common usage patterns (and handle storage there) and if someone needs to use something that is not possible using the higher level api, it's really not my problem if he misuses the bare interface and doubles the response time in the process.
Thanks for putting my mind on a better track.
 
11:15 PM
Hello. I'm curious whether hastebin.com/peragahesi.bash can be exploited to print "Yay!". The part I'm concerned about is that the first if check them separately but the second checks them after concatenating them together. The user has control over $a and $b (through a post request, but I doubt that's important).
 
11:43 PM
tried everything i could; answer appears to be "No" but i'm not sure
 
@Blob Yeah, I can't see anyway either though. But maybe there's a better way of making it secure. Presumably you're using $a.$b to be some sort of command?
Or interpreting it to what the user wants to do?
 
@Danack The code is not being used for any purpose. Just wondering if it could be exploited.
 

« first day (1645 days earlier)      last day (3296 days later) »