« first day (1943 days earlier)      last day (3004 days later) » 

3:04 PM
Hi, I have a quick question. I put a contactform in my HTML page, changed the extension of the file to '.php' and added this mailer code before the doctype html declaration. Any idea why it crashes? pastebin.com/Zuwvwu3E
 
posted on February 10, 2016 by nlecointre

/* by Nizalwey */

 
@bwoebi TIL valgrind will also report that info :D valgrind --tool=cachegrind php ...
 
@petervries that's not enough information to go on
 
I'll put the code of my form in there too, one sec
 
@Leigh valgrind is simulating it though and not using real hardware counters … it's fine for measuring instructions, but not so much for real world dependent counters
 
3:07 PM
"Website:\n $website".
?>
that last . should be a ";"
 
thanks Justin!
that solved it
 
@Leigh branch mispredicts aren't too bad, but I wouldn't rely on valgrind for cache info
 
appreciate it!
 
hopefully it works for you
Those errors are their to help you diagnose information - their usually very helpful... unless your .net "An instnace of an object can not be set to instance of an object."
 
@bwoebi ah, I tried perf but it didn't output the cache stuff, turns out you can explicitly request it though: perf stat -B -e cache-misses php ...
 
3:09 PM
works wonders
 
@Leigh yes
just no perf on OS X, only dtrace
 
small new problem:
my form sents an email every time the page it loaded, and doesn't redirect the user after sending. Code: http://pastebin.com/2xi0GiN4
 
@petervries Your code is vulnerable to header injection
Also could everybody please stop creating mail by hand
3
 
That doesn't sound too good, will adding reCaptcha fix it?
 
@PeeHaa ?
 
3:18 PM
Yes please. Use Swiftmailer, or something, anything, but mail().
 
@FlorianMargaine headers are \r\n delimited
 
especially if you have to build a MIME envelope.
 
@petervries Nope
 
@PeeHaa I still don't get it
 
Wes
@petervries check swiftmailer
 
3:20 PM
@FlorianMargaine If you do this ` $headers = "From: $_POST[somefield] \r\n";`
it's trivial to add my own custom headers
 
Wes
@PeeHaa but he isn't doing that
 
Say cc
 
@PeeHaa it's for the email
 
@Wes Yes he is
@FlorianMargaine ?
 
@PeeHaa it's the email's headers
 
3:20 PM
Yes
And it allows me to send to everybody and their mother
 
Wes
oh right. stopped reading at $headers = "From: $email_from \r\n";
 
@PeeHaa ah, I see
 
@Wes :-)
Normally I am all for DIY and reinventing wheels. But mail is one of the few (only) things where I say "just use a library" @petervries
 
Alright, ill look into swiftmailer
 
To answer your actual question:
Turn on error reporting and php will tell you what you did wrong
!!canon headers
 
3:24 PM
843
Q: How to fix "Headers already sent" error in PHP

Moses89When running my script, I am getting several errors like this: Warning: Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23 The lines mentioned in the error messages contain header() and setcookie() calls. What could...

 
is swiftmailer 10000x more complicated or did I download the wrong thing?
 
Mail is complicated
 
seems easier to use this validator: pastebin.com/ZwfmcqeJ or is that still unsafe?
 
Wes
use swiftmailer, it's not complicated
 
or PHPMailer
 
3:31 PM
It's not just the security of the thing. It's the entire protocol / servers / clients that are fucked
 
The main reason to switch is that modern libraries actually talk to the mail server over an open socket (which makes debugging much easier). mail() only uses your local server
 
@PeeHaa s/complicated/completely and utterly fucked up/
 
and good luck trying to dig out the reason sendmail didn't send your email
 
Hmm.
!!canon mysql_query
 
Cannot find the canon for you... :-( Use !!canon list to list all supported canonicals.
 
3:33 PM
Worth a shot! Guess I'm off to the Jeeves playground
 
Anonymous
stackoverflow.com/questions/35319311/… And he works for the government....
 
guy is it advisable to use htmlspecialchars_decode?
 
@Jeeves The correct answer is "That's removed in PHP7 you moron"
 
@ircmaxell oh lol ... hai :D
 
@Machavity We already have that (kinda)
 
3:34 PM
Hey Anybody online here?
I want to ask about MySql can i ask here? stuck in joins query :(
 
Nobody is online here. We're all standing in a room, typing at one another
9
 
lol
 
Not me, I'm writing this using the power of thought alone
 
Can you help me regarding mysql query??
I m banned for posting new question :(
 
@DaveRandom Finally finished mod_telepathy?
 
3:36 PM
import talk_with_brain;
 
import real_talk_with_brain;
 
@Nabeel Sounds like you need to do something about that.
@JoeWatkins I C WUT U DID THAR
 
@NorthbornDesign yeah i try and try but the last option to hit in wall xD
 
import srsly_real_talk_with_brain;
import talk_with_ass;
import talk_with_ass_brain_bridge;
 
stuck in issue - mysql aggregate sum() function double my result
 
3:39 PM
@Nabeel Yea, I meant you should do something about being unable to ask questions.
 
Amount is 11500 and it showing 23000
 
the chances that it is wrong seem small ...
 
@JoeWatkins :D
 
@Machavity No, it's buggy and it dies sometimes. Unfortunately because it's in my brain, when it dies I do as well.
It's really quite inconve
 
@DaveRandom Thank goodness you're a cat.
Oh, there he goes again.
At least he managed to hit enter halfway through a sentence.
 
3:42 PM
@ircmaxell so … did you tell him it? ;-)
 
@NorthbornDesign I have a backup keyboard lined up so that when I die my face hits it
The reanimation process only takes a few minutes
 
@DaveRandom Ah, very good. Glad you're back amongst the living.
Everytime you touch yourself, a kitten dies @DaveRandom tries to read your mind and dies... but he comes back to life so continue touching yourself.
 
@bwoebi him being Bobby-D?
yes
multiple times
want me to throw things at him?
 
Bobby-D?
 
Well, we have another Dan that sits 2 seats away
 
3:48 PM
oh well
 
so we renamed him Bob, and hence Bobby-Dan, hence Bobby-D
 
@DaveRandom systemctl brain.service keyboard
 
Is that for serious? lol
 
The proton decay of the universe will prevent you from actually being able to generate all of these strings. — David 22 secs ago
2
 
yes, seriously
@JoeWatkins there are two types of answers I love. Those that reference theoretical physics, and those that don't.
 
3:50 PM
well then go ahead and throw something at him. And tell him it was me who told you so.
 
Hi guys, what is the correct way to escape HTML attributes? I use htmlspecialchars but it changes & character into & in my url and it mess the query string up.
 
& is correct in a query string, no?
 
@BobNocraz If you're putting it into HTML, yes. if you're doing a header('Location:'); then no
 
I use an i5 processor — aXieEEE 5 mins ago
Oh, well that's OK then...
 
url components should be url encoded, not htmlentity encoded
@DaveRandom inorite, it got funnier
 
3:56 PM
@TrungDQ If it's that big of a deal just run str_replace and put them ampersands back
 
url&a=1 would turn into url&a=1 and it obviously mess the a variable in the query string, @BobNocraz
 
"How long will it take me to count to 7x10^28?"
 
Aww, he deleted the thread
 
they are all pretty small numbers, so I think "not long" is the best possible answer @DaveRandom
 
@Machavity is it the right way?
 
3:57 PM
:-P
 
@bwoebi how did fixing that leak impact memory usage?
 
@TrungDQ Given what little I know about your code, probably
 
@TrungDQ as JoeWatkins said, you should use urlencode instead
 
Thanks
 
@TrungDQ build your query string with http_build_query() function, if your data is an array... if not then create data array and use that function :)
 
3:59 PM
 
@NikiC yeah, no leak at all… 13 MB in idle mode (used memory (real size is like 115 MB))
 
Man, the epic answers kept on rolling to the end
> Is that i5 processor going to last the 1.5*10^85 or so years it would take to generate these? (Give or take, it's mostly a wild guess. But since the universe itself has only existed for 1.3*10^10 years, the precision of this guess isn't terribly important.)
> David - if it's running Windows, it'll crash before completing when it gets the automatic upgrade to Windows 11
 
@kodeart the full URL is a response from 3rd party so I think I just use urlencode.
 
actually, i forgot about http_build_query(). sounds like what you're looking for, but if you prefer, you can still use urlencode.
 
@TrungDQ whatever works for your case
but do not re-invent these wheels
 
4:02 PM
@NikiC I just feel like PHP allocator is really bad at releasing memory back to system ^^
 
unless you have a better idea for a new wheel ... because wheels aren't without problems ...
 
@bwoebi it isn't designed to do that, is it?
 
like they rolls vary fast downhill?
 
@ircmaxell no, not really … more designed for perf
 
@bwoebi well, perf in a short-cycle shared-nothing context
 
4:03 PM
Also perf in long running script
 
Well, as a single thing
 
@ircmaxell i forgot about that post of yours :) I always enjoy your stuff
 
not as a part of a system
 
after all, the system should be able to sustain all the workers peaking at the same time
 
@bwoebi btw, I wonder why you didn't get leak warnings for this
does the cycle get broken when aerys shuts down or what?
 
4:05 PM
@NikiC well, because object store list I guess?
 
@bwoebi what about it?
 
@NikiC well, it's iterating over the objects store to dtor any leftover objects and hence it gets freed?
 
refcount would be wrong
 
@bwoebi it only dtors them, it doesn't free them
at least since php 7 it doesn't
 
eih wait…
 
Hey
 
@NikiC exactly and that's causing a free to generator->value and hence the cycle is freed
 
@bwoebi but the allocation will still leak
the code doesn't free the object allocation specifically to find leaks like that
 
Anyone know how I would select the number/letter/whatever AFTER a certain symbol?
I want to select the letter after "√",
 
this is how I tracked down many cycle leaks in php 7 so I wonder why it didn't work here
 
4:11 PM
How wise is it to use -dist-upgrade. Hmm...
 
@kodeart Oops, urlencode seems not quite right, I got https%3A%2F%2... which doesn't looks like a valid url too. I'm trying to escape a url in <img src="<?= $url ?>"/>. Do you have any idea?
Maybe I have to parse the url and then build up the url with correct query string.
 
0
Q: Get Initial php script file name not by __FILE__

Nicolas RacineThe title is pretty self explanatory. Im looking for a way to get what the current script runing. But the thing is I can't use __FILE__ since it give me the file im in at the moment, and in the case of an included file, i want to inital file So if I run index.php and in that file there is an in...

:o
 
@NikiC I'll have a look shortly
 
Is there some reason that would be beneficial?
These PR's with no real description of impact :D
 
4:18 PM
@NikiC there were leaks, but not that many leaks … it leaked 24 objects which weren't related to that particular issue
 
I mean, isn't there a comment in the code saying why avoiding the main stack is beneficial?
 
@LeviMorrison That's the price you pay for the state of the internals list
 
yup
:(
 
Namely, all discussion that does not strictly have to go through an RFC is limited to four people.
 
but have fun with it :)
/me is distancing himself further and further from PHP. Not just internals, but the community as a whole
 
4:21 PM
Building a good community is hard.
 
will still stick around and be around some individuals, and do a few confs here and there
but ultimately I'm just out
 
I'm going to mostly try to improve local communities rather than online ones.
That is, if I ever have any time :)
 
@LeviMorrison The idea behind this change is that we don't want function calls to push state on the generator stack, but put it on the normal VM stack. This means that the generator stack isn't really a stack at all, it's a one time fixed size allocation. This means we can make it much smaller (as we don't need to anticipate calls happening from it -- right now every generator takes up at least 4KB of memory) and have to shuffle around less state
 
I'm going to simply "be" for a while
I've got other things to take up my spare time now ;-)
 
this is extremely crappy news ...
 
4:29 PM
@NikiC found it… it's freed when statically bound data are freed, namely lxr.php.net/xref/PHP_MASTER/Zend/zend_opcode.c#136
 
@NikiC The "generator stack" just stores the instructions plus some kind of instruction pointer?
 
and then the cycles was broken up before object storage freeing @NikiC
@LeviMorrison it stores the local temps, cvs and vars and execute_data
 
@ircmaxell what's her name? :D
 
@ircmaxell I thought you were just ditching internals ...
 
@Leigh haha
@NikiC will that work well, when due to SEND_UNPACK zend_vm_extend() is called on the generator stack frame?
 
4:41 PM
Mornings
 
@bwoebi But is it called on the generator frame?
After all it's also delayed
 
moin @Ronni
 
@NikiC eih, the SEND opcodes aren't delayed? only fetch is happening first?
 
@bwoebi the sends are delayed until after the init
 
Hey, guys, have you ever discussed the idea of "::method" suffix similar to "::class"? Can be useful for "find usages" when inside callables like [SomeClass::class, "someMethod"].
 
4:46 PM
@NikiC yes
hence it should be called on generator frame
and it will try to reallocate on the main stack
I'm pretty sure send_unpack will result in out of bounds writes with that patch
 
@ksimka It has been discussed......it's hard to see a fantastic syntax. btw PHPStorm already understands that at least partially....some of the time.
 
@Danack Is there a post(s) somewhere on the web?
 
not that I'm aware of.
 
@JoeWatkins that was the original intent. But after stepping back for a while, I'm seeing less and less that I like tieing me here.
@Leigh perhaps you'll meet her someday ;)
 
@ircmaxell serious, you got yourself a people ?
 
4:56 PM
serious
 
oh
 
I'm so happy for you, so happy ...
fuck php, it's shit anyway ... have fun :D
 
lol
:)
 
well then … that's really nice ;-D
 
its complicated
 
4:56 PM
what OS is she running?
 
compared to that PHP is really shit definitely :-D
 
but it's good
 
(but jokes aside, happy for you too :))
 
thanks man
@Leigh OSX. I'll change that at some point
 
I was actually implying she was some sort of robot :p
 
4:59 PM
hey I have two parts to a script, one is entering data in to a db and the other is echoing is out, it all works, but just one small issue. it only echoes the table after the submit button has been click, can anyone see why? here's the code :) pastebin.com/Rn7LBShF
 
@Leigh I know :-P
 
Hi guys, is it possible in PHP to get where a usb drive is mounted by its volume label (in windows the drive letter and in linux the mount point)
 
a robot would be simpler ... it is never simple ... but definitely the best thing you can do with a life is share it ... best of luck @ircmaxell
 
But after all the shit you have/had to wade through on a daily basis, a little love is well deserved :)
 
@JoeWatkins the problem I face is about 5000km :-P
 
5:02 PM
I thought you were getting an m3 ?
you'll end up in the same place if it's meant to be ...
 
I'll ask on SO. thanks
 
posted on February 10, 2016 by nlecointre

/* by vin */

 
I live on a tiny island, next to a tiny island ... that's an unimaginable distance to me actually ...
 
5000km centered on NY does overlap with Scotland, not to start any rumours ;)
 
that's a pretty big problem, but not insurmountable ... we're not trees ...
 
5:08 PM
Hi .. i posted my question here on SO stackoverflow.com/questions/35314519/…
 
@JoeWatkins I am, picking it up next week
@JoeWatkins that's what we're working on ;-)
@Leigh not Scotland
 
@ircmaxell excellent, you'll have it solved in no time :)
 
@JoeWatkins "solved" is hard
working on it, yes :-)
but yeah, I'm happy
 
hi @ircmaxell how are you ? you know i am fan of yours on PHP community ..
 
cool, thanks
 
5:13 PM
@ircmaxell can i ask some issue ?
 
@ircmaxell w00t
 
@ircmaxell until all eternity I hope? =)
 
@JoeWatkins hi
 
@bwoebi we all hope for that. Only time will tell.
 
@PuzzledBoy please don't ping random people, you asked your question, if someone wants to answer it they will ;)
 
5:16 PM
@JoeWatkins i want to disucss my problem here between you all gentle man
 
@ircmaxell a more realistic specification for relationship is probably one lifetime ... easier to achieve, I think :D
 
lol :-P
 
Congrats @ircmaxell :-) nothing better than sharing your successes with a partner
Semi-related: $300 out of $450 worth of dildos received.
 
6:09 PM
@NikiC and statically bound variables too, if it's from a closure, please.
@NikiC wouldn't it be enough to generate symtable and return it in get_gc?
or am I missing something here?
 
@bwoebi symtable wouldn't cover static vars for example. we'd allocate a gc vector and populate it with the value/key/retval/values/cvs/this/closure/...
that would make it semi-accurate
then you could also cover live ranges and call stack
 
@NorthbornDesign I'd say PHP needs more of those, but I fear that they'd only be used by Internals members to choke each other
 
though call stack may be going away soon :D
 
@NikiC oh, live ranges … ugh.
 
hmmf ...
Unless you are using new PHP 7 features, type system improvements for example, you have not upgraded to PHP 7, you are *compatible* with it.
@krakjoe that is bullshit and completely erases the work done by core developers on anything other than new features. Eg performance @__debo
 
6:22 PM
I'm going to have to agree with them.
Just because my brand-new PHP code doesn't use closures doesn't mean I haven't yet upgraded to PHP 5.3.
I understand and agree with the general point you're trying to make, though.
 
there is a difference between a project that upgraded to php 7 and one that is compatible ...
<?php
/*
* This is from a project that "upgraded" to PHP 7 ... but doesn't use any PHP 7 features ...
*/
class A {

	/**
	* @param string
	* @return int
	**/
	public function method($string) {
		return strlen($string);
	}
}

/*
* This is me attempting to use PHP 7 features with the project that "upgraded" to PHP 7
*/
class B extends A {
	public function method(string $string) : int {
		return strlen($string);
	}
}

$b = new B;
$b->method("oh ... they don't actually integrate like that ...");
?>
when you have really upgraded, you are using PHP 7 only features, and people that are using your code can do the same ...
 
IMO if the project works with a version, the project is compatible with that version; projects don't really "upgrade", environments do.
 
yeah the word is require really ...
 
They "change compatibility requirements"
Yes, that is the key word.
</semantics>
 
6:40 PM
hey, i'm trying to echo out from a db, i'm trying to echo out in information boxes, i've tried a foreach loop, but doesn't seem to work. here's the script, it's very short. pastebin.com/b9T4baGw
 
@bwoebi yep, that's totally the right reaction :)
 
@NikiC heheheheh :-D
looks like serious fun then
you're going to do it though?
 
6:56 PM
What the actual fuck
 
I am kinda proud of this answer: stackoverflow.com/a/35305774/736162
 
I can understand if your bleeding edge WebGL demo only works in one browser, but this...
 
@NikiC ah, they used .innerText, which Firefox doesn't support
they should have used .textContent
@NikiC I often see sites that only work in Chrome or WebKit these days, it sucks
 
@bwoebi am I? :P
 
@NikiC I hope, because I'm not sure how to do that as I only can return one HashTable in get_gc handler?! … Well, I'm not sure, but I would have to copy the whole array into the gc array? :-/
 
7:05 PM
@bwoebi in that case you don't use the ht, you use the zval array. you'll have to allocate it and store it in the generator object and copy all zvals in there
 
@NikiC so yea, I'll have to copy all the zvals … isn't that going to be inefficient?
 
@bwoebi sure, but there's no way around it
you'll also be doing that three times or so per gc
and keep around an allocation for the whole life of the object
but that's the only way we currently have
 
7:24 PM
@NikiC uhm… change the signature of get_gc to allow multiple hashtables to be returned? :-D
(in 7.1 obviously)
 
anyone?
 
@AboutLeros "doesn't seem to work" is so vague as to be useless for troubleshooting. Make sure you have error reporting turned all the way up and that there's actually a valid array being passed to the foreach.
 
7:47 PM
@JoeWatkins I agree
 
8:14 PM
@ircmaxell @JoeWatkins I'm not sure 'upgraded' has a clearly defined meaning here
 
@Charles hence why I posted the code and i'm not getting an errors. that's why i asked, not much to go on. :)
 
0
Q: name a directory with a form input

parseguyhello I have a website where you can create a chat page(stored in the folder xe5) you type the name of the chat into an input field, and I want the name typed into the input field to be the name of the folder. In simple terms, input content=folder name. how would I go about changing the '$dst' to...

 
8:42 PM
@NikiC but actually current get_gc should be good enough for Amp as you'll always have your Generators either referenced or terminated, there should be no unreferenced unterminated Generators (in Amp context, normal Generators still may be…)…
 
@ScottArciszewski do you by chance know of any wrapper for generating private/public ssh keys in PHP?
 
@Ocramius openssl_pkey_new() looks capable, doesn't it?
 
8:59 PM
@m6w6 indeed, was trying to do via CLI, but the extension has it, thx :-)
sufficient
 
@Ocramius openssl CLI? openssl genrsa -aes128 4096
 
@Ocramius Why does it show var_dump as an error?
 
@NikiC "forgotten debug statement"
 
> die(var_dump(
 
@m6w6 yeah, but wrapping around the CLI is much more work :-D
 
9:01 PM
@Ocramius Oh. That's even sensible.
 
but yeah, now wrapping this stuff in VOs and saving these keys in my DB :-P
 
@Ocramius Ah, of course, so you wanted a PHP version, okay
 
@Ocramius Outside of phpseclib? No
Oh, heh, OpenSSL's compatible? neat :)
 
9:44 PM
uhmmmmm
wtf?
 
as opposed to what? That's not valid base64, I don't think.
 
yeah, API states "returns false" on invalid input
well, on failure... ok, now gotta figure out what "failure" means :P
base64_encode(base64_decode($base64Key)) !== $base64Key does the trick for now. Sucks tho
 
better idea: $out = base64_decode($in); return (($out != '' || $in == '') ? $out : false);
 
@Ocramius base64_decode("...", /* $strict = */ true);
 
If you get anything but '', you can return that. If you get '', you can return that also if $in == ''.
or use the strict parameter :)
 
10:00 PM
@jbafford it seems to decode garbage if you throw in garbage
doesn't decode to empty string
 
yay
bought a old used lenovo
welcome back linux.. goodbye surface pro 3 and wondowz
 
10:18 PM
@Ocramius ah, well, the good 'ol GIGO.
 
11:13 PM
thumbs up, or down for building a github login script that you only need to copy/paste the oauth logins for facebook, since they have composers, and stuff, but i don't know how to use that stuff?
 
11:52 PM
Finally automated this damn bastard:
had to ditch openssl and go directly through CLI -.-
 

« first day (1943 days earlier)      last day (3004 days later) »