« first day (418 days earlier)      last day (4540 days later) » 
00:00 - 16:0016:00 - 00:00

12:04 AM
Hi, I've a problem with (I presume) php sessions and iframe. I'm logged inside page index.php using php session, and in the same page I have an iframe pointing to page index.php too (so it's like watching the page while watching the page :D). The problem is that the page inside the iframe is totally blank, no 404 errors or similar, just blank.
Do you know if sessions blocks multi-view of the same page at the same time
with the same sessions data?
 
I'm fairly certain that the session within your iframe has a different session id associated with it as it is a completely separate request. But, I may be mistaken.
 
so the problem should not exist.. mmmm
 
What is the expected behavior?
 
load the page inside the iframe
if I look at the page source code
this is what I get: (1 sec, going for ctrl+c)
 
Have you checked your server error logs?
 
12:11 AM
<iframe src="userProfile.php?userID=0"></iframe>
uhm nope to be sincere
i'll check it now
uhm, sorry for the question, how do I check server error logs? :D
 
Well, you've also got the src set to userProfile.php?userID=0 so of course you won't see index.php in the iframe :P
 
firebug isn't helping
yes sorry, index was an example
not specific
 
ah, ok
And where your error log could be is entirely dependent on your installation, but one second
Check your php.ini for an error_log file, if there is a path in it then your errors are getting logged to that file
Otherwise it would be the server logs, I'm assuming Apache?
 
yes
i'm on localhost
 
Windows?
 
12:15 AM
linux
wait
with windows you mean my OS or the server?
by the way, linux to both questions
 
Well, I don't have a lot of experience with Linux, just the basics. I run Mac, and occasionally when forced Windows.
 
What's the question? Doesn't matter. The answer is Linux.
 
found error_log
no errors at all about that
the strange thing is that if I change the ?userid= value to another number
it works
the problem pops up only when
I try to see the page related to the user that is logged in
with the other users works fine
 
Hrmm...remember watching a Clean Code Talk where they were talking about flakiness. You got anything in the global scope? Singletons? Static? :P
 
don't think
:O
 
12:22 AM
Well, you're getting into questions that can't be answered without looking at the code. For all I know displaying no content with a userId of 0 should be completely expected behavior
 
mmm hold on 1 sec
code coming
 
please put it in a pastebin or some equivalent
 
line 92 there's the iframe
line 18++ is where the user session is checked
you'll see probably some code-monstruosity. please close an eye and skip to the next line :D
 
Your code is highly susceptible to attacks. Things like <?php echo $_GET['userID']; ?> will eventually not be good for you.
 
i know it's full of weakness, but is not a problem. I need it just to try some xss injection
 
12:31 AM
ok
 
so I didn't pay too much attention to weakness or similar
thanks anyway for the advise
found something interesting?
 
No, to be perfectly honest I can't read your code, There is simply too much going on in each block to make any sense out of.
 
I understand, thanks anyway
 
newbie question: if you have a file with a .html extension you cant do any php inside right
 
yep
you can't
 
12:41 AM
Not necessarily. You could set up your server to run .html files through the PHP interpreter
 
<html>

<head>
</head>
<body>
<?php echo "hello";?>
</body>
</html>

doesn't work
 
@BeNdErR Not necessarily true. That could work if you have it setup for .html files to be parsed as PHP
 
sorry for the wrong response, I didn't know of that
 
yea php can be inside html tags but not in a .html file
just confirming, thanks guys
 
@JMRboosties No, that is not correct
 
12:43 AM
lol what I've done XD
gtg, thanks charles for your help, bye
 
=(
what is correct in that case?
 
Your webserver can be setup to interpret any number of files as PHP. One line in a server configuration could force all .html and .htm files to be parsed as if they were PHP
 
ah ok
 
Not suggesting you should do this, but its possible to come up with your very own file extensions
For example, arstechnica.com has a .ars file extension
 
12:47 AM
so its possible, but you gotta tinker some
its not possible by default i mean
 
Yo
 
In most server configurations no, it is not set by default to interpet .html as PHP
Hello
ugh, just saw a question requesting a programming language that compiles INTO PHP
 
I was working on one for a short time
 
Bleh, I'd choose a different target compilation language :P Of course, I couldn't even begin to imagine what goes into creating a compiler, even one that compiles into PHP...
Well, I can imagine what goes into it...pretty sure I wouldn't even know where to begin in implementing it
 
why? ease of distribution. Ease of maintenance. etc
 
 
1 hour later…
1:58 AM
Hello all
I know there's articles out there about the "proper" PHP syntax, but am out of luck in finding any - perhaps someone here knows?
 
2:33 AM
@wabbble What do you mean "proper"? Not resulting in parse errors would seem to be the proper PHP syntax
 
No I mean style
because code style is the main concern for me, I want to write like the great write
 
there is no one proper style
 
well i'm sure that $my_very_long_but_describing_var = "<why><is><my><html><here>"; is not a good technique so there must be some article out there that at least points to the good direction (the above example is not how I write code by the way)
 
Not sure I exactly want to BUY a book just to get that
which ends up telling me 99% of stuff I'll never need
 
2:40 AM
Trust me, this book is worth it. I would highly recommend it.
In my opinion, the most important aspect of your own style is that you stay consistent.
 
@wabbble That's what I do (descriptive variable names)
 
Yes, there's nothing wrong with descriptive variable names. I'd much rather see a long variable name then $w or some of the other silly variable names I see
You should know, without a doubt, the exact data stored in a variable and exactly what a method will do...just by looking at its name
 
Yea, well, I don't know.
I don't like a page wide variable
 
agreed, but descriptive is good
 
Well, nobody's saying that you use whole paragraphs to describe them either.
 
2:45 AM
for example the_awesome_variable_does_this could be shortened to awesome_variable_this
and I was more thinking in the lines of should I do
<?php if( something ){
or <?php if( something )
{
and should I add spaces in the beggining of if and in the end or not
the small things
 
read CC2
 
I think in PHP variable names are extra important because you really don't have any guarantee what type of data a given variable will hold. And of the 2 evils, short, non-descriptive names or too descriptive I think I would choose the former.
Which one is easier for you to read? if ($something) or if ( $something )? Use that one.
 
@CharlesSprayberry I would choose the latter
 
I like spaced
 
Ya know, I may have messed up use of the terminology :P
 
2:49 AM
gives a groovy feeling
 
I don't like the spaced version personally. I prefer if ($foo) {
 
space after ) interesting
I don't use a space there
 
Shucks, can't even go back and fix my mistake
I'm with you, it was just a goof on my part. Too descriptive > non descriptive
 
See that's what I'm talking about, the small things, they should be made into a standard of good coding or something.
 
@ircmaxell I agree with you. no space
 
2:50 AM
@CharlesSprayberry I figured as much
@wabbble Everyone has their own preferences
 
So that n00bs like me could follow, all I see is tons of code, everyone writes differently and I have no idea which to follow.
 
Yea, what makes sense and is easy for me to read isn't for others
 
You have a point there tho'
 
Like, I don't care for anything other than the 1TBS. Allman style indenting? Blech.
 
2:52 AM
agree
 
But, ultimately I think the more important thing is to stick to it...even if its something that you don't agree with.
I've seen some of the code written by some of my classmates and oh man
Oh...man, I looked at it and it was hard not to go saucer-eyed
 
Yup. Consistency is key
 
the worst is probably not indenting or seemingly no logical reason for the indenting
 
that's my current style
please only critisize on style not on code itself :D
otherwise it's a whole new discussion which I don't want
 
But that's part of it :P
 
2:55 AM
And yes I know don't use @, it's just a fast way to get rid of undefined indexes when I'm testing shit
for production stuff I never use it.
mkay?
now leave me be.
 
Honestly, the first thing I noticed was how deep your if statements were nested
 
What do you mean?
 
8 spaces?
I prefer 4 spaces instead of a tab
 
I don't know, that's the default for Sublime Text
Will change that
Oh and I don't like spaces
 
I dislike all spaces after ( characters
before, perhaps, but not after
 
2:58 AM
No, I'm sorry not like the actual spaces, of which I'm with the 4 spaces side, but just the actual number of ifs
 
require is not a function. it's a language construct. So no () needed. require 'foo.php';
 
I look at it and I can't help but see code that screams "abstract me out! there's duplication just down there with the second require!"
 
All right.
 
and I dislike _ separated varnames (I prefer camelCase)
 
See, that's more like it, I'm actually learning now
 
2:59 AM
But see, there's nothing wrong with _ separated names
 
I know, nor with require ()
 
Nope, just preference
 
I don't like them either, I'm in the camelCase camp but it doesn't make your program bad
 
I just want to learn style right now
 
@wabbble That's the thing. There's no "style" to learn about. Try some different ones. Some will feel really awkward. Some will feel pretty natural. And some will feel down right bad. But try them all (every permutation you can think of). Then decide which you like best
 
3:01 AM
All right.
@CharlesSprayberry where's a dublicate of the same require? I can't see one.
one takes the controller, the other the view.
how do you do that in one require?
 
what he;s saying to do is refactor that so that one block of code isn't doing so much
 
You could have a function take a parameter and the function is actually doing the require
 
you can keep the three requires, but break it out a bit more. Have separate named functions, so that it's easier to see what's happening
 
Or do what @ircmaxell is suggesting
 
Yeah, I know. $_GET should be made a ton of more secure, too.
 
3:03 AM
:-P
 
but there's just too much going on in the same block
 
yeah, right now it's pretty open to attack
index.php?get[0]=../../../../../etc/passwd
whoops...
 
I just wanted to test the idea I had, it worked. So I uploaded it to github because I needed to go on format (which I still need to do after fucking my whole C drive up)
But I don't need to explain you!
depends of server configuration, too @ircmaxell .. since my server doesn't allow to go back from doc_root
 
What does $init_controller->get_view() do? You don't have it being returned to a variable of any sort
 
basically I tried to re-create the codeigniter thing that a function in a class is the page that you get via url
so /controller/view
would be class controller and function view
 
3:08 AM
Right, I see what you're doing
But, like what is get_view() in your controller actually doing?
get_view() implies that it returns some value you should do something with but it just kinda ends there
 
yeah
currently it's public function index(){
echo'home sweet home';
}
which is the index page
about() could about or whatever
 
so, running get_view() results in 'home sweet home' being echod out?
 
no, blog/index would
and if get is empty
you can define the controller so it doesn't have to be blog
there is no get_view function
$get_view is the var that get's the view name from $_GET
 
Ah, yes I see the $ which is the appropriate method name
 
It's a huge mess as of now, am trying to learn how to create MVC and stuff with it so it's mostly like a sandbox which nobody on earth should use
 
3:12 AM
but ultimately that variable name is not really descriptive of what is going on...it should be something like render_view() or echo_content()
well, we're just talking about style at the moment
 
allright, i'm listening
I'm going to add it all in a class anyway
 
When you see get_* you expect to be getting something
 
probably going to rename it to just view
well it is
it get's the view name from $_GET
 
But it isn't.
Sure, but then it's being used as a function
Seeing this call $init_controller->$get_view() feels wrong if there's no variable getting the return value
 
I get your point
 
3:14 AM
Like we've forgotten to do something with the data being returned
 
Yes, will change that as soon as I get back from the devil called format :P
 
Well, I'm not trying to necessarily nitpick this one code snippet but more just try to make you think about what the variable and, in this case function call, is actually doing and name them so you immediately know what's going on.
 
I understand
A bit common sense to the thing and whoalaa
 
Well, I don't know that its so much common sense
 
@wabbble fair
 
3:17 AM
When I first got into programming I was awful, not that I'm not still awful but I was an extra brand of awful. A lot of this stuff I'm saying I only got after I learned a few hard lessons, read a few good books and looked at a lot of bad code.
 
sure it is, controllre->$get_view doesnt get anything there anymore, it IS there already if we're that far, so it should be just view
 
But, what are you doing with the view? Are you returning an object? Some string to print out? Is $view() doing the echoing?
 
Also I like totally need to start writing slower so I wouldn't have gazillion errors in literature.
echoing
it's a view, a page
everything within is a part of a page
 
Then make me know that by calling this you will be echoing out content
 
doesn't view tell you that already?
 
3:19 AM
think before you write. Writing should be the fastest thing you do
 
I don't think so, no. I think $echo_view or $render_view or $send_view_to_user is better than just $view in this case, mostly because you're using it is as a function that does stuff
 
It is, I guess. I haven't had the need to look where a certain key is for years
 
Granted, $send_view_to_user is a tad overboard
 
render has point
echo doesn't seem natural since it returns data and is not only limited to echoing, that function can return pretty much anything, but that anything will be displayed to a visitor
so it's a page
 
Sure, but echoing has all sorts of implications, particularly with sessions and all kinds of things. If a function echos something for me I want to know
 
3:23 AM
I get it.
Well I better get over with this darn format thingy
be back soon.
 
@ircmaxell "Writing should be the fastest thing you do" reminded me of steve-yegge.blogspot.com/2008/09/…
 
 
1 hour later…
4:44 AM
I just realized that giving birth is much like developing with GitHub ... Push, Push, Push
 
4:55 AM
Best rails like framework for php?
 
@andrewpthorp , your question is invalid
noone who has some clue about proper OOP in class based language would put "best" and "rails" in same sentence
additionally , there is no "best" framework in php .. they all suck in some aspect
the channels common recommendations ( with huge disclaimers ) are Symfony2 and Kohana3. One for people who need full stack framework , the other - minimalistic
they both are horrible in their own way , but this seems to be the best php community can do
 
5:23 AM
I intend to see things in a more optimist kind of way, not "both are horrible" rather "both have they're own pros and cons"
the way you make it sound is pretty much like "php sucks, go away"
 
Jul 4 at 14:19, by salathe
PHP sucks.
@wabbble , that message has 13 stars
 
and yet you use it
which makes me wonder, why?
I'm quite sure there's alternatives to PHP
and if you say that they suck more, then I'm sorry, but PHP does not suck. if 10 out of 10 suck, it wouldn't make sense because there can't be negative without the positive.
 
.. you tried to explain something , but it was lost in the translation
 
Yeah, whatever. I just don't get why people who so willingly participate here also hate PHP. Don't like it, don't use it. Simple? Not really, as it seems.
 
its like saying , if you a afraid of google , then just dont use it
i guess you are still naive
 
5:38 AM
I'm not afraid of Google. And I like PHP. However I think you have been using it way too long because it kind of looks like it's gotten to your head, which in my point of view means that for a developer it's time to move on to something other than PHP. But if you so want to continue hating everything related to and PHP itself, well, have fun.
maybe.
but then again, the one pointing and seeing the problem, is only you.
 
Hi
I
I've been unsuccessfully trying to insert an image into a word document transforming XML by using XSLT
I have a PHP application that needs to generate Word reports
somebody knows how can I do so? Using XSLT and XML
 
did you try this :
4
Q: how to use php to include an image in a word file?

altvaliSomebody has asked me to make an app in php that will generate a .doc file with an image and a few tables in it. My first approach was: <?php function data_uri($file, $mime) { $contents = file_get_contents($file); $base64 = base64_encode($contents); return ('data:' . $mime . ';bas...

but thats about all i can say about this .. have never tried such thing
 
I have a ^-a-zA-Z0-9_ pattern, now if I want to include to it slashes, I just .. blindly add / in the end?
 
5:53 AM
are you regexp'in URL fragment ?
 
yes
 
then you are doing it wrong
 
I'm going to split it by / using explode, but current regex will remove it.
 
URL can contain chars like āžščūēņļķŗ
 
other option is to sanitize the splits alone
yea I don't really care
all I need to know is how to add slash possibility to it
 
5:55 AM
@tereško No, I didn't try that one. I'll do it later, cause at the moment I can't try. I've have been trying to generate the Word reports for so long. Everything works all right, but there is one single image I need to insert at the end of the report and is taking me so long. I could do it in a different way for example my last attempt was using PHPWord, try to open the Word document and insert the image at the end but I was unsuccessful :(
 
@wabbble then go fuck yourself , why did i even begin to write a paragraph long answer , i wounder
 
@tereško what else can I do?
 
because your answer most likely has nothing to do with my original question?
and damn do you need to get some nerves or what
 
@ivanfreire , you could try to reverse engineer it .. generate your sample document , then open work and add an image .. look for changes
s/work/word
 
@tereško good idea but anytime I see those Word formats they seem so obscure
 
6:01 AM
( we are talking both about docx, i hope )
 
yes docx
 
thing is , the changes should not be too global
only the parts relevant for inserting the image .. or that's the hope
 
@tereško I also tried with COM I am able to insert the image at the beginning of the file I don't know how to reach the end of the Word docx
sorry connection problems
 
there is also this article : blogs.msdn.com/b/dmahugh/archive/2006/12/10/… , but that too might not be anythign new for you
but it has a sample document =)
 
@tereško no I haven't seen that one neither. I hope I can make something out of these information
 
6:08 AM
aaaaarrrrh ... MVC-ish request handling + IoC + SOLID = headache
anyone good at IoC ? .. besides @ircmaxell ?
stares dubious at bootstrap.php .. i know i am doing or wrong , somewhere
 
6:33 AM
Man, that is a big query
 
yeah , second thought you have, when looking at that thing is : "there must be a better way to do this"
@JohnP , do you have a moment ?
i kinda need to pick someones brain about MVC-related things
 
7:15 AM
@tereško hey, what's up?
I might not be the best pick though, most of my work so far has been on monolithic legacy systems :)
 
 
1 hour later…
8:26 AM
-2
Q: Parse a URL to extract all the GET variables in the URL

Sachin How can I parse the current url to get all the GET variables from it. Although there is a function by the name of HTTP_GET_VARS But the documentation says it is deprecated so I do not want to use that. I want to do something like this, if I have a url as www.example.com/variables.php?var1=1&...

anyone know if this is actually the right answer? stackoverflow.com/a/8427354/208809
 
9:02 AM
if I fsockopen a port in php and connect to a remote SMPP server, what IP will the remote server get? my $_SERVER['SERVER_ADDR'] ?
 
9:55 AM
hello everyone, can you explain me why the iframe in the code won't load the page?

---- testFrame.php ----
<html>
<head></head>
<body>
hellooooo <iframe src="testFrame.php"></iframe>
</body>
</html>

the page name is "testFrame.php", so the frame inside recall the same page he's in.
the result is "helloooo " plus one empty iframe
 
@BeNdErR I am guessing that testFrame.php has file permission errors or file not found errors, or perhaps a syntax error inside testFrame.php ...
 
uhm
there are no errors inside testFrame, as testFrame.php is the code I posted
 
ohh, I didnt realize that, but don't you think it will be recursion ? An HTML body with iframe having the same source ?
 
yep, but I need it :D
do you think that iframe is so smart to block recursive calls to the same page?
otherwise I can't figure out why it doesn't work
 
@BeNdErR I am not sure about iframe being smart, but it seems kinda obvious to me to not allow it
 
10:07 AM
mmmmm, I think this is the only solution
thanks sudhi, have a nice day :)
 
@BeNdErR yw , but I think I was wrong look here
 
thanks
hmm I don't get it
ah, it seems to work right?
 
even I dont get it completely, from what I could understand, the recursion is browser based, e.g. Firefox will allow upto 10 recursions
 
should I open a new question on stackoverflow? now is only for personal interest :D
 
Well I did a quick test
 
10:22 AM
found something interesting
?
 
yeah, it is completely browser dependent, Firefox will not allow it, chrome allows once
so I dont think you will get much of response from SO community, you test and see for yourself
 
hmm
let me try in chrome
 
opera allows twice
 
yep it works!
nice one, thanks again!
 
@BeNdErR yw. BTW, you can look at FF/Chrome/Opera screenshots here
 
10:35 AM
thanks :)
 
my pleasure. I learned a lot , so thank you too :D
 
hoy
I am using mssql db and i want to save unicode chars into a table column that has nvarchar(1200) type. so if i edit filed in this column with different locale i.e with unicode chars it shows thm well.
however when I send unicode chars from php script to save them to this column I get this output ????. also when I try to showunicode chars in browser i.e load the php script it shows also ???
So I guess that the problem is the php side. What to do to php or which function to use in order to save the real chars to db instead of ????
 
@Vlad are you using proper unicode_* functions ? or have you set appropriate locales ?
 
tried to change default_charset to utf-8 in php.ini but no success
@Sudhi appropriate locales means some setting in php.ini?
 
10:53 AM
@Vlad no need to fiddle php.ini , have a look at this function
if it works , then put it in php.ini so all your php files will have that affect , however , if you want this locale setting for a particular set of application, then you need to manually handle with utf8_encode($input_in_ascii)
something like $stmt = 'INSERT INTO foo(bar) VALUES(:bar)'; $sth = PDO::prepare($stmt); $sth->execute(array(':bar', utf8_encode('my input string in ascii'));
 
@Sudhi wow thanks I will try this right away
 
you might want to read up this part of PHP man page if you want to know/learn more about string encoding
 
11:14 AM
brb
 
 
2 hours later…
1:06 PM
hoy
 
1:23 PM
 
1:40 PM
hello
 
1:51 PM
In Git, 'rebase' would mean if I had a file in my local repo but not my github and I pulled with rebase the file on my local repo will be lost?
 
Hi
 
hi
@ircmaxell I never understood that opinion ^^
@rlemon you mean git pull --rebase? That just means that your changes are rebased on top of the pulled changes. I.e. first remove your changes, pull the upstream changes and then apply your changes on top of it.
I usually always pull by rebase
 
eaj
2:14 PM
Is "usually always" the opposite of "sometimes never"?
 
@eaj something like that ^^
 
2:31 PM
ok so I'm in the directory .git/ is in, and I try to git rm public/css/default.old.css
nvm.. works - I had a typo first time.
 
@NikiC You don't have to
 
@ircmaxell But I would like to ^^
 
:-D
 
2:58 PM
 
3:14 PM
@ircmaxell That's you!
 
it is?
 
@ircmaxell Could be.
 
who me?
 
@ircmaxell Who who?
 
eih
 
3:24 PM
hum
 
I hate mysql connection problems
 
I hate problems
Hm, no, that isn't exactly right
 
yes, it is
 
I hate problems that I can't solve
 
I hate undefined behavior
:)
 
3:35 PM
You should hate ill-defined behavior
 
True :P
 
3:54 PM
Hey, Anybody up to helping me with a quick question?
 
What is your question?
 
00:00 - 16:0016:00 - 00:00

« first day (418 days earlier)      last day (4540 days later) »