« first day (978 days earlier)      last day (4196 days later) » 

14:00
ZEnd or Symfony ?? which one is better... security reasons please
@MoeedFarooqui you don't need any framework.
@MoeedFarooqui Security reasons? Security is 99% you, 1% framework.
2
@MoeedFarooqui I like Zend because it doesn't enforce its paradigm too strictly, some may see that as a bad thing
@MoeedFarooqui both have a quite strict handling of security issues, so the question makes no sense
14:01
Also ZF2 and ZF1 are totally different animals
I mean which one is more secure? zend or symfony
@MoeedFarooqui whatever you don't screw up :P
Hey guys
@MoeedFarooqui neither. your code is going to be the weak point anywhere
seriously, they are both secure. It's the developer using them that usually builds security holes on top of them
s/secure/assumed as "secure"
14:02
@Ocramius this is not a dating and chatting portal noob..go try some social sites this is Stack!! :D
@MoeedFarooqui is this supposed to be funny?
@MoeedFarooqui WAT
@MoeedFarooqui They're both secure.
I know this might be a noob question but hey, I wrote a program that monitors disk usage and other shell commands. this program needs to be put on several servers, im wondering how i can view the data in my web browser?
@MoeedFarooqui If you expect a framework to 'do security for you', please give me your URLs so I can never use them.
14:04
@SnakeEater data is a general word, what do you want to display ?
@HamZa oh sorry :P I want to view the php webpage
@SnakeEater doesn't make sense to me ...
Have you ever coded in PHP ?
This is my first app :P
@SnakeEater Right now you see data in your shell?
<?php
$uptime = shell_exec('uptime');
$swap = shell_exec('free -m');
$diskspace = shell_exec('df -h');
$who = shell_exec('who');
$postgresql = shell_exec('ps ax | grep postgresql');
$squid = shell_exec('ps ax | grep squid');
$httpd = shell_exec('ps ax | grep httpd');
$dhcpd = shell_exec('ps ax | grep dhcpd');
$named = shell_exec('ps ax | grep named');
$url=$_SERVER['REQUEST_URI'];
header("Refresh: 1; URL=$url");

echo "<h3>Uptime</h3><pre>$uptime</pre>";
echo "<h3>Free memory</h3><pre>$swap</pre>";
this is what it looks like
now im going to put this code on 3 remote servers, but im wondering how i can view it from the server into my browser?
14:07
</h5>?! => echo "<h4>Postgresql </h5><pre>$postgresql</pre>";
Hey all, I'm a little new to php classes and am looking for some help with extending the Exception class.

I want to be able to pass the error message as either a string, array, or object. Since the standard Exception class doesn't allow for this, I thought I'd extend the class to my own Exception handler, but I'm not sure what needs to happen within my class to make this work...
I need 26 more upvotes!!!
2
82
A: Is micro-optimization worth the time?

ircmaxellWell, for a trivially small array, $array === (array) $array is significantly faster than is_array($array). On the order of over 7 times faster. But each call is only on the order of 1.0 x 10 ^ -6 seconds (0.000001 seconds). So unless you're calling it literally thousands of times, it's not go...

@bwoebi haha oops ^^
@ircmaxell done
lol, not 26 :-D
14:09
@ircmaxell link more
@ircmaxell you want to reach 100 ?
@vascowhite Sadly enough, there is no RTFM close reason :(
@HamZa I know, such a sad state of affairs!
@ircmaxell Why? You have more votes than John Skeet! That's an achievement in itself! Awesome answer btw.
I want to get a populist against John Skeet
14:16
heh
@ircmaxell Good goal. +1 from me then :)
ooooh, feeds actually posted something interesting :D
What do you guys suggest to learn: C or C++ ?
I've 0 experience in OOP
@tereško In Latvija, do you have other keyboards than Qwerty ?
Learn C first - can't really learn C++ without it. But compile in a C++ environment to avoid the slight differences that were changed from the C envrionment.
14:22
@Danack Ok, makes sense. Can you suggest me a book as a beginner ?
I'd learn C++ straight off
Otherwise you'll get into some bad habits :P
@HamZa I can't recommend any C book (as I haven't used any) - but would assume the Head First book would be decent shop.oreilly.com/product/0636920015482.do
@LightningDust eh, no problem. I also learned PHP using $var = @$_GET['var']; :p
If I use prepared statements, Should I still sanitize the user inputs?
@HamZa cppstdlib.com Best book I've used
It's more a reference than hand holding
Kishor - Yes, sanitize and validate, otherwise your db will be full of worthless junk
14:24
Ok thx
Ping @NikiC : C book you recommend ?
@ircmaxell thought you have a blog post that answers that blog.ircmaxell.com/2011/08/on-optimization-in-php.html
86
A: Are PDO prepared statements sufficient to prevent SQL injection?

ircmaxellThe short answer is NO, PDO prepares will not defend you from all possible SQL-Injection attacks. for certain obscure edge-cases I'm adapting this answer to talk about PDO... The long answer isn't so easy. It's based off an attack demonstrated here. The Attack So, let's start off by showing t...

"PDO by default does NOT do true prepared statements." wat
-1
Q: PHP - can we write files.txt via PHP in temporary internet files on the client side?

TochI was asking that. What do you think ? I think it is illogic and so impossible. isn't it ?

^ WAT
@HamZa Wow, people say crazy stuff
@dragon112 yeah, I might get crazy as well
14:34
@HamZa I'd like a ham sandwich please.
"Van de hak op de tak"
lolz
According to Gtranslate "Van de hak op de tak" == "The ramble on"
Wow, never have I seen that much fail
cant be helped
Yes it can, by google
@Danack It does emulated prepares, correct?
You can turn PDO::ATTR_EMULATE_PREPARES on / off
14:41
Apparently so. But still quite surprising - and bet it catches a lot of people out.
@Kishor Filter-In, Escape-Out
:10115278 nope. Technically there is a latvian layout, but nobody uses it. Everyone stick with QWERTY, with 3 different ways to access additional chars (ēŗūīāšģļžčņ) , either using [tag:right-alt], ~ or '
Secure input and output handling are secure programming techniques designed to prevent security bugs and the exploitation thereof. Input handling Input handling is how an application, server or other computing system handles the input supplied from users, clients, or a computer network. Secure input handling is often required to prevent vulnerabilities related to Code injection, Directory traversal and so on. Input validation Validating (or sanitizing) user input is to ensure that input is safe prior to use. The most secure way to do this is to Terminate on suspicious input and use ...
@HamZa , damn, writing ķ caused the chat to trigger fixed font ... anyway, the answer is above
14:58
I'm off, g'bye all
Is this a Mysql Issue or PHP issue?

[2002] An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full. (trying to connect via tcp://server-win-apache1:3306)
Anonymous
@dragon112 Better say "later", or "I'm out" than "Good bye" every time you have leave the room :)
Anonymous
On a side note: JAVA you SUCK!!!
@phpNoOBఠ_ఠ You're doing JAVA? Get out.
Anonymous
@Jimbo Blame C++ for giving me hard time, and making me switch to Java
15:12
@phpNoOBఠ_ఠ Haha, I was thinking of a C++ quip x)
1
Q: Cannot flush data into child Table using doctrine

noobie-phpFollowing is my Code snippet, what i am trying to do is insert ID of Parent Table to child table along with inserting Data to the Child table at same time. Following is my code Snippet public function addAction() { $ViewModel = new ViewModel(); $form = new TestForm(); $form->get('su...

@ircmaxell Both you and I are, on different questions of course, in need of only 10 more upvotes :D
Lego movie ftw
Isset has been around since PHP 4, somebody would have noticed by now if it didn't work. it's probably your code that doesn't work. — vascowhite 38 secs ago
@ircmaxell Hmm these functions are based off a very highly rated tutorial that I read a couple of years back. I have seen many methods extremely similar to this all over the web, including on that website that reverse hashes md5? Can't remember the name — Adi Bradfield 10 mins ago
@Jimbo :-D
why flagged?
Anonymous
15:15
lol. "A couple of years" So many things change everyday everymonth
@HamZa dunno
Also, you're not storing the user's password in a cookie, are you? Because that would be just about the worst handling of a user's personal data I've ever seen. And I've seen some absolute horrors... — ircmaxell 8 secs ago
Anonymous
@HamZa
Anonymous
2831
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are released every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...

@ircmaxell groan That is truly awful
15:27
@NikiC that's actually a really really nice feature for me (talking about my PR)
@Ocramius I already told you not to use it back then ^^
@NikiC I can always fallback to reflection to do this stuff, but when you deal with hydrating 20K records this thing makes a difference
I asked julien to eventually provide a bulk populate and extract api if this gets ever removed
I'm actually ok with (array) cast being wrong, but if not that, then a function would work too
set_stuff($obj, $data) and get_stuff($obj)
@Ocramius what is your use case?
doctrine ORM
filling POPO with data
and comparing POPO byval
(and obviously extracting data for DB insertion)
yeah, ofc it's for an ORM, what else would require such a terrible rape of basic OO principles?
user895378
15:32
lol
user895378
good (rape-themed) morning
@NikiC if you don't get the use case, I'm fine :) But don't come and tell me it's an OO rape. That's what a data mapper does.
at least with POPO
php-src is trending on git ...
@Ocramius you're telling me that accessing private and protected properties of an object is not an OO rape?
@Ocramius But in any case, I don't yet fully understand what you're doing with that array cast. How are you populating thigns with it?
@NikiC it's not OO, it's accessing internal object state, and I agree with that being strange (non OO) for people not used to this stuff
@NikiC: pseudo pseudo: $query->execute('... INTO ... VALUES (:foo, :bar)', normalize((array) $obj));
kinda like this
same for reads and comparison of changes
user895378
15:38
@Ocramius I don't fully understand what you're doing there, so maybe I'm wrong, but it doesn't seem like something that needs a test case. BC breaks are BC breaks ... it seems like a very odd (and hacky) reason to introduce a test in php-src ...
@rdlowrey I did it before, and since I want to use this thing (which works quite fine) I'm gonna protect it with a test, so if a BC occurs, it needs to be documented
and reported
I'm not saying "let's freeze it like this", I'm just protecting current behavior from accidental change
@Ocramius Is this hack currently in large-scale use?
user895378
Which is understandable ... but to me that is sort of testing implementation details and not the end result. Relying on private/protected property access (if I understand your goal correctly) that you probably shouldn't be able to access in the first place seems like a questionable testing practice to me.
@NikiC no, it's not widespread, but we're considering using this for ORM 2.5 if the PR goes through, or a similar API if any is provided
@rdlowrey Doctrine ORM is ALL about reflection and internal state - we actually test internal state of stuff because that's what we do as a project
and for now the logic looks like:
foreach ($someMetadata->initReflection()->getProperties() as $n => $p) {
   $data[$n] = $p->getValue($obj);
}
user895378
I get that ... and I get that it's infinitely faster than reflection for that case, but I'm not sold that it warrants a test in php-src. In your code base? Perhaps. I'd maintain two branches: one that uses the hacky method and one that uses reflection. IMO it's not behavior that should be de facto correct in the language (as inferred by the presence of a test). Again, just my two cents.
15:43
which is quite more expensive depending on the number of fields and on the number of public properties (since there's a bug in reflection that causes a mess)
@rdlowrey I just want a clear cut in docs if this gets changed. If a dev changes php-src he sees the test break and it gets to discussion
that's all I want
and the test is just a formalized way of getting to that
@Ocramius BC breaks are documented in any case ;)
then, in my code base, I can re-generate hydrators based on the PHP version where the change is introduced
@NikiC un-documented "feature", therefore probably un-documented break
this documents the feature
It's just a safe check. I can add comments to the source and explain WHY I did it if you want
I don't really have a problem with the test. Changing tests is easy enough
More with the fact that you are planning to use it
Which could make fixing the bug a good bit more complicated
@NikiC I can easily introduce switches in my code based on the PHP version
I just need a viable alternate solution to this
or eventually an API that allows me to do this bulk
@Ocramius what kind of API would this require?
user895378
Understandable. I don't really have a problem with it. It seems like one of those "this is an implementation detail and it should not be relied upon in production" sort of things. And by having a large project like Doctrine start relying upon it you make it much more difficult for future PHP versions to improve casts. It's creating a potential impediment to the language's progress down the road ... that's my only objection.
that's kind-of enough I guess
@Ocramius What does "hydrate" mean?
@rdlowrey we can adapt to that
@NikiC replace properties
so yes, clear OO violation (wanted)
hello everyone
user895378
15:49
Cool. I mean, I definitely see the appeal. That's a major performance improvement over reflection for your use case.
@NikiC it's an ORM term that some people invented because apparently "load" or "set properites" isn't hipster...
@Ocramius (array) handles the first method of those, right?
does anyone know best system based on parsing php code and building wiki ?
@ircmaxell it's not about loading... we already have the properties. And hydration is the real world example that most fits this ;)
and if you tell me I'm a hipster I'll find you and hunt you down :P
rofl
@NikiC yes, (array) $obj does exactly that right now
15:51
And there's rep-cap for today!
@Ocramius So a simple solution there is adding a boolean argument to get_object_vars
Guys ) Help please
@NikiC that may be a way, yes
@Ocramius How do you currently handle clashing properties?
@NikiC: there's no reason for the do/while here, right? lxr.php.net/xref/PHP_TRUNK/Zend/zend_gc.h#163
I'm refactoring that macro, so while I'm there I'm thinking of removing it...
15:52
@NikiC the ORM currently doesn't allow that, so I'd personally use something like FQCN#prop I guess
@ircmaxell why?
why what?
but yes, it should also be handled
@Ocramius Well, which one do you currently use when there are two?
@ircmaxell why would it not be necessary?
user895378
@Abyss Not sure what you're asking.
15:53
@NikiC the ORM currently throws exceptions on same prop names in subclasses, it's not that flexible (yet)
@Ocramius ah, I see
why is it necessary? you already have the if block there, so anywhere the do would be valid, the if by itself should be valid, no? hence it's not used to fake a block-level scoping (which is typically why the do/while(0) is used, no?)
but it's something planned for 3.x
@ircmaxell No, the do/while is not for scoping. It's for (safely) forcing a semicolon
ah, ok
that's fair
15:55
@ircmaxell has to do with usage of the macro inside a block-less if
sure. that makes sense now
user895378
Hey guys, as of 00:13 MDT this morning @LeviMorrison's a dad! I think congratulations are in order.
24
congratulations
:O @LeviMorrison grats!
Congrats @LeviMorrison!!!!!!!!!!!!
15:58
@LeviMorrison congrats to the proud dad !!!!!!!!!!
user895378
@webarto Ooooh, sparkles!
Boy or Girl!?
user895378
Boy.
in Dart Lang, 9 hours ago, by Levi Morrison
@rdlowrey Matthew was born at 12:13am on June 20th, weighing 7lbs 9oz.
16:02
Probably posted already but 5.5 is out today? github.com/php/php-src/blob/php-5.5.0/NEWS
2
I need to start hunting bounties... this is rep-cap two days in a row
@NikiC github.com/php/php-src/pull/358#issuecomment-19763118 - does it sum everything up or am I telling bs there? :)
@Danack not quite official yet. It's there, and builds are available, but the announcement hasn't been made yet ;-)
@ircmaxell why does it take time? last qa's?
user895378
> Return previous handler when passing NULL to set_error_handler and set_exception_handler
user895378
16:06
@NikiC ^ Thanks for this (among other things, of course)
user895378
I've wanted that in the past.
@Danack Line 86 is the best.
user895378
@webarto By far.
user895378
Actually, I'm partial to line 559
@webarto no. line 30.
16:08
@rdlowrey Oh! We badass.
user895378
Woah dang!
and line 23 is also very important … I already use it a lot, just my IDE still marks this as a parse error :-(
user895378
@bwoebi I like 30 a lot too.
IDE's should use the grammar of trunk :-/
0
Q: How do I get a float value when dividing two integers? (PHP)

user1869257Hi I am trying to divide two integers ex: 12/13 but I always get a whole integer 1 not a decimal number. I tried type casting the values to float before hand with no success. Basically all I want is a decimal result like: 0.923... $x = 12; $y = 13; echo $value = $x / $y; //Would like to see 0...

@LeviMorrison congratulations
16:13
@Baba is this a ?
@DaveChen nope .. just curios how that is possible
@Baba ini_set("precision", 0);
:] Thanks for the congratulations everyone.
@bwoebi that would return 0.9 on php 5.4
; The number of significant digits displayed in floating point numbers.
precision = 14
16:15
@bwoebi tested that
php.ini*
Guys
Hey
// with actual trunk (2 days ago)
php -dprecision=0 -r 'print 13/12;'
1
does anyone know best system based on parsing php code and building wiki ?
best -- I'm out :D
16:16
$x = 12;
$y = 13;

ini_set('precision', 0);
echo $value = $x / $y;
something like phpdoc
0.9 on my system .. windows
@Baba wtf, this returns 0.9 for me too
@bwoebi lol
16:17
@Abyss What's wrong with PHPDoc?
@bwoebi vodoo :)
@TimWolla not so sweet )
maybe ini_set is blocked for him? safemode or some weird setting?
@bwoebi a whole bunch of tasks need to happen, including generating builds, packaging, etc
@ircmaxell because this is lot faster for minor versions?
@Baba oh wait… 12/13 != 13/12
@Ocramius Seems good. We should discuss some time the exact APIs you'd like to have
@bwoebi that is what makes the case interesting to me
Gordon just submitted two talks to ZendCon EU
nice!
16:27
@Baba precision are the significant numbers
@bwoebi The question what PHP configuration would make him get 1 instead of 0.9x ?
no idea
@Gordon Good luck, I say.
m59
m59
@hakre @rdlowrey I got to thinking of another thing regarding REST. Would it be bad practice to get 2 resources in one call, and if that is feasible, what would the url look like?
@ircmaxell can't really judge if it's right as I don't know the reasoning behind it
16:34
well, I'm trying to lockout the GC from hitting an object that's partially destructed...
user895378
@m59 That sounds like a mistake to me. If there's a relationship between two resources (e.g. User and Address) then the resource located at /api/users/rdlowrey should supply the address as part of its payload when retrieved.
@LeviMorrison Congratulations!
so I'm setting the object's bucket to invalid in the delref handler when it goes to free the storage
@rdlowrey Agree
but the GC was still going too deep into the object...
Anonymous
16:37
@LeviMorrison Congrats
m59
m59
@rdlowrey I'm thinking of the difference between youtube and vimeo on this one. If I ask youtube for a playlist, I get an object with the playlist info as well as all of its videos and each video's info. With Vimeo, that is 2 separate requests.
@ircmaxell So basically this just moved valid=0 from after free_storage to before it?
@webarto thanks
@NikiC correct...
m59
m59
playlists/35

table playlists
row 35 = playlist info

table playlist35
rows 1-38 = videos/info

@rdlowrey that is the db setup, right?
user895378
16:42
@m59 It really depends on how you view your resources and what information you believe constitutes those resources. Neither of those approaches (youtube vs. vimeo) is more correct than the other. In that situation it's all about context.
because under certain cases the GC can be triggered within free_storage. And since we don't always have access to the zval to disable it (set to IS_NULL) prior to calling free_storage, this "hack" is the only way I can see of actually solving the problem...
@ircmaxell okay. that does not sound totally unreasonable at least ^^
user895378
@m59 If you have a lot of relationships between your data you have to draw the line somewhere. You probably don't want 100 levels of nested resources returned from /api/users/rdlowrey ... at that point the line between art and science blurs a bit IMO.
I'm definitely not happy with it, as it's not truly invalid, but...
I'd remove the line github.com/ircmaxell/php-src/blob/… now, it just duplicates the valid=0 assignment
16:44
Something a service at my university does wrong is that as part of the information about an individual they give a country code and name. That part is fine, but along with it they list ALL the country codes and names.
I don't want to, because I'm not sure if anyone else is using that macro...
m59
m59
lol yeah. I wouldn't want to get the playlist table, then get the playlist_videos table and the uploader's table and so forth. That could just get ridiculous. Is that what you mean? @rdlowrey
It's tangential information really and that is not okay.
the core search shows it's nobody, but it may be used in a PECL extension somewhere...
m59
m59
Like, overkill on related info?
16:45
@ircmaxell it's defined in a .c file ;)
Oh, so it is, I didn't even look at that. Done
@ircmaxell anyway, the patch looks reasonable (I didn't look at the exact replacements in zend_gc though)
yeah, was more thinking the concept
actually, why are we even doing that as a macro? we only call it in one place
user895378
@m59 Yes, that's what I mean. The resource should supply everything needed to fully describe that resource and nothing more. What you can do if you want is provide links to related resources in your primary resource payload ...
m59
m59
yeah that sounds cool.
16:48
@rdlowrey One could argue you should be doing that
:P
m59
m59
Thanks again =D
user895378
@cspray You're right. I agree that it's a SHOULD, but not necessarily a MUST.
@rdlowrey Agree
m59
m59
It's amazing how many - probably...weeks - you are saving me in trying to figure this out on my own. I've probably run google out of business reading everything I can and didn't get anywhere until you and hakre chipped in.
The php rest api tutorials I've found are just awful.
When I finish my cms, my first project with it is to get my blog up and put out a bunch of articles detailing everything I've learned in the process of this that doesn't seem to be well taught.
Unfortunately the best resources on REST are very technical papers. They are not very user friendly.
user895378
16:51
Happy to help. I think it all gets pretty simple once you have an understanding of REST and start organizing things using a resource-oriented URI architecture.
@LeviMorrison Congrats again my man! How's it feel to be a dad?
m59
m59
Well, the idea is simple enough, but the adaptation - not so much.
@ircmaxell Great. It's a really good feeling.
m59
m59
I've listened to many hours of conferences/seminars on REST and read lots of articles, etc and just couldn't see how to write the code.
The tutorials made it even worse because they go through about 50 methods that do nothing and are very unclear.
and at least half of them are still suggesting making an api via api?this=junk
Awesome! Now what are you doing online? You're excused from this internet thing for a while :-P
16:54
@ircmaxell It's quiet right now. My wife and baby are both sleeping.
So I figured I would get online for a bit since I'm still at the hospital and can't do much else.
@Baba something like this?/ stackoverflow.com/a/17219283/731947
and so should you be :-P
user895378
@m59 IMO the "resource oriented architecture" (ROA) in your URIs is the implementation side of things that's generally missing in the available literature. It's not technically required for or related to REST. You can be perfectly RESTful without a ROA, but I find that it provides a very straightforward outline for structuring your code.
user895378
A lot of my ideas come from shop.oreilly.com/product/9780596529260.do
user895378
It's not the greatest book and it's focused on Ruby, but I really like the ideas it presents regarding ROA.
m59
m59
16:56
pssshhh, books are for nubs.
j/k =D lol
I'll try to check it out.
user895378
It's best to skim it for concepts. The code implementation stuff it does is pretty worthless (and it's in Ruby).
@kaᵠ With precision = 0 am still getting 0.9
m59
m59
This api thing could be so huge in a lot of ways. I want to keep the server side language as separated from the cms as possible. This will get me pretty close.
I've pretty much created the anti-Joomla.
$hatemail = 'incoming';

« first day (978 days earlier)      last day (4196 days later) »