Re: [PHP] Static utility class?

2013-09-04 Thread Micky Hulse
Thank you so much for the quick and very informative/educational
replies Stephen and David, I really appreciate it! :)

On Wed, Sep 4, 2013 at 12:36 PM, Stephen stephe...@rogers.com wrote:
 This sounds simply like a library of functions that are implemented using
 objects.
 Instantiate your static variables in the library file. Again, so that only
 happens once.

functions implemented using objects sounds like exactly what I want.
Just out of curiosity, and sorry in advance for my ignorance, but does
the code I posted fit that type of pattern? If not, what would I need
to modify and how would I call it?

Actually, I should probably spend some time Googling before I ask you
for more details. :D

On Wed, Sep 4, 2013 at 1:15 PM, David Harkness
davi...@highgearmedia.com wrote:
 I can't say if what you're thinking of will make a good utility class since 
 the code you posted is fake. If you post some examples of methods you want to 
 make static, we can give you pointers on which are good candidates and which 
 are best left to instance methods.

Sorry about the fake code. To be honest, I have not written the code
just yet ... I'm kinda wanting to find the perfect pattern before I
get too far down the rabbit hole (though, this is for some simple
utility functions, so refactoring things should be easy later on).

I'll be sure to post real code for any follow up questions.

For now, thanks to you guys, I have a ton to work with. Thanks again
for the pro advice!

Cheers,
M

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



Re: [PHP] Static utility class?

2013-09-04 Thread Stephen

On 13-09-04 05:09 PM, Micky Hulse wrote:

Thank you so much for the quick and very informative/educational
replies Stephen and David, I really appreciate it! :)

On Wed, Sep 4, 2013 at 12:36 PM, Stephen stephe...@rogers.com wrote:

This sounds simply like a library of functions that are implemented using
objects.
Instantiate your static variables in the library file. Again, so that only
happens once.

functions implemented using objects sounds like exactly what I want.
Just out of curiosity, and sorry in advance for my ignorance, but does
the code I posted fit that type of pattern? If not, what would I need
to modify and how would I call it?

Actually, I should probably spend some time Googling before I ask you
for more details. :D
Well, your code does not take advantage of the features of classes, but 
the syntax is correct.


Global, static variables are not consistent with the design concepts of 
OOP. But as a first step in moving from procedural code to OOP, which is 
learning the syntax, go for it.


--
Stephen


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



Re: [PHP] Static utility class?

2013-09-04 Thread Micky Hulse
Thanks Stephen! I really appreciate the help! :)

In my PHP ventures over the years, I haven't made much use of static
variables/methods/properties ... I was thinking they might be useful
for this one bit of code, but based on your feedback (and David's) I
think I'll be heading down a different path.

Thanks again for the kick in the right direction!

Much appreciated!

Cheers,
Micky

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



Re: [PHP] message to user after complete POST

2013-09-04 Thread Rodrigo Santos
hey, if you are just trying to give the user a feedback about the
information sent, there is a Global variable for this, and it's the $_POST.
When you receive the information on the script you called on the Action
atribute of the form, via the $_POST global variable, you will test the
information end echo the feedback on that script.

Note that, unless you are using ajax (jquery, or any other javascript ajax
method), when you post a form, you will be intantly redirected to the
action path. then you have nothing to do in the source page.

hope you got it.


2013/9/4 iccsi inu...@gmail.com

 I have a POST form and action itself like following
 form name=MyForm  id=MyForm method=POST action=index.php
 /form

 I want to show success message when POST complete or error message if
 there is any.
 I would like to know are there any property or global variable I can check
 to show message to users.
 If not, it seems that the only solution is jQuery, since it has success
 function that jQuery call after POST.

 Your help and information is great appreciated,


 Regards,

 Iccsi,


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




Re: [PHP] message to user after complete POST

2013-09-04 Thread iccsi

Thanks a million for the information and help,
yes, I will use jQuery to have my success function call in jQuery.ajax.

Thanks again,

Regards,

Iccsi,

Rodrigo Santos  wrote in message 
news:caombckqonakxoc4tnhcpn2ycdpy8503xttc7sosjywhtd5x...@mail.gmail.com...


hey, if you are just trying to give the user a feedback about the
information sent, there is a Global variable for this, and it's the $_POST.
When you receive the information on the script you called on the Action
atribute of the form, via the $_POST global variable, you will test the
information end echo the feedback on that script.

Note that, unless you are using ajax (jquery, or any other javascript ajax
method), when you post a form, you will be intantly redirected to the
action path. then you have nothing to do in the source page.

hope you got it.


2013/9/4 iccsi inu...@gmail.com


I have a POST form and action itself like following
form name=MyForm  id=MyForm method=POST action=index.php
/form

I want to show success message when POST complete or error message if
there is any.
I would like to know are there any property or global variable I can check
to show message to users.
If not, it seems that the only solution is jQuery, since it has success
function that jQuery call after POST.

Your help and information is great appreciated,


Regards,

Iccsi,


--
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] Static utility class?

2013-09-04 Thread Rodrigo Santos
Hi, first, sorry for the bad English.

Yes, at least, as far as I know, this is the perfect way to do what you
want to do. Think like this: when you instanciate a class, you are
allocating memory. If you don't need any information stored, then you don't
need to allocate memory, right? So, it's is logic to have a class that you
will call only one fragment when you need it, rather than load the entire
class just for one method.

Just be careful to organize your utility methods by by meaning. Don't put a
method that make dating stuff and a method that write a random string in
the same class. By doing so, you are breaking the object orientation
purpose.


2013/9/4 Micky Hulse mickyhulse.li...@gmail.com

 Hi all!

 Example code:

 https://gist.github.com/mhulse/6441525

 Goal:

 I want to have a utility class that contain utility methods which should
 have the option of being called multiple times on a page.

 I think my main goal is to avoid having to new things ... I don't really
 need to create an instance here (there's no need for a constructor in this
 case).

 Question:

 Is the above simple pattern a good way to have a class that calls static
 methods?

 To put it another way, is there any reason why I would not want to use the
 above code?

 Basically I want to wrap these simple functions in a nice class wrapper and
 have the ability to call them without having to jump through more hoops
 than is necessary.

 Are there any pitfalls to writing a class like this? Or, is this the
 standard way of writing a simple utility class for this type of
 situation?

 Please let me know if I need to clarify my questions.

 Thanks for your time?



Re: [PHP] Static utility class?

2013-09-04 Thread Micky Hulse
Hi Rodrigo, thanks for the help, I really appreciate it!

On Wed, Sep 4, 2013 at 5:55 PM, Rodrigo Santos
rodrigos.santo...@gmail.com wrote:
 Hi, first, sorry for the bad English.

Not bad at all! Very clear and well written reply (heck, it's better
than my native English writing), so thank you! :)

 Yes, at least, as far as I know, this is the perfect way to do what you want
 to do. Think like this: when you instanciate a class, you are allocating
 memory. If you don't need any information stored, then you don't need to
 allocate memory, right? So, it's is logic to have a class that you will call
 only one fragment when you need it, rather than load the entire class just
 for one method.

Interesting! That makes a lot of sense.

Now you've piqued my interests! :)

I was going to head down a different path, but you've inspired me to
further explore the use of static methods/properties/variables/other.

A part of me just wants to learn more about PHP OOP, and using static
members is something I've not explored much. Seems like a simple
functional utility class would be a good time to play and learn more.
:D

 Just be careful to organize your utility methods by by meaning. Don't put a
 method that make dating stuff and a method that write a random string in the
 same class. By doing so, you are breaking the object orientation purpose.

Excellent tip! Thank you Rodrigo! I really appreciate the tips/advice
and inspiration. :)

Have a great afternoon!

Cheers,
Micky

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



Re: [PHP] Re: refernces, arrays, and why does it take up so much memory?

2013-09-03 Thread Jim Giner

On 9/3/2013 1:09 AM, Daevid Vincent wrote:




-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
Sent: Monday, September 02, 2013 8:14 PM
To: php-general@lists.php.net
Subject: [PHP] Re: refernces, arrays, and why does it take up so much
memory?

On 9/2/2013 9:30 PM, Daevid Vincent wrote:

I'm confused on how a reference works I think.

I have a DB result set in an array I'm looping over. All I simply want

to

do

is make the array key the id of the result set row.

This is the basic gist of it:

 private function _normalize_result_set()
 {
foreach($this-tmp_results as $k = $v)
{
   $id = $v['id'];
   $new_tmp_results[$id] = $v; //2013-08-29 [dv]

using

a

reference here cuts the memory usage in half!
   unset($this-tmp_results[$k]);

   /*
   if ($i++ % 1000 == 0)
   {
 gc_enable(); // Enable Garbage Collector
 var_dump(gc_enabled()); // true
 var_dump(gc_collect_cycles()); // # of

elements

cleaned up
 gc_disable(); // Disable Garbage Collector
   }
   */
}
$this-tmp_results = $new_tmp_results;
//var_dump($this-tmp_results); exit;
unset($new_tmp_results);
 }

Without using the = reference, my data works great:
$new_tmp_results[$id] = $v;

array (size=79552)
6904 =
  array (size=4)
'id' = string '6904' (length=4)
'studio_id' = string '5' (length=1)
'genres' = string '34|' (length=3)
6905 =
  array (size=4)
'id' = string '6905' (length=4)
'studio_id' = string '5' (length=1)
'genres' = string '6|37|' (length=5)

However it takes a stupid amount of memory for some unknown reason.
MEMORY USED @START: 262,144 - @END: 42,729,472 = 42,467,328 BYTES
MEMORY PEAK USAGE: 216,530,944 BYTES

When using the reference the memory drastically goes down to what I'd

EXPECT

it to be (and actually the problem I'm trying to solve).
MEMORY USED @START: 262,144 - @END: 6,029,312 = 5,767,168 BYTES
MEMORY PEAK USAGE: 82,051,072 BYTES

However my array is all kinds of wrong:

array (size=79552)
6904 = 
  array (size=4)
'id' = string '86260' (length=5)
'studio_id' = string '210' (length=3)
'genres' = string '8|9|10|29|58|' (length=13)
6905 = 
  array (size=4)
'id' = string '86260' (length=5)
'studio_id' = string '210' (length=3)
'genres' = string '8|9|10|29|58|' (length=13)

Notice that they're all the same values, although the keys seem right. I
don't understand why that happens because
foreach($this-tmp_results as $k = $v)
Should be changing $v each iteration I'd think.

Honestly, I am baffled as to why those unsets() make no difference. All

I

can think is that the garbage collector doesn't run. But then I had also
tried to force gc() and that still made no difference. *sigh*

I had some other cockamamie idea where I'd use the same tmp_results

array

in

a tricky way to avoid a  second array. The concept being I'd add 1

million

to the ['id'] (which we want as the new array key), then unset the

existing

sequential key, then when all done, loop through and shift all the keys

by

1

million thereby they'd be the right index ID. So add one and unset one
immediately after. Clever right? 'cept it too made no difference on

memory.

Same thing is happening as above where the gc() isn't running or

something

is holding all that memory until the end. *sigh*

Then I tried a different way using array_combine() and noticed something
very disturbing.
http://www.php.net/manual/en/function.array-combine.php


 private function _normalize_result_set()
 {
if (!$this-tmp_results || count($this-tmp_results)  1)
return;

$D_start_mem_usage = memory_get_usage();
foreach($this-tmp_results as $k = $v)
{
   $id = $v['id'];
   $tmp_keys[] = $id;

   if ($v['genres'])
   {
  $g = explode('|', $v['genres']);
 $this-tmp_results[$k]['g'] = $g; //this

causes a

massive spike in memory usage
   }
}
//var_dump($tmp_keys, $this-tmp_results); exit;
echo \nMEMORY USED BEFORE array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
(.number_format(memory_get_peak_usage(true)).)br\n;
$this-tmp_results = array_combine($tmp_keys,
$this-tmp_results);
echo \nMEMORY USED FOR array_combine:
.number_format(memory_get_usage() - $D_start_mem_usage). PEAK:

Re: [PHP] refernces, arrays, and why does it take up so much memory?

2013-09-03 Thread Stuart Dallas
On 3 Sep 2013, at 02:30, Daevid Vincent dae...@daevid.com wrote:

 I'm confused on how a reference works I think.
 
 I have a DB result set in an array I'm looping over. All I simply want to do
 is make the array key the id of the result set row.
 
 This is the basic gist of it:
 
   private function _normalize_result_set()
   {
  foreach($this-tmp_results as $k = $v)
  {
 $id = $v['id'];
 $new_tmp_results[$id] = $v; //2013-08-29 [dv] using a
 reference here cuts the memory usage in half!

You are assigning a reference to $v. In the next iteration of the loop, $v will 
be pointing at the next item in the array, as will the reference you're storing 
here. With this code I'd expect $new_tmp_results to be an array where the keys 
(i.e. the IDs) are correct, but the data in each item matches the data in the 
last item from the original array, which appears to be what you describe.

 unset($this-tmp_results[$k]);

Doing this for every loop is likely very inefficient. I don't know how the 
inner workings of PHP process something like this, but I wouldn't be surprised 
if it's allocating a new chunk of memory for a version of the array without 
this element. You may find it better to not unset anything until the loop has 
finished, at which point you can just unset($this-tmp_results).

 
 /*
 if ($i++ % 1000 == 0)
 {
   gc_enable(); // Enable Garbage Collector
   var_dump(gc_enabled()); // true
   var_dump(gc_collect_cycles()); // # of elements
 cleaned up
   gc_disable(); // Disable Garbage Collector
 }
 */
  }
  $this-tmp_results = $new_tmp_results;
  //var_dump($this-tmp_results); exit;
  unset($new_tmp_results);
   }


Try this:

private function _normalize_result_set()
{
  // Initialise the temporary variable.
  $new_tmp_results = array();

  // Loop around just the keys in the array.
  foreach (array_keys($this-tmp_results) as $k)
  {
// Store the item in the temporary array with the ID as the key.
// Note no pointless variable for the ID, and no use of !
$new_tmp_results[$this-tmp_results[$k]['id']] = $this-tmp_results[$k];
  }

  // Assign the temporary variable to the original variable.
  $this-tmp_results = $new_tmp_results;
}

I'd appreciate it if you could plug this in and see what your memory usage 
reports say. In most cases, trying to control the garbage collection through 
the use of references is the worst way to go about optimising your code. In my 
code above I'm relying on PHPs copy-on-write feature where data is only 
duplicated when assigned if it changes. No unsets, just using scope to mark a 
variable as able to be cleaned up.

Where is this result set coming from? You'd save yourself a lot of memory/time 
by putting the data in to this format when you read it from the source. For 
example, if reading it from MySQL, $this-tmp_results[$row['id']] = $row when 
looping around the result set.

Also, is there any reason why you need to process this full set of data in one 
go? Can you not break it up in to smaller pieces that won't put as much strain 
on resources?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



RE: [PHP] refernces, arrays, and why does it take up so much memory? [SOLVED]

2013-09-03 Thread Daevid Vincent
EUREKA!

 -Original Message-
 From: Stuart Dallas [mailto:stu...@3ft9.com]
 Sent: Tuesday, September 03, 2013 6:31 AM
 To: Daevid Vincent
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] refernces, arrays, and why does it take up so much
 memory?
 
 On 3 Sep 2013, at 02:30, Daevid Vincent dae...@daevid.com wrote:
 
  I'm confused on how a reference works I think.
 
  I have a DB result set in an array I'm looping over. All I simply want
to
 do
  is make the array key the id of the result set row.
 
  This is the basic gist of it:
 
private function _normalize_result_set()
{
   foreach($this-tmp_results as $k = $v)
   {
  $id = $v['id'];
  $new_tmp_results[$id] = $v; //2013-08-29 [dv] using
a
  reference here cuts the memory usage in half!
 
 You are assigning a reference to $v. In the next iteration of the loop, $v
 will be pointing at the next item in the array, as will the reference
you're
 storing here. With this code I'd expect $new_tmp_results to be an array
 where the keys (i.e. the IDs) are correct, but the data in each item
matches
 the data in the last item from the original array, which appears to be
what
 you describe.
 
  unset($this-tmp_results[$k]);
 
 Doing this for every loop is likely very inefficient. I don't know how the
 inner workings of PHP process something like this, but I wouldn't be
 surprised if it's allocating a new chunk of memory for a version of the
 array without this element. You may find it better to not unset anything
 until the loop has finished, at which point you can just unset($this-
 tmp_results).
 
 
  /*
  if ($i++ % 1000 == 0)
  {
gc_enable(); // Enable Garbage Collector
var_dump(gc_enabled()); // true
var_dump(gc_collect_cycles()); // # of
elements
  cleaned up
gc_disable(); // Disable Garbage Collector
  }
  */
   }
   $this-tmp_results = $new_tmp_results;
   //var_dump($this-tmp_results); exit;
   unset($new_tmp_results);
}
 
 
 Try this:
 
 private function _normalize_result_set()
 {
   // Initialise the temporary variable.
   $new_tmp_results = array();
 
   // Loop around just the keys in the array.
   foreach (array_keys($this-tmp_results) as $k)
   {
 // Store the item in the temporary array with the ID as the key.
 // Note no pointless variable for the ID, and no use of !
 $new_tmp_results[$this-tmp_results[$k]['id']] =
$this-tmp_results[$k];
   }
 
   // Assign the temporary variable to the original variable.
   $this-tmp_results = $new_tmp_results;
 }
 
 I'd appreciate it if you could plug this in and see what your memory usage
 reports say. In most cases, trying to control the garbage collection
through
 the use of references is the worst way to go about optimising your code.
In
 my code above I'm relying on PHPs copy-on-write feature where data is only
 duplicated when assigned if it changes. No unsets, just using scope to
mark
 a variable as able to be cleaned up.
 
 Where is this result set coming from? You'd save yourself a lot of
 memory/time by putting the data in to this format when you read it from
the
 source. For example, if reading it from MySQL, $this-
 tmp_results[$row['id']] = $row when looping around the result set.
 
 Also, is there any reason why you need to process this full set of data in
 one go? Can you not break it up in to smaller pieces that won't put as
much
 strain on resources?
 
 -Stuart

There were reasons I had the $id -- I only showed the relevant parts of the
code for sake of not overly complicating what I was trying to illustrate.
There is other processing that had to be done too in the loop and that is
also what I illustrated.

Here is your version effectively:

private function _normalize_result_set() //Stuart
{
  if (!$this-tmp_results || count($this-tmp_results)  1)
return;

  $new_tmp_results = array();

  // Loop around just the keys in the array.
  $D_start_mem_usage = memory_get_usage();
  foreach (array_keys($this-tmp_results) as $k)
  {
/*
if ($this-tmp_results[$k]['genres'])
{
// rip through each scene's `genres` and
store them as an array since we'll need'em later too
$g = explode('|',
$this-tmp_results[$k]['genres']);
array_pop($g); // there is an extra ''
element due to the final | character. :-\
$this-tmp_results[$k]['g'] = $g;
}
*/

// Store

Re: [PHP] refernces, arrays, and why does it take up so much memory? [SOLVED]

2013-09-03 Thread Stuart Dallas
On 3 Sep 2013, at 21:47, Daevid Vincent dae...@daevid.com wrote:

 There were reasons I had the $id -- I only showed the relevant parts of the
 code for sake of not overly complicating what I was trying to illustrate.
 There is other processing that had to be done too in the loop and that is
 also what I illustrated.
 
 Here is your version effectively:
 
   private function _normalize_result_set() //Stuart
   {
 if (!$this-tmp_results || count($this-tmp_results)  1)
 return;
 
 $new_tmp_results = array();
 
 // Loop around just the keys in the array.
 $D_start_mem_usage = memory_get_usage();
 foreach (array_keys($this-tmp_results) as $k)
 {

You could save another, relatively small, chunk of memory by crafting your loop 
with the rewind, key, current and next methods (look them up to see what they 
do). Using those you won't need to make a copy of the array keys as done in the 
above line. When you've got the amount of data you're dealing with it may be 
worth investing that time.

   /*
   if ($this-tmp_results[$k]['genres'])
   {
   // rip through each scene's `genres` and
 store them as an array since we'll need'em later too
   $g = explode('|',
 $this-tmp_results[$k]['genres']);
   array_pop($g); // there is an extra ''
 element due to the final | character. :-\

Then remove that from the string before you explode. Munging arrays is 
expensive, both computationally and in terms of memory usage.

   $this-tmp_results[$k]['g'] = $g;

Get rid of the temporary variable again - there's no need for it.

$this-tmp_results[$k]['g'] = explode('|', 
trim($this-tmp_results[$k]['genres'], '|'));

If this is going in to a class, and you have control over how it's accessed, 
you have the ability to do this when the value is accessed. This means you 
won't need to 

   }
   */
 
   // Store the item in the temporary array with the ID
 as the key.
   // Note no pointless variable for the ID, and no use of
 !
   $new_tmp_results[$this-tmp_results[$k]['id']] =
 $this-tmp_results[$k];
 }
 
 // Assign the temporary variable to the original variable.
 $this-tmp_results = $new_tmp_results;
 echo \nMEMORY USED FOR STUART's version:
 .number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
 (.number_format(memory_get_peak_usage(true)).)br\n;
 var_dump($this-tmp_results);
 exit();
   }
 
 MEMORY USED FOR STUART's version: -128 PEAK: (90,439,680)
 
 With the processing in the genres block
 MEMORY USED FOR STUART's version: 97,264,368 PEAK: (187,695,104)
 
 So a slight improvement from the original of -28,573,696
 MEMORY USED FOR _normalize_result_set(): 97,264,912 PEAK: (216,268,800)

Awesome.

 No matter what I tried however it seems that frustratingly just the simple
 act of adding a new hash to the array is causing a significant memory jump.
 That really blows! Therefore my solution was to not store the $g as ['g'] --
 which would seem to be the more efficient way of doing this once and re-use
 the array over and over, but instead I am forced to inline rip through and
 explode() in three different places of my code. 

Consider what you're asking PHP to do. You're taking an element in the middle 
of an array structure in memory and asking PHP to make it bigger. What's PHP 
going to do? It's going to copy the entire array to a new location in memory 
with an additional amount reserved for what you're adding. Note that this is 
just a guess - it's entirely possible that PHP manages it's memory better than 
that, but I wouldn't count on it.

 We get over 30,000 hits per second, and even with lots of caching, 216MB vs
 70-96MB is significant and the speed hit is only about 1.5 seconds more per
 page.
 
 Here are three distinctly different example pages that exercise different
 parts of the code path:
 
 PAGE RENDERED IN 7.0466279983521 SECONDS
 MEMORY USED @START: 262,144 - @END: 26,738,688 = 26,476,544 BYTES
 MEMORY PEAK USAGE: 69,730,304 BYTES
 
 PAGE RENDERED IN 6.9327299594879 SECONDS
 MEMORY USED @START: 262,144 - @END: 53,739,520 = 53,477,376 BYTES
 MEMORY PEAK USAGE: 79,167,488 BYTES
 
 PAGE RENDERED IN 7.55816092 SECONDS
 MEMORY USED @START: 262,144 - @END: 50,855,936 = 50,593,792 BYTES
 MEMORY PEAK USAGE: 96,206,848 BYTES

Knowing nothing about your application I'm obviously not in a strong position 
to comment, but seven seconds to generate a page would be unacceptable to me 
and any of my clients. I'll put money on it being possible to cut that time by 
changing your caching strategy. The memory usage is also ridiculous - does a 
single page really 

RE: [PHP] refernces, arrays, and why does it take up so much memory? [SOLVED]

2013-09-03 Thread Daevid Vincent


 -Original Message-
 From: Stuart Dallas [mailto:stu...@3ft9.com]
 Sent: Tuesday, September 03, 2013 2:37 PM
 To: Daevid Vincent
 Cc: php-general@lists.php.net; 'Jim Giner'
 Subject: Re: [PHP] refernces, arrays, and why does it take up so much
 memory? [SOLVED]
 
 On 3 Sep 2013, at 21:47, Daevid Vincent dae...@daevid.com wrote:
 
  There were reasons I had the $id -- I only showed the relevant parts of
 the
  code for sake of not overly complicating what I was trying to
illustrate.
  There is other processing that had to be done too in the loop and that
is
  also what I illustrated.
 
  Here is your version effectively:
 
  private function _normalize_result_set() //Stuart
  {
if (!$this-tmp_results || count($this-tmp_results)  1)
  return;
 
$new_tmp_results = array();
 
// Loop around just the keys in the array.
$D_start_mem_usage = memory_get_usage();
foreach (array_keys($this-tmp_results) as $k)
{
 
 You could save another, relatively small, chunk of memory by crafting your
 loop with the rewind, key, current and next methods (look them up to see
 what they do). Using those you won't need to make a copy of the array keys
 as done in the above line. When you've got the amount of data you're
dealing
 with it may be worth investing that time.
 
  /*
  if ($this-tmp_results[$k]['genres'])
  {
  // rip through each scene's `genres` and
  store them as an array since we'll need'em later too
  $g = explode('|',
  $this-tmp_results[$k]['genres']);
  array_pop($g); // there is an extra ''
  element due to the final | character. :-\
 
 Then remove that from the string before you explode.

 Munging arrays is
 expensive, both computationally and in terms of memory usage.
 
  $this-tmp_results[$k]['g'] = $g;
 
 Get rid of the temporary variable again - there's no need for it.

 $this-tmp_results[$k]['g'] = explode('|', trim($this-
 tmp_results[$k]['genres'], '|'));

Maybe an option. I'll look into trim() the last | off the tmp_results in a
loop at the top. Not sure if changing the variable will have the same effect
as adding one does. Interesting to see...

 If this is going in to a class, and you have control over how it's
accessed,
 you have the ability to do this when the value is accessed. This means you
 won't need to
 
  }
  */
 
  // Store the item in the temporary array with the ID
  as the key.
  // Note no pointless variable for the ID, and no use of
  !
  $new_tmp_results[$this-tmp_results[$k]['id']] =
  $this-tmp_results[$k];
}
 
// Assign the temporary variable to the original variable.
$this-tmp_results = $new_tmp_results;
echo \nMEMORY USED FOR STUART's version:
  .number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
  (.number_format(memory_get_peak_usage(true)).)br\n;
var_dump($this-tmp_results);
exit();
  }
 
  MEMORY USED FOR STUART's version: -128 PEAK: (90,439,680)
 
  With the processing in the genres block
  MEMORY USED FOR STUART's version: 97,264,368 PEAK: (187,695,104)
 
  So a slight improvement from the original of -28,573,696
  MEMORY USED FOR _normalize_result_set(): 97,264,912 PEAK: (216,268,800)
 
 Awesome.
 
  No matter what I tried however it seems that frustratingly just the
simple
  act of adding a new hash to the array is causing a significant memory
 jump.
  That really blows! Therefore my solution was to not store the $g as
['g']
 --
  which would seem to be the more efficient way of doing this once and re-
 use
  the array over and over, but instead I am forced to inline rip through
and
  explode() in three different places of my code.
 
 Consider what you're asking PHP to do. You're taking an element in the
 middle of an array structure in memory and asking PHP to make it bigger.
 What's PHP going to do? It's going to copy the entire array to a new
 location in memory with an additional amount reserved for what you're
 adding. Note that this is just a guess - it's entirely possible that PHP
 manages it's memory better than that, but I wouldn't count on it.
 
  We get over 30,000 hits per second, and even with lots of caching, 216MB
 vs
  70-96MB is significant and the speed hit is only about 1.5 seconds more
 per
  page.
 
  Here are three distinctly different example pages that exercise
different
  parts of the code path:
 
  PAGE RENDERED IN 7.0466279983521 SECONDS
  MEMORY USED @START: 262,144 - @END: 26,738,688 = 26,476,544 BYTES
  MEMORY PEAK USAGE: 69,730,304 BYTES
 
  PAGE RENDERED IN 6.9327299594879 SECONDS
  MEMORY USED @START: 262,144 - @END: 53,739,520 = 53,477,376 BYTES
  MEMORY PEAK

RE: [PHP] refernces, arrays, and why does it take up so much memory? [SOLVED]

2013-09-03 Thread Daevid Vincent
 
 
 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com]
 Sent: Tuesday, September 03, 2013 4:03 PM
 To: php-general@lists.php.net
 Cc: 'Stuart Dallas'
 Subject: RE: [PHP] refernces, arrays, and why does it take up so much
 memory? [SOLVED]
 
  $this-tmp_results[$k]['g'] = explode('|', trim($this-
  tmp_results[$k]['genres'], '|'));
 
 Maybe an option. I'll look into trim() the last | off the tmp_results in
a
 loop at the top. Not sure if changing the variable will have the same
effect
 as adding one does. Interesting to see...
 
Here are the results of that. Interesting changes. Overall it's a slight
improvement, but most significant on the middle one, so still a worthy
keeper. Odd that it wouldn't be improvement across the board though. PHP is
kookie.
 
PAGE RENDERED IN 7.1903319358826 SECONDS
MEMORY USED @START: 262,144 - @END: 27,000,832 = 26,738,688 BYTES
MEMORY PEAK USAGE: 69,992,448 BYTES
 
PAGE RENDERED IN 6.5189208984375 SECONDS
MEMORY USED @START: 262,144 - @END: 42,729,472 = 42,467,328 BYTES
MEMORY PEAK USAGE: 78,905,344 BYTES
 
PAGE RENDERED IN 7.5954079627991 SECONDS
MEMORY USED @START: 262,144 - @END: 50,331,648 = 50,069,504 BYTES
MEMORY PEAK USAGE: 96,206,848 BYTES
 
Old.
 
PAGE RENDERED IN 7.0466279983521 SECONDS
MEMORY USED @START: 262,144 - @END: 26,738,688 = 26,476,544 BYTES
MEMORY PEAK USAGE: 69,730,304 BYTES
 
PAGE RENDERED IN 6.9327299594879 SECONDS
MEMORY USED @START: 262,144 - @END: 53,739,520 = 53,477,376 BYTES
MEMORY PEAK USAGE: 79,167,488 BYTES
 
PAGE RENDERED IN 7.55816092 SECONDS
MEMORY USED @START: 262,144 - @END: 50,855,936 = 50,593,792 BYTES
MEMORY PEAK USAGE: 96,206,848 BYTES
 


Re: [PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-03 Thread Daniel
Just so that you know, I've posted in the forum topic as well:
http://forum.piwik.org/read.php?2,105879
Regards,
Daniel Fenn






On Tue, Sep 3, 2013 at 12:42 AM, Lester Caine les...@lsces.co.uk wrote:
 Jan Ehrhardt wrote:

 Could you try to add a function_exists check to
 libs/upgradephp/upgrade.php?
 
 This at the function declaration of _json_encode:
 if (!function_exists('_json_encode')) { function _json_encode($var, ...
 
 And a extra } at the end.

 This patch, together with upgrading to the latest OPcache from github
 solved my segfaults and fatal errors.


 Jan  - could you post the solution on http://dev.piwik.org/trac/ticket/4093
 - better that you get the credit than one of us pinch it ;)


 --
 Lester Caine - G8HFL
 -
 Contact - http://lsces.co.uk/wiki/?page=contact
 L.S.Caine Electronic Services - http://lsces.co.uk
 EnquirySolve - http://enquirysolve.com/
 Model Engineers Digital Workshop - http://medw.co.uk
 Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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


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



[PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-02 Thread Jan Ehrhardt
Grant in php.general (Sun, 25 Aug 2013 02:31:29 -0700):
I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the
opcache is disabled.  Someone filed a piwik bug but was told it's a
php bug:

http://dev.piwik.org/trac/ticket/4093

Could you try to add a function_exists check to
libs/upgradephp/upgrade.php?

This at the function declaration of _json_encode:
if (!function_exists('_json_encode')) { function _json_encode($var, ...

And a extra } at the end.

This seemed to correct this fatal error on my side:

[02-Sep-2013 10:35:40 Europe/Paris] PHP Fatal error:  Cannot redeclare
_json_encode() (previously declared in
/usr/local/lib/php/share/piwik/libs/upgradephp/upgrade.php:109) in
/usr/local/lib/php/share/piwik/libs/upgradephp/upgrade.php on line 109

I do not know what opcache has to do with it, although I suspect that
Piwik is calling itself a lot of times and that opcache is trailing
behind (or something like that).

Jan

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



[PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-02 Thread Jan Ehrhardt
Jan Ehrhardt in php.general (Mon, 02 Sep 2013 10:57:14 +0200):
Could you try to add a function_exists check to
libs/upgradephp/upgrade.php?

This at the function declaration of _json_encode:
if (!function_exists('_json_encode')) { function _json_encode($var, ...

And a extra } at the end.

This patch, together with upgrading to the latest OPcache from github
solved my segfaults and fatal errors.

Jan

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



Re: [PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-02 Thread Lester Caine

Jan Ehrhardt wrote:

Could you try to add a function_exists check to
libs/upgradephp/upgrade.php?

This at the function declaration of _json_encode:
if (!function_exists('_json_encode')) { function _json_encode($var, ...

And a extra } at the end.

This patch, together with upgrading to the latest OPcache from github
solved my segfaults and fatal errors.


Jan  - could you post the solution on http://dev.piwik.org/trac/ticket/4093 - 
better that you get the credit than one of us pinch it ;)


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



RE: [PHP] Re: refernces, arrays, and why does it take up so much memory?

2013-09-02 Thread Daevid Vincent


 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Monday, September 02, 2013 8:14 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: refernces, arrays, and why does it take up so much
 memory?
 
 On 9/2/2013 9:30 PM, Daevid Vincent wrote:
  I'm confused on how a reference works I think.
 
  I have a DB result set in an array I'm looping over. All I simply want
to
 do
  is make the array key the id of the result set row.
 
  This is the basic gist of it:
 
  private function _normalize_result_set()
  {
 foreach($this-tmp_results as $k = $v)
 {
$id = $v['id'];
$new_tmp_results[$id] = $v; //2013-08-29 [dv]
using
 a
  reference here cuts the memory usage in half!
unset($this-tmp_results[$k]);
 
/*
if ($i++ % 1000 == 0)
{
  gc_enable(); // Enable Garbage Collector
  var_dump(gc_enabled()); // true
  var_dump(gc_collect_cycles()); // # of
 elements
  cleaned up
  gc_disable(); // Disable Garbage Collector
}
*/
 }
 $this-tmp_results = $new_tmp_results;
 //var_dump($this-tmp_results); exit;
 unset($new_tmp_results);
  }
 
  Without using the = reference, my data works great:
  $new_tmp_results[$id] = $v;
 
  array (size=79552)
 6904 =
   array (size=4)
 'id' = string '6904' (length=4)
 'studio_id' = string '5' (length=1)
 'genres' = string '34|' (length=3)
 6905 =
   array (size=4)
 'id' = string '6905' (length=4)
 'studio_id' = string '5' (length=1)
 'genres' = string '6|37|' (length=5)
 
  However it takes a stupid amount of memory for some unknown reason.
  MEMORY USED @START: 262,144 - @END: 42,729,472 = 42,467,328 BYTES
  MEMORY PEAK USAGE: 216,530,944 BYTES
 
  When using the reference the memory drastically goes down to what I'd
 EXPECT
  it to be (and actually the problem I'm trying to solve).
  MEMORY USED @START: 262,144 - @END: 6,029,312 = 5,767,168 BYTES
  MEMORY PEAK USAGE: 82,051,072 BYTES
 
  However my array is all kinds of wrong:
 
  array (size=79552)
 6904 = 
   array (size=4)
 'id' = string '86260' (length=5)
 'studio_id' = string '210' (length=3)
 'genres' = string '8|9|10|29|58|' (length=13)
 6905 = 
   array (size=4)
 'id' = string '86260' (length=5)
 'studio_id' = string '210' (length=3)
 'genres' = string '8|9|10|29|58|' (length=13)
 
  Notice that they're all the same values, although the keys seem right. I
  don't understand why that happens because
  foreach($this-tmp_results as $k = $v)
  Should be changing $v each iteration I'd think.
 
  Honestly, I am baffled as to why those unsets() make no difference. All
I
  can think is that the garbage collector doesn't run. But then I had also
  tried to force gc() and that still made no difference. *sigh*
 
  I had some other cockamamie idea where I'd use the same tmp_results
array
 in
  a tricky way to avoid a  second array. The concept being I'd add 1
million
  to the ['id'] (which we want as the new array key), then unset the
 existing
  sequential key, then when all done, loop through and shift all the keys
by
 1
  million thereby they'd be the right index ID. So add one and unset one
  immediately after. Clever right? 'cept it too made no difference on
 memory.
  Same thing is happening as above where the gc() isn't running or
something
  is holding all that memory until the end. *sigh*
 
  Then I tried a different way using array_combine() and noticed something
  very disturbing.
  http://www.php.net/manual/en/function.array-combine.php
 
 
  private function _normalize_result_set()
  {
 if (!$this-tmp_results || count($this-tmp_results)  1)
  return;
 
 $D_start_mem_usage = memory_get_usage();
 foreach($this-tmp_results as $k = $v)
 {
$id = $v['id'];
$tmp_keys[] = $id;
 
if ($v['genres'])
{
   $g = explode('|', $v['genres']);
  $this-tmp_results[$k]['g'] = $g; //this
 causes a
  massive spike in memory usage
}
 }
 //var_dump($tmp_keys, $this-tmp_results); exit;
 echo \nMEMORY USED BEFORE array_combine:
  .number_format(memory_get_usage() - $D_start_mem_usage). PEAK:
  (.number_format(memory_get_peak_usage(true)).)br\n;
 $this-tmp_results = array_combine($tmp_keys,
  $this-tmp_results);
 echo \nMEMORY USED FOR 

[PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-01 Thread Grant
 I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the
 opcache is disabled.  Someone filed a piwik bug but was told it's a
 php bug:

 http://dev.piwik.org/trac/ticket/4093

 - Grant

Is this a known issue?

- Grant

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



Re: [PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-01 Thread Lester Caine

Grant wrote:

I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the
opcache is disabled.  Someone filed a piwik bug but was told it's a
php bug:

http://dev.piwik.org/trac/ticket/4093



Is this a known issue?


I'm running my own port of piwik in production with eaccelerator on 5.4 but I've 
made the decision not to move any of the machines to 5.5 until all of the legacy 
5.2 machines have been brought up to 5.4. Not an answer, but explains perhaps 
why the problem is not being seen by others.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-01 Thread Jan Ehrhardt
Lester Caine in php.general (Sun, 01 Sep 2013 12:59:18 +0100):
Grant wrote:
 I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the
 opcache is disabled.  Someone filed a piwik bug but was told it's a
 php bug:
 
 http://dev.piwik.org/trac/ticket/4093

 Is this a known issue?

 (...) Not an answer, but explains perhaps  why the problem is not being
seen by others.

It is more likely that users do not notice it. I have Piwik running with
PHP 5.3 and php_opcache.dll (Centos 5) and it segfaults:

[Sun Sep 01 17:06:53.131410 2013] [core:notice] [pid 25411] AH00052:
child pid 25451 exit signal Segmentation fault (11)
[Sun Sep 01 17:08:18.561917 2013] [core:notice] [pid 25411] AH00052:
child pid 25453 exit signal Segmentation fault (11)
[Sun Sep 01 17:08:19.569714 2013] [core:notice] [pid 25411] AH00052:
child pid 25450 exit signal Segmentation fault (11)

However, nothing special is displaying on the page. You have to grep
your Apache error_log to know that it happens. How did you notice?

Jan

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



[PHP] Re: PHP-5.5.2 +opcache segfaults with Piwik

2013-09-01 Thread Jan Ehrhardt
Grant in php.general (Sun, 1 Sep 2013 02:13:54 -0700):
 I've tried php-5.5.2 and 5.5.3 but both segfault with piwik unless the
 opcache is disabled.  Someone filed a piwik bug but was told it's a
 php bug:

 http://dev.piwik.org/trac/ticket/4093

Is this a known issue?

I changed the PHP on my (dev) Centos5 server to PHP 5.5.3, pulled the
latest OPcache from Github and tried to get a segfault. That was clearly
visible when I tried to access the Goals tab in the dashboard of one of
my websites. The page never got further than 'Loading data...' and my
Apache log showed a segfault.

So, if it was no known issue it is confirmed now.

Jan

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



[PHP] RE: php seg faults on creation pdf

2013-08-28 Thread KAs Coenen
Hi, 

Some more info. I ran gdb on the core file (after reinstalling with debug mode):

# /usr/local/gdb/bin/gdb /usr/local/php5/bin/php-cgi 
/opt/apache/htdocs/wachtlijst/core
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i386-pc-solaris2.10.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /usr/local/php5/bin/php-cgi...done.
[New LWP 1]
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
Core was generated by `/usr/local/php5/bin/php-cgi 
/opt/apache/htdocs/wachtlijst/test.php'.
Program terminated with signal 11, Segmentation fault.
#0  0x0093baa4 in _object_and_properties_init (arg=error reading 
variable: Cannot access memory at address 0xffd8,
    arg@entry=error reading variable: Cannot access memory at address 0x8, 
class_type=error reading variable: Cannot access memory at address 
0xffd0,
    class_type@entry=error reading variable: Cannot access memory at address 
0x8, properties=error reading variable: Cannot access memory at address 
0xffc8,
    properties@entry=error reading variable: Cannot access memory at address 
0x8) at /export/home/coenenka/php-5.5.1/Zend/zend_API.c:1200
1200    Z_OBJVAL_P(arg) = class_type-create_object(class_type 
TSRMLS_CC);

Does anyone see anything in this? The dir /export/home/coenenka is not the 
install dir (but my home drive) and I have no clue why it is referencing to 
that dir (it is the location of the source). 

Greetings,

Kas



 From: kascoe...@hotmail.com
 To: php-general@lists.php.net
 Subject: php seg faults on creation pdf
 Date: Wed, 28 Aug 2013 10:00:29 +0200

 Hi,

 When surfing to a website that generates a pdf the apache server segfaults. 
 This made me run the script (that generates the pdf) with the php cli 
 command. The php also segfaults with the same error:

 # /usr/local/php5/bin/php-cgi test.php
 Segmentation Fault (core dumped)

 Pstack output:

 # pstack core
 core 'core' of 726: /usr/local/php5/bin/php-cgi test.php
  00960af5 _object_and_properties_init () + 111

 I attached the truss output to the mail. I am running this on a solaris 
 server:

 # uname -a
 SunOS zone-eu4 5.10 Generic_142910-17 i86pc i386 i86pc
 # cat /etc/release
 Oracle Solaris 10 9/10 s10x_u9wos_14a X86
  Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 Assembled 11 August 2010

 pdflib module is 2.1.10. PDFlib lite is version 7.0.5. I tried to compile 
 everything in 64 bit. I suspect the problem is that somewhere a 32bit lib or 
 executable is being used instead of a 64bit.


 Can anyone help me out on this?

 Kind regards,

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



Re: [PHP] Basic Auth

2013-08-28 Thread Jim Giner

Stuart,

Just wanted to follow up with my thanks for your excellent help in 
providing understanding of how to generate the 401 error page and 
getting me thru the process of performing a sign-out from basic auth. 
Without your patience it never would have happened.


Also wanted to tell you that I've scrapped it all.  Keeping the code for 
a rainy day of course, but giving up on using it (as well as the basic 
auth signon process) to use my own 'roll-your-own' code.  Since IE 
insisted on presenting multiple credentials during the signon process it 
was a futile effort to be doing a signoff.  And yes - I've taken the 
proper precautions to hash the incoming password value before submission 
and storing in my db that way.


Thanks again.  It's help like this that makes this group such a great 
resource.


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



Re: [PHP] Basic Auth

2013-08-28 Thread Stuart Dallas
On 27 Aug 2013, at 18:45, Jim Giner jim.gi...@albanyhandball.com wrote:

 From your latest missive I gleaned that I needed to have a script on my server

One last time: YOU DON'T NEED TO CHANGE ANYTHING ON THE SERVER-SIDE!

Ok, I see that you've decided to use another method, which is great; HTTP auth 
is a pretty antiquated way to handle authentication these days. Whatever you're 
using, I wish you all the best with it.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

Re: [PHP] Re: Permissions

2013-08-27 Thread Ashley Sheridan
On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:

 Ethan Rosenberg wrote:
 
  Dear List -
  
  Tried to run the program, that we have been discussing, and received a
  403 error.
  
  rosenberg:/var/www# ls -la StoreInventory.php
  -rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php
  
  rosenberg:/var# ls -ld www
  drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www
  
  I had set the S bit [probably a nasty mistake] and I thought I was able
  to remove the bit. [it doesn't show above]
  
  How do I extricate myself from the hole into which I have planted myself?
  
  TIA
  
  Ethan
 
 This is in no way a php question, as the same result will happen no matter 
 what you ask apache to serve from that directory.
 
 You have the directory permissions set to 776 not 777.
 -- 
 Cheers
 David Robley
 
 Steal this tagline and I'll tie-dye your cat!
 
 


776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What 

It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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




Re: [PHP] Re: Permissions

2013-08-27 Thread David Robley
Ashley Sheridan wrote:

 On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:
 
 Ethan Rosenberg wrote:
 
  Dear List -
  
  Tried to run the program, that we have been discussing, and received a
  403 error.
  
  rosenberg:/var/www# ls -la StoreInventory.php
  -rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php
  
  rosenberg:/var# ls -ld www
  drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www
  
  I had set the S bit [probably a nasty mistake] and I thought I was able
  to remove the bit. [it doesn't show above]
  
  How do I extricate myself from the hole into which I have planted
  myself?
  
  TIA
  
  Ethan
 
 This is in no way a php question, as the same result will happen no
 matter what you ask apache to serve from that directory.
 
 You have the directory permissions set to 776 not 777.
 --
 Cheers
 David Robley
 
 Steal this tagline and I'll tie-dye your cat!
 
 
 
 
 776 won't matter in the case of a directory, as the last bit is for the
 eXecute permissions, which aren't applicable to a directory. What

I beg to differ here. If the x bit isn't set on a directory, that will 
prevent scanning of the directory; in this case apache will be prevented 
from scanning the directory and will return a 403.

 It's possible that this is an SELinux issue, which adds an extra layer
 of permissions over files. To see what those permissions are, use the -Z
 flag for ls. Also, check the SELinux logs (assuming that it's running
 and it is causing a problem) to see if it brings up anything. It's
 typically found on RedHat-based distros.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

-- 
Cheers
David Robley

Artificial Intelligence is no match for natural stupidity.


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



Re: [PHP] exec and system do not work

2013-08-27 Thread Jim Giner

On 8/26/2013 5:01 PM, Ethan Rosenberg, PhD wrote:


On 08/26/2013 03:28 PM, Jim Giner wrote:

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um
08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  Please show the output of the directory listing.
  Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything
works.


  When you say does not work, can you show what is actually not
working? I
  believe the exec and system functions are likely working just fine,
but that
  the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDNT ACTUALLY RUN.

I've told you multiple times that you need to do these two things and
you are back at it again.

The sample php above has plain simple syntax errors that would keep it
from running, which error checking would tell you IF YOU RAN IT.



Jim -

Thank you.

I don't totally understand your reply ...

but I will try to answer

The code is taken from an operating program.  My error checking is set
to maximum sensitivity.

If you would point out my syntax errors, I will fix them.

TIA

Ethan


you have semis after your if lines - therefore no logic gets executed.

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



Re: [PHP] Basic Auth

2013-08-27 Thread Stuart Dallas
On 27 Aug 2013, at 14:37, Jim Giner jim.gi...@albanyhandball.com wrote:

 Im using basic auth for a few of my pages that I want to limit access to - 
 nothing of a sensitive nature, but simply want to limit access to.  Want to 
 implement a signoff process, but can't figure it out.
 
 From the comments in the manual I take it one can't do this by simply 
 unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why this 
 doesn't suffice?  The signon process expects them to be there, so when they 
 are not (after the 'unset'), how come my signon process still detects them 
 and their values?


The global variables you're referring to are just that, global variables; 
changing them will have no effect on the browser. Basic Auth was not designed 
to allow users to log out, but you can make it happen with some Javascript.

Have your log out link call a Javascript function which sends an XMLHttpRequest 
with an invalid username and password. The server will return a 401 which you 
ignore and then take the user to whatever URL you want them to see after they 
log off. Not pretty, but it works.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 9:46 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 14:37, Jim Giner jim.gi...@albanyhandball.com wrote:


Im using basic auth for a few of my pages that I want to limit access to - 
nothing of a sensitive nature, but simply want to limit access to.  Want to 
implement a signoff process, but can't figure it out.

 From the comments in the manual I take it one can't do this by simply 
unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why this 
doesn't suffice?  The signon process expects them to be there, so when they are 
not (after the 'unset'), how come my signon process still detects them and 
their values?


The global variables you're referring to are just that, global variables; 
changing them will have no effect on the browser. Basic Auth was not designed 
to allow users to log out, but you can make it happen with some Javascript.

Have your log out link call a Javascript function which sends an XMLHttpRequest 
with an invalid username and password. The server will return a 401 which you 
ignore and then take the user to whatever URL you want them to see after they 
log off. Not pretty, but it works.

-Stuart


Thanks for the timely response!

Before I try your suggestion - one question.  Since when is a global 
variable not changeable?  Doesn't the fact that it reflects a modified 
value when I do change it tell me it worked?  I change the value to 
'xxx' and show it having that value, but when the script is called again 
the old value appears.  Very confusing!



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



Re: [PHP] Basic Auth

2013-08-27 Thread Stuart Dallas
On 27 Aug 2013, at 15:06, Jim Giner jim.gi...@albanyhandball.com wrote:

 
 On 8/27/2013 9:46 AM, Stuart Dallas wrote:
 On 27 Aug 2013, at 14:37, Jim Giner jim.gi...@albanyhandball.com wrote:
 
 Im using basic auth for a few of my pages that I want to limit access to - 
 nothing of a sensitive nature, but simply want to limit access to.  Want to 
 implement a signoff process, but can't figure it out.
 
 From the comments in the manual I take it one can't do this by simply 
 unsetting the PHP_AUTH_USER and _PW vars.  Can someone explain to me why 
 this doesn't suffice?  The signon process expects them to be there, so when 
 they are not (after the 'unset'), how come my signon process still detects 
 them and their values?
 
 The global variables you're referring to are just that, global variables; 
 changing them will have no effect on the browser. Basic Auth was not 
 designed to allow users to log out, but you can make it happen with some 
 Javascript.
 
 Have your log out link call a Javascript function which sends an 
 XMLHttpRequest with an invalid username and password. The server will return 
 a 401 which you ignore and then take the user to whatever URL you want them 
 to see after they log off. Not pretty, but it works.
 
 -Stuart
 
 Thanks for the timely response!
 
 Before I try your suggestion - one question.  Since when is a global variable 
 not changeable?  Doesn't the fact that it reflects a modified value when I do 
 change it tell me it worked?  I change the value to 'xxx' and show it having 
 that value, but when the script is called again the old value appears.  Very 
 confusing!

I didn't say you couldn't change it, I said doing so will have no effect on the 
browser.

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart

[1] The one exception to this is $_SESSION, but it's important to know how that 
works. The $_SESSION array is populated when you call session_start(). It's 
loaded from some form of storage (files by default) and unserialised in to 
$_SESSION. When the session is closed, either implicitly by the request ending 
or by a call to one of the methods that explicitly do it, the contents are 
serialised to the storage system. Once closed, any changes to $_SESSION will 
not be stored; it becomes just another superglobal (not that it was ever 
anything else).

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart



Not really - this is the first time I've had something not work as expected.


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



Re: [PHP] Basic Auth

2013-08-27 Thread Stuart Dallas
On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:

 On 8/27/2013 10:14 AM, Stuart Dallas wrote:
 It's not really confusing so long as you understand how PHP works. Each 
 request is brand new - nothing is retained from previous requests. The two 
 variable you're changing are set by PHP when the request comes in from the 
 browser. The fact you changed them in a previous request is irrelevant 
 because 1) that change was not communicated to the browser in any way, and 
 2) PHP doesn't retain any data between requests [1].
 
 If you've been coding assuming that changes you make to global variables are 
 retained between requests you must have been having some pretty frustrating 
 times!
 
 -Stuart
 
 
 Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

  I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

   I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart

This may very well be the first time with this problem because I haven't 
tried anything like this before.


That said - can you give me some pointers on how to do the JS solution?  
I'm calling a script that is similar to the one I used to signon.  It 
sends out something like:


header(WWW-Authenticate: Basic realm=$realm);
header('HTTP/1.0 401 Unauthorized');
echo h3You have entered invalid credentialsbr;
echo Click a href='$return_url' here /a to return to the 
menu.;

exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid 
value, but what do I do with that?  How do I ignore the 401?   Now I'm 
getting the signin dialog and I'm stuck.



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



Re: [PHP] Basic Auth

2013-08-27 Thread Stuart Dallas
On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:

 On 8/27/2013 10:39 AM, Stuart Dallas wrote:
 On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:
 
 On 8/27/2013 10:14 AM, Stuart Dallas wrote:
 It's not really confusing so long as you understand how PHP works. Each 
 request is brand new - nothing is retained from previous requests. The two 
 variable you're changing are set by PHP when the request comes in from the 
 browser. The fact you changed them in a previous request is irrelevant 
 because 1) that change was not communicated to the browser in any way, and 
 2) PHP doesn't retain any data between requests [1].
 
 If you've been coding assuming that changes you make to global variables 
 are retained between requests you must have been having some pretty 
 frustrating times!
 
 -Stuart
 
 Not really - this is the first time I've had something not work as expected.
 That was said with my tongue very much firmly in my cheek, and so is this:
 
   I've been playing with dynamite since I was 4 - hey, it must be a safe, 
 proper thing to do!
 
 Just because nothing has blown up in your face yet doesn't mean it won't, 
 and I'm concerned that you might not actually see how important it is to 
 make sure you're using the tool correctly.
 
 -Stuart
 
 This may very well be the first time with this problem because I haven't 
 tried anything like this before.
 
 That said - can you give me some pointers on how to do the JS solution?  I'm 
 calling a script that is similar to the one I used to signon.  It sends out 
 something like:
 
header(WWW-Authenticate: Basic realm=$realm);
header('HTTP/1.0 401 Unauthorized');
echo h3You have entered invalid credentialsbr;
echo Click a href='$return_url' here /a to return to the menu.;
exit();
 
 when it doesn't detect the PHP_AUTH_USER or it is an invalid value.
 
 So - to effect a signoff, what does one do?   You said to use an invalid 
 value, but what do I do with that?  How do I ignore the 401?   Now I'm 
 getting the signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

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



Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 10:55 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

   I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart


This may very well be the first time with this problem because I haven't tried 
anything like this before.

That said - can you give me some pointers on how to do the JS solution?  I'm 
calling a script that is similar to the one I used to signon.  It sends out 
something like:

header(WWW-Authenticate: Basic realm=$realm);
header('HTTP/1.0 401 Unauthorized');
echo h3You have entered invalid credentialsbr;
echo Click a href='$return_url' here /a to return to the menu.;
exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid value, 
but what do I do with that?  How do I ignore the 401?   Now I'm getting the 
signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart

I am familiar with an ajax request (xmlhttprequest) and I have a 
function ready to call a script to effect this signoff.  I just don't 
know what to put in that php script I'm calling.  From what you just 
wrote I'm guessing that my headers as shown previously  may be close - 
Im confused about your mention of contains an invalid username  
As you can see from my sample I don't include such a thing.



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



Re: [PHP] Off the wall - sub-domain question

2013-08-27 Thread Daniel Brown
On Wed, Aug 21, 2013 at 5:16 PM, Jim Giner jim.gi...@albanyhandball.com wrote:
 I have a main domain (of course) and a sub domain.  I'm really trying to
 steer my personal stuff away from the main one and have focused all of my
 php development to the sub-domain.

 Lately I noticed that google catalogs my sub-domain site stuff under the
 main domain name and the links that come up lead to that domain name with
 the path that takes the user to the sub-domain's home folder and beyond.

 Is there something that php (apache??) can do to control either google's
 robots or the user's view (url) so that it appears as a page of my
 sub-domain?  I'm really new at this stuff and know nothing.  I'm lucky that
 google is even finding my site!

You'd probably want to do some 301 redirects with mod_rewrite to
force the domain over to the subdomain if under that directory.  In so
doing, Google (and other search engines) will drop the /subdomain
folder, and index only the destination.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Re: Permissions

2013-08-27 Thread Daniel Brown
On Tue, Aug 27, 2013 at 3:07 AM, David Robley robl...@zoho.com wrote:

 I beg to differ here. If the x bit isn't set on a directory, that will
 prevent scanning of the directory; in this case apache will be prevented
 from scanning the directory and will return a 403.

Well, that's partially correct.  If a directory is owned by
someone other than the current user (for example, root) and is 0776,
you can list the directory content from outside of the directory to
get a basic file listing.  What you won't get by doing that, however,
is anything other than the file name and type, because the kernel is
forbidden from executing mtime, ctime, and owner/group queries on the
files.  In addition, you won't be able to enter the directory (cd).

That said, if Ethan is running his Apache server as the user
'ethan' (which isn't mentioned) then it would be fine regardless.

As for the 's' notation, that's either a bitmask of 0400 or 0200,
which are for setuid and setgid, respectively.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] How to send post-variables in a Location header

2013-08-27 Thread Daniel Brown
On Mon, Aug 26, 2013 at 3:48 PM, Ajay Garg ajaygargn...@gmail.com wrote:
 Hi all.

 I have a scenario, wherein I need to do something like this ::

 ###
 $original_url = /autologin.php;
 $username = ajay;
 $password = garg;

 header('Location: ' . $original_url);
 ###

 As can be seen, I wish to redirect to the URL autologin.php.

 Additionally, I wish to pass two POST key-value pairs :: user=ajay and
 password=garg (I understand that passing GET key-value pairs is trivial).

 Is it  even possible?
 If yes, I will be grateful if someone could let me know how to redirect to
 a URL, passing the POST key-value pairs as necessary.

No.  Sending a 'Location:' header issues an HTTP 301 by default,
which means the browser will follow it using a GET request.  If you
can't pass the information from one location to another using sessions
or (less ideally) cookies, you might consider doing a cURL POST
request in the background and passing the session ID back to the
browser, and having it handle it appropriately (read: session
hijack).

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] exec and system do not work

2013-08-27 Thread Daniel Brown
On Sun, Aug 25, 2013 at 11:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:
 Dear List -

 I'm lost on this one -

 This works -

 $out = system(ls -l ,$retvals);
 printf(%s, $out);

 This does -

 echo exec(ls -l);

 This does not -

 if( !file_exists(/var/www/orders.txt));
 {
$out = system(touch /var/www/orders.txt, $ret);
$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
 }

?php echo `whoami`; ?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Basic Auth

2013-08-27 Thread Stuart Dallas
On 27 Aug 2013, at 17:28, Jim Giner jim.gi...@albanyhandball.com wrote:

 On 8/27/2013 11:56 AM, Stuart Dallas wrote:
 Oops, sent this message from the wrong email address, so the list rejected 
 it.
 
 Begin forwarded message:
 
 From: Stuart Dallas stu...@3ft9.com
 Subject: Re: [PHP] Basic Auth
 Date: 27 August 2013 16:36:27 BST
 To: jim.gi...@albanyhandball.com
 Cc: php-general@lists.php.net
 
 On 27 Aug 2013, at 15:59, Jim Giner jim.gi...@albanyhandball.com wrote:
 
 On 8/27/2013 10:55 AM, Stuart Dallas wrote:
 On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:
 
 On 8/27/2013 10:39 AM, Stuart Dallas wrote:
 On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com 
 wrote:
 
 On 8/27/2013 10:14 AM, Stuart Dallas wrote:
 It's not really confusing so long as you understand how PHP works. 
 Each request is brand new - nothing is retained from previous 
 requests. The two variable you're changing are set by PHP when the 
 request comes in from the browser. The fact you changed them in a 
 previous request is irrelevant because 1) that change was not 
 communicated to the browser in any way, and 2) PHP doesn't retain any 
 data between requests [1].
 
 If you've been coding assuming that changes you make to global 
 variables are retained between requests you must have been having 
 some pretty frustrating times!
 
 -Stuart
 
 Not really - this is the first time I've had something not work as 
 expected.
 That was said with my tongue very much firmly in my cheek, and so is 
 this:
 
  I've been playing with dynamite since I was 4 - hey, it must be a 
 safe, proper thing to do!
 
 Just because nothing has blown up in your face yet doesn't mean it 
 won't, and I'm concerned that you might not actually see how important 
 it is to make sure you're using the tool correctly.
 
 -Stuart
 
 This may very well be the first time with this problem because I haven't 
 tried anything like this before.
 
 That said - can you give me some pointers on how to do the JS solution?  
 I'm calling a script that is similar to the one I used to signon.  It 
 sends out something like:
 
   header(WWW-Authenticate: Basic realm=$realm);
   header('HTTP/1.0 401 Unauthorized');
   echo h3You have entered invalid credentialsbr;
   echo Click a href='$return_url' here /a to return to the 
 menu.;
   exit();
 
 when it doesn't detect the PHP_AUTH_USER or it is an invalid value.
 
 So - to effect a signoff, what does one do?   You said to use an invalid 
 value, but what do I do with that?  How do I ignore the 401?   Now I'm 
 getting the signin dialog and I'm stuck.
 You don't need to do anything on the server-side. You simply need a JS 
 function that sends a request to a URL that requires basic auth, with an 
 Authenticate header that contains an invalid username and password. Then, 
 when your server responds with a 401 Authentication required (which it 
 should already do for an invalid request) you can set location.href to 
 whatever URL you want the logged out user to see.
 
 If you don't know how to make a request from Javascript -- commonly known 
 as an AJAX request -- then google for it. I'd recommend the jquery 
 library if you want a very easy way to do it.
 
 -Stuart
 
 I am familiar with an ajax request (xmlhttprequest) and I have a function 
 ready to call a script to effect this signoff.  I just don't know what to 
 put in that php script I'm calling.  From what you just wrote I'm guessing 
 that my headers as shown previously  may be close - Im confused about 
 your mention of contains an invalid username  As you can see from my 
 sample I don't include such a thing.
 
 For the last time: YOU DO NOT NEED TO MAKE ANY CHANGES SERVER-SIDE.
 
 From the Javascript, request any URL that requires authentication - it 
 doesn't matter. When you make the AJAX request, pass an Authentication 
 header that contains an invalid username and password. If you don't know 
 what I mean by that, please google how HTTP Basic Auth works.
 
 -Stuart
 
 It's not the basic auth that I'm having the issue with - it's the 'header' 
 thing and understanding what a 401 is doing and how I'm to ignore it.  Never 
 had to play with these things before and this part is all new.  Let's face it 
 - I'm an applications guy, not a systems guy. All this talk of headers and 
 such is greek to me.

HTTP headers are as important for application guys as they are for systems 
guys. I appreciate that this may be new to you, but it's pretty basic knowledge 
about how HTTP works.

Basic auth is simple, and you need to understand how it works to understand 
what I've been trying to say. Here's how HTTP auth works:

1) Browser hits page.
2) The PHP script knows this page requires HTTP Auth, checks the 
PHP_AUTH_[USER|PW] variables but doesn't find anything, so it responds with an 
HTTP status of 401 Unauthorised.
3) The browser gets the 401 response and displays the login box.
4) User enters username and password

Re: [PHP] Basic Auth

2013-08-27 Thread Jim Giner


On 8/27/2013 12:53 PM, Stuart Dallas wrote:

On 27 Aug 2013, at 17:28, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 11:56 AM, Stuart Dallas wrote:

Oops, sent this message from the wrong email address, so the list rejected it.

Begin forwarded message:


From: Stuart Dallas stu...@3ft9.com
Subject: Re: [PHP] Basic Auth
Date: 27 August 2013 16:36:27 BST
To: jim.gi...@albanyhandball.com
Cc: php-general@lists.php.net

On 27 Aug 2013, at 15:59, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:55 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:51, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:39 AM, Stuart Dallas wrote:

On 27 Aug 2013, at 15:18, Jim Giner jim.gi...@albanyhandball.com wrote:


On 8/27/2013 10:14 AM, Stuart Dallas wrote:

It's not really confusing so long as you understand how PHP works. Each request 
is brand new - nothing is retained from previous requests. The two variable 
you're changing are set by PHP when the request comes in from the browser. The 
fact you changed them in a previous request is irrelevant because 1) that 
change was not communicated to the browser in any way, and 2) PHP doesn't 
retain any data between requests [1].

If you've been coding assuming that changes you make to global variables are 
retained between requests you must have been having some pretty frustrating 
times!

-Stuart


Not really - this is the first time I've had something not work as expected.

That was said with my tongue very much firmly in my cheek, and so is this:

  I've been playing with dynamite since I was 4 - hey, it must be a safe, 
proper thing to do!

Just because nothing has blown up in your face yet doesn't mean it won't, and 
I'm concerned that you might not actually see how important it is to make sure 
you're using the tool correctly.

-Stuart


This may very well be the first time with this problem because I haven't tried 
anything like this before.

That said - can you give me some pointers on how to do the JS solution?  I'm 
calling a script that is similar to the one I used to signon.  It sends out 
something like:

   header(WWW-Authenticate: Basic realm=$realm);
   header('HTTP/1.0 401 Unauthorized');
   echo h3You have entered invalid credentialsbr;
   echo Click a href='$return_url' here /a to return to the menu.;
   exit();

when it doesn't detect the PHP_AUTH_USER or it is an invalid value.

So - to effect a signoff, what does one do?   You said to use an invalid value, 
but what do I do with that?  How do I ignore the 401?   Now I'm getting the 
signin dialog and I'm stuck.

You don't need to do anything on the server-side. You simply need a JS function 
that sends a request to a URL that requires basic auth, with an Authenticate 
header that contains an invalid username and password. Then, when your server 
responds with a 401 Authentication required (which it should already do for an 
invalid request) you can set location.href to whatever URL you want the logged 
out user to see.

If you don't know how to make a request from Javascript -- commonly known as an 
AJAX request -- then google for it. I'd recommend the jquery library if you 
want a very easy way to do it.

-Stuart


I am familiar with an ajax request (xmlhttprequest) and I have a function ready to call a 
script to effect this signoff.  I just don't know what to put in that php script I'm calling.  
From what you just wrote I'm guessing that my headers as shown previously  may be close - 
Im confused about your mention of contains an invalid username  As you 
can see from my sample I don't include such a thing.

For the last time: YOU DO NOT NEED TO MAKE ANY CHANGES SERVER-SIDE.

 From the Javascript, request any URL that requires authentication - it doesn't 
matter. When you make the AJAX request, pass an Authentication header that 
contains an invalid username and password. If you don't know what I mean by 
that, please google how HTTP Basic Auth works.

-Stuart

It's not the basic auth that I'm having the issue with - it's the 'header' 
thing and understanding what a 401 is doing and how I'm to ignore it.  Never 
had to play with these things before and this part is all new.  Let's face it - 
I'm an applications guy, not a systems guy. All this talk of headers and such 
is greek to me.

HTTP headers are as important for application guys as they are for systems 
guys. I appreciate that this may be new to you, but it's pretty basic knowledge 
about how HTTP works.

Basic auth is simple, and you need to understand how it works to understand 
what I've been trying to say. Here's how HTTP auth works:

1) Browser hits page.
2) The PHP script knows this page requires HTTP Auth, checks the 
PHP_AUTH_[USER|PW] variables but doesn't find anything, so it responds with an 
HTTP status of 401 Unauthorised.
3) The browser gets the 401 response and displays the login box.
4) User enters username and password.
5) Browser sends the request again

Re: [PHP] Re: Permissions

2013-08-27 Thread Ethan Rosenberg


On 08/27/2013 03:07 AM, David Robley wrote:

Ashley Sheridan wrote:


On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:


Ethan Rosenberg wrote:


Dear List -

Tried to run the program, that we have been discussing, and received a
403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was able
to remove the bit. [it doesn't show above]

How do I extricate myself from the hole into which I have planted
myself?

TIA

Ethan


This is in no way a php question, as the same result will happen no
matter what you ask apache to serve from that directory.

You have the directory permissions set to 776 not 777.
--
Cheers
David Robley

Steal this tagline and I'll tie-dye your cat!





776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What


I beg to differ here. If the x bit isn't set on a directory, that will
prevent scanning of the directory; in this case apache will be prevented
from scanning the directory and will return a 403.


It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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



I checked with the -Z option

ethan@rosenberg:/var/www$ ls -lZ StoreInventory.php
-rwxrwsr-t 1 ethan ethan ? 4232 Aug 27 00:18 StoreInventory.php

Ethan

PS David-

I promise that I will not steal your tag line.  My short hair American 
tabby cat [Gingy Feline Rosenberg]is too nice to have anything done to her.


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



Re: [PHP] Re: Permissions

2013-08-27 Thread Ethan Rosenberg


On 08/27/2013 01:52 PM, Ethan Rosenberg wrote:


On 08/27/2013 03:07 AM, David Robley wrote:

Ashley Sheridan wrote:


On Tue, 2013-08-27 at 16:16 +0930, David Robley wrote:


Ethan Rosenberg wrote:


Dear List -

Tried to run the program, that we have been discussing, and received a
403 error.

rosenberg:/var/www# ls -la StoreInventory.php
-rwxrwxrw- 1 ethan ethan 4188 Aug 26 20:26 StoreInventory.php

rosenberg:/var# ls -ld www
drwxrwxrw- 37 ethan ethan 20480 Aug 26 20:26 www

I had set the S bit [probably a nasty mistake] and I thought I was
able
to remove the bit. [it doesn't show above]

How do I extricate myself from the hole into which I have planted
myself?

TIA

Ethan


This is in no way a php question, as the same result will happen no
matter what you ask apache to serve from that directory.

You have the directory permissions set to 776 not 777.
--
Cheers
David Robley

Steal this tagline and I'll tie-dye your cat!





776 won't matter in the case of a directory, as the last bit is for the
eXecute permissions, which aren't applicable to a directory. What


I beg to differ here. If the x bit isn't set on a directory, that will
prevent scanning of the directory; in this case apache will be prevented
from scanning the directory and will return a 403.


It's possible that this is an SELinux issue, which adds an extra layer
of permissions over files. To see what those permissions are, use the -Z
flag for ls. Also, check the SELinux logs (assuming that it's running
and it is causing a problem) to see if it brings up anything. It's
typically found on RedHat-based distros.

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



I checked with the -Z option

ethan@rosenberg:/var/www$ ls -lZ StoreInventory.php
-rwxrwsr-t 1 ethan ethan ? 4232 Aug 27 00:18 StoreInventory.php

Ethan

PS David-

I promise that I will not steal your tag line.  My short hair American
tabby cat [Gingy Feline Rosenberg]is too nice to have anything done to her.

This has really morphed into a Debian issue.  I have sent it to the 
Debian list.  I will keep you informed.


Ethan

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Robert Cummings

On 13-08-25 11:41 PM, Ethan Rosenberg wrote:

Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);

This does not -

if( !file_exists(/var/www/orders.txt));
{
 $out = system(touch /var/www/orders.txt, $ret);
 $out2 = system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
 exec(touch /var/www/orders.txt);
 exec(chmod 766 /var/www/orders.txt);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

Ethan


Hi Ethan,

Is there a reason you're using shell commands to achieve the following:

?php

$path = '/var/www/orders.txt';
if( !file_exists( $path ) )
{
if( !touch( $path ) )
{
echo 'Failed to touch file into existence: '.$path.\n;
}
else
{
if( !chmod( $path, 0766 ) )
{
echo 'Failed to update file permissions: '.$path.\n;
}
}
}

?

Also, why are you setting the executable bit on a text file? :)

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Tamara Temple

On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com 
wrote:

 Dear List -
 
 I'm lost on this one -
 
 This works -
 
 $out = system(ls -l ,$retvals);
 printf(%s, $out);
 
 This does -
 
 echo exec(ls -l);
 
 This does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
   $out = system(touch /var/www/orders.txt, $ret);
   $out2 = system(chmod 766 /var/www/orders.txt, $ret);
   echo 'file2br /';
   echo file_exists(/var/www/orders.txt);
 }
 
 and this does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
   exec(touch /var/www/orders.txt);
   exec(chmod 766 /var/www/orders.txt);
   echo 'file2br /';
   echo file_exists(/var/www/orders.txt);
 }
 
 Ethan
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

When you say does not work, can you show what is actually not working? I 
believe the exec and system functions are likely working just fine, but that 
the commands you've passed to them may not be.



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



Re: [PHP] exec and system do not work

2013-08-26 Thread ma...@behnke.biz


 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:



 On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 erosenb...@hygeiabiomedical.com wrote:

  Dear List -
 
  I'm lost on this one -
 
  This works -
 
  $out = system(ls -l ,$retvals);
  printf(%s, $out);
 
  This does -
 
  echo exec(ls -l);

Please show the output of the directory listing.
Please us ls -la

 
  This does not -
 
  if( !file_exists(/var/www/orders.txt));
  {
    $out = system(touch /var/www/orders.txt, $ret);

Maybe you don't have write permissions on the folder?

    $out2 = system(chmod 766 /var/www/orders.txt, $ret);
    echo 'file2br /';
    echo file_exists(/var/www/orders.txt);
  }
 
  and this does not -
 
  if( !file_exists(/var/www/orders.txt));
  {
    exec(touch /var/www/orders.txt);
    exec(chmod 766 /var/www/orders.txt);
    echo 'file2br /';
    echo file_exists(/var/www/orders.txt);
  }
 
  Ethan
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

 When you say does not work, can you show what is actually not working? I
 believe the exec and system functions are likely working just fine, but that
 the commands you've passed to them may not be.



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


--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not working? I
believe the exec and system functions are likely working just fine, but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

 Please show the output of the directory listing.
 Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


 When you say does not work, can you show what is actually not 
working? I
 believe the exec and system functions are likely working just fine, 
but that

 the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
 cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






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



Re: [PHP] exec and system do not work

2013-08-26 Thread Jim Giner

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  Please show the output of the directory listing.
  Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


  When you say does not work, can you show what is actually not
working? I
  believe the exec and system functions are likely working just fine,
but that
  the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDNT ACTUALLY RUN.

I've told you multiple times that you need to do these two things and 
you are back at it again.


The sample php above has plain simple syntax errors that would keep it 
from running, which error checking would tell you IF YOU RAN IT.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread ma...@behnke.biz


 Ethan Rosenberg erosenb...@hygeiabiomedical.com hat am 26. August 2013 um
 20:41 geschrieben:


   Please show the output of the directory listing.
   Please us ls -la

 echo exec('ls -la orders.txt');

 -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt

Please supply the complete output. Especially the rights for . and ..

 Maybe you don't have write permissions on the folder?

 If I perform the touch and chmod from the command line, everything works.

cli and ww are different users.

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



Re: [PHP] How to send post-variables in a Location header

2013-08-26 Thread ma...@behnke.biz


 Ajay Garg ajaygargn...@gmail.com hat am 26. August 2013 um 21:48
 geschrieben:


 Hi all.

 I have a scenario, wherein I need to do something like this ::

 ###
         $original_url = /autologin.php;
         $username = ajay;
         $password = garg;

         header('Location: ' . $original_url);
 ###

 As can be seen, I wish to redirect to the URL autologin.php.

 Additionally, I wish to pass two POST key-value pairs :: user=ajay and
 password=garg (I understand that passing GET key-value pairs is trivial).

 Is it  even possible?
 If yes, I will be grateful if someone could let me know how to redirect to
 a URL, passing the POST key-value pairs as necessary.

Iirc it is not possible to pass post body content via location redirect.
What you can do: Set auth headers

http://forums.phpfreaks.com/topic/84480-solved-how-to-send-authorization-basic-header/



 Looking forward to a reply :)


 --
 Regards,
 Ajay

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

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



Re: [PHP] How to send post-variables in a Location header

2013-08-26 Thread Matijn Woudt
On Mon, Aug 26, 2013 at 9:48 PM, Ajay Garg ajaygargn...@gmail.com wrote:

 Hi all.

 I have a scenario, wherein I need to do something like this ::

 ###
 $original_url = /autologin.php;
 $username = ajay;
 $password = garg;

 header('Location: ' . $original_url);
 ###

 As can be seen, I wish to redirect to the URL autologin.php.

 Additionally, I wish to pass two POST key-value pairs :: user=ajay and
 password=garg (I understand that passing GET key-value pairs is trivial).

 Is it  even possible?
 If yes, I will be grateful if someone could let me know how to redirect to
 a URL, passing the POST key-value pairs as necessary.


 Looking forward to a reply :)


Usually you would pass this around in sessions. If you must however use
post, you can only do so with using some javascript magic. Write a form
with hidden input and auto submit it.

- Matijn


Re: [PHP] exec and system do not work

2013-08-26 Thread Tamara Temple

On Aug 26, 2013, at 1:41 PM, Ethan Rosenberg erosenb...@hygeiabiomedical.com 
wrote:
 On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:
 
 
 
 On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 erosenb...@hygeiabiomedical.com wrote:
 
 Dear List -
 
 I'm lost on this one -
 
 This works -
 
 $out = system(ls -l ,$retvals);
 printf(%s, $out);
 
 This does -
 
 echo exec(ls -l);
 
 Please show the output of the directory listing.
 Please us ls -la
 
 
 This does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
$out = system(touch /var/www/orders.txt, $ret);
 
 Maybe you don't have write permissions on the folder?
 
$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
 }
 
 and this does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
 }
 
 Ethan
 
 
 
 When you say does not work, can you show what is actually not working? I
 believe the exec and system functions are likely working just fine, but that
 the commands you've passed to them may not be.
 
 
 
 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3
 
 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz
 
 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal
 
 http://www.behnke.biz
 
 
 Tamara -

You're replying to me about something someone else asked you.

 
  Please show the output of the directory listing.
  Please us ls -la
 
 echo exec('ls -la orders.txt');
 
 -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
 
 
 Maybe you don't have write permissions on the folder?
 
 If I perform the touch and chmod from the command line, everything works.
 
 
  When you say does not work, can you show what is actually not working? I
  believe the exec and system functions are likely working just fine, but 
  that
  the commands you've passed to them may not be.
 
 Here are my commands.
 
 if( !file_exists(/var/www/orders.txt));
 {
 echo system(touch /var/www/orders.txt, $ret);
 echo system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }
 
 If I now try a ls from the command line, the return is
 cannot access /var/www/orders.txt: No such file or directory
 
 The ls -la  works because the file was created from the command line.
 
 TIA
 
 Ethan
 
 
 
 
 
 
 -- 
 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] How to send post-variables in a Location header

2013-08-26 Thread Tamara Temple

On Aug 26, 2013, at 2:48 PM, Ajay Garg ajaygargn...@gmail.com wrote:
 Hi all.
 
 I have a scenario, wherein I need to do something like this ::
 
 ###
$original_url = /autologin.php;
$username = ajay;
$password = garg;
 
header('Location: ' . $original_url);
 ###
 
 As can be seen, I wish to redirect to the URL autologin.php.
 
 Additionally, I wish to pass two POST key-value pairs :: user=ajay and
 password=garg (I understand that passing GET key-value pairs is trivial).
 
 Is it  even possible?
 If yes, I will be grateful if someone could let me know how to redirect to
 a URL, passing the POST key-value pairs as necessary.
 
 
 Looking forward to a reply :)

Since this seems that it will not work, I'm wondering if you could take a step 
back for us and say what is it you're hoping to accomplish by this. Maybe 
there's a better way to get you what you need that is possible, and also will 
be good PHP. Describe your scenario in higher level terms, not how you'd 
implement it, but what the outcome you need is, and what the design goal is for 
the user.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg, PhD


On 08/26/2013 03:28 PM, Jim Giner wrote:

On 8/26/2013 2:41 PM, Ethan Rosenberg wrote:


On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
$out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not
working? I
believe the exec and system functions are likely working just fine,
but that
the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

  Please show the output of the directory listing.
  Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


  When you say does not work, can you show what is actually not
working? I
  believe the exec and system functions are likely working just fine,
but that
  the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
  cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan






Ethan - YOU'RE DOING IT AGAIN!!!

Either you are not using error checking AGAIN!!
OR
You are showing us re-typed in code that YOU DIDNT ACTUALLY RUN.

I've told you multiple times that you need to do these two things and
you are back at it again.

The sample php above has plain simple syntax errors that would keep it
from running, which error checking would tell you IF YOU RAN IT.



Jim -

Thank you.

I don't totally understand your reply ...

but I will try to answer

The code is taken from an operating program.  My error checking is set 
to maximum sensitivity.


If you would point out my syntax errors, I will fix them.

TIA

Ethan


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



Re: [PHP] exec and system do not work

2013-08-26 Thread David Robley
Ethan Rosenberg wrote:

 
 On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:


 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:



 On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 erosenb...@hygeiabiomedical.com wrote:

 Dear List -

 I'm lost on this one -

 This works -

 $out = system(ls -l ,$retvals);
 printf(%s, $out);

 This does -

 echo exec(ls -l);

 Please show the output of the directory listing.
 Please us ls -la


 This does not -

 if( !file_exists(/var/www/orders.txt));
 {
 $out = system(touch /var/www/orders.txt, $ret);

 Maybe you don't have write permissions on the folder?

 $out2 = system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }

 and this does not -

 if( !file_exists(/var/www/orders.txt));
 {
 exec(touch /var/www/orders.txt);
 exec(chmod 766 /var/www/orders.txt);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }

 Ethan



 When you say does not work, can you show what is actually not working?
 I believe the exec and system functions are likely working just fine,
 but that the commands you've passed to them may not be.



 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz

 
 Tamara -
 
   Please show the output of the directory listing.
   Please us ls -la
 
 echo exec('ls -la orders.txt');
 
 -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
 
 
 Maybe you don't have write permissions on the folder?
 
 If I perform the touch and chmod from the command line, everything works.
 
 
   When you say does not work, can you show what is actually not
 working? I
   believe the exec and system functions are likely working just fine,
 but that
   the commands you've passed to them may not be.
 
 Here are my commands.
 
 if( !file_exists(/var/www/orders.txt));
 {
 echo system(touch /var/www/orders.txt, $ret);
 echo system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }
 
 If I now try a ls from the command line, the return is
   cannot access /var/www/orders.txt: No such file or directory
 
 The ls -la  works because the file was created from the command line.
 
 TIA
 
 Ethan

Note that touch and chmod don't return any output, so echoing the result of 
a system call for those commands will give an empty string.

You should be checking the values of $ret for each execution of system to 
see whether the command was successful or not - the return status of the 
executed command will be written to this variable. I'd guess that touch is 
returning 13 - permission denied.

if( !file_exists(/var/www/orders.txt))
{
  system(touch /var/www/orders.txt, $ret1);
  echo 'touch returned '.$ret1.'br /';
  system(chmod 766 /var/www/orders.txt, $ret2);
  echo 'chmod returned ' .$ret2.'br /';
  echo 'file2br /';
echo file_exists(/var/www/orders.txt); }

Check the permissions for directory /var/www; you'll probably find it is 
writable by the user you log on as, but not by the user that apache/php runs 
as, which is often www - a user with limited privileges.

As other(s) have pointed out, there are php functions to do what you want 
without introducing the possible insecurities involved with system et al.

-- 
Cheers
David Robley

Don't try to pull the wool over my eyes, Tom said sheepishly.


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



Re: [PHP] exec and system do not work

2013-08-26 Thread Ethan Rosenberg, PhD



Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com

On 08/26/2013 07:33 PM, David Robley wrote:

Ethan Rosenberg wrote:



On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:




Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
geschrieben:



On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
erosenb...@hygeiabiomedical.com wrote:


Dear List -

I'm lost on this one -

This works -

$out = system(ls -l ,$retvals);
printf(%s, $out);

This does -

echo exec(ls -l);


Please show the output of the directory listing.
Please us ls -la



This does not -

if( !file_exists(/var/www/orders.txt));
{
 $out = system(touch /var/www/orders.txt, $ret);


Maybe you don't have write permissions on the folder?


 $out2 = system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

and this does not -

if( !file_exists(/var/www/orders.txt));
{
 exec(touch /var/www/orders.txt);
 exec(chmod 766 /var/www/orders.txt);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
}

Ethan




When you say does not work, can you show what is actually not working?
I believe the exec and system functions are likely working just fine,
but that the commands you've passed to them may not be.




--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz



Tamara -

   Please show the output of the directory listing.
   Please us ls -la

echo exec('ls -la orders.txt');

-rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


Maybe you don't have write permissions on the folder?

If I perform the touch and chmod from the command line, everything works.


   When you say does not work, can you show what is actually not
working? I
   believe the exec and system functions are likely working just fine,
but that
   the commands you've passed to them may not be.

Here are my commands.

if( !file_exists(/var/www/orders.txt));
{
echo system(touch /var/www/orders.txt, $ret);
echo system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.txt);
}

If I now try a ls from the command line, the return is
   cannot access /var/www/orders.txt: No such file or directory

The ls -la  works because the file was created from the command line.

TIA

Ethan


Note that touch and chmod don't return any output, so echoing the result of
a system call for those commands will give an empty string.

You should be checking the values of $ret for each execution of system to
see whether the command was successful or not - the return status of the
executed command will be written to this variable. I'd guess that touch is
returning 13 - permission denied.

if( !file_exists(/var/www/orders.txt))
{
   system(touch /var/www/orders.txt, $ret1);
   echo 'touch returned '.$ret1.'br /';
   system(chmod 766 /var/www/orders.txt, $ret2);
   echo 'chmod returned ' .$ret2.'br /';
   echo 'file2br /';
echo file_exists(/var/www/orders.txt); }

Check the permissions for directory /var/www; you'll probably find it is
writable by the user you log on as, but not by the user that apache/php runs
as, which is often www - a user with limited privileges.

As other(s) have pointed out, there are php functions to do what you want
without introducing the possible insecurities involved with system et al.



David -

touch returned 1
 /chmod returned 1

rosenberg:/var/www# ls orders.txt
ls: cannot access orders.txt: No such file or directory

rosenberg:/var# ls -ld www
drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www

TIA

Ethan

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



Re: [PHP] exec and system do not work

2013-08-26 Thread Jasper Kips
Ethan,
A return code of not 0 means an error occured.
Probably /var/www is not writable. Test that one by doing this:
$a = is_writable(/var/www);
var_dump($a);
If that says anything else than (boolean) TRUE, you can't write in the 
directory. 


Sincerely,

Jasper Kips


Op 27 aug. 2013, om 02:32 heeft Ethan Rosenberg, PhD 
erosenb...@hygeiabiomedical.com het volgende geschreven:

 
 
 Ethan Rosenberg, PhD
 /Pres/CEO/
 *Hygeia Biomedical Research, Inc*
 2 Cameo Ridge Road
 Monsey, NY 10952
 T: 845 352-3908
 F: 845 352-7566
 erosenb...@hygeiabiomedical.com
 
 On 08/26/2013 07:33 PM, David Robley wrote:
 Ethan Rosenberg wrote:
 
 
 On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:
 
 
 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um 08:33
 geschrieben:
 
 
 
 On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 erosenb...@hygeiabiomedical.com wrote:
 
 Dear List -
 
 I'm lost on this one -
 
 This works -
 
 $out = system(ls -l ,$retvals);
 printf(%s, $out);
 
 This does -
 
 echo exec(ls -l);
 
 Please show the output of the directory listing.
 Please us ls -la
 
 
 This does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
 $out = system(touch /var/www/orders.txt, $ret);
 
 Maybe you don't have write permissions on the folder?
 
 $out2 = system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }
 
 and this does not -
 
 if( !file_exists(/var/www/orders.txt));
 {
 exec(touch /var/www/orders.txt);
 exec(chmod 766 /var/www/orders.txt);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }
 
 Ethan
 
 
 
 When you say does not work, can you show what is actually not working?
 I believe the exec and system functions are likely working just fine,
 but that the commands you've passed to them may not be.
 
 
 
 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3
 
 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz
 
 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal
 
 http://www.behnke.biz
 
 
 Tamara -
 
   Please show the output of the directory listing.
   Please us ls -la
 
 echo exec('ls -la orders.txt');
 
 -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt
 
 
 Maybe you don't have write permissions on the folder?
 
 If I perform the touch and chmod from the command line, everything works.
 
 
   When you say does not work, can you show what is actually not
 working? I
   believe the exec and system functions are likely working just fine,
 but that
   the commands you've passed to them may not be.
 
 Here are my commands.
 
 if( !file_exists(/var/www/orders.txt));
 {
 echo system(touch /var/www/orders.txt, $ret);
 echo system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }
 
 If I now try a ls from the command line, the return is
   cannot access /var/www/orders.txt: No such file or directory
 
 The ls -la  works because the file was created from the command line.
 
 TIA
 
 Ethan
 
 Note that touch and chmod don't return any output, so echoing the result of
 a system call for those commands will give an empty string.
 
 You should be checking the values of $ret for each execution of system to
 see whether the command was successful or not - the return status of the
 executed command will be written to this variable. I'd guess that touch is
 returning 13 - permission denied.
 
 if( !file_exists(/var/www/orders.txt))
 {
   system(touch /var/www/orders.txt, $ret1);
   echo 'touch returned '.$ret1.'br /';
   system(chmod 766 /var/www/orders.txt, $ret2);
   echo 'chmod returned ' .$ret2.'br /';
   echo 'file2br /';
 echo file_exists(/var/www/orders.txt); }
 
 Check the permissions for directory /var/www; you'll probably find it is
 writable by the user you log on as, but not by the user that apache/php runs
 as, which is often www - a user with limited privileges.
 
 As other(s) have pointed out, there are php functions to do what you want
 without introducing the possible insecurities involved with system et al.
 
 
 David -
 
 touch returned 1
 /chmod returned 1
 
 rosenberg:/var/www# ls orders.txt
 ls: cannot access orders.txt: No such file or directory
 
 rosenberg:/var# ls -ld www
 drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www
 
 TIA
 
 Ethan
 
 -- 
 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] exec and system do not work

2013-08-26 Thread David Robley
Ethan Rosenberg, PhD wrote:

 
 
 Ethan Rosenberg, PhD
 /Pres/CEO/
 *Hygeia Biomedical Research, Inc*
 2 Cameo Ridge Road
 Monsey, NY 10952
 T: 845 352-3908
 F: 845 352-7566
 erosenb...@hygeiabiomedical.com
 
 On 08/26/2013 07:33 PM, David Robley wrote:
 Ethan Rosenberg wrote:


 On 08/26/2013 11:36 AM, ma...@behnke.biz wrote:


 Tamara Temple tamouse.li...@gmail.com hat am 26. August 2013 um
 08:33 geschrieben:



 On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg
 erosenb...@hygeiabiomedical.com wrote:

 Dear List -

 I'm lost on this one -

 This works -

 $out = system(ls -l ,$retvals);
 printf(%s, $out);

 This does -

 echo exec(ls -l);

 Please show the output of the directory listing.
 Please us ls -la


 This does not -

 if( !file_exists(/var/www/orders.txt));
 {
  $out = system(touch /var/www/orders.txt, $ret);

 Maybe you don't have write permissions on the folder?

  $out2 = system(chmod 766 /var/www/orders.txt, $ret);
  echo 'file2br /';
  echo file_exists(/var/www/orders.txt);
 }

 and this does not -

 if( !file_exists(/var/www/orders.txt));
 {
  exec(touch /var/www/orders.txt);
  exec(chmod 766 /var/www/orders.txt);
  echo 'file2br /';
  echo file_exists(/var/www/orders.txt);
 }

 Ethan



 When you say does not work, can you show what is actually not
 working? I believe the exec and system functions are likely working
 just fine, but that the commands you've passed to them may not be.



 --
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3

 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz

 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal

 http://www.behnke.biz


 Tamara -

Please show the output of the directory listing.
Please us ls -la

 echo exec('ls -la orders.txt');

 -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt


 Maybe you don't have write permissions on the folder?

 If I perform the touch and chmod from the command line, everything
 works.


When you say does not work, can you show what is actually not
 working? I
believe the exec and system functions are likely working just fine,
 but that
the commands you've passed to them may not be.

 Here are my commands.

 if( !file_exists(/var/www/orders.txt));
 {
 echo system(touch /var/www/orders.txt, $ret);
 echo system(chmod 766 /var/www/orders.txt, $ret);
 echo 'file2br /';
 echo file_exists(/var/www/orders.txt);
 }

 If I now try a ls from the command line, the return is
cannot access /var/www/orders.txt: No such file or directory

 The ls -la  works because the file was created from the command line.

 TIA

 Ethan

 Note that touch and chmod don't return any output, so echoing the result
 of a system call for those commands will give an empty string.

 You should be checking the values of $ret for each execution of system to
 see whether the command was successful or not - the return status of the
 executed command will be written to this variable. I'd guess that touch
 is returning 13 - permission denied.

 if( !file_exists(/var/www/orders.txt))
 {
system(touch /var/www/orders.txt, $ret1);
echo 'touch returned '.$ret1.'br /';
system(chmod 766 /var/www/orders.txt, $ret2);
echo 'chmod returned ' .$ret2.'br /';
echo 'file2br /';
 echo file_exists(/var/www/orders.txt); }

 Check the permissions for directory /var/www; you'll probably find it is
 writable by the user you log on as, but not by the user that apache/php
 runs as, which is often www - a user with limited privileges.

 As other(s) have pointed out, there are php functions to do what you want
 without introducing the possible insecurities involved with system et al.

 
 David -
 
 touch returned 1
   /chmod returned 1
 

Non-zero return value indicates an error; touch failed and as a result there 
is no file to chmod, hence chmod also failed.

 rosenberg:/var/www# ls orders.txt
 ls: cannot access orders.txt: No such file or directory
 
 rosenberg:/var# ls -ld www
 drwxr-xr-x 37 ethan ethan 20480 Aug 26 20:15 www

/var/www is only writeable by the user ethan
-- 
Cheers
David Robley

INTERLACE: To tie two boots together.


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



Re: [PHP] exec and system do not work

2013-08-25 Thread Sorin Badea
*/var/www* is usually under *www* user. It may be a permissions problem.


On Mon, Aug 26, 2013 at 6:41 AM, Ethan Rosenberg 
erosenb...@hygeiabiomedical.com wrote:

 Dear List -

 I'm lost on this one -

 This works -

 $out = system(ls -l ,$retvals);
 printf(%s, $out);

 This does -

 echo exec(ls -l);

 This does not -

 if( !file_exists(/var/www/orders.**txt));
 {
$out = system(touch /var/www/orders.txt, $ret);
$out2 = system(chmod 766 /var/www/orders.txt, $ret);
echo 'file2br /';
echo file_exists(/var/www/orders.**txt);
 }

 and this does not -

 if( !file_exists(/var/www/orders.**txt));
 {
exec(touch /var/www/orders.txt);
exec(chmod 766 /var/www/orders.txt);
echo 'file2br /';
echo file_exists(/var/www/orders.**txt);
 }

 Ethan

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




-- 
Sorin Badea - Software Engineer


Re: [PHP] Alternate list for eclipse ide support?

2013-08-24 Thread Sebastian Krebs
2013/8/24 Lester Caine les...@lsces.co.uk

 With composer being pushed as the 'in way to go' and not being able to see
 how to get some code relating to bootstrap and smarty development because
 the links only show composer I've downloaded a plug-in for eclipse that is
 supposed to handle that. But it's not working as I expect, and while
 heading over to the plug-ins developers is the obvious step, what I'd
 actually prefer is a more general PHP/Eclipse list to discuss general IDE
 problems rather than even PDT biased discussions.

 Is there a suitable list? And if not is there any interest in setting one
 up? ... at the risk of proliferating even more lists ...


Hi,

I for myself switched over to PhpStorm from Eclipse/PDT and I fear meany
hear use either PhpStorm, or Netbeans in the meantime. I'm not saying, that
nobody is using Eclipse/PDT anymore, but I fear you wont find much interest
here.

Regards,
Sebastian



 --
 Lester Caine - G8HFL
 -
 Contact - 
 http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact
 L.S.Caine Electronic Services - http://lsces.co.uk
 EnquirySolve - http://enquirysolve.com/
 Model Engineers Digital Workshop - http://medw.co.uk
 Rainbow Digital Media - 
 http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk

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




-- 
github.com/KingCrunch


Re: [PHP] Alternate list for eclipse ide support?

2013-08-24 Thread Lester Caine

Sebastian Krebs wrote:

With composer being pushed as the 'in way to go' and not being able to see
how to get some code relating to bootstrap and smarty development because
the links only show composer I've downloaded a plug-in for eclipse that is
supposed to handle that. But it's not working as I expect, and while
heading over to the plug-ins developers is the obvious step, what I'd
actually prefer is a more general PHP/Eclipse list to discuss general IDE
problems rather than even PDT biased discussions.

Is there a suitable list? And if not is there any interest in setting one
up? ... at the risk of proliferating even more lists ...


I for myself switched over to PhpStorm from Eclipse/PDT and I fear meany
hear use either PhpStorm, or Netbeans in the meantime. I'm not saying, that
nobody is using Eclipse/PDT anymore, but I fear you wont find much interest
here.


I'm still on PHPEclipse for PHP. PDT just does not work for me, and neither did 
Netbeans for some of the other languages I have to live with, which is why 
PHPStorm is no use either. I need python in addition to C/C++ with document 
handling, and firebird which don't get any support from either so Eclipse is 
really my only option.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] Alternate list for eclipse ide support?

2013-08-24 Thread Sebastian Krebs
2013/8/24 Lester Caine les...@lsces.co.uk

 Sebastian Krebs wrote:

 With composer being pushed as the 'in way to go' and not being able to see
 how to get some code relating to bootstrap and smarty development
 because
 the links only show composer I've downloaded a plug-in for eclipse that
 is
 supposed to handle that. But it's not working as I expect, and while
 heading over to the plug-ins developers is the obvious step, what I'd
 actually prefer is a more general PHP/Eclipse list to discuss general
 IDE
 problems rather than even PDT biased discussions.
 
 Is there a suitable list? And if not is there any interest in setting
 one
 up? ... at the risk of proliferating even more lists ...


 I for myself switched over to PhpStorm from Eclipse/PDT and I fear meany
 hear use either PhpStorm, or Netbeans in the meantime. I'm not saying,
 that
 nobody is using Eclipse/PDT anymore, but I fear you wont find much
 interest
 here.


 I'm still on PHPEclipse for PHP. PDT just does not work for me, and
 neither did Netbeans for some of the other languages I have to live with,
 which is why PHPStorm is no use either.


PHPEclipse is still in development? O_o The last time I noticed it, it
looked abandoned. However, if it works for you, there is nothing wrong with
it.

(Just realized: There are really back in business. Interesting ^^)


 I need python in addition to C/C++ with document handling, and firebird
 which don't get any support from either so Eclipse is really my only option.


Well, Firebird is quite specific (dont know if its supported bei the
IntelliJ-platform), but for Python and C Jetbrains has other IDEs (PyCharm,
AppCode) :D Just saying: There _are_ alternatives :)


However, my last mail wasn't about telling you, that your IDE is bad. But I
have the feeling, that this audience may be simply not interested.

Regards,
Sebastian




 --
 Lester Caine - G8HFL
 -
 Contact - 
 http://lsces.co.uk/wiki/?page=**contacthttp://lsces.co.uk/wiki/?page=contact
 L.S.Caine Electronic Services - http://lsces.co.uk
 EnquirySolve - http://enquirysolve.com/
 Model Engineers Digital Workshop - http://medw.co.uk
 Rainbow Digital Media - 
 http://rainbowdigitalmedia.co.**ukhttp://rainbowdigitalmedia.co.uk

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




-- 
github.com/KingCrunch


Re: [PHP] Alternate list for eclipse ide support?

2013-08-24 Thread Lester Caine

Sebastian Krebs wrote:

However, my last mail wasn't about telling you, that your IDE is bad. But I have
the feeling, that this audience may be simply not interested.


I'm only using Java in order to make tweaks to PHPEclipse and and other support 
packages. ( and the same with python ).  We could do with more support in these 
areas, and comments like yours don't help, but there IS enough interest from 
users dissatisfied with the alternatives ...
The problem is that there are perhaps too many options and combining the 
activities of a few would create a more popular common base?


The vast number of different 'frameworks' add further to the dilution of effort. 
It's a pity that there is not a single universally accepted development base in 
addition to a single IDE into which support could be pooled. It's not going to 
happen as PHP now has too many diverse ways of doing the same thing? :(


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] files and folders windows permission

2013-08-23 Thread Matijn Woudt
On Fri, Aug 23, 2013 at 4:03 PM, Emiliano Boragina 
emiliano.borag...@gmail.com wrote:

 Hi everyone, sorry my ugly english. I did an upload file form. Works
 very good. Upload the files in the right folder, with the right name.
 I use chmod 0644, and for try I use 0777. But always the files are
 copyed blocked. I cant see them with windows preview for example. I
 read in forums that is Windows fault. How can I fix this? Thanks a
 lot.

 Code?


Re: [PHP] files and folders windows permission

2013-08-23 Thread Maciek Sokolewicz

On 23-8-2013 16:37, Matijn Woudt wrote:

On Fri, Aug 23, 2013 at 4:03 PM, Emiliano Boragina 
emiliano.borag...@gmail.com wrote:


Hi everyone, sorry my ugly english. I did an upload file form. Works
very good. Upload the files in the right folder, with the right name.
I use chmod 0644, and for try I use 0777. But always the files are
copyed blocked. I cant see them with windows preview for example. I
read in forums that is Windows fault. How can I fix this? Thanks a
lot.

Code?




On a sidenote, how the hell did you manage to chmod files on _windows_ ???

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



Re: [PHP] Re: PHP vs JAVA

2013-08-22 Thread Sebastian Krebs
2013/8/22 David Harkness davi...@highgearmedia.com

 On Wed, Aug 21, 2013 at 7:56 PM, Curtis Maurand cur...@maurand.comwrote:

 Sebastian Krebs wrote:

  Actually the problem is, that the dot . is already in use. With

   $foo.bar() you cannot tell, if you want to call the method bar() on
 the
  object $foo, or if you want to concatenate the value of $foo to the
  result of the function bar(). There is no other way around this than a
  different operator for method calls.

 I didn't think
 of that.  It seems to me there could be an easier operator than -
 which sometimes will make me stop and look at what keys I'm trying to
 hit.  Just a thought.  I forgot about the concatenation operator
 which is + in Java/C#


 The PHP language developers were pretty stuck. Because of automatic
 string-to-numeric-conversion, they couldn't use + for string concatenation.
 Sadly, they chose . rather than .. which I believe one or two other
 languages use. If they had, . would have been available once objects
 rolled around in PHP 4/5. I suspect they chose - since that's used in C
 and C++ to dereference a pointer.


Actually I think .. is quite error-prone, because it is hard to
distinguish from . or _ on the _first_ glance, which makes the get
quickly through the code. [1]
So . is maybe not the best choice, but also remember when it was
introduced: That was decades ago. That time it was (probably ;)) the best
choice and nowadays I don't think it is too bad at all, beside that _other_
languages use it for other purposes now ;)


[1] Yes, I know, that _ is not an operator, but mixed with strings and
variables names it is there ;)




  Ever tried the jetbrains products? :D (No, they don't pay me)

 I have not, but it looks interesting.
 I'll have to try it.


 Those are very good products which have had a strong following for a
 decade. The free IDE NetBeans also has quite good support for both Java and
 PHP, and the latest beta version provides a web project that provides
 front- and back-end debugging of PHP + JavaScript. You can be stepping
 through JS code and hit an AJAX call and then seamlessly step through the
 PHP code that handles it.

 I use NetBeans for PHP/HTML/JS (though I am evaluating JetBrains' PHPStorm
 now) and Eclipse for Java. You can't beat Eclipse's refactoring support in
 a free tool, though I think NetBeans is close to catching up. I would bet
 IntelliJ IDEA for Java by JetBrains is on par at least.


Eclipse' code-completion and debugger never worked for me well (and most of
the time: at all). It became slower and less responsive with every release.
That was the reason I decided to leave it and I don't regret it :)



 Peace,
 David




-- 
github.com/KingCrunch


Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Curtis Maurand



Is the subdomain also in a subfolder of the main domain?

Jim Giner wrote:
 I have a main domain (of course) and a sub
domain.  I'm really trying to
 steer my personal stuff away from
the main one and have focused all of
 my php development to the
sub-domain.
 
 Lately I noticed that google catalogs my
sub-domain site stuff under the
 main domain name and the links
that come up lead to that domain name
 with the path that takes
the user to the sub-domain's home folder and
 beyond.


 Is there something that php (apache??) can do to control either
google's
 robots or the user's view (url) so that it appears as a
page of my
 sub-domain?  I'm really new at this stuff and know
nothing.  I'm lucky
 that google is even finding my site!
 
 IN advance - I apologize for this off-topic question,
but this place is
 a source of much knowledge, so I just threw in
a quick interlude here to
 pick someone's brain.  :)


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



Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Jim Giner

On 8/22/2013 8:05 AM, Curtis Maurand wrote:




Is the subdomain also in a subfolder of the main domain?

Jim Giner wrote:

I have a main domain (of course) and a sub

domain.  I'm really trying to

steer my personal stuff away from

the main one and have focused all of

my php development to the

sub-domain.


Lately I noticed that google catalogs my

sub-domain site stuff under the

main domain name and the links

that come up lead to that domain name

with the path that takes

the user to the sub-domain's home folder and

beyond.




Is there something that php (apache??) can do to control either

google's

robots or the user's view (url) so that it appears as a

page of my

sub-domain?  I'm really new at this stuff and know

nothing.  I'm lucky

that google is even finding my site!

IN advance - I apologize for this off-topic question,

but this place is

a source of much knowledge, so I just threw in

a quick interlude here to

pick someone's brain.  :)




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




Yes - the sub is an add-on domain to my primary domain.  Hence the 
overlap and problem.


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



Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Willie
The only way that I know of to take care of that is to put a file in your
main directory called robots.txt. In that file you will put:


User-agent: *
Disallow: /FolderName



On Thu, Aug 22, 2013 at 6:19 AM, Jim Giner jim.gi...@albanyhandball.comwrote:

 On 8/22/2013 8:05 AM, Curtis Maurand wrote:




 Is the subdomain also in a subfolder of the main domain?

 Jim Giner wrote:

 I have a main domain (of course) and a sub

 domain.  I'm really trying to

 steer my personal stuff away from

 the main one and have focused all of

 my php development to the

 sub-domain.


 Lately I noticed that google catalogs my

 sub-domain site stuff under the

 main domain name and the links

 that come up lead to that domain name

 with the path that takes

 the user to the sub-domain's home folder and

 beyond.


  Is there something that php (apache??) can do to control either

 google's

 robots or the user's view (url) so that it appears as a

 page of my

 sub-domain?  I'm really new at this stuff and know

 nothing.  I'm lucky

 that google is even finding my site!

 IN advance - I apologize for this off-topic question,

 but this place is

 a source of much knowledge, so I just threw in

 a quick interlude here to

 pick someone's brain.  :)


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



  Yes - the sub is an add-on domain to my primary domain.  Hence the
 overlap and problem.


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




-- 

Willie Matthews
matthews.wil...@gmail.com


Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Jim Giner

On 8/22/2013 9:43 AM, Willie wrote:

The only way that I know of to take care of that is to put a file in your
main directory called robots.txt. In that file you will put:


User-agent: *
Disallow: /FolderName



On Thu, Aug 22, 2013 at 6:19 AM, Jim Giner jim.gi...@albanyhandball.comwrote:


On 8/22/2013 8:05 AM, Curtis Maurand wrote:





Is the subdomain also in a subfolder of the main domain?

Jim Giner wrote:


I have a main domain (of course) and a sub


domain.  I'm really trying to


steer my personal stuff away from


the main one and have focused all of


my php development to the


sub-domain.



Lately I noticed that google catalogs my


sub-domain site stuff under the


main domain name and the links


that come up lead to that domain name


with the path that takes


the user to the sub-domain's home folder and


beyond.



  Is there something that php (apache??) can do to control either



google's


robots or the user's view (url) so that it appears as a


page of my


sub-domain?  I'm really new at this stuff and know


nothing.  I'm lucky


that google is even finding my site!

IN advance - I apologize for this off-topic question,


but this place is


a source of much knowledge, so I just threw in


a quick interlude here to


pick someone's brain.  :)



  --

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




  Yes - the sub is an add-on domain to my primary domain.  Hence the

overlap and problem.


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






I'll try it.

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



Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Dan McCullough
So its indexing http://www.domain.com/subdomain/page.php and you would
rather it index http://subdomain.domain.com/page.php.  If that is the case
then what Willie said holds true

User-agent: *
Disallow: /subdomain

Place a robots.txt in the domain.com public root directory.

To Googles indexer http://subdomain.domain.com/page.php and
http://www.domain.com/subdomain/page.php are totally different and
therefore blocking /subdomain will not affect subdomain.domain.com.

Sign up for Google Webmaster and add two sites subdomain.domain and
www.domain  that way you can delete improperly indexed pages.
Do some test scans and see if there are links on your www.domain that are
linked to www.domain.com/subdomain rather then subdomain.domain.com


On Thu, Aug 22, 2013 at 9:43 AM, Willie matthews.wil...@gmail.com wrote:

 The only way that I know of to take care of that is to put a file in your
 main directory called robots.txt. In that file you will put:


 User-agent: *
 Disallow: /FolderName



 On Thu, Aug 22, 2013 at 6:19 AM, Jim Giner jim.gi...@albanyhandball.com
 wrote:

  On 8/22/2013 8:05 AM, Curtis Maurand wrote:
 
 
 
 
  Is the subdomain also in a subfolder of the main domain?
 
  Jim Giner wrote:
 
  I have a main domain (of course) and a sub
 
  domain.  I'm really trying to
 
  steer my personal stuff away from
 
  the main one and have focused all of
 
  my php development to the
 
  sub-domain.
 
 
  Lately I noticed that google catalogs my
 
  sub-domain site stuff under the
 
  main domain name and the links
 
  that come up lead to that domain name
 
  with the path that takes
 
  the user to the sub-domain's home folder and
 
  beyond.
 
 
   Is there something that php (apache??) can do to control either
 
  google's
 
  robots or the user's view (url) so that it appears as a
 
  page of my
 
  sub-domain?  I'm really new at this stuff and know
 
  nothing.  I'm lucky
 
  that google is even finding my site!
 
  IN advance - I apologize for this off-topic question,
 
  but this place is
 
  a source of much knowledge, so I just threw in
 
  a quick interlude here to
 
  pick someone's brain.  :)
 
 
   --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
   Yes - the sub is an add-on domain to my primary domain.  Hence the
  overlap and problem.
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --

 Willie Matthews
 matthews.wil...@gmail.com




-- 
Thank you,

Dan

Cell:  484-459-2856

https://www.facebook.com/dpmccullough
http://www.linkedin.com/in/danmccullough


Re: [PHP] Off the wall - sub-domain question

2013-08-22 Thread Lester Caine

Jim Giner wrote:

Yes - the sub is an add-on domain to my primary domain.  Hence the overlap and
problem.
I don't think there is any way to get google to separate filing information on 
different subdomains from the main domain, but you can stop them filing content 
altogether by identifying folders you do not want them to use. I have fun with 
them indexing the page histories if I forget to block that particular functions 
.php file.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] Re: PHP vs JAVA

2013-08-22 Thread David Harkness
On Thu, Aug 22, 2013 at 12:29 AM, Sebastian Krebs krebs@gmail.comwrote:

 Actually I think .. is quite error-prone, because it is hard to
 distinguish from . or _ on the _first_ glance, which makes the get
 quickly through the code. [1]


I surround all operators except member access (. and -) with spaces,
so that wouldn't be a problem for me. I thought there was an older language
that used .., but all I can find now is Lua which was developed in the
early nineties.

So . is maybe not the best choice, but also remember when it was
 introduced: That was decades ago. That time it was (probably ;)) the best
 choice and nowadays I don't think it is too bad at all, beside that _other_
 languages use it for other purposes now ;)


C introduced . as the field access operator for structs in the early
seventies, C++ kept it for object access, and Java adopted it in the early
nineties. C's use of pointers required a way to access members through a
pointer, and I suppose KR thought - looked like following a pointer (I
agree).

Since PHP was modeled on Perl and wouldn't implement objects or structs for
another decade, it adopted . for string concatenation. It works fine, and
I don't have too much trouble bouncing back-and-forth. I honestly would
have preferred . to be overloaded when the left hand side was an object.
In the rare cases that you want to convert an object to a string to be
concatenated with the RHS, you can always cast it to string, use strval(),
or call __toString() manually. But I'm not staging any protests over the
use of -. :)


 Eclipse' code-completion and debugger never worked for me well (and most
 of the time: at all). It became slower and less responsive with every
 release. That was the reason I decided to leave it and I don't regret it :)


I agree about the slowness, and until this latest release I've always left
autocompletion manual (ctrl + space). They did something with Kepler to
speed it up drastically, so much so I have it turned on with every
keypress. However, it's a little too aggressive in providing choices.
Typing null which is a Java keyword as in PHP, it will insert
nullValue() which is a method from Hamcrest. :( After a couple weeks of
this, I think I'll be switching it back to manual activation. I can type
quickly enough that I only need it when I'm not sure of a method name.

NetBeans, while not as good with refactoring and plugin support, is still
zippier than Eclipse. And my short time with the JetBrains products found
them to be fast as well. Eclipse's PHP support via PDT is not nearly as
good as NetBeans, and no doubt PHPStorm beats them both.

Peace,
David


[PHP] Re: PHP vs JAVA

2013-08-21 Thread Tim Streater
On 20 Aug 2013 at 23:59, PHP List phpl...@arashidigital.com wrote: 

 While I don't have any references to back it up - my guess would be that
 Java may be seen as more versatile in general programming terms.  A
 staggering number of enterprise level web applications are built with
 Java, add to that the possibility of writing Android apps with the same
 knowledge.

To me the salient point is, does java has as extensive a library or set of 
interfaces to other packages (such as SQLite, mysql, etc)?

 I would say that, in general, the other teacher is incorrect speaking
 strictly in terms of web development.  PHP has already won that crown
 many times over.  That said, when I was in University, it was difficult
 to find a programming class that taught anything but Java - and that was
 10yrs ago now.  I chalked it up to the education bubble not being able
 to see what the rest of the world is actually doing.

Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking down 
its nose at PHP. There being lots of courses proves nothing in and of itself. 
20 years ago, there were lots of PC mags you could buy, which caused some folks 
to say look how much better the PC is supported than other platforms. Truth 
was, at the time, such support was needed given the mess of 640k limits, DOS, 
IRQs and the like, most of which issues have ceased to be relevant.

Anyway, why should one need a course to learn PHP, assuming you already know 
other languages. It's simple enough.

--
Cheers  --  Tim

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

Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread georg chambert

Hi,

my I shake the subject a little; Ive been doing some PHP and found it ok 
to work with

not so much fuss, but that was PHP4, what about PHP5 ?
Dont really checked the difference but made a short-scan and found that it 
had be

screwed around with ?

Any think, should I change to 5 ?

BR georg

- Original Message - 
From: Tim Streater t...@clothears.org.uk

To: PHP List phpl...@arashidigital.com; php-general@lists.php.net
Sent: Wednesday, August 21, 2013 1:59 PM
Subject: [PHP] Re: PHP vs JAVA


On 20 Aug 2013 at 23:59, PHP List phpl...@arashidigital.com wrote:


While I don't have any references to back it up - my guess would be that
Java may be seen as more versatile in general programming terms.  A
staggering number of enterprise level web applications are built with
Java, add to that the possibility of writing Android apps with the same
knowledge.


To me the salient point is, does java has as extensive a library or set of 
interfaces to other packages (such as SQLite, mysql, etc)?



I would say that, in general, the other teacher is incorrect speaking
strictly in terms of web development.  PHP has already won that crown
many times over.  That said, when I was in University, it was difficult
to find a programming class that taught anything but Java - and that was
10yrs ago now.  I chalked it up to the education bubble not being able
to see what the rest of the world is actually doing.


Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking 
down its nose at PHP. There being lots of courses proves nothing in and of 
itself. 20 years ago, there were lots of PC mags you could buy, which caused 
some folks to say look how much better the PC is supported than other 
platforms. Truth was, at the time, such support was needed given the mess 
of 640k limits, DOS, IRQs and the like, most of which issues have ceased to 
be relevant.


Anyway, why should one need a course to learn PHP, assuming you already know 
other languages. It's simple enough.


--
Cheers  --  Tim








--
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] Re: PHP vs JAVA

2013-08-21 Thread Sebastian Krebs
2013/8/21 georg chambert georg.chamb...@telia.com

 Hi,

 my I shake the subject a little; Ive been doing some PHP and found it ok
 to work with
 not so much fuss, but that was PHP4, what about PHP5 ?
 Dont really checked the difference but made a short-scan and found that it
 had be
 screwed around with ?

 Any think, should I change to 5 ?


ehm ... serious?
http://php.net/eol.php



 BR georg

 - Original Message - From: Tim Streater t...@clothears.org.uk
 To: PHP List phpl...@arashidigital.com; php-general@lists.php.net
 Sent: Wednesday, August 21, 2013 1:59 PM
 Subject: [PHP] Re: PHP vs JAVA



 On 20 Aug 2013 at 23:59, PHP List phpl...@arashidigital.com wrote:

  While I don't have any references to back it up - my guess would be that
 Java may be seen as more versatile in general programming terms.  A
 staggering number of enterprise level web applications are built with
 Java, add to that the possibility of writing Android apps with the same
 knowledge.


 To me the salient point is, does java has as extensive a library or set of
 interfaces to other packages (such as SQLite, mysql, etc)?

  I would say that, in general, the other teacher is incorrect speaking
 strictly in terms of web development.  PHP has already won that crown
 many times over.  That said, when I was in University, it was difficult
 to find a programming class that taught anything but Java - and that was
 10yrs ago now.  I chalked it up to the education bubble not being able
 to see what the rest of the world is actually doing.


 Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply looking
 down its nose at PHP. There being lots of courses proves nothing in and of
 itself. 20 years ago, there were lots of PC mags you could buy, which
 caused some folks to say look how much better the PC is supported than
 other platforms. Truth was, at the time, such support was needed given the
 mess of 640k limits, DOS, IRQs and the like, most of which issues have
 ceased to be relevant.

 Anyway, why should one need a course to learn PHP, assuming you already
 know other languages. It's simple enough.

 --
 Cheers  --  Tim




 --**--**
 



  --
 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




-- 
github.com/KingCrunch


Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread Stuart Dallas
On 21 Aug 2013, at 15:01, georg chambert georg.chamb...@telia.com wrote:

 my I shake the subject a little; Ive been doing some PHP and found it ok to 
 work with
 not so much fuss, but that was PHP4, what about PHP5 ?
 Dont really checked the difference but made a short-scan and found that it 
 had be
 screwed around with ?
 
 Any think, should I change to 5 ?

Yes, even if it's only because PHP4 hasn't been supported in any way, including 
security fixes, since August 7th, 2008! This fact alone makes it pretty 
dangerous to be using it on a public site, and that's without getting into all 
of the improvements that PHP5 has introduced over the past five years!

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread Curtis Maurand



Sorry in advance for the top post.

Use the right tool for
the Job.  I've use Java, C# and PHP.

1.  I hate the
Perl-like object calls in PHP.  I'd rather use . notation
in C# and Java.  It saves a lot of wear and tear on my left pinky
finger.
2.  Java and C# are both typed languages.  Say what
you want, but I have working with a string like 02 and have
PHP convert that to an integer.  sometimes I want that zero in
front.  If I want that to be an integer in Java it's int
myInteger = Integer.parseInt(02);

3. 
Java development environments (Eclipses, NetBeans, IBM RAD) are pretty
horrible.  Visual Studio is hands down a better envrionment, even the
older versions of it. I've hooked Visual Studio into SVN in the past and
it works well.

4 PHP development environments are many and
varied and all of them suck at web debugging.  I've used PHPEdit,
Zend, Bluefish, Eclipse and a couple others.  Bluefish works better
on Linux than it does on Windows.

Use the tool for the job at
hand.  

Just my $0.02 worth.

cheers,
Curtis

Tim Streater wrote:
 On 20 Aug 2013 at 23:59,
PHP List phpl...@arashidigital.com wrote:
 

While I don't have any references to back it up - my guess would be
 that
 Java may be seen as more versatile in
general programming terms.  A
 staggering number of
enterprise level web applications are built with
 Java, add
to that the possibility of writing Android apps with the same
 knowledge.
 
 To me the salient point is,
does java has as extensive a library or set of
 interfaces to
other packages (such as SQLite, mysql, etc)?
 
 I
would say that, in general, the other teacher is incorrect speaking
 strictly in terms of web development.  PHP has already won that
crown
 many times over.  That said, when I was in University,
it was difficult
 to find a programming class that taught
anything but Java - and that
 was
 10yrs ago
now.  I chalked it up to the education bubble not being able

to see what the rest of the world is actually doing.
 

Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply
looking
 down its nose at PHP. There being lots of courses proves
nothing in and of
 itself. 20 years ago, there were lots of PC
mags you could buy, which
 caused some folks to say look
how much better the PC is supported than
 other platforms.
Truth was, at the time, such support was needed given
 the mess
of 640k limits, DOS, IRQs and the like, most of which issues have
 ceased to be relevant.
 
 Anyway, why should one
need a course to learn PHP, assuming you already
 know other
languages. It's simple enough.
 
 --
 Cheers 
--  Tim
 
 --
 PHP General Mailing List
(http://www.php.net/)
 To unsubscribe, visit:
http://www.php.net/unsub.php


Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread Sebastian Krebs
2013/8/21 Curtis Maurand cur...@maurand.com




 Sorry in advance for the top post.

 Use the right tool for
 the Job.  I've use Java, C# and PHP.

 1.  I hate the
 Perl-like object calls in PHP.  I'd rather use . notation
 in C# and Java.  It saves a lot of wear and tear on my left pinky
 finger.


Actually the problem is, that the dot . is already in use. With
$foo.bar() you cannot tell, if you want to call the method bar() on the
object $foo, or if you want to concatenate the value of $foo to the
result of the function bar(). There is no other way around this than a
different operator for method calls.


 2.  Java and C# are both typed languages.  Say what
 you want, but I have working with a string like 02 and have
 PHP convert that to an integer.  sometimes I want that zero in
 front.  If I want that to be an integer in Java it's int
 myInteger = Integer.parseInt(02);

 3.
 Java development environments (Eclipses, NetBeans, IBM RAD) are pretty
 horrible.  Visual Studio is hands down a better envrionment, even the
 older versions of it. I've hooked Visual Studio into SVN in the past and
 it works well.


Ever tried the jetbrains products? :D (No, they  don't pay me)



 4 PHP development environments are many and
 varied and all of them suck at web debugging.  I've used PHPEdit,
 Zend, Bluefish, Eclipse and a couple others.  Bluefish works better
 on Linux than it does on Windows.


I use PhpStorm and it works quite fine.



 Use the tool for the job at
 hand.

 Just my $0.02 worth.

 cheers,
 Curtis

 Tim Streater wrote:
  On 20 Aug 2013 at 23:59,
 PHP List phpl...@arashidigital.com wrote:
 
 
 While I don't have any references to back it up - my guess would be
  that
  Java may be seen as more versatile in
 general programming terms.  A
  staggering number of
 enterprise level web applications are built with
  Java, add
 to that the possibility of writing Android apps with the same
  knowledge.
 
  To me the salient point is,
 does java has as extensive a library or set of
  interfaces to
 other packages (such as SQLite, mysql, etc)?
 
  I
 would say that, in general, the other teacher is incorrect speaking
  strictly in terms of web development.  PHP has already won that
 crown
  many times over.  That said, when I was in University,
 it was difficult
  to find a programming class that taught
 anything but Java - and that
  was
  10yrs ago
 now.  I chalked it up to the education bubble not being able
 
 to see what the rest of the world is actually doing.
 
 
 Was PHP OOP-capable at the time? Perhaps the edu-bubble was simply
 looking
  down its nose at PHP. There being lots of courses proves
 nothing in and of
  itself. 20 years ago, there were lots of PC
 mags you could buy, which
  caused some folks to say look
 how much better the PC is supported than
  other platforms.
 Truth was, at the time, such support was needed given
  the mess
 of 640k limits, DOS, IRQs and the like, most of which issues have
  ceased to be relevant.
 
  Anyway, why should one
 need a course to learn PHP, assuming you already
  know other
 languages. It's simple enough.
 
  --
  Cheers
 --  Tim
 
  --
  PHP General Mailing List
 (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php




-- 
github.com/KingCrunch


Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread Curtis Maurand


Sebastian Krebs wrote:
 2013/8/21 Curtis Maurand
cur...@maurand.com
 



 Sorry in advance for the top post.

 Use the right tool for
 the Job. 
I've use Java, C# and PHP.

 1.  I hate the
 Perl-like object calls in PHP.  I'd rather use .
notation
 in C# and Java.  It saves a lot of wear and tear on
my left pinky
 finger.

 

Actually the problem is, that the dot . is already in use.
With
 $foo.bar() you cannot tell, if you want to call the method
bar() on the
 object $foo, or if you want
to concatenate the value of $foo to the
 result of
the function bar(). There is no other way around this than
a
 different operator for method calls.

I didn't think
of that.  It seems to me there could be an easier operator than -
which sometimes will make me stop and look at what keys I'm trying to
hit.  Just a thought.  I forgot about the concatenation operator
which is + in Java/C#
 
 
 2. 
Java and C# are both typed languages.  Say what
 you want,
but I have working with a string like 02 and have
 PHP convert that to an integer.  sometimes I want that zero
in
 front.  If I want that to be an integer in Java it's
int
 myInteger =
Integer.parseInt(02);

 3.
 Java development environments (Eclipses, NetBeans, IBM RAD) are
pretty
 horrible.  Visual Studio is hands down a better
envrionment, even the
 older versions of it. I've hooked
Visual Studio into SVN in the past and
 it works well.

 
 Ever tried the jetbrains products? :D (No,
they  don't pay me)

I have not, but it looks interesting. 
I'll have to try it.

 
 

 4 PHP development environments are many and

varied and all of them suck at web debugging.  I've used PHPEdit,
 Zend, Bluefish, Eclipse and a couple others.  Bluefish works
better
 on Linux than it does on Windows.

 
 I use PhpStorm and it works quite fine.
 
 

 Use the tool for the job at
 hand.

 Just my $0.02 worth.

 cheers,
 Curtis

 Tim Streater wrote:
  On 20 Aug 2013 at
23:59,
 PHP List phpl...@arashidigital.com wrote:
 
 
 While I don't have
any references to back it up - my guess would be
 
that
  Java may be seen as more versatile in
 general programming terms.  A
  staggering
number of
 enterprise level web applications are built
with
  Java, add
 to that the
possibility of writing Android apps with the same
 
knowledge.
 
  To me the salient point
is,
 does java has as extensive a library or set of
  interfaces to
 other packages (such as
SQLite, mysql, etc)?
 
  I
 would say that, in general, the other teacher is incorrect
speaking
  strictly in terms of web development.  PHP
has already won that
 crown
  many times
over.  That said, when I was in University,
 it was
difficult
  to find a programming class that
taught
 anything but Java - and that
 
was
  10yrs ago
 now.  I chalked it up
to the education bubble not being able
 
 to see what the rest of the world is actually doing.
 
 
 Was PHP OOP-capable at
the time? Perhaps the edu-bubble was simply
 looking
  down its nose at PHP. There being lots of courses
proves
 nothing in and of
  itself. 20 years
ago, there were lots of PC
 mags you could buy, which
  caused some folks to say look
 how much
better the PC is supported than
  other
platforms.
 Truth was, at the time, such support was
needed given
  the mess
 of 640k limits,
DOS, IRQs and the like, most of which issues have
 
ceased to be relevant.
 
  Anyway, why
should one
 need a course to learn PHP, assuming you
already
  know other
 languages. It's simple
enough.
 
  --
 
Cheers
 --  Tim
 
  --
  PHP General Mailing List

(http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php

 


 
 --
 github.com/KingCrunch



Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread David Harkness
On Wed, Aug 21, 2013 at 7:56 PM, Curtis Maurand cur...@maurand.com wrote:

 Sebastian Krebs wrote:

 Actually the problem is, that the dot . is already in use. With

 $foo.bar() you cannot tell, if you want to call the method bar() on the
  object $foo, or if you want to concatenate the value of $foo to the
  result of the function bar(). There is no other way around this than a
  different operator for method calls.

 I didn't think
 of that.  It seems to me there could be an easier operator than -
 which sometimes will make me stop and look at what keys I'm trying to
 hit.  Just a thought.  I forgot about the concatenation operator
 which is + in Java/C#


The PHP language developers were pretty stuck. Because of automatic
string-to-numeric-conversion, they couldn't use + for string concatenation.
Sadly, they chose . rather than .. which I believe one or two other
languages use. If they had, . would have been available once objects
rolled around in PHP 4/5. I suspect they chose - since that's used in C
and C++ to dereference a pointer.


  Ever tried the jetbrains products? :D (No, they don't pay me)

 I have not, but it looks interesting.
 I'll have to try it.


Those are very good products which have had a strong following for a
decade. The free IDE NetBeans also has quite good support for both Java and
PHP, and the latest beta version provides a web project that provides
front- and back-end debugging of PHP + JavaScript. You can be stepping
through JS code and hit an AJAX call and then seamlessly step through the
PHP code that handles it.

I use NetBeans for PHP/HTML/JS (though I am evaluating JetBrains' PHPStorm
now) and Eclipse for Java. You can't beat Eclipse's refactoring support in
a free tool, though I think NetBeans is close to catching up. I would bet
IntelliJ IDEA for Java by JetBrains is on par at least.

Peace,
David


Re: [PHP] PHP vs JAVA

2013-08-20 Thread Ashley Sheridan


Tedd Sperling t...@sperling.com wrote:
Hi guys:

A teacher at my college made the statement that JAVA for Web
Development is more popular than PHP.

Where can I go to prove this right or wrong -- and/or -- what
references do any of you have to support your answer? (sounds like a
teacher, huh?)

Here are my two references:

http://w3techs.com/technologies/details/pl-php/all/all

http://w3techs.com/technologies/history_overview/programming_language/ms/y


But I do not know how accurate they are.

What say you?

Cheers,


tedd

___
tedd sperling
t...@sperling.com






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

Is he possibly getting confused with Javascript?

Thanks,
Ash

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Stephen

On 13-08-20 10:00 AM, Tedd Sperling wrote:

Hi guys:

A teacher at my college made the statement that JAVA for Web Development is 
more popular than PHP.

Where can I go to prove this right or wrong -- and/or -- what references do any 
of you have to support your answer? (sounds like a teacher, huh?)

Here are my two references:

http://w3techs.com/technologies/details/pl-php/all/all

http://w3techs.com/technologies/history_overview/programming_language/ms/y

But I do not know how accurate they are.



I think you can use w3techs.com as a very reliable source.

But your teacher may have been talking about javascript which is not 
the same thing as java despite the similarity in their names.


Javascript is part of the web page, and executes in the users browser. 
It is very common and may rival PHP in frequency of use.


--
Stephen


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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Tedd Sperling
On Aug 20, 2013, at 10:04 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 Is he possibly getting confused with Javascript?
 
 Thanks,
 Ash

No, this guy is smarter than that -- he's pretty sharp -- so I listen to what 
he has to say.

Here's an interesting link:

http://www.sitepoint.com/best-programming-language-of-2013/

But the link does not divide languages between Web and Other -- other than 
Android Java, which I do not believe is also included in the above Java 
number.

I think there is more going on here than what I know.

For example, my college has numerous (over 3) JAVA classes filled to the max, 
whereas my PHP class was canceled due to lack of students. Granted the college 
could have advertised my PHP class more, but still there is an overwhelming 
demand for Java Programmers. My questions is Why?

Cheers,


tedd

___
tedd sperling
t...@sperling.com






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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Stephen

On 13-08-20 10:19 AM, Tedd Sperling wrote:

On Aug 20, 2013, at 10:04 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:

Is he possibly getting confused with Javascript?

Thanks,
Ash

No, this guy is smarter than that -- he's pretty sharp -- so I listen to what 
he has to say.

Here's an interesting link:

http://www.sitepoint.com/best-programming-language-of-2013/

But the link does not divide languages between Web and Other -- other than Android 
Java, which I do not believe is also included in the above Java number.

I think there is more going on here than what I know.

For example, my college has numerous (over 3) JAVA classes filled to the max, whereas my 
PHP class was canceled due to lack of students. Granted the college could have advertised 
my PHP class more, but still there is an overwhelming demand for Java Programmers. My 
questions is Why?


I think that the overwhelming majority of Android apps are written in 
JAVA. That explains its popularity.


--
Stephen


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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Sebastian Krebs
2013/8/20 Tedd Sperling t...@sperling.com

 On Aug 20, 2013, at 10:04 AM, Ashley Sheridan a...@ashleysheridan.co.uk
 wrote:
  Is he possibly getting confused with Javascript?
 
  Thanks,
  Ash

 No, this guy is smarter than that -- he's pretty sharp -- so I listen to
 what he has to say.

 Here's an interesting link:

 http://www.sitepoint.com/best-programming-language-of-2013/

 But the link does not divide languages between Web and Other -- other than
 Android Java, which I do not believe is also included in the above Java
 number.

 I think there is more going on here than what I know.

 For example, my college has numerous (over 3) JAVA classes filled to the
 max, whereas my PHP class was canceled due to lack of students. Granted the
 college could have advertised my PHP class more, but still there is an
 overwhelming demand for Java Programmers. My questions is Why?


Just tell your teacher: Java isn't more popular than PHP as _web_-language
;)
I think too, that he actually meant javascript, which is indeed a very
popular client-side language. But javascript and PHP has different
use-cases, thus saying one is more popular doesn't tell you anything
about whether they are in competition against each other, or not (hint:
they arent : :D).



 Cheers,


 tedd

 ___
 tedd sperling
 t...@sperling.com






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




-- 
github.com/KingCrunch


Re: [PHP] PHP vs JAVA

2013-08-20 Thread Tedd Sperling
 The article very clearly says..
 
 No language can be considered as good just because there are more jobs for 
 the same.
 

Yes, but I am not making a value (good/bad) judgment -- Instead I am asking for 
references supporting which language (Java or PHP) as being the most popular 
for Web Development?

Do you have any?

Cheers,

tedd

___
tedd sperling
t...@sperling.com






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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Bastien Koert
I think the big takeaway there is that JAVA is one of the primary language
for larger companies and applications. Start ups tend to use smaller easier
to use tools like php / javascript / python / ruby.

I saw one figure recently that put php at 75% of websites out there (i
think that came out when google decided to support php for the app engine)



On Tue, Aug 20, 2013 at 10:19 AM, Tedd Sperling t...@sperling.com wrote:

 On Aug 20, 2013, at 10:04 AM, Ashley Sheridan a...@ashleysheridan.co.uk
 wrote:
  Is he possibly getting confused with Javascript?
 
  Thanks,
  Ash

 No, this guy is smarter than that -- he's pretty sharp -- so I listen to
 what he has to say.

 Here's an interesting link:

 http://www.sitepoint.com/best-programming-language-of-2013/

 But the link does not divide languages between Web and Other -- other than
 Android Java, which I do not believe is also included in the above Java
 number.

 I think there is more going on here than what I know.

 For example, my college has numerous (over 3) JAVA classes filled to the
 max, whereas my PHP class was canceled due to lack of students. Granted the
 college could have advertised my PHP class more, but still there is an
 overwhelming demand for Java Programmers. My questions is Why?

 Cheers,


 tedd

 ___
 tedd sperling
 t...@sperling.com






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




-- 

Bastien

Cat, the other other white meat


Re: [PHP] PHP vs JAVA

2013-08-20 Thread Tedd Sperling
On Aug 20, 2013, at 10:29 AM, Sebastian Krebs krebs@gmail.com wrote:
 Just tell your teacher: Java isn't more popular than PHP as _web_-language ;)
 I think too, that he actually meant javascript, which is indeed a very 
 popular client-side language. But javascript and PHP has different use-cases, 
 thus saying one is more popular doesn't tell you anything about whether 
 they are in competition against each other, or not (hint: they arent : :D).

Two things:

1. He's not my teacher -- he is a fellow teacher AND a smart one! He knows the 
difference between Java and JavaScript.
2. In life, you will find that popularity (often over which is best) is the 
main reason why things prosper. 

Cheers,

tedd



___
tedd sperling
t...@sperling.com






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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Tedd Sperling
On Aug 20, 2013, at 10:36 AM, Liam l...@3sharpltd.com wrote:
 You do realise you are on a PHP based user subscription, so the vast
 majority will go with PHP, so you will get a one sided argument.
 
 Regards,
 Liam


I realize that many, maybe the majority, will be bias. HOWEVER -- there are 
professionals on this list that do know and it is to them I am asking. 
Remember, I am also asking for supporting documentation of their view. The 
people who respond with just their opinion are doing just that -- there is no 
support.

My nature is to seek the truth regardless of my bias.

Cheers,

tedd


___
tedd sperling
t...@sperling.com



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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Marc Guay
Here are two references from the Wikipedia article on Java in case you
haven't looked at them already.

http://www.langpop.com/
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

On 20 August 2013 10:43, Tedd Sperling t...@sperling.com wrote:
 On Aug 20, 2013, at 10:36 AM, Liam l...@3sharpltd.com wrote:
 You do realise you are on a PHP based user subscription, so the vast
 majority will go with PHP, so you will get a one sided argument.

 Regards,
 Liam


 I realize that many, maybe the majority, will be bias. HOWEVER -- there are 
 professionals on this list that do know and it is to them I am asking. 
 Remember, I am also asking for supporting documentation of their view. The 
 people who respond with just their opinion are doing just that -- there is no 
 support.

 My nature is to seek the truth regardless of my bias.

 Cheers,

 tedd


 ___
 tedd sperling
 t...@sperling.com



 --
 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] PHP vs JAVA

2013-08-20 Thread David OBrien
On Tue, Aug 20, 2013 at 10:43 AM, Tedd Sperling t...@sperling.com wrote:

 On Aug 20, 2013, at 10:36 AM, Liam l...@3sharpltd.com wrote:
  You do realise you are on a PHP based user subscription, so the vast
  majority will go with PHP, so you will get a one sided argument.
 
  Regards,
  Liam


 I realize that many, maybe the majority, will be bias. HOWEVER -- there
 are professionals on this list that do know and it is to them I am asking.
 Remember, I am also asking for supporting documentation of their view. The
 people who respond with just their opinion are doing just that -- there is
 no support.

 My nature is to seek the truth regardless of my bias.

 Cheers,

 tedd


 ___
 tedd sperling
 t...@sperling.com



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




Re: [PHP] PHP vs JAVA

2013-08-20 Thread David OBrien
On Tue, Aug 20, 2013 at 10:56 AM, David OBrien dgobr...@gmail.com wrote:




 On Tue, Aug 20, 2013 at 10:43 AM, Tedd Sperling t...@sperling.com wrote:

 On Aug 20, 2013, at 10:36 AM, Liam l...@3sharpltd.com wrote:
  You do realise you are on a PHP based user subscription, so the vast
  majority will go with PHP, so you will get a one sided argument.
 
  Regards,
  Liam


 I realize that many, maybe the majority, will be bias. HOWEVER -- there
 are professionals on this list that do know and it is to them I am asking.
 Remember, I am also asking for supporting documentation of their view. The
 people who respond with just their opinion are doing just that -- there is
 no support.

 My nature is to seek the truth regardless of my bias.

 Cheers,

 tedd


 ___
 tedd sperling
 t...@sperling.com



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





If your looking for popularity...
http://w3techs.com/technologies/overview/programming_language/all


Re: [PHP] PHP vs JAVA

2013-08-20 Thread Sebastian Krebs
2013/8/20 Tedd Sperling t...@sperling.com

 On Aug 20, 2013, at 10:29 AM, Sebastian Krebs krebs@gmail.com wrote:
  Just tell your teacher: Java isn't more popular than PHP as
 _web_-language ;)
  I think too, that he actually meant javascript, which is indeed a very
 popular client-side language. But javascript and PHP has different
 use-cases, thus saying one is more popular doesn't tell you anything
 about whether they are in competition against each other, or not (hint:
 they arent : :D).

 Two things:

 1. He's not my teacher -- he is a fellow teacher AND a smart one! He knows
 the difference between Java and JavaScript.


OKOK, sorry -_-
But @topic: For example see
http://w3techs.com/technologies/overview/programming_language/all
Really: Java is a good and mature language, but it is not a web-language.


 2. In life, you will find that popularity (often over which is best) is
 the main reason why things prosper.


I am not saying, that Java is bad, or it is not popular. It is just not
that popular in the web-ecosystem :)
There was one statement I remember (I don't know, where I got it from): A
static language doesn't fit very well into the dynamic web. :)



 Cheers,

 tedd



 ___
 tedd sperling
 t...@sperling.com








-- 
github.com/KingCrunch


Re: [PHP] PHP vs JAVA

2013-08-20 Thread Lester Caine

Sebastian Krebs wrote:

1. He's not my teacher -- he is a fellow teacher AND a smart one! He knows
the difference between Java and JavaScript.


OKOK, sorry -_-
But @topic: For example see
http://w3techs.com/technologies/overview/programming_language/all
Really: Java is a good and mature language, but it is not a web-language.


2. In life, you will find that popularity (often over which is best) is
the main reason why things prosper.


I think he is simply wrong in his interpretation of the facts. The number of 
websites powered by PHP vastly exceeds Java and every other language

http://w3techs.com/technologies/overview/programming_language/all
Says it all!

But you would never use PHP for a distributed application, and then 
http://www.langpop.com/ comes into play when the fight is between Java and C/C++ 
and personally I'm happier with C/C++ than Java even on Android. But even though 
you would not use PHP for distributed applications, it still gets a good 4th in 
that chart as well.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Daniel Brown
On Tue, Aug 20, 2013 at 10:00 AM, Tedd Sperling t...@sperling.com wrote:
 Hi guys:

 A teacher at my college made the statement that JAVA for Web Development is 
 more popular than PHP.

 Where can I go to prove this right or wrong -- and/or -- what references do 
 any of you have to support your answer? (sounds like a teacher, huh?)

 Here are my two references:

 http://w3techs.com/technologies/details/pl-php/all/all

 http://w3techs.com/technologies/history_overview/programming_language/ms/y

 But I do not know how accurate they are.

 What say you?

While I couldn't find anything comparable - from the same source
and window of time - for Java trends on the web, there was an article
released by Netcraft in January of this year that shows PHPs continued
growth[1].  It may, at the least, provide a basis for comparison
should you or your adversary be so inclined to dig deeper.


^1: 
http://news.netcraft.com/archives/2013/01/31/php-just-grows-grows.html

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread shiplu
What a co-incidence! I was searching PHP vs Python in google and
reading articles. Now a similar mail on my inbox. When any language
war goes on, everyone gets biased by the language he/she loves. It
applies here too. I think your college teacher loves Java.

During PHPvsPython search I found this info graphic
https://www.udemy.com/blog/modern-language-wars/#. Some of the
statistics contain Java too. Also you can search PHP and Web
Development in big job sites and compare with same search but with
Java.

On Tue, Aug 20, 2013 at 8:00 PM, Tedd Sperling t...@sperling.com wrote:
 Hi guys:

 A teacher at my college made the statement that JAVA for Web Development is 
 more popular than PHP.

 Where can I go to prove this right or wrong -- and/or -- what references do 
 any of you have to support your answer? (sounds like a teacher, huh?)

 Here are my two references:

 http://w3techs.com/technologies/details/pl-php/all/all

 http://w3techs.com/technologies/history_overview/programming_language/ms/y

 But I do not know how accurate they are.

 What say you?

 Cheers,


 tedd

 ___
 tedd sperling
 t...@sperling.com






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




-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Lester Caine

shiplu wrote:

During PHPvsPython search I found this info graphic
https://www.udemy.com/blog/modern-language-wars/#. Some of the
statistics contain Java too. Also you can search PHP and Web
Development in big job sites and compare with same search but with
Java.


'Python is arguably the most readable programming language' probably says it 
all? Personally I find it almost impossible to understand when coming in cold to 
someone elses code ... Java is not much better ... but I still have to persist 
with both since some key elements of a usable PHP IDE now rely on both :(


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP] PHP vs JAVA

2013-08-20 Thread Paul M Foster
On Tue, Aug 20, 2013 at 05:09:37PM +0100, Lester Caine wrote:

 shiplu wrote:
 During PHPvsPython search I found this info graphic
 https://www.udemy.com/blog/modern-language-wars/#. Some of the
 statistics contain Java too. Also you can search PHP and Web
 Development in big job sites and compare with same search but with
 Java.
 
 'Python is arguably the most readable programming language' probably
 says it all? Personally I find it almost impossible to understand
 when coming in cold to someone elses code ... Java is not much
 better ... but I still have to persist with both since some key
 elements of a usable PHP IDE now rely on both :(

Python may be most readable, but it's a huge fail for two reasons:

1. There are no statement terminators. Lose your indentation for ANY
reason and your program is well and truly screwed, in ways you can't
imagine.

2. Python programs fail in the most ungraceful way I've ever seen in an
interpreted programming language. (Don't even start in on C. It's a
compiled language.)

Java is an incredibly heavy language for web work. Much like Ruby but
more so.

I'll say it again-- one of the reasons for the popularity of PHP is its
similarity to C, at least a passing skill in which is common to most
programmers.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

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



<    1   2   3   4   5   6   7   8   9   10   >