« first day (338 days earlier)      last day (4834 days later) » 

14:00
I have no idea. You didn't post code. You didn't post errors that you're seeing. You didn't provide anything that could be useful in answering that question...
(sorry to sound harsh, but trying to show some methods to get better answers)
can someone please tell me how to prevent users from visiting my sites from url/bookmark?
@hussain Well, imagine bookmark as button which inserts URL to URL bar and presses Enter.
someone please...
:P
14:03
@hussain why?
i need in my company's project so that no one visits crucial transaction pages directly
or any pages at all
eih
There's no really good and clean method of doing that
you could create a random token for the page name, and store that in the session and use that for the url.
and then check the URL in the session if it exists.
but that won't work in all cases
and it will cause major issues in a lot of places
i have not put the token in the url although i have it in session because of the problems it may cause in the url....and i validate it on every page...works fine for the first time....not for the later attempts though
i dont see any clean method either...
it seems to work fine when the user first comes to the site
@ircmaxell so no better ideas i guess?
You can't do it with 100%. Besides, URLs are supposed to be Uniform Resource Locators. They are designed to be consistent and meaningful
I'd solve it by process instead of by code
how would u do it by process?
14:14
Tell users not to go there directly. And for any "action" pages, make them the result of a POST operation with a CSRF token...
the project im on has 80,000 scripts .... altering action pages might take ages mate...
Hi guys this is a correct blowfish encryption right?
crypt('MyString!', '$2a$07$useSomeWeirdStringtoDoSo$');
srry hash:P
@DownDown Yes, but that weird string should be random
@ircmaxell Like putting a rand(1,100) function?
the alphabet is abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./, so you could do this function:
function generateSalt($length = 22) {
    $seed = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./';
    $result = '';
    $seedLength = strlen($seed);
    for ($i = 0; $i < $length; $i++) {
        $result .= $seed[mt_rand(0, $seedLength - 1)];
    }
    return $result;
}
14:22
@ircmaxell any ideas on how to submit form variables when we move from one page to another .... without the action attribute ?
or let's just say POST the variables in hidden fields but without <form> tag
you can't, unless you're using ajax
@ircmaxell Tnx mate!
so if i want to submit something in $_POST without using a form .... it means i cant move the values in POST from one page to other .... is there no other way... apart from putting them in the url too...
that means im doomed....thanx anyways man...:)
14:29
I feel like I've been trolled. I joined in that __construct parameter thread on the internals list
@ircmaxell well, that's kinda like hitting yourself on the head with a hammer and complaining that it hurts, isnt it?
@ircmaxell does that have any advantage over base64_encode(md5(..., true))?
@ircmaxell Could this be the output with blowfish of a hello string : $2r72.dSSP8m. ?
@DownDown that the full output?
@ircmaxell any ideas how to get the unmasked IP of a visitor ? one behind the proxy?
14:32
yes
@KamilTomšík Well, first, base64 uses the wrong alphabet. As long as you have a good source of entropy as the input to md5(), that's not an issue. So you'd need to do something like: strtr(base64_encode(md5($data, true)), '+=', './');
@DownDown how?
@hussain You can't do that reliably
@DownDown What? That's the full output? You didn't trim anything?
this how i do this:
echo crypt('Hallo', '$2a$' . $blowfish . '$' );
@ircmaxell i want results upto say 50%
14:33
The X-Forwarded-For (XFF) HTTP header field is a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. This is a non-RFC-standard request field which was introduced by the Squid caching proxy server's developers. In this context, the caching servers are most often those of large ISPs who either encourage or force their users to use proxy servers for access to the World Wide Web, something which is often done to reduce external bandwidth through caching. In some cases, these proxy servers are transpare...
$blowfish is generatesalt()
you need the cost parameter ($10$)
@ircmaxell that's what I've meant, I was curious about that explicit naming whole alphabet when it's not necessary. (md5 was just example, pbkdf2 + strtr + substr could be almost that)
@Gordon any ideas how to use it?
This is wrong?
crypt('Hallo', '$2a$' . generateSalt() . '$' );
14:35
> php -r "var_dump(crypt('mypassword', '$2a$10$abcdefghijklmnopqrstuv'));"
string(60) "$2a$10$abcdefghijklmnopqrstuuuhWuG4XbVNUBh6FqdXhCtWV.8yGYjpG"
@KamilTomšík right. I like to be obvious.
@hussain you read it with $_SERVER['X-Forwareded-For'] but like @ircmaxell says, you cannot reliably determine that. The field might not be set or have another name.
or could be faked by an attacker
@Gordon: Check out my reply on internals: marc.info/?l=php-internals&m=131644297315311&w=2
then how does the IP tracking websites shows our exact IP? i mean what do they use?
I think I was trolled
@ircmaxell why? Who trolled you? And again: why do you join an internals discussion. It's madness
14:38
@ircmaxell I wondered when you would join in that discussion ;)
And hi :)
@ircmaxell huh? as far as I know, circle-ellipse is about roles (dynamic mixins), rather than types... that's my $0.02...
anybody who knows about paypal recurring payment???
@Tarun contact PayPal
@gordan you are here for???
Hum, why doesn't \-1 work in pcre?
14:42
@Tarun This chat has autocomplete. How did you mispell my name?
@Tarun And this is not a support channel, if that's what you mean by "you are here for"
Ah, got it, you need to write \g{-1}
@Gordon if you cant help or even get into a healthy discussion there is a casual chat room too for you.
@Tarun come on mate just contact the PayPal ... it's well explained there ... and well-documented as well
@Tarun again: this is not a support channel for PayPal. It's not even a support channel for PHP. It's just a chat where people may talk about PHP related things.
PayPal Recurring Payments : google.com.pk/…
it all starts there
:)
14:45
@Gordon this is what people who talk much and listen less fell into...
@Gordon i was about to ask paypal recurring payment api in php for unsubscribing a member..
@hussain thanks
@ircmaxell Whats the best way to store a blowfish hash into mysql database?
@Tarun which is still a PayPal support question and we dont do PayPal support here.
so the best advice apart from getting linked to their Manual is to contact them
@Tarun thanx to Google mate :) i came here with three issues and havnt got a satisfactory answer for even 1...buit it does not mean the end of the world...eveyone tries his best ...
@Gordon ok got it, what are you here for.... thanks mate.... enjoy ur party..
14:51
@Tarun any script to get the real IP of a visitor?
@Tarun are you from India by any chance?
@Gordon apparently, yes :-P
@KamilTomšík yeah, I really had a deja vu here.
@Gordon whats wrong if he's from anywhere around the world? He's here asking for help...
and what makes u say he's from india?
@hussain there is nothing wrong with that.
14:58
@Gordon can't we just concentrate on helping people out here...a bit more nicely...?
@hussain nothing wrong, just india asking-pattern :)
@hussain I did help him. I told him to contact PayPal.
@Kamil do you notice any 'asking-pattern' suggesting i'm from Pakistan?
lol
@KamilTomšík No, it's about LSP
@DownDown as a string
@ircmaxell sorry for crashing your discussion
15:04
$this->$someMethod(...)
hmm, I think I'm being really dumb here
in fact I will delete that question before anyone else reads it
lol
:1500375 u already know the method name...its simple...
yeah I know, I just noticed I had a typo that I have been trying to figure out for ages
@Greg It's better to ask than just write eval('$this->' . $methodName) and let it be ;)
15:05
it just takes a question here to make me realise that I've got a typo :D
@Gordon What discussion?
its ok .... everyone make dumb mistakes :)
@ircmaxell about internals
You hijacked it?
@ircmaxell lol, no. I mean in here.
15:12
eih, no problem. I had people come to my desk anyway
@ircmaxell if it's immutable, than maybe, if it's mutable, then it's about roles...
15:27
@KamilTomšík No, it's always a violation of LSP. It's not a solvable problem with inheritance
I haven't said a word about inheritance :)
I did
that was the point. It's definitively a solvable problem. Just not using inheritance...
@ircmaxell in that case, yes - but inheritance is contra-productive anyway.
normally, I agree. There are some cases where inheritance is acceptable (and even good), but normally it's not great. I agree (which is what I wrote at the end of my reply)
yeah, sorry for that was too long for me :-P
15:42
no problem
15:52
hi all! How to upload image to server and show that image in Html Form? I'm trying with Valums File Upload plugin but dont know how to customize it's response...
16:09
Hi All, I am not able to understand how the array are getting their index inthis code
$a=array("1"=>"A",1=>"B","C",2=>"D");
echo '<pre>';print_r($a);
echo count($a);
as per my understanding the array sud be ("!"=>"A",1=>B,0=>"C",2=>"D")
but it prints Array
(
[1] => B
[2] => D
)
@user269867 "1" == 1 in PHP. So the second overwrites the first.
then why C is not coming?
And then the third (the one without an index) is the biggest numerical index (1) plus 1 = 2
And 2 ist overwritten by D then ;)
I am sorry :(
why 1+1?
it's index of array
because the biggest numerical index is 1. And then it takes the one after it, that's 2 ;)
16:12
I am not even doing any manipulation or +/- on index values
ah
my bad
I read somewhere that if index to some var is not there then it will start with 0
Normally yes. But as you already have a numeric index here, it'll start right after it ;)
> "1" == 1 in PHP
Another proof php sucks
got it NikiC :)...gud one
:(
just to verify further i modified array to $a=array("p"=>"A",'c'=>"B","C",2=>"D");
output is
Array
(
[p] => A
[c] => B
[0] => C
[2] => D
)
isn't C must be index with 3?
as there is an element with numerical index....
okie got it
if i define C after D
it takes index 3
and if C is before D it's start the index with 0
wo!!
16:22
yep
thanks niki
one more question related to overiding of methods - can we override protected methods in child class?
yes
here is code which i am trying to understand
Fatal error: Call to protected method mya::dosm() from context '' in C:\wamp\www\testfile.php ..
echo mya::threed(); replace to $this->threed()
@user269867 Hard to say where the problem lies. Maybe you have called non static methods as static or static as non static or alike?
threed is a public function in base class
so if i call it with $this->threed()
16:47
What the heck is a threed?
@Robik Actually, that makes perfect sense
Yeah
My bad
"1" === 1 should be false
and it is
I wish I could delete that message.
17:02
@Robik But you can't. We will remember that for all times :P
That's the problem
Noooo!
48 mins ago, by Robik
> "1" == 1 in PHP
muahahahaha
Changes nick and avatar
:P
threed is a function defined in a base class........my code is not visible now....
oops
here is the code
abstract class base{
abstract protected function dosm();
function threed(){
echo ',,,';
}
}
class mya extends base
{
protected function dosm(){
echo $this->threed();
}
}
$a=new mya();
$a->dosm();
this code throws fatal error
Which one?
17:10
hello everyone
I am here for first time..
welcome
Fatal error: Call to protected method mya::dosm() from context
@user269867 because dosm is protected
@ircmaxell @Robik can anyone suggest good site having tutorials for php?
okie so when i call protected function from external it throws fatal erro...
17:13
@patelrohn no
@user269867 yes
If you want to call it outside, make it public
thanks ircmaxell
@ircmaxell @Robik : I have to develop a matrimonial website having payment option via credit / debit card..So can you people suggest me how do I implement it??Any special framework needed?? And make it secure ???
do you know how to program?
@ircmaxell :ya I developed basic php website in final year BE computer in mini project
very simple on..Basic login,session,playlist of songs and play in media player
like that
17:16
that doesn't answer the question, but whatever.
Really, if you need to ask those questions, you're not going to be able to build it well or make it secure. It's something that takes a lot of time and effort and learning to achieve. It's not something that you can learn in even a year, yet alone a few days... I wish you the best of luck, but I can't really help you. Sorry for the
@ircmaxell : sorry?? I am aware of basic things of php..And I work on iOS developement
writing an application != knowing how to program
@ircmaxel: I know how to program.!!
Ok, that answers that question then...
I really don't mean for this to be coming off as bad or as insulting as it's coming off
i just asked because some experienced may guide me to right direction and give some good tips from their experience..
@ircmaxell: no problem,,I will develope it by myself without anyone's help..Dont care if it takes a year..Bye thanks for your time..
17:26
dam. That really didn't come off correctly...
now I really do feel bad
@ircmaxell: Dont worry..
17:41
@ircmaxell :D
how can I allow my users to submit anything but a script file like a .php file...An excel file and image screen shot are all they would usually submit in a form...
I have the following code that works to allow them to upload if they upload an image only
@getimagesize($_FILES[$fieldname]['tmp_name'])
    or error('only image uploads are allowed', $uploadForm);
but what if i want to allow them to upload excel files
18:01
10
A: PHP how can i check if a file is mp3 or image file?

GordonNative way to get the mimetype: For PHP < 5.3 use mime_content_type() For PHP > 5.3 use finfo_fopen() Alternatives to get the MimeType are exif_imagetype and getimagesize, but these rely on having the appropriate libs installed. In addition, they will likely just return image mimetypes, inst...

Multipurpose Internet Mail Extensions (MIME) is an Internet standard that extends the format of email to support: * Text in character sets other than ASCII * Non-text attachments * Message bodies with multiple parts * Header information in non-ASCII character sets MIME's use, however, has grown beyond describing the content of email to describe content type in general, including for the web (see Internet media type) and as a storage for rich content in some commercial products (e.g., IBM Lotus Domino and IBM Lotus Quickr). Virtually all human-written Internet email and a fairly large pr...
@Gordon Note, that won't always work...
since mime types are notoriously hard to detect (both securely and accurately)
@ircmaxell Would you mind to answer my first-diffed-char question again on SO?
@ircmaxell well, these four functions are what's available in PHP. If that's not good enough, feel free to provide the OP a way that reads the headers of the files more reliably.
God my head hurts today...
hii..can anybdy help me to solve my problem???
18:10
> Discussion for all things PHP - Don't ask whether someone is here or can help. Just ask us.
:)
Feel free to ask.
i have hosted my site in a free domain...
it was working fine for 5 months but recently since 7 days some sort of problems i'm facing wid my site
i.e. no. of comments are automatically getting posted...
then i have used captcha in that comments post page still the same problem...
@ircmaxell You there?
@Robik:wat m8 b d problem???
Huh?
Yo
@NikiC link?
18:17
"Hey doctor, I need your help. Yeah, I've been feeling fine, but in the last week I'm feeling sick. I wouldn't possibly need to give you the symptoms in order for you to diagnose, right?"
@Gordon That's the best way, so I'm not going to answer it (since I can't better), but it's worth noting that those mime functions are not reliable...
answering @NikiC
@ircmaxell: I hope that you aren't writing an explanation why it works - you'd be losing all the nice votes you could get for that ;)
Posted
Yeah, I did write an explanation
:-D
18 hours ago, by ircmaxell
There's a saying: If you're in IT, you're either crazy, or new...
I told that joke during an interview... Half way through I realized what I was doing, but by that point it was too late and I was committed... Got the job, so couldn't have been too bad.
@ircmaxell Thanks :)
18:28
No problem :-D
Great answer +1.
Woah, +6 already!
Who's a ringer? (@ircmaxell answer comment)
:-D
I love that comment
woah, +95 rep from that one answer! Awesome!
Congratz
18:40
@ircmaxell If you had answered in 30 seconds with just $offset = strspn($str1 ^ $str2, "\0") you would have gotton something like +20 (:P)
Can anyone give me an example of a grammar that you can not parse with regex (regex = PCRE)?
I wonder if you can write a regex to parse other regular expressions...
It'd be a monster
@Zirak Sure you can
Need some help with parse_str in relation to this question stackoverflow.com/questions/7475344/…
@NikiC Link or it didn't happen
PCRE probably has a context-free grammar and that's very easy to match with PCRE.
18:45
Col. Shrapnel's answer to be specific
In the file I'm including I have $params = parse_str($_GET['params']); var_dump($params); but it's returning null
@Zirak I don't have a link. Just following it from the fact that you can match context-free and context-sensitive grammars using PCRE ;)
E.g. you can match HTML. And HTML is by no means easier than PCRE ;)
Echoing out $_GET['params'] yields 'site_id=3'
@stevether have a read of php.net/parse_str
Ninja'd :(
what yall think the best method to get: 20110919T08:11:01 able to function with strtotime()? explode on T and re-work the date or what?
18:49
@NikiC lol
0
A: Tetris'ing an array

ircmaxellWell, considering that you can use XOR in this situation to find the common parts of the string. Any time you xor two bytes that are the same, you get a nullbyte as the output. So we can use that to our advantage: $first = $array[0]; $length = strlen($first); $count = count($array); for ($i = ...

@Justin use DateTime::createFromFormat()
@salathe somehow missed the second arg, thanks
@ircmaxell i already know how to check if its an image. I made a working example, only thing left is I want to allow users to upload excel sheets too...
@ircmaxell I just wondered whether to answer that question myself using the XOR solution :D
It's really a nice trick you found
@NikiC :-P
@Justin strtotime() can already read that format
18:52
Sad thing about XORing string is that what language does not support XORing strings you have to loop anyway.
:(
@Robik There aren't such languages (practically)
@NikiC Thanks! I am quite proud of it. Especially since it works in all cases, since the xor output will be the shorter of the two strings, so even if there's a null byte at the first new character in the longer one, it'll still be correct
@salathe that I didn't know. Thanks -- saves me from having to manipulate it.
@NikiC Thanks! I am quite proud of it. Especially since it works in all cases, since the xor output will be the shorter of the two strings, so even if there's a null byte at the first new character in the longer one, it'll still be correct
@Robik Show me one that doesn't provide a bitwise xor... And I'll show you one that's missing a lot of basic functionality
@Justin See "XMLRPC" format on php.net/datetime.formats.compound
18:55
XOR on strings
@salathe I prefer JSONRPC
@ircmaxell I prefer apple pie.
+11 already
/me tosses a wet trout at @salathe
11
A: Find first character that is different between two strings

ircmaxellWell, you can use a nice property of XOR to achieve this. Basically, when you xor two strings together, the characters that are the same will become null bytes (chr(0)). So if we xor the two strings, we just need to find the position of the first non-null byte and there you have it: $temp = $s...

18:57
:-D
up to 155 rep for today :-D
for writing 2 answers
sadly, that Tetris one will never get much rep, since it won't get much visibility due to its age and number of answers
Boo, who downvoted me :-(
@ircmaxell wasn't me…
get everyone :)
hey*
clearly been coding too much -.-
still stuck on this damned carousel.
anyone here? I got a quick question :)
Im trying to use this : <?php
include "storescripts/connect_to_mysql.php";

$sql = mysql_query("SELECT id FROM products ORDER BY date_added DESC LIMIT 6");
$row = mysql_fetch_row($sql);
?>
to populate an unordered list but it isn't going according to plan
19:29
$sql = mysql_query("SELECT id FROM products ORDER BY date_added DESC LIMIT 6");

$row = mysql_fetch_assoc($sql);

foreach ($row) {
then echo out the list items or whatever.. and there ya go
uhhhhh
ok
but this is for images to be inserted into an unordered list
foreach ($row as $r) {
echo "<li><img src=".$r['id']."></li>";
}

could be a sample of your things..
hmm
if you don't need to echo it, append each one to a string and go from there
19:32
thats really awesome
how do i append it to a string?
like
$list = '';

$sql = mysql_query("SELECT id FROM products ORDER By date_added DESC LIMIT 6");
$row = mysql_fetch_assoc($sql);

foreach ($row as $r) {
$list .= "<li><img src='".$r['id']."'></li>";
}
foreach ($row as $r){
$string = "{<li><img src=".$r['id']."></li>} , {<li><img src=".$r['id']."></li>} , etc.";
}
oh
and then in the html
and then in the html, you just echo $list
put <ul> <?php echo $list; ?> </ul> ?
yep
19:35
awesome
you are my new best friend
thank you, let me try it :)
:/ the image is broken...
The id itself doesn't suffice...you need the full path besides the image id.
oh i see it in the source
yeah
yeah.. something like $list .= "<li><img src='/images/".$r['id'].".jpg'></li>"; would be the correct way to write it
of course changing /images/ to whatever your path is, and changing .jpg to whatever your image filetype is
ok
it's only showing one image though :/
instead of a list of images.
do you have .= or =
.= adds onto it whatever is there.. = overwrites it
19:42
?php
include "storescripts/connect_to_mysql.php";

$list = '';

$sql = mysql_query("SELECT id FROM products ORDER By date_added DESC LIMIT 6");
$row = mysql_fetch_assoc($sql);

foreach ($row as $r) {
$list .= "<li><img src='inventory_images/".$r['id'].".jpg'></li>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php*
okay before the foreach go: echo "<pre>";
print_r($row);
echo "</pre>"; and see what ouputs to the browser
The foreach loop only executes once, since you never update $row
Array
(
[id] => 4
)
yeah
i can tell by the array :/
foreach ($row as $r) {
    blah blah blah
    $row = get_next_row();
}
I'll let you figure out what get_next_row is yourself
Actually, that won't be completely correct...a better thing would be a `while` loop:
    while ($row = get_next_row()) {
        blah blah blah
    }
Since in the foreach, it iterates over the result row...
so a while loop in the foreach loop?
as in
19:46
no no no
the foreach should reiterate every for every one.. but see the query itself is only getting 1
so its not the foreach, its the query thats only obtaining 1 item
but if i am using SELECT * in my query
why would it only get 1
get_next_row returns a matched database row. You want to iterate over all the matched rows.
So, in a loop, you get each row, one at a time, until they are no more.
Well you're not using select * by try changing it to $sql = mysql_query ("SELEECT id FROM products LIMIT 6");

and see if 6 products display...
so i want to select all ids with the query
oh yeah
this is what i am using now
ok
changing it to SELECT * gave me all the info for that one image
not the other images
19:50
SELECT something doesn't change how many rows you get...it changes which fields you get. The WHERE or LIMIT clause is what chooses how (explicitly or implicitly) many rows you select
oh wait Zirak is right... so change your foreach to a while like he said.. so it would be...

while($row = get_next_row()) {
$list .= ....
}
well with LIMIT 6 it is saying <6
I remember having to create a function for mine -- but im not at home so I can't get you my function.
Server error
The website encountered an error while retrieving http://sunnahmatch.com/test.php. It may be down for maintenance or configured incorrectly.
fml.
19:54
while ($r = mysql_fetch_assoc($sql)) {
$list .= ...
}
see if that does anything....
i put $result not $sql
no
it still says it is offline
but the thing is locally it is 1200 bytes
remotely it is 628
okay
@Justin your way worked, but it is still only showing 1 image, but at least the page is opening now :P

« first day (338 days earlier)      last day (4834 days later) »