RE: [PHP] Opinions on Micro$oft .NET

2003-07-31 Thread Wendell Brown
On Thu, 31 Jul 2003 14:04:02 -0400, Dan Joseph wrote:

>Yeah, the framework does.  The free editor is for web apps, the Visual
>Studio is for normal apps.

FYI, I just had Visual Studio ordered for me - a single license for it
with a 1 year subscription to MSDN was over $2800!  I don't know yet
what the yearly cost is going to be.  To be able to put the generated
code on the net is going to require a Microsoft web server.  My
understanding is that there is supposed to be a seat on the license for
EVERY non-anonymous login that is provided users.

I've been looking (under duress) at moving from PHP to .net and have
played with Web Matrix (the free .net IDE).  It now supports VB.net and
C#.  Visual Studio supports those and more as well as allows for
Windows app development.  I'm a pretty good PHP programmer, and things
I could knock out in a couple of hours seem to be WAY more difficult to
do in .Net.  

For instance (and before anyone gripes that the following comparison is
unfair - I am not trying to do a comparison - merely offering a couple
of observations), I dragged a xml viewer component to the aspx work
area (this "generated" about 50 lines of code) and then pointed it at a
40 meg xml file. about 15 minutes later I got an "Out Of Memory"
error on the asp page and no usable output.  Using PHP, I opened a 100
meg xml file, read through the records checking each one using a perl
regular expression and it took it 21 seconds to return - no output (I
wanted it to just count the number of xml groups - >17,000 with 20-30
elements each).  I'm probably going to see what happens tomorrow if I
try to load the entire 100 meg xml file into a PHP array --- I expect
it to "just work" and deal with the memory.


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



Re: [PHP] Re: I'm really getting annoyed with PHP

2003-07-24 Thread Wendell Brown
On Thu, 24 Jul 2003 02:05:58 -0500, Wendell Brown wrote:

>Ok, I have a question.  Where is $_SESSION['valid_user'] getting set
>(or unset)???  

Oooops.  I thought that was the code that he was talking about.  I
missed your lead in.  Sorry!!!


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



Re: [PHP] Re: I'm really getting annoyed with PHP

2003-07-24 Thread Wendell Brown
On Wed, 23 Jul 2003 14:48:03 -0600, Kevin Stone wrote:

>Beauford, here's a login routine that I wrote using Sessions and Header
>redirects.  It is my interpretation of what you are trying to do.  I'm not
>saying this is the only way to do it but it works well for me.  Compare it
>to what you're doing to see if you're doing anything wrong.
>
>page-whatever.php
>session_start();
>$thispage = "http://www.yourdomain.com".$_SERVER['REQUEST_URI'];
>$_SESSION['return-to'] = $thispage;
>if($_SESSION['valid_user'] !== true)
>{
>// Access Denied!  Redirect to the login screen.
>header("Location: http://www.yourdomain.com/login.php";);
>exit;
>}

Ok, I have a question.  Where is $_SESSION['valid_user'] getting set
(or unset)???  

Have you checked to see if your IF statement at the top of the script
is working like you think it should be??  Try putting an echo in
instead of the header() call and see if you get the output you think
you should.

I suspect this isn't a "redirect isn't working" issue at all but a "the
if isn't working like I thought it would" issue.  :)


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



Re: [PHP] bcc on php

2003-07-17 Thread Wendell Brown
On Fri, 18 Jul 2003 08:30:24 +0800, Louie Miranda wrote:

>> A message that you sent contained a recipient address that was incorrectly
>> constructed:
>>  Bcc: [EMAIL PROTECTED]  missing or malformed local part (expected word or
>> "<")
>
>got this error..

Well, maybe your copy of php is expecting <> around the e-mail
address like this:

Bcc: <[EMAIL PROTECTED]>



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



Re: [PHP] bcc on php

2003-07-17 Thread Wendell Brown
On Thu, 17 Jul 2003 05:55:27 +, Curt Zirzow wrote:

>> Example 4. Sending complex email
>> http://www.php.net/manual/en/function.mail.php
>> 
>um.. don't use that example, it is the incorrect way to send a bcc. for
>one it wont work and two the people will see the bcc, defeating the
>purpose of a bcc.

Have you tried it?  I wrote a php script just last night that used this
format and it works like a champ!  If you do a search for bcc on that
page you will see that bcc is NOT handled by the MTA but by PHP.  I
have it bcc'ing to 3 or 4 people using a single header "Bcc: email,
email, email, email" and it bcc's to all with NO copy of the bcc'ed
folk in the header.

Now for the caveat this is php 3.0.?  For some reason the ISP
I'm using doesn't have php 4 set to run from the command line.  Why
would I care if it runs from the command line?  Because I have my
little script set up as a cron job, so it has to be command line.  :)


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



Re: [PHP] any danger in overwriting $_GET ?

2003-07-15 Thread Wendell Brown
On Tue, 15 Jul 2003 07:28:37 -0500, Wendell Brown wrote:

>If you are on Apache, you can use mod rewrite to do this for you with
>NO script changes.  I use this on a couple of sites, the /1/2 gets
>converted into "?vara=1&varb=2 in the call.  Neither the search engine
>nor the script can tell the difference.  :)

Check out this message for more info:

http://marc.theaimsgroup.com/?l=php-general&m=105370319925172&w=2


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



Re: [PHP] any danger in overwriting $_GET ?

2003-07-15 Thread Wendell Brown
On Tue, 15 Jul 2003 14:52:36 +1000, Justin French wrote:

>My *aim* was to port the expected values in the URL (/cooking/154) into 
>the $_GET superglobal array (eg $_GET['cat'] = 'cooking', $_GET['id'] = 
>154), resulting in:

If you are on Apache, you can use mod rewrite to do this for you with
NO script changes.  I use this on a couple of sites, the /1/2 gets
converted into "?vara=1&varb=2 in the call.  Neither the search engine
nor the script can tell the difference.  :)


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



Re: [PHP] /etc/passwd

2003-07-10 Thread Wendell Brown
>>  So how to make sure that no one can access other people files and
>>  server files? and is there any way that nobody would be able to
>>  download php files or how to make them look like code when they are
>>  downloaded. Thanks!

I think he means "How do I keep people who have access to upload their
OWN php scripts to my server from accessing files outside their
directory?"  :)

Check out the following:

> http://www.php.net/manual/en/features.safe-mode.php#ini.open-basedir

> http://www.php.net/manual/en/security.php
> http://www.php.net/manual/en/features.safe-mode.php#ini.safe-mode



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



Re: [PHP] Form being filled out automatically....

2003-07-09 Thread Wendell Brown
On Wed, 09 Jul 2003 13:23:59 +0100, David Otton wrote:

>On Wed, 09 Jul 2003 07:00:38 -0500, you wrote:
>
>>
>>if( ! isset( $HTTP_POST_VARS["EMail"] ) ) { 
>
>The obvious thing to do is change all instances of "EMail" to "emailaddress"
>or somesuch, and see if the problem still exists. Do you know anyone on AOL
>who isn't having the problem?

Hmmm...  I'll give that a try.  And to the best of my knowledge this is
the ONLY user having the problem.  I don't know for certain that others
are using AOL but I'm pretty sure they are and aren't having the
problem.

>Your guesses as to cause seem reasonable to me, but without an example of
>their browser to test against, you're working blind.
>
>>  
>
>Hmm... or maybe AOL is doing something wacky with onsubmit()?

Could be!



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



[PHP] Form being filled out automatically....

2003-07-09 Thread Wendell Brown
I've got a problem.  I have a form that the user fills out and then
hits submit on and it sends an e-mail.  My problem is that I have one
AOL user that claims that when ever he goes back to the form, it
doesn't present the form - it just sends the message.  It appears that
for some reason $HTTP_POST_VARS["EMAIL"] has a default value or it's a
cache issue.  Any ideas

Here is the psudo-code...  

if( ! isset( $HTTP_POST_VARS["EMail"] ) ) { 

  
  //  Rest of form stuff
   
} else {
  
 // send message here
 
}


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



Re: [PHP] Regular Expression

2003-07-08 Thread Wendell Brown
On Mon, 07 Jul 2003 21:59:23 -0700, Ralph Guzman wrote:

>I have a form where I have to check whether user is submitting a PO Box
>as an address. I wrote the following using eregi, but it returns true
>even when the field is not Po Box. How do I go about doing this
>properly?
>
>if(eregi("^Po Box$", $address)){
>  $error_message_custom = "You cannot use a PO BOX for Bill To Address";
>}

I think this would do better...

  if( preg_match( "/P[\. ]*O\.* +BOX/i", $address ) )

This will look for a "P" followed by a space, period or an "O" followed
by a period and/or one or more spaces and the word BOX.  It will also
ignore case.


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



RE: [PHP] web site security: how to hide login info for mysql-connection

2003-07-07 Thread Wendell Brown
On Mon, 7 Jul 2003 21:01:40 +0100 (BST), Graham Rule wrote:

>The only place that they are
>available is to PHP scripts run in the relevant directory. 

Which means that if a hacker finds a cross script hack in one of those
directories (ie, if you have a security hole in one of your php
scripts), then it would be possible to access mysql.default_user and
mysql.default_password via ini_get()... wouldn't it?  And yes, I
understand you could turn on safe_mode or turn off the ini_get()
function.

I think the answer is that there isn't a 100% secure way to store
user_id / passwords that can be reconstituted.  Unfortunately, I don't
know what the most secure way to do this would be.  Your way MAY be the
best that we can get, but it kinda give me the heebie jeebies.  :)


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



Re: [PHP] print html code

2003-07-03 Thread Wendell Brown
On Wed, 2 Jul 2003 14:23:23 -0700, Jim Lucas wrote:

>well, tell me.  What browser follows the standards 100% ??

I would bet that it would be easier to come up with a browser that
supports 100% of the HTML standard (which is IMHO the minimum the
browser HAS to support) than it would be to come up with a browser that
supports 100% of the nonstandard.  :)

As the old saying goes two wrongs don't make a right.


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



Re: [PHP] print html code

2003-07-02 Thread Wendell Brown
On Wed, 2 Jul 2003 19:40:37 +0200, Karina S wrote:

>I want to make a php site which can generate a html code and display it on
>the screen. (Display the code itself.)

See if this will do what you want:

> http://us2.php.net/manual/en/function.highlight-string.php

or

> http://us2.php.net/manual/en/function.highlight-file.php


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



Re: [PHP] OT (kinda): Mod_rewrite

2003-07-01 Thread Wendell Brown
On Tue, 01 Jul 2003 22:38:38 -0700, John wrote:

>When using mod_rewrite, is there any way to post variables from a form the
>way you want to.
>
>eg 
>a text box called first name
>another textbox called second name
>action being http://www.searcher.com/search
>
>and the result being
>http://www.searcher/search/firstname/secondname
>
>is this possible?? i dont think so

E... I'm not totally sure I understand what you are asking for, but
I do know the following should work:

1)  Create a index.php file in the /search/ directory that expects two
"GET" parameters.

2)  Set up the following mod_rewrite:

RewriteRule   /search/([^/]+)/(.+) 
/www/htdocs/search/index.php?First=$1&Last=$2

Should allow this:

> http://www.searcher.com/search/firstname/secondname

to call index.php as:

> http://www.searcher/search/index.php?First=firstname&Second=secondname

Hope this helps.


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



Re: [PHP] file pointer

2003-07-01 Thread Wendell Brown
On Tue, 01 Jul 2003 10:59:53 -0500, Kyle Babich wrote:

>How would I set the file pointer to the very end of the last line of the
>file?

Assuming you are trying to append to the file you can do the following
(open output append):

  $fHandle = fopen( "file.txt", "a" );

or you can fopen the file in read mode (or whatever) and then do an
fseek...

  $fHandle = fopen( "file.txt", "r" );
  fseek( $fHandle, 0, SEEK_END );


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



RE: [PHP] web site security: how to hide login info for mysql-connection

2003-06-30 Thread Wendell Brown
On Mon, 30 Jun 2003 13:50:21 -0600, Peter Janett wrote:

>My concern is that a shell emulating PHP or
>Perl script run as Apache can read or copy ANY PHP script used with PHP as
>an Apache module.

It seems to me like the safest way to handle this would be to create a
function that opens the database (with the user_id and password hard
coded) and returns a handle to the open db.  Then put this function
into a "include" directory outside the document root (you might have to
disable fopen_with_path).

function openDB() {

  $MYSQL_Server   = "localhost";
  $MYSQL_DB   = "db";
  $MYSQL_User = "user";
  $MYSQL_Password = "password";

  // Connect to database
  $dbID = mysql_connect($MYSQL_Server, $MYSQL_User, $MYSQL_Password)
  or die("Could not connect");

  mysql_select_db( $MYSQL_DB )
  or die("Could not select database");

  return( $dbID );
}

Then call openDB() from your module



Comments??


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



RE: [PHP] web site security: how to hide login info for mysql-connection

2003-06-30 Thread Wendell Brown
On Mon, 30 Jun 2003 13:50:21 -0600, Peter Janett wrote:

>
>   php_value mysql.default_user fred
>   php_value mysql.default_password secret
>   php_value mysql.default_host server.example.com
>

H what about phpinfo()?  It shows those settings in the clear.


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



Re: [PHP] time calcs

2003-06-30 Thread Wendell Brown
On Mon, 30 Jun 2003 07:31:59 -0500, Wendell Brown wrote:

>On Sun, 29 Jun 2003 15:19:56 -0400, Larry R. Sieting wrote:
>
>>I want to output the difference as a difference expressed in time 
>>format:  10:05:23 - 09:45:32 = 00:39:51
>
>Try this:
>
>
>$tot_time = ($data['end_time'] - $data['start_time']);
>
>echo strftime( "%H:%M:%S", $end_time ) . " - ";
>echo strftime( "%H:%M:%S", $start_time ) . " = ";
>echo gmstrftime( "%H:%M:%S", $tot_time );
>
>?>

E I used the wrong variables in the previous message.  I also
assumed that the start and end times are actually TIME and not strings
(which appears to be the case since you are subtracting one from the
other).  If the start and end AREN'T time types you would have to
convert them first.  You should be able to use 'strtotime' or mktime to
convert them to time type.

Also, the gmstrtime used above would limit the time to 24 hours.  If
there is a possibility that the difference in time might be more than
24 hours you can do something like this:

  printf( "%d days %s",  (int)($tot_time / 86400),   gmstrftime(
"%H:%M:%S", $tot_time ) );

So, here is what I probably should have posted:





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



Re: [PHP] Re: Speed up MySQL

2003-06-27 Thread Wendell Brown
On Fri, 27 Jun 2003 15:05:29 -0500, Erich Kolb wrote:

>I am already running MySQL 4, how would I go about adding indexes?

http://www.mysql.com/doc/en/CREATE_INDEX.html


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



Re: [PHP] Trouble reading POST data that is not associated with a value.

2003-06-27 Thread Wendell Brown
On Fri, 27 Jun 2003 21:21:34 +0200, Marcus Akre wrote:

>However the $_SERVER["CONTENT_LENGTH"] is between 300 and 400 bytes. The
>data is there, but how can i access it?

Maybe, $_SERVER["HTTP_RAW_POST_DATA"]




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



Re: [PHP] limiting functions

2003-06-26 Thread Wendell Brown
On Thu, 26 Jun 2003 06:10:48 -0500, Daryl Meese wrote:

>A quick thought -- It would be nice if we had a "authorization code" in the

What about "Safe Mode"?  It looks like it can be configured 

> http://us3.php.net/manual/en/features.safe-mode.php#ini.safe-mode

Between safe_mode_include_dir and safe_mode_exec_dir it seems you
should be able to get something pretty safe set up.


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



Re: [PHP] WEB HOST NEEDED!!!!!

2003-06-24 Thread Wendell Brown
On Tue, 24 Jun 2003 14:09:30 +0200, Denis 'Alpheus' Cahuk wrote:

>It should be TOTALY FREE!

I've got you covered.  I will happily offer all of the items you
request.  No advertising or anything, full php, front page, mysql, 500
Meg disk space.

I do charge $500 per month if you want upload privileges, a login and
in your case the necessary monthly application of Troll-Be-Gone




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



Re: [PHP] preg_replace problem

2003-06-24 Thread Wendell Brown
On Tue, 17 Jun 2003 07:25:00 -0400, Vincent Bouret wrote:

>I want "A dog jumped over a ladder" to become "A dog jumped over
>a ladder".

How about this...

$str = "A dog jumped over a ladder";

$str = preg_replace( "/(^| )(a)( |$)/i", "$1$2$3", str );


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



[PHP] Re: Search Engines and Last-Modified Header

2003-06-23 Thread Wendell Brown
On Wed, 28 May 2003 10:23:22 -0500, Wendell Brown wrote:

>To force all of the pages (both pseudo-static and dynamic) to generate
>a "Last-Modified" header, I set up prepend.php script which is
>configured as a directory level (.htaccess) parm to auto_prepend_file.

As appears to be the usual case with php, I have found that I was doing
things the HARD way.  While an auto_prepend will work, there is a
Apache specific ini setting that will turn on automatic generation of
the Last-Modified AND ETAG headers!  If you change the default value
for "last_modified" to on in your php.in or add the following to your
.htaccess file, php will generate both a default Last-Modified header
AND an ETAG:

php_flag last_modified on

Anyone care to comment on whether or not there is a down side to having
an etag on a dynamic page related to search engines (or caches for that
matter)

Here is the link - NOTE that the docs do NOT mention the ETAG, but my
testing is that this ini change also enables that functionality as
well!

http://us3.php.net/manual/en/ref.apache.php



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



[PHP] Cool use for gmstrftime...

2003-06-23 Thread Wendell Brown
How many times have you manually calculated the hours, minutes and
seconds between two dates?  I was doing that again (for the million'th
and one times) and thought there should be a different way to do
this  Here is what I came up with (I don't know if it's more
efficient than the old stand by's or not, but it is different).  




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



Re: [PHP] ErrorDocument doesn't work for PHP scripts

2003-06-20 Thread Wendell Brown
On Fri, 20 Jun 2003 10:34:04 -0500, Wendell Brown wrote:

>>> php_value auto_prepend_file header.php
>>> php_value auto_append_file footer.php

Andy, I've tried the following (with my server info, of course) in one
of my directories and it works like a champ!  It doesn't matter if it's
php, htm or html!

- .htaccess --

AddType application/x-httpd-php .html
php_value auto_prepend_file
"/spool/web/www.jeamland.org/html/header.php"
php_value auto_append_file 
"/spool/web/www.jeamland.org/html/footer.php"

ErrorDocument 404 http://www.jeamland.org/_error.html


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



Re: [PHP] ErrorDocument doesn't work for PHP scripts

2003-06-20 Thread Wendell Brown
On Fri, 20 Jun 2003 10:15:43 -0500, Wendell Brown wrote:

>Try it without the:
>
>>  php_value auto_prepend_file header.php
>>  php_value auto_append_file footer.php

Or check for the existence of the requested file in the header and if
not found, send the 302 header with a forward to your custom page.  

If you don't know what the header is supposed to look like, grab a copy
of SamSpade (http://www.samspade.org/ssw/) and use it to view the
headers of a page that is forwarding correctly.  BTW, it's FREE




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



Re: [PHP] ErrorDocument doesn't work for PHP scripts

2003-06-20 Thread Wendell Brown
On Fri, 20 Jun 2003 15:08:39 GMT, [EMAIL PROTECTED] wrote:

>   
>   AddType application/x-httpd-php .html
>   php_value include_path ".:/spool/web/www.jeamland.org/lib"
>   php_value auto_prepend_file header.php
>   php_value auto_append_file footer.php
>   

Just a guess, but... you always have a file in that directory. It looks
somehting like this:


...FILE_NOT_FOUND


Try it without the:

>   php_value auto_prepend_file header.php
>   php_value auto_append_file footer.php


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



Re: [PHP] Redirects in PHP

2003-06-13 Thread Wendell Brown
On Fri, 13 Jun 2003 10:54:39 -0600, Kevin Stone wrote:

>Javascript.. bah humbug.  :)
>
>Carl, you can avoid these issues by using output buffering allowing you to
>call header() whever you want in your script.

But he doesn't get to see the printed info - so it's basically the same
difference.  I think either JavaScipt is probably the solution

I have also found reference to the following:

 

It is supposed to do what is wanted but it's not W3C standard.



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



Re: [PHP] Redirects in PHP

2003-06-13 Thread Wendell Brown
On Fri, 13 Jun 2003 12:22:44 -0400, Carl Furst wrote:

>How do you do this?

Use JavaScript.  :)


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



Re: [PHP] Easier way to delete all entries in an array?

2003-06-12 Thread Wendell Brown
On Thu, 12 Jun 2003 10:13:10 -0400, James E Hicks III wrote:

>There's got to be an easier way, is there?
>
>for ($i=0; $i < count($the_array); $i++){
>   array_pop($the_array);
>}

Maybe this:

unset( $the_array );




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



Re: [PHP] String manipulation

2003-06-11 Thread Wendell Brown
On Wed, 11 Jun 2003 14:53:13 +0100, Marios Adamantopoulos wrote:

>[link][title]the link[/title][address]http://www.php.net[/address][/link]
>And I need to change it to this:
>http://www.php.net";>the link 

E, fun try this :)

http://www.php.net[/address][/link]';

$out = preg_replace( 
  "|\[link\]\[title\]([^\[]*)\[/title\]\[address\]([^\[]*)\[/address\]\[/link\]|i", 
  "$1", 
  $in );

echo "$in$out"
  
?>



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



Re: [PHP] Generate PHP using PERL???

2003-06-10 Thread Wendell Brown
On Tue, 10 Jun 2003 12:05:32 -0500, Todd Snyder wrote:

>My hope is that their is some directive that I can output at the start that will 
>invoke the PHP interpreter so that my output will
>be run as a PHP script rather than just HTML.

Generally speaking a script will be interpreted by one or the other. 
I'm pretty sure that if you generate perl code from a perl script, the
interpreter doesn't run on the generated output - it's output.  I can't
say for certain that simply generating php output from a perl script
can't be made to work, but I'm almost certain that it isn't intended
to.  

I would however think that it would be possible to generate the php
output to a file and then do a header forward from perl to that file or
possibly execute the php interpreter from the command line and pass it
the php file as input.


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



Re: [PHP] Please help

2003-06-10 Thread Wendell Brown
On Tue, 10 Jun 2003 21:14:52 +1000, Ben Houlton wrote:

>I've tried this code on a web server and it worked, but on my localhost server it did 
>not work. It just looped the "ADD RECORD" text (not including database infomation).
>My code is below:
>
>
>
>
>
>$register_globals;

It sounds like you have register_globals turned on on the "web server"
but off on the "localhost server".  The $register_globals line in your
code above does absolutely nothing.  I would recommend searching this
list for solutions.  To see for sure what the status of
register_globals is look at phpinfo() or simply cut and paste the code
below to phpinfo.php and run it.

-phpinfo.php-



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



[PHP] Cook Book Script

2003-06-09 Thread Wendell Brown
I'm looking for a cook book script.  I've googled for it, looked in
php.resourceindex.com and hotscripts but I haven't found one that does
what I'm looking for.  Here's what I'm shooting for.  

1) User ID registration - need to be able to have users "own" recipes
and cookbooks.

2) Allow users to add recipes - moderator CAN choose to make the recipe
public

3) Users can add categories (with moderator approval)

4) Users can create "cookbooks" by selecting recipes from either (or
both) their own and "public" recipes.  A "title" for the cookbook with
some basic info about it would be nice.

In a perfect world, it would allow for an external url where the user
could point people to their cookbook.  They would only see that
cookbook's recipes and PLEASE allow it to be printed (using PDF???).

Maybe even allow the cookbook owner to select a "template" to control
how it will look both on the screen and printed


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



RE: [PHP] Automatic Headers and Footers

2003-06-09 Thread Wendell Brown
On Mon, 9 Jun 2003 07:21:45 -0500, Jay Blanchard wrote:

>I see what you are saying, but how much modification is too much? :) 
>
>OK, another waythe HTML could be read into a page (fopen())
>containing the header/footer stuff. You'd have to deal with
>identification of which page you want loaded, but shouldn't be too hard.

Here is what I ended up doing

http://marc.theaimsgroup.com/?l=php-general&m=105484835424858&w=2


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



Re: [PHP] $PHP_AUTH_USER question...

2003-06-09 Thread Wendell Brown
On Fri, 6 Jun 2003 11:36:51 +0100, [EMAIL PROTECTED]
wrote:

>How can I get that to talk to $PHP_AUTH_USER?

I'm not sure this is exactly what you want (actually, I'm pretty sure
this is coming at it from the opposite end), but here is a way I used
it for a very simple / low security situation.

I set up the index.php to check for $_SERVER["PHP_AUTH_USER"]
(actually, I started out just using $PHP_AUTH_USER with RegisterGlobals
on, but I figured out that it could be inserted via the get method and
totally defeat my "security") where I wanted to add links that only
administrators have access to.  I also check for it at the top of the
admin only modules.  This way a normal user might see a list of items
with "Details" buttons next to them, but admins would see those buttons
and "Edit" buttons.  Edit would also check to see if the variable was
set.

At the bottom of the main page I have a link to login.php.  This is
simply a redirect back the index.php but I have that file listed in the
.htaccess file as password protected.  Once the login.php file has been
password checked, all of the programs from that directory down inherit
the $_SERVER["PHP_AUTH_USER"] value.

Here is the .htaccess file I used:


AuthType Basic
AuthUserFile /www/sbudir/.htpasswd
AuthName MyAuthName
Require valid-user


Here is the login.php file

http://www.mydomain.com/subdir/";); 
?>

And in my index.php I have lines similar to the following:

Details
  Edit";
}
  ?>




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



Re: [PHP] Automatic Headers and Footers

2003-06-06 Thread Wendell Brown
On Thu, 05 Jun 2003 16:41:01 -0400, Tom Ray [Lists] wrote:

>First, I would drop a .htaccess file that allows the HTML files to run 
>through the PHP parser. Like this AddType application/x-httpd-php .php .html
>
>-h1--/h1-

Yeah, that would work but my goal was to not have to modify the html
files at all.  Actually, I figured it out (or at least have it
working).  I guess I knew it was possible, but I was hoping for a
miracle cure like "add_html_header".  :)  Anyway, here is what I ended
up doing...

.htaccess
AddType application/x-httpd-php .htm .html
php_value auto_prepend_file "header.php"
php_value auto_append_file  "footer.php"

header.php



footer.php

This is a page header";
  $footer = "This is the footer\n";

  $content = preg_replace( "/(]*>)/i", "$1$header", $content );
  $content = preg_replace( "/(<\/body[^>]*>)/i", "$footer$1", $content
);

  echo $content;
?>

Any other ideas or simpler ways to do it would be appreciated.  


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



[PHP] Automatic Headers and Footers

2003-06-06 Thread Wendell Brown
Ok guys, I think I have a challenge for you (actually, I don't think
this can be done, but I've been proven wrong every time I've made that
assumption with php in the past, so I'll ask anyway).  Here's the
question:

Is there a way to have php insert headers and/or footers into all of
the html files in a given directory on the fly (not actually modifying
the files)?  And by this I mean take an existing valid HTML file and
add headers and footers and end up with a valid HTML file.

Now, before some of you get trigger happy and tell me to read the
manual and point me to things like .htaccess, auto_prepend_file, google
and the like, think about what I'm really asking  It needs to
insert the header after the -body- tag and put the footer in before the
-/body- tag.  It needs to do this without modifications to the HTML
file.  

And yes, I understand that by default HTML files aren't going to be
effected by the auto_prepend_file (since they aren't php files) - so it
will require adding HTML to the list of php parsed file types.

For instance, the goal would be to take the following code:

-HTML-
-Head-
-Title-This is a test-Title-
-body-

Well, did it work?

-/body-
-/html-

and convert it to this:

-HTML-
-Head-
-Title-This is a test-Title-
-body-
-h1-This is a page header-/h1-

Well, did it work?

-h3-This is the footer-/h3-
-/body-
-/html-

Can it be done?  I don't think so, but I leave it up to your wiles to
suggest a solution

Thanks!!!


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



Re: [PHP] Advice on script length please!

2003-06-06 Thread Wendell Brown
On Thu, 5 Jun 2003 10:25:01 +0100, Bix wrote:

>My file is currently 1200 lines long and consist of 450 lines of case
>statements and then the rest are functions.

Obviously there are ways to optimize the code for speed.  However, as
with many optimizations, there are trade offs...  One way to do away
with the 450 lines of case would be to use a BUNCH of include modules. 
For instance:



What this means is that you would need a "Function" file for each
option in your directory with only the code for that function.  It
would be included when the "Opt" function matched.  Of course, you
would need to either see if the file exists or catch the error if it
doesn't but you just compressed 450 lines of case into 2 lines.  You
also probably compressed 2200 lines down to about 120 or so lines (3
lines for the driver, 80 for the standard includes and another 20-40
for the main function).

The down side to this is that you have to have 100+ php files that you
will have to maintain separately.


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



Re: [PHP] Re: Using register_globals

2003-06-05 Thread Wendell Brown
On Thu, 5 Jun 2003 02:10:32 +0800, Jason Wong wrote:

>In case 1, a malicious person can bypass your password checks by passing 
>admin=1 in the URL.

Actually, I set up a very similar user security system by taking
advantage of the $PHP_AUTH_USER variable.  

I would check to see if the variable was set and if so, the user was an
"administrator" and could get to additional stuff.  To get apache to
set the variable and pass it to me, I added a "login.php" and a
matching .htaccess mod to force login.php to require authentication.

It worked like a champ!  Unfortunately, it also worked to add
"?PHP_AUTH_USER=1" to the calling script.  A simple change to use
$_SERVER['PHP_AUTH_USER'] GREATLY enhanced the security!  

Can it still be hacked?  Probably.  Is it more secure?  Absolutely!


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



Re: [PHP] setting up a cron job for a PHP script

2003-06-04 Thread Wendell Brown
On Tue, 03 Jun 2003 12:59:41 -0500, Tim Thorburn wrote:

>is it possible to have a PHP script execute on command from a cron 
>tab?  

Absolutely!

>And if so, could someone proide an example of say having the script 
>run on the first of every month?

It should look something like this. 

0 0 1 * * php -f/update_arkie_net.php

Minutes (0) -- Hours (0) -- Day (1) -- Month (*) -- DayOfWeek (*)


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



Re: [PHP] OK guys, thank you so far

2003-06-04 Thread Wendell Brown
On Tue, 3 Jun 2003 19:16:30 +0200, +ystein H†land wrote:

>Now my code is
>
>extract ($_GET);
>if ($_GET['printout'] != "yeah") { include("header.php"); }
>
>but I still get the following error:
>
>Undefined index: printout
>
>I understand nothing

Ok, it looks like you are mixing your metaphors ;)

If you use extract( $_GET ); -- you should have a $printout variable
available (assuming you aren't doing a POST form and you are on a
version of PHP that supports $_GET).  At least two of the following
should work...

--- Option 1 --- GET method - New PHP
 
extract($_GET);
if ($printout != "yeah") { include("header.php"); }

--- Option 2 --- POST method - New PHP 

extract($_POST);
if ($printout != "yeah") { include("header.php"); }

--- Option 3 --- GET method - Older PHP

extract($HTTP_GET_VARS);
if ($printout != "yeah") { include("header.php"); }

--- Option 4 --- POST method - Older PHP

extract($HTTP_POST_VARS);
if ($printout != "yeah") { include("header.php"); }

--- Option 5 --- GET method - new php - No extract

if ( $_GET[ 'printout' ] != "yeah") { include("header.php"); }

--- Option 6 --- POST method - new php - No extract

if ( $_POST[ 'printout' ] != "yeah") { include("header.php"); }

--- Option 7 --- GET method - older php - No extract

if ( $HTTP_GET_VARS[ 'printout' ] != "yeah") { include("header.php"); }

--- Option 8 --- POST method - older php - No extract

if ( $HTTP_POST_VARS[ 'printout' ] != "yeah") { include("header.php");
}

 End ---




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



Re: [PHP] Automatically include global file ...

2003-06-04 Thread Wendell Brown
On Tue, 3 Jun 2003 18:41:59 +0200, Wouter van Vliet wrote:

>I've heard something about the possibility to set an option somewhere that
>will include a file to each php file requested... but I can't find it..

It's an ini setting (auto_prepend_file).  Check here:

http://us4.php.net/ini_set

It can be set in the php.ini (or on Apache at least) in the .htaccess
as follows:

php_value  auto_prepend_file  "/www/extract_post.php"


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



Re: [PHP] howto set an address for a image

2003-06-03 Thread Wendell Brown
On Mon, 2 Jun 2003 17:07:17 +0200, Ferhat BINGOL wrote:

>I wan to do something like that, I saw some sites do but how?
>I wanto code in HTML like that
>http://www.myserver.com/image.php?id=12321>
>so it will go and that the image like the id and display it in html..

Are you intending to create an image with the php, redirect to an
existing image or simply create a link in the HTML to an existing
image?

If you intend to create an image (which the code above appears to
suggest) you might want to check out the info on the image functions
(http://us4.php.net/manual/en/ref.image.php).

If you intend to do a redirect to an existing image, you might be able
to simply return the following (untested, but I think it should work -
at least with reasonably new browsers):

http://www.myserver.com/image/"; . $_GET["id"] .
".gif");
exit;
?>

Of course you could also generate the "" tag via php.  Then
instead of:

http://www.myserver.com/image.php?id=12321>

you would have

http://www.myserver.com/' . $image . '.gif">';
?>


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



Re: [PHP] Making a PHP Script "Very" Cache Friendly

2003-06-02 Thread Wendell Brown
On Mon, 02 Jun 2003 02:38:51 -0400, Gerard Samuel wrote:

>For the life of me, according to the output of ethereal (a network 
>sniffer), this file is always fetched from the server.

Have you looked at what is actually coming out in the headers?  If not,
grab a copy of Sam Spade for windows (http://www.samspade.org/ssw/). 
It will let you see the actual headers the browser (and cache) sees. 

Here is what it shows on one of my php sites:

HTTP/1.1 200 OK 
Date: Mon, 02 Jun 2003 13:16:39 GMT 
Server: Apache/1.3.27 (Unix) PHP/4.2.3 
Cache-Control: max-age=86400 
Expires: Tue, 03 Jun 2003 13:16:39 GMT 
Last-Modified: Fri, 30 May 2003 16:33:19 GMT 
Connection: close 
Transfer-Encoding: chunked 
Content-Type: text/html 

Some of these headers (Cache-Control for instance) are configured in my
.htaccess file but others are manually sent using header("");


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



Re: [PHP] Date question

2003-05-30 Thread Wendell Brown
On Thu, 29 May 2003 15:40:00 +0100, Shaun wrote:

>of course ;)
>
>but  i couldn't find a reference to this particular problem...

I don't think you are going to find a standard PHP function to do this.
 You are going to have to do something like this (I haven't tried it
but I think it will do what you want):

// Get a starting time
$d = strtotime( "12/31/2003" );

// Get the date of the Sunday on/or before that date

$s = strtotime( "-" . date("w", $d) . " days", $d );


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



RE: [PHP] Variables don't pass... *sniff*

2003-05-30 Thread Wendell Brown
On Thu, 29 May 2003 07:21:01 -0700 (Pacific Standard Time), Rasmus
Lerdorf wrote:

>It isn't a pointer.  It is a reference which you should think of as a
>symbol table alias.  A pointer, at least by my definition, is a memory
>address.  In PHP it isn't a memory address, just another entry in the
>symbol table that references the same data as another symbol.

I understood the logical distinction, I guess I should have said "most
of the benefits of a pointer without many of the potential headaches".

Pointers in C are REAL memory addresses, HOWEVER, in many (if not most)
situations they are used as symbol table aliases.  It's when they
AREN'T carefully used this way that memory overwrites happen.

As I said, most of the good without most of the bad.  :)


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



RE: [PHP] Variables don't pass... *sniff*

2003-05-30 Thread Wendell Brown
On Thu, 29 May 2003 10:33:16 +0100, Ford, Mike   [LSS]
wrote:

>Well, how about references, then?  (And me, personally, I'd use isset()
>rather than is_array().)
>
>   if (isset($_POST)):
>  $POST = &$_POST;
>   else:
>  $POST = &$HTTP_POST_VARS;
>   endif;

I was told that PHP didn't do pointers - just goes to show that you
can't believe everything your told.  Thanks for the POINTER. ;)


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



Re: [PHP] Jpgraph troubles

2003-05-29 Thread Wendell Brown
On Wed, 28 May 2003 19:00:20 +0100, Jordan Elver wrote:

>I can't get it to display. It just shows the broken image icon.

I assume you are sending something similar to the following before the
actual pic?

header("content-type: image/png");

I have a script set up on my page that demonstrates using GD directly
(at least I think jpgraph uses GD):

http://www.arkie.net/~scripts/thermometer/


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



[PHP] PHP Rocks! ..OT..

2003-05-29 Thread Wendell Brown
I had completely forgotten how much more hassel CGI / Perl is when
compared to PHP.  I just got done doing a MINOR mod to a Perl script
(it took me about 4 hours compared to what would have taken me about 10
minutes in PHP) and I just want to say THANK YOU to all the PHP
developers!  :)


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



[PHP] Search Engines and Last-Modified Header (was: Variables don't pass...)

2003-05-29 Thread Wendell Brown
On Wed, 28 May 2003 09:31:11 -0500, Jay Blanchard wrote:

>I wouldn't go as far as using the auto_prepend_file.

Neither would I in this case Jay.It was simply an example of what
could be done, not necessarily what SHOULD be done.  I did however, use
auto_prepend_file in a .htaccess file for a somewhat similar case.  

I have a site with about 90 pseudo-static pages (the page is static but
I use PHP to include the header and footer) and a handful of fully
dynamic pages.  I REALLY want this site to be regularly updated in the
search engines but, unfortunately, many search engines only spider
pages that are "newer" than what they have in their database.  Since
PHP is dynamic, it doesn't report a "Last-Modified" header so the
search engine doesn't think anything has been updated.  Hence stale
search engine results.

To force all of the pages (both pseudo-static and dynamic) to generate
a "Last-Modified" header, I set up prepend.php script which is
configured as a directory level (.htaccess) parm to auto_prepend_file.

Here is the content of prepend.php.




For my truly dynamic pages, I figured out that only the last call to
header actually shows up in the "real" header that makes it to the
browser (or search engine), so I can create a more unique
"Last-Modified" header as part of the dynamic pages (like when the
database is updated or whatever makes sense) and it will overwrite the
automatically generated one.

Now for those of you still reading this and going "what the heck is he
talking about -- what Last-Modified header", I would like to recommend
that you grab a copy of Sam Spade for windows (it's free and an
absolute "must have") and look at the returned headers on a static html
page and the headers returned from a php page.

http://www.samspade.org/ssw/

You might also be interested in the following article about search
engine placement:

http://www.searchenginewatch.com/webmasters/


Standard disclaimer - no association with the above mentioned
product(s) except as a happy customer.  :)


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



Re: [PHP] Variables don't pass... *sniff*

2003-05-29 Thread Wendell Brown
On Wed, 28 May 2003 16:30:17 +0200, [EMAIL PROTECTED] wrote:

>Howcome? I don't think I understand that...

Check this out.

http://us4.php.net/registerglobals



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



Re: [PHP] Variables don't pass... *sniff*

2003-05-29 Thread Wendell Brown
On Wed, 28 May 2003 16:13:22 +0200, [EMAIL PROTECTED] wrote:

>if (!empty($_POST)) {
> extract($_POST);
>} else {
> extract($HTTP_POST_VARS);
>}
>
>And have it in an include file, "extract_post.php".
>This way I can just include it and all variables are available, just like if
>register_globals had been on.

Yup!  You could even add that php to the auto_prepend_file variable in
your php.ini or add this to your .htaccess file (assuming you are
running Apache and have overwrite turned on) and the prepend will
happen automagically on every php program:

php_value  auto_prepend_file  "/www/extract_post.php"

However, both of these "solutions" create the same security issue that
turning RegisterGlobals on took care of in the first place.  :)




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



Re: [PHP] Variables don't pass... *sniff*

2003-05-29 Thread Wendell Brown
On Wed, 28 May 2003 12:46:50 +0100, David Grant wrote:

>I would've thought that $HTTP_*_VARS will be deprecated sometime in the 
>future.  It might be an idea to write your own accessor methods, e.g.
>
>function RetrieveGetParameter($parameterValue)

Egads!  Wouldn't the following be a little simpler?

At the top of the file put.

if( is_array($_POST) ) 
  $pArray = $_POST;
else
  $pArray = $HTTP_POST_VARS;

Then access $pArray["fred"] where ever you want to?  And yes, I know
this creates a second copy of the post array in local memory (wouldn't
pointers be nice right about now), but if the post array is going to be
accessed a lot, it would seem to be faster to copy it once than to call
the function over and over.  :)


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