[PHP] htmlentities() does not remove escape

2008-01-27 Thread jekillen

Hello:
I have a form that has a textarea and I do not want to
disallow the use of single quote as apostrophe, or
for any other normal stylization. So I am using html
entities to change these characters into html entities.
But the function does not remove the escapes added
by the browser when sending the input.
Is there a special function in php for removing the \ escapes
as well?
My plan b would be to look for a similar function in javascript
and convert to html entities before the input is sent to the
server.
I want to screen for damaging code but do not want to
prevent legitimate use of punctuation. If the input in the
text field is then displayed as html (which it will be) I do
not want things like 'It\'s a nice day' showing up in the
html.
Thanks in advance;
Jeff k

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



Re: [PHP] htmlentities() does not remove escape

2008-01-27 Thread jekillen


On Jan 27, 2008, at 10:37 AM, Nathan Nobbe wrote:


On Jan 27, 2008 1:27 PM, jekillen [EMAIL PROTECTED] wrote:


I have a form that has a textarea and I do not want to
disallow the use of single quote as apostrophe, or
for any other normal stylization. So I am using html
entities to change these characters into html entities.
 But the function does not remove the escapes added
by the browser when sending the input.
Is there a special function in php for removing the \ escapes
as well?

stripslashes()

-nathan


Thanks, of course. Sometimes the brain just does not kick over
the way it should.
Jeff K




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



[PHP] general time question

2008-01-20 Thread jekillen

Hello again;
I am developing an application that uses php with Apache.
A user requests a script file from a web site and the server
takes such things as $_SERVER['REMOTE_ADDRESS']
and uses php's  time() function to record the time in utc
code (which would be the server's system time)
and other bits of info and saves it in a php script file on
the server.
The script is a login script. When the user successfully
logs in. Javascript is used to send the client time and
time zone offset. These are written to this file also. To
track the user for statistical and authorization reasons
this file is used to authenticate each user request and
track usage.

What I do not understand perfectly at the moment,
and I have to learn somewhere sometime, is the
figures that are recorded.

I know, I could use php's built in session handling but
I have special reasons for doing it this way.

These are the values I am recording: (a sample php script file)

$sid = '96f120f9dcf293e64e6dcbd16024491e'; // this is a session id
$da = '1200867964';  // this is 
the value generated by the time() function

$hid = '2c9a46c1a5d89469481951065cc6a621';// another session id
$ctzo = '480';  // 
This is time zone offset according to what javascript sends
$ctzn = '1200868142247';  // This is 
the client time according to javascript, which is supposed

   // to be in milliseconds


The specific questions are
what does the offset '480' mean?  (add or subtract from utc/GMT to get 
local time?)
I am in Pacific Standard Time testing this script. The server is also 
at the same location.
The javascript time value should be the original request time plus the 
time it takes

for a successful login to be processed:
The user types in the info and clicks the form button
the client pre submission script is run
then the server receives and processes
$_POST values and decides if the user has sent a valid id.

Javascript time value is specified as milliseconds.
millisecond is 1/1000 of a second, right?
and dividing the value by 1000 would give seconds elapsed
from  Jan 1 1970(?)

thank you in advance;
Jeff k

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



Re: [PHP] client time zone?

2008-01-06 Thread jekillen


On Jan 6, 2008, at 8:04 AM, Ólafur Waage wrote:


To get the clients time offset you'll need to use javascript and
date.getTimezoneOffset()

But this idea has a problem. It is that you can never trust that the
clients time is actually correct. You can get the closest to it by
using the server time and offsetting that with the javascript offset
value. But you'll never know if the client has the wrong timezone and
you'll have to deal with timezones that don't have daylight savings
like for instance Iceland :)

- Ólafur Waage

2008/1/6, Per Jessen [EMAIL PROTECTED]:

Thanks for the info.
I can live with this, I think. The javascript can give me
a good enough value for what is important. I am tracking
registered user use and can compare relative values to
see if there is a radical change, indicating that someone
may have managed to spoof a restricted connection.
That, in addition to the source of the requests can give
me an indication of problems. As far as the display is
concerned, I can have a help item that informs the user
that if the time displayed is not right for their location,
they may have their time zone set wrong, or in the case
you suggested, they may be in a time zone that does
not use daylight savings time, or some other difference.
Jeff K


jekillen wrote:


Hello;
I am running a server that is using UTC and I want to be able to
convert to clients local time in some display presentations.
Is this indicated by $_SERVER[REQUEST_TIME]?


Is there such a value at all?


If not, is there a way to get the requesting host's
time zone so I can offset the servers clock value correctly?


I think you'll need to use javascript.


/Per Jessen, Zürich

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



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



[PHP] which window?

2008-01-05 Thread jekillen

Hello;
I have a login panel that is opened as a javascript window.
In the processing script, a successful login  uses the
header function to send the user to the restricted content
index page.
But this page is loading into the javascript window instead
of the opener window of the browser. Is it possible to supply
a target property to the header() function to display
content in a specific window? Or is that strictly an html/javascript
issue? I have looked into the header() function but it is unclear
to me what all can be done with headers.
Thanks in advance for suggestions, info;
Jeff K

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



[PHP] client time zone?

2008-01-05 Thread jekillen

Hello;
I am running a server that is using UTC
and I want to be able to convert to
clients local time in some display presentations.
Is this indicated by $_SERVER[REQUEST_TIME]?
If not, is there a way to get the requesting host's
time zone so I can offset the servers clock value correctly?
Thank you for info:
Jeff K

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



Re: [PHP] which window?

2008-01-05 Thread jekillen


On Jan 5, 2008, at 3:09 PM, Casey wrote:

Try adding target=_top or target=_parent to the form element 
in HTML.


On 1/5/08, Bastien Koert [EMAIL PROTECTED] wrote:


this would be an html / js issue...

why have a popup login in this case? just show the logon in the main 
window

and then do the redirect...


bastien


Thank you, the idea of a target property in the form  opening tag is 
new to me, but it is worth a try.
However, I redid the script to process itself instead of doing a header 
redirect. Then once the
login form reloads, there is a link that has javascript do the redirect 
as document.referrer.window.location = (target file);
(for anyone who could use a little useful info on javascript). That is 
one of the things I love about php. The login
script can write javascript that is not present in the pre form 
submission version. So someone trying by trial and
error to log in cannot look at the javascript and figure anything out 
from it. Someone who can log in could see
it in the added script, but there's no point because it is visible in 
the location field of the browser, then. I have
other tricks to screen access. But no one is going to get the keys to 
Fort Knox on this site either. It is effectively
the same type of security that a forum would use, and the same type of 
content value.

Thank you for the suggestion;
Jeff K





To: php-general@lists.php.net
From: [EMAIL PROTECTED]
Date: Sat, 5 Jan 2008 10:17:55 -0800
Subject: [PHP] which window?

Hello;
I have a login panel that is opened as a javascript window.
In the processing script, a successful login  uses the
header function to send the user to the restricted content
index page.
But this page is loading into the javascript window instead
of the opener window of the browser. Is it possible to supply
a target property to the header() function to display
content in a specific window? Or is that strictly an html/javascript
issue? I have looked into the header() function but it is unclear
to me what all can be done with headers.
Thanks in advance for suggestions, info;
Jeff K

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



_
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
-Casey



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



[PHP] foreach questions

2008-01-01 Thread jekillen

Hello;
I have this section of code:

 @include('tmp_index.php');
   foreach($index as $key - $value)
  {
   if($input == $key)
 {
  $target_file = $value;
 }
  }
And I am getting this error:
Fatal error: Cannot access empty property in path/confirmation.php on 
line 131


Several questions:
How long can an index be in an associative array? (the indexes I use in 
this array are 32 character hashes)

Can it start with a number (since a hash can start with a number)
Can I use $index as an array name? (I do not remember off hand what the 
reserved key words are)

I am not sure what the empty property is that it is referring to.
Thank you in advance for info;
Jeff K

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



[PHP] Re: foreach questions

2008-01-01 Thread jekillen


On Jan 1, 2008, at 11:59 AM, Martin Jerga wrote:


Hello,
the problem is in this part of code $key - $value
This notation means that you are trying to access property $value on 
the object $key.


Just replace it with $key = $value and you will get the result as 
expected.


Martin J


Thank  you for the response;
I should have known. I don't use this type of loop often enough
to get it straight the first time.
Jeff K


jekillen  wrote / napísal(a):

Hello;
I have this section of code:
 @include('tmp_index.php');
   foreach($index as $key - $value)
  {
   if($input == $key)
 {
  $target_file = $value;
 }
  }
And I am getting this error:
Fatal error: Cannot access empty property in path/confirmation.php 
on line 131

Several questions:
How long can an index be in an associative array? (the indexes I use 
in this array are 32 character hashes)

Can it start with a number (since a hash can start with a number)
Can I use $index as an array name? (I do not remember off hand what 
the reserved key words are)

I am not sure what the empty property is that it is referring to.
Thank you in advance for info;
Jeff K




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



[PHP] variable substitution

2008-01-01 Thread jekillen

Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a  and
set $string_b  to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
stuff and by the way; and more stuff
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body - !SPAM.

this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.

Q: Is there a way to get the substitution to take
place here? (by reference, maybe?)

Thank you in advance for info
Jeff K

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



Re: [PHP] Re: foreach questions

2008-01-01 Thread jekillen


On Jan 1, 2008, at 3:34 PM, Richard Lynch wrote:


Hit send too soon.  Sorry!

On Tue, January 1, 2008 2:05 pm, jekillen wrote:

Several questions:
How long can an index be in an associative array? (the indexes I
use
in this array are 32 character hashes)


As far as I know, it can be as big as your RAM will hold...


Can it start with a number (since a hash can start with a number)


Yes.

A variable name cannot start with a number.


Can I use $index as an array name? (I do not remember off hand what
the reserved key words are)


You can use '$index' if you want, sure.


Thanks for the info;
Jeff K

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



Re: [PHP] variable substitution

2008-01-01 Thread jekillen


On Jan 1, 2008, at 3:31 PM, Richard Lynch wrote:


On Tue, January 1, 2008 4:17 pm, jekillen wrote:

Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a  and
set $string_b  to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
stuff and by the way; and more stuff
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body - !SPAM.

this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.

Q: Is there a way to get the substitution to take
 place here? (by reference, maybe?)


http://php.net/str_replace


O.K. that looks good, I can put in a target string to replace
instead of the variable.
Thanks for the suggestion;
jeff K

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



Re: [PHP] variable substitution

2008-01-01 Thread jekillen


On Jan 1, 2008, at 3:48 PM, James Ausmus wrote:


On Jan 1, 2008 2:17 PM, jekillen [EMAIL PROTECTED] wrote:

Hello again;
I have two variables declared in the global scope of a script.
$string_a = 'stuff $string_b and more stuff';
$string_b = '';
One is a string with a reference for substitution to the other
string which is empty.
In the processing body of the script are if/if else blocks.
In these blocks I want to use $string_a  and
set $string_b  to a value
if( condition)
{ $string_b = 'by the way;';... etc
so $string_a should read:
stuff and by the way; and more stuff
But this substitution will not take place
in the context of the else if block. I do not
want to write $string_a in at least 5 different
if else blocks because it is about 10 lines
intended to be an e-mail message body - !SPAM.


Several ways to do this (and avoid globals or a str_replace call):

#1:

if (condition)
{
  $string_b = 'blah';
} else if (condition2)
{
 $string_b = 'foo';
} else if (condition3)
{
  $string_b = 'bar';
} else
{
  $string_b = 'other';
}

$string_a = stuff $string_b and more stuff;

The reason for this is the variable substition occurs *at the time of
assignment* - not later.

Another way, if it's not easy to have your string_b setting
conditionals all in a row like that (or if this needs to be done
elsewhere in code, as well), would be:

function assignStrA($subStr)
{
  $retVal = stuff $subStr and more stuff;
  return $retVal;
}

if (cond1)
{
  $string_a = assignStrA('foo');
} else if (cond2)
{
  $string_a = assignStrA('bar');
} else
{
  $string_a = assignStrA('other');
}



This looks good
Thanks for the suggestion;
Jeff K


this script is used to process data sent from a
link in another e-mail message used to validate
and e-mail address.

Q: Is there a way to get the substitution to take
 place here? (by reference, maybe?)

Thank you in advance for info
Jeff K

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






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



Re: [PHP] php.ini in php5.2.1

2007-12-29 Thread jekillen


On Dec 28, 2007, at 10:40 PM, Jochem Maas wrote:


jekillen schreef:

Hello;
I have not had the necessity to deal with php.ini files for some time.
Now, because I switch from Sendmail to Postfix on one system I
need to adjust the sendmail path variable.


are you sure you need to change it? doesn't postfix come with some 
kind of
compatibility wrapper [script] that takes the place of sendmail itself 
...

IIRC most MTAs are sendmail compatible in that way.


I cannot find a php.ini file
in the specified location. That is not a problem because I can use
ini_set(). What is puzzling is that my system,
I built and installed from source on a number of different systems and
seem to remember that the process creates a php.ini file. Maybe I have
it wrong but in the past I seem to remember being able to find one to
make sure register variables was set to off. (or maybe I ignored it 
because

that is the default now). So, is the fact that this file is missing
something
I should be concerned about?


php uses it's defaults if it can't load an .ini file - the only concern
is whether this bothers you.

note that you can also set .ini settings via webserver configurations 
files

(e.g. in apache's httpd.conf or .htaccess files)



No, it does not bother me accept if I should have had a file created by 
the install.
I can create on with all the values I want to change, right? I have 
been looking
at my copy of the manual. Postfix sendmail path is different than 
default sendmail
path in php (at least on my system) and does not use options to invoke 
it.
This is to send a confirmation message to an address entered into a 
registration from.

Thanks for your reply.
Jeff K

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



[PHP] php.ini in php5.2.1

2007-12-28 Thread jekillen

Hello;
I have not had the necessity to deal with php.ini files for some time.
Now, because I switch from Sendmail to Postfix on one system I
need to adjust the sendmail path variable. I cannot find a php.ini file
in the specified location. That is not a problem because I can use
ini_set(). What is puzzling is that my system,
I built and installed from source on a number of different systems and
seem to remember that the process creates a php.ini file. Maybe I have
it wrong but in the past I seem to remember being able to find one to
make sure register variables was set to off. (or maybe I ignored it 
because
that is the default now). So, is the fact that this file is missing 
something

I should be concerned about?
PS; I have subscribed to the php-install list and get not responses to
my posts, or e-mails my ISP says contain viruses, possibly from a user
who requested I contact him (of her) off list.
Thanks
Jeff K

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



[PHP] for loop inside a switch

2007-08-31 Thread jekillen

On Aug 31, 2007, at 6:26 PM, Robert Cummings wrote:


On Fri, 2007-08-31 at 15:56 -0700, Dan wrote:
Sanjeev is right.  You're thinking about the problem backwards.  
You're
trying to build a Switch inside a loop.  Remember, if you ever have 
to do
some operating multiple times you're using a forloop, then the thing 
that

you want to repeat(switch case) is INSIDE the for loop.


Not always true. Sometimes once you've made the switch it applies to 
all
members of a data array. In which case switching on every iteration is 
a

waste of processor since you can check a single time outside the loop.

Cheers,
Rob.
--

You can run a switch inside a for loop and when a case is matched set a 
variable to true.
the break statement will break out of the switch, then inside the 
iteration code, after
the switch block, test the variable for true. If it is true the use 
another break instruction.
That should break out of the loop altogether at the end on that 
particular iteration.

like so:
for($i = 0; $i  somevalue; $i++)
{
   $bar = false;
  switch($anotherValue[$i]) // /this assumes you are looping 
through an indexed array

   { case 'foo':
 $bar = true
 //other code;
 break;
 default;
 // $bar is not set  to true so the loop continues
   }
 if($bar == true)
   {
 break;
   }
   /* instead of the default line in the switch statement
else
  {
continue;
  }
   */
 }

Hope this is useful.
Jeff K

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



[PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen

Hello again;

I have a question about  upload temp dir as defined in php.ini;

I have been working on a project that has registered users, each having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.
I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.
I do not know where else to look for an answer to this question
at present.
Any knowledgeable response appreciated.
Thanks in advance:
Jeff K.

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



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen


On Aug 26, 2007, at 9:15 AM, brian wrote:


jekillen wrote:

Hello again;
I have a question about  upload temp dir as defined in php.ini;
I have been working on a project that has registered users, each 
having

a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?
Or, is it possible to designate more than one up load temp dir in
php.ini. (that would be the best solution)
This situation is not a virtual host environment, but one site that
will be using ssl.


No, the best solution is for your application to grab the path to that 
particular user's directory and assign a unique name to the uploaded 
file, then move it from the temp dir:


move_uploaded_file($_FILES['upload_file']['tmp_name'], $upload_path);

where 'upload_file' is the name of your upload form field.

http://www.php.net/manual/en/function.move-uploaded-file.php


I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.


That's unlikely to occur. In fact, i'd be surprised if it were 
possible that PHP would assign a temp name that already existed.


brian



Thanks thats all I need to know.
Jeff K

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



Re: [PHP] upload temp dir in vhost env.

2007-08-26 Thread jekillen


On Aug 26, 2007, at 2:56 PM, Richard Lynch wrote:


On Sun, August 26, 2007 10:34 am, jekillen wrote:

I have been working on a project that has registered users, each
having
a user space portion of the web site file system. I want them to be
able to upload images and such and have the stuff transfered to their
own user spaces. With one up load temp dir designated, how do I
insure that the uploaded files get to the correct destination?


http://php.net/move_uploaded_file

And, BEFORE you move it, you should Validate the uploaded file as many
ways as practical for your web application.


Yes, I agree, I want to completely decontaminate all uploaded files but 
I

am not sure of a system that will do that.
like embedding scripts in image files, binary files, encrypted images
(I forgot the term for that, stegonography or something), shell
escape chars, incompatible files, viruses, erroneous mime or file types,
you name it, I want to check it out before it is a problem.
JK



I am using Apache on unix based host and am aware that php
assigns a temp name to files that are uploaded, but if different
users are uploading files concurrently, there could be a confusion
as to where each file should be transfered to.


The user uploading the file is probably logged in, and you probably
have some kind of user_id or Profile and can decide where to move the
file based on that user's identity.


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



Re: [PHP] Re: PHP Books - A poll of sorts

2007-08-15 Thread jekillen


On Aug 15, 2007, at 4:28 AM, David Powers wrote:


Jay Blanchard wrote:

If there was a best practices book would you buy it?


I write books on PHP aimed at the beginner/intermediate level, and 
have a considerable collection of PHP books written by others. Two 
relatively recent books that struck me as being important are Pro PHP 
Security by Chris Snyder and Michael Southwell, and Essential PHP 
Security by Chris Shiflett. (I know there's also php|architect's 
Guide to PHP Security by Ilia Ashanetsky and Rasmus Lerdorf, but I 
haven't read it.)


The thing that struck me most about the books was that anyone thought 
there should be a need for them. Of course, there is a need - that's 
why they were written. However, surely security should be taught from 
the very beginning? Every book on PHP (or any other language) should 
be a best practices book.


The problem is that books are written by human beings, who are prone 
to mistakes (myself included), and whose own view of best practice 
might leave gaps in security. The other problem is that a lot of 
people who use PHP just want to copy and paste a script that works. 
Even if the ready-made script has been designed with security in mind, 
using it without understanding *how* it works can lead to unforeseen 
problems.


By the way, I would welcome constructive criticism of the scripts in 
my books. I have tried to incorporate what I perceive to be the best 
practices at the time of writing, but I'm sure there's room for 
improvement.




If I can add some stuff here;
I have done a lot of php/javascript programming from scratch and being 
self taught, without
good texts on the subject in addition to the php manual, I would be at 
a loss. Copying and
pasting code is kind of like being a commercial designer who never does 
original art but
just use stock stuff and crams it into templates. That should be the 
difference between
a pro developer and 'paste up'  artist. Inevitably, even copied and 
pasted code has to be
adapted for a particular use, other wise it boarders on theft. Even if 
you do use open source
you do not have to be a charity (albeit, I have not made any money at 
it to speak of).
I would like to think that the money I have spent on books, lining 
authors' and publishers
pockets, the money I have spent on commercial software from Adobe, 
Quark, etc, etc,
and the thousands of dollars I have spent on computer hardware over the 
years has not
been in vain (even though I have no ' meal ticket' with student loans 
that may take the
rest of my life to pay off and won't ever be guaranteed that that 
investment would pay

for itself).
Just my two cents.
Jeff K

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



Re: [PHP] permissions for include()

2007-08-09 Thread jekillen


On Aug 8, 2007, at 9:34 PM, Richard Lynch wrote:


On Wed, August 8, 2007 7:52 pm, jekillen wrote:

I have a question about including php files that are outside of
the web server document root. What permission does Apache
use to access files outside of the document root?
Here is the situation:
I want to store sensitive data such as login/pw data for
registered users. I also want to make all the web content
rwx for user nobody (FreeBSD) only. So no ftp access,
no mortal user access, etc. Is it possible to  do this in
this situation? Would the Parent Apache process use
its privileges to include a file of this type?
I have texts and other data about storing data out side
the document root,  but  none go into it in this detail?


Apache runs as the User setting in httpd.conf

If that User can rwx the files, then PHP can rwx the files.

If not, not.

It's that simple.


Thanks, so if I make the directory and file outside of the document
root owner noboby with rwx for owner only, that will work?
Jeff K

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



[PHP] permissions for include()

2007-08-08 Thread jekillen

Hello again;
I have a question about including php files that are outside of
the web server document root. What permission does Apache
use to access files outside of the document root?
Here is the situation:
I want to store sensitive data such as login/pw data for
registered users. I also want to make all the web content
rwx for user nobody (FreeBSD) only. So no ftp access,
no mortal user access, etc. Is it possible to  do this in
this situation? Would the Parent Apache process use
its privileges to include a file of this type?
I have texts and other data about storing data out side
the document root,  but  none go into it in this detail?
Thanks for any knowledgeable response:
Jeff K

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



Re: [PHP] Php code in html buttons

2007-07-10 Thread jekillen


On Jul 10, 2007, at 3:59 PM, k w wrote:


I'm trying to make a button execute some php code when the button is
clicked. I'm not sure if it is the button i'm coding wrong or the php 
code.

Here is the code I am using.

?php
echo button action='?php 
mysqli_query($connect,$query)?'Click/button;

?

I've got all my variables stored in the php page, and I know they are 
all
correct. But when I push the button it does nothing. I'm not quite 
sure what

I am doing wrong.

I have also tried

input type=button value=Click OnClick= ?php
mysqli_query($connect,$query); ?

and

form onclick=?php mysqli_query($connect,$query); ?
input type=button value=Click
/form

Obviously i'm a complete newbie. I'd appreciate any help. Thanks.


You will have to use a form and set the action to the page that runs 
the code, It can be the same page.
In which case the action in the form open tag will be the name of the 
present file.
You have to have code in the top of the page to catch a $_POST or $_GET 
variable.

 The button will look something like this:

form action='your code processing page.php' method='get or post, you 
choose' name='form1'  NAME HERE IS IMPORTANT
input type='button' name='you name the button' 
onclick='document.forms,form1.submit(form)' THIS IS WHY THE FORM NAME 
ASSIGNMENT IS IMPORTANT
!-- The document.forms.form1.submit(form) line is javascript. In most 
browsers the word form must be entered as an argument for it to work. 
--
input type='hidden' name='you name this hidden field' value='some 
value for the processing code to look for so it knows when to do your 
processing'

/form

In the top of the page you can do:
$some_variable = '';
if($_POST[hidden field name] or $_GET[hidden field name])
  {
   // run your code here
  // assign the result to $some_variable
  // assign extra hidden field values to variables that should persist 
across page loads

}

Then in the page in the location you want it:
?php print $some_variable; ?

there is one catch, if you have variable values in the page before you 
click the button and you want them to be there when the page reloads,
or another page sends the result, these variable values will also have 
to be loaded into hidden fields, sent to the server and re entered in 
the

returned data.
You can add hidden fields like so:
input type='hidden' name='unique name for each field' value='?php 
print $your_variable; ?''

This will work with single or double quotes around the php code block
Each of these extra form fields will have to be inside the same form 
tag set that the button is in.

JK

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



Re: [PHP] Editing Files with PHP

2007-07-10 Thread jekillen


On Jul 10, 2007, at 5:33 PM, David Wonderly wrote:

I am trying to create a small script to open a file and edit it. 
However, when I open a file with PHP in it the PHP is stripped out. It 
open as if I was viewing the page source. How do I fix this?

Here is the code I am using.

form action=filewrite.php method=post
textarea rows=15 cols=70 name=content
?php
include($file) ;
?
/textarea
input type=text name=filename /
input type=submit /
/form

Filewrite looks like this
?php
$File = $filename;
$Handle = fopen($File, 'r+');
$Data = $content;
fwrite($Handle, $Data);
fclose($Handle);
print Data Written.;
?
Like I said, it is very simple but, I can write php if I start with a 
blank page but, I can open a file and view it. All of the files are at 
david.wonderly.com


Thanks!
-Dave


Look at the line:

$Handle = fopen($File, 'r+');

the 'r+' should be 'w+' if you are trying to create and write to a file.
JK

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



Re: [PHP] php security books

2007-07-04 Thread jekillen


On Jul 4, 2007, at 3:22 AM, Ross wrote:




http://amazon.co.uk/s/ref=nb_ss_w_h_/203-1671317-2810350? 
initialSearch=1url=search-alias%3Dapsfield- 
keywords=php+securityGo.x=0Go.y=0Go=Go



looking at the top 3 on the list here, personally I quite like the  
O'Reilly
books. Can someone recommend one of these or any other that will give  
me a

good solid understanding of PHP security?


Thanks,


Ross


Have you seen Pro Php Security by Snyder and Southwell; Apress ?
It appears to be as comprehensive and well written as the subject
can get.
JK

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



Re: [PHP] str_replace new line

2007-07-02 Thread jekillen


On Jul 2, 2007, at 6:07 PM, jekillen wrote:



On Jul 2, 2007, at 3:15 PM, Greg Donald wrote:


On 6/30/07, jekillen [EMAIL PROTECTED] wrote:

Hello;
I have the following  code:

$prps = str_replace(\n, ' ', $input[3]);


Are you sure $input[3] doesn't have two newlines at the end?

Why not use trim() to be sure?


  $request = str_replace(// var purpose = {} ;\n, var purpose =
'$prps';\n, $request);

In the first line $input[3] is a string formatted with new lines at 
the

end of each line.
It is to be used to initialize a javascript variable (in the second
line above), in an html file
template.
When the html file is generated from the template, the javascript
written to it fails
with unterminated string literal error message.
When opening a view source window, the 'var purpose...' line does 
have

the string
broken up with extra spaces at the beginning of each line. This
indicates that
the new line was not replaced with the space. The space was merely
added after
the new line.
How do you replace a new line with php in a case like this?


Why do you want to replace it, you just said you wanted to remove it 
above?


So it will not cause javascript errors when written as a javascript 
variable value

The out put goes like this:
var string = 'this is some text(\n)
with a new line in the string.'
It cause a javascript unterminated string literal error because of the 
line break
caused by the new line. I need to replace the new lines with spaces so 
it is

one long string.
It is that simple, Please.


Do you use Firebug?  It's a Firefox extension.

I do not need to debug the javascript, It is the php which
is tedious to change and retest.  The php code writes
the javascript to an html file, So I need to change the php
or find another way.

Does anyone have a simple answer to a simple question?
I am trying to replace newlines in a string with spaces. The code
I posted originally is not working. Perhaps I am doing something
wrong in that code,
That is all I am asking.
JK



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



[PHP] str_replace new line

2007-06-30 Thread jekillen

Hello;
I have the following  code:

$prps = str_replace(\n, ' ', $input[3]);
 $request = str_replace(// var purpose = {} ;\n, var purpose = 
'$prps';\n, $request);


In the first line $input[3] is a string formatted with new lines at the 
end of each line.
It is to be used to initialize a javascript variable (in the second 
line above), in an html file

template.
When the html file is generated from the template, the javascript 
written to it fails

with unterminated string literal error message.
When opening a view source window, the 'var purpose...' line does have 
the string
broken up with extra spaces at the beginning of each line. This 
indicates that
the new line was not replaced with the space. The space was merely 
added after

the new line.
How do you replace a new line with php in a case like this?

Testing this is very tedious. Each time I have to go through and undo
file modifications that this function performs in addition to the above.
So it is not just a case of making a change and reloading the file
and rerunning it.

Thanks in advance;
JK

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



Re: [PHP] Create .php file with php

2007-06-25 Thread jekillen


On Jun 25, 2007, at 5:13 PM, Marius Toma wrote:

I can not create .php files from PHP. I can save them as *.php5, 
*.php3, asp, *.txt , etc... but not as .php. I tried both touch and 
fopen but

none of them worked.

I'm running PHP 5.1.6 on Apache 2, safe_mode is off

Is this a security measure somewhere? How can I bypass it?

Thank you,
Marius

I had trouble with this also running php 5.1.2 and now 5.2.1. But I got 
the hang of it to the point
that I have mostly abandoned xml and flat files for temporary files and 
quick and dirty data bases
that can just be included for their content. I do not remember what I 
did that got it going but it is
definitely possible, almost spooky. You certainly do not want any user 
supplied content written to
a php file as variable values or anything without being completely 
sanitized.
I also had trouble opening and modifying html files but got the hang of 
that too.
I am running Apache 1.3.x on FreeBSD 6.0, 6.2, Mac OSX, and Yellow Dog 
Linux.

Keep trying...I had to.
JK

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



Re: [PHP] Create .php file with php

2007-06-25 Thread jekillen


On Jun 25, 2007, at 9:08 PM, jekillen wrote:



On Jun 25, 2007, at 5:13 PM, Marius Toma wrote:

I can not create .php files from PHP. I can save them as *.php5, 
*.php3, asp, *.txt , etc... but not as .php. I tried both touch and 
fopen but

none of them worked.

I'm running PHP 5.1.6 on Apache 2, safe_mode is off

Is this a security measure somewhere? How can I bypass it?

Thank you,
Marius

I had trouble with this also running php 5.1.2 and now 5.2.1. But I 
got the hang of it to the point
that I have mostly abandoned xml and flat files for temporary files 
and quick and dirty data bases
that can just be included for their content. I do not remember what I 
did that got it going but it is
definitely possible, almost spooky. You certainly do not want any user 
supplied content written to
a php file as variable values or anything without being completely 
sanitized.
I also had trouble opening and modifying html files but got the hang 
of that too.
I am running Apache 1.3.x on FreeBSD 6.0, 6.2, Mac OSX, and Yellow Dog 
Linux.

Keep trying...I had to.
JK
I just do $fp = fopen('so_and_so.php', 'w+'); // the 'w+' is necessary 
for creating files that do not exist and writing to them, just 'w' 
requires the file to exist already.

fwrite($fp, ?php\n(code)\n?);
fclose($fp);
Also in my code editor, the closing php tag screws up the syntax 
coloring but does not indicate a coding error, so
I do $close_tag = '?'.''; and in the fclose($fp, 
?php\n(code)\n$close_tag ); and my editor will keep the syntax 
coloring. (BBEdit)

JK


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



[PHP] if test

2007-06-17 Thread jekillen

Hello again;
does the following test pass if the file is successfully included:
if( include( some file ) )

or does it pass with:
if( ! include( some file ) )

Thanks
JK

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



[PHP] Syntax error, where?

2007-05-22 Thread jekillen

Hello again;
In my frustration and laziness (tired of probing around to solve syntax 
errors that are not obvious)

I have encountered the following error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in 
path removed groups_proc.php on line 585


The two lines immediately proceeding the line referenced by the error 
and line 585 follow:


line 583: $pending_to = str_replace(//\$requests_to[] = ' ';, 
\$requests_to[$list_length] = '$input[4]';\n//\$requests_to[] = ' ';, 
$pending_to);
line 584: $pending_to = str_replace(//\$r_group_to[] = ' ';, 
\$r_group_to[$list_length] = '$input[3]';\n//\$r_group_to[] = ' ';, 
$pending_to);
line 585: $pending_to = str_replace(//\$r_status_to[] = ' ';, 
\$r_status_to[$list_length] = 'pend';\n//\$r_status_to[] = ' ';, 
$pending_to); - error reference line


I can't see it. The only problem I would imagine, is that $list_length 
is an integer and not a string. But if that was what is being 
complained about,

why didn't the error occur at line 583?
(
I am trying to add array items to a php file by writing them to it. 
$list_length is a variable declared in the file to keep track of what 
index to assign
to new array items.  It is incremented when an item is added. The 
reason is that there are 3 arrays and all have to correlated item for 
item.
Yes there probably is a better way but this is what I have to deal with 
at present.

)

Thanks for help in advance
Jeff K

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



[PHP] Syntax error, where? solved

2007-05-22 Thread jekillen

Hello again;
(Blush);

I was looking at the wrong line. Somehow the line numbers changed on me
and the error was actually at a suspect line that I had changed. But the
file that was giving the error was a file that was not updated.
Now it works,
I was trying to do $list_length -1 in the middle of an interpolated 
string

like;  string.$list_length -1.string.
I had to write this message as soon as I saw the error to spare those
who would read and not be able to see it either.
Thanks again;
JK

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



Re: [PHP] Function Declared in Included File Not Being Found

2007-05-11 Thread jekillen


On May 11, 2007, at 1:43 PM, Chris wrote:


Hello,

According to the PHP manual on functions 
(http://www.php.net/manual/en/language.functions.php):


In PHP 3, functions must be defined before they are referenced. No 
such requirement exists since PHP 4. Except when a function is 
conditionally defined...


If that is true then why does the following not work as I expect?

I expect the result to be Function was called! but it actually is 
Function test() does not exist!.



File: a.php

?php

if (function_exists('test')) {
echo test();
}
else {
echo Function test() does not exist!;
}

require 'b.php';

?

---

File: b.php

?php

require 'c.php';

?

---

File: c.php

?php

function test() {
return Function was called!;
}

?


Chris



One reason I believe is that including a file in an included file will 
not work.
file a includes file b wnich includes file c, code in file c will not 
register. (if

I remember the manual correctly)
Jeff K

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



Re: [PHP] Ajax?

2007-05-09 Thread jekillen


On May 9, 2007, at 8:04 AM, Emil Edeholt wrote:


Hi!

What do you guys use to develop ajax applications and do you have any 
good articles on the subject?


I've just about finished an ajaxish site but it wasn't fun. A lot of 
nesting javascript inside php calls, having to write the logic both in 
javascript and php and so on. The source looks ugly and was time 
consuming to debug.


Thanks!


Anything involving javascript development has several built in 
debugging facilities
1: Alert dialogs: You may find it a chore to learn how to use them 
effectively. But
   the current content of any variable can be displayed with an alert 
dialog. You
   have to pay attention to how strings are concatenated; with +, The 
actual

   variable name cannot be quoted.
2: Browser error reporting, in Netscape species, javascript console. 
Take a hint,
all source code text should be formated for Unix/Linux ( line feed 
line endings)
If you do scripting on a Classic Mac OS = OS9, the line endings 
are carriage;

and Windows uses both carriage return and line feed.
return. You will drive your self crazy cussing the console because 
it will not refer

to lines containing syntax errors, but some disrelated lines.
3. View source window in browser to see exactly what the browser is 
getting on

page load.
4. Forms: I have coded special forms just for the sake of development 
and debug
   of javascript apps.  All globals are visible through out the script, 
WITH THE EXCEPTION
   OF SOME THAT ARE DEFINED IN SOURCED JS FILES; Opening a javascript 
window is
   in a function does not seem to register if the function is in a 
sourced file.
5. Patience, patience, patience, some masochism, Several large 
available paper back
   text books. No one will describe all you might need to know about 
issues like rollovers,
   DHTML, etc, Imagination and ingenuity, or the will to search and 
sift through others
   source code until you find what you are looking for, and then making 
it work for you.
  That's it, I have some suggestion that there are systems available 
for javascript but I

  have done without long enough to have my methods and approaches.
One more thing, php and javascript work very well together. I have even 
written a
function to display php variable values as javascript alert dialogs. It 
will not function
as break points for php like it does with javascript, but at least you 
do not have to

decipher php error smeared all over the screen.
And Ajax, even though I have not cracked that particular aspect of 
javascript as yet,

looks very worthwhile.
Jeff K

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



[PHP] uploads

2007-04-29 Thread jekillen

Hello again;
can someone point me to a system for cleaning
uploaded files; embedded php scripts in image
files, viruses etc, shell escape chars, anything
that would be hazardous?
The idea is when a file is uploaded, as soon
as it gets to the server it is inspected, cleaned/rejected
before it is used or sent anywhere else on the server.
I am using php to upload anything that would be sent
in an e-mail attachment. Once the files have been
'sanitized' they would be made available for display.
Thanks in advance;
Jeff k

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



Re: [PHP] TrueType font changes size when rotated?

2007-04-24 Thread jekillen


On Apr 24, 2007, at 8:26 PM, Seth Price wrote:


Hi all! I've been programming GD and PHP for a while, but I haven't
done much with font drawing. I'm trying to layout and draw text, but
the text actually changes size and shape depending on the angle it's
drawn at. This is making it extremely difficult to lay the text out
properly.

Am I doing something wrong? Is there a bug in FreeType? How can I
consistently draw text?

For example:
The following code draws 'Hello world' at differing angles. But all
drawings are at right angles to each other. FreeType shouldn't even
need to do any resampling or interpolating, but each text is drawn
with a unique length and look. You can see the output of the
following code here:
http://leopold.sage.wisc.edu/test2.php


?php
header('Content-Type:image/png');

$img = imagecreatetruecolor(300, 300);
$bak = imagecolorexact($img, 255,255,255);
imagefill($img, 0,0, $bak);
$col = imagecolorexact($img, 0,0,0);

for($i = 0; $i  360; $i += 90){
$b = imageftbbox(12, $i, '/Library/WebServer/Verdana.ttf', 'Hello
world');
$len = sqrt(($b[2] - $b[0])*($b[2] - $b[0]) + ($b[3] - $b[1])*(($b
[3] - $b[1])));
imagefttext($img, 12, $i, 150, 150, $col, '/Library/WebServer/
you're using Mac OSX, did you have to install gd or does it now come 
with
gd included in the php installation? (after looking further down the 
message,

I see you are running Server, so that is probably the difference)
Mine did not (OSX 1.4x). I have it installed on a FreeBSD system.
www.brushandbard.com - web design - dynamic image generation 
demonstration

and Word Wise the Tile Puzzle are some of my projects using gd.

Verdana.ttf', 'Hello world '.$len);
}

imagepng($img);
?

When using more interesting fonts, this 'resampling' is causing text
drawn at 90 deg to look fugly. What can I do to prevent this? Is this
a known issue? The output doesn't seem to change if I use the 'ttf'
functions vs. the 'ft' functions.

I went looking for some samples, as I have played with this some in the
past, but did not find anything current to show. I do not remember 
having
this problem. There may be a distortion that is being entered into the 
mix

when the fonts are rendered by your code. $len is the hypoteneus of a
right triangle, right off hand I would say that is your problem or some 
of it.
The length should be a linear measurement and not a diagonal 
measurement.
But I am rusty at this point. Also there is a function for explicitly 
specifying

the angle of the font in degrees, and, as I remember the angle of the
rendering box also. This is so each font can be rendered at an 
individual

angle and the whole enclosing box, so the whole word is rotated.
 you will have to look in the manual for gd related functions if you are
not aware of this.
Jeff K


System info:
Mac v10.4 Server running PHP v5.2.1  FreeType v2.3.4

Compiled with:
'./configure' '--with-apxs' '--with-mysqli=/usr/local/mysql/bin/
mysql_config' '--with-gd' '--with-png-dir=/usr/local' '--with-zlib-
dir=/usr' '--with-jpeg-dir=/usr/local' '--disable-short-tags' '--with-
iconv' '--enable-exif' '--enable-mbstring' '--enable-gd-native-ttf'
'--with-freetype-dir=/usr/local'

Thanks,
Seth

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



[PHP] Skipping items in a loop

2007-04-17 Thread jekillen

Hello again;
I have a directory that I am opening and reading to produce an
array of contents; files and subdirectories. There are a number
of subdirectories that I do not want to open and read the contents
of, and others that I do want to open and read the contents of.
This code is supposed to produce two arrays. One with directories
and the other with files, including the path. This is so I can create
the directories and copy the files. Certain files are specific to the
source  directory structure and I do not want them copied.

The only way I can think of is to loop though the $dir_only array
to see if it matches an item in the $dirs array so I can have the
code by pass it.  But that is in the middle of a while loop that is
already in the middle of a loop. I have not been able to get it to
work as I want.
using php 5.1.2

Does anyone have a better suggestion (that will work in the
context of this code, I do not want to do major rewriting if I
can avoid it).
Thanks in advance
Jeff k

The code follows:
   $cont = array();
   $dir_only = array();
   $dir_only[0] = 'jk/collections';
   $dir_only[1] = 'jk/extras';
   $dir_only[2] = 'jk/group_info';
   $dir_only[3] = 'jk/group_routes';
   $dir_only[4] = 'jk/groups_in';
   $dir_only[5] = 'jk/in';
   $dir_only[6] = 'jk/log';
   $dir_only[7] = 'jk/out';
   $dir_only[8] = 'jk/requests';
   $dir_only[9] = 'jk/store';
  $dirs = array();
  $dirs_a = array();
  $files = array();
  $cltag = '?'.''; // - for php closing tag. 
If I do it literally, it screws up the syntax coloring in my code 
editor.
  $rd = opendir('jk') or die(Could not open jk 
as source dir);

  while($x = readdir($rd))
   {
if($x == '..' || $x == '.')
   {
continue;
}
  else
   {
array_push($cont, 'jk/'.$x);
   }
}
   closedir($rd);
   unset($rd);
   unset($x);
   for($i = 0; $i  count($cont); $i++)
  {
   if(is_dir($cont[$i]))
 {
  array_push($dirs, $cont[$i]);
 }
   elseif(is_file($cont[$i]))
 {
  array_push($files, $cont[$i]);
 }
   }
   for($i = 0; $i  count($dirs); $i++) // 
looks at dirs

  {
@$rd = opendir($dirs[$i]) or die(Could 
not open $dirs[$i]);

  while($x = readdir($rd))
   {
if($x == '..' || $x == '.')
  {
continue;
  }
 
elseif(is_file($dirs[$i].'/'.$x))

   {
 array_push($files, 
$dirs[$i].'/'.$x);

   }
 
elseif(is_dir($dirs[$i].'/'.$x)  $x != )

   {
 array_push($dirs_a, 
$dirs[$i].'/'.$x);

   }
}
  closedir($rd);
  unset($rd);
  unset($x);
  };

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



Re: [PHP] install problems

2007-03-19 Thread jekillen


On Mar 18, 2007, at 10:54 PM, Chris wrote:


jekillen wrote:

Hello;
Well, this one I cannot seem to figure out:
I installed Apache 1.3.37 with
./configure --enable-module=so --enable-module=rewrite 
--enable-shared=max

Then tried to install
php 5.2.1 --with-apxs=/usr/local/apache/bin etc etc
libphp5.so is no where to be found. It sure is not
in apache/libexec


Did you run 'make' ?

Running configure doesn't create this file, 'make' does.

A rather obvious question but I couldn't see whether you ran it or not.



Yes, I did, an oversight on my part not to mention it.
It went all the way through configure, make, and make install
I watched all the text fill up the screen and fly by and I did
not get and bail outs. How ever I suspect that part of the
problem is the way I configured Apache, I know I had
trouble with Apache not editing the .conf file by putting
all the AddModule and LoadModule lines in. I got that
fixed then encountered the php problem. I even went
through and removed everything related to php I could
find and started again from scratch. No luck.
Thanks for the reply
Jeff k

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



Re: [PHP] install problems

2007-03-19 Thread jekillen


On Mar 19, 2007, at 5:58 PM, Chris wrote:


jekillen wrote:

On Mar 18, 2007, at 10:54 PM, Chris wrote:

jekillen wrote:

Hello;
Well, this one I cannot seem to figure out:
I installed Apache 1.3.37 with
./configure --enable-module=so --enable-module=rewrite 
--enable-shared=max

Then tried to install
php 5.2.1 --with-apxs=/usr/local/apache/bin etc etc
libphp5.so is no where to be found. It sure is not
in apache/libexec


Did you run 'make' ?

Running configure doesn't create this file, 'make' does.

A rather obvious question but I couldn't see whether you ran it or 
not.



Yes, I did, an oversight on my part not to mention it.


Just wanted to check :)

After 'make' you should have a libs/libphp5.a and/or libs/libphp5.so

No need to do the 'make install' step if those files don't get created 
(depending on your configure options you may only get one of them, but 
there should be something created there).


If you're not getting them at all, does 'make' finish properly - ie do 
you get:



Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).


as the last two lines?


Yes
I rm'd everything related to php and went and got a copy of php 5.1.2 
and tried that with the same

list of ./configure options read into ./configure from a file:
--with-apxs=/usr/local/sbin/apxs \
--with-openssl \
--with-zlib \
--enable-bcmath \
--with-gd \
--with-jpeg-dir \
--with-freetype-dir \
--with-ttf \
--enable-gd-native-ttf \
--with-mcrypt \
--with-mysql \
--with-mysql-sock \
--without-sqlite \
--with-regex=php
and the same thing happened.
It should be in /usr/local/libexec with all the other Apache modules, 
right?

find found nada.
I have done this twice before on FreeBSD v6.0 with out this trauma.
I subscribed to the install list to see what someone might have to say 
there.

Jeff K

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



[PHP] install problems

2007-03-18 Thread jekillen

Hello;
Well, this one I cannot seem to figure out:
I installed Apache 1.3.37 with
./configure --enable-module=so --enable-module=rewrite 
--enable-shared=max

Then tried to install
php 5.2.1 --with-apxs=/usr/local/apache/bin etc etc

libphp5.so is no where to be found. It sure is not
in apache/libexec

I saved the ./configure options in a file and had
configure read from it. All seemed to go ok,
no errors, bailouts. I can send that file if anyone
thinks it may have the answer.

The problem showed up when I tried to start apache and
it would not start because it could not find libphp5.so

OS: Freebsd 6.2
(I know there is the ports system, I have install all of this 
successfully on
 two other machines doing just untar, configure, make, make install. I 
had

 reasons for not dealing with ports)
Any clues?
Thanks in advance
Jeff K

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



Re: [PHP] Re: install problems

2007-03-18 Thread jekillen


On Mar 18, 2007, at 7:51 PM, Haydar TUNA wrote:


Hello,
  This is php.install question but I can help you. Two weeks 
ago, I

faced same problem with Apache 2.2.4 and PHP 5.2.1 in Redhat Linux AS 4
Update 3 operating system. I tried to install apache and php together 
but I
faced to same problem. I tried to install PHP 5.1.6 and Apache 2.2.4, 
my

problem could be solved.:)

Thanks, I still do have the 5.1.2 tarball. I will try that and see if 
it makes a dif.
I thought of stealing the file that is missing from another 
installation that is
very similar but decided against it because it was based on a different 
version
of php (5.2.1). And this file is in /usr/local/libexec instead of 
/usr/local/apache/libexec
(That actually be part of my problem; I.E. when I installed Apache I 
did not give
./configure a prefix because the install instructions said the default 
was /usr/local/apache.

And httpd.conf is expecting to find the stuff in /usr/local/libexec.)
Thanks again
trying again,
Jeff K

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



[PHP] Regex error

2007-03-14 Thread jekillen

Hello;
The following regex:

ereg(member value='[a-zA-Z ]{1,25}' uspace='([a-z0-9-\.\/]{2,11})' 
id='$m[1]', $groups, $m1);


is causing the following error:

Warning: ereg() [function.ereg]: REG_ERANGE in path info_proc.php on 
line 81


Can someone tell me what this means?

What I am trying to do is pick out some info from an xml tag the is 
id'd by

$m[1] ( a match from a preceding regex. This regex is only supposed to
be applied if there is an $m[1] match. This happened without the
dot (.) and forward slash escaped in the uspace=' etc ' section. I used
back slashes to see if that made a difference, it does not. I have 
gotten

a little hazy on what needs to be escaped in character classes.

 I have written a number of
similar regexs in the same collections of scripts and I can not see what
this one is complaining about.
php v5.1.2, Apache 1.3.34, FreeBSD v6.0
Thanks in advance
Jeff K

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



[PHP] re regex error

2007-03-14 Thread jekillen

Hello again;
Regarding the error I  was inquiring about:

Warning: ereg() [function.ereg]: REG_ERANGE in path info_proc.php on 
line 81


I still would like to know what it means but
I solved the script problem.
I found that since  $groups is a string  that was exploded to form the 
$g_list array
it may have been struggling to try and crawl back through the whole 
string in the
middle of the for loop. But I don't know, because I don't know what 
REG_ERANGE means.
I should have not been trying to run this regex at this stage of the 
script and, in
fact (I have been doing a lot of complex programming on this project ) 
I had
the same regex further down the list where is should have been and was 
already.
Anyhow, I think this may be valuable for anyone who is trying to learn 
by watching

and reading this list.
thanks
Jeff K

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



Re: [PHP] Back to security

2007-03-13 Thread jekillen


On Mar 12, 2007, at 3:32 PM, Richard Lynch wrote:


On Sat, March 10, 2007 12:41 pm, Alain Roger wrote:

I'm continuing to work on securing my administration part of the
website.
based on previous posts and reading materials, I was thinking to use
the
following process :


Think of HTTPS as like a bank vault in the basement of a branch bank.

Anybody can walk in the door, but very very very few people can walk
into the vault.

Better off to do all of 1, 2, and 3 inside HTTPS.

Plus, the whole point of HTTPS is to stop network sniffers from
over-hearing passwords and other sensitive data, and if you
authenticate outside HTTPS, then you are sending the authentication
credentials over the wire for anybody to hear, so what's the point?


For what it is worth, I am only aware of one drawback to https with
respect to how requests are handled that makes it difficult to use
with virtual hosting. I am a little hazy  on how it works but when
https is used only the ip address of the request is available to the
server before the rest of the request is decrypted. So, in this sense
it could be advantages to use an http login script ant start the https
server once the login was successful. I say this because I have
written a login script that uses an md5 library ported to javascript.
The login and password are hashed in the client, and just so a sniffer
cannot grab the hash and use that, I have a random hash that is hashed
against the login/password hash. The random hash, I will call a nonce,  
is
saved on the server and the server uses it against all the known login 
hashes
and compares it to what was sent. That way what the client sends is 
always

different and cannot be reused.
I cannot guarantee this but it would be straight forward to guess that 
even

if the hash was cracked:
the cracker would have to guess how the nonce was generated and find
a hash the would work to get the correct result.
The punch line is that he could not reuse it to test it.
Hope this is useful.
Jeff K

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



Re: [PHP] Is there a way to un include a file

2007-03-08 Thread jekillen


On Mar 7, 2007, at 11:47 PM, Larry Garfield wrote:


No there is not, because an included file *executes* at the time it is
included and is then done.  Any memory-resident objects (function/class
definitions, variables, etc.) that it defies then exist until you make 
them
un-exist (with unset() for variables or, well, you can't with 
functions and

classes AFAIK).

Include files are libraries.  They are not functions.  What you're 
looking for
is a function.  Don't try to use include files as functions.  Therein 
lies

pain.


I have function definitions in included files all over the place. I do 
that

so one file will not be too big to keep scrolling back and forth through
to develop and debug. These are mainly in conjunction with multi
phase self processing forms.
Variables I could guess would be overwritten,
but if I have a function fu defined in two different files that are 
include

in, say, a loop and I want to call one function fu on one iteration from
one included file, then the next iteration I include the next file and
call fu that is a different version, which function would be executed on
the second iteration?

Thanks for the response, I think I will have to do some experimentation
with this one.
Jeff K

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



Re: [PHP] Joke of the day problem

2007-03-08 Thread jekillen


On Mar 8, 2007, at 5:30 AM, Delta Storm wrote:


Hi,

again me with the silly questions...

I need a script that will take data from MySQL database and display 
one row each day.


I have googled, but with no luck.

The database retrieving mechanism is of course clear but I really dont 
know how to do a 24h delay before the next row is displayed.



Thanks in advance :)



I would write the query results to a php file as string variables and 
when someone requests the page
have a date conditional to decide which string to display. Or if you 
want to pull a joke from the database
one at a time just use date to determine which one. For this you may 
have to have a persistent php file

to include to keep track.
Ideas; maybe one looks good?
Best
Jeff k

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



Re: [PHP] php and javascript error

2007-03-08 Thread jekillen


On Mar 7, 2007, at 11:46 PM, Tijnema ! wrote:

Just a little side note, you said that firefox wasn't giving an error, 
i think it does, but that it hides the error.

Open your page, and then go to Tools-javascript console.
There it will display all javascript errors. And gives a nice detailed 
error.

 
Tijnema


Thanks,
Yes I have been around the bend with Netscape and now, Fire Fox 
javascript consoles.
Before I got it that I need to format web content text for Unix, I went 
crazy trying to interpret
Netscape console messages and the line numbers it said the errors were 
found. I was using
Mac and text file are formatted with carriage return, not new line or 
line feed as in Unix text.
The Javascript errors are based on Unix text formatting even if the 
browser is running on
Mac or Windows (well I am not sure about Windows, I have never use it 
for web development
but I do know that it uses both carriage return and line feed for plain 
text line endings).

Jeff K

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



Re: [PHP] php and javascript error

2007-03-07 Thread jekillen


On Mar 7, 2007, at 10:24 AM, Ed Curtis wrote:


Edward Kay wrote:


you've got a stay quote mark in one of your PHP vars.


Not it, I looked and there's nothing there.
I'm sure it's because you've got some stray characters in your output 
that
mess it up. It would help if you actually posted the source rather 
than just

saying it's OK, when it clearly isn't.


The problem wasn't a stray apostrophe. Brad Fuller was dead on. It was 
the space in the window name option of the javascript. It works as 
expected once the space is removed.


PPS: It's advisable not to use the short tags, use ?php instead 
of ?


Can you tell me why? Is it just a personal preference?
If you move to another server where the short tags option is off, 
your code

will break. From the manual:
Using short tags should be avoided when developing applications or 
libraries
that are meant for redistribution, or deployment on PHP servers which 
are

not under your control


My scripts aren't meant for distribution also they will only ever be 
delpoyed on a server that I control. Thanks for the tip though and 
thanks to everyone that helped.


Ed


This isn't a javascript discussion list but, javascript and php 
compliment each other very well.


Internet Explorer has error reporting that can be turned on in the 
preferences.


I would try that before making any other assumptions.

Believe me, I started developing javascript before php and with no IDE 
for javascript you
'have to rely on the browsers error reporting facilities, and lots of 
alert dialogs used as
break points. Safari on Mac is a head ache because it has no error 
reporting at all and
I have encountered problems with it that do not show up in any of the 
browsers that do

have error reporting.
Hope that helps,
Jeff K

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



[PHP] Is there a way to un include a file

2007-03-07 Thread jekillen

Hello;
Is there a way to un include a file once it has been included in a 
script.

My concern is where two php files might be included in another php
file they might have code or variables that conflict. I am thinking
of including files with different names but follow the same pattern
of code and variables but may have different values for variables
or different versions of the same function.
If there is not a specific function for un including a file (I have not
seen any indication from my text books that there is), it seems like
it would be nice to have one.
Meanwhile I will be doing some experimentation.
Thanks in advance;
Jeff K

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



[PHP] Another hand wringer

2007-02-18 Thread jekillen

Hello;
I am having trouble with a loop in scripts run under
php v5.1.2.

I have produced a form in a web page that has a variable number
of text fields. These fields represent the result of opening a file
and populating the fields with the corresponding value data found
in the file. The field names are generated in a php loop using an
iterator $i and given a_$i+1 names. If I test for the field names
on post literally, a_1, a_2, a_...n, the values are getting posted
properly.
Then when I run through a loop looking for $_POST[a_$z]
(where $z = $i +1) only one $_POST value with this name
series is processes and the loop quits.
Here is the post processing code at this stage of the script:

$edata = array();
$part = '';
$flen = '';
$file = '';
if($_POST['section'])
  {
   $part = $_POST['section']; // target file section
   $flen = $_POST['flen'];// length of text field group, shows to 
be the correct number

   $file = $_POST['df'];  // file to work on
   $z = 1;
   switch($part)
 {
  case 'name':
  /*
a_1, a_2 etc are field names
printing these values shows that all the fields are being 
posted properly

array_push($edata, $_POST[a_1]);
array_push($edata, $_POST[a_2]);
array_push($edata, $_POST[a_3]);
array_push($edata, $_POST[a_4]);
   could be as few as 1 and as many as 13 fields
  */
  for($i = 0; $i  count($flen); $i++)
  {
   array_push($edata, $_POST[a_$z]); // this loop 
terminates on the first iteration.
   print $_POST[a_$z].'br'; // only prints the first in 
the series.

   $z++;
  };
  //edit_pa_rec($edata, $file, $flen, $part);
  break; - more cases with similar code
I want to avoid hard coding the $_POST variables
so, question, is this:
A: a bug?
B: $_POST data is getting dropped in the loop?
C: Something else is wrong with my code?
Thanks in advance
Jeff K

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



[PHP] re another hand wringer

2007-02-18 Thread jekillen

Sorry all;
regarding recent post  list troubles with code below
in the loop I was using count($value) instead of just $value

 for($i = 0; $i  count($flen); $i++) // should be $flen instead of 
count($flen)

  {
   array_push($edata, $_POST[a_$z]); // this loop 
terminates on the first iteration.
   print $_POST[a_$z].'br'; // only prints the first in 
the series.

   $z++;
  };

 for($i = 0; $i  $flen; $i++) // now it works
  {
   array_push($edata, $_POST[a_$z]);
   print $_POST[a_$z].'br'; //  prints all values.
   $z++;
  };

Thanks for your time;
Jeff K

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



Re: [PHP] un include?

2007-02-11 Thread jekillen


On Feb 11, 2007, at 1:16 PM, Larry Garfield wrote:



You're using str_replace() on PHP code to control configuration 
variables?
There's a half dozen better ways that are less error prone and faster 
and

more secure.

My recommendation:

- If the config is all simple values, use an ini file.  You can then 
use
parse_ini_file() to read the data into an array that you can 
reference, and

can write the array back out easily.  (Ini is a very simple format.)

- If you want it to be programmatically editable, put it in your 
database and
be done with it.  A simple key/value table with a getter function and 
setter
function is trivial to setup, but far more robust and flexible than 
messing

around with the file system.


Thank you for your suggestions.
I am writing a web based app that creates packages for registered
users. Each user has a user space created for them on the server.
It consists of a directory with files and subdirs and files. Each 
package

is uniform. The only thing that personalizes each user space is the
user space directory name and the config file in that user space.
This config file does not effect any other users space. So an ini file
with globally set variables is completely out of the question. At 
present

I am not using any databases in this context. There are other security
measures I have in place for this. One is that the user must login and
all transactions with the server are done over ssl. Every page request
is authenticated (not by re entering id/pw). And a few other tricks.
Thanks again.
Jeff K

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



[PHP] [re]crazy time with str_replace()

2007-02-11 Thread jekillen

Hello;
I solved this problem, I think. It is the only thing I could find 
different between
two other wise identical strings in two php files with identical names 
(in different
dirs). One was formatted for Unix (linefeed line ending) and the one, 
that was
not responding,  was formatted for Mac (carriage return line endings). 
I have not

tried it yet but I believe that will solve the problem.
Perhaps this will help someone with a similar problem they cannot seem 
to solve.

JK
Addenda:
sorry, this message seems to have been placed in my drafts dir instead 
of being

sent. Here it is.

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



[PHP] un include?

2007-02-10 Thread jekillen

Hello all;
Is there a way to un include a file once it has been included in a 
script?

I have a situation where I need to include a php file for a variable and
its value. Then I need to open the file and modify it in the same 
function
'that included the file. So far the function, as I test it does not 
appear

to be making the intended changes to the file that has been included.
And I am not getting any error messages.
Am I asking too much:
$fileToInclude = 'some_file.php';
function edit_included_file( $fileToInclude)
{
include($fileToInclude);
// use some variable in it
$fr = fopen($fileToInclude, 'r');
$str = fread($fr, filesize($fileToInclude))
fclose($fr);
// make alterations to $str
// reopen file and write the changes
// done but in test function I have written changes have not been made
}
looked through the O'Reilly book Programming Php and could not find
a clue.
Thanks in advance
Jeff K

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



[PHP] crazy time with str_replace()

2007-02-07 Thread jekillen

Hello;
I really am trying to use this as a last resort but sometimes the 
solution refuses to present itself just by swearing and

staring and poking around with comments and print statements.
line 197:  $rdata = str_replace(// \$routes[] = '';\n, 
\$routes['$usr'] = '../$path/in';\n// \$routes[] = '';\n, $rdata); // 
this is not working
line 223:  $rrdata = str_replace(// \$routes[] = '';\n, 
\$routes['$user_long'] = '../$r/in';\n// \$routes[] = '';\n, 
$rrdata); // this is working


These two lines are in a function I wrote. I add the line numbers to 
indicate that they are separated by some
code. But they perform identical tasks on two different files with the 
identical names in two separate directories.
As far as I can tell the target strings are identical in both of the 
files; initially, one file is a copy of the other, but
change as array items are added. Or are supposed to. The string // 
$routes[] = '';\n is used as a template
for adding new array items. (in the str_replace code, the $ is escaped 
with \ so it will be interpreted literally)
The problem is the str_replace operation works on the $rrdata variable 
and not the $rdata variable.
 When testing the $rdata variable with a print statement, there is no 
change to the target string; I.E. // \$routes[] = '';\n
is not replaced with \$routes['$usr'] = '../$path/in';\n// \$routes[] = 
'';\n.

The file is a php file that i am trying to write to.
There is no read errors on fopen nor fread on the file in the first 
line. The file that the first str_replace() is supposed
to modify is in the same directory as the script that has this 
function. The function is included in another script
file in the same directory. The second file that str_replace is working 
on is from a file opened in another directory.
I have checked read and write permissions on both files and directories 
and found nothing i could point at as the
cause of the failure and in fact I would expect the fopen function to 
fail if there was a permissions problem.
It is obviously opening and reading the file successfully, as using 
print before the str_replace operation
show that the file has been properly read into the $rdata variable. In 
case it is not clear, the two marks
after the = sign in each line indicate an empty string surrounded by 
single quotes, that makes it appear

to be one double quotation mark when it is not.
Can anyone see what I am not seeing, or tell me something that I should 
be aware of that I may not be.

thanks for your time;
JK

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



Re: [PHP] ereg() problem

2007-01-31 Thread jekillen


On Jan 31, 2007, at 8:13 AM, Jim Lucas wrote:


jekillen wrote:

Hello php list;
I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, 
$m);

do we need to break out of the text to include the $to variable??

The $to variable is what I use to id the tag to get the path from, it is
critical. It is like answering the question 'What is Joe's address?'
Joe in this example is the $to variable.




testing $route I get:

do you mean $get_route?

No, I mean $route after I have assigned $m[1] to it;



$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)

Is this an example of th input?

This is what the regular expression (.*) is matching
in the tag. It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.


What does an actual line of $get_route look like?

$get_route is what was read from the XML file.
It will have a steadily increasing number
of tags in the above pattern and nothing else (accept
for opening and closing xml tags.



do a var_dump($m); and show output

The problem is that the regex is missing the closing single quote and
matching to the end of the tag instead of just matching what is between
the  parenthesis.



jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK


or better yet, try this

I am assuming on the actual structure of $get_route but the following 
return to me $match[1] = '../jk'


$to = 'something';
$get_route = route name='something' x='../jk/in' rec='998asdf' /;
preg_match(|route name='.$to.' x='(\.\./.*)/in' rec='.*' /|, 
$get_route, $matches);

var_dump($matches);
O.K. thanks, $m[0] is supposed to have the whole match and $m[1...n] is 
supposed to

contain the matches made by each set of parenthesis.
Does anyone know or understand the concept of greed in regular
expressions, and how to turn it off in php? That is all I am asking for.
JK

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



Re: [PHP] ereg() problem: solution

2007-01-31 Thread jekillen

Hi
In reference to my query about 'greed' in regex in php and the following
code
$x = ereg(route name='$to' x='\.\./(.*)/in' rec='.*' /, 
$get_route, $m);

I solved the immediate problem with the following:
route name='$to' x='\.\./([a-z]{2}|a?u_[0-9a-z]{8})/in' rec='.*' /
as you can see, the regex is quite a bit more complicated and I
do not know if it will match all the possibilities that it will have to.
It looks like it should. one possibility that it is matching is just two
letters, in this case jk. The other possibility is u_ or  au_ followed
by 8 randomly selected letters and/or numbers.
In short I was trying to be as simple and comprehensive as
possible with (.*) as the regular expression. But the idea of greed
came to mind when the match was containing far more than antic-
ipated. Greed is when the regular expression tries to match as much
as possible, in this case (.*) appears to be matching every instance of
anything and everything else in the way, so it ends up including the
entire balance of the line. A least that is my explanation. So I did
something more complicated to get what I wanted. Simplicity is not
always so simple.
Thanks for all responses.
JK

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



Re: [PHP] ereg() problem

2007-01-31 Thread jekillen


On Jan 31, 2007, at 4:38 PM, Richard Lynch wrote:


On Tue, January 30, 2007 8:36 pm, jekillen wrote:

I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route,
$m);
testing $route I get:
$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)
jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?


No, it's that you put the parens () around only the .* and not around
what you wanted:
ereg(route name='$to' x='\\.\\.(.*/in') rec='.*' /, ...


It seems like every time I do this I have to monkey around
with it until I get what I want.


Join the club. :-)

You may want to consider a couple actions:
  Switch to PCRE http://php.net/pcre

It's better documented, less confusing, faster, and just better all
around.

Download and play around with The Regex Coach which provides a
visual feedback on what happens when you change the #$^% inside your
pattern.


I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?


I haven't used ereg in so long, I can't answer this for ereg.
In PCRE, you use tack on 'U' after your end patter delimiter.


Thanks, I believe I do have pcre in my installation, and that
was my next target for investigation. As I turns out I got a
regex that works, albeit more complicated than (.*). See this
post subject + solution. by me.
thanks for the response.
JK

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



[PHP] ereg() problem

2007-01-30 Thread jekillen

Hello php list;

I am having trouble with ereg().
The following is the problem code
$x = ereg(route name='$to' x='../(.*)/in' rec='.*' /, $get_route, 
$m);

testing $route I get:
$route = $m[1];
print $route.'br';
jk/in' rec='a_378e6dc4.xml' / (out put of print)
jk is all I am looking for but
is it greed that is missing the
forward slash and the single quote?
It seems like every time I do this I have to monkey around
with it until I get what I want. I have even changed the
formatting of files just so a regular expression would
work without this sort of trial and error.
Is there a way I can turn off greed in php's regex?
I am using php v5.1.2 with Apache 1.3.34
Thanks in advance.
JK

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



[PHP] regarding ereg() problem

2007-01-30 Thread jekillen

Hi again;
(Blush)
I just did noticed that I
did not mask out the
two dots:
$x = ereg(route name='$to' x='\.\./(.*)/in' rec='.*' /, $get_route, 
$m);

I am trying again..
I still get the same result
jk/in' rec='a_378e6dc4.xml' /
JK

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



Re: [PHP] having trouble with is_file() and is_dir() on 5.1.2

2007-01-23 Thread jekillen


On Jan 22, 2007, at 11:18 PM, clive wrote:




everything without an extension is a directory
You will notice that the only directory detected
by this code is templates. There are no files
detected by this code. Does this have something
to do with stat cache? I want to make one array
with directories and one array with files. I can't
see any syntax or logic problems.
Thanks in advance;
JK


As far as I know is_dir and is_file require a full path , as chris 
mentioned, how are you populating $cont;


clive



Thanks all for the replies, I think I got the message.
Some times getting better at things can be a pain.
I code and code and code and get use to writing
code like the above and have it just work. Then I
use a function I've never used before, is_file()
and is_dir() and surprise... I have gotten past dumb
syntax errors and screwy logic, it must be the os
or something(?!).
JK

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



[PHP] re: having trouble with is_file() and is_dir() on 5.1.2; solved

2007-01-23 Thread jekillen

Thanks all.

**

As far as I know is_dir and is_file require a full path , ...


This did the trick. I kind of assumed that the path info would be 
understood by is_file() and is_dir().

But explicitly adding the path info solved the problem.
Now I have a beautiful array with 38 items just as I need them.
JK

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



[PHP] having trouble with is_file() and is_dir() on 5.1.2

2007-01-22 Thread jekillen

Hello php developers:
I am having a problem with the following code:
OS: FreeBSD v6.0
Apache 1.3.34
php 5.1.2
- $cont is an array produced from opening and reading a
directory:
for($i = 0; $i  count($cont); $i++)
 {
   print $cont[$i].'br';
if(is_file($cont[$i]))
  {
 print is file: .$cont[$i].'br';
 //array_push($files, $cont[$i]);
}
   else if(is_dir($cont[$i]))
{
print is dir: .$cont[$i].br;
 //array_push($dirs, $cont[$i]);
 }
  }

The print statements produce the following:

collections
groups
in
index.php
lists.php
new_multi.php
new_single.php
out
pref_code
pref_funct.php
process.php
requests
rlists
routing.php
send.php
steps.php
store
templates

is dir: templates  - only directory recognized (extra line breaks 
added here for readability)


usr_config.php
usr_pref.php

everything without an extension is a directory
You will notice that the only directory detected
by this code is templates. There are no files
detected by this code. Does this have something
to do with stat cache? I want to make one array
with directories and one array with files. I can't
see any syntax or logic problems.
Thanks in advance;
JK

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



Re: [PHP] having trouble with is_file() and is_dir() on 5.1.2

2007-01-22 Thread jekillen


On Jan 22, 2007, at 10:20 PM, Chris wrote:


jekillen wrote:

Hello php developers:
I am having a problem with the following code:
OS: FreeBSD v6.0
Apache 1.3.34
php 5.1.2
- $cont is an array produced from opening and reading a
directory:
for($i = 0; $i  count($cont); $i++)
 {
   print $cont[$i].'br';
if(is_file($cont[$i]))
  {
 print is file: .$cont[$i].'br';
 //array_push($files, $cont[$i]);
}
   else if(is_dir($cont[$i]))
{
print is dir: .$cont[$i].br;
 //array_push($dirs, $cont[$i]);
 }
  }



I'd be guessing it's a path issue.

Try prefixing the is_dir and is_file calls with the path to the 
directory they are in:


$basedir = '/whatever';

for($i = 0; $i  count($cont); $i++) {
  $fullpath = $basedir . '/' . $cont[$i];
  if (is_file($fullpath)) {
  .
}

--
Postgresql  php tutorials
http://www.designmagick.com/


Ok, I hope I can get this to work. The code
I copied here was code that was in the directory
reading loop, where I would have guess that
it would have the path info, but it did the same
thing. But I will take you suggestion.
Thanks for the reply;
JK

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



[PHP] Scope of include

2007-01-17 Thread jekillen

Hello php list:
If I include a php script inside a php function definition and then 
call the
function in another script. What is the scope of variables in the 
included
script? Are they local to the function that calls include with the file 
name?

Thanks in advance;
I'm not sure where to look for this answer;
JK

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



[PHP] reading/editing php file with php script

2007-01-06 Thread jekillen

Hello;
I have been writing a php script which is supposed to open and edit a 
php file on the same server,
in the same directory. But I have not been able to get regex as in 
function ereg() to work to match
a line of code to alter. I also have not been able to get strpos() to 
work in this code. I am not
complaining, i am just curious if this is a security feature of php, 
that it can't be used to open
and edit existing script files on a web server. Or am I doing something 
wrong? I have successfully
used php to write a php script file from scratch and then include it. 
It works good for keeping track

of things on the server.
Thanks
JK

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



Re: [PHP] Odd behavior

2006-12-25 Thread jekillen


On Dec 25, 2006, at 7:21 AM, Roman Neuhauser wrote:


# [EMAIL PROTECTED] / 2006-12-24 18:11:03 -0800:

function display($list, $in, $out, $save, $req, $x)
 {
  for($i = 0; $i  count($in); $i++)
  {$j = $i + 1;
  // two sets of links displayed instead of one
 for($i = 0; $i  count($out); $i++)
  {$j = $i + 1;
// two sets of links displayed instead of one
  for($i = 0; $i  count($save); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one
  for($i = 0; $i  count($req); $i++)
   {$j = $i + 1;
 // two sets of links displayed instead of one


The print lines above are supposed to produce a list of links to 
files.

In the web display I get duplicate sets of links which seems to mean
that the loops in the function are running twice, and in one instance
three times instead of once.


Look at the variable names you use for iteration.


Thanks, Usually, when a variable name like $i is used and then
reset to 0 in the next loop it does not matter. But I solved the
problem and posted the solution.  I also solved the regex
problem. There was an extra \n sneaking into the test pattern
so I could not get a match. I am not sure where the extra \n is
coming from.
It looks like I didn't post the solution after all:
Update:
I solved the double loops problem with this code change:

function display($list, $a, $x)
{
 for($i = 0; $i  count($a); $i++)
{$j = $i + 1;
 print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr\n;

};
 }
and:

if($list || $current)
  {
switch($list)
  {
   case 'in':
   display($list, $in, $x);
   break;
   case 'out':
   display($list, $out, $x);
   break;
   case 'save':
   display($list, $save, $x);
   break;
   case 'req':
   display($list, $req, $x);
   break;
  }
  }
Apparently what was happening was that the code running under 5.1.2
was trying to process all the arrays that had values in spite of the 
switch
statement in the original display() function. If the was an $in array 
the
switch  would process that for the $list value being 'in' but since 
there

was also a save value, the switch tried to process it also, even though
'save' wasn't the $list value. I found it would do this for all arrays 
that

had values. So if three had values the loop selected loop would run
three times.
Could this be a bonafide bug?
JK

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



[PHP] Odd behavior

2006-12-24 Thread jekillen

Hello,
Am having trouble with some code.
I have been developing a web based application on
a machine running php v4.3x, Apache 1.3x Mac OSX 10.3
The application works as expected on this machine.
So I copied the code to my server which is running FreeBSD
v6.0, Apache 1.3.34, php v5.1.2.
On this machine the exact same code does not work as expected
in some critical places.
Here is the code suspect of being troublesome:

include(process.php);
if(file_exists(in_tmp.php))
  {
   include(in_tmp.php);
  }
if(file_exists(out_tmp.php))
  {
   include(out_tmp.php);
  }
if(file_exists(save_tmp.php))
  {
   include(save_tmp.php);
  }
if(file_exists(request_tmp.php))
  {
   include(request_tmp.php);
  }

 code snipped

function display($list, $in, $out, $save, $req, $x)
 {
   switch($list)
{
  case 'in':
  for($i = 0; $i  count($in); $i++)
  {$j = $i + 1;
   print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr;

  // two sets of links displayed instead of one
   };
break;
case 'out':
 for($i = 0; $i  count($out); $i++)
  {$j = $i + 1;
 print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr;

// two sets of links displayed instead of one
};
 break;
 case 'save':
  for($i = 0; $i  count($save); $i++)
   {$j = $i + 1;
 print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr;

 // two sets of links displayed instead of one
};
  break;
  case 'requests':
  for($i = 0; $i  count($req); $i++)
   {$j = $i + 1;
print a 
href=\steps.php?list=$listnext=$jx=$x\$j/abrbr;

 // two sets of links displayed instead of one
   };
  break;
  };
  }
The print lines above are supposed to produce a list of links to files.
In the web display I get duplicate sets of links which seems to mean
that the loops in the function are running twice, and in one instance
three times instead of once. The arrays are taken from the included
files. These files are php scripts produced by a php script after a
directory is opened and read. The arrays a declared and initialized
in these scripts. If there are no files in the directories, the scripts 
are

not written (thus the code if(file_exists(so and so file) etc..).
Is there a difference in the behavior of include between php 4x and 5x?
I am also having problems with a regular expression:

$w = ereg(To:nbsp;nbsp;nbsp;nbsp;\n([ A-Za-z]*), $data, $m);
$x = ereg(recipient who='.$m[1].' to='(.*)' /, $rout, $m_1);
 $dest = $m_1[1];

This code has opened and read a file and is picking out data from the 
file
so it can use this data to copy the file to another directory. On my 
dev server
this code works fine. On the production server this code will not pick 
up the

match from the first regex and so will not find a match in the second.

Is this a difference between versions of php, known bugs, possibly a
problem with the php or Apache installation on my production server?
If nothing comes to anyone's mind, I will have to do some digging.
but if there is I would appreciate suggestions advice.
Thanks in advance.
JK

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



Re: [PHP] RE: Are PHP5 features worth it?

2006-12-20 Thread jekillen


On Dec 20, 2006, at 3:14 PM, Niels wrote:


Hi,

On Wednesday 20 December 2006 19:47, Ray Hauge wrote:

I think all this talk goes to show you that the differences between 
PHP4

and PHP5 are somewhat personal at this point in the game.  Some people
like the better OOP features of PHP5, some people think PHP5 is 
faster,

some people like the XML/WebServices in PHP5 better, and many others
(don't forget PDO, or exceptions).

Yep, that sums it up nicely.



For the OP, I think it's really going to come down to what you think.
Everyone's mileage is varying on this one.

Here's my .02.  If you go with PHP5, go with at least PHP 5.1.x, if 
not
5.2.  I'm not sure how stable 5.2 is lately. I had heard of some 
issues,

but they could have been from things most people don't do.  I'm pretty
sure that people don't install 5.0.x anymore, but 5.1 is a lot better
(from what I've heard anyway.  I never used 5.0.x)

I think I'll move to 5.2 within a couple of months and slowly start 
using

some of the new features.

Thanks,
Niels

Hey, I'd like to be able to run at least two versions of php on one 
server and switch between them
because if you've written a pile of php 4x code and need to switch to 
5x, ( hosting service switches
the boss you work for decides to switch , or what ever,) you have to go 
through all your 4x code and
rewrite it to be compatible with 5x. So, the benefit of switching 
becomes an important consideration.
While your converting 4x code to 5x compatibility you need two servers 
running, one with 4x interpreter
and one with 5x interpreter. It really would have been nice if Apache 
and Zend got together so both
version could be run by the same server based on something in 
httpd.conf and/or php.ini. What i have
done, not to berate 5x is to write code that is compatible with both 
version. I have servers running both

4.3x and 5.1.2 and  they run the same code just fine.
This might give you some more perspective.
JK

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



[PHP] erratic bounced message notices

2006-12-04 Thread jekillen
The following is a response to a message I sent to the link in a 
bounced e-mail notice from this list:


This is an automated response to your message to 
[EMAIL PROTECTED]


If you are trying to post to one of the PHP mailing lists, the correct
address looks something like [EMAIL PROTECTED]

If you are having problems unsubscribing, follow the directions
located online at http://php.net/unsub

Thanks!

And this is the reply that I sent to that address:
([EMAIL PROTECTED])

Please be advised that this erratic  behavior
is not within my control. I do not have filters
to block messages from this list. These may
be intercepted by a server and bounced as
a proxy, I also get lots of spam that is not
addressed to me. Since SBC Yahoo has
become mixed up with ATT again, I am
not even sure who has my e-mail account
info and I dread trying to find out from them,
let alone complain about spam or bounced
email problems.
JK
[EMAIL PROTECTED]

why is this list is set up to solicit responses to
messages like this and then responds
as if I am doing something wrong by following
the indicated link? 


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



Re: [PHP] Self generating variables/arrays

2006-11-26 Thread jekillen


On Nov 26, 2006, at 5:11 AM, Stut wrote:


jekillen wrote:
I am writing some code that will format results of a search for  
display.
I need to split an array into several different arrays but I won't  
know

before hand how many, so, I am looking for a way to dynamically
generate arrays for this purpose.
My present direction is to use the following code:
for($i = 0; $i  $c; $i++)
{ eval('$a_'.$i.' = array();'); }
Where '$c' is the derived number of arrays need to hold the
pieces of the bigger array. My confusion, though, is; since
these are created in the scope of the for loop, I don't know
if I can use them elsewhere in the code. The Global statement
sends them outside the scope of the function this code is in,
or does it? And I'm not even sure I am on the right track.
Perhaps someone can say yay or nay on the spot, if not
I can go back and do some experimenting.


I'm not sure why you think you need to do this. In PHP you do not need  
to 'declare' variables, you can just use them. So unless you're  
checking for the existance of these arrays after this loop, the loop  
is completely pointless. But you haven't included enough information  
about how you intend to use these arrays to give a definite answer.


As far as scope goes, if you want to create these variables in the  
global scope, create them as elements of the $GLOBALS array  
[http://php.net/manual/en/ 
reserved.variables.php#reserved.variables.globals].


-Stut

Thanks for the reply;
The problem is
1. one large array exploded around \n
2. then a loop looks for 'brbr\n' items
and records the index number of these items
as well of keeping a count: ($c)
3. Since $c is a variable it can represent a different
number each time.
4. Since I don't know what $c is going to be I can't
   declare array variables with predetermined names
5. I want to slice the large array into $c arrays that
   begin and end around items in the large array
   containing 'brbr\n';
This is as much abstraction as I can give you
In context it is represented by several hundred lines of function code.
This code is supposed to format the result of a search operation.
It is tailored for a custom application. I don't want to rewrite the
whole ball of wax just so I can use someone's wonderful pre
packaged code library or applications.
(I have gone ahead with experimenting with this code and
 was successful, up to a point...)
Thanks again;
JK





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



[PHP] Self generating variables/arrays

2006-11-25 Thread jekillen

Hello;
I am writing some code that will format results of a search for display.
I need to split an array into several different arrays but I won't know
before hand how many, so, I am looking for a way to dynamically
generate arrays for this purpose.
My present direction is to use the following code:

for($i = 0; $i  $c; $i++)
{ eval('$a_'.$i.' = array();'); }

Where '$c' is the derived number of arrays need to hold the
pieces of the bigger array. My confusion, though, is; since
these are created in the scope of the for loop, I don't know
if I can use them elsewhere in the code. The Global statement
sends them outside the scope of the function this code is in,
or does it? And I'm not even sure I am on the right track.
Perhaps someone can say yay or nay on the spot, if not
I can go back and do some experimenting.
Thanks in advance
Jeff K

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



[PHP] Use of substr()

2006-11-02 Thread jekillen

Hello all;
I am scratching my head over the following:
I have written code that is supposed to format text
sent from a form in a textarea form element.
This text does not have new lines added if
the text is allowed to automatically wrap to the
next line. I want to automatically add new lines
to this input at appropriate locations.

Here is the code I wrote:
(It is in early stages of development)
function format_text($a, $b) // $a is text to format, from textarea, $b 
is line length

{ $line = array();
   $limit = (strlen($a)/$b);
  for($i = 0; $i  $limit; $i++)
 {
$start = $i*$b;
$stop = (($i*$b) + $b) - 1;
print start : $start stop : $stopbr;
array_push($line, substr($a, $start, 
$stop)); // separate into lines not greater than $b length

 }
return $line;
 }

Here is what is entered in a test run:
(actual text has no new lines, I added them here)
Then let us test a long string that spans more than the line length of 
the text area field.
This is the way I practice both writing and typing. If I could only get 
by the booby traps

and land mines with my typing, I could get somewhere.

This is output code:

if($_POST['input'])
  {print strlen($_POST['input']);
   print'br';
   $output = array();
   $output = format_text($_POST['input'], 60);
   for($i = 0; $i  count($output); $i++)
  { print $i :.$output[$i].'br'; }
  }

Here is what comes out the other end:

239
start : 0 stop : 59
start : 60 stop : 119
start : 120 stop : 179
start : 180 stop : 239
0 :Then let us test a long string that spans more than the lin
1 : length of the text area field. This is the way I practice both 
writing and typing. If I could only get by the booby tr
2 :oth writing and typing. If I could only get by the booby traps and 
land mines with my typing, I could get somewhere.

3 :ps and land mines with my typing, I could get somewhere.

// e is missing from end of line 0
// portions of the text are repeated out of sequence.
The questions I have are:
What does the browser actually do when it automatically wraps textarea 
input?

What could explain the scrambled result?

Thanks much to anyone taking the time:
Jeff K

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



[PHP] ENV vars

2006-10-19 Thread jekillen

Hello again;
I'm wondering if it is possible to create an $_ENV var with a php
script running under a web server. I'm not sure where to look
in the manual or other documentations for this. Isn't there a
set_env() function or something like it? (would apply to php 4 0r 5x)
Thanks in advance.
JK

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



[PHP] buffer settings in php.ini?

2006-07-22 Thread jekillen

Hello;
I am having a strange breakdown in some dhtml that
uses php to dynamically generated images and support data.
The program is supposed to generate 9, 16, or 25 images.
It does 9 without problems but breaks with 16, and 25.
I've written the code to accommodate different numbers
of images, not separate code for each size.
From tracking the progress of the code (javascript/css/html and php)
It appears to be some kind of a buffer limit problem. One array
that the php is supposed to produce comes out fine when the
function to produce it is isolated and run but breaks in the context of 
the code
and appears to be the point where things go bad for the rest with 16 
images.
 It is used to generate the tile images in the gd code. Each image is 
generated

in a for loop.
So, I'm wondering if generating 16 images is causing a buffer
overflow, and if there is a gd specific buffer setting that can
be increased, as well as the general limits for php in php.ini.

Sorry, I don't remember where to look for all the php.ini info
in the manual.
I'm using php 5.1.2, gd 2.0.33
Thanks in advance.
JK

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



[PHP] forcing a script to run on page unload

2006-07-18 Thread jekillen

Hi:
I have a web application that creates files and directories to save info
for a user. If the user decides to link to another page or site 
altogether

I want to run a script that will clean up after him or her but won't
interfere with where they are going. It will eventually expand
to asking the user if he or she wants to save the info for a return
visit. If they don't want to save it has to clean up after them
and if they do it goes through the process of tagging and
saving the info on the server.
My strategy is to run a spontaneous form submission with the
body onunload event. Then run the script and exit. I seem to
remember a way to force a script to run and I've seen that
in a site that I visit occasionally. Even if I quit the browser
it still manages to delay the exit of the browser. But I don't
remember whether it was one of my books on php or the php
manual that this is in.
Can someone point me in the right direction?
Thanks in advance:
JK

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



[PHP] strange behavior

2006-07-15 Thread jekillen

Hello:
I have a directory on a server that has php code that creates and 
writes to directories as such;  /tiles_.*/.
Each directory with a matching name has graphics files written to it. 
i'm trying to write a script the will
eliminate the graphics files and the directories they are in 
(tiles_.*). The present code is:

?php
function prune()
  {
   $f = 0;
   $pat = 'tiles_.*';
   $view = array();
   $t = array();
   $str = '';
   $start = opendir('.');
   //printHello???br; debug code
   while($lst = readdir($start))
   {
if(ereg($pat, $lst))
  {
   $t[$f] = $lst;
   $str .= $t[$f].'br'; //debug code
  }
 $f++;
}
   rewind($start);
   closedir($start);
   //print $str; debug codethe array $t has all valid 
values at this point.

   for($f = 0; $f  count($t); $f++)
 {$tmp = $t[$f];
  chdir($tmp);
  $dir = opendir($tmp);
  $r = 0;
  while($i = readdir($dir))
   {
@unlink($i);
$r++;
   };
   rewind($dir);
   closedir($dir);
   unset($dir);
   chdir('../');
   rmdir($tmp);
  }

  }
prune();
?
The problem is that each time the for loop tries to chdir to an array 
$t item, errors regarding invalid resources and none existent files are 
generated.
If I use chdir('./'.$tmp) and opendir('./'.$tmp) the code removes all 
the files in the directory the script is located in, including the 
script file itself.
So, I am thinking that, in this case, the directories aren't even 
changed when the @unlink() line is reached and unlink() only sees the 
current
directory files and not included directories, and removes everything 
that isn't a directory.

Here is a sample of the errors generated:
Warning: chdir() [function.chdir]: No such file or directory (errno 2) 
in (path)/prune.php on line 30 // (all resources used based on this are 
invalid)

and;
Warning: opendir(tiles_9215fd05) [function.opendir]: failed to open 
dir: No such file or directory in 
/var/www/html/exp/tile_puzzle/prune.php on line 31
(this happens on the second iteration of the loop..tiles_9215fd05 
is a valid array $t item)
So, Can someone tell me what I might be doing wrong here. I don't want 
to swim around with any more trial and error if possible.

I'm using php 5.1.2, Apache 1.3.34
Thanks in advance.
JK

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



Re: [PHP] Re: How to re-order an array

2006-06-11 Thread jekillen


On Jun 11, 2006, at 1:21 PM, Rafael wrote:


jekillen wrote:
[···]
You misunderstand my question. I know the limitations of javascript. 
The server won't respond to events registered in the browser. I write 
tons of forms that are all processed
by the client with javascript. I have written ferocious regex filters 
that hack apart form submissions before they even leave the client. I 
have set it up so if the client doesn't
have javascript enabled, the form won't submit if it is going to the 
server. That is why as much as possible I shift form processing to 
the client as much as possible, for
security and to off load work to the client. I use php to dynamically 
write js files when necessary, anticipating what data will be 
requested.


	I didn't (misunderstood), what I told you is that you cannot rely on 
javascript (actually, that would be anything coming from the client) 
You need to do validate on the server, and it doesn't matter if you 
already did it on the client or not (simply because you cannot know 
that for sure)


This is a problem that is more a matter of programming theory. I have 
posted to javascript forums and lists and have never got a response.
I will be applying this to dhtml which the server won't and can't do 
but may help things along with Ajax.
Just a simple suggestion about how to reorder arrays if you have a 
few words and suggestions. I'm not looking for free training.
I have been learning and using php and javascript for some five years 
and have developed my own approach to testing and debugging
and such. So I am not really a newby. I have made the dumb mistakes 
of asking for help from forums and lists when it was just a dumb
syntax error that I couldn't expect anyone but my self to find, which 
i have in 99.9% of the cases. Some times it is nice to get some
quick help from a list and I will try to return the favor when ever 
possible to the next person looking for help that I have some answers 
for.


	Well, I asked you for the actual (JS) code you're using (the one that 
didn't work in all the intended browsers), that way someone might be 
able to help you (I will if I can)

Array.push(), Array.pop(), Array.shift(), Array.unshift().
I thought that if I used Ajax, php could use its push and pop, shift 
and unshift functions, but not all browsers support the asymetric 
requests.
I do screen in the server. But I force the user to have javascript 
enabled and force the form to submit using javascipt, and have a unique 
id as a javascript variable
that is sent along with the form in a hidden field to identify the 
source of the form data. I never use get requests unless they are 
appended to anchor tags, even
in  forms that are not processed by the server (I.E. running javascript 
code with user supplied arguments to functions via form fields, in 
which case an action attribute

isn't even necessary, and like wise a post or get method).
JK


--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

--
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] Re: How to re-order an array

2006-06-10 Thread jekillen


On Jun 10, 2006, at 5:32 PM, Rafael wrote:

	Since you asked for some theory... theorically, you won't rely on 
javascript to prepare/validate/whatever some data to the server, 
that's what server-side scripts are for.
Note: you may use JS to make things quicker if possible, or to 
pre-digest the data, but you shall not rely entirely on JS.
You misunderstand my question. I know the limitations of javascript. 
The server won't respond to events registered in the browser. I write 
tons of forms that are all processed
by the client with javascript. I have written ferocious regex filters 
that hack apart form submissions before they even leave the client. I 
have set it up so if the client doesn't
have javascript enabled, the form won't submit if it is going to the 
server. That is why as much as possible I shift form processing to the 
client as much as possible, for
security and to off load work to the client. I use php to dynamically 
write js files when necessary, anticipating what data will be 
requested.
This is a problem that is more a matter of programming theory. I have 
posted to javascript forums and lists and have never got a response.
I will be applying this to dhtml which the server won't and can't do 
but may help things along with Ajax.
Just a simple suggestion about how to reorder arrays if you have a few 
words and suggestions. I'm not looking for free training.
I have been learning and using php and javascript for some five years 
and have developed my own approach to testing and debugging
and such. So I am not really a newby. I have made the dumb mistakes of 
asking for help from forums and lists when it was just a dumb
syntax error that I couldn't expect anyone but my self to find, which i 
have in 99.9% of the cases. Some times it is nice to get some
quick help from a list and I will try to return the favor when ever 
possible to the next person looking for help that I have some answers 
for.


	You say that not all browsers support the javascript functions you 
pretend

'scuse me, did i pretend to use something??

to use, and that not all them support Ajax either.  That sounds just 
like saying that not all browser will have javascript enabled --that's 
why you shouldn't rely on javascript


	Although, this isn't a javascript list, why don't you send whatever 
you were trying to solve this issue? the code that uses JS functions 
not supported for all the browsers that will potentially run the 
script (as well as what these browsers are)  Most likely someone will 
be able to help you this way.

Thanks for the attitude.
jk


jekillen wrote:

Hello;
i'm scratching my head with a difficulty.
The situation is this.
A script begins with one indexed array (not associative) and one 
other indexed array

with the same values in a different order, the final order.
I want to create an interim array and progressively re order the 
array until it matches
slot for slot one of the original arrays. At this point the script is 
considered completed.
One important factor is that I'm looking to write this in javascript 
and the interim

array will be altered by the actions of a web page user.
Why am I asking the php list? Because I have a better chance of 
getting an answer
here. I'm not looking for help with javascript, specifically, just 
how one would go about
this task. Answer with php code and some theory if you wish and I 
will try to translate

it into javascript.
Some javascript functions I might use aren't supported in all the 
browsers that will

potentially run the script.
I might resort to using Ajax and let php keep track for me. But, then 
again not all

browsers will do the Ajax either (as I understand it).

--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

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



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



Re: [PHP] PHP JavaScript

2006-05-19 Thread jekillen


On May 19, 2006, at 8:20 AM, Jay Blanchard wrote:


[snip]
http://us2.php.net/variables.external
[/snip]

BINGO! We have a winner!

It can be as simple as adding an id to each checkbox;

input type=checkbox id=list37 name=list37[] value=4 /

By doing this I did not have to change the function or the function
calls. JS recognizes the boxes by id, PHP recognizes the array.

There were some other more complex solutions listed.but I believe 
in

KISS

I'm one of 'em, I do javascript programming myself and finding the right
simplicity can be one hell of a task. I'll keep this in mind for the 
future.


I'm thinking of starting a web site database for posting of any and all
who are willing to contribute to a single source for all bugs, levels of
javascript DOM and css support in all or as many as possible extant
browsers. Quirks, you name it. It will be if you have knowledge and 
solutions

and want to contribute. It won't be a gripe and hold my hand and
listen to my woes, but look for a subject like a particular browser and
version, OS, platform and get a knowledge base for that query.

Here's one to start:
Internet Explorer v5 on Mac OSX and others won't run a function
with a variable declared inside the function. The variable has to
be declared outside of the function in the global space before
it will be used inside a function. This occurs with form submission
from an onclick event, rather than a submit button. I do this to
insure that input filters are run before the form is sent to the server.
The functions I write for this do pre submit processing like run
regex filters on text fields  and text areas and use document.forms
formname.submit(). In a particular class of browser, but not all 
versions

of the same browser nor platform will run the function with variables
declared inside the function.
I don't think this is 'OT' for this list because for me php and 
javascript

are great team mates. But javascript can be a rats nest particularly
for dhtml.
I have some demonstrations in my web site but I'm being timid about
giving out the url until it has time to prove it will stay afloat 
before a crowd

tries to use it. (I host my own site from an ADSL connection).
I'm running php 5.0.1 with gd support, freetype, t1, mysql, etc, etc.
on FreeBSD.
JK.


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