php-general Digest 27 Aug 2007 18:51:18 -0000 Issue 4985

Topics (messages 261354 through 261373):

Re: Capturing shell command output.
        261354 by: shiplu

Re: PHP and SOAP calls
        261355 by: Angelo Zanetti

Why not user...?
        261356 by: Gustav Wiberg
        261360 by: Robert Cummings
        261361 by: Jay Blanchard
        261362 by: Stut
        261363 by: Gustav Wiberg

Re: Adding text before last paragraph
        261357 by: Brian Rue

Re: Database includes
        261358 by: Stut

Re: PHP4 vs PHP5 Performance?
        261359 by: Nathan Nobbe

[Job] Developer Position [50-100k] (New Hope, PA)
        261364 by: Gavin M. Roy

A simple PHP script to generate a Pie Chart based on SQL query
        261365 by: Ali, Saqib
        261367 by: Wolf
        261368 by: Ludovic André
        261370 by: mike

xml reader/writer
        261366 by: Sam Baker
        261371 by: Jay Blanchard

move_uploaded_file fails randomly with open_basedir and upload_tmp_dir
        261369 by: Hugues De Keyzer

why?
        261372 by: Gustav Wiberg
        261373 by: Stut

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
On 8/27/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
> You could look into using "named pipes" in PHP.
>
> I think PHP is already folding stderr into stdout (2>&1) for you.
>
> You could also try using http://php.net/exec instead of the backticks
> to get a separate error code if there is an error.
>
> On Sat, August 18, 2007 3:26 pm, shiplu wrote:
> > HI,
> > I am working on a PHP project that interacts with command  line
> > utilities.
> > My php is running by apache. Means I am not running any php CLI.
> >
> > here is the function that I am using for capturing command output.
> >
> > function run_command($comamnd){
> > $ret=`$command 1> COMMAND.OUT 2>1`;
> > $contents=get_file_contents("COMMAND.OUT");
> > return $contents;
> > }
> >
> > The function does not work. If I use any shell command like ls, cat,
> > echo, set. it works.
> > But If I use any utility like, mpg321, cd-info. It does not work. It
> > outputs a blank string.
> > I used system(), passthru() with both "2&>1" and "2>1". But no out
> > put.
> > All the time, its blank.
> > Even I used a shell script "run.sh"
> > run.sh contents:
> > =====================================
> > #!/bin/sh
> > sh COMMAND 1> COMMAND.OUT 2&>1
> > cat COMMAND.OUT
> > echo 0 > COMMAND
> > =====================================
> >
> > I called this script by this function
> > function run_command($command){
> >                $h=fopen("COMMAND","w");
> >                fwrite($h,$command);
> >                fclose($h);
> >                ob_start();
> >                passthru("./run.sh");
> >                $ret = ob_get_contents();
> >                ob_end_clean();
> >                return $ret;
> > }
> >
> > and by this.
> >
> > function run_command($command){
> >                $h=fopen("COMMAND","w");
> >                fwrite($h,$command);
> >                fclose($h);
> >                return system("./run.sh");
> > }
> >
> > Please help me. or show me some way.
> >
> >
> > --
> > shout at http://shiplu.awardspace.com/
> >
> > Available for Hire/Contract/Full Time
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
>
I have tried same file as cli and as webpage. I don't know why only
cli version works nicely.  There may be some issue. But my technique
has some advantages. It can run command asynchronously. Thats what i
need for my application. I can create command queue. I and I can get
the completion percentage from there.
Whatever, I wish I could know those issues.
Rather it could happen that, php-apache framework is doing something
that I am unaware of.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time

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


Richard Lynch wrote:
On Fri, August 24, 2007 12:55 am, Angelo Zanetti wrote:
Dear All

I have been using nusoap to development a client that makes SOAP calls
to a server. I have however been stuck on a  small issue but can't
seem
to solve it and therefore I need to relook at using another package to
get a solution.

So I have read that PEAR also has a package that makes SOAP calls
(PEAR::SOAP). And there is PHP-SOAP.

Now Im running PHP 4.4xxx and I need to get this up and running ASAP.
What would you suggest I use as the package to make the client calls?

I have read that the PEAR::SOAP thing is fairly easy to use?

Does anyone have suggestions or recommendations or what not to use and
why?

I have fought with SOAP in PHP 5, and PHP 4, and I think maybe even
PHP 3 (shudder).

I've used nuSoap, and I think I used PEAR::SOAP once.  I also tried to
use some other SOAP package once, I think, that failed miserably.

My recommendations:

#1
If you can move to PHP 5 and use the built-in SOAP there, do it ASAP.
It's like night and day.

#2
If you are stuck in PHP 4, try the PEAR::SOAP.
I believe it will handle the whatsit tag namespace-y thingie you are
getting with that <tag:0> business better than nuSoap, as I recall.  I
won't swear to it in court, though, as I only use PEAR::SOAP once
before I moved to PHP 5 and my SOAP life was way way way cleaner.
Thanks Richard.

I've pretty much got it working with nuSoap but lack of documentation and support makes it difficult to progress quickly and is very frustrating.

Angelo

--

--- End Message ---
--- Begin Message ---
Hi!

Why is it so that I get this error. I'm using Windows Integrated authorization-method for actual webb I'm testing on.

Notice: Undefined index: PHP_AUTH_USER in C:\www\utveckling\username.php on line 2


?

Best regards
/Gustav Wiberg
--- End Message ---
--- Begin Message ---
On Mon, 2007-08-27 at 09:56 +0200, Gustav Wiberg wrote:
> Hi!
> 
> Why is it so that I get this error. I'm using Windows Integrated 
> authorization-method for actual webb I'm testing on.
> 
> Notice: Undefined index: PHP_AUTH_USER in C:\www\utveckling\username.php on 
> line 2

Because on line 2 of C:\www\utveckling\username.php an attempt is made
to access that variable or a key in an array by that name when the
variable (or key) does not exist. Probably the page wasn't requested
with any auth but the script expects it.

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

--- End Message ---
--- Begin Message ---
[snip]
Why is it so that I get this error. I'm using Windows Integrated 
authorization-method for actual webb I'm testing on.

Notice: Undefined index: PHP_AUTH_USER in C:\www\utveckling\username.php
on 
line 2
[/snip]

Hmm, can only take a guess since we do not see what sets PHP_AUTH_USER,
but line 2 is trying to use it and it appears not to be set.

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
Why is it so that I get this error. I'm using Windows Integrated authorization-method for actual webb I'm testing on.

Notice: Undefined index: PHP_AUTH_USER in C:\www\utveckling\username.php on line 2

For some reason it's not getting set. This could be because you've not configured IIS correctly, are you sure you've disabled anonymous authentication?

If you're sure it's configured correctly try var_dump'ing $_SERVER - it's possible (though unlikely) the username is in another place.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Hi!

Thanx!
I figured it out. The username wasn't in server-variable PHP_AUTH_USER but in AUTH_USER ....

Best regards
/Gustav Wiberg


----- Original Message ----- From: "Stut" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>
Cc: "PHP General" <[EMAIL PROTECTED]>
Sent: Monday, August 27, 2007 3:51 PM
Subject: Re: [PHP] Why not user...?


Gustav Wiberg wrote:
Why is it so that I get this error. I'm using Windows Integrated authorization-method for actual webb I'm testing on.

Notice: Undefined index: PHP_AUTH_USER in C:\www\utveckling\username.php on line 2

For some reason it's not getting set. This could be because you've not configured IIS correctly, are you sure you've disabled anonymous authentication?

If you're sure it's configured correctly try var_dump'ing $_SERVER - it's possible (though unlikely) the username is in another place.

-Stut

--
http://stut.net/


--- End Message ---
--- Begin Message ---
Dotan, try this:

$text="<p>First paragraph</p>\n<p>More text</p>\n<p>Some more
text</p>\n<p>End of story</p>";

$story = preg_replace('{(?=<p(?:>|\s)(?!.*<p(?:>|\s)))}is', "<p>new
paragraph goes here</p>\n", $text);

This matches a position that has an opening <p> tag (with or without
parameters), which is NOT followed anywhere in $text by another opening <p>
tag. The replacement string will be inserted at the matched position, which
will be directly before the last <p> tag. Not sure if this is the most
efficient regex, but it should get the job done. Let me know how it goes...
I'd also be interested to hear any comments on that regex's efficiency.

-Brian Rue


Dotan Cohen wrote:

> On 27/08/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
>> On Sun, August 26, 2007 3:41 pm, Dotan Cohen wrote:
>> > I have a string with some HTML paragraphs, like so:
>> > $text="<p>First paragraph</p>\n<p>More text</p>\n<p>Some more
>> > text</p>\n<p>End of story</p>";
>> >
>> > I'd like to add an image before the last paragraph. I know that
>> > preg_replace can replace only the first n occurrences of a string, but
>> > how can I replace the _last_ occurrence of a string? My initial idea
>> > was to do this:
>> > 1) Count how many  times "</p>\n<p>" occurs as $n
>> > 2) Replace them all with  "</p>\n<img src= alt=>\n<p>"
>> > 3) Replace $n-1 replacements back to "</p>\n<p>"
>> >
>> > Is there a cleaner way? Thanks in advance.
>>
>> If the string really really ENDS on that LAST "</p>", then you can key
>> off of that:
>>
>> $story = preg_replace("|(<p>.*</p>\$|Umsi",
>> "<p>$new_paragraph</p>\n\\1", $story;
>>
>> You may have to fiddle with the DOT_ALL setting to only match the true
>> end of string and not just any old "\n" within the string...
>> http://php.net/pcre
>>
> 
> Thanks, Richard, I was also trying to use a regex with pre_replace and
> getting nowhere. In the manual page for strrpos, there is a
> user-comment function for finding the last occurrence of a string:
> http://il2.php.net/manual/en/function.strrpos.php#56735
> 
> However, I am unable to piece 2 and 2 together.
> 
> Note that I'm adding a paragraph before the last paragraph, so I'm
> searching for the last instance of "</p>\n<p>".
> 
> This is what I've done to your code, but I'm unable to get much further:
> $text = preg_replace("|(</p>\n<p>)\$|Umsi", "</p>\n<p>Test</p>\n<p>",
> $text);
> 
> Dotan Cohen
> 
> http://lyricslist.com/
> http://what-is-what.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
Bruce Cowin wrote:
I'm curious as to how everyone organises and includes their classes in
PHP5.  Let's take a simple example that has 3 classes: customer, order,
and database.  The database class has a base sql db class (I know there
is PDO and other things but this class is already written and working)
and classes that inherit from the base class for dev, test, and prod,
passing the associated logins.  The customer and order will both use the
appropriate database class depending on which environment its in (e.g.,
SalesDevDB, SalesTestDB, SalesProdDB).

I don't want to have to go into the customer and order class code and
change which db class it uses when I move it from dev to test and from
test to prod.  What's the proper way to handle this?  Or am I way off
base?

Could you just have 3 config files and use the appropriate one in each environment?

The settings are in 'config.php'. When it's in dev:

cp dev.php config.php

when it's in test:

cp test.php config.php

I use a slightly different approach to prevent the need to mess about with files when moving to production. At the end on config.php I have this...

if (file_exists('config_dev.php'))
    require 'config_dev.php';

In config_dev.php I override anything defined in config.php that needs to be different on the current server. The config_dev.php file is *not* in source control so it doesn't exist in production but each development and test environment has a version that modifies the production environment.

There is a hit involved in the call to file_exists, but PHP caches it so the effect is minimal.

-Stut

--
http://stut.net/

--- End Message ---
--- Begin Message ---
Stut wrote:

> Just wanted to pick you up on this. PHP is the only language you've
> listed that only has a single implementation. There are implementations
> of C++ compilers that are writting in other languages. I can't speak for
> Java since I have little experience but I'd be surprised if all
> implementations are written in C.


one thing thats nice about java is it has a formal specification.  so in
creating
alternative implementations they can be certified against the spec by sun.
i
think thats another big plus of java.


> they are high level, and although php allows you to write proceedrual
> > code, i think it is best used from an oop paradigm.
>
> This would be a personal choice. Just like C++ "allows you to write
> procedural code" there are times when OOP makes sense and times when
> procedural is "better". It's a choice that should be left up to the
> developer, and the argument over whether OOP is better than procedural
> is not winnable. It's in the same league as PHP vs Python.
>

unfortunately im a bit rusty w/ my c++; but looking a java the only way to
write
procedural code is to place it in a method called main inside of a class.
does that
count as procedural or does it count as oop ??
when i say oop paradigm i refer to the overall design of an application, or
framework.
said app consists largely of objects; each w/ a focused purpose, the methods
of
which are also small and have a focused purpose.
*sigh*  i dont care to get into this debate again.  in my mind its clear oop
is superior to
strictly procedural programming, but alas you are probably right.  so whats
the use in
arguing ..?

-nathan

--- End Message ---
--- Begin Message ---
Are you tired of working on the same types of web apps?  Are you
looking for more of a challenge where you can put your code-fu to its
test working in a high-traffic, open-source friendly environment?  Can
you tackle any problem put in front of you, hacking your way through
problems you've not previously encountered?

myYearbook.com is looking to fill a primarily PHP development position
that reports directly to the CTO.  Applicant should have a strong
development background and problem solving skills, be a good
communicator and be willing to take direction.  This position is out
of our mainline development team and is for working on special
projects, be it infrastructure related, working on pre-existing open
source applications we use, bleeding edge development or
proof-of-concept applications.

Perks include being paid well to work on open source projects, free
gym membership, company stock options, health & dental insurance, and
don't forget pushing your development skills and knowledge in
different directions.

Requirements:

 * Strong knowledge of PHP and PostgreSQL
 * Some background in database design
 * Ability to demonstrate more than a base level knowledge of XML,
XSL, XHTML, CSS, JavaScript
 * Familiarity with Linux as a server or desktop
 * Past experience with SVN or other version control systems
 * Knowledge of C, C++ and other languages such as Ruby or Java a plus
 * Should not be intimidated by doing things you haven't done before
 * Solid work record with excellent references

This job is full-time, on-site in New Hope, PA.  Unfortunately we can
not sponsor H1-B visas.  We have a great office atmosphere and
benefits to match.  We are very invested in the Open Source community
and this position is a great way to leverage your open-source interest
into a important role in our organization.  You should be willing to
relocate and if you fit this role, we'll help pay for you to do  so.

Salary commensurate with experience.

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

I am looking for a simple PHP script that can generate Pie Chart based
on SQL query resultset.

I don't want a reporting system, as we are already using Crystal
Reports for that.

Any suggestions?

Saqib Ali

--- End Message ---
--- Begin Message ---
http://www.hotscripts.com/PHP/Scripts_and_Programs/Graphs_and_Charts/index.html

or 

http://www.phpclasses.org/browse/package/1063.html

or

http://www.google.com/search?q=PHP%3A+Pie+Chart&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

I've used the PHP classes one onces before, and used the one on hotscripts for 
another project.  There are some pay-for ones as well, but either of those 2 
should give you a good starting point even if you want to roll your own.

Robert


---- "Ali wrote: 
> Hello All,
> 
> I am looking for a simple PHP script that can generate Pie Chart based
> on SQL query resultset.
> 
> I don't want a reporting system, as we are already using Crystal
> Reports for that.
> 
> Any suggestions?
> 
> Saqib Ali
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

I am looking for a simple PHP script that can generate Pie Chart based
on SQL query resultset.
http://www.aditus.nu/jpgraph/

This lib works great!

Ludo

--- End Message ---
--- Begin Message ---
> > Hello All,
> >
> > I am looking for a simple PHP script that can generate Pie Chart based
> > on SQL query resultset.
> >
> > I don't want a reporting system, as we are already using Crystal
> > Reports for that.
> >
> > Any suggestions?

one word is all you need:

jpgraph

--- End Message ---
--- Begin Message ---
So I don't have to reinvent anything, does such a thing exist anywhere that 
anyone knows of:

I'm looking for a php script that will read any xml file, display the
contents in html, with the option of adding an entry (in the same scheme,
whatever that might be) or deleting existing entries.

I think I could write this, but it would take a while.

Thanks
-§

--- End Message ---
--- Begin Message ---
[snip]
So I don't have to reinvent anything, does such a thing exist anywhere
that 
anyone knows of:

I'm looking for a php script that will read any xml file, display the
contents in html, with the option of adding an entry (in the same
scheme,
whatever that might be) or deleting existing entries.

I think I could write this, but it would take a while.
[/snip]

http://www.php.net/xmlreader
http://www.php.net/xmlwriter

You will have to use some XSLT to do the content display

http://www.php.net/xslt

--- End Message ---
--- Begin Message ---
Hi all,

I'm having a weird problem on my web hosting provider's server. I'm using drupal with the image module and the image_pub module to upload a series of pictures using Gallery Remote. This software uploads pictures one after the other using a classic HTTP POST method.

The upload always succeeds, but the problem I have is that move_uploaded_file() randomly fails.
open_basedir is set to /home/
DOCUMENT_ROOT is /home/myuser
upload_tmp_dir is set to ./tmp-php/, which exists is /home/myuser and has full 777 permission the script is called from the DOCUMENT_ROOT directory: /test.php which is in fact /home/myuser/test.php

In the script, just before calling move_uploaded_file, I created a file in the current directory with debug values in it. It is indeed created in the DOCUMENT_ROOT directory.

The errors I have are:

First, 2 times:
move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/var/tmp/phpNN2JDd) is not within the allowed path(s): (/home/)

then:
move_uploaded_file(/var/tmp/phpNN2JDd) [function.move-uploaded-file]: failed to open stream: Operation not permitted

move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpNN2JDd' to 'files/tmp/res-2108703551.jpg'

When it succeeds, the file is correctly uploaded in ./tmp-php. When it fails, it goes to /var/tmp although upload_tmp_dir is still set to "./tmp-php/". is_uploaded_file() returns true even when move_uploaded_file() fails.

What seems really strange to me is that it fails *randomly*. It works for a couple of picture, then fails, then succeeds again, etc.

My web hosting provider doesn't really seem to care about such problems, so if I can point out this is a PHP bug and ask them for an update, it would be great.

Running PHP version 5.1.6 on FreeBSD 5.4-RELEASE-p13

Configure Command './configure' '--enable-fastcgi' '--prefix=/usr/local/php5' '--with-config-file=/usr/local/php5/lib/php.ini' '--with-config-file-path=/usr/local/php5/lib' '--enable-versioning' '--with-openssl' '--with-zlib' '--with-zlib-dir=/usr' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--with-jpeg-dir=/usr/local' '--with-tiff-dir=/usr/local' '--with-curl=/usr/local' '--enable-exif' '--enable-ftp' '--with-gd=/usr/local' '--with-png-dir=/usr/local' '--with-xpm-dir=/usr/local' '--with-ttf' '--with-freetype-dir=/usr/local' '--with-t1lib' '--enable-gd-native-ttf' '--with-gdbm' '--with-gettext' '--with-imap-ssl' '--enable-mbstring' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr/local' '--with-unixODBC' '--with-dom=/usr/local' '--with-dom-xslt=/usr/local' '--with-dom-exslt=/usr/local' '--with-mcal' '--with-xsl' '--enable-xslt' '--with-xslt-sablot' '--with-iconv-dir=/usr/local' '--enable-trans-sid' '--enable-memory-limit' '--enable-zend-multibyte'

Server API  CGI/FastCGI

Apache/1.3.37 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0404142202

--- End Message ---
--- Begin Message ---
Hi!

I can't figure the thing with Windows Integrated authentication... I have checked a website for doing this. I still have to enter username and password even if I'm on the local computer (through a VPN though) This would be the same as using computer locally on the network, but I have to enter username and password. I'm sure I have checked the "Windows Integreated authenication" - checkbox for the website it's about.

When I have entered username and password I can go on and do whatever I want on that site...

I've tested with both IE6, and IE7. What could be the problem?

Best regards
/Gustav Wiberg

--- End Message ---
--- Begin Message ---
Gustav Wiberg wrote:
I can't figure the thing with Windows Integrated authentication... I have checked a website for doing this. I still have to enter username and password even if I'm on the local computer (through a VPN though) This would be the same as using computer locally on the network, but I have to enter username and password. I'm sure I have checked the "Windows Integreated authenication" - checkbox for the website it's about.

When I have entered username and password I can go on and do whatever I want on that site...

I've tested with both IE6, and IE7. What could be the problem?

Transparent authentication between IE and IIS may not work over a VPN depending on a huge number of factors, but mainly how the VPN server has been configured.

Does it work when on the same network as the web server and AD server?

-Stut

--
http://stut.net/

--- End Message ---

Reply via email to