php-general Digest 28 Nov 2003 05:46:25 -0000 Issue 2441

Topics (messages 171223 through 171243):

2 (simple?) php related questions
        171223 by: Ryan A
        171225 by: Graham Solomon

Re: Does anyone have Upload meter php codes?
        171224 by: Ryan A

Re: House for rent - Good price
        171226 by: Kim Steinhaug

Re: Translate web site language
        171227 by: Kim Steinhaug

Re: Associative vs normal arrays
        171228 by: Kim Steinhaug

The clock issue in this forum!
        171229 by: Kim Steinhaug

Re: Print..
        171230 by: Kim Steinhaug

Re: Count online users question
        171231 by: Kim Steinhaug

Re: Getting the required GD Memmory Usage.
        171232 by: William Bailey

wddx in sessions
        171233 by: Jon Hill

Re: preg_replace Guru question
        171234 by: Justin French

Re: array problems
        171235 by: Curtis Maurand
        171236 by: Curtis Maurand

How compatible is using PATH_INFO?
        171237 by: Leif K-Brooks

Converting to ASCII HEX
        171238 by: Ashley M. Kirchner
        171239 by: John Nichel
        171240 by: Robert Cummings
        171241 by: Ashley M. Kirchner

Telling GD2 Where Fonts Are
        171242 by: stiano.optonline.net
        171243 by: Tom Rogers

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 ---
Hi,
I have 2 main php questions and a few sub questions :-)

1.
 I have Dreamweaver/EditPlus and Zend developer (some full versions some
trial) (am open to trying out other tools)

Is there anyway to do a find/replace on a particular variable in a whole
directory? (or all files that refer/use that variable)
eg:
find $GuessableVariable and replace it with $HardToGuessVariable

or do i have to go file by file and do a search?

2.
I have visited many sites which use ASP/JSP and PHP which instead of calling
*differient* pages like so:
http://somesite.com/pageName.php?s=blah
http://somesite.com/DifferientPageName.php?s=blah2

(thats the way i generally program)

keep calling the *same* page with numbers, like so:
http://somesite.com/pageName.php?s=333
then
http://somesite.com/pageName.php?s=334
http://somesite.com/pageName.php?s=253
etc

Whats the advantage of the above and whats the idea?
isnt it much easier (and logical) to keep track of pages if you give them a
logical name?

giving a page: loginClient.php is much easier than remembering
script.php?val=214

right?
Or am I missing something?

Thanks,
-Ryan
http://Bestwebhosters.com

--- End Message ---
--- Begin Message --- Ryan A wrote:

Hi,
I have 2 main php questions and a few sub questions :-)

1.
 I have Dreamweaver/EditPlus and Zend developer (some full versions some
trial) (am open to trying out other tools)

Is there anyway to do a find/replace on a particular variable in a whole
directory? (or all files that refer/use that variable)
eg:
find $GuessableVariable and replace it with $HardToGuessVariable

or do i have to go file by file and do a search?

2.
I have visited many sites which use ASP/JSP and PHP which instead of calling
*differient* pages like so:
http://somesite.com/pageName.php?s=blah
http://somesite.com/DifferientPageName.php?s=blah2

(thats the way i generally program)

keep calling the *same* page with numbers, like so:
http://somesite.com/pageName.php?s=333
then
http://somesite.com/pageName.php?s=334
http://somesite.com/pageName.php?s=253
etc

Whats the advantage of the above and whats the idea?
isnt it much easier (and logical) to keep track of pages if you give them a
logical name?

giving a page: loginClient.php is much easier than remembering
script.php?val=214

right?
Or am I missing something?

Thanks,
-Ryan
http://Bestwebhosters.com

Hi ryan,


I have a search replace tool which i'll send to you, you can add all php files to it and do a search replace on all of them at once, very simple.

and as for the 2nd question when I build sites I use the index.php?page=contact etc type method, the point is to have one file with your navigation/header/footer in so you can make one change to these common parts for all pages.

e.g.

index.php?page=contact

would be as follows

*********
//header
//navigation

switch(page) {
        case contact:   include("contact.php"); break;
}

//footer
*********

whereas when you call a different file for each page it is more like this...


********* include("header.php");


// code & content here



include("footer.php"); *********

or at least thats how I do it : )

Regards
  G.Solomon

--- End Message ---
--- Begin Message ---
> http://pear.php.net/package/HTML_Progress


Very nice,
But seems to have a problem with Netscape Communicator 4.75
Works perfectly with IE and Opera it seems....

Cheers,
-Ryan A
http://Bestwebhosters.com

 

--- End Message ---
--- Begin Message ---
Fix your clock!

Post like theese really screws up the layout in my newsreader!

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"O J P P" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hello all mailing list, House for rent - Good price, :), bye.

URL : http://www.geocities.com/rapogo

--- End Message ---
--- Begin Message ---
Fix your clock!

Post like theese really screws up the layout in my newsreader!

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Orlando Pozo" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
I think that PHP have libraries to translate one language into another, if
you have information about it, please, give me a hand, thanks, bye.

--- End Message ---
--- Begin Message ---
Fix your clock!

Post like theese really screws up the layout in my newsreader!

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Joe" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Is there a way to determine if an array is associative or not?  Maybe
something similar to the is_array() function ??

Thanks,

JOE

--- End Message ---
--- Begin Message ---
Im using Outlook Express reading theese messages and I
think the newsreader works just fine.

But what do I do when theese people post with wrong dates.
Is there any way in Outlook Express I can remove theese posts,
or do I have to see them topping the list every time I check the
lists?

Ive tried several ways now, but I cant seem to fix them.

Any help would be appritiated? Maby I should change
newsreader?

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------

--- End Message ---
--- Begin Message ---
Fix your clock!

Post like theese really screws up the layout in my newsreader!

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Daniel Antonio De Lima" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Good Morning....

I am working with PHP 4.0.6, and I do not obtain to send given of the page
for the printer. I use function " PRINTER_OPEN() ", I make the manual in
accordance with, exactly thus it gives an error to me of indefinite
function. What it can be?
Fatal error: Call you undefined function:printer_open()

$print = printer_open();
$print = printer_open("LPT1 ");
printer_write($print, " Test of printer ");
printer_write($print, " Test of printer ");
printer_write($print, " Test of printer ");
$print = printer_close();

e this error it even gives to me with function " PRINTER_WRITE() ", could
give tips of that he can be happening.

Yours truly.

Daniel

--- End Message ---
--- Begin Message ---
Cookies, or browsersession. I found the latter to be very
easy to work with.

-- 
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------


"Al" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > I am trying to figure an accurate way to calculate how many users are
> > viewing a site, at any particular time. This task is very simple except
> for
> > one part - How do you determine when a person has left the site...apache
> > hasn't served anymore requests from a particular ip for xx minutes ??
>
> Hi Mike,
>
> There is no surefire way to measure the exact time a user leaves your
site.
> The most accurate way I can think of would be to use a hidden frame on all
> your pages that refreshes itself every X seconds. When a user has not
> requested that special tracking page for more than X seconds, you can
assume
> they have 'left' the site.
>
> However this solution seems like overkill for most purposes: you'll be
> wasitng server resources and slowing down your users' experience on your
> site.
>
> In response to your proposed method, most advertising associations
> (including the US-based Internet Advertising Bureau) and web analytics
> companies (such as Red Sherrif, Nielsens and Hitwise) define the end of a
> user session on a website when there is 30 minutes without a further
request
> for a page from the site.
>
> And while you may be tempted to track only IP numbers, remember that many
> users are behind shared IP numbers (e.g. firewalls) which may skew your
> stats. You would be better off using cookies on user's machines to
identify
> them and log their accesses to a DB.
>
> Hope that helps,
>
> Al

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sorry but thats not what i'm after. I want to know the available memory
needed to load the image. The default php memory limit is 8M and if the
image is large php is not able to load it because the 8M limit is
reached and therefore causes php to error out.

Is there a way to calculate the memory required to load the image
without haveing to load it? Would the following work...

$memSize = $imageWidth * $imageHeight * 4

This assumes that gd uses 32bits per pixel.

Regards,
        William Bailey.
        Pro-Net Internet Services Ltd.
        http://www.pro-net.co.uk/


Vail, Warren wrote: | actually what you probably need is | | http://www.zend.com/manual/function.getimagesize.php | | Warren Vail | | -----Original Message----- | From: William Bailey [mailto:[EMAIL PROTECTED] | Sent: Wednesday, November 26, 2003 10:01 AM | To: [EMAIL PROTECTED] | Subject: [PHP] Getting the required GD Memmory Usage. | | | Hi All, | | I have a site that loads images with the built in GD functions. Most | of | the images are small and load fine however there are a few images that | are large and when trying to load them causes php to exit with the | unable to allocate memory message. I was wondering if anybody knows of a | way to look at a file (in this case a JPEG) and then calculate the | memory requirements required for GD to load it. | | I know that i can just set the memory limit value to a higher value | but | i don't want to load these large images anyway so if i could work out | the GD memory requirement without having to load the image it would be | most useful. | | -- | Regards, | William Bailey. | Pro-Net Internet Services Ltd. | http://www.pro-net.co.uk/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/xmOQzSfrYDJMXmERAsixAKCoEDRd4JSXHuWvLtXA19zuZiBSJgCeMvJ+
7cp6i4j3YM0n3FVAzMIQFfg=
=CIC2
-----END PGP SIGNATURE-----

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

I came across some strange session behaviour today using latest version of php 
under apache 1.3.29 on redhat 9.

I am using a customer handler for the sessions, a simple mysql table. I am 
finding that the session data intermitently switches to wddx serialisation 
rather than the deault method. It appears to be random and I only noticed 
when I ever so often I got SQL errors due to the single quotes in the WDDX. 
There appeared to be no pattern to the behaviour. My php.ini file is set to 
php not wddx and I have not used ini_set in my script to alter the default.

Has anyone seen anything similar?

Jon

--- End Message ---
--- Begin Message --- On Friday, November 28, 2003, at 12:17 AM, pete M wrote:

What Preg_replace code would I need to highlight all the code within the "<script </script>" tags in red.. (case insensitive)


What I want is a view_source.php page to highlight the javascript for a tutorial I'm writing. Can view the source ok but need to highlight the code.


Not a regular expression expert ;-(

UNTESTED:


<?
$old = "before before
<script type='text/javascript'>
function foo()
        {
        // bah
        }
</script>
after after";

// i assume the source will have htmlentities applied...
$old = htmlentities($old);

// ...therefore we need to match on &lt; and &gt; rather than < and >
$new = preg_replace('/&lt;script(.*?)&gt;(.*?)&lt;\/script&gt;/ s','&lt;script\\1&gt;<span style="color:red;">\\2</span>&lt;/script&gt;',$old);


echo "<pre>{$new}</pre>";
?>


season to taste :)


Justin French
--- End Message ---
--- Begin Message ---
Thank you, I'll try that.

Curtis


On Wednesday 26 November 2003 21:53, the council of elders heard Marek 
Kilimajer mumble incoherently:
> Curtis Maurand wrote:
> > Sorry, its a typo.  it should be:
> >
> > $city = "Ipswitch";
> > $city_found = 0;
> > $contentfile = fopen("content.txt", "r");
> > while (!feof($contentfile) && $city_found == 0);
> >   {
> >     $my_line = fgets($contentfile, 16384);
> >     $content_array = explode("\t",$my_line);
> >     if ($content_array[0] == $city)
> >      {
> >     $city_found = 1;
> >         print("Matched on $content_aray[0]<br>\n");
>
> /* Break out of the while loop */
>         break;
>
> >      }
> >   }
> > print("$content_array[0]\n");
> >
> > //end
> >
> > As I stated.  The match happens and the "Matched on..." message
> > happens, but the print statement outside the "while" loop does
> > not.  Its php-4.2.2 running on RedHat 8.0 (don't go there.)  Its
> > the stock redhat php package. I don't trust redhat libraries for
> > building php from scratch.  Of course, this might actually be the
> > problem, too.  :-)
> >
> > Curtis

--- End Message ---
--- Begin Message ---
OK.  That worked, thanks.  

Is it me, or is that rather odd behavior?  Shouldn't array elements 
set within a loop be available to me outside the loop if the loop 
exits normally?  A loop is not a function (well it is, sort of.)  
Should I declare the variable as global?

global $content_array;
$city_found = 1;
while(!feof ...

When I was taking programming courses in college, I was taught that 
breaking out of a loop like that was bad practice; that it was better 
to leave a loop normally.  I've never programmed in "C" other than to 
write a crude little "dos2unix" (actually mac2dos) utility.  Mosty 
i've written Perl, PHP Pascal and Basic.  Pascal, Perl and Basic 
don't exhibit this behavior.  I never worked with arrays in "C."  Am 
I wrong?




On Wednesday 26 November 2003 21:53, the council of elders heard Marek 
Kilimajer mumble incoherently:
> Curtis Maurand wrote:
> > Sorry, its a typo.  it should be:
> >
> > $city = "Ipswitch";
> > $city_found = 0;
> > $contentfile = fopen("content.txt", "r");
> > while (!feof($contentfile) && $city_found == 0);
> >   {
> >     $my_line = fgets($contentfile, 16384);
> >     $content_array = explode("\t",$my_line);
> >     if ($content_array[0] == $city)
> >      {
> >     $city_found = 1;
> >         print("Matched on $content_aray[0]<br>\n");
>
> /* Break out of the while loop */
>         break;
>
> >      }
> >   }
> > print("$content_array[0]\n");
> >
> > //end
> >
> > As I stated.  The match happens and the "Matched on..." message
> > happens, but the print statement outside the "while" loop does
> > not.  Its php-4.2.2 running on RedHat 8.0 (don't go there.)  Its
> > the stock redhat php package. I don't trust redhat libraries for
> > building php from scratch.  Of course, this might actually be the
> > problem, too.  :-)
> >
> > Curtis

--- End Message ---
--- Begin Message --- One common way to work around many search engines ignoring pages with query strings is to use scripts with odd URIs (http://server.com/foo.php/foo/bar for instance) and get them with $_SERVER['PATH_INFO']. How compatible is doing that? Will servers besides Apache support it?
--- End Message ---
--- Begin Message ---
How can I convert a string like this: "test & test" into "test%20%26%20test" so I can then pass it to a script? Essentially convert the spaces and & symbol to their ASCII HEX equivalent.


--
H| I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.

--- End Message ---
--- Begin Message --- Ashley M. Kirchner wrote:


How can I convert a string like this: "test & test" into "test%20%26%20test" so I can then pass it to a script? Essentially convert the spaces and & symbol to their ASCII HEX equivalent.



http://us3.php.net/manual/en/function.urlencode.php


--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
On Thu, 2003-11-27 at 20:51, Ashley M. Kirchner wrote:
> 
>     How can I convert a string like this:  "test & test" into 
> "test%20%26%20test" so I can then pass it to a script?  Essentially 
> convert the spaces and & symbol to their ASCII HEX equivalent.

urlencode()

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

--- End Message ---
--- Begin Message ---
Duh, why didn't I think of urlencode() ?! I kept looking for something with hex in it, or some string conversion. It never dawned on me...I'm dealing with html stuff and conversion...and url never even came to mind. Must be the turkey (more like, lack thereof...) Hay, thanks everyone. Happy Gobble Day for those who celebrate it.


--
H| I haven't lost my mind; it's backed up on tape somewhere.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
IT Director / SysAdmin / WebSmith . 800.441.3873 x130
Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.

--- End Message ---
--- Begin Message ---
Working on a Macintosh G3 PowerBook running OS 10.2 and PHP 4.3.0 with GD2
...

I'm having trouble telling GD2 where the font I'm using in a PHP exercise
(Chapter 19 of the 2nd edition of the Welling/Thomson book), arial.ttf, 
resides. The font is obviously in a folder on my hard drive, the path of
which runs like so:

Macintosh HD/Fonts/arial.ttf

The line of PHP code that gives this info goes like this--at least the way
I unsuccessfully put it:

putenv('GDFONTPATH=Macintosh HD/Fonts
$fontname = 'arial.ttf'

As I say, it doesn't work. Can anyone tell me how I should alter the code?
Should I put the font in the root folder, 'localhost/..."?

Thank you.

Steve Tiano

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

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

Friday, November 28, 2003, 12:12:57 PM, you wrote:
son> Working on a Macintosh G3 PowerBook running OS 10.2 and PHP 4.3.0 with GD2
son> ...

son> I'm having trouble telling GD2 where the font I'm using in a PHP exercise
son> (Chapter 19 of the 2nd edition of the Welling/Thomson book), arial.ttf, 
son> resides. The font is obviously in a folder on my hard drive, the path of
son> which runs like so:

son> Macintosh HD/Fonts/arial.ttf

son> The line of PHP code that gives this info goes like this--at least the way
son> I unsuccessfully put it:

son> putenv('GDFONTPATH=Macintosh HD/Fonts
son> $fontname = 'arial.ttf'

son> As I say, it doesn't work. Can anyone tell me how I should alter the code?
son> Should I put the font in the root folder, 'localhost/..."?

son> Thank you.

son> Steve Tiano

son> --------------------------------------------------------------------
son> mail2web - Check your email from the web at
son> http://mail2web.com/ .

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


Give the full path to the font file, I do like this

$font = $path_to_font.'/font.ttf';

-- 
regards,
Tom

--- End Message ---

Reply via email to