php-general Digest 7 Jul 2012 22:07:14 -0000 Issue 7879

2012-07-07 Thread php-general-digest-help

php-general Digest 7 Jul 2012 22:07:14 - Issue 7879

Topics (messages 318403 through 318408):

Re: Unexpected Notice message
318403 by: Andrew Ballard
318406 by: RGraph.net support
318407 by: Matijn Woudt

How to make a secure download ?
318404 by: donkfather.donkfather.eu
318405 by: Gibbs

[PHP-DEV] SQLite - Unwanted values using group-by
318408 by: Simon Schick

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On Thu, Jul 5, 2012 at 3:10 AM, Arno Kuhl a...@dotcontent.net wrote:
 -Original Message-
 From: Tim Streater [mailto:t...@clothears.org.uk]
 Sent: 04 July 2012 06:56 PM
 To: Marc Guay; php-gene...@lists.php.net
 Subject: Re: [PHP] Unexpected Notice message

 On 04 Jul 2012 at 16:51, Marc Guay marc.g...@gmail.com wrote:

 Notice: Use of undefined constant QUERY_STRING - assumed 'QUERY_STRING' in

 I would guess that it's asking you to add quotes around QUERY_STRING...?

 As in:
 if (strlen($_SERVER['QUERY_STRING'])  0) {


 Cheers  --  Tim
 

 Excellent, a bit surprised but that was it, thanks a lot.

 Cheers
 Arno

Why does this surprise you? $_SERVER is an array with string indices,
one of which happens to be the string 'QUERY_STRING'. However, your
code is trying to reference a constant named QUERY_STRING that does
not exist. The code will work because PHP will assume you meant to use
a string instead of a constant, but this will also generate a notice
to let you know that the code should be fixed.

Andrew
---End Message---
---BeginMessage---
Hi,

 that the code should be fixed.

Or the error reporting turned down... :-)

-- 
Richard, RGraph.net support
JavaScript charts for your website using RGraph
http://www.rgraph.net
---End Message---
---BeginMessage---
On Thu, Jul 5, 2012 at 6:54 PM, RGraph.net support supp...@rgraph.net wrote:
 Hi,

 that the code should be fixed.

 Or the error reporting turned down... :-)

And one day, you decide to write
define('QUERY_STRING', Oh I was so stupid that day);

and since you turned down your error reporting, you will have lots of fun!
---End Message---
---BeginMessage---

Hi,

I am trying to put a file to download. I want it secure so only the 
people having the password can access it.
I made a page that requires a password.. if the password is correct it 
changes the password send it on my mail and redirects
the user to another script. This script searches in the database for 
the id given with GET and finds the name of the file
which is md5(something). it changes the name of the file in md5(smth 
else). After that it searches in the download folder
 for a file named md5(smth else). if it finds the file it gives you the 
link to the file.
So i need to find a way to change the filename after the user downloads 
the file. to keep it secure so the user

wont be able to share the link to oters.

if you need more info ask :D
thanks
and sorry for my bad english .
---End Message---
---BeginMessage---

On 05/07/12 14:32, donkfat...@donkfather.eu wrote:

Hi,

I am trying to put a file to download. I want it secure so only the 
people having the password can access it.
I made a page that requires a password.. if the password is correct it 
changes the password send it on my mail and redirects
the user to another script. This script searches in the database for 
the id given with GET and finds the name of the file
which is md5(something). it changes the name of the file in md5(smth 
else). After that it searches in the download folder
 for a file named md5(smth else). if it finds the file it gives you 
the link to the file.
So i need to find a way to change the filename after the user 
downloads the file. to keep it secure so the user

wont be able to share the link to oters.

if you need more info ask :D
thanks
and sorry for my bad english .



Sounds like you are overcomplicating it. Following what you've already 
done though...


Have the original files stored somewhere outside of the web root. That 
way they aren't accessible whatsoever + you shouldn't have to change any 
of the files at any stage.


Then you can simply update/change the ID that associates with it in your 
database when that URL is hit...


Gibbs
---End Message---
---BeginMessage---
Hi, All

May you have an idea ...

Here's the full code-example:
http://viper-7.com/M5mldG

I have the following SQL command:

SELECT max(r.month+r.year*100), r.year, r.month
FROM base b LEFT JOIN remote r ON b.id = r.remote_id
GROUP BY r.remote_id

Now I expect that the first column in the results should look like a
combination of the second and third one .. so f.e. this:
array(3) { [max(r.month+r.year*100)]= string(6) 201201 [year]=
string(4) 2012 

[PHP] [PHP-DEV] SQLite - Unwanted values using group-by

2012-07-07 Thread Simon Schick
Hi, All

May you have an idea ...

Here's the full code-example:
http://viper-7.com/M5mldG

I have the following SQL command:

SELECT max(r.month+r.year*100), r.year, r.month
FROM base b LEFT JOIN remote r ON b.id = r.remote_id
GROUP BY r.remote_id

Now I expect that the first column in the results should look like a
combination of the second and third one .. so f.e. this:
array(3) { [max(r.month+r.year*100)]= string(6) 201201 [year]=
string(4) 2012 [month]= string(2) 01 }

But instead I get this result:
array(3) { [max(r.month+r.year*100)]= string(6) 201201 [year]=
string(4) 2011 [month]= string(2) 12 }

I tested it on Windows7 (PHP 5.4.4, SQLiteLib v3.7.7.1), where I get the
result as shown above ... and I've also tested it on a fresh installation
on LinuxArch (PHP 5.4.4 and SQLiteLib v3.7.13) - where it works as
expected! A college of mine has tested it on OSX (PHP 5.3.7 and SQLiteLib
v3.7.13) and he gets the same result as I on the windows version.
Someone of you have an idea?
Maybe had the same problem before ... what could it be?

I thought it might a problem of the SQLite-lib but both, the LinuxArch and
the OSX system, have the same SQLite version - and both, the windows and
the LinuxArch version, have the same PHP-version.

Even if the example just uses PDO, I've also tested this using the native
SQLite3 lib and I got at least the same result on Windows. Haven't tested
the other systems with the native SQLite3 lib.

Bye
Simon


Re: [PHP] [PHP-DEV] SQLite - Unwanted values using group-by

2012-07-07 Thread Matijn Woudt
On Sun, Jul 8, 2012 at 12:07 AM, Simon Schick simonsimc...@gmail.com wrote:
 Hi, All

 May you have an idea ...

 Here's the full code-example:
 http://viper-7.com/M5mldG

 I have the following SQL command:

 SELECT max(r.month+r.year*100), r.year, r.month
 FROM base b LEFT JOIN remote r ON b.id = r.remote_id
 GROUP BY r.remote_id

 Now I expect that the first column in the results should look like a
 combination of the second and third one .. so f.e. this:
 array(3) { [max(r.month+r.year*100)]= string(6) 201201 [year]=
 string(4) 2012 [month]= string(2) 01 }

 But instead I get this result:
 array(3) { [max(r.month+r.year*100)]= string(6) 201201 [year]=
 string(4) 2011 [month]= string(2) 12 }

Both of the results are valid outcomes. I think you don't understand
the GROUP BY clause well enough. The parameters in the SELECT clause,
should be either
1) an aggregate function (like the max function you're using)
2) one of the parameters in the GROUP BY clause.
If not one of the above, it will return 'random' values for r.month
and r.year. (probably the first it finds, which might differ in your
test cases)

- Matijn



- Matijn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php