php-general Digest 5 Nov 2010 23:41:46 -0000 Issue 7023

Topics (messages 309331 through 309352):

Re: How to code in PHP an onchange event in a <select>?
        309331 by: Tommy Pham
        309333 by: Tomás Corrales Lemoine
        309334 by: Jim Lucas
        309335 by: tedd

Re: Pros/Cons of using mysqli prepared statments
        309332 by: Richard Quadling

read smb drive
        309336 by: Steve Staples
        309337 by: Nathan Nobbe
        309338 by: Steve Staples
        309339 by: Nathan Nobbe
        309340 by: Ian
        309341 by: Nathan Nobbe
        309342 by: Richard Quadling
        309343 by: Richard Quadling
        309344 by: Nathan Nobbe
        309345 by: Alexandr
        309346 by: Nathan Nobbe
        309347 by: Steve Staples
        309348 by: Alexander Holodny
        309352 by: Tommy Pham

Shopping cart question
        309349 by: Jack
        309350 by: Nathan Nobbe
        309351 by: Jack

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


----------------------------------------------------------------------
--- Begin Message ---
> -----Original Message-----
> From: Paul Waring [mailto:p...@xk7.net]
> Sent: Friday, November 05, 2010 1:27 AM
> To: php-gene...@lists.php.net
> Subject: Re: [PHP] How to code in PHP an onchange event in a <select>?
> 
> On 04/11/10 20:23, Tomás Corrales Lemoine wrote:
> > I have this two files (“index.php” and “include.php”). They both work
> > fine, but I want to substitute the code for de onchange event in the
> > <select> tag. Can I use PHP to code this event? How?
> 
> xajax will allow you to call PHP code as if it was JavaScript:
> 
> http://www.xajax-project.org/
> 
> Paul
> 

It looks very promising except the demo is a bit slow for just changing ''
to '610'... maybe their server/connection is a bit slow?  It takes almost a
full second from button click to display on my 20mb up/down connection.

Regards,
Tommy


--- End Message ---
--- Begin Message ---
Hi, List,

 

Thanks everybody for your answers.

 


 
Aeropuerto Internacional Frank País García de Holguín.




--- End Message ---
--- Begin Message ---
On 11/4/2010 1:23 PM, Tomás Corrales Lemoine wrote:
> Hi, List,
> 
> I have this two files (“index.php” and “include.php”). They both work fine,
> but I want to substitute the code for de onchange event in the <select> tag.
> Can I use PHP to code this event? How?

Looks to me that you are looking for "chained select boxes".  Doing a G search
for that and the first result is this:

http://www.dhtmlgoodies.com/index.html?whichScript=ajax_chained_select

It has a very good example that shows the concept that you are trying to have
happen in your code below.

> 
> Thanks.
> 
> index.php:
> <?php
> echo '<html><body>';
> include_once 'include.php';
> $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password');
> tcl_MySQL_OpenDataBase($mysql_link, 'production');
> $query = 'SELECT DISTINCT recipe.product_id, product.description FROM
> recipe, product WHERE recipe.product_id = product.product_id ORDER BY
> product.description';
> $result = tcl_MySQL_DataQuery($mysql_link, $query);
> tcl_FillComboBox($result, 'Product', 'product_id', 'description',
> 'alert(\'Alert Message\')');
> tcl_MySQL_CloseConnection($mysql_link);
> echo '</body></html>';
> ?>
> 
> include.php:
> <?php
> function tcl_MySQL_CloseConnection($link) {
>       mysql_close($link);
> }
> function tcl_MySQL_ConnectToServer($host, $user, $password) {
>       $link = mysql_connect($host, $user, $password);
>       if (!$link) {
>             die('No se pudo conectar: '.mysql_error());
>       }
>       echo '<h3>User '.strtoupper($user).' connected to MySQL server.</h3>';
>       return $link;
> }
> function tcl_MySQL_DataQuery($link, $query) {
>       return mysql_query($query, $link);
> }
> function tcl_MySQL_OpenDataBase($link, $database) {
>       mysql_select_db($database, $link);
> }
> function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) {
>       echo '<label>'.$label.'</label><select> 
> onchange="'.$onchange.'"><option value="">';
>       while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
>             echo '<option value="'.$line[$col1].'">'.$line[$col2];
>       }
>       echo '</select>';
> }
> ?>
>  


--- End Message ---
--- Begin Message ---
At 7:58 AM -0700 11/5/10, Jim Lucas wrote:
On 11/4/2010 1:23 PM, Tomás Corrales Lemoine wrote:
 Hi, List,

 I have this two files ("index.php" and "include.php"). They both work fine,
 but I want to substitute the code for de onchange event in the <select> tag.
 Can I use PHP to code this event? How?

Looks to me that you are looking for "chained select boxes".  Doing a G search
for that and the first result is this:

If that is the case (the post was confusing to me), here's my solution:

http://php1.net/a/ajax-select/index.php

You simply use a PHP script (main) to set things up and then JavaScript (ajax) to run a slave PHP script.

All the code is there.

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
On 5 November 2010 05:21, Tamara Temple <tamouse.li...@gmail.com> wrote:
>
> On Nov 4, 2010, at 6:36 AM, Jay Blanchard wrote:
>
>> [snip]
>> If you have a query in your PHP code, which you are going to be
>> executing a lot, even if you are using prepared statements, you can go
>> one further by creating a stored procedure. Now the SQL server will
>> only ever need to compile the statement once. No matter how many times
>> it is used. You only need to supply the data which will be type
>> appropriate.
>> [/snip]
>>
>> I second this, using stored procedures has a lot of advantages. If you
>> need to change your SQL you can do it in one spot. It reinforces MVS or
>> modular coding behavior, the SP becomes very re-usable. Security is
>> improved. Performance can be improved. You can put the bulk of the data
>> handling on the database where it really belongs because SP's can
>> perform complex operations complete with control structures. Lastly it
>> simplifies your PHP code.
>>
>
> (dangit, i sent this from the wrong address initially)
>
> I do know about stored procedures and have used them where appropriate
> (retrieving the entire contents of a table, one record from a table, etc.).
> It was the prepared statements that I haven't had experience with. I wasn't
> away that these were precompiled. That does make them more attractive for
> heavily executed pulls. On the other hand, the seem to require more intense
> maintenance than just changing some lines of code in a file if need be. (I
> assume prepared statements don't share the same efficiency of maintenance
> that stored procedures do across applications.)
>
>
>

Ad hoc queries. These will need to be compiled every single time it is
used. If it is in a loop, then every single time the server has to go
through the compile process.

Prepared statements. These will be compiled every time the prepare
statement is called. You can execute the query multiple times, but
only the prepare will actually be compiled.

Stored procedures. In many regards, these are like prepared
statements. Depending upon your DB, you may be able to call a stored
procedure directly without the need of building an SQL statement to
call the SP. If you have to build a query, then you should build a
prepared statement, even if you are only calling it once. The
advantage is that passing parameters to stored procedures and prepared
statements significantly reduce the potential for SQL injection.

But, as mentioned, one of queries don't need to be SP. The main
advantage I've found is I can get significant optimization on my SQL
server if the server knows about it's workload before it is used. I
can optimize my indexes for my actual usage.

For more complex select statements, then server side views are another
optimization you can do. So, not a server side stored procedure, not a
client side prepared statement, but a server side prepared statement.
Again, client side you can use a prepared statement to get multiple
hits on the view (if that's how you are going to run).

Basically, ad hoc queries result in more complex client side code. You
have to do all the SQL injection protection yourself (or use a
Poka-Yoke - STRONGLY recommend). If you can do all the DB related work
on the DB, your client code is simpler. The DB work exists in 1 place.
Everyone will know where it is. Using the right tool for the job, AND
getting the balance right is what being an experienced developer is
all about. Start with what you can understand. Ask questions. Learn.
Refactor. Improve.

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:

> 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...
>

is there any reason the php application code has to be responsible for
mounting the network drive?

typically this is an os-level responsibility.

-nathan

--- End Message ---
--- Begin Message ---
On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
> 
> > 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...
> >
> 
> is there any reason the php application code has to be responsible for
> mounting the network drive?
> 
> typically this is an os-level responsibility.
> 
> -nathan

this is true, but i am looking at mounting it, reading the contents,
maybe moving a file to it, or renaming a file... and then closing the
smb share.

i have thought abotu making it a requirement on the users end to have
the directory ready for the application... but thought also about maybe
giving them the option to connect to it and do what it has to do, then
close it... 

i've been doing it the second way, but was wondering if the first was a
viable option or not.

Steve


--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net> wrote:

> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> > On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
> >
> > > 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...
> > >
> >
> > is there any reason the php application code has to be responsible for
> > mounting the network drive?
> >
> > typically this is an os-level responsibility.
> >
> > -nathan
>
> this is true, but i am looking at mounting it, reading the contents,
> maybe moving a file to it, or renaming a file... and then closing the
> smb share.
>
> i have thought abotu making it a requirement on the users end to have
> the directory ready for the application... but thought also about maybe
> giving them the option to connect to it and do what it has to do, then
> close it...
>
> i've been doing it the second way, but was wondering if the first was a
> viable option or not.


hmm, yeah im not sure if theres a clean mounting interface between windows
and linux.  the nomenclature is different for one, and im not even sure how
to mount a network drive programmatically under windows.  maybe someone else
on the list does.

-nathan

--- End Message ---
--- Begin Message ---
On 05/11/2010 16:18, Steve Staples wrote:
> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
>>
>>> 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...
>>>
>>
>> is there any reason the php application code has to be responsible for
>> mounting the network drive?
>>
>> typically this is an os-level responsibility.
>>
>> -nathan
> 
> this is true, but i am looking at mounting it, reading the contents,
> maybe moving a file to it, or renaming a file... and then closing the
> smb share.
> 
> i have thought abotu making it a requirement on the users end to have
> the directory ready for the application... but thought also about maybe
> giving them the option to connect to it and do what it has to do, then
> close it... 
> 
> i've been doing it the second way, but was wondering if the first was a
> viable option or not.
> 
> Steve
> 
> 
Hi,

To do this without giving your web site root permissions you will have
to split out the required actions.

You could have a php daemon running as root which periodically checks if
the share needs mounting. The trigger could be many things, like the
existence of a file or database record.

You can then have the web site create the file or database record when
it needs the share mounting and then wait for the mount to appear.


I have used the Pear module System_Daemon[1] to do this in the past,
very easy to use.

[1] http://pear.php.net/package/System_Daemon

Regards

Ian

--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 10:37 AM, Ian <php_l...@fishnet.co.uk> wrote:

> On 05/11/2010 16:18, Steve Staples wrote:
> > On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> >> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
> wrote:
> >>
> >>> 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...
> >>>
> >>
> >> is there any reason the php application code has to be responsible for
> >> mounting the network drive?
> >>
> >> typically this is an os-level responsibility.
> >>
> >> -nathan
> >
> > this is true, but i am looking at mounting it, reading the contents,
> > maybe moving a file to it, or renaming a file... and then closing the
> > smb share.
> >
> > i have thought abotu making it a requirement on the users end to have
> > the directory ready for the application... but thought also about maybe
> > giving them the option to connect to it and do what it has to do, then
> > close it...
> >
> > i've been doing it the second way, but was wondering if the first was a
> > viable option or not.
> >
> > Steve
> >
> >
> Hi,
>
> To do this without giving your web site root permissions you will have
> to split out the required actions.
>

not true, this could easily be facilitated through sudo on linux, which
would eliminate the need for an extra moving part like a running daemon.  in
fact that would be the first solution i would propose on a linux system.

again tho, on the windows side, who knows, lol.

-nathan

--- End Message ---
--- Begin Message ---
On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
> On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net> wrote:
>
>> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>> > On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
>> >
>> > > 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...
>> > >
>> >
>> > is there any reason the php application code has to be responsible for
>> > mounting the network drive?
>> >
>> > typically this is an os-level responsibility.
>> >
>> > -nathan
>>
>> this is true, but i am looking at mounting it, reading the contents,
>> maybe moving a file to it, or renaming a file... and then closing the
>> smb share.
>>
>> i have thought abotu making it a requirement on the users end to have
>> the directory ready for the application... but thought also about maybe
>> giving them the option to connect to it and do what it has to do, then
>> close it...
>>
>> i've been doing it the second way, but was wondering if the first was a
>> viable option or not.
>
>
> hmm, yeah im not sure if theres a clean mounting interface between windows
> and linux.  the nomenclature is different for one, and im not even sure how
> to mount a network drive programmatically under windows.  maybe someone else
> on the list does.
>
> -nathan
>

You don't need to "mount" the share. If the share is available, then
you can access using UNC ...

\\server\share\directory\file.ext is fine.
Or
\\xxx.xxx.xxx.xxx\share\directory\file.ext

But watch out ... in PHP, you'll need to either use / or \\ for each \
in the UNC path ...

\\\\server\\share\\directory\\file.ext is fine.
Or
//xxx.xxx.xxx.xxx/share/directory/file.ext


If you do really need to map it, then

net use x: \\server\share

and

net use x: /d

to drop the mapping.

But you don't need to mount the share if the server with

Is this not the same on unix?

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
On 5 November 2010 16:43, Richard Quadling <rquadl...@gmail.com> wrote:
> On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
>> On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net> wrote:
>>
>>> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>>> > On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net> wrote:
>>> >
>>> > > 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...
>>> > >
>>> >
>>> > is there any reason the php application code has to be responsible for
>>> > mounting the network drive?
>>> >
>>> > typically this is an os-level responsibility.
>>> >
>>> > -nathan
>>>
>>> this is true, but i am looking at mounting it, reading the contents,
>>> maybe moving a file to it, or renaming a file... and then closing the
>>> smb share.
>>>
>>> i have thought abotu making it a requirement on the users end to have
>>> the directory ready for the application... but thought also about maybe
>>> giving them the option to connect to it and do what it has to do, then
>>> close it...
>>>
>>> i've been doing it the second way, but was wondering if the first was a
>>> viable option or not.
>>
>>
>> hmm, yeah im not sure if theres a clean mounting interface between windows
>> and linux.  the nomenclature is different for one, and im not even sure how
>> to mount a network drive programmatically under windows.  maybe someone else
>> on the list does.
>>
>> -nathan
>>
>
> You don't need to "mount" the share. If the share is available, then
> you can access using UNC ...
>
> \\server\share\directory\file.ext is fine.
> Or
> \\xxx.xxx.xxx.xxx\share\directory\file.ext
>
> But watch out ... in PHP, you'll need to either use / or \\ for each \
> in the UNC path ...
>
> \\\\server\\share\\directory\\file.ext is fine.
> Or
> //xxx.xxx.xxx.xxx/share/directory/file.ext
>
>
> If you do really need to map it, then
>
> net use x: \\server\share
>
> and
>
> net use x: /d
>
> to drop the mapping.
>
> But you don't need to mount the share if the server with
>
> Is this not the same on unix?
>

If you need to supply credentials to access the share, then mapping it
(I think) is the only way PHP could access it ...

net use x: \\server\share /user:domain\username password

If you don't supply the password, the user would need to enter it at
the command line. A bit difficult via the web.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[usern...@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]


If the device and permissions are a fixed, then I'd use the /SAVECRED
option and ask the user to do the job once. Thereafter you can just
...

net use x: \\server\share

and no need to enter permissions as this will use the stored ones.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling <rquadl...@gmail.com>wrote:

> On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
> > On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net>
> wrote:
> >
> >> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> >> > On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
> wrote:
> >> >
> >> > > 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...
> >> > >
> >> >
> >> > is there any reason the php application code has to be responsible for
> >> > mounting the network drive?
> >> >
> >> > typically this is an os-level responsibility.
> >> >
> >> > -nathan
> >>
> >> this is true, but i am looking at mounting it, reading the contents,
> >> maybe moving a file to it, or renaming a file... and then closing the
> >> smb share.
> >>
> >> i have thought abotu making it a requirement on the users end to have
> >> the directory ready for the application... but thought also about maybe
> >> giving them the option to connect to it and do what it has to do, then
> >> close it...
> >>
> >> i've been doing it the second way, but was wondering if the first was a
> >> viable option or not.
> >
> >
> > hmm, yeah im not sure if theres a clean mounting interface between
> windows
> > and linux.  the nomenclature is different for one, and im not even sure
> how
> > to mount a network drive programmatically under windows.  maybe someone
> else
> > on the list does.
> >
> > -nathan
> >
>
> You don't need to "mount" the share. If the share is available, then
> you can access using UNC ...
>
> But you don't need to mount the share
>
> Is this not the same on unix?


im not sure, ive got some linux machines mounting windows shares and it
seems ls is not happy using the smb url to the share.  there may be a way
though, for those willing to dig a little :D

-nathan

--- End Message ---
--- Begin Message ---
Nathan Nobbe пишет:
On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling <rquadl...@gmail.com>wrote:

On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net>
wrote:
On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
wrote:
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...

is there any reason the php application code has to be responsible for
mounting the network drive?

typically this is an os-level responsibility.

-nathan
this is true, but i am looking at mounting it, reading the contents,
maybe moving a file to it, or renaming a file... and then closing the
smb share.

i have thought abotu making it a requirement on the users end to have
the directory ready for the application... but thought also about maybe
giving them the option to connect to it and do what it has to do, then
close it...

i've been doing it the second way, but was wondering if the first was a
viable option or not.
hmm, yeah im not sure if theres a clean mounting interface between
windows
and linux.  the nomenclature is different for one, and im not even sure
how
to mount a network drive programmatically under windows.  maybe someone
else
on the list does.

-nathan

You don't need to "mount" the share. If the share is available, then
you can access using UNC ...

But you don't need to mount the share

Is this not the same on unix?


im not sure, ive got some linux machines mounting windows shares and it
seems ls is not happy using the smb url to the share.  there may be a way
though, for those willing to dig a little :D

-nathan

You can use 'smbclient' for copy file from the machine running the
client (Linux) to the server (Windows). In PHP it is necessary to use
functions like system or shell_exec.


--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 11:01 AM, Alexandr <verbitsky_alexa...@mail.by>wrote:

> Nathan Nobbe пишет:
>
>  On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling <rquadl...@gmail.com
>> >wrote:
>>
>>
>>
>>> On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
>>>
>>>
>>>> On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net>
>>>>
>>>>
>>> wrote:
>>>
>>>
>>>> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
>>>>>
>>>>>
>>>>>> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
>>>>>>
>>>>>>
>>>>> wrote:
>>>
>>>
>>>> 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...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> is there any reason the php application code has to be responsible for
>>>>>> mounting the network drive?
>>>>>>
>>>>>> typically this is an os-level responsibility.
>>>>>>
>>>>>> -nathan
>>>>>>
>>>>>>
>>>>> this is true, but i am looking at mounting it, reading the contents,
>>>>> maybe moving a file to it, or renaming a file... and then closing the
>>>>> smb share.
>>>>>
>>>>> i have thought abotu making it a requirement on the users end to have
>>>>> the directory ready for the application... but thought also about maybe
>>>>> giving them the option to connect to it and do what it has to do, then
>>>>> close it...
>>>>>
>>>>> i've been doing it the second way, but was wondering if the first was a
>>>>> viable option or not.
>>>>>
>>>>>
>>>> hmm, yeah im not sure if theres a clean mounting interface between
>>>>
>>>>
>>> windows
>>>
>>>
>>>> and linux.  the nomenclature is different for one, and im not even sure
>>>>
>>>>
>>> how
>>>
>>>
>>>> to mount a network drive programmatically under windows.  maybe someone
>>>>
>>>>
>>> else
>>>
>>>
>>>> on the list does.
>>>>
>>>> -nathan
>>>>
>>>>
>>>>
>>> You don't need to "mount" the share. If the share is available, then
>>> you can access using UNC ...
>>>
>>> But you don't need to mount the share
>>>
>>> Is this not the same on unix?
>>>
>>>
>>
>>
>> im not sure, ive got some linux machines mounting windows shares and it
>> seems ls is not happy using the smb url to the share.  there may be a way
>> though, for those willing to dig a little :D
>>
>> -nathan
>>
>>
>>
> You can use 'smbclient' for copy file from the machine running the
> client (Linux) to the server (Windows). In PHP it is necessary to use
> functions like system or shell_exec.


ahh - good call.  iirc that's the underlying program used by mount actually
when mounting smb shares.  i know it's called by our automount scripts as
well.  never bothered to use it directly, however that sounds like the way
to go in this scenario.

-nathan

--- End Message ---
--- Begin Message ---
On Fri, 2010-11-05 at 11:06 -0600, Nathan Nobbe wrote:
> On Fri, Nov 5, 2010 at 11:01 AM, Alexandr <verbitsky_alexa...@mail.by>wrote:
> 
> > Nathan Nobbe пишет:
> >
> >  On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling <rquadl...@gmail.com
> >> >wrote:
> >>
> >>
> >>
> >>> On 5 November 2010 16:30, Nathan Nobbe <quickshif...@gmail.com> wrote:
> >>>
> >>>
> >>>> On Fri, Nov 5, 2010 at 10:18 AM, Steve Staples <sstap...@mnsi.net>
> >>>>
> >>>>
> >>> wrote:
> >>>
> >>>
> >>>> On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> >>>>>
> >>>>>
> >>>>>> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
> >>>>>>
> >>>>>>
> >>>>> wrote:
> >>>
> >>>
> >>>> 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...
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> is there any reason the php application code has to be responsible for
> >>>>>> mounting the network drive?
> >>>>>>
> >>>>>> typically this is an os-level responsibility.
> >>>>>>
> >>>>>> -nathan
> >>>>>>
> >>>>>>
> >>>>> this is true, but i am looking at mounting it, reading the contents,
> >>>>> maybe moving a file to it, or renaming a file... and then closing the
> >>>>> smb share.
> >>>>>
> >>>>> i have thought abotu making it a requirement on the users end to have
> >>>>> the directory ready for the application... but thought also about maybe
> >>>>> giving them the option to connect to it and do what it has to do, then
> >>>>> close it...
> >>>>>
> >>>>> i've been doing it the second way, but was wondering if the first was a
> >>>>> viable option or not.
> >>>>>
> >>>>>
> >>>> hmm, yeah im not sure if theres a clean mounting interface between
> >>>>
> >>>>
> >>> windows
> >>>
> >>>
> >>>> and linux.  the nomenclature is different for one, and im not even sure
> >>>>
> >>>>
> >>> how
> >>>
> >>>
> >>>> to mount a network drive programmatically under windows.  maybe someone
> >>>>
> >>>>
> >>> else
> >>>
> >>>
> >>>> on the list does.
> >>>>
> >>>> -nathan
> >>>>
> >>>>
> >>>>
> >>> You don't need to "mount" the share. If the share is available, then
> >>> you can access using UNC ...
> >>>
> >>> But you don't need to mount the share
> >>>
> >>> Is this not the same on unix?
> >>>
> >>>
> >>
> >>
> >> im not sure, ive got some linux machines mounting windows shares and it
> >> seems ls is not happy using the smb url to the share.  there may be a way
> >> though, for those willing to dig a little :D
> >>
> >> -nathan
> >>
> >>
> >>
> > You can use 'smbclient' for copy file from the machine running the
> > client (Linux) to the server (Windows). In PHP it is necessary to use
> > functions like system or shell_exec.
> 
> 
> ahh - good call.  iirc that's the underlying program used by mount actually
> when mounting smb shares.  i know it's called by our automount scripts as
> well.  never bothered to use it directly, however that sounds like the way
> to go in this scenario.
> 
> -nathan


looks like it is not as simple as i had hoped/thought...

i found a smb class on phpclasses.org, maybe tonight i will look at that
and see if it what i need it to be.




--- End Message ---
--- Begin Message ---
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
>
>

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Nathan Nobbe [mailto:quickshif...@gmail.com]
> Sent: Friday, November 05, 2010 9:43 AM
> To: php_l...@fishnet.co.uk
> Cc: php-gene...@lists.php.net
> Subject: Re: [PHP] Re: read smb drive
> 
> On Fri, Nov 5, 2010 at 10:37 AM, Ian <php_l...@fishnet.co.uk> wrote:
> 
> > On 05/11/2010 16:18, Steve Staples wrote:
> > > On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> > >> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples <sstap...@mnsi.net>
> > wrote:
> > >>
> > >>> 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...
> > >>>
> > >>
> > >> is there any reason the php application code has to be responsible
> > >> for mounting the network drive?
> > >>
> > >> typically this is an os-level responsibility.
> > >>
> > >> -nathan
> > >
> > > this is true, but i am looking at mounting it, reading the contents,
> > > maybe moving a file to it, or renaming a file... and then closing
> > > the smb share.
> > >
> > > i have thought abotu making it a requirement on the users end to
> > > have the directory ready for the application... but thought also
> > > about maybe giving them the option to connect to it and do what it
> > > has to do, then close it...
> > >
> > > i've been doing it the second way, but was wondering if the first
> > > was a viable option or not.
> > >
> > > Steve
> > >
> > >
> > Hi,
> >
> > To do this without giving your web site root permissions you will have
> > to split out the required actions.
> >
> 
> not true, this could easily be facilitated through sudo on linux, which would
> eliminate the need for an extra moving part like a running daemon.  in fact
> that would be the first solution i would propose on a linux system.
> 
> again tho, on the windows side, who knows, lol.
> 
> -nathan

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true



--- End Message ---
--- Begin Message ---
Hello All,


I'm looking to build a DB with items that are considered more of a catalog
on one side of a website, and then provide those same items including the
same images, descriptions etc. to a shopping cart.

I don't want to re-invent all of the basic shopping cart functionality and
I'm not sure I want to use something like OScommerce and inject the data
into it at the same time as putting data into our database that we are
writing.


I was hoping someone out there has some suggestions, or even a cart module
that would allow me to easily integrate into.

 

 

Thanks!

Jack

 



--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 12:30 PM, Jack <jacklistm...@gmail.com> wrote:

> Hello All,
>
>
> I'm looking to build a DB with items that are considered more of a catalog
> on one side of a website, and then provide those same items including the
> same images, descriptions etc. to a shopping cart.
>
> I don't want to re-invent all of the basic shopping cart functionality and
> I'm not sure I want to use something like OScommerce and inject the data
> into it at the same time as putting data into our database that we are
> writing.
>
>
> I was hoping someone out there has some suggestions, or even a cart module
> that would allow me to easily integrate into.
>

One recommendation I can give you is to spend some time determining if
Magento works for you.  This is a conventional platform written on top of
Zend Framework.  OScommerce, and a derivative, ZenCart are ancient, and
there are many nasty things about the programming practices, most notably,
the 'view' layer, which is markup intermingled with logic .. its pretty bad.

Magento is robust, and has a feature set that makes OScommerce look like it
shipped from the third world.  That said it may be overkill as well - just
my 2c.

-nathan

--- End Message ---
--- Begin Message ---
On Fri, Nov 5, 2010 at 12:30 PM, Jack <jacklistm...@gmail.com> wrote:

Hello All,


I'm looking to build a DB with items that are considered more of a catalog
on one side of a website, and then provide those same items including the
same images, descriptions etc. to a shopping cart.

I don't want to re-invent all of the basic shopping cart functionality and
I'm not sure I want to use something like OScommerce and inject the data
into it at the same time as putting data into our database that we are
writing.


I was hoping someone out there has some suggestions, or even a cart module
that would allow me to easily integrate into.

 

One recommendation I can give you is to spend some time determining if Magento 
works for you.  This is a conventional platform written on top of Zend 
Framework.  OScommerce, and a derivative, ZenCart are ancient, and there are 
many nasty things about the programming practices, most notably, the 'view' 
layer, which is markup intermingled with logic .. its pretty bad.

 

Magento is robust, and has a feature set that makes OScommerce look like it 
shipped from the third world.  That said it may be overkill as well - just my 
2c.

 

-nathan

 

I agree, this is a cart I was going to check into because it has many more 
features and is probably a little more if not a lot more stable than 
OScommerce.  I just am not sure if I want to inject everything, although I may 
not have a choice.

 

Thanks!


--- End Message ---

Reply via email to