php-general Digest 23 Aug 2009 17:55:08 -0000 Issue 6301

Topics (messages 297101 through 297110):

Re: Is there limitation for switch case: argument's value?
        297101 by: Lars Torben Wilson

Re: daemon without pcntl_fork
        297102 by: Jim Lucas

wierd behavior on parsing css with no php included
        297103 by: Ralph Deffke
        297104 by: Ralph Deffke
        297105 by: Ralph Deffke
        297106 by: Ralph Deffke
        297107 by: Ashley Sheridan
        297108 by: Gary
        297110 by: LinuxManMikeC

Can't find the server path when, in http.conf, using Alias and DirectoryIndex
        297109 by: Paul Gardiner

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Aargh. Slipped on the trigger there--premature Send. See below for
what I meant to send:

2009/8/22 Lars Torben Wilson <tor...@php.net>:
> 2009/8/22 Keith <survivor_...@hotmail.com>:
>> Thanks! Torben.
>> I got the point now and it works! :-)
>> I'm doing this because the statements of each cases is quite long, and I
>> wish to have minimum coding without repetition.

Hi Keith,

Glad it works! I'm not sure how inverting the case statement helps you
minimize the code in each case. As both I and Adam showed, you can do
the same thing more efficiently (and IMHO more readably) like
this:

switch ($sum)
{
case 8:
    echo "The sum is 8";
    break;
case 7:
case 6:
    echo "The sum is 7 or 6";
    break;
case 2:
case 1:
    echo "The sum is 2 or 1";
    break;
case 0:
    echo "The sum is 0";
    break;
default:
    echo "The sum is 3, 4, or 5";
    break;
}

And if the code is getting so long that it's getting unwieldy, you
might want to look into breaking it out into separate functions.

Anyway, it's not a huge thing; personally though I feel that it's a
syntax that if ever used, should only be used for very good reasons.
Most of the uses I've seen of it, however, fall into the "overly
clever" category and add nothing in the end to the quality of the
code. That's totally a judgement call on my part, of course. :)

Again, glad it works, and keep on coding!


Regards,

Torben

>> "Lars Torben Wilson" <larstor...@gmail.com> wrote in message
>> news:36d4833b0908202323p3c858b5fn6a1d6775aa7f8...@mail.gmail.com...
>>>
>>> 2009/8/20 Keith <survivor_...@hotmail.com>:
>>>>
>>>> Hi,
>>>> I encounter a funny limitation here with switch case as below:
>>>> The value for $sum is worked as expected for 1 to 8, but not for 0.
>>>> When the $sum=0, the first case will be return, which is "sum=8".
>>>> Is there any limitation / rules for switch case? Thanks for advice!
>>>>
>>>> Keith
>>>
>>> Hi Keith,
>>>
>>> Try replacing 'switch($sum)' with 'switch(true)'.
>>>
>>> Note that unless you have very good reasons for using a switch
>>> statement like this, and know exactly why you're doing it, it's often
>>> better just to use it in the normal fashion. i.e.:
>>>
>>>      switch ($sum)
>>>       {
>>>       case 8:
>>>           break;
>>>       case 7:
>>>       case 6:
>>>           break;
>>>       case 2:
>>>       case 1:
>>>           break;
>>>       case 0:
>>>           break;
>>> default:
>>>           break;
>>>       }
>>>
>>> Some people like the syntax you've presented but honestly, there's
>>> usually a better way to do it.
>>>
>>> This is also somewhat faster too, although you may only notice the
>>> difference in very tight loops where you're counting every nanosecond.
>>>
>>>
>>> Regards,
>>>
>>> Torben
>>>
>>>> $sum=0;
>>>> switch($sum)
>>>> {
>>>>  case ($sum==8):
>>>>  echo "sum=8";
>>>>  break;
>>>>      case ($sum==7 || $sum==6):
>>>>      echo "sum=7 or 6";
>>>>      break;
>>>>  case ($sum==2 || $sum==1):
>>>>  echo "sum=2 or 1";
>>>>  break;
>>>>      case 0:
>>>>      echo "sum=0";
>>>>      break;
>>>>  default:
>>>>  echo "sum=3/4/5";
>>>>  break;
>>>> }
>>>> --
>>>> 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
>>
>>
>

--- End Message ---
--- Begin Message ---
Lars Torben Wilson wrote:
2009/8/20 Jim Lucas <li...@cmsws.com>:
Lars Torben Wilson wrote:
2009/8/19 Per Jessen <p...@computer.org>:
Jim Lucas wrote:
[snip]

I probably wouldn't have chosen PHP for the first one, but there's no
reason it shouldn't work.  For the second one, did you mean to
write "serial port"?  That's a bit of a different animal, I'm not sure
how far you'll get with php.

Here is what I have come up with so far.  Looks to satisfying my
needs:

tms_daemon
[snip]
# END OF SCRIPT
Looks good to me. It'll certainly do the job.


/Per
I agree with Per on all points--I probably wouldn't choose PHP as a
first choice for the first task, but the startup script you have shown
looks like a bog-standard startup script and should serve you well. I
haven't really gone over it with a fine-toothed comb though. Typos
etc. are still up to to you. :) Of course, the whole thing depends on
how tms_daemon behaves, but the startup script looks OK.

Can you explain in a bit more detail exactly what the second part (the
serial-network data logger) needs to do? I've written similar daemons
in C but not PHP--when I've needed to get something like that going
with a PHP script, I've used ser2net (which I linked to in an earlier
post) and been quite happy. Maybe you don't even have to do the hard
work yourself (or buy extra hardware to do it for you).


Cheers,

Torben

As for the second project, I asked about it in the previous thread about
the SMDR/CDR processor.

http://www.nabble.com/SMDR-CDR-daemon-processor-td25014822.html

Sorry, missed that thread.

Basically, I need to have a process that collects data via serial
(USB|RS323), connects to a remote port, or listens and receives data
from the PBX pushing it.

The most common is the RS232 serial connection.  Thats why I need to be
able to listen on the local RS232 port for data coming from the PBX system.

What I have built so far can connect to a remote machine, via a TCP/IP
connection, and wait for data to be push out the specified TCP port.

I haven't done it yet, but I know that I can easily build, using a
different project as a base, the version that would connect to a local
TCP/IP IP:PORT and wait for a PBX to send the data to that IP:PORT.

After the data has been received, the process flow will be the same with
all three methods.  Parse it, sanitize it, store it.

Hopefully that explains a little more.

Jim

In short, are you looking for a program which listens on a serial port
and a network port at the same time, and places any data received from
either into a database?


No, I am looking to build and application that will have the option doing either of the three methods. All at separate times.

It will be configured to work one phone system at a time. It will either listen locally, connect remotely via TCP/IP, or open a COM port. But, at this point, I don't see a need to have the ability to have it doing more then one method at a time.

Thanks


Regards,

Torben


--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message ---
Hi folks, i did post this also on the Wamp page but maybe someone out there
had to solve that problem as well.

systems involved

Firefox 3.0.13
Firefox 3.5.2
IE 6

Wamp:
apache 2.2.11
PHP 5.2.9 & php 5.3

I do parse css files through php

Problem: css files are loaded into the browsers but not interpreted or used
on RAW HTML files no php included. The html files are produced with
phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
page, Firefox NOT AT ALL.

I think it might be possible that wamp throughs some wierd characters into
the css files or is the header type a problem? It looks like parsing the css
through the php engine changes the header of the css to text/html. this
would explain why IE6 can use them. on the other hand firebug shows the
loaded css, indicates however that no css is available.

as an reverse check I did load the html files direktly from the disk with
file:/// ... and the css are interpreted perfectly. so the source of the
problem is wamp.

it seems that the @importcsss does the biggest problem.it creates a 404
error "file not found"

it seems creating dynamic css files got some secrets involved with the wamp.
I'm using this concept since ages on linux with no problem.

on the @includecss it seems that the search for files are changing to the
php include path or something.

any idear what to check?

is important for my work to create css dynamicly

ralph_def...@yahoo.de



--- End Message ---
--- Begin Message ---
Hi folks, i did post this also on the Wamp page but maybe someone out there
had to solve that problem as well.

systems involved

Firefox 3.0.13
Firefox 3.5.2
IE 6

Wamp:
apache 2.2.11
PHP 5.2.9 & php 5.3

I do parse css files through php

Problem: css files are loaded into the browsers but not interpreted or used
on RAW HTML files no php included. The html files are produced with
phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
page, Firefox NOT AT ALL.

I think it might be possible that wamp throughs some wierd characters into
the css files or is the header type a problem? It looks like parsing the css
through the php engine changes the header of the css to text/html. this
would explain why IE6 can use them. on the other hand firebug shows the
loaded css, indicates however that no css is available.

as an reverse check I did load the html files direktly from the disk with
file:/// ... and the css are interpreted perfectly. so the source of the
problem is wamp.

it seems that the @importcsss does the biggest problem.it creates a 404
error "file not found"

it seems creating dynamic css files got some secrets involved with the wamp.
I'm using this concept since ages on linux with no problem.

on the @includecss it seems that the search for files are changing to the
php include path or something.

any idear what to check?

is important for my work to create css dynamicly

ralph_def...@yahoo.de




--- End Message ---
--- Begin Message ---
Yes, pasring .css is the problem, is there a way to tell php to send
different headers based on the file extention of the file parsed ? should
be, it worked on linux.

ralph_def...@yahoo.de


""Ralph Deffke"" <ralph_def...@yahoo.de> wrote in message
news:67.4f.03363.a1e21...@pb1.pair.com...
> Hi folks, i did post this also on the Wamp page but maybe someone out
there
> had to solve that problem as well.
>
> systems involved
>
> Firefox 3.0.13
> Firefox 3.5.2
> IE 6
>
> Wamp:
> apache 2.2.11
> PHP 5.2.9 & php 5.3
>
> I do parse css files through php
>
> Problem: css files are loaded into the browsers but not interpreted or
used
> on RAW HTML files no php included. The html files are produced with
> phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
> page, Firefox NOT AT ALL.
>
> I think it might be possible that wamp throughs some wierd characters into
> the css files or is the header type a problem? It looks like parsing the
css
> through the php engine changes the header of the css to text/html. this
> would explain why IE6 can use them. on the other hand firebug shows the
> loaded css, indicates however that no css is available.
>
> as an reverse check I did load the html files direktly from the disk with
> file:/// ... and the css are interpreted perfectly. so the source of the
> problem is wamp.
>
> it seems that the @importcsss does the biggest problem.it creates a 404
> error "file not found"
>
> it seems creating dynamic css files got some secrets involved with the
wamp.
> I'm using this concept since ages on linux with no problem.
>
> on the @includecss it seems that the search for files are changing to the
> php include path or something.
>
> any idear what to check?
>
> is important for my work to create css dynamicly
>
> ralph_def...@yahoo.de
>
>



--- End Message ---
--- Begin Message ---
before you come up with how to send a header in php

I'm TALKING ABOUT .CSS FILES NOT INCLUDING ANY PHP

if you put this in httpconf
    AddType application/x-httpd-php .css
the problem is caused


""Ralph Deffke"" <ralph_def...@yahoo.de> wrote in message
news:67.4f.03363.a1e21...@pb1.pair.com...
> Hi folks, i did post this also on the Wamp page but maybe someone out
there
> had to solve that problem as well.
>
> systems involved
>
> Firefox 3.0.13
> Firefox 3.5.2
> IE 6
>
> Wamp:
> apache 2.2.11
> PHP 5.2.9 & php 5.3
>
> I do parse css files through php
>
> Problem: css files are loaded into the browsers but not interpreted or
used
> on RAW HTML files no php included. The html files are produced with
> phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
> page, Firefox NOT AT ALL.
>
> I think it might be possible that wamp throughs some wierd characters into
> the css files or is the header type a problem? It looks like parsing the
css
> through the php engine changes the header of the css to text/html. this
> would explain why IE6 can use them. on the other hand firebug shows the
> loaded css, indicates however that no css is available.
>
> as an reverse check I did load the html files direktly from the disk with
> file:/// ... and the css are interpreted perfectly. so the source of the
> problem is wamp.
>
> it seems that the @importcsss does the biggest problem.it creates a 404
> error "file not found"
>
> it seems creating dynamic css files got some secrets involved with the
wamp.
> I'm using this concept since ages on linux with no problem.
>
> on the @includecss it seems that the search for files are changing to the
> php include path or something.
>
> any idear what to check?
>
> is important for my work to create css dynamicly
>
> ralph_def...@yahoo.de
>
>



--- End Message ---
--- Begin Message ---
On Sun, 2009-08-23 at 14:29 +0200, Ralph Deffke wrote:
> before you come up with how to send a header in php
> 
> I'm TALKING ABOUT .CSS FILES NOT INCLUDING ANY PHP
> 
> if you put this in httpconf
>     AddType application/x-httpd-php .css
> the problem is caused
> 
> 
> ""Ralph Deffke"" <ralph_def...@yahoo.de> wrote in message
> news:67.4f.03363.a1e21...@pb1.pair.com...
> > Hi folks, i did post this also on the Wamp page but maybe someone out
> there
> > had to solve that problem as well.
> >
> > systems involved
> >
> > Firefox 3.0.13
> > Firefox 3.5.2
> > IE 6
> >
> > Wamp:
> > apache 2.2.11
> > PHP 5.2.9 & php 5.3
> >
> > I do parse css files through php
> >
> > Problem: css files are loaded into the browsers but not interpreted or
> used
> > on RAW HTML files no php included. The html files are produced with
> > phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
> > page, Firefox NOT AT ALL.
> >
> > I think it might be possible that wamp throughs some wierd characters into
> > the css files or is the header type a problem? It looks like parsing the
> css
> > through the php engine changes the header of the css to text/html. this
> > would explain why IE6 can use them. on the other hand firebug shows the
> > loaded css, indicates however that no css is available.
> >
> > as an reverse check I did load the html files direktly from the disk with
> > file:/// ... and the css are interpreted perfectly. so the source of the
> > problem is wamp.
> >
> > it seems that the @importcsss does the biggest problem.it creates a 404
> > error "file not found"
> >
> > it seems creating dynamic css files got some secrets involved with the
> wamp.
> > I'm using this concept since ages on linux with no problem.
> >
> > on the @includecss it seems that the search for files are changing to the
> > php include path or something.
> >
> > any idear what to check?
> >
> > is important for my work to create css dynamicly
> >
> > ralph_def...@yahoo.de
> >
> >
> 
> 
> 

Well, take the line out that's causing the problems then?!

You say you don't need to know how to set a header, but you seem to
insist that the CSS files are parsed by PHP. Which one is it?

Thanks,
Ash
http://www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
You have a path problem.  The browser is looking for your file/// . Remove 
all but the folder and file information (that is if the css folder/file are 
in the root directory).

So if your file looks like 
url(f/////desktop/yourcomputer/mydocuments/sites/thissite/css/css.css), 
remove all but the css/css.css

Or, if you are using Dreamweaver, right click and use the url locator

Gary
""Ralph Deffke"" <ralph_def...@yahoo.de> wrote in message 
news:67.4f.03363.a1e21...@pb1.pair.com...
> Hi folks, i did post this also on the Wamp page but maybe someone out 
> there
> had to solve that problem as well.
>
> systems involved
>
> Firefox 3.0.13
> Firefox 3.5.2
> IE 6
>
> Wamp:
> apache 2.2.11
> PHP 5.2.9 & php 5.3
>
> I do parse css files through php
>
> Problem: css files are loaded into the browsers but not interpreted or 
> used
> on RAW HTML files no php included. The html files are produced with
> phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
> page, Firefox NOT AT ALL.
>
> I think it might be possible that wamp throughs some wierd characters into
> the css files or is the header type a problem? It looks like parsing the 
> css
> through the php engine changes the header of the css to text/html. this
> would explain why IE6 can use them. on the other hand firebug shows the
> loaded css, indicates however that no css is available.
>
> as an reverse check I did load the html files direktly from the disk with
> file:/// ... and the css are interpreted perfectly. so the source of the
> problem is wamp.
>
> it seems that the @importcsss does the biggest problem.it creates a 404
> error "file not found"
>
> it seems creating dynamic css files got some secrets involved with the 
> wamp.
> I'm using this concept since ages on linux with no problem.
>
> on the @includecss it seems that the search for files are changing to the
> php include path or something.
>
> any idear what to check?
>
> is important for my work to create css dynamicly
>
> ralph_def...@yahoo.de
>
>
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 4360 (20090823) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature 
database 4360 (20090823) __________

The message was checked by ESET Smart Security.

http://www.eset.com





--- End Message ---
--- Begin Message ---
Try this at the beginning of each css file?

<?php
header('Content-type: text/css');
?>

On Sun, Aug 23, 2009 at 5:49 AM, Ralph Deffke<ralph_def...@yahoo.de> wrote:
> Hi folks, i did post this also on the Wamp page but maybe someone out there
> had to solve that problem as well.
>
> systems involved
>
> Firefox 3.0.13
> Firefox 3.5.2
> IE 6
>
> Wamp:
> apache 2.2.11
> PHP 5.2.9 & php 5.3
>
> I do parse css files through php
>
> Problem: css files are loaded into the browsers but not interpreted or used
> on RAW HTML files no php included. The html files are produced with
> phpDocumentor 1.4.2. IE6 uses parts of the css files loaded to display the
> page, Firefox NOT AT ALL.
>
> I think it might be possible that wamp throughs some wierd characters into
> the css files or is the header type a problem? It looks like parsing the css
> through the php engine changes the header of the css to text/html. this
> would explain why IE6 can use them. on the other hand firebug shows the
> loaded css, indicates however that no css is available.
>
> as an reverse check I did load the html files direktly from the disk with
> file:/// ... and the css are interpreted perfectly. so the source of the
> problem is wamp.
>
> it seems that the @importcsss does the biggest problem.it creates a 404
> error "file not found"
>
> it seems creating dynamic css files got some secrets involved with the wamp.
> I'm using this concept since ages on linux with no problem.
>
> on the @includecss it seems that the search for files are changing to the
> php include path or something.
>
> any idear what to check?
>
> is important for my work to create css dynamicly
>
> ralph_def...@yahoo.de
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
I want to write a simple indexing script to display a
directory full of photos as a gallery of thumbnails.
(There are various solutions out there for this, but
they're all a bit more complicated than I need).

I've added a file in /etc/apache2/conf.d that
looks like this:

Alias /photos /home/public/photos
<Directory "/home/public/photos">
    AllowOverride None
    Order allow,deny
    Allow from all

    DirectoryIndex /cgi-bin/index.php
</Directory>


I use "Alias" so that I can leave the photos where they are
and not have to move them to DocumentRoot. I use "DirectoryIndex"
so that the script doesn't have to be in with the photos. My
problem is that the running script seems to have no way to
work out the photos are in /home/public/photos.

$_SERVER[REQUEST_URI] is "/photos/", but I can't see how to
derive the server path from that, since $_SERVER[DOCUMENT_ROOT]
is "/srv/www/htdocs".

$_SERVER[PHP_SELF] is "/cgi-bin/index.php", so no use either.


How can I do this? Is there a way to interrogate the alias,
or can I set a variable in the conf file that PHP can pick up?

Cheers,
        Paul.


--- End Message ---

Reply via email to