Re: [PHP] read smb drive

2010-11-05 Thread Alexander Holodny
Small and maybe useless note about privileges required to exec 'mount'
command via php's system():
root is not required if 'user' option exists in /etc/fstab.
It is true because mount cmd has always root privileges due to suexec
bit and it decides whether calling user is authorized to mount
something or not.

2010/11/5, Steve Staples sstap...@mnsi.net:
 Hey guys (and gals)

 I am writing something that needs to connect to a SMB server... can this
 be done easliy?

 I copied a sample code from php.net that used the system() command and
 mounted the SMB to a /mnt/tmp partion, and technically, it works the
 problem is, is that mount has to be run as root...

 is there a way to put the mount/unmount commands into an allowed
 command?   i supposed, the other problem is, is waht if this is on a
 windows machine?

 i dont really want to mess with permissions too much, since this will
 have to be portable from linux to windows...   any help would be
 appreciated...

 Steve


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



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



Re: [PHP] PHP sessions - users being automatically logged out

2010-11-04 Thread Alexander Holodny
Inc session.cache_expire. You have only 3 minutes.
This means browser will drop cookie containing session id in three
minutes, or even less, of clients inactivity.
I prefer to set expire-time to zero. So, browser will never forget session id.
In other case, if security requires, i usually set it to 24 hours, to
avoid some mystic problems, in case of misconfigured servers and/or
clients TZ; they are rare.

2010/11/4, Paul Waring p...@xk7.net:
 I'm having trouble with a PHP site whereby some users are being logged
 out on a regular basis. This will usually happen after they have been
 using the site for a few minutes, they can login without any problems
 and access a few pages, but then suddenly they will request a page and
 be sent to the login form, which suggests that their session no longer
 exists. However, this doesn't affect all users - I can login and use the
 application without any problems, as can some other users.

 According to phpinfo(), the following session values are set (all are
 what I'd expect - either the default or something I've deliberately
 changed):

 session.auto_start = Off
 session.bug_compat_42 = On
 session.bug_compat_warn = On
 session.cache_expire = 180
 session.cache_limiter = nocache
 session.cookie_domain = no value
 session.cookie_httponly = Off
 session.cookie_lifetime = 0
 session.cookie_path = /
 session.cookie_secure = Off
 session.entropy_file = no value
 session.entropy_length = 0
 session.gc_divisor = 100
 session.gc_maxlifetime = 1440
 session.gc_probability = 1
 session.hash_bits_per_character = 4
 session.hash_function = 0
 session.name = PHPSESSID
 session.referer_check = no value
 session.save_handler = files
 session.save_path = /shared/sessions
 session.serialize_handler = php
 session.use_cookies = On
 session.use_only_cookies = Off
 session.use_trans_sid = 0

 I've tried checking a few obvious things:

 * IP addresses - the site doesn't use the IP address as part of the
 authentication process, and almost all our users (including the ones
 experiencing problems) have static IP addresses anyway.

 * Number of sessions - there are between 40-60 session files on disk at
 any one time, so I doubt there's a maximum number of session files
 limit being broken, if such a configuration option exists.

 * Permissions - the web server user (www-data) has read/write
 permissions to the directory where the sessions are stored and all the
 files within it, and they are all owned by this user.

 Is there anything else obvious which could be causing the problem? This
 seemed to occur when we moved hosts, and I haven't changed the site's
 session handling code for some time, so I suspect it might be a
 configuration issue but can't figure out what.

 Thanks,

 Paul

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



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



Re: [PHP] Problems converting strings with 0 to integer

2010-11-03 Thread Alexander Holodny
To exclude unexcepted behavior in case of wrongly formated input data,
it would be much better to use such type-casting method:
intval(ltrim(trim($inStr), '0'))

2010/11/3, Nicholas Kell n...@monkeyknight.com:

 On Nov 3, 2010, at 4:22 PM, robert mena wrote:

 Hi,

 I have a text file (utf-8 encoded) which contains lines with numbers and
 text separated by \t.  I need to convert the numbers that contains 0 (at
 left) to integers.

 For some reason one line that contains 0002 is casted to 0 instead of
 2.
 Bellow the output of the cast (int) $field[0]  where I get this from
 explode each line.

 0 0002
 4 0004



 My first guess is wondering how you are grabbing the strings from the file.
 Seems to me like it would just drop the zeros on the left by default. Are
 you including the \t in the string by accident? If so, that may be hosing
 it. Otherwise, have you tried ltrim on it?

 Ex:

 $_castableString = ltrim($_yourString, '0');

 // Now cast



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



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