Re: [PHP] What software do you use for writing PHP?

2005-12-06 Thread Torgny Bjers

Quoting Michael Crute [EMAIL PROTECTED]:


On 12/6/05, Jeff McKeon [EMAIL PROTECTED] wrote:

Hey all,

Forever now I've been using Frontpage for all my web work including php.
I'm sure there's better software out there that is more suited to
writing and editing PHP pages.  What do you all use?

Thanks,

Jeff


Actually, there isn't much WORSE than FrontPage for any kind of
coding. My personal favorite for projects at work is Eclipse with
phpEclipse plugin and at home I use vim almost exclusively.


I recommend Zend Studio if you can afford it since it has a GUI for 
both Windows

and Linux, and it runs fairly fast for being a Java application. ;)

I agree with Mike, pretty much anything is better than FrontPage for 
editing web

pages.  If you're going to be changing both HTML and PHP, Zend works fine, but
if you want something with less features but with all the important stuff such
as syntax highlighting, multiple window buffers, and all that shebang, go for
EditPlus www.editplus.com or UltraEdit www.ultraedit.com, I prefer EditPlus
over most such simpler editors on Windows, and on Linux I use Jed, which has
good menu handling and Windows-like shortcuts that speed up the work. I 
tend to

get slightly confused when working 95% in Windows and then having to edit
something in vim or emacs.

Just my two cents...


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



Re: [PHP] SOAP and PHP

2005-11-16 Thread Torgny Bjers
Angelo Zanetti wrote:

 Hi guys.

 I've googled but found so many pages that I'm not sure what to use.

 I want to use PHP to make use of SOAP.

 I've found:
 -nuSoap
 -libxml(2)
 -php-soap
 -and others which seemed less important.

 Can you recommend which one to use? and which one is the most supported.
 Also if I've missed some that you feel I should know about please let
 me know.
 Thanks in advance.

 Angelo


Not sure, but there's already a couple of relevant classes in PEAR:
http://pear.php.net/search.php?q=soapin=packagesx=0y=0

A hot tip is to always search in the packages there. :)
http://pear.php.net/packages.php

Warm Regards,
Torgny

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



Re: [PHP] Re: Template style question

2005-11-06 Thread Torgny Bjers
Petr Smith wrote:

 Smarty sucks. Mixing presentation and logic is never good idea. I know
 Smarty is very popular, but big popularity doesn't always mean quality.

 Back to original question: If you decided to reinvent the wheel,
 please don't reinvent square wheel without tire.

 Mixing presentation and logic is bad. You should have no sqls, loops,
 ifs or any other logic things in templates. Templates should be
 editable by any stupid guy, anyone who knows just css/html. No sql, no
 php, no other language.

 Back to original idea to parse table. Do not copy bad ideas from other
 templating engines. Again - reinvent a better wheel or use some from
 1000s of existing libraries. Download some existing libraries, think
 about good and bad things, make it better, make it different!
 Otherwise we will end with 1000+1 stupid, same, useless templating
 libraries.


You don't need to mix presentation and logic with Smarty. If you create
your custom tags with Smarty and use these instead of having the inline
Smarty PHP code, you'll have separated them just fine. Then if the end
user wants to use PHP inline, fine, either let them, or don't. Either
way, Smarty is about the fastest and most versatile engine in the PEAR
library, as far as I know. I'd rather use that, than build something
custom from scratch. And, in combination with Tidy and Cache_Lite,
you'll get a very fast and precise rendering engine...

Just my $0.02.

Regards,
Torgny
   

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



Re: [PHP] Simple CopyOf XSLT translation

2005-11-02 Thread Torgny Bjers

Quoting Andy Pieters [EMAIL PROTECTED]:


Hi list

I made an entire site in xhtml for a client but now complaints are comming
from the m$ explorer front.  Broken layouts, long loading times etc.

Would it be possible for php to do the xslt translation?

All that is currently in my xslt is

stylesheet
template match=/
copy-of select=. /
/template
/stylesheet

And serve those pages as html 4.01 instead of xhtml on internet explorer?

With kind regards


Andy


Hello Andy,

If you are using PHP 5, look at the XSL module, otherwise you'll have to use
XSLT and Sablotron. Check out the manual http://www.php.net/manual/en/ 
for more
information on these. I suggest using Tidy if possible to convert from 
XHTML to

HTML 4.0.1, this is the easiest way to convert/clean markup without having to
do all the hard work yourself.

It seems to me that with your very small xslt file, you could skip 
using xslt in
general? Or maybe you did it that way to pave way for future additions 
with more

advanced XSLT function usage?

Regards,
Torgny

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



Re: [PHP] XML-RPC Error:-32300:transport error - could not open socket

2005-10-22 Thread Torgny Bjers
Dan McCullough wrote:

I'm having any issue finding out why this is happening and how to fix
it.  Is it a permissions problem between php and the server or
something else?
Help


Without looking up this specific error code thoroughly through Google or
elsewhere, I would have to ask you to submit the code excerpt that
generates this error. If it is a permission error it could be because
you are trying to listen to a system reserved port in the 0-1024 range,
or it could be that the URL that you are trying to open is actually
invalid. For instance, if trying to connect to http:// you could have
forgotten a slash, or used backslashes, or any other common mistake.
Please submit more information the next time, and use Google, it
actually finds information for you. :)

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-19 Thread Torgny Bjers
Jochem Maas wrote:

 and the next site that displays a PDF when I wasn't expecting it
 and I have to spend the next five minutes waiting for the b'std to load
 (with the alternative being to KILL the browser - losing all open pages
 in the process) ... might just make me snap ;-)

I agree, those moments are annoying. That's why one needs to make sure
that the user expects, and is aware, that a PDF is going to open down
there in that little iframe/. I do not see any motivated use for a PDF
in this fashion on a normal site, but, in a document versioning system
or a CMS, sure, that would be awesome. Otherwise I side with Jochem.

This is not an approach that should be used in any normal web page, it
should be utilized with care, where it is needed, and the user has to be
made aware that when clicking on a specific link, a PDF will be loading.
Otherwise, some poor webmaster's going to have to answer to Jochem, and
they don't want that. ;)

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Richard Lynch wrote:

On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:
  

Do they want the PDF to display in the page, or is a link to a PDF ok
for them?



I've already warned them that a PDF embedded into a page is impossible.

That may not be true, technically, for all I know, but I've sure never
seen it, and don't even want to try to go somewhere that so few have
gone.
  


I think you would be able to use an IFRAME, or even a FRAME, to load the
PDF into like you would open it in any normal browser using the standard
PDF plugin that's used when you click a PDF in your browser. That is,
set the src of the iframe to the path of the PDF. Give it a try and let
us know how it works out. IFRAMEs are smart sometimes, especially when
building application interfaces.

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Jasper Bryant-Greene wrote:

 Richard Lynch wrote:

  On Sat, October 15, 2005 7:26 am, Edward Vermillion wrote:

  Do they want the PDF to display in the page, or is a link to a PDF
  ok for them?


  I've already warned them that a PDF embedded into a page is
  impossible.

  That may not be true, technically, for all I know, but I've sure
  never seen it, and don't even want to try to go somewhere that so few
  have gone.


 I would expect that putting the PDF in an iframe would work, but I
 wouldn't trust browsers or the Acrobat plugin to not crash horribly in
 that sort of situation. It's also going to be very confusing for users
 seeing the Acrobat toolbar floating in the middle of their page.

 It would be interesting to see some tests of PDF-in-iframe done in
 various different browsers, but unless it just happened to work
 perfectly in every common browser (we can all dream, can't we?) I
 wouldn't touch it.

 Jasper


After some consideration I am pretty sure it works, since an iframe/
is just the same as a frame/, and I am dead certain you can open a PDF
document, or a Word document, or a Flash file, inside a frame without
anything crashing. As for the PDF toolbar, I think that with the proper
CSS styles on the iframe/ element you can make it pretty apparent that
the iframe/ contains a PDF document.

Also, when using iframe/ you are weeding out those old browsers that
wouldn't support even loading an iframe/, which means that you get
relatively new browsers, and those should all support this method.

Besides, if this is for an editor interface, for a specific client, one
could reasonably demand that they use at least one of the newer browsers
such as IE5+ or Mozilla. If not for a specific client, or subset of
clients, but for a general update of an entire application that is open
sourced, I agree with Jasper, don't touch it. :)

Regards,
Torgny

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



Re: [PHP] fckeditor and PDF and pesky users

2005-10-17 Thread Torgny Bjers
Richard Lynch wrote:

On Mon, October 17, 2005 3:56 pm, Torgny Bjers wrote:
  

Also, when using iframe/ you are weeding out those old browsers that



If somebody else wants to weed out old browsers, that's all fine and
good, but that's not me...
  


Didn't say I wanted to. It was a suggestion. :) I personally prefer Lynx
when I am surfing, since then I get rid of everything, including images,
javascript, and plugins -- just me and text. Nah, seriously, I kind of
like Firefox since 80x25 text space in lynx can get a bit annoying when
navigating a site that somebody added a bzillion images to, but let's
not talk about browsers and favorites, since that'd be another long
ardous flame fest. :P

Besides, if this is for an editor interface, for a specific client,
one
could reasonably demand that they use at least one of the newer
browsers
such as IE5+ or Mozilla. If not for a specific client, or subset of
clients, but for a general update of an entire application that is
open
sourced, I agree with Jasper, don't touch it. :)



I personally don't think I should demand editors use a specific browser.

I believe in customer choice.

For that matter, *I* probably don't use a browser that does this
right, being as I'm usually on Linux, almost always on Netscape, and
very very very rarely do PDF and/or Flash work really right for me.

And you know what?

I very very very seldom care badly enough about any of the content I'm
missing and when I do care enough to go get it, I'm disappointed by
the content more often than I'm pleased that I took that effort.

Again, this is obviously MY weird world-view at work here. :-)
  

I wasn't trying to advocate you doing something you don't want to do. If
you consider the feature worth implementing, weighing the options, you
implement it, or you don't, either way, your choice. I merely stated
that it does work, when using a recent browser.

The iframe/ tag was added in IE3+ which is pretty darn old, and if
you've seen ANYBODY using anything Microsoft-made prior to IE3 in your
server logs of late, let me know. :)

The following major browsers have support for iframe/:

Internet Explorer for Macintosh: 5.2 (not sure about 5.1)
Internet Explorer: 3.0 and above
Mozilla: 1.0 and above
Netscape Navigator: above 4.0 (which should be 6.0)
Opera: 4.0 and above
Safari: 1.0 and above

So, if you use one of these browsers, and considering that you rarely
(I'd say about %1-5) see people using anything below these versions,
you'd be safe adding an iframe/ if you wanted to. If the browser does
not have support for iframe/ it will ignore the tag and it won't break
anything at all.

As Jason Karns showed in the example from cstv, and you could test that
on all your different browsers and see what happens, if they have the
plugin installed, it ought to work...

But, on that note, if it is entirely vital to display the PDF, why not
convert the PDF to HTML instead and display that then? Would work in all
browsers, a little hit on the server performance, which can be avoided
by caching the results of a PDF - HTML conversion. Don't ask me where
to get code for this, as I have no clue, but I am sure it exists somewhere.

Regards,
Torgny

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



Re: [PHP] Send postcard link

2005-10-09 Thread Torgny Bjers
Roger Thomas wrote:

On server-1 I have my photogallery working. On another box, server-2, I have 
my postcard script also working great. Users can send postcards using ready 
inhouse designs or upload their own (max 100K). Both have been serving our 
community for the past  2 years or so.

Current requirement:

When I browsed my photogallery, I would like to have a button that says 'Send 
this picture as postcard'. Behind the scenes, how do I send that picture to 
server-2 postcard script?

  


The easiest way would probably be to use file_get_contents, which is
binary safe. The file_get_contents function supports opening remote
files if allow_url_fopen is activated.

An example:
$handle = fopen(ftp://user:[EMAIL PROTECTED]/somefile.txt, r);

Regards,
Torgny

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



Re: [PHP] ICQ

2005-10-08 Thread Torgny Bjers
Al Hafoudh wrote:

 is it possible to connect to icq,  send messages and etc? thanx


It should be possible, since PHP has full socket support. I googled a
bit and then checked the PHP Resource Index, and found the following:
http://php.resourceindex.com/Complete_Scripts/Instant_Messaging/ which
doesn't give us the information we're looking for, so I'd suggest taking
a look at the Perl libraries for ICQ/AIM and other IM clients that you
can probably adapt to PHP without too much work. Check www.cpan.org for
this.

Regards,
Torgny

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



Re: [PHP] domit and XML

2005-10-04 Thread Torgny Bjers
Erik Barba wrote:

hi im new in the list i dont know where to write the email so i did it here,
i am having a problem
 I have a xml file and im parsing with domit 1.0 but im from mexico, and we
use  é í ó ú á ñ 
the xml acept it but when the php show the code in html, i cant see the
letters
  


Erik,

The easiest way to make sure that all characters are represented
correctly is to specify the UTF-8 codepage on your HTML pages and making
sure that you edit and save your XML documents with an editor that is
capable of handling UTF-8, such as Windows Notepad (W2000 or later I
think) or Editplus from editplus.com, or one of the major editors, such
as Dreamweaver or Visual Studio or Zend Studio.

This ought to fix most problems.

Regards,
Torgny

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



Re: [PHP] PHP5 Webhost

2005-10-04 Thread Torgny Bjers
Michael Crute wrote:

Hi All,

I am in the process of looking for a webhost for the company I work
for. I must have PHP5 support as the CMS I am using only supports
PHP5. Does anyone know of any good quality hosts that also support
PHP5 and MySQL for less than $40/mo? Dedicated hosting is right out as
we obviously don't have the budget for that. Any thoughts/suggestions
would be very much appreciated. Thanks.
  


If Greg Donald can do it, so can I:
[shameless plug]
http://mu-host.com
[/shameless plug]

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



Re: [PHP] PHP 5 Hosting

2005-10-02 Thread Torgny Bjers
Oliver Grätz wrote:

Sheesh! No week passing by without people complaining about hosters
missiong out on PHP5. This is one point where we in Germany seem to be
lucky. The two biggest german hosters 11 (about 4 million domains) and
Strato (about 2.5 million domains) both offer SSH and the possibility to
chosse the PHP version on a per directory basis (via .htaccess). Strato
offers PHP 3.x, 4.0.x, 4.3.x and 5.0.x in parallel. Perhaps you should
think about outsourcing your hosting *g*.
  


I am assuming they're running PHP through CGI in this case, am I
correct, or are they hosting on Windows to achieve the multiple PHP
versions? If CGI, that rather affects performance of larger
applications, it especially impact render time of more complex templates
and forms. During my own testing we gained lots of time by just running
it as a compiled Apache module instead of through CGI and in .htaccess.

On our hosting servers we solved it by running a compiled PHP 5 Apache
module on one server, and regular on the others. This way, if someone
requests PHP 5, they can be put on the server that supports it, and if
somebody wants to switch server from PHP 4 to PHP 5, it's an easy enough
task. Or, of course, we have the CGI option to fall back on.

Regards,
Torgny

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



Re: [PHP] mail function-new line-security

2005-09-29 Thread Torgny Bjers
Peppy wrote:
 AJ,
 
 So what your reply means is that I should not have a new line character in 
 any variable on my page???

Of course you can have newlines in your email message, just make sure
that any user input is received through POST, and that you run a regular
expression to validate that only one email has been specified in the
recipient field (whatever you call that on your form I don't know) to
ensure that it is only sent to one person.

Other than that you ought to be pretty secure. Make sure that the user
cannot enter any type of header information in the beginning of their
message, so, for instance you could do what you did:

$usermailmsg = This is the information you submitted.\n // ...

It will ensure that other text appears before the user submitted data.
Hope that helps.

Regards,
Torgny

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



Re: [PHP] PHP CLI - possible for mass mailing?

2005-09-27 Thread Torgny Bjers
Denis Gerasimov wrote:

 We are working on a PHP project that implements mass mailing to a large
 number of its subscribers (expected 100,000-200,000 users; not spam mailing
 BTW). So I am wondering if it is possible to use PHP CLI binary for this
 purpose and if there are any problems with PHP in this case.

No problems that I can think of as long as you use a custom php.ini file
to avoid such things as safe_mode, max_execution_time, and various other
nasties that you might bump into if you run it on various servers.

 I was said that using Perl script is more suitable for such task since PHP
 scripts have problems with sending large amount of mail.

Bah humbug. PHP CLI works just fine, and, it is quite easy to do both
ncurses and text positioning/coloring for both Windows and Linux, and it
is a lot easier to run it either from the web or shell. It's not the PHP
script that has the problem, in reality, it's just an issue of making
sure that you're sending the mails in batches, which you can do if you
make sure that there's no maximum execution time set for the PHP script.

 Is that true or not? Any success/failure stories?

It is false. And, I am sure that someone can dig up a success story,
but, I know for a fact that I'd rather use PHP for sending large amounts
of email, especially if there's to be MIME parts and or HTML included in
it. There are already several well-coded PEAR packages that do this for
you out of the box.

Warm Regards,
Torgny

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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread Torgny Bjers
Ross wrote:
 can someone show me the right way to do the following...
 
 a href=?=$PHP_SELF?action=bigger; ?
 
 I want to pass a variable to a  self submitting link.

Easiest way to do that is to use sprintf() or printf():

?php
$link_title = click my self-referring link;
printf('a href=%s?action=bigger%s/a', $_SERVER['PHP_SELF'],
$link_title);
?

Or, like you did with inline code in the HTML:

a href=?php echo $_SERVER['PHP_SELF']; ??action=biggerclick my
self-referring link/a

Warm Regards,
Torgny

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



Re: [PHP] best way to save program prefs to a file?

2005-09-27 Thread Torgny Bjers
Chris wrote:
 I'd like to save some program preferences to a txt file where they can be 
 recalled and updated at a later time. Basically this will be a variable name 
 and a value. Can someone suggest a reference or method to best perform this 
 task?
 
 Thanks
 Chris
 BTW: I do not want to use MySql. 

Write a regular Windows .ini file like:

; My INI-file (this is a comment line):
key = value
key2 = value2
; It even works with PHP constants (defines) in the ini file
key3 = E_ALL

Reading it in is simple, use parse_ini_file():
http://www.php.net/manual/en/function.parse-ini-file.php

You can also keep sections in the .ini file such as:

; a section name uses []
[section1]
key = value
[section2]
key = value

To write this down is easy, just do a foreach on your associative array
and write to a string that you then save into a file if you wish to
update the values here.

Warm Regards,
Torgny

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



Re: [PHP] cache xml objects in php5

2005-09-26 Thread Torgny Bjers
Kevin Wang wrote:

Hi All,

My php5 web application needs to parse/marshall a bunch of large xml files into
php5 objects at the beginning of handling each request.  These xml files are
static across all the requests and it is really time consuming to
parse/marshall them into php5 objects.

I am wondering if there is any means to cache these xml objects so that each
request will not go through the same time consuming xml parsing/building
operation.  Serialization doesn't work in my case as deserialization is also
very expensive.

I am using Apache as the web server.  What I am thinking is that if php5 allows
us to keep certain objects (and their references) around across all the
requests in a child process instead of cleaning all the object memory every
time after a script/request is finished.

I guess this problem is quite common for any large and complicated php
applications.
  


If I had XML files that large, I would either switch database engine to
MySQL or PostgreSQL since that way I can page/load the data quicker than
parsing an XML document, or, I would consider the following:

Does the XML data change a lot? If not, why not cache the actual HTML
output instead of the data? That way you get n number of HTML documents
instead of one dynamic script, these files would only change when the
XML file has a changed filemtime(), and, it's easier for the server to
handle the requests. Take a look at:

http://pear.php.net/manual/en/package.caching.cache-lite.php

Cache_Lite is actually quite powerful since it allows you to cache
either the entire finished output, or just a part of the site and render
that from cache until the data has changed.

You could write down a whole series of cached documents either from one
request, or by running a cron under Linux or scheduler task under
Windows, and one user wouldn't get the brute of the waiting time when it
renders the cached parts.

Just some ideas... I hope I helped somehow.

Warm Regards,
Torgny

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



Re: [PHP] php 4 script with php 5.

2005-09-24 Thread Torgny Bjers
Dwayne Hottinger wrote:

I am trying to transfer some databases and php scripts that populate them to a
new server.  Server is running Fedora core 4 with mysql 4.x and php 5.0.5.
Original scripts were writen with php 4.x and worked fine.  I get a PHP Notice:
 Undefined variable: return_array when running them on the new server and the
database doesnt get populated.  Mysql database and mysql user rights seem to be
correct.  Do I have to rewrite the script for php 5.x or should it work and I
need to dig for another problem?  Im quite new to php and dont know quite which
way to go for help. I hope I have posted this on the right list.

ddh


Hello Dwayne,

This is easy enough, all you need to do is define return_array. I've
included an example here, it's mailer code, but, should illustrate what
you need to do.

function test()
{
$return_array = null;
if (...) {
$return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC);
}
return $return_array;
}

That means, you need to assign or indicate that return_array exists
before you use it in something like return or other PHP function. Your
php.ini file for PHP 4 could have been more forgiving coming to these
notices/warnings.

Warm Regards,
Torgny Bjers

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



Re: [PHP] php 4 script with php 5.

2005-09-24 Thread Torgny Bjers
Don't top-post (on mailing lists, always respond below the other
person's post). Please see below for my reply.

Dwayne Hottinger wrote:

Thanks Torgny,
Im a real newby here at php scripting.  What should I put in the ()? 
Copying the snip into the script complains about that.  This is in a db.php
which defines how another script should utilize the database.  I could copy the
db.php into an email for someone to look over.

thanks,

ddh


Quoting Torgny Bjers [EMAIL PROTECTED]:

  

Dwayne Hottinger wrote:



I am trying to transfer some databases and php scripts that populate them to
  

a


new server.  Server is running Fedora core 4 with mysql 4.x and php 5.0.5.
Original scripts were writen with php 4.x and worked fine.  I get a PHP
  

Notice:


Undefined variable: return_array when running them on the new server and
  

the


database doesnt get populated.  Mysql database and mysql user rights seem to
  

be


correct.  Do I have to rewrite the script for php 5.x or should it work and
  

I


need to dig for another problem?  Im quite new to php and dont know quite
  

which


way to go for help. I hope I have posted this on the right list.

ddh

  

Hello Dwayne,

This is easy enough, all you need to do is define return_array. I've
included an example here, it's mailer code, but, should illustrate what
you need to do.

function test()
{
$return_array = null;
if (...) {
$return_array = $db-getAll(SELECT * FROM table, DB_FETCHMODE_ASSOC);
}
return $return_array;
}

That means, you need to assign or indicate that return_array exists
before you use it in something like return or other PHP function. Your
php.ini file for PHP 4 could have been more forgiving coming to these
notices/warnings.

Warm Regards,
Torgny Bjers



The (...) was just an illustration if you had an if statement that
didn't fire, then $return_array wouldn't be defined at all. Just put
$return_array = null; in the top of the script somewhere so that it is
defined at all times, that way you don't have to worry about the actual
notice about it not being defined.

You can then also make a simple check to see if it is an array, for
instance:

if (!emtpy($return_array)  is_array($return_array)) {
/* Code to do something with $return_array */
}

That would be a good idea if you for instance are going to iterate the
items in the array somewhere, if you don't check first, you might
attempt to iterate a variable that doesn't contain an array but null,
then PHP will yell at you for that.

You are welcome to mail the script to me privately and I can take a look
at it for you.

Warm Regards,
Torgny

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



Re: [PHP] php Slow with Mac OS X 10.4

2005-09-14 Thread Torgny Bjers

Quoting Nicolas Ross [EMAIL PROTECTED]:

[snip]


Now, in a different server room, we have a set of 3 xserves cluster node
dual g5 with 4 gigs of ram each. One of them was upgraded to Mac OS X 10.4
(server) and the other 2 are still with 10.3.

If I take the same setup (same compile options, same versions) on these
machines, the exact same site is slow as hell on the 10.4, and lightning
fast on 10.3.


[snip]


Any hints ?


Have you compared the httpd.conf files? It could be that they've for 
some reason

changed the KeepAlive to Off and MaxKeepAliveRequests and KeepAliveTimeout
values to something odd, check those, might improve performance a bit.

Regards,
Torgny

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



Re: [PHP] installing php5 on apache2 as a module (on win xp)

2005-09-09 Thread Torgny Bjers
Cristian Ionitoiu wrote:

Hi,

 

 I have a strange behaviour. After following all the suggested installation
procedures for php5 and apache2, when I restart apache I get a warning
window saying PHP Startup: Unable to load dynamic library
'C:\php\ext\php_mcrypt.dll' - The specified module could not be found. I
get this for 6-7 modules.

But, the module DOES EXITS at that address. Please advise. Thanks,
  


Make sure you have set extension_dir properly in php.ini:

extension_dir = C:\PHP\ext

Of course, change to where you have the extensions installed. Could fix
your problem.

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



Re: [PHP] Help: Get the value of pi up to 200+ digits?

2005-09-01 Thread Torgny Bjers
Wong HoWang wrote:
 Dear all,

 I'm trying to do like this but failed:

 ?php
 ini_set('precision',16);
 echo pi();
 ?

 How can I get more digits after . ?

I am fairly sure that you have to use BCMath for this:
http://www.php.net/manual/en/ref.bc.php

Give it a go and see what happens! :)

Regards,
Torgny

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



Re: [PHP] Re: upload file - clients path to file?

2005-08-30 Thread Torgny Bjers
IMHO this is just a design issue, why not just hide the upload field,
display a message that they need not re-upload, and just add a hidden
field with the name of the uploaded file and once they've corrected
their fields, they re-post, and viola, you've got your file still.

[EMAIL PROTECTED] wrote:

Thanks for the replies.

Well basically i need it for an add products page and if the users doesnt 
fill
in all the fields correctly I display some error message as well as populate 
the
textfields and dropdown lists with the values they previously entered, so if
they entered/selected the file I want to display it again so they don't have to
upload the file again. I know that I could do it without the user knowing
(backed) but then they might think they have to select the file again because
the upload field will be blank.


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



Re: [PHP] php vulnerability

2005-08-22 Thread Torgny Bjers
Shafiq Rehman wrote:
 My server was hacked last week and the message displayed on home page was 
 spy kidz owns your server. I researched on internet and found that this is 
 some kind of trojan which infects the *.index files. It penetrate from HTTP. 
 Some paople were saying that there is vulnerability in PHP. Please help how 
 can I protect my server from further attacks.

Hello Shafiq,

One very common culprit in this scenario would be phpBB, especially
older versions, and if you are running PHP without safe_mode and
include_path directives, a script could very well overwrite every
world-writable (or web server writable) file on your entire server.
Happened to us once after a client had been running an old phpBB
version. We now have a set of scripts in place that scan our servers for
vulnerable scripts, phpBB among those, and alerts us when they're found
in a client's home directory.

So, to protect your server: turn on safe_mode. If clients (if you have
clients on the machine) request safe_mode to be turned off, you can do
that manually in httpd.conf for Apache (not sure about IIS on Windows).
Also, using hard include paths in the httpd.conf for each virtual host
will prevent the scripts running on a site from including/touching files
that are outside said paths unless they manage to run a shell with a PHP
script that can be activated without using php.ini, which might in this
case be another security hole.

Regards,
Torgny

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



Re: [PHP] Upgrading PHP 4.2.3 to PHP 4.3.2

2005-08-16 Thread Torgny Bjers
T.N.Prasad wrote:

HI All,
 
Our company servers are being upgraded from 4.2.3 to 4.3.2.
 
Is there any special care that I should take (as far as my scripts are
concerned)?
 
Plz help me. I'm new to PHP.


Hello,

You don't have to worry at all.

Nothing have changed between those versions that break compatibility
with older scripts. If you were to downgrade from 4.3.2 to 4.2.3
instead, that would pose problems if you for instance were using
internal functions such as file_get_contents() which appeared in 4.3.0. :)

Regards,
Torgny

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



Re: [PHP] counting nested array

2005-08-16 Thread Torgny Bjers
Ing. Josué Aranda wrote:

Hi to everyone..

now i have a little problem counting an nested array. Im using it to
fill a Java TreeView... it looks like this:

[snip]

The number of the branches is not always the same.. (it depends on the
query).. when i use count($array, COUNT_RECURSIVE) for nested arrays..
it give to me the total including the nodes in the branches ( in this
case 28).. now here is the question, how i can get only the last nodes
in this case ... exist a easy way to do it?. or its necessary to make
a funcion with a bunch of foreach?.. any suggestions are welcome =o) 
thanks!


Well, if you do a count of the root, you ought to get the amount of
numbers in there, and, with that number of the last item, access that
array, do a count() on that, get the last item, and so forth and so on,
you could write a small recursive function here to call itself with each
new child, getting the last item, down into the structure until X level.

Not sure if there's a PHP native function for doing this, though.
Perhaps someone else knows. If nothing else, try this way.

Regards,
Torgny

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



Re: [PHP] Problem with php.ini

2005-08-16 Thread Torgny Bjers
Tim Boring wrote:

I'm having a problem with php-cli and php_mod reading my php.ini file.
I've compiled php from source, during which process I set
--with-config-file=/etc.  Once the compile completed, I then copied
php.ini-recommened to /etc/php.ini.

After restarting Apache, I run phpinfo() and Configuration File Path
is showing only /etc, which means it's not find /etc/php.ini.  So then
I tried the cli and ran phpinfo() from it and same thing.  If I run it
as php -c /etc/php.ini, it can find/read it.  

For what it's worth, this is happening on a Gentoo system, but this
shouldn't make too much of a difference since I've compiled PHP from
source (v5.0.4), the same source I've used on a couple of other
(non-Gentoo) machines.

Just in case, here's the configure command I used:
'./configure' '--with-apxs2=/usr/sbin/apxs2' '--disable-cgi'
'--with-config-file-path=/etc' '--with-openssl' '--with-zlib'
'-enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-dba'
'--with-db4' '--with-inifile' '--with-flatfile' '--enable-dio'
'--enable-ftp' '--enable-gmp' '--with-unixODBC' '--with-pgsql'
'--with-readline' '--enable-soap' '--enable-sockets' '--enable-wddx'
'--with-xsl' '--with-pear'

Any ideas?
  


I think that --with-config-file-path is an absolute path to the php.ini
file, and not just a directory name, although, it ought to default to
php.ini, but perhaps when setting that directive it assumes that you are
specifying a custom configuration file, for instance /etc/php5_alt.ini
or /etc/my_php.ini instead of just php.ini. So, I think you should use
the --sysconfdir directive instead if you just want to specify where PHP
has its ini file.

Regards,
Torgny

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



Re: [PHP] ? PHP in XML document

2005-08-15 Thread Torgny Bjers
Labunski wrote:

Hello,

Is it possible to write some PHP code lines in the XML document?

e.g. I want to add ?php require_once(read_database.php); ? to the xml 
document, but
I don't know the right syntax to do this.

Btw, I need this, cause I'm trying to make CMS system for Flash page.


The easiest way to do this in Flash is to call a PHP script instead of
an XML file in Flash, that way you can render the XML document however
you want with PHP and load data directly from the database into XML or
whatever you wish. So, replace the XML filename for your PHP script, and
that way you should be able to add querystrings and whatnot too.

Regards,
Torgny

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



Re: [PHP] which operating system?

2005-08-15 Thread Torgny Bjers
Sebastian wrote:

 I will be building a new server and wondering what would be a good
 choice for php/mysql/apache other than redhat.

 I was thinking either Debian or CentOS. can anyone share their
 thoughts on them for php environment?

 does anyone use them on high traffic php sites? or is there not a
 difference in what distro you run php on?

 sorry these may sound like stupid questions but i mostly used redhat
 since i started using php and thought i'd try something different


I can recommend CentOS. We've been running it for some time now on
several of our hosting machines with Plesk setups. But, as far as that
goes, it doesn't make a lick of difference if you're running Debian,
CentOS, or another flavor, as long as you've got a 2.6 kernel and a
decently optimized setup for your PHP sites. The 2.6 kernel makes a lot
of difference when it comes to scaling Apache. With the 2.4 kernel our
Apache 2.0 was somewhat sensitive to DOS attacks, mostly on the memory
side, but with 2.6 and grsec it runs like a dream.

Regards,
Torgny

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



Re: [PHP] Re: ? PHP in XML document

2005-08-15 Thread Torgny Bjers
Well, in this case, XML would care, since you'd be using a  or  inside
a tag, so, in order for that to work, if what he meant was that he
wanted to store PHP code directly inside the XML document, and not
actually EXECUTE code INSIDE the XML file, he would have to use
![CDATA[bla]] syntax around the PHP code for it not to break the XML file.

So, in this case that would be:
root
data![CDATA[?php require_once(read_database.php); ?]]/data
/root

Which works fine as long as he doesn't have ]] somewhere in the code. :)

Satyam wrote:

Whatever starts with ? immediatly followed by an identifier is called a 
Processing Instruction, which ends with a ?   XML doesn't care what is 
within those tags, as long as it doesn't contain a ?

Satyam



Labunski [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
  

Hello,

Is it possible to write some PHP code lines in the XML document?

e.g. I want to add ?php require_once(read_database.php); ? to the xml 
document, but
I don't know the right syntax to do this.

Btw, I need this, cause I'm trying to make CMS system for Flash page.

Thanks a lot!
Roman 



  


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



Re: [PHP] one more mysql question

2005-08-15 Thread Torgny Bjers
Shaw, Chris - Accenture wrote:

I agree with Sebastian, there is no excuse for being arrogant and rude.
I understand the frustration, but is there any need for some of the replies
people get?

If I can, I will try to help anyone, even if the thread is OT.

C.


On that note I think we can agree to disagree on various topics and
leave the beating of dead horses to another list, perhaps alt.flame or
something? :P

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



[PHP] Migrating PHP4 to PHP5 (WAS: 'God' has spoken... :-))

2005-08-15 Thread Torgny Bjers
Miles Thompson wrote:

 The problem with PHP 5 is that the ISP's have to be so conservative.
 There's no tagging mechanism which says process these files with
 PHP5, use PHP 4 for everything else.


That would be so wonderful. Just to be able to set what PHP .so to use
based on VirtualHost/ or Directory/ in Apache would be bliss. Under
Windows it's easier, of course, since you have specific configurations
for each virtual host in IIS.

I've tried running the CGI version of PHP5 on a PHP4 system, and of
course it works, but it's slower than molasses in January.

 So, based on experience, better to move early than later. I suspect a
 jump from PHP4 to PHP6 will be huge -- the problem is to move the ISPs.


A lot of ISPs run some form of enterprise Linux, or it could be just a
control panel, that is dependent on the RPM version of PHP, which in
most cases is still stuck arond 4.3.x somewhere, except in those cases
where the ISP has taken the law in their own hands and compiled PHP from
scratch, overwriting the RPM version, and hoping that this will not
break anything too seriously when the control panel tries to upgrade
itself the next time. ;)

Others use scripts that are encoded with either IonCube or Zend, and are
thus forced to stay with PHP4 since their software vendor hasn't made
the leap yet. For instance, when encoding with Zend Encoder for PHP4,
you can get some pretty nasty errors when running under PHP5.

If the software vendors could make the leap RIGHT NOW and convert their
godforsaken software to PHP5 and release two versions since there'll
hardly be any difference in the code, we'd be a long way already. It's
all mostly related to the encoder in these cases, for instance Zend.

That's the way we do it with one of the applications I've written, it's
shipped both as PHP4 and PHP5 Zend encoded, as well as IonCube encoded.

Warm Regards,
Torgny

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



Re: [PHP] 'God' has spoken... :-)

2005-08-14 Thread Torgny Bjers
Sebastian wrote:

 Greg Donald wrote:

 On 8/14/05, Sebastian [EMAIL PROTECTED] wrote:
  

 now if they say php5 is 20% faster than php4 than i would upgrade
 overnight ;)
   


 Who is 'they' ?  Go write a benchmark and see for yourself.
  


 obviously coming from the developers..
 i guess im more or less wanting to know exactly where the php5
 performance gains are over php4, if any.

 sure i can do benchmarks, but again, would be nice to hear from the
 devs on certain performance gains as well as overall. 


As Robert said, if you have heavy Object Oriented applications (properly
coded), PHP5 is likely to speed up your application, in some cases,
remarkably. It also gains in other cases, such as when using certain
template engines, where the cached templates are a lot faster, for
instance Flexy and Sigma, which I've found were lots faster on PHP5.

Regards,
Torgny

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



Re: [PHP] curl?

2005-08-13 Thread Torgny Bjers
Wong HoWang wrote:

Hi, Everybody!

I got this when I execute the script:
Fatal error: Call to undefined function: curl_init() in msnp9.class.php on 
line 259

is there anyway to solve it?


Yes, by installing the curl libraries. If you are using Windows and PHP
5.0, you can get the curl library DLL from the PECL collection:

http://www.php.net/get/pecl-5.0.4-Win32.zip/from/a/mirror

If you are using Linux, you can add the --with-curl (or was it
--enable-curl) configure argument and re-compile PHP.

Regards,
Torgny

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



Re: [PHP] Sort multi array.

2005-08-13 Thread Torgny Bjers
João Cândido de Souza Neto wrote:

I´ve in a array the coluns: date , weekday , hour , etc...

I need to sort him by coluns 0 and 2 but not found the correctly function to
do it.

Take a look at this manual page:

http://www.php.net/manual/en/function.array-multisort.php

Regards,
Torgny

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



Re: [PHP] 'God' has spoken... :-)

2005-08-13 Thread Torgny Bjers
Jochem Maas wrote:

 if you haven't seen it yet and are interested in the future
 of php you might be interested in the _big_ thread on php-internals
 that starts with the message:

 http://www.manucorp.com/archives/internals/200508/msg00398.php

 IMHO every halfbaked php coder should read it ;-)


I suppose I am halfbaked. Maybe even a bit burnt and crispy on the
edges, Jochem.

Greatest news I've heard in a long time. Remove register_globals and
magic_quotes_*! Wow. Well, considering that they've been the cause for
most of the simpler PHP hacks that could have been prevented had not
register_globals been active. :P

I am not so sure that removing function aliases and making identifiers
case-sensitive is academic purity alone, though. I consider that a very
good step towards more easily managed code, that way there's only one
function, and no aliases, or case-specific variations thereof.

After reading the responses to Rasmus' post I am delighted to see that
most of the list has agreed to this as well, splendid. Some of these
were what I had expected for 5.x though, so in part I am disappointed
that they were not already removed/implemented.

/Torgny

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



[PHP] XSL namespaces and callbacks

2005-08-12 Thread Torgny Bjers
Hello,

A while back I posted a question in relation to XSL namespaces and
callbacks, but never got a response, not even a flame, which I found a
bit odd for this list. :P  I know this is pretty cutting-edge for PHP
since the XSL library has only been used in PHP 5, well, except for the
XSLT/Sablotron that was available for 4.

My original post can be found here:
http://marc.theaimsgroup.com/?l=php-generalm=112299671816888w=2

What I am trying to do here is what the .NET framework does in XSL by
adding a custom namespace that binds to an Assembly and a class. Is this
at all possible in PHP? The reason why I am asking this is because I do
not want the end user to be able to execute any type of PHP code through
XSL, which they can if I call $xslt-registerPHPFunctions(); and enable
the php namespace through

xsl:stylesheet version=1.0
   xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
   xmlns:php=http://php.net/xsl;

For security reasons I would want to limit the user to a specific custom
library class instead of allowing them to use the php:function() that
can call any PHP method/function/internal.

So, instead of:
xsl:value-of select=php:function('ClassName::Method', ./@id)/
I would like the call to be:
xsl:value-of select=namespace.classname:Method(./@id)/

Where the stylesheet declaration looks like:
xsl:stylesheet version=1.0
   xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
   xmlns:namespace.classname=urn:namespace.classname

Since that way they can only call the macro classes/methods that have
been validated and added as libraries when loading the XSL renderer.

Any help in this matter is greatly appreciated. Also, if somebody can
forward this matter to the PHP internals, Jochem comes to mind, it would
be awesome. I think this would definitely be a very competitive feature
for the PHP XSL implementation.

Warm Regards,
Torgny

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



Re: [PHP] logs problem

2005-08-12 Thread Torgny Bjers
FSA wrote:
 hi, i have a big php script with alot of db inserts and updates, what i
 want to do it's to log all this db commands into a table. I was wonderig
 if there is a better way to do this than the insert into logs_table the
 actual queryes.
 
 ty

Depending the amount of queries and the number of times the actual
script is loaded, your logs could flood very easily and bog down the
server. These notions of logging EVERYTHING is sometimes worse than
actually allowing the culprit script to run slowly or execute lots of
queries. 4 GB of logfile says way less than actually reading through the
script and checking to make sure that the queries are proper. If you are
still intent on logging these queries, I would go with your logs_table
idea and limit the fields and field lengths to the extreme and index it
tightly to make sure that it does not grow too much in size, that means,
char or varchar, and definitely no text/blob fields.

If this is a web script, one idea would be to only trigger the logging
for a specific set of IP numbers, so that only your own browser triggers
the logging, but it is left dormant while others browse.

Regards,
Torgny

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



Re: [PHP] getting ip of server

2005-08-12 Thread Torgny Bjers
Tom Cruickshank wrote:
 Hello,
 I'm curious to know if there is a php command that can get the IP of the 
 server it's running on. I could always do this...
 
 $results = exec(/sbin/ifconfig ethernet device | grep broadcast | awk 
 '{print $2}', $value);
 
 but I would prefer to not have to use system commands for this.
 
 Would anyone happen to know?

This is one of the few times I say RTFM :D
http://www.php.net/manual/en/language.variables.predefined.php

Look under $_SERVER and there's a whole bunch of nice stuff.

Regards,
Torgny

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



Re: [PHP] optional rule quick_form

2005-08-11 Thread Torgny Bjers
I am assuming that this is after a post operation. If it's JavaScript, I
think the question should be directed to another list. So, if you group
the elements that should be validated after the checkbox has been
checked, you can activate/deactivate the group validation rules based on
the state of the checkbox. Makes sense?

Regards,
Torgny

Uroš Gruber wrote:

 Hi!

 I have one checkbox. I checkbox is checked I show additional fields
 (just set visiblity to true).  But some of that fields are required
 only if this checkbox is checked. Is this possible with quick_form. I
 try myself with grouping but without any luck.

 regards

 Uros


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



Re: [PHP] Redisplaying information from a HTML form

2005-08-11 Thread Torgny Bjers
Ravi Gogna wrote:

[snip]

 I've managed to write the checking program in such a way that clicking
 submit launches an 'error' page which displays at the top of the page
 which field is wrong, and then redisplays the form. (The form
 redisplay is done using a function which uses the variables I used in
 the HTML form page). My problem is this: when the 'error' page comes
 up all of the text boxes will quite happily redisplay the data that
 was put into them, but I have a couple of drop-down boxes and radio
 buttons which lose their value. Is there a way I can make these boxes
 and buttons retain their value?


The easiest way to do this is to keep all the select option items in an
associative array and iterating this with foreach or for to output the
option/ elements. That way you can directly check the value of each
option to detect which was selected.

MailerCode(tm):

?php
$select = array('a' = 'Item 1', 'b' = 'Item 2', 'c' = 'Item 3');
?
form ...
select name=MySelect id=MySelect
?php
foreach ($select as $value = $text) {
$selected = '';
if (!empty($_POST['MySelect'])  $_POST['MySelect'] == $value) {
   $selected = ' selected';
}
printf('option value=%s%s%s/option%s', $value, $selected,
$text, \r\n);
}
?
/select
/form

Warm Regards,
Torgny

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



Re: [PHP] optional rule quick_form

2005-08-11 Thread Torgny Bjers
Uroš Gruber wrote:

 Torgny Bjers said the following on 11.8.2005 14:44:

 I am assuming that this is after a post operation. If it's JavaScript, I
 think the question should be directed to another list. So, if you group
 the elements that should be validated after the checkbox has been
 checked, you can activate/deactivate the group validation rules based on
 the state of the checkbox. Makes sense?


 If I understand your idea the code would look like this
 $form-addElement('text', 'taxNumber', 'Tax:');
 $checkbox = HTML_QuickForm::createElement('checkbox', 'isCompany','');

 if ($checkbox-getChecked()) {
 $form-addRule('taxNumber','required','Tax number is required');
 }

 if ($form-validate()) {
 


That would be the idea, yes. It was some time since worked with
Quick_Form, so there might be a specific order you need to perform the
adding of the rule in relation to the validate() method call on the
$form object.

 Btw yes it must be checked when user submit this. But If it's possible
 client option on rule, would be better.


I am not sure about this, is there even client-side validation support
in Quick_Form? Haven't really looked into this. I would suggest writing
a manual javascript evaluation for the specific fields that should be
visible when the checkbox is checked, or to have a postback between. The
JavaScript option sounds most tempting, since it makes it a bit more
user-friendly. That way you can use the JavaScript alert() function to
present the fields that have erroneous information as well as altering
styles in the fields in question to perhaps have a red border to
indicate errors.

Regards,
Torgny

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



Re: [PHP] possible bug (string equality to zero)?

2005-08-11 Thread Torgny Bjers
No, Christopher, that is not a bug. As long as the var is empty, and if
you try to compare with 0, or false, it will report true in the
comparison because the variable does not contain anything, which will
mean false for a boolean and 0 for a variable. If you are attempting to
discover if a string contains data, use empty() instead. You can also
check if the string is null or actual zero (0).

Regards,
Torgny

Christopher J. Bottaro wrote:

Is it a bug that ($var == 0) is always true for any string $var?


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



Re: [PHP] Exceptions: function x throws Exception

2005-08-05 Thread Torgny Bjers
Norbert Wenzel wrote:
 If there is a class with a function, that might throw exceptions and
 does NOT catch them, may I write that like in Java?
 
 class FooClass {
 
 public function foo() throws Exception {
 
 }
 
 }
 
 Or is there another possibility to tell a function throws an exception
 and to force the caller to handle that exception?
 
 thanks in advance,
 
 Norbert
 

Hello Norbert,

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }

Regards,
Torgny

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



Re: [PHP] Timing out a remote call

2005-08-04 Thread Torgny Bjers
Brian Dunning wrote:

 For one project, I'm required to access a web service for every page. 
 Basically it returns a little bit of random text. I have no control 
 over the web service, and there is no possibility of cacheing or 
 bringing it locally: the requirements are that it be accessed live 
 across the Internet every time.

 Most times it's instantaneous, but sometimes it can hang. I want to 
 give it a half-second timeout, which we're allowed to do, but there's 
 no documentation provided. Here is how we call it now (really simple):

   include('http://04planet.info/kfc/grab_one.php');

 I have STFW and RTFM and could only find vague references like use 
 fsockopen instead or stream_set_timeout() but I can't find an 
 actual complete working example anywhere. Any pointers?

Generally, using include or file_get_contents() for a remote call is a
Bad Idea. Perhaps if you used curl instead? You have a lot more control
over the entire call that way. Of course, the curl code might be a bit
bulkier in PHP, but I find it works quite well.

As for fsockopen(), it works just like a file pointer.

http://www.php.net/manual/en/function.fsockopen.php

That manual page gives a pretty good description of how to use it.

Idea: The socket will by default be opened in blocking mode. You can
switch it to non-blocking mode by using stream_set_blocking().

The last parameter to fsockopen() is the timeout for connecting to the
socket, and the manual describes it as such:

Note:  If you need to set a timeout for reading/writing data over the
socket, use stream_set_timeout(), as the timeout  parameter to
fsockopen() only applies while connecting the socket.

Regards,
Torgny

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



[PHP] XSL custom xmlns/urn in PHP5 for callbacks

2005-08-02 Thread Torgny Bjers
Hello,

I recently started working with PHP5 after having spent quite some time
with C#.NET (at work), and I was wondering if there's a way to create a
custom callback namespace for XSL in PHP5? The example below should
illustrate what I need:

?xml version=1.0 encoding=UTF-8?
xsl:stylesheet
version=1.0
xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
xmlns:myapp.library=urn:myapp.library
exclude-result-prefixes=myapp.library

xsl:output method=html/

xsl:param name=currentPage/

xsl:template match=/xsl:value-of
select=myapp.library:ClassMethod('arg1', 'arg2')
disable-output-escaping=yes//xsl:template

/xsl:stylesheet

Hope someone can help here. If not possible, I can always use the
standard PHP function/class::method callbacks, but it would be nice to
have custom xmlns so that I could add several different libraries.

Warm Regards,
Torgny

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread Torgny Bjers
Hello Justin,

I would guess that this is mostly performance and memory related. When,
for instance, trying to iterate an array, or a directory with files,
using @ on all function calls, it will attempt to go through the array,
attempting to allocate memory for each item, but when finding it
empty/broken, it leaves the loop and goes on to the next statement in
the code.

From what I can tell, PHP handles memory efficiently, although I
wouldn't hazard this when deploying a larger site using this type of
approach. Especially if the code inside a larger if..else block was
performed on an object that was created with @function() call, and then
all the consecutive calls to functions operating on that object also
used @. This would take up both CPU time and memory, possibly creating
leaks, based on how efficiently PHP would handle the operations on a
non-existant object.

A rule of thumb is to instead use empty() and is_array() and such
functions to discern if the object you are going to handle indeed is of
the type you wish it to be, that saves you both time and effort when
trying to debug something in the future. The empty() function goes a
long way here, unless dealing with integers, since empty() will return
true if the value is 0, which might not be desireable.

I hope this helps you in your argument against your fellow developer. :]

Regards,
Torgny

Justin Burger wrote:

Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


Thanks Again.

Justin.
  


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



Re: [PHP] Converting integer type to long

2005-08-02 Thread Torgny Bjers
Wee Keat wrote:

The problem is, I have not been able to convert PHP's integer/float type
to long because there is no function that does it. Or is there?


The reason why is because there's no real long support in PHP.

But, since you mention a value such as 0.01, you are not looking for a
long, you are looking for a float. So, what you need to do is to
type-cast all the values involved in the making of the variable that
holds the float value.

For instance:
$var = (float)$var1 / (float)$var2;
$query = sprintf('%.2f %s', (float)$var, $string);

I haven't found the exact points where PHP forgets it's a float, but
it's always good to make sure all mathematical operations are performed
on the value as a float by type-casting, otherwise it might lose
information.

Regards,
Torgny

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