Re: [PHP] Replacing accented characters?

2010-01-28 Thread Marcus Gnaß
On 28.01.2010 03:40, Paul M Foster wrote:
> On Wed, Jan 27, 2010 at 04:55:46PM -0600, Skip Evans wrote:
> 
>> Hey all,
>>
>> I'm looking for recommendations on how to replace accented
>> characters, like e and u with those two little dots above
>> them, with the regular e and u characters.
> 
> FWIW, those two dots are called an "umlaut".
> 
> Paul
> 

FWIW, the whole letters ÄäÖöÜü are called "Umlaute" (umlauts).
The two dots above *these* letters are "Umlautzeichen" (umlaut marks).
But two dots above an e or i are called "Trema" (diacritic mark).

Marcus

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



Re: [PHP] Re: Question: Sorting through table headers?

2009-09-14 Thread Marcus Gnaß
Tony Marston wrote:

> You cannot do this in a separate class as it requires action in both the 
> presentation (UI) and data access layers, and a single class is not allowed 
> to operate in more than one layer.

You can, but you shouldn't if you want to write your classes according
to the MVC pattern.

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



Re: [PHP] Question: Sorting through table headers?

2009-09-14 Thread Marcus Gna?
Jim Lucas wrote:
> Parham Doustdar wrote:
>> Hello there,
>> I've been asked to create something like the tables you usually see,
>> where the headers are actually links and when you click the links, the
>> table gets sorted based on the header. Are there any classes that you
>> know of that would do the job? My current idea is to return an array
>> of the colomn which contains the data you want to sort on (like
>> 'name') then sort the array and do something like:
>> [code]
>> for (i = 0; i < length(array); i++)
>> mysql_query("select * from table where 'name' = ${aray[i]}");
>> [/code]
>> Any better algorithms anyone?
>> Thanks!
> 
> My suggestion would be to have the client do it.
> 
> http://www.js-vault.us/iscripts/007.html
> 
> I use it on a number of different pages.

This could be done clientside if you intend to show all data. If you
want to implement paging too, you have to do it on the server though.

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



Re: [PHP] Creating alphanumeric id for a table

2009-09-11 Thread Marcus Gnaß
aveev wrote:
>  function generate_id($num) {
> $start_dig = 4;
> $num_dig = strlen($num);
> 
> $id = $num;
> if($num_dig <= $start_dig) {
> $num_zero = $start_dig - $num_dig;
> 
> for($i=0;$i< $num_zero; $i++) {
> $id = '0' . $id;
> }
> }
> $id = 'AAA' . $id;
> return $id;
> }
> 
> $app_id = generate_id(1);
>   
> ?>

Your function can be reduced to a one-liner:

function generate_id($num) {
  return 'AAA' . str_pad(strval($num), 4, '0', STR_PAD_LEFT);
}

If the prefix is always 'AAA' you should consider to use a numeric ID
for your database and let your database generate the autoincrement id
and use this function just for display.

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



Re: [PHP] header problem

2009-09-10 Thread Marcus Gnaß
A.a.k wrote:
> is there any alternative to header() for redirect users?

As far as I know there isn't.

Is the header-error the first error on the page? If not, the other error
message itself is the reason for the header-error and will be solved if
you solve the other error.

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



Re: [PHP] SQL help?

2009-05-18 Thread Marcus Gnaß
Skip Evans wrote:
> Hey all,
> 
> I have a SQL requirement I'm not quite sure how to compose.
> 
> I have two tables, shows, and shows_dates. It's a one to many
> relationship where there is a single entry in shows and multiple entries
> in shows_dates that list each date and time for a play production for a
> run of entries in shows, like
> 
> I need a query that will read each record in shows, but I only want the
> first record from shows_dates, the first one sorted by date, so I can
> display all shows in order of their opening date.
> 
> Not sure how to grab just the first record from shows_dates though.
> 
> Hint, anyone?
> 
> Thanks,
> Skip
> 


Join the two tables like you normally would do and aggregate the opening
date column with your dbms-specific max function and finally group the
result by a distinct value from shows.

It would have bee easier if you stated which rdbms you use ...

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



Re: [PHP] speaking of control structures...

2009-05-06 Thread Marcus Gnaß
Robert Cummings wrote:
> On Wed, 2009-05-06 at 22:23 +0200, Marcus Gnaß wrote:
>> Robert Cummings wrote:
>>> On Wed, 2009-05-06 at 12:56 +0200, Marcus Gnaß wrote:
>>>> Tom Worster wrote:
>>>>> there's a control structure i wish php had: a simple block that you can
>>>>> break out of, e.g.
>>>>> 
>>>> As Maarten pointed out you could use a function. Another alternative is
>>>> to use Exceptions which might be the most proper way to do it.
>>>> 
>>> That seems like an abuse of exceptions. But then we're already abusing
>>> loops. I just don't think one could say it's the proper way to do it :)
>>>
>> Why do you think it's an abuse of exceptions? If I have a block of code
>> which I expect to run from the beginning to the end and I discover a
>> situation where its not appropriate to continue this block of code I is
>> what I would call an exception. Exception don't have to be errors or
>> such. It's just a special situation ...
> 
> While exceptions can certainly be used in this context and in a valid
> manner, there's a fine line between an exception and a condition. The OP
> was processing code that didn't appear exceptional, he was merely
> managing flow control of the logic. This is a condition, not an
> exception.

Agreed! He wrote:

if ( condition )
  break;

Although I had the impression that he expected the whole block of code
to be executed and just wanted to break from this block in an
exceptional situation.

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



Re: [PHP] speaking of control structures...

2009-05-06 Thread Marcus Gnaß
Robert Cummings wrote:
> On Wed, 2009-05-06 at 12:56 +0200, Marcus Gnaß wrote:
>> Tom Worster wrote:
>>> there's a control structure i wish php had: a simple block that you can
>>> break out of, e.g.
>>
>> As Maarten pointed out you could use a function. Another alternative is
>> to use Exceptions which might be the most proper way to do it.
> 
> That seems like an abuse of exceptions. But then we're already abusing
> loops. I just don't think one could say it's the proper way to do it :)
> 
> Cheers,
> Rob.

Why do you think it's an abuse of exceptions? If I have a block of code
which I expect to run from the beginning to the end and I discover a
situation wher its not appropriate to continue this block of code I is
what I would call an exception. Exception don't have to be errors or
such. It's just a special situation ...

Marcus

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



Re: [PHP] speaking of control structures...

2009-05-06 Thread Marcus Gnaß
Tom Worster wrote:
> there's a control structure i wish php had: a simple block that you can
> break out of, e.g.


As Maarten pointed out you could use a function. Another alternative is
to use Exceptions which might be the most proper way to do it.

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



Re: [PHP] php forms - select menu selected behavior

2009-04-30 Thread Marcus Gnaß
Troy Oltmanns wrote:
> I have the code below being used to rifle through a list of available
> categories and create select options for them. The code is being used to
> query the database and compare the product category to the current
> iteration, if there's a match, then add selected code so the category is
> prechosen. More code (not included) does the saving and all that, I've check
> phpmyadmin. But when the page submits, the old category appears in the drop
> down as selected. If I leave the page and come back it's fine, it's just
> right after it is saved. The form script is being used on itself, in that
> there is only one file for the form, the submission, etc. All of the other
> input elements will load the data after being saved, is it something
> specific to dropdowns, or it is the way the code is being instatiated?
> 
> All help is much appreciated. Please let me know if anymore info is needed.
> 

//MAKE CATEGORIES DROPDOWN

$catlist1 = "";

// read product
$catmatch = "SELECT prod_cat0 FROM product WHERE dbi='$dbi';";
$catresult = mysql_query($catmatch);
$catquery = mysql_fetch_array($catresult);

// read categories
$sql = "SELECT category FROM categories ORDER BY category;";
$result = mysql_query($sql);
while ($col2 = mysql_fetch_array($result)) {

$id = $col2["category"];

if ($id == $catquery['prod_cat0']){

$catlist1 .= "$id";

}   else {

$catlist1 .= "$id";

}

}

> 
> to instantiate 
> 

The only data you need from table product is the column prod_cat0, from
table categories it's category, so you should read only the needed data
instead of using * for better performance.

Take the SQL and verify if it returns what you want it to return then.

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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Marcus Gnaß

Paul M Foster wrote:

On Fri, Apr 10, 2009 at 09:01:14AM -0400, Bob McConnell wrote:

  

From: Paul M Foster


Here's a hairbrained idea I was kicking around. I object to the idea
  

of


including 15 or 30 files in a PHP application just to display one page
on the internet. It makes the coding faster, but it makes the display
slower and seems silly to me.

So what if you had a tool or a set of tools where you could write code
snippets and such, and then hit a button or issue a command, and
everything you specified got written into a single file? You'd specify
that this page needs to read the config, set up a database connection,
validate these fields, etc. When you were done, it would write all
  

this


code to a *single* file, which the user would invoke by surfing to
  

that


page. The resulting code would be *static*, not like what results from
most templating systems. So rather than specify a specific variable
value in the resulting file, it would embed the PHP code to display
  

the


variable, etc.

What might be the liabilities of something like that? Would there be
security issues? Would there be increased difficulty in debugging?
  

What


can you think of?
  

Programs to do that used to be called compilers. There is an entire
branch of computer science and a lot of tools (lex, yacc, etc.)
dedicated to that topic.



I know compilers. I've coded in C for years. I'm not talking about a
compiler here. It's more an "aggregator". The resulting page would still
be php/html, but everything needed in it would be self-contained (except
the web server and PHP interpreter). Kind of like what "make" does,
except that make typically invokes the compiler to mash it all into one
executable at the end.

  

It's not a bad idea, but there is one precarious assumption that
underlies it. Can you absolutely guarantee there will never be a second,
or third, or more pages on that server that will need some of those
functions or classes? As soon as the site begins to evolve and grow, you
will have multiple copies of many of those snippets, and when (not if)
you need to modify them, you will have to find and change every single
copy.

So you need to ask yourself if this strategy is maintainable in your
case. And will it make any real difference in the end?




Good point. That's why I asked the question in the first place. Every
time you revised a supporting file, you'd have to regenerate all the
files that depended on it. Might be okay for a small site, but could be
a nightmare for a large site.

Paul

  


You could try to substitute all your calls to include() or require() 
with SSI-includes and let your webserver do the aggregation then.


I read an article about retrieving the webservers result after 
performing SSI actions but before handing this over to the application 
server, but I can't remember where ...


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



Re: [PHP] Question about template systems

2009-03-03 Thread Marcus Gnaß

Matthew Croud wrote:

Hello,

First post here, I'm in the process of learning PHP , I'm digesting a 
few books as we speak.
I'm working on a content heavy website that provides a lot of 
information, a template system would be great and so i've been looking 
at ways to create dynamic data with a static navigation system.


So far, using the require_once(); function seems to fit the bill in 
order to bring in the same header html file on each page.

I've also looked at Smartys template system.

I wondered how you folk would go about creating a template system ?
Smarty is a good choice, although some people might prefer other 
templating systems. This is kind of a religious question like with 
programming questions in general. But I guess that most people would 
advise you to use an existing templating system instead of writing one 
on your own.
My second question might be me jumping the gun here, I haven't come 
across this part in my book but i'll ask about it anyway.  I often see 
websites that have a dynamic body and static header, and their web 
addresses end like this: "index.php?id=445" where 445 i presume is 
some file reference.
What is this called ?  It seems like the system i'm after but it 
doesn't appear in my book,  If anyone could let me know what this page 
id subject is called i can do some research on the subject.
Have a look at the PHP manual and be sure to bookmark it! ;) 
http://www.php.net/manual/en/


The ID you mentioned is a query. "id=445&other_id=653" would be a 
querystring.
To retrieve data passed via this querystring you can use $_GET 
(http://de.php.net/manual/en/reserved.variables.get.php).



Have fun

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



Re: [PHP] Question about template systems

2009-03-03 Thread Marcus Gnaß

Marcus Gnaß wrote:

like with programming questions in general.



Should have read my own post before sending! ;) Should be "programming 
languages"!


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



Re: [PHP] PHP OOP

2009-02-10 Thread Marcus Gnaß

Paul M Foster wrote:

On Mon, Feb 09, 2009 at 11:02:37AM -0500, tedd wrote:
  
As a side note, I think students should learn a language like C before

learning something like Perl, Python or PHP. Having to deal with
defining/declaring variables and their storage methods before use I
think makes for more conscientious programmers. And pointers are an
education all on their own. ;-}
  
For teaching programming or OOP I would choose a language which 
concentrates on the topic. The hard stuff, which you have to deal with 
in C for example, can be learned later. I'm glad that I started 
programming in Pascal, not in C. If today I had to learn programming as 
such I would definitively opt for Python! My choice for learning OOP 
would be Python or even better Java cause you don't have the choice to 
do it in a procedural way.


Marcus

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



Re: [PHP] maybe we could all?

2009-02-09 Thread Marcus Gnaß

Nathan Rixham wrote:

Marcus Gnaß wrote:

Nathan Rixham wrote:

Project: PHP Common Objects and Datatypes


Has anything been setup for project COD-pieces yet? I like this name! ;)

Actually, yes it has - the project, well working group, has been 
called "voom".

Sounds fine too! ;)
If you're interested just let me know and we'll get you introduced and 
set-up.
Yes please! I'm an intermediate PHP programmer who is lurking this list 
since october 06 and wrote a small CMS for my own (and a couple of 
friends) use so far.
I'm quite comfortable with (classical ... sigh) ASP so far which I use 
now for about 10 years and recently I began to get along with Java.


Your ideas sounded really great and I would like to join this group.

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



Re: [PHP] maybe we could all?

2009-02-09 Thread Marcus Gnaß

Nathan Rixham wrote:

Project: PHP Common Objects and Datatypes


Has anything been setup for project COD-pieces yet? I like this name! ;)

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



[PHP] [RFC] Replace the flex-based scanner with an re2c [1] based lexer

2008-03-03 Thread Marcus Boerger
Hello everyone,

  sorry for the crosspost. But recent discussions about:
'[RFC] Replace the flex-based scanner with an re2c [1] based lexer'
revealed one big issue. During the development of said RFC we dropped
--enable-multibyte-support and interaction between engine and ext/mbstring
using declare(encoding=..). Now neither of the two is documented anywhere,
nor does any of the core developers happen to know how it works, what it is
supposed to do or how to test it.

Since we do not want to drop this feature we need some test code, best in
the form of .PHPTs. You can find information on how to write tests here:
http://qa.php.net/write-test.php and
http://talks.somabo.de/200703_montreal_need_for_testing.pdf

If you are interested in this further you are of course also more than
welcome to help in any other form. Apart from the proposal below, there
is also my blog entry to help you getting started:
http://blog.somabo.de/2008/02/php-on-re2c.html

thanks
marcus


Sunday, March 2, 2008, 11:21:34 PM, you wrote:

> RFC: REPLACE THE FLEX-BASED SCANNER WITH AN RE2C [1] BASED LEXER

> Situation:
> The current flex-based lexer depends on an outdated and unsupported flex
> version. Alternatives include either updating to a newer version of flex or
> using re2c, which we already use for a variety of things (serializing, pdo sql
> scanning, date/time parsing). While moving towards a newer flex version would
> be much easier, switching to re2c promises a much faster lexer. Actually,
> without any specific re2c optimizations we already get around a 20% scanner
> performance increase. Running the tests gets an overall speedup of 2%. It is
> arguable whether this is enough, but re2c has more advantages. First of all,
> re2c allows one to scan any type of input (ASCII, UTF-8, UTF-16, UTF-32).
> Secondly, it allows for better integration with Lemon [2], which would be the
> next step. And thirdly we can switch to a reentrant scanner.

> Current state:
> Flex has been fully replaced by re2c in Zend. We have also switched to an
> mmap-based lexer approach for now. However, we had to drop multibyte support
> as well as the encoding declare. The current state can be checked out from
> Scott's subversion repository [3] and you can follow the development on his
> Trac setup [4]. When you want to build php with re2c, then you need to grab
> re2c from its sourceforge subversion repository [5]. You can also check out
> the changes in a patch created Sunday 2nd March against a PHP checkout from 
> 14th February [6].

> Further steps:
> Commit this to PHP 5.3. Synch to HEAD. Add pecl/intl to 5.3. Discuss/recreate
> multibyte support with libintl.

> Future steps:
> Replace bison with lemon in PHP 5.4 or HEAD.

> Time Frame:
> Commit to 5.3 between the 5th and the 15th of March. Synch to HEAD a couple
> of days later. Moving pecl/libintl to ext (depends on the 5.3 RMs decision).
> After that is done, decide about multibyte support. Along with the commit to
> the 5.3 branch there will be a new re2c version available.


> Marcus Boerger
> Nuno Lopes
> Scott MacVicar


> [1] http://re2c.org/
> [2] http://www.hwaci.com/sw/lemon/
> [3] svn://whisky.macvicar.net/php-re2c
> [4] http://trac.macvicar.net/php-re2c/
> [5] https://re2c.svn.sourceforge.net/svnroot/re2c/trunk/re2c
> [6] http://php.net/~helly/php-re2c-20080302.diff.txt



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



[PHP] Re: Expand variable in comparison

2008-01-18 Thread Marcus

Andrés Robinet wrote:

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Marcus
Sent: Friday, January 18, 2008 9:56 PM
To: php-general@lists.php.net
Subject: [PHP] Re: Expand variable in comparison

Andrés Robinet wrote:

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Marcus
Sent: Friday, January 18, 2008 4:51 PM
To: php-general@lists.php.net
Subject: [PHP] Expand variable in comparison

Hi!


Is there any way to get the following snippet returning a true?


...
$this->var = ?
if ($this->var == $preDefinedStringToTestWith)
 return true;
else
 false;



The problem:
I don't know, what $preDefinedStringToTestWith is!
$this->var can be set to any string.

I tried
$this->var = "${preDefinedStringToTestWith}"
but this doesn't get expanded.


Uh! Shouldn't it work?

$this->var = $preDefinedStringToTestWith

For certain reason $this->var can only be set to a string and not to a
variable!

Any suggestions?


I don't understand what you are trying to do, 


I do only have control over the content of this variable itself (Comes from 
$_REQUEST) - not over the code.





but maybe you are trying to achieve something like:

var = "theVariableName"; // Hold variable name
$theVariableName = "whatever you want";
if (${$this->var} == $theVariableName)
  echo ${$this->var}." is equal to ".$theVariableName;
else
  echo "bad dog! stop it!";
}
}

new Test();
?>


Nearly, but I can only alter the content of $var itself!
I cannot change the comparison.
Comparison is always
if ($this->var == $preDefinedStringToTestWith)

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



[PHP] Re: Expand variable in comparison

2008-01-18 Thread Marcus

Andrés Robinet wrote:

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Marcus
Sent: Friday, January 18, 2008 4:51 PM
To: php-general@lists.php.net
Subject: [PHP] Expand variable in comparison

Hi!


Is there any way to get the following snippet returning a true?


...
$this->var = ?
if ($this->var == $preDefinedStringToTestWith)
 return true;
else
 false;



The problem:
I don't know, what $preDefinedStringToTestWith is!
$this->var can be set to any string.

I tried
$this->var = "${preDefinedStringToTestWith}"
but this doesn't get expanded.



Uh! Shouldn't it work?

$this->var = $preDefinedStringToTestWith


For certain reason $this->var can only be set to a string and not to a variable!

Any suggestions?

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



[PHP] Re: [PHP-DEV] PHP 4.4.8RC1

2007-12-20 Thread Marcus Boerger
Hello Derick,

  to stick with our announced plan, can we release this in 2007?

marcus

Thursday, December 20, 2007, 1:43:18 PM, you wrote:

> Hello!

> I packed PHP 4.4.8RC1 today, which you can find here:
> http://downloads.php.net/derick/

> Please test it carefully, and report any bugs in the bug system, but 
> only if you have a short reproducable test case.

> If everything goes well, we can release it somewhere in the first week 
> of 2008.

> regards,
> Derick

> -- 
> Derick Rethans
> http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org




Best regards,
 Marcus

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



Re: [PHP] Detect local or remote call?

2007-10-11 Thread Marcus Mueller
Anders Norrbring wrote:
> Is there a good way to detect in a script if it's called locally from
> command line, or via a remote browser?

Check out .

Greetings
m.

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



RE: [PHP] parsing objects

2006-12-21 Thread Marcus
I need to output that as

Category:  X

   Sub-category:  1
   Sub-category: 2

..
..

linking by id's to parent id's just like in a database.



-Original Message-
From: Roman Neuhauser [mailto:[EMAIL PROTECTED]
Sent: Friday, December 22, 2006 12:18 AM
To: Marcus
Cc: php-general@lists.php.net
Subject: Re: [PHP] parsing objects


# [EMAIL PROTECTED] / 2006-12-21 18:06:28 +0200:
> Hello
>
> I have a soap call that returns something like;
>
> Result from a print_r();
>
> stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass
Object
> ( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
> 114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
> [iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
> [iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
> Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] =>
57142 )
> [2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] =>
1
> [iTreeCount] => 11 [iLocalCount] => 0 )
>
> I need to convert that to a multidimensional array to link ID's to Parent
> ID's.

What makes you think so?

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



[PHP] parsing objects

2006-12-21 Thread Marcus
Hello

I have a soap call that returns something like;

Result from a print_r();

stdClass Object ( [getCategoryTreeReturn] => Array ( [0] => stdClass Object
( [iId] => 1 [sName] => Cars & Motorbikes [iParentId] => 0 [iTreeCount] =>
114302 [iLocalCount] => 0 [aSubCats] => Array ( [0] => stdClass Object (
[iId] => 2 [sName] => Car Electronics [iParentId] => 1 [iTreeCount] => 0
[iLocalCount] => 0 ) [1] => stdClass Object ( [iId] => 5 [sName] => Car
Accessories [iParentId] => 1 [iTreeCount] => 57160 [iLocalCount] => 57142 )
[2] => stdClass Object ( [iId] => 16 [sName] => Motorcycles [iParentId] => 1
[iTreeCount] => 11 [iLocalCount] => 0 )

I need to convert that to a multidimensional array to link ID's to Parent
ID's. I have created a function which recursively scans the result variable.
It writes the rows to a temporary file for later fetching, but it is
somewhat slow. Can i maintain those recursive seek to an array. As function
is being called inside and inside, i can not return a proper value. Is there
any way to maintain those rows without writing to tmp.


The function is :

--- BEGIN ---

function deepseek($val) {

foreach ($val as $key => $value) {

if (is_object($value)) {
$newarr = get_object_vars($newarr);
foreach ($newarr as $key2 => $value2) {
deepseek($value2);
}
}

if (is_array($value)) {

foreach ($value as $key2 => $value2) {
deepseek($value2);
}
}

if (!is_array($value) AND !is_object($value)) {

if ($key == "iParentId" OR $key == "sName" OR $key == "iId") {

$output .= "$value-";

}

if ($key == "iTreeCount") {
$handle = fopen("tmp/tmp","a");
fwrite($handle,$output."\n");
fclose($handle);

unset($output);

}


}

}


}
--- END ---

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



RE: [PHP] Curl and cookies

2006-12-15 Thread Marcus

1. Set option "HEADER" true for the login part in Curl
2. Take the output of login page, you will notice Set-cookie:
name=cookie_value;   parametres returned from the header.
3. Preg match or use (explode,str_replace etc) to get those names and
values. Prepare them for the next Curl fetch
4. Make a new call to a new page, using the cookies with curl option COOKIE.

--aras

-Original Message-
From: Fernando M. M. [mailto:[EMAIL PROTECTED]
Sent: Friday, December 15, 2006 4:07 PM
To: php-general@lists.php.net
Subject: [PHP] Curl and cookies




Hello,

I have just started using curl and i have some question about
cookies.

The website i'm logging in controls everything using cookies (from
login to the actions inside it).

Is there a way to store the cookie values
into a php session variable ($_SESSION['cookie'])?

How do i make curl receive
the cookie and store in this variable?

How do i make curl send it?

Thanks,

Fernando.

--

Blog:
http://blog.forumdebian.com.br/fernando
Contato:
http://www.forumdebian.com.br/fernando/contato.php

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



Re: [PHP] Object to array conversion oddity

2006-09-26 Thread Marcus Bointon

On 26 Sep 2006, at 23:52, Richard Lynch wrote:


You start using that PHP5 private/protected stuff, and it just doesn't
make sense to coerce it to an array, imho.


I'm quite aware of that, and in this case I'm using it in a one-off  
string-and-glue fix for a specific problem until I fix it properly.  
The original question wasn't whether it was a good idea or not, but  
that it didn't act as the docs said it did. In the mean time, you  
might like to know that this behaviour IS apparently considered  
correct and a patch to documentation has been committed.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-24 Thread Marcus Bointon

On 24 Sep 2006, at 22:07, Ray Hauge wrote:


Maybe you missed it, but he did submit a bug report:

http://bugs.php.net/?id=38935

He just wanted to see if other people had run into a similar  
situation before
submitting the bug... from my understanding.  I don't want to put  
words in

Marcus' mouth


Yup (and thanks), that was exactly my intention. Initially I wasn't  
sure that I was not doing something wrong, or seeing interference  
from XDebug etc. It's hard enough getting a PHP bug report accepted  
at all, so I try to make sure that it's very, very clear. I'm quite  
used to getting 'bogusbotted' by now - you seem to have to fight for  
every bug, in code or documentation. I appreciate that the  
maintainers have to deal with a lot of crap, and I make an effort not  
to waste their time (e.g. by reading docs, searching archives,  
posting on -users, as they suggest), but occasionally they just don't  
read the report - in this case I was referred to the documentation,  
which agrees 100% with my complaint!


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-24 Thread Marcus Bointon

On 24 Sep 2006, at 01:09, Robert Cummings wrote:


It's broken, it doesn't preserve references.


B = $a;
var_dump(object2array($b));
?>

array(3) {
  ["A"]=>
  NULL
  ["B"]=>
  object(B)#1 (4) {
["A:private"]=>
NULL
["B"]=>
NULL
["c:protected"]=>
NULL
["A:private"]=>
NULL
  }
  ["c"]=>
  NULL
}

Reference preserved. It's not like I care about PHP4, nor am I doing  
a deep conversion.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-24 Thread Marcus Bointon

On 24 Sep 2006, at 01:05, Robert Cummings wrote:

Blah, blah, blah. The documentation is probably out of date and  
applied
to PHP4. Feel free to get off your arse and volunteer if you don't  
like

it >:) You don't get have your cake and eat it *PTHTHTHTHTTHTHTH*


How exactly am I not helping by pointing out there's a problem in the  
first place? It's a lot more constructive than being rude.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon
I've written a function that does a conversion that matches the docs,  
based on the other info I've mentioned:


/**
* Clean up the name munging that PHP applies while casting from  
object to array
* The resulting array looks like what the documentation says that  
(array)$object delivers, but actually doesn't

* @param object $object The object to convert
* @return array
*/
function object2array($object) {
$class = get_class($object);
$array = (array)$object;
$propArray = array();
$matches = array();
foreach ($array as $key => $value) {
		if (preg_match('/^\0(([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\0 
([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$/', $key, $matches)) {

//It's a private property
if ($matches[1] == $class) { //Ignore private props of 
superclasses
$propArray[$matches[2]] = $value;
}
		} elseif (preg_match('/^\0(\*)\0([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f- 
\xff]*)$/', $key, $matches)) {

//It's a protected property
$propArray[$matches[2]] = $value;
} else {
//It's a public property
$propArray[$key] = $value;
}
}
    return $propArray;
}

Works nicely for me.

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon


On 23 Sep 2006, at 18:54, Jon Anderson wrote:


If you just want an array of properties, add this to your class...


That's exactly the kind of thing I was on about. Since reflection  
gives access to all this information, why bother trying to squeeze  
the same info into an array-shaped container that just can't hold all  
the same info without corrupting it? I can see that there might be  
some reason for converting the object with additional information in  
some circumstances (much like serialization to strings does), but  
here we're only talking about casting, which should be a 'best-fit'  
data matter. The behaviour we've got would be better served with a  
function like toArrayPreservingClassInfo() rather than the default  
casting behaviour.


Since reporting the bug (which was immediately marked as bogus; go  
figure), I've had something else brought to my attention: The  
resulting array keys are not what they seem! Their actual structure is:


NULLNULL

So, here we have undocumented behaviour justified by yet more  
undocumented behaviour! How behaviour so wildly different to what's  
documented is not considered a bug I don't know. At least this format  
can be dismantled reliably, rather than trying to string-match class  
names. I think trying to preserve this information (as you said) is  
entirely pointless - it's not as if you can cast back from an array  
to an object, and I can't think of any circumstances in which it is  
preferable to using reflection (unless it's a relic from PHP4?).  
What's next - appending a creation time to integers when they're cast  
into strings?


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon

On 23 Sep 2006, at 16:46, Robert Cummings wrote:


And the likelihood of you having a property called Myclassfield1 is?


Sure, but don't you think that coding should at least try to be  
driven by logic rather than luck? I'm also not denying that it's not  
too hard to work around (with a function not dissimilar to what you  
suggested), but I'd really prefer it if it just did what it says on  
the tin. By its very nature, casting from object to array indicates  
that you no longer want the constraints of property protection, which  
an array can't preserve anyway, and it's not as if there are not  
intentional, documented methods of obtaining this information.



It sounds like they've helped out by giving more data than was
necessary.


...and in doing so defaults to breaking code that expects it to  
behave like the documentation says it does? I don't think I'd  
classify that as helping out. Bear in mind that my code broke in  
exactly this way. If you want to find out what the access level of a  
property is, I doubt your first thought would be to convert it to an  
array - and I bet you didn't know that this info was even there  
because it's not documented, thus helping nobody. This is what  
introspection is for. I don't have a problem with being provided with  
extra information, just as long as it doesn't interfere with correct  
operation, which is what it currently does. It could provide the  
extra info in a marginally less destructive way, for example by  
adding 'private' and 'protected' array properties containing field  
names for each access level to the resulting array. OTOH, that would  
break what you'd expect count() to deliver after the conversion. I  
really think it should just do what's it's meant to, and no more.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon

On 23 Sep 2006, at 16:37, Ray Hauge wrote:


Could you do something like this?

$private = "Myclass"
$protected = "*";


No, because if I have a property called 'Myclassfield1', after  
casting to an array I can't tell if it's private property called  
'field1' or a public property called 'Myclassfield1'.


I think it's just plain wrong. Arrays should not try to be objects.  
You can find out protection level of a property via introspection of  
the object that you have in hand. In the vast majority of cases,  
you'll want it to act just like the docs say it does, and if you  
don't, you should probably be using the object itself anyway.


Bug report is here: http://bugs.php.net/?id=38935

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon

Here's a more accurate example:



This produces:

object(Myclass)#1 (3) {
  ["field1"]=>
  string(0) ""
  ["field2:private"]=>
  string(0) ""
  ["field3:protected"]=>
  string(0) ""
}
array(3) {
  ["field1"]=>
  string(0) ""
  ["Myclassfield2"]=>
  string(0) ""
  ["*field3"]=>
  string(0) ""
}

So it seems protected fields behave differently too.

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon

On 23 Sep 2006, at 15:51, Ray Hauge wrote:


To me it looks like they append the name of the class to any private
variables.  I would guess that it does this to make sure you know  
what you're
doing and using the private variable like that.  I'm  just guessing  
at that

point though.


Well, I realised that, but it's not very helpful as there's no  
separator between class name and variable name it's impossible to  
separate it correctly - if I had happened to have a property called  
'myclassfield1', I would not be able to tell if the real property  
name was 'myclassfield1' or a private property called 'field1'. If it  
is going to stray from the documented behaviour, It would be far more  
useful to retain the names that the var_dump on the object uses -  
'field1:private'. That's safe as : is not a value char in a variable  
name, but it's fine as an array index.


Try a test with multiple public and multiple private variables.  If  
the format

of the array keys stays the same, then you should have your answer.


In my real code I do have multiple fields all exhibiting this  
behaviour. I'll report it.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



[PHP] Object to array conversion oddity

2006-09-23 Thread Marcus Bointon

A simple class like this:

class Myclass() {
public $field1 = '';
private $field2 = '';
public function __sleep() {
  return array('field1', 'field2');
}
}
$myclass = new Myclass;

If I var_dump this, I get:

object(Myclass)#6 (2) {
  ["field1"]=>
  string(0) ""
  ["field2:private"]=>
  string(0) ""
}

If I coerce this to an array:

$arr = (array)$myclass;

the properties change names in a most unhelpful way:

array(2) {
  ["field1"]=>
  string(0) ""
  ["Myclassfield2"]=>
  string(0) ""
}

The docs (http://www.php.net/manual/en/language.types.array.php) say:

"If you convert an object to an array, you get the properties (member  
variables) of that object as the array's elements. The keys are the  
member variable names."


It seems that's not quite true.

How can I stop it doing this? Looks a bit buggy to me.

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Recommendations for PHP debuggers?

2006-08-21 Thread Marcus Bointon

On 21 Aug 2006, at 04:55, Dave M G wrote:


So I'm looking around for other debugging options.


One oft-overlooked option: xdebug.org. It enhances PHP's built-in  
debugging features enormously, adds profiling, trace and coverage  
logging, remote debugging too. The improved readability of stack  
traces alone makes it worthwhile IMHO.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/

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



Re: [PHP] Re: loop in horizontal direction (php-html)

2006-08-10 Thread Marcus Bointon

On 10 Aug 2006, at 16:39, Al wrote:


s don't need to be terminated with s


That is, assuming you don't want your pages to validate. As closing  
your tags is so trivially easy, it's really not worth not doing! I  
recently encountered a site that contained 3500 unclosed font tags on  
a single page; This is a very good way of making a browser go very  
slowly and eat lots of memory.


Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/



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



Re: [PHP] $_SERVER['REMOTE_ADDR'] arriving in IPv6

2006-05-18 Thread Marcus Bointon

On 18 May 2006, at 21:11, Stut wrote:

The value in that variable is coming from the web server not PHP. I  
suggest you change the web server configuration so it's listening  
on specific v4 IPs only rather than all IPs. See the docs for your  
web server for details on how to do that.


Yup, that was it, thanks. It appears that Apache 2 on OS X listens on  
IPv6 by default. To force it to listen on IPv4 only, change the  
default listen directive in httpd.conf to look like this:


Listen 0.0.0.0:80

Here's the reference: http://httpd.apache.org/docs/2.0/bind.html

Worked a treat for me.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] $_SERVER['REMOTE_ADDR'] arriving in IPv6

2006-05-18 Thread Marcus Bointon
I'm running PHP 5.1.4 on OS X. When I look at $_SERVER 
['REMOTE_ADDR'], it seems to contain an ipv6 address rather than an  
ipv4 one (at present it's giving me 'fe80::1' instead of the usual  
dotted quad), and that confuses the hell out of things like MySQL's  
INET_ATON() function. I have ipv6 networking disabled in my network  
control panel, and my PHP is configured with --disable-ipv6. How can  
I force it to return only ipv4 addresses? Is there an ini setting  
somewhere?


Thanks,

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: SimpleXML is creating nodes when it shouldn't...

2006-05-12 Thread Marcus Boerger
Hello D.,

  SimpleXML was never ever designed to have methods. If you prefer methods
then you probably might be better with xmlReader or Dom. Either way i *may*
do something about it. Right now it perfectly fits my needs :-)

best regards
marcus

Friday, May 12, 2006, 5:42:23 PM, you wrote:

> Marcus Boerger wrote:
>>> I think that's a bug and not a feature.  Why was this changed?
>>> 
>> It is called write support. I think we are going to add a flag
>> so that one can specify whether write support is enabled or not.
>>   

> Creating data without using '=' assignment or calling a function is 
> scary and somewhat 'magical' behavior.  When I 'read' from a SimpleXML 
> node and cast that read into an array context, I NEVER expect to 
> actually create an array on the object I am reading from.  If I do a SET 
> (__set), I'd be ok with the magical behavior:

> $xmlstr = "1";
> $xml = simplexml_load_string($xmlstr);
> $xml->nonexist = array();

> But if I'm doing a GET, changing the structure of the object is very bad:

> foreach ($xml->nonexist2 as $nonexist2) {
> }

> Adding a flag is fine and all, but I definitely don't want that flag to
> be inside an INI file.  We don't need yet another flag which causes the
> language to behave differently under different circumstances.  Can't you
> distinguish between __get and __set on the object and handle it
> differently that way?  If not, the flag needs to somehow be set in code
> and not in an INI file with the default behavior to be NO, do not enable
> write support.  This is a bad break in BC from such a minor version upgrade 
> of 5.1.2 to 5.1.4.

> Dante






-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

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



[PHP] Re: SimpleXML is creating nodes when it shouldn't...

2006-05-12 Thread Marcus Boerger
Hello D.,

Friday, May 12, 2006, 5:29:42 AM, you wrote:

> I've recently upgraded to PHP 5.1.4 from 5.1.2 and noticed that in 5.1.3 
> there were changes made to SimpleXML.  Now, when I touch an element 
> which didn't used to exist, instead of acting like it didn't exist, it 
> creates it!  That's horrible!

> Well, this used to work:

>  $xmlstr = "1";
> $xml = simplexml_load_string($xmlstr);
> print_r($xml);

> foreach ($xml->nonexist as $nonexist) {
> // do nothing
> }
> print_r($xml);
?>>

> But now, the output of the print_r is different when I do it the second 
> time because the foreach statement created nodes:

> SimpleXMLElement Object
> (
> [item] => 1
> )
> SimpleXMLElement Object
> (
> [item] => 1
> [nonexist] => SimpleXMLElement Object
> (
> )
> )

> I think that's a bug and not a feature.  Why was this changed?

It is called write support. I think we are going to add a flag
so that one can specify whether write support is enabled or not.

-- 
Best regards,
 Marcusmailto:[EMAIL PROTECTED]

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



[PHP] colored text in images

2006-03-24 Thread Marcus Gnaß

Hi list!

I like to generate a larger image from different tiles. Each tile should 
have a text on it which should be red for better readability. I figured 
out how to compose the larger image but got stuck when to color the 
text. I tried the following code:


$img = imagecreate($w * 100, $h * 100);
$tile = imagecreatefromgif($tile_name);
$red = imagecolorallocate($tile, 255, 0, 0);
imagestring($tile, $font, $gebilde_x, $gebilde_y, $gebilde, $rot);
imagecopy($map, $tile, $dst_x, $dst_y, 0, 0, imagesx($tile), 
imagesy($tile));

header("Content-Type: image/gif");
imagegif($map);

The text was writte an expected, just it was grey and not red. What do I 
have to do to make it read and why was it grey?


Marcus

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



[PHP] Beware of OS X PHP security update...

2006-03-03 Thread Marcus Bointon
The OS X security update issued yesterday includes a PHP 'fix', by  
which they mean that it installs PHP 4.4.1. If you have installed PHP  
5 from elsewhere, it will get trashed along with your PEAR setup.  
PEAR is now completely confused or me and just crashes when I try to  
do anything.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] Compiling PHP with freetype2 on MacOS X

2006-02-24 Thread Marcus Bointon
Recently I've not been able to compile PHP 5.1.2 on OS X 10.4 with gd  
and freetype2 support. I've found various threads on this, but none  
of the proposed fixes work. My configure line includes:


--with-gd=/sw --with-freetype-dir=/sw/lib/freetype2 --with-t1lib=/sw

It doesn't report any problems when configuring:

...
checking for GD support... yes
checking for the location of libjpeg... /sw
checking for the location of libpng... /sw
checking for the location of libXpm... no
checking for FreeType 1.x support... /sw
checking for FreeType 2... /sw/lib/freetype2
checking for T1lib support... /sw
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for jpeg_read_header in -ljpeg... (cached) yes
checking for png_write_image in -lpng... (cached) yes
If configure fails try --with-xpm-dir=
checking for FreeType 1 support... no - FreeType 2.x is to be used  
instead

checking for T1_StrError in -lt1... (cached) yes
checking for gdImageString16 in -lgd... (cached) yes
checking for gdImagePaletteCopy in -lgd... (cached) yes
checking for gdImageCreateFromPng in -lgd... (cached) yes
checking for gdImageCreateFromGif in -lgd... (cached) yes
checking for gdImageGif in -lgd... (cached) yes
checking for gdImageWBMP in -lgd... (cached) yes
checking for gdImageCreateFromJpeg in -lgd... (cached) yes
checking for gdImageCreateFromXpm in -lgd... (cached) yes
checking for gdImageCreateFromGd2 in -lgd... (cached) yes
checking for gdImageCreateTrueColor in -lgd... (cached) yes
checking for gdImageSetTile in -lgd... (cached) yes
checking for gdImageEllipse in -lgd... no
checking for gdImageSetBrush in -lgd... (cached) yes
checking for gdImageStringTTF in -lgd... (cached) yes
checking for gdImageStringFT in -lgd... (cached) yes
checking for gdImageStringFTEx in -lgd... (cached) yes
checking for gdImageColorClosestHWB in -lgd... (cached) yes
checking for gdImageColorResolve in -lgd... (cached) yes
checking for gdImageGifCtx in -lgd... (cached) yes
checking for gdCacheCreate in -lgd... (cached) yes
checking for gdFontCacheShutdown in -lgd... (cached) yes
checking for gdFreeFontCache in -lgd... (cached) yes
checking for gdNewDynamicCtxEx in -lgd... (cached) yes
checking for gdImageCreate in -lgd... (cached) yes

but when I make:

/Users/marcus/src/php-5.1.2/ext/gd/gd.c: In function 'zm_info_gd':
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:505: error: 'FREETYPE_MAJOR'  
undeclared (first use in this function)
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:505: error: (Each undeclared  
identifier is reported only once
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:505: error: for each function  
it appears in.)
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:505: error: 'FREETYPE_MINOR'  
undeclared (first use in this function)

/Users/marcus/src/php-5.1.2/ext/gd/gd.c: In function 'php_imagechar':
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:2817: warning: pointer  
targets in passing argument 1 of 'strlen' differ in signedness
/Users/marcus/src/php-5.1.2/ext/gd/gd.c: In function  
'php_imagettftext_common':
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:3197: warning: pointer  
targets in passing argument 4 of 'gdImageStringFTEx' differ in  
signedness
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:3197: warning: pointer  
targets in passing argument 9 of 'gdImageStringFTEx' differ in  
signedness
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:3203: warning: pointer  
targets in passing argument 4 of 'gdImageStringFT' differ in signedness
/Users/marcus/src/php-5.1.2/ext/gd/gd.c:3203: warning: pointer  
targets in passing argument 9 of 'gdImageStringFT' differ in signedness

make: *** [ext/gd/gd.lo] Error 1

Those undefined constants sound like it's missing a header file  
somewhere.


I've also tried using the built-in freetype2 lib using --with- 
freetype-dir=/usr/X11R6 but that gives me the same error. I've also  
tried using the bundled gd lib, again I get the same error. I've cut  
my configure line down to just the options for the environment, gd  
and freetype. I've looked in /sw/lib/freetype2/include/freetype2/ 
freetype/freetype.h and the missing constants are correctly defined  
in there, and also in /usr/X11R6/include/freetype2/freetype/ 
freetype.h Those files should be found using the paths I gave in  
configure.


Anyone got any idea how I can fix this?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Recompile PHP on pre-installed system

2006-02-07 Thread Marcus Bointon

On 7 Feb 2006, at 11:13, Jochem Maas wrote:

in theory your done, in practice something might bite you in the  
ass ...
oh and then there is the issue of making sure that the redhat  
package manager really
won't overwrite your handbuilt php install (cannot for the life of  
me remember what you have

to do to make redhat ignore the php install).


This might be of help: http://www.ae.iitm.ac.in/pipermail/ilugc/2005- 
August/020152.html


You can edit those srpms to include whatever configure line switches  
you need.


I run RHEL4, and my own compile of PHP, set up outside of rpm. You  
only need to worry about rpm getting confused if you use it to  
install any packages that are dependent on php, e.g. squirrelmail.  
Essentially either do ALL of your PHP setup and install through rpm  
or none of it. I'm quite happy handling PHP myself, and conflicts are  
rare as php is rarely a dependency for apps installed through rpm.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] mail() and Return-Path header

2006-02-06 Thread Marcus Bointon

On 2 Feb 2006, at 13:00, Søren Schimkat wrote:

I'm using the mail function for sending mail, and I would like to  
specify the
Return-Path header, but it would seem that PHP or Apache is  
modyfying the

header.


Strictly speaking, you should not set a return-path header at all.  
You should set a 'sender' header, and the return-path header will be  
generated for you by your MTA. The reason for this is that a message  
may gain multiple return-path headers on its journey so that its full  
path can be traced backwards to the source. The common exception to  
this is if you're on Windows and don't have a local MTA (or on any  
platform and have PHPMailer's IsSMTP set), and your script is sending  
directly via SMTP and thus IS the MTA.


If you want to do proper bounce handling, you should also look into  
VERP addressing, as it's the only way to guarantee that you get  
tracable bounces - MS Exchange server sometimes bounces messages with  
no indication of the address the original message was sent to!


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Wysiwyg editors?

2006-02-01 Thread Marcus Bointon

On 1 Feb 2006, at 07:45, William Stokes wrote:


I once tested htmlarea (http://www.htmlarea.com/) and I think thats


I'd recommend fckeditor and tinymce over htmlarea. Both seem to have  
much more active development, not least that they're both trying to  
get it working in Safari. fckeditor is working great for me from PHP.


http://www.fckeditor.net/
http://tinymce.moxiecode.com/

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Class constructor

2006-02-01 Thread Marcus Bointon


On 31 Jan 2006, at 13:52, David Grant wrote:


Drop __construct, PHP5 will call Test() anyway.

From http://uk.php.net/manual/en/language.oop5.decon.php:

"For backwards compatibility, if PHP 5 cannot find a __construct()
function for a given class, it will search for the old-style  
constructor

function, by the name of the class."


Sure, if you're planning on writing 'backwards' code for ever more...  
For maximum efficiency in PHP5, do it this way around:


class test{
function Test(){
$this->__construct()
//This will be called in PHP4
}
function __construct(){
//This will be called in PHP5
}
}

Why penalise the platform you're intending to run it on?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] HTML rendering extension?

2005-12-21 Thread Marcus Bointon

On 21 Dec 2005, at 18:17, Richard Lynch wrote:


At least I *think* it was called "webthumb"...

Maybe from the GD folks???

It's out there somewhere, and I was going to look into it, but...

You'd feed it a URL and it gives you an image.  You need X installed,
so it can run X in the background and render it.


It is indeed called webthumb: http://www.boutell.com/webthumb/

After installing firefox on my server, tweaking webthumb to use  
firefox instead of Mozilla, a bit of messing with xauth settings, and  
I've got it working! It seems like a more polished alternative to  
html2jpg. It uses Xvfb for a local display so you don't need a real  
one, and it doesn't interfere with remote X sessions, though firefox  
complains if you try to run it on both X displays at once. Now I just  
need to go find a borderless chrome package for ff...


khtml2jpg is definitely a more advanced solution as it contains its  
own browser and is thus not limited by screen size - you could grab a  
page 10,000 pixels tall if you wanted to - and it can monitor browser  
state e.g. so it can know when all images are loaded instead of just  
waiting for a bit. Flipside - it's not working for me...


Thanks very much for the tip, very glad to have finally found a  
solution.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] HTML rendering extension?

2005-12-21 Thread Marcus Bointon

On 21 Dec 2005, at 21:18, M wrote:


http://marginalhacks.com/Hacks/html2jpg/


That's the kind of marginal hack I was hoping to avoid ;^) However,  
it did lead me to http://khtml2png.sourceforge.net/ which seems far  
more like it. Now I just have to persuade it to compile.


Thanks.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] HTML rendering extension?

2005-12-21 Thread Marcus Bointon
Has anyone seen such a thing? I'm looking to be able to generate web  
page previews dynamically and automatically, so I need to render the  
page on the server. The most efficient way would be if there was a  
PHP HTML rendering extension - gecko or KHTML perhaps. HTML2PDF  
doesn't go nearly far enough. Alternatively something like a CLI  
option to firefox to run without X (i.e. no visible windows) and  
output to a file instead of a display device. The options here don't  
indicate that it can do that:


http://kb.mozillazine.org/Command_line_arguments

Any other ideas?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] forking off in php

2005-11-21 Thread Marcus Bointon

On 21 Nov 2005, at 17:47, Jay Blanchard wrote:


It would have been nice to see your command line. Add '&' i.e.


You don't need to do that - the forking script will start, spawn a  
child process then exit, so adding & will do nothing. Having said  
that, you could achieve something similar by not forking and using  
nohup (look it up with man) with &, however, that will mean it runs  
as you, whereas a forked process can easily switch users and drop  
privileges for increased security.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] forking off in php

2005-11-21 Thread Marcus Bointon

On 21 Nov 2005, at 17:39, matt VanDeWalle wrote:


I have what may seem like a small problem but its not obvious to me.
I have a script that I forked and that part works fine, it forks,  
tells me the pid like I wanted, and keeps running.  Well, the  
problem that was not apparent to me until about 3 days ago when I  
was wondering why the script(my php chat server) was crashing at  
seeminly random times.  I finally  figured out that when I logged  
out of my shell in linux, the talker would go down as well.   
Obviously I don't want that but what do I need to add to the line  
when i start the script


Example1 on the php docs page is what you need:

http://www.php.net/manual/en/ref.pcntl.php

The important thing is the call to posix_setsid(), which detaches  
your forked process from your terminal process. Works great for me -  
I've had PHP daemons running for over 9 months without a break.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] using ($test)?$true:$false in a string

2005-11-21 Thread Marcus Bointon

On 21 Nov 2005, at 15:43, Jochem Maas wrote:


using sprintf() is
such a simple case may be excessive BUT I was merely introducing  
the OP to

something new (possibly) - anyone asking such 'simple' questions is
not at a stage that this kind of efficiency is an issue (i.e. give
them 'whats possible' before telling them 'whats best')


sprintf is also a good example of a different way of thinking about  
string interpolation, and what's more it's remarkably close to the  
whole concept of using prepared statements in SQL, a measure that can  
gain you both speed and security, plus it's supported very nicely in  
PDO in PHP 5.1. A tangent I know, but a useful one nonetheless. Hey,  
and I remember when "print using" was considered a 'power user'  
feature in BASIC in 1981!


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Sorting users geographically...

2005-11-21 Thread Marcus Bointon


On 21 Nov 2005, at 14:14, Tony Di Croce wrote:

Does anyone know of any commercial or free implementations of this?  
Is it

primarily a database problem or is their some way (computationally) to
compute the probable proximity of two zip codes?


All the suggested packages could be all you need, but also note that  
MySQL 5 has built-in GIS features which may make searches like these  
way more efficient should they use them:


http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions-in-mysql.html
http://dev.mysql.com/doc/refman/5.0/en/functions-that-test-spatial- 
relationships-between-geometries.html


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: PHP 4.4.1 on Apache 2.0.x issue

2005-11-21 Thread Marcus Bointon

On 20 Nov 2005, at 15:14, Geert Booster wrote:


  PHP 4.4.0, since PHP developers seem not interested in
  fixing the bug with apache2 and mod_rewrite


I think you might find this bug report of interest, especially since  
it's been fixed: http://bugs.php.net/bug.php?id=35059 It's certainly  
fixed things for me.


Derick's 4.4.2RC1 release note a couple of days ago:

On 18 Nov 2005, at 11:58, Derick Rethans wrote:

I packed PHP 4.4.2RC1 today, which you can find here:
http://downloads.php.net/derick/ . Windows binaries will follow  
shortly.


Please test it carefully, and report any bugs in the bug system, but
only if you have a short reproducable test case.

If everything goes well, we can release it next tuesday. Especially  
test

issues with mod_rewrite and Apache 2 please!


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] APC caching keys.

2005-11-21 Thread Marcus Bointon

On 21 Nov 2005, at 10:54, Jochem Maas wrote:

having said that I don't use __autoload() - I did but it was just a  
PITA -


I thought it was a good idea for a while... One major irritation with  
it is that with standard error reporting you can't tell where a  
missing class can't be found from (it is reported as having come from  
your __autoload function). You need a stack trace to figure out where  
the original problem occurred - xdebug works a treat (but it won't  
mix with APC).


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] using ($test)?$true:$false in a string

2005-11-21 Thread Marcus Bointon


On 18 Nov 2005, at 20:13, Dylan wrote:


$var = "first part of string ".(($a==$b)?$c:$d)." rest of string";

and I feel it would be more elegant to be able to do something like:

$var ="first part of string {(($a==$b)?$c:$d)} rest of string";


Strange as it may seem, you'll probably find that this is the fastest  
method:


'first part of string '.(($a==$b)?$c:$d).' rest of string'

I benchmarked this a while ago and was surprised to find that  
multiple concats with single quotes are significantly faster than  
interpolation.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] php5 call by refference

2005-11-21 Thread Marcus Bointon

On 21 Nov 2005, at 09:26, Georgi Ivanov wrote:


AFAIK, in PHP5 one can't call function with function parameters .
The error is that you only can pass variables by reference.
foo(strlen('aaa'),strlen(''));


You can call functions like that without problems UNLESS the function  
is expecting values by reference, i.e. results are passed back  
through the parameters. If you supply a function result, then you may  
as well not be calling the function as you'll never be able to get a  
result back from it, hence the error message. e.g.


function foo(&$a, $b) {
$a = $a.$b;
}

If you call this as you asked, where would the result go?


Is there some sort of workaround ?


As was suggested, put your values in variables before calling the  
function, though the code example you posted suggests you're trying  
to do something odd.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] APC caching keys.

2005-11-21 Thread Marcus Bointon

On 19 Nov 2005, at 04:07, Curt Zirzow wrote:


If you are using mysql i would use the SQL_CACHE flag, it will
eliminate the need for you to manage the cache.


You don't necessarily need to us the SQL_CACHE flag in queries - you  
can just turn on the query cache globally using query_cache_type=1 in  
your my.cnf. Otherwise I quite agree - and MySQL has the huge  
advantage that it will work very nicely across multi-server deployments:


http://dev.mysql.com/doc/refman/5.0/en/query-cache.html


The last version of php5.1 i have installed APC on is a cvs
snapshot of around Feb 4 2005 11:49:05. Nothing special was needed.


The current 3.0.8 release of APC is broken in PHP 5.1.0-dev if you  
ever use __autoload. It will be fixed in 3.0.9 (and is fixed in CVS),  
though Rasmus implied that 3.0.9 is waiting until 5.1 release.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] mod_rewrite and include paths

2005-11-21 Thread Marcus Bointon
I found the source of my mod_rewrite problems. I was doing everything  
right to start with - The odd behaviour was due to a PHP bug (http:// 
bugs.php.net/bug.php?id=35059) that's fixed in 4.4.2-dev and 5.1.0RC7- 
dev (I'd assume 5.0.x as well). Recompiling with a new checkout works  
fine.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Set Timezone to localtime in php.ini

2005-11-18 Thread Marcus Bointon

On 16 Nov 2005, at 04:49, The Doctor wrote:


IS their a way to set the time to localtime instead of GMT in
the ini file?

Some users are complaining that they are seeing GMT, which this server
is set to.


If you use PHP 5.1, yes: http://www.php.net/manual/en/ref.datetime.php

Note the new date.timezone ini setting.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Is echo tag reasonably portable?

2005-11-18 Thread Marcus Bointon

On 15 Nov 2005, at 19:53, Robin Vickery wrote:


I doubt very much if they will be disabled. They are perfectly valid
SGML processing instructions.


Firstly, I didn't actually suggest they were disabled. I suggested
that they should be off by default.


Late to the party I know, but I think something has been missed here.  
Here's an excerpt from php.ini-recommended in a fresh download of PHP:


; Allow the  tags are  
recognized.
; NOTE: Using short tags should be avoided when developing  
applications or

; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off

Given most ISPs habit of leaving everything at defaults, I'd say this  
pretty much puts paid to using short tags.


Admittedly it is on in php.ini-dist, but that's not recommended is  
it ;^)


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Newbie to PHP5

2005-11-15 Thread Marcus Bointon

On 15 Nov 2005, at 10:06, Danny wrote:

 I´m familiar with PHP syntax, but I´ve been reading some sample  
scripts, in

PHP5 and i´ve seen some "strange" things, like diferent ways to read a
collection of rows, magic functions, wrapers, and operators like  
"::" and
"->". I know that all is the manual, but before that anyone nows, a  
website
or a simple tutorial or explained samples, in order that the  
transition from

PHP4 and PHP5 were easiest as possible.


Many of the things you mention are not new in PHP5. This will help:

http://www.zend.com/php5/migration.php

If you want a book:

http://www.oreilly.com/catalog/upgradephp5/

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Printing to a buffer

2005-11-14 Thread Marcus Bointon

On 14 Nov 2005, at 19:01, Richard Lynch wrote:


It may not be my final choice whether they download or not, but if a
browser doesn't treat:
application/octet-stream
as a download, and only as a download, then that browser is pretty
broken.

Letting the user configure their browser for that MIME type to be
opened by an application is just plain wrong for a browser, by
specification.

If you find a browser that lets you configure application/octet-stream
to be opened with a specific application, then file a bug report with
whomever wrote that browser.


There's no such spec for browsers per se (which is why they vary so  
much) - they are just HTTP clients. I can think of a perfectly  
reasonable situation where I would want a plugin to handle  
application/octet-stream - say I'm pulling some arbitrary binary data  
and while I'm debugging, an in-browser hex dump could be very useful.  
The other thing is that I may be being forced to use that 'wrong'  
MIME type to work around bad implementations of content- 
disposition... I know that's not a common situation, but there should  
be nothing preventing me from doing it. There are browsers that don't  
do downloads at all (I've written some), there are others that do  
nothing but downloads (I use Interarchy for just that). I could offer  
a similar opinion about the browsers that have odd implementations of  
content-disposition.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] mod_rewrite and include paths

2005-11-14 Thread Marcus Bointon


On 14 Nov 2005, at 18:51, Richard Lynch wrote:


include_path("/full/path/to/DocumentRoot:" . include_path());
This may not be the right syntax/function to set include_path, but it
is a dynamic way to set the include path, from within PHP.


Yup, I tried this and it kind-of works, but still leads to some weird  
behaviour.



INSTEAD, do this.

Create a PHP script, and name it 'x'

In .htaccess, force 'x' to be PHP as far as Apache is concerned:

  ForceType application/x-httpd-php


You can now access your "x=123" from $_SERVER['PATHINFO'] (or is it
'PATH_INFO'?

No more endless tweaking of Regex rules in httpd.conf and logging the
mod_rewrite and dinking with ^/[0-9]+ junk and re-starting Apache
every time you want to try a change.


That's a nice trick - I'll have to remember that. My rules are  
in .htaccess (as seems normal for 'deployable' systems) so I don't  
need to restart apache and it's easy to twiddle with them, and  
besides, I like regexes ;^) The issue isn't really the passing of  
parameters (which your approach deals with very nicely), it's that  
PHP gets fooled into thinking that it's somewhere that it's not. The  
most annoying thing about this problem is that I'm sure it should  
'just work', and I know I've seen it do so before in both my scripts  
and others - Serendipity has an almost identical setup for rewrites  
and it doesn't do anything special to work with them - all this  
futzing with paths that mod_rewrite does is long finished by the time  
that PHP gets to hear about anything - PHP never has to know the real  
URL, it should be happy to deal with the rewritten one.


The problem seems to be that given the incoming URL:

/x/123

this gets rewritten to

/x.php?x=123

and it does run the correct script in the correct directory, however,  
once it's running PHP acts as if it had said:


/x/x.php?x=123

Which just breaks paths everywhere. I know that this is what the  
passthrough option is supposed to deal with, but removing it doesn't  
help either. Maybe I should look more carefully at my RewriteBase etc.


I've asked in sitepoint apache forums too, see if anyone there has  
any idea.


Thanks for the ideas.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] mod_rewrite and include paths

2005-11-13 Thread Marcus Bointon

On 13 Nov 2005, at 22:15, Marco Kaiser wrote:

try to use realpath, dirname and other related funktion to resolv  
the real path.


dirname(__FILE__) ?


Good point (you can tell I've been up too long). I've just had a play  
with that - I appended the current path to my include_path, but it  
seems it's not inherited, so sub-includes are not found. I also tried  
chdir(dirname(__FILE__)) which had the same results and interferes  
with the operation of require_once (the same file found by a  
different path doesn't get counted as the same file). Incidentally  
doing just 'echo getcwd();' seems to fail completely when called via  
a rewrite. After all that, smarty still can't find its templates_c  
for some reason. I'm sure there must be something simple and elegant  
I'm missing. Probably a good night's sleep.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] mod_rewrite and include paths

2005-11-13 Thread Marcus Bointon

This seems like a simple problem...

I have a rewrite like this:

RewriteRule ^x/([0-9]+) x.php?x=$1 [PT,L]

This maps a url like http://www.example.com/x/123 to http:// 
www.example.com/x.php?x=123


x.php contains a line to include some class like:

require_once 'x.class.php';

My include path contains '.' (plus paths to pear, etc), and the class  
file is in the top level directory.


This configuration will fail with a file not found error. Because of  
the rewrite, PHP ends up looking for x/x.class.php instead of just  
x.class.php. If I change the PT option to R (AKA ugly mode), it works  
fine as PHP gets to know about the real URL.


So how can I get PHP to look in /? I can set include_path with a  
php_value in .htaccess, but I can only set it absolutely (losing  
existing values), not add to it (AFAIK?). I don't want to add an  
absolute path to my global include_path as there may be multiple  
independent deployments of the same scripts on the server, and I  
don't want them including each others files. Adding .. to the path  
would work but is a security risk. Any other ideas?


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Printing to a buffer

2005-11-13 Thread Marcus Bointon

On 13 Nov 2005, at 19:27, Jasper Bryant-Greene wrote:


Many thanks!  I did not know that MIME-Type.  Change duly made!


You're not suggesting that you actually set the MIME-Type to  
application/force-download, are you?


I think he is. I've called the MIME-type police and they'll be round  
later.


Todd, I think you should read this: http://support.microsoft.com/kb/ 
q260519/


There's a PHP example just before the user notes here: http:// 
www.php.net/header


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Printing to a buffer

2005-11-13 Thread Marcus Bointon


On 13 Nov 2005, at 00:17, Jasper Bryant-Greene wrote:

seem to do that.  I just tried "application/text" since I use  
"application/pdf" for other applications.


Whatever it's giving the user the ability to do, it's probably  
because the browser doesn't recognise the (invalid) MIME-Type.


Quite - it's right up there with 'application/force-download'. If you  
want to suggest (the final choice is not yours to make) that a  
browser might download something instead of displaying it, set an  
appropriate content-disposition header instead of setting the wrong  
type.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Recommendations for the Zend PHP Certification

2005-11-13 Thread Marcus Bointon

On 12 Nov 2005, at 16:29, Gustavo Narea wrote:


  - Zend PHP Certification Study Guide.


This book would be good if it were not so full of errors. With a bit  
of luck it's been revised since my edition (July 2004 printing); I  
noticed quite a few problems and then found a huge errata list on  
their site.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] php session in ie

2005-11-11 Thread Marcus Bointon

On 11 Nov 2005, at 11:43, sunaram patir wrote:


 it works fine in firefox and msn explorer. in internet explorer, when
i visit to a
link in any page it asks for the login details again. could anyone
please help me out?!


It just sounds like you have cookies disabled or not allowed for this  
site in IE.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] mod_rewrite, apache2, php5RC1 and osx bsd

2005-11-11 Thread Marcus Bointon

On 10 Nov 2005, at 21:36, Richard Lynch wrote:


On Wed, November 9, 2005 10:36 pm, Dan Rossi wrote:

RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.+\.(video))$
../../phpscript.php


I should think all those .* should be .+ instead...

I mean, if somebody surfs to this URL:

http://example.com//example.video


There's nothing really wrong with a URL like that, and I used to do  
the same thing until I discovered another fly in this particular  
ointment. Should source URLs like these ever appear in Microsoft  
Outlook, they are likely to get 'corrected', for example a URL that  
goes in as:


http://example.com//example.video

When you click it, you're quite likely to have it go to:

http://example.com/example.video

thus completely missing all your mod_rewrite patterns. This is why we  
love MS so. I've taken up using _ as a pattern separator as a  
workaround.


There's also a very nasty bug in current mod_rewrite (at least in  
Apache 2.0.54) where mod_rewrite url decodes submatches between input  
and output URLs, so for example:


RewriteRule ^(.*) blah.php?x$1

if you feed that a URL that contains a URL encoded value like 'Hello% 
20there', your resulting URL will be: 'blah.php?x=Hello there', which  
is obviously broken.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Sessions and register_long_arrays

2005-11-05 Thread Marcus Bointon

On 5 Nov 2005, at 00:25, Unknown Unknown wrote:

how do you reference the sessions? do you refrence them *with* the  
old arrays? because that would obviously be a problem


No, obviously that would be dumb! There is no mention of the old  
style HTTP_*_VARS arrays anywhere in my code. Smarty does use them by  
default, but I've turned that off. I'm also avoiding old-style  
session_register, only using current functions like session_start,  
session_name, session_destroy and putting everything in $_SESSION.


Someone pointed me at his bug:

http://bugs.php.net/bug.php?id=34542

I've been trying to come up with a small test case but no luck so far  
(so the bug remains with feedback status). xdebug is now working  
under 5.1RC5-dev but it doesn't trace quite how I thought it did. I  
suspect we might have more bug reports if more people were turning  
register_long_arrays off!


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: Richard Lynch's Email Address ...

2005-11-03 Thread Marcus Bointon

On 3 Nov 2005, at 14:16, Richard Heyes wrote:

It even has a method specifically for "normal" email addresses of  
the form [EMAIL PROTECTED]


Ah, well, that's good news. It's been a while since I looked at it.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: Richard Lynch's Email Address ...

2005-11-03 Thread Marcus Bointon

On 3 Nov 2005, at 04:32, viraj wrote:


does PHP really needs a function to validate an email address!! i
doubt. because PHP is a language which provides number of string
functions with regex capabilities to develop what ever pattern
matching you want.


Writing a regex for RFC2822 is not easy - the format is extremely  
flexible. Having said that, I've got on very well using these:


http://www.hexillion.com/samples/#Regex

Though it doesn't deal with that oddity that Richard mentioned.

The PEAR rfc822 class is pretty good, but it should be noted it's  
designed for parsing entire to, cc, bcc fields which may contain  
multiple addresses, and it's not quite as simple as asking it 'is  
this address ok'.



second point is, different organizations have different policies on
validating email addresses, so again those developers have to mend
their own mechanisms. so everybody will not benefit this effort.


Well, unless you're counting really different addressing standards  
like X.500, everyone has to operate within RFC2822. You're quite free  
to put additional constraints on addresses, but should be within that  
spec, not in addition to it. If an address is not RFC2822 compliant,  
it's pretty unlikely to work, though I have occasionally seen things  
like non-ASCII chars and '_' get through.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon


On 31 Oct 2005, at 21:11, Chris Shiflett wrote:

I think this is where some (most?) of the misunderstanding  
originates. Testing to see whether something exists is exactly what  
isset() does.


No. Given $myarray['a'] = NULL, isset($myarray[a']) returns false.  
You're saying that therefore, $myarray['a'] does not exist, which is  
clearly untrue. Testing to see whether something has a value is  
exactly what isset does, not whether it exists. In many cases it  
comes down to the same thing (because if it doesn't exist it can't  
have a value), but they are definitely not identical.


Wouldn't it seem like a bug if a function intended to check whether  
a variable is set generates a notice when you test a variable that  
isn't?


Since we're on such thin ice, you need to tread carefully - first you  
said it's for "testing to see whether something exists", but now you  
describe it as "a function intended to check whether a variable is  
set". Which is it? They are not the same thing. Here's an experiment  
to distinguish which it is - it may come as quite a surprise:


var_dump(isset($bar));
echo $bar;
$bar = NULL;
var_dump(isset($bar));
echo $bar;


bool(false)
PHP Notice:  Undefined variable: bar in /test.php on line 3
Notice: Undefined variable: bar in /test.php on line 3
bool(false)

Holy Smoke! isset quite definitely CANNOT tell you if a variable does  
not exist - though PHP clearly knows as the second echo did not  
generate an error! If it returns true then it does definitely both  
exist and has a value (which is useful and why you can use isset as  
you do), but if it returns false you really have no idea if the var  
exists or not. So what can you use instead? Is there no direct  
equivalent of array_key_exists for variables? I did discover that  
array_key_exists('bar', get_defined_vars()) works, but though at  
least it's definitive, I don't think I could face using that  
everywhere ;^)


To summarize, I see nothing wrong with your way of using  
array_key_exists(), but I don't think you can claim Richard's use  
of isset() is inappropriate. His method is "safer" in cases where  
the array itself is not set, and your method is "safer" when an  
element's value is NULL. Neither of these cases ever exist with  
$_GET, $_POST, etc., because they are always set, and they only  
contain strings. Therefore, there's no debate to be won here. :-)


Of course isset has a valid place - array_key_exists cannot replicate  
what it does (it doesn't know about values), so they can play  
together nicely - for example I'd consider this pretty robust:


if (isset($_SESSION) and is_array($_SESSION) and array_key_exists 
('myvar', $_SESSION)) ...


If you get past that you can be absolutely certain that $_SESSION 
['myvar'] exists, regardless of its value, and there is no  
opportunity to trigger an error, whereas if you said:


if (isset($_SESSION) and is_array($_SESSION) and isset($_SESSION 
['myvar'])) ...


you could still be wrong. The merest possibility of being wrong is a  
bad thing in code. Why not use marginally different syntax and be  
absolutely sure?


Yesterday I encountered an error in a large commercial php script and  
it turned out that it was looking in $_SERVER['SERVER_NAME'] which  
was there but set to NULL for some reason, and their test with isset  
was failing. So it's not just academic and I'm not making it up -  
this problem does happen for real.


All this over such a little thing - imagine if we had a whole  
language to worry about! Oh wait...


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon

On 31 Oct 2005, at 17:55, Richard Lynch wrote:


You're wrong.


No. You're just missing what I'm on about. I'll agree it's very dull.


isset() does not, under any circumstances, create an index nor a
variable.


Quite right; I never said it did.

Its entire purpose *IS* to tell you if something has been set to a  
value.

That's why it's CALLED "isSet"


But that's not the question you're using isset to answer. You just  
want to know if something exists - you probably don't even care what  
its value is.


Take apart this operation:

$a = isset($myarray['a']);

Implicit in this simple line is a 'hidden' step which is to look up  
the index 'a' in $myarray to get its value before testing if it is  
set or not. The issue I have is that that step's existence is being  
overlooked. That line could also be written:


$a = !is_null($myarray['a']);

Either way, if $myarray['a'] does not exist, its value will be  
regarded as null (and as such, isset and !is_null would give correct  
results as a consequence of this convenient side-effect), but I would  
also fully expect to receive an undefined index notice as you have  
explicitly looked up an array index that does not exist. If you used  
other functions the same way you're using isset, you would see  
nothing wrong with this:


$myarray = array();
print $myarray['a'];

but I would hope that you would have a problem with that. Why treat  
isset differently?


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon

On 31 Oct 2005, at 14:54, Chris Shiflett wrote:

Hopefully it is also clear that your argument revolves around the  
idea that PHP would create $_POST['foo'] as NULL if the checkbox is  
not checked. This is wrong for two reasons:


No, no, that's not what I said - I wouldn't contemplate such  
silliness! The thing I was wrong on is that PHP converts unset  
parameters (as opposed to nonexistent ones which it obviously can't  
do anything about) to an empty string, e.g. given ?a=&b=1, $_REQUEST 
['a'] is "", not NULL. However, it still serves to underline my other  
point that using isset without actually knowing that is a potentially  
dangerous thing. Getting into the habit of using it for looking in  
the likes of $_REQUEST means you're likely to use it other places  
where you have no such guarantee, and you'll have a bug to track  
down. Using array_key_exists means you will never be exposed to this  
possibility, no matter where your data comes from.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] php mail function vs smtp server

2005-10-31 Thread Marcus Bointon

On 31 Oct 2005, at 10:34, Richard Heyes wrote:

Depends on your setup. If you're on Linux/Unix you could use the  
mail() function along with the "-odq" option to Sendmail/Postfix/ 
Exim etc (fifth argument to the mail() function) which will dump  
all the mails into the MTAs queue. After this, the MTA will handle  
delivery. This is probably the quickest for this platform.


I agree. Sending directly is usually reserved for Windows machines  
with no local MTA and is usually way slower and doesn't handle  
queuing. I'd advise anyone to use PHPMailer for mail anyway as it  
makes it much more reliable to deal with all the other stuff like  
MIME encoding, plus it has support for all these sending methods  
without having to change much code. I use it with qmail.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: Substr by words

2005-10-31 Thread Marcus Bointon


On 31 Oct 2005, at 03:29, Gustavo Narea wrote:

I think It is OK what I said about the caret, but what we need to  
change is the position of \W*:

   Your suggestion: /(\b\w+\b\W*){1,$MaxWords}/
   My suggestion: /^(\W*\b\w+\b){1,$MaxWords}/

We need the *first* ($MaxWords)th words.


I makes no difference - they will both work. Mine doesn't care where  
the first word starts because it doesn't use ^, and yours doesn't  
care where the first word starts because it's got ^ followed by \W*.  
Your overall match will end up with leading spaces, mine will end up  
with trailing spaces - the subsequent trim fixes them both. I like  
mine because it has 1 less char ;^)


Ultimately, if it works for you, great!

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Type of form element

2005-10-31 Thread Marcus Bointon

On 31 Oct 2005, at 06:18, Richard Lynch wrote:

But I really do believe isset($_POST['checkbox_name']) is a "good"  
coding practice.


OK, so PHP may not pass through unset params as NULL (it's not up to  
the browser), but if you don't select any checkboxes at all, the  
param won't exist, and asking for an index of something that doesn't  
exist is normally a good way to generate notices. isset's job is not  
to tell you if an array key exists, so why use it for that purpose?


This is the difference I'm on about:

$z = array('a' => 1, 'b' => NULL);
echo array_key_exists('a', $z)?"yes\n":"no\n";
echo isset($z['a'])?"yes\n":"no\n";
echo array_key_exists('b', $z)?"yes\n":"no\n";
echo isset($z['b'])?"yes\n":"no\n";

This prints:

yes
yes
yes
no

That last 'no' has huge bug potential.

I'm not saying it doesn't have practical use, but I wouldn't call it  
good practice, and I wouldn't advise people to do it that way in new  
code. As it happens, isset _will_ usually work for things that come  
through the web-driven superglobals, but not all arrays come from  
there - if you use the same syntax for dealing with databases or your  
own objects you could be creating some very entertaining bugs. I  
don't know about you but I often deal with arrays containing NULL  
values where using isset would be very wrong.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] [DONE] Substr by words

2005-10-31 Thread Marcus Bointon

On 31 Oct 2005, at 06:27, Richard Lynch wrote:


There's a certain point where the Regex expression reaches a level of
complexity that I'm just not willing to accept in my code and call it
"maintainable"

/  */ is fine, of course.

But there's lots of times when I know there must be a one-line regex
to replace 10 lines of code, but I don't WANT to use it because I'll
stumble over that one-line Regex every time I have to change it.


I quite agree that many regexes are 'write only', but I don't think  
that that means that using substr and friends is necessarily any  
clearer. I sometimes find that a nested mass of string functions is  
even more confusing - at least a regex has a fixed grammar. I've just  
written a load of stuff that uses preg_replace_callback that I'm  
quite pleased with.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: Substr by words

2005-10-30 Thread Marcus Bointon


On 30 Oct 2005, at 15:35, Gustavo Narea wrote:

I think that trim($matches[0]) will return the whole string with no  
change.


No, it will return the entire matching pattern, not just the sub- 
matches. I added the trim to remove any leading space, and there will  
nearly always be a trailing space because of the part of my pattern  
that defines a word will include it. It was simpler to use trim than  
to make the pattern skip it. Did you actually try it?


On the other hand, I think we have to place a caret after the first  
slash.


Only if you insist that your string must start with a word - putting  
a ^ at the start would make it omit the first word if there was a  
space in front if it.



Instead of preg_match(), I had to type preg_replace():


err. I think you missed the point here. You don't need all that messy  
substr stuff at all. The preg_match already did it.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] php not activated

2005-10-30 Thread Marcus Bointon

On 30 Oct 2005, at 14:13, John Taylor-Johnston wrote:


echo $contents;


PHP doesn't now that it's PHP - it just treats it as text. You can  
tell it to run it as PHP explicitly using:


eval($contents);

Eval is usually worth avoiding, but it will do what you ask.

Your display function could be improved:

function display()
{
   $file = basename($_SERVER['PHP_SELF']);
   require 'connect.inc';
   $sql = "SELECT HTML FROM `$db`.`$table_editor` WHERE `Filename`  
LIKE '".addslashes($file)."' LIMIT 1;";

   if ($myquery = mysql_query($sql) and mysql_num_rows($myquery) > 0) {
   $mydata = mysql_fetch_array($myquery, MYSQL_NUM);
   return $mydata[0];
   }
   return false;
}

Then call it:

if ($contents = display())
eval($contents);

This should be faster and safer than your original code.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: Substr by words

2005-10-30 Thread Marcus Bointon

On 30 Oct 2005, at 06:22, Gustavo Narea wrote:

$replacement = ereg_replace ("^([[:space:]]*[^[:space:][:cntrl:]]+) 
{1,$MaxWords}", "",$MyOriginalString);


echo substr( $MyOriginalString, 0, ($replacement) ? -strlen 
($replacement) : strlen($MyOriginalString));


You could get the regex to do the search and the extraction in one go:

$MyOriginalString = "This is my original string.\nWhat do you think  
about this script?";

$MaxWords = 6; // How many words are needed?
$matches = array();
if (preg_match("/(\b\w+\b\W*){1,$MaxWords}/", $MyOriginalString,  
$matches)) {

$result = trim($matches[0]);
echo $result;
}

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] [DONE] Substr by words

2005-10-30 Thread Marcus Bointon

On 29 Oct 2005, at 20:41, Richard Lynch wrote:


It was probably replacing *TWO* spaces with one.

If so, it should really be in a while loop, because there could be 3
or more spaces in a row, and if the goal is only single-spaced
words...


I can hardly think of a better application for a regex:

$text = preg_replace('/  */', ' ', $text);

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Type of form element

2005-10-30 Thread Marcus Bointon

On 29 Oct 2005, at 20:59, Richard Lynch wrote:


So you will most likely be using isset($_POST['checkbox_name']) rather
than testing for "on"


I classify using isset for checking for the existence of array keys  
to be a bad habit as in some common cases it will not work as you  
expect, for example:




(note it has no value attribute) If it's checked, you would get the  
equivalent URL of "...?checkbox_name=", so $_REQUEST['checkbox_name']  
exists, but may contain NULL, and isset would return false even  
though it's there. A completely reliable check that will never  
generate any warnings is:


array_key_exists('checkbox_name', $_REQUEST).

If you have several checkboxes in an array (using names like  
name="checkbox_name[option1]"), you would say:


if (array_key_exists('checkbox_name', $_REQUEST) and is_array 
($_REQUEST['checkbox_name'])) {

if (array_key_exists('option1', $_REQUEST['checkbox_name'])) {
echo "you selected option 1\n";
}
if (array_key_exists('option2', $_REQUEST['checkbox_name'])) {
echo "you selected option 2\n";
}
//etc...
}

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Sessions and register_long_arrays

2005-10-29 Thread Marcus Bointon

On 29 Oct 2005, at 14:48, Marcus Bointon wrote:

changing an item in $_SESSION simply does not get saved back to the  
session file if register_long_arrays is enabled.


I meant disabled.

I've also tried using it with the mm session save handler and I get  
the same symptoms. I also get identical results on OS X and Linux.


FYI, I want to disable this setting for increased performance,  
especially as I'm not using these old arrays anyway.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] Sessions and register_long_arrays

2005-10-29 Thread Marcus Bointon
Strange behaviour that's taken me ages to track down. I have the  
situation where I can create a session, but any changes to it are not  
saved. session_write_close() didn't help. Eventually I tracked it  
down: if you have register_long_arrays disabled (as is the default in  
PHP5), this can happen. Enabling it fixed the problem. A very simple  
test case didn't show this problem, so I guess something in my  
sessions has a dependency on HTTP_GET_VARS or similar, though these  
old-style vars do not appear anywhere in my code... Some of the  
libraries I'm using may use them (for example Smarty, though I have  
the request_use_auto_globals option enabled for that which should  
stop it using them), but nothing to do with them is stored in the  
session. If I look at a session file, it's all just scalars and  
arrays, no complex types at all, but changing an item in $_SESSION  
simply does not get saved back to the session file if  
register_long_arrays is enabled.


Anyone else seen this? Any idea why it might be happening?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] PHP version check

2005-10-28 Thread Marcus Bointon


On 28 Oct 2005, at 07:46, Richard Davey wrote:


Friday, October 28, 2005, 7:41:21 AM, you wrote:


How can I query for PHP version?


phpversion() !


While it's true that that will get you a version string, if you're  
going to actually check it, you need:


http://www.php.net/manual/en/function.version-compare.php

to do so reliably. Version strings are messy things.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] OPTIMIZING - The fastest way to open and show a file

2005-10-14 Thread Marcus Bointon

On 14 Oct 2005, at 12:29, Ruben Rubio Rey wrote:

* For files less or equal 6 Kb, takes arround 0.02-0.03 miliseconds  
- its ok
* For files arround 35 Kb takes arround 0.2-0.4 miliseconds - too  
much.


Bearing in mind that average access time on a 7200rpm HD is around  
8ms, those numbers sound too good to be true anyway. You could  
configure some kind of software disk cache on your system, or ideally  
a hardware caching RAID controller and it could improve things  
dramatically, but not down to that kind of level (which represents  
about 200x what a single disk system might be expected to deliver).


Otherwise as Jochem says, use RAM for your cache in the first place.

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] prevent user from getting scripts outside the web folder [this better?]

2005-10-14 Thread Marcus Bointon

On 14 Oct 2005, at 04:48, David Robley wrote:

That is incorrect. mysql_real_escape_string is a php function, not  
mysql.


Mostly true: mysql_real_escape_string is a php function, but it's  
provided by the mysql extension as part of the mysql client libraries  
(which explains the name). It doesn't do anything significantly  
different to addslashes(), which is purely a PHP internal function.  
If you are writing database independent code, you should probably  
prefer addslashes (or things like adodb::qstr).


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Re: ampersand in dom with utf-8

2005-10-13 Thread Marcus Bointon

On 13 Oct 2005, at 07:24, cc wrote:


both `è' and `î' are not entities in charset utf-8, use
`&egrave;' and `&icirc;' instead.


I would expect that to result in unconverted entities in the output.  
If you're intending to send that content as HTML, then I guess that  
would be OK. However, if you're using UTF-8 anyway, why not just use  
the real characters?


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] SOAP WSDL location

2005-10-12 Thread Marcus Bointon
This is a minor thing that's been troubling me, making it difficult  
to deploy a salesforce.com SOAP client across multiple projects.  
Salesforce is a particular interest because its WSDL files are NOT  
available directly online - you have to download and save local  
copies manually.


When constructing a SOAPClient object, the WSDL parameter provided is  
treated like a URL (because it will usually BE a URL). For 'local'  
URLs, it searches the current directory, including any relative path  
that it uses. However, because it is fundamentally a URL and not a  
file request like an include, it does not search the include path.  
The net result of this is that I'm having to copy my WSDL files into  
every place that my class library is called from because the URL  
resolution will only ever look in the calling directory and not in  
the include path that allowed it to find my classes.


An alternative would be to allow providing the WSDL as a literal  
string, probably read using file_get_contents() which does support  
using the include path.


A worse solution is to provide the WSDL contents as the response to a  
separate HTTP call (i.e. act like the WSDL is online after all). This  
would work, but it's way less efficient.


I can't use an absolute path as it's deployed in multiple  
configurations on multiple servers, and config is bad enough already.


Now before I report this as a bug/feature request, does anyone have  
any better ideas?


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Global unavailable?

2005-10-05 Thread Marcus Bointon

On 5 Oct 2005, at 13:37, Jochem Maas wrote:


if changing the declaration in a.inc.php fixes it then you must
NOT be including b.inc.php form the global scope.


Well, that's what I thought, but it just isn't! The include really is  
in the global scope outside any class or function definition. The  
original definition is directly inside the included file, and not  
itself inside a function or class.


I should have mentioned that I'm using PHP 5.1-dev, so it could just  
be  bug...


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] Global unavailable?

2005-10-05 Thread Marcus Bointon

I have a simple situation:

in a.inc.php:

$a = 1;

in b.class.php

require 'a.inc.php';
class b {
function test() {
global $a;
echo $a;
}
}

With this pattern, $a is NOT visible within class b, even though it  
is declared in the global scope and I'm using the global keyword! I  
can work around it two ways; by changing the original declaration  
(which just seems wrong - it's already in the global scope at this  
point):


global $a;
$a = 1;

or by requiring the inc file inside each function of b (much less  
efficient):


class b {
function test() {
require 'a.inc.php';
global $a;
echo $a;
}
}

Is this just how it is, or am I doing something wrong?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] OS X compile problem with GD

2005-08-30 Thread Marcus Bointon
I've suddenly developed a peculiar compile problem in PHP5. I'm  
trying to build PHP 5.0.4, 5.0.5RC1, 5.0.5RC2 or 5.1RC1, and they  
have started giving me an odd problem with GD:


gcc -I/Users/marcus/src/php-5.0.4/ext/gd/libgd -DHAVE_LIBPNG - 
DHAVE_LIBJPEG -DHAVE_LIBFREETYPE -Iext/gd/ -I/Users/marcus/src/ 
php-5.0.4/ext/gd/ -DPHP_ATOM_INC -I/Users/marcus/src/php-5.0.4/ 
include -I/Users/marcus/src/php-5.0.4/main -I/Users/marcus/src/ 
php-5.0.4 -I/usr/include/libxml2 -I/sw/include -I/sw/lib/freetype219/ 
include -I/sw/lib/freetype219/include/freetype2 -I/Users/marcus/src/ 
php-5.0.4/ext/mbstring/oniguruma -I/Users/marcus/src/php-5.0.4/ext/ 
mbstring/libmbfl -I/Users/marcus/src/php-5.0.4/ext/mbstring/libmbfl/ 
mbfl -I/usr/local/mysql/include -I/sw/include/libxml2 -I/Users/marcus/ 
src/php-5.0.4/TSRM -I/Users/marcus/src/php-5.0.4/Zend  -I/sw/include - 
no-cpp-precomp  -DBIND_8_COMPAT=1 -DEAPI -O3 -mcpu=G4 -mtune=G4 -I/sw/ 
include  -c /Users/marcus/src/php-5.0.4/ext/gd/gd.c -o ext/gd/gd.o   
&& echo > ext/gd/gd.lo

/Users/marcus/src/php-5.0.4/ext/gd/gd.c: In function 'zm_info_gd':
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:504: error: 'FREETYPE_MAJOR'  
undeclared (first use in this function)
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:504: error: (Each undeclared  
identifier is reported only once
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:504: error: for each function  
it appears in.)
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:504: error: 'FREETYPE_MINOR'  
undeclared (first use in this function)

/Users/marcus/src/php-5.0.4/ext/gd/gd.c: In function 'php_imagechar':
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:2810: warning: pointer  
targets in passing argument 1 of 'strlen' differ in signedness
/Users/marcus/src/php-5.0.4/ext/gd/gd.c: In function  
'php_imagettftext_common':
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:3189: warning: pointer  
targets in passing argument 4 of 'gdImageStringFTEx' differ in  
signedness
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:3189: warning: pointer  
targets in passing argument 9 of 'gdImageStringFTEx' differ in  
signedness
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:3195: warning: pointer  
targets in passing argument 4 of 'gdImageStringFT' differ in signedness
/Users/marcus/src/php-5.0.4/ext/gd/gd.c:3195: warning: pointer  
targets in passing argument 9 of 'gdImageStringFT' differ in signedness

make: *** [ext/gd/gd.lo] Error 1

I tried switching from the bundled GD to a version compiled from  
fink, but it made no difference. My current configure is:


'./configure' \
'--with-layout=Darwin' \
'--bindir=/usr/bin' \
'--disable-ipv6' \
'--enable-bcmath' \
'--enable-calendar' \
'--enable-dba' \
'--enable-exif' \
'--enable-ftp' \
'--enable-gd-imgstrttf' \
'--enable-gd-native-ttf' \
'--enable-mbregex' \
'--enable-mbstring' \
'--enable-mcal' \
'--enable-pcntl' \
'--enable-shmop' \
'--enable-soap' \
'--enable-sockets' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--enable-track-vars' \
'--enable-wddx' \
'--sysconfdir=/etc' \
'--with-apxs2filter=/sw/sbin/apxs' \
'--with-bz2' \
'--with-config-file-path=/etc' \
'--with-config-file-scan-dir=/etc/php.d' \
'--with-curl' \
'--with-db4=/sw' \
'--with-dom=/sw' \
'--with-freetype-dir=/sw/lib/freetype219' \
'--with-gd=/sw' \
'--with-gdbm=/sw' \
'--with-iconv=/sw' \
'--with-imap-ssl=/sw' \
'--with-jpeg-dir=/sw' \
'--with-png-dir=/sw' \
'--with-ldap' \
'--with-mcrypt=/sw' \
'--with-mhash=/sw' \
'--with-mysql=/usr/local/mysql' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' \
'--with-openssl' \
'--with-pcre=/sw' \
'--with-pear' \
'--with-png' \
'--with-tidy=/sw' \
'--with-ttf' \
'--with-xml' \
'--with-xmlrpc' \
'--with-xsl' \
'--with-zlib' \
'--without-oci8'

you can see that I'm pulling in a fair number of things form fink,  
but until recently it was all working fine with 5.0.4. There are only  
two options that affect gd directly: --with-gd and --with-freetype- 
dir. The configure script doesn't report any problems:


...
checking for GD support... yes
checking for the location of libjpeg... /sw
checking for the location of libpng... /sw
checking for the location of libXpm... no
checking for FreeType 1.x support... yes
checking for FreeType 2... /sw/lib/freetype219
checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... (cached) yes
checking for floorf... (cached) yes
checking for jpeg_read_header in -ljpeg... (cached) yes
checking for png_write_image in -lpng... (cached) yes
If configure fails try --with-xpm-dir=
checking for FreeType 1 support... no - FreeType 2.x is to be used  
instead

...

Any idea why this is not working?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Looking for CMS advice

2005-08-23 Thread Marcus Bointon

On 23 Aug 2005, at 14:05, Jay Paulson wrote:


I would say check out Dupral, Mambo, and XOOPS.


Drupal looks great, but whenever I've tried to get into it, nothing  
seems to work properly. Xoops is capable (I've used it on a couple of  
sites), but generally a complete mess internally. Both of them have  
massive, cryptic control panels and it's inordinately complicated to  
do simple things like "put this bit of text at the top of the front  
page". Unless you want your site to look and work like everyone  
else's Nuke clone, I'd steer clear of these.


The majority of so-called content management systems actually fail  
dismally at managing content. I don't know why they even use the name.


For simple sites, Website Baker is great, especially if the intended  
admin wants little hassle. It's one of the few that seems to put a  
strong emphasis on usability over feature bloat.


Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



[PHP] __sleep, __wakeup and persistent connections

2005-08-20 Thread Marcus Bointon
I'm sorting out some code to handle session object storage,  
particularly where the objects contain DB connections. I've found  
lots of articles that go on about how __sleep should clean up db  
stuff, close connections etc and how __wakeup should reconnect, but  
weirdly enough I've not found a single concrete example of doing this!


It's also not quite clear how this behaviour interacts with  
persistent connections. For example, If I do this:


class foo {

protected $db;

public function __construct() {
$this->db = mysql_pconnect();
}

protected function __wakeup() {
$this->db = mysql_pconnect();
}

protected function __sleep() {
mysql_close($this->db);
$this->db = NULL;
return array();
}
}

given that the connection is persistent, and may thus be used by  
other scripts, is calling mysql_close a particularly bad idea? Should  
I just not bother closing the connection, letting PHP deal with it -  
the object will not attempt to re-use the stale connection because it  
will get a new instance courtesy of __wakeup when unserialized.


I'm also unclear about how __sleep acts in subclasses - it seems that  
as soon as I have a __sleep function in a base class, I don't have  
any choice but to implement __sleep functions in every subclass of  
it, even if I don't want them to do anything that would not be done  
if __sleep were not defined. in the exampel, the base class has no  
properties to save, so it returns an empty array from __sleep, but  
that's unlikely to be useful for a subclass that does have properties  
(and serializing an object without any properties is pointless!).


Ideas?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



  1   2   3   >