« first day (624 days earlier)      last day (4339 days later) » 
00:00 - 15:0015:00 - 00:00

12:00 AM
and getting following error
Strict standards: Non-static method db::get_instance() should not be called statically, assuming $this from incompatible context in class.common.php on line 7
 
are you aware that since php 5.0 (like 5+ years ago) , we are not using var to define variables
 
even inside class?
This problem isn't related with var
 
we have public, protected and private now
and no , error message already explains the problem
 
var=public
 
you are executing get_instance() which is not a static method
actually best choice usually is protected
you should not expose variables , it breaks encapsulation
 
12:03 AM
so what can I do to fix this problem?
 
define get_instance() method as static
ask google "how to define static method in php class"
the first result will contain answer
 
public static function get_instance()
 
also , i would advocate again use of Singleton antipattern in your code
@epic_syntax yes
 
I did, but now,
On other class
class page{
    var $common, $db;

    public function __construct() {
        $this->db = db::get_instance();
        $this->common = new common();
    }

    public function detectPage() {
...
        $stmt = $this->db->prepare($sql);
getting error Fatal error: Call to undefined method db::prepare() in class.page.php on line 17
 
have you checked , what is inside $this->db at that point ?
put var_dump( $this->db); exit; one line about $stmt = $this->db->prepare($sql);
that will let you see what is contained in that variable
 
12:09 AM
object(db)[2]
  protected 'connection' =>
    object(mysqli)[3]
      public 'affected_rows' => null
      public 'client_info' => null
      public 'client_version' => null
      public 'connect_errno' => null
      public 'connect_error' => null
      public 'errno' => null
      public 'error' => null
      public 'error_list' => null
      public 'field_count' => null
      public 'host_info' => null
      public 'info' => null
      public 'insert_id' => null
      public 'server_info' => null
 
the prepare() method is part of MySQLi and PDO class definitions
yeah ...
 
Yes I'm working with mysqli
 
object(db)[2]
 /\    /\  /\
 |     |   |
 |     |    handler ID (internal stuff)
 |       objects class
tells you that you are dealing with object
 
So?
 
so .. the $this->db is not instance of MySQLi
in class db you will have to define method get_connection()
 
12:13 AM
Ok. I think ti get instance of connection and send it to all classes, is the best solution
I can get work singleton stuff
 
actually it is not the best solution
but it is easiest to understand for a beginner
 
public static function get_instance() defined
What's best way for beginner++ ?
 
lemme find the post
the basic use-case looks like this : stackoverflow.com/a/9755423/727208 (you can replace PDO with MySQLi , that has no impact on pattern )
this approacher can be used in combination with factory pattern : stackoverflow.com/a/9755579/727208
which , would in turn provide you with loose initialization ( connection is establishe only when you fist time need it)
 
Lol. 1st answer is exactly what I told.
I'll go with 1 instance I think
 
at the end of fist link , there are two lectures ... you might want to watch them
code examples are in java , but the lectures are about general OOP principles
 
1:06 AM
Facebook, because you deserve it : news.cnet.com/8301-1023_3-57464415-93/…
 
@tereško Nice, Facebook tries to place advertisement for their brand in everybodies address books. How insane must one be?
Risking other persons data for such a needless operation.
But facebook users probably deserve no less.
 
1:28 AM
tnx , @hakre
that's what i get for writing post at 3 am
 
the cool thing with the new facebook emails is, that you can easily create spam listings.
 
2:12 AM
@hakre that's not cool xD
 
3:07 AM
Good evening
 
user895378
yo
 
3:35 AM
Typography adjustments for prototype documentation. Let me know what you think. You'll want to view the enlarged images.
The goal was to make things more readable. In general, that means larger text and a larger line-height.
@tereško Better?
@rdlowrey What's new?
 
user895378
@LeviMorrison hey what's up dude
 
user895378
@LeviMorrison I pushed the initial commit of the content negotation package. And by initial commit I mean it's 100% test-covered and production ready. All that's left for negotiation is a couple of aggregation and adapter classes to make things dead simple. I have them written, but I haven't pushed them yet because they aren't fully tested. Before the end of the evening I will have done so, however.
 
@rdlowrey Splendid.
 
user895378
I'm thinking about moving things like route shortcuts out of the "listeners" section of the config file and just making them boolean config directives. Such as:
 
Also splendid: even 3800 rep.
 
user895378
3:50 AM
3800? nevermind
 
user895378
$cfg->routeShortcuts = true;
 
user895378
And I also have these three others I'm going to add:
 
user895378
autoContentEncode -> for gzip or deflate encoding responses automatically if the Content-Encoding header specifies those codings
 
user895378
autoContentMd5 -> populates the optional Content-MD5 header for you
 
user895378
autoContentLength --> populates the Content-Length header for you
 
3:53 AM
@rdlowrey Automatic content length would be nice.
It'd also be nice to have some form of caching using etags or whatever they are called.
 
user895378
So yeah, I'm thinking built-in things like that will be boolean config directives
 
user895378
@LeviMorrison Yeah, that's one of the next few things I plan on getting to
 
user895378
For the record, the content negotiation stuff is $$$.
 
user895378
With the yet-to-be-pushed adapter, you negotiate content by injecting an Atreyu\Http\Negotiation\RequestNegotiator instance into your resource class and calling negotiation methods like:
 
user895378
RequestNegotiator::negotiateContentType($request, $arrayOfAvailableContentTypes)
 
user895378
4:01 AM
And if no acceptable types are available a NotAcceptableException is thrown and the process is handled by the built-in 406 handler in the same way as the built-in 404 and 405 handlers
 
user895378
@LeviMorrison One other thing, now that things are slowly stabilizing, I'm making an effort to keep my commits focused and give them specific, meaningful messages. No more messages like "OMG super-duper refactor of everything" ... which should make it easier for you to tell what's happening by looking at the commit history :)
 
4:30 AM
@rdlowrey lol, I know that feeling.
I also tend to start making really small commits but pushing them by the dozen.
 
user895378
5:16 AM
I just wasted 45 minutes trying to figure out why any browser I tried to run was maxing out my cpu. I should've known it was flash's fault. I hate you, Adobe.
 
I feel really dumb for having a starred message with a grammatical error.
lol
I thought about fixing it
Too late.
 
user895378
I hate when that happens :)
 
user895378
Of course, the person who starred it should feel even dumber.
 
:) lol
Did you look at the before / after shots of the prototype?
2 hours ago, by Levi Morrison
Typography adjustments for prototype documentation. Let me know what you think. You'll want to view the enlarged images.
 
user895378
why is dumber spelled with a "b" but dummy isn't?
 
user895378
5:28 AM
No, will do so now
 
user895378
Yeah, big improvement. I'd personally like to see the subheaders go even a little bit larger
 
user895378
Yeah, I like that a lot more.
 
user895378
Except for my enduring hate for Arial ...
 
It's actually Helvetica.
Slightly better than Arial.
 
user895378
5:38 AM
Oh, I can't tell the difference :)
 
Do you like Droid Sans better?
 
user895378
I do.
 
@rdlowrey @tereško @salathe @NikiC The latest (unpushed) changes to the prototype are posted just above here. Big emphasis on readability and improving secondary navigation.
By the way, that's one of the few pages that has a lot of text without code examples.
Well, I'm off to bed.
Good night!
 
user895378
Later dude
 
what if i enter google.com in canvas url of facebook
 
 
2 hours later…
9:21 AM
morning
 
 
1 hour later…
10:41 AM
which php frame work do u all prefer?
 
morning ;)
@LeviMorrison that looks nifty dude. crush arial ;)
with that font I want to visit manual more often ;) +1
 
@hakre heya
 
jow ;)
@r20rock Why do you ask? PHP Frameworks are not a popularity contest.
 
just curious :)
 
10:56 AM
I like Kohana
good morning working people
 
@r20rock Okay, if you don't want to waste too much of your developer time, take a look into Symfony2. Apart from that, you don't need to use PHP, there are other languages available, too. So there are more frameworks than just PHP frameworks and often developers have more than one language, so even this is the PHP channel it must not meant that folks here use actually PHP frameworks.
morning @webarto ;)
 
nice answer :)
 
Well actually one PHP framework I use very often is PHPUnit.
And I like it ;)
 
11:12 AM
i have also heard about CakePHP
 
@hakre only one that works good :P
 
@r20rock Yes, that terms floats around a lot but if you ask some PHP developer as of today they run away crying.
Question is what are you looking for? You want something to start with? Something compact?
 
if you want compact, look for Zend Framework :P
 
@hakre actually i am not looking for anything...just asked it as a conversation starter :P
 
@r20rock So what do you prefer as a PHP framework?
 
11:21 AM
just reading job ad... looking for senior php developer, with 7-10 years in experience, fluent in CodeIgniter... well, if I end up coding in CI after 7 years, I'll kill myself...
 
I am not familiar with many...actually I recently developed a Quiz Component in Joomla using MVC and I personally felt quite hard understating Joomla API. So I thought about getting your views about the best framework if I have to use any in the near future.
 
say wat?
 
@r20rock here is a near future plan: finish writing my own one and play around with symfony2
 
I wanted to get one project I work with to port to symfony2 but they opted for Yii for php version reasons mainly (5.2)
So there can be many reasons why you (sometimes have to) choose a specific one.
 
11:37 AM
I just don't understand why people turn to Yii, there is really no excuse... @hakre, you mean PHP on server is 5.2 or something else?
pokit.org/get/img/1959cfd9907c2c58f668732113f33088.png Kohana ORM... I thought it selects only what you want (if you specify)...
 
@webarto Yes, and it's not only one server. It's a free application that can be downloaded so this was a question of inter-operation and how pushing the project will be.
We first evaluated CI as well, but they have an incompatible software license (and the project leads behaved extremely unsupportive and stupid) so after porting it to CI, the Yii port was started. Yii is much better than CI btw.
Before it was ported to CI, it was ported to Cake btw, which was a complete mess.
so actually three major rewrites in two years.
With all the ups and downs ;)
 
haha too many ports :) yes, that can be a problem... I took me an email to upgrade server from 5.2 to 5.4, but there is only one app on it, and it all worked well after restart...
@hakre I hope you've got paid for it :P
 
@webarto The cake port was payed (I didn't do it), the CI port was sponsored by google and for the Yii port I think the project paid one developer from it's own budget.
If I do the work, I'm normally paid because I do the work while I work for the one or other company.
 
that is nice if you can keep it up.. so far I've worked for outsourcing companies, and it was pure exploiting, I didn't minded... last month I got job in www.site5.com, work is so relaxed I'm starting to think they'll fire me...
@hakre is it a secret where you work?
 
11:53 AM
woops
 
@webarto Yes, sure. I keep it secret in my pocket ;) - But I've been freelancing in the past as well as I worked as a employee.
@PeeHaa More of those ;)
 
:P
 
@hakre , well , what was your experience with Yii
i used it for half-a-year one project , and it was quite horrible
 
12:13 PM
Well I'd say it's going okay. It's an improvement over the earlier codebase, and it makes diverse parts of the application more identifiable which is a huge benefit. It's more used in a pragmatical sense I'd say.
Sometimes the structure of a framework can stand in your way, sometimes, it's good to have at least some structure.
It's more the later so far.
 
12:36 PM
Anyone of you guys has a rooted android phone?
 
hi guys
OOP
anyone here?
 
It depends
 
Good morning
 
@ircmaxell morninbg
 
good morning
 
12:46 PM
sup?
 
Morning all. Well afternoon here :)
I'm trying to use mysqli within my php application. Usually this isnt an issue. At the minute though i'm coming across an issue. I have created a VPN and my front end boxes need to connect to Mysql through the network 192.168.0.200 instead of localhost. I do this using:
parent::__construct("192.168.0.200","root","blah");
(I've extended mysqli)
but i get the following error: Access denied for user 'root'@'192.168.0.5' why is mysqli changing the hostname of 192.168.0.200 to the one the front end is sitting on
o_0?
 
@Andy Because the user connects from there. Users are per (client) host.
 
? bit confused by that, what do you mean?
 
@Andy You should properly setup the privileges to allow that user to connect from that machine (ip)
 
ah you mean user from FrontEnd needs an account on DBServer?
@PeeHaa where might i do that?
 
1:13 PM
e.g.: GRANT ALL PRIVILEGES ON database.* TO 'root'@'192.168.0.5'
(untested)
where database is the database name
And I think you need to flush the privileges afterwards
 
client <--> server : user@client connects to server. server looks if user@client is allowed to do something. if not, you see the error. that simple it is.
 
ah
 
ok, gotcha.
i've also seen this: cyberciti.biz/tips/…
which is helping, turns out i didnt have bind-address on either
 
there is a wildcard for host, so you can allow the same username from many hosts.
yes, nixcraft is a great resource. they are straight to the point.
 
1:22 PM
still not getting a connection. Do i not need to create an account with that user aswell? will it still use the same password that i have for mysql?
i'm thinking i might need to update the password for that user?
[actually let me read the docs you gave me]
 
@Andy yes, do so. the user is not the OS user, however by default the client library picks the OS user ;). Better read through the docs, because there are some caveats.
 
You're all amazing bows thanks!
 
CREATE USER 'andy'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'andy'@'%' WITH GRANT OPTION;
this will create user "andy" with password "some_pass", with all privileges on all databases, and remote access ("%" is a wildcard hakre mentioned)
 
1:38 PM
@hakre ahhahaha nice
 
@PeeHaa Some little illustration I did for hakre.wordpress.com/2012/06/30/where-is-your-vision-jeff ;)
 
cool
 
morning
or afternoon
 
good morning ;)
 
1:47 PM
morning
 
hey @hakre and @PeeHaa
 
What's up @NikiC
 
hey @ircmaxell
@ircmaxell btw, I assigned a doc bug to you. did you get a mail?
 
I responded
 
you did?
oh, right, I see
I hate it that you don't get mails if you aren't assigned
most bugtrackers also mail you if you comment
 
yeah, it should
or have the ability to "watch" a bug
BTW: why not a warning or notice for data-loss on a cast?
 
because we didn't argue about that yet :P
 
which is why I'm bringing it up :-P
 
@ircmaxell That whole crypto stuff is too high for me. I absolutely don't get what you two are talking about there ^^
okay, so, start arguing ;)
 
want me to explain what we're talking about?
 
1:56 PM
9,999 questions tagged - finally a milestone reached. months of hard work ;)
 
@hakre 0 should be tagged php5
 
@hakre grats
@ircmaxell I suspect that it would take a lot of time ^^
 
About 6,300 in the tag are tagged as well btw.
 
@NikiC yeah, but not a heck of a lot. I could give a quick rundown in 10 minutes or so
 
From what I've seen so far, it's normally possible to just drop the from them when they have both.
 
1:59 PM
@ircmaxell Then go ahead :)
 
or we could just argue about the type casting patches
your call
 
we can combine both :D
 
we can do both
ok, cryptography first
mcrypt provides a type of encryption called block ciphers
they encrypt "blocks" of data using a key
for example: AES (Rijndael-128) encrypts 128 bit blocks (16 bytes) at a time. That's all the cipher can ever do
So, if we want to encrypt more than just the 16 bytes the cipher provides for us, we need to iterate over the cipher
A trivial method of doing that is:
 
@hakre it would be nice if people stoped that stupidity
 
foreach ($blocks as $block) {
    $cyphertext .= encrypt($block);
}
That's called Electronic Code Book, or ECB for short
 
2:03 PM
have you been editing posts with to ?
 
It's a chaining mode. It allows the cipher to chain multiple input blocks together to encrypt a larger string
 
@tereško Yeah started at 15k ;) or so. Don't remember any longer.
Mainly to burn down the new ones added to the site.
It already has a positive effect.
 
however, there's a problem with ECB. If you're encrypting a large number of blocks, it can enable statistical analysis on those blocks to eventually provide information about the key
 
wow
 
So, there are other chaining modes available
one of the best is Cypher Feed Back (CFB)
the way it works, is that you generate a random block of data to use as an Initialization vector.
 
2:05 PM
need a hand , @hakre ?
 
$iv = random(16);
foreach ($blocks as $block) {
    $text = $block ^ encrypt($iv);
    $ciphertext .= $text;
    $iv = $text;
}
 
@tereško everybody is welcome. keep new questions on php5 tag out of the site is best I think.
 
That provides far greater resistance to statistical analysis...
 
I tag php-5.2 for example if a specific version plays a role (next to the php tag)
 
Now, an important thing to note is that the resistance is not dependent upon the IV being a secret. Therefore, the IV can be shared publically without compromising the integrety of the cipher
follow so far?
 
2:07 PM
yup
 
Ok, so that's the cipher
Now, remember that the block cipher operates on blocks
if your input data doesn't align to those blocks already, we need to make it align...
there are several packing modes that allow that to work
 
PKCS7 defines it as appending padding consisting of the number of padding bytes needed.
So if we had a 14 byte string, we'd append chr(2) . chr(2)
 
please star it.
 
so then to strip the padding, you'd look at the last byte, decode it, and remove that number of bytes from the end of the string
Now, two more things to go over.
The first is the key. Keys are supposed to be full-byte strings that look random
the more random they look, the better
If you're going to use a password, it should be derived using PBKDF2 (Password Base Key Derivation Function) into a random looking key
and that's why it's important to distinguish key from passphrase
Finally, there's the section on integrety and authentication
 
2:11 PM
@ircmaxell And it's enough for it to look random, even if it is not actually random?
 
@NikiC exactly
The important thing is that the bits are reasonably randomly dispursed
as it will enable the cipher to work better
Remember that block ciphers don't care about the data being encrypted. All they do is move bits around
So if we change the first bit of ciphertext, it will still decrypt the output, but decrypt it incorrectly (the wrong data will appear).
So we can solve that by taking a HMAC (Hash Message Authentication Code). We'd want to use a different key from the one that the cipher used (for security)
So, what we can do is: $output = $iv . $ciphertext . hash_hmac('sha512', $ciphertext, $hashKey)
Now, before we decrypt the ciphertext, we can verify the HMAC. That provides integrity information, telling us that the raw bytes weren't compromised.
It also provides us authentication, since the hash key is separate from the cipher key (so deriving one doesn't let you attack the other)
make sense?
 
make sense
 
cool
 
thanks
 
anything else to go over? I think that's about it
 
yeah, I that's all I think
 
cool
so now, to scalar typing
Personally I think that a recoverable error is too much, given the type behavior of PHP
$a = 1 + "2abc" works, so passing 2abc to a method that requires an int shouldn't fatal bomb... A notice or warning that there was data loss should be enough IMHO
 
It should be a fatal imho
You did type hinted for a reason didn't you
 
@ircmaxell What happens when you pass "foo" into int?
 
same notice/warning, and it's treated like a normal cast to int
@PeeHaa but you still get an int inside the function
 
2:24 PM
well, we can argue about "123 apples" being cast to 123, but "foo" definitely should give a hard failure
 
well, I'm not so sure about that. Because what if you pass foo(true). What should happen then?
or if you pass "1.5"
or if you pass "1.5 abc"
 
that depends on whether we want notice or recoverable for that case ;)
 
well...?
 
but "foo" definitely should fail
you can't disagree with that...
 
why should it?
 
2:28 PM
@ircmaxell Why would you want to have it casted?
 
consistency
 
When I ask you for a int and you give me a string I'll start yelling at you
 
@ircmaxell Consistency with a wrong behavior
 
consistency with the way variables work through the rest of core
consistency with zpp
 
zpp denies "foo" for int
 
2:33 PM
php -r 'var_dump(substr("foo", "bar"));'

Warning: substr() expects parameter 2 to be long, string given in Command line code on line 1
NULL
php -r 'var_dump(pow("foo", 2));'
int(0)
 
pow probably has custom parameter handling ;)
that's why it misbehaves
 
 php -derror_reporting=-1 -r 'var_dump(substr("foo", "1 ab"));'

Notice: A non well formed numeric value encountered in Command line code on line 1
string(2) "oo"
 
Same goes for floats
 
the problem is that there's no way to tell the difference between "1", "1 ab" and "ab" at the same time.
because is_numeric_string either returns 0 for a non-well formed number, or raises a notice
 
2:40 PM
@ircmaxell huh?
 
but why is that an issue?
 
eih
 
you want to throw a notice anyways, right?
 
2:45 PM
ok, so another question.
if 1.5 is passed to foo(int $a), what should happen?
 
Huh, I should be more careful with git reset --hard
just lost two hours worth of work on that tiny little command
 
yeah, be careful there
 
but it turned out to be not working anyways, so ... maybe that was a sign ^^
 
@ircmaxell That's a tough issue. 1.5 seems clearly wrong, but there are also other cases like 1.0000000000001, where it's hard to say whether or not it is an integer
though I'd say that it should only go through if it is exactly representable
 
2:48 PM
if (Z_DVAL_P(op) == (double)(long) Z_DVAL_P(op)) {
which is what that line does
I feel we may be getting too strict here, but ok...
 
that line will detect exactly 1, but not anything near it. And I don't know whether that's good or bad ^^
 
@NikiC no, it will detect anything that's exactly representable
so 2^128 will fail...
now, passing a resource should fail, right?
 
@ircmaxell yes, that's my point ^^
@ircmaxell definitely
 
ok, now for a float argument
passing a long that's not exactly representable should fail, right? PHP_INT_MAX on a 64 bit platform is not exactly representable as a float
so bool is the only hint that has no error state
 
@ircmaxell I'd say yes
 
2:55 PM
actually, ZPP does have error states for it
so I'll add a convert_to_boolean_safe_ex() macro/function
 
@ircmaxell Do you also always have merging issues with the php_version.h file?
It always causes problems for me
 
nope
I've never edited it though
 
me neither
I just did a few reverse-merges and it showed up again: github.com/php/php-src/commit/… (last file)
 
no-ff?
 
no-ff
I always merge with --no-ff --log
 
00:00 - 15:0015:00 - 00:00

« first day (624 days earlier)      last day (4339 days later) »