Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-08 Thread ioan...@btinternet.com



There are essentially 2 ways:
1. All POSTed data is present in the $_POST superglobal array. So you
could just loop over that, ignore the fields you already knew were there,
and the data remaining is then essentially the data you seek. The keys in
the $_POST array are the fieldnames you are looking for.

2. There's a special trick in PHP, when you name a field "name[]" in HTML
and then POST it to a PHP script, it will turn into an array field. So
will then end up
in:
$_POST = [
'a' =>  [
   0 =>  '1',
   1 =>  '2'
]
]

If you had not added the square-brackets, you would have:
ending up in:
$_POST = [
'a' =>  '2'
]
Thus not ever seeing the value '1'.






checkbox field name="input_1" value="y"
checkbox field name="input_2" value="y"
field name input_n
..




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



Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-06 Thread Jim Giner

"Maciek Sokolewicz"  wrote in message 
news:4fcf23af.7040...@php.net...
> On 06-06-2012 05:11, Jim Giner wrote:
>> "Govinda"  wrote in message
>> news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com...
>>
>> On 2012-06-05, at 10:54 PM, Devangnp wrote:
>>
>>> I know how to pass variable but having difficulties when I use the 
>>> dynamic
>>> form field in HTML that add more boxes as per user require.
>>>
>>
> Hi All,
>
> I am a basic user of PHP and I have need of reading the dynamic HTML
> form
> field as a variable in PHP so it will be great if someone can share 
> some
> good link or snip for quick understanding.
>
> Thanks,
> Devang


 http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable

 When just starting out, "Google is your friend".

 Or did I misunderstand your question?

 -Govinda
>>
>>
>> Devang,
>>
>> Please keep replies on-list.
>> Please post your replies at the bottom, past the older (snipped) content.
>>
>> Many here will be glad to help..  but you'll need to make your question 
>> more
>> clear.. at least for me to be able to help anyway.
>> First of all, what do you mean exactly, by, "the dynamic form field in
>> HTML"?  And by "boxes" do you mean form inputs of 'text' type?  If so, 
>> then
>> do you mean to suggest that input by the end user should determine the
>> number of text inputs that should display in a second HTML form?
>> Please spend more time describing what you are trying to do.. and also
>> please show any code you attempt(ed) to accomplish this.  If you are 
>> unable
>> to write any code, then try pseudo code - meaning write in successive 
>> lines
>> of prose what you want code to do, and post that here.
>>
>> -Govinda=
>>
>> I thought he meant previously generated "array" type fields, that use the
>> same name.  I've never done it myself, but  I thought the method of 
>> handling
>> this kind of input included placing a hidden field with the count on the
>> form to be retriieved later and used in processing the dynamic fields in 
>> a
>> loop.
>>
>>
>
> A possible answer to a possible question that he might have (yes, the 
> question is very vaguely described, as Govinda already explained) would be 
> the following:
>
> Assuming you have an HTML form, which may contain a variable number of 
> fields, you want to somehow access their passed-through values in PHP 
> without prior knowledge of the exact number of those fields.
>
> There are essentially 2 ways:
> 1. All POSTed data is present in the $_POST superglobal array. So you 
> could just loop over that, ignore the fields you already knew were there, 
> and the data remaining is then essentially the data you seek. The keys in 
> the $_POST array are the fieldnames you are looking for.
>
> 2. There's a special trick in PHP, when you name a field "name[]" in HTML 
> and then POST it to a PHP script, it will turn into an array field. So 
>   will then end up 
> in:
> $_POST = [
>'a' => [
>   0 => '1',
>   1 => '2'
>]
> ]
>
> If you had not added the square-brackets, you would have:
>   ending up in:
> $_POST = [
>'a' => '2'
> ]
> Thus not ever seeing the value '1'.
>
> I hope this answers part of your question; and if not, PLEASE explain in 
> more detail what your problem is, what you tried, why it didn't work, and 
> what you want to know exactly. Your current question is very very short 
> and vague enough to easily cause misunderstanding.
>
> - Tul

Thank you Tul for your eloquent post.  Now I understand how to handle those 
kinds of "array" inputs myself!

And - I do think from his vague description that the OP is looking for this 
kind of help.  If not, then it was REALLY vague! 



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



Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-06 Thread Maciek Sokolewicz

On 06-06-2012 05:11, Jim Giner wrote:

"Govinda"  wrote in message
news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com...

On 2012-06-05, at 10:54 PM, Devangnp wrote:


I know how to pass variable but having difficulties when I use the dynamic
form field in HTML that add more boxes as per user require.




Hi All,

I am a basic user of PHP and I have need of reading the dynamic HTML
form
field as a variable in PHP so it will be great if someone can share some
good link or snip for quick understanding.

Thanks,
Devang



http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable

When just starting out, "Google is your friend".

Or did I misunderstand your question?

-Govinda



Devang,

Please keep replies on-list.
Please post your replies at the bottom, past the older (snipped) content.

Many here will be glad to help..  but you'll need to make your question more
clear.. at least for me to be able to help anyway.
First of all, what do you mean exactly, by, "the dynamic form field in
HTML"?  And by "boxes" do you mean form inputs of 'text' type?  If so, then
do you mean to suggest that input by the end user should determine the
number of text inputs that should display in a second HTML form?
Please spend more time describing what you are trying to do.. and also
please show any code you attempt(ed) to accomplish this.  If you are unable
to write any code, then try pseudo code - meaning write in successive lines
of prose what you want code to do, and post that here.

-Govinda=

I thought he meant previously generated "array" type fields, that use the
same name.  I've never done it myself, but  I thought the method of handling
this kind of input included placing a hidden field with the count on the
form to be retriieved later and used in processing the dynamic fields in a
loop.




A possible answer to a possible question that he might have (yes, the 
question is very vaguely described, as Govinda already explained) would 
be the following:


Assuming you have an HTML form, which may contain a variable number of 
fields, you want to somehow access their passed-through values in PHP 
without prior knowledge of the exact number of those fields.


There are essentially 2 ways:
1. All POSTed data is present in the $_POST superglobal array. So you 
could just loop over that, ignore the fields you already knew were 
there, and the data remaining is then essentially the data you seek. The 
keys in the $_POST array are the fieldnames you are looking for.


2. There's a special trick in PHP, when you name a field "name[]" in 
HTML and then POST it to a PHP script, it will turn into an array field. 
So   will then 
end up in:

$_POST = [
   'a' => [
  0 => '1',
  1 => '2'
   ]
]

If you had not added the square-brackets, you would have:
  ending up in:
$_POST = [
   'a' => '2'
]
Thus not ever seeing the value '1'.

I hope this answers part of your question; and if not, PLEASE explain in 
more detail what your problem is, what you tried, why it didn't work, 
and what you want to know exactly. Your current question is very very 
short and vague enough to easily cause misunderstanding.


- Tul

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



Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-05 Thread Jim Giner

"Govinda"  wrote in message 
news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com...

On 2012-06-05, at 10:54 PM, Devangnp wrote:

> I know how to pass variable but having difficulties when I use the dynamic 
> form field in HTML that add more boxes as per user require.
>

>>> Hi All,
>>>
>>> I am a basic user of PHP and I have need of reading the dynamic HTML 
>>> form
>>> field as a variable in PHP so it will be great if someone can share some
>>> good link or snip for quick understanding.
>>>
>>> Thanks,
>>> Devang
>>
>>
>> http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable
>>
>> When just starting out, "Google is your friend".
>>
>> Or did I misunderstand your question?
>>
>> -Govinda


Devang,

Please keep replies on-list.
Please post your replies at the bottom, past the older (snipped) content.

Many here will be glad to help..  but you'll need to make your question more 
clear.. at least for me to be able to help anyway.
First of all, what do you mean exactly, by, "the dynamic form field in 
HTML"?  And by "boxes" do you mean form inputs of 'text' type?  If so, then 
do you mean to suggest that input by the end user should determine the 
number of text inputs that should display in a second HTML form?
Please spend more time describing what you are trying to do.. and also 
please show any code you attempt(ed) to accomplish this.  If you are unable 
to write any code, then try pseudo code - meaning write in successive lines 
of prose what you want code to do, and post that here.

-Govinda=

I thought he meant previously generated "array" type fields, that use the 
same name.  I've never done it myself, but  I thought the method of handling 
this kind of input included placing a hidden field with the count on the 
form to be retriieved later and used in processing the dynamic fields in a 
loop. 



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



Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-05 Thread Govinda

On 2012-06-05, at 10:54 PM, Devangnp wrote:

> I know how to pass variable but having difficulties when I use the dynamic 
> form field in HTML that add more boxes as per user require.
> 

>>> Hi All,
>>> 
>>> I am a basic user of PHP and I have need of reading the dynamic HTML form
>>> field as a variable in PHP so it will be great if someone can share some
>>> good link or snip for quick understanding.
>>> 
>>> Thanks,
>>> Devang
>> 
>> 
>> http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable
>> 
>> When just starting out, "Google is your friend".
>> 
>> Or did I misunderstand your question?
>> 
>> -Govinda


Devang,

Please keep replies on-list.
Please post your replies at the bottom, past the older (snipped) content.

Many here will be glad to help..  but you'll need to make your question more 
clear.. at least for me to be able to help anyway.
First of all, what do you mean exactly, by, "the dynamic form field in HTML"?  
And by "boxes" do you mean form inputs of 'text' type?  If so, then do you mean 
to suggest that input by the end user should determine the number of text 
inputs that should display in a second HTML form?  
Please spend more time describing what you are trying to do.. and also please 
show any code you attempt(ed) to accomplish this.  If you are unable to write 
any code, then try pseudo code - meaning write in successive lines of prose 
what you want code to do, and post that here. 

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



Re: [PHP] Read dynamic variable from HTML form into PHP

2012-06-05 Thread Govinda
> Hi All,
> 
> I am a basic user of PHP and I have need of reading the dynamic HTML form
> field as a variable in PHP so it will be great if someone can share some
> good link or snip for quick understanding.
> 
> Thanks,
> Devang


http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable

When just starting out, "Google is your friend".

Or did I misunderstand your question?

-Govinda

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



[PHP] Read dynamic variable from HTML form into PHP

2012-06-05 Thread Devang Patel
Hi All,

I am a basic user of PHP and I have need of reading the dynamic HTML form
field as a variable in PHP so it will be great if someone can share some
good link or snip for quick understanding.

Thanks,
Devang


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 :
> 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] read smb drive

2010-11-05 Thread Steve Staples
On Fri, 2010-11-05 at 11:06 -0600, Nathan Nobbe wrote:
> On Fri, Nov 5, 2010 at 11:01 AM, Alexandr wrote:
> 
> > Nathan Nobbe пишет:
> >
> >  On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling  >> >wrote:
> >>
> >>
> >>
> >>> On 5 November 2010 16:30, Nathan Nobbe  wrote:
> >>>
> >>>
>  On Fri, Nov 5, 2010 at 10:18 AM, 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 
> >>
> >>
> > 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.




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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 11:01 AM, Alexandr wrote:

> Nathan Nobbe пишет:
>
>  On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling > >wrote:
>>
>>
>>
>>> On 5 November 2010 16:30, Nathan Nobbe  wrote:
>>>
>>>
 On Fri, Nov 5, 2010 at 10:18 AM, 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 
>>
>>
> 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


Re: [PHP] read smb drive

2010-11-05 Thread Alexandr

Nathan Nobbe пишет:

On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling wrote:

  

On 5 November 2010 16:30, Nathan Nobbe  wrote:


On Fri, Nov 5, 2010 at 10:18 AM, 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 
  

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.


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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 10:43 AM, Richard Quadling wrote:

> On 5 November 2010 16:30, Nathan Nobbe  wrote:
> > On Fri, Nov 5, 2010 at 10:18 AM, 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 
> 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


Re: [PHP] read smb drive

2010-11-05 Thread Richard Quadling
On 5 November 2010 16:43, Richard Quadling  wrote:
> On 5 November 2010 16:30, Nathan Nobbe  wrote:
>> On Fri, Nov 5, 2010 at 10:18 AM, 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  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

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



Re: [PHP] read smb drive

2010-11-05 Thread Richard Quadling
On 5 November 2010 16:30, Nathan Nobbe  wrote:
> On Fri, Nov 5, 2010 at 10:18 AM, 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  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

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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 10:18 AM, 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  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


Re: [PHP] read smb drive

2010-11-05 Thread Steve Staples
On Fri, 2010-11-05 at 10:06 -0600, Nathan Nobbe wrote:
> On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples  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


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



Re: [PHP] read smb drive

2010-11-05 Thread Nathan Nobbe
On Fri, Nov 5, 2010 at 9:48 AM, Steve Staples  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


[PHP] read smb drive

2010-11-05 Thread Steve Staples
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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Shawn McKenzie
Kenneth Sande wrote:
> I use the glob function in my little homemade "web cam" page, which can
> really swell up in memory when used against a large amount of files (in
> my case around 30k files).

+1 for glob()


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Bastien Koert
On Wed, Jan 13, 2010 at 10:50 AM, Rahul S. Johari
 wrote:
>
> On Jan 13, 2010, at 10:40 AM, Rahul S. Johari wrote:
>
>>
>> On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:
>>
>>> On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

 Ave,

 This is what I'm trying to do; I want to read a directory (eg: W:\Test\)
 and take all the filenames found in the directory (eg: 1.vox, 2.wav, 3.txt)
 and store them in  a simple mySQL table.

 Can I do this?
>>>
>>> I tried to very quickly convert something I've done. It may need some
>>> work. Will work in  linux env.
>>>
>>> $origin = "Path"
>>>
>>> #load file listing into an array
>>> $shell = shell_exec("du $origin");
>>> $array  = array_reverse(explode("\n",$shell));
>>> $contIdArr = array();
>>>
>>> $newArr = array();
>>> foreach($array as $elem){
>>>  $newDir = "";
>>>  $pathArray = explode("/", $elem);
>>>  $nodeDepth = count($pathArray);
>>>  for($count=1; $count<$nodeDepth; $count++){
>>>      $newDir = $newDir.$pathArray[$count].'/';
>>>  }
>>>  $newArr[] = '/'.$newDir;
>>> }
>>> sort($newArr);
>>>
>>>
>>> foreach($newArr as $dir){
>>>  $pathArray = explode("/", $dir);
>>>
>>>  $fileListArr = dirList($dir);
>>>
>>>  foreach($fileListArr as $file){
>>>      //Insert file($file) and current dir/path($dir) into db
>>>  }
>>> }
>>>
>>> Kind regards
>>> Warren
>>>
>>
>>
>> Warren,
>>
>> I tried using your code and it definitely is very efficient & fast;
>> however I'm running into a small problem and I'm not sure how to correct it.
>> I'm getting the array with filenames from the folder I'm searching in PLUS
>> all the root folders of the machine as well.
>>
>> This is the code I'm using (note that I'm just echoing the array right
>> now; I'll move to inserting data into mySQL after):
>>
>> function dirList ($directory) {
>>  $results = array();
>>  $handler = opendir($directory);
>>  while ($file = readdir($handler)) {
>>      if ($file != '.' && $file != '..')
>>          $results[] = $file;
>>  }
>>  closedir($handler);
>>  return $results;
>> }
>>
>> $origin = "/Library/WebServer/Documents/folder1/folder2/images/";
>>
>> #load file listing into an array
>> $shell = shell_exec("du $origin");
>> $array  = array_reverse(explode("\n",$shell));
>> $contIdArr = array();
>>
>> $newArr = array();
>> foreach($array as $elem){
>>  $newDir = "";
>>  $pathArray = explode("/", $elem);
>>  $nodeDepth = count($pathArray);
>>  for($count=1; $count<$nodeDepth; $count++){
>>      $newDir = $newDir.$pathArray[$count].'/';
>>  }
>>  $newArr[] = '/'.$newDir;
>> }
>> sort($newArr);
>>
>> foreach($newArr as $dir){
>>  $pathArray = explode("/", $dir);
>>  $fileListArr = dirList($dir);
>>
>>  foreach($fileListArr as $file){
>>        echo $file."";
>>      //Insert file($file) and current dir/path($dir) into db
>>  }
>> }
>>
>>
>> As an output ... i get a list of all the files in the "images" folder
>> preceeded by the all the list of root folders on my machine!! How do I
>> eliminate the list of root folders?
>
>
> Nevermind, I was looking at the wrong output. I got it!! I've got all my
> filenames in my $fileListArr[] array!!
> Now I just to get the values in a mySQL table.
>
>
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
>
> [Email] sleepwal...@rahulsjohari.com
> [Web]   http://www.rahulsjohari.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


consider stacking the insert statements in sql to allow for a certain
number of inserts in one connect.

insert into my_table (field1, field2...fieldn)
values('field1','field2'...fieldn),('field1','field2'...fieldn),('field1','field2'...fieldn),('field1','field2'...fieldn)...

keep to something like 100 to avoid buffer overflows and it should
make the inserts much faster

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Read directory; store filenames found in mySQL table? :: SOLVED!!

2010-01-13 Thread Rahul S. Johari


Thanks All (Especially Warren); Final Code:

function dirList ($directory) {
   $results = array();
   $handler = opendir($directory);
   while ($file = readdir($handler)) {
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }
   closedir($handler);
   return $results;
}

$origin = "pathto/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
   $pathArray = explode("/", $dir);
   $fileListArr = dirList($dir);
}

$db = mysql_connect("localhost","usr","pwd");
mysql_select_db("db",$db);

foreach($fileListArr AS $value) {
$sql="INSERT INTO r2 (ID, RECORDING) VALUES('','$value')";
$result = mysql_query($sql) or die (mysql_error());
}


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 10:40 AM, Rahul S. Johari wrote:



On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?
I tried to very quickly convert something I've done. It may need  
some work. Will work in  linux env.


$origin = "Path"

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
  $newDir = "";
  $pathArray = explode("/", $elem);
  $nodeDepth = count($pathArray);
  for($count=1; $count<$nodeDepth; $count++){
  $newDir = $newDir.$pathArray[$count].'/';
  }
  $newArr[] = '/'.$newDir;
}
sort($newArr);


foreach($newArr as $dir){
  $pathArray = explode("/", $dir);

  $fileListArr = dirList($dir);

  foreach($fileListArr as $file){
  //Insert file($file) and current dir/path($dir) into db
  }
}

Kind regards
Warren




Warren,

I tried using your code and it definitely is very efficient & fast;  
however I'm running into a small problem and I'm not sure how to  
correct it. I'm getting the array with filenames from the folder I'm  
searching in PLUS all the root folders of the machine as well.


This is the code I'm using (note that I'm just echoing the array  
right now; I'll move to inserting data into mySQL after):


function dirList ($directory) {
  $results = array();
  $handler = opendir($directory);
  while ($file = readdir($handler)) {
  if ($file != '.' && $file != '..')
  $results[] = $file;
  }
  closedir($handler);
  return $results;
}

$origin = "/Library/WebServer/Documents/folder1/folder2/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
  $newDir = "";
  $pathArray = explode("/", $elem);
  $nodeDepth = count($pathArray);
  for($count=1; $count<$nodeDepth; $count++){
  $newDir = $newDir.$pathArray[$count].'/';
  }
  $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
  $pathArray = explode("/", $dir);
  $fileListArr = dirList($dir);

  foreach($fileListArr as $file){
echo $file."";
  //Insert file($file) and current dir/path($dir) into db
  }
}


As an output ... i get a list of all the files in the "images"  
folder preceeded by the all the list of root folders on my machine!!  
How do I eliminate the list of root folders?



Nevermind, I was looking at the wrong output. I got it!! I've got all  
my filenames in my $fileListArr[] array!!

Now I just to get the values in a mySQL table.


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 9:50 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?
I tried to very quickly convert something I've done. It may need  
some work. Will work in  linux env.


$origin = "Path"

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);


foreach($newArr as $dir){
   $pathArray = explode("/", $dir);

   $fileListArr = dirList($dir);

   foreach($fileListArr as $file){
   //Insert file($file) and current dir/path($dir) into db
   }
}

Kind regards
Warren




Warren,

I tried using your code and it definitely is very efficient & fast;  
however I'm running into a small problem and I'm not sure how to  
correct it. I'm getting the array with filenames from the folder I'm  
searching in PLUS all the root folders of the machine as well.


This is the code I'm using (note that I'm just echoing the array right  
now; I'll move to inserting data into mySQL after):


function dirList ($directory) {
   $results = array();
   $handler = opendir($directory);
   while ($file = readdir($handler)) {
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }
   closedir($handler);
   return $results;
}

$origin = "/Library/WebServer/Documents/folder1/folder2/images/";

#load file listing into an array
$shell = shell_exec("du $origin");
$array  = array_reverse(explode("\n",$shell));
$contIdArr = array();

$newArr = array();
foreach($array as $elem){
   $newDir = "";
   $pathArray = explode("/", $elem);
   $nodeDepth = count($pathArray);
   for($count=1; $count<$nodeDepth; $count++){
   $newDir = $newDir.$pathArray[$count].'/';
   }
   $newArr[] = '/'.$newDir;
}
sort($newArr);

foreach($newArr as $dir){
   $pathArray = explode("/", $dir);
   $fileListArr = dirList($dir);

   foreach($fileListArr as $file){
echo $file."";
   //Insert file($file) and current dir/path($dir) into db
   }
}


As an output ... i get a list of all the files in the "images" folder  
preceeded by the all the list of root folders on my machine!! How do I  
eliminate the list of root folders?


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 10:07 AM, Kenneth Sande wrote:



Ashley Sheridan wrote:

On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:



Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test \) and take all the filenames found in the directory (eg:  
1.vox,  2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com









You'll probably want to look at the readdir() function. The manual  
page
also has dozens of different example scripts that would be easy to  
tweak

for your purpose.

http://php.net/manual/en/function.readdir.php


Thanks,
Ash
http://www.ashleysheridan.co.uk




I use the glob function in my little homemade "web cam" page, which  
can really swell up in memory when used against a large amount of  
files (in my case around 30k files).

=
$imgdir = 'img/south*';
$files = glob( $imgdir );

// Sort files by modified time, latest to earliest
// Use SORT_ASC in place of SORT_DESC for earliest to latest
array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC,  
SORT_DESC, $files );

=
http://www.php.net/manual/en/function.glob.php
DISCLAIMER: I found this code on a how-to somewhere out there and  
modified it to fit my need. Quite possibly there are much better  
means to this end.


Ken Sande/KC8QNI





Considering that I have over 80K files in the folder, would this be a  
faster/efficient then the readdir() method? Or should I stick to what  
I'm doing (other email)?


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari


On Jan 13, 2010, at 9:56 AM, Warren Windvogel wrote:


On 2010/01/13 04:25 PM, Rahul S. Johari wrote:

Ave,

This is what I'm trying to do; I want to read a directory (eg: W: 
\Test\) and take all the filenames found in the directory (eg:  
1.vox, 2.wav, 3.txt) and store them in  a simple mySQL table.




Sorry. Forgot to include this.

function dirList ($directory)
{

   // create an array to hold directory list
   $results = array();

   // create a handler for the directory
   $handler = opendir($directory);

   // keep going until all files in directory have been read
   while ($file = readdir($handler)) {

   // if $file isn't this directory or its parent,
   // add it to the results array
   if ($file != '.' && $file != '..')
   $results[] = $file;
   }

   // tidy up: close the handler
   closedir($handler);

   // done!
   return $results;

}

If you're dealing with 1 directory you can use it to read all files  
in it to an array.


Kind regards
Warren




This is an interesting approach. Following is what I came up with to  
scan a directory and store the filenames into an array ... very  
similar to your example:


   $listDir = array();
$dir = "../mounts/wd/IDT/IDT/";
if($handler = opendir($dir)) {
while (($sub = readdir($handler)) !== FALSE) {
if ($sub != "." && $sub != ".." && $sub !=  
"Thumb.db") {

if(is_file($dir."/".$sub)) {
$listDir[] = $sub;
}elseif(is_dir($dir."/".$sub)){
$listDir[$sub] = $this- 
>ReadFolderDirectory($dir."/".$sub);

}
}
}
closedir($handler);
}

and this is what I'm trying to implement in order to store the array  
into a mysql table ..


$db = mysql_connect("localhost","usr","pwd");
mysql_select_db("db",$db);
			$colors=serialize($listDir); //takes the data from a post  
operation...
			$sql="INSERT INTO recordings (ID, RECORDING, ADDED)  
VALUES('','$colors','')";

$result = mysql_query($sql) or die (mysql_error());

I'm not sure if this the best or fastest approach ... but it's running  
in the background as I write this (I should have tested on a smaller  
folder). The folder I'm scanning has literally over 80,000 files ...  
so it's taking LOOONG!!


---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Kenneth Sande


Ashley Sheridan wrote:

On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:

  

Ave,

This is what I'm trying to do; I want to read a directory (eg: W:\Test 
\) and take all the filenames found in the directory (eg: 1.vox,  
2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com









You'll probably want to look at the readdir() function. The manual page
also has dozens of different example scripts that would be easy to tweak
for your purpose.

http://php.net/manual/en/function.readdir.php


Thanks,
Ash
http://www.ashleysheridan.co.uk



  
I use the glob function in my little homemade "web cam" page, which can 
really swell up in memory when used against a large amount of files (in 
my case around 30k files).

=
$imgdir = 'img/south*';
$files = glob( $imgdir );

// Sort files by modified time, latest to earliest
// Use SORT_ASC in place of SORT_DESC for earliest to latest
array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC, 
SORT_DESC, $files );

=
http://www.php.net/manual/en/function.glob.php
DISCLAIMER: I found this code on a how-to somewhere out there and 
modified it to fit my need. Quite possibly there are much better means 
to this end.


Ken Sande/KC8QNI


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



Re: [PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Ashley Sheridan
On Wed, 2010-01-13 at 09:25 -0500, Rahul S. Johari wrote:

> Ave,
> 
> This is what I'm trying to do; I want to read a directory (eg: W:\Test 
> \) and take all the filenames found in the directory (eg: 1.vox,  
> 2.wav, 3.txt) and store them in  a simple mySQL table.
> 
> Can I do this?
> 
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
> 
> [Email]   sleepwal...@rahulsjohari.com
> [Web] http://www.rahulsjohari.com
> 
> 
> 
> 
> 


You'll probably want to look at the readdir() function. The manual page
also has dozens of different example scripts that would be easy to tweak
for your purpose.

http://php.net/manual/en/function.readdir.php


Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] Read directory; store filenames found in mySQL table?

2010-01-13 Thread Rahul S. Johari

Ave,

This is what I'm trying to do; I want to read a directory (eg: W:\Test 
\) and take all the filenames found in the directory (eg: 1.vox,  
2.wav, 3.txt) and store them in  a simple mySQL table.


Can I do this?

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] sleepwal...@rahulsjohari.com
[Web]   http://www.rahulsjohari.com





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



Re: [PHP] [php] read/write error

2009-06-12 Thread HELP!
ALSO TRYING 0X0A or A still no respond. its realy frustrating becuase
written or readiing is a simple straight foward

On Wed, Jun 10, 2009 at 3:51 PM, Robin Vickery  wrote:

> 2009/6/8 HELP! 
>
>> opening of the sorket is ok and writting LOGIN packet to the sorket is
>> also
>> ok but reading the response to know if the login is accepted or rejected
>> is
>> a not OK.
>
>
> Don't use fread() to read from sockets, use stream_get_contents(). Example
> 3 on the fread() manual page tells you why.
>
> -robin
>



-- 
www.bemycandy.com


Re: [PHP] [php] read/write error

2009-06-12 Thread Robin Vickery
Hello Mr HELP!

2009/6/12 HELP! 
>
> I can not get the stream_get_contents() to work.  it's returning empty.

Is that simply because there's nothing to read from the socket?

> If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft, 
> "ALOGINPASS 1A"); or do you need to add other things

You've not told us what protocol you're using, but a quick google
search seems to indicate that you're trying to send a login request
message for a market data stream.

You appear to using the character 'A' as the request terminator,
whereas market data streams generally use 0x0A, which is a linefeed
character.

If the stream hasn't realised you've finished sending your login
request, then it won't send a response.

> what is the meaning of this string" GET / HTTP/1.0\r\nHost: 
> www.example.com\r\nAccept: */*\r\n\r\n"

It's a HTTP 1.0 GET request, but that doesn't seem to be consistent
with the rest of the data you've mentioned.

-robin

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



Re: [PHP] [php] read/write error

2009-06-12 Thread HELP!
I can not get the stream_get_contents() to work.  it's returning empty.
If you have a login details "ALOGINPASS 1A" cant you just fwrite($ft,
"ALOGINPASS 1A"); or do you need to add other things


what is the meaning of this string" GET / HTTP/1.0\r\nHost:
www.example.com\r\nAccept : */*\r\n\r\n"

On Wed, Jun 10, 2009 at 3:51 PM, Robin Vickery  wrote:

> 2009/6/8 HELP! 
>
>> opening of the sorket is ok and writting LOGIN packet to the sorket is
>> also
>> ok but reading the response to know if the login is accepted or rejected
>> is
>> a not OK.
>
>
> Don't use fread() to read from sockets, use stream_get_contents(). Example
> 3 on the fread() manual page tells you why.
>
> -robin
>



-- 
www.bemycandy.com


Re: [PHP] [php] read/write error

2009-06-10 Thread Robin Vickery
2009/6/8 HELP! 

> opening of the sorket is ok and writting LOGIN packet to the sorket is also
> ok but reading the response to know if the login is accepted or rejected is
> a not OK.


Don't use fread() to read from sockets, use stream_get_contents(). Example 3
on the fread() manual page tells you why.

-robin


[PHP] [php] read/write error

2009-06-08 Thread HELP!
opening of the sorket is ok and writting LOGIN packet to the sorket is also
ok but reading the response to know if the login is accepted or rejected is
a not OK.

please help
  $port ="xx";
 $ip ="xx.xx.xxx";

 $timeout = 30;


 $start ="L";
 $Login = "user  ";
 $Password ="pass  ";
 $session = "  ";
 $Sequence = " 1"; //
 $Terminator ="A";

 $LRG = "$start$Login$Password$session$Sequence$Terminator";

 $fsock = fsockopen($ip,$port, $errno, $errstr, $timeout);  // *OK
*
 if (!$fsock) {
  echo "$errstr ($errno)"; //"$errstr ($errno)\n";
 }
 else {
  $bits = fwrite($fsock,$LRG);
  echo "bits: $bits"; //*OK
*
  //read responds
  $contents = fread( $fsock, filesize($fsock)); //*ERROR
*  //echo stream_get_contents($fsock);

  echo filesize($contents);
  if($contents===FALSE) {
   echo "*THERE WAS AN ERROR READING*\n";
  }
  else{

   while ( ($buf=fread( $contents, 8192 )) != '' ) {

$contents .= $buf;
echo $contents."";
   }
  }
  fclose($fsock);
 }
-- 
www.bemycandy.com


Re: [PHP] read the last line in a file?

2009-05-17 Thread Michael A. Peters

Tom Worster wrote:



do you mean the pecl inotify extension? that would eliminate the polling and
the associated lag. but the php manual says it requires linux.


Yup - and it's kernel, so I don't think it could easily be ported to OS X.

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



Re: [PHP] read the last line in a file?

2009-05-17 Thread Per Jessen
Tom Worster wrote:

>> 1) the inotify interface will alert you when a file or directory
>> changes.
> 
> do you mean the pecl inotify extension? 

Not specifically, but if that's how inotify is available in PHP, then
yes. 

> that would eliminate the polling and the associated lag. but the php
> manual says it requires linux. if that's the case then it's not going
> to work for me. the app i'm working with runs on os x.

inotify comes with linux, yes.

>> 2) run tail -f logfile |  and read from stdin. (not
>> tested).
> 
> i thought of this but i couldn't see much difference between reading
> from stdin and opening the log file itself and reading from that
> (reading and tesing for eof periodically in both cases i suppose). but
> i may be missing something in your suggestion.

With the above, your code can just keep reading from stdi, no need to
check for eof etc. 

>> 3) if you can change the logfile to a fifo, you're all set.
> 
> i don't have any control over the app that writes the log file. if
> there were a utility like tail -f that opens a fifo for output rather
> than outputting to sdtout...

Once piped to your script, reading from stdout will be just like reading
from a fifo.  


/Per

-- 
Per Jessen, Zürich (16.2°C)


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



Re: [PHP] read the last line in a file?

2009-05-16 Thread Tom Worster
On 5/16/09 3:55 AM, "Per Jessen"  wrote:

> Tom Worster wrote:
> 
>> imagine writing a script to run as a daemon reading data off the
>> bottom of a log file that gets updated every few minutes and
>> processing each new log line as they arrive.
>> 
>> i could exec("tail $logfile", $lines, $status) every now and then. or
>> poll the file mtime and run exec("tail $logfile", $lines, $status)
>> when it changes. there will be some lag due to the polling interval.
>> 
>> but it would be nice to not have to poll the file and somehow trigger
>> the processing of the new line when the log file is written. but i'm
>> not sure how to do that.
>> 
>> any ideas?
> 
> 1) the inotify interface will alert you when a file or directory
> changes. 

do you mean the pecl inotify extension? that would eliminate the polling and
the associated lag. but the php manual says it requires linux. if that's the
case then it's not going to work for me. the app i'm working with runs on os
x.

os x 10.5 has FSEvents but i'm not sure that's much improvement on polling
the log file.


> 2) run tail -f logfile |  and read from stdin. (not tested).

i thought of this but i couldn't see much difference between reading from
stdin and opening the log file itself and reading from that (reading and
tesing for eof periodically in both cases i suppose). but i may be missing
something in your suggestion.


> 3) if you can change the logfile to a fifo, you're all set.

i don't have any control over the app that writes the log file. if there
were a utility like tail -f that opens a fifo for output rather than
outputting to sdtout...

thanks for the suggestions, per!



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



Re: [PHP] read the last line in a file?

2009-05-16 Thread Per Jessen
Tom Worster wrote:

> imagine writing a script to run as a daemon reading data off the
> bottom of a log file that gets updated every few minutes and
> processing each new log line as they arrive.
> 
> i could exec("tail $logfile", $lines, $status) every now and then. or
> poll the file mtime and run exec("tail $logfile", $lines, $status)
> when it changes. there will be some lag due to the polling interval.
> 
> but it would be nice to not have to poll the file and somehow trigger
> the processing of the new line when the log file is written. but i'm
> not sure how to do that.
> 
> any ideas?

1) the inotify interface will alert you when a file or directory
changes. 

2) run tail -f logfile |  and read from stdin. (not tested).

3) if you can change the logfile to a fifo, you're all set.


/Per


-- 
Per Jessen, Zürich (11.7°C)


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



[PHP] read the last line in a file?

2009-05-15 Thread Tom Worster
imagine writing a script to run as a daemon reading data off the bottom of a
log file that gets updated every few minutes and processing each new log
line as they arrive.

i could exec("tail $logfile", $lines, $status) every now and then. or poll
the file mtime and run exec("tail $logfile", $lines, $status) when it
changes. there will be some lag due to the polling interval.

but it would be nice to not have to poll the file and somehow trigger the
processing of the new line when the log file is written. but i'm not sure
how to do that.

any ideas?



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



Re: AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread Michael A. Peters

haliphax wrote:

On Mon, Mar 30, 2009 at 3:16 AM, Michael A. Peters  wrote:

Andrei Bintintan wrote:

Any other ideas?



Also - I believe the commercial (full) version of PDFlib can - in fact, I
believe you can do it with the pecl-pdflib library if you have the full
version of pdflib installed.

I seem to remember there work on a clibpdf php wrapper back when php 4 was
new, I don't know if it ever amounted to anything.


It may be worth your time to look into Adobe's IFilters. I know
they've got class libraries for C# and other .NET languages--those COM
DLLs could either be leveraged for PHP or there may be a "native" PHP
implementation.

Not in the mood to Google,



Just a note -

It looks overpriced for me but may be of value to corporate users, 
pdflib has a program called tet that can eat a pdf file and spit out an 
xml file with all kinds of groovy info about the pdf in it.


Wish I had a spare grand just to play with it (since I'm Linux only, 
even at home, the server license is only possibility for me).


It looks like tet would be superior way to grab info from pdf files for 
database/etc storage.


I wonder if xpdf/poppler-utils could be extended to do something similar 
under a FOSS license. But that's off topic for this list.


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



Re: AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread haliphax
On Mon, Mar 30, 2009 at 3:16 AM, Michael A. Peters  wrote:
> Andrei Bintintan wrote:
>>
>> Any other ideas?
>>
>>
>
> Also - I believe the commercial (full) version of PDFlib can - in fact, I
> believe you can do it with the pecl-pdflib library if you have the full
> version of pdflib installed.
>
> I seem to remember there work on a clibpdf php wrapper back when php 4 was
> new, I don't know if it ever amounted to anything.

It may be worth your time to look into Adobe's IFilters. I know
they've got class libraries for C# and other .NET languages--those COM
DLLs could either be leveraged for PHP or there may be a "native" PHP
implementation.

Not in the mood to Google,

-- 
// Todd

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



Re: AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread Michael A. Peters

Andrei Bintintan wrote:

Any other ideas?

 


Also - I believe the commercial (full) version of PDFlib can - in fact, 
I believe you can do it with the pecl-pdflib library if you have the 
full version of pdflib installed.


I seem to remember there work on a clibpdf php wrapper back when php 4 
was new, I don't know if it ever amounted to anything.


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



Re: AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread Michael A. Peters

Andrei Bintintan wrote:

Any other ideas?

 


I believe there is a windows binary called pdf2txt.exe out there somewhere.

I doubt you will find any solution that does not require installation of 
a binary on the server, so if you can't install xpdf on the server then 
you probably will have to send the file to another machine for reading.


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



AW: [PHP] Read Text Content from PDF file

2009-03-30 Thread Andrei Bintintan
Any other ideas?

 

 

Von: Bastien Koert [mailto:phps...@gmail.com] 
Gesendet: 20 March 2009 15:49
An: Andrei Bintintan
Cc: php-general@lists.php.net
Betreff: Re: [PHP] Read Text Content from PDF file

 

 

On Fri, Mar 20, 2009 at 10:23 AM, Andrei Bintintan 
wrote:

Could you be more precise? I'm looking at that class, but I can't see any
function that does that. 

Andy.

 

Von: Bastien Koert [mailto:phps...@gmail.com] 
Gesendet: 20 March 2009 14:57
An: Andrei Bintintan
Cc: php-general@lists.php.net
Betreff: Re: [PHP] Read Text Content from PDF file

 

 

On Fri, Mar 20, 2009 at 9:48 AM, Andrei Bintintan  wrote:

Hi to all,



I have to read the texts from PDF documents with PHP. A solution would be to
use http://www.foolabs.com/xpdf, but it is not installed on the server that
I work with and it is not wanted to be installed. So I have to look for
another solution.



Is there a possibility, PHP library, something with which I can READ the
texts from a PDF document with PHP?



Thanks a lot,

Andy.




http://www.setasign.de/products/pdf-php-solutions/fpdi FPDI makes it
possible. 

-- 

Bastien

Cat, the other other white meat



http://www.setasign.de/support/manuals/fpdi/ 

 

that is what a manual is for


-- 

Bastien

Cat, the other other white meat



Re: [PHP] Read Text Content from PDF file

2009-03-20 Thread Bastien Koert
On Fri, Mar 20, 2009 at 10:23 AM, Andrei Bintintan wrote:

>  Could you be more precise? I’m looking at that class, but I can’t see any
> function that does that.
>
> Andy.
>
>
>
> *Von:* Bastien Koert [mailto:phps...@gmail.com]
> *Gesendet:* 20 March 2009 14:57
> *An:* Andrei Bintintan
> *Cc:* php-general@lists.php.net
> *Betreff:* Re: [PHP] Read Text Content from PDF file
>
>
>
>
>
> On Fri, Mar 20, 2009 at 9:48 AM, Andrei Bintintan 
> wrote:
>
> Hi to all,
>
>
>
> I have to read the texts from PDF documents with PHP. A solution would be
> to
> use http://www.foolabs.com/xpdf, but it is not installed on the server
> that
> I work with and it is not wanted to be installed. So I have to look for
> another solution.
>
>
>
> Is there a possibility, PHP library, something with which I can READ the
> texts from a PDF document with PHP?
>
>
>
> Thanks a lot,
>
> Andy.
>
>
>
> http://www.setasign.de/products/pdf-php-solutions/fpdi FPDI makes it
> possible.
>
> --
>
> Bastien
>
> Cat, the other other white meat
>


http://www.setasign.de/support/manuals/fpdi/

that is what a manual is for

-- 

Bastien

Cat, the other other white meat


AW: [PHP] Read Text Content from PDF file

2009-03-20 Thread Andrei Bintintan
Could you be more precise? I'm looking at that class, but I can't see any
function that does that. 

Andy.

 

Von: Bastien Koert [mailto:phps...@gmail.com] 
Gesendet: 20 March 2009 14:57
An: Andrei Bintintan
Cc: php-general@lists.php.net
Betreff: Re: [PHP] Read Text Content from PDF file

 

 

On Fri, Mar 20, 2009 at 9:48 AM, Andrei Bintintan  wrote:

Hi to all,



I have to read the texts from PDF documents with PHP. A solution would be to
use http://www.foolabs.com/xpdf, but it is not installed on the server that
I work with and it is not wanted to be installed. So I have to look for
another solution.



Is there a possibility, PHP library, something with which I can READ the
texts from a PDF document with PHP?



Thanks a lot,

Andy.





http://www.setasign.de/products/pdf-php-solutions/fpdi FPDI makes it
possible. 

-- 

Bastien

Cat, the other other white meat



Re: [PHP] Read Text Content from PDF file

2009-03-20 Thread Bastien Koert
On Fri, Mar 20, 2009 at 9:48 AM, Andrei Bintintan  wrote:

> Hi to all,
>
>
>
> I have to read the texts from PDF documents with PHP. A solution would be
> to
> use http://www.foolabs.com/xpdf, but it is not installed on the server
> that
> I work with and it is not wanted to be installed. So I have to look for
> another solution.
>
>
>
> Is there a possibility, PHP library, something with which I can READ the
> texts from a PDF document with PHP?
>
>
>
> Thanks a lot,
>
> Andy.
>
>
>
>
http://www.setasign.de/products/pdf-php-solutions/fpdi FPDI makes it
possible.

-- 

Bastien

Cat, the other other white meat


[PHP] Read Text Content from PDF file

2009-03-20 Thread Andrei Bintintan
Hi to all, 

 

I have to read the texts from PDF documents with PHP. A solution would be to
use http://www.foolabs.com/xpdf, but it is not installed on the server that
I work with and it is not wanted to be installed. So I have to look for
another solution. 

 

Is there a possibility, PHP library, something with which I can READ the
texts from a PDF document with PHP? 

 

Thanks a lot, 

Andy.

 



RES: [PHP] Read a XML (not a file)

2009-02-06 Thread Jônatas Zechim
But the 'server.php' is on another Server, i did this and is ok now.

function ctalk_fopen($u){
$b=parse_url($u);
$h=$b['host'];
$p=(isset($b['query']))?$b['path']."?".$b['query']:$b['path'];
$s=socket_create(AF_INET,SOCK_STREAM,0);
socket_set_block($s);
$r=socket_connect($s,gethostbyname($h),getservbyname('www','tcp'));
$i="GET $p HTTP/1.1\r\nHost: $h\r\nConnection: close\r\n\r\n";
socket_write($s,$i,strlen($i));
$r='';
while($o=socket_read($s,4096)){$r=$r.$o;}
socket_close($s);
$c=preg_split("/\r?\n\r?\n/", $r,2);
return $c[1];
}

$u = "http://localhost/xml/server.php";;

function ctalk_se($xp,$a){global $f;}
function ctalk_ee($xp,$n){global $f,$i;$k=$n;$f[$k]=$i;$i="";}
function ctalk_dt($xp,$d){global $i;$i.=$d;}

$xp=xml_parser_create();
xml_set_element_handler($xp,"ctalk_se","ctalk_ee");
xml_set_character_data_handler($xp,"ctalk_dt");
xml_parse($xp,ctalk_fopen($u),true);

print_r($f);
returns an array of the XML that server.php had output.

Zechim



-Mensagem original-
De: Jim Lucas [mailto:li...@cmsws.com] 
Enviada em: sexta-feira, 6 de fevereiro de 2009 14:39
Para: Jônatas Zechim
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Read a XML (not a file)

Jônatas Zechim wrote:
> Hi there, i want do read a XML like this:
> 
> Server.php
>  
>   header ("content-type: text/xml");
> 
> echo "   
>   1
>teste
>/images/teste.jpg
>  
> ";
> ?>
> 
> How can do this?
> 
> zechim
> 
> 

test.php


mind you that the header() call within the include is going to change the 
default headers(), so be sure to reset the content-type one you come out of
the include file.


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


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



Re: [PHP] Read a XML (not a file)

2009-02-06 Thread Jim Lucas
Jônatas Zechim wrote:
> Hi there, i want do read a XML like this:
> 
> Server.php
>  
>   header ("content-type: text/xml");
> 
> echo "   
>   1
>teste
>/images/teste.jpg
>  
> ";
> ?>
> 
> How can do this?
> 
> zechim
> 
> 

test.php


mind you that the header() call within the include is going to change the 
default headers(), so be sure to reset the content-type one you come out of
the include file.


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

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



Re: [PHP] Read a XML (not a file)

2009-02-06 Thread Carlos Medina

Phpster schrieb:



On Feb 6, 2009, at 9:12, Jônatas Zechim  wrote:


Hi there, i want do read a XML like this:

Server.php
   
 1
  teste
  /images/teste.jpg

";
?>

How can do this?

zechim


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



Remove the php tags and code, and just save the file as XML. Then you 
can have another file read in and or echo the HTML



Bastien

Hi,
call the site to generate the XML data with simplexml function

$xml = simplexml_load_string( fopen("http://www.example.com/";, "r") );

But if we want to be serious: Use classes to do this is better.

Regards

Carlos


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



Re: [PHP] Read a XML (not a file)

2009-02-06 Thread Phpster



On Feb 6, 2009, at 9:12, Jônatas Zechim  wrote:


Hi there, i want do read a XML like this:

Server.php
   
 1
  teste
  /images/teste.jpg

";
?>

How can do this?

zechim


--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php



Remove the php tags and code, and just save the file as XML. Then you  
can have another file read in and or echo the HTML



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



[PHP] Read a XML (not a file)

2009-02-06 Thread Jônatas Zechim
Hi there, i want do read a XML like this:

Server.php
   
  1
   teste
   /images/teste.jpg
 
";
?>

How can do this?

zechim


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



Re: [PHP] Read Form values prior to submit?

2008-12-28 Thread Tim Rude
Thanks! I haven't played with javascript but it looks pretty
straight-forward. I appreciate the samples.

Tim Rude

-- 

"tedd"  wrote in message
news:p06240817c57d610ba...@[192.168.1.101]...
> At 9:41 AM -0600 12/28/08, Tim Rude wrote:
> >Using PHP, is there a way for me to read the values that a user has
> >entered into the text fields of a  prior to the user clicking
the
> >submit button?
> >
> >Essentially what I want to do is make sure the user has filled in all
> >three text fields on my form before allowing it to be submitted [to a
> >third party website].
> >
> >--
> >
> >Tim Rude [PHP newbie]
>
> Tim:
>
> Can not do that using php. Php is server-side and hasn't a clue as to
> what the user is doing until the user clicks the submit.
>
> If you want to check for user input in real-time, then you'll have to
> do that client-side with javascript.
>
> Here's an example:
>
> http://webbytedd.com/c/form-submit/
>
> All the code is there -- use as you may.
>
> Cheers,
>
> tedd
>
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com



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



Re: [PHP] Read Form values prior to submit?

2008-12-28 Thread tedd

At 9:41 AM -0600 12/28/08, Tim Rude wrote:

Using PHP, is there a way for me to read the values that a user has
entered into the text fields of a  prior to the user clicking the
submit button?

Essentially what I want to do is make sure the user has filled in all
three text fields on my form before allowing it to be submitted [to a
third party website].

--

Tim Rude [PHP newbie]


Tim:

Can not do that using php. Php is server-side and hasn't a clue as to 
what the user is doing until the user clicks the submit.


If you want to check for user input in real-time, then you'll have to 
do that client-side with javascript.


Here's an example:

http://webbytedd.com/c/form-submit/

All the code is there -- use as you may.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Read Form values prior to submit?

2008-12-28 Thread Thiago H. Pojda
On Sun, Dec 28, 2008 at 12:41 PM, Tim Rude  wrote:
> Using PHP, is there a way for me to read the values that a user has
> entered into the text fields of a  prior to the user clicking the
> submit button?

If the user doesnt press the submit button PHP has no idea what's
going on there.

That's client-side and you should use JavaScript for that.

> Essentially what I want to do is make sure the user has filled in all
> three text fields on my form before allowing it to be submitted [to a
> third party website].

In case you have a specific business logic in that field and don't
want the user to know about it, you should use AJAX.

But this sounds simple, a small JS should help you.

The JS can submit the form, if it's okay. Or you can add a action to
form's onsubmit event. (you can "return false" if the validation
fails).

Hope this helps!

Regards,
Thiago Henrique Pojda
nerdnaweb.blogspot DOT com

> --
>
> Tim Rude [PHP newbie]
>
>
>
> --
> 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] Read/decode barcodes from an image

2008-12-18 Thread ceo

Certainly if the quality of the input can be improved by using some digital 
transfer that is not a fax, go for it...



I assumed the OP already knew that, but perhaps not.



The fax is going to cost you a LOT of accuracy, probably too much to make OCR 
even viable, really, but it depends on the faxes involved.  If it's always the 
same two fax machines, and they are both set at image quality and have good 
feeders, you *might* get halfway decent quality out of them.



If you're talking random faxes from random people, then forget about OCR. Not 
gonna work.



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



RE: [PHP] Read/decode barcodes from an image

2008-12-18 Thread Boyd, Todd M.
> -Original Message-
> From: c...@l-i-e.com [mailto:c...@l-i-e.com]
> Sent: Thursday, December 18, 2008 10:06 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Read/decode barcodes from an image
> 
> The barcodes are on faxes and whatnot, with no predictable skew,
> position, nor orientation.
> 
> You've tried JOCR/GOCR, and they don't do very well.
> 
> Here are your options:
> 1) Shell out the money for that PaperPort OMNI or whatever it is
> commercial OCR product. It *is* better than JOCR/GOCR, in my
> experience.
> [If you Google for OCR you'll find it, as it's the only/best
contender,
> and referenced everywhere.]
> 
> 2) Roll your own with GD. With sufficient skill and time, you can
> utilize very specific knowledge of your content to do even better than
> the generalized commercial solution. I have done this myself for
> standardized medical documents that were scanned in, getting a
> percentage point or two better than 1)
> 
> No matter what you do, OCR will never ever get you 100%.  You WILL
need
> a human oversight process on the results that hand-checks everything,
> or be prepared to accept a (small) failure rate.
> 
> Set your [client's] expectations properly, or be doomed to frustration
> [failure].

I had always thought that faxes were a big no-no for character
recognition software? I know that we can't use it for one of our OCR
solutions because it is just too... well, crappy. The image quality is
nowhere near what it should be for a successful OCR pass.

As for client expectations: hell yes--tell them not to use a fax machine
in the digital age. Scan the document and e-mail it or something. Where
I work, we've done away with 90% of any fax machine usage in order to
have documents that can be used by our OCR solution.

My 2c,


// Todd

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



Re: [PHP] Read/decode barcodes from an image

2008-12-18 Thread ceo

AIUI:



The barcodes are on faxes and whatnot, with no predictable skew, position, nor 
orientation.



You've tried JOCR/GOCR, and they don't do very well.



Here are your options:

1) Shell out the money for that PaperPort OMNI or whatever it is commercial OCR 
product. It *is* better than JOCR/GOCR, in my experience.

[If you Google for OCR you'll find it, as it's the only/best contender, and 
referenced everywhere.]



2) Roll your own with GD. With sufficient skill and time, you can utilize very 
specific knowledge of your content to do even better than the generalized 
commercial solution. I have done this myself for standardized medical documents 
that were scanned in, getting a percentage point or two better than 1)



No matter what you do, OCR will never ever get you 100%.  You WILL need a human 
oversight process on the results that hand-checks everything, or be prepared to 
accept a (small) failure rate.



Set your [client's] expectations properly, or be doomed to frustration 
[failure].





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



Re: [PHP] Read/decode barcodes from an image

2008-12-18 Thread Per Jessen
Adam Randall wrote:

> I'm amazed that this either doesn't exist, or is hard to find. I
> basically am looking for a way to read in an image into PHP, or shell
> out to something on the Linux side, and determine, and see if it has a
> barcode in it or not. If it does, I need to decode the barcode so that
> I can identify the page as a separator page or not.
> 
> Basically, what I'm doing is reading in a PDF or TIF which will
> contain multiple pages (probably a lot of pages) and look for a page
> containing a barcode. The barcode will identify the page as a
> separator page which will be used to split the multipage document into
> smaller single or multipage documents.
> 
> Has anyone ever heard of anything that might help me in this process?

I can't say for certain, but have a look at zebra:

http://zebra.sourceforge.net/

Looks like the sort of thing you could use. 


/Per Jessen, Zürich


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



Re: [PHP] Read/decode barcodes from an image

2008-12-17 Thread Adam Randall
Are you referring to a project, class, or just generally curious about
what I'm asking? Barcode reader can be many things, including a
scanning wand (not applicable to what I am looking for).

On Wed, Dec 17, 2008 at 3:47 PM, Robert Cummings  wrote:
> On Wed, 2008-12-17 at 14:56 -0800, Adam Randall wrote:
>> I'm amazed that this either doesn't exist, or is hard to find. I
>> basically am looking for a way to read in an image into PHP, or shell
>> out to something on the Linux side, and determine, and see if it has a
>> barcode in it or not. If it does, I need to decode the barcode so that
>> I can identify the page as a separator page or not.
>>
>> Basically, what I'm doing is reading in a PDF or TIF which will
>> contain multiple pages (probably a lot of pages) and look for a page
>> containing a barcode. The barcode will identify the page as a
>> separator page which will be used to split the multipage document into
>> smaller single or multipage documents.
>>
>> Has anyone ever heard of anything that might help me in this process?
>
> Barcode reader?
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>



-- 
Adam Randall
AIM: blitz574

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



Re: [PHP] Read/decode barcodes from an image

2008-12-17 Thread Robert Cummings
On Wed, 2008-12-17 at 14:56 -0800, Adam Randall wrote:
> I'm amazed that this either doesn't exist, or is hard to find. I
> basically am looking for a way to read in an image into PHP, or shell
> out to something on the Linux side, and determine, and see if it has a
> barcode in it or not. If it does, I need to decode the barcode so that
> I can identify the page as a separator page or not.
> 
> Basically, what I'm doing is reading in a PDF or TIF which will
> contain multiple pages (probably a lot of pages) and look for a page
> containing a barcode. The barcode will identify the page as a
> separator page which will be used to split the multipage document into
> smaller single or multipage documents.
> 
> Has anyone ever heard of anything that might help me in this process?

Barcode reader?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Read/decode barcodes from an image

2008-12-17 Thread Adam Randall
I'm amazed that this either doesn't exist, or is hard to find. I
basically am looking for a way to read in an image into PHP, or shell
out to something on the Linux side, and determine, and see if it has a
barcode in it or not. If it does, I need to decode the barcode so that
I can identify the page as a separator page or not.

Basically, what I'm doing is reading in a PDF or TIF which will
contain multiple pages (probably a lot of pages) and look for a page
containing a barcode. The barcode will identify the page as a
separator page which will be used to split the multipage document into
smaller single or multipage documents.

Has anyone ever heard of anything that might help me in this process?

Adam.
-- 
Adam Randall
AIM: blitz574

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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

I had to add the full path and it works just fine.
Thanks

Well, make sure $rootPath is correct for your environment.  Also, add a
slash after the directory name.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files


foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)
   


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = "$rootPath/$dirNum";
chdir($dir);
$files = glob("13*");
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

Version 5
  


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  
  

I am trying to read a bunch of files that are in many directors
into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file="/remote/0/13*";
$data ="";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data



  
  



  
  
  





  



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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Micah Gersten
Well, make sure $rootPath is correct for your environment.  Also, add a
slash after the directory name.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
> *Now I get  this error
> Warning*: chdir() [function.chdir]: No error (errno 0) in
> *C:\web\easycontactpro\removeemail.php* on line *7*
> Where can I find what errno 0 means
> it loops through all the directors but does not process any of the files
>> foreach (range(0,22) as $dirNum)
>>
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> Richard Kurth wrote:
>>  
>>> *I get this when I run it
>>> Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
>>> line *4
>>> it does not like the *foreach (0..22 as $dirNum)
>>>
 Try this:

 $rootPath = '/remote';
 $string = '';
 foreach (0..22 as $dirNum)
 {
 $dir = "$rootPath/$dirNum";
 chdir($dir);
 $files = glob("13*");
 foreach ($files as $file)
 {
$string .= file_get_contents($file);
 }
 }

 echo $string;
   Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
  
> Version 5
>   
>> First, which version of PHP?  PHP 5 added a lot of features for
>> reading
>> files.
>>
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> Richard Kurth wrote:
>>  
>>   
>>> I am trying to read a bunch of files that are in many directors
>>> into
>>> one string
>>> But it will only read one file.
>>> Every file is a number 134328923 but they all start with 13
>>> They are in 22 directors named 0 to 22
>>> How can I make the script look in each directory and read each file
>>> into a string that is one line after another.
>>> There is only one line per file they are email address
>>>
>>> $file="/remote/0/13*";
>>> $data ="";
>>> $fp = fopen($file, "r");
>>> while(!feof($fp)) {
>>> $data .= fgets($fp, 1024);
>>> }
>>>
>>> echo $data
>>>
>>> 
>>   
> 
 
>>
>>   
>
>
>

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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Richard Kurth

*Now I get  this error
Warning*: chdir() [function.chdir]: No error (errno 0) in
*C:\web\easycontactpro\removeemail.php* on line *7*
Where can I find what errno 0 means
it loops through all the directors but does not process any of the files

foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
line *4
it does not like the *foreach (0..22 as $dirNum)


Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = "$rootPath/$dirNum";
chdir($dir);
$files = glob("13*");
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
  
Thank you,

Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

Version 5
   


First, which version of PHP?  PHP 5 added a lot of features for
reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
 
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file="/remote/0/13*";
$data ="";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data




  


  
  


  




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



Re: [PHP] read a bunch of files that are in many directors into one string -- oops again

2008-08-07 Thread Micah Gersten
foreach (range(0,22) as $dirNum)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
> *I get this when I run it
> Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
> line *4
> it does not like the *foreach (0..22 as $dirNum)
>> Try this:
>>
>> $rootPath = '/remote';
>> $string = '';
>> foreach (0..22 as $dirNum)
>> {
>> $dir = "$rootPath/$dirNum";
>> chdir($dir);
>> $files = glob("13*");
>> foreach ($files as $file)
>> {
>>$string .= file_get_contents($file);
>> }
>> }
>>
>> echo $string;
>>   
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> Richard Kurth wrote:
>>  
>>> Version 5
>>>
 First, which version of PHP?  PHP 5 added a lot of features for
 reading
 files.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
  
> I am trying to read a bunch of files that are in many directors into
> one string
> But it will only read one file.
> Every file is a number 134328923 but they all start with 13
> They are in 22 directors named 0 to 22
> How can I make the script look in each directory and read each file
> into a string that is one line after another.
> There is only one line per file they are email address
>
> $file="/remote/0/13*";
> $data ="";
> $fp = fopen($file, "r");
> while(!feof($fp)) {
> $data .= fgets($fp, 1024);
> }
>
> echo $data
>
> 
 
>>> 
>>
>>   

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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Micah Gersten
oops.
foreach (range(0..22) as $dirNum)

:)

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
> *I get this when I run it
> Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on
> line *4
> it does not like the *foreach (0..22 as $dirNum)
>> Try this:
>>
>> $rootPath = '/remote';
>> $string = '';
>> foreach (0..22 as $dirNum)
>> {
>> $dir = "$rootPath/$dirNum";
>> chdir($dir);
>> $files = glob("13*");
>> foreach ($files as $file)
>> {
>>$string .= file_get_contents($file);
>> }
>> }
>>
>> echo $string;
>>   
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> Richard Kurth wrote:
>>  
>>> Version 5
>>>
 First, which version of PHP?  PHP 5 added a lot of features for
 reading
 files.

 Thank you,
 Micah Gersten
 onShore Networks
 Internal Developer
 http://www.onshore.com



 Richard Kurth wrote:
  
  
> I am trying to read a bunch of files that are in many directors into
> one string
> But it will only read one file.
> Every file is a number 134328923 but they all start with 13
> They are in 22 directors named 0 to 22
> How can I make the script look in each directory and read each file
> into a string that is one line after another.
> There is only one line per file they are email address
>
> $file="/remote/0/13*";
> $data ="";
> $fp = fopen($file, "r");
> while(!feof($fp)) {
> $data .= fgets($fp, 1024);
> }
>
> echo $data
>
> 
 
>>> 
>>
>>   

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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth

*I get this when I run it
Parse error*: syntax error, unexpected T_DNUMBER in *remove.php* on line *4
it does not like the *foreach (0..22 as $dirNum)

Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = "$rootPath/$dirNum";
chdir($dir);
$files = glob("13*");
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
   


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

Version 5


First, which version of PHP?  PHP 5 added a lot of features for reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
 
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file="/remote/0/13*";
$data ="";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data



  
  



  



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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Micah Gersten
Try this:

$rootPath = '/remote';
$string = '';
foreach (0..22 as $dirNum)
{
$dir = "$rootPath/$dirNum";
chdir($dir);
$files = glob("13*");
foreach ($files as $file)
{
   $string .= file_get_contents($file);
}
}

echo $string;
   

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
> Version 5
>> First, which version of PHP?  PHP 5 added a lot of features for reading
>> files.
>>
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>>
>>
>> Richard Kurth wrote:
>>  
>>> I am trying to read a bunch of files that are in many directors into
>>> one string
>>> But it will only read one file.
>>> Every file is a number 134328923 but they all start with 13
>>> They are in 22 directors named 0 to 22
>>> How can I make the script look in each directory and read each file
>>> into a string that is one line after another.
>>> There is only one line per file they are email address
>>>
>>> $file="/remote/0/13*";
>>> $data ="";
>>> $fp = fopen($file, "r");
>>> while(!feof($fp)) {
>>> $data .= fgets($fp, 1024);
>>> }
>>>
>>> echo $data
>>>
>>> 
>>
>>   
>
>

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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth

Version 5

First, which version of PHP?  PHP 5 added a lot of features for reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
  

I am trying to read a bunch of files that are in many directors into
one string
But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file
into a string that is one line after another.
There is only one line per file they are email address

$file="/remote/0/13*";
$data ="";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data




  



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



Re: [PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Micah Gersten
First, which version of PHP?  PHP 5 added a lot of features for reading
files.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Kurth wrote:
> I am trying to read a bunch of files that are in many directors into
> one string
> But it will only read one file.
> Every file is a number 134328923 but they all start with 13
> They are in 22 directors named 0 to 22
> How can I make the script look in each directory and read each file
> into a string that is one line after another.
> There is only one line per file they are email address
>
> $file="/remote/0/13*";
> $data ="";
> $fp = fopen($file, "r");
> while(!feof($fp)) {
> $data .= fgets($fp, 1024);
> }
>
> echo $data
>

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



[PHP] read a bunch of files that are in many directors into one string

2008-08-07 Thread Richard Kurth
I am trying to read a bunch of files that are in many directors into one 
string

But it will only read one file.
Every file is a number 134328923 but they all start with 13
They are in 22 directors named 0 to 22
How can I make the script look in each directory and read each file into 
a string that is one line after another.

There is only one line per file they are email address

$file="/remote/0/13*";
$data ="";
$fp = fopen($file, "r");
while(!feof($fp)) {
$data .= fgets($fp, 1024);
}

echo $data

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



[PHP] read xml files with namespaces

2008-05-27 Thread Selwyn Polit
I am writing code to read a bunch of xml files which describe 
pharmaceutical drugs.  They have namespace references at the top of each 
file that look like this:


http://www.hl7.org/v3/voc"; xmlns="urn:hl7-org:v3" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="urn:hl7-org:v3 
http://www.fda.gov/oc/datacouncil/schemas/spl/spl.xsd";>


I am having a challenging time coming up with an xpath query that works 
even after registering a namespace like this:


 $xpath->registerNamespace("voc","http://www.hl7.org/v3/voc"; );

I am trying a query like this:

$qry = '//component' ;
$nodeList = $xpath->query($qry);

I can't seem to make it work.  Could someone please advise?

thanks
Selwyn


The whole program looks like this:

$dom=new DOMDocument;
$dom->load('./828C40F4-5969-4254-9008-36AF15CC601B.xml') ;
$qry = '//component' ;
$nodeList = $xpath->query($qry);

header('Content-Type: text/plain');
foreach ($nodeList as $node)
{
echo $dom->saveXML($node) . "\r\n";
}



--
Selwyn Polit
Computer Consulting, programming, web sites
512-696-0410
www.AustinProgressiveCalendar.com


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



Re: [PHP] read email

2007-12-30 Thread Richard Lynch
On Sun, December 30, 2007 2:19 pm, Yui Hiroaki wrote:
> HI!
>
> I am trying to access qmail with php.
>
> Why!
> Because I would like to read mail who someone send an email me to
> qmail.
>
> If anyone knows the code, please send me the code.

http://php.net/imap

Sample Code:

http://l-i-e.com/imap/index.phps

Some spam filtering I set up to catch what slips through spam assasin
and get the email sorted server-side rather than have my desktop
client CHOKES trying to sort out thousands of emails upon login...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] read email

2007-12-30 Thread Børge Holen
On Sunday 30 December 2007 21:19:16 Yui Hiroaki wrote:
> HI!
>
> I am trying to access qmail with php.
>
> Why!
> Because I would like to read mail who someone send an email me to qmail.
>
> If anyone knows the code, please send me the code.


NOW that was straight forward 
I always thought the easiest way to figure out how this works, is to take 
appart... something like squirrelmail or openwebmail... even something like 
the one we use on our students at work, a short name, like zork dork work... 
can't remember. :).
Even so, never got to it and forgot about it. Never thought about the shortcut 
of askin' here...
However, why doesn't this seem likely ;D


>
> Regards,
> Yui



-- 
---
Børge Holen
http://www.arivene.net

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



[PHP] read email

2007-12-30 Thread Yui Hiroaki
HI!

I am trying to access qmail with php.

Why!
Because I would like to read mail who someone send an email me to qmail.

If anyone knows the code, please send me the code.

Regards,
Yui


Re: [PHP] read post data as a buffer

2007-09-25 Thread Jürgen Wind

You may be looking for this :
http://martinjansen.com/2007/04/upload-progress/  

David Blanco-3 wrote:
> 
> Hi!
> 
> I think that is not possible to read post data as a buffer with php like
> it´s in perl. If this is true, how do you deal with large file uploads
> to know the status of the operation at any time?
> 
> Thanks
> 
> Greetings from Spain
> -- 
> David Blanco
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/read-post-data-as-a-buffer-tf4514831.html#a12879787
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] read post data as a buffer

2007-09-25 Thread David Blanco
Hi!

I think that is not possible to read post data as a buffer with php like
it´s in perl. If this is true, how do you deal with large file uploads
to know the status of the operation at any time?

Thanks

Greetings from Spain
-- 
David Blanco

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



RE: [PHP] read the main domain cookie in sub domain

2007-09-18 Thread Sanjeev N
Hey Stut, Thanks.. 
Now its working fine. Now I am able to access the value. Actually problem
was in main domain the cookies path was wrong. It was showing /user/ . I set
it to /

Thanks Stut.

Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan

-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 19, 2007 12:46 AM
To: Sanjeev N
Cc: php-general@lists.php.net
Subject: Re: [PHP] read the main domain cookie in sub domain

Sanjeev N wrote:
> I did it. Still I am not able to access it. 

You'll probably need to delete the existing cookie from your browser and 
get it set again.

-Stut

> -Original Message-
> From: Stut [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 19, 2007 12:41 AM
> To: Sanjeev N
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] read the main domain cookie in sub domain
> 
> Sanjeev N wrote:
>> Assume, I have www.domain.com <http://www.domain.com/>  in which I wrote
> the
>> functionality for user authentication and his profile related
> functionality.
>> Now, when user logs in using http://www.domain.com/users/login.php then
>> after his successful login a session as well as a cookie is getting
> created.
>> This will creates a cookie called myCookie123
>>
>> Now I have my subdomain as http://sub.domain.com/index.php . here at the
> top
>> I am checking whether the user is logged in or not, for that I have to
> check
>> whether the cookie is created or not..
>>
>> Here my problem is that, I am not getting the idea about, how to access
or
>> read the cookie of http://www.domain.com <http://www.domain.com/>  from
>> http://sub.domain.com/. can anyone please suggest me how to achieve this.
> 
> Set the $domain parameter of setcookie to '.domain.com'.
> 
> -Stut
> 

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



Re: [PHP] read the main domain cookie in sub domain

2007-09-18 Thread Stut

Sanjeev N wrote:
I did it. Still I am not able to access it. 


You'll probably need to delete the existing cookie from your browser and 
get it set again.


-Stut


-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 19, 2007 12:41 AM

To: Sanjeev N
Cc: php-general@lists.php.net
Subject: Re: [PHP] read the main domain cookie in sub domain

Sanjeev N wrote:

Assume, I have www.domain.com <http://www.domain.com/>  in which I wrote

the

functionality for user authentication and his profile related

functionality.

Now, when user logs in using http://www.domain.com/users/login.php then
after his successful login a session as well as a cookie is getting

created.

This will creates a cookie called myCookie123

Now I have my subdomain as http://sub.domain.com/index.php . here at the

top

I am checking whether the user is logged in or not, for that I have to

check

whether the cookie is created or not..

Here my problem is that, I am not getting the idea about, how to access or
read the cookie of http://www.domain.com <http://www.domain.com/>  from
http://sub.domain.com/. can anyone please suggest me how to achieve this.


Set the $domain parameter of setcookie to '.domain.com'.

-Stut



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



RE: [PHP] read the main domain cookie in sub domain

2007-09-18 Thread Sanjeev N
I did it. Still I am not able to access it. 

Warm Regards,
Sanjeev
http://www.sanchanworld.com/
http://webdirectory.sanchanworld.com - Submit your website URL
http://webhosting.sanchanworld.com - Choose your best web hosting plan
-Original Message-
From: Stut [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 19, 2007 12:41 AM
To: Sanjeev N
Cc: php-general@lists.php.net
Subject: Re: [PHP] read the main domain cookie in sub domain

Sanjeev N wrote:
> Assume, I have www.domain.com <http://www.domain.com/>  in which I wrote
the
> functionality for user authentication and his profile related
functionality.
> 
> Now, when user logs in using http://www.domain.com/users/login.php then
> after his successful login a session as well as a cookie is getting
created.
> 
> This will creates a cookie called myCookie123
> 
> Now I have my subdomain as http://sub.domain.com/index.php . here at the
top
> I am checking whether the user is logged in or not, for that I have to
check
> whether the cookie is created or not..
> 
> Here my problem is that, I am not getting the idea about, how to access or
> read the cookie of http://www.domain.com <http://www.domain.com/>  from
> http://sub.domain.com/. can anyone please suggest me how to achieve this.

Set the $domain parameter of setcookie to '.domain.com'.

-Stut

-- 
http://stut.net/

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



Re: [PHP] read the main domain cookie in sub domain

2007-09-18 Thread Stut

Sanjeev N wrote:

Assume, I have www.domain.com   in which I wrote the
functionality for user authentication and his profile related functionality.

Now, when user logs in using http://www.domain.com/users/login.php then
after his successful login a session as well as a cookie is getting created.

This will creates a cookie called myCookie123

Now I have my subdomain as http://sub.domain.com/index.php . here at the top
I am checking whether the user is logged in or not, for that I have to check
whether the cookie is created or not..

Here my problem is that, I am not getting the idea about, how to access or
read the cookie of http://www.domain.com   from
http://sub.domain.com/. can anyone please suggest me how to achieve this.


Set the $domain parameter of setcookie to '.domain.com'.

-Stut

--
http://stut.net/

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



[PHP] read the main domain cookie in sub domain

2007-09-18 Thread Sanjeev N
Hi,

 

Assume, I have www.domain.com   in which I wrote the
functionality for user authentication and his profile related functionality.

Now, when user logs in using http://www.domain.com/users/login.php then
after his successful login a session as well as a cookie is getting created.

This will creates a cookie called myCookie123

 

Now I have my subdomain as http://sub.domain.com/index.php . here at the top
I am checking whether the user is logged in or not, for that I have to check
whether the cookie is created or not..

 

Here my problem is that, I am not getting the idea about, how to access or
read the cookie of http://www.domain.com   from
http://sub.domain.com/. can anyone please suggest me how to achieve this.

 

Thanks In advance.

 

Warm Regards,

Sanjeev

http://www.sanchanworld.com/

http://webdirectory.sanchanworld.com - Submit your website URL

http://webhosting.sanchanworld.com - Choose your best web hosting plan

 



RE: [PHP] read only?

2007-08-23 Thread Chris Boget
> Is there a simple php way to make a webpage read-only, please? 

Webpages are already read only.  Well, read only in the browser.  There
is nothing to prevent the user from saving the page and altering to
their hearts content.

Did you mean to ask if there was a simple way to make a *form* read
only?  If so, you can simply add the 'readonly' attribute to the form
elements (although, that won't work with select boxes, radio buttons or
checkboxes, I believe).  Also, you can look into PEAR's QuickForm; it
has a Freeze Form and Freeze Element feature.

thnx,
Chris

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



[PHP] read only?

2007-08-23 Thread coolcoder

Is there a simple php way to make a webpage read-only, please? 






www.coderewind.com
Best Place to hunt for Code 
-- 
View this message in context: 
http://www.nabble.com/read-only--tf4316703.html#a12291195
Sent from the PHP - General mailing list archive at Nabble.com.

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



Re: [PHP] read only texbox to html with php

2007-03-23 Thread Richard Lynch
The fact that you are using stripslashes tells me that something is
very very very wrong somewhere...

For output to the textarea, just htmlentities should be sufficient.

Emailing HTML "enhanced" newsletter will reduce the number of people
who actually read the dang thing, you know.

On Wed, March 21, 2007 6:51 am, Ross wrote:
> I have a readonly textbox that gets mailed as a newsletter. The text
> is a
> standard covering letter. The problem is when I try and convert it to
> html
> it doesn't work  It is inserted into a variable via a form textarea
> $mail_text.
>
>  "available on the web site  href="http://www.myurl.org";>http://www.myurl.org so you can see
> who is
> doing."
>
> I tried this
>
> htmlentities((stripslashes($mail_text)));
>
>
> Any ideas?
>
> R.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] read only texbox to html with php

2007-03-21 Thread Edward Kay
2007. 03. 21, szerda keltezéssel 11.51-kor Ross ezt írta:
> I have a readonly textbox that gets mailed as a newsletter. The 
text is a 
> standard covering letter. The problem is when I try and convert 
it to html 
> it doesn't work  It is inserted into a variable via a form textarea 
> $mail_text.
> 
>  "available on the web site  href="http://www.myurl.org";>http://www.myurl.org so you can 
see who is 
> doing."
> 

If I understand correctly, you are setting the value of an HTML textbox to some 
HTML code. When viewing the page, you want the HTML in the textbox to be 
rendered. This isn't possible.

> I tried this
> 
> htmlentities((stripslashes($mail_text)));
> 
> 
> Any ideas?
> 

Why can't you forget the textbox just output the HTML directly?

Edward

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



Re: [PHP] read only texbox to html with php

2007-03-21 Thread Shafiq Rehman

Please elaborate the question

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/21/07, Ross <[EMAIL PROTECTED]> wrote:


I have a readonly textbox that gets mailed as a newsletter. The text is a
standard covering letter. The problem is when I try and convert it to html
it doesn't work  It is inserted into a variable via a form textarea
$mail_text.

"available on the web site http://www.myurl.org";>http://www.myurl.org so you can see who is
doing."

I tried this

htmlentities((stripslashes($mail_text)));


Any ideas?

R.

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




Re: [PHP] read only texbox to html with php

2007-03-21 Thread Németh Zoltán
2007. 03. 21, szerda keltezéssel 11.51-kor Ross ezt írta:
> I have a readonly textbox that gets mailed as a newsletter. The text is a 
> standard covering letter. The problem is when I try and convert it to html 
> it doesn't work  It is inserted into a variable via a form textarea 
> $mail_text.

what do you mean by converting to html?
if it is just plain text what do you want to do with it? enclose it
within  tags, etc? or what?
and what do you mean by doesn't work?

greets
Zoltán Németh

> 
>  "available on the web site  href="http://www.myurl.org";>http://www.myurl.org so you can see who is 
> doing."
> 
> I tried this
> 
> htmlentities((stripslashes($mail_text)));
> 
> 
> Any ideas?
> 
> R.
> 

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



[PHP] read only texbox to html with php

2007-03-21 Thread Ross
I have a readonly textbox that gets mailed as a newsletter. The text is a 
standard covering letter. The problem is when I try and convert it to html 
it doesn't work  It is inserted into a variable via a form textarea 
$mail_text.

 "available on the web site http://www.myurl.org";>http://www.myurl.org so you can see who is 
doing."

I tried this

htmlentities((stripslashes($mail_text)));


Any ideas?

R.

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



Re: [PHP] read file local not remote

2007-02-26 Thread Joker7
In news: [EMAIL PROTECTED],
"Martin Zvarík"  said:
>> Difference: You don't call file as http://www.myweb.com/ but instead
>> you use the path like c:\some.txt or ../some.txt etc.
>>
>> PHP 5
>> =
>> echo file_get_contents("some.txt");

Works a treat

Cheers
Chris








-- 
Cheap As Chips Broadband http://yeah.kick-butt.co.uk
Superb hosting & domain name deals http://host.kick-butt.co.uk 

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



Re: [PHP] read file local not remote

2007-02-25 Thread Martin Zvarík
Difference: You don't call file as http://www.myweb.com/ but instead you 
use the path like c:\some.txt or ../some.txt etc.


PHP 5
=
echo file_get_contents("some.txt");


PHP 4
=
$fp = fopen("some.txt", "r");
echo  fread($fp, filesize ("some.txt"));
fclose($fp);


Another solution

foreach(readfile("some.txt") as $line) echo $line;



-
Joker7 napsal(a):

$url =www.mysite.ru/some.txt;

$fa = fopen($url,"r");

/*
$fa = fsockopen("http://mysite.ru";, 80, &$num_error, &$str_error, 30);
if(!$fa)
   { print "Weather is not available: $str_error ($num_error)\n"; }
else
{
  fputs($fa,"GET /some.txt HTTP/1.0\n\n");
  $answer=fgets($fa,128);



I use the above code to read a file on remote server but now I need to read 
it on local server,question is how.


Cheers
Chris



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



[PHP] read file local not remote

2007-02-25 Thread Joker7
$url =www.mysite.ru/some.txt;

$fa = fopen($url,"r");

/*
$fa = fsockopen("http://mysite.ru";, 80, &$num_error, &$str_error, 30);
if(!$fa)
   { print "Weather is not available: $str_error ($num_error)\n"; }
else
{
  fputs($fa,"GET /some.txt HTTP/1.0\n\n");
  $answer=fgets($fa,128);



I use the above code to read a file on remote server but now I need to read 
it on local server,question is how.

Cheers
Chris

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



Re: [PHP] Read file on file system

2007-02-04 Thread Richard Lynch
On Sun, February 4, 2007 7:47 am, Bagus Nugroho wrote:
> If I have file on[windows] c:\test.csv.
> How I can read the entire contents of this file?
>
> I have try file_get_contents, fgetcsv and etc but didn't work.
> May I'm mis-understanding about using those function.

Define "didn't work"

Because all of them should have been fine...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Read file on file system

2007-02-04 Thread Satyam
file_get_contents takes a file name as an argument, not an opened file 
handle.



- Original Message - 
From: "Bagus Nugroho" <[EMAIL PROTECTED]>

To: "Stut" <[EMAIL PROTECTED]>; 
Sent: Sunday, February 04, 2007 3:45 PM
Subject: RE: [PHP] Read file on file system


in simple like this

$filename = "d:\\test.csv";
$openfile = fopen($filename,'r');
$readfile = fread($openfile,filesize($filename);

echo $readfile


or like this
.

echo file_get_contents($openfile);

.
echo fgetcsv($openfile);



Thxs and rgds
bn



-Original Message-
From: Stut [mailto:[EMAIL PROTECTED]
Sent: Sun 04-Feb-2007 21:14
To: Bagus Nugroho
Cc: php-general@lists.php.net
Subject: Re: [PHP] Read file on file system

Bagus Nugroho wrote:

If I have file on[windows] c:\test.csv.
How I can read the entire contents of this file?

I have try file_get_contents, fgetcsv and etc but didn't work.
May I'm mis-understanding about using those function.


Well, from examining the code you included in your post, and reading the
output you're seeing, I have determined that... ahh, hang on a second,
I've started seeing code where no code exists. Is that a bad thing?
Should I see someone?

-Stut

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



Re: [PHP] Read file on file system

2007-02-04 Thread Stut

Stut wrote:

$filenane = "d:\\test.csv


Oops...

$filename = "d:\\test.csv";

-Stut

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



Re: [PHP] Read file on file system

2007-02-04 Thread Stut

Bagus Nugroho wrote:

in simple like this

$filename = "d:\\test.csv";
$openfile = fopen($filename,'r');
$readfile = fread($openfile,filesize($filename);

echo $readfile


or like this
.

echo file_get_contents($openfile);

.
echo fgetcsv($openfile);


Try this...



...and nothing else. Do you get any errors? Are errors turned on in php.ini?

-Stut

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



RE: [PHP] Read file on file system

2007-02-04 Thread Bagus Nugroho
in simple like this

$filename = "d:\\test.csv";
$openfile = fopen($filename,'r');
$readfile = fread($openfile,filesize($filename);

echo $readfile


or like this
.

echo file_get_contents($openfile);

.
echo fgetcsv($openfile);



Thxs and rgds
bn



-Original Message-
From: Stut [mailto:[EMAIL PROTECTED]
Sent: Sun 04-Feb-2007 21:14
To: Bagus Nugroho
Cc: php-general@lists.php.net
Subject: Re: [PHP] Read file on file system
 
Bagus Nugroho wrote:
> If I have file on[windows] c:\test.csv.
> How I can read the entire contents of this file?
> 
> I have try file_get_contents, fgetcsv and etc but didn't work.
> May I'm mis-understanding about using those function.

Well, from examining the code you included in your post, and reading the 
output you're seeing, I have determined that... ahh, hang on a second, 
I've started seeing code where no code exists. Is that a bad thing? 
Should I see someone?

-Stut





Re: [PHP] Read file on file system

2007-02-04 Thread Satyam
Have you doubled the backslash to escape it?  Or put it in between single 
quotes?  Either:


"c:\\test.csv"  or 'c:\test.csv' or even 'c:/test.csv'

Otherwise, a \t in between double quotes will be interpreted as a tab

Satyam

- Original Message - 
From: "Bagus Nugroho" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, February 04, 2007 2:47 PM
Subject: [PHP] Read file on file system


Hi All,

If I have file on[windows] c:\test.csv.
How I can read the entire contents of this file?

I have try file_get_contents, fgetcsv and etc but didn't work.
May I'm mis-understanding about using those function.

Thanks in advance
Regards,
bn

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



Re: [PHP] Read file on file system

2007-02-04 Thread Stut

Bagus Nugroho wrote:

If I have file on[windows] c:\test.csv.
How I can read the entire contents of this file?

I have try file_get_contents, fgetcsv and etc but didn't work.
May I'm mis-understanding about using those function.


Well, from examining the code you included in your post, and reading the 
output you're seeing, I have determined that... ahh, hang on a second, 
I've started seeing code where no code exists. Is that a bad thing? 
Should I see someone?


-Stut

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



  1   2   3   4   >