php-general Digest 17 Oct 2007 22:26:52 -0000 Issue 5077
Topics (messages 263254 through 263272):
Re: php gallery for pictures and videos
263254 by: Colin Guthrie
263271 by: Jim Lucas
How to replace define in a require file with mysql?
263255 by: Ronald Wiplinger
263256 by: Ronald Wiplinger
263261 by: Richard Heyes
263269 by: Jim Lucas
Sessions - Ini settings and timeout
263257 by: Holografix
263259 by: Zoltán Németh
263266 by: Holografix
263272 by: Casey
Array problem
263258 by: Merlin
263260 by: Zoltán Németh
263263 by: Ford, Mike
Re: Which PHP-Editor to use?
263262 by: Jason Pruim
Security Question
263264 by: Andrew Peterson
263265 by: Richard Heyes
263270 by: Jim Lucas
Why $_REQUEST do the same thing as mysql_escape_string()
263267 by: truncatei.gmail.com
263268 by: Eric Butera
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
zakaria ghandour wrote:
> i must create gallery (pictures and videos) in php
> The user must login to see only his personal files.
> There is any tool doing this.
Yes.
Google: "php photo gallery" the very first link:
http://gallery.menalto.com/
It's very good and has lots of features and as an added bonus is easy to
embed inside other PHP applications (e.g. CMSs like Joomla, Drupal etc.)
Col
--- End Message ---
--- Begin Message ---
zakaria ghandour wrote:
Hi,
i must create gallery (pictures and videos) in php
The user must login to see only his personal files.
There is any tool doing this.
thanks
the answer you seek is in the words of your question
google: php gallery
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
I have a file linked with require into my program with statements like:
define("_ADDRESS","Address");
define("_CITY","City");
I would like to replace this with a mysql table with these two fields
(out of many other fields).
How can I do that?
bye
Ronald
--- End Message ---
--- Begin Message ---
I have a file linked with require into my program with statements like:
define("_ADDRESS","Address");
define("_CITY","City");
I would like to replace this with a mysql table with these two fields
(out of many other fields).
How can I do that?
bye
Ronald
--- End Message ---
--- Begin Message ---
I have a file linked with require into my program with statements like:
define("_ADDRESS","Address");
define("_CITY","City");
I would like to replace this with a mysql table with these two fields
(out of many other fields).
How can I do that?
I'm not aware of any method of "undefining" an already defined constant.
Except changing the line in your required file...
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---
--- Begin Message ---
Ronald Wiplinger wrote:
I have a file linked with require into my program with statements like:
define("_ADDRESS","Address");
define("_CITY","City");
I would like to replace this with a mysql table with these two fields
(out of many other fields).
How can I do that?
bye
Ronald
Well, if you have all the settings in a DB already, then what I would do is
this.
SELECT param_name, param_value FROM yourTable;
then
while ( list($name, $value) = mysql_fetch_row($results_handler) ) {
define($name, $value);
}
put this in place of your existing defines and you should be good.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
I have some questions about sessions timeout and sessions ini settings.
In php.ini I have session.gc_maxlifetime = 30 (for testing purpose only) ,
session.gc_probability = 1 and session.gc_divisor = 100 (didn't touch this
values)
I have two simple pages
page1.php
---------
session_start();
$_SESSION["test"] = "TEST";
<a href="page2.php">test timeout</a>
page2.php
=========
session_start();
if (!isset($_SESSION["test"]) ) {
echo "no session"; die();
}
print_r($_SESSION);
I open page1.php in the browser and only click in the link after waiting
more than 30 seconds (session.gc_maxlifetime).
After this period what should happen with $_SESSION["test"] in page2.php?
In php, session.gc_maxlifetime: ; After this number of seconds, stored data
will be seen as 'garbage' and
; cleaned up by the garbage collection process.
I need to understand this and get a way to automaticly logout a user after n
minutes of inactivity.
My environment:
Windows XP PRO SP2, apache 2.2.4, php 5.2.4 (apache module), mysql 5.4.5
Best regards
holo
--- End Message ---
--- Begin Message ---
2007. 10. 17, szerda keltezéssel 11.58-kor Holografix ezt írta:
> I have some questions about sessions timeout and sessions ini settings.
>
> In php.ini I have session.gc_maxlifetime = 30 (for testing purpose only) ,
> session.gc_probability = 1 and session.gc_divisor = 100 (didn't touch this
> values)
>
> I have two simple pages
>
>
> page1.php
> ---------
> session_start();
> $_SESSION["test"] = "TEST";
> <a href="page2.php">test timeout</a>
>
>
> page2.php
> =========
> session_start();
> if (!isset($_SESSION["test"]) ) {
> echo "no session"; die();
> }
> print_r($_SESSION);
>
>
> I open page1.php in the browser and only click in the link after waiting
> more than 30 seconds (session.gc_maxlifetime).
> After this period what should happen with $_SESSION["test"] in page2.php?
>
> In php, session.gc_maxlifetime: ; After this number of seconds, stored data
> will be seen as 'garbage' and
> ; cleaned up by the garbage collection process.
>
> I need to understand this and get a way to automaticly logout a user after n
> minutes of inactivity.
session.gc_maxlifetime is not what you are looking for. it works like at
every request there is a 1/100 chance
(session.gc_probability/session.gc_divisor) that the garbage collector
will run. if it runs, and finds session data older than
session.gc_maxlifetime, that is cleaned up.
in order to achieve what you want you should store a 'last action'
timestamp or something like that in the session, and upon each request
check how many seconds passed since that timestamp and decide session
validity based on that. eg:
session_start();
if ($_SESSION['last_action_timestamp'] - time() > $max_lifetime)
{
// session expired
}
else
{
$_SESSION['last_action_timestamp'] = time();
}
greets
Zoltán Németh
>
> My environment:
> Windows XP PRO SP2, apache 2.2.4, php 5.2.4 (apache module), mysql 5.4.5
>
>
> Best regards
> holo
>
--- End Message ---
--- Begin Message ---
Many thanks Zoltán.
It's clear now
One more thing: session.cookie_lifetime defaults to 0 (until browser is
closed).
if setting session.cookie_lifetime to 60 can I look for
$_SESSION[session_name()] in every request ?
best regards
holo
""Zoltán Németh"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 2007. 10. 17, szerda keltezéssel 11.58-kor Holografix ezt írta:
>> I have some questions about sessions timeout and sessions ini settings.
>>
>> In php.ini I have session.gc_maxlifetime = 30 (for testing purpose only)
>> ,
>> session.gc_probability = 1 and session.gc_divisor = 100 (didn't touch
>> this
>> values)
>>
>> I have two simple pages
>>
>>
>> page1.php
>> ---------
>> session_start();
>> $_SESSION["test"] = "TEST";
>> <a href="page2.php">test timeout</a>
>>
>>
>> page2.php
>> =========
>> session_start();
>> if (!isset($_SESSION["test"]) ) {
>> echo "no session"; die();
>> }
>> print_r($_SESSION);
>>
>>
>> I open page1.php in the browser and only click in the link after waiting
>> more than 30 seconds (session.gc_maxlifetime).
>> After this period what should happen with $_SESSION["test"] in page2.php?
>>
>> In php, session.gc_maxlifetime: ; After this number of seconds, stored
>> data
>> will be seen as 'garbage' and
>> ; cleaned up by the garbage collection process.
>>
>> I need to understand this and get a way to automaticly logout a user
>> after n
>> minutes of inactivity.
>
> session.gc_maxlifetime is not what you are looking for. it works like at
> every request there is a 1/100 chance
> (session.gc_probability/session.gc_divisor) that the garbage collector
> will run. if it runs, and finds session data older than
> session.gc_maxlifetime, that is cleaned up.
>
> in order to achieve what you want you should store a 'last action'
> timestamp or something like that in the session, and upon each request
> check how many seconds passed since that timestamp and decide session
> validity based on that. eg:
>
> session_start();
> if ($_SESSION['last_action_timestamp'] - time() > $max_lifetime)
> {
> // session expired
> }
> else
> {
> $_SESSION['last_action_timestamp'] = time();
> }
>
> greets
> Zoltán Németh
>
>>
>> My environment:
>> Windows XP PRO SP2, apache 2.2.4, php 5.2.4 (apache module), mysql 5.4.5
>>
>>
>> Best regards
>> holo
>>
--- End Message ---
--- Begin Message ---
You could set $_SESSION['lasttime'] to time() and check it on every
page.
On Oct 17, 2007, at 3:58 AM, "Holografix" <[EMAIL PROTECTED]> wrote:
I have some questions about sessions timeout and sessions ini
settings.
In php.ini I have session.gc_maxlifetime = 30 (for testing purpose
only) ,
session.gc_probability = 1 and session.gc_divisor = 100 (didn't
touch this
values)
I have two simple pages
page1.php
---------
session_start();
$_SESSION["test"] = "TEST";
<a href="page2.php">test timeout</a>
page2.php
=========
session_start();
if (!isset($_SESSION["test"]) ) {
echo "no session"; die();
}
print_r($_SESSION);
I open page1.php in the browser and only click in the link after
waiting
more than 30 seconds (session.gc_maxlifetime).
After this period what should happen with $_SESSION["test"] in
page2.php?
In php, session.gc_maxlifetime: ; After this number of seconds,
stored data
will be seen as 'garbage' and
; cleaned up by the garbage collection process.
I need to understand this and get a way to automaticly logout a user
after n
minutes of inactivity.
My environment:
Windows XP PRO SP2, apache 2.2.4, php 5.2.4 (apache module), mysql
5.4.5
Best regards
holo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi there,
I am pulling picture ids out of a db and comment ids. The comments
belong to the pic ids and are stored in two seperate tables.
I am having trouble with the arrays to display them after pulling out of
the db.
The data is filled like this:
while (rows etc.){
$comment_id[$row->pic_id][] = $row->comment_id;
}
The goal is to cycle through that array and display the picture followed
by the belonging comments:
Picture ID 1
-Comment 1 to pic_id 1
-Comment 2 to pic_id 1
-Comment 3 to pic_id 1
Picture ID 2
-Comment 1 to pic_id 2
-Comment 2 to pic_id 2
That does sound easy, but unfortunatelly I could not figure it out so far.
Can somebody give me a hint on how to cycle throug the arrays, or an
alternative way to achive my goal?
Thank you for any help.
Best regards, Merlin
--- End Message ---
--- Begin Message ---
2007. 10. 17, szerda keltezéssel 13.08-kor Merlin ezt írta:
> Hi there,
>
> I am pulling picture ids out of a db and comment ids. The comments
> belong to the pic ids and are stored in two seperate tables.
> I am having trouble with the arrays to display them after pulling out of
> the db.
>
> The data is filled like this:
>
> while (rows etc.){
> $comment_id[$row->pic_id][] = $row->comment_id;
> }
>
> The goal is to cycle through that array and display the picture followed
> by the belonging comments:
>
> Picture ID 1
> -Comment 1 to pic_id 1
> -Comment 2 to pic_id 1
> -Comment 3 to pic_id 1
>
> Picture ID 2
> -Comment 1 to pic_id 2
> -Comment 2 to pic_id 2
>
> That does sound easy, but unfortunatelly I could not figure it out so far.
>
> Can somebody give me a hint on how to cycle throug the arrays, or an
> alternative way to achive my goal?
something like
$pic_ids = array_keys($comment_id);
foreach ($pic_ids as $pic_id) {
// echo image tag or what you want
foreach ($comment_id[$pic_id] as $comment) {
// echo comment or what you want
}
}
greets
Zoltán Németh
>
> Thank you for any help.
>
> Best regards, Merlin
>
--- End Message ---
--- Begin Message ---
On 17 October 2007 12:09, Merlin wrote:
> Hi there,
>
> I am pulling picture ids out of a db and comment ids. The comments
> belong to the pic ids and are stored in two seperate tables.
> I am having trouble with the arrays to display them after
> pulling out of
> the db.
>
> The data is filled like this:
>
> while (rows etc.){
> $comment_id[$row->pic_id][] = $row->comment_id;
> }
>
> The goal is to cycle through that array and display the
> picture followed
> by the belonging comments:
>
> Picture ID 1
> -Comment 1 to pic_id 1
> -Comment 2 to pic_id 1
> -Comment 3 to pic_id 1
>
> Picture ID 2
> -Comment 1 to pic_id 2
> -Comment 2 to pic_id 2
>
> That does sound easy, but unfortunatelly I could not figure
> it out so far.
>
> Can somebody give me a hint on how to cycle throug the arrays, or an
> alternative way to achive my goal?
Something like this should work:
foreach ($comment_id as $pic_id=>$comment_ids):
echo "Start of information for picture $pic_id";
foreach ($comment_ids as $com_id):
echo "Comment $com_id for picture $pic_id";
endforeach;
endforeach;
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730 Fax: +44 113 812 3211
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
--- End Message ---
--- Begin Message ---
On Oct 16, 2007, at 5:26 PM, Matt Livingston wrote:
That is why I believe in a "disposable system"
I have 2 main computers, one running XP and the other running
Ubuntu Linux.
I make regular backups to secure server online via FTP and
regularly burn
backups to CD. At any time if I got a virus that was by some
(small) chance
powerful enough to cause damage to my PC that could not easily be
cleaned up
- I would simply reformat the HD and reinstall the OS ;) (and that
process
of reformatting and reinstalling takes a mere 30 minutes to 2 hours
- latter
being the Windows and former being Ubuntu)
-Matt
Just another reason I'm glad I have a Mac :) No virus to worry about :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Does anyone know a good way to protect a directory that a php script NEEDS
to write too?
What I'm doing now:
1. create a directory manually "myDir"
2. chmod 777 myDir
3. password protect the directory with htaccess
Is this the best way, or is there something better?
Also, is there a way to mkdir or fopen a file dynamically, without
pre-creating a directory with 777 permissions?
Thanks for the help,
Andrew
--- End Message ---
--- Begin Message ---
Does anyone know a good way to protect a directory that a php script NEEDS
to write too?
What I'm doing now:
1. create a directory manually "myDir"
2. chmod 777 myDir
3. password protect the directory with htaccess
Is this the best way, or is there something better?
You could chmod the file/directory to 700 and change the owner to that
of the webserver (presumably the script is being run via the webserver).
This has the drawback that anything run from the webserver will have
write access to the files.
--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software
that can cut the cost of online support
--- End Message ---
--- Begin Message ---
Andrew Peterson wrote:
Does anyone know a good way to protect a directory that a php script NEEDS
to write too?
What I'm doing now:
1. create a directory manually "myDir"
2. chmod 777 myDir
3. password protect the directory with htaccess
Is this the best way, or is there something better?
Also, is there a way to mkdir or fopen a file dynamically, without
pre-creating a directory with 777 permissions?
Thanks for the help,
Andrew
Along with what Richard said, you could also move the directory outside of the webroot and not have
to worry about the .htaccess file. Nothing but PHP could access the directory contents, and only
through your interface could it be access.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Twelfth Night, Act II, Scene V
by William Shakespeare
--- End Message ---
--- Begin Message ---
I put some thing in an form input filed like this:
' " \
then submit to a php script.
When use $_GET / $_POST / $_REQUEST to get the value,
I always get:
\' \" \\
In php expression it should be:
$_REQUEST['field'] = "\\' \\\" \\\\";
Any one who can tell me why?
--- End Message ---
--- Begin Message ---
On 10/17/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I put some thing in an form input filed like this:
> ' " \
> then submit to a php script.
> When use $_GET / $_POST / $_REQUEST to get the value,
> I always get:
> \' \" \\
> In php expression it should be:
> $_REQUEST['field'] = "\\' \\\" \\\\";
>
> Any one who can tell me why?
>
magic_quotes_gpc
Also it doesn't necessarily do the same thing.
mysql_real_escape_string() takes into consideration character sets.
--- End Message ---