Re: [PHP] php 4.3.7/5.0

2004-07-13 Thread Adam Bregenzer
On Tue, 2004-07-13 at 15:35, Josh Close wrote:
 The problem is, if 0 gets changed to 0 somewhere throughout. That's
 why I've always used if($var) because it's usually not cared what the
 type is, but it seems to now.

You can typecast values as well, this may be a good way to achieve what
you are looking for:
if ((int)$var != 0) {
  // Do Something
}

Also, if you are going to use this variable as an integer later you can
do the following to explicitly convert $var into an integer:
$var = (int)$var;

That should convert 0 into the integer value 0.  Also, note the
following:

var_dump(0 == 0); //bool(true)
var_dump(0 === 0);//bool(false)

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] getting the line number

2004-06-07 Thread Adam Bregenzer
On Mon, 2004-06-07 at 14:52, Tim Traver wrote:
 I have a script that includes a separate file for functions.
 
 In a particular function, if a query gets an error,  write out a log file 
 that explains the error.
 
 The thing I am trying to determine is from what line the call was made from 
 the parent script to the subroutine.
 
 I know that I can get the line number of the current script, but that 
 doesn't tell me where the function was called from...

debug_backtrace[1] should get you everything you want and then some.

[1] http://www.php.net/debug_backtrace

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] row colours

2004-06-05 Thread Adam Bregenzer
On Sat, 2004-06-05 at 11:21, James Kaufman wrote:
 $bgcolor = ($i % 16  8) ? #ff : #ff;
 print tr
 bgcolor='$bgcolor'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcen
 ter$item_5/center/td/tr\n;

You probably want to do:
$bgcolor = (($i % 16)  7) ? #ff : #ff;

Since $i % 16 will rotate from 0 - 15.  This will work assuming $i
starts at 0.  If not then you should do:
$bgcolor = ((($i - $x) % 16)  7) ? #ff : #ff;
Where $x is whatever value $i started at.  However, I would recommend
using a new counter that starts a 0 and is incremented at the end of
your loop.

Alternatively you could do:
print tr
bgcolor='#ff'td$item_1/tdtd$item_2/tdtd$item_4/tdtdcenter$item_5/center/td/tr\n;
if ($i % 8 == 7) {
print trtd colspan='4'/td/tr\n;
}

which would keep them the same color and add a blank row after every
eighth; again adjust $i as necessary to fit.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Class variable unexpected behavior

2004-05-15 Thread Adam Bregenzer
On Sat, 2004-05-15 at 06:24, Richard Shaffer wrote:
 class test {
   var $a;
   var $b = goodbye;
   function c($arg) {
 $this-$a = $arg;
 echo pa =  . $this-$a . /p\n;
 echo pb =  . $this-$b . /p\n;
   }
 }

$this-$a should be $this-a
same with '$b': $this-$b should be $this-b

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] List() help

2004-05-09 Thread Adam Bregenzer
On Sun, 2004-05-09 at 21:13, PHPDiscuss - PHP Newsgroups and mailing
lists wrote:
 I'm using list like
 list($a,$b,$c,$d) = $MyArray
 MyArray holds more than three items, 0-4 more,
 my problem is that $d only gets one and I lose the others if more tha one
 extra. I know I can just add more $e,f,g,h,i but how do I get the extras
 into an array?

Try using array_shift[1] for the first few items instead of list:
$a = array_shift($MyArray);
$b = array_shift($MyArray);
$c = array_shift($MyArray);

$MyArray will have the leftovers, you can just assign it if you need a
copy:
$d = $MyArray;

If you only want $d to be an array when there is more than one entry
left do this instead:
if (count($MyArray) == 1) {
 $d = array_shift($MyArray);
} else {
 $d = $MyArray;
}

[1] http://www.php.net/array_shift

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: Image resize on upload

2004-02-26 Thread Adam Bregenzer
On Thu, 2004-02-26 at 02:25, Will wrote:
 I forgot to mention what I was trying to do.
 There is a web page that pulls the image file name from the database 
 then  reads the URL to the directory where the image is.  Is it possible 
 to just resize it when the web page is brought up in the browser?

I use ImageMagick's[1] convert[2] to do this.  It is not a PHP module
and must be run through exec[3].  Also, in my experience image
manipulation is rather time consuming, it is a good idea to cache
altered images so they do not have to be recreated on every page load.

[1] http://www.imagemagick.org/
[2] http://www.imagemagick.org/www/convert.html
[3] http://www.php.net/exec

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/


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



Re: [PHP] Re: renamed images are now corrupt...

2004-02-26 Thread Adam Bregenzer
On Thu, 2004-02-26 at 20:18, Bryan Henry wrote:
 I realized that I did not trim the end line characters off of the file 
 extensions
 after I grabbed all the file names from a text file. Now all the images 
 have
 end of line chracters as part of the extension.  I cannot access/edit the 
 files
 through SHH, PHP or FTP...

You should be able to through a shell.  Try using a shell script to
rename the files, here's something in bash script to get you started:

for x in `ls`; do
  good_name=`echo -n ${x}|sed s/\(.*\.[a-zA-Z]*\)/\1/`;
  mv ${x} ${good_name};
done

This will find any characters followed by a '.' and any upper or
lowercase letter.  This should grab everything except for the newline at
the end and rename the file accordingly.  Since I don't have any files
with newlines in their names I didn't test it so it may need a bit of
tweaking.

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Sequential Random Character Generator

2004-02-25 Thread Adam Bregenzer
On Wed, 2004-02-25 at 11:25, [EMAIL PROTECTED] wrote:
 I'm trying to create a PHP sequential random character generator that will output to 
 a file database of some sort. The randomization needs to be using both capital 
 letters and numbers. I need to output like 2 million records. Can someone point me 
 in the right direction on how to do this?
 
 I'm also looking to to this without letters as well.

Make an array containing the characters/numbers/whatever you want to be
selected at random then pick from it using a random integer generated
from mt_rand[1] and echo your selection.  If you have PHP  4.2.0 you
will also need to use mt_srand[2].

$field = array('a','b');
$field_max = count($field) - 1;
echo $field[mt_rand(0, $field_max)];

[1] http://www.php.net/mt_rand
[2] http://www.php.net/mt_srand

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



RE: [PHP] Sequential Random Character Generator

2004-02-25 Thread Adam Bregenzer
On Wed, 2004-02-25 at 12:56, [EMAIL PROTECTED] wrote:
 The first column being a key, which the printer requested, the second
 being the random tag, and the third being what prize package they get,
 or don't get.

Verifying you have unique records as well as generating the prize
information are part of the tasks you need to solve in writing the
application.  You may want to store the information in a database and
use it to verify the uniqueness of the keys, also you can then easily
batch process the application so it can be stopped and started.

 As was mentioned I don't want this script to take ten years to output
 2 million records and I wasn't sure if there are size constraints with
 comma delimited files. 

I would recommend splitting the application into pieces, first generate
the keys, then assign the prizes, this way you have more control.  Also,
I would run this through the cli, not as a web page.  As for how long it
will take, that's anybody's guess and greatly depends on the speed of
the system you run it on.

 Hope this clarifies things a little more.

If you have a particular problem please ask about that, mostly I see
here a request for someone to design your application for you.

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



Re: [PHP] function.date.php

2004-02-25 Thread Adam Bregenzer
On Wed, 2004-02-25 at 15:58, John Taylor-Johnston wrote:
 I want to feed in 2003-02-28 and extract February 28, 2003. I can substr it out ...

Use strtotime[1] then date[2].

[1] http://www.php.net/strtotime
[2] http://www.php.net/date

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] apostrophe ( ' ) on a form, adding \; How can i fix this?

2004-02-25 Thread Adam Bregenzer
On Thu, 2004-02-26 at 00:19, Louie Miranda wrote:
 I have a user/form that client enters data. And one of my clients have an
 apostrophe on his name
 
 eg: Ero's
 
 Now, this page has a confirmation page that the client would see first
 before his form will be directed into my system. Now its shows Ero\'s how
 come this is happening? I dont have any filters for this?

Check php.ini, you probably have magic_quotes_gpc[1] enabled, disable
this to remove the backslashes.  If you can not edit php.ini or you are
distributing your application and can not control PHP's settings search
the archives for code based solutions to this.

Welcome to the most annoying PHP feature ever. :)

Regards,
Adam

[1] http://www.php.net/ref.info#ini.magic-quotes-gpc

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



Re: [PHP] Re: regexp appears to be faulty!?

2004-02-24 Thread Adam Bregenzer
On Tue, 2004-02-24 at 10:49, Henry Grech-Cini wrote:
 http://www.alpha-geek.com/2003/12/31/do_not_do_not_parse_html_with_regexs.html
 
 Do we all agree or should I keep trying?

The important thing to keep in mind here is to use the right tool for
the job.  If you are parsing an HTML document looking for tags,
attributes, etc. I do recommend using domxml/simplexml/some XML parsing
tool to get your job done quickly and cleanly.  However, if you have a
very specific need to extract some text from a string then you can
probably get away with regular expressions.  The big catch with regexp
is that it has a very low reuse value.  Generally regexps are difficult
to read and rarely will you just copy and pate a regular expression from
one piece of code to another.  If your regexp is growing beyond one line
and is taking a long time to process then it is time to move on.

Additionally, regular expressions are not good at providing context.  It
just so happens that HTML documents are just text documents so if you
can parse the text to get what you need great.  However, if you want to
move through the elements and attributes, you want something more
powerful, like XPath or XQuery. (ie. you want to find the third fieldset
child of the body element that has an attribute set to foo)

As a side note, that article has a link to a similar one that lists a
regexp based XML parser as the only PHP solution. :)

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] What's wrong with this code please?

2004-02-24 Thread Adam Bregenzer
On Tue, 2004-02-24 at 12:51, Donpro wrote:
 $emails = array([EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]);
 $addresses = explode(,,$emails);
 for ($i=0; $i  count($addresses); $i++) {
echo $i . ': ' . $addresses[$i] . 'br';
if ($i == count($addresses) - 1)
   $form['recipient'] .= $addresses[$i];
else
   $form['recipient'] .= $addresses[$i] . ',';
}
echo 'Recipient = ' . $form['recipient'] . 'br';
 
  
 The output I am receiving is:
 0: Array
 Recipient = Array
  
 Obviously, I want to see the output of each array element as well as the
 final contents of $form['recipient'].

You need to look up how to use explode[1], my guess is you don't want to
use it at all here.  In fact, implode[2] may be exactly what you are
looking for.

Regards,
Adam

[1] http://www.php.net/explode
[2] http://www.php.net/implode

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Parsing large log files with PHP

2004-02-24 Thread Adam Bregenzer
On Tue, 2004-02-24 at 12:39, Pablo Gosse wrote:
 I've got a log file that's about 1.2 gig that I need to parse.
 
 Can PHP handle this or am I better of breaking this down into 12 100mb
 chunks and processing it?

PHP has a very rich set of functions to read in files, it all depends on
what you are doing with the log file and how you read it in.  For
example, if you use the file[1] function it will read the entire log
file into memory, that is probably a bad thing for what you are trying
to do.  However, if you need to access many different parts of the file
frequently and you have the ram go for it.  On the other side of the
spectrum are the C-like functions: fopen[2], fgets[3], fread[4],
fclose[5], et. al.  These will give you a high level of control over how
much of the file you read in at a time.  Lastly, the stream[6] functions
may be a good middle ground for you.

Regards,
Adam

[1] http://www.php.net/file
[2] http://www.php.net/fopen
[3] http://www.php.net/fgets
[4] http://www.php.net/fread
[5] http://www.php.net/fclose
[6] http://www.php.net/stream

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] date functions

2004-02-24 Thread Adam Bregenzer
On Tue, 2004-02-24 at 13:29, Matthew Oatham wrote:
 You might already be fed up with my posts but I'm a complete PHP
 newbie and find these groups are the best way to learn! Anyway I have
 the database date in the format: -mm-dd hh:mm:ss e.g. 2004-02-24
 07:57:59 but when in some situations I only want to show the user the
 date in the format dd-mm- what is the correct / best php function
 to use for this purpose ?

You can either use the date functions or regexps, I would recommend the
date functions, they may be a bit slower but they are more flexible and
easier to read:
$timestamp = strtotime('2004-02-24 07:57:59');
$date = date('d-m-Y', $timestamp);

Also, it would be best to try and get the date in a timestamp instead of
a formatted string, check if your database can do this.  If so then you
can skip the strtotime step above.  If you are using MySQL and the date
field is one of the date formats (ie. not char/varchar) take a look at
MySQL's date formatting functions[1].

Regards,
Adam

[1] http://www.mysql.com/doc/en/Date_and_time_functions.html

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Make sure folder is writable

2004-02-24 Thread Adam Bregenzer
On Tue, 2004-02-24 at 13:32, Matt Palermo wrote:
 Is there a way to check a folder on the server to make sure a specified
 folder has write permissions?  I'm writing an upload script, but I need to
 make sure the user gave the destination directory write permissions before I
 can copy the files to the new folder.  Anyone got any ideas?

How about is_writable[1]?

Just to throw it out there.  My favorite, non-portable, hackish solution
is `touch $dir`; :)

[1] http://www.php.net/is_writable

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Php and GpG

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 08:35, Paul Marinas wrote:
 Those anyone know hoh to use php with gpg. I've tryed gpgext, but doesn't
 seems to work maybe my php is not compiled with some kind of support.

You will need to call gpg from your script using either a socket
connection[1], something from the exec family[2], or backticks[3].

[1] http://www.php.net/popen
[2] http://www.php.net/ref.exec
[3] http://www.php.net/operators.execution

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Possible to write CRC/MD5 to the file?

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 00:01, Evan Nemerson wrote:
 What you would have to do is find a collision, which is thankfully difficult 
 to do- if it were easy, MD5 would be useless. Theoretically, you could modify 
 say John The Ripper and have it brute force something, but you may end up 
 waiting a few lifetimes :)

Just as a note, check out www.md5crk.com.  They aim to do just this and
imho have a good plan of attack.  I have already moved to sha1 for
passwords, this is only further support of why it's time to move on.

 I'd recommend PGP/GPG signing instead- anyone can create a valid MD5 checksum, 
 but only you can cryptographically sign your files (theoretically- if someone 
 else can, you've got serious problems)
 
 Everyone seems happy enough with detached signatures. Also, you could use the 
 OpenPGP specification to do what you want, just like when you send a 
 PGP-signed e-mail the signature and the message are all in a single 
 container. You may have to hack GPG a bit (not as difficult as you'd think) 
 to have the PGP stuff in PHP comments, but i think you could do it... Sorry, 
 I'm rambling.

Here, here, PGP adds more benefits as long as you don't leak your
private key.  You could always try and wrap everything as a mime message
or zip the two together.  Also, place a link to the pgp signature in the
README file.  Not that anyone ever reads those though. ;)

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Detecting Binaries

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 14:19, Axel IS Main wrote:
 Yes, and in fact that is what I am doing now. This is a spider bot 
 though, so I'm having to think of every single type of binary file that 
 could be linked to on the web. So far I'm up to 28 with no end in sight. 
 What about a .com file? I can't omit links that end in .com can I? That 
 would be counterproductive to say the least. Also, the function that 
 does the checking just keep getting longer and longer, which makes the 
 spider go slower and slower. Granted, the thing is pretty fast if it has 
 enough BW to work with, but still. This could eventually turn into a 
 script killer. Detecting whether the stream from file_get_contents(), or 
 fopen() for that matter, is binary or not and going with that result is 
 the elegant solution to this problem. There has to be a way to do it.

You could trying writing a script to check the first several bytes of
the file for control characters.  If the first 1kb is = 20% (randomly
pulled from my head) control characters it's a safe bet it is a binary
file.  This is not 100% accurate, but it's something to play with that
doesn't rely on mime types or file extensions, both of which can easily
be inaccurate.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP 5

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 14:25, Karl Timmermann wrote:
 I am new to the list, so sorry if this has been asked before. I was 
 wondering if anyone knew of an approx. date for the final release of 
 PHP 5.0? I ask because I have a project to do semi-soon that uses XML 
 and I would rather wait for PHP 5 and use the SimpleXML extension to 
 make things easier. My client does not want to put beta software on 
 their server, which is why I can't use B4.

It will be released when it is done.  AFAIK there is not a release date
yet at all.  It will be released when enough bugs are fixed and enough
people do not complain about it not working right when they use it.  If
you want to shorten the time to release you can always go and fix some
bugs. :)

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] preg guru again.....

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 11:36, pete M wrote:
 Here is a snippet
 ð­:2002020720020208:[EMAIL 
 PROTECTED]://www.lyricsworld.com/cgi-bin/search.cgi?q=Bruce
 +Springsteenm=phraseps=20o=0wm=wrdul=wf=1ð­ð­ð­ð­
 
 it breaks down in the following elements
 the :date: in the format mmddmmdd
 The expression I'm using is
 (:16[0-9]:)
 ie matching the : with 16 digits :

here's a start:
/:(\d+):([EMAIL PROTECTED])@([\w=+\/:\\%-]+)/i

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] delete a function

2004-02-23 Thread Adam Bregenzer
 to maintain your code.

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Constants in class definitions

2004-02-23 Thread Adam Bregenzer
On Tue, 2004-02-24 at 08:22, Toro Hill wrote:
 I've looked throught the PHP documentation and from what I can
 tell it is legal. I'm using PHP4.3.4, and haven't had any problems with 
 class definitions like this. 

I use constants in classes myself without problems.  In PHP 5 you can
actually declare constant class properties! :)

 However, I've had some problems with Turck MMCache and class definitions
 that are similar to above. I suspect that it's probably a bug with 
 MMCache but I wanted to check to make sure that the code was completely
 correct. 

I also use MMCache, mind sharing the problems you are experiencing?

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Constants in class definitions

2004-02-23 Thread Adam Bregenzer
On Tue, 2004-02-24 at 09:26, Toro Hill wrote:
 Here's the situation:
 PHP 4.3.4
 Apache 1.3.29
 MMCache 2.4.6
 
 I'm ending up with some garbage in certain class variables. 
 The code runs fine without MMCache disabled.
 There seems to be a very specific circumstances under which the error occurs. 
 Namely:
 1. The constants must be defined in a seperate file.
 2. The member array ($stuff, refer below) must be populated in the class definition, 
 not the class constructor 
 3. index.php can't be modified after apache has been started. If I touch index.php 
 then the problem disappears, but then if I restart apache the problem reappears. 
 
 If you want to see the output of the script go to http://outreach.net.nz/test/

Wow, looks like a bug to me, good find!

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] enum('part1','...')

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 22:57, John Taylor-Johnston wrote:
 district enum('part1','part2','part3','part4')
 
 while (district??)
 {
 echo a href=\page.htm#.district[0].\.district[0]./a
 }

Are you doing this in PHP?  I do not think you can even create enums in
PHP.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: [PHP-DB] Embedded MySQL server (libmysqld)?

2004-02-23 Thread Adam Bregenzer
On Mon, 2004-02-23 at 23:02, [EMAIL PROTECTED] wrote:
 Adam,
 Thanks for your repsone(s) now back the root of the problem.
 As stated above I need to be able to run the database from with the home 
 direcory/document root?

I hesitate to answer this so as to not create a naming confusion but I
can not resist. :)

However, Adam (not me) already answered your question.  If your hosting
provider does not provide you with a mysql or any other database server
you need to use a flat file database solution.  I second his
recommendation of sqlite if you can use it with your hosting provider. 
Another choice may be db or access of you are on windows through odbc. 
If none of these options work for you then you either need to change
hosting providers (which you should since they don't provide what you
seem to need) or you are of course able to write your own database in
PHP and share it with the world. (This is a joke, please don't ask us
how to write your own database).

Also, *please* do not cross post in the future, pick a list and give it
a shot, if you don't have any luck try another one.  I hesitate to cross
post this response but you did not even provide a valid e-mail address
so I am not sure which list you are checking.

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Padding the decimals

2004-02-22 Thread Adam Bregenzer
On Sun, 2004-02-22 at 21:14, Simon Fredriksson wrote:
 Is there any functions to pad the decimals in a number? There's round() 
 to put it down to two decimals, but what if I want to take it up to two?
 
 Example:
 
 5 - 5.00
 20 - 20.00
 4.3 - 4.30
 etc.

I assume you mean adding zeros to the end for displaying, not for
further calculation?  Look at printf[1] and sprintf[2].  Here's an
example:
printf(%.3f, 4.1) // 4.100

[1] http://www.php.net/printf
[2] http://www.php.net/sprintf

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] delete a function

2004-02-21 Thread Adam Bregenzer
On Sat, 2004-02-21 at 06:02, Sztankó Demeter wrote:
 Hello!
 
 Is there any way to delete (unset) a function?

No, why would you really want to delete a function?

 I want to write some function with one constantyl defined name, then call a
 function_manager function, that will gice this function an unique name, than
 delete the original function, so I can start the process from the beginning.
 
 I will call this function through a wrapper, which will find the function I
 need.

I'm not completely sure what your intended use of the process you
described is, but it sounds to me like you are trying to implement the
factory pattern[1].  I would recommend looking into using classes in PHP
and giving it a shot.

http://www.phppatterns.com/index.php/article/articleview/49/1/1/

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] running php through cron

2004-02-21 Thread Adam Bregenzer
On Sat, 2004-02-21 at 22:12, Pablo Gosse wrote:
 php /home/pablo/cmsutil/CMS_monitor.php
 
 and the permissions on CMS_monitor.php are as follows:
 
 -rw-rw-r--1 pablopablo3636 Feb 21 00:48 CMS_monitor.php
 
 My question is under these permissions could someone else with an
 account on this server execute this file?  I'm pretty sure they couldn't
 but my knowledge of Linux isn't yet as extensive as I would like it to
 be so I can't say for sure.

If the script can be read (the r permission) it can be run through the
php cli like you are doing in cron.  If the cron command you have is
running under your username, and the script does not need to be viewable
by the web server, you can set the permissions to 600, which would be
-rw---.  This will allow you as the user to read (as well as execute
through php) and write to the file and not let anyone else (besides root
of course) to do anything with it.  Technically, if an executable can be
read it can be executed.  If it's a binary it can be copied by a user
and the copy can be run, if it's a script it can be passed to an
interpreter and run.

Good Luck,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Split()

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 11:03, John Taylor-Johnston wrote:
 Can I while this? Not sure how to go about it?
 
 $pizza  = piece1 piece2 piece3 piece4 piece5 piece6;
 $pieces = explode( , $pizza);
 echo $pieces[0]; // piece1
 echo $pieces[1]; // piece2

Try while(each($pieces)) or foreach($pieces as $piece)

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Split()

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 11:02, Adam Bregenzer wrote:
 Try while(each($pieces)) or foreach($pieces as $piece)

Brain to fingers problem:
while($piece = each($pieces))

http://www.php.net/each
http://www.php.net/foreach

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: Split()

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 13:01, John Taylor-Johnston wrote:
   $tempauthors = explode(\r\n, $mydata-AuthorList);
   foreach ($tempauthors as $singleauthor)
 # while($tempauthors = each($singleauthor))
   {
   echo a href=\http://www.foo.org$singleauthor\;$singleauthor/a ;
   }

First of all, you are flipping your variables:
while ($singleauthor = each($tempauthors))

Secondly, check the manual to see what each() returns[1].  It returns an
array with the key and value of the result in it.  If you want to use
each() then you need to evaluate $singleauthor as $singleauthor[0] or
$singleauthor['value'] to get its value.  Another way to do this that
would be closer to what foreach does would be:
while (list($key, $singleauthor) = each($tempauthors))

This will assign the key to $key and the value you are looking for to
$singleauthor.

[1] http://www.php.net/each

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] how to deal with http and https directory structures?

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 18:39, Chris W. Parker wrote:
 http root:
 /home/cparker/www/domain.com/http/
 
 https root:
 /home/cparker/www/domain.com/https/
 
 includes directory:
 /home/cparker/www/domain.com/includes/
 
 this way i don't have to worry about symlinks or keeping two separate
 and identical directory trees up to date (if i chose to put the includes
 within each directory).

I think this is the best solution, it is very similar to how I implement
virtual hosting.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Split()

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 15:22, Jochem Maas wrote:
 $applePie = array(1,2,3,4,5,6,7,8);
 
 while ($pieceOfPie = array_shift($applePie)) {
   echo $pieceOfPie; // want some pie?
 }

Careful, that will eat your array as well.  When the while loop finishes
you won't have any pieces of pie left!

IE:
$applePie = array(1,2,3,4,5,6,7,8);

while ($pieceOfPie = array_shift($applePie)) {
echo $pieceOfPie; // want some pie?
}

// Both of these are now true:
$applePie == array();
$applePie != array(1,2,3,4,5,6,7,8);

-Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Javascript array [] length is undefined when only single element

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 20:21, Daevid Vincent wrote:
 Okay kids. Here's another strange one. Very simple form. The array is
 dynamically generated from PHP as per the suggested method:
 http://us2.php.net/manual/en/faq.html.php#faq.html.arrays
 
 However, when there is only a single element, the myMultiSelect.length is
 undefined in javascript.
 If there are two or more elements, then the length works as expected...

This is a javascript question not a PHP question, but how about:
selectedAudits = 0;
if (myMultiSelect.length) {
  for(i = 0; i  myMultiSelect.length; i++)
if (myMultiSelect[i].checked) selectedAudits++;
} else {
if (myMultiSelect.checked) selectedAudits++;
}

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP4 vs. PHP5 test case for objects question.....

2004-02-17 Thread Adam Bregenzer
Richard,

On Tue, 2004-02-17 at 19:25, Richard Gintz wrote:
 Using the exact same code, I created 50 objects.  It took twice as
 long in php5 as it did in the older php4.  

From what I remember the speed improvement with objects in PHP 5 was
that they would be passed by reference, which I understand to be the
case.  Try passing an object to a function, modifying it, then returning
it and echoing the result.  I was surprised however to hear that you
found PHP 5 to be slower, I would be interested in any benchmarking
results you have.  I also decided to do a quick test.

I wanted to test some decent sized classes so I used some I have written
already.  Each class inherits from the one above it (names have been
changed to protect the innocent), therefore Class is a sub-class of
ClassData, etc. up to Object.  Here is the wc output for the class
files:
   43   200  1355 Object.php
  190   533  5311 ClassBase.php
  428  1554 15648 ClassData.php
  481  1274 18831 Class.php
 1142  3561 41145 total

Here is the script I tested with:
?php
include_once('Object.php');
include_once('ClassBase.php');
include_once('ClassData.php');
include_once('Class.php');

function getmicrotime() {
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}

$script_start = getmicrotime();
for ($x = 0; $x  10; $x++)
$a = new Class();
echo 'Script Time: ' . sprintf('%.4f',(getmicrotime() - $script_start))
. \n;
?

I tried to measure only the execution time of creating 100,000 objects
as accurately as possible.  Creating them in an array would have been
interesting as well, but rather memory intensive, so I decided against
it.  Another note is that I did run PHP 5 in cli mode only.  I installed
both copies of php as well as apache2 and Turck MM Cache through emerge
on a Gentoo system.  They were compiled from source but I did not change
their optimizations from the default.  Since this is a testing box PHP
is installed with pretty much everything.  Disclaimers aside, below is
what I found.

PHP 4.3.4 and apache2:
Script Time: 16.0964
Script Time: 16.0322
Script Time: 16.0289
Script Time: 16.0710
Script Time: 16.0306
Average: 16.0518

PHP 4.3.4 and apache2 with Turck MMCache v2.4.6:
Script Time: 15.1848
Script Time: 15.2146
Script Time: 15.2527
Script Time: 15.2354
Script Time: 15.2507
Average: 15.2276

PHP 5.0.0RC1-dev (cli):
Script Time: 15.2346
Script Time: 15.2254
Script Time: 15.2538
Script Time: 15.2414
Script Time: 15.2554
Average: 15.2421

PHP 4 is a bit slower than PHP 5, however with an optimizer it comes to
be about the same, maybe a touch faster.  If/when a PHP 5 optimizer
comes out this may change some.  I hope to run more benchmarks as I have
time.  Also, PHP 5 is still in Beta, and this is not even the latest
version.

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Split()

2004-02-17 Thread Adam Bregenzer
On Tue, 2004-02-17 at 22:28, Jochem Maas wrote:
 that was the idea: you can't have your pie at eat it right? ;-)

Heh, I thought you might have done that deliberately. :)

 seriously thought, John Taylor-Johnston was asking for help on while 
 loops and I thought I'd give him some brainfood (i.e. a little 
 optimalization thrown in). besides which how many times have we in our PHP
 careers not created arrays just to loop over them once, outputting each 
 item?

Oh yeah, that's one side effect of PHP, you completely forget about:
memory and garbage collection concerns.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Need help with output from form to .txt file

2004-02-15 Thread Adam Bregenzer
On Sun, 2004-02-15 at 05:59, Kristers hotmail wrote:
 I'm sendeing hello from the form
 
 The result I get in my gb.txt file is \hello\

You need to check out magic_quotes[1].  If you do not have access to
php.ini, or want a way to disable it without changing php.ini see my
previous post[2].

[1] http://us4.php.net/ref.info#ini.magic-quotes-gpc
[2] http://marc.theaimsgroup.com/?l=php-generalm=107669185927933w=2

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP5: ext/dom - set namespace of node manually

2004-02-15 Thread Adam Bregenzer
On Sun, 2004-02-15 at 19:04, Vivian Steller wrote:
 As you can see it is impossible to set the namespace manually! I tried to
 set it with the help of a DomNamespaceNode-object but those objects are no
 real nodes (why!?!) and the consequence is that you couldn't append such
 a node with $node-appendChild($domnamspacenode_object); ...

I am not sure if PHP 5 has many changes from PHP 4, however have you
tried calling set_namespace[1]?
$node-set_namespace('http://www.somedomain.de/');

[1] http://www.php.net/domnode-set-namespace

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] $REMOTE_HOST in email subject

2004-02-15 Thread Adam Bregenzer
On Sun, 2004-02-15 at 19:03, Birkholz, James wrote:
 mail([EMAIL PROTECTED],[EMAIL PROTECTED],'[FLAG] Info edited: '.$theInfo.' by
 '.$REMOTE_HOST, 'From: '.$emailAdmin.\r\n);

Try $_SERVER['REMOTE_HOST']

Also, if apache is not configured with HostnameLookups On this won't be
set.  You can get the IP from: $_SERVER['REMOTE_ADDR']

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] php as cgi with static libraries?

2004-02-15 Thread Adam Bregenzer
On Sun, 2004-02-15 at 17:19, Marten Lehmann wrote:
 when I'm building php as a cgi-module, a 'ldd php' shows a list of some 
 libraries, that are linked in dynamically. How can I link some of them 
 statically into the php-binary? I can't rely of external libs in some cases.

You will need to build php yourself, take a look at configure --help:

$ ./configure --help | grep static
  --enable-static[=PKGS]  build static libraries [default=yes]

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP and Word...

2004-02-15 Thread Adam Bregenzer
On Sun, 2004-02-15 at 18:28, Russell P Jones wrote:
 I need to use PHP to pull the first page from a Word Document and then
 print it to the screen. It doesnt have to be fancy, so even if just the
 text is pulled that would be fine (although formatting would be grand
 too).

[snip]

 I was thinking about converting it to text somehow, and then just pulling
 the first 50 lines or so - but I dont know how to convert it to text...

Here is a snippet of sample code I have that uses wvWare[1] to display a
Word doc.  You should be able to pass it through shell_exec[2].  It is
not perfect but does a decent job of keeping formatting.

passthru(WV_HTML_PATH . ' ' . FILES_HOME_DIR . $file . ' -');

[1] http://wvware.sourceforge.net/
[2] http://us4.php.net/shell_exec

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] General Function usage question (simple)

2004-02-14 Thread Adam Bregenzer
On Sat, 2004-02-14 at 02:31, Dave Carrera wrote:
 My question is what do or where do or why are the $var1 and or $var2
 included inside the brackets of a function.
 
 What do they do ?
 
 Why are they in there ?
 
 And how are they used within an application ?

A good place to start reading about functions is in the php manual[1].

In short, functions are blocks of code that achieve a particular
purpose, or function.  Arguments[2] are used with functions to pass
information, or variables, to these blocks of code.  Generally the
arguments are used or manipulated by the function.  Functions may pass
back, or return[3], information as well.  Here are some sample
functions, function calls, and output for context.  Steps are separated
as much as possible for clarity:

// No arguments
function echoHelloWorld() {
echo Hello World\n;
}
echoHelloWorld(); // Output: Hello World

// Has arguments, uses data.
function printPlusOne($number) {
$number = $number + 1;
echo $number . \n;
}
printPlusOne(2); // Output: 3

// Has arguments, manipulates and returns data.
function doubleNumber($number) {
$number = $number * 2;
return $number;
}
$value = doubleNumber(10);
echo $value . \n; // Output: 20

Good Luck,
Adam

[1] http://www.php.net/functions
[2] http://www.php.net/functions.arguments
[3] http://us2.php.net/functions.returning-values

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP5: Problem concerning multiple inheritance / interfaces

2004-02-14 Thread Adam Bregenzer
Oops, I left this in my Drafts folder, sorry about that.

On Wed, 2004-02-04 at 20:28, Vivian Steller wrote:
 ok my problem in a nutshell: i need multiple inheritance! is there a
 solution to fake this functionallity in php5?

It sounds like you would want to check out association and
aggregation[1].  Though aggregation looks mighty attractive, I doubt it
will work in your situation since you do not get the constructor, and
therefore the underlying reference to the DOM library is missing.  See
below for a possible solution.

 i have the following problem:
 the goal is to implement my own DomXML implementation based on the existing
 DomNode, DomDocument, Dom... Classes.
 
 thus, i implement my classes as follows:
 
 class MyNode extends DomNode {} // that isn't the problem
 class MyDocument extends DomDocument {} // would be fine, but...
 
 this would be an easy solution,  but there is a logical problem:
 if i extend the DomNode (with the methods in MyNode) then -i think-
 MyDocument should have those extended methods, too.
 so i could write:
 
 class MyDocument extends MyNode {}  // problem
 
 but now i'm missing all the nice methods of DomDocument!!
 multiple inheritance would solve this problem:
 
 class MyDocument extends MyNode,DomDocument {}  // not possible

Neither prototype nor multiple inheritance is directly supported in
php.  The best option to achieve what you want would be to define your
new class layer (MyNode, MyDocument, etc.) as inheriting from their
respective classes (ex. MyDocument extends MyNode).  Then within each
class definition hold the respective DOM class in a property:
class MyNode {
  var $dom_node;
  function MyNode($param) {
$this-dom_node = new DomNode($param);
  }
}

You then will need to write stub methods to implement each method in the
DOM class for your class.  You can then manually override any DOM method
as well as extend the class in your own manner.  An important note: You
*never* want to access the property for the DOM instance directly, if
you are using PHP 5 you *must* make this property private.  This is a
fair amount of code bloat but afaik the only way you can conform php4 to
your design.  See below for more solutions relating to PHP 5.

 I'm thinking about the new __call() method implemented as follows:
 
 class MyDocument extends MyNode {
 function __call($method, $params) { // fake solution
 ...
 eval(DomDocument::$method($paramsString););
 }
 }
 
 but with a fake solution like this i wouldn't get all methods with
 get_class_methods() and that wouldn't be that nice:)

The Reflection API[2] in PHP 5 can help you here.  I'm hoping to play
with it sometime and see if it can be used to fake prototypes by
allowing modification of the method and property spaces.  That *would*
be nice. :)  Even if it does not, you can still use it to look up and
call methods from other classes.

 Can Interfaces help me?

They may, but interfaces will not implement the code themselves. 
Without prototypes you will need to either write accessor code to the
DOM methods in a function outside your classes and a wrapper for each
object, or copy and paste the code manually to implement the additional
Node sub-class functions across all other sub-classes.  I would
recommend leaving interfaces out of this as they will provide
unnecessary structure and rigidity to your code.  Implement only the
constraints you absolutely need.

Hopefully this gives you something to think on.  As I am still working
out the possibilities in php myself I would appreciate any findings you
have back here.

Hope this helps,
Adam

[1] http://www.php.net/ref.objaggregation
[2]
http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Using exceptions to write more perfect software ...

2004-02-14 Thread Adam Bregenzer
On Tue, 2004-02-10 at 11:40, Markus Fischer wrote:
   Isn't this the same thing I started doing anyway? I however didn't 
 integrated those functions in my application directly but put them in a 
 file of its own so I can (hopefully ;) reuse them.

I started putting them together then I realized I was not nor wanted to
implement the framework necessary to have a proper hierarchy.  Instead I
am playing with replacing each function call that should throw an
exception manually.  This has also helped me increase the granularity of
my exceptions.  Because I generate practically all the code I have that
uses system function calls in some way it's not much additional code for
me to write.

   This sounds very interesting. Can you elaborate how and what you 
 actually did for generating the code (what was your input and how did 
 you transform it)?

Right now I have a php script that reads in sql code (currently MySQL's
semantics) and outputs a series of classes.  I can not get into too much
detail as I consider it very dear to my process. :)  However, I am able
to generate a complete class based data abstraction layer from sql code,
which is nice. :)

   I think such a real hierarchy of classes will never exist. That's too 
 much for PHP; none of the developers want to break BC and also follow 
 the KISS credo (which is good, imho).

I wonder what will happen to the user base as PHP 5 comes out and later
when PHP 6 is in the works.  Classes are becoming more popular in php
and I have already seen some discussion on implementing a base PHP
framework in classes.  It seems some people are considering using Java's
structure, which I would agree is way to formal for PHP, however
hopefully some good middle ground will be found.

   But it sounds interesting in re-creating the globbered global function 
 table of PHP in a well thought class framework and make it 
 exception-proof. But that would be a step back either if this wrapping 
 would only occur in PHP side - for every PHP function there would need 
 to be called a userland PHP code before. I even don't want to think 
 about the performance implications. But well, since this is effectively 
 what I started with with my System class, there my be needs where this 
 trade off is accecptable (compensating longer execution time with caches 
 and more hardware power/ram/whatever).

I don't think an in system solution would be a good idea.  I appreciate
the PHP developer's respect for functional programming and think it
would be a mistake to being integrating an object oriented framework in
all of PHP itself.  One if the benefits of PHP is its similarity to C.

   I think for the current issue I will just continue recreating the PHP 
 functions inside an exception-proof class if I don't find a better way. 
 Only creating them on-demand isn't a real problem (at the moment).

Let me know how it goes.  If you want to merge code and start an
impromptu class repository for PHP 5 I would be interested.  I have only
been playing around with PHP 5 since it is still in beta, I haven't
tried converting an entire application over to the new class syntax yet.

Regards,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Error with ftp_get()

2004-02-14 Thread Adam Bregenzer
On Fri, 2003-11-14 at 07:33, Thorben wrote:
 Warning: ftp_get(): 'RETR ' not understood.
 
 I guess 'RETR' is a message from FTPServer to PHP and PHP don't 
 understand it. So, can you tell me, how to avoid this?

When you request (get) a file using the ftp command you send a RETR
command to the ftp server indicating which file you want to retrieve. 
I'm not 100% sure what is going on since there is no code in your post,
but it looks like the RETR command is disabled on the ftp server.  This
means you will not be able to download files.  Try retrieving the file
manually using your favorite ftp client and see what happens.  If you
can post the code you are using we may be able to help better.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] include result from script in midle of other script

2004-02-14 Thread Adam Bregenzer
On Sat, 2004-02-14 at 15:46, Boneripper wrote:
 ? if ($_SESSION['valores_relativos']) echo 'img
 src=./5_grafico_total.php?aVar=aValue';
 else include (./5_grafico_total.php?aVar=aValue);?

Using include literally inserts the contents of the file into your
code.  One way to achieve what you are looking for is to set the
variables you want to pass as a query string before including the
script:
if ($_SESSION['valores_relativos']) {
  echo 'img src=./5_grafico_total.php?aVar=aValue';
} else {
  $_GET[aVar] = 'aValue';
  include (./5_grafico_total.php);
}

If you rely on register globals you would want to set the variables
directly like so:
if ($_SESSION['valores_relativos']) {
  echo 'img src=./5_grafico_total.php?aVar=aValue';
} else {
  $aVar = 'aValue';
  include (./5_grafico_total.php);
}

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] $_POST getting lost, $GLOBALS['HTTP_RAW_POST_DATA'] is still set

2004-02-13 Thread Adam Bregenzer
On Fri, 2004-02-13 at 11:38, Joshua Beall wrote:
 I want to turn off magic quotes.  I realize in retrospect that using a
 .htaccess file to turn magic quotes would probably be better than this code,
 and I am going to switch to that solution, but I am still trying
 to figure out what is causing my current problem:

Having a function to undo magic quotes can be very useful if you
distribute your application.  Here is what I use, just call
disable_magic_quotes().  It should not do any damage if magic_quotes is
already disabled.

/* Undo damage caused by magic quotes */
function remove_magic_quotes($vars,$suffix = '') {
eval(\$vars_val = \$GLOBALS['$vars']$suffix;);
if (is_array($vars_val)) {
foreach ($vars_val as $key = $val) {
remove_magic_quotes($vars, $suffix . ['$key']);
}
} else if (!is_object($vars_val)) {
$vars_val = stripslashes($vars_val);
eval(\$GLOBALS['$vars']$suffix = \$vars_val;);
}
}

// Defeat magic quotes
function disable_magic_quotes() {
if (get_magic_quotes_gpc()) {
remove_magic_quotes('_GET');
remove_magic_quotes('_POST');
remove_magic_quotes('_COOKIE');
ini_set('magic_quotes_gpc',0);
}
set_magic_quotes_runtime(0);
}

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: $_POST getting lost, $GLOBALS['HTTP_RAW_POST_DATA'] isstill set

2004-02-13 Thread Adam Bregenzer
On Fri, 2004-02-13 at 12:14, Joshua Beall wrote:
 However, I am still interested in knowing if my code is broken in any way.
 It seems to work fine for me, but as per my original post, I did get this
 one odd behavior, with HTTP_RAW_POST_DATA being set, but _POST being an
 empty array.  Any thoughts?

Honestly, I didn't see anything glaringly wrong so I deftly skirted your
problem by posting code that I find works. :)

One part that may be an issue is you are using each() on $data then
re-assigning the stripped code to $data, maybe that is exposing some
bug/issue with php?  Try making a new array by assigning the stripped
output to $data2 and returning $data2, maybe that will solve it.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP and Kerberos5 Single Sign-on

2004-02-13 Thread Adam Bregenzer
On Fri, 2004-02-13 at 10:34, Ricky Boone wrote:
 I can get the Linux server to talk to Active Directory through LDAP and
 Kerberos, but to achieve SSO the only way to get it to work on Apache is
 with mod_auth_gss_krb5 (though I can't seem to get it to build for
 Apache2), and I couldn't find anything that would do the same with PHP.

PHP supports ldap[1] which should allow you to talk to Active Directory,
also there is mod_auth_kerb[2] for kerberos authentication.  If you are
against using an apache module for kerberos you can try using
pam_auth[3] in PHP with a kerberos module for pam.  I do not think PHP
supports kerberos natively, though you could hack together an extension
for it if you were motivated enough. :)

[1] http://www.php.net/ldap
[2] http://modauthkerb.sourceforge.net/
[3] http://www.math.ohio-state.edu/~ccunning/pam_auth/

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] preg guru question

2004-02-13 Thread Adam Bregenzer
On Fri, 2004-02-13 at 13:25, pete M wrote:
 Im trying to  scan a file and lift the image name from the img tag
 
 ie
 img src=THISBIT.ext
 where there could be ' or 
 
 I messed around but am 2 embarassed to post code cos it dont work ;-(

Always post code, it can help us understand what you are looking to do. 
Are you looking for a regexp?
'/img\s+src=([\'])([^\1]+)\1\s*\/?\s*/i'

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] cli input and screen question(s)

2004-02-13 Thread Adam Bregenzer
On Fri, 2004-02-13 at 18:25, Matthias Nothhaft wrote:
 The other problem is: I would like to draw a screen
 like midnight commander does. Is there a way to get that
 work with PHP ?

Ahh, sounds like a Slackware fan. :)

You want to look at ncurses[1] in PHP.  This lets you draw on a screen. 
It does require a decent terminal interface but that should not be a
problem.  Also readline[2] may help you with reading input.

[1] http://www.php.net/ncurses
[2] http://www.php.net/readline

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: preg guru question

2004-02-13 Thread Adam Bregenzer
On Sat, 2004-02-14 at 00:24, André Cerqueira wrote:
 strange bug happened on my newsreader...
 'joel boonstra' regex seems to be the better one hehe
 all others forgot that if u start with ', u must end with ' hehe (same 
 thing with  :p)

As far as I could tell the regexp I posted was the only one to use a
subpattern to match the first quote type used and then re-apply that
after matching the file name:
'/img\s+src=([\'])([^\1]+)\1\s*\/?\s*/i'

I am a bit of a regular expression fan and I would be interested in
seeing another way to match without using subpatterns.  What was Joel's
regexp again?

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Session, loging users in.

2004-02-13 Thread Adam Bregenzer
On Sat, 2004-02-14 at 13:48, Philip J. Newman wrote:
 Whats the best information to add to a session to say a user is logged in?
 
 I currently have $siteUserLogIn=true;
 
 anything else that I could add to beef up security?

For storing user status use whatever fits your application best.  I save
an instance of my user class in the session and use it to check if I
have a logged in user.  If it is set then that is the user, if not then
the session is not logged in.  To beef up security I use a combination
of the session id (cookies only) and set an additional cookie that
contains a random sequence.  This acts like an initialization vector
does in cryptography.  It is always a random sequence and never contains
any identifying information about the user.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] SESSION VARIABLES

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 02:45, Ronald Ramos wrote:
 $_SESSION['username'];
 $_SESSION['password'];

Close, try this instead:
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

 I edited page3.php but it still shows me nothing.

It looks great, now you just need to clear up your use of the $_SESSION
variable in page2.php.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] SESSION VARIABLES

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 03:13, Ronald Ramos wrote:
 It Worked. Thanks Man!
 So I can use this to any other page?

Awesome!  You have access to the $_SESSION variables on any php page on
the same server.  Just make sure you call session_start() before you
access the $_SESSION array.

 Let's say I have two users, first one logged in, using ronald as
 username, while user ronald is still logged-in
 User nhadie also logged-in from somewhere, will the value of $username
 of user ronald be changed to nhadie?

No, with sessions there will essentially be multiple values for the
variables, one for each session.  When a user requests a page their
session id will be used to set the correct values in the $_SESSION
array.  For example, when ronald loads the page $_SESSION['username']
will be ronald.  When nhadie loads the page the $_SESSION['username']
variable will be nahdie.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: Linked Table Structure

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 09:49, Sajid wrote:
  A way you could do this, is to set up the tables like this:
 
  DG1:
  Continent_Id | Continent_Name | Continent_Image | Continent_Text
 
  DG2: Country_Id | Continent_Id | Country_Name | Country_Image |
 Country_Text
 
  DG3: Club_Id | Country_Id | Club_Name | Club_Image | Club_Text | Club_Url
 
 Thanks for your help.
 But what i feel is that this is a more tedious process to achieve what i
 want to.
 What will happen in this is that i have to enter proper Continent ID and
 Country ID in both Country and Club tables respectively.
 For that i have to go and check that these ID's are in the other tables.
 
 I was looking for something to do with Linked Tables.
 Can anyone show me an example of how this can be done using Linked Tables?

You can write an admin interface to manage adding the rows to your
tables if you don't want to do it manually.  This seems like as close to
a linked list as you are going to get: each item in the child table has
a link (id column) to it's parent.  You reference that to find
children/parents.  This is generally the way relational databases are
structured.  Maybe if you expand on what you mean by a linked list we
can provide a different answer.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: Re[2]: [PHP] HELP: Nested include(...)'s take relative paths not intuitively

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 19:06, Richard Davey wrote:
 This is slightly off-topic, but related to the include() function.
 What is the given standard regarding when you should or shouldn't
 use braces on a function.

[snip]

 Both work just fine. The manual includes examples of both methods. So
 which do most people consider the right way ?

I always use parens on function calls, I think it is more readable. 
Also, some syntax highlighters look for it.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] HELP: Nested include(...)'s take relative paths

2004-02-10 Thread Adam Bregenzer
On Tue, 2004-02-10 at 21:00, André Cerqueira wrote:
 If it was a function, parenteses would be mandatory hehe
 I prefer no parentheses on include/require/echo/print/..., cant justify 
 it with arguments though, its just the style i chose...
 
 What about:
   if (...) {
 ...
   }
 and:
   if (...)
   {
 ...
   }
 
 I prefer the second, but people find good reasons for each of them...

I'm anal about code formatting.  I always use parens with no space
before a function call, put a space before parens for builtin words (if,
while, etc), don't indent case phrases, move multiple arguments that go
over 80 characters to their own lines, and always use the former of the
above methods.  Of course, if I am modifying someone else's code I
*always* use the coding standards already in place.  The most important
thing is to be consistent.  Everybody has their own preference about how
using different coding styles increases or decreases readability, 
however I think what really improves readability is commenting, not
coding style.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] HELP: Nested include(...)'s take relative paths not intuitively

2004-02-10 Thread Adam Bregenzer
On Wed, 2004-02-11 at 19:36, John W. Holmes wrote:
 If you use echo, then you should use include().
 If you use print, then you should use include  .
 Unless you use echo(), then you should use include 
 and if you use print  , then you should use include().
 Unless you don't want to. :)

Heh, what if I use print('')? :P

Actually, I use echo(''), even though using single quotes doesn't give
me better performance I like to separate my strings and variables.

I enjoy using echo, it's like a rebellion against printf.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] julian date

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 00:32, adwinwijaya wrote:
 Hello php-general,
 
   I wonder is there any class/function in php to convert from dates
   (dd/mm/ hh:mm:ss) to Julian date ?
 
   (I also wonder why there is no Julian date function in php function
   libraries ... i think it is nice to have Julian date )

There are functions available that work with Julian dates, check the
calender section:
http://www.php.net/manual/en/ref.calendar.php

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] ftell ? fseek ? help, please

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 07:21, Anna Yamaguchi wrote:
 I would like to read first 224 bytes from a file A1, write them to another
 file, and then coming back to file A1 read bytes from 225 to the end of
 file.
 Could somebody help me with this? Please.

This is the traditional method:
// Open input file
$fh = fopen('some_file', 'rb');
// Read header
$header_data = fread($fh, 224);
// Open header output file
$ofh = fopen('some_other_file', 'wb');
// Write header
fwrite($ofh, $header_data);
// Get rest of file
do {
   $data = fread($fh, 8192);
   if (strlen($data) == 0) {
   break;
   }
   $contents .= $data;
} while (true);
fclose($fh);

If you know you want the entire file, you can always use
file_get_contents.  It may behoove you to check the file size first
before reading it entirely into memory:
if (filesize('some_file') = 1048576) {
$data = file_get_contents('some_file');
$header_data = substr($data, 0, 224);
$data = substr($data, 223);
}

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] triple DES encryption

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 12:36, craig wrote:
 Hi all,
 I have to replicate the file encryption of a desktop bound
 application. This means using triple DES, but I can't find 
 anything on the web or in the maunual (other than single 
 DES).

The mcrypt[1] module will do triple DES as well as stronger encryption
methods.  In the manual it is referred to as 3DES.

[1] http://www.php.net/mcrypt

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Can PHP redirects be detected?

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 14:31, Lowell Allen wrote:
 A recent thread on the WebDesign-L raised the question of whether search
 engines can detect (and penalize sites for) PHP redirects of the form:
 
 header(Location: http://www.whatever.com/;);
 
 I don't see how that could be the case, since the redirect occurs on the
 server before any HTML is output to the browser. Someone else says:

Technically the header function sends an HTTP reply to the client
(browser) with your Location header in the response.  The client then
initiates a second HTTP request with the new URL.  I remember reading
that apache[1] will look at Location: headers and if it can handle the
request it will process it and pass the output of the Location's URL to
the browser.  Regardless, the content will be cached by search engines
but the original URL used to initiate the process will be associated
with the content.  To have the redirected URL remembered you need to
pass a 301 Permanent Redirect status instead.

[1] I can not find this anywhere after a short search on Google, it
could be incorrect.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] HELP: Detecting the name of the file a function is being called from

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 23:17, Samuel Ventura wrote:
 what I need is to detect the name of the script
 from which I called the function, (test2.php) in this
 case. 
 
 For this application, it is not practical to pass an
 aditional parameter to the function specifying the
 caller, i need independence.
 
 Any ideas?

I don't think this is possible in php4.  The __FILE__ variable is a
constant that is always replaced with a string containing the name of
the file it is in.  Check out reflection[1] in php5 for an answer from
the future.

[1]
http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] [PHP5] Using exceptions to write more perfect software, but ...

2004-02-09 Thread Adam Bregenzer
On Mon, 2004-02-09 at 15:58, Markus Fischer wrote:
 But doing this now for every internal function call I don't want to
 lead my program into an unwanted state isn't very appealing.
snip
 I'm seeking for a more perfect programming model for application
 demanding that uncontrolled factors are limited to the max.
 
 Has anyone played around with PHP5 and thought about such issues?

I have been thinking about this myself.  When exceptions come they will
be interesting.  I almost went down the path you are considering but
decided that I would likely end up with an object hierarchy of the
system calls available in PHP.  This is something I very much did not
want to deal with.  I also played with creating wrapper functions that
are designed to test for a specific indication of failure (returns
false, returns null, etc.).  The problem there is the error reporting
must become more technical (ERROR: function mysql_query returned
NULL), or more useless (a function returned an error).  Plus, code
that uses this is harder to read.  Ultimately I decided to wrap my
necessary function calls in error checking wherever they are in my
files.  This gives me more granularity in the application of the error
at the cost of some code bloat.  It's not an optimal solution but I have
found I use little functions calls in the first place that would
generate an exception in return (memory errors are handled by PHP so
it's only functions that have system calls).  This has actually forced
me into creating libraries for what I use and abstracting out system
interfaces anyways.  Also, I have started using code generation for
handling the data side.

Ultimately I think it would be nice to have an object hierarchy of the
function calls in php.  However I don't see php supporting it natively
and PEAR is still trying to sort itself out.  Being a 'third party'
project it is too much for one person but would be quite useful.  Maybe
when php5 becomes more popular we can all band together and standardize
this.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] SESSION VARIABLES

2004-02-09 Thread Adam Bregenzer
On Tue, 2004-02-10 at 00:43, Ronald Ramos wrote:
 Hi All,
 
 I've created 3 sample scripts, pls see below.
 My problem is that page3.php can't display the value $username and
 $password
 Or is it because it the variables were not importe to that page, that's
 why
 $username and $password has no value? If it is, how can I import it?

You need to have session_start() at the top of the third script as
well.  Also you have a typo:
 echo #password;

should be:
echo $password;

Consider using $_SESSION[1] instead of session_register[2].

[1] http://www.php.net/reserved.variables#reserved.variables.session
[2] http://www.php.net/session_register

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: Can I do this?

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 03:18, John Taylor-Johnston wrote:
 Ah! A little experimenting ... Yes I can :) Answered my own question.
 
 include(http://elsewhere.com/list.php?number=$number;);

Careful with that.  If someone were to stumble upon your list.php script
they would be able to see your php code.  You would probably be better
off having a local copy of that file.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Revised: RE: [PHP] Re: Can I do this?

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 04:14, PHP Email List wrote:
 Ok so on this topic, I do something similar to this with my scripts, and if
 my includes are vulnerable... I need to know how?
 
 I have tested this and the includes parse the information as it includes it,
 I can't see the code, so how is this possible where you say:

Are you referring to including a file locally, or including a file from
a remote server via http?  From what I understand this thread is about
including a php script from a different server over http.  In this case
the php code will be viewable if you open it via a web browser.  If you
know of a way to include a file remotely with php, but not browse to it,
please let me know.  Presumably you could use apache to restrict access
to the file by ip, however that can still be subverted by a man in the
middle attack.  I would be curious to see an example where this method
of including a file would be necessary.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Revised: RE: [PHP] Re: Can I do this?

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 08:27, Andrew Séguin wrote:
 A test to confirm that, is to point the browser to the address being
 included. See the source? vulnerable. See the results? not vulnerable.

If you do not see 'source' then what are you including?  For example the
following script could be included remotely:

?php
echo EOF
?php
\$sql = SELECT * FROM table WHERE id = $number;
?
EOF;
?

If you were able to do include the above source with:
include(http://somewhere.com/file.php?number=123;);
You could include and see php code.  Not the original but something that
is still useful.  include() includes php code, if you can include a file
from a remote source you can view it with a browser.  What you say is
true:
See the source? vulnerable. See the results? not vulnerable.
Of course if you can not see it you also can not include it remotely.

As a side note it is safer to put includes outside the web path.  An
overflow or some other bug may be found that would bypass processing of
.php files (or a different bug could be exploited to write a .htaccess
file in that directory).  If you have the option to move includes to a
different directory it is more secure.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] $_POST trouble with html form

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 13:15, Paul Furman wrote:
 Why am I getting the error Undefined index: comment?
 
 It's probably a typo because I had something similar that worked.
 
 form action=?php include (ACTION_DIR./jpeg-comment.php); ? 
 method=post
  textarea name=comment ROWS=6 COLS=60
?php print $comments[$thumb_num] ?
  /textareabr
  input type=submit value=update annotation
 /form
  ?php
  echo $_POST[comment]; # this is just for debugging
  ?

You will not have access to the $_POST[comment] variable until the
form is submitted.  It looks like you are trying to access this when the
form is loaded.  Whatever action is echoed in the jpeg-comment.php
script is where you want to use you comment variable.

 Also perhaps related, when I call $_POST[comment] in the action file, 
 it gives me Forbidden You don't have permission to access...[error 
 message] but this is my own server at home. I'm quite unfamiliar with 
 forms (and new to PHP for that matter).

That looks like an access error from your web server.  Make sure the
directory this file is in is accessible from the web.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] mcrypt don't work.

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 05:18, [EMAIL PROTECTED] wrote:
 Hi all,
 I have problem with mcrypt function.
 There is always an error that I don't know how to correct this.
 This is my code:
 
 $string = Text string;
 $key= My key;
 $encrypted = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $string, MCRYPT_ENCRYPT);  
 echostringa cifrata= $encrypted;
 $key = My key;
 $string = mcrypt_cfb(MCRYPT_RIJNDAEL-256, $key, $encrypted, MCRYPT_DECRYPT);  
 echostringa decifrata= $string;

If you are using mycrypt 2.4.x you need to do something like this:
encrypt:
# initialize the encryption module
$mc_module = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '',
MCRYPT_MODE_ECB, '');
mcrypt_generic_init($mc_module, $encryption_key, $iv);

# encrypt the data
$encrypted_data = mcrypt_generic($mc_module, $data);

# de-initialize the encryption module
mcrypt_generic_deinit($mc_module);
mcrypt_module_close($mc_module);


decrypt:
# initialize the encryption module
$mc_module = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', 
MCRYPT_MODE_ECB, '');
mcrypt_generic_init($mc_module, $encryption_key, $iv);

# decrypt the data
$decrypted_data = mdecrypt_generic($mc_module, $encrypted_data);
# trim any trailing \0, encrypted data is automatically padded to a
32byte boundary with \0
$decrypted_data = rtrim($decrypted_data);

# de-initialize the encryption module
mcrypt_generic_deinit($mc_module);
mcrypt_module_close($mc_module);

Check the documentation[1] for more information on encryption keys and
initialization vectors.

[1] http://www.php.net/mcrypt

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] $_POST trouble with html form

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 13:32, Paul Furman wrote:
 No, it's not accessible from the web, it's in my protected php_library 
 outside public_html. Can't I execute a hidden script with a form?

no

 Should 
 I make a little php action file in public_html that includes the actual 
 file?

yes

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] $_POST trouble with html form

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 13:58, Paul Furman wrote:
 OK thanks, I made this:
 
 ?php
# jpeg-comment-public.php
   include (C:/_Paul/web/phplib/action/jpeg-comment.php);
 ?
 
 but now the hidden one isn't aware of any variables.
 
 Forbidden
 You don't have permission to access
 Notice: Undefined variable: thumb_num in 
 C:/_Paul/web/phplib/action/jpeg-comment.php on line 4

Where are these variables coming from?  The action in your form should
be a url that points to the script you want to process the form.  In
that script you access the form variables by $_POST['variable_name']. 
IE:

form.html:
form method=post action=process.php
input type=text name=comment /
/form

process.php:
?php
echo $_POST['comment'];
?

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] Revised: RE: [PHP] Re: Can I do this?

2004-02-08 Thread Adam Bregenzer
On Sun, 2004-02-08 at 18:23, PHP Email List wrote:
 I am going to be running some more tests, but so far all of the testing that
 I have done running a http request is parsing the include files. I have even
 checked a broswser based ftp request and nothing shows for the php file.
 I'd be interested in hearing about you testing one of these ideas you have
 and posting a link so that we can see what you are talking about is actually
 working.

I actually included a sample script in my last post.  I think this may
all be a communication problem.  The original php is not included, but
output is and there is nothing to prevent you from outputting php code
from a php script.  It was my understanding that this is what this
thread was originally about:

 ?php
 echo EOF
 ?php
 \$sql = SELECT * FROM table WHERE id = $number;
 ?
 EOF;
 ?

The bottom line is be careful with what you are including and where it
comes from.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Re: How can I run php 5 beta 3 on windows?

2004-02-07 Thread Adam Bregenzer
On Fri, 2004-02-06 at 18:47, omer katz wrote:
 Help!!!
 Omer Katz [EMAIL PROTECTED] 
 :[EMAIL PROTECTED]
  Can I update PHPTraid's php files?

I'm not sure I understand what you are having a problem with...

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] explode() an array and grep out a string

2004-02-07 Thread Adam Bregenzer
On Sat, 2004-02-07 at 03:09, Bobby R.Cox wrote:
 Is it possible to explode an array and have it exclude a certain 
 string.   I currently have an array that is an ldapsearch that returns 
 sub-accounts of a parent account. These accounts are then displayed so 
 customer can either change the passwd or delete them.Thing is 
 ldapsearch returns everymatch which includes the parent account, which 
 is already listed on the page as the parent account.  I would like to 
 eliminate the second listing of the parent account where the 
 sub-accounts are listed.

Try this:

$parent_account = 'parent_name';
$ldap_results = array('account1','account2','parent_name');
$results = array_diff($ldap_results, array($parent_account));

$results will now have only account1 and account2.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] include_once() isnt!

2004-02-07 Thread Adam Bregenzer
On Tue, 2004-02-03 at 17:04, Rob wrote:
 Ive programmed with C/C++ for years and have recently started to dabble in
 PHP. Ive written a multi-part script for a friend and Ive run into a
 problem.
snip
 Heres where the problem lies. Each component is in a separate file, and when
 I run the script, I get an arror saying I cant re-define the classes.
 Which makes me believe that the include_once() function is trying to include
 the other components even though they are already included. So, does that
 mean that include_once() only works right when it is used in the same file?
 It wont recognise that an include was already included in another include?
 Have I confused you yet? I am.

This is not an answer, but it is a solution.  I don't ever rely on
include_once.  If someone else uses my include files they may not use
include_once.  Instead I use the old C/C++ trick of defines:
?php
if (!defined('SOME_INCLUDE')) {
define('SOME_INCLUDE', TRUE);
// Place code here
}
?

I use the following structure for creating unique constants to prevent
collisions:
{projectname}_{classname}( include ? _INC:)

A global class outside my projects:
_CLASS_NAME

The class FooBar in my Rule The World project:
RULE_THE_WORLD_FOO_BAR

The config include in my Rule The World project:
RULE_THE_WORLD_CONFIG_INC


-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] refresh page (might be 0t)

2004-02-07 Thread Adam Bregenzer
On Sat, 2004-02-07 at 23:03, Ryan A wrote:
 Heres what I am doing:
 I give the client a control panel where he can add,edit and delete accounts,
 after each of the actions I have a link back to
 the index page of the contol panel...problem is, unless he presses the
 refresh button it shows him the same cached content.
 How do i force the browser to display the new updated accounts after and
 edit or the new list of accounts after a delete?

It sounds like you may want to set the page to not be cached.  Here's
what I use to prevent pages from being cached:

function noCacheHeaders() {
 header('Expires: Tue, 1 Jan 1980 12:00:00 GMT');
 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
 header('Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0, no-transform');
 header('Pragma: no-cache');
}

This should prevent proxies, browsers, etc from caching your pages.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] how to conver a string to float

2004-02-07 Thread Adam Bregenzer
On Sat, 2004-02-07 at 23:50, Michal Migurski wrote:
 Another possibility is to pipe the expression to bc, which could do the
 input check for you, and probably covers a lot of syntactic ground.
 Slightly less resource-efficient, but you don't have to reinvent the
 wheel (untested, unix only):
   $result = shell_exec(echo '${expr}' | bc);

Both eval and piping to bc via the shell work but open up big security
holes if you are not careful.  If you have bcmath or gmp enabled in php
I recommend looking at these functions:
http://www.php.net/manual/en/function.gmp-mul.php
http://www.php.net/manual/en/function.bcmul.php

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] CVS style project system

2004-02-06 Thread Adam Bregenzer
On Thu, 2004-02-05 at 20:21, [EMAIL PROTECTED] wrote:
 i have been asked to build a system for a project file space, where a
 list of users of different groups can start new projects for their
 group, add files for that project of the group and/or revise current
 files with different versions. It will be a cvs like system, but i
 dont think cvs would be apropriate for this, as they want to add
 titles to the project and comments etc. It will be database in Mysql.
 I was wondering how i could go about designing this system, and any
 ways to force people to sync up with the latest versions of the
 documents. Let me know thanks.

I know you don't want to hear someone say use cvs so...

Use viewcvs[1], or write your own version of it.  You can put a database
behind it, add descriptions to projects and/or folders to your database,
whatever you want on top of cvs.  You can even use cvsgrab[2] to
download a repository from a viewcvs site.  There is also cvsweb[3], if
you think perl is better than python.  If you need to significantly
extend the functionality of these possible solutions and you still want
to hack out some PHP code then use these as a base for designing
whatever you are looking for.  As a side note, cvsgraph[4] integrates
nicely with viewcvs, and if you do use viewcvs check out the querycvs
script.

The points I am trying to impress are:
1.) Writing your own version of cvs in PHP is a bigger deal than you
likely realize.  Even if you do not need every single possible feature
of cvs your project will probably grow and you may some day.
2.) The rcs format does a good job of maintaining version control and if
you use cvs you get all of its stability, future improvements, etc.
3.) There is a long history behind cvs.  It has accumulated a large
amount of supporting applications, helper scripts, mailing lists (of
which I am on btw), etc.  In short an entire community.  It would be
better for us all if you would join in and help yourself.
4.) Short of using webdav[5] as well as basic HTTP it is a poor
usability decision to design a file based revision control system with
its only interface being via HTTP.  What if people want to download
entire directories, etc.  You can make direct cvs access an
afterthought, but still a possibility.
5.) I am of the camp that thinks storing entire files in a database is a
bad thing.  Think of your filesystem as a database optimized for storing
files.

class new_wheel extends wheel  class new_wheel

Regards,
Adam

[1] http://viewcvs.sourceforge.net/
[2] http://cvsgrab.sourceforge.net/
[3] http://www.freebsd.org/projects/cvsweb.html
[4] http://www.akhphd.au.dk/~bertho/cvsgraph/
[5] http://www.webdav.org/

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] getting classname of current class

2004-02-06 Thread Adam Bregenzer
On Fri, 2004-02-06 at 08:29, Vivian Steller wrote:
 The problem is, that i want MyClass::getClassname() to return MyClass?!

I have the same problem:
http://marc.theaimsgroup.com/?l=php-generalm=107575408628272w=2

I continued discussion of this in the php internals list:
http://lists.php.net/article.php?group=php.internalsarticle=7520

What I have found so far is that it is impossible to get exactly what we
are looking for in php4.  When I get a moment again I want to renew the
discussion on the internals list and see if I can't get $this to be a
reference to a static instance of a class within static methods.
*crosses fingers*

Here is some sample code of what I use to get around this bug.  It's
leaky and imperfect, but it is inheritable.  Also, other than changing
the function name you can simply copy and paste the code into inherited
classes.  Also, while the extra parameter is there you would never call
the function with it in your code so the implementation is fairly clean.

class Foo { 
 function someFunc($class_name) {
  return $class_name;
 }
} 
class Bar extends Foo {
 function someFunc($class_name = NULL) {
  return parent::someFunc(isset($class_name) ? $class_name : __CLASS__);
 }
}

If you find a better solution *please* let me know.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Pspell Functions!! problem I explain in English

2004-02-06 Thread Adam Bregenzer
On Fri, 2004-02-06 at 08:51, Antonio J. Hdez. Blanco wrote: 
 But now run the script, says to me,
  Call undefined function pspell_config_create().

Reading the manual[1] on pspell I notice at the top it says this
function is not supported in windows.  However if you really do have a
pspell library for windows that somehow came with 4.3.3 and isn't
working with 4.3.4 you may be able to change your php.ini file to load
the extension[2] but I doubt it.

 PD: sorry mi english is not good :(

We may not speak many languages but the php manual does :)
http://www.php.net/manual/es/ref.pspell.php
http://www.php.net/manual/es/configuration.directives.php#ini.extension

Regards,
Adam

[1] http://www.php.net/manual/en/ref.pspell.php
[2]
http://www.php.net/manual/en/configuration.directives.php#ini.extension

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Undefined Index Errors

2004-02-06 Thread Adam Bregenzer
On Fri, 2004-02-06 at 10:51, Cameron B. Prince wrote:
 I'm creating some strings from array elements obviously. The issue is, the
 array elements don't always exist depending on which function you are
 running. And when they don't, the server log is full of undefined index
 errors. Is there a way I can avoid these errors without adding a
 if(isset(...)) around each one?

If you know which variables are required per 'function' that is being
called wrap an if around these variable declarations in blocks.  You
will still have ifs, but you should have a lot fewer.  If by function
you mean actual functions then you could move these lines to the top of
their respective functions.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Recommendation on PHP encoder please

2004-02-05 Thread Adam Bregenzer
On Thu, 2004-02-05 at 08:13, Harry Sufehmi wrote:
 So there's a reasonably easy way to decrypt those encoded files then ? (despite 
 those vendors' claim...)

There isn't a program to revert encoded files to their original state,
but there is a disassembler[1].  However, assuming your encryption key
is a string all one would need is to do strings filename on the
encoded php file to get your encryption key.

The real problem you are facing here is security through obscurity is
not security.  First of all, your method of encrypting these files and
decrypting them before serving up pages is just going to slow down your
web server.  The key is stored in a file somewhere and therefore easily
accessible if someone gained access comparable to the web server.  Since
the key is readily available the data is not really encrypted, just
obfuscated.

I assume you are not transmitting these pages over the Internet and even
within your intranet are using SSL?  If not then that is a much bigger
security hole.

If you are really dedicated to encrypting these files I have a possible
suggestion (see below for big caveats!).  Continue with your encryption,
however do not store the password anywhere on the server.   You could
either require the password be typed by users to view the pages (and
*don't* cache it in any way anywhere!) or write an extension to apache
(or whichever web server you use) to request the password when apache
starts.  It would then securely store it in ram and use it to decrypt
pages, similar to how encrypted SSL certificates are handled.  This
would not be a php based solution, if php were to have access to the
password then all that would be required to retrieve it would be the
ability to execute custom php on the system by the hacker.  You could
try writing a php extension that would handle this however you may have
a few problems:
1.) Depending on the web server used the php library's lifetime in
memory may be shorter than the web server, or there may be multiple
copies of the php library in ram.  This would require typing the
password more than once per web server restart.
2.) You need to make sure it is not possible to access arbitrary parts
of php's memory using documented or undocumented php functions, etc.  If
so a cracker could write a php script to obtain the password.
3.) You would need to disable the dl() function so a custom extension
could not be loaded to grab the password, though php.ini could be
modified and the web server restarted.  Then all the cracker would need
to do would be to wait for you to re-type the password.

Additionally make sure core dumps are disabled on the server, otherwise
forcing the web server to crash could put the password in the core file.

You know, after writing all that I realized something else:  these are
web pages being served.  If the attacker has root access to the system
what would prevent him from just using lynx to view the pages directly
form the web server?  SSL won't stop him/her and usernames and passwords
will most likely be available if you use web based authentication.  Your
best method would be to require the password be typed every time a page
is viewed, which has its own set of problems.

Hopefully this gives you something to think about.

Regards,
Adam

[1] http://www.derickrethans.nl/vld.php

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] PHP5: __call() implementation

2004-02-05 Thread Adam Bregenzer
On Thu, 2004-02-05 at 09:22, Vivian Steller wrote:
 i want this function simply call the method of another class with
 SomeClass::$method(...) but i'm getting into trouble (bit heavy
 programming!:) passing the arguments (stored as Array in $params) to the
 SomeClass::$method([arguments]) method...
 further, i think i'm getting problems with objects passed through the
 __call() method?!

You probably want to check out this for working with __call:
http://www.php.net/overload

And this for not having to use eval:
http://www.php.net/call_user_func_array

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



[PHP] php-general list question - [Fwd: Delivery Report (failure) for php-general@lists.php.net]

2004-02-05 Thread Adam Bregenzer
I get one of these for almost every message I send, usually with a delay
of a few days and always the same error.  I see my posts come from the
list to me and I see people replying to my messages so the list seems to
be processing my posts.  It's annoying however to keep getting these. 
Anybody else getting this?

-Forwarded Message-
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: Delivery Report (failure) for [EMAIL PROTECTED]
 Date: Thu, 05 Feb 2004 20:39:26 +
 
 This report relates to your message:
 Subject: [PHP] Retrieving class names in a static method,
   Message-ID: [EMAIL PROTECTED],
   To: [EMAIL PROTECTED]
 
 of Thu, 5 Feb 2004 20:39:20 +
 
 Your message was not delivered to:
   [EMAIL PROTECTED]
 for the following reason:
 Diagnostic was Unable to transfer, Message timed out
 Information Message timed out
 
 The Original Message follows:
 
 __
 Reporting-MTA: x400; mta dswu232-hme1 in /ADMD= /C=WW/
 Arrival-Date: Mon, 2 Feb 2004 20:37:36 +
 DSN-Gateway: dns; dswu232.btconnect.com
 X400-Conversion-Date: Thu, 5 Feb 2004 20:39:26 +
 X400-Content-Correlator: Subject: [PHP] Retrieving class names in a static method,
   Message-ID: [EMAIL PROTECTED],
   To: [EMAIL PROTECTED]
 Original-Envelope-Id: [/ADMD= /C=WW/;[EMAIL PROTECTED]
 X400-Content-Identifier: (091)PHP(093)...
 X400-Encoded-Info: ia5-text
 
 Original-Recipient: rfc822; [EMAIL PROTECTED]
 Final-Recipient: x400; /RFC-822=php-general(a)lists.php.net/ADMD= /C=WW/
 Action: failed
 Status: 4.4.7
 Diagnostic-Code: Reason 1 (Unable-To-Transfer); Diagnostic 5 (Maximum-Time-Expired)
 X400-Supplementary-Info: Message timed out
 X400-Originally-Specified-Recipient-Number: 1
 X400-Last-Trace: Mon, 2 Feb 2004 20:37:36 +
 
 __
 Received: from gateway.btopenworld.com (actually host 185.136.40.217.in-addr.arpa) 
 by dswu232 with SMTP-CUST (XT-PP) with ESMTP; Mon, 2 Feb 2004 20:37:36 +
 Received: from gateway (127.0.0.1) by gateway.btopenworld.com (Worldmail 1.3.167) 
 for [EMAIL PROTECTED]; 2 Feb 2004 20:47:18 +
 Delivery-Date: Mon, 2 Feb 2004 20:35:21 +
 Received: from pb1.pair.com (actually host 4.131.92.216.in-addr.arpa) by dswu194 
 with SMTP (XT-PP); Mon, 2 Feb 2004 20:35:17 +
 Received: (qmail 67282 invoked by uid 1010); 2 Feb 2004 20:34:44 -
 Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
 Precedence: bulk
 list-help: mailto:[EMAIL PROTECTED]
 list-unsubscribe: mailto:[EMAIL PROTECTED]
 list-post: mailto:[EMAIL PROTECTED]
 Delivered-To: mailing list [EMAIL PROTECTED]
 Received: (qmail 67259 invoked by uid 1010); 2 Feb 2004 20:34:44 -
 Delivered-To: [EMAIL PROTECTED]
 Delivered-To: [EMAIL PROTECTED]
 From: Adam Bregenzer [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Content-Type: text/plain
 Message-Id: [EMAIL PROTECTED]
 Mime-Version: 1.0
 X-Mailer: Ximian Evolution 1.4.5 
 Date: Mon, 02 Feb 2004 15:32:56 -0500
 Content-Transfer-Encoding: 7bit
 Subject: [PHP] Retrieving class names in a static method
-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/
Reporting-MTA: x400; mta dswu232-hme1 in /ADMD= /C=WW/
Arrival-Date: Mon, 2 Feb 2004 20:37:36 +
DSN-Gateway: dns; dswu232.btconnect.com
X400-Conversion-Date: Thu, 5 Feb 2004 20:39:26 +
X400-Content-Correlator: Subject: [PHP] Retrieving class names in a static method,
	Message-ID: 1075753976.29947.43.camel@arcon,
	To: [EMAIL PROTECTED]
Original-Envelope-Id: [/ADMD= /C=WW/;1075753976.29947.43.camel@arcon]
X400-Content-Identifier: (091)PHP(093)...
X400-Encoded-Info: ia5-text

Original-Recipient: rfc822; [EMAIL PROTECTED]
Final-Recipient: x400; /RFC-822=php-general(a)lists.php.net/ADMD= /C=WW/
Action: failed
Status: 4.4.7
Diagnostic-Code: Reason 1 (Unable-To-Transfer); Diagnostic 5 (Maximum-Time-Expired)
X400-Supplementary-Info: Message timed out
X400-Originally-Specified-Recipient-Number: 1
X400-Last-Trace: Mon, 2 Feb 2004 20:37:36 +

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

Re: [PHP] php-general list question - [Fwd: Delivery Report (failure) forphp-general@lists.php.net]

2004-02-05 Thread Adam Bregenzer
On Thu, 2004-02-05 at 17:50, Luke wrote:
 Me too, and im using the newsgroup, not even the mailing list!! :/

Hmm, that leads me to think this is a problem not related to php's mail
server at all.  (/me stops filling out a bug report)  I sent a message
to [EMAIL PROTECTED]  If I find a solution I'll update this
thread.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Running Apache in one machine and php in another

2004-02-05 Thread Adam Bregenzer
On Fri, 2004-02-06 at 14:55, Mrs. Geeta Thanu wrote:
  I feel the PHP script and the C program should be in one machine
 and apache in another.
 
 When a user click the link the php script should upload a form get the
 input and show the result.
 
 So apache should support running PHP in another machine.Is it possible.

The answer you are looking for is no.

The solution you are looking for is to have an interface from the
application on the powerful system doing these calculations to the web
server running php.  This could be as complicated as an extension to the
application doing all this processing, or as simple as an nfs share with
some flat files on it.

If you are going to put php on the system doing all this processing, why
not put apache as well?  If it's a security issue you could use squid as
a proxy or even have a php script on a public web server access the php
running on apache off the secondary server as your integration.  You
could use ssh to access a cli php script on the secondary server through
a php/cgi/etc. gateway on your public web server as well.

Good luck,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] php-general list question - [Fwd: Delivery Report (failure) forphp-general@lists.php.net]

2004-02-05 Thread Adam Bregenzer
On Thu, 2004-02-05 at 18:57, Chris W. Parker wrote:
 Yeah this list seems to be the worst when it comes to messages of this
 sort. I suggest you just get used to it. :)
 
 Also understand that EVERYONE else gets the same stuff. (At least I
 think everyone else gets them...)

What makes these messages unique is that they claim the list's posting
address was what failed.  I don't know why the list forwards e-mails so
that bounces come back to me instead of the list itself.  Anyways, this
list is not for discussion of list behaviorl

/me stretches tape across his mou..*grunt*

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Is there a PHP Style Sheet Switcher that doesn't reload

2004-02-04 Thread Adam Bregenzer
On Wed, 2004-02-04 at 04:47, Freedomware wrote:
 Hm... I haven't found Kumar's style sheet switcher post yet, but if 
 you say it can't be done, I'll take your word for it.

The problem here is your approach.  PHP can only be used to control the
content sent to browsers.  Once the browser receives the content PHP is
out of the picture until the next reload.  You have to use javascript or
some other client side language to change anything on a page once it is
loaded in the browser.  The referred to post describes this in detail.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Backslashing the [ and ] in a regex

2004-02-04 Thread Adam Bregenzer
On Wed, 2004-02-04 at 14:06, Sam Masiello wrote:
 $rule = ereg_replace([[:alpha:]+*/.|()$], 0, $rule) ;
 
 But if the user backslashes either a left or right bracket ([ or ]), I
 am having difficulty getting that extra backslash into the string.  I
 tried just adding the [ and ] characters to the line above between the
  and () characters, but that didn't work along with several other
 iterations of attempts to get it to work.
 
 Does anyone have any ideas?  I am stuck.

Try adding \\[\\]

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Extract of a Paragraph

2004-02-04 Thread Adam Bregenzer
On Wed, 2004-02-04 at 09:00, Daniel Perez Clavero wrote:
 To Extract the first 50 words, should I use str_word_count, and
 explode/implode or there´s another way, much simple.
 
 Any sample would be apreciated.
 Regards

Regular expressions should do the trick:
$extract = array();
preg_match('/^(\W*\w+){50}/', $paragraph, $extract);
$extract = array_shift($extract);

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



RE: [PHP] Backslashing the [ and ] in a regex

2004-02-04 Thread Adam Bregenzer
On Wed, 2004-02-04 at 16:35, Sam Masiello wrote:
 Thank you for the reply, Adam, but unfortunately it didn't work.

Sorry bout that.  Here's another shot at it.

If I understand your goal correctly you want to escape the existing
backslashes that proceed certain special characters (namely
[:alpha:]+*/.|()$).  That works fine so far,  but you want to add the
[ and ] characters to the list I am guessing.  Here is one way you could
do it:
$rule = ereg_replace([[:alpha:]+*/.|()$[\[], 0, $rule);

That turns this:
a\a\+\-\*\[\{\\|

into this:
a\\a\\+\-\\*\\[\{|

However, you will have a problem if there are double escaped characters,
or characters that are escaped but on in your list.  I suggest doing
this:
$rule = ereg_replace(, , $rule);

This turns this:
a\a\+\-\*\\a+\\-\\*\\a\\[\[\{\\{|\\|

into this:
a\\a\\+\\-\\*a+-*a[\\[\\{{||

which should back out nicely when handled by postgres.

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Session (maybe cookies)

2004-02-03 Thread Adam Bregenzer
On Tue, 2004-02-03 at 13:44, Rolf van de Krol wrote:
 I tried to start a session by this code:
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 http://www.w3.org/TR/html4/loose.dtd;
 html
 head
 titleUntitled Document/title
 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
 /head
 
 body
 ?php session_start();
 echo(session_id());
 ?
 /body
 /html


The session_start() function call needs to be at the top of the page,
before you send any html to the browser.

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



Re: [PHP] Problem setting include_path for virtual servers

2004-02-03 Thread Adam Bregenzer
On Tue, 2004-02-03 at 12:46, Pablo Gosse wrote:
 However when I call the following file under either domain:
 
 ?php
 echo get_include_path();
 ?
 
 I get this:
 
 .:/usr/local/lib/php

Are you sure you have the correct Options set for the directories that
those files are under?  Try setting:
AllowOverride All

for those directories in you apache config file.  See the following for
more information:
Apache 2.x:
http://httpd.apache.org/docs-2.0/mod/core.html#allowoverride
Apache 1.x:
http://httpd.apache.org/docs/mod/core.html#allowoverride

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



Re: [PHP] Sessions vs. MySQL records?

2004-02-03 Thread Adam Bregenzer
On Tue, 2004-02-03 at 11:05, Brian Dunning wrote:
 I have an application where I want users to only be allowed 5 searches 
 per day unless they create an account.
 
 There may not be a simple answer to this, but in general, would it be 
 preferred to do this with 24-hour session variables, or by writing a 
 MySQL record for each visitor with the date and their IP address and 
 tracking their usage count?

This is one of those tricky problems with web applications.  If you rely
on sessions then they can just delete the cookie and start over.  If you
use IP address than people can either disconnect and reconnect.  Or even
worse if someone gets an IP from their isp someone else already used on
your site then they won't be able to do even one search.  Lastly, If you
have them create a 'basic' account so you can track it they can just
create as many accounts as they want.

Armed with that knowledge I would suggest the following:
First of all, forget IP addresses.  They are not reliable enough to
assume that multiple requests from the same IP are the same person,
especially if you are targeting business customers.  Using a
non-authenticated session is an easy way to solve your problem, however
it will be *dead* simple to get around - switch browsers or delete your
cookies.  If your searches are relevant to each other (the second search
uses session information from the first search, etc.) then this may be
more useful since the only way around this is to destroy the session,
effectively starting over.  Lastly, using basic user accounts (just a
username, password, and e-mail) would be your best solution.  Granted
someone can create 50 yahoo accounts and sign up 50 times.  However, the
cost to them of creating those accounts, maintaining 50 accounts on your
site, and having to log-out and back in every 5 searches may be enough
to convince them to pay you instead.

Good Luck,
Adam

P.S.  Should you find a 'magic' bullet to the web authentication problem
please let all of us know!

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



Re: [PHP] Need to refine this:

2004-02-03 Thread Adam Bregenzer
On Wed, 2004-02-04 at 00:32, John Taylor-Johnston wrote:
 I cannot declare $temp = $mydata-district; outside while ($mydata so ... ?
 I'm missing something in my logic. That's why I asked.
 It wouldn't make sense to declare this twice:
 while ($mydata = mysql_fetch_object($myquery))

You could set the flag to null outside the loop, then check at the top
of your loop to see if the flag and district differ.  If so set the
flag, echo what you need, and move on.  The first time the loop runs the
flag will differ and you will set it to the first vale of district as
well as echo your district header, afterwords things will continue as
expected.  If you do not want to print out the district info the first
time the loop runs then you can set $mydata outside the loop, initialize
the flag variable, then use a do..while[1] loop to process the rest of
your data.

-Adam

[1] http://us2.php.net/manual/en/control-structures.do.while.php 

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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



Re: [PHP] Regular expression help?

2004-02-02 Thread Adam Bregenzer
On Mon, 2004-02-02 at 14:15, Jas wrote:
 I have tried this but its not working.

 !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}$,$_POST['mac'])
 
 so it should match 2 characters 0-9a-fA-F
 each block of 2 characters is followed by a : and repreated in 6
 blocks.

That's a long expression, try:
!preg_match('/^([0-9a-f]{2}($|:)){6}/i', $_POST['mac']);

This pattern finds 6 matches of a number or letter (the /i means
case-insensitive) followed by either a ':' or the end of the string.

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



[PHP] Retrieving class names in a static method

2004-02-02 Thread Adam Bregenzer
I'm looking for a way to find the class name of an object within a
static method.  class_name($this) works for instances, but in a static
method $this does not exist.  Also, __CLASS__ isn't inheritable so isn't
really a solution for what I am looking for.  Has anybody done this
before?

Here's a theoretical example:

class Foo {
 function getClassName() {
  // ???
 }
}
class Bar extends Foo {
}

echo Foo::getClassName();  // returns 'foo'
echo Bar::getClassName();  // returns 'bar'

One sample application of this would be a debugging method in a base
class that is inherited and used in a static method.

TIA,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]

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



  1   2   >