php-general Digest 23 Apr 2002 11:02:04 -0000 Issue 1303

Topics (messages 94084 through 94134):

Re: From where was function called?
        94084 by: Martin Towell
        94119 by: Adrian Ciutureanu

Re: Second opinion needed - javascript blocker
        94085 by: Martin Towell
        94114 by: Justin French

LogiCreate: looking for resellers
        94086 by: Michael Kimsal
        94087 by: Richard Archer
        94088 by: Michael Kimsal
        94089 by: Michael Kimsal

Unsubscribe?
        94090 by: Josiah Wallingford
        94091 by: Martin Towell
        94092 by: Miguel Cruz

Why isn't this working? :(
        94093 by: Leif K-Brooks
        94094 by: Martin Towell
        94096 by: Richard Archer

Re: ereg size limit???
        94095 by: SP

Regex: catchall function to validate Last and First names
        94097 by: Carl E Shmidt

Re: Why isn't this working? :( - I found my solution!
        94098 by: Leif K-Brooks

remove last character in a string
        94099 by: Craig Westerman
        94100 by: Rasmus Lerdorf
        94101 by: Tyler Longren
        94103 by: Craig Westerman
        94105 by: Evan Nemerson
        94106 by: Rasmus Lerdorf
        94107 by: Tyler Longren
        94108 by: Tyler Longren
        94110 by: Matthew Walker
        94111 by: Jarrad Kabral

Can php support ttf??
        94102 by: zhaoxd
        94104 by: Rahul Bhide
        94109 by: Matthew Walker
        94112 by: Richard Archer

Interesting Links, can be not PHP
        94113 by: Mantas Kriauciunas
        94115 by: Martin Towell
        94116 by: Mantas Kriauciunas

Setting the name of a file in a download....
        94117 by: Brian White
        94122 by: Richard Archer

TEST
        94118 by: kip

store pics on mysql db
        94120 by: mm fernandez
        94121 by: Brian White
        94123 by: Richard Archer

get ip of visitors
        94124 by: Cosmin Vlasiu
        94125 by: Luc Saint-Elie
        94126 by: Cosmin Vlasiu
        94127 by: Claudiu
        94132 by: Cosmin Vlasiu

need help sorting an array...tricky
        94128 by: Leif Högberg

Arrat question
        94129 by: Bas Jochems

Array question
        94130 by: Bas Jochems
        94131 by: Michal Dvoracek

Re: The so-called improvment in PHP 4.2.0
        94133 by: Rouvas Stathis

dynamic drop down
        94134 by: Kunal Jhunjhunwala

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 ---
um - (unix) grep   (windows) find files
That's something that I've been wanting for a while - a function call stack
that the php script can look at.

-----Original Message-----
From: Nico van der Dussen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 3:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] From where was function called?


Hi,

I'm having a real problem:

In a codeset of more than 5000 lines of code, I have a rogue call to a
function.

Is there a way I can determine in a function from where the call was
made?  (Filename, linenumber etc)

Thanks

Nico


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
You can use the 'magic constants' __FILE__ and __LINE__
For example, if you have an editor that can replace the newline "\n"
character, you can replace all "\n" with
"\nerror_log(__FILE__ . '[' .  __LINE__ . ']');"

"Nico Van Der Dussen" <[EMAIL PROTECTED]> wrote in message
3CC45EB5.6064.19C3129@localhost">news:3CC45EB5.6064.19C3129@localhost...
> Hi,
>
> I'm having a real problem:
>
> In a codeset of more than 5000 lines of code, I have a rogue call to a
> function.
>
> Is there a way I can determine in a function from where the call was
> made?  (Filename, linenumber etc)
>
> Thanks
>
> Nico
>


--- End Message ---
--- Begin Message ---
What about:
        1. getting rid of anything between "<script" and </script.*>"
        2. get rid of any attributes that start with " on" and end with a
quotes or space
                Maybe I'm forgetting about some valid attributes that start
with "on", you might have to cater for them

Does this work?

HTH
Martin


-----Original Message-----
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 6:49 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: AW: [PHP] Re: Second opinion needed - javascript blocker


Thynks, but I don't want to block html, I want to block javascript!  And
since onmouseover and similar events can be put in any tag, I'm trying to
block them.
on 4/22/02 4:44 PM, J Smith at [EMAIL PROTECTED] wrote:


Then I'd suggest using the strip_tags() function and define which tags you'd
like to leave untouched.

J


Red Wingate wrote:

> He might want to use this function but doing so no links or bold underline
> Tags will be destroyed as well.
> 




--- End Message ---
--- Begin Message ---
on 23/04/02 1:59 PM, Martin Towell ([EMAIL PROTECTED]) wrote:


> would become
> 
> =foo
> ="foo"
> = "foo"
> ='foo'
> ='foo'
> 
> which the browser would just ignore

In theory, yes.  I don't think I'd trust it here -- this is potentially
malicious content added by unknown people.  I'd be taking the approach keep
what you trust, throw out the rest, which is a more complex set of regexps
though.

hence <B anything> should be trimmed back to <B>.... this is easier on a
smaller subset of HTML, rather than "all HTML".

I personally would not give unknown contributors any more than you have to.


Justin
--------------------
Creative Director
http://Indent.com.au
--------------------

--- End Message ---
--- Begin Message ---
Hello all!

My company, Tap Internet, has launched the latest
version of our development platform - LogiCreate.  The basic
info can be found at http://www.logicreate.com, but I'm writing
here specifically to solicit product resellers from
the PHP developer community.

The product itself has been tested in numerous deployments
over the past 2 years, including ecommerce, extranet, intranet and
CMS-oriented installations.

Although there are numerous open source projects and toolkits
you can base your development work on, we'd like to appeal to
your commercial instincts.  By becoming a LogiCreate
reseller, you'll be getting much more than code and updates,
including

* Deployment experience and support.  Our engineers
have deployed large scale ecommerce sites (processing
tens of millions of dollars per day) as well as handled
migration from ColdFusion and ASP-based sites.

* Sales support - if you need help developing proposals
to go up against competitors, we can help.  Whether it's
the validity of PHP itself, or questions about open source
security, we'll lend our support to your sales efforts.

* Training - we offer the only professional PHP training course
in the US, and as a reseller you get preferred rates on
training courses (as well as at least one free class per year).

While there's nothing wrong with the mailing lists and
support forums on various free sites, you won't find a stronger 
combination of a solid development framework and professional support
anywhere else. If you're ready to step up your development
efforts with PHP, give us a call.


-------------------------
Michael Kimsal
734-480-9961
http://www.logicreate.com

--- End Message ---
--- Begin Message ---
At 7:57 PM -0400 22/4/02, Michael Kimsal wrote:

> you won't find a stronger combination of a solid development
>framework and professional support anywhere else.

In a word: Bollocks.

This obviously an untrue claim for all but one company in the world.
And I find it very hard to believe that you could be that company.

I would never purchase (or possibly even use) a product from someone
who lies and misleads in their promotional material.

Thanks for the spam.

 ...R.
--- End Message ---
--- Begin Message ---
Richard Archer wrote:
> At 7:57 PM -0400 22/4/02, Michael Kimsal wrote:
> 
> 
>>you won't find a stronger combination of a solid development
>>framework and professional support anywhere else.
> 
> 
> In a word: Bollocks.
> 
> This obviously an untrue claim for all but one company in the world.
> And I find it very hard to believe that you could be that company.
> 
> I would never purchase (or possibly even use) a product from someone
> who lies and misleads in their promotional material.
> 
> Thanks for the spam.
> 
>  ...R.

Perhaps I should have clarified (and I thought it was evident)
that we were referring to the PHP market, not the
software development market in general.  We still don't know
anyone else who provides guaranteed PHP development support
service or professional training courses for PHP.  If you
know of others in the US, please let me know.

I apologize to you if you've felt misled - it was not the
intention at all.


Michael Kimsal
http://www.logicreate.com
734-480-9961

--- End Message ---
--- Begin Message ---
Richard Archer wrote:
> At 7:57 PM -0400 22/4/02, Michael Kimsal wrote:
> 
> 
>>you won't find a stronger combination of a solid development
>>framework and professional support anywhere else.
> 
> 
> In a word: Bollocks.
> 
> This obviously an untrue claim for all but one company in the world.
> And I find it very hard to believe that you could be that company.
> 
> I would never purchase (or possibly even use) a product from someone
> who lies and misleads in their promotional material.
> 
> Thanks for the spam.
> 
>  ...R.

Perhaps I should have clarified (and I thought it was evident)
that we were referring to the PHP market, not the
software development market in general.  We still don't know
anyone else who provides guaranteed PHP development support
service or professional training courses for PHP.  If you
know of others in the US, please let me know.

I apologize to you if you've felt misled - it was not the
intention at all.


Michael Kimsal
http://www.logicreate.com
734-480-9961

--- End Message ---
--- Begin Message ---
How do you unsubscribe to this mailing list?
--- End Message ---
--- Begin Message ---
[snip from bottom of msgs]
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[end snip]

-----Original Message-----
From: Josiah Wallingford [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 10:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Unsubscribe?


How do you unsubscribe to this mailing list?
--- End Message ---
--- Begin Message ---
On Mon, 22 Apr 2002, Josiah Wallingford wrote:
> How do you unsubscribe to this mailing list?

Instructions are provided in the header of each list message.

miguel

--- End Message ---
--- Begin Message ---
I have a site where users can sign up.  I have had huge problems with people
using auto-signups, so I tried to stop them with an authentication image.
Someone has since gotten around that.  I highly doubt he is using OCR.  Can
someone try to figure out what's wrong with my code?  Here it is:
Contents of auth_image.php:
<?php
$dbh = mysql_connect ("MYSERVER", "MYUSER", "MYPASS");
mysql_select_db ("MYDB",$dbh);
$authimage = ImageCreate(40,15);
$white = ImageColorAllocate($authimage, 255, 255, 255);
$black = ImageColorAllocate($authimage, 0, 0, 0);
header("Content-type: image/jpeg");
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$id'"));
imagestring($authimage,5,0,0,$getcode[code],$black);
imagejpeg($authimage);
imagedestroy($authimage);
?>

Some code from signup.php:
//I do seed the random number in the header
$code = mt_rand(1000,9999);
mysql_query("insert into signupcodes(code) values('$code')");
$codeid = mysql_insert_id();
<input type=hidden name=codeid value=$codeid><img
src='authimage.php?id=$codeid'><br>
<b>Code from above:</b> <input type=text name=code><br>

At top of proccess_signup.php:
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$codeid'"));
if($code != $getcode[code]){
die("<b>Error:</b> wrong code");
}

In the middle of process_signup.php, after I've done checks of a few other
things:
 echo "You're a member! :D<br><a href='/'>Back to homepage</a>";
mysql_query("delete from signupcodes where id='$codeid'") or print 

--- End Message ---
--- Begin Message ---
> Can someone try to figure out what's wrong with my code?
What are you expecting, and what are you seeing?


-----Original Message-----
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 11:12 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Why isn't this working? :(


I have a site where users can sign up.  I have had huge problems with people
using auto-signups, so I tried to stop them with an authentication image.
Someone has since gotten around that.  I highly doubt he is using OCR.  Can
someone try to figure out what's wrong with my code?  Here it is:
Contents of auth_image.php:
<?php
$dbh = mysql_connect ("MYSERVER", "MYUSER", "MYPASS");
mysql_select_db ("MYDB",$dbh);
$authimage = ImageCreate(40,15);
$white = ImageColorAllocate($authimage, 255, 255, 255);
$black = ImageColorAllocate($authimage, 0, 0, 0);
header("Content-type: image/jpeg");
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$id'"));
imagestring($authimage,5,0,0,$getcode[code],$black);
imagejpeg($authimage);
imagedestroy($authimage);
?>

Some code from signup.php:
//I do seed the random number in the header
$code = mt_rand(1000,9999);
mysql_query("insert into signupcodes(code) values('$code')");
$codeid = mysql_insert_id();
<input type=hidden name=codeid value=$codeid><img
src='authimage.php?id=$codeid'><br>
<b>Code from above:</b> <input type=text name=code><br>

At top of proccess_signup.php:
$getcode = mysql_fetch_array(mysql_query("select * from signupcodes where id
= '$codeid'"));
if($code != $getcode[code]){
die("<b>Error:</b> wrong code");
}

In the middle of process_signup.php, after I've done checks of a few other
things:
 echo "You're a member! :D<br><a href='/'>Back to homepage</a>";
mysql_query("delete from signupcodes where id='$codeid'") or print 

--- End Message ---
--- Begin Message ---
At 9:11 PM -0400 22/4/02, Leif K-Brooks wrote:


At 9:11 PM -0400 22/4/02, Leif K-Brooks wrote:

>I have a site where users can sign up.  I have had huge problems with people
>using auto-signups, so I tried to stop them with an authentication image.
>Someone has since gotten around that.  I highly doubt he is using OCR.  Can
>someone try to figure out what's wrong with my code?

I can't see anything wrong with it. Maybe the hacker is smarter than
you give him credit for.


>$authimage = ImageCreate(40,15);

Try randomising the size of the image. That'll stuff up any hash tables
he's built.


>imagestring($authimage,5,0,0,$getcode[code],$black);

and try varying the offset of the string in the image.


>$code = mt_rand(1000,9999);

Only 8999 possible codes? Is he brute-forcing it?
Check the server logs for thousands of verification attempts.


>if($code != $getcode[code]){
>die("<b>Error:</b> wrong code");

And consider deleting the code after 3 incorrect attempts.

 ...R.
--- End Message ---
--- Begin Message ---
Hey James, yeah you're right that was a typo, ereg was what I meant.  Thanks
your suggestion worked and plus I think preg is much faster then ereg so
that's cool.


-----Original Message-----
From: liljim [mailto:[EMAIL PROTECTED]]
Sent: April 22, 2002 4:44 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: ereg size limit???


Hi,


"Sp" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I am trying to validate my input with ereg but I get the error "Warning:
> REG_BADBR" when I try over 255 characters.  Is there anyway around this?
>
> Works
> =====
> if(eregi('^[A-Za-z]{1,255}$', "test sentence"))
>   echo "valid input";
>
> Doesn't Work
> ============
> if(eregi('^[A-Za-z]{1,256}$', "test sentence"))
>   echo "valid input";


First off, you're using eregi (case insensitive), but defining a-zA-Z (a
through z, case insensitive) in your characters class. You could just use
ereg and leave the character class as it is, or drop the A-Z from the eregi
version.

Secondly, I'd amend your code to:
^[a-z]+$

And thirdly, I'd just use a combination of ereg / preg_* functions and
strlen.

if(preg_match("/^[a-z]+$/i", $string) && strlen($string) < 255)
{
    echo "Whatever.";
}

I'm not sure why you're getting that error, but then again, I haven't
bothered reading up about it :)

James



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


--- End Message ---
--- Begin Message ---
I have a guest book , and I want to make sure that those people who sign the
guest book can't impersonate a member of the web site.  the code below
checks the input string, which is the guestbook signer's name, against a
list of defined web site members.  Is there any way to circumvent the code
as I've written it?

  function validateGuestbookSigner($valToEval,&$errorArray){
echo "Value: $valToEval<BR>";
    $valToEval=preg_replace("/[^A-Za-z0-9]/","",$valToEval);
echo "Value after stripping all nonessential debris: $valToEval<BR>";

    //obtain the list of names to test against
    $names=getGuestBookNames();

    //iterate through each person in the list
    foreach($names as $name){

      //explode to get first and last name
      $namePieces=explode(",",$name);


      //look for the last name,case insensitive
      if(preg_match("/" . $namePieces[0] . "/i", $valToEval)){
        $errorArray[]="The last name that it matched is: $namePieces[0]";
        $errorArray[]="Please consult the Guestbook Rules for a list of
names of those people in the band or are affilliated with the web site
";
        $errorArray[]="Part of the guestbook signer's name matches a last
name that cannot be used";
        return false;
      }

      //look for the first name,case insensitive
      //(the name might just be Webmaster, so make sure
      // to check if first name exists at all)
      if(count($namePieces)>1){
         if(preg_match("/" . $namePieces[1]  . "/i", $valToEval)){
           $errorArray[]="The first name that it matched is:
$namePieces[1]";
           $errorArray[]="Please consult the Guestbook rules for a list of
names of those people in the band or are affilliated with the web s
ite";
           $errorArray[]="Part of the guestbook signer's name matches a last
name that cannot be used";
           return false;
         }
      }
    }
    return true;
  }


--- End Message ---
--- Begin Message ---
Thanks for everyone's help.  I just figured out was wrong.  I wasn't
checking if a code was being returned.  So all he had to do was chenge the
codeid field to a non-existant code.  Lol. 
--- End Message ---
--- Begin Message ---
I have a string that ends in a comma. What is best method to remove the
comma?

Craig ><>
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
read php.net/substr

On Mon, 22 Apr 2002, Craig Westerman wrote:

> I have a string that ends in a comma. What is best method to remove the
> comma?
> 
> Craig ><>
> [EMAIL PROTECTED]
> 

--- End Message ---
--- Begin Message ---
First, you'll need to get the length of the str with the str_len() function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]

----- Original Message -----
From: "Craig Westerman" <[EMAIL PROTECTED]>
To: "php-general-list" <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 10:26 PM
Subject: [PHP] remove last character in a string


> I have a string that ends in a comma. What is best method to remove the
> comma?
>
> Craig ><>
> [EMAIL PROTECTED]
>

--- End Message ---
--- Begin Message ---
Wouldn't it be better to check to see if charicater is indeed a comma before
removing it?

I was guessing eregi_replace would be the way to go.

Am I thinking wrong?

Craig ><>
[EMAIL PROTECTED]


First, you'll need to get the length of the str with the str_len() function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Why get strlen involved???

$string = substr("$string", 0, -1);



-- 
He is richest who is content with the least, for content is the wealth of 
nature.

Socrates
--- End Message ---
--- Begin Message ---
No you don't.  You should go read the substr() docs as well:

    substr($str,0,-1);

-Rasmus

On Mon, 22 Apr 2002, Tyler Longren wrote:

> First, you'll need to get the length of the str with the str_len() function.
> After you have that, use the substr() function like Rasmus mentioned.
> 
> Tyler Longren
> Captain Jack Communications
> www.captainjack.com
> [EMAIL PROTECTED]
> 
> ----- Original Message -----
> From: "Craig Westerman" <[EMAIL PROTECTED]>
> To: "php-general-list" <[EMAIL PROTECTED]>
> Sent: Monday, April 22, 2002 10:26 PM
> Subject: [PHP] remove last character in a string
> 
> 
> > I have a string that ends in a comma. What is best method to remove the
> > comma?
> >
> > Craig ><>
> > [EMAIL PROTECTED]
> >
> 
> 
> 

--- End Message ---
--- Begin Message ---
Yeah, I thought about that and said to myself "That's not right".  But I had
already clicked the "Send" button and the message was no longer in my
outbox.  :)

tyler

----- Original Message -----
From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>
Cc: "Craig Westerman" <[EMAIL PROTECTED]>; "php-general-list"
<[EMAIL PROTECTED]>
Sent: Tuesday, April 23, 2002 12:04 AM
Subject: Re: [PHP] remove last character in a string


> No you don't.  You should go read the substr() docs as well:
>
>     substr($str,0,-1);
>
> -Rasmus
>
> On Mon, 22 Apr 2002, Tyler Longren wrote:
>
> > First, you'll need to get the length of the str with the str_len()
function.
> > After you have that, use the substr() function like Rasmus mentioned.
> >
> > Tyler Longren
> > Captain Jack Communications
> > www.captainjack.com
> > [EMAIL PROTECTED]
> >
> > ----- Original Message -----
> > From: "Craig Westerman" <[EMAIL PROTECTED]>
> > To: "php-general-list" <[EMAIL PROTECTED]>
> > Sent: Monday, April 22, 2002 10:26 PM
> > Subject: [PHP] remove last character in a string
> >
> >
> > > I have a string that ends in a comma. What is best method to remove
the
> > > comma?
> > >
> > > Craig ><>
> > > [EMAIL PROTECTED]
> > >
> >
> >
> >
>

--- End Message ---
--- Begin Message ---
Because I'm kinda stupid.  :)

tyler

----- Original Message -----
From: "Evan Nemerson" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 10:53 PM
Subject: Re: [PHP] remove last character in a string


> Why get strlen involved???
>
> $string = substr("$string", 0, -1);
>
>
>
> --
> He is richest who is content with the least, for content is the wealth of
> nature.
>
> Socrates
>

--- End Message ---
--- Begin Message ---
Actually, if he uses a negative index in substr(), he doesn't need to
know the length of the string.

Matthew Walker
Senior Software Engineer
ePliant Marketing
 

-----Original Message-----
From: Tyler Longren [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 22, 2002 9:29 PM
To: Craig Westerman; php-general-list
Subject: Re: [PHP] remove last character in a string

First, you'll need to get the length of the str with the str_len()
function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]

----- Original Message -----
From: "Craig Westerman" <[EMAIL PROTECTED]>
To: "php-general-list" <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 10:26 PM
Subject: [PHP] remove last character in a string


> I have a string that ends in a comma. What is best method to remove
the
> comma?
>
> Craig ><>
> [EMAIL PROTECTED]
>


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
 
--- End Message ---
--- Begin Message ---
its my understanding that you wish to strip the last character of the string
not return it. Putting -1 in the length parameter will just return the last
character, it wont get rid of it....


$string = "This is the string,";
$str_length = strlen($string);

if (substr($string,0,-1) == ",") {
        //Strip
        $formatted_str = substr($string,0,str_length-1);
} else {
        //Dont strip
        //
}


That should work but I didnt test it  ;)


Regards
Jarrad Kabral



-----Original Message-----
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 23 April 2002 1:57 PM
To: Evan Nemerson; [EMAIL PROTECTED]
Subject: Re: [PHP] remove last character in a string


Because I'm kinda stupid.  :)

tyler

----- Original Message -----
From: "Evan Nemerson" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, April 22, 2002 10:53 PM
Subject: Re: [PHP] remove last character in a string


> Why get strlen involved???
>
> $string = substr("$string", 0, -1);
>
>
>
> --
> He is richest who is content with the least, for content is the wealth of
> nature.
>
> Socrates
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
hello all:
:)
My version of gd is 1.8.4,my php is 4.1.2,which works on apache server whose version 
is 1.3.24 and my OS is linux7.2.

When I compiled gd ,I used some libraries,such as 
libpng-1.2.0,zlib-1.1.4,freetype-2.1.0,I want my gd can support ttf besides png 
image,is it enough?

Can php support ttf?I hava just compiled gd in php,but I found it can not use some 
functions like ImageTTFtext and ImageTTFBBox,why?

Is that right that  gd-1.8.4 can't support functions about ttf ,just as gd cannot 
support gif?

Thank you
                                        zhaoxd

--- End Message ---
--- Begin Message ---
Hi,
    You need freetype-1.* library . You can get it at www.freetype.org . Then compile 
php --with-ttf=/usr/local assuming you have the library in
/usr/local/lib .

    I struggled a lot getting the TTF fonts to work in my env . Now I conclude that 
only specific combinations of versions of php/gd/freetype work well
with each other . I am using

freetype-1.3.1
gd-1.8.4
php-4.0.4pl1

which works well for me .

hope this helps.

~Rahul

zhaoxd wrote:

> hello all:
> :)
> My version of gd is 1.8.4,my php is 4.1.2,which works on apache server whose version 
>is 1.3.24 and my OS is linux7.2.
>
> When I compiled gd ,I used some libraries,such as 
>libpng-1.2.0,zlib-1.1.4,freetype-2.1.0,I want my gd can support ttf besides png 
>image,is it enough?
>
> Can php support ttf?I hava just compiled gd in php,but I found it can not use some 
>functions like ImageTTFtext and ImageTTFBBox,why?
>
> Is that right that  gd-1.8.4 can't support functions about ttf ,just as gd cannot 
>support gif?
>
> Thank you
>                                         zhaoxd

--- End Message ---
--- Begin Message ---
Also, non-Unicode TTF fonts will /not/ work with PHP.

Matthew Walker
Senior Software Engineer
ePliant Marketing
 

-----Original Message-----
From: Rahul Bhide [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 22, 2002 9:45 PM
To: zhaoxd
Cc: php mailling list
Subject: Re: [PHP] Can php support ttf??

Hi,
    You need freetype-1.* library . You can get it at www.freetype.org .
Then compile php --with-ttf=/usr/local assuming you have the library in
/usr/local/lib .

    I struggled a lot getting the TTF fonts to work in my env . Now I
conclude that only specific combinations of versions of php/gd/freetype
work well
with each other . I am using

freetype-1.3.1
gd-1.8.4
php-4.0.4pl1

which works well for me .

hope this helps.

~Rahul

zhaoxd wrote:

> hello all:
> :)
> My version of gd is 1.8.4,my php is 4.1.2,which works on apache server
whose version is 1.3.24 and my OS is linux7.2.
>
> When I compiled gd ,I used some libraries,such as
libpng-1.2.0,zlib-1.1.4,freetype-2.1.0,I want my gd can support ttf
besides png image,is it enough?
>
> Can php support ttf?I hava just compiled gd in php,but I found it can
not use some functions like ImageTTFtext and ImageTTFBBox,why?
>
> Is that right that  gd-1.8.4 can't support functions about ttf ,just
as gd cannot support gif?
>
> Thank you
>                                         zhaoxd


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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
 
--- End Message ---
--- Begin Message ---
At 11:29 AM +0800 23/4/02, zhaoxd wrote:

>When I compiled gd ,I used some libraries,such as
>libpng-1.2.0,zlib-1.1.4,freetype-2.1.0,I want my gd can support ttf
>besides png image,is it enough?
>
>Can php support ttf?I hava just compiled gd in php,but I found it can
>not use some functions like ImageTTFtext and ImageTTFBBox,why?

You be using ImageFtText and ImageFtBBox with freetype 2.

 ...R.
--- End Message ---
--- Begin Message ---
Hey PHP General List,

  Well i have seen some strange links last few months.... earlyer i
  didn't look at them because i didn't care... and now i am curious...
  how to understand link like this Http://www.foo.com/# and thats
  it... links ends and as it sayes for example it links to Our Works
  page on that website... how to understand that # ? can anybody
  expain? or give link to explanation ?

:------------------------------:
        Have A Nice Day! 
 Mantas Kriauciunas A.k.A mNTKz

Contacts:
[EMAIL PROTECTED]
Http://mntkz-hata.visiems.lt

--- End Message ---
--- Begin Message ---
it's a "bookmark"

basically, it's telling the browser to scroll the page down until it finds
the named bookmark

eg
<a name="top">Top of page</a>
blah...
...
<a href="#top">go to top</a>

clicking on that link will scrol the page to "top"

in your case, it's a "no-name" bookmark, and most browsers treat this as
either "don't move" or "top"

it's useful when doing "onClicks", etc. when you don't want to user to go to
a different page

HTH


-----Original Message-----
From: Mantas Kriauciunas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 5:17 PM
To: PHP General List
Subject: [PHP] Interesting Links, can be not PHP


Hey PHP General List,

  Well i have seen some strange links last few months.... earlyer i
  didn't look at them because i didn't care... and now i am curious...
  how to understand link like this Http://www.foo.com/# and thats
  it... links ends and as it sayes for example it links to Our Works
  page on that website... how to understand that # ? can anybody
  expain? or give link to explanation ?

:------------------------------:
        Have A Nice Day! 
 Mantas Kriauciunas A.k.A mNTKz

Contacts:
[EMAIL PROTECTED]
Http://mntkz-hata.visiems.lt


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

Got your email on:Monday, April 22, 2002, 10:29:52 PM writing:

:----
MT> it's a "bookmark"

MT> basically, it's telling the browser to scroll the page down until it finds
MT> the named bookmark

MT> eg
MT> <a name="top">Top of page</a>
MT> blah...
MT> ...
MT> <a href="#top">go to top</a>

MT> clicking on that link will scrol the page to "top"

MT> in your case, it's a "no-name" bookmark, and most browsers treat this as
MT> either "don't move" or "top"

MT> it's useful when doing "onClicks", etc. when you don't want to user to go to
MT> a different page

MT> HTH


MT> -----Original Message-----
MT> From: Mantas Kriauciunas [mailto:[EMAIL PROTECTED]]
MT> Sent: Tuesday, April 23, 2002 5:17 PM
MT> To: PHP General List
MT> Subject: [PHP] Interesting Links, can be not PHP


MT> Hey PHP General List,

MT>   Well i have seen some strange links last few months.... earlyer i
MT>   didn't look at them because i didn't care... and now i am curious...
MT>   how to understand link like this Http://www.foo.com/# and thats
MT>   it... links ends and as it sayes for example it links to Our Works
MT>   page on that website... how to understand that # ? can anybody
MT>   expain? or give link to explanation ?


:----

Thanks for your brief explanation. Now i understand little more. I got
confused before whyt it is only # no letters.. thanks again ;)

:------------------------------:
        Have A Nice Day! 
 Mantas Kriauciunas A.k.A mNTKz

Contacts:
[EMAIL PROTECTED]
Http://mntkz-hata.visiems.lt

--- End Message ---
--- Begin Message ---
I am using the following code to create a downloader. It works, except
that IE will just dump the contents to it's browser and Netscape 4
asks if I want to save it in a file called "blah.php".


     // File: blah.php

     if ( ! $fp = fsockopen ("www.steptwo.com.au", 80, $errno, $errstr, 30) )
     {
         echo "$errstr ($errno)<br>\n";
     }
     else
     {
         $userpass = "user:password";
         fputs ($fp, "GET /files/file.zip HTTP/1.0\r\n" .
                     "Host: www.steptwo.com.au\r\n" .
                     "Authorization: Basic " . base64_encode( $userpass ) . 
"\r\n" .
                     "\r\n");

         while ( $headerStr = trim( fgets( $fp , 3072 ) ) )
         {
             if ( strpos( $headerStr, ":" ) )
                 header( $headerStr );
         }


         fpassthru( $fp );
     }

Is there any way to get it to save as a file called "file.zip"?
Is there any header I can set? The headers it currently returns
are:

    Date: Tue, 23 Apr 2002 06:02:36 GMT
    Server: Apache/1.3.12 (Unix) ApacheJServ/1.1.2 PHP/4.0.1pl2 
FrontPage/4.0.4.3 mod_ssl/2.6.6 OpenSSL/0.9.5a
    Last-Modified: Tue, 23 Apr 2002 05:13:07 GMT
    ETag: "61b3e-ba-3cc4ed63"
    Accept-Ranges: bytes
    Content-Length: 186
    Connection: close
    Content-Type: application/zip

regs

Brian White
-------------------------
Brian White
Step Two Designs Pty Ltd
Knowledge Management Consultancy, SGML & XML
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
At 3:59 PM +1000 23/4/02, Brian White wrote:

>Is there any way to get it to save as a file called "file.zip"?
>Is there any header I can set? The headers it currently returns

header("Content-type: application/octet-stream; name=\"file.zip\"");
header("Content-Disposition: attachment; filename=\"file.zip\"");
header("Content-transfer-encoding: binary");

 ...R.
--- End Message ---
--- Begin Message ---
TEST


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

hi...is it possible to store pics (jpeg/gif) on the mysql database? if so, 
how and what type should that field be?

thanks.


_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com

--- End Message ---
--- Begin Message ---
Yes. The field would need to be some kind of binary blob.
You would need to access it using a PHP script that
set  the header eg:

     header( "Content-type:image/gif" )

and then out put the image.



At 16:37 23/04/2002, mm fernandez wrote:

>hi...is it possible to store pics (jpeg/gif) on the mysql database? if so, 
>how and what type should that field be?
>
>thanks.
>
>
>_________________________________________________________________
>Join the world's largest e-mail service with MSN Hotmail. 
>http://www.hotmail.com
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

-------------------------
Brian White
Step Two Designs Pty Ltd
Knowledge Management Consultancy, SGML & XML
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
At 6:37 AM +0000 23/4/02, mm fernandez wrote:

>hi...is it possible to store pics (jpeg/gif) on the mysql database? if so,
>how and what type should that field be?

How: just addslashes() on the content and insert it.

What: a blob of an appropriate size.

 ...R.
--- End Message ---
--- Begin Message ---
Hello,
How can I take the IP of the visitator of my php page?
not gethostbyname...
I need the ip of any visitator not for the specified visitator.

Thank you

Cosmin

--- End Message ---
--- Begin Message ---
At 11:04 23/04/2002 +0300, Cosmin Vlasiu wrote:
>Hello,
>How can I take the IP of the visitator of my php page?
>not gethostbyname...
>I need the ip of any visitator not for the specified visitator.
>
>Thank you
>
>Cosmin

Hello,

function http_data()
{
         $user_data = array ();

// IP Number
if (getenv(HTTP_X_FORWARDED_FOR)){
         $user_data['ip']=getenv(HTTP_X_FORWARDED_FOR);
         } else {
                 $user_data['ip'] =getenv(REMOTE_ADDR);
         }

// HOSTNAME
         if ((getenv("REMOTE_HOST ")== "")){
                 $r_hostname = @gethostbyaddr($REMOTE_ADDR);
                 if ($r_hostname ==""){
                         $user_data['machine']   = 'unknown';
                           }else {
                         $user_data['machine'] = $r_hostname;
                         }
         } else {
                 $user_data['machine']   = getenv("REMOTE_HOST ");
                 }

// Browser
         $user_data['navigateur']        =       getenv("HTTP_USER_AGENT");

// HTTP Refer
         $user_data['comefrom']  =       getenv("HTTP_REFERER");

         return $user_data;
}

Hope this helps

Luc

--- End Message ---
--- Begin Message ---
Ya I found
$ip = gethostbyname($REMOTE_ADDR);
Thanks anyway

Cosmin

"Cosmin Vlasiu" <[EMAIL PROTECTED]> wrote in message
007d01c1ea9d$9db78660$[EMAIL PROTECTED]">news:007d01c1ea9d$9db78660$[EMAIL PROTECTED]...
Hello,
How can I take the IP of the visitator of my php page?
not gethostbyname...
I need the ip of any visitator not for the specified visitator.

Thank you

Cosmin



--- End Message ---
--- Begin Message ---
$ipaddr=getenv("REMOTE_ADDR");


Cam asta ar fi...


On Tue, 23 Apr 2002, Cosmin wrote:

> Ya I found
> $ip = gethostbyname($REMOTE_ADDR);
> Thanks anyway
>
> Cosmin
>
> "Cosmin Vlasiu" <[EMAIL PROTECTED]> wrote in message
> 007d01c1ea9d$9db78660$[EMAIL PROTECTED]">news:007d01c1ea9d$9db78660$[EMAIL PROTECTED]...
> Hello,
> How can I take the IP of the visitator of my php page?
> not gethostbyname...
> I need the ip of any visitator not for the specified visitator.
>
> Thank you
>
> Cosmin
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
Thanks to all, very usefull samples

Cosmin


"Cosmin Vlasiu" <[EMAIL PROTECTED]> wrote in message
007d01c1ea9d$9db78660$[EMAIL PROTECTED]">news:007d01c1ea9d$9db78660$[EMAIL PROTECTED]...
Hello,
How can I take the IP of the visitator of my php page?
not gethostbyname...
I need the ip of any visitator not for the specified visitator.

Thank you

Cosmin




--- End Message ---
--- Begin Message ---
I have an array where each element contains an array that in turn contains
2 numbers indexed by "id" and "parent".

Every id except for the first one belongs to another, its parent.

What I want to do now is sort the array so that every id is put after its
parent starting with id 1.

Example:
arr1 = (
    0 => array("id" => 1, "parent" => 0),
    1 => array("id" => 2, "parent" => 1),
    2 => array("id" => 3, "parent" => 1),
    3 => array("id" => 4, "parent" => 2),
    4 => array("id" => 5, "parent" => 3),
    5 => array("id" => 6, "parent" => 2),
    6 => array("id" => 7, "parent" => 1),
    7 => array("id" => 8, "parent" => 4),
    8 => array("id" => 9, "parent" => 5)
   )

In other words they are in the following order..
1=0
2=1
3=1
4=2
5=3
6=2
7=1
8=4
9=5

After the sort I want them to be in the following order..
1=0
2=1
4=2
8=4
6=2
3=1
5=3
9=5
7=1

Note that id 6 isn't placed right after id 4 since id 4 has parents of its
own which have precedence.

An easier way to illustrate this would be by indenting the list..



1=0
    2=1
        4=2
            8=4
        6=2
    3=1
        5=3
            9=5
    7=1


The index of $arr1 makes no difference so the array can be shifted or
rebuilt..

If you are wondering I need this for a forum that im building. If you have
any suggestions as how to do this better feel free to tell me all about it
:)



Thanks in advance.



// Leif Högberg





--- End Message ---
--- Begin Message ---
Hello,

Suppose i've got the following array

$a = array(
     "color" => "red",
     "taste" => "sweet",
     "shape" => "round",
     "name"  => "apple",
     3       => 4
);

Now I would like to remove the "color" field and  value. Whats the best
way to do this?

Thanks



--- End Message ---
--- Begin Message ---
Hello,

Suppose i've got the following array:

$a = array(
     "color" => "red",
     "taste" => "sweet",
     "shape" => "round",
     "name"  => "apple",
     3       => 4
);

Now I would like to remove the "color" field and  value. Whats the best
way to do this?

Thanks.




--- End Message ---
--- Begin Message ---
Hello,

i think that unset($a['color']); is the best way :)

Regards
Michal Dvoracek                          [EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Miguel Cruz wrote:
> 
> On Mon, 22 Apr 2002, Leif K-Brooks wrote:
> > I use $formvar for form processing, I don't use the arrays.  This is how I
> > was taught to do it.  If my host upgrades to 4.2.0, my website is as good as
> > gone!  What am I supposed to do?!
> 
> Fix them! This direction was first announced in 4Q1999; 2.5 years ought to
> be enough preparation time.

No, it isn't! For anything that breaks old functionality, 'forever' is
not enough time.

> 
> This change improves your security, so it'd be rational to be happy about
> it.

No it doesn't. It just provides another excuse for lazy programming.
Nothing will save a lazy programmer or one that doesn't understand basic
principles.

-Stathis.

> 
> In any case, you can probably override it for your web space with a
> .htaccess directive, should you want to persist in your resistance to
> positive change.
> 
> Also, if you were taught to do it the $formvar way in the past year or so,
> you should find the person who taught you and tweak their nose.
> 
> miguel
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hey,
I am trying to make a drop down list such that, when some one selects an
option, it refreshs and displays the option on the same page. There are a
couple of things already in the URL [ the query string ], which need to
remain there. How would I do this easily?
Regards,
Kunal Jhunjhunwala

"Minds think with ideas, not information. No amount of data, bandwidth, or
processing power can substitute for inspired thought." - Clifford Stoll

--- End Message ---

Reply via email to