« first day (504 days earlier)      last day (4435 days later) » 
00:00 - 18:0018:00 - 00:00

12:06 AM
@NikiC should it be E_WARNING? Or E_NOTICE???
 
 
1 hour later…
1:23 AM
what is the best way to protect a class directory from direct access?
 
huh?
 
on a web server, you have a directory, classes, which contain only php class files. what is the best way to protect the directory from direct access?
 
put it above the web root
/lib
/public
 
what if your client pays for crappy shared hosting :D
@ircmaxell is this a pliable solution?
`if (strtolower($_SERVER['SCRIPT_URL']) == '/someclass.php')
{
header("HTTP/1.1 404 Not Found");
?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>Not Found</H1>
The requested URL /someclass.php was not found on this server.<P>
</BODY></HTML>
<?php
return;
}'
 
no
You could use htaccess to take anything prefixed by the classes and throw a 404
 
1:38 AM
okay, thanks
 
@tereško What is code-kata?
@CarrieKendall Some fake public .htaccess code, used it once to hide a .git subdir for such kind of hosting:
Options -Indexes

# fix trailing slash for .git / make it disappear + .gitignore and similar files.
RedirectMatch 404 ^/\.git(.*)$

# mask 403 on .ht* as 404
<Files ~ "^\.ht">
  Order Deny,Allow
  Allow from all
  Satisfy All
  Redirect 404 /
</Files>

RewriteEngine On
RewriteBase /

# map everything into public and set environment var
# to tag the request being valid
RewriteCond %{ENV:REDIRECT_sitealias} !set
RewriteRule ^(.*)$ /public/$1 [E=sitealias:set,L]
 
@hakre much appreciated
 
It has a public folder as well which should only be accessible.In this case it's a wordpress installation, so it needs it's own .htaccess again:
RewriteEngine On
# mask as 404 if directly accessed
RewriteCond %{ENV:REDIRECT_sitealias} !set
RewriteRule .* - [L,R=404]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
That's /public/.htaccess.
 
1:55 AM
make -j4 is awesome
 
@tereško Resolve the innermost parts first and expand them. Continue with expansion until all combinations have been expanded. Strip slashes and don't allow duplicates. codepad.viper-7.com/zCvGNp
 
thats wrong
and horribly suboptimal
 
Results not good?
 
first of all , why are you generating all of possible results ?
 
I read it so: "Implement a function spinParts($str) performing the transformation described below on the string supplied as an argument."
 
2:09 AM
> Characters enclosed in { and } should be treated as a set of |-delimited options, one of which should be chosen at random and used to replace the enclosure in the resulting string. Enclosures may be nested.
 
well, that's trivial to change and infact would reduce the stacksize.
because it will follow only one path
 
2:33 AM
is still think that it is a extremely ugly way yo do something like this
 
PHP's compiler uses zval's for the opcode data storage internally
why oh why?
 
3:02 AM
@tereško suggest something else, so probably you will enlighten me with your beautiful code ;)
 
3:34 AM
night guys
 
gn8
got to leave as well
 
 
4 hours later…
8:01 AM
Fatal error: Call to undefined method DOMNodeList::replaceChild()
 
 
2 hours later…
10:11 AM
Good morning
 
10:25 AM
Morning all.
 
Hi @Leigh
 
Someone is trying to tell me "Using ternary operators is bad practice". So I thought I'd come and ask the experts ;) Any opinions?
 
10:39 AM
Heh, some guy is being petty and going through all my questions and downvoting them. What a fag.
 
He will be suspected :)
 
I've only asked 4 questions, not really a problem for me :p
 
But can dv your answers
Not sure if answer dv affects rep.
 
It does
 
So much SO changes recently...
 
10:42 AM
It's always been that way, to stop people downvoting without a good reason. It's only -1 for the downvoter.
The guy who did it has 239 questions. I'll just note down his name and hit him next week. sigh politics suck :D
He says ternary operates are bad and downvotes me. I say his code doesn't actually work and downvote him. He goes all petty and downvotes questions.. and this is someone who is almost a moderator.
 
Flag him?
 
Can mods see who downvoted?
Otherwise there's no proof, and no point
 
hello friends
 
Hello @Rstar
 
Wow, I've only been awake less than an hour, and I made a new friend...
 
10:49 AM
i want to integrate my site with facebook
just for login
 
Ok. Good luck :)
 
how can i do it ?
 
and want to create slider for image like facebook
whenever i click on image a pop up open with large view of image
 
I love Saturdays
Just got up :)
 
10:52 AM
Hello @NikiC!
 
@ircmaxell Well, what level is the current array->string cast error?
Hey @Donut!
@ircmaxell E_NOTICE
For typehints that should then be promoted to an E_RECOVERABLE_ERROR or E_WARNING though, imho.
 
@NikiC: $var = (string)array(); doesn't have any error?
 
@Leigh As of 5.4 it has ;)
 
Ok, tested on 5.3.10... on my gaming machine so using a stock EasyPHP install, I guess I could supplant 5.4 in there
 
friends i have to create a pop up like facebook , whenever i click on image it should open with large view (Lightbox).
 
10:56 AM
@Rstar: thats nice, go and do it then.
 
@Rstar Ask in JavaScript room.
 
You can actually do it with pure CSS
 
Of course he can. But "jQuery is answer to everything"
 
11:18 AM
I created many functions in PHP and I want to add them to the "autocomplete" of Notepad++.

How can I do that?
 
11:37 AM
@ircmaxell I can't get your patch to apply cleanly.
Maybe that's because your patch is using whitespace indentation?
 
@user1123379 Does Notepad++ have autocompletion?
 
@Donut Yes
 
Then it should parse file and add functions to list automaticly :S
 
@Donut No, there is a hardcoded list somewhere
@user1123379 I'd recommend switching to an IDE that can properly detect your own functions. Personally I can recommend PhpStorm :)
 
@NikiC I like to use notepad++, there is option to add my functions to notepad++?
 
11:51 AM
I quite like Sublime Text 2 - I used PHP Storm, it was good, but I don't like having to pay for things :)
 
12:17 PM
Lost another 500 rep on #StackOverflow b/c moderator deleted a 3 year old question I answered. http://stackoverflow.com/questions/402050/
 
12:40 PM
@markustharkun seen it but i dont know why he is fussing about it so much. the question wasnt a question by SO standards, so there is nothing to complain about here.
and "another" is hardly correct given that the other question he complained about was a community wiki for which he didnt earn any reputation. i told him so but he didnt answer.
 
@Gordon I don't think that popular old questions should be deleted.
 
@NikiC i do. and first and foremost bobince's regex answer.
 
1:10 PM
@Gordon which?
 
urgh why isn't it closed yet (re. ) :(
 
@salathe done
 
thanks @NikiC et al.
 
I like the comments on stackoverflow.com/a/1735479/385378
 
can anyone help me with polling implementation
here's my code
$res = $database->news_poll($profileid,$actionid);
$k = 0;
while(!$NROW =$res->fetch_array())
{
usleep('50000000');
$res = $database->news_poll($profileid,$actionid);
}
actiontype_encode($NROW,'0',$json,$encode,$database);
$data['action'] = $action;
echo json_encode($data);
 
1:20 PM
@NikiC There is none...
@NikiC Odd, you're patching against trunk?
 
@ircmaxell There is one...
@ircmaxell yes
 
@NikiC Nope. Not for explicit casting. The only error an explicit cast can throw is if you try to cast an object to a string that doesn't implement __toString
 
@ircmaxell Yes, not explicit casting ^^ I mean an implicit cast
 
@NikiC Well, that's another story then... That's what I wanted to implement (the same casting that happens with internal functions)
 
@ircmaxell Seems like the explicit also errors: lxr.php.net/xref/PHP_TRUNK/Zend/zend.c#253
 
1:25 PM
Right, array to string
 
Which is good :)
@ircmaxell Which is what I wrote, isn't it? :P
 
yeah, but array to int doesn't error at all
 
@ircmaxell And that's something that might be changed ;)
I'd like that to be changed
(int) 'foobar' should throw a notice in my eyes
 
@NikiC I agree, but that level of BC break may be too much...
I figured out why you couldn't apply the patch
because SVN hasn't been updating in months
 
Ah, btw yesterday I discussed how much BC may be broken in 5.5 with pierre
 
1:28 PM
I had a stray proxy config that it didn't tell me errors (I assumed there were just no changes)
@NikiC Oh?
 
Seems like the releaseprocess no BC break policy really isn't as strict
 
hi :)
 
E.g. Pierre would consider PHP 5.4 not having BC breaks :D
 
@NikiC Right, it's not. It's no major BC breaks, especially on the Zend API level
 
1:29 PM
and how would you solve this issue?
 
@ircmaxell Nah, ABI can be broken in any case
 
@NikiC tony the pony here he comes of course
 
But I would have argued that removing magic quotes, register globals and safe mode to be a BC break ;)
But Pierre doesn't think so, and that's good news :)
@Gordon ah, that one
 
@NikiC Well, so coupling that (notice/warning on data-loss of cast) with this patch (casting in parameter list) as two different but complementary issues... That could be really powerful
 
1:32 PM
@ircmaxell And coupling it together with object casts and ... uh, no, no dreaming :)
 
@NikiC Actually, the three go together quite nicely
 
@Gordon Like the screenshot ...
 
but we're kidding oursevles, all three wouldn't get in...
 
exactly :D
 
We'll be very lucky if 1 gets in...
 
1:35 PM
But I probably still will try to create an RFC for the warnings stuff
 
I'm updating the gist with the patch off of updated svn, so it should be able to be applied. I'll let you know when it's done
 
Okay
 
gist.github.com/1963999 <-- try that version
 
I just installed PhpStorm 5.4. It has code coverage included, which is awesome :D
 
1:38 PM
nice
 
@ircmaxell Still doesn't apply
@ircmaxell I really think that it's due to the whitespace
 
how to authenticate users in any website using facebook login
 
@NikiC hrm, I'm generating it using svn diff
off of trunk
how are you applying it?
 
PhpStorm is slow than netbeans
 
@ircmaxell patch -p0 -iP
@user1246800 good joke :D really funny :D
 
1:46 PM
odd, let me try applying it here
 
@ircmaxell Could you maybe post it someplace different? (i.e. not gist?)
 
is there something like an autocorrecting IDE? maybe VIM? I want it to automatically correct when I type pubic function or return coid
 
# patch -p0 < ../type_hints.patch
patching file Zend/zend.h
Hunk #1 succeeded at 577 (offset 2 lines).
patching file Zend/zend_execute.c
patching file Zend/zend_compile.c
patching file Zend/zend_language_parser.y
patching file Zend/zend_vm_def.h
Hunk #1 succeeded at 2663 (offset -13 lines).
Hunk #2 succeeded at 3201 (offset -1 lines).
Hunk #3 succeeded at 3225 (offset -13 lines).
patching file Zend/zend_vm_execute.h
Hunk #3 succeeded at 1365 (offset -1 lines).
 
1 min ago, by NikiC
@ircmaxell Could you maybe post it someplace different? (i.e. not gist?)
 
@NikiC working on it
preference as to where?
 
1:51 PM
no idea
 
@ircmaxell That worked :)
 
Ok, so GIST is not a good method for patches
will keep that in mind
 
2:19 PM
hrmm...I've been away from SO too long. When did meta start notifying you of post activity?
 
@CharlesSprayberry: They patched in some magic rep calc stuff yesterday, since you've only been gone a week or so, probably since yesterday :P
 
always
 
or that
 
@ircmaxell No, like there's a number in my title bar now and there's a section at the top that says "1 question has new activity"
That wasn't there before
Or if it was I never noticed it
 
@CharlesSprayberry Yes it has
been there for at least a year or 2
 
2:24 PM
I created many functions in PHP and I want to add them to the "autocomplete" of Notepad++.

How can I do that?
 
@ircmaxell That is really weird. I've never seen the meta title change until today
 
@user1123379: Edit the notepad++ autocomplete config I guess, probably better asking in the notepad++ channel...
 
@CharlesSprayberry happens on all SE sites
 
@ircmaxell I have never seen Stack Overflow <title></title> change to show that a new question has activity
 
Oh, the page title?
 
2:27 PM
Yea
Like, the title in my browser's tab
 
I know it does for chat
 
Not the inbox or anything like that
Hah! It happened again, I'll get a screenie
 
@CharlesSprayberry: Is "c spray" a happy accident or are you intentionally trying to be cute? :)
 
@Leigh A long, long, long time ago I had joined a site, pointlesswasteoftime.com, and I chose cspray because I'm about as creative as a rock. It stuck.
 
@NikiC Thank you
 
@CharlesSprayberry: So it's nothing to do with sea spray? :D
 
@Leigh Absolutely nothing to do with sea spray. Just the first letter in my first name and the first half of my last name.
Also, I absolutely hate the "new question activity" feature on meta. Completely useless. Just show me the questions.
 
While we're on the topic of titlebar changes, how do i make that asterisk go away after someone said my name :/
Oh, it seems I have to say something
 
@NikiC: I'm re-creating the object casting one...
make -j4 makes life so much easier
 
2:44 PM
@ircmaxell Yep :)
The only thing better than -j4 is probably -j8 :D Or -j32 ^^
 
well, if I had that many cores
 
yeah...
 
odd, I'm getting a memory leak, even though I'm calling dtor
 
The you're not calling dtor enough :P
 
is just doing Z_DELREF_P(zval) enough?
 
2:50 PM
no
you have to do zval_ptr_dtor(&zval)
 
and that'll remove the ref?
 
yes
and dtor the zval if rc=0
 
Ah, that's what I missed
 
i am integrating facebook with my website but getting error on $user = $facebook->api('/me');
$user = $facebook->api('/me');
 
That fixed it!!!
 
2:52 PM
here what is meaning of /me ?
@Leingh waht is this ?
@ircmaxell help me
 
@Rstar If I had any idea, I would help, but I don't, which is why I didn't
3 messages moved to bin
@NikiC: still getting a memory leak here. When I call a user function, so I'm screwing something up...
        zval *retval = NULL;
        int status = FAILURE;
        ALLOC_INIT_ZVAL(retval);
        switch (type) {
                case IS_LONG:
                        if (ce->__toint) {
                                status = zend_call_method_with_0_params(&readobj, ce, &ce->__toint, "__toint", &retval);
                                Z_DELREF_P(retval);
                        }
                        break;
                case IS_DOUBLE:
                        if (ce->__tofloat) {
                                status = zend_call_method_with_0_params(&readobj, ce, &ce->__tofloat,
 
@ircmaxell Well, you still have lots of Z_DELREF_P's there...
 
such as?
 
@ircmaxell You are doing lots of strange stuff there
 
such as?
 
2:58 PM
@ircmaxell You are first decrementing using Z_DELREF_P, then you are dtoring once in ZVAL_ZVAL and then again with the explicit zval_ptr_dtor...
 
Ahh, good point
do I need to pre-allocate retval before passing to zend_call_method?
 
Don't think so, but you should check ;)
 
hrm...
 
is it still not working?
 
making
I just realized that zend_call_method returns the return zval...
annoying
 
3:03 PM
morning all
 
it both returns and takes it as a return argument
that works, cleaned up the memory leak
        zval *retval = NULL;
        int status = FAILURE;
        switch (type) {
                case IS_LONG:
                        if (ce->__toint) {
                                status = (NULL == zend_call_method_with_0_params(&readobj, ce, &ce->__toint, "__toint", &retval) ? FAILURE : SUCCESS);
                        }
                        break;
                case IS_DOUBLE:
                        if (ce->__tofloat) {
                                status = (NULL == zend_call_method_with_0_params(&readobj, ce, &ce->__tofloat, "__tofloat", &retval) ? FAILURE : SUCCESS);
 
@ircmaxell Can't you leave out status and check for retval != NULL later?
Btw, whats the SUCCESS ? SUCCESS : ... ?
 
probrably
a fallback...
ok, cleaned
 
@ircmaxell a fallback?
Maybe you mean status == SUCCESS ? ... ?
 
yeah, if you don't implement one of the handlers, it calls tostring just like it does now (bc)
good point, but I removed that anyway
lxr.php.net/xref/PHP_TRUNK/Zend/zend_operators.c#632 <-- Is it just me, or is that if backwards, where it should try to convert the object using cast_object first, then fall back to pulling from properties...
 
3:12 PM
maybe it's assuming that internal objects don't have properties anyways often ^^
but yeah, looks wrong
 
patching that too...
Yay, got object to array casting working
 
:)
 
@ircmaxell Is this in reference to the RFC you posted about scalar casting objects?
 
@CharlesSprayberry yup
and this patch doesn't leak memory!!!
 
@ircmaxell :D
 
3:24 PM
@ircmaxell Neato. I think it's an awesome idea.
 
Thanks to @NikiC for helping out on that one!
this patch adds: __toInt(), __toFloat(), __toArray() and __toScalar()
and has them actually work in most places...
 
@ircmaxell So you want to keep the Int/Float destinction?
 
Question: should I update zend_parse_parameters to try to cast the object using those functions as well?
@NikiC well, that's only for explicit cast
 
@ircmaxell Isn't that the whole point?
 
@NikiC I've just got it working with casts
 
3:25 PM
@ircmaxell And implicit will do __toScalar?
 
correct
so $obj + 1 would call __toScalar()
but (int) $obj would call __toInt()
 
@ircmaxell And there is no way around that, yes? No way to know whether it's a concat or addition? (So that one can at least distinguish string and number)
 
@NikiC concat calls string context
$obj . "foo" always works properly, calling __toString
 
@ircmaxell So why __toScalar then?
 
because there are a number of operations (such as + and others) that call the get() handler to return an unknown scalar type
 
3:34 PM
@ircmaxell Yeah, but are there cases where strings are reasonable in that context?
E.g. + would expect numbers
 
__toString is not called for + today or with this patch
 
Are there get() cases where strings should be returned?
 
right now, + will cause the object to be casted to int(1)
 
@ircmaxell Basically my question is why __toScalar and not __toNumber ;)
 
because you may want to return an array
array() + array()
 
3:35 PM
ahhhhhhhhhhhhh
I did not make the scalar -> array association
for me array is a composite type ^^
 
Fair enough
or a boolean
or a resource
(althoguh resource could get very dirty
 
@ircmaxell Very nice PoC. I really liked id and hope it will be added to next PHP version :)
 
Thanks!
 
What happened with function foo(array $foo) ?
 
still works as normal
so foo(array $foo) will error if a non-array is passed. ` foo((array) $foo)` will cast a non-array argument to an array...
Woot!
I really should configure without cgi for these tests
@NikiC: do you see the segfault here?
zend_class_entry *ce = Z_OBJCE_PP(arg);
                                        zval *tmp = NULL;
                                        if (ce->__toarray) {
                                                zend_call_method_with_0_params(arg, ce, &ce->__toarray, "__toarray", &tmp);
                                                if (tmp && Z_TYPE_P(tmp) == IS_ARRAY) {
                                                        SEPARATE_ZVAL_IF_NOT_REF(arg);
                                                        ZVAL_ZVAL(*arg, tmp, 1, 1);
DOH, nevermind
WOAH!!!
I got sorting working on objects... well, kindof
if you do sort($obj) on an object implementing __toArray(), the variable will be turned into an array...
which may be... non-obvious
 
3:57 PM
lol
 
actually, any function which operates on a reference with a cast (even the userland ones) will cause that to happen
so...
 
I'm not sure we want references and casts go together ...
 
mmm...unit tests. After starting my new job I'm coming to appreciate my code a little bit more.
 
Asking something on stackapps sucks when you are used to the speed of SO :(
 
4:11 PM
Ah, you started your new job
how is it?
 
Anybody has an account on stackapps and is willing to upvote this: stackapps.com/questions/3207/…
Thanks in advance
 
4:50 PM
can anyone help me with a update function not working on a php trade script ?
 
im looking inject sql in a database
can someone help me?
this is what i get from the search field in the website:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' OR prod_desc LIKE '%"'%' OR prod_desc2 LIKE '%"'%' OR prod_desc3 LIKE' at line 1
so i have the table names, how can i drop them?
 
hey people
what would be a noun for "how often something occurs" ?
"occurrence" sounds a bit off .. that word _tastes_ like "event"
 
tada no one will help you hack a website
 
hacking a website is a great thing
 
maybe read the rules be for posting ?
 
5:00 PM
@tada , you either don't ask for help , or you dont hack sites
 
ok
 
it's nothing even to do with rules .. it is the common sense
@PeeHaa , tnx , i think it will actually do
 
stackoverflow.com/questions/9547767/… love how no 1 answers my questions on here :)
 
:P
 
im working with sets .. needed a word for how often condition is met
 
5:02 PM
@user1121083 Well your code looks like a monster
@tereško Indeed frequency will be ok
 
naming variables is haaard
 
@PeeHaa i guess that's because i toke the spaces out of my code
 
user895378
@user1121083 Concise, well-written, targeted questions result in concise, well-written, targeted answers.
 
user895378
If you aren't getting the answers you want (or any) try trimming down to only the code that you think is the problem. Most people don't want to wade through some huge copy paste. I see that and my eyes glaze over immediately.
 
@user1121083 nopez nothing to do with the use of spaces (although you should use proper indentation), but rather your code is just a monster :)
 
5:06 PM
@rdlowrey so i have not explained the problem well enough ? Ive edited the code so looks better to read
 
user895378
@user1121083 I'm hungover, lazy and it's raining really hard where I live. I don't feel like troubleshooting.
 
user895378
But, I would suggest the typical debug process: test things incrementally and verify that each step works as expected until you find the step that's broken.
 
The step which is broken is the mysql update
which is the second snip of code
 
user895378
Sorry, it just hurts my eyes to look at your code. I'm not going to be of any help at the moment. But, I'll say this: if you rewrite it using PDO instead of the mysql* functions I promise I'll help :)
2
 
oh, and @user1121083 , tables have not been an "acceptable way of creating layout" since 2003 .. maybe even earlier then that
 
5:18 PM
@tereško LOL
 
what was so funny ?
 
user895378
@tereško What's this CSS nonsense? Table-based layouts with transparent 1x1 spacer .gif files is all you need in life. Maybe with a sweet flash landing page intro on top.
 
user895378
Circa 1998 ... Oh and <blink> tags. You know, so people can tell what's important ... <h1> just doesn't make the important text stand out enough.
 
@rdlowrey please stop XD
 
user895378
Then you can wrap it all up with some nifty inline IE6 behaviors. Of course, you need to include the most important message: "Best viewed in Netscape Navigator with 800X600 resolution" and maybe "Powered by MS FrontPage" just so people know they're dealing with a pro.
 
5:34 PM
@rdlowrey what? no music and no dancing mice in the background? I am disappoint.
 
user895378
Well, naturally you'll include a link to the original. The one and only hamsterdance
 
user895378
The idea of using CodeIgniter AND obfuscating the code AND doing it under the auspices of a custom compiler for .NET assemblies is more than I can take.
 
user895378
0
Q: How to use Phalanger to obfuscate php code on CodeIgniter?

k83I have been working on PHP application built using CodeIgniter framework, which needs to be deployed on client site. I want to protect php code by compiling it before deployment using Phalanger. For testing this I've created a demo project on CodeIgniter with just one function and controller. Now...

 
5:53 PM
it's just sad
 
00:00 - 18:0018:00 - 00:00

« first day (504 days earlier)      last day (4435 days later) »