Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-30 Thread Sebastian Krebs
2013/5/29 Matijn Woudt tijn...@gmail.com



 On Wed, May 29, 2013 at 10:51 PM, Sebastian Krebs krebs@gmail.comwrote:




 2013/5/29 Matijn Woudt tijn...@gmail.com

 On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade zootboys...@gmail.com
 wrote:

  On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
   On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
   I'm adding some minification to our cache.class.php and am running
 into
  an
   edge case that is causing me grief.
  
   I want to remove all comments of the // variety, HOWEVER I don't
 want to
   remove URLs...
  
   KISS.
  
   To make it simple, straight-forward, and understandable next year
 when I
   have to re-read what I've written:
  
   I'd change all :// to QqQ  -- or any unlikely text string.
  
   Then I'd do whatever needs to be done to the // occurances.
  
   Finally, I'd change all QqQ back to ://.
  
   Jonesy
 
  Wow. This is just a spectacularly bad suggestion.
 
  First off, this task is probably a bit beyond the capabilities of a
  regex. Yes, you may be able to come up with something that works 99%
  of the time, but this is really a job for a parser of some sort. I'm
  sorry I don't have any suggestions on exactly where to go with that,
  however I'm sure Google can be of assistance. The main problem is that
  regex doesn't understand context. It just blindly finds patterns. A
  parser understands context, and can figure out which //'s are comments
  and which are something else. As a bonus, it can probably understand
  other forms of comments like /* */, which regex would completely die
  on.
 
 
 It is possible to write a whole parser as a single regex, being it
 terribly
 long and complex.


 No, it isn't.



 It's better if you throw some smart words on the screen if you want to
 convince someone. Just thinking about it, it makes sense as a true regular
 expression can only describe a regular language, and I think all the
 programming languages are not regular languages.
 But, We have PHP PCRE with extensions like Recursive patterns[1] and Back
 references[2], which can describe much more than just a regular language.
 And I do believe it would be able to handle it.
 Too bad it probably takes months to complete a regular expression like
 this.


Then you start as soon as possible, so that you not realitze, that this is
wrong, when it is too late. I am not going to start explaining this again,
because it becomes a waste of time. You call it smart words on the
screen, I call it advice.


 - Matijn

 [1] http://php.net/manual/en/regexp.reference.recursive.php
 [2] http://php.net/manual/en/regexp.reference.back-references.php




-- 
github.com/KingCrunch


Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-30 Thread David Harkness
On Wed, May 29, 2013 at 10:20 AM, Matijn Woudt tijn...@gmail.com wrote:

 It is possible to write a whole parser as a single regex, being it terribly
 long and complex.


While regular expressions are often used in the lexer--the part that scans
the input stream and breaks it up into meaningful tokens like

{ keyword: function }
{ operator: + }

and

{ identifier: $foo }

that form the building blocks of the language--they aren't combined into a
single expression. Instead, a lexer generator is used to build a state
machine that switches the active expressions to check based on the previous
tokens and context. Each expression recognizes a different type of token,
and many times these aren't even regular expressions.

The second stage--combining tokens based on the rules of the grammar--is
more complex and beyond the abilities of regular expressions. There are
plenty of books on the subject and tools [1] to build the pieces such as
Lex, Yacc, Flex, and Bison. Someone even asked this question on Stack
Overflow [2] a few years ago. And I'm sure if you look you can find someone
that did a masters thesis proving that regular expressions cannot handle a
context-free grammar. And finally I leave you with Jeff Atwood's article
about (not) parsing HTML with regex. [3]

Peace,
David

[1] http://dinosaur.compilertools.net/
[2]
http://stackoverflow.com/questions/3487089/are-regular-expressions-used-to-build-parsers
[3]
http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html


[PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Jonesy
On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
 I'm adding some minification to our cache.class.php and am running into an
 edge case that is causing me grief.

 I want to remove all comments of the // variety, HOWEVER I don't want to
 remove URLs...

KISS.

To make it simple, straight-forward, and understandable next year when I 
have to re-read what I've written:

I'd change all :// to QqQ  -- or any unlikely text string.

Then I'd do whatever needs to be done to the // occurances.

Finally, I'd change all QqQ back to ://.

Jonesy


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



Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Sean Greenslade
On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
 On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
 I'm adding some minification to our cache.class.php and am running into an
 edge case that is causing me grief.

 I want to remove all comments of the // variety, HOWEVER I don't want to
 remove URLs...

 KISS.

 To make it simple, straight-forward, and understandable next year when I
 have to re-read what I've written:

 I'd change all :// to QqQ  -- or any unlikely text string.

 Then I'd do whatever needs to be done to the // occurances.

 Finally, I'd change all QqQ back to ://.

 Jonesy

Wow. This is just a spectacularly bad suggestion.

First off, this task is probably a bit beyond the capabilities of a
regex. Yes, you may be able to come up with something that works 99%
of the time, but this is really a job for a parser of some sort. I'm
sorry I don't have any suggestions on exactly where to go with that,
however I'm sure Google can be of assistance. The main problem is that
regex doesn't understand context. It just blindly finds patterns. A
parser understands context, and can figure out which //'s are comments
and which are something else. As a bonus, it can probably understand
other forms of comments like /* */, which regex would completely die
on.

Blindly replacing a string with any unlikely text string is just
bad. I don't care how unlikely your text string is, it _will_
eventually show up in a page. It may take 5 years, but it'll happen.
And when it does, this little hack will blow up spectacularly.

I'm sorry to rain on your parade, but this is not KISS. This may seem
simple, but the submarine bugs it introduces will be a nightmare to
track down, and then you'll be in the same boat that you are in right
now. Don't do that to yourself. Do it right the first time.


-- 
--Zootboy

Sent from some sort of computing device.

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



Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Matijn Woudt
On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade zootboys...@gmail.comwrote:

 On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
  On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
  I'm adding some minification to our cache.class.php and am running into
 an
  edge case that is causing me grief.
 
  I want to remove all comments of the // variety, HOWEVER I don't want to
  remove URLs...
 
  KISS.
 
  To make it simple, straight-forward, and understandable next year when I
  have to re-read what I've written:
 
  I'd change all :// to QqQ  -- or any unlikely text string.
 
  Then I'd do whatever needs to be done to the // occurances.
 
  Finally, I'd change all QqQ back to ://.
 
  Jonesy

 Wow. This is just a spectacularly bad suggestion.

 First off, this task is probably a bit beyond the capabilities of a
 regex. Yes, you may be able to come up with something that works 99%
 of the time, but this is really a job for a parser of some sort. I'm
 sorry I don't have any suggestions on exactly where to go with that,
 however I'm sure Google can be of assistance. The main problem is that
 regex doesn't understand context. It just blindly finds patterns. A
 parser understands context, and can figure out which //'s are comments
 and which are something else. As a bonus, it can probably understand
 other forms of comments like /* */, which regex would completely die
 on.


It is possible to write a whole parser as a single regex, being it terribly
long and complex.
That said, there's no other simple syntax that would work, for example in
javascript you could to the following:
var http = 5;
switch(value) {
case http:// Http case here! (this whould not be deleted)
// Do something
}
But most likely you wouldn't care about that..

- Matijn


Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Sean Greenslade
 It is possible to write a whole parser as a single regex, being it terribly
 long and complex.
 That said, there's no other simple syntax that would work, for example in
 javascript you could to the following:
 var http = 5;
 switch(value) {
 case http:// Http case here! (this whould not be deleted)
 // Do something
 }
 But most likely you wouldn't care about that..

 - Matijn

I would have to disagree. There are things that regex just can't at a
fundamental level grok. Things like nested brackets (e.g. the standard
blocking syntax of C, javascript, php, etc.). It's not a parser, and
despite all the little lookahead/behind tricks that enhanced regex can
do, it can't at a fundamental level _interret_ the text it sees. This
task involves interpreting what the text you're looking for actually
means, and should therefore be handled by something that can
interpret.

Also, (I haven't tested it, but) I don't think that example you gave
would work. Without any sort of quoting around the http://;
, I would assume the JS interpreter would take that double slash as a
comment starter. Do tell me if I'm wrong, though.

-- 
--Zootboy

Sent from some sort of computing device.

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



Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Matijn Woudt
On Wed, May 29, 2013 at 7:27 PM, Sean Greenslade zootboys...@gmail.comwrote:

  It is possible to write a whole parser as a single regex, being it
 terribly
  long and complex.
  That said, there's no other simple syntax that would work, for example in
  javascript you could to the following:
  var http = 5;
  switch(value) {
  case http:// Http case here! (this whould not be deleted)
  // Do something
  }
  But most likely you wouldn't care about that..
 
  - Matijn

 I would have to disagree. There are things that regex just can't at a
 fundamental level grok. Things like nested brackets (e.g. the standard
 blocking syntax of C, javascript, php, etc.). It's not a parser, and
 despite all the little lookahead/behind tricks that enhanced regex can
 do, it can't at a fundamental level _interret_ the text it sees. This
 task involves interpreting what the text you're looking for actually
 means, and should therefore be handled by something that can
 interpret.


I think it should be possible, but as I said, very very complex. Let's not
try it;)


 Also, (I haven't tested it, but) I don't think that example you gave
 would work. Without any sort of quoting around the http://;
 , I would assume the JS interpreter would take that double slash as a
 comment starter. Do tell me if I'm wrong, though.

 Which is exactly what I meant. Because http is a var set to 5, it is a
valid case statement, it would be equal to:
switch(value) {
case 5: // Http case here! (this whould not be deleted)
// Do something
}

But any regex given above would treat the first one as a http url, and
won't strip the // and everything after it, though in this modified case it
will strip the comments.

- Matijn


Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Sean Greenslade
On Wed, May 29, 2013 at 1:33 PM, Matijn Woudt tijn...@gmail.com wrote:



 On Wed, May 29, 2013 at 7:27 PM, Sean Greenslade zootboys...@gmail.com
 wrote:

  It is possible to write a whole parser as a single regex, being it
  terribly
  long and complex.
  That said, there's no other simple syntax that would work, for example
  in
  javascript you could to the following:
  var http = 5;
  switch(value) {
  case http:// Http case here! (this whould not be deleted)
  // Do something
  }
  But most likely you wouldn't care about that..
 
SNIP
 I think it should be possible, but as I said, very very complex. Let's not
 try it;)


 Also, (I haven't tested it, but) I don't think that example you gave
 would work. Without any sort of quoting around the http://;
 , I would assume the JS interpreter would take that double slash as a
 comment starter. Do tell me if I'm wrong, though.

 Which is exactly what I meant. Because http is a var set to 5, it is a valid
 case statement, it would be equal to:
 switch(value) {
 case 5: // Http case here! (this whould not be deleted)
 // Do something
 }

 But any regex given above would treat the first one as a http url, and won't
 strip the // and everything after it, though in this modified case it will
 strip the comments.

 - Matijn

Sorry, I slightly mis-interpreted what that code was intending to do.
Regardless, it is still something that should be done by an
interpreter. So this is another edge case where regexes would more
than likely break down but an interpreter should (I do say should) do
The Right Thing.

-- 
--Zootboy

Sent from some sort of computing device.

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



RE: [PHP] [SOLVED] need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Daevid Vincent


 -Original Message-
 From: Andreas Perstinger [mailto:andiper...@gmail.com]
 Sent: Tuesday, May 28, 2013 11:10 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] need some regex help to strip out // comments but not
 http:// urls
 
 On 28.05.2013 23:17, Daevid Vincent wrote:
  I want to remove all comments of the // variety, HOWEVER I don't want to
  remove URLs...
 
 
 You need a negative look behind assertion
 ( http://www.php.net/manual/en/regexp.reference.assertions.php ).
 
 (?!http:)// will match // only if it isn't preceded by http:.
 
 Bye, Andreas

This worked like a CHAMP Andreas my friend! You are a regex guru!

 -Original Message-
 From: Sean Greenslade [mailto:zootboys...@gmail.com]
 Sent: Wednesday, May 29, 2013 10:28 AM

 Also, (I haven't tested it, but) I don't think that example you gave
 would work. Without any sort of quoting around the http://;
 , I would assume the JS interpreter would take that double slash as a
 comment starter. Do tell me if I'm wrong, though.

You're wrong Sean. :-p

This regex works in all cases listed in my example target string.

\s*(?!:)//.*?$

Or in my actual compress() method:

$sBlob = preg_replace(@\s*(?!:)//.*?$@m,'',$sBlob);

Target test case with intentional traps:

// another comment here
iframe src=http://foo.com;
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, );
else if(window.opera  window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
} 
else if(document.all)// ie
window.external.AddFavorite(url, title);
}


And for those interested here is the whole method...

public function compress($sBlob)
{
//remove C style /* */ blocks as well as PHPDoc /** */ blocks
$sBlob = preg_replace(@/\*(.*?)\*/@s,'',$sBlob);
//$sBlob =
preg_replace(/\*[^*]*\*+(?:[^*/][^*]*\*+)*/s,'',$sBlob);
//$sBlob = preg_replace(/\\*(?:.|[\\n\\r])*?\\*/s,'',$sBlob);

//remove // or # style comments at the start of a line possibly
redundant with next preg_replace
$sBlob =
preg_replace(@^\s*((^\s*(#+|//+)\s*.+?$\n)+)@m,'',$sBlob);
//remove // style comments that might be tagged onto valid code
lines. we don't try for # style as that's risky and not widely used
// @see http://www.php.net/manual/en/regexp.reference.assertions.php
$sBlob = preg_replace(@\s*(?!:)//.*?$@m,'',$sBlob);

if (in_array($this-_file_name_suffix, array('html','htm')))
{
//remove !-- -- blocks
$sBlob = preg_replace(/!--[^\[](.*?)--/s,'',$sBlob);

//if Tidy is enabled...
//if (!extension_loaded('tidy')) dl( ((PHP_SHLIB_SUFFIX ===
'dll') ? 'php_' : '') . 'tidy.' . PHP_SHLIB_SUFFIX);
if (FALSE  extension_loaded('tidy'))
{
//use Tidy to clean up the rest. There may be some
redundancy with the above, but it shouldn't hurt
//See all parameters available here:
http://tidy.sourceforge.net/docs/quickref.html
$tconfig = array(
'clean' = true,
'hide-comments' = true,
'hide-endtags' = true,

'drop-proprietary-attributes' = true,
'join-classes' = true,
'join-styles' = true,
'quote-marks' = false,
'fix-uri' = false,
'numeric-entities' = true,
'preserve-entities' = true,
'doctype' = 'omit',
'tab-size' = 1,
'wrap' = 0,
'wrap-php' = false,
'char-encoding' = 'raw',
'input-encoding' = 'raw',
'output-encoding' = 'raw',
'ascii-chars' = true,
'newline' = 'LF',
'tidy-mark' = false,
'quiet' = true,
'show-errors' =
($this-_debug ? 6 : 0),
'show-warnings' =
$this-_debug,
);

if ($this-_log_messages) $tconfig['error-file'] =
DBLOGPATH

Re: [PHP] [SOLVED] need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Sean Greenslade
On Wed, May 29, 2013 at 4:26 PM, Daevid Vincent dae...@daevid.com wrote:


 -Original Message-
 From: Sean Greenslade [mailto:zootboys...@gmail.com]
 Sent: Wednesday, May 29, 2013 10:28 AM

 Also, (I haven't tested it, but) I don't think that example you gave
 would work. Without any sort of quoting around the http://;
 , I would assume the JS interpreter would take that double slash as a
 comment starter. Do tell me if I'm wrong, though.

 You're wrong Sean. :-p

Glad to hear it. I knew I shouldn't have opened my mouth. =P
(In all seriousness, I realize that I mis-read that code earlier. I
think I was still reeling from the suggestion of doing arbitrary
string replacements in files.)


 This regex works in all cases listed in my example target string.

 \s*(?!:)//.*?$

 Or in my actual compress() method:

 $sBlob = preg_replace(@\s*(?!:)//.*?$@m,'',$sBlob);

 Target test case with intentional traps:

 // another comment here
 iframe src=http://foo.com;
 function bookmarksite(title,url){
 if (window.sidebar) // firefox
 window.sidebar.addPanel(title, url, );
 else if(window.opera  window.print){ // opera
 var elem = document.createElement('a');
 elem.setAttribute('href',url);
 elem.setAttribute('title',title);
 elem.setAttribute('rel','sidebar');
 elem.click();
 }
 else if(document.all)// ie
 window.external.AddFavorite(url, title);
 }


And if that's the only case you're concerned about, I suppose that
regex will do just fine. Just always keep an eye out for double
slashes elsewhere. My concern would be something within a quoted
string. If that happens, no regex will save you. As I mentioned
before, regexes aren't smart enough to understand whether they're
inside or outside matching quotes. Thus, a line like this may get
eaten by your regex:
document.getElementById(textField).innerHTML = Lol slashes // are // fun;

The JS parser sees that the double slashes are inside a string, but
your regex won't. Just something to be aware of, especially because
it's something that might not show up right away.

-- 
--Zootboy

Sent from some sort of computing device.

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



Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Sebastian Krebs
2013/5/29 Matijn Woudt tijn...@gmail.com

 On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade zootboys...@gmail.com
 wrote:

  On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
   On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
   I'm adding some minification to our cache.class.php and am running
 into
  an
   edge case that is causing me grief.
  
   I want to remove all comments of the // variety, HOWEVER I don't want
 to
   remove URLs...
  
   KISS.
  
   To make it simple, straight-forward, and understandable next year when
 I
   have to re-read what I've written:
  
   I'd change all :// to QqQ  -- or any unlikely text string.
  
   Then I'd do whatever needs to be done to the // occurances.
  
   Finally, I'd change all QqQ back to ://.
  
   Jonesy
 
  Wow. This is just a spectacularly bad suggestion.
 
  First off, this task is probably a bit beyond the capabilities of a
  regex. Yes, you may be able to come up with something that works 99%
  of the time, but this is really a job for a parser of some sort. I'm
  sorry I don't have any suggestions on exactly where to go with that,
  however I'm sure Google can be of assistance. The main problem is that
  regex doesn't understand context. It just blindly finds patterns. A
  parser understands context, and can figure out which //'s are comments
  and which are something else. As a bonus, it can probably understand
  other forms of comments like /* */, which regex would completely die
  on.
 
 
 It is possible to write a whole parser as a single regex, being it terribly
 long and complex.


No, it isn't.


 That said, there's no other simple syntax that would work, for example in
 javascript you could to the following:
 var http = 5;
 switch(value) {
 case http:// Http case here! (this whould not be deleted)
 // Do something
 }
 But most likely you wouldn't care about that..

 - Matijn




-- 
github.com/KingCrunch


Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Matijn Woudt
On Wed, May 29, 2013 at 10:51 PM, Sebastian Krebs krebs@gmail.comwrote:




 2013/5/29 Matijn Woudt tijn...@gmail.com

 On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade zootboys...@gmail.com
 wrote:

  On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
   On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
   I'm adding some minification to our cache.class.php and am running
 into
  an
   edge case that is causing me grief.
  
   I want to remove all comments of the // variety, HOWEVER I don't
 want to
   remove URLs...
  
   KISS.
  
   To make it simple, straight-forward, and understandable next year
 when I
   have to re-read what I've written:
  
   I'd change all :// to QqQ  -- or any unlikely text string.
  
   Then I'd do whatever needs to be done to the // occurances.
  
   Finally, I'd change all QqQ back to ://.
  
   Jonesy
 
  Wow. This is just a spectacularly bad suggestion.
 
  First off, this task is probably a bit beyond the capabilities of a
  regex. Yes, you may be able to come up with something that works 99%
  of the time, but this is really a job for a parser of some sort. I'm
  sorry I don't have any suggestions on exactly where to go with that,
  however I'm sure Google can be of assistance. The main problem is that
  regex doesn't understand context. It just blindly finds patterns. A
  parser understands context, and can figure out which //'s are comments
  and which are something else. As a bonus, it can probably understand
  other forms of comments like /* */, which regex would completely die
  on.
 
 
 It is possible to write a whole parser as a single regex, being it
 terribly
 long and complex.


 No, it isn't.



It's better if you throw some smart words on the screen if you want to
convince someone. Just thinking about it, it makes sense as a true regular
expression can only describe a regular language, and I think all the
programming languages are not regular languages.
But, We have PHP PCRE with extensions like Recursive patterns[1] and Back
references[2], which can describe much more than just a regular language.
And I do believe it would be able to handle it.
Too bad it probably takes months to complete a regular expression like this.

- Matijn

[1] http://php.net/manual/en/regexp.reference.recursive.php
[2] http://php.net/manual/en/regexp.reference.back-references.php


Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-29 Thread Ashley Sheridan


Matijn Woudt tijn...@gmail.com wrote:

On Wed, May 29, 2013 at 10:51 PM, Sebastian Krebs
krebs@gmail.comwrote:




 2013/5/29 Matijn Woudt tijn...@gmail.com

 On Wed, May 29, 2013 at 6:08 PM, Sean Greenslade
zootboys...@gmail.com
 wrote:

  On Wed, May 29, 2013 at 9:57 AM, Jonesy gm...@jonz.net wrote:
   On Tue, 28 May 2013 14:17:06 -0700, Daevid Vincent wrote:
   I'm adding some minification to our cache.class.php and am
running
 into
  an
   edge case that is causing me grief.
  
   I want to remove all comments of the // variety, HOWEVER I
don't
 want to
   remove URLs...
  
   KISS.
  
   To make it simple, straight-forward, and understandable next
year
 when I
   have to re-read what I've written:
  
   I'd change all :// to QqQ  -- or any unlikely text string.
  
   Then I'd do whatever needs to be done to the // occurances.
  
   Finally, I'd change all QqQ back to ://.
  
   Jonesy
 
  Wow. This is just a spectacularly bad suggestion.
 
  First off, this task is probably a bit beyond the capabilities of
a
  regex. Yes, you may be able to come up with something that works
99%
  of the time, but this is really a job for a parser of some sort.
I'm
  sorry I don't have any suggestions on exactly where to go with
that,
  however I'm sure Google can be of assistance. The main problem is
that
  regex doesn't understand context. It just blindly finds patterns.
A
  parser understands context, and can figure out which //'s are
comments
  and which are something else. As a bonus, it can probably
understand
  other forms of comments like /* */, which regex would completely
die
  on.
 
 
 It is possible to write a whole parser as a single regex, being it
 terribly
 long and complex.


 No, it isn't.



It's better if you throw some smart words on the screen if you want to
convince someone. Just thinking about it, it makes sense as a true
regular
expression can only describe a regular language, and I think all the
programming languages are not regular languages.
But, We have PHP PCRE with extensions like Recursive patterns[1] and
Back
references[2], which can describe much more than just a regular
language.
And I do believe it would be able to handle it.
Too bad it probably takes months to complete a regular expression like
this.

- Matijn

[1] http://php.net/manual/en/regexp.reference.recursive.php
[2] http://php.net/manual/en/regexp.reference.back-references.php

Sometimes when all you know is regex, everything looks like a nail...

Thanks,
Ash

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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-26 Thread Alan Hoffmeister
2012/10/25  l...@afan.net:
 Hi to all,
 My site with Drupal 7. I contacted tech support and he said he accessed to
 the site with FTP - what I doubt. But if it's truth - it's even worse
 because whole server is then compromised.
 I need help with command line for list all new/modified files within the
 last 24 hours.

 Thanks for any help,
 LAMP


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


Easy one.
1) List all files within a directory recursively:
http://php.net/manual/en/function.readdir.php
2) Now just excract the modification time of each file:
http://php.net/manual/en/function.filemtime.php
3) Print on the screen those with modificication time  than 24 hours
4) Profit!

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



[PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread lamp
Hi to all,
My site with Drupal 7. I contacted tech support and he said he accessed to
the site with FTP - what I doubt. But if it's truth - it's even worse
because whole server is then compromised.
I need help with command line for list all new/modified files within the
last 24 hours.

Thanks for any help,
LAMP


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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread Jim Lucas

On 10/25/2012 06:15 PM, l...@afan.net wrote:

Hi to all,
My site with Drupal 7. I contacted tech support and he said he accessed to
the site with FTP - what I doubt. But if it's truth - it's even worse
because whole server is then compromised.
I need help with command line for list all new/modified files within the
last 24 hours.

Thanks for any help,
LAMP




First off, don't hijack someone else's thread for a new topic
Secondly, this has nothing to do with PHP
Third, if it is Linux, man find and you will find the answer you seek
Forth, if it is Windows, I have nothing else to say

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread lamp
 On 10/25/2012 06:15 PM, l...@afan.net wrote:
 Hi to all,
 My site with Drupal 7. I contacted tech support and he said he accessed
 to
 the site with FTP - what I doubt. But if it's truth - it's even worse
 because whole server is then compromised.
 I need help with command line for list all new/modified files within
 the
 last 24 hours.

 Thanks for any help,
 LAMP



 First off, don't hijack someone else's thread for a new topic

I apologize for this, I thought by changing the Subject It's new thread.

 Secondly, this has nothing to do with PHP
I apologize again. You're right, I should post on Linux group.

 Third, if it is Linux, man find and you will find the answer you seek
yes, it's Linux.

 Forth, if it is Windows, I have nothing else to say
:-)



 --
 Jim Lucas

 http://www.cmsws.com/
 http://www.cmsws.com/examples/

 --
 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] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread lamp
 Remove all compromised files:

 sudo rm -rf /

 Really you should move to a new server. Dump the database and upload code
 from your local copy.

I wish it's so easy :(




 Regards,

 -Josh
 ___
 http://joshuakehn.com
 Currently mobile

 On Oct 25, 2012, at 9:15 PM, l...@afan.net wrote:

 Hi to all,
 My site with Drupal 7. I contacted tech support and he said he accessed
 to
 the site with FTP - what I doubt. But if it's truth - it's even worse
 because whole server is then compromised.
 I need help with command line for list all new/modified files within
 the
 last 24 hours.

 Thanks for any help,
 LAMP


 --
 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] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread lamp


 -Original Message-
 From: l...@afan.net [mailto:l...@afan.net]
 Sent: Thursday, October 25, 2012 9:16 PM
 To: php-general@lists.php.net
 Subject: [PHP] URGENT! Need help with command line for list all
 new/modified files within the last 24 hours

 Hi to all,
 My site with Drupal 7. I contacted tech support and he said he accessed
 to the site with FTP - what I doubt. But if it's truth - it's even
 worse because whole server is then compromised.
 I need help with command line for list all new/modified files within
 the last 24 hours.

 Thanks for any help,
 LAMP


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



 $ ls -n -r * /directory-path ($fmtime = 20121024)


Thanks a lot!!!
:-)





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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread Jay Blanchard

[snip]
Third, if it is Linux, man find and you will find the answer you seek
[/snip]

RTFMP

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



Re: [PHP] URGENT! Need help with command line for list all new/modified files within the last 24 hours

2012-10-25 Thread lamp
 On 10/25/2012 06:15 PM, l...@afan.net wrote:
 Hi to all,
 My site with Drupal 7. I contacted tech support and he said he accessed
 to
 the site with FTP - what I doubt. But if it's truth - it's even worse
 because whole server is then compromised.
 I need help with command line for list all new/modified files within
 the
 last 24 hours.

 Thanks for any help,
 LAMP



 First off, don't hijack someone else's thread for a new topic

I apologize for this, I thought by changing the Subject It's new thread.

 Secondly, this has nothing to do with PHP
I apologize again. You're right, I should post on Linux group.

 Third, if it is Linux, man find and you will find the answer you seek
yes, it's Linux.

 Forth, if it is Windows, I have nothing else to say
:-)



 --
 Jim Lucas

 http://www.cmsws.com/
 http://www.cmsws.com/examples/

 --
 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: Need help to understand a code

2012-09-22 Thread Maciek Sokolewicz

On 22-09-2012 12:34, Ashickur Rahman Noor wrote:

Hi all

I need some help to understand a code. The code is like this

$result = mysql_query($sSQL) or die(err:  . mysql_error().$sSQL);

 if($row = mysql_fetch_array($result))
 {
   foreach($row as $key =$value){ $$key=$value;}
 }



I don't get the code from the foreach loop.
It simply assigns all values from the array to variables, which have the 
name of the keys.


So basically what happens is:
$array = array('a'=1, 'b'=2, 'c'=3);
foreach($array as $key=$val) {
   $$key = $val;
}

will result in the creation of:
$a = 1;
$b = 2;
$c = 3;

$$foo means I want a variable whose name is contained in the variable 
$foo. So if $foo has the value 'bar', then you'll actually be saying I 
want a variable whose name is 'bar': $bar.


So:
$foo = 'bar';
$bar = 'this works!';

echo $$foo; // returns this works!



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



Re: [PHP] Re: Need help to understand a code

2012-09-22 Thread Ashley Sheridan
On Sat, 2012-09-22 at 13:13 +0200, Maciek Sokolewicz wrote:

 On 22-09-2012 12:34, Ashickur Rahman Noor wrote:
  Hi all
 
  I need some help to understand a code. The code is like this
 
  $result = mysql_query($sSQL) or die(err:  . mysql_error().$sSQL);
   if($row = mysql_fetch_array($result))
   {
 foreach($row as $key =$value){ $$key=$value;}
   }
 
 
  I don't get the code from the foreach loop.
 It simply assigns all values from the array to variables, which have the 
 name of the keys.
 
 So basically what happens is:
 $array = array('a'=1, 'b'=2, 'c'=3);
 foreach($array as $key=$val) {
 $$key = $val;
 }
 
 will result in the creation of:
 $a = 1;
 $b = 2;
 $c = 3;
 
 $$foo means I want a variable whose name is contained in the variable 
 $foo. So if $foo has the value 'bar', then you'll actually be saying I 
 want a variable whose name is 'bar': $bar.
 
 So:
 $foo = 'bar';
 $bar = 'this works!';
 
 echo $$foo; // returns this works!
 
 
 


Be careful with this though. I'm working on fixing some old code that
someone wrote. They used this technique to update their code when it
got moved to a server where register_globals was turned off.
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Re: Need help to understand a code

2012-09-22 Thread Ashickur Rahman Noor
Hi Ashley

I am updating some one code. Thanks for the notify.

Thanks to all. Now I get that.
--
Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
2048R/89C932E1 http://goo.gl/TkP5U
Coordinator - Public Relation Cell, FOSS Bangladesh
http://fossbd.org/  Mozilla
Reps http://reps.mozilla.org
01199151550, 01551151550


Re: [PHP] Re: Need help to understand a code

2012-09-22 Thread Ashley Sheridan
On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:

 Hi Ashley
 
 I am updating some one code. Thanks for the notify.
 
 Thanks to all. Now I get that.
 --
 Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
 2048R/89C932E1 http://goo.gl/TkP5U
 Coordinator - Public Relation Cell, FOSS Bangladesh
 http://fossbd.org/  Mozilla
 Reps http://reps.mozilla.org
 01199151550, 01551151550


It's probably fine doing that for your example, as the content coming
from the database will be content you expect, but be wary of using it on
any of the user-generated arrays like $_GET, or $_POST.

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




Re: [PHP] Re: Need help to understand a code

2012-09-22 Thread Matijn Woudt
Op 22 sep. 2012 13:47 schreef Ashley Sheridan a...@ashleysheridan.co.uk
het volgende:

 On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:

  Hi Ashley
 
  I am updating some one code. Thanks for the notify.
 
  Thanks to all. Now I get that.
  --
  Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
  2048R/89C932E1 http://goo.gl/TkP5U
  Coordinator - Public Relation Cell, FOSS Bangladesh
  http://fossbd.org/  Mozilla
  Reps http://reps.mozilla.org
  01199151550, 01551151550


 It's probably fine doing that for your example, as the content coming
 from the database will be content you expect, but be wary of using it on
 any of the user-generated arrays like $_GET, or $_POST.


And a few months/years later you decide to add a new column to your db
which has the same name as one of the variables you're already using and
the script starts acting very strange...
People should stop using bad coding habits like these..

- Matijn


RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Samuel Lopes Grigolato
+1 to bad maintainability of the code.

As a suggestion, one better solution could be something like:

[...]

class Entity {
   public $id;
   public $name;
}

[...]

$entity = new Entity();
foreach [...]
  $entity-$$key = $value;  

[...]

And, of course, never ever use * in SQL queries.

Samuel.

-Mensagem original-
De: Matijn Woudt [mailto:tijn...@gmail.com] 
Enviada em: sábado, 22 de setembro de 2012 11:02
Para: a...@ashleysheridan.co.uk
Cc: Ashickur Rahman Noor; PHP List
Assunto: Re: [PHP] Re: Need help to understand a code

Op 22 sep. 2012 13:47 schreef Ashley Sheridan a...@ashleysheridan.co.uk het 
volgende:

 On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:

  Hi Ashley
 
  I am updating some one code. Thanks for the notify.
 
  Thanks to all. Now I get that.
  --
  Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
  2048R/89C932E1 http://goo.gl/TkP5U Coordinator - Public Relation 
  Cell, FOSS Bangladesh http://fossbd.org/  Mozilla Reps 
  http://reps.mozilla.org 01199151550, 01551151550


 It's probably fine doing that for your example, as the content coming 
 from the database will be content you expect, but be wary of using it 
 on any of the user-generated arrays like $_GET, or $_POST.


And a few months/years later you decide to add a new column to your db which 
has the same name as one of the variables you're already using and the script 
starts acting very strange...
People should stop using bad coding habits like these..

- Matijn


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



Re: RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Ashley Sheridan


Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote:

+1 to bad maintainability of the code.

As a suggestion, one better solution could be something like:

[...]

class Entity {
   public $id;
   public $name;
}

[...]

$entity = new Entity();
foreach [...]
  $entity-$$key = $value;

[...]

And, of course, never ever use * in SQL queries.

Samuel.

-Mensagem original-
De: Matijn Woudt [mailto:tijn...@gmail.com]
Enviada em: sábado, 22 de setembro de 2012 11:02
Para: a...@ashleysheridan.co.uk
Cc: Ashickur Rahman Noor; PHP List
Assunto: Re: [PHP] Re: Need help to understand a code

Op 22 sep. 2012 13:47 schreef Ashley Sheridan
a...@ashleysheridan.co.uk het volgende:

 On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:

  Hi Ashley
 
  I am updating some one code. Thanks for the notify.
 
  Thanks to all. Now I get that.
  --
  Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
  2048R/89C932E1 http://goo.gl/TkP5U Coordinator - Public Relation
  Cell, FOSS Bangladesh http://fossbd.org/  Mozilla Reps
  http://reps.mozilla.org 01199151550, 01551151550


 It's probably fine doing that for your example, as the content coming

 from the database will be content you expect, but be wary of using it

 on any of the user-generated arrays like $_GET, or $_POST.


And a few months/years later you decide to add a new column to your db
which has the same name as one of the variables you're already using
and the script starts acting very strange...
People should stop using bad coding habits like these..

- Matijn


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

there's nothing wrong with using * in queries.

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



Re: RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Maciek Sokolewicz

On 22-09-2012 16:19, Samuel Lopes Grigolato wrote:

+1 to bad maintainability of the code.

As a suggestion, one better solution could be something like:

[...]

class Entity {
public $id;
public $name;
}

[...]

$entity = new Entity();
foreach [...]
   $entity-$$key = $value;

[...]

And, of course, never ever use * in SQL queries.

Samuel.



If you're doing it that way, just use mysqli and then mysqli_result's 
fetch_object with your Entity as the class. ie:

$result = $mysqli-query('some query');
$entity = $result-fetch_object('Entity');


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



RES: RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Samuel Lopes Grigolato
I disagree with you Ashley, some arguments can be found here: 
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list.aspx

Using explicit columns names in the select clause is, IMHO, at least a good 
documentation for what is being requested to the database layer.

+1 to Maciek's suggestion, had totally forgotten this one.

Cheers.

-Mensagem original-
De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Enviada em: sábado, 22 de setembro de 2012 11:52
Para: Samuel Lopes Grigolato; 'PHP List'
Assunto: Re: RES: [PHP] Re: Need help to understand a code



Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote:

+1 to bad maintainability of the code.

As a suggestion, one better solution could be something like:

[...]

class Entity {
   public $id;
   public $name;
}

[...]

$entity = new Entity();
foreach [...]
  $entity-$$key = $value;

[...]

And, of course, never ever use * in SQL queries.

Samuel.

-Mensagem original-
De: Matijn Woudt [mailto:tijn...@gmail.com] Enviada em: sábado, 22 de 
setembro de 2012 11:02
Para: a...@ashleysheridan.co.uk
Cc: Ashickur Rahman Noor; PHP List
Assunto: Re: [PHP] Re: Need help to understand a code

Op 22 sep. 2012 13:47 schreef Ashley Sheridan
a...@ashleysheridan.co.uk het volgende:

 On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:

  Hi Ashley
 
  I am updating some one code. Thanks for the notify.
 
  Thanks to all. Now I get that.
  --
  Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
  2048R/89C932E1 http://goo.gl/TkP5U Coordinator - Public Relation 
  Cell, FOSS Bangladesh http://fossbd.org/  Mozilla Reps 
  http://reps.mozilla.org 01199151550, 01551151550


 It's probably fine doing that for your example, as the content coming

 from the database will be content you expect, but be wary of using it

 on any of the user-generated arrays like $_GET, or $_POST.


And a few months/years later you decide to add a new column to your db 
which has the same name as one of the variables you're already using 
and the script starts acting very strange...
People should stop using bad coding habits like these..

- Matijn


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

there's nothing wrong with using * in queries.

--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


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



Re: RES: RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Ashley Sheridan
On Sat, 2012-09-22 at 12:12 -0300, Samuel Lopes Grigolato wrote:

 I disagree with you Ashley, some arguments can be found here: 
 http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list.aspx
 
 Using explicit columns names in the select clause is, IMHO, at least a good 
 documentation for what is being requested to the database layer.
 
 +1 to Maciek's suggestion, had totally forgotten this one.
 
 Cheers.
 
 -Mensagem original-
 De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
 Enviada em: sábado, 22 de setembro de 2012 11:52
 Para: Samuel Lopes Grigolato; 'PHP List'
 Assunto: Re: RES: [PHP] Re: Need help to understand a code
 
 
 
 Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote:
 
 +1 to bad maintainability of the code.
 
 As a suggestion, one better solution could be something like:
 
 [...]
 
 class Entity {
public $id;
public $name;
 }
 
 [...]
 
 $entity = new Entity();
 foreach [...]
   $entity-$$key = $value;
 
 [...]
 
 And, of course, never ever use * in SQL queries.
 
 Samuel.
 
 -Mensagem original-
 De: Matijn Woudt [mailto:tijn...@gmail.com] Enviada em: sábado, 22 de 
 setembro de 2012 11:02
 Para: a...@ashleysheridan.co.uk
 Cc: Ashickur Rahman Noor; PHP List
 Assunto: Re: [PHP] Re: Need help to understand a code
 
 Op 22 sep. 2012 13:47 schreef Ashley Sheridan
 a...@ashleysheridan.co.uk het volgende:
 
  On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:
 
   Hi Ashley
  
   I am updating some one code. Thanks for the notify.
  
   Thanks to all. Now I get that.
   --
   Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
   2048R/89C932E1 http://goo.gl/TkP5U Coordinator - Public Relation 
   Cell, FOSS Bangladesh http://fossbd.org/  Mozilla Reps 
   http://reps.mozilla.org 01199151550, 01551151550
 
 
  It's probably fine doing that for your example, as the content coming
 
  from the database will be content you expect, but be wary of using it
 
  on any of the user-generated arrays like $_GET, or $_POST.
 
 
 And a few months/years later you decide to add a new column to your db 
 which has the same name as one of the variables you're already using 
 and the script starts acting very strange...
 People should stop using bad coding habits like these..
 
 - Matijn
 
 
 --
 PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
 http://www.php.net/unsub.php
 
 there's nothing wrong with using * in queries.
 
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.
 


There are plenty of times that you need all fields from a table though.
I go by the rule that if I need less than two thirds of the fields of a
table, then I specify the fields I need, otherwise, it's easier to go
with *.

I've looked at the link you posted. The join issue is too broad. I use *
with joins, but avoid the conflicts by specifying the table name, still
going by the ⅔ rule above on a table by table basis. Of course, if there
are tables used in the join that are not necessary to the actual output,
I won't include them in the list, but I may do something like this:

SELECT a.a, a.b, a.c, b.*
FROM a
LEFT JOIN a on a.a = b.a

I would say that if you're in the position of writing the queries then
you should be aware of the database schema, so using the query as a form
of documentation shouldn't be a factor. Of course there are occasions
where the database is updated and breaks code, in which case specifying
all the field names would potentially avoid that, but procedures should
be in place which would at least make you aware of such updates to allow
you to plan for them.



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




RES: RES: RES: [PHP] Re: Need help to understand a code

2012-09-22 Thread Samuel Lopes Grigolato
When I said that it’s a form of documentation, I was saying that I think it’s 
better to know everything the script is using from the tables right on the SQL 
command, without the need to inspect all the code, for example:

 

SELECT * FROM a;

$values = some_fetch_array_thing

[…] bunch of lines of code

echo $values[“column1”];

[…] another bunch of code

echo $values[“column2”];

 

In my opinion it’s is easier to forget that column2 is being utilized by this 
script, than if it was explicit in the SQL command. Of course, if the lifecycle 
of the array fetched from the resultset doesn’t spread too much, there isn’t 
any problem.

 

Besides that, I’ve got your points =). The “a.*” thing successfully beats the 
join problem.

 

One last point: “Of course there are occasions where the database is updated 
and breaks code, in which case specifying all the field names would potentially 
avoid that”, we should only declare in the SELECT clause fields we’re actually 
using along the script, and even if we go with the “*” way the code will broke 
eventually with schema changes.

 

Regards.

 

De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Enviada em: sábado, 22 de setembro de 2012 12:35
Para: Samuel Lopes Grigolato
Cc: 'PHP List'
Assunto: Re: RES: RES: [PHP] Re: Need help to understand a code

 

On Sat, 2012-09-22 at 12:12 -0300, Samuel Lopes Grigolato wrote: 

 
I disagree with you Ashley, some arguments can be found here: 
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/10/bad-habits-to-kick-using-select-omitting-the-column-list.aspx
 
Using explicit columns names in the select clause is, IMHO, at least a good 
documentation for what is being requested to the database layer.
 
+1 to Maciek's suggestion, had totally forgotten this one.
 
Cheers.
 
-Mensagem original-
De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Enviada em: sábado, 22 de setembro de 2012 11:52
Para: Samuel Lopes Grigolato; 'PHP List'
Assunto: Re: RES: [PHP] Re: Need help to understand a code
 
 
 
Samuel Lopes Grigolato samuel.grigol...@gmail.com wrote:
 
+1 to bad maintainability of the code.
 
As a suggestion, one better solution could be something like:
 
[...]
 
class Entity {
   public $id;
   public $name;
}
 
[...]
 
$entity = new Entity();
foreach [...]
  $entity-$$key = $value;
 
[...]
 
And, of course, never ever use * in SQL queries.
 
Samuel.
 
-Mensagem original-
De: Matijn Woudt [mailto:tijn...@gmail.com] Enviada em: sábado, 22 de 
setembro de 2012 11:02
Para: a...@ashleysheridan.co.uk
Cc: Ashickur Rahman Noor; PHP List
Assunto: Re: [PHP] Re: Need help to understand a code
 
Op 22 sep. 2012 13:47 schreef Ashley Sheridan
a...@ashleysheridan.co.uk het volgende:
 
 On Sat, 2012-09-22 at 17:43 +0600, Ashickur Rahman Noor wrote:
 
  Hi Ashley
 
  I am updating some one code. Thanks for the notify.
 
  Thanks to all. Now I get that.
  --
  Dedicated Linux Forum in Bangladesh http://goo.gl/238Ck
  2048R/89C932E1 http://goo.gl/TkP5U Coordinator - Public Relation 
  Cell, FOSS Bangladesh http://fossbd.org/  Mozilla Reps 
  http://reps.mozilla.org 01199151550, 01551151550
 
 
 It's probably fine doing that for your example, as the content coming
 
 from the database will be content you expect, but be wary of using it
 
 on any of the user-generated arrays like $_GET, or $_POST.
 
 
And a few months/years later you decide to add a new column to your db 
which has the same name as one of the variables you're already using 
and the script starts acting very strange...
People should stop using bad coding habits like these..
 
- Matijn
 
 
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php
 
there's nothing wrong with using * in queries.
 
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
 


There are plenty of times that you need all fields from a table though. I go by 
the rule that if I need less than two thirds of the fields of a table, then I 
specify the fields I need, otherwise, it's easier to go with *.

I've looked at the link you posted. The join issue is too broad. I use * with 
joins, but avoid the conflicts by specifying the table name, still going by the 
⅔ rule above on a table by table basis. Of course, if there are tables used in 
the join that are not necessary to the actual output, I won't include them in 
the list, but I may do something like this:

SELECT a.a, a.b, a.c, b.*
FROM a
LEFT JOIN a on a.a = b.a

I would say that if you're in the position of writing the queries then you 
should be aware of the database schema, so using the query as a form of 
documentation shouldn't be a factor. Of course there are occasions where the 
database is updated and breaks code, in which case specifying all the field 
names would potentially avoid that, but procedures should be in place which 
would at least make you aware of such updates to allow you to plan

[PHP] Re: Need Help in Yaf spreading

2012-08-20 Thread Laruence
CC to php-general.

thanks

On Mon, Aug 20, 2012 at 4:06 PM, Laruence larue...@php.net wrote:
 Hi:
 Yaf (http://pecl.php.net/yaf) is a PHP MVC framework,  which is
 build as a PHP extension.

 It could be considered as the fastest PHP framework for
 now(http://www.laruence.com/2011/12/02/2333.html),

 and it has already been used in a lots of productions in baidu,
 sina. like weibo.com.

 we gain 76% performance boost while refactor weibo.com based on
 yaf ( of course and some other improvements)

 so, I can say that Yaf is very popular in chinese world.  but it
 was a little hysteretic in english world.

 I asked for some help in sepreading Yaf in english world.  any
 recommends of Yaf (post, twitter, etc) will be appreciated.

 thanks

 --
 Laruence  Xinchen Hui
 http://www.laruence.com/



-- 
Laruence  Xinchen Hui
http://www.laruence.com/

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



[PHP] Re: Need to have form protection techniques

2012-08-17 Thread Jim Giner

On 8/17/2012 12:05 AM, Ansry User 01 wrote:

I need to know the forms validity techniques for Php.



Really?

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



[PHP] I need a good access and error log..

2012-05-07 Thread rene7705
Hi.

I've been using Google Analytics, and I'm sure I'm using the analytics
code correctly, but when I checked my dev server's apache access logs
(dozens of hits per day) against what Google Analytics reports (zip,
zero, nada), I realized I needed something different. BTW, I'm not the
only one to report this problem
(https://www.google.nl/search?aq=fsourceid=chromeie=UTF-8q=google+analytics+lower+number)

I thought of rolling something of my own, a PHP-MySQL based
access+error log, add a viewer for it (http://dygraphs.com/ perhaps),
and spend the next month perfecting it..
But before I start coding, I thought it would be better to ask you all
what you use to see who's visiting your sites and when.
Oh, I need something that will work on shared hosting (php+mysql).

Thanks for your input.

(and purists; I couldn't think of a better place to post this, as this
is a large community of web developers who use the same language as I
do. I may even end up writing an opensourced php logging facility for
you)

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



RE: [PHP] I need a good access and error log..

2012-05-07 Thread admin
-Original Message-
From: rene7705 [mailto:rene7...@gmail.com] 
Sent: Monday, May 07, 2012 3:00 AM
To: php-general
Subject: [PHP] I need a good access and error log..

Hi.

I've been using Google Analytics, and I'm sure I'm using the analytics code
correctly, but when I checked my dev server's apache access logs (dozens of
hits per day) against what Google Analytics reports (zip, zero, nada), I
realized I needed something different. BTW, I'm not the only one to report
this problem
(https://www.google.nl/search?aq=fsourceid=chromeie=UTF-8q=google+analyti
cs+lower+number)

I thought of rolling something of my own, a PHP-MySQL based
access+error log, add a viewer for it (http://dygraphs.com/ perhaps),
and spend the next month perfecting it..
But before I start coding, I thought it would be better to ask you all what
you use to see who's visiting your sites and when.
Oh, I need something that will work on shared hosting (php+mysql).

Thanks for your input.

(and purists; I couldn't think of a better place to post this, as this is a
large community of web developers who use the same language as I do. I may
even end up writing an opensourced php logging facility for
you)

--


I have seen and dealt with this for a few companies.
I have setup PHP scripting, JavaScript, Perl scripting you name it I have
tried it.
I have NEVER came up with the same number Google Analytics comes up with.
Sporadic behavior from Analytics not tied to a unique browser, OS or time.
Almost like random addition values are just added to the total for no
reason.

I like Google, but the numbers are not real!
When I can track each and every visit, site navigation and the numbers do
not match.
I asked Google for click by click information IP, Time and any other
information they could give me.
I never got that list to this day. Probably because it would allow me to
argue traffic that simply didn’t happen!

Suggestions when logging traffic, Avoid JavaScript that relies on the client
side to tell you information. Bad Idea!
Use php, perl or any server side language.
When logging information remember that apache/.NET process web request and
generally the best place to log.
It you log at the process you do not need to have scripting in each landing
page.
Log light information, never request overwhelming amounts of information for
each request you may cause horrid loading results.

PHP example (Just a simple example, there are many ways to do it)
Index.php
?php
$query = INSERT INTO click_log (`ip`,`action_time`) VALUES
('.$_SERVER['REMOTE_ADDR'].','.date(y-m-d H:i:s).') ;
$result = mysql_query($query);
?

I HIGHLY recommend you have a full understand of httaccess or web.config
before you attempt logging from them.
 

Rick









   


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



Re: [PHP] I need a good access and error log..

2012-05-07 Thread Lester Caine

rene7705 wrote:

But before I start coding, I thought it would be better to ask you all
what you use to see who's visiting your sites and when.
Oh, I need something that will work on shared hosting (php+mysql).


piwik ...
http://piwik.org/
A couple of my heavy google users are finding the results much more informative, 
and we have started switch google analytics off on all the sites.


( And while it says PHP MySQL I'm using it quite happily on Firebird :) )

--
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//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] I need a good access and error log..

2012-05-07 Thread Ashley Sheridan


Lester Caine les...@lsces.co.uk wrote:

rene7705 wrote:
 But before I start coding, I thought it would be better to ask you
all
 what you use to see who's visiting your sites and when.
 Oh, I need something that will work on shared hosting (php+mysql).

piwik ...
http://piwik.org/
A couple of my heavy google users are finding the results much more
informative,
and we have started switch google analytics off on all the sites.

( And while it says PHP MySQL I'm using it quite happily on Firebird :)
)

--
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//
Firebird - http://www.firebirdsql.org/index.php

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

Google analytics only tracks when javascript is enabled, so that could account 
for some of the discrepencies. It also uses cookies, which now have to be 
legally opted in by the user in the EU (unless they're vital to the 
functionality of the site, such as for shopping carts, etc)

I've rolled my own for these reasons. It's not perfect, but it does a pretty 
good job at tracking browsers and bits alike. I use the IP to track individual 
users; its not wholly accurate (people can share the IP in a given day), but it 
does the trick.

The key is using images to track. If javascript is enabled it can add extra 
info to the url. Obviously it won't work with images turned off, so I'll need 
to look at that soon too.

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

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



Re: [PHP] I need a good access and error log..

2012-05-07 Thread rene7705
On Mon, May 7, 2012 at 11:27 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:


 Lester Caine les...@lsces.co.uk wrote:

rene7705 wrote:
 But before I start coding, I thought it would be better to ask you
all
 what you use to see who's visiting your sites and when.
 Oh, I need something that will work on shared hosting (php+mysql).

piwik ...
http://piwik.org/
A couple of my heavy google users are finding the results much more
informative,
and we have started switch google analytics off on all the sites.

( And while it says PHP MySQL I'm using it quite happily on Firebird :)
)

--
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//
Firebird - http://www.firebirdsql.org/index.php

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

 Google analytics only tracks when javascript is enabled, so that could 
 account for some of the discrepencies. It also uses cookies, which now have 
 to be legally opted in by the user in the EU (unless they're vital to the 
 functionality of the site, such as for shopping carts, etc)

 I've rolled my own for these reasons. It's not perfect, but it does a pretty 
 good job at tracking browsers and bits alike. I use the IP to track 
 individual users; its not wholly accurate (people can share the IP in a given 
 day), but it does the trick.

 The key is using images to track. If javascript is enabled it can add extra 
 info to the url. Obviously it won't work with images turned off, so I'll need 
 to look at that soon too.

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

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


Thanks for the replies, everyone..

I'm going to roll my own as well.

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



Re: [PHP] I need a good access and error log..

2012-05-07 Thread ma...@behnke.biz


Lester Caine les...@lsces.co.uk hat am 7. Mai 2012 um 11:03 geschrieben:

 rene7705 wrote:
  But before I start coding, I thought it would be better to ask you all

 piwik ...
 http://piwik.org/
 A couple of my heavy google users are finding the results much more
informative,
 and we have started switch google analytics off on all the sites.

I can support this one too. I have been using for quite a few now. It
supports JS and NOSCRIPT.
And you can go from Track the visits up to campaign setups and so on.

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



[PHP] Re: Need Part-time Coder

2011-12-28 Thread Jonesy
On Tue, 27 Dec 2011 17:29:27 -0500, John R. Cornell II wrote:

 Email PHP sample for consideration

Thanks for (perhaps) the last LMAOROFL Posting of 2011!


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



[PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Micky Hulse
On Fri, May 27, 2011 at 10:27 AM, Micky Hulse
mickyhulse.li...@gmail.com wrote:
 Would it be safe for me to conclude that Pair is not setup properly?

Haha, Pear the package, not the host. :D

http://www.pair.com/

Typo. My bad.

Also, what the heck does this mean:

It is not safe to rely on the system's timezone settings. Please use
the date.timezone setting, the TZ environment variable or the
date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected 'America/New_York' for
'EDT/-4.0/DST' instead in /home/USER/public_html/test.php on line 6

Never seen that warning message before when including files... Like I
said, I know nothing about this host, but so far I am wondering if
they have things setup properly?

Thanks for listening.

Cheers,
Micky

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



Re: [PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Philip Thompson
On Fri, May 27, 2011 at 1:36 PM, Micky Hulse mickyhulse.li...@gmail.comwrote:

 On Fri, May 27, 2011 at 10:27 AM, Micky Hulse
 mickyhulse.li...@gmail.com wrote:
  Would it be safe for me to conclude that Pair is not setup properly?

 Haha, Pear the package, not the host. :D

 http://www.pair.com/

 Typo. My bad.

 Also, what the heck does this mean:

 It is not safe to rely on the system's timezone settings. Please use
 the date.timezone setting, the TZ environment variable or the
 date_default_timezone_set() function. In case you used any of those
 methods and you are still getting this warning, you most likely
 misspelled the timezone identifier. We selected 'America/New_York' for
 'EDT/-4.0/DST' instead in /home/USER/public_html/test.php on line 6


The host is apparently using PHP 5.3 - this message started to appear in
this version. Use date_default_timezone_set() somewhere in your code to
explicitly set your timezone. I'm in the central US, so I use
'America/Chicago'. See the docs for more info.

Not sure about your original question.

Happy coding,
~Philip

http://lonestarlightandsound.com/


Re: [PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Micky Hulse
On Fri, May 27, 2011 at 12:06 PM, Philip Thompson
philthath...@gmail.com wrote:
 The host is apparently using PHP 5.3 - this message started to appear in
 this version. Use date_default_timezone_set() somewhere in your code to
 explicitly set your timezone. I'm in the central US, so I use
 'America/Chicago'. See the docs for more info.

Thanks Philip! I will give that a try. :)

Testing now...

Nice! That helped! :)

date_default_timezone_set('America/Los_Angeles');

Now all I got to do is convince my friend that the host needs to add
Pear to the include path (at least, I think this is the problem with
Pear).

Thanks again Philip!

Have a great day.

Cheers,
Micky

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



Re: [PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Micky Hulse
Looks like the host changed my include path:

(include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/lib/php/PEAR')

I am still getting file not found include errors.

I am guess that Mail.php and Mail_Mime/mime.php are extras that are
not installed.

This is my first time trying to use Pear. Normally I use other code
for sending emails with attachments...

I think my friend setup an e-mail form using this tutorial:

http://www.html-form-guide.com/email-form/php-email-form-attachment.html

He could not get it to work, and I am just trying to get it to work for him.

I will probably ditch the whole Pear idea and use something else.

I hate working for free! :D

Thanks for listening all.. Sorry to bug the list with my crud.

Cheers,
Micky

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



Re: [PHP] Re: Need pro advice: Is Pear installed and/or setup correctly?

2011-05-27 Thread Micky Hulse
On Fri, May 27, 2011 at 12:48 PM, Micky Hulse rgmi...@gmail.com wrote:
 Looks like the host changed my include path:
 I will probably ditch the whole Pear idea and use something else.

Well, actually, it looks like having PEAR on the include path did help.

Mail.php was found... It was Mail_Mime/mime.php that was not getting found.

This seems totally hackish, but I had to download Mail_Mime and put it
in the web root of my friend's server:

http://pear.php.net/package/Mail_Mime/download

And changed the Mail_Mime include path to point to the new location
and it worked.

What a headache. Lol.

Problem solved. Thanks for the help Philip, and thanks for listening all!

Have a nice day.

Cheers,
Micky

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



[PHP] i need delay time in doing array_key_exists but while(true) can't work 4 it.

2011-05-20 Thread Negin Nickparsa
===if(array_key_exists('sub5',$_POST))
this line runs before i clicked on the submit
while(true) before this line can't work then how can i solve the time
problem?
here is the whole code:
?php
session_start();

$connection=Mysql_connect('localhost','admin','123');
if(array_key_exists('sub3',$_POST))
{


if(!$connection)
{
echo 'connection is invalid';
}
else
{
Mysql_select_db('drugnet',$connection);
$query=select * from patient;
$result=mysql_query($query);
$num=Mysql_num_rows($result);
$num1=Mysql_num_fields($result);
}
if($num0)
{
echo table border=2;
for($i=0;$i$num;$i++)
{
$row=mysql_fetch_row($result);
echo tr;
for($j=0;$j$num1;$j++)
{
echotd$row[$j]/td;
}
echotdinput type='submit' name='sub5' value='patient
file$row[0]'//td;
echo/tr;
}
echo/table;
}
}
if(array_key_exists('sub5',$_POST))
{
$_SESSION[s1]=$row[0];
header(Location: patient.php?);
}
?
html
head
titleDoctor/title
form method=post
input type=submit name=sub3 value=patient list/
input type=submit name=sub4 value=search patient/

/form
/head
/html


Re: [PHP] i need delay time in doing array_key_exists but while(true) can't work 4 it.

2011-05-20 Thread Jim Lucas
Negin,

You cannot pause PHP.  You need to do your checking and header() redirect on a
processing page that your form is submitting to.

file   process
form.php   Displays form
process.phpdecide what to you, redirect to secondary page
secondary.php  display your secondary page


On 5/20/2011 7:54 AM, Negin Nickparsa wrote:
 ===if(array_key_exists('sub5',$_POST))
 this line runs before i clicked on the submit
 while(true) before this line can't work then how can i solve the time
 problem?
 here is the whole code:
 ?php
 session_start();
 
 $connection=Mysql_connect('localhost','admin','123');
 if(array_key_exists('sub3',$_POST))
 {
 
 
 if(!$connection)
 {
 echo 'connection is invalid';
 }
 else
 {
 Mysql_select_db('drugnet',$connection);
 $query=select * from patient;
 $result=mysql_query($query);
 $num=Mysql_num_rows($result);
 $num1=Mysql_num_fields($result);
 }
 if($num0)
 {
 echo table border=2;
 for($i=0;$i$num;$i++)
 {
 $row=mysql_fetch_row($result);
 echo tr;
 for($j=0;$j$num1;$j++)
 {
 echotd$row[$j]/td;
 }
 echotdinput type='submit' name='sub5' value='patient
 file$row[0]'//td;
 echo/tr;
 }
 echo/table;
 }
 }
 if(array_key_exists('sub5',$_POST))
 {
 $_SESSION[s1]=$row[0];
 header(Location: patient.php?);
 }
 ?
 html
 head
 titleDoctor/title
 form method=post
 input type=submit name=sub3 value=patient list/
 input type=submit name=sub4 value=search patient/
 
 /form
 /head
 /html
 


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



Re: [PHP] i need delay time in doing array_key_exists but while(true) can't work 4 it.

2011-05-20 Thread Negin Nickparsa
i can't understand what u wanted to tell me.
i want to when clicking on the sub button then go to another page i wrote it
but i can't solve this problem:
php runs the code and then i click it
i don't know,how can i solve it

any suggestion?


Re: [PHP] i need delay time in doing array_key_exists but while(true) can't work 4 it.

2011-05-20 Thread Negin Nickparsa
the thing that is important to me is setting session
because i want the tables of the one that clicked be showed on patient.php
how can i change my wrong code?


Re: [PHP] i need delay time in doing array_key_exists but while(true) can't work 4 it.

2011-05-20 Thread Ashley Sheridan
On Fri, 2011-05-20 at 19:46 +0430, Negin Nickparsa wrote:

 the thing that is important to me is setting session
 because i want the tables of the one that clicked be showed on patient.php
 how can i change my wrong code?


You have to realise that PHP code runs on the server, all before it
sends the output to your browser. A basic example works like this:


 1. You request a page in your browser by typing in the URL
 2. The server receives this request
 3. The server then does whatever processing is in the script
(assuming you requested a .php file) and it is the script which
is responsible for your HTML output
 4. The web server sends this output back to your browser


If you need things to be run on the server as a result of you doing
something in your browser, then you need to either trigger some sort of
page refresh or new page request, or use Javascript to make a series of
AJAX requests.

PHP code isn't run in your browser, and it knows nothing about what you
do in it. For that, you need a client-side language such as Javascript.

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




[PHP] Re: Need code like pastebin.org

2010-12-27 Thread Michelle Konzack
Hello Daniel P. Brown,

Am 2010-12-27 12:11:46, hacktest Du folgendes herunter:
 Sure, you can just download the actual PasteBin script from the
 original author.  It's GPL'd, and you can grab it here:
 
 http://links.parasane.net/42ez

Realy cool!  Thankyou!

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsyst...@tdnet France EURL   itsyst...@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

http://www.itsystems.tamay-dogan.net/  http://www.flexray4linux.org/
http://www.debian.tamay-dogan.net/ http://www.can4linux.org/

Jabber linux4miche...@jabber.ccc.de
ICQ#328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


[PHP] Re: Need code like pastebin.org

2010-12-27 Thread Michelle Konzack
Hello Daniel P. Brown,

Am 2010-12-27 12:11:46, hacktest Du folgendes herunter:
 Sure, you can just download the actual PasteBin script from the
 original author.  It's GPL'd, and you can grab it here:
 
 http://links.parasane.net/42ez

OK, installed and it works  ;-)  but it seems, there are many  thing  to
do to get it running like on pastebin.com, like  public/private  and
pgsql support or  e-mail  input  and  links_emailer.php.  Also  my
version must work over two physical servers.

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsyst...@tdnet France EURL   itsyst...@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

http://www.itsystems.tamay-dogan.net/  http://www.flexray4linux.org/
http://www.debian.tamay-dogan.net/ http://www.can4linux.org/

Jabber linux4miche...@jabber.ccc.de
ICQ#328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


[PHP] Re: Need code like pastebin.org

2010-12-27 Thread Michelle Konzack
Hello Daniel P. Brown,

Am 2010-12-27 12:11:46, hacktest Du folgendes herunter:
 Sure, you can just download the actual PasteBin script from the
 original author.  It's GPL'd, and you can grab it here:
 
 http://links.parasane.net/42ez

OK, I was a little bit working on it, but a  GPLed  code  which  include
AdWords and GoogleAnalytics is already suspect.

Then the whole code is spagetti...

And I do not know what Paul was smoking, when he has written layout.php.

It I want to adapt the code for my webste I can   recode  anything  from
scratch.

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
# Debian GNU/Linux Consultant ##
   Development of Intranet and Embedded Systems with Debian GNU/Linux

itsyst...@tdnet France EURL   itsyst...@tdnet UG (limited liability)
Owner Michelle KonzackOwner Michelle Konzack

Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France   77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix

http://www.itsystems.tamay-dogan.net/  http://www.flexray4linux.org/
http://www.debian.tamay-dogan.net/ http://www.can4linux.org/

Jabber linux4miche...@jabber.ccc.de
ICQ#328449886

Linux-User #280138 with the Linux Counter, http://counter.li.org/


signature.pgp
Description: Digital signature


Re: [PHP] Re: Need code like pastebin.org

2010-12-27 Thread Daniel P. Brown
On Mon, Dec 27, 2010 at 19:51, Michelle Konzack
linux4miche...@tamay-dogan.net wrote:

 OK, I was a little bit working on it, but a  GPLed  code  which  include
 AdWords and GoogleAnalytics is already suspect.

 Then the whole code is spagetti...

 And I do not know what Paul was smoking, when he has written layout.php.

 It I want to adapt the code for my webste I can   recode  anything  from
 scratch.

I didn't evaluate the code, I merely did a single two-second
Google search, as I presumed you'd already done yourself.

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-24 Thread Rico Secada
On Thu, 21 Oct 2010 10:55:14 -0400
Paul M Foster pa...@quillandmouse.com wrote:

 On Thu, Oct 21, 2010 at 04:05:50AM +0200, Rico Secada wrote:
 
  Hi.
  
  I am working on a small system where I am both trying to avoid code
  duplication and at the same time I am trying to keep the
  presentation logic separated from the application logic.
  
  I am using sessions and are avoiding headers already sent problem
  by keeping the HTML out of the application.
  
  For example, I would like to have a common header.php file, but it
  is difficult to create this since one file needs to have some
  specific Javascript located in the head /head tags, but the
  other files doesn't need this.
  
  Another file needs to have a specific onload call in the body
  tag, while yet another file also needs to have an onload call,
  but with different attributes.
  
  I have been looking around in other systems to see what kinds of
  solutions are being used - as inspiration.
  
  I have been thinking about the following solutions:
  
  1. Create only ONE header.php file that contains a lot of
  conditionals depending on what file is including it - the output of
  HTML/Javascript changes.
  
  I believe this would turn into a very ugly hack. Difficult to
  maintain.
 
 Not really. Here's what I do. I have a page controller which defines
 variables and such, and then calls the header.php file. The page
 controller will contain something like this:
 
 $meta['jsfiles'] = 'onload.js';
 
 The header.php will contain code like this:
 
 ?php if (!empty($meta['jsfiles'])): ?
 ?php include $meta['jsfiles']; ?
 ?php endif; ?
 
 The page controller can also contain a variety of other settings,
 like:
 
 $meta['content'] = 'cust_add.php';
 
 and the header.php will contain:
 
 ?php include $meta['content']; ?
 
 This directs the proper internal content for the header.php, which is
 really like a template file.
 
 Also remember that at the bottom of the page controller, you do a like
 like this:
 
 include 'header.php';
 
 You can change this as you like for any given page controller.
 
 Paul
 
 -- 
 Paul M. Foster

Thanks Paul! It's a nice way to do it.

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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-21 Thread Peter Lind
On 21 October 2010 04:59, David McGlone da...@dmcentral.net wrote:
 On Thu, 2010-10-21 at 04:05 +0200, Rico Secada wrote:
 Hi.

 I am working on a small system where I am both trying to avoid code
 duplication and at the same time I am trying to keep the presentation
 logic separated from the application logic.

 I am using sessions and are avoiding headers already sent problem by
 keeping the HTML out of the application.

 For example, I would like to have a common header.php file, but it is
 difficult to create this since one file needs to have some specific
 Javascript located in the head /head tags, but the other files
 doesn't need this.

 Another file needs to have a specific onload call in the body tag,
 while yet another file also needs to have an onload call, but with
 different attributes.

 I have been looking around in other systems to see what kinds of
 solutions are being used - as inspiration.

 I have been thinking about the following solutions:

 1. Create only ONE header.php file that contains a lot of conditionals
 depending on what file is including it - the output of HTML/Javascript
 changes.

 I believe this would turn into a very ugly hack. Difficult to maintain.

 2. Create a HTML generating class with a set of methods that each
 contains an adequate amount of parameters. Each method maintains its
 own HTML tag. For example, docType($type) would generate the doctype
 specification.

 I believe this is a cleaner solution, but the problem with code
 duplication isn't avoided.

 Some of the presentation logic contains conditionals and the HTML
 changes when the conditional changes, hence the header content changes,
 but the doctype, html, and head doesn't necessarily change and
 they would get duplicated a couple of times in some files.

 3. Avoid the problem all together, use output buffering and completely
 forget about separation between application and presentation.

 I hope I make sense.

 Any thoughts on these kinds of problems?

 sounds like a job for smarty http://www.smarty.net/

 I've used smarty and it's nice.


How does Smarty solve this problem? Just curious.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-21 Thread a...@ashleysheridan.co.uk
Bit late to this one, but what about an mvc framework like codeigniter? It's 
perfectly acceptable to use if statements and loops in the view, which would 
solve your problem. You can set a trigger variable in the controller, and in 
the header view, check to see if its set and output your javascript lines as 
appropriate.

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

- Reply message -
From: Peter Lind peter.e.l...@gmail.com
Date: Thu, Oct 21, 2010 07:01
Subject: [PHP] I need some thoughts on code duplication and separation
To: David McGlone da...@dmcentral.net
Cc: php-general@lists.php.net


On 21 October 2010 04:59, David McGlone da...@dmcentral.net wrote:
 On Thu, 2010-10-21 at 04:05 +0200, Rico Secada wrote:
 Hi.

 I am working on a small system where I am both trying to avoid code
 duplication and at the same time I am trying to keep the presentation
 logic separated from the application logic.

 I am using sessions and are avoiding headers already sent problem by
 keeping the HTML out of the application.

 For example, I would like to have a common header.php file, but it is
 difficult to create this since one file needs to have some specific
 Javascript located in the head /head tags, but the other files
 doesn't need this.

 Another file needs to have a specific onload call in the body tag,
 while yet another file also needs to have an onload call, but with
 different attributes.

 I have been looking around in other systems to see what kinds of
 solutions are being used - as inspiration.

 I have been thinking about the following solutions:

 1. Create only ONE header.php file that contains a lot of conditionals
 depending on what file is including it - the output of HTML/Javascript
 changes.

 I believe this would turn into a very ugly hack. Difficult to maintain.

 2. Create a HTML generating class with a set of methods that each
 contains an adequate amount of parameters. Each method maintains its
 own HTML tag. For example, docType($type) would generate the doctype
 specification.

 I believe this is a cleaner solution, but the problem with code
 duplication isn't avoided.

 Some of the presentation logic contains conditionals and the HTML
 changes when the conditional changes, hence the header content changes,
 but the doctype, html, and head doesn't necessarily change and
 they would get duplicated a couple of times in some files.

 3. Avoid the problem all together, use output buffering and completely
 forget about separation between application and presentation.

 I hope I make sense.

 Any thoughts on these kinds of problems?

 sounds like a job for smarty http://www.smarty.net/

 I've used smarty and it's nice.


How does Smarty solve this problem? Just curious.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-21 Thread Paul M Foster
On Thu, Oct 21, 2010 at 04:05:50AM +0200, Rico Secada wrote:

 Hi.
 
 I am working on a small system where I am both trying to avoid code
 duplication and at the same time I am trying to keep the presentation
 logic separated from the application logic.
 
 I am using sessions and are avoiding headers already sent problem by
 keeping the HTML out of the application.
 
 For example, I would like to have a common header.php file, but it is
 difficult to create this since one file needs to have some specific
 Javascript located in the head /head tags, but the other files
 doesn't need this.
 
 Another file needs to have a specific onload call in the body tag,
 while yet another file also needs to have an onload call, but with
 different attributes.
 
 I have been looking around in other systems to see what kinds of
 solutions are being used - as inspiration.
 
 I have been thinking about the following solutions:
 
 1. Create only ONE header.php file that contains a lot of conditionals
 depending on what file is including it - the output of HTML/Javascript
 changes.
 
 I believe this would turn into a very ugly hack. Difficult to maintain.

Not really. Here's what I do. I have a page controller which defines
variables and such, and then calls the header.php file. The page
controller will contain something like this:

$meta['jsfiles'] = 'onload.js';

The header.php will contain code like this:

?php if (!empty($meta['jsfiles'])): ?
?php include $meta['jsfiles']; ?
?php endif; ?

The page controller can also contain a variety of other settings, like:

$meta['content'] = 'cust_add.php';

and the header.php will contain:

?php include $meta['content']; ?

This directs the proper internal content for the header.php, which is
really like a template file.

Also remember that at the bottom of the page controller, you do a like
like this:

include 'header.php';

You can change this as you like for any given page controller.

Paul

-- 
Paul M. Foster

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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-21 Thread David McGlone
On Thu, 2010-10-21 at 08:01 +0200, Peter Lind wrote:
 On 21 October 2010 04:59, David McGlone da...@dmcentral.net wrote:
  On Thu, 2010-10-21 at 04:05 +0200, Rico Secada wrote:
  Hi.
 
  I am working on a small system where I am both trying to avoid code
  duplication and at the same time I am trying to keep the presentation
  logic separated from the application logic.
 
  I am using sessions and are avoiding headers already sent problem by
  keeping the HTML out of the application.
 
  For example, I would like to have a common header.php file, but it is
  difficult to create this since one file needs to have some specific
  Javascript located in the head /head tags, but the other files
  doesn't need this.
 
  Another file needs to have a specific onload call in the body tag,
  while yet another file also needs to have an onload call, but with
  different attributes.
 
  I have been looking around in other systems to see what kinds of
  solutions are being used - as inspiration.
 
  I have been thinking about the following solutions:
 
  1. Create only ONE header.php file that contains a lot of conditionals
  depending on what file is including it - the output of HTML/Javascript
  changes.
 
  I believe this would turn into a very ugly hack. Difficult to maintain.
 
  2. Create a HTML generating class with a set of methods that each
  contains an adequate amount of parameters. Each method maintains its
  own HTML tag. For example, docType($type) would generate the doctype
  specification.
 
  I believe this is a cleaner solution, but the problem with code
  duplication isn't avoided.
 
  Some of the presentation logic contains conditionals and the HTML
  changes when the conditional changes, hence the header content changes,
  but the doctype, html, and head doesn't necessarily change and
  they would get duplicated a couple of times in some files.
 
  3. Avoid the problem all together, use output buffering and completely
  forget about separation between application and presentation.
 
  I hope I make sense.
 
  Any thoughts on these kinds of problems?
 
  sounds like a job for smarty http://www.smarty.net/
 
  I've used smarty and it's nice.
 
 
 How does Smarty solve this problem? Just curious.

from what I understood from his post He mentions he wants to separate
the application and presentation, code duplication is avoided and it's a
cleaner solution and #2 above sounds like he's describing a smarty
template.

I'm not 100% positive it will help him completely, but it does do a lot
of the things he mentions.



-- 
Blessings,
David M.


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



[PHP] I need some thoughts on code duplication and separation

2010-10-20 Thread Rico Secada
Hi.

I am working on a small system where I am both trying to avoid code
duplication and at the same time I am trying to keep the presentation
logic separated from the application logic.

I am using sessions and are avoiding headers already sent problem by
keeping the HTML out of the application.

For example, I would like to have a common header.php file, but it is
difficult to create this since one file needs to have some specific
Javascript located in the head /head tags, but the other files
doesn't need this.

Another file needs to have a specific onload call in the body tag,
while yet another file also needs to have an onload call, but with
different attributes.

I have been looking around in other systems to see what kinds of
solutions are being used - as inspiration.

I have been thinking about the following solutions:

1. Create only ONE header.php file that contains a lot of conditionals
depending on what file is including it - the output of HTML/Javascript
changes.

I believe this would turn into a very ugly hack. Difficult to maintain.

2. Create a HTML generating class with a set of methods that each
contains an adequate amount of parameters. Each method maintains its
own HTML tag. For example, docType($type) would generate the doctype
specification.

I believe this is a cleaner solution, but the problem with code
duplication isn't avoided.

Some of the presentation logic contains conditionals and the HTML
changes when the conditional changes, hence the header content changes,
but the doctype, html, and head doesn't necessarily change and
they would get duplicated a couple of times in some files.

3. Avoid the problem all together, use output buffering and completely
forget about separation between application and presentation.

I hope I make sense.

Any thoughts on these kinds of problems?

Best regards.


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



Re: [PHP] I need some thoughts on code duplication and separation

2010-10-20 Thread David McGlone
On Thu, 2010-10-21 at 04:05 +0200, Rico Secada wrote:
 Hi.
 
 I am working on a small system where I am both trying to avoid code
 duplication and at the same time I am trying to keep the presentation
 logic separated from the application logic.
 
 I am using sessions and are avoiding headers already sent problem by
 keeping the HTML out of the application.
 
 For example, I would like to have a common header.php file, but it is
 difficult to create this since one file needs to have some specific
 Javascript located in the head /head tags, but the other files
 doesn't need this.
 
 Another file needs to have a specific onload call in the body tag,
 while yet another file also needs to have an onload call, but with
 different attributes.
 
 I have been looking around in other systems to see what kinds of
 solutions are being used - as inspiration.
 
 I have been thinking about the following solutions:
 
 1. Create only ONE header.php file that contains a lot of conditionals
 depending on what file is including it - the output of HTML/Javascript
 changes.
 
 I believe this would turn into a very ugly hack. Difficult to maintain.
 
 2. Create a HTML generating class with a set of methods that each
 contains an adequate amount of parameters. Each method maintains its
 own HTML tag. For example, docType($type) would generate the doctype
 specification.
 
 I believe this is a cleaner solution, but the problem with code
 duplication isn't avoided.
 
 Some of the presentation logic contains conditionals and the HTML
 changes when the conditional changes, hence the header content changes,
 but the doctype, html, and head doesn't necessarily change and
 they would get duplicated a couple of times in some files.
 
 3. Avoid the problem all together, use output buffering and completely
 forget about separation between application and presentation.
 
 I hope I make sense.
 
 Any thoughts on these kinds of problems?

sounds like a job for smarty http://www.smarty.net/

I've used smarty and it's nice.

-- 
Blessings
David M.


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



RE: [PHP] I need some thoughts on code duplication and separation

2010-10-20 Thread Tommy Pham
 -Original Message-
 From: David McGlone [mailto:da...@dmcentral.net]
 Sent: Wednesday, October 20, 2010 7:59 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] I need some thoughts on code duplication and separation
 
 On Thu, 2010-10-21 at 04:05 +0200, Rico Secada wrote:
  Hi.
 
  I am working on a small system where I am both trying to avoid code
  duplication and at the same time I am trying to keep the presentation
  logic separated from the application logic.
 
  I am using sessions and are avoiding headers already sent problem by
  keeping the HTML out of the application.
 
  For example, I would like to have a common header.php file, but it is
  difficult to create this since one file needs to have some specific
  Javascript located in the head /head tags, but the other files
  doesn't need this.
 
  Another file needs to have a specific onload call in the body tag,
  while yet another file also needs to have an onload call, but with
  different attributes.
 
  I have been looking around in other systems to see what kinds of
  solutions are being used - as inspiration.
 
  I have been thinking about the following solutions:
 
  1. Create only ONE header.php file that contains a lot of conditionals
  depending on what file is including it - the output of HTML/Javascript
  changes.
 
  I believe this would turn into a very ugly hack. Difficult to maintain.
 
  2. Create a HTML generating class with a set of methods that each
  contains an adequate amount of parameters. Each method maintains its
  own HTML tag. For example, docType($type) would generate the doctype
  specification.
 
  I believe this is a cleaner solution, but the problem with code
  duplication isn't avoided.
 
  Some of the presentation logic contains conditionals and the HTML
  changes when the conditional changes, hence the header content
  changes, but the doctype, html, and head doesn't necessarily
  change and they would get duplicated a couple of times in some files.
 
  3. Avoid the problem all together, use output buffering and completely
  forget about separation between application and presentation.
 
  I hope I make sense.
 
  Any thoughts on these kinds of problems?
 
 sounds like a job for smarty http://www.smarty.net/
 
 I've used smarty and it's nice.
 
 --
 Blessings
 David M.
 
 

Thanks David!  I was looking for something like that too!

Regards,
Tommy


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



[PHP] I need me a Good Book for PHP

2010-07-19 Thread Joce Jovanov
Hello,

I work only 6 mouth with PHP, and now star to like more and more. Do you
someone know samo good books (tutorials) for PHP and MySQL.
 Thanks

Best Regard
Jovanov Jordan


Re: [PHP] I need me a Good Book for PHP

2010-07-19 Thread Shreyas Agasthya
Joce,

6 mouth? I assume it's months. :)
You can choose Head First with PHP and MySQL. Very good and I am currently
learning form it; I am no veteran with the language but it's AWESOME.

Also, good to know (for the PHP-veterans) will be :

1. Why are you learning PHP?
2. How do you plan to put your learning to usage?
3. Any specific things that you want to achieve from PHP?

Regards,
Shreyas

On Mon, Jul 19, 2010 at 9:24 PM, Joce Jovanov jovanovj...@gmail.com wrote:

 Hello,

 I work only 6 mouth with PHP, and now star to like more and more. Do you
 someone know samo good books (tutorials) for PHP and MySQL.
  Thanks

 Best Regard
 Jovanov Jordan




-- 
Regards,
Shreyas Agasthya


Re: [PHP] I need me a Good Book for PHP

2010-07-19 Thread rehmanms
I think php manual is one of the best thing to learn php

--
Shafiq
http://shafiq.pk
--Original Message--
From: Joce Jovanov
To: php-general@lists.php.net
Subject: [PHP] I need me a Good Book for PHP
Sent: Jul 19, 2010 8:54 PM

Hello,

I work only 6 mouth with PHP, and now star to like more and more. Do you
someone know samo good books (tutorials) for PHP and MySQL.
 Thanks

Best Regard
Jovanov Jordan



*** This Message Has Been Sent Using BlackBerry Internet Service from Mobilink 
***

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



RE: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-12 Thread Daevid Vincent
 

 -Original Message-
 From: tedd [mailto:tedd.sperl...@gmail.com] 
 Sent: Thursday, May 06, 2010 9:06 AM
 To: Daevid Vincent; php-general@lists.php.net
 Subject: RE: [PHP] In need of CVS/SVN checkout script for 
 Production servers [solved]
 
 At 5:43 PM -0700 5/5/10, Daevid Vincent wrote:
-Original Message-
From: tedd [mailto:tedd.sperl...@gmail.com]
Sent: Wednesday, May 05, 2010 8:19 AM
To: Daevid Vincent; php-general@lists.php.net
Subject: RE: [PHP] In need of CVS/SVN checkout script for
   -snip- stuff which fell on deaf ears
   
tedd
 
 *sigh* once again you people focus on something S off 
 topic compared to
 the meat of the thread -- which is a production repository 
 checkout script.
 
 Let me get this right -- you created a repository for people to 
 check-out/deposit scripts, but then deny some people access because 
 of their choice of browser? That seems counter productive. Do your 
 scripts only work for certain browsers?

No. I created a little miniscule dumping ground for some useful scripts *I*
use, and if someone else can use them, then feel free. I don't support
them. I don't even pretend to maintain them once posted. They are what they
are.

 ---
 
 As for my site.
 
 [*] I really don't care about the fringe browsers...
 
 That obvious. But what happens when your client's do care?

I make 6+ figures and have so for years. I'm not a freelancer. My
experience, networking and resume get me jobs, not my home page. I don't
have clients.

 ---
 
  Give me a break man. I've got more important things to do.
 
 Let me get this right --  it's more important to do something else 
 than to fix something you did wrong? If you're gong to take the time 
 to do something, then why not do it right? Remember, this is an 
 example of *your* work.

No. Examples of my work are what I get PAID for. This is simply a
personal page and a hobby.

 I spend a lot of my time making my code as good as I can get it, not 
 because of clients, or what others might think, but because of me. 
 It's a personal choice of mine to always learn and improve. If you 
 allow I've got more important things to do altitude to excuse bad 
 code, then you are only hurting yourself in the long run. I think you 
 know that.
 
 ---
 
 [*] Honestly, I also dislike Apple. I think it's stupid for 
 them to make a
 browser. I think they make crappy products.
 
 LOL!
 
 So you think that M$ makes better stuff, like IE6? Even Apple's worst 
 browser was better than that!

Yes I do. I won't get into an OS war with you though.

XP is the best OS thus far. Everything in the world supports it. It is
stable and fast. 

As for browser, I use FF for developing (mostly for Firebug) and some
flavor of IE (usually all three to test with) as that is what most people
still use. IE6 is still the standard default browser Panasonic uses (that's
5000 users alone). Many other large enterprise companies also stick with
XP/IE6. Only slowly are they migrating to IE8.

 ---
 
 As for CSS, inline styles, separation of logic, and all that 
 other stuff
 you ASSUME I don't use -- you are very wrong. I just happen 
 to use a lot of
 PHP to dynamically create various parts.
 
 I'm not ASSUMING anything -- it's a fact the site you provided 
 doesn't follow said practices.
 
 Additionally, you seem to be blaming PHP for the bad code but the 
 fact is you're just being lazy. Many of my sites are dynamically 
 created via PHP but still generate good code. One doesn't exclude the 
 other.

Not blaming at all. Just saying that while you see inline JS or CSS, it's
actually not as it appears. Some of that is generated in routines or loops.

 The point is that you want us to go to your site to check-out/provide 
 scripts, but the site you provided reeks of bad code. That's a bit 
 like a dinner saying Don't mind the dirty silverware, just eat the 
 food.

No. I don't want you to do anything. I offered up some free code. Take it
or leave it. If you want it, then the least you can do is use the required
browsers (which mostly everyone has already installed) to get to it. In
fact, if you're such a die-hard Safari user, just change your USER_AGENT
string and it will probably work. No sweat off my balls if you don't.

 ---
 
 In some cases I inline styles where they are used one time or used 
 in a PHP function.
 
 Okay, then why not learn how to do it right? Using a validator can 
 help you improve your code. Standards are not just for an elite group 
 of people but rather to improve overall coding practices. What's 
 wrong with that? Validation is giving you the opportunity to 
 critically review your code.
 

What part about coded 4 years ago don't you understand?

 ---
 
 If I had to choose between my
 daevid.com site and one of the three you (presumably) 
 illustrate as beacons
 of the way to do it (http://sperling.com  http://ancientstones.com
 http

Re: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-06 Thread David Otton
On 6 May 2010 04:14, Adam Richardson simples...@gmail.com wrote:

 Daevid asked the list for a an app that facilitated SVN/CVS, and when nobody
 provided options, he crafted a solution of his own and then offered it back
 to the list.

Er... I suggested Phing. Phing/Ant/Gradle/Maven/Capistrano... a build
tool is the standard solution here, and there are about a million of
them (http://en.wikipedia.org/wiki/List_of_build_automation_software).
I can't believe people are seriously discussing rolling your own when
all those mature tools are sitting right there.

Did my post not get through or something?

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



RE: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-06 Thread tedd

At 5:43 PM -0700 5/5/10, Daevid Vincent wrote:

  -Original Message-
  From: tedd [mailto:tedd.sperl...@gmail.com]
  Sent: Wednesday, May 05, 2010 8:19 AM
  To: Daevid Vincent; php-general@lists.php.net
  Subject: RE: [PHP] In need of CVS/SVN checkout script for
 -snip- stuff which fell on deaf ears
 
  tedd

*sigh* once again you people focus on something S off topic compared to
the meat of the thread -- which is a production repository checkout script.


Let me get this right -- you created a repository for people to 
check-out/deposit scripts, but then deny some people access because 
of their choice of browser? That seems counter productive. Do your 
scripts only work for certain browsers?


---


As for my site.

[*] I really don't care about the fringe browsers...


That obvious. But what happens when your client's do care?

---


Give me a break man. I've got more important things to do.


Let me get this right --  it's more important to do something else 
than to fix something you did wrong? If you're gong to take the time 
to do something, then why not do it right? Remember, this is an 
example of *your* work.


I spend a lot of my time making my code as good as I can get it, not 
because of clients, or what others might think, but because of me. 
It's a personal choice of mine to always learn and improve. If you 
allow I've got more important things to do altitude to excuse bad 
code, then you are only hurting yourself in the long run. I think you 
know that.


---


[*] Honestly, I also dislike Apple. I think it's stupid for them to make a
browser. I think they make crappy products.


LOL!

So you think that M$ makes better stuff, like IE6? Even Apple's worst 
browser was better than that!


---


As for CSS, inline styles, separation of logic, and all that other stuff
you ASSUME I don't use -- you are very wrong. I just happen to use a lot of
PHP to dynamically create various parts.


I'm not ASSUMING anything -- it's a fact the site you provided 
doesn't follow said practices.


Additionally, you seem to be blaming PHP for the bad code but the 
fact is you're just being lazy. Many of my sites are dynamically 
created via PHP but still generate good code. One doesn't exclude the 
other.


The point is that you want us to go to your site to check-out/provide 
scripts, but the site you provided reeks of bad code. That's a bit 
like a dinner saying Don't mind the dirty silverware, just eat the 
food.


---

In some cases I inline styles where they are used one time or used 
in a PHP function.


Okay, then why not learn how to do it right? Using a validator can 
help you improve your code. Standards are not just for an elite group 
of people but rather to improve overall coding practices. What's 
wrong with that? Validation is giving you the opportunity to 
critically review your code.


---


If I had to choose between my
daevid.com site and one of the three you (presumably) illustrate as beacons
of the way to do it (http://sperling.com  http://ancientstones.com
http://earthstones.com), then I would take my site any day of the week.


Go ahead -- but many people won't -- as shown by your site's NULL 
Google PageRank.


At least my sites have traffic. For example, according to today's 
Google Analyitics report during the last 30 days my sperling.com site 
has received 5970 unique visitors -- I'll take *that* any day of the 
week over shutting people out.


Daevid -- after all is said and done, I know you are better than 
this. I'm not sure why you are arguing the point.


Cheers,

tedd

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

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



RE: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-05 Thread tedd

At 1:10 PM -0700 5/4/10, Daevid Vincent wrote:

Well, here is the one I'm using. I ended up just writing one (again!)

http://www.daevid.com/content/examples/snippets.php :: Production
Deployment Script


What?!?

Advanced features??

I know you don't mean it, but you certainly know how to piss people 
off. You are not going to like what I have to say, but please accept 
the following as constructive criticism with no personal intent meant.


The site fails W3C CSS validation with 96 errors.

The site fails W3C HTML validation with 92 errors and 9 warnings.

I have not run into a site like this since before the turn of this 
century where we had browser wars. The problem isn't just with my 
browser, but many more as you can see here:


http://www.browsercam.com/public.aspx?proj_id=516739

The page (not addressing the entire site) is riddled with embedded 
javascript and embedded styling both of which are considered bad from.


I haven't even addressed accessibility, graceful degradation, or 
separation of content from presentation from behavior all of which 
are the goals of best practices sites -- and all of which this site 
fails miserably.


My advice, which I realize that you didn't ask for, is if you want to 
provide something of substance, then do so for all and not just the 
privileged elite who think they are the leading edge with this type 
of gimmick nonsense. This site is a step backward into the old 
browser wars.


Of course, I could tell you what I really think, but I don't want to 
be too abrasive. :-)


Cheers,

tedd

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

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



Re: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-05 Thread Michiel Sikma
On 5 May 2010 17:18, tedd tedd.sperl...@gmail.com wrote:

 At 1:10 PM -0700 5/4/10, Daevid Vincent wrote:

 Well, here is the one I'm using. I ended up just writing one (again!)

 http://www.daevid.com/content/examples/snippets.php :: Production
 Deployment Script


 What?!?

 Advanced features??
 -snip-



Just want to add my +1 to this. I'm running Safari, which most definitely
will support whatever advanced features you put in there, and I'm being
blocked. Putting aside the level of standards compliance of your site, you
really should blacklist browsers instead of whitelisting them. Sites should
never become inaccessible if your browser lacks features, and even if the
entire site revolves around some fancy Javascript, you should at least
provide a go ahead at your own risk link in case you're accidentally
shutting out the wrong browser.

Here's an example from a site I made a while ago which mimics the workings
of Gmail. It's accessible to screen readers through alternative content, and
if you're trying to visit using IE6 (we consciously decided not to apply
browser fixes for it), you get the following message:

http://wedemandhtml.com/tmp/tag_ie6_is_unsupported.png

Michiel


RE: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-05 Thread Daevid Vincent
 -Original Message-
 From: tedd [mailto:tedd.sperl...@gmail.com] 
 Sent: Wednesday, May 05, 2010 8:19 AM
 To: Daevid Vincent; php-general@lists.php.net
 Subject: RE: [PHP] In need of CVS/SVN checkout script for 
 Production servers [solved]
 
 At 1:10 PM -0700 5/4/10, Daevid Vincent wrote:
 Well, here is the one I'm using. I ended up just writing one (again!)
 
 http://www.daevid.com/content/examples/snippets.php :: Production
 Deployment Script
 
 What?!?
 
 Advanced features??
 
 I know you don't mean it, but you certainly know how to piss people 
 off. You are not going to like what I have to say, but please accept 
 the following as constructive criticism with no personal intent meant.
 
 The site fails W3C CSS validation with 96 errors.
 
 The site fails W3C HTML validation with 92 errors and 9 warnings.
 
 I have not run into a site like this since before the turn of this 
 century where we had browser wars. The problem isn't just with my 
 browser, but many more as you can see here:
 
 http://www.browsercam.com/public.aspx?proj_id=516739
 
 The page (not addressing the entire site) is riddled with embedded 
 javascript and embedded styling both of which are considered bad from.
 
 I haven't even addressed accessibility, graceful degradation, or 
 separation of content from presentation from behavior all of which 
 are the goals of best practices sites -- and all of which this site 
 fails miserably.
 
 My advice, which I realize that you didn't ask for, is if you want to 
 provide something of substance, then do so for all and not just the 
 privileged elite who think they are the leading edge with this type 
 of gimmick nonsense. This site is a step backward into the old 
 browser wars.
 
 Of course, I could tell you what I really think, but I don't want to 
 be too abrasive. :-)
 
 Cheers,
 
 tedd

*sigh* once again you people focus on something S off topic compared to
the meat of the thread -- which is a production repository checkout script.

As for my site.

[*] I wrote it like 4 years ago or more when there were TWO browsers worth
mentioning: IE and FF.
[*] I used a 3rd party JS library from www.ceiton.com -- who are pretty
much dormant.
[*] The cieton code is not only compressed and impossible to debug, but
often written in German!
[*] I've looked at it a few times over the years to try and remove the
limitation, 
because I also agree that most modern browsers should be able to handle
the JS at this point.
[*] I really don't care about the fringe browsers of Chrome, Opera,
Konquerer, Blackberry, whatever (for my PERSONAL HOME PAGE)
[*] http://www.w3schools.com/browsers/browsers_stats.asp
[*] http://marketshare.hitslink.com/report.aspx?qprid=0 
[*] I'm sorry your using a browser that falls under the top 25%. 
In fact ALL the browsers besides IE and FF don't even add up to 16% of
the ENTIRE market. 
Give me a break man. I've got more important things to do.
[*] If you don't have Firefox, well then let me tell you where to go 
download it for free: http://www.mozilla.com 
They make it for all major OS's in case you didn't know.
[*] Honestly, I also dislike Apple. I think it's stupid for them to make a
browser. I think they make crappy products. I HATE my iPod. I am a Linux
guy (or was until I realized my time was too valuable to keep wasting on
Linux as a Desktop), and WANTED to LOVE OSX. I sold the damn notebook after
a month of owning it. OSX blows. It's too dumbed down IMHO (as is Windows7,
but that's another topic). In light of recent events where they fired a guy
for showing that even more stupid iPad (great, a big iPhone that can't even
call) to Wozniak and then going after Gizmodo, I have even more distain for
them. So I really have no care to support them in any way shape or form. If
the site works for Safari, fine. If not, oh well, change your USER_AGENT
string or get Firefox/IE.

As for CSS, inline styles, separation of logic, and all that other stuff
you ASSUME I don't use -- you are very wrong. I just happen to use a lot of
PHP to dynamically create various parts. In some cases I inline styles
where they are used one time or used in a PHP function. I freely admit that
there is some archaic code there too. Code that I'm not about to go back
and re-factor at this stage. I know much more now than I did then. I would
certainly do things differently, and the next time I get a wild-hair up my
ass and a few days of that elusive commodity known as free time to code
up a new design I will.  Again, this is my personal site that's only
purpose is to show some pictures and other random shit.

And with all due respect Tedd -- as I know you're an icon here and I've
learned many things from you myself. If I had to choose between my
daevid.com site and one of the three you (presumably) illustrate as beacons
of the way to do it (http://sperling.com  http://ancientstones.com
http://earthstones.com), then I would take my site any day of the week.
These three sites

Re: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-05 Thread Nathan Rixham

Daevid Vincent wrote:

-Original Message-
From: tedd [mailto:tedd.sperl...@gmail.com] 
Sent: Wednesday, May 05, 2010 8:19 AM

To: Daevid Vincent; php-general@lists.php.net
Subject: RE: [PHP] In need of CVS/SVN checkout script for 
Production servers [solved]


At 1:10 PM -0700 5/4/10, Daevid Vincent wrote:

Well, here is the one I'm using. I ended up just writing one (again!)

http://www.daevid.com/content/examples/snippets.php :: Production
Deployment Script

What?!?

Advanced features??

I know you don't mean it, but you certainly know how to piss people 
off. You are not going to like what I have to say, but please accept 
the following as constructive criticism with no personal intent meant.


The site fails W3C CSS validation with 96 errors.

The site fails W3C HTML validation with 92 errors and 9 warnings.

I have not run into a site like this since before the turn of this 
century where we had browser wars. The problem isn't just with my 
browser, but many more as you can see here:


http://www.browsercam.com/public.aspx?proj_id=516739

The page (not addressing the entire site) is riddled with embedded 
javascript and embedded styling both of which are considered bad from.


I haven't even addressed accessibility, graceful degradation, or 
separation of content from presentation from behavior all of which 
are the goals of best practices sites -- and all of which this site 
fails miserably.


My advice, which I realize that you didn't ask for, is if you want to 
provide something of substance, then do so for all and not just the 
privileged elite who think they are the leading edge with this type 
of gimmick nonsense. This site is a step backward into the old 
browser wars.


Of course, I could tell you what I really think, but I don't want to 
be too abrasive. :-)


Cheers,

tedd


*sigh* once again you people focus on something S off topic compared to
the meat of the thread -- which is a production repository checkout script.

As for my site.

[*] I wrote it like 4 years ago or more when there were TWO browsers worth
mentioning: IE and FF.
[*] I used a 3rd party JS library from www.ceiton.com -- who are pretty
much dormant.
[*] The cieton code is not only compressed and impossible to debug, but
often written in German!
[*] I've looked at it a few times over the years to try and remove the
limitation, 
because I also agree that most modern browsers should be able to handle

the JS at this point.
[*] I really don't care about the fringe browsers of Chrome, Opera,
Konquerer, Blackberry, whatever (for my PERSONAL HOME PAGE)
[*] http://www.w3schools.com/browsers/browsers_stats.asp
[*] http://marketshare.hitslink.com/report.aspx?qprid=0 
[*] I'm sorry your using a browser that falls under the top 25%. 
In fact ALL the browsers besides IE and FF don't even add up to 16% of
the ENTIRE market. 
Give me a break man. I've got more important things to do.
[*] If you don't have Firefox, well then let me tell you where to go 
download it for free: http://www.mozilla.com 
They make it for all major OS's in case you didn't know.

[*] Honestly, I also dislike Apple. I think it's stupid for them to make a
browser. I think they make crappy products. I HATE my iPod. I am a Linux
guy (or was until I realized my time was too valuable to keep wasting on
Linux as a Desktop), and WANTED to LOVE OSX. I sold the damn notebook after
a month of owning it. OSX blows. It's too dumbed down IMHO (as is Windows7,
but that's another topic). In light of recent events where they fired a guy
for showing that even more stupid iPad (great, a big iPhone that can't even
call) to Wozniak and then going after Gizmodo, I have even more distain for
them. So I really have no care to support them in any way shape or form. If
the site works for Safari, fine. If not, oh well, change your USER_AGENT
string or get Firefox/IE.

As for CSS, inline styles, separation of logic, and all that other stuff
you ASSUME I don't use -- you are very wrong. I just happen to use a lot of
PHP to dynamically create various parts. In some cases I inline styles
where they are used one time or used in a PHP function. I freely admit that
there is some archaic code there too. Code that I'm not about to go back
and re-factor at this stage. I know much more now than I did then. I would
certainly do things differently, and the next time I get a wild-hair up my
ass and a few days of that elusive commodity known as free time to code
up a new design I will.  Again, this is my personal site that's only
purpose is to show some pictures and other random shit.

And with all due respect Tedd -- as I know you're an icon here and I've
learned many things from you myself. If I had to choose between my
daevid.com site and one of the three you (presumably) illustrate as beacons
of the way to do it (http://sperling.com  http://ancientstones.com
http://earthstones.com), then I would take my site any day of the week.
These three sites harkon back

Re: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-05 Thread Adam Richardson
On Wed, May 5, 2010 at 9:27 PM, Nathan Rixham nrix...@gmail.com wrote:

 Daevid Vincent wrote:

 -Original Message-
 From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Wednesday, May 05,
 2010 8:19 AM
 To: Daevid Vincent; php-general@lists.php.net
 Subject: RE: [PHP] In need of CVS/SVN checkout script for Production
 servers [solved]

 At 1:10 PM -0700 5/4/10, Daevid Vincent wrote:

 Well, here is the one I'm using. I ended up just writing one (again!)

 http://www.daevid.com/content/examples/snippets.php :: Production
 Deployment Script

 What?!?

 Advanced features??

 I know you don't mean it, but you certainly know how to piss people off.
 You are not going to like what I have to say, but please accept the
 following as constructive criticism with no personal intent meant.

 The site fails W3C CSS validation with 96 errors.

 The site fails W3C HTML validation with 92 errors and 9 warnings.

 I have not run into a site like this since before the turn of this
 century where we had browser wars. The problem isn't just with my browser,
 but many more as you can see here:

 http://www.browsercam.com/public.aspx?proj_id=516739

 The page (not addressing the entire site) is riddled with embedded
 javascript and embedded styling both of which are considered bad from.

 I haven't even addressed accessibility, graceful degradation, or
 separation of content from presentation from behavior all of which are the
 goals of best practices sites -- and all of which this site fails
 miserably.

 My advice, which I realize that you didn't ask for, is if you want to
 provide something of substance, then do so for all and not just the
 privileged elite who think they are the leading edge with this type of
 gimmick nonsense. This site is a step backward into the old browser wars.

 Of course, I could tell you what I really think, but I don't want to be
 too abrasive. :-)

 Cheers,

 tedd


 *sigh* once again you people focus on something S off topic compared
 to
 the meat of the thread -- which is a production repository checkout
 script.

 As for my site.

 [*] I wrote it like 4 years ago or more when there were TWO browsers worth
 mentioning: IE and FF.
 [*] I used a 3rd party JS library from www.ceiton.com -- who are pretty
 much dormant.
 [*] The cieton code is not only compressed and impossible to debug, but
 often written in German!
 [*] I've looked at it a few times over the years to try and remove the
 limitation, because I also agree that most modern browsers should be
 able to handle
 the JS at this point.
 [*] I really don't care about the fringe browsers of Chrome, Opera,
 Konquerer, Blackberry, whatever (for my PERSONAL HOME PAGE)
 [*] http://www.w3schools.com/browsers/browsers_stats.asp
 [*] http://marketshare.hitslink.com/report.aspx?qprid=0 [*] I'm sorry
 your using a browser that falls under the top 25%. In fact ALL the
 browsers besides IE and FF don't even add up to 16% of
 the ENTIRE market. Give me a break man. I've got more important things
 to do.
 [*] If you don't have Firefox, well then let me tell you where to go
 download it for free: http://www.mozilla.com They make it for all
 major OS's in case you didn't know.
 [*] Honestly, I also dislike Apple. I think it's stupid for them to make a
 browser. I think they make crappy products. I HATE my iPod. I am a Linux
 guy (or was until I realized my time was too valuable to keep wasting on
 Linux as a Desktop), and WANTED to LOVE OSX. I sold the damn notebook
 after
 a month of owning it. OSX blows. It's too dumbed down IMHO (as is
 Windows7,
 but that's another topic). In light of recent events where they fired a
 guy
 for showing that even more stupid iPad (great, a big iPhone that can't
 even
 call) to Wozniak and then going after Gizmodo, I have even more distain
 for
 them. So I really have no care to support them in any way shape or form.
 If
 the site works for Safari, fine. If not, oh well, change your USER_AGENT
 string or get Firefox/IE.

 As for CSS, inline styles, separation of logic, and all that other stuff
 you ASSUME I don't use -- you are very wrong. I just happen to use a lot
 of
 PHP to dynamically create various parts. In some cases I inline styles
 where they are used one time or used in a PHP function. I freely admit
 that
 there is some archaic code there too. Code that I'm not about to go back
 and re-factor at this stage. I know much more now than I did then. I would
 certainly do things differently, and the next time I get a wild-hair up my
 ass and a few days of that elusive commodity known as free time to code
 up a new design I will.  Again, this is my personal site that's only
 purpose is to show some pictures and other random shit.

 And with all due respect Tedd -- as I know you're an icon here and I've
 learned many things from you myself. If I had to choose between my
 daevid.com site and one of the three you (presumably) illustrate as
 beacons
 of the way to do it (http://sperling.com

RE: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-04 Thread Daevid Vincent
 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com] 
 Sent: Thursday, April 29, 2010 12:33 PM
 To: php-general@lists.php.net
 Subject: [PHP] In need of CVS/SVN checkout script for 
 Production servers
 
 Semi-off-topic, but I'm pretty sure you all are faced with this same
 challenge, I figured it's worth a shot and maybe some flaming.
 
 I'm looking for a script (bash or php) that I would run on my 
 production
 web server that would do this or close to it:
 
   1. do a CVS/SVN checkout to a new timestamped directory
   2. change the symlink from the old directory
   3. change permissions to www-data:www-data on new directory
   4. and possibly tarball up the old directory.
 
 I'm assuming this is a fairly common task, and I actually wrote one of
 these at my previous job, but I can't find the script 
 anymore. I remember
 it's not quite as trivial as it sounds and took a few hours 
 to perfect, so
 I thought I'd try to save myself some time. :)
  
 I have some other useful SVN scripts here if anyone is interested:
 http://daevid.com/content/examples/snippets.php

Well, here is the one I'm using. I ended up just writing one (again!)

http://www.daevid.com/content/examples/snippets.php :: Production
Deployment Script


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



Re: [PHP] In need of CVS/SVN checkout script for Production servers [solved]

2010-05-04 Thread Nathan Rixham

Daevid Vincent wrote:

-Original Message-
From: Daevid Vincent [mailto:dae...@daevid.com] 
Sent: Thursday, April 29, 2010 12:33 PM

To: php-general@lists.php.net
Subject: [PHP] In need of CVS/SVN checkout script for 
Production servers


Semi-off-topic, but I'm pretty sure you all are faced with this same
challenge, I figured it's worth a shot and maybe some flaming.

I'm looking for a script (bash or php) that I would run on my 
production

web server that would do this or close to it:

1. do a CVS/SVN checkout to a new timestamped directory
2. change the symlink from the old directory
3. change permissions to www-data:www-data on new directory
4. and possibly tarball up the old directory.

I'm assuming this is a fairly common task, and I actually wrote one of
these at my previous job, but I can't find the script 
anymore. I remember
it's not quite as trivial as it sounds and took a few hours 
to perfect, so

I thought I'd try to save myself some time. :)
 
I have some other useful SVN scripts here if anyone is interested:

http://daevid.com/content/examples/snippets.php


Well, here is the one I'm using. I ended up just writing one (again!)

http://www.daevid.com/content/examples/snippets.php :: Production
Deployment Script



It appears your browser does not support some of the advanced features 
this site requires.


Please use Internet Explorer or Firefox.

getting that in chrome 5.0.375.29 beta - what advanced features am I 
(and chrome) missing?


sounds like I'm being negative, but I'm not :)

tip though; degrade gracefully mate, don't break the net for 
non-required features.


best,

nathan

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



[PHP] Re: Need login suggestions

2010-05-02 Thread Nathan Rixham
Ashley M. Kirchner wrote:
 Slightly OT, but I can't think of a better forum to ask this in.  I'm sure a
 lot of us here have at some point or another built a system that requires
 registration to gain access.  What I'm trying to figure is how to set
 different levels of access.
 
  
 
 We're building a large site for a school district, to be used by both
 students and parents.  When a student logs in, they gain some access to the
 site, and when a parent logs in, they gain access to other sections on the
 site.  That's all fine and dandy, it's the actual registration process that
 I'm having a hard time with.
 
  
 
 How to determine if a registration is a student or a parent.  Do I simply
 give them a check box (or other method) to pick from (student or parent) and
 hope they're being honest?  Has anyone here have to deal with that in the
 past, and would you be willing to give me some ideas of what you did?
 Thanks!


Ideally you need to be able to unambiguously identify either a student
or a parent, you're best bet is to go for student - thus try and find a
single bit of information that both a student and you know about that
student, possibilities are:

  student id
  class
  teacher
  year

and so forth.. if the person signing up has any of these things then
they must be a student.

Best,

Nathan


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



Re: [PHP] Re: Need login suggestions

2010-05-02 Thread Bobby Pejman
I would also agree that allowing parent registration could be risky.  What you 
may be able to do just off the top is create a UserLevel field in your users 
table and assign value 1 for all those who say they're students.  That is, if 
you have no student ids at your disposal.

Then, when parents register, you can ask who their kid is, and assign a user 
level 2, for example.  When a parent finishes their registration, don't allow 
them access.  Display a message saying you'll have to call in to get your 
password or something similar.

What you're essentially doing is identifying parents by their user level yet 
making sure parents are parents.

Just an idea I thought I share.
-Original Message-
From: Nathan Rixham nrix...@gmail.com
Date: Mon, 03 May 2010 03:21:12 
To: Ashley M. Kirchnerash...@pcraft.com
Cc: php-general@lists.php.net
Subject: [PHP] Re: Need login suggestions
Ashley M. Kirchner wrote:
 Slightly OT, but I can't think of a better forum to ask this in.  I'm sure a
 lot of us here have at some point or another built a system that requires
 registration to gain access.  What I'm trying to figure is how to set
 different levels of access.
 
  
 
 We're building a large site for a school district, to be used by both
 students and parents.  When a student logs in, they gain some access to the
 site, and when a parent logs in, they gain access to other sections on the
 site.  That's all fine and dandy, it's the actual registration process that
 I'm having a hard time with.
 
  
 
 How to determine if a registration is a student or a parent.  Do I simply
 give them a check box (or other method) to pick from (student or parent) and
 hope they're being honest?  Has anyone here have to deal with that in the
 past, and would you be willing to give me some ideas of what you did?
 Thanks!


Ideally you need to be able to unambiguously identify either a student
or a parent, you're best bet is to go for student - thus try and find a
single bit of information that both a student and you know about that
student, possibilities are:

  student id
  class
  teacher
  year

and so forth.. if the person signing up has any of these things then
they must be a student.

Best,

Nathan


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



Re: [PHP] Re: Need login suggestions

2010-05-02 Thread Nathan Rixham
Bobby Pejman wrote:
 I would also agree that allowing parent registration could be risky.  What 
 you may be able to do just off the top is create a UserLevel field in your 
 users table and assign value 1 for all those who say they're students.  That 
 is, if you have no student ids at your disposal.
 
 Then, when parents register, you can ask who their kid is, and assign a user 
 level 2, for example.  When a parent finishes their registration, don't allow 
 them access.  Display a message saying you'll have to call in to get your 
 password or something similar.
 
 What you're essentially doing is identifying parents by their user level yet 
 making sure parents are parents.
 
 Just an idea I thought I share.

yeah - that's quite a strong point! whatever you do, do not give any
details of students to anybody unless they are 100% verified and allowed
the info - that's one thing I would not want to screw up on myself,
could be a nasty lawsuit.

best,

nathan

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



[PHP] RE: Need login suggestions

2010-05-02 Thread Ashley M. Kirchner

 -Original Message-
 From: Nathan Rixham [mailto:nrix...@gmail.com]
 Sent: Sunday, May 02, 2010 8:21 PM
 To: Ashley M. Kirchner
 Cc: php-general@lists.php.net
 Subject: Re: Need login suggestions
 
 Ideally you need to be able to unambiguously identify either a student
 or a parent, you're best bet is to go for student - thus try and find a
 single bit of information that both a student and you know about that
 student, possibilities are:

Yep, easier said than done.  It would be rather easy to determine a
student, they're all common login formats.  Staff e-mails are different yet,
as are others.  However, for the charter schools, they don't fall in the
same common pool, and thus have totally different e-mails, public e-mails
at that.  So I can't simply rely on their e-mail.

I can certainly ask for a student ID (and verify that on the
backend), but again, parents also know their student's IDs.  They also know
what year.  Teacher won't have any bearing here because there is no such
thing as a 'home room' at the level we're working at.  I'm not so much
worried about a parent registering on the wrong side of the wall ... the
access would be even less anyway.  And while a student registering on the
wrong side simply won't give them access to the contest, there is also no
reason for them to be there.  And rather than me getting an e-mail to change
their registration, I'd rather it happen automatically.  There is nothing on
the parent side that is a secret or that the student can't know.  This isn't
any kind of secure or secret site we're working with here.


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



RE: [PHP] Re: Need login suggestions

2010-05-02 Thread Ashley M. Kirchner
 -Original Message-
 From: Bobby Pejman [mailto:bpej...@gmail.com]
 Sent: Sunday, May 02, 2010 8:30 PM
 To: Nathan Rixham; Ashley M. Kirchner
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Re: Need login suggestions
 
 I would also agree that allowing parent registration could be risky.
 What you may be able to do just off the top is create a UserLevel field
 in your users table and assign value 1 for all those who say they're
 students.  That is, if you have no student ids at your disposal.
 
 Then, when parents register, you can ask who their kid is, and assign a
 user level 2, for example.  When a parent finishes their registration,
 don't allow them access.  Display a message saying you'll have to call
 in to get your password or something similar.
 
 What you're essentially doing is identifying parents by their user
 level yet making sure parents are parents.
 
 Just an idea I thought I share.

What you're suggesting, multi level access, is already in place.  It's
determined by whatever group a login falls in, student, staff,
administrator, contractor, volunteer, parent, etc., etc.  However, for what
I'm doing, working with one of the departments, we don't have full access to
the LDAP server to verify a login, nor can we expect someone registering for
*transportation* is also registered in the main LDAP server.  So things work
separately.

What we're doing has nothing at all to do with what's on the main server.
No personal information is being shared or broadcasted.  No student
information, absolutely nothing.  This is strictly a case of 'user A' versus
'user B' and figuring out a way to determine, through registration, what
level of access they get.  Is it based solely on the honor system, hoping
that each user does the right thing when they register, or have people come
up with some other kind of mechanism ...


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



[PHP] In need of CVS/SVN checkout script for Production servers

2010-04-29 Thread Daevid Vincent
Semi-off-topic, but I'm pretty sure you all are faced with this same
challenge, I figured it's worth a shot and maybe some flaming.

I'm looking for a script (bash or php) that I would run on my production
web server that would do this or close to it:

1. do a CVS/SVN checkout to a new timestamped directory
2. change the symlink from the old directory
3. change permissions to www-data:www-data on new directory
4. and possibly tarball up the old directory.

I'm assuming this is a fairly common task, and I actually wrote one of
these at my previous job, but I can't find the script anymore. I remember
it's not quite as trivial as it sounds and took a few hours to perfect, so
I thought I'd try to save myself some time. :)
 
I have some other useful SVN scripts here if anyone is interested:
http://daevid.com/content/examples/snippets.php


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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-18 Thread tedd

At 5:18 PM -0700 3/17/10, Tommy Pham wrote:

-snip-
  Below is how I'd do the db structure:

tbl_survey_questions:
questionId = int / uid  your call
languageId = int / uid / char  your call if you intend to I18n it ;)
question = varchar  length is your requirement
PK  questionId + languageId

tbl_participants:
userId = int / uid
userName = varchar
PK  userId

tbl_answers:
userId = int / uid
questionId = int / uid
languageId = int / uid
answer = varchar / mediumtext / or another type of text field
PK  userId + questionId + languageId

The reason why I'd structure it like this is:

Let's say you have question 1 with 5 (a-e) multiple choices, you
aggregrate your query (GROUP BY) to db for question 1 and see how many
responses are for a to e (each).  If your survey is I18n and your DB
reflects it, you can even analyze how/why certain cultural background
would choose each of those answer. (don't flame me... I know the
environment comes in to growing up too :p and that's way beyond the
scope of this list )



Tommy:

The way I handled this was that all responder aspects, such as 
cultural background, were all recorded before the responder started 
the survey. This was part an authorization process and the responders 
had to earn their way into the survey by providing personal data. 
If they did not, then they weren't allowed to enter the survey. 
Likewise, they had to turn javascript ON or they were not permitted 
to continue.


Please understand that in this survey, the purpose was that the 
client wasn't hoping for responders to fill out the survey (even 
though they would like them to), but rather providing a method for 
the membership to show their preferences in a union contract for 
their collective interest. As such, responders had a vested interest 
in participating. The survey would take between 20 to 60 minutes to 
complete and thus required a significant time investment.


Considering that each answer (or series) could be compared to any 
number of others, I thought it best to make each question/answer 
created an individual record -- the table was very simple:


survey_id
question_id
key1
key2
answer

1) The union wants several surveys like this, so I provided a survey_id.

2) The question_id was simply an identifier for the question -- a 
remote key to a question table.


3) Key1 and Key2 were simply values that were intended to tie the 
question/answer pairs together into a single event (i.e., a vote).


4) Answer -- what we are after.

This format lends itself well to analyses using MySQL.

Cheers,

tedd

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

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-17 Thread Tommy Pham
On Sat, Mar 13, 2010 at 11:10 AM, tedd tedd.sperl...@gmail.com wrote:
 Hi gang:

 I just completed writing a survey that has approximately 180 questions in it
 and I need a fresh look at how to store the results so I can use them later.

 The survey requires the responder to identify themselves via an
 authorization script. After which, the responder is permitted to take the
 survey. Everything works as the client wants so there are no problems there.

 My question is how to store the results?

 I have the answers stored in a session variable, like:

 $_SESSION['answer']['e1']
 $_SESSION['answer']['e2']
 $_SESSION['answer']['e2a']
 $_SESSION['answer']['e2ai']
 $_SESSION['answer']['p1']
 $_SESSION['answer']['p1a']
 $_SESSION['answer']['p1ai']

 and so on. As I said, there are around 180 questions/answers.

 Most of the answers are integers (less than 100), some are text, and some
 will be null.

 Each vote will have a unique number (i.e., time) assigned to it as well as
 a common survey id.

 My first thought was to simply record the vote as a single record with the
 answers as a long string (maybe MEDIUMTEXT), such as:

 1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

 Then I thought I might make the data xml, such as:

 survey_id1/survey_idvote_id1268501271/vote_ide11/e1e216/e2e2aFour
 score and .../e2ae2ai/e2ai

 That way I can strip text entries for  and have absolute control over
 question separation.

 Then I thought I could make each question/answer combination have it's own
 record while using the vote_id to tie the vote together. That way I can
 use MySQL to do the heavy lifting during the analysis. While each vote
 creates 180 records, I like this way best.

 Then I thought, what would you guys do? So, what would you guys do?

 Keep in mind that this survey must evaluated in terms of answers, such as
 Of the ones who answered e1 as 1 how did they answer e2?

 If there is something wrong with my preference, please let me know.

 Thanks,

 tedd

 --
 ---

Tedd,

Sorry to be jumping in late, trying to migrate from yahoo mail to
gmail since I'm experiencing more problems with yahoo mail then I'd
like.  Any way, I'd go with db storage for storing of the results
since it will give better and more flexible analysis and reporting
later.  Below is how I'd do the db structure:

tbl_survey_questions:
questionId = int / uid  your call
languageId = int / uid / char  your call if you intend to I18n it ;)
question = varchar  length is your requirement
PK  questionId + languageId

tbl_participants:
userId = int / uid
userName = varchar
PK  userId

tbl_answers:
userId = int / uid
questionId = int / uid
languageId = int / uid
answer = varchar / mediumtext / or another type of text field
PK  userId + questionId + languageId

The reason why I'd structure it like this is:

Let's say you have question 1 with 5 (a-e) multiple choices, you
aggregrate your query (GROUP BY) to db for question 1 and see how many
responses are for a to e (each).  If your survey is I18n and your DB
reflects it, you can even analyze how/why certain cultural background
would choose each of those answer. (don't flame me... I know the
environment comes in to growing up too :p and that's way beyond the
scope of this list )

For question 2 with could be user entry (non multiple choice
selection), again, you see what their opinions are for that question.
You get the idea as how the rest may go.

I used to do lots of reporting with the real tool, Crystal Report ;)

Regards,
Tommy

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Rene Veerman
On Sun, Mar 14, 2010 at 7:18 AM, Paul M Foster pa...@quillandmouse.com wrote:

 Tedd's perfectly capable of speaking for himself, but I can tell you
 he's been on this list for a long time, and his skills are plenty
 adequate for this task. He's just asking for second opinions.

Wouldn't someone with adequate DB skills know if he(/she) even needs
to build a datamodel, and given the simplicity of this one, how? Based
on what i mentioned earlier, type and amount of use of stored reports?

I don't mind noobishness in any area, but i have learned to keep code
as simple as possible.

BTW;
- as always, i recommend adodb.sf.net for DB abstractions.
- if you are storing in DB and displaying from DB later you need to
prevent code injections (sql, html, js, flash) by pushing all strings
used in sql insert- and update-fields;
 $sql = 'insert into table (field1_int, field2_string,etc) values
('.$field1.', '.antiSQLinjection($field2).', ...);

I'm using this function atm, maybe someone can improve upon it. This
disables all sql injections, and strips all html, js  flash.

function antiSQLinjection ($string) {

//anti SQL injections:
  if (phpversion() = '4.3.0')
  {
$string = mysql_real_escape_string($string);
  }
  else
  {
$string = mysql_escape_string($string);
  }

  if(get_magic_quotes_gpc())  // prevents duplicate backslashes
  {
$string = stripslashes($string);
  }

//anti HTML/JS/flash injections (into searchterms, for instance):
  $string = strip_tags ($string);

  return $string;
}

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Rene Veerman
On Sun, Mar 14, 2010 at 8:22 AM, Jochem Maas joc...@iamjochem.com wrote:

 first off - wasn't there a cut'n'dried piece of survey software out there
 that did the job? don't know off hand what the 'market' currently offers but
 I'm pretty sure there are a number of candidate php-based wotsits.

 as such they might be worth looking at just to check out their data models.


+1, good point.

I know there are free cloud services for dutch petitions and surveys,
i bet there are for english too.
A google for free online survey hosting will reap many such sites.

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Ashley Sheridan
On Sun, 2010-03-14 at 11:15 +0100, Rene Veerman wrote:

 On Sun, Mar 14, 2010 at 7:18 AM, Paul M Foster pa...@quillandmouse.com 
 wrote:
 
  Tedd's perfectly capable of speaking for himself, but I can tell you
  he's been on this list for a long time, and his skills are plenty
  adequate for this task. He's just asking for second opinions.
 
 Wouldn't someone with adequate DB skills know if he(/she) even needs
 to build a datamodel, and given the simplicity of this one, how? Based
 on what i mentioned earlier, type and amount of use of stored reports?
 
 I don't mind noobishness in any area, but i have learned to keep code
 as simple as possible.
 
 BTW;
 - as always, i recommend adodb.sf.net for DB abstractions.
 - if you are storing in DB and displaying from DB later you need to
 prevent code injections (sql, html, js, flash) by pushing all strings
 used in sql insert- and update-fields;
  $sql = 'insert into table (field1_int, field2_string,etc) values
 ('.$field1.', '.antiSQLinjection($field2).', ...);
 
 I'm using this function atm, maybe someone can improve upon it. This
 disables all sql injections, and strips all html, js  flash.
 
 function antiSQLinjection ($string) {
 
 //anti SQL injections:
   if (phpversion() = '4.3.0')
   {
 $string = mysql_real_escape_string($string);
   }
   else
   {
 $string = mysql_escape_string($string);
   }
 
   if(get_magic_quotes_gpc())  // prevents duplicate backslashes
   {
 $string = stripslashes($string);
   }
 
 //anti HTML/JS/flash injections (into searchterms, for instance):
   $string = strip_tags ($string);
 
   return $string;
 }
 


That function won't always work. You're using a PHP version check for
mysql_real_escape_string() when the most likely failure point for it is
if no database connection has been opened.

Also, you shouldn't strip the tags from a string that's being inserted
into the database. strip_tags() is for the display of data on a web
page. It's best practice not to alter the actual data you've stored but
to convert it once it's displayed. Don't forget that the browser display
may not be the only use for that data.

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




Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Rene Veerman
On Sun, Mar 14, 2010 at 11:16 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

  That function won't always work. You're using a PHP version check for
 mysql_real_escape_string() when the most likely failure point for it is if
 no database connection has been opened.


I never call it without an open db connection..



 Also, you shouldn't strip the tags from a string that's being inserted into
 the database. strip_tags() is for the display of data on a web page. It's
 best practice not to alter the actual data you've stored but to convert it
 once it's displayed. Don't forget that the browser display may not be the
 only use for that data.


Let's call that a coder's / payer's preference..

If i'd need human text, i'd want to strip it of computer code before it
enters the db. Possibly log the attempt to insert code.


Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Ashley Sheridan
On Sun, 2010-03-14 at 12:14 +0100, Rene Veerman wrote:

 
 
 
 On Sun, Mar 14, 2010 at 11:16 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
 
 
 
 That function won't always work. You're using a PHP version
 check for mysql_real_escape_string() when the most likely
 failure point for it is if no database connection has been
 opened.
 
 
 I never call it without an open db connection..
  
 
 Also, you shouldn't strip the tags from a string that's being
 inserted into the database. strip_tags() is for the display of
 data on a web page. It's best practice not to alter the actual
 data you've stored but to convert it once it's displayed.
 Don't forget that the browser display may not be the only use
 for that data.
 
 
 
 Let's call that a coder's / payer's preference..
 
 If i'd need human text, i'd want to strip it of computer code before
 it enters the db. Possibly log the attempt to insert code.
 
  
 
 


I have to deal with a lot of CMS's, so I expect the users to enter some
HTML code through a rich-text editor, and they expect to be able to.

Aside from that, it's good to have a complete copy of the code a user
attempted to insert, to see the methodology of an attack should it ever
occur.

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




Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Rene Veerman
On Sun, Mar 14, 2010 at 12:13 PM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:


 I have to deal with a lot of CMS's, so I expect the users to enter some
 HTML code through a rich-text editor, and they expect to be able to.


I'd love to have a copy of whatever function you use to filter out bad
HTML/js/flash for use cases where users are allowed to enter html.
I'm aware of strip_tags() allowed tags param, but haven't got a good list
for it.



 Aside from that, it's good to have a complete copy of the code a user
 attempted to insert, to see the methodology of an attack should it ever
 occur.


I should've said possibly log  mail the details of the attempt, which is
what i'd do ;)


Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Rene Veerman
On Sun, Mar 14, 2010 at 12:24 PM, Rene Veerman rene7...@gmail.com wrote:

 I'd love to have a copy of whatever function you use to filter out bad
 HTML/js/flash for use cases where users are allowed to enter html.
 I'm aware of strip_tags() allowed tags param, but haven't got a good list
 for it.


oh, and even img tags can be used for cookie-stuffing on many browsers..

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Ashley Sheridan
On Sun, 2010-03-14 at 12:25 +0100, Rene Veerman wrote:

 On Sun, Mar 14, 2010 at 12:24 PM, Rene Veerman rene7...@gmail.com wrote:
 
  I'd love to have a copy of whatever function you use to filter out bad
  HTML/js/flash for use cases where users are allowed to enter html.
  I'm aware of strip_tags() allowed tags param, but haven't got a good list
  for it.
 
 
 oh, and even img tags can be used for cookie-stuffing on many browsers..
 


Yes, and you call strip_tags() before the data goes to the browser for
display, not before it gets inserted into the database. Essentially, you
need to keep as much original information as possible.

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




Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-14 Thread Jochem Maas
Op 3/14/10 11:45 AM, Ashley Sheridan schreef:
 On Sun, 2010-03-14 at 12:25 +0100, Rene Veerman wrote:
 
 On Sun, Mar 14, 2010 at 12:24 PM, Rene Veerman rene7...@gmail.com wrote:

 I'd love to have a copy of whatever function you use to filter out bad
 HTML/js/flash for use cases where users are allowed to enter html.
 I'm aware of strip_tags() allowed tags param, but haven't got a good list
 for it.


 oh, and even img tags can be used for cookie-stuffing on many browsers..

 
 
 Yes, and you call strip_tags() before the data goes to the browser for
 display, not before it gets inserted into the database. Essentially, you
 need to keep as much original information as possible.

I disagree with both you. I'm like that :)

let's assume we're not talking about data that is allowed to contain HTML,
in such cases I would do a strip_tags() on the incoming data then compare
the output ofstrip_tags() to the original input ... if they don't match then
I would log the problem and refuse to input the data at all.

using strip_tags() on a piece of data everytime you output it if you know
that it shouldn't contain any in the first is a waste of resources ... this
does assume that you can trust the data source ... which in the case of a 
database
that you control should be the case.

at any rate, strip_tags() doesn't belong in an 'anti-sql-injection' routine as
it has nothing to do with sql injection at all.

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


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



[PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread tedd

Hi gang:

I just completed writing a survey that has approximately 180 
questions in it and I need a fresh look at how to store the results 
so I can use them later.


The survey requires the responder to identify themselves via an 
authorization script. After which, the responder is permitted to take 
the survey. Everything works as the client wants so there are no 
problems there.


My question is how to store the results?

I have the answers stored in a session variable, like:

$_SESSION['answer']['e1']
$_SESSION['answer']['e2']
$_SESSION['answer']['e2a']
$_SESSION['answer']['e2ai']
$_SESSION['answer']['p1']
$_SESSION['answer']['p1a']
$_SESSION['answer']['p1ai']

and so on. As I said, there are around 180 questions/answers.

Most of the answers are integers (less than 100), some are text, and 
some will be null.


Each vote will have a unique number (i.e., time) assigned to it as 
well as a common survey id.


My first thought was to simply record the vote as a single record 
with the answers as a long string (maybe MEDIUMTEXT), such as:


1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

Then I thought I might make the data xml, such as:

survey_id1/survey_idvote_id1268501271/vote_ide11/e1e216/e2e2aFour 
score and .../e2ae2ai/e2ai


That way I can strip text entries for  and have absolute control 
over question separation.


Then I thought I could make each question/answer combination have 
it's own record while using the vote_id to tie the vote together. 
That way I can use MySQL to do the heavy lifting during the analysis. 
While each vote creates 180 records, I like this way best.


Then I thought, what would you guys do? So, what would you guys do?

Keep in mind that this survey must evaluated in terms of answers, 
such as Of the ones who answered e1 as 1 how did they answer e2?


If there is something wrong with my preference, please let me know.

Thanks,

tedd

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

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread paragasu
On Sun, Mar 14, 2010 at 2:10 AM, tedd tedd.sperl...@gmail.com wrote:

 Hi gang:

 I just completed writing a survey that has approximately 180 questions in
 it and I need a fresh look at how to store the results so I can use them
 later.

 The survey requires the responder to identify themselves via an
 authorization script. After which, the responder is permitted to take the
 survey. Everything works as the client wants so there are no problems there.

 My question is how to store the results?

 I have the answers stored in a session variable, like:

 $_SESSION['answer']['e1']
 $_SESSION['answer']['e2']
 $_SESSION['answer']['e2a']
 $_SESSION['answer']['e2ai']
 $_SESSION['answer']['p1']
 $_SESSION['answer']['p1a']
 $_SESSION['answer']['p1ai']

 and so on. As I said, there are around 180 questions/answers.

 Most of the answers are integers (less than 100), some are text, and some
 will be null.

 Each vote will have a unique number (i.e., time) assigned to it as well
 as a common survey id.

 My first thought was to simply record the vote as a single record with
 the answers as a long string (maybe MEDIUMTEXT), such as:

 1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

 Then I thought I might make the data xml, such as:

 survey_id1/survey_idvote_id1268501271/vote_ide11/e1e216/e2e2aFour
 score and .../e2ae2ai/e2ai

 That way I can strip text entries for  and have absolute control over
 question separation.

 Then I thought I could make each question/answer combination have it's own
 record while using the vote_id to tie the vote together. That way I can
 use MySQL to do the heavy lifting during the analysis. While each vote
 creates 180 records, I like this way best.

 Then I thought, what would you guys do? So, what would you guys do?

 Keep in mind that this survey must evaluated in terms of answers, such as
 Of the ones who answered e1 as 1 how did they answer e2?

 If there is something wrong with my preference, please let me know.

 Thanks,

 tedd

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

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


Hi Ted,

How about saving the array in serialize variable to TEXT column

$answer = serialize($_SESSION['answer']);

to get the original array value simply unserialize the value from the
database..

Paragasu


Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread Rene Veerman
+1, but it also kinda depends on what you want to do with it later,
and how much.

if you want to re-use filled-in reports on the javascript end, you may
want to use json_encode() instead of serialize().

if you plan to have many (say 5000) reports filled in and want users
to be able to search quickly on values or generate reports based on
searches, then you'd need an actual datamodel, so mysql can do the
searching, sorting and adding.

On Sat, Mar 13, 2010 at 7:55 PM, paragasu parag...@gmail.com wrote:
 On Sun, Mar 14, 2010 at 2:10 AM, tedd tedd.sperl...@gmail.com wrote:

 Hi gang:

 I just completed writing a survey that has approximately 180 questions in
 it and I need a fresh look at how to store the results so I can use them
 later.

 The survey requires the responder to identify themselves via an
 authorization script. After which, the responder is permitted to take the
 survey. Everything works as the client wants so there are no problems there.

 My question is how to store the results?

 I have the answers stored in a session variable, like:

 $_SESSION['answer']['e1']
 $_SESSION['answer']['e2']
 $_SESSION['answer']['e2a']
 $_SESSION['answer']['e2ai']
 $_SESSION['answer']['p1']
 $_SESSION['answer']['p1a']
 $_SESSION['answer']['p1ai']

 and so on. As I said, there are around 180 questions/answers.

 Most of the answers are integers (less than 100), some are text, and some
 will be null.

 Each vote will have a unique number (i.e., time) assigned to it as well
 as a common survey id.

 My first thought was to simply record the vote as a single record with
 the answers as a long string (maybe MEDIUMTEXT), such as:

 1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

 Then I thought I might make the data xml, such as:

 survey_id1/survey_idvote_id1268501271/vote_ide11/e1e216/e2e2aFour
 score and .../e2ae2ai/e2ai

 That way I can strip text entries for  and have absolute control over
 question separation.

 Then I thought I could make each question/answer combination have it's own
 record while using the vote_id to tie the vote together. That way I can
 use MySQL to do the heavy lifting during the analysis. While each vote
 creates 180 records, I like this way best.

 Then I thought, what would you guys do? So, what would you guys do?

 Keep in mind that this survey must evaluated in terms of answers, such as
 Of the ones who answered e1 as 1 how did they answer e2?

 If there is something wrong with my preference, please let me know.

 Thanks,

 tedd

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

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


 Hi Ted,

 How about saving the array in serialize variable to TEXT column

 $answer = serialize($_SESSION['answer']);

 to get the original array value simply unserialize the value from the
 database..

 Paragasu


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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread Phpster
I'd go with a mysql data modelled approach as it will allow mysql to  
do lots of the heavy lifting during analysis as you've mentioned. If  
there are a lot of entries, it's gonna get complex and expensive  
memory-wise to manage XML or session based datasets.


Plus having each question as it's own record should give you greater  
flexibility in packaging the data for analysis and reporting.


Bastien

Sent from my iPod

On Mar 13, 2010, at 1:10 PM, tedd tedd.sperl...@gmail.com wrote:


Hi gang:

I just completed writing a survey that has approximately 180  
questions in it and I need a fresh look at how to store the results  
so I can use them later.


The survey requires the responder to identify themselves via an  
authorization script. After which, the responder is permitted to  
take the survey. Everything works as the client wants so there are  
no problems there.


My question is how to store the results?

I have the answers stored in a session variable, like:

$_SESSION['answer']['e1']
$_SESSION['answer']['e2']
$_SESSION['answer']['e2a']
$_SESSION['answer']['e2ai']
$_SESSION['answer']['p1']
$_SESSION['answer']['p1a']
$_SESSION['answer']['p1ai']

and so on. As I said, there are around 180 questions/answers.

Most of the answers are integers (less than 100), some are text, and  
some will be null.


Each vote will have a unique number (i.e., time) assigned to it as  
well as a common survey id.


My first thought was to simply record the vote as a single record  
with the answers as a long string (maybe MEDIUMTEXT), such as:


1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

Then I thought I might make the data xml, such as:

survey_id1/survey_idvote_id1268501271/vote_ide11/ 
e1e216/e2e2aFour score and .../e2ae2ai/e2ai


That way I can strip text entries for  and have absolute control  
over question separation.


Then I thought I could make each question/answer combination have  
it's own record while using the vote_id to tie the vote together.  
That way I can use MySQL to do the heavy lifting during the  
analysis. While each vote creates 180 records, I like this way best.


Then I thought, what would you guys do? So, what would you guys do?

Keep in mind that this survey must evaluated in terms of answers,  
such as Of the ones who answered e1 as 1 how did they answer e2?


If there is something wrong with my preference, please let me know.

Thanks,

tedd

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

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



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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread Rene Veerman
the OP may not need such fanciness.. it depends on the amount of
reports he wants to store, the types of searches (if any) done by
browsers, and the amount of searches to expect.

and the OP may not have good db design skills yet.
for a noob, it's one timeconsuming thing to build a datamodel, but
it's harder to get it efficient yet simple.

if the oop wants to start a site with lots of reports and lots of
searching, we'd even have to remind him of the cloud hosting option,
which i'm sorry to say, has no real rdbms (mysql) support yet, and is
not always paid by the minute (but by the hour), meaning it's got only
a small chance of reducing his operating cost (by a lot); it's still
worth investigating in this case (given the much easier scaling
abilities of cloud hosting).

OP: if you need a mysql datamodel for reports, i'm willing to give it
a free shot. i'm sure others here would too, or improve upon mine.
It's probably not more than 3 tables i think.
Let us know eh..

On Sat, Mar 13, 2010 at 8:45 PM, Phpster phps...@gmail.com wrote:
 I'd go with a mysql data modelled approach as it will allow mysql to do lots
 of the heavy lifting during analysis as you've mentioned. If there are a lot
 of entries, it's gonna get complex and expensive memory-wise to manage XML
 or session based datasets.

 Plus having each question as it's own record should give you greater
 flexibility in packaging the data for analysis and reporting.

 Bastien

 Sent from my iPod

 On Mar 13, 2010, at 1:10 PM, tedd tedd.sperl...@gmail.com wrote:

 Hi gang:

 I just completed writing a survey that has approximately 180 questions in
 it and I need a fresh look at how to store the results so I can use them
 later.

 The survey requires the responder to identify themselves via an
 authorization script. After which, the responder is permitted to take the
 survey. Everything works as the client wants so there are no problems there.

 My question is how to store the results?

 I have the answers stored in a session variable, like:

 $_SESSION['answer']['e1']
 $_SESSION['answer']['e2']
 $_SESSION['answer']['e2a']
 $_SESSION['answer']['e2ai']
 $_SESSION['answer']['p1']
 $_SESSION['answer']['p1a']
 $_SESSION['answer']['p1ai']

 and so on. As I said, there are around 180 questions/answers.

 Most of the answers are integers (less than 100), some are text, and some
 will be null.

 Each vote will have a unique number (i.e., time) assigned to it as well
 as a common survey id.

 My first thought was to simply record the vote as a single record with
 the answers as a long string (maybe MEDIUMTEXT), such as:

 1, 1268501271, e1, 1, e2, 16, e2a, Four score and ..., e2a1, ,

 Then I thought I might make the data xml, such as:


 survey_id1/survey_idvote_id1268501271/vote_ide11/e1e216/e2e2aFour
 score and .../e2ae2ai/e2ai

 That way I can strip text entries for  and have absolute control over
 question separation.

 Then I thought I could make each question/answer combination have it's own
 record while using the vote_id to tie the vote together. That way I can
 use MySQL to do the heavy lifting during the analysis. While each vote
 creates 180 records, I like this way best.

 Then I thought, what would you guys do? So, what would you guys do?

 Keep in mind that this survey must evaluated in terms of answers, such as
 Of the ones who answered e1 as 1 how did they answer e2?

 If there is something wrong with my preference, please let me know.

 Thanks,

 tedd

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

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


 --
 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] I need a fresh look at storing variables in MySQL

2010-03-13 Thread Paul M Foster
On Sat, Mar 13, 2010 at 02:45:37PM -0500, Phpster wrote:

 I'd go with a mysql data modelled approach as it will allow mysql to
 do lots of the heavy lifting during analysis as you've mentioned. If
 there are a lot of entries, it's gonna get complex and expensive
 memory-wise to manage XML or session based datasets.

 Plus having each question as it's own record should give you greater
 flexibility in packaging the data for analysis and reporting.


+1

I invariably find that the original design for a project needs to be
tweaked. The customer wants to add or delete questions, they want to
add/change reports for the data. So I nearly always approach this kind
of project this way. Maybe:

vote table:

id  serial/sequence not null primary key
voter_idint references voters (voter_id)
question_id varchar(10)
answer  varchar(10)

You can easily subset by voter, or by question ID. Or analyze answers in
relation to other answers, etc.

Paul

-- 
Paul M. Foster

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



Re: [PHP] I need a fresh look at storing variables in MySQL

2010-03-13 Thread Paul M Foster
On Sat, Mar 13, 2010 at 09:04:46PM +0100, Rene Veerman wrote:

snip

 
 and the OP may not have good db design skills yet.
 for a noob, it's one timeconsuming thing to build a datamodel, but
 it's harder to get it efficient yet simple.
 

snip

 
 OP: if you need a mysql datamodel for reports, i'm willing to give it
 a free shot. i'm sure others here would too, or improve upon mine.
 It's probably not more than 3 tables i think.
 Let us know eh..

Tedd's perfectly capable of speaking for himself, but I can tell you
he's been on this list for a long time, and his skills are plenty
adequate for this task. He's just asking for second opinions.

Paul

-- 
Paul M. Foster

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



  1   2   3   4   5   6   7   >