Re: [PHP] actually the egrave; not the ampersand

2005-11-04 Thread Fredrik Tolf
,
rArr = 8658,
dArr = 8659,
hArr = 8660,
forall = 8704,
part = 8706,
exist = 8707,
empty = 8709,
nabla = 8711,
isin = 8712,
notin = 8713,
ni = 8715,
prod = 8719,
sum = 8721,
minus = 8722,
lowast = 8727,
radic = 8730,
prop = 8733,
infin = 8734,
ang = 8736,
and = 8743,
or = 8744,
cap = 8745,
cup = 8746,
int = 8747,
there4 = 8756,
sim = 8764,
cong = 8773,
asymp = 8776,
ne = 8800,
equiv = 8801,
le = 8804,
ge = 8805,
sub = 8834,
sup = 8835,
nsub = 8836,
sube = 8838,
supe = 8839,
oplus = 8853,
otimes = 8855,
perp = 8869,
sdot = 8901,
lceil = 8968,
rceil = 8969,
lfloor = 8970,
rfloor = 8971,
lang = 9001,
rang = 9002,
loz = 9674,
spades = 9824,
clubs = 9827,
hearts = 9829,
diams = 9830,
quot = 34,
amp = 38,
lt = 60,
gt = 62,
OElig = 338,
oelig = 339,
Scaron = 352,
scaron = 353,
Yuml = 376,
circ = 710,
tilde = 732,
ensp = 8194,
emsp = 8195,
thinsp = 8201,
zwnj = 8204,
zwj = 8205,
lrm = 8206,
rlm = 8207,
ndash = 8211,
mdash = 8212,
lsquo = 8216,
rsquo = 8217,
sbquo = 8218,
ldquo = 8220,
rdquo = 8221,
bdquo = 8222,
dagger = 8224,
Dagger = 8225,
permil = 8240,
lsaquo = 8249,
rsaquo = 8250,
euro = 8364,
);
?

Hope it helps.
Fredrik Tolf

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



[PHP] PHP from CLI with SAPI

2005-07-18 Thread Fredrik Tolf
Hi!

I've begun to be more and more displeased with Apache lately, so I've
been thinking of writing my own HTTP server instead. I still want PHP
support, but writing a new SAPI for PHP seems like overkill.

Therefore, is it possible to use PHP from the command line, but still
enable some HTTP-server-only stuff, like GET and POST variables,
cookies, session management, file uploads, and so on? I haven't been
able to find any docs on doing that, but I'm thinking that it should be
possible.

So, can someone either point me to some docs in this, or, lacking such,
give me a short intro to it?

Thanks for reading!

Fredrik Tolf

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



Re: [PHP] PHP from CLI with SAPI

2005-07-18 Thread Fredrik Tolf
On Mon, 2005-07-18 at 15:57 -0400, Evert | Rooftop wrote:
 Fredrik Tolf wrote:
 I've begun to be more and more displeased with Apache lately, so I've
 been thinking of writing my own HTTP server instead. I still want PHP
 support, but writing a new SAPI for PHP seems like overkill.
 
 Therefore, is it possible to use PHP from the command line, but still
 enable some HTTP-server-only stuff, like GET and POST variables,
 cookies, session management, file uploads, and so on? I haven't been
 able to find any docs on doing that, but I'm thinking that it should be
 possible.
 
 So, can someone either point me to some docs in this, or, lacking such,
 give me a short intro to it?
 
 Hi Fredrick,

Hi!

 I wonder too why you are displeased with apache =) to me (and I know
 many others in this group) it is the best webserver around.

One of the problems for me with Apache is that it's too complex. To
begin with, it contains a million feature that I'll never use, but which
does bring up resource consumption.

It also contains a lot of high-performance stuff which impedes
flexibility, such as not being able to keep file descriptors to instead
be able to load-balance requests between workers and servers.

Almost foremost, however, I'm looking to build a server with far better
support for multi-user operation. While Apache with UserDir and suexec
does some things good, it cannot, for example, running PHP applications
as different users. I know there is a worker module for apache that can
run different vhosts as different users, but that's just vhosts -- you
still cannot define arbitrary authoritative domains (such as
directories) that are run as different users. At least not the way I've
understood it.

I'm just running a multi-user POSIX system at home with shell access,
and having to run all web processing as the apache user, well, kinda
sucks, when it could instead actually be run as the user it should run
as, and access the users' data correctly.

 If you would want to do it (and not use php as a library [SAPI-style] )
 you shouldn't look in to CLI, but into CGI.

Yes, that's what I meant. I meant calling PHP's CLI interface with a
CGI-style interface.

 Using CGI you can lauch a php process every time a script is called.
 Many years ago they discovered this isn't the best way to handle this.
 To launch a process every time a script is called takes too much time
 and resources.
 So they invented the FASTCGI interface, which allows php processes to
 remain persistant in the memory. You would probably (depending on your
 demands) want to have a bunch of php processes forked in the memory.

While that is true, I don't think that the real CGI interface would be
a problem with the kind of load that my server is under.

 If it's an experment, I would say go for it. If you want to use it
 commercially or at least in a live enviroment I would strongly
 discourage you to do it.

Well, of course it's not a commercial environment. I just want a good
multi-user server on my home system.

 In any case, if you want it to be fast, you want to do it 'SAPI-style'..

Well, I've been considering writing a SAPI for PHP. I haven't actually
looked at the SAPI interface, but I'm getting the feeling that that's
probably more work than writing an entire web server. ;)

Anyways, thanks for your input!

Fredrik Tolf

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



Re: [PHP] Re: PHP from CLI with SAPI

2005-07-18 Thread Fredrik Tolf
On Mon, 2005-07-18 at 20:44 +0100, Mikey wrote:
 Catalin Trifu wrote:
 Fredrik Tolf wrote:
 I've begun to be more and more displeased with Apache lately, so I've
 been thinking of writing my own HTTP server instead. I still want PHP
 support, but writing a new SAPI for PHP seems like overkill.
 
 Therefore, is it possible to use PHP from the command line, but still
 enable some HTTP-server-only stuff, like GET and POST variables,
 cookies, session management, file uploads, and so on? I haven't been
 able to find any docs on doing that, but I'm thinking that it should be
 possible.
 
 So, can someone either point me to some docs in this, or, lacking such,
 give me a short intro to it?
 
 All of the features you mentioned are those provided for you by Apache, 
 barring the session management.  If you really want to write your own 
 http server then maybe take a look at the Apache source code.  It will 
 either give you some good pointers or make you realise what a huge task 
 you are undertaking...

Are you sure about this? The way I've understood it, the web server just
passes the URL to PHP, and then PHP parses and extracts the GET
variables from it and construct an array of them.

Likewise, surely the server just passes the content passed by the client
browser, and then PHP extracts the POST variables and file uploads,
right? I wouldn't think that Apache extracts POST variables and file
uploads by itself.

Same thing with cookies, right? Surely, the webserver just passes the
headers to PHP, which extracts the cookies, right?

I would think that it should be possible to pass the URL, headers, and
client-passed content to PHP via PHP's CLI interface, to let it do that
job. Isn't that possible?

Even if not, parsing GET URLs and headers doesn't really seem like a
very huge undertaking. I realize that Apache is huge, but that's just
because it has so insanely many features -- an HTTP server in itself
shouldn't need to be very complex, the way I see it.

Thanks for responding!

Fredrik Tolf

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



[PHP] Unix sockets and fsockopen

2005-07-16 Thread Fredrik Tolf
Hi List!

I'm writing an open source PHP application which uses (connects to) Unix
sockets. To that means, I'm using the fsockopen function.

However, when reading the fsockopen documentation on php.net and being
referred to Appendix N, it seems clear that one should use the notation
unix:///path/to/socket. However, that doesn't work with any version of
PHP that I've tried myself -- they only work if I give them a normal
path (without the unix:// specifier). Right now, I'm using PHP 4.2.2
(comes with RH9), but previously I was using some PHP 4.3 version,
although I don't remember which.

Recently, however, I've started receiving mails from people who say that
it only works if they replace the fsockopen call so that it uses the
unix:// scheme. At least one of them was using PHP 4.3.11, and another
one was using PHP 5. I don't think I asked for the PHP versions of the
others.

So, what is one supposed to do with this really? Is there any particular
way that I can detect if I should use unix:// and prepend it if
necessary? If you don't mind me asking, what's the reason for this
inconsistency?

Thanks for your attention!

Fredrik Tolf

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



[PHP] Re: [PHP-I18N] How to get WIN-1255 encoded string

2004-11-07 Thread Fredrik Tolf
On Sun, 2004-11-07 at 13:57 +0200, Marina Markus wrote:
 Hello,

Hi!
 
 I need a PHP script to create an email message in a way that a subject line
 in Hebrew will be readable in all mail clients. Some mail clients cannot
 cope with Hebrew if they don't have character set explicitly denoted. 

I believe that should be _all_ e-mail clients. Since the default MIME
charset is US-ASCII (as per RFC 2047 and 2822), only faulty e-mail
clients would be able to cope with non-ASCII characters without wrapping
the header in MIME.
 
 Is there a possibility in PHP allowing to encode a string
 with WIN-1255 character set encoding? The result should look like:
  
 =?windows-1255?B?Rlc6IOz26eHl+CDk8uXj6e0=?=
  
 which the mail client then is able to decode back into Hebrew. 

If you're running PHP5, you might want to look at iconv_mime_encode. If
not, you can take these functions, which are from a GPL:d webmail I'm
writing, and adapt them to your purpose:

function mimifyhdr($header)
{
if(strpos($header,  ) !== FALSE)
{
$temp = ;
$cp = 0;
while(($np = strpos($header,  , $cp)) !== FALSE)
{
$temp .= mimifyhdr(substr($header, $cp, $np - $cp)) .  ;
$cp = $np + 1;
}
$temp .= mimifyhdr(substr($header, $cp));
return($temp);
}
$nh = ;
$num = 0;
for($i = 0; $i  strlen($header); $i++)
{
$c = substr($header, $i, 1);
if(ord($c) = 128)
$num++;
}
if($num == 0)
return($header);
if($num  (strlen($header) / 4))
return(=?UTF-8?B? . encodemime($header, base64) . ?=);
$nt = ;
for($i = 0; $i  strlen($header); $i++)
{
$c = substr($header, $i, 1);
if(($c == =) || (ord($c) = 128) || ($c == _))
{
$nt .= = . strtoupper(dechex(ord($c)));
} else if($c ==  ) {
$nt .= _;
} else {
$nt .= $c;
}
}
return(=?UTF-8?Q? . $nt . ?=);
}

function addhdr($name, $val)
{
global $headers;

if(trim($val) != )
{
$temp .= $name . :  . mimifyhdr($val);
$maxlen = strlen($temp);
$ls = 0;
while($maxlen  70)
{
$cp = $ls + 70;
while(strpos(\t , substr($temp, $cp, 1)) === FALSE)
{
if(--$cp  $ls)
break;
}
if($cp  $ls)
break;
$temp = substr($temp, 0, $cp) . \r\n\t .
substr($temp, $cp+ 1);
$ls = $cp + 3;
$maxlen = strlen($temp) - $ls;
}
$headers .= $temp . \r\n;
}
}

Note that they take values which are already in the UTF-8 encoding. If
your values aren't in UTF-8, take a look at the iconv function.

 If anyone has a solution for another character set, I suppose it can also
 help.

I'd recommend that you use UTF-8 instead. It's more general than
Windows-1255 (copes with characters outside the Hebrew range), and is
probably supported by more MUAs.

Hope it helps!

Fredrik Tolf

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



[PHP] Re: [PHP-I18N] How to get WIN-1255 encoded string

2004-11-07 Thread Fredrik Tolf
On Sun, 2004-11-07 at 20:42 +0100, Fredrik Tolf wrote:
 On Sun, 2004-11-07 at 13:57 +0200, Marina Markus wrote:
  Is there a possibility in PHP allowing to encode a string
  with WIN-1255 character set encoding? The result should look like:
   
  =?windows-1255?B?Rlc6IOz26eHl+CDk8uXj6e0=?=
   
  which the mail client then is able to decode back into Hebrew. 
 
 If you're running PHP5, you might want to look at iconv_mime_encode. If
 not, you can take these functions, which are from a GPL:d webmail I'm
 writing, and adapt them to your purpose:
 [snip]
   return(=?UTF-8?B? . encodemime($header, base64) . ?=);
 [snip]

Sorry, it seems the `encodemime' function was mine as well:

function encodemime($text, $encoding)
{
if($encoding == quoted-printable)
{
$nt = ;
for($i = 0; $i  strlen($text); $i++)
{
$c = substr($text, $i, 1);
if(($c == =) || (ord($c) = 128))
$nt .= = . dechex(ord($c));
else
$nt .= $c;
}
return($nt);
}
if($encoding == base64)
return(base64_encode($text));
return($text);
}

Sorry for taking two mails.

Fredrik Tolf

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