« first day (930 days earlier)      last day (4018 days later) » 

12:37 AM
hello
 
Where can I find bookmarks for this room?
I don't remember the date, but there was a post here about some codepad tricks :o
 
12:57 AM
@SethJeremiMalaki search field top right of chatroom or if you want actual bookmarks check here chat.stackoverflow.com/rooms/info/11/php?tab=conversations but the conversation would have to have been bookmarked
 
thanks @crypticツ
 
1:13 AM
@HapshoutDotCom heyooo
 
> Around the world
 
I have the following object. I need to get "language" but I do not know the name of the file as is it the property name of {'detect_locales.php'} which can differ. How can I get that needed value, if it's not possible how do I get the name of the file?

            [files] => stdClass Object
                (
                    [detect_locales.php] => stdClass Object
                        (
                            [filename] => detect_locales.php
                            [type] => application/httpd-php
 
Hey is there any way to log all queries that go through mysqli_ ?
No, mysql server-side logging won't be an option since it's on RDS
 
1:33 AM
@rdlowrey At the cost of bounty, I'm interested to see how a PHP solution would work for this question:
6
Q: Break HTTP file uploading from server side by PHP or Apache

AlixWhen uploading big file (>100M) to server, PHP always accept entire data POST from browser first. We cannot inject into the process of uploading. For example, check the value of "token" before entire data send to server is IMPOSSIBLE in my PHP code: <form enctype="multipart/form-data" action=...

(This is my suggestion using node.js stackoverflow.com/a/16349882/1348195 , I'm interested in seeing how PHP would handle this, I'm assuming that contrary to other answers it's possible and you seem like the guy for the job)
 
Bros (and ladies)! Hope everyone is doing alright in here
Got a situation I need help thinking through for anyone who would oblige.
I have a shopping cart esque experience being built. Customer searches through records from other groups and then makes competitive offers based off of the result set they see (actually, based off of selections from the result set).
Once they've selected the results they want to make offers on they proceed to make offers. This is a two part process.
The way I was doing it was through AJAX, so I'd hold on to part 1's variables until part 2 was done then send off all at once
Now I'm doing multi uploading in part 2 and due to a quick deadline went with the quickest solution I could think: non-ajax, just straight up form submission.
So now my problem is that I have this info from part 1 stored in JS, but part 2 being submitted through a normal form $_POST
 
Hello, is anyone here experienced with Google's APIs?
I'm in a bit of a tough situation
 
And now for the part that makes it sticky for me: part 2 creates a row in Table1 that is referenced in the corresponding rows in Table2.
So I need that row ID
 
@BenjaminGruenbaum why the hell did you write your own HTTP parser? node already ships with one...
 
@igorw Mainly? To illustrate a point of how it works in the protocol level
Also, I need to catch the request on the TCP level and not as a HTTP request
I don't want to even start processing the body, I'm aware of the http module and everything built on top of it like connect and express
 
1:49 AM
the http stuff in node lets you do that just fine. you basically re-implement it in an incomplete manner. what about chunked transfer encoding? what about keep-alive? you're not handling those at all.
 
@igorw I'm not handling any of those, He wanted to check a header and abort the request
Hmmm, I guess adding a solution using http could be interesting
 
My favorite part was when they said "Around the world!"
 
2:08 AM
@BenjaminGruenbaum real solution
 
@igorw IIRC most browsers don't support 100 continue headers, I'm not sure if this is still correct in 2013
 
@BenjaminGruenbaum yes, they support it
 
I did not test that, but you can easily move the check into the request handler.
 
@igorw wouldn't it be simpler to adding the check to the callback of createServer and if the headers pass validation pump the data?
 
that's exactly what I just said. but with the 100-continue you can prevent the client from even sending any data. so as long as your target clients support 100-continue, that's the better solution.
 
2:17 AM
Do you have any reference indicating 100 continue browser support? I worked for a company that used it a few years ago and we got a lot of clients complaining so we switched back
 
1
Q: Which browsers send "Expect: 100-Continue" request header?

user960567I just want to make sure which browsers send the Expect: 100-Continue header? So that until the server responds with a 100 Continue HTTP status, no data should be sent.

(closed as not a real question)
 
Also doesn't look too optimistic
 
can't find any resources on it
 
Also, on rep.end();, will node.js stop reading the request?
 
yes, because request and response use the same underlying tcp connection
 
2:21 AM
can i ask about SQL queries here?
 
@igorw one can call req.destroy() , but that's not in the official API so I'm hesitant to use it
OutgoingMessage seems to have a destroy method as well
 
@BenjaminGruenbaum don't, it will not close the TCP connection cleanly afaik.
 
I'm not sure he wants to close the connection cleanly
It just calls this.socket.destroy
 
if you're not sure, you want to close it cleanly.
 
http://stackoverflow.com/questions/16350540/
I am correct with my answer, those are his options?
 
2:27 AM
@igorw may I add your solution in addition to another one using HTTP (with full attribution of course)
 
@BenjaminGruenbaum sure, I only invested so much because I was angry that such a hackish and unmaintainable solution got upvotes and bounty ;-)
but actually, let me fix it first
 
@igorw The point wasn't for OP to use it in production
 
if a checkContinue listener is present, the request event doesn't fire
 
The point was for OP to understand how the underlying protocol works
 
can you fix it to use new http.Server() instead of createServer? since no request handler is needed
0
Q: Which browsers send the expect: 100-continue header?

igorwThe HTTP spec allows for clients to send an Expect: 100-continue header for large request payloads. This will pause the request after the headers have been sent and allow the server to reject it based on those headers. If those headers did not indicate a bad request (e.g. a too large Content-Len...

^ :)
 
2:34 AM
You got an upvote for that :)
You're probably not going to hear the answer you hope for though
 
well hey, it's my 6th question ever on SO
 
I need some help with codeigniter form validation
 
@igorw Come to think of it, you don't really need the browser 'to support' 100 continue, you just need to add that header on the client-side, you can add headers in AJAX requests and the server should act accordingly.
I mean, the server would just keep reading the data and respond with 100 continue or terminate with whatever
 
sure you can do uploads in AJAX manually, but why?
what is it with you and re-implementing HTTP?
 
How would you get the browser to send Expect: 100-Continue ?
 
2:47 AM
my point is: the browser should send the expect header already. I'm too lazy to check if it does.
if it doesn't, I'd rather just check the headers in the request handler and reject early than re-implement client-side HTTP uploads in javascript.
 
I added that sort of solution to the answer, again, the point was not creating production code for OP but illustrating how HTTP requests work
What criteria would you expect browsers to use in order to send Expect: headers? I mean, you wouldn't expect any POST request to do that, right?
 
in theory it could, in practice I'd expect a certain content-length threshold
 
Browsers waiting for a round trip just for that specific use case seems pretty silly...
 
curl works that way
 
user895378
@BenjaminGruenbaum Actually, with standard PHP SAPIs you don't have any access to the request until the full body of the POST is received. This means that you also cannot utilize the HTTP/1.1 Expect: 100-continue header and respond with a 417 Expectation Failed. You have no choice but to accept the full request without verification before the entity body arrives. IMHO this is a major flaw. It's a big part of why I threw up my hands and started writing my own server.
 
2:59 AM
curl doesn't have the same use case as most most web-browsers. At least from my humble experience, using 100 Continue on code that makes HTTP requests to your service from one another is a lot more common than usage on websites.
 
@rdlowrey agree.
@BenjaminGruenbaum we're talking about large request payloads. I think it's quite reasonable.
 
user895378
PHP's treatment of HTTP is ... sadly ... not as robust as it ought to be.
 
@rdlowrey I believe this may also be a limitation of most FCGI implementations. in theory, the authorizer role could be used to address that.
 
@rdlowrey I agree, this does seem like somewhat of a flaw. I figured solutions existed on the language level, without using the SAPIs. I guess that's sort of what you're making though :)
 
actually, while FCGI does not support 100-continue (afaik), aborting early is most certainly possible. so it's not really an issue.
 
3:03 AM
@igorw Oh, I completely agree. It might also be perfectly reasonable for browsers to do this for large requests or at least attempt to. I just recall having problems with that ourselves a few years ago
 
Does anybody know why having my htaccess redirecting all my traffic to index.php, which includes my projects path SomeProject/index.php would cause double records when I use execute PDO from SomeProject/index.php.
 
user895378
What I do is I have a generic onHeaders event that broadcasts the parsed message results (excluding the body, of course) before the entity is received. If I want to handle something like that I just register a callback for the URI in question to evaluate the headers and assign a response if needed.
 
user895378
I used to optionally invoke the full-blown application at that stage but it seemed like unnecessary complexity when I could easily register an event callback to handle the few cases where I needed pre-body request processing.
 
@igorw A HTTP1/1 compliant daemon must support this.
FCGI is not a HTTP1/1 compiant daemon AFAIK.
 
user895378
In case anyone cares, this is what that looks like right now in my code:
 
user895378
3:10 AM
    function onHeaders($requestId) {
        $asgiEnv = $this->httpServer->getRequest($requestId);
        if (!isset($asgiEnv['HTTP_EXPECT'])) {
            return;
        }
        if (strcasecmp($asgiEnv['HTTP_EXPECT'], '100-continue')) {
            return;
        }
        if ($asgiEnv['CONTENT_LENGTH'] > 42) {
            $asgiResponse = [417, 'Expectation Failed', $headers = [], $body = ''];
            $this->httpServer->setResponse($requestId, $asgiResponse);
        }
    }
 
@rdlowrey I read what you wrote, it makes good sense :) I''m trying to figure out how node.js implements this, that is, when the 'request' event is invoked
 
well, I'm off
g'night
 
user895378
@BenjaminGruenbaum I believe the http object has an .expect() event, no?
 
user895378
@igorw later
 
@igorw night
 
3:12 AM
gn @igorw
 
it was nice HTTP-ing (that sounds wrong) with you fine gentlemen
 
@rdlowrey The http server has an 'checkContinue' event
 
user895378
@BenjaminGruenbaum I'm not sure exactly the mechanism because I haven't ever used it but I know node.js provides the ability to handle that situation.
 
user895378
(removed) in the name of good taste.
 
Yay for reading C++ code because of how node internals were migrated to C++ for speed :((
 
user895378
^ there's an event hook for checking the expect header. I'm not sure if there's a mechanism for manually aborting though if there's no Expect header and you want to stop an upload before it occurs.
 
@rdlowrey At the bottom of stackoverflow.com/questions/16167935/… you can see @igorw 's solution in node.js using 100-continue
 
@rdlowrey the client waits for a response status of 100 Continue. So if you give back a 400 Whatever, you abort.
 
user895378
@hakre I understand that, I'm thinking of the situation where I use my own naughty user-agent and don't send you Expect: 100-continue. How do you stop a malicious request like that?
 
3:19 AM
@rdlowrey close the connection.
 
There is an explicit check for 100 continue in the function that is invoked after it in the server module github.com/joyent/node/blob/master/lib/…
 
user895378
@hakre lol yeah I understand that, that's what I do in my server. But good luck doing that in PHP behind apache or nginx.
 
@rdlowrey okay, well, you can easily ddos PHP here if you don't limit the post data.
 
user895378
Yeah, which is what those ini directives are for. The underlying problem is that you can't examine request headers with standard PHP until after the request is fully received.
 
user895378
But what if you're okay with a 100MiB file but I upload 100.1MiB? Then you're forced to accept the whole thing first. It's just a poor HTTP implementation.
 
3:23 AM
@rdlowrey Right, so in node.js the http server module defines a onIncoming method for the parser a parser. onIncoming is a function defined by the server to do the 100 continue checks/etc . The parser issues onIncoming after headers have been read on a new message.
 
@rdlowrey exactly. I also wonder about this more and more often because actually PHP as webscripting language should do better here IMHO.
 
So in nodejs the default handle, and the one for request is after the headers have been read, but not the entire request
 
I can understand for the early days, but this is worth an overhaul.
probably a bit complicated to bring all SAPIs under one umbrella
 
user895378
@hakre Yeah, that may be the bigger problem.
 
anyway it's far too late for me and I did all my commits. so gn8.
 
user895378
3:24 AM
@hakre later
 
@rdlowrey I'm not 100% booked on that but as things grew over the years, there can be some nifty details :)
but the sapi/moduel/engine is pretty modular AFAIK.
 
user895378
I'm not familiar with where it hooks into the servers. I would expect it to be relatively straightforward as long as the web servers could provide access to the headers before processing the body.
 
user895378
@BenjaminGruenbaum I see. So that's more or less equivalent to what I've been doing with my onHeaders event.
 
:9201913 If you're interested in comparing more code you can check this: github.com/joyent/node/blob/master/lib/_http_common.js#L62 , it's the implementation of parserOnHeadersComplete which is the parser event (which invokes the callback placed by the server)
Although that seems a bit backwards to me, then again the nodejs source code needs a lot of other re-factoring first.
The server alters a callback on the parser, which the parser invokes in an onHeadersComplete event, which is (probably) invoked from C++
 
user895378
<--- jealous of how much faster js is than php
3
 
user895378
3:31 AM
I'll eventually have to get my hands dirty and move a lot into an extension written in C to get the performance I'm looking for.
 
JS is insanely fast and is about to get much faster with recent stuff. That's not a fair comparison though, nodejs's HTTP server isn't written in JS, it's written in C using libevent
 
user895378
Well I'm using PHP's libevent extension too, but I still have to do the parsing in PHP userland ...
 
user895378
It would be crazy fast if I merged the HTTP parsing + socket IO into a single extension using the C libevent API directly but that would be .... more work than I'm capable of given my current remedial C skills.
 
user895378
Some combo of github.com/joyent/http-parser and the libevent C API might not be too terrible to do, though.
 
I don't know if this is practical or doable in a considerable amount of time, but couldn't you just use C++ code from nodejs and bind it to PHP instead of JavaScript?
Yeah
I mean, that way you could get bug fixes from node.js without having to get your hands dirty with low-level code and handle the binding to php. You could add everything you miss in node.js or JavaScript to it
I mean, their server already has hooks for all the interesting stuff, and it's fast
 
user895378
3:38 AM
Yeah, in all likelihood I'll end up doing something like that. I am a chronic wheel-reinventor, though.
 
I still don't get the problem with using node.js itself, but implementing this sort of library sounds like a lot of fun regardless.
 
user895378
I kind of wanted to see what PHP was capable of first. I had to eliminate any semblance of the socket IO abstractions that node makes so pleasant and deal directly with the PHP socket streams :/
 
I think the main advantage of PHP at this point is that there is a lot of good libraries in PHP node developers would die for
 
user895378
@BenjaminGruenbaum I don't have a problem with node.js ... implementing this myself has been fun, but I definitely have a whole new respect for what node.js has been able to do.
 
user895378
And I just would rather write in PHP. But node.js is a great thing.
 
3:41 AM
Can PHP hook to node.js?
I know C++ does, you can write a function in C++ and execute it in node (like the HTTP module)
Recently, someone built this sort of hook for C# (which looks amazing)
 
user895378
I believe @igorw has been working on something like that github.com/bergie/dnode-php
 
I meant something simpler, something like:
 
Good morning Friends, Please can u help me how to create a Database if the server is Windows based Server.
 
//nodejs
var code = php("myPhpFile.php");
code.exec("functionName",[params]).then(function(returnValue){
    //get PHP method return value
}).error(function(e){
   //get exception thrown from PHP
});
That sort of binding would be a lot of fun, that's how good the C# binding is getting
 
user895378
Funny you say that, I've actually been writing something along those lines for PHP.
 
3:45 AM
Edge does it bi-directionally
 
user895378
I've been developing a language-agnostic asynchronous function dispatcher (runs on libevent) that delegates function calls to a pool of worker processes so I can make async calls from PHP. I've only written PHP and Python adapters so far (because that's all I need).
 
user895378
using it looks like ...
 
   public async Task<object> Invoke(IDictionary<string, object> input)
        {
            Func<object, Task<object>> add = (Func<object, Task<object>>)input["add"];
            var twoNumbers = new { a = 2, b = 3 };
            var addResult = (int)await add(twoNumbers);
            return addResult * 2;
        } // add method exported from nodejs
 
user895378
$dispatcher = new Dispatcher($reactor);
$dispatcher->start($poolSize = 4, '/usr/bin/php my_userland_funcs.php');
$dispatcher->call($onResultCallback, 'sleep', 5); // <-- asynchronously call `sleep(5);`
 
That looks clean :)
 
user895378
3:48 AM
And I just pass around a dispatcher instance to any part of my application that needs to call something that's IO bound.
 
I wish JavaScript had C# tasks and async, that's one of their major selling points, very strong co-routines.
var task = method1.ContinueWith(method2).ContinueWith(method3).Start();
//do stuff that doesn't require the value
var result = await task;
Tasks might be threads but they might be events either... Ah, C#, you're such a good language, if only you weren't Microsoft's :(
 
user895378
hehe
 
user895378
Allrighty, I'm off for the night. Glad to catch the tail end of your interesting conversation @igorw and @BenjaminGruenbaum
 
List of stuff I need in JavaScript to like it better
- Generators (`yield`, PHP has those if I recall correctly, allow co-routines)
- Value types (Not having infinite precision integer sucks, language should let me add that myself)
- Proxies (That is, wrapper objects that let me define how to handle undefined member call for example, can you do that in PHP?)

Then, I will be happy
@rdlowrey Night :)
 
user895378
php implements the magic class method __call($methodName, $args) to capture non-existent instance method invocations.
 
user895378
3:56 AM
Technically yield/generators don't arrive until whenever PHP5.5 is released (beta4 right now).
 
Close enough :)
 
 
2 hours later…
6:15 AM
Calling all PHP lovers to checkout this article me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design
 
1 message moved from HTML / CSS / DOM
 
Uby
That's pretty old and well known :P
@ircmaxell replied with this: http://blog.ircmaxell.com/2012/04/php-sucks-but-i-like-it.html
 
Heey, good morning everyone! :D
 
Hi guys I need a rails implementation of PHP curl
Any Idea?
 
6:28 AM
Do any of you smart gentlemen have the answer to this question?
0
Q: Protecting Root Directory from all but IP, allowing Subdirectory

jmalaisI've seen some other questions and answers here, but I'm not really getting things to work. I have two directories: ROOT/ and ROOT/SUB/. I also have two .htaccess files in those directories. My ROOT .htaccess has the following code: # Send them get access ErrorDocument 403 /SUB/index.php # BLOC...

 
@jmalais you just totally ruled out the ladies on this one ):
 
@Yasky Well they're just not usually gentle....
 
1
Q: Rails Use Net/Http like curl

Jakecurl -F 'access_token=...' \ -F 'message=Check out this funny article' \ https://graph.facebook.com/me/feed I've written this in curl with php before, but how would I do this in rails? Is there such thing as curl in rails?

 
Do you have to click the reply, you can't just type @name?
 
@name is a general mention. Clicking reply replies to a specific message. I like the order it somewhat enforces
 
6:34 AM
@Yasky Gotcha. Any other chat channels I should try to get this question answered in? Not quite sure where it is best asked.
 
@jmalais this would be ideal. I don't think Apache has a room. Unfortunately, I cannot help though. Stick around and someone who knows their way around config files may come along.
 
@Yasky Alright thanks
 
6:52 AM
Small question, you have basic directory setup online like, www / public_html / public_ftp / ...
The first question, in wich dir do you guys put your website?
 
7:04 AM
Hi all.
@Duikboot public_html
 
PLB
Morning.
 
hi
@Duikboot If you plan to put multiple sites or applications, open a directory for them. Specially when developing. You can route to application from public_html/index.php etc.. And make sure your script includes are relative
 
Okay, now the question I really want to ask : ) so the site is uploaded in public_html.
Where do you guys put your database connection?
Isn't it much safer to put that connection /config file somewhere behind the public_html?
 
hii all...
 
Oh... Database can be at another server. It is another story.
 
7:11 AM
anyone have idea how to develop virtual room for e commerce project ??
 
PLB
@Ihsan It depends on size of a project. For small to medium projects having database "farm" is overkill, imho.
@Duikboot It's a good idea to keep config outside of public_html
 
@Duikboot It depends on server configuration. But generally keeping it away from public_html is a good idea... It should be inaccessible from direct web requests.
@PLB I agree, I keep sending the previous message but the connection was lost... :D
 
How are database setups configured for big websites?
Like CNN or something?
 
Nowadays they are using farms in cloud formation.
 
Is this what they call DBaaS?
 
7:23 AM
What you see is logiaclly a single server. In fact the databases are
1 Distributed for speed and size limits,
2 Mirrored for failsafe.

btw my connection sucks...
DBaaS is not an infrastructure but a product bundle which is sold .
 
Do you know a service big websites use for online datase storage?
 
xeround (closing the shop now)
Amazon has 3 services.
contegix
cloudant
 
mornings
 
@Duikboot en.wikipedia.org/wiki/Cloud_database here is a list of the "big mama"s
@iroegbu Good morning
 
7:38 AM
Thanks for the mama's :)
 
lol
 
When do you decide using one? When is a project big enough?
 
Oh also heroku gives dbaas too.
@Duikboot directory of dbaas providers dbaas.wordpress.com/…
 
hey every one
 
@Duikboot There are multiple criteria for making this choice.
1) Can the data legally exist on web. (In health care biz for example, some countries ban that)
 
7:49 AM
facing problem in :-
Installing the optional soap extension is useful for web services and some contrib modules.
Intl extension is used to improve internationalization support, such as locale aware sorting.
i am using Moodle2.5beta+
 
2) Is the data maintainable in-house (even on the web) or would you prefer to hand this job to professionals which have dedicated infrastructure and time for that.
 
any one have any idea regarding this
 
3) Comparison of the performance/price of two choices in (2)
 
Allright thanks :)
 
4) The rate of migrating data on system. If too much, cloud may not be a good choice
 
7:53 AM
Do you think that is it the future? Everything cloud based?
 
@Duikboot Of course not. But this will dominate the future.
 
Allright thanks for the information Ihsan :)
 
Internet is not a mature entity yet. It's fragility mainly comes from security problems. So other systems will keep living too but cloud has many pluses.
 
morning
 
I see cloud most of the time as a perfect way for backing up files/data
 
7:57 AM
Nobody wants to install and maintain their applications to user's computer anymore. The thing is, make them use the application from web so no more installations, updates etc.
And instead of selling applications, renting them is a better choice both for users and firms.
@PeeHaa埽 morning. why do you hate fun?
 
@Ihsan Those kids were playing on my lawn
 
@Ihsan At the moment though, some things are just too difficult with the web. You can't write web applications with a heavy reliance on access to the user's file system. Well, you can, but it's seriously hard work. Desktop applications aren't dead yet.
also morning
 

« first day (930 days earlier)      last day (4018 days later) »