Re: [PHP] PHP running Python script - not waiting for Python script to finish

2009-06-09 Thread Per Jessen
Adrian Price-Whelan wrote:

> Hey -
> 
> Running these on a Linux server with PHP 5 and Python 2.5.
> 
> My problem is this: I have a simple php form that executes a long (~3
> minutes) Python script using the 'exec' function from php. The issue
> is that the browser, I think, 'times out' before the Python script is
> finished and therefore kills Python and displays no output from
> Python. After some intense googling, I haven't found an answer, 

Can't you just change whichever timeout it is that terminates your
script?


/Per

-- 
Per Jessen, Zürich (17.2°C)


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



Re: [PHP] Strange PHP/Python problem

2009-06-09 Thread Robert Cummings

Adrian Price-Whelan wrote:

Hey all-

Something strange is happening with a python script I am executing from 
a php page:

I am executing this by doing $output = `python blahblah.py arg1 arg2 arg3`

Say my Python code looks like this:
import sys
import os

thisPID = os.getpid()
print thisPID

print "1"

RADeg = float(sys.argv[1])
decDeg = float(sys.argv[2])
clipSizeDeg = float(sys.argv[3])

print "2"

ic.myFunction(RAdeg, decDeg, clipSizeDeg)

print "3"

os.system(SOME LONG COMMAND)

print "4"

for i in os.listdir(blah):
 print "5"
 os.system("gunzip BLAH")[/code]

print "6"

$output collects these numbers from the print statements, all the way 
through #6, but it doesn't execute the rest of the code - the stuff that 
I actually want it to do...any ideas?


Your question belongs on a python list.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] PHP running Python script - not waiting for Python script to finish

2009-06-09 Thread Robert Cummings



Per Jessen wrote:

Adrian Price-Whelan wrote:


Hey -

Running these on a Linux server with PHP 5 and Python 2.5.

My problem is this: I have a simple php form that executes a long (~3
minutes) Python script using the 'exec' function from php. The issue
is that the browser, I think, 'times out' before the Python script is
finished and therefore kills Python and displays no output from
Python. After some intense googling, I haven't found an answer, 


Can't you just change whichever timeout it is that terminates your
script?


set_time_limit( 600 );

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Stuart
2009/6/8 Dotan Cohen :
>> If its the request from the browser, why not just fire up a packet sniffer
>> and get it that way? Unless it's using SSL/TLS/VPN/something that would
>> encrypt it, you should be able to see the request in clear text.
>>
>
> The browser is running on a Symbian cellphone.

Run this on a command line and hit the IP on port 8000. All it does is
read the request and send it back as the response. It ignores POST
bodies but it would be pretty simple to modify it so it echo's those
back too.

http://dev.stut.net/php/httpsrv.phps

-Stuart

-- 
http://stut.net/

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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Dotan Cohen
> Run this on a command line and hit the IP on port 8000. All it does is
> read the request and send it back as the response. It ignores POST
> bodies but it would be pretty simple to modify it so it echo's those
> back too.
>
>    http://dev.stut.net/php/httpsrv.phps
>

Stuart, that is quite a bit of work! Nice!

I also learned some really nice tips here, such as your usage of
define for the header and footer, and why that is the cleanest
solution when you need the content-length. The usage of sockets is new
to me too, but this was easy to follow.

Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

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



[PHP] automatic timezone adjustment

2009-06-09 Thread viraj
hi all,
i'm trying to implement automatic timezone adjustment in one of my
application, it should work based on the country,state and city which
users specify in their account settings.

i have two questions.

1. since there are thousands of cities, what is the best and the
easiest way to figure out the correct time zone for each
country-state-city combination? (i couldn't find a free database or a
service for this specific purpose, but those many social networking
sites do this)

2. http://en.wikipedia.org/wiki/Zoneinfo says 'It also includes
transitions such as daylight saving time, and even records leap
seconds', does this means, that i do not have to worry about DST
calculations?

many thanks!


~viraj

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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Dotan Cohen
Why should this be run on port 8000? Is there a security implication
of running this on port 80? Would it be unwise to use this as a public
service, for instance?

I was considering adding the tool to http://simplesniff, which is why
I ask. Of course, that would only be with your permission, and it
would give you credit for writing the code as well.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Stuart
2009/6/9 Dotan Cohen :
> Why should this be run on port 8000? Is there a security implication
> of running this on port 80? Would it be unwise to use this as a public
> service, for instance?

You can run it on port 80 but you'll need to make sure there's not
another web server running on that port and you'll probably need to
run it as an admin user.

> I was considering adding the tool to http://simplesniff, which is why
> I ask. Of course, that would only be with your permission, and it
> would give you credit for writing the code as well.

There are no risks that I can see in the code. You're welcome to use
it, and a link to http://stut.net/ is always appreciated ;-)

If you're running it on a server that already has a web server on port
80 you have 2 choices...

1) Run it on another port.

2) Bind it to a different IP address.

Option 1 is the simplest and wasting an IP for just this is a bit daft IMHO.

One thing to note is that it can only handle a single request at once.
If you want it to handle more simultaneously it'll need modifying a
bit. Another way to go about this would be to run it using xinetd, but
be sure to remove the while(true) loop before you do that, and close
the $s socket at the end of the script.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] how to get rid of that annoying |

2009-06-09 Thread Bastien Koert
On Tue, Jun 9, 2009 at 1:47 AM, PJ wrote:
> Robert Cummings wrote:
>>
>>
>> PJ wrote:
>>> Robert Cummings wrote:
 PJ wrote:
> Robert Cummings wrote:
>> PJ wrote:
>>> I know this a silly question, but I can't figure out if it's even
>>> possible to get rid of that final annoying | in my pagination
>>> script.
>>>
>>> Navigation";
>>>
>>> echo (($page !=1)?"first":"first")." ... ";
>>> echo (($page>1)?"prev":"prev")." | ";
>>> for($i=$page; $i<=($page+$records_per_page-2)+1; $i++){
>>>   if ($i!=$page && $i>>     echo "$i", "
>>> | ";
>>>   elseif ($i>ceil($count/$records_per_page))
>>>     continue;
>>>   else echo $i, " | ";
>>> }
> ---|
>>> echo " | ... ".(($page<$count)?"next":"next");
>>> echo "  ... ".(($page<$count)?"last":"last");
>>> //echo "Table Order";
>>> echo "Ordered alphabetically by book title : ";
>>> echo $dir=="ASC"?"Ascending":"Ascending";
>>> echo " | ";
>>> echo $dir=="DESC"?"Descending":"Descending";
>>> echo "";?>
>>>
>>> This produces a very nifty pagination - the problem is how to get
>>> rid of
>>> the final pages that show up as greater than what is available. The
>>> script above works fine, except it leaves that final | ...
>>> Any simple solutions?
>>>
>> Do it differently... build an array of the appropriate entries. When
>> done, use implode( ' | ', $yourArray ).
>>
>> Cheers,
>> Rob.
> Hate to disappoint you all, but I finally found the errant | .
> Ridiculous, really, that I bothered you all.
> it's in the line indicated above --- echo " | ... " --- lose the | and
> it all works like a charm.
>
> :-)     ;-)
 You didn't disappoint me... I've seen code like that before, I just
 thought you'd benefit from a cleaner approach instead of the above
 mess.
>>> Actually, as I am new to this, I still have another little glitch which
>>> is a pita. Oh, I know it's a bit of a mess; I have a hard time
>>> following, myself. But, being lazy, I'm trying to fix thigs with a
>>> band-aid. :-(
>>>
>>> But I don't understand how I would "build an array of the appropriate
>>> entries"... what entries do you mean?
>>
>> You have links, each separated by the pipe '|' character. Add each
>> link to a links array:
>>
>> >
>>     $links = array();
>>     foreach( $items as $item )
>>     {
>>         $links[] = ''.$item.'';
>>     }
>>
>>     echo implode( ' | ', $links );
>>
>> ?>
>>
>> Hope that helps.
> I'm afraid I still don't understand. I think you are seeing something
> that I don't see. What do you mean by link in the present context... are
> you talking about some snippet of code equaling each page or every page
> in the db? This is an ever growing db.
>
> Anyway, I finally found the error of my ways (at least in this code). It
> may look sloppy, but then I haven't looked that hard for other examples.
> Some I found were too simple, others too bloated.
> At least, this one works for what I need and does exactly what I wanted.
> :-)
> Here's the final fixed code; some obvious (I hope) variables are left
> out and precede the code:
>
> echo (($page !=1)?"first":"first")." ... ";
> echo (($page>1)?"prev":"prev")." | ";
> for($i=$page; $i<=($page+$records_per_page-2)+1; $i++){
>  if ($i>ceil($count/$records_per_page))
>    continue;
>  elseif ($i!=$page)
>    echo "$i", " | ";
>  else
>    echo $i, " | ";
> }
> echo " ... ".(($page href='".build_url("books.php", "page", $page+1)."'>next":"next");
> if ($page==ceil($count/$records_per_page))
>  echo " ... last";
> elseif ($i!=ceil($count/$records_per_page)) echo "  ...
> ".(($page href='".build_url("books.php", "page",
> ceil($count/$records_per_page))."'>last":"last");
> else echo "  ... ".(($page<$count)?"last":"last");
> echo "Ordered alphabetically by book title : ";
> echo $dir=="ASC"?"Ascending":"Ascending";
> echo " | ";
> echo $dir=="DESC"?"Descending":"Descending";
>
> If there is a way to simplify things, please do let me know (with an
> example, please)
> PJ
>
>
>
> --
> Hervé Kempf: "Pour sauver la plančte, sortez du capitalisme."
> -
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

http://www.weberdev.com/get_example-4092.html

http://www.weberdev.com/get_example-4093.html

are two paging examples that I wrote some time ago

-- 

Bastien

Cat, the other other white meat

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



[PHP] socket_write return wrong data length

2009-06-09 Thread Manuel C.

Hi all,

I'm writting a little telnet client, but I've a problem with the socket_write 
function

public function send($data){
$datalen = strlen($data);
$datawritten = 0;
do {
$datawritten = socket_write($this->_tnsocket, $data, 
$datalen);
if( $datawritten === FALSE) {
echo __METHOD__." : 
".socket_strerror(socket_last_error())."\n";
return (FALSE);
}
echo "Bytes written : ".$datawritten."\n";
$data = substr($data, $datawritten);
$datalen = strlen($data);
} while($datawritten < $datalen);

return (TRUE);
}


When I use this function for writting a sample message of 4526 Bytes it returns 
:
Bytes written : 4526
But it really wrotes only 1460 Bytes (verified with Wireshark).

So my question is why socket_write returns me a wrong data length ?

Thanks


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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Dotan Cohen
> There are no risks that I can see in the code. You're welcome to use
> it, and a link to http://stut.net/ is always appreciated ;-)
>

In August when I will have more time to devote to it I will put it on
the site. With link, and it is _me_ who appreciates _your_ help.
Thanks!

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

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



[PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread Keith
Let's say user A and user B submitting purchase order form with "order.php" 
at the same time, with method=post action='confirmation.php'.


(1)   Will $_POST['order'] submitted by user A replaced by $_POST['order'] 
submitted by user B, and the both user A & B getting the same order, which 
is made by user B? Why?


(2)Since $_POST['xxx'] is superglobal array, will $_POST['order'] read 
by users other than A & B? In shared hosting server environment, are all 
domains hosted within that server using the same $_POST array? Can $_POST 
array accessible by all domains even if not from the originating domain?


Thx for clarification!

Keith 



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



Re: [PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread Nitsan Bin-Nun
Hell no!

Why would they be overwritten?

An HTTP request is sent from user A, the interpreter is "compiling"
the PHP script with the received HTTP request variables and send back
the HTTP response to user A, during this time the same thing happens
with user B.

I can't think of any possible reason in which the $_POST variables
will be overwritten during paralell requests.

Regards,
Nitsan

On Tue, Jun 9, 2009 at 9:27 AM, Keith wrote:
> Let's say user A and user B submitting purchase order form with "order.php"
> at the same time, with method=post action='confirmation.php'.
>
> (1)   Will $_POST['order'] submitted by user A replaced by $_POST['order']
> submitted by user B, and the both user A & B getting the same order, which
> is made by user B? Why?
>
> (2)    Since $_POST['xxx'] is superglobal array, will $_POST['order'] read
> by users other than A & B? In shared hosting server environment, are all
> domains hosted within that server using the same $_POST array? Can $_POST
> array accessible by all domains even if not from the originating domain?
>
> Thx for clarification!
>
> Keith
>
> --
> 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



Re: [PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread Bastien Koert
On Tue, Jun 9, 2009 at 11:51 AM, Nitsan Bin-Nun wrote:
> Hell no!
>
> Why would they be overwritten?
>
> An HTTP request is sent from user A, the interpreter is "compiling"
> the PHP script with the received HTTP request variables and send back
> the HTTP response to user A, during this time the same thing happens
> with user B.
>
> I can't think of any possible reason in which the $_POST variables
> will be overwritten during paralell requests.
>
> Regards,
> Nitsan
>
> On Tue, Jun 9, 2009 at 9:27 AM, Keith wrote:
>> Let's say user A and user B submitting purchase order form with "order.php"
>> at the same time, with method=post action='confirmation.php'.
>>
>> (1)   Will $_POST['order'] submitted by user A replaced by $_POST['order']
>> submitted by user B, and the both user A & B getting the same order, which
>> is made by user B? Why?
>>
>> (2)    Since $_POST['xxx'] is superglobal array, will $_POST['order'] read
>> by users other than A & B? In shared hosting server environment, are all
>> domains hosted within that server using the same $_POST array? Can $_POST
>> array accessible by all domains even if not from the originating domain?
>>
>> Thx for clarification!
>>
>> Keith
>>
>> --
>> 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
>
>

You can also use sessions to keep thing separate

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread Craige Leeder
While yes $_POST is a supergloabal, even a superglobal has it's own 
scope. The scope of $_POST is to the call of the user to the web server. 
Therefor, no User A's information will not be overwritten by User B's 
information.


Hope this helps. Let me know if you want any further clarification. This 
was just a very simplified answer.


Keith wrote:
Let's say user A and user B submitting purchase order form with 
"order.php" at the same time, with method=post action='confirmation.php'.


(1)   Will $_POST['order'] submitted by user A replaced by 
$_POST['order'] submitted by user B, and the both user A & B getting 
the same order, which is made by user B? Why?


(2)Since $_POST['xxx'] is superglobal array, will $_POST['order'] 
read by users other than A & B? In shared hosting server environment, 
are all domains hosted within that server using the same $_POST array? 
Can $_POST array accessible by all domains even if not from the 
originating domain?


Thx for clarification!

Keith



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



[PHP] Cross site scripting

2009-06-09 Thread Skip Evans

Hey all,

You may have seen my earlier message about a current client 
whose site I've taken over maintenance on that is trying to 
get PCI Compliance from Security Metrics. I've put all the 
forms behind https and a couple of other things, but this one 
I don't know how to solve. I'll read up on cross site 
scripting, but could someone help me understand what they 
believe the vulnerability is in their notes below?


Thanks,
Skip

Possible cross site scripting on 
http://www.ranghart.com/index.php


Use the following commands to verify this: wp --inject

"http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
TCP http/https 4
 curl -L

"http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
 grep "123" This website may have other 
injection related vulnerabilities.


--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-09 Thread Craige Leeder
I'm not sure I agree with NEVER using else. Sometimes else is a very 
logical way to organize code. However, it should not be used for data 
validation IE:



function myValidatorFunc($data) {
   if (empty(data)) {
  return false;
   } else {
  if (!is_numeric($data)) {
 return false;
  } else {

  }
   }
}


It's all about how deep you nest your code, and keeping the flow clean. 
That code would be much more readable as such:


function myValidatorFunc($data) {
   if (empty(data)) {
  throw new BadMethodCallException("Paramater data missing");
   }
   if (!is_numeric($data)) {
  throw new InvalidArgumentException("Paramater data should be an 
integer.");

   }
}

See the difference?

- Craige

O. Lavell wrote:

adam.timberlake wrote:

  

Im reading this post and i donnot understand how i should write my code:
http://www.talkphp.com/absolute-beginners/4237-curly-


brackets.html#post23720
  

Does it mean that i am to not write else statements in my ifs? or is it
just saying it is something i should avoid to rite better code?

please help me...



I happen to not agree completely with the post, because it seems to 
propose the use of things like "continue", "break" and "return" within 
control structures (the latter as opposed to at the end of a function, 
exclusively). Very bad practice in my opinion. Think of everything that 
has ever been said of "goto", it's just as bad for structured programming.


(however the use of "break" in "switch .. case" statements is an 
unfortunate necessity in PHP)


Not that I am diagramming much nowadays, but I still try to write code 
such that it could fit into a Nassi-Shneiderman diagram (NSD):




If you have never learnt to draw these then you probably should. It can 
be fun to do and they are very helpful for planning ahead and writing 
uncluttered code that can be easily debugged. And you will know you are 
nesting too deep when the diagram doesn't fit on the piece of paper you 
started on :)


To more directly answer your question I would say that if there is a 
*logical* requirement to use "else" after "if" then yes, you should use 
it and certainly not try to avoid it. There is absolutely nothing wrong 
with "else".




  


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



Re: [PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-09 Thread Robert Cummings

Craige Leeder wrote:
I'm not sure I agree with NEVER using else. Sometimes else is a very 
logical way to organize code. However, it should not be used for data 
validation IE:



function myValidatorFunc($data) {
   if (empty(data)) {
  return false;
   } else {
  if (!is_numeric($data)) {
 return false;
  } else {

  }
   }
}


It's all about how deep you nest your code, and keeping the flow clean. 
That code would be much more readable as such:


function myValidatorFunc($data) {
   if (empty(data)) {
  throw new BadMethodCallException("Paramater data missing");
   }
   if (!is_numeric($data)) {
  throw new InvalidArgumentException("Paramater data should be an 
integer.");

   }
}

See the difference?


I believe the article was suggesting not ending a function that returns 
a value with no return. So rather than return in the else, return 
outside the else as the last expression of the function. This way it is 
clear that the function returns a value.


Contrast:



Versus:



Personally, I also prefer the latter style.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread HallMarc Websites
-Original Message-
From: Craige Leeder [mailto:clee...@gmail.com] 
Sent: Tuesday, June 09, 2009 11:54 AM
To: Keith; PHP-General List
Subject: Re: [PHP] Any conflict with $_POST when 2 users concurrently
submitting the same form using POST method?

While yes $_POST is a supergloabal, even a superglobal has it's own 
scope. The scope of $_POST is to the call of the user to the web server. 
Therefor, no User A's information will not be overwritten by User B's 
information.

Hope this helps. Let me know if you want any further clarification. This 
was just a very simplified answer.

Keith wrote:
> Let's say user A and user B submitting purchase order form with 
> "order.php" at the same time, with method=post action='confirmation.php'.
>
> (1)   Will $_POST['order'] submitted by user A replaced by 
> $_POST['order'] submitted by user B, and the both user A & B getting 
> the same order, which is made by user B? Why?
>
> (2)Since $_POST['xxx'] is superglobal array, will $_POST['order'] 
> read by users other than A & B? In shared hosting server environment, 
> are all domains hosted within that server using the same $_POST array? 
> Can $_POST array accessible by all domains even if not from the 
> originating domain?
>
> Thx for clarification!
>
> Keith
>


Wow what a major security risk and headache this would be




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


__ Information from ESET Smart Security, version of virus signature
database 4141 (20090609) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



[PHP] Php and Imagemagick problems

2009-06-09 Thread Miller, Terion
I am having a heck of a time getting a script to convert images to
workit worked fine for a few hours, then someone "tweaked it" and now it
doesn't work and I can't get it back...they "tweaked" the original file

The script runs and uploads files but no longer "converts" them with the
ImageMagick..wondering if anyone else has run into this

Code:
--

// -- Get Images from
folder--- //

 $FileName = $row['Image'];   

 $ImageName = $row['Image'];
 
 $ImageName = str_replace("/",
"", $ImageName);
 
 
 
 //the many confusing paths
 

//Local path on localhost of image names with NO file extenstion on them as
seen through the webserver
 $FilePath =
"http://127.0.0.1/HarrisAutomate/output/WebImagesHiRes/test/$ImageName";;


 
 //same as $SysPath not sure why - as of this point
$FileName and $ImageName are the same thing
 $FullSysPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/test/$ImageName";

 $BackupPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/backup/test/";
  


//add jpg extenstion to the filename stored in the harris folder


$FileName = str_replace("/", "", $FileName);
  
  $FileName =
str_replace(".jpg", "", $FileName);
 
 
  $FileName =
str_replace("/", "", $ImageName);
  $FileName = str_replace(".jpg", "",
$ImageName);
  
   //actual path to the files with NO file extension
as found on the hard drive
 $SysPath =
"C:/Inetpub/wwwroot/HarrisAutomate/output/WebImagesHiRes/test/$FileName";

 
 
  //lets do some echos
  echo $FileName .'';
  echo
$ImageName  .'';

// include ("VariableReveal3.php");

  
echo
($FileName) . '';
echo ($FilePath) . '';
echo '' . '';

 if (file_exists($SysPath))   {
echo
"The file $ImageName Exists!! Hooray!!"  . '';


} else {

echo "The file $FileName located at $SysPath does not exist"  . '';
}




//--If they exist go ahead and convert them
WINDOWS VERSION//


if (file_exists($SysPath)) {
  
  
   $command =
"convert.exe mogrify -format eps *.jpg -normalize -density 200x200 -trim
-resize 150 -colorspace rgb -filter Sinc -quality 100 ñtrim -identify
-verbose ";
$command .= addslashes($SysPath . $FileName) ." ";

$command .= addslashes($FilePath . $FileName) .".jpg";
   
  /*

$command = "convert.exe -normalize -density 200x200 -trim -resize 150
-colorspace rgb -filter Sinc -quality 100  -identify -verbose ";

$command .= addslashes($SysPath) ." ";
  $command .=
addslashes($FullSysPath) ." ";
 */
  
//echo the command for
the image not so magick
   echo $command . "";


//--Error Reporting about the
Conversions-//



if (system($command, $status) === false) {
echo ($command).
'';

 echo "Image Failed" . '';
} else {

echo "Image Processed" . '';
  }


 


//---Once Converted Then connect to the php
server online//


$ftp_server = "20.20.20.20.";

 $ftp_user_name = "blah blah ";

 $ftp_user_pass = "blahblah";


 $conn_id = ftp_connect($ftp_server);

  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);


$FilePath =  
"http://127.0.0.1/HarrisAutomate/output/WebImagesHiRes/$FileName";;

$remote_path = "/httpdocs/Announcements/photos/obitsTest/$ImageName";


echo "I'm going to upload $FilePath to $remote_path." . '';


set_time_limit(120);
ftp_pasv($conn_id, true);

// upload a
file
if (ftp_put($conn_id, $remote_path, $SysPath, FTP_BINARY)) {

echo "successfully uploaded $ImageName\n";
} else {

echo "There was a problem while uploading $ImageName\n";
}


 



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



[PHP] Re: Cross site scripting

2009-06-09 Thread Shawn McKenzie
Skip Evans wrote:
> Hey all,
> 
> You may have seen my earlier message about a current client whose site
> I've taken over maintenance on that is trying to get PCI Compliance from
> Security Metrics. I've put all the forms behind https and a couple of
> other things, but this one I don't know how to solve. I'll read up on
> cross site scripting, but could someone help me understand what they
> believe the vulnerability is in their notes below?
> 
> Thanks,
> Skip
> 
> Possible cross site scripting on http://www.ranghart.com/index.php
> 
> Use the following commands to verify this: wp --inject
> 
> "http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
> 
> TCP http/https 4
>  curl -L
> 
> "http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
> 
>  grep "123" This website may have other injection
> related vulnerabilities.
> 

Well, their example is not correct, try:
http://www.ranghart.com/index.php?action=search&kw=SEARCH%3Cscript%3Ealert%28"Im
doing some nasty JavaScipt hacking here!"%29%3B%3C%2Fscript%3E in a browser.

This means that you're not validating/sanitizing input.  You can't just
take the contents of a $_GET, $_POST, etc. (any user input) variable and
echo it out.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-09 Thread Colin Guthrie

'Twas brillig, and O. Lavell at 08/06/09 16:33 did gyre and gimble:

adam.timberlake wrote:


Im reading this post and i donnot understand how i should write my code:
http://www.talkphp.com/absolute-beginners/4237-curly-

brackets.html#post23720

Does it mean that i am to not write else statements in my ifs? or is it
just saying it is something i should avoid to rite better code?

please help me...


I happen to not agree completely with the post, because it seems to 
propose the use of things like "continue", "break" and "return" within 
control structures (the latter as opposed to at the end of a function, 
exclusively). Very bad practice in my opinion. Think of everything that 
has ever been said of "goto", it's just as bad for structured programming.


(however the use of "break" in "switch .. case" statements is an 
unfortunate necessity in PHP)


And in C. And there is nothing inherently *wrong* with goto. Sure it 
*can* lead to less readable code, but by going out of your way to avoid 
it's use can lead to equally unreadable code.


Just like the break statement which is a fundamental part of switch 
statements but also very useful to get out of infinite loops (our old 
favourite for (;;)) etc.


For this reason early return should not be completely discounted out of 
hand as a "bad programming practice" as this is simply not true.


If early return is ugly for you then you can never use other constructs 
in OOP like exceptions. These interrupt the code flow execution in 
interesting ways too (and the same for the whole break and continue 
statements in controlled loops)


So personally I like early return. I use it mostly to cut down brace and 
indentation churn. I try to keep code into 80 cols and if 40 of them are 
used up with indents that doesn't leave much room for the actual code!


I think with any programming structure, you just have to make sure your 
code is clear, obvious and readable. If you've got a function that 
sprawls four+ screenfulls and has returns littered throughout it, then 
this is obviously not very readable. Re-factoring should solve this, but 
just re-factoring to avoid early return will probably do very little to 
improve it's overall readability IMO.


In many cases early return can improve readability.

e.g. consider

$rv = false;
if ($condition)
{
  // ... several pages of code.
}
return $rv;


When reading this function, I *could* be interested in what happens if 
the condition is not met. In this scenario I have to scroll down and 
track where the brace is closed and then follow the code on from there.


Now consider this:

if (!$condition)
  return false;

$rv = false;
// ... several pages of code.
return $rv;

With this code, considering I'm interested in what happens if the 
condition is not met, I can satisfy my curiosity immediately without 
looking further.


In both cases if I was interested in the opposite, it's the same amount 
of tracking to look through the code itself.



As with everything in programming style, this mostly comes down to 
personal preference. So just stick with a style you like :)


People get almost as emotive about this topic as top-posting on mailing 
lists :) I'm not overly fussed. I know what i like and it doesn't offend 
anyone in public :p


HTHs

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Re: Cross site scripting

2009-06-09 Thread Skip Evans
Well, the function filter_input(INPUT_GET, 'kw', 
FILTER_SANITIZE_ENCODED);


...seemed to take care of the example on the report by 
Security Metrics.


Am I on the right track here, at least?

I'm reading pages on 'sanitizing PHP input'. Is that where I 
should be headed?


Skip

Shawn McKenzie wrote:

Skip Evans wrote:

Hey all,

You may have seen my earlier message about a current client whose site
I've taken over maintenance on that is trying to get PCI Compliance from
Security Metrics. I've put all the forms behind https and a couple of
other things, but this one I don't know how to solve. I'll read up on
cross site scripting, but could someone help me understand what they
believe the vulnerability is in their notes below?

Thanks,
Skip

Possible cross site scripting on http://www.ranghart.com/index.php

Use the following commands to verify this: wp --inject

"http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%

TCP http/https 4
 curl -L

"http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%

 grep "123" This website may have other injection
related vulnerabilities.



Well, their example is not correct, try:
http://www.ranghart.com/index.php?action=search&kw=SEARCH%3Cscript%3Ealert%28"Im
doing some nasty JavaScipt hacking here!"%29%3B%3C%2Fscript%3E in a browser.

This means that you're not validating/sanitizing input.  You can't just
take the contents of a $_GET, $_POST, etc. (any user input) variable and
echo it out.



--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



[PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-09 Thread O. Lavell
Colin Guthrie wrote:

> 'Twas brillig, and O. Lavell at 08/06/09 16:33 did gyre and gimble:

[..]

> So personally I like early return. I use it mostly to cut down brace and
> indentation churn. I try to keep code into 80 cols and if 40 of them are
> used up with indents that doesn't leave much room for the actual code!

I disagree with you on quite a few points obviously, so let me just 
respond to your statement above. You seem to be saying that if we are 
indenting to column 40 in our code we are doing something wrong, yes? I 
agree on that. But now, I would say the same thing about your example 
with "several pages of code" inside an "if" clause.

The remedy in both cases should be to make our code more modular. Create 
handy objects, compact functions and the occasional include file (e.g. 
for HTML). Whatever really, to split things up into well-manageable 
parts. This improves readability enormously. It also helps you 
concentrate on solving smaller problems instead of larger ones, which may 
benefit your own productivity as a coder as well.

I try to never write anything much longer than about 15 or 20 lines of 
PHP. Whatever part of the whole it is, like a function most likely, it 
needs to do its task within that constraint. Doesn't always work out of 
course, but I get close enough often enough. HTML I have to deal with is 
another matter obviously. Though sprintf() is fantastic help there :)


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



[PHP] How does caching work?

2009-06-09 Thread Paul M Foster
This question may be too complex for a reasonable answer on this list,
but I'll ask anyway.

If a page has static content (no PHP variables, etc.), I can
understand how caching works. The engine just checks to see if it's got
a copy of the requested page in the cache, and displays it if so, or
fetches it if not.

But if a page is populated with variables from a database (for example)
which could change from time to time, how could a caching engine
possibly cache it? How would it determine whether to re-fetch the page
or use the cached version?

Paul

-- 
Paul M. Foster

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



Re: [PHP] best solution to ecommerce web pages

2009-06-09 Thread Ashley Sheridan
On Sun, 2009-06-07 at 13:29 +0200, mrfroasty wrote:
> Alain Roger wrote:
> > Hi,
> >
> > i'm currently investigating what would be the best solution to develop an
> > e-commerce web site.
> > should i use some PHP template engine like smarty or CMS like Joomla, Drupal
> > ?
> >
> > thanks a lot,
> >
> >   
> Joomla +++
> 
> 
> -- 
> Extra details:
> OSS:Gentoo Linux
> profile:x86
> Hardware:msi geforce 8600GT asus p5k-se
> location:/home/muhsin
> language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
> Typo:40WPM
> url:http://mambo-tech.net
> url:http://blog.mambo-tech.net
> 
> 
As commerce-orientated CMSs go, I've found OSCommerce to be pretty easy
to get to grips with


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] How does caching work?

2009-06-09 Thread Daniel Brown
On Tue, Jun 9, 2009 at 16:35, Paul M Foster wrote:
>
> But if a page is populated with variables from a database (for example)
> which could change from time to time, how could a caching engine
> possibly cache it? How would it determine whether to re-fetch the page
> or use the cached version?

This is more a matter of the HTTP protocol and HTML standards.
Check into meta (pragma) 'no-cache' tags and Google "cache control"
for the basics on this.

Thankfully, (at least most) clients do not check the full page to
see if there's an updated version --- because if they did, they may as
well display it, as they'd use up the network, server, and a portion
of the client resources in doing so.  Instead, they check the cache
expire time and/or compare the local (cached) copy against the
timestamp of what the server says for the file's "last-modified" stamp
- known as a file's 'mtime' data.

If I've somehow circumlocuted your question, ignore me and pretend
I was never here.  ;-P

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] How does caching work?

2009-06-09 Thread Robert Cummings



Paul M Foster wrote:

This question may be too complex for a reasonable answer on this list,
but I'll ask anyway.

If a page has static content (no PHP variables, etc.), I can
understand how caching works. The engine just checks to see if it's got
a copy of the requested page in the cache, and displays it if so, or
fetches it if not.

But if a page is populated with variables from a database (for example)
which could change from time to time, how could a caching engine
possibly cache it? How would it determine whether to re-fetch the page
or use the cached version?


By setting a duration during which stale information is not a problem. 
let's say you have a request for your homepage once per second. Now 
let's say you display the 10 most recent news articles on your homepage. 
Now let's say you cache the homepage news articles for 10 minutes. You 
save a bunch of database queries for every homepage request during those 
10 minutes... approximately 600 requests. What does this cost you? 
You're homepage news articles may be stale for 9 minutes and 59 seconds. 
This is just a minor example, look at MediaWiki as an example of some 
heavy computation to render a page. This intense operation is cached so 
that it not be necessary on every article view. Wikis usually have a 
high number of read operations versus writes, in fact any site with a 
high number of reads versus writes probably has an opportunity for caching.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Re: Cross site scripting

2009-06-09 Thread Nitsan Bin-Nun
XSS or Cross Site Scripting is the ability to inject malicious
javascript or HTML to the $_POST or $_GET variables, and at the bottom
line - to get them printed and output-ed to the client through the
HTML code of the page.

In order to avoid such security issues all you have to do is to
sanitise the $_GET and $_POST input before output-ing them to the
browser. Check out htmlentities() and similar stuff.

On Tue, Jun 9, 2009 at 8:47 PM, Skip Evans wrote:
> Well, the function filter_input(INPUT_GET, 'kw', FILTER_SANITIZE_ENCODED);
>
> ...seemed to take care of the example on the report by Security Metrics.
>
> Am I on the right track here, at least?
>
> I'm reading pages on 'sanitizing PHP input'. Is that where I should be
> headed?
>
> Skip
>
> Shawn McKenzie wrote:
>>
>> Skip Evans wrote:
>>>
>>> Hey all,
>>>
>>> You may have seen my earlier message about a current client whose site
>>> I've taken over maintenance on that is trying to get PCI Compliance from
>>> Security Metrics. I've put all the forms behind https and a couple of
>>> other things, but this one I don't know how to solve. I'll read up on
>>> cross site scripting, but could someone help me understand what they
>>> believe the vulnerability is in their notes below?
>>>
>>> Thanks,
>>> Skip
>>>
>>> Possible cross site scripting on http://www.ranghart.com/index.php
>>>
>>> Use the following commands to verify this: wp --inject
>>>
>>>
>>> "http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
>>>
>>> TCP http/https 4
>>>                 curl -L
>>>
>>>
>>> "http://www.ranghart.com/index.php?action=searchkw=SEARCH%22%3E%3Cscript%3Ealert%28123%29%3C%
>>>
>>>                 grep "123" This website may have other injection
>>> related vulnerabilities.
>>>
>>
>> Well, their example is not correct, try:
>>
>> http://www.ranghart.com/index.php?action=search&kw=SEARCH%3Cscript%3Ealert%28"Im
>> doing some nasty JavaScipt hacking here!"%29%3B%3C%2Fscript%3E in a
>> browser.
>>
>> This means that you're not validating/sanitizing input.  You can't just
>> take the contents of a $_GET, $_POST, etc. (any user input) variable and
>> echo it out.
>>
>
> --
> 
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin St, #1
> Madison WI 53703
> 608.250.2720
> http://bigskypenguin.com
> 
> Those of you who believe in
> telekinesis, raise my hand.
>  -- Kurt Vonnegut
>
> --
> 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



Re: [PHP] best solution to ecommerce web pages

2009-06-09 Thread Robert Cummings

Ashley Sheridan wrote:

On Sun, 2009-06-07 at 13:29 +0200, mrfroasty wrote:

Alain Roger wrote:

Hi,

i'm currently investigating what would be the best solution to develop an
e-commerce web site.
should i use some PHP template engine like smarty or CMS like Joomla, Drupal
?

thanks a lot,

  

Joomla +++


--
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://mambo-tech.net
url:http://blog.mambo-tech.net



As commerce-orientated CMSs go, I've found OSCommerce to be pretty easy
to get to grips with


osCommerce is lethargic, no realeses or release candidates have been put 
out in about 2 years. I'd put my money on ZenCart at this time.


Cheers,
Rob
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Ashley Sheridan
On Tue, 2009-06-09 at 17:58 +0300, Dotan Cohen wrote:
> > There are no risks that I can see in the code. You're welcome to use
> > it, and a link to http://stut.net/ is always appreciated ;-)
> >
> 
> In August when I will have more time to devote to it I will put it on
> the site. With link, and it is _me_ who appreciates _your_ help.
> Thanks!
> 
> Dotan Cohen
> 
> http://what-is-what.com
> http://gibberish.co.il
> 
Just checked your site in Elinks (works like Lynx) and I'm getting the
headers come back to me. I'm assuming you changed your site code before
me sending this and after you sent the original message?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] best solution to ecommerce web pages

2009-06-09 Thread LAMP

Ashley Sheridan wrote:

On Sun, 2009-06-07 at 13:29 +0200, mrfroasty wrote:
  

Alain Roger wrote:


Hi,

i'm currently investigating what would be the best solution to develop an
e-commerce web site.
should i use some PHP template engine like smarty or CMS like Joomla, Drupal
?

thanks a lot,

  
  

Joomla +++


--
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://mambo-tech.net
url:http://blog.mambo-tech.net




As commerce-orientated CMSs go, I've found OSCommerce to be pretty easy
to get to grips with


Ash
www.ashleysheridan.co.uk
  

I had really bad experience with osCommerce.
- I used on several stores in the company I worked for and it happened 
few times that "fresh" downloaded will be "demaged"
- the code is easy to modify because it's writen very simple. but, since 
there was tons of developers (community) you will find annoying number 
of stiles the code is written.
- easy to modify, but with any modification there is big chance you will 
not be able to patch/update/upgrade
- every time I had an issue I had to wait several days on answers/help 
on their forum. of course, nobody is paid to help me but if just want to 
let you know - don't count on forum as fast help.

- simply, my suggestion stay away from osCommerce, CRA and other derivates.

I didn't use (yet), but according research I did, I wold recommend 
Drupal + Ubercart


afan




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



Re: [PHP] Show the entire browser request

2009-06-09 Thread Dotan Cohen
> Just checked your site in Elinks (works like Lynx) and I'm getting the
> headers come back to me. I'm assuming you changed your site code before
> me sending this and after you sent the original message?
>

The individual headers are as they always were. It's the entire
request verbatim (valid or not) that I'd like to add.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

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



Re: [PHP] best solution to ecommerce web pages

2009-06-09 Thread Ashley Sheridan
On Tue, 2009-06-09 at 16:52 -0400, Robert Cummings wrote:
> Ashley Sheridan wrote:
> > On Sun, 2009-06-07 at 13:29 +0200, mrfroasty wrote:
> >> Alain Roger wrote:
> >>> Hi,
> >>>
> >>> i'm currently investigating what would be the best solution to develop an
> >>> e-commerce web site.
> >>> should i use some PHP template engine like smarty or CMS like Joomla, 
> >>> Drupal
> >>> ?
> >>>
> >>> thanks a lot,
> >>>
> >>>   
> >> Joomla +++
> >>
> >>
> >> -- 
> >> Extra details:
> >> OSS:Gentoo Linux
> >> profile:x86
> >> Hardware:msi geforce 8600GT asus p5k-se
> >> location:/home/muhsin
> >> language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
> >> Typo:40WPM
> >> url:http://mambo-tech.net
> >> url:http://blog.mambo-tech.net
> >>
> >>
> > As commerce-orientated CMSs go, I've found OSCommerce to be pretty easy
> > to get to grips with
> 
> osCommerce is lethargic, no realeses or release candidates have been put 
> out in about 2 years. I'd put my money on ZenCart at this time.
> 
> Cheers,
> Rob
> -- 
> http://www.interjinn.com
> Application and Templating Framework for PHP
> 
Ah, my last experience with it was 2 years ago, so that might explain
why I didn't find that problem!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] php applications

2009-06-09 Thread Michael

Paul M Foster wrote:

On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:




I don't mean to be the thread spirit killer, but I think another language
would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't use it for
a production application.


I've coded a bit in Python, and parts of it really annoy me. I much
prefer PHP, as it's more C-ish.

Why wouldn't you use PHP for production applications?

Paul




Why wouldnt you? Besides the design of PHP generally being completely 
against it?  PHP is not designed to be run continuously in infinite-loop 
(while true) scenarios... it's threading support is poor and it's memory 
handing and library are geared almost exclusively towards web-programming.


If you want to compile it, or use it in a .NET/Java context... fine (see 
phc, etc.). The language itself can handle it, but the standard 
implementation *shouldnt*.


In anycase other languages have much better support of desktop and 
network programming, entire libraries and communities have been 
developed around it. Preferably use Python/Java/etc. though C has its place.


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



Re: [PHP] How does caching work?

2009-06-09 Thread Stuart
2009/6/9 Paul M Foster :
> This question may be too complex for a reasonable answer on this list,
> but I'll ask anyway.
>
> If a page has static content (no PHP variables, etc.), I can
> understand how caching works. The engine just checks to see if it's got
> a copy of the requested page in the cache, and displays it if so, or
> fetches it if not.
>
> But if a page is populated with variables from a database (for example)
> which could change from time to time, how could a caching engine
> possibly cache it? How would it determine whether to re-fetch the page
> or use the cached version?

Assuming you're not talking about client-side caching which Dan has
already covered...

Generally speaking there's two ways to approach server-side caching...
update-on-expiry and update-on-change.

For update-on-expiry you simply tell the caching system how long the
cache should last and when the cache expires that chunk the code will
generate it again from the database.

In update-on-change you take a more pro-active approach and have any
code that changes cached data update/expire any cache items that use
it.

Which approach is best depends on a number of factors including the
type of data being cached, how often it will change and how fresh you
need the site to be. It's also worth nothing that update-on-expiry is
fine as it is for low traffic sites but if you have a high traffic
site you'll need to look at locking the cache item while it's
generated otherwise you could have a large number of requests
simultaneously updating the same cache items.

On the main site I maintain I use update-on-change and just store the
raw data in the cache - most pages are generated from this data
on-the-fly. There are a few pages that are hit a lot that I cache as
an HTML chunk but for the most part it's just data in the cache. My
reasoning behind this is that DB's are painful and expensive to scale
whereas HTTP/PHP servers are simple and cheap.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] php applications

2009-06-09 Thread Kyle Terry
On Mon, Jun 8, 2009 at 9:33 AM, Robert Cummings wrote:

> Kyle Terry wrote:
>
>> On Mon, Jun 8, 2009 at 8:48 AM, tedd  wrote:
>>
>>  Hi gang:
>>>
>>> I've heard that php can be used for more than web programming, but I am
>>> not
>>> aware of specifically how that can be done. So, let me ask directly --
>>> can
>>> php be used to create a Mac Application?
>>>
>>> If so, how?
>>>
>>> Cheers,
>>>
>>> tedd
>>>
>>>
>>> --
>>> ---
>>> http://sperling.com  http://ancientstones.com  http://earthstones.com
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>  I don't mean to be the thread spirit killer, but I think another
>> language
>> would be better for this. Such as Python.
>>
>> PHP desktop apps might be fun to hack around with, but I wouldn't use it
>> for
>> a production application.
>>
>
> Why not? The technology won't mature if nobody uses it. And since there's a
> want, there's no reason why it can't.
>

Not too sure how good "Programmed desktop applications in PHP" would look on
a resume. ;)


>
> Cheers,
> Rob.
>


Re: [PHP] php applications

2009-06-09 Thread Eddie Drapkin
Depends on how you look at it, I'd take the perspective that that's a
non-normal approach to the language and demonstrates a fuller understanding
of the language.  Same as if you put (and I do) "wrote an asynchronous
socket server in PHP."  Despite the position PHP developers are usually
applying for being limited to web development, I take the approach that
non-standard usage of the language not only demonstrates a more mature
understanding of the language, but also the ability to handle more complex
(because who are we kidding, GUI programming is much more complex than web
development) programming concepts and the ability to solve non-standard
problems which aren't easily able to be googled.

On Tue, Jun 9, 2009 at 7:59 PM, Kyle Terry  wrote:

> On Mon, Jun 8, 2009 at 9:33 AM, Robert Cummings  >wrote:
>
> > Kyle Terry wrote:
> >
> >> On Mon, Jun 8, 2009 at 8:48 AM, tedd  wrote:
> >>
> >>  Hi gang:
> >>>
> >>> I've heard that php can be used for more than web programming, but I am
> >>> not
> >>> aware of specifically how that can be done. So, let me ask directly --
> >>> can
> >>> php be used to create a Mac Application?
> >>>
> >>> If so, how?
> >>>
> >>> Cheers,
> >>>
> >>> tedd
> >>>
> >>>
> >>> --
> >>> ---
> >>> http://sperling.com  http://ancientstones.com  http://earthstones.com
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>>  I don't mean to be the thread spirit killer, but I think another
> >> language
> >> would be better for this. Such as Python.
> >>
> >> PHP desktop apps might be fun to hack around with, but I wouldn't use it
> >> for
> >> a production application.
> >>
> >
> > Why not? The technology won't mature if nobody uses it. And since there's
> a
> > want, there's no reason why it can't.
> >
>
> Not too sure how good "Programmed desktop applications in PHP" would look
> on
> a resume. ;)
>
>
> >
> > Cheers,
> > Rob.
> >
>


Re: [PHP] php applications

2009-06-09 Thread Robert Cummings

Kyle Terry wrote:

On Mon, Jun 8, 2009 at 9:33 AM, Robert Cummings wrote:


Kyle Terry wrote:


On Mon, Jun 8, 2009 at 8:48 AM, tedd  wrote:

 Hi gang:

I've heard that php can be used for more than web programming, but I am
not
aware of specifically how that can be done. So, let me ask directly --
can
php be used to create a Mac Application?

If so, how?

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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


 I don't mean to be the thread spirit killer, but I think another

language
would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't use it
for
a production application.


Why not? The technology won't mature if nobody uses it. And since there's a
want, there's no reason why it can't.



Not too sure how good "Programmed desktop applications in PHP" would look on
a resume. ;)



From my POV, better than writing "Programmed desktop applications in 
VB". But that's just my POV :)


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-09 Thread Clancy
On Tue, 09 Jun 2009 12:22:22 -0400, rob...@interjinn.com (Robert Cummings) 
wrote:

>Craige Leeder wrote:
>> I'm not sure I agree with NEVER using else. Sometimes else is a very 
>> logical way to organize code. However, it should not be used for data 
>> validation IE:
>> 
>> 
>> function myValidatorFunc($data) {
>>if (empty(data)) {
>>   return false;
>>} else {
>>   if (!is_numeric($data)) {
>>  return false;
>>   } else {
>> 
>>   }
>>}
>> }
>> 
>> 
>> It's all about how deep you nest your code, and keeping the flow clean. 
>> That code would be much more readable as such:
>> 
>> function myValidatorFunc($data) {
>>if (empty(data)) {
>>   throw new BadMethodCallException("Paramater data missing");
>>}
>>if (!is_numeric($data)) {
>>   throw new InvalidArgumentException("Paramater data should be an 
>> integer.");
>>}
>> }
>> 
>> See the difference?
>
>I believe the article was suggesting not ending a function that returns 
>a value with no return. So rather than return in the else, return 
>outside the else as the last expression of the function. This way it is 
>clear that the function returns a value.
>
>Contrast:
>
>
>function foo( $foo )
>{
> if( $foo )
> {
> return true;
> }
> else
> {
> return false;
> }
>}
>
>?>
>
>Versus:
>
>
>function foo( $foo )
>{
> if( $foo )
> {
> return true;
> }
>
> return false;
>}
>
>?>
>
>Personally, I also prefer the latter style.

I don't particularly like scattered returns, and prefer

Function foo;
{
result = false;
if (  ) { $result = 'yellow'; }
elseif (  ) { $result = 'blue'; }
return $result;
}


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



Re: [PHP] php applications

2009-06-09 Thread Robert Cummings



Michael wrote:

Paul M Foster wrote:

On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:



I don't mean to be the thread spirit killer, but I think another 
language

would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't use 
it for

a production application.


I've coded a bit in Python, and parts of it really annoy me. I much
prefer PHP, as it's more C-ish.

Why wouldn't you use PHP for production applications?

Paul




Why wouldnt you? Besides the design of PHP generally being completely 
against it?  PHP is not designed to be run continuously in infinite-loop 
(while true) scenarios...


Citation?

it's threading support is poor and it's memory 


What does threading support have to do with running something in an 
infinite loop? What if I don't need threads?



handing and library are geared almost exclusively towards web-programming.


I dunno, I've written amultitude of shell/cron scripts in PHP that 
leverage the codebase already written for the web application.


If you want to compile it, or use it in a .NET/Java context... fine (see 
phc, etc.). The language itself can handle it, but the standard 
implementation *shouldnt*.


Why?

In anycase other languages have much better support of desktop and 
network programming, entire libraries and communities have been 
developed around it. Preferably use Python/Java/etc. though C has its 
place.


As I've said before, ones place in the sun can't be identified if one 
never tries sitting in the sun. It's hard to grasp the proverbial brass 
ring if you never extend your reach.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] php applications

2009-06-09 Thread Daniel Brown
On Tue, Jun 9, 2009 at 20:42, Robert Cummings wrote:
>
> From my POV, better than writing "Programmed desktop applications in VB".
> But that's just my POV :)

Did I happen to tell you that's what I've been doing all day, or
are you just *that* good at making me miserable --- even when it's not
*me* to whom you're speaking?  ;-P

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] php applications

2009-06-09 Thread Michael

Robert Cummings wrote:



Michael wrote:

Paul M Foster wrote:

On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:



I don't mean to be the thread spirit killer, but I think another 
language

would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't 
use it for

a production application.


I've coded a bit in Python, and parts of it really annoy me. I much
prefer PHP, as it's more C-ish.

Why wouldn't you use PHP for production applications?

Paul




Why wouldnt you? Besides the design of PHP generally being completely 
against it?  PHP is not designed to be run continuously in 
infinite-loop (while true) scenarios...


Citation?

see the history of php development and use



it's threading support is poor and it's memory 


What does threading support have to do with running something in an 
infinite loop? What if I don't need threads?


handing and library are geared almost exclusively towards 
web-programming.


I dunno, I've written amultitude of shell/cron scripts in PHP that 
leverage the codebase already written for the web application.
i wasnt arguing against cron-scripts, these are 'run-once' sort of 
things which php handles well. they dont run for minutes let alone hours.




If you want to compile it, or use it in a .NET/Java context... fine 
(see phc, etc.). The language itself can handle it, but the standard 
implementation *shouldnt*.


Why?
for the reasons detailed in this post. using web-oriented php as a 
desktop programming language is a magnitude of dumb perhaps only 
eclipsed by the smarty programming language


In anycase other languages have much better support of desktop and 
network programming, entire libraries and communities have been 
developed around it. Preferably use Python/Java/etc. though C has its 
place.


As I've said before, ones place in the sun can't be identified if one 
never tries sitting in the sun. It's hard to grasp the proverbial brass 
ring if you never extend your reach.
There are good reasons why php isnt "in the sun" (ie. used for desktop 
programming), as i've listed. If you'd care to learn a few other 
languages the reasons would be immediately obvious, python can be learnt 
in a few days - try it.


Cheers,
Rob.


The standard PHP execution model is geared almost exclusively towards 
web-used (though crons etc. are reasonable)... that is, to sit in/with a 
server and handle requests... to operate over, at maximum, "insane" 
lifespans of 30 seconds.


There are languages designed to be used for desktop programming, and for 
various tasks in general. The smart thing would be to use them. PHP may 
be a hammer, but every problem is not a nail.


Use the tools designed for the job.

Michael

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



Re: [PHP] php applications

2009-06-09 Thread Eddie Drapkin
While the technology is pretty immature at the moment, due to its under-use
no doubt, saying that PHP is never the tool for a desktop application is
pretty inane.  While the primary developmental lifecycle is geared towards
web development (who's arguing that?), there's nothing really pervasive
preventing people from using it for desktop apps.  Given the recent focus
towards closing memory leaks internally and the control of the (new, iirc)
garbage collector, I wouldn't say it's a bad idea, resource speaking, to
write in PHP (certainly no worse than Java).  There's sound support, GTK
support, CUPS support, Windows COM / printing support, so the support for
the APIs is certainly there (and where it's not, there's ways around it,
like with the java extension).

Just because you have a hammer that's only been used for nailing particle
board doesn't mean it's not suited for hammering into plywood!   The only
issue I see with PHP is the relative difficulty of making "stand-alone"
applications that are bundled with a statically compiled PHP executable, but
that shouldn't be too hard to overcome, with a little bit of time and
creativity.

On Tue, Jun 9, 2009 at 9:28 PM, Michael  wrote:

> Robert Cummings wrote:
>
>>
>>
>> Michael wrote:
>>
>>> Paul M Foster wrote:
>>>
 On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:

 

  I don't mean to be the thread spirit killer, but I think another
> language
> would be better for this. Such as Python.
>
> PHP desktop apps might be fun to hack around with, but I wouldn't use
> it for
> a production application.
>

 I've coded a bit in Python, and parts of it really annoy me. I much
 prefer PHP, as it's more C-ish.

 Why wouldn't you use PHP for production applications?

 Paul


>>>
>>> Why wouldnt you? Besides the design of PHP generally being completely
>>> against it?  PHP is not designed to be run continuously in infinite-loop
>>> (while true) scenarios...
>>>
>>
>> Citation?
>>
> see the history of php development and use
>
>
>>  it's threading support is poor and it's memory
>>>
>>
>> What does threading support have to do with running something in an
>> infinite loop? What if I don't need threads?
>>
>>  handing and library are geared almost exclusively towards
>>> web-programming.
>>>
>>
>> I dunno, I've written amultitude of shell/cron scripts in PHP that
>> leverage the codebase already written for the web application.
>>
> i wasnt arguing against cron-scripts, these are 'run-once' sort of things
> which php handles well. they dont run for minutes let alone hours.
>
>
>>  If you want to compile it, or use it in a .NET/Java context... fine (see
>>> phc, etc.). The language itself can handle it, but the standard
>>> implementation *shouldnt*.
>>>
>>
>> Why?
>>
> for the reasons detailed in this post. using web-oriented php as a desktop
> programming language is a magnitude of dumb perhaps only eclipsed by the
> smarty programming language
>
>>
>>  In anycase other languages have much better support of desktop and
>>> network programming, entire libraries and communities have been developed
>>> around it. Preferably use Python/Java/etc. though C has its place.
>>>
>>
>> As I've said before, ones place in the sun can't be identified if one
>> never tries sitting in the sun. It's hard to grasp the proverbial brass ring
>> if you never extend your reach.
>>
> There are good reasons why php isnt "in the sun" (ie. used for desktop
> programming), as i've listed. If you'd care to learn a few other languages
> the reasons would be immediately obvious, python can be learnt in a few days
> - try it.
>
>>
>> Cheers,
>> Rob.
>>
>
> The standard PHP execution model is geared almost exclusively towards
> web-used (though crons etc. are reasonable)... that is, to sit in/with a
> server and handle requests... to operate over, at maximum, "insane"
> lifespans of 30 seconds.
>
> There are languages designed to be used for desktop programming, and for
> various tasks in general. The smart thing would be to use them. PHP may be a
> hammer, but every problem is not a nail.
>
> Use the tools designed for the job.
>
> Michael
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] php applications

2009-06-09 Thread Michael
This was about half of my point, writing these applications in PHP is 
difficult, it is a task to be overcome. PHP requires cajoling into being 
useful. Your solution to "use the Java extension" is peculiarly ironic - 
yes: Use Java!


If the only language you know is PHP i'm sure it looks very capable, and 
i was, several years ago, in this position (wanting to write various 
desktop apps in it) the wise and experienced freenode gurus then told me 
to learn the right tools. Despite how it may look from the myopia of 
primarily PHP development, PHP isnt a desktop-capable language. It would 
take a great deal of time and effort to do in PHP what would take a 
handful of lines in python, due to the extensive library support.


Many PHP programmers goes thru' the phase of wanting to write 'http 
servers', 'irc clients', etc. in PHP. It would be irresponsible to not 
point them in the direction of more capable languages, when they are in 
fact, greatly more capable.


Eddie Drapkin wrote:

While the technology is pretty immature at the moment, due to its under-use
no doubt, saying that PHP is never the tool for a desktop application is
pretty inane.  While the primary developmental lifecycle is geared towards
web development (who's arguing that?), there's nothing really pervasive
preventing people from using it for desktop apps.  Given the recent focus
towards closing memory leaks internally and the control of the (new, iirc)
garbage collector, I wouldn't say it's a bad idea, resource speaking, to
write in PHP (certainly no worse than Java).  There's sound support, GTK
support, CUPS support, Windows COM / printing support, so the support for
the APIs is certainly there (and where it's not, there's ways around it,
like with the java extension).

Just because you have a hammer that's only been used for nailing particle
board doesn't mean it's not suited for hammering into plywood!   The only
issue I see with PHP is the relative difficulty of making "stand-alone"
applications that are bundled with a statically compiled PHP executable, but
that shouldn't be too hard to overcome, with a little bit of time and
creativity.

On Tue, Jun 9, 2009 at 9:28 PM, Michael  wrote:


Robert Cummings wrote:



Michael wrote:


Paul M Foster wrote:


On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:



 I don't mean to be the thread spirit killer, but I think another

language
would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't use
it for
a production application.


I've coded a bit in Python, and parts of it really annoy me. I much
prefer PHP, as it's more C-ish.

Why wouldn't you use PHP for production applications?

Paul



Why wouldnt you? Besides the design of PHP generally being completely
against it?  PHP is not designed to be run continuously in infinite-loop
(while true) scenarios...


Citation?


see the history of php development and use



 it's threading support is poor and it's memory
What does threading support have to do with running something in an
infinite loop? What if I don't need threads?

 handing and library are geared almost exclusively towards

web-programming.


I dunno, I've written amultitude of shell/cron scripts in PHP that
leverage the codebase already written for the web application.


i wasnt arguing against cron-scripts, these are 'run-once' sort of things
which php handles well. they dont run for minutes let alone hours.



 If you want to compile it, or use it in a .NET/Java context... fine (see

phc, etc.). The language itself can handle it, but the standard
implementation *shouldnt*.


Why?


for the reasons detailed in this post. using web-oriented php as a desktop
programming language is a magnitude of dumb perhaps only eclipsed by the
smarty programming language


 In anycase other languages have much better support of desktop and

network programming, entire libraries and communities have been developed
around it. Preferably use Python/Java/etc. though C has its place.


As I've said before, ones place in the sun can't be identified if one
never tries sitting in the sun. It's hard to grasp the proverbial brass ring
if you never extend your reach.


There are good reasons why php isnt "in the sun" (ie. used for desktop
programming), as i've listed. If you'd care to learn a few other languages
the reasons would be immediately obvious, python can be learnt in a few days
- try it.


Cheers,
Rob.


The standard PHP execution model is geared almost exclusively towards
web-used (though crons etc. are reasonable)... that is, to sit in/with a
server and handle requests... to operate over, at maximum, "insane"
lifespans of 30 seconds.

There are languages designed to be used for desktop programming, and for
various tasks in general. The smart thing would be to use them. PHP may be a
hammer, but every problem is not a nail.

Use the tools designed for the job.

Michael


--
PHP General Mailing List (http://www.php.net/)
To unsubscrib

Re: [PHP] php applications

2009-06-09 Thread Daniel Brown
Hate to police threads here, but please don't top-post.

On Tue, Jun 9, 2009 at 21:48, Michael wrote:
> This was about half of my point, writing these applications in PHP is
> difficult, it is a task to be overcome. PHP requires cajoling into being
> useful. Your solution to "use the Java extension" is peculiarly ironic -
> yes: Use Java!

As someone who programs in several languages (to a degree of
competence and skill I shall leave judged by those who receive the
end-result of my work) and who is directly-involved in the PHP
Project, I feel more than qualified to disagree with you on this.
Coincidentally, I do.  For once my qualifications and opinion lie in
the same place (and not just because my wife told me that they belong
there).

> If the only language you know is PHP i'm sure it looks very capable, and i
> was, several years ago, in this position (wanting to write various desktop
> apps in it) the wise and experienced freenode gurus then told me to learn
> the right tools. Despite how it may look from the myopia of primarily PHP
> development, PHP isnt a desktop-capable language. It would take a great deal
> of time and effort to do in PHP what would take a handful of lines in
> python, due to the extensive library support.

This is not only incorrect, but exhibits deeper issues.  Python
seems more capable because you are importing numerous modules, nodes,
and extensions, in turn inheriting and extending others, building a
full framework.  The same can - and is - done in PHP.  Perhaps not in
the stock distribution, but in more than a few third-party offerings.
And this doesn't even touch into the PEAR and PECL stuff, nor the fact
that Python is more than one-and-a-half times as old as modern PHP.

> Many PHP programmers goes thru' the phase of wanting to write 'http
> servers', 'irc clients', etc. in PHP. It would be irresponsible to not point
> them in the direction of more capable languages, when they are in fact,
> greatly more capable.

 is what you would say if you hoped beyond hope that
technology would stagnate.

All of this said, believe it or not, I do agree with the statement
that there are other languages better-suited to desktop programming
(at this time), just not for the points so far that you've argued.
We're on the same side, just not the same end.  ;-P

-- 

daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] php applications

2009-06-09 Thread Michael

Daniel Brown wrote:
> Hate to police threads here, but please don't top-post.

Apologies, my client was not configured properly. Hopefully it is 
threading now, if not please notify me.


Michael

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



Re: [PHP] php applications

2009-06-09 Thread Robert Cummings



Michael wrote:

Robert Cummings wrote:



Michael wrote:

Paul M Foster wrote:

On Mon, Jun 08, 2009 at 09:30:18AM -0700, Kyle Terry wrote:



I don't mean to be the thread spirit killer, but I think another 
language

would be better for this. Such as Python.

PHP desktop apps might be fun to hack around with, but I wouldn't 
use it for

a production application.


I've coded a bit in Python, and parts of it really annoy me. I much
prefer PHP, as it's more C-ish.

Why wouldn't you use PHP for production applications?

Paul




Why wouldnt you? Besides the design of PHP generally being completely 
against it?  PHP is not designed to be run continuously in 
infinite-loop (while true) scenarios...


Citation?

see the history of php development and use


Please explain the purpose of the php-cli binary?

it's threading support is poor and it's memory 


What does threading support have to do with running something in an 
infinite loop? What if I don't need threads?


handing and library are geared almost exclusively towards 
web-programming.


I dunno, I've written amultitude of shell/cron scripts in PHP that 
leverage the codebase already written for the web application.

>
i wasnt arguing against cron-scripts, these are 'run-once' sort of 
things which php handles well. they dont run for minutes let alone hours.


I have daemons in PHP that have been running for months without stop. 
They are using the infinite-loop mechanism you purport to be not 
designed for continuous long-term use. I have an mplayer wrapper script 
that has been running for the past 3 months non-stop... it's purpose is 
to shuffle my kids shows, reload a play list when it changes, allow 
queueing of shows, handle random selection of shows based on tags and 
weighting, remember what episode in a series was last played and where 
the timestamp currently rests... all this without being shut down.


If you want to compile it, or use it in a .NET/Java context... fine 
(see phc, etc.). The language itself can handle it, but the standard 
implementation *shouldnt*.


Why?
for the reasons detailed in this post. using web-oriented php as a 
desktop programming language is a magnitude of dumb perhaps only 
eclipsed by the smarty programming language


Narrow mindedness won't earn you any brownie points from me.

In anycase other languages have much better support of desktop and 
network programming, entire libraries and communities have been 
developed around it. Preferably use Python/Java/etc. though C has its 
place.


There's always other languages... there's always another language better 
at doing something... so what? There was Perl before PHP, Perl was 
undoubtedly better than PHP for web applications at one point... yet I 
would argue that has changed... why? Because the naysayers were ignored.


As I've said before, ones place in the sun can't be identified if one 
never tries sitting in the sun. It's hard to grasp the proverbial 
brass ring if you never extend your reach.
There are good reasons why php isnt "in the sun" (ie. used for desktop 
programming), as i've listed. If you'd care to learn a few other 
languages the reasons would be immediately obvious, python can be learnt 
in a few days - try it.


Cheers,
Rob.


The standard PHP execution model is geared almost exclusively towards 
web-used (though crons etc. are reasonable)... that is, to sit in/with a 
server and handle requests... to operate over, at maximum, "insane" 
lifespans of 30 seconds.


Please point me to this "standard"-- I would like to have a gander at it.

There are languages designed to be used for desktop programming, and for 
various tasks in general. The smart thing would be to use them. PHP may 
be a hammer, but every problem is not a nail.


Languages were designed to be programmed, what they are programmed to do 
is entirely up to the programmer.



Use the tools designed for the job.


Then how would we find new uses for the tools? Just because there's only 
one known use for a tool, doesn't exclude it for consideration for new 
uses. There's always serendipity too.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] php applications

2009-06-09 Thread Robert Cummings

Michael wrote:
This was about half of my point, writing these applications in PHP is 
difficult, it is a task to be overcome. PHP requires cajoling into being 
useful. Your solution to "use the Java extension" is peculiarly ironic - 
yes: Use Java!


If the only language you know is PHP i'm sure it looks very capable, and 
i was, several years ago, in this position (wanting to write various 
desktop apps in it) the wise and experienced freenode gurus then told me 
to learn the right tools. Despite how it may look from the myopia of 
primarily PHP development, PHP isnt a desktop-capable language. It would 
take a great deal of time and effort to do in PHP what would take a 
handful of lines in python, due to the extensive library support.


Many PHP programmers goes thru' the phase of wanting to write 'http 
servers', 'irc clients', etc. in PHP. It would be irresponsible to not 
point them in the direction of more capable languages, when they are in 
fact, greatly more capable.


I program in several languages, but I do enjoy the speed in which I can 
cobble together something functional in PHP with minimal effort. You 
underestimate the glue power of PHP. I don't need to program something 
like mplayer in PHP, it is sufficient that I can control it and expand 
upon it via PHP. PHP is quite competent at filling many of the roles 
formerly handled by Perl. Yes there are advantages to other languages, 
certainly other languages can be better choices for any particular 
application, but outright exclusion of PHP just to fulfill your fantasy 
of the right tool for the job is just silly.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] php applications

2009-06-09 Thread Michael
"Languages were designed to be programmed, what they are programmed to 
do is entirely up to the programmer."


Perhaps there is no hope then. This is so distant from the actual case 
it does not require more than pointing out.


If you want to write demons in php fine, i wince at the thought.

The question isnt whether a PHP programmer thinks PHP is the right tool 
for the job, unanimously the answer will be 'yes' because of the myopia 
of the position. It is whether people with experience on a number of 
different platform, using a number of different languages think it is... 
i've yet to hear *anyone* in this position advocate PHP.



Michael

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



Re: [PHP] php applications

2009-06-09 Thread Robert Cummings

Michael wrote:
"Languages were designed to be programmed, what they are programmed to 
do is entirely up to the programmer."


Perhaps there is no hope then. This is so distant from the actual case 
it does not require more than pointing out.


If you want to write demons in php fine, i wince at the thought.


Demons are fantastical creatures. The word you're erroneously trying to 
repeat is "daemon".


The question isnt whether a PHP programmer thinks PHP is the right tool 
for the job, unanimously the answer will be 'yes' because of the myopia 
of the position. It is whether people with experience on a number of 
different platform, using a number of different languages think it is... 
i've yet to hear *anyone* in this position advocate PHP.


I don't have myopia, I've already said many times that there can 
certainly be better ways to do something, there can be more established 
choices, but just because there are, doesn't preclude the use of a less 
worthy tool with the possible side effect that the less worthy tool 
undergoes some kind of evolution such that it becomes a better choice in 
the future. There was a time when C was a less worthy choice, there was 
a time when Java was a less worthy choice, there was a time when you 
probably had a more open mind. The fact remains that things change, and 
usually change is driven by some impetus. That impetus may indeed be due 
to the selected environment having been found lacking.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] php applications

2009-06-09 Thread Michael

Robert Cummings wrote:
> Michael wrote:
>> "Languages were designed to be programmed, what they are programmed to
>> do is entirely up to the programmer."
>>
>> Perhaps there is no hope then. This is so distant from the actual case
>> it does not require more than pointing out.
>>
>> If you want to write demons in php fine, i wince at the thought.
>
> Demons are fantastical creatures. The word you're erroneously trying to
> repeat is "daemon".
You'll find both spellings refer to the same thing.

>
>> The question isnt whether a PHP programmer thinks PHP is the right
>> tool for the job, unanimously the answer will be 'yes' because of the
>> myopia of the position. It is whether people with experience on a
>> number of different platform, using a number of different languages
>> think it is... i've yet to hear *anyone* in this position advocate PHP.
>
> I don't have myopia, I've already said many times that there can
> certainly be better ways to do something, there can be more established
> choices, but just because there are, doesn't preclude the use of a less
> worthy tool with the possible side effect that the less worthy tool
> undergoes some kind of evolution such that it becomes a better choice in
> the future.
You're advocating using a hammer as a screwdriver to spur the invention 
of the screwdriver? We already have the screwdriver, it's called python. 
If you need a drill there's Java, etc.


There was a time when C was a less worthy choice, there was
> a time when Java was a less worthy choice, there was a time when you
> probably had a more open mind. The fact remains that things change, and
> usually change is driven by some impetus. That impetus may indeed be due
> to the selected environment having been found lacking.

Yes, certainly. This is why we have phc, phalanger, pint, mod_php, 
PHP4Mono, etc.


You'll also notice youre talking about a progression of languages... not 
a progression within a language. People arent writing operating systems 
in python precisely because that would be an absurd misuse of a tool, 
nor are they writing RDMBs in PHP. There are good reasons for this.


Michael

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



Re: [PHP] php applications

2009-06-09 Thread Robert Cummings

Michael wrote:

Robert Cummings wrote:
 > Michael wrote:
 >> "Languages were designed to be programmed, what they are programmed to
 >> do is entirely up to the programmer."
 >>
 >> Perhaps there is no hope then. This is so distant from the actual case
 >> it does not require more than pointing out.
 >>
 >> If you want to write demons in php fine, i wince at the thought.
 >
 > Demons are fantastical creatures. The word you're erroneously trying to
 > repeat is "daemon".
You'll find both spellings refer to the same thing.


Doh.


 >> The question isnt whether a PHP programmer thinks PHP is the right
 >> tool for the job, unanimously the answer will be 'yes' because of the
 >> myopia of the position. It is whether people with experience on a
 >> number of different platform, using a number of different languages
 >> think it is... i've yet to hear *anyone* in this position advocate PHP.
 >
 > I don't have myopia, I've already said many times that there can
 > certainly be better ways to do something, there can be more established
 > choices, but just because there are, doesn't preclude the use of a less
 > worthy tool with the possible side effect that the less worthy tool
 > undergoes some kind of evolution such that it becomes a better choice in
 > the future.
You're advocating using a hammer as a screwdriver to spur the invention 
of the screwdriver? We already have the screwdriver, it's called python. 
If you need a drill there's Java, etc.


No, I'm advocation the invention of the Robertson screwdriver despite 
the existence of the Philips screwdriver!



There was a time when C was a less worthy choice, there was
 > a time when Java was a less worthy choice, there was a time when you
 > probably had a more open mind. The fact remains that things change, and
 > usually change is driven by some impetus. That impetus may indeed be due
 > to the selected environment having been found lacking.

Yes, certainly. This is why we have phc, phalanger, pint, mod_php, 
PHP4Mono, etc.


I'm not sure what point you were making with the above list.

You'll also notice youre talking about a progression of languages... not 
a progression within a language. People arent writing operating systems 
in python precisely because that would be an absurd misuse of a tool, 
nor are they writing RDMBs in PHP. There are good reasons for this.


No, I'm specifically talking about a progression WITHIN a language. When 
C first came out there were likely almost no libraries available and 
many many ASM libraries. That changed over time. You already made a 
point about libraries being a reasonable criteria for language selection.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] php applications

2009-06-09 Thread Paul M Foster
On Wed, Jun 10, 2009 at 02:48:23AM +0100, Michael wrote:

> This was about half of my point, writing these applications in PHP is
> difficult, it is a task to be overcome. PHP requires cajoling into being
> useful. Your solution to "use the Java extension" is peculiarly ironic -
> yes: Use Java!
>
> If the only language you know is PHP i'm sure it looks very capable, and
> i was, several years ago, in this position (wanting to write various
> desktop apps in it) the wise and experienced freenode gurus then told me
> to learn the right tools. Despite how it may look from the myopia of
> primarily PHP development, PHP isnt a desktop-capable language. It would
> take a great deal of time and effort to do in PHP what would take a
> handful of lines in python, due to the extensive library support.

Not. PHP is based very closely on C. Its syntax and native function
calls mirror C almost completely. Considering the breadth of
applications written for the desktop in C, I think your argument is
weak. Especially when you consider that, unlike C, we don't have to
predefine variables and PHP does its own memory management and
housecleaning, unlike C. Moreover, there are tons of add-on extensions
for PHP which allow it to do some very unusual things. Same is true for
C (but in C, they're "libraries").

I'm just playing devil's advocate here. Normally I would use Python or
Bash for anything shell, and some GUI apps. But I haven't heard a really
compelling reason yet for *not* using PHP.

Paul

-- 
Paul M. Foster

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



[PHP] PHP as Server Side for a Web Database Application.

2009-06-09 Thread R. S. Patil
Hi,

We are in phase of evaluating PHP as Serverside technology for our first web
application.
We have finalized Flex for user interface and Birt as reporting engine. Now
the data services
are to be evaluated. Flex forums recommended us using PHP for this.

We would like to implement SOA for database access/Inserts/Updates/Queries
for report engine BIRT.
For SOA implementation we are considering XML-RPC and WSO2-WSF since we dont
have any past
experience on web development we are not position to make any decisions
about PHP serverside
technologies can somebody guide use which one we should select (May be
different than these two).
We will be using flex forms to insert and update data through web services
(mainly CRUD operations)
and PHP "Query" data services will be acting as Data Source to Birt for
reporting. Please suggest us
technolgy which is secure and prooven. The problem of integrating Birt in to
PHP has been solved
and successfully tested also.

Thanks and Best Regards

Raja


Re: [PHP] Any conflict with $_POST when 2 users concurrently submitting the same form using POST method?

2009-06-09 Thread Keith

Craige, Marc, Nitsan,Bastien,
Thanks for your reply!
This is my understanding and comment from your replies:

(1) If the web server do have assign anonymous request ID to each HTTP 
request from client browser, and assign $_POST to each request ID and works 
within request ID scope, this is fine with session or without session.


(2) If the above is not the case, then session is required. However web 
server still need to provide each session ID a $_POST array and works within 
this scope.


(3) If the web server does not work in case(1) neither case(2), then include 
user ID into $_POST is appropriate, e.g.

$_POST[userID][input_submitted_name][input_submitted_value]
instead of just
$_POST][input_submitted_name][input_submitted_value].

So, which of the 3 cases above is appropriate?

Thanks!

"Craige Leeder"  wrote in message 
news:4a2e85b3@gmail.com...
While yes $_POST is a supergloabal, even a superglobal has it's own scope. 
The scope of $_POST is to the call of the user to the web server. 
Therefor, no User A's information will not be overwritten by User B's 
information.


Hope this helps. Let me know if you want any further clarification. This 
was just a very simplified answer.


Keith wrote:
Let's say user A and user B submitting purchase order form with 
"order.php" at the same time, with method=post action='confirmation.php'.


(1)   Will $_POST['order'] submitted by user A replaced by 
$_POST['order'] submitted by user B, and the both user A & B getting the 
same order, which is made by user B? Why?


(2)Since $_POST['xxx'] is superglobal array, will $_POST['order'] 
read by users other than A & B? In shared hosting server environment, are 
all domains hosted within that server using the same $_POST array? Can 
$_POST array accessible by all domains even if not from the originating 
domain?


Thx for clarification!

Keith



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