|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 16 Jul 2005 08:40:46 -0000 Issue 3570
php-general-digest-help
lists.php.net
Date: Sat Jul 16 2005 - 03:40:46 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 16 Jul 2005 08:40:46 -0000 Issue 3570
Topics (messages 218776 through 218800):
Re: Question about apache-php concurrent process control
218776 by: Rasmus Lerdorf
218780 by: Liang ZHONG
218781 by: Rasmus Lerdorf
218782 by: Liang ZHONG
218784 by: Rasmus Lerdorf
218790 by: Liang ZHONG
Re: PHP 5 Object Inheritance
218777 by: Matthew Weier O'Phinney
218778 by: Jochem Maas
218779 by: Chris
218783 by: Brian V Bonini
218785 by: Chris
Re: How to run .sql files using php
218786 by: glumtail
Re: Displaying HTML safely
218787 by: Jasper Bryant-Greene
218800 by: Lauri Harpf
Re: Is GD available
218788 by: Jasper Bryant-Greene
not sure why form submission gives me error
218789 by: Bruce Gilbert
218797 by: glumtail
218799 by: Edward Vermillion
Copy Remote File to Local Server
218791 by: Matt Palermo
218792 by: Richard Davey
218793 by: Matt Darby
218794 by: Richard Davey
skewed up images
218795 by: Ryan A
218796 by: Richard Davey
Getting server information
218798 by: Matt Palermo
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Liang wrote:
> I am a programmer and new to php. I wonder what process control can php
> interpreter do for multithreading . I notice that through http request, php
> interpreter can execute 2 php programs simataneously, but will only
> sequentially queued and execute if I try to execute one php code in the same
> time.
>
> Can somebody tell me is it a problem by php design not to be execute code
> concurrently, or some apache/php configuration problem where I can fix?
Apache is a multi-process single-threaded architecture. 1 request, 1
process. Concurrent requests are handled by concurrent processes. What
is it you think you need a second thread for during a request?
-Rasmus
attached mail follows:
As I know, apache-php works this way. When the web server gets an http
request with file name extension ".php", it will start the php interpreter
to process the php file.
Now I have a php program does something like this: when it is executing with
one parameter p1, the program code goes to contact a database, gets back
huge amount of data, writes it to file system. This will take pretty long
time to finish. In the mean time, the same php code will be invoked by
apache with another request, passing different parameter p2, indicates the
code need to run to check the availability and read partial of the data
which has already writen to the file system just now. The program location
need to be in the same URL, but with only different parameter passing to it.
for example:
http://baseURL/a.php?v=p1
http://baseURL/a.php?v=p2
I want these 2 process can be run concurrently, but through a small test, I
found out that they just sequentially execute one after the other.
http://baseURL/a.php
http://baseURL/b.php
howevery can run concurrently well, it means that apache can invoke multiple
php interpreter processes. But I do not know how to make php interpreter to
do the same thing. Or 2 php interpreter processes process one php program
sepreately without interfer with each other.
Hope I have explained myself clearly.
Thank you.
>From: Rasmus Lerdorf <rasmus
lerdorf.com>
>To: Liang <little00wofl
hotmail.com>
>CC: php-general
lists.php.net
>Subject: Re: [PHP] Question about apache-php concurrent process control
>Date: Fri, 15 Jul 2005 13:46:37 -0700
>
>Liang wrote:
> > I am a programmer and new to php. I wonder what process control can php
> > interpreter do for multithreading . I notice that through http request,
>php
> > interpreter can execute 2 php programs simataneously, but will only
> > sequentially queued and execute if I try to execute one php code in the
>same
> > time.
> >
> > Can somebody tell me is it a problem by php design not to be execute
>code
> > concurrently, or some apache/php configuration problem where I can fix?
>
>Apache is a multi-process single-threaded architecture. 1 request, 1
>process. Concurrent requests are handled by concurrent processes. What
>is it you think you need a second thread for during a request?
>
>-Rasmus
attached mail follows:
Liang ZHONG wrote:
> As I know, apache-php works this way. When the web server gets an http
> request with file name extension ".php", it will start the php
> interpreter to process the php file.
>
> Now I have a php program does something like this: when it is executing
> with one parameter p1, the program code goes to contact a database, gets
> back huge amount of data, writes it to file system. This will take
> pretty long time to finish. In the mean time, the same php code will be
> invoked by apache with another request, passing different parameter p2,
> indicates the code need to run to check the availability and read
> partial of the data which has already writen to the file system just
> now. The program location need to be in the same URL, but with only
> different parameter passing to it.
>
> for example:
>
> http://baseURL/a.php?v=p1
> http://baseURL/a.php?v=p2
>
> I want these 2 process can be run concurrently, but through a small
> test, I found out that they just sequentially execute one after the other.
Sorry, your test is wrong then. Apache/PHP does not serialize requests
like that. If somehow the backend you are collecting data from is
serializing the requests, then you are out of luck and frontend threads
isn't going to solve that since your threads would simply be serialized
as well. You are on the wrong track here.
-Rasmus
attached mail follows:
Could you please explain it a little bit more?
I did test this way.
The code is the same for a.php and b.php
<?php
sleep(20);
print Done. <br />";
?>
I place request from 2 browser windows.
First time, I placed with http://baseURL/a.php with both 2 browsers,
starting times have 5 second interval. Then the first "Done" shows after 20
seconds and the second "Done" shows 20 seconds after the first "Done".
Then, I placed one browser with http://baseURL/a.php and the second one with
http://baseURL/b.php, with starting time of 5 second interval. Then I got
the first browser showing "Done" after 20 seconds and 5 seconds later, the
second browser showed "Done", too.
Thus it seems that the apache can spoon out multiple php interpreters
responding to http requests, while php can not deal with concurrent process
from one program.
I do not know if it is due to the php's design limitation, or I did not
configure the php correctly to fulfill its full functionality?
Thank you
>
>Liang ZHONG wrote:
> > As I know, apache-php works this way. When the web server gets an http
> > request with file name extension ".php", it will start the php
> > interpreter to process the php file.
> >
> > Now I have a php program does something like this: when it is executing
> > with one parameter p1, the program code goes to contact a database, gets
> > back huge amount of data, writes it to file system. This will take
> > pretty long time to finish. In the mean time, the same php code will be
> > invoked by apache with another request, passing different parameter p2,
> > indicates the code need to run to check the availability and read
> > partial of the data which has already writen to the file system just
> > now. The program location need to be in the same URL, but with only
> > different parameter passing to it.
> >
> > for example:
> >
> > http://baseURL/a.php?v=p1
> > http://baseURL/a.php?v=p2
> >
> > I want these 2 process can be run concurrently, but through a small
> > test, I found out that they just sequentially execute one after the
>other.
>
>Sorry, your test is wrong then. Apache/PHP does not serialize requests
>like that. If somehow the backend you are collecting data from is
>serializing the requests, then you are out of luck and frontend threads
>isn't going to solve that since your threads would simply be serialized
>as well. You are on the wrong track here.
>
>-Rasmus
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
Liang ZHONG wrote:
> Could you please explain it a little bit more?
> I did test this way.
>
> The code is the same for a.php and b.php
> <?php
>
> sleep(20);
> print Done. <br />";
>
> ?>
>
> I place request from 2 browser windows.
> First time, I placed with http://baseURL/a.php with both 2 browsers,
> starting times have 5 second interval. Then the first "Done" shows after
> 20 seconds and the second "Done" shows 20 seconds after the first "Done".
>
> Then, I placed one browser with http://baseURL/a.php and the second one
> with http://baseURL/b.php, with starting time of 5 second interval. Then
> I got the first browser showing "Done" after 20 seconds and 5 seconds
> later, the second browser showed "Done", too.
>
> Thus it seems that the apache can spoon out multiple php interpreters
> responding to http requests, while php can not deal with concurrent
> process from one program.
I have no idea what you did to configure it this way. I wouldn't even
know how to do that if you asked me to. As far as PHP is concerned it
has no idea which processes are handling which script files at any one
point. So whether you request a.php and b.php at the same time or a.php
twice at the same time, it makes absolutely no difference to PHP. If
you are really seeing this, then the limitation is in your browser or
somewhere else. Try making a.php output stuff so it becomes easier to
see. As in for($i=0;$i<20;$i++) { echo $i; flush(); sleep(1); }
You should see the counter start counting as soon as you hit the page.
-Rasmus
attached mail follows:
Hi Rasmus,
You are right. It was the problem with the browser. I used Mozilla Firefox
to try, and do not know what consideration it just serialized the identical
url http requests. I then turned to use 2 IE 6.0 windows, 2 tabs within
Maxthon browser, one IE windows and one Firefox, to test. Then I got the
conclusion as you told. Thank you very much for the help.
BTW, I could not get the flush() work, neither flush() with ob_flush(). I
tried almost all methods mentioned in the followed posts under
http://us2.php.net/flush, but none of them can really pushed the buffer out.
The site is configurated with http://liang.ns2user.info/php/info.php on Red
head, kernel 2.4.29. What can I do to get it work?
Thank you again.
>Liang ZHONG wrote:
> > Could you please explain it a little bit more?
> > I did test this way.
> >
> > The code is the same for a.php and b.php
> > <?php
> >
> > sleep(20);
> > print Done. <br />";
> >
> > ?>
> >
> > I place request from 2 browser windows.
> > First time, I placed with http://baseURL/a.php with both 2 browsers,
> > starting times have 5 second interval. Then the first "Done" shows after
> > 20 seconds and the second "Done" shows 20 seconds after the first
>"Done".
> >
> > Then, I placed one browser with http://baseURL/a.php and the second one
> > with http://baseURL/b.php, with starting time of 5 second interval. Then
> > I got the first browser showing "Done" after 20 seconds and 5 seconds
> > later, the second browser showed "Done", too.
> >
> > Thus it seems that the apache can spoon out multiple php interpreters
> > responding to http requests, while php can not deal with concurrent
> > process from one program.
>
>I have no idea what you did to configure it this way. I wouldn't even
>know how to do that if you asked me to. As far as PHP is concerned it
>has no idea which processes are handling which script files at any one
>point. So whether you request a.php and b.php at the same time or a.php
>twice at the same time, it makes absolutely no difference to PHP. If
>you are really seeing this, then the limitation is in your browser or
>somewhere else. Try making a.php output stuff so it becomes easier to
>see. As in for($i=0;$i<20;$i++) { echo $i; flush(); sleep(1); }
>You should see the counter start counting as soon as you hit the page.
>
>-Rasmus
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
* Chris <listschris
leftbrained.org>:
> I've got a collection of Element classes (about 8 different ones). They
> are all subclasses of a single parent element. I'm trying to extend
> their functionality (both the individual classes, and the parent class
> they inherit).
>
> I can extend each Element subclass with it's new specific functionality,
> but I would also like to add specific functionality to all of the
> subclasses. Extending the parent element with the new functionality
> would *seem* to be the way to go, but I can't make it work None of the
> Subclasses inherit from the extended superclass.
That should work. Have you checked your include_path to make sure a
different, unmodified version of the parent class isn't getting loaded?
--
Matthew Weier O'Phinney
Zend Certified Engineer
http://weierophinney.net/matthew/
attached mail follows:
Chris wrote:
> Hi,
>
> I've got a collection of Element classes (about 8 different ones). They
> are all subclasses of a single parent element. I'm trying to extend
> their functionality (both the individual classes, and the parent class
> they inherit).
>
> I can extend each Element subclass with it's new specific functionality,
> but I would also like to add specific functionality to all of the
> subclasses. Extending the parent element with the new functionality
> would *seem* to be the way to go, but I can't make it work None of the
> Subclasses inherit from the extended superclass. Any thoughts? I'd
> appreciate any ideas.
BaseElement
|- SubElement1
| \- ExtendedSubElement
|- SubElement2
|- SubElement3
|- SubElement4
|- SubElement5
|- SubElement6
|- SubElement7
|- SubElement8
\- ExtendedBaseElement
ExtendedSubElement will never be able to inherit from ExtendedBaseElement.
there is no multiple inheritance in php.
So either change your 'tree':
BaseElement
\- ExtendedBaseElement
|- SubElement1
| \- ExtendedSubElement
|- SubElement2
|- SubElement3
|- SubElement4
|- SubElement5
|- SubElement6
|- SubElement7
|- SubElement8
... stick the functionality of ExtendedBaseElement into BaseElement
and get rid of the ExtendedBaseElement
... or figure out a neat way to use the 'Decorator Pattern'
(http://www.google.com/search?q=Decorator+Pattern) in order to
conditionally make extended functionality available in specific
descendant classes?
otherwise post some code (cutdown :-) for people to look at.
>
> Thanks,
> Chris
>
attached mail follows:
Jochem Maas wrote:
> Chris wrote:
>
>> Hi,
>>
>> I've got a collection of Element classes (about 8 different ones).
>> They are all subclasses of a single parent element. I'm trying to
>> extend their functionality (both the individual classes, and the
>> parent class they inherit).
>>
>> I can extend each Element subclass with it's new specific
>> functionality, but I would also like to add specific functionality to
>> all of the subclasses. Extending the parent element with the new
>> functionality would *seem* to be the way to go, but I can't make it
>> work None of the Subclasses inherit from the extended superclass. Any
>> thoughts? I'd appreciate any ideas.
>
>
>
> BaseElement
> |- SubElement1
> | \- ExtendedSubElement
> |- SubElement2
> |- SubElement3
> |- SubElement4
> |- SubElement5
> |- SubElement6
> |- SubElement7
> |- SubElement8
> \- ExtendedBaseElement
>
> ExtendedSubElement will never be able to inherit from
> ExtendedBaseElement.
> there is no multiple inheritance in php.
>
Yeah, I understand... Is multiple inheritance something that true OOP
languages can do?
> So either change your 'tree':
>
> BaseElement
> \- ExtendedBaseElement
> |- SubElement1
> | \- ExtendedSubElement
> |- SubElement2
> |- SubElement3
> |- SubElement4
> |- SubElement5
> |- SubElement6
> |- SubElement7
> |- SubElement8
>
> ... stick the functionality of ExtendedBaseElement into BaseElement
> and get rid of the ExtendedBaseElement
>
I can't change the tree, because the non-extended elements still need to
be able to function independantly.
> ... or figure out a neat way to use the 'Decorator Pattern'
> (http://www.google.com/search?q=Decorator+Pattern) in order to
> conditionally make extended functionality available in specific
> descendant classes?
>
That seems like it would work, but itdoesn't feel very clean. I'll look
into some more.
> otherwise post some code (cutdown :-) for people to look at.
>
Well, here is my actual tree with all the internals pulled out:
<?php
abstract class CForm_Element {}
class CForm_Datetime extends CForm_Element {}
class CForm_File extends CForm_Element {}
abstract class CForm_StandardElement extends CForm_Element {}
class CForm_Hidden extends CForm_StandardElement {}
class CForm_Checkbox extends CForm_StandardElement {}
class CForm_Radio extends CForm_StandardElement {}
class CForm_Select extends CForm_StandardElement {}
class CForm_Textarea extends CForm_StandardElement {}
class CForm_Text extends CForm_StandardElement {}
class CForm_Password extends CForm_Text {}
class CForm_Email extends CForm_Text {}
class CForm_Timestamp extends CForm_Text {}
abstract class CForm_Number extends CForm_Text {}
class CForm_Float extends CForm_Number {}
class CForm_Integer extends CForm_Number {}
?>
They are the elements of a Form Object, to create the form and validate
the input. The extended classes I'm working on now associate a database
table with the Form object, and will Create, Delete, and Update rows in
a database.
This is my currently anticpated Structure.
<?php
abstract CAdminForm_Element {}
CAdminForm_Boolean {}
CAdminForm_Email {}
CAdminForm_File {}
CAdminForm_Float {}
CAdminForm_Integer {}
CAdminForm_Password {}
CAdminForm_Select {}
CAdminForm_String {}
?>
When I was typing out this structure I realized that some of those have
2 possible objects they'll need to inherit from, which further
complicates things.
An example: I'll want the CAdminForm_Boolean to optionally be Yes/No
Radio buttons, or a Checkbox. Which is handled with two separate Form
Elements.
I'm *this* close to concluding that it would be better to not extend any
of the new AdminForm classes from any of the old, but rather instantiate
a Form Element class for each AdminForm Element, then use __call() to
pass methods through to the instantied, while overriding the necessary
methods in almost the normal way.
Thanks for your time,
Chris
attached mail follows:
On Fri, 2005-07-15 at 17:53, Chris wrote:
> >
> Yeah, I understand... Is multiple inheritance something that true OOP
> languages can do?
>
Yes.
--
s/:-[(/]/:-)/g
Brian GnuPG -> KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
======================================================================
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org
attached mail follows:
Brian V Bonini wrote:
>On Fri, 2005-07-15 at 17:53, Chris wrote:
>
>
>>Yeah, I understand... Is multiple inheritance something that true OOP
>>languages can do?
>>
>>
>>
>
>Yes.
>
>
>
Thanks
attached mail follows:
Ahmed:
It's real perfect!
B/R
2005/7/14, Ahmed Saad <myanywhere
gmail.com>:
>
> hi babu
>
> On 7/13/05, babu <garavindbabu
yahoo.co.uk> wrote:
> > i have a set of queries which i have placed them in one .sql file.i want
> to run this file using php's mssql and oracle(oci) functions.
>
> you need a database abstraction layer to help you with that (adodb for
> example)
>
> function fireSQL( $driver )
> {
>
> // establish the connection to the database using the specified driver
>
> // read SQL from the file (probably tokenizing it into sql statements)
>
> // feed the sql into the connection
>
> }
>
> -ahmed
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Lauri Harpf wrote:
> Now, if I make a point of not "chmod 755"ing the .html files in
> question, the server should be safe from someone feeding a html file
> with an embedded PHP script, right? Is there something else I should
> be looking out for - or is there an even better way of handling the
> transferring of the HTML code from the application to the user?
Well, unless you have set your server up to execute PHP or CGI scripts
in .html files, which is a very bad idea, the only thing you need to
worry about is client-side scripting. You could just filter out all
<script></script> tags if client-side scripting isn't important for your
application...
Jasper
attached mail follows:
> Well, unless you have set your server up to execute PHP or CGI scripts in
> .html files, which is a very bad idea, the only thing you need to worry
> about is client-side scripting. You could just filter out all
> <script></script> tags if client-side scripting isn't important for your
> application...
That's one of the problems I have, but it seems a tough nut to crack. If I
leave in the scripts, it opens a possibility of malicious scripts being fed
to a user through the application.
On the other hand, if I take out the scripts, I will be providing a broken
version of the original page. People are not going to be happy if my "llama
to alpaca"-application has the side effect of deleting all of their scripts.
I've been thinking of limiting this problem by preventing the direct
displaying of the code (ie. only allowing "Save As.." for the link to the
user-submitted HTML). I guess a bit of JS could prevent accidental
left-clicking on the link. I've also been thinking of passing a special
header for the HTML source code file, "Content-type:
application/octet-stream" to suggest downloading rather than displaying the
contents, but IE seems to just ignore it and display the HTML anyhow.
- Lauri Harpf
attached mail follows:
Todd Cary wrote:
> Damn! I should have checked the error_log first!
>
> PHP Warning: Unknown(): Invalid library (maybe not a PHP library)
> 'libgd.so.2' in Unknown on line 0
>
> And this is the library from the rpm specified in ww.php.net:
> http://www.boutell.com/gd/. However, the site says that gd should be
> supported out of the box. I am going to try and find the rpm for
> php-4.3.11 and reinstall it.
That is the GD library, not the GD PHP extension. The latter requires
the former, but they are not equivalent. Please don't top-post.
Jasper
attached mail follows:
Hello,
I have a form on my site
http://www.inspired-evolution.com/Contact.php
produces this error on submission
Parse error: parse error, unexpected T_STRING in
/hsphere/local/home/bruceg/inspired-evolution.com/Thankyou.php on line
35
here is the PHP code, please let me know if you see where the error is:
Also, if someone has a good editor, that may provide the clue. I don't
have a good PHP editor at my disposal yet :-(
<?php
$name=$_POST["firstname"];
$name=$_POST["lastname"];
$company=$_POST["company"];
$phone=$_POST["phone"];
$email=$_POST["email"];
$email2=$_POST["email2"];
$URL=$_POST["URL"];
$Contact_Preference=$_POST["Contact_Preference"];
$Contact_Time=$_POST["Contact_Time"];
$message=$_POST["Message"];
if ((!$firstname) || (!$Contact_Preference)) { echo
'<p><strong>Error!</strong> Fields marked * are required to
continue.</p></br>'; include 'include/contact.php'; return; }
if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
."
"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)) {
echo '<p>Invalid email address entered</p></br>'; include
'include/contact.php'; return; }
$formsent=mail("webguync
gmail.com",
"There has been a disturbance in the force",
"Request from:$firstname $lastname\r\n
Company name: $company\r\n
Phone Number: $phone\r\n
Email Address: $email\r\n
Retyped Email Address: $email2\r\n
URL: $URL\r\n
Please Contact me via: $Contact_Preference\r\n
The best time to reach me is: $Contact_Time\r\n
I wish to request the following additional information: $Textarea");
if ($formsent) {
echo "<p> Hello,<strong> $firstname</strong>.</p>
<p> We have received your request for additional information, and will
respond shortly.</p>
<p> Thanks for visiting inspired-evolution.com and have a wonderful day!</p>";
}
?>
--
::Bruce::
attached mail follows:
I recommend PSPad
2005/7/16, Bruce Gilbert <webguync
gmail.com>:
>
> Hello,
>
> I have a form on my site
>
> http://www.inspired-evolution.com/Contact.php
>
> produces this error on submission
>
> Parse error: parse error, unexpected T_STRING in
> /hsphere/local/home/bruceg/inspired-evolution.com/Thankyou.php<http://evolution.com/Thankyou.php>on line
> 35
>
> here is the PHP code, please let me know if you see where the error is:
>
> Also, if someone has a good editor, that may provide the clue. I don't
> have a good PHP editor at my disposal yet :-(
>
> <?php
> $name=$_POST["firstname"];
> $name=$_POST["lastname"];
> $company=$_POST["company"];
> $phone=$_POST["phone"];
> $email=$_POST["email"];
> $email2=$_POST["email2"];
> $URL=$_POST["URL"];
> $Contact_Preference=$_POST["Contact_Preference"];
> $Contact_Time=$_POST["Contact_Time"];
> $message=$_POST["Message"];
>
> if ((!$firstname) || (!$Contact_Preference)) { echo
> '<p><strong>Error!</strong> Fields marked * are required to
> continue.</p></br>'; include 'include/contact.php'; return; }
>
> if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"
> ."
"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)) {
> echo '<p>Invalid email address entered</p></br>'; include
> 'include/contact.php'; return; }
>
> $formsent=mail("webguync
gmail.com",
> "There has been a disturbance in the force",
> "Request from:$firstname $lastname\r\n
> Company name: $company\r\n
> Phone Number: $phone\r\n
> Email Address: $email\r\n
> Retyped Email Address: $email2\r\n
> URL: $URL\r\n
> Please Contact me via: $Contact_Preference\r\n
> The best time to reach me is: $Contact_Time\r\n
> I wish to request the following additional information: $Textarea");
> if ($formsent) {
> echo "<p> Hello,<strong> $firstname</strong>.</p>
> <p> We have received your request for additional information, and will
> respond shortly.</p>
> <p> Thanks for visiting inspired-evolution.com<http://inspired-evolution.com>and have a wonderful day!</p>";
>
> }
> ?>
>
> --
> ::Bruce::
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Bruce Gilbert wrote:
> Hello,
>
> I have a form on my site
>
> http://www.inspired-evolution.com/Contact.php
>
> produces this error on submission
>
> Parse error: parse error, unexpected T_STRING in
> /hsphere/local/home/bruceg/inspired-evolution.com/Thankyou.php on line
> 35
Well.. it says it's found a string it wasn't expecting on, or around,
line 35 but I can't find it. Did you cut and past the code here or
retype it when you posted?
BTW... A nice editor for windows is Crimson Editor, and for the mac
TextWrangler works pretty good too. Both have built in FTP features that
are easy to use and some decent syntax highlighting. And both are free.
If your on *nix then I'm not gonna start that war... :P
attached mail follows:
I am writing a script that will read a file from a remote server and write
it to the local server. It works fine except when large files are
attempted. It times out and gives the error that the maximum execution time
has been reached and the file will only be partially copied to the local
server. Is there a way around something like this? Or perhaps could the
script keep time of how long it has been running will reading/writing and
then be able to continue writing to the partial file? Does anyone have any
suggestions for this problem?
Thanks,
Matt Palermo
http://sweetphp.com
attached mail follows:
Hello Matt,
Saturday, July 16, 2005, 3:04:29 AM, you wrote:
MP> I am writing a script that will read a file from a remote server
MP> and write it to the local server. It works fine except when large
MP> files are attempted. It times out and gives the error that the
MP> maximum execution time has been reached and the file will only be
MP> partially copied to the local server. Is there a way around
MP> something like this? Or perhaps could the script keep time of how
MP> long it has been running will reading/writing and then be able to
MP> continue writing to the partial file? Does anyone have any
MP> suggestions for this problem?
Providing you feel it's safe / user friendly to do so, just increase
the time-out: set_time_limit()
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov
attached mail follows:
Wouldn't something like rsync be better suited for this?
I only ask because I've run something like this before...
Matt Darby
Richard Davey wrote:
>Hello Matt,
>
>Saturday, July 16, 2005, 3:04:29 AM, you wrote:
>
>MP> I am writing a script that will read a file from a remote server
>MP> and write it to the local server. It works fine except when large
>MP> files are attempted. It times out and gives the error that the
>MP> maximum execution time has been reached and the file will only be
>MP> partially copied to the local server. Is there a way around
>MP> something like this? Or perhaps could the script keep time of how
>MP> long it has been running will reading/writing and then be able to
>MP> continue writing to the partial file? Does anyone have any
>MP> suggestions for this problem?
>
>Providing you feel it's safe / user friendly to do so, just increase
>the time-out: set_time_limit()
>
>Best regards,
>
>Richard Davey
>
>
attached mail follows:
Hello Matt,
Saturday, July 16, 2005, 3:31:26 AM, you wrote:
MP> I don't have access to edit the php.ini settings. Is there anyway to
MP> copy part of the file, then copy the rest where it left off?
[ Note: Please reply to the mailing list - not to me personally ]
The suggestion I gave you doesn't involve the php.ini file at all -
try looking in the PHP manual for the function given.
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov
attached mail follows:
Hey,
Below the code code I am using, but before you see it let me try to explain
it a bit to you.
Basically I first check to see if a certain image has a bigger width, bigger
height or they are
equal, according to that I call the correct function.
I point the script to a image file (.jpg) then the script resizes the pic to
120pix while keeping the
pic proportionate.
in the beginning if the height is more, then its resizing perfectly...but if
the width is more I want to
cut out 90pix from the middle of the pic...instead its giving me a skewed
image as you can see from
here:
http://www.instantclub.com/skew.jpg
(I have also drawn a red rectangle on the original for where it was supposed
to cut)
*****************************
** And heres the code I am using: **
*****************************
<?php
function prop_thumb_height($filename)
{
header('Content-type: image/jpeg');
list($width_orig, $height_orig) =
getimagesize($profile_pics_path.strtolower($filename));
//echo $_SERVER['DOCUMENT_ROOT'].$profile_pics_path.$filename;
$width = 90;
$scale_by = $width / $width_orig;
$height = floor($height_orig * $scale_by + 0.5);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($profile_pics_path.strtolower($filename));
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);
imagejpeg($image_p,$profile_thumbs_path.$filename, 100);
return $height;
}
function prop_thumb_width($filename,$the_height)
{
$width = 90;$height = $the_height;
header('Content-type: image/jpeg');
list($width_orig, $height_orig) =
getimagesize($profile_pics_path.strtolower($filename));
if ($width && ($width_orig < $height_orig))
{$width = ($height / $height_orig) * $width_orig;}
else {$height = ($width / $width_orig) * $height_orig;}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($profile_pics_path.strtolower($filename));
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);
imagejpeg($image_p,$full_path.$profile_thumbs_path.$filename,100);
return $width;
}
function CR_make_crop($filename)
{
$new = imagecreatetruecolor(90,120);
$img = imagecreatefromjpeg ($profile_pics_path.strtolower($filename));
list($width_orig2, $height_orig2) =
getimagesize($profile_pics_path.strtolower($filename));
imagecopyresized ($new, $img, 0, 0, 0, 0,
90,120,$width_orig2,$height_orig2);
imagedestroy($img);
return $new;
}
function CR_make_crop2($cut_from_top,$filename)
{
$new = imagecreatetruecolor(90,120);
$img = imagecreatefromjpeg($profile_thumbs_path.$filename);
list($width_orig2, $height_orig2) =
getimagesize($profile_thumbs_path.$filename);
imagecopyresized ($new, $img, 0, 0, 0, $cut_from_top,
90,120,$width_orig2,120);
imagedestroy($img);
return $new;
}
/////// All functions on top
$pic1_name="1UilXQSj2S5VV29L.jpg";
// #### Get image size
list($the_image_width1, $the_image_height1) = getimagesize($pic1_name);
if($the_image_height1 > $the_image_width1)
{
$make_prop_thumb_and_get_height=prop_thumb_height($pic1_name);
$step1=$make_prop_thumb_and_get_height-120;
$step2=round($step1 / 2);
$im = CR_make_crop2($step2,$pic1_name);
imagejpeg($im,strtolower($pic1_name),80);
imagedestroy($im);
header('Content-type: text/html');
}
elseif($the_image_height1 < $the_image_width1)
{
prop_thumb_width($pic1_name,$the_image_height1);
$im = CR_make_crop($pic1_name);
imagejpeg($im,strtolower($pic1_name),80);
imagedestroy($im);
header('Content-type: text/html');
}
else // Width and height are same
{
$im = CR_make_crop($pic1_name);
imagejpeg($im,strtolower($pic1_name),80);
imagedestroy($im);
header('Content-type: text/html');
}
?>
Any ideas? I know I screwed up somewhere in the function...but just cant
figure it out...
Thanks,
Ryan
attached mail follows:
Hello Ryan,
Saturday, July 16, 2005, 3:53:16 AM, you wrote:
RA> in the beginning if the height is more, then its resizing
RA> perfectly...but if the width is more I want to cut out 90pix from
RA> the middle of the pic...instead its giving me a skewed image as
RA> you can see from
RA> Any ideas? I know I screwed up somewhere in the function...but just cant
RA> figure it out...
If the width is greater than the height you're calling CR_make_crop
which has this line:
imagecopyresized ($new, $img, 0, 0, 0, 0, 90,120,$width_orig2,$height_orig2);
The problem is that what you're effectively saying is:
Copy the entire original picture (0,0 to $width_orig2, $height_orig2)
into an area 90x120, and resize it when you do it.
That's not a crop :) That's a resize. You'd be better off with a
function like imagecopy() instead - once you have that 90x120 cropped
piece, then you can do whatever it is you wanted to do with it.
Best regards,
Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov
attached mail follows:
I am working on a script which will open a remote PHP file (located on one
of my other website servers) and collect information that gets outputted
from the remote file. I have it working now by using the fopen() function
to open the file on the remote webserver. I am just wondering if it is
possible to collect information and log the info with code in the remote
file. I basically want to keep a log of all domains/servers/ip addresses
that are accessing this remote file and store it in a database on the remote
files server. Is it possible that when the "guest" script uses the fopen()
function to access the PHP file, that when the remote PHP file gets executed
it can log some information about the source server which is accessing it?
If so, what kind of code would I need to place in the remote PHP file to
obtain some of the information.
Thanks,
Matt Palermo
http://sweetphp.com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]