php-general Digest 6 Jan 2002 15:32:57 -0000 Issue 1095

Topics (messages 79592 through 79609):

To you know-it-all's out there...
        79592 by: Torkil Johnsen
        79593 by: Manuel Lemos
        79603 by: nico_netcourrier

Re: regular expressions
        79594 by: Michael Sims
        79595 by: Michael Sims

Re: Checking the season
        79596 by: Tom Rogers
        79597 by: webapprentice

Re: NEWBIE IN DISTRESS:  Install Instructions are not work for PHP 4.1.1!!!
        79598 by: snyperx

Is the 'dl' function a bad idea to use?
        79599 by: Joelmon2001.aol.com

take links from url
        79600 by: Alawi

flock
        79601 by: David Robinson

PHP Security Alert for Apache/Win32
        79602 by: Garth Dahlstrom
        79606 by: David

distinct element from array
        79604 by: Kancha .
        79607 by: Bogdan Stancescu
        79608 by: Andrey Hristov

Re: Still need help with miscount
        79605 by: Daniel Alsén

What can I use instead?
        79609 by: Mark Evans

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Yeah this is a BIT of topic...

I have this code:
<?
  header("Content-type: image/svg+xml");
  print('<?xml version="1.0" encoding="iso-8859-1"?>');
?>

<?php $text="This page uses PHP and SVG"; ?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd";
>

<svg xml:space="preserve" width="100%" height="20">
        <desc>Using styles</desc>
        <rect style="fill:#333333" x="0" y="0" width="100%" height="145"/>
        <text x="50" y="70" style="text-anchor:left; fill:#cccccc; font-size:26;
        font-weight:15; font-family:Tahoma, Verdana; font-style:regular"><?php echo
        $text; ?></text>
</svg>

See for yourself at:
http://www.torkiljohnsen.com/xperiment/index.psvg

This produces an error message (which you can read at the same page).

Why is this?
I had an xml/svg "specialist" make this code and it works perfectly on his
server... Anyone got ANY clue as to why this is happening?

ehhh... does anyone know of any good XML/SVG mailing lists out there ? :S

Didn't know where else to ask.....

 - Torkil

--- End Message ---
--- Begin Message ---
Torkil Johnsen wrote:
> 
> Yeah this is a BIT of topic...
> 
> I have this code:
> <?
>   header("Content-type: image/svg+xml");
>   print('<?xml version="1.0" encoding="iso-8859-1"?>');
> ?>
> 
> <?php $text="This page uses PHP and SVG"; ?>
> 
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
> "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd";
> >
> 
> <svg xml:space="preserve" width="100%" height="20">
>         <desc>Using styles</desc>
>         <rect style="fill:#333333" x="0" y="0" width="100%" height="145"/>
>         <text x="50" y="70" style="text-anchor:left; fill:#cccccc; font-size:26;
>         font-weight:15; font-family:Tahoma, Verdana; font-style:regular"><?php echo
>         $text; ?></text>
> </svg>
> 
> See for yourself at:
> http://www.torkiljohnsen.com/xperiment/index.psvg
> 
> This produces an error message (which you can read at the same page).
> 
> Why is this?
> I had an xml/svg "specialist" make this code and it works perfectly on his
> server... Anyone got ANY clue as to why this is happening?

It is not an error. The server just returns the script contents in plain
text, so it is not executed as a PHP script. You need to configure your
server to either process this script as a PHP script (it could be as
simple as rename its extension to .php) or configure it to process all
files with extension .psvg as PHP scripts.

Regards,
Manuel Lemos
--- End Message ---
--- Begin Message ---
La page XML ne peut pas être affichée
Impossible d'afficher l'entrée XML en utilisant la feuille de style .
Corrigez l'erreur, puis cliquez sur le bouton Actualiser ou réessayez
ultérieurement.


----------------------------------------------------------------------------
----

Aucun espace blanc n'est autorisé à cet emplacement. Ligne 1, Position 3

<?

Well, something's wrong (the style sheet ???), i think the integrated
debbugger is a good idea...

----- Original Message -----
From: Torkil Johnsen <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 06, 2002 4:39 AM
Subject: [PHP] To you know-it-all's out there...


> Yeah this is a BIT of topic...
>
> I have this code:
> <?
>   header("Content-type: image/svg+xml");
>   print('<?xml version="1.0" encoding="iso-8859-1"?>');
> ?>
>
> <?php $text="This page uses PHP and SVG"; ?>
>
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
>
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd";
> >
>
> <svg xml:space="preserve" width="100%" height="20">
> <desc>Using styles</desc>
> <rect style="fill:#333333" x="0" y="0" width="100%" height="145"/>
> <text x="50" y="70" style="text-anchor:left; fill:#cccccc; font-size:26;
> font-weight:15; font-family:Tahoma, Verdana; font-style:regular"><?php
echo
> $text; ?></text>
> </svg>
>
> See for yourself at:
> http://www.torkiljohnsen.com/xperiment/index.psvg
>
> This produces an error message (which you can read at the same page).
>
> Why is this?
> I had an xml/svg "specialist" make this code and it works perfectly on his
> server... Anyone got ANY clue as to why this is happening?
>
> ehhh... does anyone know of any good XML/SVG mailing lists out there ? :S
>
> Didn't know where else to ask.....
>
>  - Torkil
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


--- End Message ---
--- Begin Message ---
At 10:16 PM 1/5/2002 -0500, Gerard Samuel wrote:
>Need some help with this one.  Dont know where to begin.  I have content 
>in a string and a constant that changes depending on if yourre in the root 
>or in a directory.
>The purpose of the constant is to provide dynamic links.
>The string will have href links like <a href="index.php">Index</a>
>I want to figure out a way to inject my constant value into the href like so
><a href="'._CONSTANT'index.php">Index</a>
>I would like the rules to say,
>If string contains <href="> and there are <alphanumerical chars> .php 
>place _CONSTANT between <href="> and <alphanumerical chars>
>I figure a regular expression, but I have no idea where to start..

This seems to work:

<?
define("_CONSTANT","/path/");

$string = "Click <a href=\"index.php\">here</a> to return to the main page.";

echo insertpath($string);

function insertpath($string) {

         return preg_replace("/(<a 
href=\")(.*\">.*<\/a>)/i","$1"._CONSTANT."$2",$string);

}
?>

Preg_replace allows you to use backreferences and access them via variables 
such as $1 and $2, etc.  Earlier versions of PHP required you to use \\1, 
\\2 instead (see the documentation for preg_replace for more info).  Each 
section of the regex that is in parenthesis can be accessed.  In the above 
example, the (<a href=\") section is reprinted in the replacement string by 
using $1, so on a so forth.  The ".*" in the regex basically means match 
"any old junk" since the "." refers to any single character and the "*" 
means match the previous character zero or more times.

http://download.php.net/manual/en/function.preg-replace.php

--- End Message ---
--- Begin Message ---
At 10:22 PM 1/5/2002 -0600, Michael Sims wrote:
>function insertpath($string) {
>
>         return preg_replace("/(<a 
> href=\")(.*\">.*<\/a>)/i","$1"._CONSTANT."$2",$string);
>
>}
>?>

Forgot to mention that the "i" at the end of the regex means to make the 
match case-insensitive...

--- End Message ---
--- Begin Message ---
Hi
This should work:
<?
$year = date("Y");
$spring = mktime (0,0,0,3,21,$year);
$summer = mktime (0,0,0,6,21,$year);
$autumn = mktime (0,0,0,9,21,$year);
$winter = mktime (0,0,0,12,21,$year);
$now = mktime();
if($now < $spring || $now >= $winter):
         echo "Winter";
elseif($now >= $autumn):
         echo "Autumn";
elseif($now >= $summer):
         echo "Summer";
else:
         echo "Spring";
endif;
?>
  BTW There may be a bug in mktime() (php4) if you use 08 or 09 in the 
month part...on my system this happens
(linux/apache/php4.1)

<?
$autumn = mktime (0,0,0,09,21,2002);
echo "date = ".date("d/m/Y",$autumn)."<br>";
?>

This prints: date = 21/12/2001

Also prints the same date for a month of 08

Tom



At 11:34 AM 6/01/02, webapprentice wrote:
>I'll have to use and if/elseif construct, because I don't believe a switch()
>constructs cases can take expressions, can it?
>
>
>----- Original Message -----
>From: "Bogdan Stancescu" <[EMAIL PROTECTED]>
>To: "webapprentice" <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Sent: Saturday, January 05, 2002 11:38 AM
>Subject: Re: [PHP] Checking the season
>
>
> > You could do a case() or if/elseif, check if it's spring, summer or autumn
>and leave the code for winter as default/else.
> >
> > Bogdan
> >
> > webapprentice wrote:
> >
> > > Hi,
> > > Just need a sounding board to help me think this through.
> > >
> > > I want to check the current date to determine what "season" it is and
>display the appropriate picture.
> > >
> > > I define spring as 03/21/YYYY, summer as 06/21/YYYY, autumn as
>09/21/YYYY, and winter as 12/21/YYYY.
> > >
> > > I form a string for the current date and get a timestamp via mktime().
> > > I also get the equivalent timestamps for the dates above for the
>seasonal changes.
> > >
> > > Then, I compare the current date to see if it's between the seasonal
>dates.
> > > The problem is when I go from 12/31/YYYY to 01/01/(YYYY+1).
> > > Since winter and spring dates are one year apart, the current date
>timestamp comparison gets messed up and nothing displays.
> > >
> > > How do I do a proper comparison?  I was thinking of just seeing if the
>current date timestamp is greater than each of the seasonal date timestamp,
>but it feels like I would miss something.  Would I?  Or is there another
>solution?
> > >
> > > Thank you for your time.
> > >
> > > --Stephen
> >
> >
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Thanks for the code snippet.
I see that everybody defaults to a season.  I was doing a && comparison
between two seasons, so that's why it messed up when it into the new year.

Thanks to Bogdan and Tom for the helpers.  I can go debug my code.  And make
it less complicated. ^_^;;;
(It's was a lot longer than what is here.)

----- Original Message -----
From: "Tom Rogers" <[EMAIL PROTECTED]>
To: "webapprentice" <[EMAIL PROTECTED]>; "Bogdan Stancescu"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, January 05, 2002 11:17 PM
Subject: Re: [PHP] Checking the season


> Hi
> This should work:
> <?
> $year = date("Y");
> $spring = mktime (0,0,0,3,21,$year);
> $summer = mktime (0,0,0,6,21,$year);
> $autumn = mktime (0,0,0,9,21,$year);
> $winter = mktime (0,0,0,12,21,$year);
> $now = mktime();
> if($now < $spring || $now >= $winter):
>          echo "Winter";
> elseif($now >= $autumn):
>          echo "Autumn";
> elseif($now >= $summer):
>          echo "Summer";
> else:
>          echo "Spring";
> endif;
> ?>
>   BTW There may be a bug in mktime() (php4) if you use 08 or 09 in the
> month part...on my system this happens
> (linux/apache/php4.1)
>
> <?
> $autumn = mktime (0,0,0,09,21,2002);
> echo "date = ".date("d/m/Y",$autumn)."<br>";
> ?>
>
> This prints: date = 21/12/2001
>
> Also prints the same date for a month of 08
>
> Tom
>
>
>
> At 11:34 AM 6/01/02, webapprentice wrote:
> >I'll have to use and if/elseif construct, because I don't believe a
switch()
> >constructs cases can take expressions, can it?
> >
> >
> >----- Original Message -----
> >From: "Bogdan Stancescu" <[EMAIL PROTECTED]>
> >To: "webapprentice" <[EMAIL PROTECTED]>
> >Cc: <[EMAIL PROTECTED]>
> >Sent: Saturday, January 05, 2002 11:38 AM
> >Subject: Re: [PHP] Checking the season
> >
> >
> > > You could do a case() or if/elseif, check if it's spring, summer or
autumn
> >and leave the code for winter as default/else.
> > >
> > > Bogdan
> > >
> > > webapprentice wrote:
> > >
> > > > Hi,
> > > > Just need a sounding board to help me think this through.
> > > >
> > > > I want to check the current date to determine what "season" it is
and
> >display the appropriate picture.
> > > >
> > > > I define spring as 03/21/YYYY, summer as 06/21/YYYY, autumn as
> >09/21/YYYY, and winter as 12/21/YYYY.
> > > >
> > > > I form a string for the current date and get a timestamp via
mktime().
> > > > I also get the equivalent timestamps for the dates above for the
> >seasonal changes.
> > > >
> > > > Then, I compare the current date to see if it's between the seasonal
> >dates.
> > > > The problem is when I go from 12/31/YYYY to 01/01/(YYYY+1).
> > > > Since winter and spring dates are one year apart, the current date
> >timestamp comparison gets messed up and nothing displays.
> > > >
> > > > How do I do a proper comparison?  I was thinking of just seeing if
the
> >current date timestamp is greater than each of the seasonal date
timestamp,
> >but it feels like I would miss something.  Would I?  Or is there another
> >solution?
> > > >
> > > > Thank you for your time.
> > > >
> > > > --Stephen
> > >
> > >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

--- End Message ---
--- Begin Message ---
Nothing noted in the error log.  The lines I have tried using are the EXACT
ones stated in the install.txt file.  I basically copied them from the
install doc and pasted it into the httpd.conf file.

Mark

"Brian Clark" <[EMAIL PROTECTED]> wrote in message
20020105034518.GH17616@ganymede">news:20020105034518.GH17616@ganymede...
> * Mark ([EMAIL PROTECTED]) [Jan 04. 2002 12:14]:
>
> [...]
>
> > the Module version (Get a "Requested Operation Failed" message).  can
> > someone please help?????  My system is as follows:
>
> > Windows 2000 SP2
> > Apache 2.0.28 (I have also tried version 1.3.22 with same results as
>
> People had problems in that past with 2.x; I don't know if the php-dev's
> have worked that out yet.
>
> > mentioned above)
> > PHP 4.1.1
> > MDAC 2.7
> > MySQL 3.23.46a
>
> Are there any hints in Apache's error_log? What is your exact LoadModule
> line you're using in httpd.conf?
>
> --
> Brian Clark | Avoiding the general public since 1805!
> Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8
> In politics, stupidity is not a handicap.
>


--- End Message ---
--- Begin Message ---
Hey, thanks for your time. You are busy, so I'll be brief

A.) If I were to use it, for a gd or mysql library, not oftenly, certainly 
not more than 100 requests per day, would it affect the server negatively?

B.) Is there a delay in using it as oppossed to compiling them during 
installation (or recompile)

I ask as I am not familiar at all with this feature, but saw it in some code, 
(For ming, actually, to make flash movies) and it worked well for me

So, if I use it, am I doing myself a disservice? Or not? Thanks, I have no 
clue 

Joel
Ps. In case one asks why I'd use such a method, I am picklehead, no 
intelligent answer, can be provided, I am just curious as I wasn't really 
aware of such an option earlier on. Thanks ;)


--- End Message ---
--- Begin Message ---
I want to take string between <table></table> tags in put it 
in variable 
How can I do that ? 
--- End Message ---
--- Begin Message ---
I'm using flock to manage the access of a file.  I've noticed that php seems to
wait for the file to be freed up.  Is there a ordered que that each request goes
into?  And a timeout period, or does it just wait?

David
--- End Message ---
--- Begin Message ---
Folks running Apache/Win32 should read this:

http://www.securiteam.com/windowsntfocus/5ZP030U60U.html

If you run in CGI mode you likely have a line similar to the
following in your httpd.conf:
ScriptAlias /php/ "C:\php\"

Also, if you run SAPI mode (apache plugin mode) and used 
to run CGI, make sure that that line is commented out.

Has someone else got an idea for a workaround, without having
to go into safe-mode?  Would safe-mode be able to prevent this?

-GED

Northern.CA ===--
http://www.northern.ca 
Canada's Search Engine


--- End Message ---
--- Begin Message ---
 Wow!, i tried it and it really works, this is serious man! is there a fix around it 
without safe mode like GED suggested?

>Folks running Apache/Win32 should read this: 
>
>http://www.securiteam.com/windowsntfocus/5ZP030U60U.html 
>
>If you run in CGI mode you likely have a line similar to >the 
>following in your httpd.conf: 
>ScriptAlias /php/ \"C:php\" 
>
>Also, if you run SAPI mode (apache plugin mode) and used 
>to run CGI, make sure that that line is commented out. 
>
>Has someone else got an idea for a workaround, without >having 
>to go into safe-mode? Would safe-mode be able to prevent >this? 
>
>-GED 
>
>Northern.CA ===-- 
>http://www.northern.ca 
>Canada\'s Search Engine 
>
--- End Message ---
--- Begin Message ---
An array contains various values eg: list of fruits.
Now i want to retrieve only unique fruits from the
array. The array may contain duplicate names. How can
i achieve this?

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- End Message ---
--- Begin Message ---
$distincts=array();
while (list($key,$val)=each($yourarray)
{
  if (!in_array($val,$distincts))
  {
    $distincts[]=$val;
  }
}

"Kancha ." wrote:

> An array contains various values eg: list of fruits.
> Now i want to retrieve only unique fruits from the
> array. The array may contain duplicate names. How can
> i achieve this?
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]



--- End Message ---
--- Begin Message ---
Try array_unique()

Regards,
Andrey Hristov

--- End Message ---
--- Begin Message ---
> I don't know if this is actually it, but the line
> $num_vals[$i] = mysql_fetch_array($result);
> seems strange to me - doesn't mysql_fetch_array return an array?
> You should try
> list($num_vals[$i]) = mysql_fetch_array($result);
> and see if you get any improvements...

No, that was not it. It gave me different results - but still wrong.
I have, however, got a little closer by extending the loop to 0-11,
for ($i=0; $i<11; $i++), and changing the display, starting with: echo
$num_vals[1][0];;. I had alla numbers shifted one step to the right before
when counting zeroes as well.

But - still the same problem. It doesn´t count correctly - and i can´t
figure out why...

- Daniel

--- End Message ---
--- Begin Message ---
Hi

I am writing a piece of code that uses contstant names that are dynamic.

My first solution was to use the

constant() function from within PHP.

My problem now is that the code needs to be compatible with PHP 3.018 and
early versions of PHP 4.

Can anyone offer a better way of doing things?

My current code is

        $expected_result = 0;
        for ($i = 1; $i <= $this->total_num; $i ++) {
          $information = constant('CONS_' . $i);
          $information_2 = split("[,]", $information);
          if ( in_array($expected_result, $information_2) ) {
            $expected_result = $i;
            break;
          }
        }

Thanks in advance for any suggestions.

Mark


--- End Message ---

Reply via email to