RE: [PHP] XML Select

2005-04-08 Thread Robinson, Matthew
 There's a few xml - array libraries out there which is probably the
easier way to examine xml stuff.

I use http://keithdevens.com/software/phpxml but there are many others.

M

-Original Message-
From: Stefan [mailto:[EMAIL PROTECTED] 
Sent: 08 April 2005 13:26
To: php-general@lists.php.net
Subject: [PHP] XML Select

Hi NG
I've a question about searching in a xmlfile.
Is there a mehtod to select a xml-node with a specific value?

e.g.
xml
nameabc/name
namedef/name
/xml

and I want search for the node with name abc.
Or is it possible with a xpath definition?

Thanks in advance
Stefan 

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


_
This message has been checked for all known viruses.



_
This message has been checked for all known viruses.

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



RE: [PHP] Some questions about if and isset.

2005-01-31 Thread Robinson, Matthew
Can we see some sample data? An example of what $variable and $constant
are would help.

A quick glance at the code I'd have:

if (isset($variable)
{
if ($variable  $contstant)
{
stuff
}
elseif ($variable  $constant)
{
more stuff
}
else
{
other stuff
}
}
else
{
even more stuff
}

M

-Original Message-
From: Geir Anders Berge [mailto:[EMAIL PROTECTED] 
Sent: 28 January 2005 19:05
To: php-general@lists.php.net
Subject: [PHP] Some questions about if and isset.

I'm sure that this code can be written more efficient, please tell me
how, but that's not my problem. The problem is that when i run this
script all lines are executed. I'm sure I'm doing something wrong, but
can't find out just what.

?php
if (isset($variable))
{
if ($variable  $constant)
{
Execute this code if $variable is less than $constant
}
if ($variable  $constant)
{
Execute this code if $variable is more than $constant
}
if ($variable == $constant)
{
Execute this code if $variable and $constant are equal
}
}
else
{
Execute this code if $variable is not set
}
?

Thanks for all help!

Geir Anders Berge

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



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] regex help

2005-01-14 Thread Robinson, Matthew
Do you have the example regex so far?

I'd suggest maybe b[^r] might just do what you want 

-Original Message-
From: Jason Morehouse [mailto:[EMAIL PROTECTED] 
Sent: 13 January 2005 21:07
To: php-general@lists.php.net
Subject: [PHP] regex help

Hello,

I normally can take a bit of regex fun, but not this time.

Simple enough, in theory... I need to match (count) all of the bold tags
in a string, including ones with embedded styles (or whatever else can
go in there).  b and b style=color:red.  My attempts keep matching
br as well.

Thanks!

--
Jason Morehouse
Vendorama - Create your own online store http://www.vendorama.com

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



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] unable to execute external program

2005-01-13 Thread Robinson, Matthew
I think you've answered your own question.

Check the permissions on the file. Can it be executed by the other user?
Is it in the path? What error do you see in the log?

ls -l
chmod

might just be your friends ;-)

 

-Original Message-
From: Sagar C Nannapaneni [mailto:[EMAIL PROTECTED] 
Sent: 13 January 2005 06:54
To: php-general@lists.php.net
Subject: [PHP] unable to execute external program

Hi,

I've compiled an external program in my linux server.
That program creates a pdf file taking a html file as input.
when i run it thru the command line its working fine.
But when i tried to execute the same command from php with exec()
command its not working.

Note that from command i'm logged in as root. And i'm using PHP as
another user on the same server.

Any other suggestions to run a command line commad thru PHP??

/sagar


This message has been checked for all known viruses by the CitC Virus
Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] Using encrypted passwords

2004-12-23 Thread Robinson, Matthew
And the good Lord saw that clear was bad and gave us ssh...

If you care that much build an ssh tunnel to the db server and talk over
that. 

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: 20 December 2004 17:29
To: php-general@lists.php.net
Subject: Re: [PHP] Using encrypted passwords

On Tuesday 21 December 2004 00:03, symbulos partners wrote:
 is it possible to use encrypted passwords in php files, for connecting

 to a database?

 We do not like too much the idea of the password being in clear text.

 Example
 $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');

 'mysql_password' should be encrypted

Why? It's not going to offer any protection. If I know your encrypted
password and am able to access your database using it there is no reason
for me to know what your cleartext password is. In other words if I am
able to read the file containing your password (whether encrypted or
cleartext) then I can access your database.


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] File Locking during *other* file operations

2004-12-23 Thread Robinson, Matthew
No really good reason that I can think of. I don't see any reason as to
why it wouldn't work with just 'x'.

Must have been having a 'beer' moment.

yes, it should probably clear out stale lock files but the files I
protect with this are better left untouched if the lock fails. I think
that locks fail for a reason and you should find that reason before you
unlock and potentially break something.

M 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: 20 December 2004 18:26
To: Robinson, Matthew
Cc: Michael Sims; php-general
Subject: RE: [PHP] File Locking during *other* file operations

Robinson, Matthew wrote:
  I use this code, Not all my own, some from the php manual (probably 
 most of it in fact) I lock the file as filename.lock so that I can 
 muck about with it completely and then unlock the .lock and remove it.

 M

 function LockFile($file)
 {

 $LockFile = $file . .lock;# Lock the
file
 $lf = fopen ($LockFile, wx);

 while ($lf === FALSE  $i++  20)
 {
 clearstatcache();
 usleep(rand(5,85));
 $lf = @fopen ($LockFile, 'x');


How come you use wx up there, and just 'x' here?

Is there some reason for that?

One may (or may not) want to consider a mechanism for throwing out
really old lock files, since it's possible your PHP script or
application would eventually fail to remove a lock file...  Or not,
depending on how you code the rest of it.

--
Like Music?
http://l-i-e.com/artists.htm



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] converting whole or tenth prices to double decimal

2004-12-23 Thread Robinson, Matthew
sprintf should also meet your needs although not as well as
money_format()

-Original Message-
From: Richard Davey [mailto:[EMAIL PROTECTED] 
Sent: 23 December 2004 12:31
To: php-general@lists.php.net
Subject: Re: [PHP] converting whole or tenth prices to double decimal

Hello Brian,

Thursday, December 23, 2004, 12:25:23 PM, you wrote:

BAA Anybody know the easiest way to convert a number like 2.1 to $2.10 
BAA or 2 to $2.00?

Use the money_format() function.

(Yes, PHP really does have a solution for nearly everything!)

Best regards,

Richard Davey


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] File Locking during *other* file operations

2004-12-20 Thread Robinson, Matthew
 I use this code, Not all my own, some from the php manual (probably
most of it in fact) I lock the file as filename.lock so that I can muck
about with it completely and then unlock the .lock and remove it.

M

function LockFile($file)
{

$LockFile = $file . .lock;# Lock the file
$lf = fopen ($LockFile, wx);

while ($lf === FALSE  $i++  20)
{
clearstatcache();
usleep(rand(5,85));
$lf = @fopen ($LockFile, 'x');
}

if ($lf !== False)
{
return array ($lf,$LockFile);
} else {
return FALSE;
}
}

###
#
# UnLockFile()
#

function UnLockFile($LockArray)
{
list($lf, $LockFile) = $LockArray;
fclose($lf);
unlink($LockFile);
}

-Original Message-
From: Michael Sims [mailto:[EMAIL PROTECTED] 
Sent: 17 December 2004 15:28
To: php-general
Subject: RE: [PHP] File Locking during *other* file operations

Gerard Samuel wrote:
 Im talking about file locking during deleting, and moving files.
 Is it possible to perform file locking for these file operations?

Yes, have your scripts attempt to lock a separate lock file before
performing deleting or moving operations.

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



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] Re: Hostname

2004-12-15 Thread Robinson, Matthew
?php
$Hostname = exec('hostname');
print $Hostname;
?


-Original Message-
From: Boget, Chris [mailto:[EMAIL PROTECTED] 
Sent: 15 December 2004 16:58
To: 'Jason Motes'; [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Hostname

  In earlier versions of PHP, you could use the $HOSTNAME global 
  variable to get the server/machine name that is running Apache/PHP.
  However, that variable is no longer working and I can't seem to find

  a replacement in any of the super global variables.  Is there one?  
  How can you get the server/machine name?
 $_SERVER['HTTP_HOST']
 $_SERVER['SERVER_NAME']

Interesting.  When I do:

print_r( $_SERVER )

both of the above print out the site name and not the host name.  For
example, the site name is 'mysite.mydomain.com' 
and the servername is 'machinebob'.  Each of the above print out
'mysite.mydomain.com' and not 'machinebob', which is what I was
expecting.

thnx,
Chris



This message has been checked for all known viruses by the CitC Virus
Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] Hostname

2004-12-15 Thread Robinson, Matthew
$_SERVER['SERVER_NAME']

'SERVER_NAME'

The name of the server host under which the current script is
executing. If the script is running on a virtual host, this will be the
value defined for that virtual host. 


-Original Message-
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: 15 December 2004 16:28
To: PHP General
Subject: [PHP] Hostname

In earlier versions of PHP, you could use the $HOSTNAME global variable
to get the server/machine name that is running Apache/PHP.  However,
that variable is no longer working and I can't seem to find a
replacement in any of the super global variables.  Is there one?  How
can you get the server/machine name?

thnx,
Chris

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



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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


RE: [PHP] How can I fix that

2004-12-13 Thread Robinson, Matthew
 
I've just had this exact problem. The solution as far as I found is one
of the following:

1. Keep a $_SESSION going and set a flag, then on a re-post you can
check the flag to see if it's set and hopefully spot the re-post.

2. Check to see if what you're about to enter is already there, chances
are it's a repost - this only works for certain sorts of applications
though.

3. Divert the user to a different page using header() so that if they
hit refresh they only refresh the thankyou page and not the post - this
doesn't stop 'back' for screwing things though.

4. Use java to prevent the history, I've found this example (not tested
it)

script language=php
  history.forward();
/script 

Hope this helps

Matthew

-Original Message-
From: Aalee [mailto:[EMAIL PROTECTED] 
Sent: 13 December 2004 09:50
To: [EMAIL PROTECTED]
Subject: [PHP] How can I fix that

Hi there everyone...

I did a form to add data to a database and it works fine. Once the data
is entered its gives a thankyou message. But the problem is, if I
refresh this thankyou page, the data is entered again into the database.
Why is it doing so. I couldnt think of a way to fix it. Help...

cheers

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



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information
visit
http://www.citc.it

___


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



[PHP] Referencing Multi Dimensional Arrays

2004-12-01 Thread Robinson, Matthew
Hi,
I've kind of solved this question already using recursion but I
recon (in the grand tradition) that someone has a better solution!

I have an multi dimensional array that is of variable depth, a snippet
is shown below. The problem is that I don't know how deep the array goes
as any entry can contain further entries which can contain further
entries and as the array grows the data is increasingly unknown. My
first thought was to use variable variables but the following doesn't
work:

$Network = array(--as-below--);

$MyKey = [allocations][network][0];
print $Network[$$MyKey];

Now the obvious use of

print $Network[$$key1][$$key2];

won't work for me as sometimes I need to be two layers deep and other
times five.

As I mentioned I've solved this problem using recursive functions but
it's all a bit nasty. I've knicked various functions from the php site
to search multi-dimensional arrays and can return myself an array of
keys leading to the item I'm after but I can't seem to use that array to
reference the data!

All/any solutions or pointers (no pun intended) welcome.

Kind regards

Matthew

Array
(
[allocations] = Array
(
[network] = Array
(
[0] = Array
(
[address] = 10.0.0.0
[netbits] = 8
[name] = TEST
[creationdate] = 20041124
[description] = Test Address Space
[security] = Array
(
[alloc] = intech
[subnet] = intech
[unalloc] = intech
)

[free] = Array
(
[0] = Array
(
[netbits] = 9
[address] = 10.128.0.0
[creationdate] = 20041125
)

[1] = Array
(
[netbits] = 10
[address] = 10.64.0.0
[creationdate] = 20041125
)
   )

[network] = Array
(
[0] = Array
(
[address] = 10.0.0.0
[netbits] = 24
[name] = MAFFNET
[creationdate] = 20041125
[security] = Array
(
[alloc] = intech
[subnet] = intech
[unalloc] = intech
)

[description] = A Test
network
[free] = Array
(
[address] =
10.0.0.0
[netbits] = 24
[creationdate] =
20041125
)
)
)
)
)
)


This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] Referencing Multi Dimensional Arrays

2004-12-01 Thread Robinson, Matthew
lol, perhaps embedded a bit too deep in my pre-amble. My question is
simply what's a good way to reference a given array entry when you don't
know where it is or how deep the array is. I can do a multi dimensional
array search and return an array of keys to locate the item, I then want
to use that array of keys to be able to reference the data to perhaps do
work on it ie:

The array is a collection of network data that can consist of address
allocation entries or other networks which can contain either more
networks or allocations. I call my search function to locate a
particular network which returns me an array of keys to locate that
entry. I then want to pass that to another function to actually work on
the data.

I have a search function:

$search_result = multi_array_search($net_array,needle);

now search_result equals an array of keys to locate the needle, this is
variable in count.

Sometimes the array of keys is 3 entries other times 5, I want a way of
taking those entries and being able to do something like:

$net_array[multi-dimensional-key] = value;

where sometimes it might be in longhand:

$net_array[net1][net2][address1] 

or other times:

$net_array[net1][address1]

but you don't know how deep you're going until the search returns you
the keys.

Hope that clears things a bit!

Kind regards

Matthew
 

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: 01 December 2004 17:23
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Referencing Multi Dimensional Arrays

Sorry if I missed it, what was the question?



This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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



RE: [PHP] remove first character in text file

2004-11-24 Thread Robinson, Matthew

?php
$email =  '[EMAIL PROTECTED]@[EMAIL PROTECTED]';
$email = preg_replace('/^%%+/','%',$email);
print $email;
?


-Original Message-
From: Dustin Krysak [mailto:[EMAIL PROTECTED] 
Sent: 24 November 2004 09:53
To: PHP
Subject: Re: [PHP] remove first character in text file

Just want to add to this with a little more info

my text file is a list of email addresses with a % separating them. 
For example:

[EMAIL PROTECTED]@[EMAIL PROTECTED]

Now sometimes I end up with a % at the beginning. For example:

[EMAIL PROTECTED]@[EMAIL PROTECTED]

Or:
[EMAIL PROTECTED]@[EMAIL PROTECTED]

Now that causes me issues else where in the script. So what I need to do
is check if the % character exists at the beginning of the file and
remove any if the % is there.

ideas?

d




 Hi there.. I have a text file where I need to remove JUST the first 
 character in the text file. Can anyone point me to a tutorial?

 d




This message has been checked for all known viruses by the 
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it

___

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