[PHP] Re: Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Lupus Michaelis

Cameron B. Prince a écrit :


An example of the code is here:

$buffer = 
preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca

ffoh6jaeapkke35qpp87;?)/',
'"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);


  I never build my regex inline. I write them by pieces I can test. It 
is obviously to divide (and I don't know in english the end). So when 
the starting and ending marks are too frequents in my pattern, I use an 
other mark (like `).


  $domain = '(http://www\.domain\.com)' ;
  $path = '(/\\w*)+' ;
  $search_part = 'PHPSESSID=(?:[\w\d]+)' ;

  $re = sprintf("`%s%s?%s`", $domain, $path, $search_part) ;

  $buffer = '\1\2?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;' ;

  $buffer = preg_match($re, $url, $buffer) ;

  So said, it doesn't work anymore when you'll have other parameters in 
your search part.


--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

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



[PHP] Re: PHP editor for linux

2008-08-18 Thread Carlos Medina

It flance schrieb:

Hi,

What do you think is the best php editor for linux.

I'm using the Debian distribution.

Thanks


  


Hi it´s allways the same: What for Editor are you using? and blah.
Please this dicussion is old and not funny anymore (i think ). The
Developer which vi or nano  on debian to can be a good programmer too.

Regards

Carlos Medina

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



Re: [PHP] Re: PHP editor for linux

2008-08-18 Thread Ashley Sheridan
To  be honest, I've always favoured KATE. It's just a plain old text
editor with syntax highlighting for most languages. There are plugins
for Eclipse which let you edit PHP code, so yu could start looking in
that direction. Oh, and it should never really matter what distro you
use. You can install any program if you have the source and are willing
to compile it yourself, which isn't as daunting as it sounds! I use
Fedora and Suse interchangeably, and have had no trouble installing what
I need on either.


Ash
www.ashleysheridan.co.uk
--- Begin Message ---

It flance schrieb:

Hi,

What do you think is the best php editor for linux.

I'm using the Debian distribution.

Thanks


  


Hi it´s allways the same: What for Editor are you using? and blah.
Please this dicussion is old and not funny anymore (i think ). The
Developer which vi or nano  on debian to can be a good programmer too.

Regards

Carlos Medina

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

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

Re: [PHP] Re: PHP editor for linux

2008-08-18 Thread Aschwin Wesselius

Carlos Medina wrote:

It flance schrieb:

Hi,

What do you think is the best php editor for linux.

I'm using the Debian distribution.

Thanks


 

Hi it´s allways the same: What for Editor are you using? and blah.
Please this dicussion is old and not funny anymore (i think ). The
Developer which vi or nano  on debian to can be a good programmer too.

Regards

Carlos Medina


Hi,

It always comes down to what someone prefers to be useful. On the other 
hand, some people can point out quirks in some tools so you don't have 
to bother trying it out. A lot of people say Vi is a very good editor, 
but it takes a long time to get used to it.


Other editors have the also cons and pro's etc. But some editors are 
plain out not useful for programming. It is good to notice so you don't 
have to install all the thousands of editors out there. If somebody on 
this list already has tried the software and has arguments against it, 
fine let them speak out.


But I do feel much against a 'my editor, my framework, my blah is better 
than yours' flamewar discussion for the next 3 weeks. So I think I get 
your point.


--

Aschwin Wesselius

'What you would like to be done to you, do that to the other'


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



Re: [PHP] preg_replace strange behaviour, duplicates

2008-08-18 Thread Adz07

Problem is that a negative assertion assumes i know what is going to come
after the match, but i don't. I am a bit stuck now :(


Adz07 wrote:
> 
> I am trying to nail down a bit of code for changing processor names
> depending on matches.
> Problem i am having is the replacement takes place then it seems to do it
> again replacing the text just replaced as there are similar matches
> afterwards. example (easier)
> 
> $string = "The new Intel Core 2 Duo T8300";
> 
> $patterns = array("/Intel Core 2 Duo/","/Intel Core 2/");
> 
> $replacements = array("Intel Core 2 Duo Processor Technology","Intel Core
> 2 Processor Technology");
> 
> I would expect to get the following:
> 
> The new Intel Core 2 Duo Processor Technology T8300
> 
> but i get 
> 
> The new Intel Core 2 Processor Technology Duo Processor Technology T8300
> 
> I can see why its doing it, reading the string in and making the
> replacement but then reading the string in for the next pattern, but i
> don't want it to do this. How do i stop preg_replace from reading in the
> same part of the string that has been replaced already?
> 
> (it's a bad day! :( )
> 

-- 
View this message in context: 
http://www.nabble.com/preg_replace-strange-behaviour%2C-duplicates-tp19001166p19027490.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Regarding threads...

2008-08-18 Thread Ashley Sheridan
As far as I'm aware, threading is not possible in PHP. You can run
separate processes off in the background, but they are not actual
threads. I found a good article some guy wrote about it
http://immike.net/blog/2007/04/08/fork-php-and-speed-up-your-scripts/
which might be of some use?

Ash
www.ashleysheridan.co.uk
--- Begin Message ---

Hello friends,
   hope we all know about threads in java..
   Like that, can we use that in php?...

   Thanks in advance
 


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


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

Re: [PHP] Regarding threads...

2008-08-18 Thread Richard Heyes
Hi,

>   hope we all know about threads in java..

Not really. But anyway...

> Like that, can we use that in php?...

IIRC there was a pthread extension in PECL, however it seems to have
been removed. You could try pcntl (http://uk.php.net/pcntl) if you
want multiple process support. Not exactly advisable in a web server
environment.

-- 
Richard Heyes
http://www.phpguru.org

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



RE: [PHP] preg_replace strange behaviour, duplicates

2008-08-18 Thread Simcha Younger


 

 

Simcha Younger

 

-Original Message-

From: Adz07 [mailto:[EMAIL PROTECTED]

Sent: Monday, August 18, 2008 10:17 AM

To: php-general@lists.php.net

Subject: Re: [PHP] preg_replace strange behaviour, duplicates

 

 

Problem is that a negative assertion assumes i know what is going to come

after the match, but i don't. I am a bit stuck now :(

 

 

Adz07 wrote:

> 

> I am trying to nail down a bit of code for changing processor names

> depending on matches.

> Problem i am having is the replacement takes place then it seems to do it

> again replacing the text just replaced as there are similar matches

> afterwards. example (easier)

> 

> $string = "The new Intel Core 2 Duo T8300";

> 

> $patterns = array("/Intel Core 2 Duo/","/Intel Core 2/");

> 

> $replacements = array("Intel Core 2 Duo Processor Technology","Intel Core

> 2 Processor Technology");

> 

> I would expect to get the following:

> 

> The new Intel Core 2 Duo Processor Technology T8300

> 

> but i get 

> 

> The new Intel Core 2 Processor Technology Duo Processor Technology T8300

> 

> I can see why its doing it, reading the string in and making the

> replacement but then reading the string in for the next pattern, but i

> don't want it to do this. How do i stop preg_replace from reading in the

> same part of the string that has been replaced already?

> 

> (it's a bad day! :( )

> 

 

-- 

View this message in context:
http://www.nabble.com/preg_replace-strange-behaviour%2C-duplicates-tp1900116
6p19027490.html

Sent from the PHP - General mailing list archive at Nabble.com.

 

 

-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php

 

No virus found in this incoming message.

Checked by AVG - http://www.avg.com   

Version: 8.0.138 / Virus Database: 270.6.4/1617 - Release Date: 17/08/2008
12:58

 

 



[PHP] Regexp to get paramname

2008-08-18 Thread HostWare Kft.

Hi,

I have these lines to get parameters' name to $regs, but I always get the 
first one twice.


What do I do wrong?

$sql = 'select * from hotsys where ALREND=:alrend and SYSKOD=:syskod';
eregi('(:[a-z,A-Z,0-9]+)', $sql, $regs);


Thanks,
SanTa 



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



Re: [PHP] Regexp to get paramname

2008-08-18 Thread Richard Heyes
> eregi();

That would be your first mistake. The preg_* functions are better.

-- 
Richard Heyes
http://www.phpguru.org

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



[PHP] Re: Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Al
Run your pattern thru preg_quote() prior to using it in your preg_replace(). Don't backslash 
anything yourself, let preg_quote() do it.


Cameron B. Prince wrote:

Hello,

I¹ve run into a problem with a regex and need help determining if this is my
mistake or a bug. The regex is for inserting a SID into every link in the
buffer before it¹s flushed, but only when each link doesn¹t already have a
SID.

An example of the code is here:

$buffer = 
preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca

ffoh6jaeapkke35qpp87;?)/',
'"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);

The code works correctly in most cases except when a SID already exists and
there is a path after the .com such as:

http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;

When this URL is processed by the regex, it becomes:

http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;


So the problem is the regex not only falsely matches, it's inserting the SID
in between 2nd and 3rd letters of the extension.

You can see the code in action here:

http://kottmann.com/test.php

The full source for the test code is also available when viewing the source
of this page.

I've tested this on PHP v5.1.6 and PHP v5.2.6.

TIA,
Cameron









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



Re: [PHP] Re: SOAP - return a list of items

2008-08-18 Thread Dan Joseph
On Sun, Aug 17, 2008 at 8:32 AM, Luke <[EMAIL PROTECTED]> wrote:

> why use soap for this? I just use a javascript array for this kind of
> thing...
>
> 2008/8/13 Dan Joseph <[EMAIL PROTECTED]>
>
> Maybe more info will help:
>>
>> Here is what I have so far for the WSDL...
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> type="tns:ArrayOfgetQuoteHistoryResult" />
>>
>>
>>
>>
>>
>>> name="getQuoteHistoryResult" nillable="true"
>> type="tns:getQuoteHistoryResult" />
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> This validates fine in soapUI, and seems to work fine when the client
>> connects to it.
>>
>> The piece from PHP:
>>
>>$count = 0;
>>
>>while ( $data = $this->dbconn->fetchrow( $res ) )
>>{
>>foreach ( $data as $key => $value )
>>{
>>$quotes[$count][$key] = $value;
>>}
>>
>>$count++;
>>}
>>
>> return $quotes;
>>
>> This is the soap response:
>>
>> http://schemas.xmlsoap.org/soap/encoding/"; xmlns:SOAP-ENV="
>> http://schemas.xmlsoap.org/soap/envelope/";
>> xmlns:ns1="urn:ursquoteservice"
>> xmlns:ns2="urn:ursquote" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:SOAP-ENC="
>> http://schemas.xmlsoap.org/soap/encoding/";>
>>   
>>  
>> 
>>  
>>   
>> 
>>
>> It seems like I am just missing something somewhere.
>>
>> Anyone able to help?
>>
>> --
>> -Dan Joseph
>>
>> www.canishosting.com - Plans start @ $1.99/month.
>>
>> "Build a man a fire, and he will be warm for the rest of the day.
>> Light a man on fire, and will be warm for the rest of his life."
>>
>
>
>
> --
> Luke Slater
>

I'm using SOAP because its a web service, in this situation, JavaScript
wouldn't be an option.

I did figure this all out.  The problem was in my WSDL.  I had to add [] to
the end of my responses that return an array list.  Example:





-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


[PHP] File download problem

2008-08-18 Thread Stefano Noffke

Greetings,

I need to create a script to let registered users to download files from 
a non-public folder.


The files name, type, and size are stored in a MySQL Database. The user 
need to click on a link, and a PHP script should handle the download of 
the file.


Here is how I organized it:

The script gets the ID from the $_GET array, retrieve the name, type, 
and size from the database, and then it sends the following:


[CODE]

header("Content-Type: $type");
header("Content-Length: " . filesize($fileNameWithAbsolutePath));
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$fileName\"");

readfile($fileNameWithAbsolutePath) or die("File not found.");

[/CODE]

This script needs to work with any file type. I checked it and it works 
fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG 
which are corrupted and won't even open. Those are the only files I 
tried so far.


I should add that the connection to the web page is encrypted through 
SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and 
MySQL version 5.0.51a.


I cannot find any solution to this problem, and I hope that anyone here 
can help me.


Thank you.

Stefano

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



Re: [PHP] File download problem

2008-08-18 Thread Ashley Sheridan
Hi Stefano,

You can use this code instead to read in the file and output it to the
browser, as it is binary safe. I've used it for the same reason you
require, and it works fine with video clips.

$fp = fopen($path, "rb"); 
while(!feof($fp)) 
{ 
print(fread($fp, 1024)); 
flush($fp); 
} 
fclose($fp); 
exit(); 


The "rb" in the fopen function instructs PHP to open the file for
reading in a binary safe manner.

Hope this helps.

Ash
www.ashleysheridan.co.uk
--- Begin Message ---

Greetings,

I need to create a script to let registered users to download files from 
a non-public folder.


The files name, type, and size are stored in a MySQL Database. The user 
need to click on a link, and a PHP script should handle the download of 
the file.


Here is how I organized it:

The script gets the ID from the $_GET array, retrieve the name, type, 
and size from the database, and then it sends the following:


[CODE]

header("Content-Type: $type");
header("Content-Length: " . filesize($fileNameWithAbsolutePath));
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$fileName\"");

readfile($fileNameWithAbsolutePath) or die("File not found.");

[/CODE]

This script needs to work with any file type. I checked it and it works 
fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG 
which are corrupted and won't even open. Those are the only files I 
tried so far.


I should add that the connection to the web page is encrypted through 
SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and 
MySQL version 5.0.51a.


I cannot find any solution to this problem, and I hope that anyone here 
can help me.


Thank you.

Stefano

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


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

[PHP] PHP Prado

2008-08-18 Thread Hélio Rocha
Does anyone has an opinion 'bout developing with Prado?

Thanks in advance,
Hélio Rocha


[PHP] Number of duplicates in an array?

2008-08-18 Thread tedd

Hi gang:

Anyone have a cool method of finding duplicate items in an array and 
the number of times they appear?


I'm doing it in a way that is probably less than optimum. I want to 
see how you guys solve it.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] PHP Prado

2008-08-18 Thread Dan Joseph
On Mon, Aug 18, 2008 at 10:11 AM, Hélio Rocha <[EMAIL PROTECTED]> wrote:

> Does anyone has an opinion 'bout developing with Prado?
>
> Thanks in advance,
> Hélio Rocha
>

I tried it out a couple times about a year and a half ago.  I had a coworker
at the time that used it heavily.  It looked to me like it was pretty good.
It did everything he needed, in a timely fashion, and didn't seem to have a
whole lot of overhead to it.  From what I saw when I was looking over the
tutorials, its pretty flexible and was easy to pick up on.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] Number of duplicates in an array?

2008-08-18 Thread Ashley Sheridan
Best way to remove duplicates from an array is to use the built in PHP
function array_unique().

As for counting the number of times each unique value occurs, use
array_count_values().


Ash
www.ashleysheridan.co.uk
--- Begin Message ---

Hi gang:

Anyone have a cool method of finding duplicate items in an array and 
the number of times they appear?


I'm doing it in a way that is probably less than optimum. I want to 
see how you guys solve it.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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


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

Re: [PHP] Number of duplicates in an array?

2008-08-18 Thread David Otton
2008/8/18 tedd <[EMAIL PROTECTED]>:

> Anyone have a cool method of finding duplicate items in an array and the
> number of times they appear?
>
> I'm doing it in a way that is probably less than optimum. I want to see how
> you guys solve it.

Hmm. Assuming the following inputs and outputs:

$input_array = array( 'one', 'two', 'three', 'one', 'two', 'one' );
$output_array = array( 'one' => 3, 'two' => 2, 'three' => 1 );

$input_array = array( 'one', 'two', 'three', 'one', 'two', 'one' );
$output_array = array();
foreach( $input_array as $input )
{
if ( !isset( $output_array[$input] ) )
{
$output_array[$input] = 0;
}
$output_array[$input]++;
}

Untested code.

>From a CompSci PoV, input_array is a list while output_array would be
better implemented as a binary tree (with the normal caveats about
tree balancing). But given that we're working in PHP and your data
sets probably aren't that large, this is the "good enough" solution.

-- 

http://www.otton.org/

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



Re: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Cameron B. Prince
Hi Simcha,

I tried your suggestion and it does prevent the SID from being inserted
inside the extension, but causes double ?'s and SID's in some cases.

Thanks,
Cameron


On 8/18/08 2:25 AM, "Simcha Younger" <[EMAIL PROTECTED]> wrote:

> 
> Hi
> 
> 
> You did not put a question mark in your character class  ([\/\w\.-] and
> instead you put it together with the session id.
> The expression looks for a sequence without which is not followed by the
> next expression --- ?PHPSESSID\=2u0cca.
> If it would count the last `p` of `.php` then the next expression would
> violate the negative lookahead.
> Instead it stops just before it, after the `.ph` which is the longest
> expression it could find that fulfills your negative lookahead, and then it
> inserts the new sessionid over there.
> 
> Try instead 
> $buffer =
> preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.\-]*\??)(?!PHPSESSID\=2u0c
> caffoh6jaeapkke35qpp87;?)/',
> '"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
> 
> (not tested)
> 
> 
> 
> Simcha Younger
> 
> -Original Message-
> From: Cameron B. Prince [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 18, 2008 12:56 AM
> To: php-general@lists.php.net
> Subject: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?
> 
> Hello,
> 
> I¹ve run into a problem with a regex and need help determining if this is my
> mistake or a bug. The regex is for inserting a SID into every link in the
> buffer before it¹s flushed, but only when each link doesn¹t already have a
> SID.
> 
> An example of the code is here:
> 
> $buffer = 
> preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
> ffoh6jaeapkke35qpp87;?)/',
> '"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
> 
> The code works correctly in most cases except when a SID already exists and
> there is a path after the .com such as:
> 
> http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
> 
> When this URL is processed by the regex, it becomes:
> 
> http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
> PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
> 
> 
> So the problem is the regex not only falsely matches, it's inserting the SID
> in between 2nd and 3rd letters of the extension.
> 
> You can see the code in action here:
> 
> http://kottmann.com/test.php
> 
> The full source for the test code is also available when viewing the source
> of this page.
> 
> I've tested this on PHP v5.1.6 and PHP v5.2.6.
> 
> TIA,
> Cameron
> 
> 
> 
> 
> 
> 
> 



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



Re: [PHP] Re: Negative Look Ahead Regex - Code Mistake or Bug?

2008-08-18 Thread Cameron B. Prince
Hi Al,

I am using preg_quote in the live code. I omitted it from the example code
to simplify the example.

Thanks,
Cameron


On 8/18/08 8:31 AM, "Al" <[EMAIL PROTECTED]> wrote:

> Run your pattern thru preg_quote() prior to using it in your preg_replace().
> Don't backslash 
> anything yourself, let preg_quote() do it.
> 
> Cameron B. Prince wrote:
>> Hello,
>> 
>> I¹ve run into a problem with a regex and need help determining if this is my
>> mistake or a bug. The regex is for inserting a SID into every link in the
>> buffer before it¹s flushed, but only when each link doesn¹t already have a
>> SID.
>> 
>> An example of the code is here:
>> 
>> $buffer = 
>> preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
>> ffoh6jaeapkke35qpp87;?)/',
>> '"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;', $buffer);
>> 
>> The code works correctly in most cases except when a SID already exists and
>> there is a path after the .com such as:
>> 
>> http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
>> 
>> When this URL is processed by the regex, it becomes:
>> 
>> http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
>> PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
>> 
>> 
>> So the problem is the regex not only falsely matches, it's inserting the SID
>> in between 2nd and 3rd letters of the extension.
>> 
>> You can see the code in action here:
>> 
>> http://kottmann.com/test.php
>> 
>> The full source for the test code is also available when viewing the source
>> of this page.
>> 
>> I've tested this on PHP v5.1.6 and PHP v5.2.6.
>> 
>> TIA,
>> Cameron
>> 
>> 
>> 
>> 
>> 
>> 
>> 



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



Re: [PHP] php-gd problems on Ubuntu 8.04

2008-08-18 Thread Luke
Which gd package did you install? Php5-gd worked for me. Could be  
something like it trying to install a php4 module onto php5


Luke Slater
Lead Developer
NuVoo

On 18 Aug 2008, at 15:47, Chantal Rosmuller <[EMAIL PROTECTED]> wrote:


I did, but it doens't help

On Thursday 14 August 2008 18:58:57 Micah Gersten wrote:

Make sure  that your php.ini file for the cli is loading gd.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com

Chantal Rosmuller wrote:

Hi list,

I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu
doesn't use the gd bundles library for security reasons if I  
understood

this correctly. I solved it by downloading a php-gd fedora rpm and
converting it to .deb with alien. it works for the apache websites  
but

not for the commandline. I get the follwoing error:


php /path/to/process.php variable1 variable2

Warning: Wrong parameter count for strpos() in /path/to/config.php  
on

line 30
JpGraph Error This PHP installation is not configured with the GD
library. Please recompile PHP with GD support to run JpGraph.  
(Neither

function imagetypes() nor imagecreatefromstring() does exist)ro

does anyone know how to fix this?

regards Chantal




--
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] File download problem

2008-08-18 Thread Stefano Noffke

Hi,

Thank you for your reply. I tried your code, but the problem remains. I 
still can download PDF, TXT, and MP3 fine, but the ODT, DOC, and JPG are 
still corrupted.


I wonder why it works with some files and not with others...

Stefano

Ashley Sheridan ha scritto:

Hi Stefano,

You can use this code instead to read in the file and output it to the
browser, as it is binary safe. I've used it for the same reason you
require, and it works fine with video clips.

$fp = fopen($path, "rb"); 
while(!feof($fp)) 
{ 
print(fread($fp, 1024)); 
flush($fp); 
} 
fclose($fp); 
exit(); 



The "rb" in the fopen function instructs PHP to open the file for
reading in a binary safe manner.

Hope this helps.

Ash
www.ashleysheridan.co.uk




Oggetto:
[PHP] File download problem
Da:
Stefano Noffke <[EMAIL PROTECTED]>
Data:
Mon, 18 Aug 2008 16:01:22 +0200
A:
php-general@lists.php.net

A:
php-general@lists.php.net


Greetings,

I need to create a script to let registered users to download files from 
a non-public folder.


The files name, type, and size are stored in a MySQL Database. The user 
need to click on a link, and a PHP script should handle the download of 
the file.


Here is how I organized it:

The script gets the ID from the $_GET array, retrieve the name, type, 
and size from the database, and then it sends the following:


[CODE]

header("Content-Type: $type");
header("Content-Length: " . filesize($fileNameWithAbsolutePath));
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: private");
header("Content-Disposition: attachment; filename=\"$fileName\"");

readfile($fileNameWithAbsolutePath) or die("File not found.");

[/CODE]

This script needs to work with any file type. I checked it and it works 
fine with PDF, TXT, and MP3 for example, but not with ODT, DOC, or JPG 
which are corrupted and won't even open. Those are the only files I 
tried so far.


I should add that the connection to the web page is encrypted through 
SSL. The server (Fedora 9) runs Apache 2.2.9, PHP Version 5.2.6, and 
MySQL version 5.0.51a.


I cannot find any solution to this problem, and I hope that anyone here 
can help me.


Thank you.

Stefano



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



Re: [PHP] Number of duplicates in an array?

2008-08-18 Thread tedd

At 3:33 PM +0100 8/18/08, Ashley Sheridan wrote:

Best way to remove duplicates from an array is to use the built in PHP
function array_unique().

As for counting the number of times each unique value occurs, use
array_count_values().


Ash
www.ashleysheridan.co.uk



Ash:

I'm aware of array_unique() and have used it -- but I must have 
looked past array_count_values() ten times and didn't recognize it 
for what it was.


Thanks,

tedd



Hi gang:

Anyone have a cool method of finding duplicate items in an array and 
the number of times they appear?


I'm doing it in a way that is probably less than optimum. I want to 
see how you guys solve it.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] php-gd problems on Ubuntu 8.04

2008-08-18 Thread Chantal Rosmuller
I did, but it doens't help

On Thursday 14 August 2008 18:58:57 Micah Gersten wrote:
> Make sure  that your php.ini file for the cli is loading gd.
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
>
> Chantal Rosmuller wrote:
> > Hi list,
> >
> > I have a PHP problem on Ubuntu 8.04, the php-gd package for ubuntu
> > doesn't use the gd bundles library for security reasons if I understood
> > this correctly. I solved it by downloading a php-gd fedora rpm and
> > converting it to .deb with alien. it works for the apache websites but
> > not for the commandline. I get the follwoing error:
> >
> >
> >  php /path/to/process.php variable1 variable2
> >
> > Warning: Wrong parameter count for strpos() in /path/to/config.php on
> > line 30
> > JpGraph Error This PHP installation is not configured with the GD
> > library. Please recompile PHP with GD support to run JpGraph. (Neither
> > function imagetypes() nor imagecreatefromstring() does exist)ro
> >
> > does anyone know how to fix this?
> >
> > regards Chantal



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



Re: [PHP] FCKEditor, TinyMCE, ... I need a light weight WYSIWYG HTML Editor

2008-08-18 Thread afan pasalic
Warren Vail wrote:
> A textarea is a simple editor, I am assuming you want something better than
> that, or you wouldn't have looked further.
>   
I just tried Demo and got this:
"Sorry, you must have Internet Explorer 5.5 or higher to use the WYSIWYG
editor"
?!?

I'm using FF.

-afan

> Have you heard the expression (there is no free lunch), it applies here.
> Strictly speaking, a textarea is a wysiwyg editor, (what you see is what you
> get) you just don't see or get very much, one font, no formatting(other than
> what you can do with a carriage return, or a space bar).
>
> These editors can be very complex, but you do have some control in most of
> them to manage the complexity that you reveal to your users, and to do that
> you will have to know more about it than your users do (again, no free
> lunch).  
>
> I like TinyMCE, it allows me to make sure that my users have a simple
> interface, and is real easy to setup (relative to developing the whole thing
> myself), but most of the ones you cite can probably fill that bill.
>
> Warren Vail
>
>   
>> -Original Message-
>> From: mike [mailto:[EMAIL PROTECTED] 
>> Sent: Sunday, August 17, 2008 12:05 PM
>> To: AmirBehzad Eslami
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] FCKEditor, TinyMCE, ... I need a light 
>> weight WYSIWYG HTML Editor
>>
>> On 8/17/08, AmirBehzad Eslami <[EMAIL PROTECTED]> wrote:
>> 
>>> Dear list,
>>>
>>> I'm looking for a light weight WYSIWYG HTML Editor to allow 
>>>   
>> users to 
>> 
>>> send private messages to each other in a forum application.
>>>
>>> FCKEditor is too complex and very huge for my purposes. I want a 
>>> simple editor. What do you recommend?
>>>   
>> WordPress has tweaked tinymce a lot to maintain  spacing 
>> and code snippets and embedded objects. We've tried both at 
>> my job with various configurations, both have had issues - 
>> but we've had the most success and our users have been happy 
>> with WordPress's configuration (which uses a couple custom 
>> javascript things + specific tinymce
>> configuration)
>>
>> I've been trying to examine the differences so I can create a 
>> reusable standalone component we can use in all our various 
>> apps... but WP has hooked in a lot of custom code and it's 
>> been a bit annoying trying to split it out into a single 
>> reusable javascript file and stuff. Almost done though. I 
>> went overboard and tried to make it more generic by renaming 
>> and cleaning up the functions to not need any WordPress 
>> callbacks and stuff and wound up messing it up, so I have to 
>> go back again and probably re-create it from scratch.. Doh :)
>>
>> Honestly in a forum setting you can just give them a bbcode 
>> howto/link on the side and let them put in their own bbcode 
>> (which can be a strict subset of HTML) - or even just allow 
>> HTML tags and limit what they can do. Loading up a 
>> javascript-based thing even if it's pretty lightweight is 
>> still annoying and I could see that being overkill for a forum.
>>
>> --
>> 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] Negative Look Ahead Regex

2008-08-18 Thread Simcha Younger
Hi

I do not know if this is possible using negative assertions, but you can do
it with a search for any links, and then applying a callback which will
conditionally add your session id.

This seems to do the trick:

function addid($href){
$id = "?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;";
$href = $href[1];
if(!strpos($href, "PHPSESSID")) $href = preg_replace("/^([^#?]*)\??/",
"$1$id", $href);
return $href."\"";
}
$buffer = preg_replace_callback("/(href=\".*?)\"/", "addid", $buffer);


Simcha Younger

-Original Message-
From: Cameron B. Prince [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 18, 2008 4:41 PM
To: Simcha Younger; php-general@lists.php.net
Subject: Re: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?

Hi Simcha,

I tried your suggestion and it does prevent the SID from being inserted
inside the extension, but causes double ?'s and SID's in some cases.

Thanks,
Cameron


On 8/18/08 2:25 AM, "Simcha Younger" <[EMAIL PROTECTED]> wrote:

> 
> Hi
> 
> 
> You did not put a question mark in your character class  ([\/\w\.-] and
> instead you put it together with the session id.
> The expression looks for a sequence without which is not followed by the
> next expression --- ?PHPSESSID\=2u0cca.
> If it would count the last `p` of `.php` then the next expression would
> violate the negative lookahead.
> Instead it stops just before it, after the `.ph` which is the longest
> expression it could find that fulfills your negative lookahead, and then
it
> inserts the new sessionid over there.
> 
> Try instead 
> $buffer =
>
preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.\-]*\??)(?!PHPSESSID\=2u0c
> caffoh6jaeapkke35qpp87;?)/',
> '"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;',
$buffer);
> 
> (not tested)
> 
> 
> 
> Simcha Younger
> 
> -Original Message-
> From: Cameron B. Prince [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 18, 2008 12:56 AM
> To: php-general@lists.php.net
> Subject: [PHP] Negative Look Ahead Regex - Code Mistake or Bug?
> 
> Hello,
> 
> I¹ve run into a problem with a regex and need help determining if this is
my
> mistake or a bug. The regex is for inserting a SID into every link in the
> buffer before it¹s flushed, but only when each link doesn¹t already have a
> SID.
> 
> An example of the code is here:
> 
> $buffer = 
>
preg_replace('/"http\:\/\/www\.domain\.com([\/\w\.-]*)(?!\?PHPSESSID\=2u0cca
> ffoh6jaeapkke35qpp87;?)/',
> '"http://www.domain.com$1?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;',
$buffer);
> 
> The code works correctly in most cases except when a SID already exists
and
> there is a path after the .com such as:
> 
>
http://www.domain.com/path1/path2.php?PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
> 
> When this URL is processed by the regex, it becomes:
> 
>
http://www.domain.com/path1/path2.ph?PHPSESSID=t9gksvpdcuobsnqt98qloe6lg4;p?
> PHPSESSID=2u0ccaffoh6jaeapkke35qpp87;
> 
> 
> So the problem is the regex not only falsely matches, it's inserting the
SID
> in between 2nd and 3rd letters of the extension.
> 
> You can see the code in action here:
> 
> http://kottmann.com/test.php
> 
> The full source for the test code is also available when viewing the
source
> of this page.
> 
> I've tested this on PHP v5.1.6 and PHP v5.2.6.
> 
> TIA,
> Cameron
> 
> 
> 
> 
> 
> 
> 



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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.6.4/1617 - Release Date: 17/08/2008
12:58


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



Re: [PHP] FCKEditor, TinyMCE, ... I need a light weight WYSIWYG HTML Editor

2008-08-18 Thread Christoph Boget
>> A textarea is a simple editor, I am assuming you want something better than
>> that, or you wouldn't have looked further.
> I just tried Demo and got this:
> "Sorry, you must have Internet Explorer 5.5 or higher to use the WYSIWYG
> editor"
> ?!?

Wow.  You know people who are still using IE5.5?  Seriously?

Textareas do have their problems but I wouldn't consider IE5.5 one of them... :p

thnx,
Christoph

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



[PHP] pdo compilation question

2008-08-18 Thread Tim Rupp
Hi list, I hope this is the right area to ask,

I'm trying to compile PDO support in 5.2.6 and am following the
instructions here

http://us2.php.net/manual/en/pdo.installation.php

My compile line is the following



./configure  --enable-force-cgi-redirect \
--disable-rpath \
--with-bz2 \
--with-db4=/usr \
--with-curl \
--with-gd \
--enable-gd-native-ttf \
--without-gdbm \
--with-gettext \
--with-ncurses \
--with-gmp \
--with-iconv \
--with-openssl \
--with-regex=system \
--with-zlib \
--with-layout=GNU \
--enable-bcmath \
--enable-exif \
--enable-ftp \
--enable-magic-quotes \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-kerberos \
--with-ldap=shared \
--with-mysql=shared \
--enable-mbstring=all \
--with-apxs2=/usr/sbin/apxs \
--with-pgsql=shared \
--with-mysqli \
--with-freetype-dir=/usr/include/freetype2 \
--with-mcrypt \
--enable-soap \
--enable-pcntl \
--enable-pdo=shared \
--with-sqlite=shared \
--with-pdo-sqlite=shared \
--with-pdo-mysql=shared \
--with-pdo-pgsql=shared \
--with-pdo-oci=shared


This config line I'm working with has been a growing one, so there may
be some things here that may or may not be needed. Anyway, Upon
compiling the above, I get the following error when I do a php -m



Warning: PHP Startup: Invalid library (maybe not a PHP library)
'pdo.so'  in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20060613/pdo_mysql.so' -
/usr/local/lib/php/20060613/pdo_mysql.so: undefined symbol:
php_pdo_get_dbh_ce in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20060613/pdo_pgsql.so' -
/usr/local/lib/php/20060613/pdo_pgsql.so: undefined symbol:
php_pdo_register_driver in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20060613/pdo_sqlite.so' -
/usr/local/lib/php/20060613/pdo_sqlite.so: undefined symbol:
php_pdo_register_driver in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20060613/sqlite.so' -
/usr/local/lib/php/20060613/sqlite.so: undefined symbol:
php_pdo_register_driver in Unknown on line 0





I've included the extensions in my php.ini file, but I'm completely
lost on where to go from here because the error is less than helpful.
The order that I've included them is

extension=pdo.so
extension=pdo_mysql.so
extension=pdo_pgsql.so
extension=pdo_sqlite.so
extension=sqlite.so


and they do exist, as shown here


-rwxr-xr-x  1 root root  364012 May 14  2007 apc.so
-rwxr-xr-x  1 root root  102531 Aug 18 14:25 ldap.so
-rwxr-xr-x  1 root root  120644 Aug 18 14:25 mysql.so
-rwxr-xr-x  1 root root  270860 Nov 13  2006 oci8.so
-rwxr-xr-x  1 root root  125246 Aug 18 14:25 pdo_mysql.so
-rwxr-xr-x  1 root root  100772 Aug 18 14:25 pdo_oci.so
-rwxr-xr-x  1 root root  111246 Aug 18 14:25 pdo_pgsql.so
-rwxr-xr-x  1 root root  270276 Aug 18 14:25 pdo.so
-rwxr-xr-x  1 root root 1370516 Aug 18 14:25 pdo_sqlite.so
-rwxr-xr-x  1 root root  235943 Aug 18 14:25 pgsql.so
-rwxr-xr-x  1 root root 1010437 Aug 18 14:25 sqlite.so
-rwxr-xr-x  1 root root  598407 Jan 29  2008 xdebug.so


I'm using RHEL 4, and have installed the sqlite-devel, but I think php
is choosing to use the sqlite that comes with it I'm hoping
someone on the list can point me in the right direction.

Thanks in advance,
Tim

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



Re: [PHP] Re: PHP editor for linux

2008-08-18 Thread Pavel
I use Zend Studio (shareware, but i couldn't find better things). There are 
some plugins for Eclipse,but if you used Zend before, you will be cunfused by 
that plugins...

P.S. Sorry for my English...


-- 
===
С уважением, Манылов Павел aka [R-k]
icq: 949-388-0
mailto:[EMAIL PROTECTED]
===
А ещё говорят так:
В каждом толстом человеке сидит худой и требует, чтобы его выпустили.
-- Сирил Коннолли
[fortune]


Re: [PHP] Tool Tip in pdf

2008-08-18 Thread Subhranil

Hi Micah,
Sorry for late reply. Actually 15th August is our INDEPENDENCE DAY and I was
out of work.
I am a newbie. I have very little knowledge about pdf. Could you please give
some tip for wraping the text

Thanks,
Subhranil. 



Micah Gersten wrote:
> 
> Why not wrap the text?
> 
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
> 
> 
> 
> Subhranil wrote:
>> Hi all,
>>
>> I am creating a pdf where text size of cell is not fixed.
>> My problem is if one text is too long than that cell then it overlap the
>> next cell.
>>
>> I wish to show the part of the text which are loneger than cell size and
>> put
>> a tool tip on that cell which show the complete text.
>>
>> Is it possible ? Looking for any suggestion.
>>
>> Thanks,
>> Subhranil.
>>   
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Tool-Tip-in-pdf-tp18980527p19045252.html
Sent from the PHP - General mailing list archive at Nabble.com.


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