php-general Digest 15 Nov 2009 10:20:08 -0000 Issue 6443

Topics (messages 299823 through 299840):

Re: exec() problem
        299823 by: Ashley Sheridan
        299824 by: A. Mannini
        299825 by: A. Mannini
        299826 by: Ashley Sheridan
        299827 by: A. Mannini
        299828 by: A. Mannini
        299829 by: Ashley Sheridan
        299830 by: Kim Madsen
        299831 by: A. Mannini
        299832 by: A. Mannini

Re: exec() problem [SOLVED]
        299833 by: A. Mannini

Re: RIGHT Function?
        299834 by: sono-io.fannullone.us

File To Blob Corruption
        299835 by: Don Wieland
        299836 by: German Geek
        299840 by: Ashley Sheridan

Re: uniqid() and repetition of numbers generated
        299837 by: German Geek

Re: What method is best for generating thumbnails in PHP from PDF's?
        299838 by: German Geek

Re: Need suggestions on PHP frameworks
        299839 by: German Geek

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Sat, 2009-11-14 at 22:20 +0100, A. Mannini wrote:

> Hi all,
> 
> i've a problem using exec() on a Linux server with PHP 5.2.9 on Apache 
> 2.2.13. Safe mode is OFF and Apache isn't chrooted.
> 
> I would run /usr/lib/mailman/bin/find_member -l <list> <email> so i used 
> exec("sudo run /usr/lib/mailman/bin/find_member -l <list> 
> <email>",$output) and set /etc/sudoers with apache ALL=NOPASSWD: 
> /usr/lib/mailman/bin/find_member    but it doesn't work.
> 
> I tried simple commands "/bin/ls" works, "sudo -V" work but "sudo 
> /bin/ls" doesn't work.
> 
> I get return code 1 and no messages in logs..
> 
> What is worng?
> 
> Thanks
> 
> Alessandro
> 


Did you mean to put 'run' into the exec call?

Thanks,
Ash
http://www.ashleysheridan.co.uk



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

i've a problem using exec() on a Linux server with PHP 5.2.9 on Apache
2.2.13. Safe mode is OFF and Apache isn't chrooted.

I would run /usr/lib/mailman/bin/find_member -l <list> <email> so i used
exec("sudo run /usr/lib/mailman/bin/find_member -l <list>
<email>",$output) and set /etc/sudoers with apache ALL=NOPASSWD:
/usr/lib/mailman/bin/find_member    but it doesn't work.

I tried simple commands "/bin/ls" works, "sudo -V" work but "sudo
/bin/ls" doesn't work.

I get return code 1 and no messages in logs..

What is worng?

Thanks

Alessandro

--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:

Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk



Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro

--- End Message ---
--- Begin Message ---
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

> Ashley Sheridan ha scritto:
> >
> > Have you checked to ensure that the exec is actually running at all? 
> > Check the error logs to see what they say. There may be a problem with 
> > the string argument for exec(), like an unescaped character that is 
> > causing an issue
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> Yes i had no messages in Apache logs so i tried to use error_log in 
> php.ini but again no messages.
> Don't know if there is a way to see what php module interpeter and try 
> to execute.
> 
> Thanks
> 
> Alessandro
> 


I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro



I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Looked to all log...nothing! :-(

--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro



I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Looked to all log...nothing! :-(

--- End Message ---
--- Begin Message ---
On Sun, 2009-11-15 at 00:25 +0100, A. Mannini wrote:

> Ashley Sheridan ha scritto:
> > On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:
> > 
> >> Ashley Sheridan ha scritto:
> >>> Have you checked to ensure that the exec is actually running at all? 
> >>> Check the error logs to see what they say. There may be a problem with 
> >>> the string argument for exec(), like an unescaped character that is 
> >>> causing an issue
> >>>
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>>
> >>>
> >> Yes i had no messages in Apache logs so i tried to use error_log in 
> >> php.ini but again no messages.
> >> Don't know if there is a way to see what php module interpeter and try 
> >> to execute.
> >>
> >> Thanks
> >>
> >> Alessandro
> >>
> > 
> > 
> > I think for something like that, you should be looking at your system
> > logs, as that's likely where the errors would log.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> > 
> 
> Looked to all log...nothing! :-(
> 


What other logs did you look at?

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Ashley Sheridan wrote on 2009-11-15 00:23:

Looked to all log...nothing! :-(



What other logs did you look at?

Then do this from a command line:

su - "the user apache runs as"

copy the command from the ph script and run it from commandline and let us see the error you recieve...

--
Kind regards
Kim Emax - masterminds.dk

--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro



I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Ok i found that Fedora has, as default, a line Defaults requiretty in /etc/sudoers, i disabled that ....but i get a different message.

sudo: no tty present and no askpass program specified


--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro



I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Ok i found that Fedora has, as default, a line Defaults requiretty in /etc/sudoers, i disabled that ....but i get a different message.

sudo: no tty present and no askpass program specified



--- End Message ---
--- Begin Message ---
Ashley Sheridan ha scritto:
On Sun, 2009-11-15 at 00:06 +0100, A. Mannini wrote:

Ashley Sheridan ha scritto:
Have you checked to ensure that the exec is actually running at all? Check the error logs to see what they say. There may be a problem with the string argument for exec(), like an unescaped character that is causing an issue

Thanks,
Ash
http://www.ashleysheridan.co.uk


Yes i had no messages in Apache logs so i tried to use error_log in php.ini but again no messages. Don't know if there is a way to see what php module interpeter and try to execute.

Thanks

Alessandro



I think for something like that, you should be looking at your system
logs, as that's likely where the errors would log.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Ok commenting out Defaults requiretty now it works!

The second message "
sudo: no tty present and no askpass program specified" was due to wrong command issued during tests.

Many thanks

Alessandro

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

On Nov 13, 2009, at 6:34 PM, Jim Lucas wrote:

You basic problem with the PHP_EOL is that when echo'ed out, it represents a \n character.
The value you are working with might be \n\r or just \r

I read the links you sent, plus some others. It took me awhile, but I get it now. If the "return character" that was entered into that field is not the same as what PHP_EOL is looking for, it won't work.

$parts = preg_split('|[\n\r]+|', $item['unitprice']);

preg_split works perfectly! Very similar to Perl's split function. Here's what I have now:

$parts = preg_split('|\s+|', $item['unitprice']);
$price = '$'.number_format((count($parts) > 1) ? $parts[(count($parts)-1)] : $parts[0],2);

Clean and concise. Thanks a million, Jim! I really appreciate your helpful responses.

Thanks again,
Frank

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

I am trying to create an UPLOAD page to Update a Images and PDFs into a BLOB field in mySQL. The image keeps getting corrupted (it draws a portion of the image and the rest is GRAY) We tried it with Safari and Firefox with bad results.

Here is the form that is used to browse and select the file.

<!-- Upload Image dialog -->
<div id="uploadImage">
<div id="llback"></div>
<center><div id="uploadForm">
<div id="uploadTitle">Upload Thumbnail image</div>
<iframe name="saveImage"></iframe>
<b>Please select the thumbnail image, then press Upload.</b>
<div style="margin-top:14px;margin-bottom:14px;text-align:center;width: 100%"> <form target="saveImage" method="post" action="ajax/saveDialog.php" enctype="multipart/form-data"> Select Thumbnail: <input type="file" name="img" id="img" accept="image/ jpeg" /></div>
<input type="hidden" name="obj" value="uploadImage" />
<input type="hidden" name="id" value="<?php echo $Area_id ?>" />
<input type="button" value="Upload" onclick="saveDialog('uploadImage','img','jpg');"> <input type="button" value="Cancel" onclick="cancelDialog('uploadImage','img')">
</form>
</div></center>
</div>

Here is the QUERY to upload the image (saveDialog.php):

if($_POST['obj'] == "uploadImage") {
$file = $db->real_escape_string(file_get_contents($_FILES['img'] ['tmp_name']));
$db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);

Has anyone else ever run into this type of UPDATE error with images and PDF? We really need to get this dealt with ASAP.

Thanks!

Don Wieland
D W   D a t a   C o n c e p t s
~~~~~~~~~~~~~~~~~~~~~~~~~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or higher
http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html


--- End Message ---
--- Begin Message ---
Hi, Could it have something to do with an eof character being encoded or
something like that? Do you really need to store the files in the DB? It
uses more processing power if stored in the DB because on retrieval, you
have to unescape the string and return it. Modern filesystems are optimised
better for files than databases and storing a filename and returning the
contents is easier to implement than retrieving it from the DB...

http://forums.codewalkers.com/php-applications-45/upload-image-file-to-mysql-as-blob-849194.html

++Tim Hinnerk Heuer++

http://www.ihostnz.com


2009/11/15 Don Wieland <d...@dwdataconcepts.com>

> Hello,
>
> I am trying to create an UPLOAD page to Update a Images and PDFs into a
> BLOB field in mySQL. The image keeps getting corrupted (it draws a portion
> of the image and the rest is GRAY) We tried it with Safari and Firefox with
> bad results.
>
> Here is the form that is used to browse and select the file.
>
> <!-- Upload Image dialog -->
> <div id="uploadImage">
> <div id="llback"></div>
> <center><div id="uploadForm">
> <div id="uploadTitle">Upload Thumbnail image</div>
> <iframe name="saveImage"></iframe>
> <b>Please select the thumbnail image, then press Upload.</b>
> <div
> style="margin-top:14px;margin-bottom:14px;text-align:center;width:100%">
> <form target="saveImage" method="post" action="ajax/saveDialog.php"
> enctype="multipart/form-data">
> Select Thumbnail: <input type="file" name="img" id="img"
> accept="image/jpeg" /></div>
> <input type="hidden" name="obj" value="uploadImage" />
> <input type="hidden" name="id" value="<?php echo $Area_id ?>" />
> <input type="button" value="Upload"
> onclick="saveDialog('uploadImage','img','jpg');"> <input type="button"
> value="Cancel" onclick="cancelDialog('uploadImage','img')">
> </form>
> </div></center>
> </div>
>
> Here is the QUERY to upload the image (saveDialog.php):
>
> if($_POST['obj'] == "uploadImage") {
> $file =
> $db->real_escape_string(file_get_contents($_FILES['img']['tmp_name']));
> $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);
>
> Has anyone else ever run into this type of UPDATE error with images and
> PDF? We really need to get this dealt with ASAP.
>
> Thanks!
>
> Don Wieland
> D W   D a t a   C o n c e p t s
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> d...@dwdataconcepts.com
> Direct Line - (949) 305-2771
>
> Integrated data solutions to fit your business needs.
>
> Need assistance in dialing in your FileMaker solution? Check out our
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
>
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
> higher
> http://www.appointment10.com
>
> For a quick overview -
> http://www.appointment10.com/Appt10_Promo/Overview.html
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sun, 2009-11-15 at 16:43 +1300, German Geek wrote:

> Hi, Could it have something to do with an eof character being encoded or
> something like that? Do you really need to store the files in the DB? It
> uses more processing power if stored in the DB because on retrieval, you
> have to unescape the string and return it. Modern filesystems are optimised
> better for files than databases and storing a filename and returning the
> contents is easier to implement than retrieving it from the DB...
> 
> http://forums.codewalkers.com/php-applications-45/upload-image-file-to-mysql-as-blob-849194.html
> 
> ++Tim Hinnerk Heuer++
> 
> http://www.ihostnz.com
> 
> 
> 2009/11/15 Don Wieland <d...@dwdataconcepts.com>
> 
> > Hello,
> >
> > I am trying to create an UPLOAD page to Update a Images and PDFs into a
> > BLOB field in mySQL. The image keeps getting corrupted (it draws a portion
> > of the image and the rest is GRAY) We tried it with Safari and Firefox with
> > bad results.
> >
> > Here is the form that is used to browse and select the file.
> >
> > <!-- Upload Image dialog -->
> > <div id="uploadImage">
> > <div id="llback"></div>
> > <center><div id="uploadForm">
> > <div id="uploadTitle">Upload Thumbnail image</div>
> > <iframe name="saveImage"></iframe>
> > <b>Please select the thumbnail image, then press Upload.</b>
> > <div
> > style="margin-top:14px;margin-bottom:14px;text-align:center;width:100%">
> > <form target="saveImage" method="post" action="ajax/saveDialog.php"
> > enctype="multipart/form-data">
> > Select Thumbnail: <input type="file" name="img" id="img"
> > accept="image/jpeg" /></div>
> > <input type="hidden" name="obj" value="uploadImage" />
> > <input type="hidden" name="id" value="<?php echo $Area_id ?>" />
> > <input type="button" value="Upload"
> > onclick="saveDialog('uploadImage','img','jpg');"> <input type="button"
> > value="Cancel" onclick="cancelDialog('uploadImage','img')">
> > </form>
> > </div></center>
> > </div>
> >
> > Here is the QUERY to upload the image (saveDialog.php):
> >
> > if($_POST['obj'] == "uploadImage") {
> > $file =
> > $db->real_escape_string(file_get_contents($_FILES['img']['tmp_name']));
> > $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);
> >
> > Has anyone else ever run into this type of UPDATE error with images and
> > PDF? We really need to get this dealt with ASAP.
> >
> > Thanks!
> >
> > Don Wieland
> > D W   D a t a   C o n c e p t s
> > ~~~~~~~~~~~~~~~~~~~~~~~~~
> > d...@dwdataconcepts.com
> > Direct Line - (949) 305-2771
> >
> > Integrated data solutions to fit your business needs.
> >
> > Need assistance in dialing in your FileMaker solution? Check out our
> > Developer Support Plan at:
> > http://www.dwdataconcepts.com/DevSup.html
> >
> > Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
> > higher
> > http://www.appointment10.com
> >
> > For a quick overview -
> > http://www.appointment10.com/Appt10_Promo/Overview.html
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


Like someone mentioned on the link you posted; storing the images in the
database does offer a layer of security, as database access is far
easier to control than file access.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
2009/11/14 tedd <tedd.sperl...@gmail.com>

> A
>

Interesting thought. My idea on this is to use the approach used when
replicating a DB. It is similar to the namespace idea if not the same:

Say you have 3 databases, you could use mod 3 numbers for A=0, B=1 and C=2
So on A you would have 0, 3, 6, 9, ... on B 1, 4, 7, 10, ... and on C 2, 5,
8, 11. This way you can just use auto increment and set the increment value
3 and the start value to 0,1,2 respectively. Also, this way you will not run
out of numbers until you run out of integers.

++Tim Hinnerk Heuer++

http://www.ihostnz.com

--- End Message ---
--- Begin Message ---
Hi, I've spent ages trying to figure out a good way for this. Ghostscript
and ImageMagick were slow and not giving satisfactory results because the
colors were wrong in some instances.

The solution for me was to use ImageMagick with X-PDF. You can install xpdf
in any linux distro or even on windows. It has a neat little program called
pdf2ppm which converts a PDF into a bitmap format which convert from
imagemagick can then transform. Even though the ppm images are huge, it
seems to work faster than using just convert.

++Tim Hinnerk Heuer++

http://www.ihostnz.com


2009/11/13 <clanc...@cybec.com.au>

> On Thu, 12 Nov 2009 09:45:55 -0800 (PST), stephe...@rogers.com (Stephen)
> wrote:
>
> >--- On Thu, 11/12/09, Chris Payne <chris_pa...@danmangames.com> wrote:
> >
> >> I have been asked to create thumbnails from the first page
> >> of a PDF
> >> document on the fly with PHP, I have looked online but am
> >> confused as
> >> there doesn't seem 1 simple solution.
> >
> >Go to sitepoint.com and search for "photo gallery in minutes"
>
> Sitepoint: Home ยป Search for "photo gallery in minutes"
>
> doesn't find anything for me?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Which framework to use is more of a religious war than anything, but I would
recommend Symfony. It has a nice architechture and is very extendable.

++Tim Hinnerk Heuer++

http://www.ihostnz.com


2009/11/13 Sudheer Satyanarayana <sudhee...@sudheer.net>

>
>  I doubt you'll get a reasoned bunch of suggestions, more a religious
>> war... :-) Still, I like PEAR components.
>>
>>
>>
> Exactly.
>
> You have to visit the websites of frameworks, comparison articles, etc and
> find out for yourself which one suits you best.
>
> Currently, if I get to decide, I choose ZF for all the new PHP projects. I
> am also comfortable with
> * my own framework
> * other frameworks like Symfony
> * framework less projects
>
> Recently, I wrote about ZF -
> http://techchorus.net/reasons-use-zend-framework
>
> --
>
> With warm regards,
> Sudheer. S
> Tech stuff: http://techchorus.net
> Business: http://binaryvibes.co.in
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to