Re: [PHP] auto refresh once

2005-03-02 Thread Bret Hughes
On Wed, 2005-03-02 at 01:55, William Stokes wrote:
 Hello,
 
 Is it possible to force one automatic refresh browser when user enters to a 
 webpage? If so, how?


javascript timer and a reload in a function called vi body onLoad wouldd
do it I guess.  if you are only going to do it once you need to not
write the javascript the second time through so you will have to keep
track of whether this is the first time or not.

HTH

Bret

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



Re: [PHP] How to handle actions that may take a long time?

2005-03-01 Thread Bret Hughes
On Tue, 2005-03-01 at 03:05, Cajus Pollmeier wrote:
 Am Dienstag, 1. März 2005 09:14 schrieb [EMAIL PROTECTED]:
  You can send a piece of HTML defining some little thing like a div layer
  with your please wait, bla bla bla
  So the visitor can read something.
  When the process is finished, you can write another piece of HTML
  containing some JavaScript lines, changing the text (and icons or
  images) so you can inform your visitor that the process had finished.
 
 If it's possible I'd like to avoid js ;-)
 
  This is the clasical no end web page... You can do something similar
  with frames, so in a little frame the visitor can see the status,
  (searching, wait...) and in another big frame can do something usefull.
 
 I'm going to evaluate some things...
 

I don't know where I read it but there are some ideas out there that
people use to monitor long running html uploads and provide status on
them.  IIRC the main idea was to write the status to a file ( or like
you said, to a session var) and periodically reload the page to get the
latest status.  Now that I think about it it may have been a how to do a
status bar for uploads.  I do not recall if it needed js or not. 

HTH
Bret

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



RE: [PHP] textarea posting duplicate text

2005-03-01 Thread Bret Hughes
On Tue, 2005-03-01 at 08:43, Elizabeth Lawrence wrote:
 Thanks, Dan. I copied your code exactly and posted it here:
 http://www.tidefans.com/test.php I pasted a large part of O'Henry's Gift of
 the Magi into the textarea, and it gets repeated, as before.
 
 Thanks for any help,
 Elizabeth


There are some settings in php.ini that affect the max size of post
variables.  It is sort of interesting to me that it is not a complete
copy but the first 1303 bytes or so are printed and then the test as a
whole is there preceded by testarea=.

It does not do this on my server. 4.3.6 apache 2

I notice that the Server API  says  Apache 2.0 Filter on your box and on
mine it says Apache 2.0 Handler.  I have no idea what that means.

Bret

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



RE: [PHP] textarea posting duplicate text

2005-03-01 Thread Bret Hughes
On Tue, 2005-03-01 at 10:19, Bret Hughes wrote:
 On Tue, 2005-03-01 at 08:43, Elizabeth Lawrence wrote:
  Thanks, Dan. I copied your code exactly and posted it here:
  http://www.tidefans.com/test.php I pasted a large part of O'Henry's Gift of
  the Magi into the textarea, and it gets repeated, as before.
  
  Thanks for any help,
  Elizabeth
 
 
 There are some settings in php.ini that affect the max size of post
 variables.  It is sort of interesting to me that it is not a complete
 copy but the first 1303 bytes or so are printed and then the test as a
 whole is there preceded by testarea=.
 
 It does not do this on my server. 4.3.6 apache 2
 
 I notice that the Server API  says  Apache 2.0 Filter on your box and on
 mine it says Apache 2.0 Handler.  I have no idea what that means.
 
 Bret
 

Hmm I did not remember writing the bit about post_max_size.  I was
checking your settings in the phpinfo output when I found the
filter/handler deal. obviously the post_max_size is not the culprit.

Bret

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



Re: [PHP] combining values

2005-03-01 Thread Bret Hughes
On Tue, 2005-03-01 at 11:44, Sascha Kaufmann wrote:
 $birthday = $day.'.'.$month.'.'.$year;
 

why wouldn't 

$birthday = $day.$month.$year;

work as well.

Bret

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



Re: [PHP] Catalog or cart

2005-03-01 Thread Bret Hughes
On Wed, 2005-03-02 at 04:45, Ryan A wrote:
 Hey all,
 I have a client who has a computer store, now he wants to put all his stuff
 in one site.
 He does not want to do any selling from his site, but just list all his
 items.

I don't have a solution but I just wanted to say that the very first
thing that came to mind was.  

Warning Will Robinson.  Scope creep approaching! 

He does not want to do any selling from his site, NOW.  If you are going
to go to the trouble to set us something especially an existing solution
I would strongly recommend that you give the ability to grow into a cart
based ecommerce site serious weight over those catalog only solutions
that do not have that capability.  Best to look the hero when he says
Ya know, I have had several customers that wish they could purchase via
a web site.

my $0.02 US.

Bret

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



Re: [PHP] php DBMS

2005-02-28 Thread Bret Hughes
On Mon, 2005-02-28 at 11:31, Gerben wrote:
 Hi,
 
 I'm wondering if there is any DBMS, like MySQL, which is (fully) implemented
 in php. This so you don't have to buy a MySQL database.
 
 I'm currently trying to put something together, but this would be a waste of
 time if it already exists.
 

Does MySQL cost money?  I thought it was open source and available at no
cost.  

Bret

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



Re: [PHP] php DBMS

2005-02-28 Thread Bret Hughes
On Mon, 2005-02-28 at 13:35, Jochem Maas wrote:
 Bret Hughes wrote:
  Does MySQL cost money?  I thought it was open source and available at no
  cost.  
 
 true its free, but you can also run a comcercial version which gives you
 indemnity and support and stuff Google for instance are known to run 
 MySQL,
 companies like that like to have support contracts - at MySQL they are glad 
 to oblige,
 just unlike some other very fairplaying non-antitrust type businesses they 
 don't
 force feed you the license fee :-)


So if he is looking for a non licensed dbms MySQL would still work
albeit without formal support lie the rest of the open source world.

Bret

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



Re: [PHP] Identifying a user who previously created a profile

2005-02-25 Thread Bret Hughes
On Thu, 2005-02-24 at 04:02, Jacques wrote:
 How can I ensure that a user is prevented from creating a second profile 
 after he has registered a second time with different registration details?
 
 I thought of capturing his IP Address and checking this value against my 
 users table in my database where I have captured IP Addresses of users who 
 have previously registered.
 

Not a good way for several reasons:

Dynamic IP addresing:
NAT based firewalls.

I suspect your best bet is to place a cookie.

Bret

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



Re: [PHP] uploading files with a single quote in the filename

2005-02-25 Thread Bret Hughes
On Thu, 2005-02-24 at 01:04, Dotan Cohen wrote:
  that.  A little javascript goes a  long way in these sort of situations
 
 You don't want to do that will javascript. I, for one, surf with
 javascript turned off. The malicious script kiddie, I would presume,
 also would be very happy to send you a silly filename without letting
 javascript check it.

Very good point.

Bret

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



Re: [PHP] how to increase maximum upload file size

2005-02-25 Thread Bret Hughes
On Thu, 2005-02-24 at 06:32, Srinadh Sannidhanam wrote:
 Hi,
   In my application I need to allow the user to upload a file with size more 
 than 2M.
   I came to know that by default php will allow only 2M. How can change it.
   I changed, that in php.ini file and restarted apache. but still not working.
  How to solve this problem?
  
 Thanks,

Seems like I had to change post_nax_size also.  It is set to the same as
upload_max_size in my php.ini.

Bret

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



Re: [PHP] uploading files with a single quote in the filename

2005-02-23 Thread Bret Hughes
On Wed, 2005-02-23 at 06:49, [EMAIL PROTECTED] wrote:
 Hi
 When uploading files using a type=file in a form, if a file is uploaded with
 a single quote the file gets truncated to whatever is after the quote
 eg.
 blah'sblah.txt
 
 will be uploaded as
 sblah.txt
 
 Is this a magic quotes issue?
 
 What is the best way to deal with it?


I ran into a similar deal with a textbox and  a while back but I think
the issue was sending it back to the browser after the browser sent it
up.

In the absence of direct help,  I would first look to see where the
truncation is occurring ie; what is the browser sending? can you post
the value and see what your browser is sending it as?  is there anything
in the logs with error_reporting set to E_ALL?

I found trouble shooting the upload process cumbersome since it would
fail without any messages but that was before I started setting the
error_reporting to also log messages.

Not much help but all I got.

Bret

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



Re: [PHP] uploading files with a single quote in the filename

2005-02-23 Thread Bret Hughes
On Wed, 2005-02-23 at 16:40, [EMAIL PROTECTED] wrote:
 Thanks Bret
 
 I have tried turning all reporting on - error_reporting(E_ALL);
 but that doesn't reveal anything significant
 
 I have looked in the logs but there is nothing significant there.
 
 Because the type is file in the form it is not handled like a post - the
 values go into an array called $_FILES
 
 There seems to be no way to intercept this before the filename gets
 truncated
 


Well for another data point when I uploaded a file using our upload form
the ' gets escaped on both IE6 (win98 running in win4lin) and galeon.

test's qoutes.jpg becomes test\'s quotes.jpg on a fedora server with
apache and php of course.

I don't suppose the file gets put into a directory named with the first
portion of the file?

FWIW here is what my form tag looks like 

 form enctype=multipart/form-data action=uploadFiles.php
method=POST

and the filechooser

 input name=userfile type=file 

Bret

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



Re: [PHP] uploading files with a single quote in the filename

2005-02-23 Thread Bret Hughes
On Wed, 2005-02-23 at 18:45, [EMAIL PROTECTED] wrote:
 Hi Brett
 
 My form is effectively identical to yours
 form enctype=multipart/form-data action=/uploadfiles.php method=post
 bUpload a file:/b input name=userfile type=file size=100
 
 No the first part of the file name is just dropped and the file with the
 truncated name is saved in the correct place.
 
 But with it escaping the quote do you mean that you end up with a file with
 \ in it? That would be an illegal filename.
 
 Neil
 

Yep that is exactly what I mean.  Not sure if \it is illegal on a linux
box although unusualThe directory separator is /.  I am going to be
looking at the code soon to try and get a handle on it.  At this point I
do not know where it is coming from but I should be able to examine the
variables that get sent to the server and see where in the
browser/php/OS interaction the thing is occurring. 

I'll let you know.  I like allowing users to name files as they will and
test all my scripts that handle file names to make sure the handle
spaces well but should probably check for a few boneheaded things like
that.  A little javascript goes a  long way in these sort of situations
:)

Bret

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




Re: [PHP] Hi ALL

2005-02-22 Thread Bret Hughes
On Tue, 2005-02-22 at 05:27, Dhanasekar T wrote:
 hi all,
 i m new to this group ...now i want to learn php.
 i want all u r guidence  to utilise this group...
 thanks in advance 
 dhanas


I would start by looking at and dare I say reading the manual at
php.net.  Then surf around for a beginners tutorial, and start coding.  

I suspect the learning curve shape depends on whether you have any
previous programming experience or not.

Bret

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



Re: [PHP] errors in insert queries

2005-02-22 Thread Bret Hughes
On Tue, 2005-02-22 at 07:32, Bryan Dina wrote:
 I am having problems making proper insert queries against a MS SQL box
 when using a Linux server.  A little background info, I have had this
 working correctly for many months.  I am running Fedora Core 1, have
 compiled php 5.0.3 using the FreeTDS v.0.7 driver to access the MS SQL
 2000 DBMS, and like I said, it has been working with out problems for
 several months now.  I tried to update MySQL (which I also use locally
 on the web server for certain projects), which went fine as well,
 although after that every insert query I made against the MS SQL server
 returned a failed status EVEN THOUGH the inserts were ACTUALLY made.  I
 have seen posts to the PHP site with users of php v.4.x.x complaining
 about this problem, and so far no answers on what to do to fix the
 problem(s).  Any help would be greatly appreciated.
 

Have you checked the bug database to see if it has been entered as a
bug?  Most projects don't get anything fixed unless there is a bug
filed.

Bret

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



Re: [PHP] [HAB] str_replace

2005-02-22 Thread Bret Hughes
On Tue, 2005-02-22 at 09:59, OOzy Pal wrote:
 Dears
  
 I am trying replace anything between '{!' and '!}' i.e {!A!} and {!B!} 
 and {!ABC!} with XYZ. I tried the following but no help. Can anyone 
 help?
  
 $this-template=str_replace({!*!},XYZ,$this-template);
  
 Thank you
 
 

IIRC str_replace does not use any type of globbing.  You need to use one
of the function that uses regular expresions I prefer preg_replace
personally.  regexes can get complicated looking pretty quick but are an
incredibly powerful mechanism once you understand even the rudiments.  I
would place my self in that catagory.

try something like :

$this-template = preg_replace (/![^!]*!/,!XYZ!,$this-template);

untested but should be close.

what the /![^!]*!/ says is match any string that starts with a ! and is
followed by zero or more characters that are not ! followed by a ! the
replacement part of the function replaces it all with !XYZ!.

this will also catch the string !! and replace it with !XYZ! if this is
not what you want replace the * above with + (one or more)  exactly one
char between them leave the * off altogether.

HTH

Bret

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



Re: [PHP] Writing PNG Images to File from Command Line

2005-02-22 Thread Bret Hughes
On Tue, 2005-02-22 at 10:14, [EMAIL PROTECTED] wrote:
 Howdy,
 
 Because of some latency issues in the display of dynamically created PNG 
 images, I've been trying to separate the image-creation process from the 
 image-display process. Essentially, I'm trying to run a cron job that 
 writes a PNG image to file every 5 seconds. The php file pulls data from a 
 MySQL db and creates a color-coded map of a cancer treatment building. The 
 presence of normal levels of Neutrons would lead to the creation of a 
 green flag, above-normal levels yields a yellow flag, and high levels 
 yields a red flag. Another page will simply use a SRC tag to display the 
 image, and will refresh every 5-6 seconds to get the latest 
 readings/image.
 
 The concept worked extremely well when the image was output to the 
 browser, except for the fact that a latency caused the image in the 
 browser to flicker when it refreshed.
 
 So I've attempted the above, but without success, in that I can't get the 
 cron job to actually make the image file. I know that the file is being 
 processed because I can echo out a few words to the screen. And I know 
 that the php file can create an image file because it does so when I add 
 the file_name attribute to the imagecreate() function. 
 
 I've checked permissions on folders, etc, and have tried both the CLI and 
 SAPI versions of php, with and without available command line flags, but 
 no luck. And it's not the db query portion of the process because I've 
 commented out that portion of the code.
 
 Pretty much stumped and very open to thoughts/comments. 
 
 The Set Up: 
 RH 9.0 
 Apache 2.0.48
 PHP 4.3.4
 Mozilla 1.5
 (MySQL 4.0.18)
 

how are you trying to do this?  your comment that it can create the file
when you add the filename attribute to imagecreate leads me to believe
you are not using this feature.  Why not?

Also what is the error_reporting set to?

you might try error_reporting(E_ALL); at the top of your script to get
additional info.  

Are you checking the returncode from the imagecreate?

you might try posting the code and letting someone wiht more experience
than I take a look.

Bret

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



Re: [PHP] Fatal error: Maximum execution time

2005-02-21 Thread Bret Hughes
On Mon, 2005-02-21 at 06:52, Stanislav Kuhn wrote:
 Hi guys,
 
 I've got a processing script which takes long time to finish. The script
 includes several others and is ran from command line(by cron). I've sent
 phpinfo from inside of processing to my email, here is the important part
 max_execution_time = 1800 = 0
 max_input_time = 120 = 120
 memory_limit = 64M = 64M
 
 I'm setting 1800 inside a script and 0 exec time is by default... anyway I
 have tried to set it to whatever and wherever ;o) Script always terminates
 and that is strange not exactly at same time... it's aprox from 6 to 10
 minutes and not in same place (in any of included script). And error message
 always displays 30 seconds... I have tried to grep a source for ini_set as
 well, nothing important anywhere in the code.
 
 PHP Fatal error:  Maximum execution time of 30 seconds exceeded in .php
 on line 130
 
 Has somebody seen something like this or has an idea what's going on there?
 
 PHP Version = 4.3.10-2
 Running with apache on Linux..
 

If this is running inside cron, can we assume that it is  run from a
command line - php myscript.php and that the webserver is not in use in
anyway?  I know that Apache has time constraints as well is the reason I
ask.

It looks like your timeouts are being set correctly and I have no idea
what might cause this other than the apache stuff.

have you tried running set_time_linit(60) occasionally in the main loop
to reset the counter?

just a thought.

Bret

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



Re: [PHP] My FIRST php atempt

2005-02-18 Thread Bret Hughes
On Fri, 2005-02-18 at 01:47, David Freedman wrote:
 I am trying my FIRST php file with an attempt to connect
 to my mySql server.
 
 ?php
 // Connecting, selecting database
 $link = mysql_connect('localhost', 'host', 'my_passqword')
or die('Could not connect: ' . mysql_error());
 echo 'Connected successfully';
 mysql_select_db('eatc7402') or die('Could not select database');
 
 // Performing SQL query
 $query = 'SELECT * FROM my_table';
 $result = mysql_query($query) or die('Query failed: ' . mysql_error());
 ==
 more code to print results.
 ..
 ..
 
 // Free resultset
 mysql_free_result($result);
 
 // Closing connection
 mysql_close($link);
 ?
 
 The problem is it won't connect to the database. The server IS running. The
 host, username,
 and password are the exact same thing I use to connect the mySqlAdmin tool
 to the database.
 Doesn't seem like this should be that difficult. How can I discover why it
 doesn't
 seem to connect.
 

what is in the mysql log?  chances are it is a db permission issue since
you are not running as the same user as the server is.

There was a thread like this earlier this week maybe even today?

look in the archives of this list.

Bret

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



Re: [PHP] fgetcsv() excel data missing

2005-02-18 Thread Bret Hughes
On Fri, 2005-02-18 at 09:12, M. Sokolewicz wrote:
 Binoy AV wrote:
 
   Thanks Jay.

Could anybody please tell me how to read the data from an excel
file ? It should work independent of the operating system. I don't want
the csv format. 


 excel files aren't independent of the OS, csv files are. Excel files 
 need to be parsed, because they contain heaps of formatting data. If 
 you're using php on a windows OS, then you can use COM or .NET to read 
 it in. On other systems however, you'll likely run into problems pretty 
 quickly, and will most probably need to write your own parser routine
  

Not to mention the different versions of excel that alter the format.

Bret

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



Re: [PHP] Help with SQL statement

2005-02-18 Thread Bret Hughes
On Thu, 2005-02-17 at 23:21, Jacques wrote:
 How can I determine which users have signed in and are still on-line during 
 the first minute after they have signed in? My sql statement currently 
 reads:
 
 SELECT * FROM tblusers WHERE usignedin = yes AND utimesignedin = (time() - 
 60)
 
 Hoe does one indicate seconds in a SQL statement? Can I use the time() 
 function or should I use the now() function rather?
 
 Thanks
 Jacques 

I almost do not know where to begin.

What database are you using?  The functions you need to be looking at
are going to be executed by the dbms not php.  Look in the dbms docs for
the time functions available.  Are you really interested in users who
logged in exactly 60 seconds ago ( you are using = afterall )?

if course this also depends on what type of data is stored in
utimesignedin if it is a timestamp with the resolution in seconds then
you should be good to go with the
whatever_database_function_returns_the_current_timestamp() - 60 deal.

Bret

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



Re: [PHP] mysql query

2005-02-17 Thread Bret Hughes
On Thu, 2005-02-17 at 18:24, Sebastian wrote:
 Hello,
 im working on an article system and looking to avoid running three queries.
 example, i have this query:
 
 SELECT id,title FROM articles WHERE id=$_GET[id]
 
 now say $_GET[id] = 5
 
 I would like to get the previous id 4 and the next id 6 (if there is one)
 so i can do something like:
 

sure how about :

select id, title 
from articles 
where id = $_GET[id] - 1 
and id = $_GET[id] + 1
order by num;

should be valid sql but I have no experience with mysql

Bret

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



Re: [PHP] mysql query

2005-02-17 Thread Bret Hughes
On Thu, 2005-02-17 at 22:02, Jason Petersen wrote:
 On 17 Feb 2005 19:28:18 -0600, Bret Hughes [EMAIL PROTECTED] wrote:
  On Thu, 2005-02-17 at 18:24, Sebastian wrote:
   Hello,
   im working on an article system and looking to avoid running three 
   queries.
   example, i have this query:
  
   SELECT id,title FROM articles WHERE id=$_GET[id]
  
   now say $_GET[id] = 5
  
   I would like to get the previous id 4 and the next id 6 (if there is one)
   so i can do something like:
 
 I would do something like:
 
 $theId = $_GET['id'];
 $ids = $theId-1 . , . $theId  , . $theId+1;
 $query = SELECT id, title FROM articles WHERE id IN ($ids);
 

That is a good approach I wonder if there is any difference in
performance?  ...

To answer my own question before I even post it:

A quick test or two shows that on a postgres table with about 45K rows
both ways used an index scan.  on a table with about 35 rows the  
always used a index scan but the in() used a seq scan.  I am sure mysql
would use the index both ways as well but I do not know.  Seems like the
smaller the number of elements used the better off you are with the in()
deal since each element in the index had to be compared to each of the
numbers where as with the   approach only two comparisions have to be
made regardless of the range.

This is not to say my approach was better I am just thinking out loud.

Bret

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



Re: [PHP] How do I add PHP code into a DB field

2005-02-17 Thread Bret Hughes
On Fri, 2005-02-18 at 00:45, Tim Burgan wrote:
 Hello,
 
 
 On my page, all my content is updated via a textarea online.
 
 If I include PHP code embeded with my HTML in the textarea, the database 
 converts it to plain text, instead of code that can be used. It doesn't 
 convert  to lt; though, it's still in the database as , just when 
 it's read out again.. it don't work!
 
 I want to be able to call a random image script in PHP from the content 
 that's stored in the DB.
 
 How do I do this?
 

How are you calling the page that retrieves the code?  Does the file
name end in php?  I suspect that simply echoing code to the browser
won't work because it's a string.  Are you using eval?

Bret 

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



Re: [PHP] [php] -help me

2005-02-17 Thread Bret Hughes
On Thu, 2005-02-17 at 23:50, K Karthik wrote:
 i have got string as /home/karthik/welcome.php/view.php
 i just need view.php how shall i remove rest of the string.
 please do help me.i am new to php.
 -thanks,
 karthik
 

Lets see if you can learn to fish.

Since you are new you should learn that one of the greatest resources in
all of opensource software is the php.net documentation.

try entering php.net/searchterm in the browser
ie: php.net/filename

hmm looks like there is a function called basename you might want to
look at.

The manual has all functions arranged by functional area ( eg
filesystem)

I can't tell you enough what a powerful resource this was to me a a
beginning php programmer and remains so to this day.

Bret

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



Re: [PHP] Re: isset

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
 * Bret Hughes [EMAIL PROTECTED]:
  I just wish there was a use strict; sort of deal so I would not have to
  hunt down logic errors due to mistyping a variable name.
 
 There is, in PHP5: E_STRICT. From the manual
 (http://php.net/manual/en/ref.errorfunc.php#errorfunc.constants):
 
 Run-time notices. Enable to have PHP suggest changes to your 
 code which will ensure the best interoperability and forward
 compatibility of your code. 
 

Hmm.  Good tip thanks.  chalk up another reason to upgrade to 5. 
getting close to haveing enough reasons to do so :)

E_STRICT is closer but still does not warn of assigning to undeclared
variables in or out of a class. bummer.

Bret

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



Re: [PHP] Re: isset

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 10:34, Richard Lynch wrote:
 Bret Hughes wrote:
  On Wed, 2005-02-16 at 07:54, Matthew Weier O'Phinney wrote:
  * Bret Hughes [EMAIL PROTECTED]:
   I just wish there was a use strict; sort of deal so I would not have
  to
   hunt down logic errors due to mistyping a variable name.

 You SHOULD be using E_NOTICE to get warned when you *USE* an unassigned
 variable/propery/element and PHP is forced to initialize it.
 
 That will catch a bunch of your variable name typos -- And also will often
 let you know you typed it wrong in the place where you did the assignment.
 EG:


this is exactly what I was looking for Richard thanks.

Bret

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



Re: [PHP] Re: Minimalist permissions

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 10:17, Jason Wong wrote:
 On Wednesday 16 February 2005 23:30, Ugo Bellavance wrote:
 
  If the needed permissions for standard PHP files and directories
  are 'r' on files and 'r-x' on directories, how can I set my umask so
  that files and directories are always created as such?  I looked up
  'man umask' and it seems to treat files and directories the same way. 
  Maybe that is impossible, but I logged in via FTP to a server of a web
  hosting company, and it implements just this: creates directories as
  rwxr-xr-x and files as rw-r--r--.
 
 chmod() after creating any directory or file.
 

This is a very good idea.  There was a bug in php at one time that
allowed a umask setting to be held in the apache process that it was run
in so you really could not rely on a umask being set to any specific
value.

It was reported via redhat:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=121454

Bret

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



Re: [PHP] Password Protection

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 21:31, Kevin Javia wrote:
 I am experimenting on my site and I want to make it password protected like
 www.realsolution.com.
 
 If any one enters correct user name and password, only then they will be
 able to enter into my site.
 
 How can I do that in PHP?
 
 Any ideas? Thanks a ton in advance.


Chances are this is not a php thing at all but uses the webserver's
authentication infrastructure.  It depends on the server being used. 
The apache manual has a very good write up on authentication options
available:

See if this gets you started:

http://httpd.apache.org/docs-2.0/howto/auth.html


Bret

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



Re: [PHP] Getting floats from 8 byte IEEE binary representations

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 18:36, Ian Johnson wrote:
 I am trying to write a function which will read a string of bytes from a
 binary file and convert 8 byte sequences to Float type data.  I've been
 through the manual and can find nothing but think I must be missing
 something.  It can't be that hard.  Can someone help me out.
 
 

what have you tried?  won't fread() work?

http://us4.php.net/manual/en/function.fread.php

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



Re: [PHP] XHTML 1.1 + php sessions = :(

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 19:07, b1nary Developement Team wrote:
 Hi there guys... First time caller here ;).
 
 I'm currently developing a content management system.  One of it's 
 features is that it's going to be completely standards compliant (XHTML 
 1.1).
 
 I'm having some troubles however, and they come in the form of 
 sessions.  When I use session_start(), it throws the PHPSESSID into the 
 URL of all of my links and form actions and what not.  This is a problem 
 because in my forms it throws in a hidden input, which doesn't validate 
 right, plus they don't use amp; insteand of just .  Is there any way 
 to stop a session from being passed through the URL?
 

Sure enable session.use_only_cookies in php.cfg and cookies will be
used. nothing in the page sent to the browser at all as far as I know.

http://us4.php.net/session

Bret
 -- 
 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: Why is my class throwing this error?

2005-02-16 Thread Bret Hughes
On Wed, 2005-02-16 at 23:11, Dan Phiffer wrote:
 NathanielGuy#21 wrote:
  Error thrown
  --
  Parse error: parse error, unexpected T_STRING in
  /home/blacknut/public_html/picserv/includes/gallery.class on line 52
  --
 
 For what it's worth, I'm able to execute the code without parse errors 
 (v5.0.3). A long shot, but could there be another file called 
 gallery.class that you've mistaken for this one? (I've done that a 
 couple times.)
 

what about stray no native linefeeds or other non printable chars?

delete the line and retype it.

Bret

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



Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 14:00, Richard Lynch wrote:
 Matt M. wrote:
  I have a database that contains encrypted data using Mysql function
  ENCODE(). Certain users will be allowed to view this data and I will
  allow
  them to download a CSV file contain the decrypted data using the Mysql
  DECODE() function. However I don't want this file to be left on the
  server,
  is there a way to ensure that the file is deleted immediately after it
  has
  been downloaded?
 
  http://us4.php.net/unlink
 
 PS If the data is REALLY sensitive, you may want to look into command line
 tools to actually ERASE the data instead of just doing unlink.
 
 'unlink' only nukes the directory information to find the file.  The file
 contents still exist, intact, and there are tools to mine un-linked files
 to find content.
 
 Hard Drive forensics experts can even manage to retrieve over-written
 files based on some very very very expensive/hard analysis of the magentic
 fields -- Sort of like reading through scratched out stuff on paper by
 holding it up to the light, only a lot more technical and a lot more
 expensive...  It's unlikely you need to worry about *THAT* though, as I
 understand it...
 

As Richard pointed out the unlink will leave the data on the disk but
simply remove the directory pointers to it.  If physical security of the
box is an issue then overwriting the file with random data and then
unlinking it might be a decent solution.  If a file is opened for
writing I suspect it depends on the operating system as to whether the
same disk blocks are used so overwriting a file might not actually over
write the data on the disk.  It should, however at least change the
directory entry enough that someone with access to the box will not be
able to use a simple undelete utility to retrieve the file.

Bret

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



Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 17:00, dan wrote:
 Matt M. wrote:
 Any feedback will be appreciated.
  
  
  
  why reinvent the wheel?
  
  take a look at:
  http://pear.php.net/package/Html_quickform
  
 
 To the people who want to truly understand how the system works, the 
 wheel, as it stands, is wothless :)
 
 I know I can use a drop-in solution, and I might consider it in the 
 future.  However, if I understood in more detail the entire process, I 
 would be able to troubleshoot and add advanced features to the wheel.
 
 That's how I look at it, anyway.
 

I like the attitude from a learning standpoint but since you asked for
feedback you could have at least acknowledged the guys effort in offerin
one solution.

This thread is very similar to another one today.  and the answer is the
same. use some sort of conditional construct to determine how you are
being requested and process accordingly.

I usually set a hidden variable that can be checked to let me know what
to do.

if (isset($_POST[myvar]  $_POST[myvar] = expected value){
 #   perform second phase form
}
else {

#do  form phase one stuff.

print input type=hidden name=myvar value='expected value'\n;

}

one of many ways to do it.  I have to say I have done quite a bit of
this sort of thing and it gets really confusing to maintain if there is
a lot of logic involved.

One one hand it is nice to know you only have to change one file if a
change is needed ( especially if there are changes to the parameters
being passed from the entry side to the processing side.  I have yet to
feel strongly one way or the other whether it is better to use a single
file or multiples.  

Bret

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



Re: [PHP] issue with accents and mysql

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 17:40, mario wrote:
 Hi,
 
 thanks, but that seems to be ok:
 SQL result
 Host: 127.0.0.1
 Database : 
 Generation Time: Feb 15, 2005 at 11:36 PM
 Generated by: phpMyAdmin 2.5.7-pl1 / MySQL 3.23.58
 SQL-query: SHOW VARIABLES LIKE 'character_set%'; 
 Rows: 2 
 
Variable_name 
Value 
 character_set
 latin1
 character_sets
 latin1 big5 cp1251 cp1257 croat
 czech danish dec8 ...
 
 any further idea?
 thanks
 mario
 
 ps of course, I could 
 On Tue, 2005-02-15 at 21:42, Guillermo Rauch wrote:
  Try
  SHOW VARIABLES LIKE 'character_set%'
  
  and verify your character set is latin1.
  
  If not, see http://dev.mysql.com/doc/mysql/en/charset-database.html
  
  On Tue, 15 Feb 2005 22:04:30 +, mario [EMAIL PROTECTED] wrote:
   Hello,
   
   please help me on the following issue.
   please reply to [EMAIL PROTECTED] too.
   (I asked for help on the php-db ml, but nobody replied)
   
   I have hacked the following function:
   function accents($text) {
 global $export;
 $search  = array ( 'à', 'è', 'ì', 'ò' , 'ù');
 $replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
 $export= str_replace($search, $replace, $text);
 return $export;
   }
   
   It works fine, as long as I feed it with a string:
   accents('à') -- \`{a}
   
   The issue is when I get 'à' from a mysql table.
   I.e., for some record of a mysql table Table, let à the value of the
   field Field, and say
   $result =  mysql_fetch_array($answer, MYSQL_BOTH),
   where $answer= mysql_query(SELECT * FROM Table).
   
   Now accents($result['Field']) returns à (instead of \`{a}).
   Why? I have no idea.
   
   Any hint is welcome.
   Thanks a lot


I have no idea what might be the problem but I would probably start by
seeing what the difference is at the ascii level.

preg_split the strings and run ord on each one

foreach ( preg_split(//,this is a string) as $char ) {
echo The ascii value for $char is . ord($char) . \n;
}

post the results from both sources and lets see what can be found.

Bret

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



Re: [PHP] Re: isset

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 16:22, M. Sokolewicz wrote:

  Chris.
 that's a different issue.
 There are always at least 2 things you should do with your (expected) input:
 1 - check if it *exists* (isset)
 2 - check the validity (input-validation)
 
 for step #2 empty is very commonly used, and also a very useful 
 function. However, you should never do #2 without #1, since that again 
 raises issues (of security, problems, unexpected input, etc)
 
 Also note that empty($non_existent_var) will always throw an E_NOTICE 
 error when the variable in question is not set. isset() is the only 
 function/language-construct that can check for the existence of 
 variables without throwing an E_NOTICE.


This is not true and explicitly states so in the doc.  I had to reread
it to remember why I stopped using it.  empty will return true if the
value is one of several things , 0, 0 to name a few.  Since I do not
consider these empty I stick with isset and then test for a valid value
depending on the circumstance.

Personally, I think people piss and moan too much about what I consider
proper coding practices.  Input validation is to important to skimp on.
Again it is my opinion.

I have been revisiting some php code that I wrote a couple of years ago
and have been pleasantly surprised at the job I did on input validation.

A similar complaint occurs when installing a new version of or moving
code to another box where register_globals is not on.  I pissed and
moaned and wailed for about 10 minutes until I thought about it and can
now see the value in not having unknown variables pollute the namespace.

Of course, since most of my code was already validating the variables, a
few :s/\$\(var\)/\$_GET[\1]/ iterations and I was good to go.  Yes it
took some time but I feel better having done it.

I just wish there was a use strict; sort of deal so I would not have to
hunt down logic errors due to mistyping a variable name.

Bret

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



RE: [PHP] Regex help

2005-01-29 Thread Bret Hughes
On Sat, 2005-01-29 at 08:58, Michael Sims wrote:
 [EMAIL PROTECTED] wrote:
  OK, this is off-topic like every other regex help post, but I know
  some of you enjoy these puzzles :)
 
 This isn't an exam question, is it? ;)
 
  I need a validation regex that will pass a string. The string can
  be no longer than some maximum length, and it can contain any
  characters except two consecutive ampersands () anywhere in the
  string.
 
  I'm stumped - ideas?
 
 Yup, use this perl regex:
 
 /^(?:()(?!)|[^]){1,5}$/
 
 Where 5 above is the maximum length of the string.  You can change this to
 any positive value and the regex will still work.  Basically it says look
 for 1 to 5 single characters where each either isn't an ampersand, or IS an
 ampersand but isn't immediately followed by an ampersand.  The (?!) is a
 zero-width negative look-ahead assertion which is like other assertions such
 as \b that don't eat up the portions of the string that they match.


Great explanation.  Thanks from one who has not had an exam for over ten
years.

Bret

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



Re: [PHP] Class declaration, constants and array

2005-01-28 Thread Bret Hughes
On Fri, 2005-01-28 at 14:50, Marek wrote:
 php5 class {
 
 const _SOMETHING_ = 'test';
 
 private $abc=_SOMETHING_;  // fails, well actually anything fails
 similar to this.
 var $test=$test2;// also fails
 
 So since I can not use dynamic var assignment within the class declaration,
 what are some of the easy solutions to this ? without making anything global
 to the script ?
 
 Thanks

I believe you will have to establish stuff like this in the
constructor.  jsut create a function the same name as the class and it
will be run on object instantiation.  I had to do the a couple of years
ago for an array.

Check out the manual it used to explain this.
Bret

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



Re: [PHP] Re: [NEWBIE GUIDE] For the benefit of new members

2005-01-25 Thread Bret Hughes
On Tue, 2005-01-25 at 11:15, Rory Browne wrote:

 
 P.S. An addition to the above, a reminder that you have to CC to
 php-general@lists.php.net, for responses to be sent to the list might
 be a good idea. I've lost count of how many times I've forgotten to do
 this, including this time(sorry Jay), and ended up sending it only to
 the original sender, instead of to the list, resulting in the original
 sender recieving the thing twice.
 

I did this a few times when subscribed so I added this to my procmail.rc
( actually to a file lists.rc that I keep all my list processing stuff
in.

:0 fhw
* [EMAIL PROTECTED]
| formail -i Reply-To: php-general@lists.php.net

Now I just hit reply.  and I do not feel stupid two days later when I
wonder why my reply never made it :)

Another favorite if someone gets too obnoxious:

:0
* ^FROM: [EMAIL PROTECTED]
/dev/null


Bret

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



Re: [PHP] Log-in script help

2005-01-25 Thread Bret Hughes
On Tue, 2005-01-25 at 16:45, [EMAIL PROTECTED] wrote:
 Hey,
I need a particular type log in script. I'm not sure how to do it or 
 where I could find a tutorial that would help me, so I'll describe what I 
 need 
 and then maybe someone could tell me what kind of script I need (sessions or 
 whatever) and where I could get the script/learn how to make it.
I need a pretty basic log in script. Something that people log in to, 
 and the page and all linked/related pages cannot be accessed unless the 
 person 
 has logged in. 
So what do I need for this? Cookies, sessions both? And where can I 
 learn how?
 
 -Andrew

I use the pear auth package and like it alot.  I know I did some
modification for our purposes but I suspect it works out of the box.

All you do is include auth.php on all pages you want to protect and it
will direct you to a login page if you have not logged in.  Pretty cool
stuff.

http://pear.php.net/package/Auth
HTH

Bret

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



Re: [PHP] Understanding intval() and types conversion

2005-01-25 Thread Bret Hughes
On Tue, 2005-01-25 at 17:29, Bruce Douglas wrote:
 so...
 
 you're saying that 7.9 (repeating) is equal to 8.0
 
 i say prove it..  as i recall the numbers might be for all practical purposes 
 the same, they are in fact vastly different...
 
 so, prove your assertion...
 
 -bruce
 
Check out this one:

http://mathforum.org/dr.math/faq/faq.0..html

Bret

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



Re: [PHP] Help with file not writing

2005-01-25 Thread Bret Hughes
On Tue, 2005-01-25 at 07:53, Joey wrote:
 I'm not too good with classes, in the below class I can get the hit counter
 to write to the hit counter file, but I can't get it to write the log file,
 I know security is done correctly on the file because it's the same as the
 counter log file, but I can't figure out why the other file isn't being
 written to.
 Also while the IP address works within the code prior to calling the class
  
  function writeLog()
  {
   $ip_address=$REMOTE_ADDR;
   $date_stamp=date(F j, Y, g:i a);
$log_entry=$date_stamp .   :   . $ip_address . \n ;
echo TEST-  . $log_entry ;
   $log = fopen($this-log_file,w+);
   fputs($log,$this-$log_entry );
   fclose($log);
  

you set $log_entry but write $this-log_entry which does not exist.

try fputs($log,$log_entry );

HTH

Bret

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



Re: [PHP] String to Date and Date to String Functions?

2005-01-24 Thread Bret Hughes
On Mon, 2005-01-24 at 11:03, Ben Edwards wrote:
 On Mon, 24 Jan 2005 10:38:03 -0600, Jay Blanchard
 [EMAIL PROTECTED] wrote:
  [snip]
  
  String to Date Function
  
  return date stringToDate( str Date, str Format )
  e.g. $todayDt = stringToDate( '01/01/2003','DD/MM/' );
  
  Date to String Function
  
  return str dateToString( date Date, str Format )
  e.g. $todayStr = dateToString ( $todayDt,'DD/MM/' );
  
  Anyone know of any functions that do this or have pointers as to how
  it can be done.
  [/snip]
  
  You've looked at http://www.php.net/date ?
  
 Yes.  It douse the dateToString bit but how do I do the reverse.  I
 can use it to convert a timestamp to a string but how do I convert a
 string to a timestamp.
 
 I must say i've used a few languages in my time and the PHP data/time
 functions are a mess.  Generaly when you find a function to do
 something to a data item there is an obvious way of reversing this
 (i.e. it has a simeler name).  This douse not seem to be the case with
 PHP;(


I have never come across something that I could not achieve using a
combination of mktime, date, time, and strtotime.  I think mktime is the
piece you are missing.  I have been irritated by date parsing in the
past but If it works ...  

HTH
Bret

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



RE: [PHP] Date ranges

2005-01-24 Thread Bret Hughes
On Mon, 2005-01-24 at 14:07, Mikey wrote:
 
 *PLEASE NOTE*
 I know that if I spent time on it, I would be able to do it, but I have
 A very close deadline and if anyone else has been through this I would
 *really* appreciate the help...
 
 Are you using MySQL? If so you can start with the DATE_ADD and DATE_SUB
 functions. http://www.mysql.com/date Then RTFM http://www.php.net/date,
 spacifically http://www.php.net/mktime. With a combination of the two
 you can do all sorts of things.
 
 So you haven't been through this, and didn't bother to read what I said?
 Thanks!
 

I have done a fair bit of date parsing/ processing and if you had not
been so rude to this guy I would have helped just because it is a neat
exercise.  I may do it anyway.  if I do I will post it.  

And no, I have not done this exact thing so I guess that disqualifies me
from making suggestions that might be helpful as well.

Bummer.

Bret

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



Re: [PHP] regular expression help

2005-01-21 Thread Bret Hughes
On Fri, 2005-01-21 at 10:12, Jason wrote:
 Simple functions to check  fix if necessary invalid formating of a MAC 
 address... I seem to be having problems with the global variable $mac 
 not being returned from the fix_mac() function.  Any help is appreciated.
 
 ?php
 /*
   * ex. 00:AA:11:BB:22:CC
   */
 function chk_mac( $mac ) {
   if( eregi( 
 ^[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}\:[0-9A-Fa-f]{2}$,
  
 $mac ) ) {
return 0;
   } else {
return 1;
   }
 }
 
 /*
   * check validity of MAC  do replacements if necessary
   */
 function fix_mac( $mac ) {
   global $mac;
   /* strip the dash  replace with a colon */
   if( eregi( 
 ^[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}\-[0-9A-Fa-f]{2}$,
  
 $mac ) ) {
$mac = preg_replace( /\-/, :, $mac );
return $mac;
   }
   /* add a colon for every two characters */
   if( eregi( ^[0-9A-Fa-f]{12}$, $mac ) ) {
/* split up the MAC and assign new var names */
@list( $mac1, $mac2, $mac3, $mac4, $mac5, $mac6 ) = @str_split( $mac, 
 2 );
/* put it back together with the required colons */
$mac = $mac1 . : . $mac2 . : . $mac3 . : . $mac4 . : . $mac5 
 . : . $mac6;
return $mac;
   }
 }
 
 // do our checks to make sure we are using these damn things right
 $mac1 = 00aa11bb22cc;
 $mac2 = 00-aa-11-bb-22-cc;
 $mac3 = 00:aa:11:bb:22:cc;
 
 // make sure it is global
 global $mac;
 

if you want to use globals you need to use the global in the function
not the main body.

afaict you don't need globals at all you pass mac1 to each function and
use it as $mac in the function (exactly what you want to do) and return
local $mac to $mac in the main body.  perfectly legal.  If you set mac
to global in the function I suspect that you end up not using  the local
mac and are testing an empty var in the first pass of fix_mac.

remove the global statements and you are well on your way.

Bret

 // if mac submitted is invalid check  fix if necessary
 if( chk_mac( $mac1 ) != 0 ) {
   $mac = fix_mac( $mac1 ); echo $mac1 .  converted to  . $mac . br;
 }
 if( chk_mac( $mac2 ) != 0 ) {
   $mac = fix_mac( $mac2 ); echo $mac2 .  converted to  . $mac . br;
 }
 if( chk_mac( $mac3 ) != 0 ) {
   $mac = fix_mac( $mac3 ); echo $mac3 .  converted to  . $mac . br;
 }
 
 ?
 -- 
 Jason Gerfen
 
 And remember... If the ladies
   don't find you handsome, they
   should at least find you handy...
   ~The Red Green show
 
 -- 
 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] nl2br misprint

2005-01-21 Thread Bret Hughes
On Fri, 2005-01-21 at 17:52, Jason Wong wrote:
 On Saturday 22 January 2005 07:36, Scott DeMers wrote:
  From the function page on php.net (
  http://us4.php.net/manual/en/function.nl2br.php ):
 
  Starting with PHP 4.0.5, nl2br() is now XHTML compliant. All versions
  before 4.0.5 will return string with 'br' inserted before newlines
  instead of 'br /'.
 
  Is this a misprint, ot does the revised function actually do this?
  According to the w3c, br /' is compliant, while br is not; see
  http://www.w3.org/TR/xhtml1/.
 
 Versions before 4.0.5 returns br
 Versions after 4.0.5 returns br /
 

Logic error.  what about the case of version = 4.0.5.  :)

No need to reply.  I get it but could not resist the dig.

Bret

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



Re: [PHP] Seemingly weird regex problem

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 11:59, Richard Lynch wrote:
 Tim Boring wrote:
  Hello!  I'm having an odd regex problem.  Here's a summary of what I'm
  trying to accomplish:
 
  switch ($line)
  {
  case ($total_counter = 5):
  break;
 case preg_match(/^\W+/, $line):
 
 While it would be Really Nifty (tm) if PHP worked this way, as far as I
 know, you can only have a CONSTANT in your case.
 
 switch($char){
   case 'X': echo It was an X; break;
 }
 
 You can't just put arbitrary expressions there...
 
 Feel free to correct me if the Manual sez different.
 

yeah,  the discussion for switch illustrates the use of functions in
case statements.  I have never done it and I wonder if there is a
difference in what preg_replace returns vs what is true but if that
was an issue, why doesn't the if catch it.  wish I had time to play.

Bret

http://www/php.net/switch

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



Re: [PHP] Seemingly weird regex problem

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 12:43, Jason Wong wrote:
 On Friday 21 January 2005 02:16, Tim Boring wrote:
 
  It's perfectly legit to use expressions.  Now perhaps there is something
  wrong with the regex I'm trying to use, but using a regex in and of
  itself is legal.
  http://www.php.net/manual/en/control-structures.switch.php
 
 Yes, but comparing those expressions to:
 
   switch ($line)
 
 where $line is a string, doesn't make sense. See my other post.
 

Chaching ( sound of light bulb turning on)  I see that in the example in
the manual it needs to be compared to true ( a boolean value)


switch (true)

rather than switch ($line)

What is not apparent to me is why the first case matches if the preg
fails.  Wouldn't line evaluate to true in a boolean context?

Bret

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



Re: [PHP] Seemingly weird regex problem

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 13:21, Tim Boring wrote:
 On Thu, 2005-01-20 at 13:41, Jason Wong wrote:
  On Friday 21 January 2005 01:52, Tim Boring wrote:
  
  Well the biggest problem in your code right now is your incomprehensible 
  (to 
  me anyway) use of the switch construct. For a start I've no idea why you're 
  using ...
  
   switch ($line)
  
  ... when your tests do not involve $line
  
   case ($total_counter = 5):
 
 I see your point, but the other tests do involve $line. This one that
 you reference I'm using for a special need--basically so I leave in
 the initial column headings from the report, because they would match
 several of the tests that would discard those lines.
 
  
  I suspect what you want to be doing is something like this:
  
switch (TRUE) {
  case ANY_EXPRESSION_THAT_EVALUATES_TO_TRUE:
  ...
}
 
 Thanks for the suggestion, but I'm not sure that does what I'm looking
 for.  I really think the problem is with my regex, not necessarily with
 the way I've constructed my switch statement.
 
 I say this because I have since changed the first word in each line from
 something like AKRN to a numeric value, and everything works just as I
 would expect it to.  So it seems as if the ^ might be negating the \W+
 part of the regex.  Although that shouldn't be happening because ^
 only acts as a negation when it's used inside brackets, at least
 according the documentation.
 
 Again, thanks for the suggestion!
 

I think I see a possible explanation for the behavior.  preg_replace
does not return a true or false value it returns the string passed as
the subject with any matched replacements done.  Hmm the manual says it
better:

If matches are found, the new subject will be returned, otherwise
subject will be returned unchanged. 

What I think is happening is that the first match is not finding
anything to replace and returning $line unchanged.  the comparison is
true since you are comparing to $line in the switch statement.

I will p[lay with it a bit since it pisses me off when I can't figure
out what is happening.

Bret

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



Re: [PHP] Seemingly weird regex problem

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 14:06, Bret Hughes wrote:

 
 I think I see a possible explanation for the behavior.  preg_replace
 does not return a true or false value it returns the string passed as
 the subject with any matched replacements done.  Hmm the manual says it
 better:
 
 If matches are found, the new subject will be returned, otherwise
 subject will be returned unchanged. 
 
 What I think is happening is that the first match is not finding
 anything to replace and returning $line unchanged.  the comparison is
 true since you are comparing to $line in the switch statement.
 
 I will p[lay with it a bit since it pisses me off when I can't figure
 out what is happening.


Well it sure is easier to debug when you are looking at the right
frigging function.  I think the logic error is still similar you are
comparing two values that are not meant to be compared.  

Since if an integer is involved in a comparison, and it is here since
preg_match returns an integer, the string will be converted to an
integer.  IIRC string to integer conversion results in 0 if the string
does not look like number.

Since the match is not found, preg_match returns 0 compared to the
string contained in $line will be converted to 0 ( if it begins with a
letter its integer represetation is 0) the case mathes and the block
executes.

That and the first case is totally misued.  you are trying to use the
switch as a series of ifs and the analogy only holds true if the
comparison is the same.

I would not hesitate to rewrite this and encourage you to do so because
even if you get it to work as intended it is not clear what you are
trying to do.

Bret

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



Re: [PHP] Providing a means for the surfer to send a file

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 14:03, Todd Cary wrote:
 I am looking for some sample code on setting up a page that provides a 
 means for the surfer to send a file to the server.

Hmm lets see:

http://www.google.com/search?hl=enlr=q=html+file+upload+phpbtnG=Search

First hit looks promising.

Bret

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



Re: [PHP] Upgrading PHP 4.2.2 on Red Hat 9

2005-01-20 Thread Bret Hughes
On Thu, 2005-01-20 at 18:12, James Butler wrote:
 Greetings,
 
 Has anyone successfully upgraded a PHP 4.2.2 installation on a
 Red Hat 9 machine to a more secure version?
 
 I just want any more-secure version of PHP than 4.2.2, but it's looking
 like I'll have to use Fedora or Gentoo or Mandrake or something in order

snip
 Thanks in advance for ANY help at all.
 

Redhat used to do a pretty good job of backporting security issues and I
am assuming that fedoralegacy.org is still doing it.  There are php rpms
out there dated October so I it looks like to me they are trying to keep
up.

http://download.fedoralegacy.org/redhat/9/updates/i386/

you might take a look at the changelog to see if the fix you are worried
about is there.

Bret

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



Re: [PHP] debugging

2005-01-19 Thread Bret Hughes
On Wed, 2005-01-19 at 05:51, Marek Kilimajer wrote:
 Justin French wrote:
  On 19/01/2005, at 5:36 PM, William Stokes wrote:
  
  I would like to add some debugging/info code to my pages. In test
  environment of course. Any ideas how to do this? I mean for example to 
  print
  to a web page the line number when the script fails or something like 
  that.
  It's a pain on the **s to hunt typo's by just reading the source over and
  over again.
  
  
  William,
  
  I start by trying to programatically find out if I'm in a development or 
  production environment and setting a constant DEV to true or false.  For 
  me, I development things on my desktop Mac, so the server and client are 
  the same machine, and share the same IP address.  So my check for DEV is 
  if the client IP and server IP match.
  
  ? define('DEV',($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR'])); ?
 
 Interesting. So I just need to use the same hosting server as you do and 
 your scripts will tell me interesting facts ;)
 
 I use simple define('DEBUG', true'); in the main config file where also 
 database login info is stored.
 

for complicated stuff I will usually place if $(DEBUG N ){echo stuff}
lines in the code so I can easily print interesting stuff in various
parts of the script then if I hit a problem place a $DEBUG=1; or
whatever level I want at the top of the script;  This way I can turn it
off and on without making code changes other than setting $DEBUG = 0;
when moving to production.  This causes some additional work in
production but I suppose if I had that many ifs in there I could write a
script to remove the $DEBUG { } blocks from the code during the move to
production.

Since we are on the topic, does anyone have such an animal? If I write
one, would anyone be interested in it?

Bret

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



Re: [PHP] Need best way to determine if cronjob or external browser called my script

2005-01-19 Thread Bret Hughes
On Wed, 2005-01-19 at 07:47, Al wrote:
 I'm working on a script that can be initiated by a cronjob or from a browser.
 
 I want the script to act differently depending on which one called it.
 
 -- 

I do not know what the definitive answer is but there are a bunch of
environment differences.  Here is one taken from 

http://us2.php.net/features.commandline

[EMAIL PROTECTED] elevatetest]$ cat testbrowser.php
?php
if ($_SERVER['SERVER_PORT']) { echo SERVER MODE\n; } 
else { echo CLI MODE\n; } 
?


results from wget:

[EMAIL PROTECTED] elevatetest]$ wget -q --output-document=-
https://localhost/elevatetest/testbrowser.php 
SERVER MODE
[EMAIL PROTECTED] elevatetest]$ 

results from cli 

[EMAIL PROTECTED] elevatetest]$ php testbrowser.php 
Content-type: text/html
X-Powered-By: PHP/4.3.6

CLI MODE
[EMAIL PROTECTED] elevatetest]$ 

mozilla returns 

SERVER MODE

HTH

Bret

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



Re: Re: [PHP] Re: Delay at first use of OpenSSL functions

2005-01-18 Thread Bret Hughes
On Tue, 2005-01-18 at 11:45, Vladas Shukevichus wrote:
 18.01.2005 18:06:31
 Marek Kilimajer [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]
 
  M. Sokolewicz wrote:
   didn't you read what wez said? they're gathering entropy... you 
 *can't* 
   (and shouldn't want to) prevent that.
   
  
  Or get some good entropy source
 
 Can you explain this a bit? How can I do this?
 

Now you  getting back to the there are only six people in the world
that understand encryption deal :)

entropy in these terms ( as I understand it ) is a source of randomness
used by open ssl.  I believe /dev/random is the source for this on a
linux system.  various system events cause random characters to be added
to the entropy pool that is then  accessed via /dev/random.  I rna into
this a couple of years ago setting up a freeswan link that was taking
forever (hours) to generate the keys. Turns out that since I was on a
headless scsi system there was a severe lack of entropy.  At the time,
ide hard drive activity, mouse events and possibly keyboard activity
were the primary inputs into the pool.  If your system needs a lot of
randomness there are various random number generators available.  

Do some searching, cryptogeeks take thier randomness very seriously.  I
had no idea until I ran into this.  The coolest one I found was a
lavalamp array that had a camera pointed at it and the output was
massaged to generate the random data. Last I heard, even this was being
debated as to whether it was random enough.

this is important enough that Via puts a random number generator built
into the epia boards so appliances will have enough of an entropy pool
to quickly establish vpns.

Have fun learing about it.  I did.

Having said all this, you might try moving the server mouse around
immediatly before and during the transaction to see if its faster.


HTH

Bret

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



Re: [PHP] Re: Delay at first use of OpenSSL functions

2005-01-18 Thread Bret Hughes
On Tue, 2005-01-18 at 14:34, Marek Kilimajer wrote:
 Bret Hughes wrote:
  
  Having said all this, you might try moving the server mouse around
  immediatly before and during the transaction to see if its faster.
 
 Or hire a monkey :)

Hmm. depending on the current cost of Purina Monkey Chow, this might
yield a good cost per bit of random data.  But then there is the clean
up.  I wonder if you would have to give the monkey an account on the
box?

Bret

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



Re: [PHP] Re: Hidden Images.

2005-01-18 Thread Bret Hughes
On Tue, 2005-01-18 at 12:24, Rob Adams wrote:
 Ok - Let me restate some of this:
 
 I am creating these images in PHP.  I have a script right now that accepts 
 two images.  A main one, and the one that will be hidden.  These can be 
 either jpg, gif, or png.  It then outputs a png image like this:
 
 http://imagineinc.net/images/
 
 I really don't know much about graphics, and struggled quite a bit just 
 getting it to this point.  I've tried several techniques to 'dim' the hidden 
 image, or take the color out of it, but nothing has really produced what I'm 
 after.  I'm not even sure of the terminology, but does anyone know a way to 
 'dim' the image or to make it blend with another image?  I'm just doing this 
 for fun, because I thought the concept was really cool.  I don't have access 
 to my code right now, but can post it later today, if any else is 
 interested.

dim might refer to transparency or alpha level.  I don't know if
browsers do that but I suppose a div might have an alpha level you could
manipulate via javascript.

Bret

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



Re: [PHP] question about a cron job

2005-01-17 Thread Bret Hughes
On Mon, 2005-01-17 at 09:01, Erwin Kerk wrote:
 Al wrote:
  I've got a question about the following cronjob.
  
 
  #At 3:01 our time, run backups
  1 0 * * * /usr/local/bin/php 
  /www/r/rester/htdocs/auto_backup/back_em_up.php 
  /www/r/rester/htdocs/auto_backup/cron.log 21
 
  #At 3:02 clean up sessions folder
  2 0 * * * (find /www/r/rester/htdocs/sessions/ -name 'sess_*' -mtime 
  +1 -delete)
 
  #this is only for testing a new cronjob, every minute
  * * * * * /usr/local/bin/php 
  /www/r/rester/htdocs/phpList_cronjob/process_cronjob.php 
  /www/r/rester/htdocs/phpList_cronjob/cron.log 21
 
  
  The new one doesn't seem to want to run until after 3:01 or 3:02.  
  Shouldn't the sever just run it every minute?
  
  And, the every minute job doesn't add anything to its log file.
  
  Apache on a virtual host.  The 3:01 and 3:02 jobs have been running fine 
  for months.
  
  Thanks
  
 
 The CRON daemon only refreshes it's job list after a job in the current 
 list is completed. Therefore, the CRON daemon won't notice the 
 every-minute job until 3.01 pm.
 

I am not sure I read that correctly.  Are you saying that the job cannot
be running for the new crontab to be installed?  If so, I could see that
althought I have never experienced it.  

If you are saying that each job in the crontab must be run before the
new crontab is completed, then I believe you are in error.  I have often
changed crontab entries to test how a job will operate in the cron
environment and never experienced any delay on the acceptance of the new
job even though I have hourly and daily jobs there.

Bret

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



Re: [PHP] Finding first/last occurrence of a substring

2005-01-17 Thread Bret Hughes
On Mon, 2005-01-17 at 09:27, Vikram Vaswani wrote:
 Hi
 I have a string like this:
 
 Just when you begin to think the wagon of Vietnam-grounded movies is grinding 
 to a slow halt, you’re hit squarely in the face with another one. However, 
 while other movies depict the gory and glory of war and its effects, this 
 centres on the psychology of troopers before they're led to battle.
 
 I need to know the index position of every occurrence of the pattern the in 
 the string above, and replace it with something else. Specifically, I need 
 the position of the last, first and third occurrences of the.
  
 I'm totally lost as to how to do this. Could someone help me out?
  

do you want to replace them or just find the position in the string? 
There are functions for both  try looking at the manual for
preg_replace:

http://www.php.net/preg_replace

looks like 

$replacedstr = preg_replace('/the/','whatever',$origstr,3);

would replace the first three occurances of the with whatever in the
string contained in $origstr and place it in $replacedstr.

HTH
Bret

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



Re: [PHP] Re: PHP in MS-DOS

2005-01-17 Thread Bret Hughes
On Mon, 2005-01-17 at 09:45, Shawn McKenzie wrote:
 Thanks, but I'm not running Windows, I'm running just MS-DOS from a 
 bootable floppy.  Hence my question :-)
 
 PHP seems to actually be the php5ts.dll.  Would there be binaries for 
 MS-DOS or is there a way to get this working?
 

Must be a big floppy if you are going to put it all on there :)

Bret

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



Re: [PHP] Writing static file from dynamic PHP page

2005-01-17 Thread Bret Hughes
On Mon, 2005-01-17 at 21:16, Chris Bruce wrote:
 Hi,
 
 I am looking for a way to write to a file what the browser would see 
 (raw html) when viewing a dynamic PHP page. I have numerous include 
 files, MySQL db queries, loops etc. and I want to generate the static 
 result of that file and save it as an html page. I have toyed a little 
 with output buffering to no avail.
 
 Is there an easy way to do this?

Interesting requirement.  I suppose something other than view source 
from the browser or wget is needed?

Bret

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



Re: [PHP] cron job style php...

2005-01-16 Thread Bret Hughes
On Sun, 2005-01-16 at 17:00, Russell P Jones wrote:
 I have written a simple script that when a date in an array matches todays
 date, it sends an email (notifies me when bills are due). Any ideas on how
 to make this run once a day? Can you do a cron job on a PHP prog?
 
 Russ Jones


Never tried it but on linux (RHL or Fedora) I would add a file to
/etc/cron.daily with something like this in it

/usr/bin/php /usr/local/bin/myjob.php

where myjob.php  is the php script.  if it runs from the command link
now it should work.  This will run as root of course and if you wnated
it to be run as someone else you could probably add the line:

0 2 * * * username /usr/bin/php /usr/local/bin/myjob.php

to /etc/crontab  or the users crontab without the username field.

hth

Bret

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



Re: [PHP] Executing command in Linux

2005-01-15 Thread Bret Hughes
On Sat, 2005-01-15 at 11:57, Rosen wrote:
 Hi,
 I have this problem:
 Linux Red Hat 7.3 server and PHP 4.3.8  MySQL 4. When I Try to execute
 linux command - nothing happens and in Apache logs I see Access denied.
 This is about permissions in executing this command.
 
 My question is can I execute a linux command via PHP ( this is command
 allowed only for root user ) ?
 
 P.S. I own this server - i.e. I have user  pass for root.


I use sudo for these situations.  use visudo to establish that the user
that owns the apache process ( I can't remember if RHL 7.3 was nobody or
if the had switched to apache by then ).

THen you can use exec(sudo yourCommandThatMustBeRunAsRoot arg1 arg2);

man pages for sudo, sudoers and visudo  are good resources.  I am pretty
sure 7.3 had the rpm available.

visudo MUST be used to edit the sudoers file.  you can add the following
line to get you started

apache  ALL=(root) NOPASSWD:yourCommandThatMustBeRunAsRoot, someotherCmd

What this says is let the user apache run yourCommandThatMustBeRunAsRoot
and someotherCmd without having to enter a passwd.  There are some
things you can do to limit the arguments that can be passed to the
commands see the man pages.

Very cool stuff with finegrained permission on what can be run by who.

Bret

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



Re: [PHP] Simple question: $_POST

2005-01-15 Thread Bret Hughes
On Fri, 2005-01-14 at 07:48, Stuart Felenstein wrote:
 When using $_POST vars is it required that a form is
 used ?
 
 In other words I can create an href link and echo
 variable and pick them up using $_GET in the following
 page. 
 
 No so with $_POST ?

You could probably create hidden vars and on the href set the var values
and submit the form ( with form method defined as post of course).

You could create the javascript needed in a function built dynamically
setting the vars and simply call the function in the onclick method of
the href.  I think you will have to return false from the function so
that the link won't try to go to nowhere.

Bret

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



Re: [PHP] regex help

2005-01-14 Thread Bret Hughes
On Thu, 2005-01-13 at 15:06, Jason Morehouse wrote:
 Hello,
 
 I normally can take a bit of regex fun, but not this time.
 
 Simple enough, in theory... I need to match (count) all of the bold tags 
 in a string, including ones with embedded styles (or whatever else can 
 go in there).  b and b style=color:red.  My attempts keep matching 
 br as well.
 

interesting.  I usually try to specifically describe in english what I
am looking for.  in your case, I would say a string that begins with 
followed by zero or more spaces followed by a b or a B followed by zero
or more spaces followed by zero or more anything followed by 

/\s*[bB]\s*.*/ 

or perhaps it is enough to say match a  followed by 0 or more spaces
followed by a b or a B and not followed by a r or a R and followed by
zero or more anything followed by 

/\s*[bB][^rR].*/

These are untested but should be close and can be used in preg*
functions.  the greedy matching might grab too much stuff and I always
forget how to do that when I hit it.

try them, let us see the results and we can get there

Bret


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



Re: [PHP] php editor

2005-01-13 Thread Bret Hughes
On Thu, 2005-01-13 at 10:02, William Stokes wrote:
 Hello,
 
 I'm quite new with writing php code. I was considering of using some kind of
 php editor program to help with the syntax. Know any goog ones?

These sort of threads are good every now and then I think.  Especially
since it has been so long since I read this list on a day to day basis.

I assume windows by your mailer.  html-kit was good when I used windows
on a day to day basis several years ago.  I wish there was an html-kit
for linux.. gvim is my old stand by on windows and linux and does a
pretty good job of syntax highlighting but no completion/options based
stuff. gvim in combination with a browser ready to hit the manual pages
is all I use nowadays.

I am interested to hear what other folks are using.

Bret

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



Re: [PHP] php dot net auto complete search engine

2005-01-12 Thread Bret Hughes
On Wed, 2005-01-12 at 05:38, Jochem Maas wrote:
 Richard Davey wrote:
 ...
  It's JS (what else could it be?!) - more info here:
 
 what else? spontaneous self-realising tele-kinetic voodoo. :-D

We used to call that MTAM (Mental Telepathy Access Method)  

Bret

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



Re: [PHP] use of curly braces with string interpolation.

2005-01-12 Thread Bret Hughes
On Wed, 2005-01-12 at 12:08, Jochem Maas wrote:
 Marek Kilimajer wrote:
  Jochem Maas wrote:
  
  hi guys,
  
  
  I always use curly braces around vars placed in double quoted strings, 
  I do this for 2 reasons:
 
  1. I believe It helps the engine because the var delimitation is 
  explicit, and this means the interpolation is (should be?) faster.
  2. it looks nice (easier to read!)
 
  I have tried to test this with a simple script that does a million 
  interations - but I cannot get it to return consistent results - one 
  time with curlies is faster, another its slower. 
  
  
  The difference happens at parse time, so if you want to measure any 
  difference execute php script in a loop, not loop inside php script.
  
 
 DOH! nice one Marek, will make an attempt to 'bash' a script together 
 asap (I'm crap at shell scripting! but the challenge is a good one).
 thanks for the heads up.
 
 thinking about what you said, dumping some test code inside an exec() 
 call would have the same effect, no?

Try this, put your code in a file, say, testparse.php and
testparsebracket.php
and try something like 

myseq=`seq 1 1000`
time for i in $myseq; do php testparse.php;done
time for i in $myseq; do php testparsebracket.php;done

of course the time to spawn php will probably be the most time consuming
part

Bret

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



Re: [PHP] long running page on apache 2

2005-01-10 Thread Bret Hughes
On Mon, 2005-01-10 at 10:17, Richard Lynch wrote:
 Bret Hughes wrote:
  As I begin to write this I wonder if this really an apache issue but
  will ask here to see if anyone has some idea.
 
  We have a php interface to our system running apache 2 on fedora 1 box.
  One page calls a script that does a system() call on a script that runs
  for several minutes.  The issue is that no other calls to the server
  will return from the client until the script returns.  I like the
 
 From the *same* browser?
 
 Cuz, like, some browsers only allow one connection at a time, others limit
 it to 4, some let you configure it, some don't...
 
 Check your browser settings or try a different browser to access other
 content while the first browser plugs away at the slow stuff.
 
 You can also throw something like Apache Benchmark at your server to see
 if the children are behaving.  It should be pretty apparent if things are
 out of whack with that, I should think.
 
  ability to watch the progress of this script but is suppose I can send
  the output to a file and occasionally retrieve the contents of the file
  but that seems really inefficient.  If there is another way to have
  apache process additional requests, from the same client, that would be
  a good thing.  As far as  can tell, the same apache process is is used
  each time, but i am having trouble verifying that to my satisfaction.
 
 Always seems to me like the same child will get used unless you actually
 manage to get TWO requests through at the same time.
 
 Presumably, this is more efficient, as it avoids having to page memory to
 swap in another child.
 
  All work is done in https and there is extensive use of php sessions on
  the system if that makes a difference.
 
 Shouldn't matter, I don't think.
 

Thanks for the reply.  It turns out that it was session usage.  See my
other post if you haven't already.

Bret


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

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



Re: [PHP] if(date(Y-m-d)

2005-01-10 Thread Bret Hughes
On Mon, 2005-01-10 at 12:08, John Taylor-Johnston wrote:
 Hi,
 I would like some help to improve this script. I'm a teacher with a schedule 
 of 17 weeks.
 Instead of using if(date(Y-m-d) = $week3)  I would like to do a for i = 1 
 to 17 and if the current date date(Y-m-d) = week[i] I would like to echo 
 This is week $week[i];
 
 Can someone show me how please?
 
 
 ?php
 #old code:
 $week1 = 2005-01-17;
 $week2 = 2005-01-24;
 ...
 $week17 = 2005-05-09;
 
 if(date(Y-m-d) = $week3)
 {
 echo this is week 3);
 }
 ?
 

(Mistakenly sent to the OP only and I could not stand having my code not
seen by all :)  tested in a shell not web page so YMMV.  Now as I look
at it, a valid date in the last week would not work since there was no
end defined.  I added a 18th date and modified the if to  next week
date.  This code should work with no assumptions that today is even in
the range of weeks defined.

You practically wrote it already.  Also you can use a for loop to load
the array of dates.
$m=1;
$d=11;
$y=2005;

//Load week array
$week= array();
for ($i=0; $i= 17; $i++ ) {
$week[$i] = date(Y-m-d,mktime(0, 0, 0, $m  , $d + (7*$i), $y));
}
$today=date(Y-m-d);
for ($i=0; $i= 16; $i++ ){
if ($today =  $week[$i] and $today  $week[$i+1] ){
echo This is week . ($i + 1) .  that began on $week[$i]\n;
exit;
}
}
echo could not find what week $today is in\n;
echo start date is $y-$m-$d\n;
echo end date is $week[17]\n;


HTH

Bret

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



Re: [PHP] 403 not working -- apache 2 / php5 / linux

2005-01-10 Thread Bret Hughes
On Mon, 2005-01-10 at 15:21, Jason Morehouse wrote:
 Jonel Rienton wrote:
  man chmod, i gather you're new to linux/*nix
 
 I don't need a lesson in file permissions, thanks.  Apache runs as 
 nobody.  The problem isn't trying to get apache to display test.php, 
 it's having it display the proper 403 error page, rather than a php 
 error when it doesn't have access to a page.
 
 Each page, test.html and test.php have the same permissions.  The html 
 page gives the expected 403 error message when I try and access it 
 (thats what I want).  The other, php script doesn't.  This is a security 
 concern for me as it reveals paths on my system in the event a page has 
 the wrong permissions.  Why does apache not server the 403 on the php 
 page?  Maybe  this is better off in the apache list.


Ahh.  well I guess everyone got a refresher on *nix perms at least :)  I
see what you are concerned about but am wondering if relying on the
underlying file system perms is a good thing to begin with.  Still, I
have no answer for your question.  It is an interesting one and I hope
you will enlighten us once you find the answer.

FWIW it sounds to me to be a php issue.  Apache sees the php extension
and passes it off to php who then pukes on the perms.

Bret

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



[PHP] long running page on apache 2

2005-01-09 Thread Bret Hughes
As I begin to write this I wonder if this really an apache issue but
will ask here to see if anyone has some idea.  


We have a php interface to our system running apache 2 on fedora 1 box.
One page calls a script that does a system() call on a script that runs
for several minutes.  The issue is that no other calls to the server
will return from the client until the script returns.  I like the
ability to watch the progress of this script but is suppose I can send
the output to a file and occasionally retrieve the contents of the file
but that seems really inefficient.  If there is another way to have
apache process additional requests, from the same client, that would be
a good thing.  As far as  can tell, the same apache process is is used
each time, but i am having trouble verifying that to my satisfaction.  


Any tips appreciated.

All work is done in https and there is extensive use of php sessions on
the system if that makes a difference.

Bret

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



Re: [PHP] umask wierdness

2004-04-22 Thread Bret Hughes
On Wed, 2004-04-21 at 22:10, Curt Zirzow wrote:
 * Thus wrote Bret Hughes ([EMAIL PROTECTED]):
  I have found a funky situation that I am trying to figure out if it is 
  bug or not:
  
  I see this behavior on both redhat 9 and fedora running 
  
  php 4.3.4
  httpd(apache) 2.0.48
  
  calling umask(0002) in a script leaves the httpd process with a umask of
  2 after exit so that the next process to hit that process gets the new
  umask. in other words the environment does not revert to default as the
  umask() docs say it should.  This does not happen on my 7.3 box running 
  apache-1.3.27-2
  php-4.1.2-7.3.6
  
  I found this chasing a rabbit trail of a bug.  This is kind of sneaky
  since it only changes the umask for the single httpd process it hits. 
  multiple calls to umask(0002) will change every process it hits.
 
 This set up works perfectly fine for me, umask is reset to original
 value after php dies so all my checkumask.sh output results with
 18.
 
 System: FreeBSD, apache 1.3.29, php5.
 
 Looking at the php source code, it looks like all its doing is
 calling the system's umask(), which leads me to belive its an issue
 with either the OS or apache.
 
 You might want to ask [EMAIL PROTECTED] about this they might be
 able to help you a little more about this.
 

Last email went straight to Curt by mistake.  Basically said thanks.

here is the latest on the bug report at redhat:

From redhat developer/bug owner:

 It's a bug in the Apache 2.0 support in PHP: I've got a patch which
 I'll integrate and submit upstream.

I suspect this is a pretty wide ranging problem, and if you are using
redhat/fedora and have sensitive data you are writing to disk expecting
the default umask,  I would check it out.  


Bret
 

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



[PHP] umask wierdness

2004-04-21 Thread Bret Hughes
I have found a funky situation that I am trying to figure out if it is 
bug or not:

I see this behavior on both redhat 9 and fedora running 

php 4.3.4
httpd(apache) 2.0.48

calling umask(0002) in a script leaves the httpd process with a umask of
2 after exit so that the next process to hit that process gets the new
umask. in other words the environment does not revert to default as the
umask() docs say it should.  This does not happen on my 7.3 box running 
apache-1.3.27-2
php-4.1.2-7.3.6

I found this chasing a rabbit trail of a bug.  This is kind of sneaky
since it only changes the umask for the single httpd process it hits. 
multiple calls to umask(0002) will change every process it hits.

I distilled this down to this test:
BTW this is also file at buzilla.redhat.com as bug number 121454:

http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=121454

1.install umask.php in a directory accessible by the web server 

### umask.php

?php
if ( isset( $_GET['newmask']) ) {
print newmask is set to $_GET[newmask] calling umask()br\n;
print umask($_GET['newmask']) .br\n;
}
else {
print umask is . umask() . br\n;
}
?
# end of umask.php

2. copy chkmask.sh somwhere on the server


## chkumask.sh  

#!/bin/sh

if [ -n $1 ] ; then
echo setting hostname to input host $1
myhost=$1
else
myhost=$HOSTNAME
fi
echo using $myhost as wget host

while [ 1 ]; do

echo -n `date +'%D'`  host: $myhost  

wget -q -O - http://$myhost/umask.php;
sleep 1
done

 end of of chkumask.sh   

3. run chkumask.sh [hostnameofserver]
this will start looping and making calls to the umask.php script on
the server  defaults to value of $HOSTNAME

4. with a broser or whatever go to
http://servername/locationofumask.php?newmask=0002

5 observe output of chkumask.sh depending on the number of threads
started by httpd the umask changes from 18(octal 22, the default) to 2
for that thread.

refresh the browser several times to have more threads get changed.

Actual Results:  output of chkumask.sh:

using 10.23.0.137 as wget host
04/21/04  host: 10.23.0.137  umask is 2br
04/21/04  host: 10.23.0.137  umask is 18br
04/21/04  host: 10.23.0.137  umask is 2br
04/21/04  host: 10.23.0.137  umask is 2br
04/21/04  host: 10.23.0.137  umask is 18br
04/21/04  host: 10.23.0.137  umask is 18br
04/21/04  host: 10.23.0.137  umask is 18br
04/21/04  host: 10.23.0.137  umask is 2br
04/21/04  host: 10.23.0.137  umask is 2br
04/21/04  host: 10.23.0.137  umask is 18br
04/21/04  host: 10.23.0.137  umask is 2br

any tips appreciated as well as report wither the behavior is seen or
not on various versions.  I am trying to isolate when this behavior
started or what I have done wrong.


Bret



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