Re: [PHP] _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us

2006-10-17 Thread Stut

John Taylor-Johnston wrote:


This is what http_accept_language gives me depending on which browser. 
Depending on the visitor in my region, it will either be French or 
English.


_SERVER["HTTP_ACCEPT_LANGUAGE"] en-us,en;q=0.8,fr;q=0.5,fr-ca;q=0.3
_SERVER["HTTP_ACCEPT_LANGUAGE"] fr-ca,en-us;q=0.5


Is this a reasonable approach?

if(stristr($_SERVER["HTTP_HOST"],"fr"))
{ include("french.htm");}else{ include("english.htm");}


No it's not unless you want to ignore the users preferred language. The 
order is important in that header - the first language is the preferred 
language. So in the first example you should serve english.htm and 
french.htm in the second. If you only have english and french, your best 
bet is to do the following...


if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == 'fr')
{
   include('french.htm');
}
else
{
   include('english.htm');
}

However, if you don't care about their preferred language, and want to 
serve french.htm if they specify french at all in their language 
preferences then what you've got will do that.


-Stut

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



Re: [PHP] A no brainer...

2006-10-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-16 16:40:34 -0700:
> 
> On Oct 16, 2006, at 6:20 PM, Roman Neuhauser wrote:
> >Modern filesystems cope well with large directories (plus it's  
> >quite trivial to derive a directory hierarchy from the
> >filenames).  Looking at the numbers produced by timing various
> >operations in a directory with exactly 100,000 files on sw RAID 1
> >(2 SATA disks) in my desktop i'd say this concern is completely
> >baseless.
> 
> I knew that you could get PHP to use a directory structure for the  
> session data files, but hearing that you can have 100k files in a  
> single directory and not run into performance issues or problems is  
> news to me.  Which OS are you running?

FreeBSD. What do your tests show, on what OS/version/FS?
 
> >>It still uses  files, but hopefully you don't hit them very often,
> >>especially when  you're dealing with the same table records.
> >
> >A RDBMS is basically required to hit the disk with the data on
> >commit. One of the defining features of a RDBMS, Durability, says
> >that once you commit, the data is there no matter what. The  
> >host OS may crash right after the commit has been acked, the data
> >must  stay.
> >
> >You can turn on query caching in MySQL, but this will give you
> >*nothing* for purposes of session storage.
> 
> Unless session storage is used to save time in retrieving data,  
> right?  I'm seeing your point on the writing, but what about reading?
> 
> I think it would be kind of fun to run some actual tests.

Check out the query cache in the MySQL 5.0 manual, it clearly
says that any modification of a table (INSERT, UPDATE, ALTER
TABLE...) will invalidate all cache entries that use that table.
IOW, request from any visitor such that it starts or updates
a session invalidates query cache entries for all sessions.

Max cache hits for any single cache entry depend on the number
of requests a visitor can produce in sequence without updating the
session table, number of concurrent visitors, request frequency...

You're likely to max cache hits for any entry at 1, and all but
that one will be purged with 0 cache hits.

> >>Also, having raw data is  always faster than having to process it
> >>before you can use it.
> >
> >I don't know what that means.
 
> >Bytes in files on disk are as raw
> >as it gets, you get one roundtrip process -> kernel -> process;
> >compare the communication protocol MySQL (or just any other DB)  
> >uses where data is marshalled by the client, and unmarshalled by
> >the server, overhead of the database process(es) taking part in
> >the write...
 
> If you pull a record from the db, you can access the data.  Or you  
> can query the db, get the serialized data, de-serialize it, and now  
> access the data.

That's not really filesystem vs. database, that's "to serialize or
not to serialize".

> I tested this previously and found the database to be faster.
> The references I gave supported this and listed additional benefits.   

The article from Chris Shiflett contains zero quantifications of the
purported performance benefits.

> Things change tho, especially with technology.  It seems like we  
> should be able to test this pretty easily.  I actually think it would  
> be fun to do as well.  Do you have a box we can test this on?   
> Meanwhile, I'll check one of my boxes to see if I can use it.  If  
> anything, it'll be interesting to see if two systems report the same.

Yes I can provide a testbed, just post a testing methodology
proposal.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



Re: [PHP] Text from Excel csv file loaded into MySQL table

2006-10-17 Thread Alan Milnes

Richard Lynch wrote:

Ah...

Try something like this:



This assumes that no record (all 4 fields) with overhead is move than
1Mb in size -- Change the 100 if you have monster fields.  And
count on needing to tweak my.cnf in that case anyway.
  
Looks a lot neater than my code!  Is it version dependent?  Running on 
MySQL 4.1.21 and PHP 4.4.4 (not my Server so I can't control that) 
generates the following warnings:-


"mysql_real_escape_string() expects parameter 2 to be resource, integer" 
for each of the fields then when it goes to do the query it returns 
"Column count doesn't match value count at row 1", if I echo the query 
it reads "insert into invw2wtest values('Array')".



Thanks,

Alan

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



[PHP] How to recognise url in a block of text

2006-10-17 Thread AYSERVE.NET
Please, I need help on how to to recognise url in a block of text being 
retrieved from a database and present it as a link within that text.


I will appreciate any help.
Regards,
Bunmi

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



[PHP] Re: Nicht gelesen: [PHP] How to recognise url in a block of text

2006-10-17 Thread AYSERVE.NET

I did not see any text in your mail.

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



Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread AYSERVE.NET

Hello,
Thanks Toby. The aim is to show the entire text taken from the database 
(mysql) with the link within the text showing as a clickable link. Not 
just to remove entirely.

Regards,
Bunmi
www.ayserve.net
www.budelak.com

Toby Osbourn wrote:

Hello,

I would suggest first of all splitting the block of text into single 
words (I would assume you would use " " as the delimiter for this 
assuming the text stored on the database is readable and not just 
random words delimited by something else).


The use the eregi() function to see if any of the words contain either 
www. or http://www.


If they do simply store them in an array or directly output them to 
your page.


Regards

Toby

On 17/10/06, *AYSERVE.NET * <[EMAIL PROTECTED] 
> wrote:


Please, I need help on how to to recognise url in a block of text
being
retrieved from a database and present it as a link within that text.

I will appreciate any help.
Regards,
Bunmi

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




--
http://www.borninblood.co.uk 


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



[PHP] looking for the developer of webcbq

2006-10-17 Thread Gregory Machin

Hi
I'm looking for the developer of webcbq, I'm trying to get it to work on
fc5_64 but I have hit a wall there are some errors I can't see why the
variables are being populated ... and I think is was writtn in php 3 because
I have had to change alot on the syntax of the code to get it half way
working ...

here are the errors 

*Notice*: Undefined variable: nuevoPadre in *
/var/www/html/webcbq/parents.php* on line *38*

*Notice*: Undefined variable: borrarRegla in *
/var/www/html/webcbq/parents.php* on line *53*

*Notice*: Undefined variable: modificarRegla in *
/var/www/html/webcbq/parents.php* on line *67*

*Notice*: Undefined variable: cambiarNombre in *
/var/www/html/webcbq/parents.php* on line *76*

*Notice*: Undefined variable: nuevaRegla in *
/var/www/html/webcbq/children.php* on line *38*

*Notice*: Undefined variable: borrarRegla in *
/var/www/html/webcbq/children.php* on line *51*

*Notice*: Undefined variable: modificarRegla in *
/var/www/html/webcbq/children.php* on line *63*

*Notice*: Undefined variable: cambiarNombre in *
/var/www/html/webcbq/children.php* on line *72*

Many thanks
--
Gregory Machin
[EMAIL PROTECTED]
www.linuxpro.co.za


[PHP] [PEAR] help pear quickform FormBuilder and checkboxes

2006-10-17 Thread Marco Sottana
> marco schrieb:
>> [code]
>> function preGenerateForm()
>> {
>> $this->fb_preDefElements['alive'] =
>> HTML_QuickForm::
>>  createElement('advcheckbox','alive','Ali
>> ve',null,null,$this->alive);
>> }
>> [/code]
>> this code generate a only one checkbox..
>> i would like to generate a list of checkbox so i tryed [code]
>> function preGenerateForm(&$fb) {$box=array();$box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '0',null,'0'); $box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '1',null,'1'); $box[]=&
>> HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null,
>> '2',null,'2'); $this->fb_preDefElements['checkbox_intention'] =
>> $box;  }
>> [/code]
>> but this don't save correctly.. field called "checkbox_intention" is a 
>> varchar(200) and a i would like
>> to save as a list
>> so if i generate []labelA  []labelB []labelC []labelDand i check A,C 
>> i save in my
>> field "valueA,ValueC"
>> please help me.. i just send my request of help in forum.. but nobody
>> answer me
>
> Hi Marco,
>
> I read your code and your description, and I am still not sure I 
> understand what you want to achieve. Please try to rephrase.
>
> If your problem is that the elements are not being properly grouped 
> together, try to put the array of elements into a QuickForm group:
>
> $group =& new HTML_QuickForm_group('checkbox_intention', 'Intention', 
> $box);
> $this->fb_preDefElements['checkbox_intention'] =& $group;
>
> See also:
> http://pear.php.net/manual/en/package.html.html-quickform.php#package.html.html-quickform.groups
>
> CU
>  Markus


Hallo Marcus,
Thanks a lot for your availability,

i update my code so :

[code]
function preGenerateForm() {
   $box=array();
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'0',null,'0');
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'1',null,'1');
   $box[]=& 
HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, 
'2',null,'2');
   $group =& new HTML_QuickForm_group('checkbox_intention', 'Intention', 
$box);
   $this->fb_preDefElements['checkbox_intention'] =& $group;
}
[/code]

but it makes an error

[error]
Notice: Array to string conversion in /usr/share/php5/PEAR/DB/DataObject.php 
on line 1218
[/error]

[input]
Intention 0 1 2
[/input]

even if i check 0 and 1 and 2 in output

[output]
Intention [ ]0 [ ]1 [x]2
[/output]

Your suggest is near to the correct code version but as you've seen up, 
there's also some problemes, please help me another one



[PHP] Re: Empfangsbestätigung (angezeigt) - Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread AYSERVE.NET

Sorry,
I don't speak german.
Regards,
Bunmi
www.ayserve.net, www.budelak.com
[EMAIL PROTECTED] wrote:

Dies ist eine Empfangsbestätigung für eine Nachricht, die Sie an [EMAIL 
PROTECTED] gesendet haben.

Hinweis: Diese Empfangsbestätigung sagt nur aus, dass die Nachricht am Computer 
des Empfängers angezeigt wurde. Es gibt keine Garantie, dass der Empfänger die 
Nachrichteninhalte gelesen oder verstanden hat.
  



Reporting-UA: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.0.7) 
Gecko/20060909 Thunderbird/1.5.0.7
Final-Recipient: rfc822;[EMAIL PROTECTED]
Original-Message-ID: <[EMAIL PROTECTED]>
Disposition: manual-action/MDN-sent-manually; displayed
  



Return-path: <[EMAIL PROTECTED]>
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Tue, 17 Oct 2006 10:17:06 +0200
Received: from lists.php.net ([216.92.131.4])
by mail.comtrance.net with esmtp (Exim 4.60)
(envelope-from <[EMAIL PROTECTED]>)
id 1GZk8H-sW-Ca
for [EMAIL PROTECTED]; Tue, 17 Oct 2006 10:17:06 +0200
X-Host-Fingerprint: 216.92.131.4 lists.php.net  
Received: from [216.92.131.4] ([216.92.131.4:7357] helo=lists.php.net)

by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
id 16/03-04054-A1194354 for <[EMAIL PROTECTED]>; Tue, 17 Oct 2006 
04:15:23 -0400
Received: (qmail 8561 invoked by uid 1010); 17 Oct 2006 08:15:16 -
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: 
list-unsubscribe: 
list-post: 
Delivered-To: mailing list php-general@lists.php.net
Received: (qmail 8553 invoked by uid 1010); 17 Oct 2006 08:15:15 -
Delivered-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Authentication-Results: pb1.pair.com [EMAIL PROTECTED]; spf=permerror; 
sender-id=unknown
Authentication-Results: pb1.pair.com [EMAIL PROTECTED]; sender-id=unknown
Received-SPF: error (pb1.pair.com: domain ayserve.net from 70.84.85.66 cause 
and error)
X-PHP-List-Original-Sender: [EMAIL PROTECTED]
X-Host-Fingerprint: 70.84.85.66 bmw.websitewelcome.com Linux 2.6
Message-ID: <[EMAIL PROTECTED]>
Disposition-Notification-To: "AYSERVE.NET" <[EMAIL PROTECTED]>
Date: Tue, 17 Oct 2006 09:13:53 +0100
From: "AYSERVE.NET" <[EMAIL PROTECTED]>
User-Agent: Thunderbird 1.5.0.7 (Windows/20060909)
MIME-Version: 1.0
To: Toby Osbourn <[EMAIL PROTECTED]>, 
 php-general@lists.php.net

References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
In-Reply-To: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-AntiAbuse: This header was added to track abuse, please include it with any 
abuse report
X-AntiAbuse: Primary Hostname - bmw.websitewelcome.com
X-AntiAbuse: Original Domain - lists.php.net
X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12]
X-AntiAbuse: Sender Address Domain - ayserve.net
X-Source: 
X-Source-Args: 
X-Source-Dir: 
Subject: Re: [PHP] How to recognise url in a block of text
  


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



[PHP] Re: mktime()'s is_dst deprecated, but needed?

2006-10-17 Thread Ivo F.A.C. Fokkema
On Sun, 15 Oct 2006 13:22:02 +0200, Zora wrote:

> Hi all,
> 
> (first time I send an email here, so please be forgiving if something 
> doesn't follow expected rules.)
> 
> My web application allows users to enter time stamps (date and time) 
> given as local times. The time stamp is to be stored as UTC into the 
> data base.
> 
> Since we have summer and winter times (dst) there's an hour in the 
> autumn which exists twice in local time (it's 2:00 - 3:00 at the last 
> sunday in october here). Only the user knows which of these two hour is 
> intended to be stored into the data base, no program ever can decide 
> that by itself. Thus, the user has to add a character to the supplied 
> time stamp.
> 
> E.g.
> ", 02:30 A" is summer time (e.g. GMT +02:00),
> ", 02:30 B" is winter time (e.g. GMT +01:00).
> 
> My php function used the "is_dst" parameter of mktime() responding to 
> the user given "A" or "B".
> 
> How's that to solve in the future if "is_dst" doesn't exist any more?
> (For now, it still works but gives a log line everytime the function is 
> called - E_STRICT is set).
> 
> Thanks for your help,
> 
> Zora

Hi Zora,

How is the data stored in the database? By the timestamp of your
local time? In that case, you could just increment the timestamp by one
hour if someone sets summertime. You can also feed the mktime the
incremented hour, cause it will calculate the time correctly even with
values that are out of range (such as 25 hours, 75 minutes, etc).

Hope this helps,

Ivo

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



[PHP] random string

2006-10-17 Thread Ross

Hi,

I want to randomise a string

$myrandom = rand("ross", "andrea");

echo $myrandom;


I know this doesn't work but is there a built in function to do this?


R. 

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



[PHP] random string

2006-10-17 Thread Ross

Hi,

I want to randomise a string

$myrandom = rand("ross", "andrea");

echo $myrandom;


I know this doesn't work but is there a built in function to do this?


R.

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



Re: [PHP] random string

2006-10-17 Thread Brice

On 10/17/06, Ross <[EMAIL PROTECTED]> wrote:



Hi,

I want to randomise a string

$myrandom = rand("ross", "andrea");



I suggest :
$array_name  = array("rose","andrea");
$myrandom = array_rand($array_name);
echo $myrandom[0];

Brice.

I know this doesn't work but is there a built in function to do this?



R.

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




Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread AYSERVE.NET

Thanks Alan. Retuen receipt disabled.

Who can help regarding my problem below. I will appreciate any assistance.
Regards,
Bunmi
www.ayserve.net., www.budelak.com

AYSERVE.NET wrote:

Hello,
Thanks Toby. The aim is to show the entire text taken from the 
database (mysql) with the link within the text showing as a clickable 
link. Not just to remove entirely.

Regards,
Bunmi
www.ayserve.net
www.budelak.com

Toby Osbourn wrote:

Hello,

I would suggest first of all splitting the block of text into single 
words (I would assume you would use " " as the delimiter for this 
assuming the text stored on the database is readable and not just 
random words delimited by something else).


The use the eregi() function to see if any of the words contain 
either www. or http://www.


If they do simply store them in an array or directly output them to 
your page.


Regards

Toby

On 17/10/06, *AYSERVE.NET * <[EMAIL PROTECTED] 
> wrote:


Please, I need help on how to to recognise url in a block of text
being
retrieved from a database and present it as a link within that text.

I will appreciate any help.
Regards,
Bunmi

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




--
http://www.borninblood.co.uk


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



[PHP] Re: How to recognise url in a block of text

2006-10-17 Thread Al

AYSERVE.NET wrote:
Please, I need help on how to to recognise url in a block of text being 
retrieved from a database and present it as a link within that text.


I will appreciate any help.
Regards,
Bunmi

Show us some examples of URL substrings, with any variations, you want to 
handle.

Most likely a regex function will do the job.

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



Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-17 15:13:50 +0100:
> Who can help regarding my problem below. I will appreciate any assistance.

> >>On 17/10/06, *AYSERVE.NET * <[EMAIL PROTECTED] 
> >>> wrote:
> >>
> >>Please, I need help on how to to recognise url in a block of text
> >>being retrieved from a database and present it as a link within
> >>that text.

Study [REs] and [URIs]. come back with specific questions if you hit
any problems.

[REs]  http://www.php.net/manual/en/ref.pcre.php
[URIs] http://www.rfc-editor.org/rfc/rfc3986.txt

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

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



[PHP] pdflib - change text color mid-sentence

2006-10-17 Thread j1c
Hi,

I'm having some problems with a pdf file I'm compiling dynamically with
pdflib, and my searches for answers have come up empty, so I'm hoping
someone else out there has faced the same problem and came up with a
solution.

I want to change the text color of a word mid-sentence when outputting
text to a pdf file.

I've looked at pdf_show_boxed and pdf_show_xy, but I dont think either
would actually work the way I need, and I'm hoping their is an easier way
than trying to step through a long string word by word, then changing
color to display one word, and then trying to continue while making it all
look as though it flows.  This, of course, would open up all kinds of
issues in terms of line feeds and the like

If anyone has any advice or could help in any way, please let me know
because this has been frustrating.

Thanks in advance,
Michael.

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



Re: [PHP] Re: How to recognise url in a block of text

2006-10-17 Thread Robin Vickery

On 17/10/06, Al <[EMAIL PROTECTED]> wrote:

AYSERVE.NET wrote:
> Please, I need help on how to to recognise url in a block of text being
> retrieved from a database and present it as a link within that text.
>
> I will appreciate any help.
> Regards,
> Bunmi
Show us some examples of URL substrings, with any variations, you want to 
handle.

Most likely a regex function will do the job.


In 6 easy steps:

Step 1: Pinch  a regexp from perl...

 perl -e 'use Regexp::Common; print $RE{URI}{HTTP}, "\n";'

Step 2: Double up all backslashes

 M-x replace-string \ \\

Step 3: Escape single quote-marks

 M-x replace-string ' \'

Step 4. modify slightly to cope with the https scheme by adding an
optional 's' to the http scheme.

Step 5. add angle-brackets as delimiters

Step 6. use in a preg_replace()

http://example.com  imperdiet nec, tempus ac, purus.
Suspendisse id lectus. Nam vitae quam. Aliquam ligula nisl, vestibulum
vulputate, tempor nec, https://www.example.com  tincidunt sit amet,
libero. Suspendisse a justo. Cum sociis natoque penatibus et.';

$url_regexp = 
'<(?:(?:https?)://(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:/(?:(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\\-_.!~*\'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;/?:@&=+$,a-zA-Z0-9\\-_.!~*\'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)>';

$output = preg_replace($url_regexp, '$0', $textString);

print $output;
?>

If http and https isn't enough for you, there's another more general
regexp but... well, it's 8.5Kb long.

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



Re: [PHP] pdflib - change text color mid-sentence

2006-10-17 Thread Richard Lynch
On Tue, October 17, 2006 9:50 am, [EMAIL PROTECTED] wrote:
> I want to change the text color of a word mid-sentence when outputting
> text to a pdf file.
>
> I've looked at pdf_show_boxed and pdf_show_xy, but I dont think either
> would actually work the way I need, and I'm hoping their is an easier
> way
> than trying to step through a long string word by word, then changing
> color to display one word, and then trying to continue while making it
> all
> look as though it flows.  This, of course, would open up all kinds of
> issues in terms of line feeds and the like
>
> If anyone has any advice or could help in any way, please let me know
> because this has been frustrating.

After you do pdf_show_boxed() for the one color, do this:
$textx = pdf_get_value($pdf, 'textx', 0);
$texty = pdf_get_value($pdf, 'texty', 0);

Now you know where PDFlib "left off" for the last word of that color.

You can begin again at that point with a new color.

Rinse.

Repeat.

It's probably going to be a pain to finish off a line, and then do a
large chunk of text after that, but it's totally do-able.

Note that pdf_show_boxed returns all the text that didn't "fit" -- so
if you do this with boxes that are one line, and just keep doing that
line after line, interspersing with the colored text and using the
pdf_get_value() above, this is totally do-able, if somewhat tedious.

If the colored text is "rare" enough, it might be worth doing
something like:

1. text up to next colored text
2. pdf_get_value()
3. colored text
4. pdf_get_value()
5. one_line box size for pdf_show_boxed, returns rest of text
6. GOTO 1.

particularly if you have huge texts and need performance to not loop
through it one line at a time for ALL of it.

On the plus side, pdflib, in my experience, tends to generate VERY
small and compact PDF output, so the bandwidth is as cheap as it can
be...

YMMV

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] random string

2006-10-17 Thread Richard Lynch
On Tue, October 17, 2006 7:30 am, Ross wrote:
> I want to randomise a string
>
> $myrandom = rand("ross", "andrea");
>
> echo $myrandom;
>
> I know this doesn't work but is there a built in function to do this?

I'm not real clear on what "this" is...

Choose a string at random from an array?

$possibles = array('ross', 'andrea');
shuffle($possibles);
echo $possibles[0];


Or are you trying to compose a new string of randomly-selected
characters of a bunch of other strings?

Some combination of these functions might be in the recipe:
http://php.net/mt_rand
http://php.net/shuffle
http://php.net/explode

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Text from Excel csv file loaded into MySQL table

2006-10-17 Thread Richard Lynch
On Tue, October 17, 2006 2:36 am, Alan Milnes wrote:
>> >   $file = fopen($filename, "r") or die("Could not open $filename");
>>   while (!feof($file)){
>> $values = fgetcsv($file, 100);
>> array_walk($values, 'mysql_real_escape_string');
>> $values_sql = implode("', '", $values);
>> $query = "insert into invw2wfinal ";
>> $query .= "values('$values') ";
>> $result = mysql_query($query) or die(mysql_error());
>>   }
>> ?>
>>
>> This assumes that no record (all 4 fields) with overhead is move
>> than
>> 1Mb in size -- Change the 100 if you have monster fields.  And
>> count on needing to tweak my.cnf in that case anyway.
>>
> Looks a lot neater than my code!  Is it version dependent?  Running on
> MySQL 4.1.21 and PHP 4.4.4 (not my Server so I can't control that)
> generates the following warnings:-
>
> "mysql_real_escape_string() expects parameter 2 to be resource,
> integer"

Dang.

Yeah, array_walk passes in the key as second arg, and we wanted nothing.

You'll have to write your own custom function like:
function my_mysql_real_escape_string($value, $key, $connection){
  return mysql_real_escape_string($value, $connection);
}

and then change it to:
array_walk($values, 'my_mysql_real_escape_string', $connection);
where $connection is the return value from your mysql_connect call.

Or just skip all the $connection parts everywhere above to use the
last-opened connection.

> for each of the fields then when it goes to do the query it returns
> "Column count doesn't match value count at row 1", if I echo the query
> it reads "insert into invw2wtest values('Array')".

D'oh!

Change $values to $values_sql in the $query line.

I'm not sure in what version mysql_real_escape_string first appeared,
but it's in the manual.
http://php.net/mysql_real_escape_string

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] A no brainer...

2006-10-17 Thread Ed Lazor
Hi Guys :)  I'm off today, so I'll follow-up with you tomorrow.   
Meanwhile, have a great day :)


-Ed


On Oct 17, 2006, at 2:20 AM, Roman Neuhauser wrote:


# [EMAIL PROTECTED] / 2006-10-16 16:40:34 -0700:


On Oct 16, 2006, at 6:20 PM, Roman Neuhauser wrote:

   Modern filesystems cope well with large directories (plus it's
   quite trivial to derive a directory hierarchy from the
   filenames).  Looking at the numbers produced by timing various
   operations in a directory with exactly 100,000 files on sw RAID 1
   (2 SATA disks) in my desktop i'd say this concern is completely
   baseless.


I knew that you could get PHP to use a directory structure for the
session data files, but hearing that you can have 100k files in a
single directory and not run into performance issues or problems is
news to me.  Which OS are you running?


FreeBSD. What do your tests show, on what OS/version/FS?


It still uses  files, but hopefully you don't hit them very often,
especially when  you're dealing with the same table records.


   A RDBMS is basically required to hit the disk with the data on
   commit. One of the defining features of a RDBMS, Durability, says
   that once you commit, the data is there no matter what. The
   host OS may crash right after the commit has been acked, the data
   must  stay.

   You can turn on query caching in MySQL, but this will give you
   *nothing* for purposes of session storage.


Unless session storage is used to save time in retrieving data,
right?  I'm seeing your point on the writing, but what about reading?

I think it would be kind of fun to run some actual tests.


Check out the query cache in the MySQL 5.0 manual, it clearly
says that any modification of a table (INSERT, UPDATE, ALTER
TABLE...) will invalidate all cache entries that use that table.
IOW, request from any visitor such that it starts or updates
a session invalidates query cache entries for all sessions.

Max cache hits for any single cache entry depend on the number
of requests a visitor can produce in sequence without updating the
session table, number of concurrent visitors, request frequency...

You're likely to max cache hits for any entry at 1, and all but
that one will be purged with 0 cache hits.


Also, having raw data is  always faster than having to process it
before you can use it.


   I don't know what that means.



   Bytes in files on disk are as raw
   as it gets, you get one roundtrip process -> kernel -> process;
   compare the communication protocol MySQL (or just any other DB)
   uses where data is marshalled by the client, and unmarshalled by
   the server, overhead of the database process(es) taking part in
   the write...



If you pull a record from the db, you can access the data.  Or you
can query the db, get the serialized data, de-serialize it, and now
access the data.


That's not really filesystem vs. database, that's "to serialize or
not to serialize".


I tested this previously and found the database to be faster.
The references I gave supported this and listed additional benefits.


The article from Chris Shiflett contains zero quantifications  
of the

purported performance benefits.


Things change tho, especially with technology.  It seems like we
should be able to test this pretty easily.  I actually think it would
be fun to do as well.  Do you have a box we can test this on?
Meanwhile, I'll check one of my boxes to see if I can use it.  If
anything, it'll be interesting to see if two systems report the same.


Yes I can provide a testbed, just post a testing methodology
proposal.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

--
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



Re: [PHP] A no brainer...

2006-10-17 Thread Richard Lynch
On Mon, October 16, 2006 8:20 pm, Roman Neuhauser wrote:
> So no, it makes no sense for a database to be faster than
> filesystem.

The database may, or may not, have finely-tuned a lot of things to
write their records more quickly/efficiently than the PHP approach of
writing individual files for each session.

E.g., if the DB has allocate a larger chunk of disk-space, and is
micro-managing it, and doing fread/fwrite in an fopen(, 'r+')
environment (or similar) it *MIGHT* be more efficient than PHP's
method -- even *with* the DB overhead you point out.

The *only* way to be certain of any benchmark is to run it on your own
hardware, and the only way to be certain that has any meaning is to
make the benchmark as much like the "real world" as you can.

And, as I have said alread in this thread, raw performance is seldom
the be-all end-all of software develoment decisions.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Regular expressions

2006-10-17 Thread Richard Lynch
On Mon, October 16, 2006 4:01 pm, Curt Zirzow wrote:
> That makes me wonder.. according to the docs U inverts greediness, if
> you have...
> /foo.*?bar/U
>
> does that make .*? a greedy .*

I believe I stubbed my toe on that fact once, yes...

I always manage to mess up the greedy/ungreedy stuff, and then throw
up my hands and try to use an expression to look for a specific
character to be there or not there, and then I don't have to worry
about the greedy stuff as much...

Sometimes, though, you have to grit your teeth and dink with ? and U
until it works.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us

2006-10-17 Thread Richard Lynch
On Tue, October 17, 2006 1:13 am, John Taylor-Johnston wrote:
> This is what http_accept_language gives me depending on which browser.
> Depending on the visitor in my region, it will either be French or
> English.
>
> _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us,en;q=0.8,fr;q=0.5,fr-ca;q=0.3
> _SERVER["HTTP_ACCEPT_LANGUAGE"] fr-ca,en-us;q=0.5
>
>
> Is this a reasonable approach?
>
> if(stristr($_SERVER["HTTP_HOST"],"fr"))
> { include("french.htm");}else{ include("english.htm");}

Yes, but you still need to give me the little link flags to get to the
English version, for when I'm in Paris at some Internet Cafe...

Cuz being in Paris and using a French keyboard and a French browser
didn't improve my French language skills as all :-(

So you'll probably want to use the ACCEPT_LANGUAGE stuff only if the
user has not previously selected their own option of language -- and
then store it in $_SESSION once they have selected, so you can
"remember" who doesn't speak French, no matter what their browser
might be telling you.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] A no brainer...

2006-10-17 Thread Richard Lynch
On Mon, October 16, 2006 9:43 pm, Larry Garfield wrote:
>> I suspect that serialization overhead is trivial for scalar data,
>> and
>> only starts to kill you when one starts schlepping bloated OOP
>> structures or arrays back and forth -- at which point you messed up
>> your architecture, and the serialization performance is just a
>> symptom, not the disease.
>
> Yes, serialization is trivial for scalar data.  However, to use a
> real-world
> example, the Drupal CMS allows users to define an unlimited number of
> path
> aliases.  They're just key/value mappings, one string to another.  Any
> given
> page can have dozens of links on it, which means dozens of mappings.
> The
> database table is really just a simple two column table, user path to
> system
> path.
>
> In older versions, the system pulled the whole table out at once and
> built a
> look up array, once per page.  Only one query per page, but it meant a
> lot of
> data to pull and build.  On sites with lots of aliases, that got very
> slow.
> So the latest version now pulls records one at a time.  But that's a
> ton of
> SQL queries, many of which simply find no data in the first place.  So
> now
> there's talk of building the look up table one record at a time and
> caching
> that, but the serialization/deserialization costs there are
> non-trivial when
> you're talking about a large array.
>
> The balance is still being worked out. :-)  I'm just pointing out that
> no
> matter how you slice it, there is no free lunch performance-wise when
> you
> need to store data.  The right balance will depend greatly on your use
> case.

One Idea:

Pull all the records in one query at first request and keep the
$result around -- but don't walk through the whole thing.  *DO* sort
the records by the input value with an ORDER BY on an indexed field.

Now, to find an actual lookup, use a binary search with mysql_seek()
and cache any lookup results in an array.

Not sure it will be faster, but run some benchmarks and see. :-)

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread Richard Lynch
On Tue, October 17, 2006 2:39 am, AYSERVE.NET wrote:
> Please, I need help on how to to recognise url in a block of text
> being
> retrieved from a database and present it as a link within that text.

read the User Contributed Notes at:
http://php.net/preg_match_all
and friends.

There are only about 100 solutions there alone.

Google for a thousand more.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] looking for the developer of webcbq

2006-10-17 Thread Richard Lynch
Wild Guess:

It relies on register_globals being "on" and you need to change
$nuevoPadre to $_REQUEST['nuevoPadre']

hard to say without seeing the code, but this is my first guess with
the info we have.

On Tue, October 17, 2006 3:35 am, Gregory Machin wrote:
> Hi
> I'm looking for the developer of webcbq, I'm trying to get it to work
> on
> fc5_64 but I have hit a wall there are some errors I can't see why the
> variables are being populated ... and I think is was writtn in php 3
> because
> I have had to change alot on the syntax of the code to get it half way
> working ...
>
> here are the errors 
>
> *Notice*: Undefined variable: nuevoPadre in *
> /var/www/html/webcbq/parents.php* on line *38*
>
> *Notice*: Undefined variable: borrarRegla in *
> /var/www/html/webcbq/parents.php* on line *53*
>
> *Notice*: Undefined variable: modificarRegla in *
> /var/www/html/webcbq/parents.php* on line *67*
>
> *Notice*: Undefined variable: cambiarNombre in *
> /var/www/html/webcbq/parents.php* on line *76*
>
> *Notice*: Undefined variable: nuevaRegla in *
> /var/www/html/webcbq/children.php* on line *38*
>
> *Notice*: Undefined variable: borrarRegla in *
> /var/www/html/webcbq/children.php* on line *51*
>
> *Notice*: Undefined variable: modificarRegla in *
> /var/www/html/webcbq/children.php* on line *63*
>
> *Notice*: Undefined variable: cambiarNombre in *
> /var/www/html/webcbq/children.php* on line *72*
>
> Many thanks
> --
> Gregory Machin
> [EMAIL PROTECTED]
> www.linuxpro.co.za
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Michael Hogsett

Why can I not set "upload_max_filesize" or "upload_tmp_dir" inside
my virtual host directive?  These are exactly the kinds of ini
directives that you would want to set per virtual host.

I can set "open_basedir" inside my virtual host using php_admin_value,
but neither of "upload_max_filesize" nor "upload_tmp_dir" take effect
unless I move those directives outside the virtual host configuration
and into Apache's global context.

Can anyone offer a suggestion as to how I would go about setting,
at the very least, "upload_tmp_dir" per virtual host?


PHP Version 5.1.6

Apache 1.3, mod_ssl, and mod_php on FreeBSD 5.4.

Thanks,

 - Michael Hogsett



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] [PEAR] help pear quickform FormBuilder and checkboxes

2006-10-17 Thread Chris

Marco Sottana wrote:

marco schrieb:


Maybe you meant to send this to pear-general instead of php-general?

The php-general list won't help you with pear related problems - nor 
will the php-db list which you also somehow sent this email to.


--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Chris

Michael Hogsett wrote:

Why can I not set "upload_max_filesize" or "upload_tmp_dir" inside
my virtual host directive?  These are exactly the kinds of ini
directives that you would want to set per virtual host.

I can set "open_basedir" inside my virtual host using php_admin_value,
but neither of "upload_max_filesize" nor "upload_tmp_dir" take effect
unless I move those directives outside the virtual host configuration
and into Apache's global context.

Can anyone offer a suggestion as to how I would go about setting,
at the very least, "upload_tmp_dir" per virtual host?


I just tried it and it worked:


php_admin_flag engine on
php_admin_value upload_tmp_dir "/php_uploads"


That was inside a virtual host...

Checking a phpinfo page did change it.

Did you remember to restart apache?

Maybe an unnecessary hint but I've seen plenty of problems with this - 
If you change the upload_tmp_dir value don't forget to adjust the 
open_basedir to allow access to the new upload_tmp_dir otherwise uploads 
will break.


--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Michael Hogsett

Chris wrote:

Michael Hogsett wrote:

Why can I not set "upload_max_filesize" or "upload_tmp_dir" inside
my virtual host directive?  These are exactly the kinds of ini
directives that you would want to set per virtual host.

I can set "open_basedir" inside my virtual host using php_admin_value,
but neither of "upload_max_filesize" nor "upload_tmp_dir" take effect
unless I move those directives outside the virtual host configuration
and into Apache's global context.

Can anyone offer a suggestion as to how I would go about setting,
at the very least, "upload_tmp_dir" per virtual host?


I just tried it and it worked:


php_admin_flag engine on
php_admin_value upload_tmp_dir "/php_uploads"


That was inside a virtual host...



Interesting. Here's a snippet from my httpd.conf file.

...

NameVirtualHost *

...

php_admin_value upload_tmp_dir  
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads/
php_admin_value upload_max_filesize "100M"


ServerAdmin [EMAIL PROTECTED]
DocumentRoot /usr/local/www/subsite/virtual-server-hostname.domain/data
ServerName hostname.domain
ErrorLog /var/log/hostname.domain-error_log
CustomLog /var/log/hostname.domain-access_log common


Options FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all


php_admin_value open_basedir
"/usr/local/www/subsite/virtual-server-hostname.domain:/usr/local/share/pear"


ScriptAlias /cgi-bin/ 
"/usr/local/www/subsite/virtual-server-hostname.domain/cgi-bin/"

AllowOverride None
Options None
Order allow,deny
Allow from all







The two outside the VirtualHost work when they're there, but
do not work if I move them next to the entry for "open_basedir".
My error log states "php_admin_value not allowed here" when I
place them there.  Oddly it does not compain about the one
that is there now.

Likewise the only place (other than globally in php.ini) that
I've been able to configure the include_path is within the
.htaccess file inside my document root directory.  I was unable
to set this value inside the virtual host either.

Perhaps I should wrap the directives in a  conditional
like you have.  I've found the documentation on this to be
very vague.

 - Mike

P.S.  Yes I want 100 meg uploads enabled, and yes I found
out the hard way that I have to alter the max post size too.




smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Chris

Michael Hogsett wrote:

Chris wrote:

Michael Hogsett wrote:

Why can I not set "upload_max_filesize" or "upload_tmp_dir" inside
my virtual host directive?  These are exactly the kinds of ini
directives that you would want to set per virtual host.

I can set "open_basedir" inside my virtual host using php_admin_value,
but neither of "upload_max_filesize" nor "upload_tmp_dir" take effect
unless I move those directives outside the virtual host configuration
and into Apache's global context.

Can anyone offer a suggestion as to how I would go about setting,
at the very least, "upload_tmp_dir" per virtual host?


I just tried it and it worked:


php_admin_flag engine on
php_admin_value upload_tmp_dir "/php_uploads"


That was inside a virtual host...



Interesting. Here's a snippet from my httpd.conf file.

...

NameVirtualHost *

...

php_admin_value upload_tmp_dir  
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads/

php_admin_value upload_max_filesize "100M"


ServerAdmin [EMAIL PROTECTED]
DocumentRoot /usr/local/www/subsite/virtual-server-hostname.domain/data
ServerName hostname.domain
ErrorLog /var/log/hostname.domain-error_log
CustomLog /var/log/hostname.domain-access_log common

"/usr/local/www/subsite/virtual-server-hostname.domain/data">

Options FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
Allow from all


php_admin_value open_basedir
"/usr/local/www/subsite/virtual-server-hostname.domain:/usr/local/share/pear" 




ScriptAlias /cgi-bin/ 
"/usr/local/www/subsite/virtual-server-hostname.domain/cgi-bin/"
"/usr/local/www/subsite/virtual-server-hostname.domain/cgi-bin">

AllowOverride None
Options None
Order allow,deny
Allow from all







The two outside the VirtualHost work when they're there, but
do not work if I move them next to the entry for "open_basedir".
My error log states "php_admin_value not allowed here" when I
place them there.  Oddly it does not compain about the one
that is there now.


That is rather strange.

I'm running different versions of both php and apache but it works:



php_admin_value upload_tmp_dir 
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads

php_admin_value upload_max_filesize "100M"




That is - not inside the if_module section and it worked.

I thought maybe quotes around the path would make a difference but it 
didn't.


--
Postgresql & php tutorials
http://www.designmagick.com/

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



[PHP] Displaying Arabic Texts as Image (Problems: arabic chars is reversed?)

2006-10-17 Thread Louie Miranda
I had been looking for a solution on how to display arabic characters on an image using PHP "properly", but could not find yet a solution.Tried google, and nothing (Maybe the howto is written in arabic, i dont know).
I found http://www.php4arab.org/, but could not understand the chars on how to join.Im hoping someone here do know how.I am able to display and save to mysql (database) the characters (which i copied and pasted from this site: 
http://www.unicode.org/standard/translations/arabic.html)When i display it on a browser.. i used..
header("Content-type: text/html; charset=utf-8");?>On before saving on a database i do..
SET NAMES 'utf8'About the fonts, im using Arial Unicode MS.My problem is, whenever i display arabic characters like this one..
http://unicode.org/standard/translations/arabic.html (from)

ما هي الشفرة الموحدة "يونِكود" ؟On the input box..Nothing has changed.. But the image generated was..
http://public.axishift.com/arabic_reverse.jpgAnd its really weird, its reversing by itself.Some lines i used to display the text on an image.
    imagettftext($background, 8, 0, 18, 140, $black, "fonts/$fonts", "$line_4");Please help!-- Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com//JSM-W
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] How to recognise url in a block of text

2006-10-17 Thread Paul Novitski

At 10/17/2006 12:39 AM, AYSERVE.NET wrote:
Please, I need help on how to to recognise url in a block of text 
being retrieved from a database and present it as a link within that text.



Here's an illustration of your problem:

Input:
Text text http://example.com/directory/filename.html#anchor text text 
http://www.example.com/filename.php?arg=val&arg=val text text.


Output:
Text text href="http://example.com/directory/filename.html#anchor";>http://example.com/directory/filename.html#anchor 
text text href="http://www.example.com/filename.php?arg=val&arg=val";>http://www.example.com/filename.php?arg=val&arg=val 
text text.


Method:
- find each URL within the text
- replace each URL with an anchor tag that includes two copies of the 
URL, one in the href attribute and one enclosed in the tag.


Technique:
I'd use Regular Expressions for this:

PHP - Regular Expression Functions (Perl-Compatible)
http://php.net/pcre

To write your own regexp to identify URIs, you'll want to read the spec:

RFC 1738 - Uniform Resource Locators (URL)
http://www.faqs.org/rfcs/rfc1738.html

Specifically you'll need to know what characters can and cannot occur 
in an URL, and in what context, so that you can separate an URL from 
surrounding text and punctuation such as parentheses, periods, commas, etc.


If you google "regular expression url" you'll find a lot of examples 
of regexp's that find URLs, including:


Regex for URLs by Abigail
http://foad.org/~abigail/Perl/url2.html

Have fun,
Paul 


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



Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Michael Hogsett

Chris wrote:


That is rather strange.

I'm running different versions of both php and apache but it works:



php_admin_value upload_tmp_dir 
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads

php_admin_value upload_max_filesize "100M"




That is - not inside the if_module section and it worked.

I thought maybe quotes around the path would make a difference but it 
didn't.




Thanks for your help Chris.  I guess I'll have to keep looking.
Do you think there's any chance that it would be related to
some other setting within the php.ini file?



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Chris

Michael Hogsett wrote:

Chris wrote:


That is rather strange.

I'm running different versions of both php and apache but it works:



php_admin_value upload_tmp_dir 
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads

php_admin_value upload_max_filesize "100M"
I'm fairly sure you can't use constants or size shortucts (like "100M") 
anywhere but php.ini. Maybe it works in the global scope because it gets 
read into PHP before it parses php.ini?


Just a guess.





That is - not inside the if_module section and it worked.

I thought maybe quotes around the path would make a difference but it 
didn't.




Thanks for your help Chris.  I guess I'll have to keep looking.
Do you think there's any chance that it would be related to
some other setting within the php.ini file?



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



Re: [PHP] php_admin_value, virtual hosts, & upload_tmp_dir

2006-10-17 Thread Michael Hogsett

Chris wrote:
php_admin_value upload_tmp_dir 
/usr/local/www/subsite/virtual-server-hostname.domain/tmp/uploads

php_admin_value upload_max_filesize "100M"
I'm fairly sure you can't use constants or size shortucts (like "100M") 
anywhere but php.ini. Maybe it works in the global scope because it gets 
read into PHP before it parses php.ini?


That is an interesting supposition, although I don't think
that would not explain the upload_tmp_dir file path also not working.

 - Mike



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PHP] _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us

2006-10-17 Thread John Taylor-Johnston

Stut,
Richard,
Thanks for the feedback!
Quebec has a language law, so I'm obligated to serve French first. I can 
wiggle around that if the preferred language is "other".

John


Is this a reasonable approach?

if(stristr($_SERVER["HTTP_HOST"],"fr"))
{ include("french.htm");}else{ include("english.htm");}




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



[PHP] tod help (copy function)

2006-10-17 Thread todtot87
I am having an issue with the copy function.

When I use the php.net specifications with the URLs being relative URLs I get a 
permission error but all files and folders are set to 777. See Code 1.

If I use an ftp url it works for a few times but eventually I start copying 
blank pages. See Code 2.

I echo the URLs in the browser and they look fine.

Code 1:

//submit form (post) field dir_name: entered: music

if($_POST['action'] == 'Create'){

$dir_name = $path . $_POST['dir_name'] . '/';
ftp_mkdir($conn_id, $dir_name);
$template_file = $dir . 'temp/index.php';
$index_file = $_POST['dir_name'] . '/index.php';
copy($template_file,$index_file);
echo $template_file;
echo '';
echo $index_file;
}

results with:
dir created
error:
Warning: copy(music/index.php): failed to open stream: Permission denied in 
/home//public_html/leaders/tod/index.php on line 27


Code 2:

//submit form (post) field dir_name: entered: music

if($_POST['action'] == 'Create'){

$dir_name = $path . $_POST['dir_name'] . '/';
ftp_mkdir($conn_id, $dir_name);
$template_file = $dir . 'temp/index.php';
$index_file =  'ftp://:@/' . $dir_name . 
'index.php';
copy($template_file,$index_file);
echo $template_file;
echo '';
echo $index_file;
}

result with:
dir created

page blank
or
page copied success

echo $template_file; // result: ../temp/index.php
echo '';
echo $index_file; //result: 
ftp://:@/public_html/leaders/tod/music/index.php

can you tell me why code 1 gives me an error or why code 2 gives blank pages 
some of the time (my theory for this maybe b/c ftp only allows so many 
connections).

Thank You,
Tod Toter

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