Re: [PHP] problems with exec()

2006-11-29 Thread admin
Try

exec('/path/to/copy', $return);
print_r($return);

read the manual : http://nl3.php.net/manual/en/function.exec.php

Description
string exec ( string command [, array &output [, int &return_var]] )

gr,
Thijs

On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <[EMAIL PROTECTED]> wrote:
> hello;
> I am trying to write a script to do some auto configuration of my
> webserver. Part of the process involves copying some configuration files
> from other places on the server to a working directory where they can be
> modified.
> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
> I can't seem to get the exec() command to work.
> I have an external shell script called 'copy' that takes care of getting
> files. script is currently set to mode 777 when run from the shell it
> works perfectly.
> 
> however, in the php script
> 
> echo exec('whoami');
> exec('/path/to/copy');
> the only return is
> 'www' (the username correctly returned from whoami) also files aren't
> changed.
> any suggestions, pointers, log files to check would be appreciated as I
> have spent several hours on google, in manuals, etc. haven't tried the
> ougi board, but that's about it  ;-)
> tia
> Ray
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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



Re: [PHP] Connect to Sybase !

2006-11-29 Thread Chris

Le Phuoc Canh wrote:
Thanks Chris, I understand my problem, but can you show me where to find 
the libct.dll or where I can get libct.dll


Search for it.

"libct.dll sybase" returns a few results.

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

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



RE: [PHP] Connect to Sybase !

2006-11-29 Thread Le Phuoc Canh
Thanks Chris, I understand my problem, but can you show me where to find the
libct.dll or where I can get libct.dll

Thanks & Best Regard 

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 30, 2006 11:14 AM
To: Le Phuoc Canh
Cc: PHP Mailing
Subject: Re: [PHP] Connect to Sybase !

Le Phuoc Canh wrote:
>  
> Of course I know edit my php.ini, but the problem here that when I 
> test use
> sybase_connect() function and run by command line, a message "This 
> application has failed to start because libct.dll was not found".

..so it's not that php doesn't support it, it's that php can't get to the
sybase dll's.

Completely different issue.

Does the libct.dll file exist on your system? Is it in the environment path?

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


Re: [PHP] counting clicks

2006-11-29 Thread clive

Ross wrote:
Anyone got a script so I can count clicks on adverts. Doesn't have tosve to 
myqsl or anything just a text file will do.


What about using mysql, but use a memory resident heap table, then every 
once in a while write this to a file or even better to a myisam table





Ta

Ross 



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



[PHP] problems with exec()

2006-11-29 Thread Ray
hello;
I am trying to write a script to do some auto configuration of my
webserver. Part of the process involves copying some configuration files
from other places on the server to a working directory where they can be
modified.
I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
I can't seem to get the exec() command to work.
I have an external shell script called 'copy' that takes care of getting
files. script is currently set to mode 777 when run from the shell it
works perfectly.

however, in the php script

echo exec('whoami');
exec('/path/to/copy');
the only return is 
'www' (the username correctly returned from whoami) also files aren't changed.
any suggestions, pointers, log files to check would be appreciated as I
have spent several hours on google, in manuals, etc. haven't tried the
ougi board, but that's about it  ;-)
tia
Ray

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



Re: [PHP] Re: mail header questions

2006-11-29 Thread Chris

Chantal Rosmuller wrote:

On Wednesday 29 November 2006 00:45, Chris wrote:
you will most likely change what


I forgot to mention that I can't set the return-path either.

That can *only* be an email address - you can't include a "name" in the
return-path. Also it can't be changed if safe-mode is on for the server.

 From your code, where does $mainmail come from? It's not in the code
you posted at all.

$headers .= "From: $mainmail \r\n";

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


Hi Chris,

The return path works now, $mainmail comes from a different file config.php 
that is included. $mainmail is also used for the return-path and that works 
so $mainmail being empty is also not the problem.


The strange thing is that even the fifth parameter solution doesn't work. I 
use Postfix as MTA by the way.


Strange - I use postfix on my dev server and it works fine. Are you 
running anything non-default in postfix (eg chroot) ?


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

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



Re: [PHP] magic_quotes

2006-11-29 Thread Chris

Johannes Lindenbaum wrote:

Evening,

I am new to this list, so please if this email is "offensive" to anyone 
I didn't know any better. Not here to start a war or similar.


I have a couple questions about magic_quotes and it's deletion in PHP 6.

I've been lazily following php.internals and read about register_globals 
and magic_quotes (finally) being deleted from PHP.


I don't have any scripts that run with register_globals - not worried 
about PHP 6 for that case.


But... magic_quotes.
If my understanding is correct magic quotes will give ', " and \ (for 
ASCII characters, e.g. \n) a preceding backslash to escape it. I also 
see that magic_quotes_gpc() is On by default. So all data in $_POST and 
$_GET etc. has escaping backslashes.

If in a .htaccess I should set
php_flag magic_quotes_gpc Off

That would lead to $_POST data like Jingle's Bells to be passed as 
Jingle's Bells, not Jingle\'s Bells. Usually most of my $_POST data gets 
written into a MySQL table to which I perform addslashes(). And on 
retrieval stripslashes().
If I keep on doing that - and just start coding with magic_quotes_gpc 
Off - my scripts shouldn't alter behaviour upon PHP 6 arrival, should they?


That part is correct.

You shouldn't need to use addslashes - use mysql_real_escape_string or 
mysql_escape_string depending on your (current) php version - they are 
both "locale aware" and will escape things for you depending on mysql 
server (re: language setup).


Then just use htmlentities to display on the frontend rather than using 
stripslashes.


Of course other db's have similar functions, check the manual.

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

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



Re: [PHP] cURL: can't prevent url redirect

2006-11-29 Thread Andrew Warner

oops... I see my mistake:

   foreach($restored_cookies as $name=>$value)
array_push($the_headers, "Cookie: ".$name.'='.$value);


should be:

   $cookie='';
   foreach($restored_cookies as $name=>$value)
   $cookie .= "$key=$value; ";

$cookie = substr ($cookie,0,-2);

Then either:

  curl_setopt($ch, CURLOPT_COOKIE, $cookie);

or:
  array_push($the_headers, "Cookie: ".$cookie);

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



[PHP] magic_quotes

2006-11-29 Thread Johannes Lindenbaum

Evening,

I am new to this list, so please if this email is "offensive" to anyone 
I didn't know any better. Not here to start a war or similar.


I have a couple questions about magic_quotes and it's deletion in PHP 6.

I've been lazily following php.internals and read about register_globals 
and magic_quotes (finally) being deleted from PHP.


I don't have any scripts that run with register_globals - not worried 
about PHP 6 for that case.


But... magic_quotes.
If my understanding is correct magic quotes will give ', " and \ (for 
ASCII characters, e.g. \n) a preceding backslash to escape it. I also 
see that magic_quotes_gpc() is On by default. So all data in $_POST and 
$_GET etc. has escaping backslashes.

If in a .htaccess I should set
php_flag magic_quotes_gpc Off

That would lead to $_POST data like Jingle's Bells to be passed as 
Jingle's Bells, not Jingle\'s Bells. Usually most of my $_POST data gets 
written into a MySQL table to which I perform addslashes(). And on 
retrieval stripslashes().
If I keep on doing that - and just start coding with magic_quotes_gpc 
Off - my scripts shouldn't alter behaviour upon PHP 6 arrival, should they?


Kind Regards,
Johannes Lindenbaum

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



Re: [PHP] func_get_args as a hash? (faster constructors)

2006-11-29 Thread Larry Garfield
On Tuesday 28 November 2006 20:09, Jochem Maas wrote:
> Kelly Jones wrote:
> > If I define a function like this:
> >
> > function foo ($x, $y, $z) {}
> >
> > and then call: foo(1,2,"bar");
> >
> > is there a function I can call inside foo() that yields this hash:
> >
> > {"x" => 1, "y" => 2, "z" => "bar"}
> >
> > In other words, gives me the values *and names* of the arguments to foo?
> >
> > func_get_args just yields the values.
> >
> > Having this function would make writing constuctors easier.
> >
> > The normal way:
> >
> > fuction ClassName ($x, $y, $z) {
> >   $this->x = $x;
> >   $this->y = $y;
> >   $this->z = $z;
> > }
> >
> > could be replaced with:
> >
> > function ClassName ($x, $y, $z) {
> >   foreach (magic_function_i_want() as $key=>$val) {
> >  $this->$key =$val;
> >   }

In the Javascript world, it's becoming more common to pass a key/value object 
(what in the PHP world we call an associative array) as a single parameter.  
That gives you keyed values, and no order-requirements if you want default 
values for the first 5 parameters and just one difference for the last one.  
To wit:

function foo($params) {
  if (!isset($params['bar']) $params['bar'] = 'a';
  if (!isset($params['baz']) $params['baz'] = 'b';
...
}

Or for a constructor, you'd do something like this:

class Foo {
  private $bar = 'a';
  private $baz = 'b';

  function __construct($params) {
foreach ($params as $key => $value) {
  $this->$key = $value;
}
  }
}

The down side of course is that calling the function/object has a different 
syntax then.  Nothing is free. :-)

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] cURL: can't prevent url redirect

2006-11-29 Thread Chris

Andrew Warner wrote:
Actually, the problem is that the site isn't recognizing my cookies. Is 
there anything wrong with the below code? Same thing in Snoopy works 
perfectly. Going to stick with Snoopy.


$the_headers = array(
   "Language: en",
   "Accept: */*",
   "User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) 
AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3",

   "Content-type: text/html"
);


$restored_cookies = restore_cookies ();


foreach($restored_cookies as $name=>$value)
 array_push($the_headers, "Cookie: ".$name.'='.$value);

// headers look good:
echo ''; print_r($the_headers); echo '';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $the_headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);


Curl uses different cookie options.

See CURLOPT_COOKIE, CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR on 
http://www.php.net/manual/en/function.curl-setopt.php


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

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



Re: [PHP] cURL: can't prevent url redirect

2006-11-29 Thread Andrew Warner
Actually, the problem is that the site isn't recognizing my cookies.  
Is there anything wrong with the below code? Same thing in Snoopy  
works perfectly. Going to stick with Snoopy.


$the_headers = array(
   "Language: en",
   "Accept: */*",
   "User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)  
AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3",

   "Content-type: text/html"
);


$restored_cookies = restore_cookies ();


foreach($restored_cookies as $name=>$value)
 array_push($the_headers, "Cookie: ".$name.'='.$value);

// headers look good:
echo ''; print_r($the_headers); echo '';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $the_headers);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

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



Re: [PHP] cURL: can't prevent url redirect

2006-11-29 Thread Chris

Andrew Warner wrote:
This login script works when I use Snoopy (php http class), but here 
with php curl the response is the redirected page. The script is 
following a 302 redirect and I don't want it to because I need some 
header info from the 302 page. The curl_setopt($ch, CURLOPT_MAXREDIRS, 
0); doesn't seem to be preventing redirect:




$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_MAXREDIRS, 0);

//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);


Why is FOLLOWLOCATION commented out?

If you set that does it do what you want (that should be the one 
controlling the redirect) ?


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

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



Re: [PHP] Connect to Sybase !

2006-11-29 Thread Chris

Le Phuoc Canh wrote:
 
Of course I know edit my php.ini, but the problem here that when I test use

sybase_connect() function and run by command line, a message "This
application has failed to start because libct.dll was not found". 


..so it's not that php doesn't support it, it's that php can't get to 
the sybase dll's.


Completely different issue.

Does the libct.dll file exist on your system? Is it in the environment path?

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

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



[PHP] cURL: can't prevent url redirect

2006-11-29 Thread Andrew Warner
This login script works when I use Snoopy (php http class), but here  
with php curl the response is the redirected page. The script is  
following a 302 redirect and I don't want it to because I need some  
header info from the 302 page. The curl_setopt($ch,  
CURLOPT_MAXREDIRS, 0); doesn't seem to be preventing redirect:




$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);

curl_setopt($ch, CURLOPT_REFERER, $url_ref);
curl_setopt($ch, CURLOPT_HTTPHEADER, $the_headers);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);

$response = curl_exec($ch);
curl_close($ch);


drew




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



RE: [PHP] Connect to Sybase !

2006-11-29 Thread Le Phuoc Canh
 
Of course I know edit my php.ini, but the problem here that when I test use
sybase_connect() function and run by command line, a message "This
application has failed to start because libct.dll was not found". 

Can you help me to solve that problem.
BR

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 30, 2006 1:59 AM
To: Le Phuoc Canh
Cc: PHP Mailing
Subject: Re: [PHP] Connect to Sybase !

On Tue, November 28, 2006 8:01 pm, Le Phuoc Canh wrote:
> I want to make a connection to sybase database with PHP on win32 
> platform, but i can't recompile PHP with extension --with-cybase-ct. 
> Please help me

In the .zip file you downloaded for PHP, there should have been, hopefully,
a file named something like php_sybase.dll

If you fix up your php.ini and uncomment the line matching that, you'll get
the Sybase DLL loaded in.

Caveats:
You have to check with  where your php.ini file is, or is
supposed to be, and make sure you have a php.ini file in that directory, and
edit THAT php.ini file, and php.ini has to be readable by the user that PHP
is running as, and the DLL has to be in the directory named in php.ini and
the DLL also has to be readable/executable by the user running PHP.  Whew.
That's a lot of "gotchas" to stumble through for a newbie, but there it is.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?



Re: [PHP] several sites sharing the same script

2006-11-29 Thread Curt Zirzow

On 11/29/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Hello all,

I am writing new php application which will be used by several sites.
All sites will use same script (all files), but every will have its own 
config.php file.
I would like to place all necessary files to separate directory and all sites 
should share them, so all sites will be updated.

for e.x. structure will be:

| - script directory
|- site1.com dir
config.php
|- site2.com dir
config.php
|- site3.com dir
config.php

Does anyone have idea how to organize and share files?


My thinking is always like:
siteX.com/
include/
secure/

where siteX.com has a basic common code base, include/ has common code
that is shared across siteX.com, and in secure you have individual
settings per site, for example

siteX.com/index.php:
 require('setup.php');

include/setup.php:
 require($siteX .'.setup.php');
 // perform standard setup routines
 // include standard things you need to use accross sites

secure/$siteX.setup.php
 // setup defines specific to the site and used in include/setup.php

and then you ensure you have set your your include_path to:
 root_to/secure:root_to/include:root_to/:.:/usr/local/lib/php/

Curt.

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



[PHP] several sites sharing the same script

2006-11-29 Thread [EMAIL PROTECTED]
Hello all,

I am writing new php application which will be used by several sites.
All sites will use same script (all files), but every will have its own 
config.php file.
I would like to place all necessary files to separate directory and all sites 
should share them, so all sites will be updated.

for e.x. structure will be:

| - script directory
|- site1.com dir
config.php
|- site2.com dir
config.php
|- site3.com dir
config.php

Does anyone have idea how to organize and share files?


Thanks For Your Time !

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



[PHP] LDAP password question

2006-11-29 Thread Ray Hauge
I'm working on integrating an application with an AD server, and I was
wondering if the password is encrypted at all, or if I need to go
through the troubles of setting up ldaps://

 

I checked the documentation, but I couldn't find any information about
plain-text vs. encrypted.

 

Thanks!

 

--

Ray Hauge

Application Development Lead

American Student Loan Services

www.americanstudentloan.com

 



Re: [PHP] Tidy HTML source?

2006-11-29 Thread Paul Novitski

At 11/29/2006 05:13 AM, Satyam wrote:

- Original Message - From: "Paul Novitski" <[EMAIL PROTECTED]>
What I find to be a much greater problem is the 
human readability of logic code when HTML is 
mixed throughout.  Your innovation is helpful 
here, as you're nearly making HTML tags into 
PHP key words, eliminating some of the literal 
quoting that makes PHP+HTML so 
tiresome.  However, even with your pre-compiler 
the messy quotes are still there on the attribute level.


The value of the attribute is any valid PHP 
expression and if they are literal strings there 
will be quotes, but then, you can also use 
heredoc if, for example, you are putting some 
JavaScript code into an event.  If the value is 
a numeric value, there is no need for any quotes 
at all.  In the end, the value of an attribute 
is any valid PHP expression and it follows PHP rules.



XHTML, which I would hope you would lean toward 
in your pursuit of XML, does require quotes on all attributes:


XHTML™ 1.0
4.4. Attribute values must always be quoted
http://www.w3.org/TR/xhtml1/#h-4.4

But it's not the quotes in the attributes I was 
referring to as messy, but instead the necessity 
for two sets of nested quotes when quoted 
expressions and concatenation syntax are 
contained within assignment statements.


I am an ardent user of heredoc exactly because it 
allows a level of separation of logic from 
markup, and at the same time permits embedded PHP 
variables.  I use heredoc extensively for both 
HTML markup and SQL queries, both when they 
appear in my PHP scripts and when they imported from separate files.


By the way, I'm not expressing strong opposition 
to embedding PHP variables in HTML, as in:


$sCaption

To my eye, this is a small step away from the more ideal:

x

where the attribute values and the content of 
plain old validatable HTML are replaced based on selectors.


Instead, what I'm objecting to are control 
structures, concatenation, mixed quotes, and 
escaped quotes fracturing the integrity of the output string.



And, stepping back, you're perpetuating the 
embedding of markup with logic so that it will 
still take a PHP programmer to modify the 
markup of one of your pages.  Do you not see 
the advantage in separating the two layers?


Yes, I do, and I would recommend using templates 
or similar tools to provide for separation of 
code and markup, but sometimes there are reasons 
not to do so, for example, web services.


Please explain why you think web services promote mixing markup with logic.


I appreciate your comments and, I admit, my main 
purpose in doing this was to learn how to do 
it.  I am an engineer and when I studied, a 
couple of semesters of Fortran IV was all I got 
(and punching cards at that, yes, I am that 
old), all the rest was self-taught so I wanted 
to go deeper into some aspects of computer 
science such as compilers (there is also a PHP 
grammar for JavaCC which I made earlier in the process).


Hah!  Fortran on punch cards was my first 
computer language as well, back there in the 
Mesozoic.  And writing compilers is the best 
fun.  I like to view programming in general as 
language creation -- we create functions and 
objects as the key words in the custom language 
we use at the higher levels of our own 
scripts.  Writing compilers seems like just an extension of that.



In fact, my original idea was some sort of 
embedded SQL as it exists for C, but I know it 
does not work quite Ok, in fact, it has been 
there for quite some time and it doesn't catch 
up.  SQL is such a different kind of beast that 
it is hard to make it compatible. SQL cursors 
and error handling are concepts which are hard 
to blend into a procedural language so I believe 
it is better to handle SQL through functions 
where it is clearly separate from the language 
calling them.   Thus, I thought, we have three 
main languages here, HTML, PHP and SQL.  I know 
PHP and SQL don't mix well, how about the other 
end?  That's when I started to think about this 
pre-compiler and found it to be a pretty logical mix.


That's interesting, I don't have a problem 
allowing PHP & MySQL to play together.  I'm 
pretty happy with the PHP mysql function library 
in which the two communicate with strings and 
handles; and negotiation of SQL data structures 
maps nicely onto PHP logic blocks.  Can you give 
an example of where you see the discord?


I try to separate the text of my SQL queries from 
my PHP logic in the same way that I try to separate PHP from HTML.


Warm regards,
Paul 


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



Re: [PHP] regular expressions

2006-11-29 Thread Dotan Cohen

On 20/11/06, Paul Novitski <[EMAIL PROTECTED]> wrote:


Børge,

Here's how I would think this one through:

First, I'm having to make several guesses at the nature of your text content:

- You use the single word "topic" but I'll assume
this can be multiple words and spaces.

- Your source string includes a space after "rest
of the text " while your marked-up result
doesn't.  However I will assume that you really
do mean the rest of the text until end-of-string.

- Your source string also includes a space before
the initial  but your regexp pattern
doesn't.  I'll assume that both beginning and ending spaces are unintentional.


Your source string:

 " FF topic  99 rest of the text"

consists of these parts:

1) [start-of-string]
2) " "
3) "FF" (color code 1)
4) " "
5) "topic"  (text 1)
6) "  "
7) "99" (color code 2)
8) " "
9) "rest of the text"   (text 2)
10) [end-of-string]

i.e.:

1) [start-of-string]
2)  + whitespace
3) color code 1
4) whitespace
5) one or more characters
6) whitespace +  + whitespace
7) color code 2
8) whitespace
9) one or more characters
10) [end-of-string]

This suggests the regexp pattern:

1) ^
2) \s
3) ([0-9A-F]{6})
4) \s
5) (.+)
6) \s\s
7) ([0-9A-F]{6})
8) \s
9) (.+)
10) $

/^\s([0-9A-F]{6})\s(.+)\s\s([0-9A-F]{6})\s(.+)$/i

Everything in the source string that you need to
retain needs to be in parentheses so regexp can grab it.

In 5) I can let the pattern be greedy, safe in
the knowledge that there WILL be a /s to terminate the character-grab.

I end with the pattern modifier /i so it will
work with lowercase letters in the RGB color codes.

PHP:

$sText = ' FF topic  99 rest of the text';
$sPattern = '/^\s([0-9A-F]{6})\s(.+)\s\s([0-9A-F]{6})\s(.+)$/i';
preg_match($sPattern, $sText, $aMatches);
print_r($aMatches);

result:

Array
(
 [0] =>  FF topic  99 rest of the text
 [1] => FF
 [2] => topic
 [3] => 99
 [4] => rest of the text
)

This isolates the four substrings you want in regexp references $1 through $4.

Replacement:

[Tangentially, I'd like to comment that font tags
are passe.  I urge you to use spans with styling
instead.  I normally dislike using inline styles
(style details mixed with the HTML), but in this
case (as far as I know) you don't have any
choice.  If you can, I suggest you replace the
literal color codes with style names and define
the precise colors in your stylesheet, not your database.

[What this further suggests is that you ought to
have two discrete database fields, `topic` and
`description`, if you can, rather than combining
them into one field that needs to be
parsed.  Then you can output something like:

 TOPIC DESCRIPTION

and leave the RGB color codes out of this layer
of your application altogether.]


However, working with the data you've been dealt:

$sTagBegin = '';
$sCloseTag = '';

$sReplacement = $sTagBegin . '$1' . $sTagEnd . '$2' . $sCloseTag .
 $sTagBegin . '$3' . $sTagEnd . '$4' . $sCloseTag;

echo preg_replace($sPattern, $sReplacement, $sText);

result:

topic rest of the text



It's tempting to write the pattern more
succinctly to take advantage of the repeating pattern of the source text:

  COLORCODE text

The regexp pattern might be:

1) \s*
2) \s
3) ([0-9A-F]{6})
4) \s
5) ([^<]+)

1) optional whitespace
2)  + whitespace
3) color code
4) whitespace
5) one or more characters until the next <

$sText = ' FF topic  99 rest of the text';

$sPattern = '/\s*\s([0-9A-F]{6})\s([^<]+)/i';

preg_match_all($sPattern, $sText, $aMatches);

result:

Array
(
 [0] => Array
 (
 [0] =>  FF topic
 [1] =>  99 rest of the text
 )

 [1] => Array
 (
 [0] => FF
 [1] => 99
 )

 [2] => Array
 (
 [0] => topic
 [1] => rest of the text
 )

)

In this case, we need to specify the tag pattern only once:

$sReplacement = $sTagBegin . '$1' . $sTagEnd . '$2' . $sCloseTag;

echo preg_replace($sPattern, $sReplacement, $sText);

result:

topic  rest of the text

Notice is that this results in whitespace after
the topic string.  Someone more knowledgeable in
regular expressions can probably tell you how to
eliminate that, perhaps by using a regexp assertion:
http://php.net/manual/en/reference.pcre.pattern.syntax.php#regexp.reference.assertions

Regards,
Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com



Paul, I just got around to reading this thread. The post of yours that
I quote above has got to be one of the best posts that I've read in
the 5 years that I've been on and off the php list. The way you break
that regex down taught me things that have eluded me for half a
decade. Although I have nothing to do with the OP, I really want to
say thanks for that bit of information.

Dotan Cohen

http://lyricslist.com/
http://what-is-

RE: [PHP] Maybe an HTML prob?

2006-11-29 Thread Frank Reichenbacher, Bio-Concepts, Inc.
Aha! The secret handshake. That was it. Thanks to Brad and to David for
pointing me to an invaluable online php resource.

Frank

> -Original Message-
> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 29, 2006 12:42
> To: php-general@lists.php.net
> Subject: RE: [PHP] Maybe an HTML prob?
> 
> if ($Permission = "Yes")
> 
> should be
> 
> if ($Permission == "Yes")
> 
> It's one of those elusive little oversights we've all come across in our
> time. :)
> 
> -B
> 
> > -Original Message-
> > From: Frank Reichenbacher, Bio-Concepts, Inc. [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, November 29, 2006 1:53 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Maybe an HTML prob?
> >
> > I am trying to pass the results of a form to a simple php mail()
> routine.
> > Everything works except the checkbox, Permission". No matter what state
> > the
> > checkbox is in, the php says it is whatever the "value" is set to on the
> > form. I must not be trying to pull the checkbox state correctly.
> >
> > I've tried several different means of evaluating $Permission, including
> > using empty() and isset(), but no matter what, $Permission always
> returns
> > whatever value is set in "value" on the form. In the case below, echo
> > $Permission returns "Yes" whether the box is checked or not.
> >
> > Here is the relevant code slightly doctored so as not to give a way a
> site
> > in early development:
> >
> > FORM:
> > 
> >   
> >> checked>
> >   I grant permission to include the
> > above information on the website
> > 
> >
> > ACTION:
> >  > $to = $_POST["to"];
> > $FName = $_POST["FName"];
> > $MI = $_POST["MI"];
> > $LName = $_POST["LNAME"];
> > $Specialty = $_POST["Specialty"];
> > $Quals = $_POST["Quals"];
> > $Hospital = $_POST["Hospital"];
> > $Address1 = $_POST["Address1"];
> > $Address2 = $_POST["Address2"];
> > $Address3 = $_POST["Address3"];
> > $Address4 = $_POST["Address4"];
> > $Telephone = $_POST["Telephone"];
> > $Fax = $_POST["Fax"];
> > $New_First_Email = $_POST["New_First_Email"];
> > $OldEmail = $_POST["OldEmail"];
> > $Permission = $_POST["Permission"];
> > if ($Permission = "Yes") {
> > $Permission = "Yes";
> > }   else {
> > $Permission = "No";
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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



RE: [PHP] Maybe an HTML prob?

2006-11-29 Thread Frank Reichenbacher, Bio-Concepts, Inc.

Well, my code worked fine with that one simple change from "=" to "=="


> -Original Message-
> From: Richard Lynch [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 29, 2006 13:47
> To: [EMAIL PROTECTED]
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Maybe an HTML prob?
> 
> On Wed, November 29, 2006 12:52 pm, Frank Reichenbacher, Bio-Concepts,
> Inc. wrote:
> > $Permission = $_POST["Permission"];
> > if ($Permission = "Yes") {
> 
> In addition to the aforementioned = versus == error, your code will
> generate an E_NOTICE for an unchecked "Permission" box.
> 
> HTML/HTTP simply does not transmit anything at all for unchecked boxes.


Which is why my code worked. If $Permission is not "Yes" then $Permission
evaluates to "No". I did understand that the HTML wouldn't transmit anything
for an unchecked checkbox. That is what I was counting on. I was expecting
that $Permission would have been "empty" (or is it not isset?).

Frank


> 
> A better expression might be:
> $Permission = isset($_POST['Permission']) ? "yes" : "no";
> 
> The actual value sent by a single checkbox is rarely of any use.
> 
> But when you have a whole array of them, it can be very useful indeed.
> 
> E.g.;
> 
> 
> 
> ..
> ..
> ..
>  //list of all possible permissions:
> $Permissions = array('newsletter', 'coupons', 'share_email');
> $Permission = isset($_POST['Permission']) ? $_POST['Permission'] :
> array();
> $granted = array();
> foreach($Permissions as $p){
>   if (isset($Permission[$p])) $granted[$p] = $Permission[$p];
> }
> var_dump($granted);
> ?>
> 
> In this not-so-great example, not only do we have the index of the
> array for the Permission, but also the value -- which doesn't have
> much meaning in this context.
> 
> But with an N-to-N relationship in SQL, the multiple checkbox as an
> array can often provide a very nice pattern for relating:
> table1 <-> cross-table <-> table2
> where the checkboxes indicate which rows exist in 'cross-table' for
> any given ID in table1, to relate them N-to-N to all the IDs in the
> checkbox values for table2.
> 
> This is an idiom where PHP performs like a thoroughbred, while most
> other web application languages look like total nags.
> 
> YMMV
> 
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?

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



Re: [PHP] Maybe an HTML prob?

2006-11-29 Thread Richard Lynch
On Wed, November 29, 2006 12:52 pm, Frank Reichenbacher, Bio-Concepts,
Inc. wrote:
> $Permission = $_POST["Permission"];
> if ($Permission = "Yes") {

In addition to the aforementioned = versus == error, your code will
generate an E_NOTICE for an unchecked "Permission" box.

HTML/HTTP simply does not transmit anything at all for unchecked boxes.

A better expression might be:
$Permission = isset($_POST['Permission']) ? "yes" : "no";

The actual value sent by a single checkbox is rarely of any use.

But when you have a whole array of them, it can be very useful indeed.

E.g.;



.
.
.


In this not-so-great example, not only do we have the index of the
array for the Permission, but also the value -- which doesn't have
much meaning in this context.

But with an N-to-N relationship in SQL, the multiple checkbox as an
array can often provide a very nice pattern for relating:
table1 <-> cross-table <-> table2
where the checkboxes indicate which rows exist in 'cross-table' for
any given ID in table1, to relate them N-to-N to all the IDs in the
checkbox values for table2.

This is an idiom where PHP performs like a thoroughbred, while most
other web application languages look like total nags.

YMMV

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Running AMP from CD

2006-11-29 Thread Richard Lynch
You'll need to "trick" wget into downloading all the .php? content,
even if it is a link embedded in the JS.

How hard this is or isn't is more than I can tell you, as I also only
understand about half the switches of wget, and have been known to
wrap my own PHP program around wget to do what is probably a one-liner
for a wget expert.  But so be it.  Don't really care how long it takes
when I'm just dumping something out overnight while I sleep. :-)

On Mon, November 27, 2006 1:37 pm, Ryan A wrote:
> Hey Rich,
>
> To be honest I thought of using WGET and if I remember correctly it
> was suggested in the original old thread... but once i started reading
> up on wget, the damn thing has so many switches I got lost and
> gave up hope pretty soon.
>
> Another thing that I am not sure if WGET will handle soo well is...
> there are quite a few javascript popups on each page (basically icons
> on the side, when clicked open a JS popup with the content of the main
> page in a different language
>
> for example:
> the main page is in Swedish, when you click the language icon on the
> side it opens a popup with the same content in Arabic or Spanish)
>
> but these popups are calling php scripts with something like this:
> get_popup_content.php?content_id=2354
>
> But if you think this is the best solution, I am willing to start
> reading up on WGET again to see if this time I get the hang of it..
>
> Thanks!
> Ryan
>
> Richard Lynch <[EMAIL PROTECTED]> wrote: Another option might be to use
> something like wget or htdig to just
> rip through the whole site and generate a static site out of it...
>
> I did something like that once for an educational CD, except I just
> wrote the generator myself.  I'm not sure wget existed back then, and
> I'm pretty sure htdig didn't...
>
> Had to put a bit of stuff into JavaScript for the "quiz" portion, but
> it worked fairly well.
>
> On Mon, November 27, 2006 10:51 am, Alberto Ferrer wrote:
>> www.apachefriends.org have a "Lamp" on CD project.
>>
>> 2006/11/27, Ryan A :
>>> Hello,
>>>
>>> A little while back there was a discussion on running Apache,MySql
>>> and PHP from a CD... I can't seem to find that thread and i cant
>>> seem to find the links i had from that thread, so
>>>
>>> Can anybody suggest/recommend a way to run our project from CD?
>>> Our project is made in PHP 4 with a MySql backend... so far its
>>> been
>>> running on Apache..
>>>
>>> I have found some commercial alternatives via google(PortableWebAp
>>> ,dwebpro,microweb to name a few) but if I remember correctly the
>>> solution in the old thread was a freeware. The commercial solutions
>>> offer a lot of bells and whistles and inter platform compatability
>>> but all we need is for AMP to run on CD and on Windows 2000
>>> onwards.
>>>
>>> Any help appreciated, even if its a one line link, thanks in
>>> advance!
>>> -Ryan
>>>
>>>
>>> --
>>> - The faulty interface lies between the chair and the keyboard.
>>> - Creativity is great, but plagiarism is faster!
>>> - Smile, everyone loves a moron. :-)
>>>
>>> -
>>> Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call
>>> rates.
>>>
>>
>>
>> --
>> bet0x - Barrahome
>> http://www.barrahome.com.ar
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
>
> -
> Everyone is raving about the all-new Yahoo! Mail beta.


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] func_get_args as a hash? (faster constructors)

2006-11-29 Thread Richard Lynch
On Mon, November 27, 2006 7:57 pm, Kelly Jones wrote:
> If I define a function like this:
>
> function foo ($x, $y, $z) {}
>
> and then call: foo(1,2,"bar");
>
> is there a function I can call inside foo() that yields this hash:
>
> {"x" => 1, "y" => 2, "z" => "bar"}
>
> In other words, gives me the values *and names* of the arguments to
> foo?
>
> func_get_args just yields the values.
>
> Having this function would make writing constuctors easier.
>
> The normal way:
>
> fuction ClassName ($x, $y, $z) {
>$this->x = $x;
>$this->y = $y;
>$this->z = $z;
> }
>
> could be replaced with:
>
> function ClassName ($x, $y, $z) {
>foreach (magic_function_i_want() as $key=>$val) {
>   $this->$key =$val;
>}
> }
>
> Obviously, it's more of a savings when you have a large number of
> parameters.

It's probably a Bad Road you are on, but you could also consider the
dirt-simple:

function ClassName($x, $y = NULL, $z = NULL) {
  if (is_null($y) && is_null($z) && is_array($x)){
foreach($x as $k => $v){
  $this->$k = $v;
}
  }
}

You may even be able to wrap that up in some fancy OOP thingie that
makes you happy.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Maybe an HTML prob?

2006-11-29 Thread Dave Goodchild

Indeed. A good habit to get into to avoid that is the write it like this:

if ('yes' == $Permission)

that way, if you write = rather than == you catch the error

On 11/29/06, Brad Fuller <[EMAIL PROTECTED]> wrote:


if ($Permission = "Yes")

should be

if ($Permission == "Yes")

It's one of those elusive little oversights we've all come across in our
time. :)

-B

> -Original Message-
> From: Frank Reichenbacher, Bio-Concepts, Inc. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 29, 2006 1:53 PM
> To: php-general@lists.php.net
> Subject: [PHP] Maybe an HTML prob?
>
> I am trying to pass the results of a form to a simple php mail()
routine.
> Everything works except the checkbox, Permission". No matter what state
> the
> checkbox is in, the php says it is whatever the "value" is set to on the
> form. I must not be trying to pull the checkbox state correctly.
>
> I've tried several different means of evaluating $Permission, including
> using empty() and isset(), but no matter what, $Permission always
returns
> whatever value is set in "value" on the form. In the case below, echo
> $Permission returns "Yes" whether the box is checked or not.
>
> Here is the relevant code slightly doctored so as not to give a way a
site
> in early development:
>
> FORM:
> 
>   
>checked>
>   I grant permission to include the
>   above information on the website
> 
>
> ACTION:
>  $to = $_POST["to"];
> $FName = $_POST["FName"];
> $MI = $_POST["MI"];
> $LName = $_POST["LNAME"];
> $Specialty = $_POST["Specialty"];
> $Quals = $_POST["Quals"];
> $Hospital = $_POST["Hospital"];
> $Address1 = $_POST["Address1"];
> $Address2 = $_POST["Address2"];
> $Address3 = $_POST["Address3"];
> $Address4 = $_POST["Address4"];
> $Telephone = $_POST["Telephone"];
> $Fax = $_POST["Fax"];
> $New_First_Email = $_POST["New_First_Email"];
> $OldEmail = $_POST["OldEmail"];
> $Permission = $_POST["Permission"];
> if ($Permission = "Yes") {
>   $Permission = "Yes";
> } else {
>   $Permission = "No";
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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





--
http://www.web-buddha.co.uk


Re: [PHP] Detecting naughty sites

2006-11-29 Thread tedd

At 8:57 PM +0100 11/28/06, Rory Browne wrote:

I didn't mean something quite that simple, or as an absolute solution.

I meant something slightly more advanced, but based on that idea.

From a robot point of view, what do you think is the difference
between the php archives and a porn site?



There's a difference?

Both provide things you can't get?

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Maybe an HTML prob?

2006-11-29 Thread David Giragosian

On 11/29/06, Frank Reichenbacher, Bio-Concepts, Inc. <[EMAIL PROTECTED]>
wrote:


I am trying to pass the results of a form to a simple php mail() routine.
Everything works except the checkbox, Permission". No matter what state
the
checkbox is in, the php says it is whatever the "value" is set to on the
form. I must not be trying to pull the checkbox state correctly.

I've tried several different means of evaluating $Permission, including
using empty() and isset(), but no matter what, $Permission always returns
whatever value is set in "value" on the form. In the case below, echo
$Permission returns "Yes" whether the box is checked or not.

Here is the relevant code slightly doctored so as not to give a way a site
in early development:

FORM:



I grant permission to include the
   above information on the website


ACTION:



Frank,

You are hardcoding $Permission ($_POST["Permission"]) to be "Yes" in your
code:


Google "PHP checkbox example"...

An early hit : http://www.globalissa.com/articles/articleCheckbox.php

David


RE: [PHP] Maybe an HTML prob?

2006-11-29 Thread Brad Fuller
if ($Permission = "Yes")

should be

if ($Permission == "Yes")

It's one of those elusive little oversights we've all come across in our
time. :)

-B

> -Original Message-
> From: Frank Reichenbacher, Bio-Concepts, Inc. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 29, 2006 1:53 PM
> To: php-general@lists.php.net
> Subject: [PHP] Maybe an HTML prob?
> 
> I am trying to pass the results of a form to a simple php mail() routine.
> Everything works except the checkbox, Permission". No matter what state
> the
> checkbox is in, the php says it is whatever the "value" is set to on the
> form. I must not be trying to pull the checkbox state correctly.
> 
> I've tried several different means of evaluating $Permission, including
> using empty() and isset(), but no matter what, $Permission always returns
> whatever value is set in "value" on the form. In the case below, echo
> $Permission returns "Yes" whether the box is checked or not.
> 
> Here is the relevant code slightly doctored so as not to give a way a site
> in early development:
> 
> FORM:
> 
>   
>checked>
>   I grant permission to include the
>   above information on the website
> 
> 
> ACTION:
>  $to = $_POST["to"];
> $FName = $_POST["FName"];
> $MI = $_POST["MI"];
> $LName = $_POST["LNAME"];
> $Specialty = $_POST["Specialty"];
> $Quals = $_POST["Quals"];
> $Hospital = $_POST["Hospital"];
> $Address1 = $_POST["Address1"];
> $Address2 = $_POST["Address2"];
> $Address3 = $_POST["Address3"];
> $Address4 = $_POST["Address4"];
> $Telephone = $_POST["Telephone"];
> $Fax = $_POST["Fax"];
> $New_First_Email = $_POST["New_First_Email"];
> $OldEmail = $_POST["OldEmail"];
> $Permission = $_POST["Permission"];
> if ($Permission = "Yes") {
>   $Permission = "Yes";
> } else {
>   $Permission = "No";
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



Re: [PHP] combining a text sizer and text only link

2006-11-29 Thread Richard Lynch
Store their current choice of text_only and/or text_size in $_SESSION.

http://php.net/session_start

//start the session:
session_start();
//use saved setting:
$text_only = isset($_SESSION['text_only']) ? $_SESSION['text_only'] : 0;
//override saved if they clicked on link and it's in GET:
$text_only = isset($_GET['text_only']) ? 1 : $text_only;
//save their current choice:
$_SESSION['text_only'] = $text_only;

Repeat all that (except the session_start) for all user preferences.

coo coo ka choo

On Tue, November 28, 2006 3:51 am, Ross wrote:
>
> $text_only = isset($_GET['text_only']) ? $_GET['text_only'] : 1;
>
>  if ($text_only==1) {
>  ?>
> off
> // import css here
>  }
> else {
> ?>
> on
> // import css here
>  }
> ?>
>
>
> secondly the text size links
>
>
>  id="one">A
>  id="two">A
>  id="three">A
>
>
>  $text_size = isset( $_REQUEST['text_size'] ) ? $_REQUEST['text_size']
> : '';
>
> switch ($text_size) {
> case "medium":
> ?>
> 
>  break;
> case "larger":
> ?>
> 
>  break;
> case "largest":
> ?>
> 
>  break;
> }
> ?>
>
> these work great independently but when I use one the other switches
> off.
> any ideas how I can combine them?
>
>
> Ross
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] Maybe an HTML prob?

2006-11-29 Thread Frank Reichenbacher, Bio-Concepts, Inc.
I am trying to pass the results of a form to a simple php mail() routine.
Everything works except the checkbox, Permission". No matter what state the
checkbox is in, the php says it is whatever the "value" is set to on the
form. I must not be trying to pull the checkbox state correctly. 

I've tried several different means of evaluating $Permission, including
using empty() and isset(), but no matter what, $Permission always returns
whatever value is set in "value" on the form. In the case below, echo
$Permission returns "Yes" whether the box is checked or not.

Here is the relevant code slightly doctored so as not to give a way a site
in early development:

FORM:

  
  
  I grant permission to include the 
above information on the website


ACTION:
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] CLI script & exec() - how to control what gets dumped on the screen.

2006-11-29 Thread Richard Lynch

exec() doesn't show anything on the screen, I don't think...

You'd have to echo implode('', $output) to show the results on the
screen...


On Tue, November 28, 2006 5:37 am, Edward Kay wrote:
> As a check, does 'apache2ctl graceful' actually output anything to
> STDOUT? I
> would expect your exec commands to work - try with something like 'ls'
> or
> 'whoami' and see if you get any results that way.
>
> Edward
>
>> I have been trying to figure out how to use exec to run some
>> commandline
>> scripts (some perl scripts & mysql in this case) WITH the output
>> of the commands
>> run via exec being shown on the screen.
>>
>> neither of these examples have the desired effect:
>>
>> $output = array(); $exit = 0;
>> exec('apache2ctl graceful', $output, $exit);
>>
>>
>> $output = array(); $exit = 0;
>> @exec('apache2ctl graceful', $output, $exit);
>>
>> please someone tell me there is a decent way to do this (something
>> to do with STD input/output redirection or something?) and that
>> I'm not left
>> with trying something like:
>>
>> ob_start();
>> $output = array(); $exit1 = $exit2 = 0;
>> @exec('apache2ctl graceful', $output, $exit1);
>> ob_end_clean();
>>
>> ... of which I don't even know if it would work.
>>
>> anyone care to share their clue?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] SEGINT, readline extension & clean script exit - how to do it

2006-11-29 Thread Richard Lynch
On Tue, November 28, 2006 7:25 am, Jochem Maas wrote:
> so the question is how can I use readline() and handle the SIGINT
> gracefully whilst not waiting
> for readline() to return control to my script?

I'm just guessing here, but you probably don't.

You could, howver, write your own PHP function similar to readline,
only without whatever is in readline that ignores/buffers signals.

You'd want something like an fread($x, 1) on a non-blocking stream,
and then build up the string character by character, until you get a
newline.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] session issues on ie

2006-11-29 Thread Richard Lynch
On Tue, November 28, 2006 3:47 pm, blackwater dev wrote:
> I have code which logs someone in and then allows them to see certain
> info
> if they are logged in.  I have users who claim it works fin in some of
> their
> browsers, firefox, safari, etc and some versions of IE but not all and
> I'm
> stumped.
>
> Here's the code:
>
>
> //this is from the login routine
>  if ($this->db->getField('user_id')){
>
> session_start();
>
> $_SESSION['user']['user_id']=$this->db->getField('user_id');
>
> $_SESSION['user']['email']=$this->db->getField('email');
> return true;
>  }
>
>  //only show if they are logged in
> if (isset($_SESSION['user']['user_id']) &&
> !$_REQUEST['mlsid']){
> //show something
> }
> ?>
>
> People are claiming it tells them they are logged in yet they don't
> see what
> is displayed under the code which checks their session.  For some
> reason,
> sessions don't seem to be there on all browsers yet they claim that
> cookies
> and all are on.

I have a similar issue, and it always seems to be the people who are
incapable of responding to requests for more info about their browser
version etc...

The teeny tiny percentage who can tell me what browser version they
have, it works just fine.

My current theories include:

Their cookies aren't really "on", they just think they are, and once
they start digging, they solve it.

Some versions of IE refuse cookies in some security settings unless
you have the stupid P3P headers.

They were not paying attention when the web page told them that
CAPITALIZATION matters for their password.

I have resorted to telling the users to just switch browsers, which is
not what I'd like to do, but I can never seem to find the time to
track this down.

Good luck!

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Connect to Sybase !

2006-11-29 Thread Richard Lynch
On Tue, November 28, 2006 8:01 pm, Le Phuoc Canh wrote:
> I want to make a connection to sybase database with PHP on win32
> platform,
> but i can't recompile PHP with extension --with-cybase-ct. Please help
> me

In the .zip file you downloaded for PHP, there should have been,
hopefully, a file named something like php_sybase.dll

If you fix up your php.ini and uncomment the line matching that,
you'll get the Sybase DLL loaded in.

Caveats:
You have to check with  where your php.ini file is,
or is supposed to be, and make sure you have a php.ini file in that
directory, and edit THAT php.ini file, and php.ini has to be readable
by the user that PHP is running as, and the DLL has to be in the
directory named in php.ini and the DLL also has to be
readable/executable by the user running PHP.  Whew.  That's a lot of
"gotchas" to stumble through for a newbie, but there it is.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] counting clicks

2006-11-29 Thread Jay Blanchard
[snip]
This has a race condition where a busy server, or even a not-so-busy
one where 2 people happen to click at the same time, at least one of
them will be "missed", at best.

There's also a distinct possiblity of the counter file getting
completely trashed, depending on the OS and its underlying atomicity
of fwrite().

And, finally, you'd need "w+" in that fopen() to avoid wiping out the
old data to start with.

For this reason, and more, you're almost-for-sure better off keeping
track in a database which solves all the nasty race condition issues.
[/snip]

Exactly, YMMV

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



Re: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread Richard Lynch
Don't use exec. ;-v

Or, perhaps, write a shell script that reads the password and provides
it to MySQL somehow without invoking another exec of some kind.

You also could look into other MySQL authentication mechanisms such as
SSL keys and whatnot -- which I only vaguely recall seeing somewhere
in the MySQL docs.

That might still end up with a PHP/world readable file that has a
private key in it, but at least it requires the Bad Guy to take one
more step to read said file.

On Wed, November 29, 2006 6:10 am, Jochem Maas wrote:
> I have been using exec() for a number of things recently - one of the
> things
> I'm using it for it to run mysql in order to import SQL scripts
>
> so I have some code that looks like:
>
> // build the cmdline
> $cmd = sprintf('mysql -h %s --user=%s --password=`cat %s` -D %s <
> "%s" 2>&1',
>MYSQL_SERVER, MYSQL_ROOT_USER, $rootPasswdFile,
>$data['db_name']['value'], $file);
>
> // run the mysql command via the cmdline
> $output = array(); $exit = 0;
> @exec($cmd, $output, $exit);
>
> everything works. but there is a security issue - one that I thought I
> had
> specifically tackled.
>
> the security issue occurs due to the fact that the process list (this
> is
> just linux I'm talking about) will show the complete command line,
> which in
> my case would look something like (in the processlist):
>
>
> mysql -h localhost --user=admin --password=`cat
> /my/sql/root/passwd/file` -D somedb < "/my/import/script.sql" 2>&1
>
>
> AH I hear you say but the wily use of "`cat /my/sql/root/passwd/file`"
> masks the actual
> password from any looking in the process list. indeed undeer normal
> shell scripting circumstances
> that may have been true.
>
> BUT in using php's exec() to run the cmdline causes the following to
> show up in the processlist:
>
>
> sh -c mysql -h localhost --user=admin --password=`cat
> /my/sql/root/passwd/file` -D somedb < "/my/import/script.sql" 2>&1
>
>
> AND that [sub]shell then lists it's process[s] in the list also, there
> is only one
> and it is this:
>
>
> mysql -h localhost --user=admin --password=MYFINGPWD -D somedb
>
>
> does anyone have an idea how to over come this security issue (without
> resorting to having to
> type in the mysql admin passwd interactively!)
>
> thanks & regards,
> Jochem
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] counting clicks

2006-11-29 Thread Richard Lynch
On Wed, November 29, 2006 11:21 am, Jay Blanchard wrote:
> [snip]
> Anyone got a script so I can count clicks on adverts. Doesn't have
> tosve
> to
> myqsl or anything just a text file will do.
> [/snip]
>
> 
> if("yes" == $adClicked){
>$adClickCountFile = fopen("countClick.txt", "w");
>$getCount = fgets($adClickCountFile, 4096);
>$newCount = $getCount + 1;
>fwrite($adClickCountFile, $newCount);
>fclose($adClickCountFile);
> }
> ?>

This has a race condition where a busy server, or even a not-so-busy
one where 2 people happen to click at the same time, at least one of
them will be "missed", at best.

There's also a distinct possiblity of the counter file getting
completely trashed, depending on the OS and its underlying atomicity
of fwrite().

And, finally, you'd need "w+" in that fopen() to avoid wiping out the
old data to start with.

For this reason, and more, you're almost-for-sure better off keeping
track in a database which solves all the nasty race condition issues.

YMMV

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


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] passing an object using session var

2006-11-29 Thread list arama

errata:

$newObj->display();// this *does* work


On 11/29/06, list arama <[EMAIL PROTECTED]> wrote:


Here's what I came up with:

--script1---
setName('MyName');
$obj->display();
header("Location: http://localhost/~mdl/webProj/photoAlbum2/receive.php
");
ob_flush();
?>
---script2---
display();//
$newObj->display();// this doesn't
$_SESSION = array();// unsets session having effect that script fails
on every second call
?>

My only remaining question is why the session fails every second time if
the session is emptied and destroyed. Shouldn't script1 initialize a totally
new session and populate with fresh session vars?


On 11/29/06, Eric Butera <[EMAIL PROTECTED]> wrote:
>
> On 11/29/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > Thomas Munz wrote:
> > > Try that:
> > >
> > >  --script1---
> > >  > >  include(" TestClass.php");
> > > session_start();
> > >
> > > $obj = new TestClass();
> > > $obj->setName('MyName');
> > > $obj->display();// outputs 'MyName'
> > >
> > > $str_object = serialize($obj); //-- You need to serialize an object
> ( see php.net manual ) in order to make an object working via session
> >
> > DONT SERIALIZE! its done automatically
> >
> > >
> > > $_SESSION['obj'] = $str_object: //-- save serialized string in the
> session,note: Use $_SESSION instead of session_register();
> > >
> > > header("Location:
> 
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php");
  //
> re-direct to script2
> > >
> > > ---script 2
> > >  > > include("TestClass.php");
> > > session_start();
> > >
> > > $newObj = unserialize($_SESSION['obj']); //-- convert string back
> into object
> >
> > DONT UNSERIALIZE! its done automatically
> >
> > > $newObj->display();   // MyName
> > >
> > >
> > > on Wednesday 29 November 2006 16:18, list arama wrote:
> > >> Why am I not able to access the obj name field in script 2?
> > >>
> > >> thanks in advance,
> > >>
> > >> --script1---
> > >>
> > >>  > >>
> > >> include("TestClass.php");
> > >>
> > >> session_start();
> > >> session_register('obj');
> >
> > session_register() et al are going the way of the dino.
> > just use $_SESSION directly, just remember to call session_start()
> > before you try to use $_SESSION
> >
> > >>
> > >> ob_start();
> > >>
> > >> $obj = new TestClass();
> > >>
> > >> $obj->setName('MyName');
> > >> $obj->display();// outputs 'MyName'
> > >>
> > >> header("Location:
> > >> 
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php");
  //
>
> > >> re-direct to script2
> > >>
> > >> ob_flush();
> > >>
> > >> ?>
> > >>
> > >> ---script 2
> > >>
> > >>  > >>
> > >> include("TestClass.php");
> > >>
> > >> session_start();
> > >>
> > >> $newObj = $HTTP_SESSION_VARS['obj'];
> > >>
> > >> $newObj->display();   // no output, meaning no data?
> > >>
> > >> $newObj->setName('Michael');
> > >> $newObj->display();  // outputs 'Michael' using obj methods
> > >>
> > >> ?>
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> It might be worth noting that if you are using php4 remember to pass
> your object by reference when setting/retrieving from the session.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



Re: [PHP] passing an object using session var

2006-11-29 Thread list arama

Here's what I came up with:

--script1---
setName('MyName');
$obj->display();
header("Location: http://localhost/~mdl/webProj/photoAlbum2/receive.php";);
ob_flush();
?>
---script2---
display();//
$newObj->display();// this doesn't
$_SESSION = array();// unsets session having effect that script fails on
every second call
?>

My only remaining question is why the session fails every second time if the
session is emptied and destroyed. Shouldn't script1 initialize a totally new
session and populate with fresh session vars?


On 11/29/06, Eric Butera <[EMAIL PROTECTED]> wrote:


On 11/29/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Thomas Munz wrote:
> > Try that:
> >
> >  --script1---
> >  >  include("TestClass.php");
> > session_start();
> >
> > $obj = new TestClass();
> > $obj->setName('MyName');
> > $obj->display();// outputs 'MyName'
> >
> > $str_object = serialize($obj); //-- You need to serialize an object (
see php.net manual ) in order to make an object working via session
>
> DONT SERIALIZE! its done automatically
>
> >
> > $_SESSION['obj'] = $str_object: //-- save serialized string in the
session,note: Use $_SESSION instead of session_register();
> >
> > header("Location:
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
re-direct to script2
> >
> > ---script 2
> >  > include("TestClass.php");
> > session_start();
> >
> > $newObj = unserialize($_SESSION['obj']); //-- convert string back into
object
>
> DONT UNSERIALIZE! its done automatically
>
> > $newObj->display();   // MyName
> >
> >
> > on Wednesday 29 November 2006 16:18, list arama wrote:
> >> Why am I not able to access the obj name field in script 2?
> >>
> >> thanks in advance,
> >>
> >> --script1---
> >>
> >>  >>
> >> include("TestClass.php");
> >>
> >> session_start();
> >> session_register('obj');
>
> session_register() et al are going the way of the dino.
> just use $_SESSION directly, just remember to call session_start()
> before you try to use $_SESSION
>
> >>
> >> ob_start();
> >>
> >> $obj = new TestClass();
> >>
> >> $obj->setName('MyName');
> >> $obj->display();// outputs 'MyName'
> >>
> >> header("Location:
> >> http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
> >> re-direct to script2
> >>
> >> ob_flush();
> >>
> >> ?>
> >>
> >> ---script 2
> >>
> >>  >>
> >> include("TestClass.php");
> >>
> >> session_start();
> >>
> >> $newObj = $HTTP_SESSION_VARS['obj'];
> >>
> >> $newObj->display();   // no output, meaning no data?
> >>
> >> $newObj->setName('Michael');
> >> $newObj->display();  // outputs 'Michael' using obj methods
> >>
> >> ?>
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

It might be worth noting that if you are using php4 remember to pass
your object by reference when setting/retrieving from the session.

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




Re: [PHP] passing an object using session var

2006-11-29 Thread Eric Butera

On 11/29/06, Jochem Maas <[EMAIL PROTECTED]> wrote:

Thomas Munz wrote:
> Try that:
>
>  --script1---
>   include("TestClass.php");
> session_start();
>
> $obj = new TestClass();
> $obj->setName('MyName');
> $obj->display();// outputs 'MyName'
>
> $str_object = serialize($obj); //-- You need to serialize an object ( see 
php.net manual ) in order to make an object working via session

DONT SERIALIZE! its done automatically

>
> $_SESSION['obj'] = $str_object: //-- save serialized string in the 
session,note: Use $_SESSION instead of session_register();
>
> header("Location: 
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  // re-direct to 
script2
>
> ---script 2
>  include("TestClass.php");
> session_start();
>
> $newObj = unserialize($_SESSION['obj']); //-- convert string back into object

DONT UNSERIALIZE! its done automatically

> $newObj->display();   // MyName
>
>
> on Wednesday 29 November 2006 16:18, list arama wrote:
>> Why am I not able to access the obj name field in script 2?
>>
>> thanks in advance,
>>
>> --script1---
>>
>> >
>> include("TestClass.php");
>>
>> session_start();
>> session_register('obj');

session_register() et al are going the way of the dino.
just use $_SESSION directly, just remember to call session_start()
before you try to use $_SESSION

>>
>> ob_start();
>>
>> $obj = new TestClass();
>>
>> $obj->setName('MyName');
>> $obj->display();// outputs 'MyName'
>>
>> header("Location:
>> http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
>> re-direct to script2
>>
>> ob_flush();
>>
>> ?>
>>
>> ---script 2
>>
>> >
>> include("TestClass.php");
>>
>> session_start();
>>
>> $newObj = $HTTP_SESSION_VARS['obj'];
>>
>> $newObj->display();   // no output, meaning no data?
>>
>> $newObj->setName('Michael');
>> $newObj->display();  // outputs 'Michael' using obj methods
>>
>> ?>
>

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




It might be worth noting that if you are using php4 remember to pass
your object by reference when setting/retrieving from the session.

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



RE: [PHP] counting clicks

2006-11-29 Thread Jay Blanchard
[snip]
Anyone got a script so I can count clicks on adverts. Doesn't have tosve
to 
myqsl or anything just a text file will do.
[/snip]



YMMV

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



[PHP] counting clicks

2006-11-29 Thread Ross
Anyone got a script so I can count clicks on adverts. Doesn't have tosve to 
myqsl or anything just a text file will do.


Ta

Ross 

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



Re: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread Stut

[EMAIL PROTECTED] wrote:

Ah.. makes sense.   Good old DOS is stupid enough not to card most times.  You can create 
a text file with a "Y" in it, and redirect it into a command like:

del . < y.txt


Guess that's not a pipe technically.  And some commands may be smart enough to 
prevent something like this.
  


Technically it is a pipe, but that's really beside the point.

The point I was making is that you cannot pipe something into a process 
with the | character *and* redirect stdin with the < character.


The stdin redirect (<) can be used with any command that takes input 
through stdin (usually the keyboard on a standard console).


-Stut

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



Re: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread tg-php
Ah.. makes sense.   Good old DOS is stupid enough not to card most times.  You 
can create a text file with a "Y" in it, and redirect it into a command like:

del . < y.txt


Guess that's not a pipe technically.  And some commands may be smart enough to 
prevent something like this.

Thanks for the info Stut!

-TG

= = = Original message = = =

[EMAIL PROTECTED] wrote:
> I don't know if this would work, but maybe something like this:
>
> cat /my/sql/root/passwd/file | mysql -h localhost --user=admin -D somedb < 
> "/my/import/script.sql" 2>&1
>
> No idea if that'd work, but it might put you in the right ballpark.

You can't do this. The pipe gets overridden by the stdin redirect (at 
least it does on FreeBSD 5.4).

Jochem: You need to read this... 
http://dev.mysql.com/doc/refman/5.0/en/password-security.html

-Stut



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread Stut

[EMAIL PROTECTED] wrote:

I don't know if this would work, but maybe something like this:

cat /my/sql/root/passwd/file | mysql -h localhost --user=admin -D somedb < 
"/my/import/script.sql" 2>&1

No idea if that'd work, but it might put you in the right ballpark.


You can't do this. The pipe gets overridden by the stdin redirect (at 
least it does on FreeBSD 5.4).


Jochem: You need to read this... 
http://dev.mysql.com/doc/refman/5.0/en/password-security.html


-Stut

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



RE: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread tg-php
Would it be possible, Jochem, to just make a shell script that does the call to 
mysql and have PHP exec() the shell script?

I don't know if you'd have the same problem or not.  I've never done something 
like this in *nix and paid attention to the process list.

Also, I'm guessing you're seeing your password show up because, if I recall, 
putting a command in backticks `command`  will evaluate the command insert it's 
output in that spot, so your "cat" command gets pre-evaluated before the line 
is executed. (maybe you knew how that worked or maybe you just knew that doing 
it this way worked.. but I think that's what happens if memory serves).

You may be able to do something else that doesn't involve using the backticks.

If you leave off the password string, it asks for the password interactively 
right?  In DOS and I believe in *nix systems, you can simulate the interactive 
part with pipes.

I don't know if this would work, but maybe something like this:

cat /my/sql/root/passwd/file | mysql -h localhost --user=admin -D somedb < 
"/my/import/script.sql" 2>&1


No idea if that'd work, but it might put you in the right ballpark.

Good luck and let us know when you find a good solution!

-TG


= = = Original message = = =

hi jochem...

if no one provides you with a solution.. you might replicate what's already
been done in one of the php/mysql/web admin apps. given that these apps
already manage the mysql functions, so i'm willing to bet that some of them
have resolved this issue...



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 29, 2006 4:10 AM
To: [php] PHP General List
Subject: [PHP] hiding passwd in cmdlines that appear in the process list


I have been using exec() for a number of things recently - one of the things
I'm using it for it to run mysql in order to import SQL scripts

so I have some code that looks like:

// build the cmdline
$cmd = sprintf('mysql -h %s --user=%s --password=`cat %s` -D %s < "%s"
2>&1',
   MYSQL_SERVER, MYSQL_ROOT_USER, $rootPasswdFile,
   $data['db_name']['value'], $file);

// run the mysql command via the cmdline
$output = array(); $exit = 0;
@exec($cmd, $output, $exit);

everything works. but there is a security issue - one that I thought I had
specifically tackled.

the security issue occurs due to the fact that the process list (this is
just linux I'm talking about) will show the complete command line, which in
my case would look something like (in the processlist):


mysql -h localhost --user=admin --password=`cat /my/sql/root/passwd/file` -D
somedb < "/my/import/script.sql" 2>&1


AH I hear you say but the wily use of "`cat /my/sql/root/passwd/file`" masks
the actual
password from any looking in the process list. indeed undeer normal shell
scripting circumstances
that may have been true.

BUT in using php's exec() to run the cmdline causes the following to show up
in the processlist:


sh -c mysql -h localhost --user=admin --password=`cat
/my/sql/root/passwd/file` -D somedb < "/my/import/script.sql" 2>&1


AND that [sub]shell then lists it's process[s] in the list also, there is
only one
and it is this:


mysql -h localhost --user=admin --password=MYFINGPWD -D somedb


does anyone have an idea how to over come this security issue (without
resorting to having to
type in the mysql admin passwd interactively!)

thanks & regards,
Jochem



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Tidy HTML source?

2006-11-29 Thread Sancar Saran
OUCH,

man this was avesome, probably best idea after php himself. 

 More than 6 years I punching php code. 

I try tons of aproach to find better solution for html output and this one far 
more advanced any of them.

I'll check it now 

Many thanks

Regards

Sancar

On Tuesday 28 November 2006 15:05, Satyam wrote:
> May I invite you to check http://satyam.com.ar/pht/?   This is a project I
> started some time ago to help me produced HTML in a more clean and
> efficient way.  Usually, producing good HTML involves running a sample
> output through some HTML validator or looking at the HTML and checking it
> out by hand, which, of course, requires good formatting to make it
> understandable.   In the case of too dynamic HTML (meaning, output can vary
> widely) it is impossible to produce enough samples of all the possible
> outputs to get them checked out.
>
> So, my idea was to embed HTML into the language itself so that the final
> output could be checked at 'compile time' and even before, using the
> standard tools provided by the IDE (even just matching braces goes a long
> way into checking for missmatched HTML tags).
>
> The samples page (http://satyam.com.ar/pht/sample.htm) show several
> examples.
>
> I think that a tool such as this one might avoid any concern about tidying
> up HTML since, after all, most of the checking could be done at the PHP
> source level.   Further development (which I have not started yet) would
> lead to automatic verification against DTDs or XSchemas.
>
> And, of course, I would appreciate any comment on the project, EXCEPT that
> you use template engines and that you do not generate HTML directly.  I've
> heard that and it is completely missing the point so, please, spare me that
> one.  At one point or another plain HTML has to be generated.
>
> Satyam
>
> - Original Message -
> From: "Mark Kelly" <[EMAIL PROTECTED]>
> To: 
> Sent: Tuesday, November 28, 2006 4:13 AM
> Subject: Re: [PHP] Tidy HTML source?
>
> > On Monday 27 November 2006 17:10, Mark Kelly wrote:
> >> Am I crazy to make an extra effort in my code to make the generated HTML
> >> pretty?
> >
> > Thanks everyone for your thoughts on this - I'm quite relieved that I'm
> > not
> > the only one who sits and tweaks so that the HTML is nice and readable.
> >
> > It just struck me that trying to make my PHP spit out page source that
> > looks like it was made lovingly by hand was perhaps the work of an
> > obsessive.
> >
> > Now I know that even if it is, I'm not alone :)
> >
> > Cheers!
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php

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



Re: [PHP] Passwords suddenly not working

2006-11-29 Thread Janet Valade

Dave M G wrote:


PHP List,

I have a few scripts that have been around for a while. In one, is a 
simple login function:


$query = "SELECT * FROM forum_members WHERE memberName = '" . $username 
. "' AND passwd = MD5('" . $password . "')";

$result = mysql_query($query);

This was working fine, but recently I haven't been able to log in. I 
think the only thing that has changed is that on my hosting service, 
they recently upgraded to PHP 5.1.6. (MySQL is 4.1.21, but I think it's 
been that for quite a while)


Perhaps you have error reporting turned off. Errors or warnings may be 
generated but not displayed. Add the following to the top of your 
program to temporarily see the error messages:


error_reporting(E_ALL);

Also check in php.ini to make sure that

You may also want to see if any MySQL errors are being generated. Try 
the following code:


$result = mysql_query($query)
 or die("Query failed: ".mysql_error());

With this code, if the query fails, the program will stop and an error 
message will be displayed.


You also may want to display $query before you execute it to see what, 
exactly, is being executed.


Janet






Is there any potential for PHP 5.1.6 to handle things different when it 
comes to MySQL queries, post data, or anything? I thought it might be 
that I still had $HTTP_POST_VARS for some of my variables, but I changed 
them all to $_POST, and it still doesn't work.


I don't get any errors or anything. My own code is not very 
sophisticated for error reporting. But I'm not getting any PHP syntax 
errors of any kind. If I run the SQL code by itself at an SQL command 
prompt, I get results back, so I don't think the SQL is failing.


Are there any gotchas in the upgrade that I might be missing? I can't 
think of anything else that could be a culprit (though of course I'm 
open to suggestions).


Any advice would be much appreciated.

--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2




--
Janet Valade -- janet.valade.com

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



Re: [PHP] passing an object using session var

2006-11-29 Thread Jochem Maas
Thomas Munz wrote:
> Try that:
> 
>  --script1---
>   include("TestClass.php");
> session_start();
> 
> $obj = new TestClass();
> $obj->setName('MyName');
> $obj->display();// outputs 'MyName'
> 
> $str_object = serialize($obj); //-- You need to serialize an object ( see 
> php.net manual ) in order to make an object working via session

DONT SERIALIZE! its done automatically

> 
> $_SESSION['obj'] = $str_object: //-- save serialized string in the 
> session,note: Use $_SESSION instead of session_register();
> 
> header("Location: 
> http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  // 
> re-direct to script2
> 
> ---script 2
>  include("TestClass.php");
> session_start();
> 
> $newObj = unserialize($_SESSION['obj']); //-- convert string back into object

DONT UNSERIALIZE! its done automatically

> $newObj->display();   // MyName 
> 
> 
> on Wednesday 29 November 2006 16:18, list arama wrote:
>> Why am I not able to access the obj name field in script 2?
>>
>> thanks in advance,
>>
>> --script1---
>>
>> >
>> include("TestClass.php");
>>
>> session_start();
>> session_register('obj');

session_register() et al are going the way of the dino.
just use $_SESSION directly, just remember to call session_start()
before you try to use $_SESSION

>>
>> ob_start();
>>
>> $obj = new TestClass();
>>
>> $obj->setName('MyName');
>> $obj->display();// outputs 'MyName'
>>
>> header("Location:
>> http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
>> re-direct to script2
>>
>> ob_flush();
>>
>> ?>
>>
>> ---script 2
>>
>> >
>> include("TestClass.php");
>>
>> session_start();
>>
>> $newObj = $HTTP_SESSION_VARS['obj'];
>>
>> $newObj->display();   // no output, meaning no data?
>>
>> $newObj->setName('Michael');
>> $newObj->display();  // outputs 'Michael' using obj methods
>>
>> ?>
> 

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



Re: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread Jochem Maas
bruce wrote:
> hi jochem...
> 
> if no one provides you with a solution.. you might replicate what's already
> been done in one of the php/mysql/web admin apps. given that these apps
> already manage the mysql functions, so i'm willing to bet that some of them
> have resolved this issue...

they don't have the issue because they don't use exec() to call mysql via the
command line.

and I'm rather hoping not to have to replicate squillions of lines of code
to safely parse and execute an abitrarily complex SQL script in order to
circumvent an annoyance with exec()

my problem is nothing to do with mysql as such - it's a case of wanting
to stop passwords that need to be given in cmdline (like you do when you run 
mysql)
being visible in the process list (ps -ef) ... I thought I had the answer
but found I was actuallt being given the bird by a subshell :-).

> 
> 
> 
> -Original Message-
> From: Jochem Maas [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 29, 2006 4:10 AM
> To: [php] PHP General List
> Subject: [PHP] hiding passwd in cmdlines that appear in the process list
> 
> 
> I have been using exec() for a number of things recently - one of the things
> I'm using it for it to run mysql in order to import SQL scripts
> 
> so I have some code that looks like:
> 
> // build the cmdline
> $cmd = sprintf('mysql -h %s --user=%s --password=`cat %s` -D %s < "%s"
> 2>&1',
>MYSQL_SERVER, MYSQL_ROOT_USER, $rootPasswdFile,
>$data['db_name']['value'], $file);
> 
> // run the mysql command via the cmdline
> $output = array(); $exit = 0;
> @exec($cmd, $output, $exit);
> 
> everything works. but there is a security issue - one that I thought I had
> specifically tackled.
> 
> the security issue occurs due to the fact that the process list (this is
> just linux I'm talking about) will show the complete command line, which in
> my case would look something like (in the processlist):
> 
> 
> mysql -h localhost --user=admin --password=`cat /my/sql/root/passwd/file` -D
> somedb < "/my/import/script.sql" 2>&1
> 
> 
> AH I hear you say but the wily use of "`cat /my/sql/root/passwd/file`" masks
> the actual
> password from any looking in the process list. indeed undeer normal shell
> scripting circumstances
> that may have been true.
> 
> BUT in using php's exec() to run the cmdline causes the following to show up
> in the processlist:
> 
> 
> sh -c mysql -h localhost --user=admin --password=`cat
> /my/sql/root/passwd/file` -D somedb < "/my/import/script.sql" 2>&1
> 
> 
> AND that [sub]shell then lists it's process[s] in the list also, there is
> only one
> and it is this:
> 
> 
> mysql -h localhost --user=admin --password=MYFINGPWD -D somedb
> 
> 
> does anyone have an idea how to over come this security issue (without
> resorting to having to
> type in the mysql admin passwd interactively!)
> 
> thanks & regards,
> Jochem
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread bruce
hi jochem...

if no one provides you with a solution.. you might replicate what's already
been done in one of the php/mysql/web admin apps. given that these apps
already manage the mysql functions, so i'm willing to bet that some of them
have resolved this issue...



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 29, 2006 4:10 AM
To: [php] PHP General List
Subject: [PHP] hiding passwd in cmdlines that appear in the process list


I have been using exec() for a number of things recently - one of the things
I'm using it for it to run mysql in order to import SQL scripts

so I have some code that looks like:

// build the cmdline
$cmd = sprintf('mysql -h %s --user=%s --password=`cat %s` -D %s < "%s"
2>&1',
   MYSQL_SERVER, MYSQL_ROOT_USER, $rootPasswdFile,
   $data['db_name']['value'], $file);

// run the mysql command via the cmdline
$output = array(); $exit = 0;
@exec($cmd, $output, $exit);

everything works. but there is a security issue - one that I thought I had
specifically tackled.

the security issue occurs due to the fact that the process list (this is
just linux I'm talking about) will show the complete command line, which in
my case would look something like (in the processlist):


mysql -h localhost --user=admin --password=`cat /my/sql/root/passwd/file` -D
somedb < "/my/import/script.sql" 2>&1


AH I hear you say but the wily use of "`cat /my/sql/root/passwd/file`" masks
the actual
password from any looking in the process list. indeed undeer normal shell
scripting circumstances
that may have been true.

BUT in using php's exec() to run the cmdline causes the following to show up
in the processlist:


sh -c mysql -h localhost --user=admin --password=`cat
/my/sql/root/passwd/file` -D somedb < "/my/import/script.sql" 2>&1


AND that [sub]shell then lists it's process[s] in the list also, there is
only one
and it is this:


mysql -h localhost --user=admin --password=MYFINGPWD -D somedb


does anyone have an idea how to over come this security issue (without
resorting to having to
type in the mysql admin passwd interactively!)

thanks & regards,
Jochem

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

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



Re: [PHP] passing an object using session var

2006-11-29 Thread Thomas Munz
Try that:

 --script1---
setName('MyName');
$obj->display();// outputs 'MyName'

$str_object = serialize($obj); //-- You need to serialize an object ( see 
php.net manual ) in order to make an object working via session

$_SESSION['obj'] = $str_object: //-- save serialized string in the 
session,note: Use $_SESSION instead of session_register();

header("Location: 
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  // re-direct 
to script2

---script 2
display();   // MyName 


on Wednesday 29 November 2006 16:18, list arama wrote:
> Why am I not able to access the obj name field in script 2?
>
> thanks in advance,
>
> --script1---
>
> 
> include("TestClass.php");
>
> session_start();
> session_register('obj');
>
> ob_start();
>
> $obj = new TestClass();
>
> $obj->setName('MyName');
> $obj->display();// outputs 'MyName'
>
> header("Location:
> http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
> re-direct to script2
>
> ob_flush();
>
> ?>
>
> ---script 2
>
> 
> include("TestClass.php");
>
> session_start();
>
> $newObj = $HTTP_SESSION_VARS['obj'];
>
> $newObj->display();   // no output, meaning no data?
>
> $newObj->setName('Michael');
> $newObj->display();  // outputs 'Michael' using obj methods
>
> ?>

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



[PHP] passing an object using session var

2006-11-29 Thread list arama

Why am I not able to access the obj name field in script 2?

thanks in advance,

--script1---

setName('MyName');
$obj->display();// outputs 'MyName'

header("Location:
http://localhost/~lr/webProj/photoAlbum2/sessionReceiveObj.php";);  //
re-direct to script2

ob_flush();

?>

---script 2

display();   // no output, meaning no data?

$newObj->setName('Michael');
$newObj->display();  // outputs 'Michael' using obj methods

?>


Re: [PHP] Tidy HTML source?

2006-11-29 Thread Fredrik Thuresson
"is ever generated by anyone at anytime?   Most pre-packaged applications
> such as blogs, CMS, picture galleries do produce HTML directly without
> template engines which would require a separate installation issues and
> dependencies which most designers try to avoid.  Even template engines
> have
> libraries of gadgets which do produce HTML directly."

Good point. That's the example I was looking for. Thanks. Just didn't make
sense late last night why you would go through all the effort and I did
read your thread. The \n\t\t\t was just meant to show one of the reasons
why I chose to move it out of the php code.

No doubt, is your solution impressive for the purpose it serves. I did not
mean to offend you in any way.
GL.
Fredrik
>
> - Original Message -
> From: "Fredrik Thuresson" <[EMAIL PROTECTED]>
> To: 
> Sent: Wednesday, November 29, 2006 5:45 AM
> Subject: Re: [PHP] Tidy HTML source?
>
>
>> "At one point or another plain HTML has to be generated. "
>>
>> Care to give me an example? I never generate any html in my php code
>> anymore.
>>
> You are entitled not to, but stretching it to the point of denying that
> HTML
> is ever generated by anyone at anytime?   Most pre-packaged applications
> such as blogs, CMS, picture galleries do produce HTML directly without
> template engines which would require a separate installation issues and
> dependencies which most designers try to avoid.  Even template engines
> have
> libraries of gadgets which do produce HTML directly.
>
> So, you might not echo HTML directly.  That is fine, it is an option.
> This
> is not for you.  Evidently those who participated in these thread before
> do
> generate HTML directly because they are concerned about formatting it and
> that would be unnecesary if they used templates.
>
>> It's not very pretty when your code looks like echo
>> "\n\t\t\t\t\t\t";
>>
>
> Look at the examples I pointed to, you won't see anything like that.
>
>> Is that not a form of a templating engine that your are building?
>
> No, not at all.  Just read the document.  Moreover, I would appreciated if
> you read my e-mail in full, specially the part that says:  " I would
> appreciate any comment on the project, EXCEPT that you use template
> engines
> and that you do not generate HTML  directly."
>
> Satyam
>
>
>>
>> Fredrik
>>
>> Satyam wrote:
>>> May I invite you to check http://satyam.com.ar/pht/?   This is a
>>> project
>>> I started some time ago to help me produced HTML in a more clean and
>>> efficient way.  Usually, producing good HTML involves running a sample
>>> output through some HTML validator or looking at the HTML and checking
>>> it
>>> out by hand, which, of course, requires good formatting to make it
>>> understandable.   In the case of too dynamic HTML (meaning, output can
>>> vary widely) it is impossible to produce enough samples of all the
>>> possible outputs to get them checked out.
>>>
>>> So, my idea was to embed HTML into the language itself so that the
>>> final
>>> output could be checked at 'compile time' and even before, using the
>>> standard tools provided by the IDE (even just matching braces goes a
>>> long
>>> way into checking for missmatched HTML tags).
>>>
>>> The samples page (http://satyam.com.ar/pht/sample.htm) show several
>>> examples.
>>>
>>> I think that a tool such as this one might avoid any concern about
>>> tidying up HTML since, after all, most of the checking could be done at
>>> the PHP source level.   Further development (which I have not started
>>> yet) would lead to automatic verification against DTDs or XSchemas.
>>>
>>> And, of course, I would appreciate any comment on the project, EXCEPT
>>> that you use template engines and that you do not generate HTML
>>> directly.
>>> I've heard that and it is completely missing the point so, please,
>>> spare
>>> me that one.  At one point or another plain HTML has to be generated.
>>>
>>> Satyam
>>>
>>> - Original Message - From: "Mark Kelly" <[EMAIL PROTECTED]>
>>> To: 
>>> Sent: Tuesday, November 28, 2006 4:13 AM
>>> Subject: Re: [PHP] Tidy HTML source?
>>>
>>>
 On Monday 27 November 2006 17:10, Mark Kelly wrote:

> Am I crazy to make an extra effort in my code to make the generated
> HTML
> pretty?

 Thanks everyone for your thoughts on this - I'm quite relieved that
 I'm
 not
 the only one who sits and tweaks so that the HTML is nice and
 readable.

 It just struck me that trying to make my PHP spit out page source that
 looks like it was made lovingly by hand was perhaps the work of an
 obsessive.

 Now I know that even if it is, I'm not alone :)

 Cheers!

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

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

RE: [PHP] backing up a database

2006-11-29 Thread Kristen G. Thorson
> -Original Message-
> From: James Tu [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 28, 2006 5:03 PM
> To: PHP General List
> Subject: Re: [PHP] backing up a database
> 
> Thanks Brad:
> 
> I'm just surprised that when people mention mysqldump, most of the
> time they don't talk about locking the tables at all.
> I'm curious why this is the case.
> 
> -James
> 



Unless you tell mysqldump not to lock tables, or change the defaults, it
automatically locks:

"For example, use of --opt is the same as specifying --add-drop-table
--add-locks --create-options --disable-keys --extended-insert
--lock-tables --quick --set-charset. Note that as of MySQL 4.1, all of
the options that --opt stands for also are on by default because --opt
is on by default."

http://dev.mysql.com/doc/refman/4.1/en/mysqldump.html

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



[PHP] Re: backing up a database

2006-11-29 Thread David Giragosian

On 11/28/06, Warren Vail <[EMAIL PROTECTED] > wrote:


I think it becomes an issue only if the database structure is complex
with multiple related tables, and have lots of update activity.  I think
most people design applications that don't require anything so complex,
and most queries are of the select variety.

Warren Vail

-Original Message-
From: Chris [mailto: [EMAIL PROTECTED]
Sent: Tuesday, November 28, 2006 2:50 PM
To: James Tu
Cc: PHP General List
Subject: Re: [PHP] backing up a database

James Tu wrote:
> Thanks Brad:
>
> I'm just surprised that when people mention mysqldump, most of the
time
> they don't talk about locking the tables at all.
> I'm curious why this is the case.

Because you don't need to. More of a mysql-mailing list question to be
honest.

C:\>mysqldump  --help


--opt   Same as --add-drop-table, --add-locks, --create-options,
--quick, --extended-insert, --lock-tables,
--set-charset,
and --disable-keys. *Enabled by default *, disable with
--skip-opt.

If you use the --opt flag, all is well...

David


Re: [PHP] Tidy HTML source?

2006-11-29 Thread Satyam
- Original Message - 
From: "Paul Novitski" <[EMAIL PROTECTED]>




At 11/28/2006 05:05 AM, Satyam wrote:
May I invite you to check http://satyam.com.ar/pht/?   This is a project I 
started some time ago to help me produced HTML in a more clean and 
efficient way.  Usually, producing good HTML involves running a sample 
output through some HTML validator or looking at the HTML and checking it 
out by hand, which, of course, requires good formatting to make it 
understandable.   In the case of too dynamic HTML (meaning, output can 
vary widely) it is impossible to produce enough samples of all the 
possible outputs to get them checked out.


So, my idea was to embed HTML into the language itself so that the final 
output could be checked at 'compile time' and even before, using the 
standard tools provided by the IDE (even just matching braces goes a long 
way into checking for missmatched HTML tags).



Satyam,

That's an impressive bit of work, congratulations.

It's interesting to see someone spend such energy merging PHP logic with 
HTML.  I've gone in the opposite direction, separating the two as much as 
possible.  My own CMS merges content with HTML based on CSS-style 
selectors so that the logic layer of my applications doesn't need to 
know -- or contain -- the full details of the markup.  I find this a 
natural and agreeable extension of the move to separate HTML markup from 
CSS presentation and JavaScript behavior.



It's interesting to note that for all your effort to generate good, clean 
HTML, you're still able to generate a div nested inside a table:


http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1

Your pre-compiler has ensured that all your tags are well-formed, but it 
doesn't ensure that you've followed the rules of correct markup.  Perhaps 
a future iteration of your software will incorporate more HTML structural 
rules and will give you precompiler errors in such cases.




That would be something to be dealt with in the second part of the project, 
that of validating the HTML output against the DTD.  Actually, the 
pre-compiler is meant for generic XML, thus it does not know about divs and 
tables, it just knows about how to output properly formatted XML.




You write:

So, we have two well structured languages, one is procedural (any flavor 
of C, JavaScript, PHP, Perl, etc.), the other descriptive. Their blocks 
are quite compatible: to start with, they nest nicely within each other. 
If an XML block is contained within an if() block, it has to be completely 
within it, the boundaries of their blocks should not overlap.


Help me understand the relevance of this statement. A very common pattern 
in a mixed logic/HTML script goes like this:


echo '';

foreach (array as item)
{
echo 'item';
}

echo '';

In these cases the boundaries of the HTML block do in fact overlap the 
boundaries of the foreach() logic block.




Perhaps 'overlap' is not the right word, I mean that one is fully contained 
within the other.  The braces of the foreach are fully enclosed by the ul 
and the li tag is fully within the braces.


And, of course, I would appreciate any comment on the project, EXCEPT that 
you use template engines and that you do not generate HTML directly.  I've 
heard that and it is completely missing the point so, please, spare me 
that one.  At one point or another plain HTML has to be generated.


Unless I'm missing the boat, it seems to me that the primary advantage of 
your precompiler is that it enables you to close HTML tags simply by 
closing braces, a convention policed by your pre-compiler and the PHP 
interpreter itself, so that you'll get pre-compiler or interpreter errors 
for incorrect closure instead of waiting for the W3C validator to check 
your work.  I don't mean to minimize the significance of your 
accomplishment, but personally I don't find generating accurate markup to 
be a great problem.  I'm a careful hand-coder, and true to the topic of 
this thread I find that neatly-indented HTML helps me validate my own 
markup.  Online validators help me catch any errors I miss.


Without the second part, validating against the DTD, yes, it doesn't do much 
more than you say.




What I find to be a much greater problem is the human readability of logic 
code when HTML is mixed throughout.  Your innovation is helpful here, as 
you're nearly making HTML tags into PHP key words, eliminating some of the 
literal quoting that makes PHP+HTML so tiresome.  However, even with your 
pre-compiler the messy quotes are still there on the attribute level.


The value of the attribute is any valid PHP expression and if they are 
literal strings there will be quotes, but then, you can also use heredoc if, 
for example, you are putting some JavaScript code into an event.  If the 
value is a numeric value, there is no need for any quotes at all.  In the 
end, the value of an attribute is any valid PHP expression an

[PHP] hiding passwd in cmdlines that appear in the process list

2006-11-29 Thread Jochem Maas
I have been using exec() for a number of things recently - one of the things
I'm using it for it to run mysql in order to import SQL scripts

so I have some code that looks like:

// build the cmdline
$cmd = sprintf('mysql -h %s --user=%s --password=`cat %s` -D %s < "%s" 
2>&1',
   MYSQL_SERVER, MYSQL_ROOT_USER, $rootPasswdFile,
   $data['db_name']['value'], $file);

// run the mysql command via the cmdline
$output = array(); $exit = 0;
@exec($cmd, $output, $exit);

everything works. but there is a security issue - one that I thought I had
specifically tackled.

the security issue occurs due to the fact that the process list (this is
just linux I'm talking about) will show the complete command line, which in
my case would look something like (in the processlist):


mysql -h localhost --user=admin --password=`cat /my/sql/root/passwd/file` -D 
somedb < "/my/import/script.sql" 2>&1


AH I hear you say but the wily use of "`cat /my/sql/root/passwd/file`" masks 
the actual
password from any looking in the process list. indeed undeer normal shell 
scripting circumstances
that may have been true.

BUT in using php's exec() to run the cmdline causes the following to show up in 
the processlist:


sh -c mysql -h localhost --user=admin --password=`cat /my/sql/root/passwd/file` 
-D somedb < "/my/import/script.sql" 2>&1


AND that [sub]shell then lists it's process[s] in the list also, there is only 
one
and it is this:


mysql -h localhost --user=admin --password=MYFINGPWD -D somedb


does anyone have an idea how to over come this security issue (without 
resorting to having to
type in the mysql admin passwd interactively!)

thanks & regards,
Jochem

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



Re: [PHP] Detecting naughty sites

2006-11-29 Thread Paul Novitski

At 11/29/2006 01:51 AM, Robin Vickery wrote:

Cubist Porn - very big in certain 'artistic' circles.


What, both eggs on the same side of the sausage? 


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



Re: [PHP] Tidy HTML source?

2006-11-29 Thread Paul Novitski

At 11/28/2006 05:05 AM, Satyam wrote:
May I invite you to check http://satyam.com.ar/pht/?   This is a 
project I started some time ago to help me produced HTML in a more 
clean and efficient way.  Usually, producing good HTML involves 
running a sample output through some HTML validator or looking at 
the HTML and checking it out by hand, which, of course, requires 
good formatting to make it understandable.   In the case of too 
dynamic HTML (meaning, output can vary widely) it is impossible to 
produce enough samples of all the possible outputs to get them checked out.


So, my idea was to embed HTML into the language itself so that the 
final output could be checked at 'compile time' and even before, 
using the standard tools provided by the IDE (even just matching 
braces goes a long way into checking for missmatched HTML tags).



Satyam,

That's an impressive bit of work, congratulations.

It's interesting to see someone spend such energy merging PHP logic 
with HTML.  I've gone in the opposite direction, separating the two 
as much as possible.  My own CMS merges content with HTML based on 
CSS-style selectors so that the logic layer of my applications 
doesn't need to know -- or contain -- the full details of the 
markup.  I find this a natural and agreeable extension of the move to 
separate HTML markup from CSS presentation and JavaScript behavior.



It's interesting to note that for all your effort to generate good, 
clean HTML, you're still able to generate a div nested inside a table:


http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1

Your pre-compiler has ensured that all your tags are well-formed, but 
it doesn't ensure that you've followed the rules of correct 
markup.  Perhaps a future iteration of your software will incorporate 
more HTML structural rules and will give you precompiler errors in such cases.



You write:

So, we have two well structured languages, one is procedural (any 
flavor of C, JavaScript, PHP, Perl, etc.), the other descriptive. 
Their blocks are quite compatible: to start with, they nest nicely 
within each other. If an XML block is contained within an if() 
block, it has to be completely within it, the boundaries of their 
blocks should not overlap.


Help me understand the relevance of this statement. A very common 
pattern in a mixed logic/HTML script goes like this:


echo '';

foreach (array as item)
{
echo 'item';
}

echo '';

In these cases the boundaries of the HTML block do in fact overlap 
the boundaries of the foreach() logic block.



And, of course, I would appreciate any comment on the project, 
EXCEPT that you use template engines and that you do not generate 
HTML directly.  I've heard that and it is completely missing the 
point so, please, spare me that one.  At one point or another plain 
HTML has to be generated.


Unless I'm missing the boat, it seems to me that the primary 
advantage of your precompiler is that it enables you to close HTML 
tags simply by closing braces, a convention policed by your 
pre-compiler and the PHP interpreter itself, so that you'll get 
pre-compiler or interpreter errors for incorrect closure instead of 
waiting for the W3C validator to check your work.  I don't mean to 
minimize the significance of your accomplishment, but personally I 
don't find generating accurate markup to be a great problem.  I'm a 
careful hand-coder, and true to the topic of this thread I find that 
neatly-indented HTML helps me validate my own markup.  Online 
validators help me catch any errors I miss.


What I find to be a much greater problem is the human readability of 
logic code when HTML is mixed throughout.  Your innovation is helpful 
here, as you're nearly making HTML tags into PHP key words, 
eliminating some of the literal quoting that makes PHP+HTML so 
tiresome.  However, even with your pre-compiler the messy quotes are 
still there on the attribute level.  And, stepping back, you're 
perpetuating the embedding of markup with logic so that it will still 
take a PHP programmer to modify the markup of one of your pages.  Do 
you not see the advantage in separating the two layers?


Again, in spite of this criticism I'm impressed with your effort.  Good work!

Regards,
Paul 


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



Re: [PHP] Detecting naughty sites

2006-11-29 Thread Robin Vickery

On 29/11/06, Travis Doherty <[EMAIL PROTECTED]> wrote:

Tom Chubb wrote:

> On 28/11/06, Dave Goodchild <[EMAIL PROTECTED]> wrote:
>
>> Hi all. I am building a web app and as part of it advertisers can upload
>> their ad image and website URL to go with their ad. Is there a good
>> way to
>> detect whether that site is a porn site via php?
>>
>> --
>> http://www.web-buddha.co.uk
>>
>>
> I remember seeing something that used GD to detect colours similar to
> flesh within an image and thinking it was funny that someone had taken
> so much time to to it, but I can't remember where it was.
> I think it was on phpclasses.org but can't find it. Maybe someone else
> remembers it?
>
And more recently a commercial vendor is performing something along the
lines of 'curve recognition' to the same effect.  That's fine for any
vector graphics (banner ads might fall here.)  False positives will be
high with beach photos from family vacation, for example.


Cubist Porn - very big in certain 'artistic' circles.

-robin

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



Re: [PHP] Tidy HTML source?

2006-11-29 Thread Satyam


- Original Message - 
From: "Fredrik Thuresson" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, November 29, 2006 5:45 AM
Subject: Re: [PHP] Tidy HTML source?



"At one point or another plain HTML has to be generated. "

Care to give me an example? I never generate any html in my php code 
anymore.


You are entitled not to, but stretching it to the point of denying that HTML 
is ever generated by anyone at anytime?   Most pre-packaged applications 
such as blogs, CMS, picture galleries do produce HTML directly without 
template engines which would require a separate installation issues and 
dependencies which most designers try to avoid.  Even template engines have 
libraries of gadgets which do produce HTML directly.


So, you might not echo HTML directly.  That is fine, it is an option.  This 
is not for you.  Evidently those who participated in these thread before do 
generate HTML directly because they are concerned about formatting it and 
that would be unnecesary if they used templates.



It's not very pretty when your code looks like echo "\n\t\t\t\t\t\t";



Look at the examples I pointed to, you won't see anything like that.


Is that not a form of a templating engine that your are building?


No, not at all.  Just read the document.  Moreover, I would appreciated if 
you read my e-mail in full, specially the part that says:  " I would 
appreciate any comment on the project, EXCEPT that you use template engines 
and that you do not generate HTML  directly."


Satyam




Fredrik

Satyam wrote:
May I invite you to check http://satyam.com.ar/pht/?   This is a project 
I started some time ago to help me produced HTML in a more clean and 
efficient way.  Usually, producing good HTML involves running a sample 
output through some HTML validator or looking at the HTML and checking it 
out by hand, which, of course, requires good formatting to make it 
understandable.   In the case of too dynamic HTML (meaning, output can 
vary widely) it is impossible to produce enough samples of all the 
possible outputs to get them checked out.


So, my idea was to embed HTML into the language itself so that the final 
output could be checked at 'compile time' and even before, using the 
standard tools provided by the IDE (even just matching braces goes a long 
way into checking for missmatched HTML tags).


The samples page (http://satyam.com.ar/pht/sample.htm) show several 
examples.


I think that a tool such as this one might avoid any concern about 
tidying up HTML since, after all, most of the checking could be done at 
the PHP source level.   Further development (which I have not started 
yet) would lead to automatic verification against DTDs or XSchemas.


And, of course, I would appreciate any comment on the project, EXCEPT 
that you use template engines and that you do not generate HTML directly. 
I've heard that and it is completely missing the point so, please, spare 
me that one.  At one point or another plain HTML has to be generated.


Satyam

- Original Message - From: "Mark Kelly" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, November 28, 2006 4:13 AM
Subject: Re: [PHP] Tidy HTML source?



On Monday 27 November 2006 17:10, Mark Kelly wrote:

Am I crazy to make an extra effort in my code to make the generated 
HTML

pretty?


Thanks everyone for your thoughts on this - I'm quite relieved that I'm 
not

the only one who sits and tweaks so that the HTML is nice and readable.

It just struck me that trying to make my PHP spit out page source that
looks like it was made lovingly by hand was perhaps the work of an
obsessive.

Now I know that even if it is, I'm not alone :)

Cheers!

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





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



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



Re: [PHP] LDAP: Write to boolean attribute

2006-11-29 Thread Jochem Maas
Carsten Gehling wrote:
> Sorry for that - I couldn't see the previous post.
> 
> I've tried true/false, but I think PHP might be converting this to
> string values (eg. "" and "1") before sending to AD

any reason to think this?
have you tried passing the strings 'false', 'true' or 'FALSE', 'TRUE'?

> 
> - Carsten
> 

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



Re: [PHP] mail header questions solved

2006-11-29 Thread Chantal Rosmuller

>
> You can use the fifth parameter:
>
> "[EMAIL PROTECTED]"
>
> This will cause the from to be from [EMAIL PROTECTED] instead of from
> [EMAIL PROTECTED]
>
> Regards,
>  Emmett

Hi Emmett,

Thanks this works. I already tried this on my local machine and it didn't work 
but it does work on the webserver so apparantly there's something wrong with 
my own MTA settings.

Regards Chantal

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



[PHP] Passwords suddenly not working

2006-11-29 Thread Dave M G

PHP List,

I have a few scripts that have been around for a while. In one, is a 
simple login function:


$query = "SELECT * FROM forum_members WHERE memberName = '" . $username 
. "' AND passwd = MD5('" . $password . "')";

$result = mysql_query($query);

This was working fine, but recently I haven't been able to log in. I 
think the only thing that has changed is that on my hosting service, 
they recently upgraded to PHP 5.1.6. (MySQL is 4.1.21, but I think it's 
been that for quite a while)


Is there any potential for PHP 5.1.6 to handle things different when it 
comes to MySQL queries, post data, or anything? I thought it might be 
that I still had $HTTP_POST_VARS for some of my variables, but I changed 
them all to $_POST, and it still doesn't work.


I don't get any errors or anything. My own code is not very 
sophisticated for error reporting. But I'm not getting any PHP syntax 
errors of any kind. If I run the SQL code by itself at an SQL command 
prompt, I get results back, so I don't think the SQL is failing.


Are there any gotchas in the upgrade that I might be missing? I can't 
think of anything else that could be a culprit (though of course I'm 
open to suggestions).


Any advice would be much appreciated.

--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2

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



Re: [PHP] Re: mail header questions

2006-11-29 Thread Chantal Rosmuller
On Wednesday 29 November 2006 00:45, Chris wrote:
you will most likely change what

> >
> > I forgot to mention that I can't set the return-path either.
>
> That can *only* be an email address - you can't include a "name" in the
> return-path. Also it can't be changed if safe-mode is on for the server.
>
>  From your code, where does $mainmail come from? It's not in the code
> you posted at all.
>
> $headers .= "From: $mainmail \r\n";
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/

Hi Chris,

The return path works now, $mainmail comes from a different file config.php 
that is included. $mainmail is also used for the return-path and that works 
so $mainmail being empty is also not the problem.

The strange thing is that even the fifth parameter solution doesn't work. I 
use Postfix as MTA by the way.

Chantal

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



Re: [PHP] Odd error after upgrading from Php4 to Php5

2006-11-29 Thread Jochem Maas
Ian Barnes wrote:
> Hi,
> 
> $sql1 = "UPDATE members SET $pass WHERE id = '$editid'";

you might consider that $editid is not what you think.
use var_dump() et al to discover what is really in each var.

> 
> Thats whats on 199. ON line 198 i have: $pass = $_POST['pass'];

which means I can inject just about any SQL I want into your server.
(you need to plug that hole)

> 
> Thanks,
> Ian
> 
> 
> 
> On 11/29/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
>>
>> Ian Barnes wrote:
>> > Hi,
>> >
>> > We recently upgraded our primary webserver to php 5 from php4 and we
>> are
>> > now
>> > getting the following errors on the site:
>> >
>> > *Catchable fatal error*: Object of class stdClass could not be
>> converted
>> to
>> > string in /home/www/somesite/somfile.php on line *199
>> >
>> > *Around that area in the code is some code something like:
>>
>> so what is line 199?
>>
>> >
>> > if(!$db->query("SQL $HaveYouGoTAVarInHere HERE"))
>>
>>  ??
>>
>> > {
>> >   echo 'Fail';
>> > }
>> >
>> > Any ideas what it means or how I can fix it ?
>> >
>> > Thanks
>> > Ian
>> >
>> > P.S. Please copy me, i dont know if my list membership is working.
>> >
>>
>>
> 

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