Re: [PHP] Upload dir
my mistake didn't use move_uploaded_file to see if the uploading is working or not in the first case but i could not understand why 1. ini_get() is giving correct value while $_FILES['file']['tmp_name'] is ignoring that. 2. move_uploaded_file($_FILES['file']['tmp_name'], 'file.php'); is working fine but file_exists($_FILES['file']['tmp_name']) is returning false 3. php_admin_value upload_tmp_dir "/var/www/html" in httpd.conf seems to work ($_FILES['file']['tmp_name'] is not ignoring that); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
2009/12/11 kranthi : > How can i change the temporary upload directory? > var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in > php.ini) > string '/var/www/cgi-bin' (length=16) > > but > var_dump($_FILES) gives me > 'tmp_name' => string '/tmp/phpbSZ6WP' (length=14) > > var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp > has permissions drwxrwxrwt and i never used file_move_upload or any > similar functions) > boolean false > > am I missing something here? > Kranthi. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Just assuming you could alter the upload_tmp_dir setting in your code (you can't) ... PHP puts the uploaded files into the upload_tmp_dir BEFORE your script runs, so changing it in your script essentially hides the uploaded files. PHP drops the files into directory A. PHP then runs your code. Your code changes the directory to B. Your code cannot see the files PHP put into A as your code is now looking in B. But, as I said earlier, you can't use your code to change upload_tmp_dir. It can only be done at the system level (php.ini or httpd.conf). See [1] and [2]. Regards, Richard Quadling. [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads [2] http://docs.php.net/manual/en/configuration.changes.modes.php -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload dir
On Fri, 2009-12-11 at 15:44 +, Richard Quadling wrote: > 2009/12/11 kranthi : > > How can i change the temporary upload directory? > > var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in > > php.ini) > > string '/var/www/cgi-bin' (length=16) > > > > but > > var_dump($_FILES) gives > > me > > 'tmp_name' => string '/tmp/phpbSZ6WP' (length=14) > > > > var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp > > has permissions drwxrwxrwt and i never used file_move_upload or any > > similar functions) > > boolean false > > > > am I missing something here? > > Kranthi. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Just assuming you could alter the upload_tmp_dir setting in your code > (you can't) ... > > PHP puts the uploaded files into the upload_tmp_dir BEFORE your script > runs, so changing it in your script essentially hides the uploaded > files. > > PHP drops the files into directory A. > PHP then runs your code. > Your code changes the directory to B. > Your code cannot see the files PHP put into A as your code is now looking in > B. > > But, as I said earlier, you can't use your code to change > upload_tmp_dir. It can only be done at the system level (php.ini or > httpd.conf). See [1] and [2]. > > Regards, > > Richard Quadling. > > [1] http://docs.php.net/manual/en/ini.core.php#ini.sect.file-uploads > [2] http://docs.php.net/manual/en/configuration.changes.modes.php > > -- > - > Richard Quadling > "Standing on the shoulders of some very clever giants!" > EE : http://www.experts-exchange.com/M_248814.html > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > ZOPA : http://uk.zopa.com/member/RQuadling > The only reason I can see for wanting to do this would be where several sites exist on the same server and you might want each site to have its own temporary upload directory. It won't have any bearing on how you handle the uploads unless it becomes full. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Using Curl to replicate a site
On Thu, 2009-12-10 at 16:25 +, Ashley Sheridan wrote: > On Thu, 2009-12-10 at 11:25 -0500, Robert Cummings wrote: > > > Joseph Thayne wrote: > > > If the site can be a few minutes behind, (say 15-30 minutes), then what > > > I recommend is to create a caching script that will update the necessary > > > files if the md5 checksum has changed at all (or a specified time period > > > has past). Then store those files locally, and run local copies of the > > > files. Your performance will be much better than if you have to request > > > the page from another server every time. You could run this script > > > every 15-30 minutes depending on your needs via a cron job. > > > > Use URL rewriting or capture 404 errors to handle the proxy request. No > > need to download and cache the entire site if everyone is just > > requesting the homepage. > > > > Cheers, > > Rob. > > -- > > http://www.interjinn.com > > Application and Templating Framework for PHP > > > > > Yeah, I was going to use the page request to trigger the caching > mechanism, as it's unlikely that all pages are going to be equally as > popular as one another. I'll let you all know how it goes on! > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Well I got it working just great in the end. Aside from the odd issue with relative URLs use in referencing images and Javascripts that I had to sort out, everything seems to be working fine and is live. I've got it on a 12-hour refresh, as the site will probably not be changing very often at all. Thanks for all the pointers! Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] move_uploaded_file
Am I just drunk or blind or the documentation is simply wrong? >From the official doc (http://uk2.php.net/manual/en/function.move-uploaded-file.php): $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } } ?> The path for the upload dir should be a relative one, not an absolute one. Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] move_uploaded_file
You should be able to use either an absolute or relative path. In the code below, the path specified is absolute (it starts with /). If you want it to be relative to your current directory, change the line to: $uploads_dir = 'uploads'; or $uploads_dir = '../uploads'; So basically, it all depends on how you define your path. Joseph Roberto wrote: Am I just drunk or blind or the documentation is simply wrong? >From the official doc (http://uk2.php.net/manual/en/function.move-uploaded-file.php): $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir/$name"); } } ?> The path for the upload dir should be a relative one, not an absolute one. Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Backup to local drive
Hello - I have an application I'm building that allows users to store personal information and files (images, PDFs, etc.) in our database, but I need a way for them to be able to save the HTML output of that personal data to a local (for the user) flash drive. I'm guessing I'm going to need a clientSide language like javascript for this, but was wondering if maybe there was a PHP addon or something like that for downloading content to the user's PC. Thanks in advance. Ben
Re: [PHP] Backup to local drive
If you are wanting to save the information as a PDF (formatted the same as the HTML page), check out tcpdf at www.tcpdf.org. It is fairly simple to implement and can interpret an HTML page causing it to be saved as PDF. Joseph Ben Miller wrote: Hello - I have an application I'm building that allows users to store personal information and files (images, PDFs, etc.) in our database, but I need a way for them to be able to save the HTML output of that personal data to a local (for the user) flash drive. I'm guessing I'm going to need a clientSide language like javascript for this, but was wondering if maybe there was a PHP addon or something like that for downloading content to the user's PC. Thanks in advance. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] move_uploaded_file
HI, Premise 1: echo exec("pwd"); -> "/home/prof3ta/projects/moodle/htdocs/feedback_tool" Premise 2: I have an "upload" folder with 777 permissions under: /home/prof3ta/projects/moodle/htdocs/upload Premise 3: The server root is obviously htdocs: /home/prof3ta/projects/moodle/htdocs This said, the following doesn't work: The following does work: I consider it as a documentation bug (in the sample code they use an absolute path). I indeed believe I *should* be able to use both of them if not documented otherwise. I will dig into the C implementation of the move_uploaded_file function and I'll check, though. Cheers, Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Backup to local drive
Hi, you lost me a bit. Let say a user uploads a PDF file to one of your servers. What do you mean when you say "I want the users to be able to save the HTML output of their data"?!? Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > Hello - I have an application I'm building that allows users to store > personal information and files (images, PDFs, etc.) in our database, but I > need a way for them to be able to save the HTML output of that personal data > to a local (for the user) flash drive. I'm guessing I'm going to need a > clientSide language like javascript for this, but was wondering if maybe > there was a PHP addon or something like that for downloading content to the > user's PC. Thanks in advance. > > > > Ben > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] move_uploaded_file
When used in PHP, an absolute path does not go off the web root. In Premise 3 below, an absolute path of "/upload" will NOT bring up the directory "/home/prof3ta/projects/moodle/htdocs/upload" but rather simply "/upload" In Windows terms, an absolute path would be "C:\upload" versus "C:\home\prof3ta\projects\moodle\htdocs\upload". The only time an absolute path is figured relative to the web root is when it is referenced in a browser. At this point, for all intents and purposes, it locates the file based on the web root. This is a fundamental difference between absolute and relative paths. Absolute: begins at "/" in Linux operating systems and "C:\" in Windows OS Relative: begins wherever the running script is located in the file system. Joseph Roberto wrote: HI, Premise 1: echo exec("pwd"); -> "/home/prof3ta/projects/moodle/htdocs/feedback_tool" Premise 2: I have an "upload" folder with 777 permissions under: /home/prof3ta/projects/moodle/htdocs/upload Premise 3: The server root is obviously htdocs: /home/prof3ta/projects/moodle/htdocs This said, the following doesn't work: The following does work: I consider it as a documentation bug (in the sample code they use an absolute path). I indeed believe I *should* be able to use both of them if not documented otherwise. I will dig into the C implementation of the move_uploaded_file function and I'll check, though. Cheers, Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Server-side encryption to prevent form hacking: new idea?
If you have an HTML form select field xyz with possible values "apple", "banana", and "cucumber", anyone can easily set xyz to an arbitrary value. To prevent this, I create a hidden field code[xyz] with value: base64_encode(mcrypt_ecb( MCRYPT_RIJNDAEL_256,$salt,"apple,banana,cucumber",MCRYPT_ENCRYPT)); where $salt is stored in a file outside my webroot. The script receiving the POST data uses: mcrypt_ecb(MCRYPT_RIJNDAEL_256,$salt, base64_decode($_REQUEST[code][xyz]), MCRYPT_DECRYPT); and confirms xyz is really one of "apple", "banana", or "cucumber". Obviously, this can be extended to other types of form fields, and the check value can be a regular expression or even a function call. Is this a new idea, or have people done this before? -- We're just a Bunch Of Regular Guys, a collective group that's trying to understand and assimilate technology. We feel that resistance to new ideas and technology is unwise and ultimately futile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server-side encryption to prevent form hacking: new idea?
Kelly Jones wrote: If you have an HTML form select field xyz with possible values "apple", "banana", and "cucumber", anyone can easily set xyz to an arbitrary value. To prevent this, I create a hidden field code[xyz] with value: base64_encode(mcrypt_ecb( MCRYPT_RIJNDAEL_256,$salt,"apple,banana,cucumber",MCRYPT_ENCRYPT)); where $salt is stored in a file outside my webroot. The script receiving the POST data uses: mcrypt_ecb(MCRYPT_RIJNDAEL_256,$salt, base64_decode($_REQUEST[code][xyz]), MCRYPT_DECRYPT); and confirms xyz is really one of "apple", "banana", or "cucumber". Obviously, this can be extended to other types of form fields, and the check value can be a regular expression or even a function call. Is this a new idea, or have people done this before? If the server-side script knows which values are expected, then there is no need to send that to the client (browser) and back. If this is not simply hard-coded in your script, you can keep it in a different file, in a database, or in the session, depending on your particular situation. For most of the fields, the number of acceptable values aren't limited to a small set, so it's more practical to check for expected length, data type, and escape the data before saving it. Cheers, Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Server-side encryption to prevent form hacking: new idea?
you don't necessarily need encryption, you could use digests instead and issue a use-once ticket as well. On Fri, Dec 11, 2009 at 12:29 PM, Mattias Thorslund wrote: > Kelly Jones wrote: >> >> If you have an HTML form select field xyz with possible values >> "apple", "banana", and "cucumber", anyone can easily set xyz to an >> arbitrary value. >> >> To prevent this, I create a hidden field code[xyz] with value: >> base64_encode(mcrypt_ecb( >> MCRYPT_RIJNDAEL_256,$salt,"apple,banana,cucumber",MCRYPT_ENCRYPT)); >> >> where $salt is stored in a file outside my webroot. >> >> The script receiving the POST data uses: >> >> mcrypt_ecb(MCRYPT_RIJNDAEL_256,$salt, >> base64_decode($_REQUEST[code][xyz]), MCRYPT_DECRYPT); >> >> and confirms xyz is really one of "apple", "banana", or "cucumber". >> >> Obviously, this can be extended to other types of form fields, and the >> check value can be a regular expression or even a function call. >> >> Is this a new idea, or have people done this before? >> > > If the server-side script knows which values are expected, then there is no > need to send that to the client (browser) and back. If this is not simply > hard-coded in your script, you can keep it in a different file, in a > database, or in the session, depending on your particular situation. For > most of the fields, the number of acceptable values aren't limited to a > small set, so it's more practical to check for expected length, data type, > and escape the data before saving it. > > Cheers, > > Mattias > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Issue with $HTTP_POST_VARS Not getting Variables
Hello, I am working with a login page to use with an application that we are planning to make available as a web service. The login.php page itself works correctly, however when I try and pass parameters to the login page the are not being recognized by the login.php page. Here is the basic code that I am dealing with to attempt to the the variables: When I enter the url http://localost/index.php?username=jasperadmin&password=** Where localhost is the ip address of my server and ** is the password of the user that is logging in, I am not having the username questioned and the login.php isacting as if I have not entered any parameters. Why are the parameters not being accepted? I am using php version 5.2.6 on a ubuntu linux box Thank you Eric H. Lommatsch Programmer 360 Business
Re: [PHP] Issue with $HTTP_POST_VARS Not getting Variables
On Fri, 2009-12-11 at 13:37 -0700, Eric Lommatsch wrote: > Hello, > > I am working with a login page to use with an application that we are > planning to make available as a web service. The login.php page itself works > correctly, however when I try and pass parameters to the login page the are > not being recognized by the login.php page. > > Here is the basic code that I am dealing with to attempt to the the > variables: > > > $username = $HTTP_POST_VARS['username']; > > $password = $HTTP_POST_VARS['password']; > > $username = $_POST['username']; > > $password = $_POST['password']; > > echo $username; > > ?> > > When I enter the url > http://localost/index.php?username=jasperadmin&password=** > > Where localhost is the ip address of my server and ** is the password of > the user that is logging in, I am not having the username questioned and the > login.php isacting as if I have not entered any parameters. > > Why are the parameters not being accepted? > > I am using php version 5.2.6 on a ubuntu linux box > > > Thank you > > Eric H. Lommatsch > Programmer > 360 Business > First off, take out those HTTP_POST_VARS lines. That's an outdated way of accessing post variables, and is made useless by the next two lines that follow it. Second, the two lines you are using at the end there are for post data, but you clearly use get data in the URL! If you have to accept the username and password from both get and post, change the lines to use $_REQUEST instead of $_POST. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Server-side encryption to prevent form hacking: new idea?
On Fri, Dec 11, 2009 at 3:34 PM, Michael Shadle wrote: > On Fri, Dec 11, 2009 at 12:29 PM, Mattias Thorslund > wrote: >> Kelly Jones wrote: >>> >>> If you have an HTML form select field xyz with possible values >>> "apple", "banana", and "cucumber", anyone can easily set xyz to an >>> arbitrary value. >>> >>> To prevent this, I create a hidden field code[xyz] with value: >>> base64_encode(mcrypt_ecb( >>> MCRYPT_RIJNDAEL_256,$salt,"apple,banana,cucumber",MCRYPT_ENCRYPT)); >>> >>> where $salt is stored in a file outside my webroot. >>> >>> The script receiving the POST data uses: >>> >>> mcrypt_ecb(MCRYPT_RIJNDAEL_256,$salt, >>> base64_decode($_REQUEST[code][xyz]), MCRYPT_DECRYPT); >>> >>> and confirms xyz is really one of "apple", "banana", or "cucumber". [snip] >> >> If the server-side script knows which values are expected, then there is no >> need to send that to the client (browser) and back. If this is not simply >> hard-coded in your script, you can keep it in a different file, in a >> database, or in the session, depending on your particular situation. For >> most of the fields, the number of acceptable values aren't limited to a >> small set, so it's more practical to check for expected length, data type, >> and escape the data before saving it. >> >> Cheers, >> >> Mattias > you don't necessarily need encryption, you could use digests instead > and issue a use-once ticket as well. > Why is any of this necessary? Most of the time I build select lists from arrays, so it is easy to test the value submitted by the client to make sure it exists in the array without any encryption or hashing. Am I missing something? Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Issue with $HTTP_POST_VARS Not getting Variables
Doh, I should have thought of that! Thanks, that is what happens when you use code that someone else has writen and included with a software package. At least I assumed that the code was already written correctly to accept parameters. I guess it wasn't. Thank you Eric H. Lommatsch Programmer 360 Business From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 1:39 PM To: Eric Lommatsch Cc: php-general@lists.php.net Subject: Re: [PHP] Issue with $HTTP_POST_VARS Not getting Variables On Fri, 2009-12-11 at 13:37 -0700, Eric Lommatsch wrote: Hello, I am working with a login page to use with an application that we are planning to make available as a web service. The login.php page itself works correctly, however when I try and pass parameters to the login page the are not being recognized by the login.php page. Here is the basic code that I am dealing with to attempt to the the variables: When I enter the url http://localost/index.php?username=jasperadmin&password=** Where localhost is the ip address of my server and ** is the password of the user that is logging in, I am not having the username questioned and the login.php isacting as if I have not entered any parameters. Why are the parameters not being accepted? I am using php version 5.2.6 on a ubuntu linux box Thank you Eric H. Lommatsch Programmer 360 Business First off, take out those HTTP_POST_VARS lines. That's an outdated way of accessing post variables, and is made useless by the next two lines that follow it. Second, the two lines you are using at the end there are for post data, but you clearly use get data in the URL! If you have to accept the username and password from both get and post, change the lines to use $_REQUEST instead of $_POST. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Issue with $HTTP_POST_VARS Not getting Variables
Because you're passing the args through the Url (GET), not through a POST request. Roberto Aloi On 11 Dec 2009, at 20:37, "Eric Lommatsch" wrote: Hello, I am working with a login page to use with an application that we are planning to make available as a web service. The login.php page itself works correctly, however when I try and pass parameters to the login page the are not being recognized by the login.php page. Here is the basic code that I am dealing with to attempt to the the variables: When I enter the url http://localost/index.php?username=jasperadmin&password=** Where localhost is the ip address of my server and ** is the password of the user that is logging in, I am not having the username questioned and the login.php isacting as if I have not entered any parameters. Why are the parameters not being accepted? I am using php version 5.2.6 on a ubuntu linux box Thank you Eric H. Lommatsch Programmer 360 Business -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Backup to local drive
Users would be updating data via form input (address, tel, product catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating their own presentations and saving those presentations to a flash drive as HTML files with calls to the images/PDFs so that they can simply plug their drive into a USB port and present the info on the road, regardless of connection to the internet. Ben -Original Message- From: Roberto [mailto:prof...@gmail.com] Sent: Friday, December 11, 2009 11:58 AM To: Ben Miller Cc: php-general@lists.php.net Subject: Re: [PHP] Backup to local drive Hi, you lost me a bit. Let say a user uploads a PDF file to one of your servers. What do you mean when you say "I want the users to be able to save the HTML output of their data"?!? Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > Hello - I have an application I'm building that allows users to store > personal information and files (images, PDFs, etc.) in our database, but I > need a way for them to be able to save the HTML output of that personal data > to a local (for the user) flash drive. I'm guessing I'm going to need a > clientSide language like javascript for this, but was wondering if maybe > there was a PHP addon or something like that for downloading content to the > user's PC. Thanks in advance. > > > > Ben > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Backup to local drive
On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: > Users would be updating data via form input (address, tel, product > catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating > their own presentations and saving those presentations to a flash drive as > HTML files with calls to the images/PDFs so that they can simply plug their > drive into a USB port and present the info on the road, regardless of > connection to the internet. > > Ben > > -Original Message- > From: Roberto [mailto:prof...@gmail.com] > Sent: Friday, December 11, 2009 11:58 AM > To: Ben Miller > Cc: php-general@lists.php.net > Subject: Re: [PHP] Backup to local drive > > Hi, > > you lost me a bit. Let say a user uploads a PDF file to one of your servers. > What do you mean when you say "I want the users to be able to save the > HTML output of their data"?!? > > Roberto Aloi > http://aloiroberto.wordpress.com > Twitter: @prof3ta > > On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > > Hello - I have an application I'm building that allows users to store > > personal information and files (images, PDFs, etc.) in our database, but I > > need a way for them to be able to save the HTML output of that personal > data > > to a local (for the user) flash drive. I'm guessing I'm going to need a > > clientSide language like javascript for this, but was wondering if maybe > > there was a PHP addon or something like that for downloading content to > the > > user's PC. Thanks in advance. > > > > > > > > Ben > > > > > > Why not create all the HTML files and images on the server, and zip it up then send that down to the user? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Backup to local drive
Too much reliance on the user knowing how to extract the files to the flash drive – need something that does it all for them so all they have to do is insert the flash drive on their own computer to store the preformatted presentation and then insert into a prospect’s computer and either a) (preferred) run the presentation via an autoplay command or b) open the presentation.html file. Ben From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 2:25 PM To: Ben Miller Cc: 'Roberto'; php-general@lists.php.net Subject: RE: [PHP] Backup to local drive On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: Users would be updating data via form input (address, tel, product catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating their own presentations and saving those presentations to a flash drive as HTML files with calls to the images/PDFs so that they can simply plug their drive into a USB port and present the info on the road, regardless of connection to the internet. Ben -Original Message- From: Roberto [mailto:prof...@gmail.com] Sent: Friday, December 11, 2009 11:58 AM To: Ben Miller Cc: php-general@lists.php.net Subject: Re: [PHP] Backup to local drive Hi, you lost me a bit. Let say a user uploads a PDF file to one of your servers. What do you mean when you say "I want the users to be able to save the HTML output of their data"?!? Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > Hello - I have an application I'm building that allows users to store > personal information and files (images, PDFs, etc.) in our database, but I > need a way for them to be able to save the HTML output of that personal data > to a local (for the user) flash drive. I'm guessing I'm going to need a > clientSide language like javascript for this, but was wondering if maybe > there was a PHP addon or something like that for downloading content to the > user's PC. Thanks in advance. > > > > Ben > > Why not create all the HTML files and images on the server, and zip it up then send that down to the user? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Backup to local drive
On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: > Too much reliance on the user knowing how to extract the files to the flash > drive – need something that does it all for them so all they have to do is > insert the flash drive on their own computer to store the preformatted > presentation and then insert into a prospect’s computer and either a) > (preferred) run the presentation via an autoplay command or b) open the > presentation.html file. > > > > Ben > > > > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: Friday, December 11, 2009 2:25 PM > To: Ben Miller > Cc: 'Roberto'; php-general@lists.php.net > Subject: RE: [PHP] Backup to local drive > > > > On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: > > > Users would be updating data via form input (address, tel, product > catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating > their own presentations and saving those presentations to a flash drive as > HTML files with calls to the images/PDFs so that they can simply plug their > drive into a USB port and present the info on the road, regardless of > connection to the internet. > > Ben > > -Original Message- > From: Roberto [mailto:prof...@gmail.com] > Sent: Friday, December 11, 2009 11:58 AM > To: Ben Miller > Cc: php-general@lists.php.net > Subject: Re: [PHP] Backup to local drive > > Hi, > > you lost me a bit. Let say a user uploads a PDF file to one of your servers. > What do you mean when you say "I want the users to be able to save the > HTML output of their data"?!? > > Roberto Aloi > http://aloiroberto.wordpress.com > Twitter: @prof3ta > > On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > > Hello - I have an application I'm building that allows users to store > > personal information and files (images, PDFs, etc.) in our database, but I > > need a way for them to be able to save the HTML output of that personal > data > > to a local (for the user) flash drive. I'm guessing I'm going to need a > > clientSide language like javascript for this, but was wondering if maybe > > there was a PHP addon or something like that for downloading content to > the > > user's PC. Thanks in advance. > > > > > > > > Ben > > > > > > > > > Why not create all the HTML files and images on the server, and zip it up > then send that down to the user? > > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > > > That could end up in a lot of HTML and image files. Also, if you can't rely on people to unzip a file, can you rely on them to know that they need to keep the images with the HTML? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Backup to local drive
That’s exactly why I need something that will put all the needed files directly onto the flash drive – to take that responsibility away from the user. Pulling the data from the DB and creating the folder structure is easy with PHP – just not sure how to copy that folder structure and related files to the flash drive without the user having to know much of anything about computers. Was hoping there is maybe a PHP extension that I didn’t know about, but sounds like a client side is going to be my best bet. From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 2:39 PM To: Ben Miller Cc: 'Roberto'; php-general@lists.php.net Subject: RE: [PHP] Backup to local drive On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: Too much reliance on the user knowing how to extract the files to the flash drive – need something that does it all for them so all they have to do is insert the flash drive on their own computer to store the preformatted presentation and then insert into a prospect’s computer and either a) (preferred) run the presentation via an autoplay command or b) open the presentation.html file. Ben From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 2:25 PM To: Ben Miller Cc: 'Roberto'; php-general@lists.php.net Subject: RE: [PHP] Backup to local drive On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: Users would be updating data via form input (address, tel, product catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating their own presentations and saving those presentations to a flash drive as HTML files with calls to the images/PDFs so that they can simply plug their drive into a USB port and present the info on the road, regardless of connection to the internet. Ben -Original Message- From: Roberto [mailto:prof...@gmail.com] Sent: Friday, December 11, 2009 11:58 AM To: Ben Miller Cc: php-general@lists.php.net Subject: Re: [PHP] Backup to local drive Hi, you lost me a bit. Let say a user uploads a PDF file to one of your servers. What do you mean when you say "I want the users to be able to save the HTML output of their data"?!? Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > Hello - I have an application I'm building that allows users to store > personal information and files (images, PDFs, etc.) in our database, but I > need a way for them to be able to save the HTML output of that personal data > to a local (for the user) flash drive. I'm guessing I'm going to need a > clientSide language like javascript for this, but was wondering if maybe > there was a PHP addon or something like that for downloading content to the > user's PC. Thanks in advance. > > > > Ben > > Why not create all the HTML files and images on the server, and zip it up then send that down to the user? Thanks, Ash http://www.ashleysheridan.co.uk That could end up in a lot of HTML and image files. Also, if you can't rely on people to unzip a file, can you rely on them to know that they need to keep the images with the HTML? Thanks, Ash http://www.ashleysheridan.co.uk
RE: [PHP] Backup to local drive
On Fri, 2009-12-11 at 15:04 -0700, Ben Miller wrote: > That’s exactly why I need something that will put all the needed files > directly onto the flash drive – to take that responsibility away from > the user. Pulling the data from the DB and creating the folder > structure is easy with PHP – just not sure how to copy that folder > structure and related files to the flash drive without the user having > to know much of anything about computers. Was hoping there is maybe a > PHP extension that I didn’t know about, but sounds like a client side > is going to be my best bet. > > > > > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: Friday, December 11, 2009 2:39 PM > To: Ben Miller > Cc: 'Roberto'; php-general@lists.php.net > Subject: RE: [PHP] Backup to local drive > > > > > > On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: > > > > Too much reliance on the user knowing how to extract the files to the flash > drive – need something that does it all for them so all they have to do is > insert the flash drive on their own computer to store the preformatted > presentation and then insert into a prospect’s computer and either a) > (preferred) run the presentation via an autoplay command or b) open the > presentation.html file. > > > Ben > > > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > Sent: Friday, December 11, 2009 2:25 PM > To: Ben Miller > Cc: 'Roberto'; php-general@lists.php.net > Subject: RE: [PHP] Backup to local drive > > > On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: > > Users would be updating data via form input (address, tel, product > catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating > their own presentations and saving those presentations to a flash drive as > HTML files with calls to the images/PDFs so that they can simply plug their > drive into a USB port and present the info on the road, regardless of > connection to the internet. > Ben > -Original Message- > From: Roberto [mailto:prof...@gmail.com] > Sent: Friday, December 11, 2009 11:58 AM > To: Ben Miller > Cc: php-general@lists.php.net > Subject: Re: [PHP] Backup to local drive > Hi, > you lost me a bit. Let say a user uploads a PDF file to one of your servers. > What do you mean when you say "I want the users to be able to save the > HTML output of their data"?!? > Roberto Aloi > http://aloiroberto.wordpress.com > Twitter: @prof3ta > On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > > Hello - I have an application I'm building that allows users to store > > personal information and files (images, PDFs, etc.) in our database, but I > > need a way for them to be able to save the HTML output of that personal > data > > to a local (for the user) flash drive. I'm guessing I'm going to need a > > clientSide language like javascript for this, but was wondering if maybe > > there was a PHP addon or something like that for downloading content to > the > > user's PC. Thanks in advance. > > > > > > > > Ben > > > > > > > > > Why not create all the HTML files and images on the server, and zip it up > then send that down to the user? > > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > > > > > > That could end up in a lot of HTML and image files. Also, if you can't > rely on people to unzip a file, can you rely on them to know that they > need to keep the images with the HTML? > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > > > > > > > PHP can't do anything like that, PHP is all on the server. Javascript doesn't have anything like that either, but JScript and VBScript do I believe, although that limits you to only Internet Explorer, and only if the user has allowed the unsafe actions. Your best bet is to maybe try to use a format that keeps it all in one file, such as a PDF. Another solution would be to have the HTML reference the images from your own hosting, and put the entire presentation in one file. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] move_uploaded_file
Hi Joseph, I'm perfectly fine with the concepts of absolute/relative path and webroot, trust me. For me it was just unclear from the documentation the fact that the "target path" in the move_uploaded_file function was "absolute" with respect to the file system and not to the "webroot". At the beginning I thought the function itself was taking care about adding the server root on its own to that path. Thinking carefully, it makes perfectly sense for the function to behave the way it actually does, since otherwise it would be impossible to get these files out of the server root in file system terms. Just, this should be written in CAPITAL LETTERS in the documentation. Thanks for the interest, Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta > When used in PHP, an absolute path does not go off the web root. In Premise > 3 below, an absolute path of "/upload" will NOT bring up the directory > "/home/prof3ta/projects/moodle/htdocs/upload" but rather simply "/upload" > In Windows terms, an absolute path would be "C:\upload" versus > "C:\home\prof3ta\projects\moodle\htdocs\upload". The only time an absolute > path is figured relative to the web root is when it is referenced in a > browser. At this point, for all intents and purposes, it locates the file > based on the web root. This is a fundamental difference between absolute > and relative paths. > > Absolute: begins at "/" in Linux operating systems and "C:\" in Windows OS > Relative: begins wherever the running script is located in the file system. > > Joseph > > Roberto wrote: >> >> HI, >> >> Premise 1: >> echo exec("pwd"); -> "/home/prof3ta/projects/moodle/htdocs/feedback_tool" >> >> Premise 2: >> I have an "upload" folder with 777 permissions under: >> /home/prof3ta/projects/moodle/htdocs/upload >> >> Premise 3: >> The server root is obviously htdocs: >> /home/prof3ta/projects/moodle/htdocs >> >> This said, the following doesn't work: >> >> > $uploads_dir = "/upload"; >> $tmp_name = $_FILES["file"]["tmp_name"]; >> $name = $_FILES["file"]["name"]; >> move_uploaded_file($tmp_name, "$uploads_dir/$name"); >> ?> >> >> The following does work: >> >> > $uploads_dir = "../upload"; >> $tmp_name = $_FILES["file"]["tmp_name"]; >> $name = $_FILES["file"]["name"]; >> move_uploaded_file($tmp_name, "$uploads_dir/$name"); >> ?> >> >> I consider it as a documentation bug (in the sample code they use an >> absolute path). >> I indeed believe I *should* be able to use both of them if not >> documented otherwise. >> I will dig into the C implementation of the move_uploaded_file >> function and I'll check, though. >> >> Cheers, >> >> Roberto Aloi >> http://aloiroberto.wordpress.com >> Twitter: @prof3ta >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ErrorException and set_exception_handler()
Hello "randallgirard" Since the bug tracker isn't really a discussion forum, lets move it to the "General PHP User List" (which is a discussion forum). Regarding bug#50446[1] you filed, either I am misunderstanding what you are hoping to achieve or you are misunderstanding the expected behavior/documentations. As far as I can tell; you are expecting the "ErrorException" class to be some sort of magical exception which turns normal E_USER_* errors into exceptions, without actually behaving like exceptions (i.e. stopping program execution if not caught). If you have a "exception handler" registered (via set_exception_handler()) and there is no try/catch block around the code that triggered the exception (doesn't matter where the exception is thrown, from set_error_handler() or regular code), then the exception handler will kick in. After the exception handler has done its job PHP will stop the execution of the script. No matter what. There are no exceptions to that. On uncaught exceptions (i.e. not caught via catch() blocks) PHP *will* stop execution of the script. There are multiple reasons for that, including: * How should PHP know where to return to? If an exception was thrown inside an method, which was called in a function from global scope; Where do you expect PHP to continue from? Global scope? >From the function that called the method? >From the method that threw the exception? * Exceptions are thrown when there is something very very wrong. If the application doesn't know how to handle that particular type of exception (via a catch() block) then the application has no fallback procedure in place. PHP has no other resort then to stop the execution of the script. * The ErrorException isn't treated specially from PHP point of view. Its just another exception type, like InvalidArgumentException, ErrorExeption, BadMethodCallException, LogicException, RuntimeException, UnexpectedValueException. There is no technical difference between the exceptions or any other built-in exception classes. The built-in exceptions (SPL has a good chunk) simply suggest a standard naming convention for exceptions to use (to simplify the catch() clauses in applications for example). Those exceptions will be treated just as any other exceptions, so you must catch them if you want to deal with them and continue the script execution. If you want to turn all your E_USER_* errors into exceptions then you absolutely can. If you prefer to throw an exception when something internally emits E_* errors (for example, invalid parameters to functions) you can. But you still have to catch() those exceptions. The only reason why the ErrorException exists is because many people in the past complained over the fact PHP didn't stop execution when internal function emitted E_* errors (such as sending array to a function that expects an string). Now you can throw exceptions on such errors. Simply create an error handler and make it throw Exception (ErrorException maps nicely to the information contained in normal E_* errors, as it contains the "error message", "the errors code"(E_*), "severity" (fatal error/recoverable error/warning/notice/), the filename it occurred, and line number. Note: You still need to catch the exception if you want to continue the program flow. I don't quite understand your comment about E_USER_* errors being useless. I use those error levels extensively when I can't to inform the caller that something happened, but "I could still do the job the caller expected". I personally do not use exceptions for my application flow (*I* consider it extremely bad practice). If I want to inform the caller/developer that something I had to guess what he wanted, or if something skeptical/wrong happend, I throw E_USER_* errors. My main error handler is actually the set_error_handler(). My "default" exception handler calls back to my error handler, as my error handler allready deals with sever error conditions. Hope it this post shed some light on ErrorException and set_exception_handler(). If not, please "reply-to-all" with your questions (I CCed php-general@lists.php.net on this post, which is a discussion list). -Hannes [1] http://bugs.php.net/50446 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] move_uploaded_file
On Fri, 2009-12-11 at 22:14 +, Roberto wrote: > Hi Joseph, > > I'm perfectly fine with the concepts of absolute/relative path and > webroot, trust me. > For me it was just unclear from the documentation the fact that the > "target path" in the move_uploaded_file function was "absolute" with > respect to the file system and not to the "webroot". > At the beginning I thought the function itself was taking care about > adding the server root on its own to that path. > Thinking carefully, it makes perfectly sense for the function to > behave the way it actually does, since otherwise it would be > impossible to get these files out of the server root in file system > terms. > Just, this should be written in CAPITAL LETTERS in the documentation. > Thanks for the interest, > > Roberto Aloi > http://aloiroberto.wordpress.com > Twitter: @prof3ta > > > When used in PHP, an absolute path does not go off the web root. In Premise > > 3 below, an absolute path of "/upload" will NOT bring up the directory > > "/home/prof3ta/projects/moodle/htdocs/upload" but rather simply "/upload" > > In Windows terms, an absolute path would be "C:\upload" versus > > "C:\home\prof3ta\projects\moodle\htdocs\upload". The only time an absolute > > path is figured relative to the web root is when it is referenced in a > > browser. At this point, for all intents and purposes, it locates the file > > based on the web root. This is a fundamental difference between absolute > > and relative paths. > > > > Absolute: begins at "/" in Linux operating systems and "C:\" in Windows OS > > Relative: begins wherever the running script is located in the file system. > > > > Joseph > > > > Roberto wrote: > >> > >> HI, > >> > >> Premise 1: > >> echo exec("pwd"); -> "/home/prof3ta/projects/moodle/htdocs/feedback_tool" > >> > >> Premise 2: > >> I have an "upload" folder with 777 permissions under: > >> /home/prof3ta/projects/moodle/htdocs/upload > >> > >> Premise 3: > >> The server root is obviously htdocs: > >> /home/prof3ta/projects/moodle/htdocs > >> > >> This said, the following doesn't work: > >> > >> >> $uploads_dir = "/upload"; > >> $tmp_name = $_FILES["file"]["tmp_name"]; > >> $name = $_FILES["file"]["name"]; > >> move_uploaded_file($tmp_name, "$uploads_dir/$name"); > >> ?> > >> > >> The following does work: > >> > >> >> $uploads_dir = "../upload"; > >> $tmp_name = $_FILES["file"]["tmp_name"]; > >> $name = $_FILES["file"]["name"]; > >> move_uploaded_file($tmp_name, "$uploads_dir/$name"); > >> ?> > >> > >> I consider it as a documentation bug (in the sample code they use an > >> absolute path). > >> I indeed believe I *should* be able to use both of them if not > >> documented otherwise. > >> I will dig into the C implementation of the move_uploaded_file > >> function and I'll check, though. > >> > >> Cheers, > >> > >> Roberto Aloi > >> http://aloiroberto.wordpress.com > >> Twitter: @prof3ta > >> > >> > > > I've never had any issue with the documentation for this function. I think it might just be an issue with interpretation? :p Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Backup to local drive
PHP cannot create a folder structure on your local machine. I don't think Javascript or VBScript can either. Your best bet is with the zip files. Windows users have it fairly simple actually (as much as I hate to admit it) as all they would have to do is right-click and "Extract". You can always include instructions in either an on-screen format or a README file (or both). As I have been thinking about it, you are going to need to do a zip file so that the user only has to download a single file. Joseph Ashley Sheridan wrote: On Fri, 2009-12-11 at 15:04 -0700, Ben Miller wrote: That’s exactly why I need something that will put all the needed files directly onto the flash drive – to take that responsibility away from the user. Pulling the data from the DB and creating the folder structure is easy with PHP – just not sure how to copy that folder structure and related files to the flash drive without the user having to know much of anything about computers. Was hoping there is maybe a PHP extension that I didn’t know about, but sounds like a client side is going to be my best bet. From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 2:39 PM To: Ben Miller Cc: 'Roberto'; php-general@lists.php.net Subject: RE: [PHP] Backup to local drive On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: Too much reliance on the user knowing how to extract the files to the flash drive – need something that does it all for them so all they have to do is insert the flash drive on their own computer to store the preformatted presentation and then insert into a prospect’s computer and either a) (preferred) run the presentation via an autoplay command or b) open the presentation.html file. Ben From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Friday, December 11, 2009 2:25 PM To: Ben Miller Cc: 'Roberto'; php-general@lists.php.net Subject: RE: [PHP] Backup to local drive On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: Users would be updating data via form input (address, tel, product catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating their own presentations and saving those presentations to a flash drive as HTML files with calls to the images/PDFs so that they can simply plug their drive into a USB port and present the info on the road, regardless of connection to the internet. Ben -Original Message- From: Roberto [mailto:prof...@gmail.com] Sent: Friday, December 11, 2009 11:58 AM To: Ben Miller Cc: php-general@lists.php.net Subject: Re: [PHP] Backup to local drive Hi, you lost me a bit. Let say a user uploads a PDF file to one of your servers. What do you mean when you say "I want the users to be able to save the HTML output of their data"?!? Roberto Aloi http://aloiroberto.wordpress.com Twitter: @prof3ta On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: Hello - I have an application I'm building that allows users to store personal information and files (images, PDFs, etc.) in our database, but I need a way for them to be able to save the HTML output of that personal data to a local (for the user) flash drive. I'm guessing I'm going to need a clientSide language like javascript for this, but was wondering if maybe there was a PHP addon or something like that for downloading content to the user's PC. Thanks in advance. Ben Why not create all the HTML files and images on the server, and zip it up then send that down to the user? Thanks, Ash http://www.ashleysheridan.co.uk That could end up in a lot of HTML and image files. Also, if you can't rely on people to unzip a file, can you rely on them to know that they need to keep the images with the HTML? Thanks, Ash http://www.ashleysheridan.co.uk PHP can't do anything like that, PHP is all on the server. Javascript doesn't have anything like that either, but JScript and VBScript do I believe, although that limits you to only Internet Explorer, and only if the user has allowed the unsafe actions. Your best bet is to maybe try to use a format that keeps it all in one file, such as a PDF. Another solution would be to have the HTML reference the images from your own hosting, and put the entire presentation in one file. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Backup to local drive
On Fri, 2009-12-11 at 16:52 -0600, Joseph Thayne wrote: > PHP cannot create a folder structure on your local machine. I don't > think Javascript or VBScript can either. Your best bet is with the zip > files. Windows users have it fairly simple actually (as much as I hate > to admit it) as all they would have to do is right-click and "Extract". > You can always include instructions in either an on-screen format or a > README file (or both). > > As I have been thinking about it, you are going to need to do a zip file > so that the user only has to download a single file. > > Joseph > > Ashley Sheridan wrote: > > On Fri, 2009-12-11 at 15:04 -0700, Ben Miller wrote: > > > >> That’s exactly why I need something that will put all the needed files > >> directly onto the flash drive – to take that responsibility away from > >> the user. Pulling the data from the DB and creating the folder > >> structure is easy with PHP – just not sure how to copy that folder > >> structure and related files to the flash drive without the user having > >> to know much of anything about computers. Was hoping there is maybe a > >> PHP extension that I didn’t know about, but sounds like a client side > >> is going to be my best bet. > >> > >> > >> > >> > >> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > >> Sent: Friday, December 11, 2009 2:39 PM > >> To: Ben Miller > >> Cc: 'Roberto'; php-general@lists.php.net > >> Subject: RE: [PHP] Backup to local drive > >> > >> > >> > >> > >> > >> On Fri, 2009-12-11 at 14:36 -0700, Ben Miller wrote: > >> > >> > >> > >> Too much reliance on the user knowing how to extract the files to the > >> flash drive – need something that does it all for them so all they have to > >> do is insert the flash drive on their own computer to store the > >> preformatted presentation and then insert into a prospect’s computer and > >> either a) (preferred) run the presentation via an autoplay command or b) > >> open the presentation.html file. > >> > >> > >> Ben > >> > >> > >> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] > >> Sent: Friday, December 11, 2009 2:25 PM > >> To: Ben Miller > >> Cc: 'Roberto'; php-general@lists.php.net > >> Subject: RE: [PHP] Backup to local drive > >> > >> > >> On Fri, 2009-12-11 at 14:25 -0700, Ben Miller wrote: > >> > >> Users would be updating data via form input (address, tel, product > >> catalogues, etc.) as well as uploading files (images, PDFs, etc.), creating > >> their own presentations and saving those presentations to a flash drive as > >> HTML files with calls to the images/PDFs so that they can simply plug their > >> drive into a USB port and present the info on the road, regardless of > >> connection to the internet. > >> Ben > >> -Original Message- > >> From: Roberto [mailto:prof...@gmail.com] > >> Sent: Friday, December 11, 2009 11:58 AM > >> To: Ben Miller > >> Cc: php-general@lists.php.net > >> Subject: Re: [PHP] Backup to local drive > >> Hi, > >> you lost me a bit. Let say a user uploads a PDF file to one of your > >> servers. > >> What do you mean when you say "I want the users to be able to save the > >> HTML output of their data"?!? > >> Roberto Aloi > >> http://aloiroberto.wordpress.com > >> Twitter: @prof3ta > >> On Fri, Dec 11, 2009 at 6:44 PM, Ben Miller wrote: > >> > >>> Hello - I have an application I'm building that allows users to store > >>> personal information and files (images, PDFs, etc.) in our database, but I > >>> need a way for them to be able to save the HTML output of that personal > >>> > >> data > >> > >>> to a local (for the user) flash drive. I'm guessing I'm going to need a > >>> clientSide language like javascript for this, but was wondering if maybe > >>> there was a PHP addon or something like that for downloading content to > >>> > >> the > >> > >>> user's PC. Thanks in advance. > >>> > >>> > >>> > >>> Ben > >>> > >>> > >>> > >> > >> > >> > >> > >> Why not create all the HTML files and images on the server, and zip it up > >> then send that down to the user? > >> > >> > >> Thanks, > >> Ash > >> http://www.ashleysheridan.co.uk > >> > >> > >> > >> > >> > >> > >> > >> That could end up in a lot of HTML and image files. Also, if you can't > >> rely on people to unzip a file, can you rely on them to know that they > >> need to keep the images with the HTML? > >> > >> Thanks, > >> Ash > >> http://www.ashleysheridan.co.uk > >> > >> > >> > >> > >> > >> > >> > >> > >> > > > > PHP can't do anything like that, PHP is all on the server. Javascript > > doesn't have anything like that either, but JScript and VBScript do I > > believe, although that limits you to only Internet Explorer, and only if > > the user has allowed the unsafe actions. > > > > Your best bet is to maybe try to use a format that keeps it all in one > > file, such as a PDF. > > > > Another solution would be to have the HTML reference
[PHP] Re: ErrorException and set_exception_handler()
On Fri, Dec 11, 2009 at 23:39, Randall Girard wrote: > Okay, my mistake. > > > E_USER_WARNING and E_USER_NOTICE are supposed to continue execution, > correct? Correct. > Then I will restate what I previously said. throwing ErrorException from an No no. Stop there. Exceptions are *totally* different from E_*. > ERROR_HANDLER(...) is useless iwht E_USER_WARNING and E_USER_NOTICE. Why? > Because when you throw the exception from the ERROR_HANDLER, presumably it > may NOT get caught in a try/catch block. Therefor the execution cannot > continue. Exactly. And that is the point. Why would you be turning E_USER_* into exceptions if you don't want to bail out of the current scope? If you throw an exception from the error handler, what exactly do you expect to happen? I gave several reasons for why that simply is impossible, but I am curious: what exactly are you expecting? > Therefor, I think that either a check to see if the TRY/CATCH has been > initiated further up the call stack, or a function to call from within the > EXCEPTION_HANDLER that will return execution to the previous scope. > > > I don't see how this is difficult to understand. So you expect a scripting language to scroll up the entire execution chain to see if there is a catch() block at all, and if there is no catch() block, the simply ignore the exception and continue? If thats your expectations then you are severely misunderstanding the concept of exceptions. Please do "reply-all". And please do not top-post. -Hannes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
Hi Gaurav, On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote: > A very typical problem. Good you sent the error message. > > This problem can be caused due to one of the following- > > 1. I have faced similar problem due to local firewall settings. Don't think this is it, since (1) the firewall settings haven't changed, and (2) other machines on the same network can execute this same code and function (but they aren't running OS X Server 10.6. > 2. Try some other domain; i.e. other than google com. Try some of the local > area website with a particular page like www.somedomain.com/somefile.html I've tried many different external and local web sites, and they all fail. > 3. Some times the remote host does not allow you to connect to get the file > contents. (Also not the cause -- as explained above.) > 4. # 3 can be either way round from both the ends a) you host server does not > allow external connections b) Remote host does not allow anonymous connection. Thanks for the options. I don't think they apply in this case. If you have any other suggestions on what to do, I would welcome them. > Gaurav Kumar > blog.oswebstudio.com > > > > On Thu, Dec 10, 2009 at 9:01 PM, René Fournier wrote: > I thought error_reporting would display them, but I guess php.ini had them > suppressed. Anyway, with: > > > error_reporting(-1); > ini_set('display_errors', 1); > set_time_limit(0); > var_dump (file_get_contents ('http://www.google.com')); > > ?> > > I get: > > Warning: file_get_contents(http://www.google.com): failed to open stream: > Operation now in progress in //.php on line 7 bool(false) > > Does that help with the diagnosis? > > > On 2009-12-10, at 12:28 AM, Richard Quadling wrote: > > > 2009/12/9 René Fournier : > >> It is, and I use curl elsewhere in the same script to fetch remote content. > >> This exact same function works fine on my MacBook Pro (10.6 client, PHP > >> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, > >> > >> On 2009-12-09, at 11:10 PM, laruence wrote: > >> > >>> try > >>> wget http://www.google.com in your command line to see whether the > >>> network is reachable > >>> > >>> LinuxManMikeC wrote: > > On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC > wrote: > > > On Wed, Dec 9, 2009 at 6:45 AM, René Fournier > > wrote: > > > >> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. > >> Any call of file_get_contents() on a local file works fine -- the file > >> is read and returned. But any call of file_get_contents on a url -- > >> any url, local or remote -- always returns false. > >> > >> var_dump (file_get_contents ('http://www.google.com/')); > >> > >> bool(false) > >> > >> I've checked php.ini, and the obvious seems okay: > >> > >>allow_url_fopen => On => On > >> > >> Any ideas? > >> > >> ...Rene > >> > > http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen > > > > > > "I've checked php.ini" > Right, must remember not to reply to stuff till I'm awake. :-D > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > >>> > >>> -- > >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 | > >>> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence > >> > >> > > > > Do you have ANY errors/warning/notices? > > > > > > > > -- > > - > > Richard Quadling > > "Standing on the shoulders of some very clever giants!" > > EE : http://www.experts-exchange.com/M_248814.html > > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > > ZOPA : http://uk.zopa.com/member/RQuadling > >
[PHP] Transparent PNGs: Merging
Hi All, I apologise if this is a newbie post; i'm new to transparent graphics (PNGs in my case). I have a transparent PNG on disk, which I want PHP to load into memory and add some text to ("watermarking", I guess). This seems to be what is achieved @ http://php.ca/manual/en/image.examples.merged-watermark.php I have taken the following code almost entirely from the manual, but can not understand what I have done wrong: //Create the image $img = @imagecreatetruecolor($width, $height) or die("Cannot Initialize new GD image stream"); //Make it transparent imagesavealpha($img, true); $trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127); imagefill($img, 0, 0, $trans_colour); //Get the text color $text_color = imagecolorallocate($img, 255, 0, 0); //Draw the string imagestring($img, $font_size, 0, 0, $string, $text_color); // Load background image, find position, print $img2 = imagecreatefrompng('xxx.png'); $yoffset = (imagesx($img2)/2) - (imagesx($img)/2); imagecopymerge($img2, $img, $yoffset, 5, 0, 0, imagesx($img), imagesy($img), 100); // Output the merged images header ("Content-type: image/png"); imagepng($img2); This code prints the background image with transparancy removed with a light grey, and the text image in red on a black background in the correct position. If I change it to imagepng($img), the text image is printed correctly (transparency and all) Suggestions appreciated, i'm lost! Many thanks, Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php