Re: [PHP] Reseting the auto-increment number in a MySQL database.

2013-06-26 Thread Samuel Lopes Grigolato
You can try this: *ALTER TABLE tbl AUTO_INCREMENT = 100;*
*
*
*Source: *http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

(never did it myself, though)


On Wed, Jun 26, 2013 at 2:07 PM, Tedd Sperling t...@sperling.com wrote:

 Hi gang:

 I have a client where their next auto-increment number just jumped from
 2300 to 10 for reasons not understood. They want it set back.

 Options such as dropping the primary key and rebuilding the index is NOT
 possible -- this is a relational table thing.

 So, is there a way (programmatically) to set the next number in an
 auto-increment?

 Something like:

 alter table abc auto_increment = 2301;

 Any ideas of why this happened?

 Cheers,


 tedd

 _
 t...@sperling.com
 http://sperling.com


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




Re: [PHP] Last Record INSERT

2013-06-26 Thread Samuel Lopes Grigolato
AFAIK mysql_[...] is deprecated in favor of mysqli_[...] correspondent
functions, there's nothing to do specifically with mysql[i]_insert_id.


On Wed, Jun 26, 2013 at 3:01 PM, Tedd Sperling tedd.sperl...@gmail.comwrote:

 On Jun 26, 2013, at 1:56 PM, Stuart Dallas stu...@3ft9.com wrote:
  On Wednesday, 26 June 2013 at 18:39, Tedd Sperling wrote:
  Let me add, currently I am inserting an email address into a database.
 
  To find which record was created, I ask for the record number (ID) back.
 
  I am asking simply because mysql_insert_id() is deprecated.

 Now you tell me. :-)

 I learn something new every day of my life... and I'm getting damned tried
 of it.

 Back to the books.

 Thanks.

 Cheers,

 tedd

 _
 tedd.sperl...@gmail.com
 http://sperling.com

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




Re: [PHP] Some Advice

2013-06-25 Thread Samuel Lopes Grigolato
Hope it helps:
http://stackoverflow.com/questions/3740845/php-session-without-cookies (go
directly to the answer)


On Tue, Jun 25, 2013 at 9:15 AM, Floyd Resler fres...@adex-intl.com wrote:

 I use sessions to store login information.  However, a particular user of
 a site can only access it at the library which has cookies shut off.  So,
 I'm thinking of creating an entry in the database with a unique identifier
 and expiration time.  I would then pass that identifier to each page.  Does
 that sound like a good alternative to sessions or is there something else I
 could do?

 Thanks!
 Floyd



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




Re: [PHP] Some Advice

2013-06-25 Thread Samuel Lopes Grigolato
But please, PLEASE, read carefully: *If a user were to copy and paste the
URL of the page they were on, and someone else were to click on it, they
would both be using the same session.*


On Tue, Jun 25, 2013 at 9:17 AM, Samuel Lopes Grigolato 
samuel.grigol...@gmail.com wrote:

 Hope it helps:
 http://stackoverflow.com/questions/3740845/php-session-without-cookies (go
 directly to the answer)


 On Tue, Jun 25, 2013 at 9:15 AM, Floyd Resler fres...@adex-intl.comwrote:

 I use sessions to store login information.  However, a particular user of
 a site can only access it at the library which has cookies shut off.  So,
 I'm thinking of creating an entry in the database with a unique identifier
 and expiration time.  I would then pass that identifier to each page.  Does
 that sound like a good alternative to sessions or is there something else I
 could do?

 Thanks!
 Floyd



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





Re: [PHP] Some Advice

2013-06-25 Thread Samuel Lopes Grigolato
Just be cautious if going to check IP, because:

1) The two users could be in the same house or cybercafé, which gives them
the same IP.
2) The user could be traveling with a wireless card, his IP would change
quite a lot in this scenario.


On Tue, Jun 25, 2013 at 9:32 AM, p...@nobswolf.info wrote:

 You should at least check the IP of the client additionally to have some
 prove
 it is the same client you gave the session-ID.

 And it is better to put the session-ID in a POST-field than in GET. So it
 es very unlikely someone passes a session ID around accidently.

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




Re: AW: [PHP] PHP is Zero

2013-06-13 Thread Samuel Lopes Grigolato
I agree with you that this is a confusing and error-prone behavior, but I
also agree with Richard Gray, I wouldn't try to change this for the same
reason that a 1+1=3 shouldn't be touched if it's correct on a huge
amount of existing codebases...



On Thu, Jun 13, 2013 at 8:49 AM, BUSCHKE Daniel 
daniel.busc...@nextiraone.eu wrote:

 To be more technical:

 If intval('8315e839da08e2a7afe6dd12ec58245d') would return NULL instead of
 8315 then PHP would be still weak-typed and the developer could know that
 the conversion failed. Good idea? Of course NULL should be transparent in
 operations like +. So 0 + NULL should be still 0.

 Regards
 Daniel

 -Ursprüngliche Nachricht-
 Von: BUSCHKE Daniel
 Gesendet: Donnerstag, 13. Juni 2013 13:28
 An: 'Pete Ford'; php-general@lists.php.net
 Betreff: AW: AW: [PHP] PHP is Zero

 Hi,

  It gives up when it finds a non-numeric character (as the documentation
 would tell you)

 Why is PHP doing that? I know it works as designed and I know it is
 documented like this but that does not mean that it is a good feature, does
 it? So lets talk about the question: Is that behaviour awaited by PHP
 software developers? Is that really the way PHP should work here? May we
 should change that?!

 BTW: I talked to some collegues and friends since my first post. They all
 guessed that 'PHP' == 0 is false within a few seconds. I think the
 weak-typed-PHP is a little to weak at this point.

 Regards
 Daniel


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




Re: [PHP] PHP is Zero

2013-06-13 Thread Samuel Lopes Grigolato
Just found out that MySQL uses the same implicit conversion precedence on
SQL clauses. That shows me that possibly exists some higher order rule
that states this consistency, and changing that is outside the scope of PHP.


On Thu, Jun 13, 2013 at 9:20 AM, Stuart Dallas stu...@3ft9.com wrote:

 On 13 Jun 2013, at 12:27, BUSCHKE Daniel daniel.busc...@nextiraone.eu
 wrote:

  Hi,
 
  It gives up when it finds a non-numeric character (as the documentation
 would tell you)
 
  Why is PHP doing that? I know it works as designed and I know it is
 documented like this but that does not mean that it is a good feature, does
 it? So lets talk about the question: Is that behaviour awaited by PHP
 software developers? Is that really the way PHP should work here? May we
 should change that?!
 
  BTW: I talked to some collegues and friends since my first post. They
 all guessed that 'PHP' == 0 is false within a few seconds. I think the
 weak-typed-PHP is a little to weak at this point.

 I don't know what the actual reasoning is; if you want that I suggest you
 ask on the internals list, but be careful how you phrase the question. If
 it's pure curiosity then that's fine, but whether you agree with the
 reasoning or not it's gone way past the point where it can be changed.

 My take it that the behaviour is perfectly reasonable. When you compare
 two different types it has to convert one of them. If you're comparing a
 string to a number it seems logical to me that the number should be the
 preferred type, so the string gets converted. What would you expect
 array(5) == 5 to give you? Would you expect the 5 to be converted in to an
 array? No. The reason it looks odd for PHP == 0 is that there's no reason
 why the 0 should not be converted to 0, except that strings and numbers
 are not the only types available and there has to be an order of
 precedence. And consistency is key.

 As for how strings get converted to numbers I have no idea why it will
 take everything up to the first non-e|E|. character. The documentation[1]
 simply states the behaviour and doesn't go in to why. However, I have to
 ask why it matters? Why would you want to convert
 '8315e839da08e2a7afe6dd12ec58245d' to an integer? If you have code that's
 juggling it automatically, be more explicit. It's fine to be interested in
 the reasons why it does what it does, but if it's causing you problems then
 the issue is with your code not being explicit enough, not PHP.

 -Stuart

 [1] http://php.net/language.types.string#language.types.string.conversion

 --
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Detecting massive web hits

2013-04-12 Thread Samuel Lopes Grigolato
I don't know exactly how search engine spiders work, but just be cautious
to not block these users, they aren't customers but they may bring you
some =).

Again, I don't know if this is your case, but the possibility sparked on my
mind anyway.

Cheers.


On Fri, Apr 12, 2013 at 12:23 PM, Angela Barone ang...@italian-getaways.com
 wrote:

 Does anyone know if there's a ready-made script that detects if
 someone hits multiple web pages within seconds of each other and then can
 temporarily ban them by IP from accessing our site?

 Looking through the logs, I see someone/something hit each and
 every page of a site I work on within only a few seconds of each other.  I
 seriously doubt they are a customer. ;)

 I'd appreciate any insights.

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




Re: [PHP] target question

2013-03-25 Thread Samuel Lopes Grigolato
Have you tried to set a Content-Disposition header in the PHP script that
creates the PDF, asking the browser to attach the download? This way you
don't even need a new window.

Example from php.net/manual:

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename=downloaded.pdf');


On Mon, Mar 25, 2013 at 11:01 AM, Jim Giner jim.gi...@albanyhandball.comwrote:

 target as in the form attribute

 In my appl devl I utilize an extra window when my current form is asked to
 generate a pdf report.  Works well since that way the user can generate one
 report into a new window, read it, close it, and still have the reports
 menu in front of him/her and generate a 2nd report.

 I'm experiencing a problem tho and I'm guessing it's associated with ie9
 or FPDF. In my reports menu form, when I click on a button that will
 generate a pdf, I alter the form's target to create a new window.  This
 used to work last fall, but since then I have a new laptop running ie9, not
 8.  The target changing js logic is working as far as I can see (alerts in
 my js) but the effect is not there.  Instead of a new window, the pdf opens
 up in the same window where the menu was and so when the user does a back
 he ends up going up one too many levels and has to re-request the reports
 menu.

 Didn't have this much trouble originally setting this up as I'm having now
 trying to debug this.  I'm using the FPDF extension/class to generate my
 pdfs - made no recent changes there.  Also my concept works very well still
 in a simple html document that has only two buttons on it which I created
 today to test a theory.  That is - maybe it's not just IE9, but FPDF.

 Anyone have any experience in this area?

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




Re: [PHP] target question

2013-03-25 Thread Samuel Lopes Grigolato
With the header Content-Disposition: attachment the browser will
offer the response as a regular file download (with save/open
options). Your original page (menu) will remain intact.

Please note that this solution will not present the PDF directly to
the user (as it would with a popup window), instead he will need to
open the downloaded file in his computer.

On Mon, Mar 25, 2013 at 12:23 PM, Jim Giner
jim.gi...@albanyhandball.com wrote:
 On 3/25/2013 10:13 AM, Samuel Lopes Grigolato wrote:

 Have you tried to set a Content-Disposition header in the PHP script that
 creates the PDF, asking the browser to attach the download? This way you
 don't even need a new window.

 Example from php.net/manual:

 // It will be called downloaded.pdf
 header('Content-Disposition: attachment; filename=downloaded.pdf');


 On Mon, Mar 25, 2013 at 11:01 AM, Jim Giner
 jim.gi...@albanyhandball.comwrote:

 target as in the form attribute

 In my appl devl I utilize an extra window when my current form is asked
 to
 generate a pdf report.  Works well since that way the user can generate
 one
 report into a new window, read it, close it, and still have the reports
 menu in front of him/her and generate a 2nd report.

 I'm experiencing a problem tho and I'm guessing it's associated with ie9
 or FPDF. In my reports menu form, when I click on a button that will
 generate a pdf, I alter the form's target to create a new window.  This
 used to work last fall, but since then I have a new laptop running ie9,
 not
 8.  The target changing js logic is working as far as I can see (alerts
 in
 my js) but the effect is not there.  Instead of a new window, the pdf
 opens
 up in the same window where the menu was and so when the user does a back
 he ends up going up one too many levels and has to re-request the reports
 menu.

 Didn't have this much trouble originally setting this up as I'm having
 now
 trying to debug this.  I'm using the FPDF extension/class to generate my
 pdfs - made no recent changes there.  Also my concept works very well
 still
 in a simple html document that has only two buttons on it which I created
 today to test a theory.  That is - maybe it's not just IE9, but FPDF.

 Anyone have any experience in this area?

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



 And what happens to my original menu window?


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


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



Re: [PHP] Re: application level variable file

2013-03-22 Thread Samuel Lopes Grigolato
I highly suggest you to read some begginers book or the
php.net/manualbefore trying to implement other technologies concepts
with PHP. That is
because you WILL find some tricks to do what you want, and you'll think
PHP is a big chunk of bad smelling code, a totally wrong concept.

Forget momentarily the roots and learn PHP with a clear space on your RAM.

Cheers!


On Fri, Mar 22, 2013 at 12:13 PM, Jim Giner jim.gi...@albanyhandball.comwrote:

 On 3/22/2013 10:22 AM, inu...@gmail.com wrote:

 I am very new to the PHP application and would like to create a new
 project.
 I would like to have a file to save my application level variable and
 functions.

 I would like to know does PHP have any default file name and file path for
 this file like Web.config file for ASP.Net and Application.cfm for
 ColdFusion?

 Your help and information is great appreciated,

 Regards,

 Inungh

 Why not try reading the php manual to get an understanding of how PHP
 works first??  You obviously haven't learned about the include/require
 statements and what they can do.


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




Re: [PHP] variable type - conversion/checking

2013-03-18 Thread Samuel Lopes Grigolato
Sorry if I'm missing something, there's a lot of replies after my first
post on this thread.

Is there something wrong with the floor() approach? I liked the regex
solution but isn't it more expensive and more verbose than just doing a
well commented is_numeric plus floor/ceil math?

Just trying to understand the motivations behind the preferences.

Thanks.


On Sun, Mar 17, 2013 at 7:17 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Sun, Mar 17, 2013 at 10:20 PM, Maciek Sokolewicz 
 maciek.sokolew...@gmail.com wrote:

  On 16-3-2013 19:20, Matijn Woudt wrote:
 
  On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz 
  maciek.sokolew...@gmail.com wrote:
 
   Hi,
 
 
  I have tried to find a way to check if a character string is possible
 to
  test whether it is convertible to an intger !
 
  any suggestion ?
 
  BR georg
 
 
  All responses in this thread have been very nice; but you could also
 try
  a
  much simpler 2-step check:
 
  1. is_numeric
  2. if true  check if there's a decimal character in the string:
 
  if(is_numeric($str)  false === strpos('.', $str)) {
  // it's an int for sure
  } else {
  // might be a number, but it's definitly not an int
 
  }
 
 
  Wrong.  is_numeric will accept 1e1, which is a float, so you would need
 to
  check for e or E too.
 
  - Matijn
 
   Although in theory I agree, indeed any e* number is treated as a
  floating point number. However, considering the exponent and the base are
  forced to be integer numbers (due to exclusion of decimal points), in the
  real number system, you will *always* end up with a natural number, i.e.
  integer. Regardless of your input.
 
  So as a result, the input could always be interpreted as an integer,
  without any precision-loss using the method above.
  - Tul
 

 Except... that it might not fit in an 32 or 64 bit integer, which would
 lead to precision loss.

 - Matijn



Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Samuel Lopes Grigolato
Something like if (is_numeric($var)   $var == floor($var)) will do the
trick. I don't know if there's a better (more elegant) way.


On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt tijn...@gmail.com wrote:

 On Thu, Mar 14, 2013 at 7:02 PM, georg georg.chamb...@telia.com wrote:

  Hi,
 
  I have tried to find a way to check if a character string is possible to
  test whether it is convertible to an intger !
 
  any suggestion ?
 
  BR georg


 You could use is_numeric for that, though it also accepts floats.

 - Matijn



Re: [PHP] Re: Generating CRUD code for normalized db

2013-03-11 Thread Samuel Lopes Grigolato
If you don't appreciate Open Source solutions, why are you losing time on
a Open Source Project Mailing List? Go pay (a lot) for a handholding
framework and be happy =), just don't demotivate the ones who bring free
software to reality, even if the free software is not as good as you would
like.


On Mon, Mar 11, 2013 at 11:51 AM, Gary listgj-phpgene...@yahoo.co.ukwrote:

 Ashley Sheridan wrote:
  Gary listgj-phpgene...@yahoo.co.uk wrote:

 The inadequacies of so much Free Open Source Shit never ceases to
 amaze me. Too many wannabes doing it who overestimate their own
 capabilities and have no clue what is really required in the real
 world.
 
  Well, you don't really help yourself with a reply like that to the very
  people helping you.

 I wasn't aware you would feel that the cap fitted.

  I and others have pointed you towards open source solutions, the fact
  you don't want to put any effort in to make them work for you is not
  because of the state of open source software.

 If you think that solutions are things which do not work, following
 precisely the instructions on those solutions' websites, then I feel
 sorry for you.

 --
 GaryPlease do NOT send me 'courtesy' replies off-list.


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




RES: [PHP] Array help.

2012-10-24 Thread Samuel Lopes Grigolato
Could you try changing this:

if($groupTest != FALSE) {

to this:

if($groupTest !== FALSE) {

?

-Mensagem original-
De: Paul Halliday [mailto:paul.halli...@gmail.com] 
Enviada em: quarta-feira, 24 de outubro de 2012 15:38
Para: PHP-General
Assunto: [PHP] Array help.

I am processing v4IP's and what I want to do is a prefix substitution if the
3rd octet matches a predefined list $groupMappings. I went down this  path
and it isn't working as expected. Drawing a blank on this one. Why does 40
miss the comparison?

$hostname = Z;
$ips = array('10.1.40.1','10.1.41.1','10.1.1.1','10.1.40.1','10.9.1.1');

foreach ($ips as $ip) {

$groupMappings = array('40' ='A','41' ='B','1' ='C');

$ocTest = explode(., $ip);
$groupKeys = array_keys($groupMappings);
$groupTest = array_search($ocTest[2], $groupKeys);

if($groupTest != FALSE) {
$hostGroup = $groupMappings[$groupKeys[$groupTest]];
echo Hit! $ip : $hostname : $hostGroup\n;
} else {
$hostGroup = substr($hostname, 0,2);
echo Miss! $ip : $hostname : $hostGroup\n;
}
}

Miss! 10.1.40.1 : Z : Z
Hit! 10.1.41.1 : Z : B
Hit! 10.1.1.1 : Z : C
Miss! 10.1.40.1 : Z : Z
Hit! 10.9.1.1 : Z : C

Thanks!

--
Paul Halliday
http://www.pintumbler.org/

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



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



Re: [PHP] Re: User Timezone

2012-10-21 Thread Samuel Lopes Grigolato
Sorry if it's to dumb or hacky solution, but can't you just create a Date
with JavaScript and send it with your request in a hidden field? You could
guess the timezone with this date and the server's one.

I don't know what you're going to do with this info, just be aware that if
the users clock is wrong intentionally or not, this will obviously not work
correctly. Although I think (just an assumption) that 99% of user's clock
are in fact, correct.

Another thing I'm thinking now is for users out on a travel, if they aren't
in their home, you will get a wrong date.

I'm with Maciek on this, TimeZones doesn't change a lot, it's not too
difficult to develop a simple from/to database based on the country and
state/province names. You may even start a Open Source project and get
collaborators to help maintain this database on an open format (okay, maybe
this is not going to happen, maybe).

Cheers,
Samuel.

On Sun, Oct 21, 2012 at 9:12 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:



 Karl DeSaulniers k...@designdrumm.com wrote:

 
 On Oct 21, 2012, at 5:01 AM, Maciek Sokolewicz wrote:
 
  On 21-10-2012 01:11, Karl DeSaulniers wrote:
  Thanks for the response. Yes, for the US I plan on calculating by
  state, but
  this website is not geared to just the US.
  So I am looking for a solution that lets me also calculate by
  country/region.
  Was looking on google and found geoip, but not sure if this will
 do
  the job
  I am looking for.
  Anyone with experience on geoip that can send pointers?
 
  Thanks,
 
 
  Best,
  Karl DeSaulniers
  Design Drumm
  http://designdrumm.com
 
 
  Geo IP is based on IP, and I must warn you that IP data is not
  always
  accurate. Especially here in Europe, companies that are based in
  multiple countries sometimes only register their IPs in a single
  country, and share them between all the countries they are active
  in.
  This will give you wrong data from GeoIP. The time difference will
  only be 1 hour at max, but still.
 
 
  That was what my own suspicions were leading to.
  I am familiar with the fact that ips can be spoofed.
  Thanks for the corroboration.
 
  Best,
 
  Karl DeSaulniers
  Design Drumm
  http://designdrumm.com
 
 
  As Bart said, IP is not ideal for this situation.
 
  Since you do have information about the location of that person (as
  in country and possible state), you can find out the timezone via a
  static database.
 
  The HTML5 geolocation tool is nice, and would certainly help a lot!
  However, be aware of the fact that it only works if there is the
  device on which the browser runs actually has the ability to find
  out its location. Many smartphones have GPS chips, but most PCs
  don't. Asking a PC where are you located? the PC will answer How
  should I know?.
 
  Luckily for you, the way of country and state is pretty easy. I've
  handed you a list to find it in the USA. For most countries in the
  world, there's a simple 1:1 mapping of timezone and country
 (http://en.wikipedia.org/wiki/List_of_time_zones_by_country
  ), there are however 21 countries which have multiple timezones. In
  these cases, you'll need extra information to be able to distinguish
 
  between them.
 
  For the USA, you already have a way.
  For (ex-)colonical islands and such (such as for France), you could
  always add them to the country list:
  - France
  - France (Marquesas Islands)
  - France (Gambier)
  etc.
  Thus treating them as separate countries for your timezone db.
 
  In Russia, Canada, Australia, New Zealand, Brasil, Indonesia,
  Kiribati, Mexico,Congo, Ecuador, Micronesia, Kazakhstan and Mongolia
 
  you'll need to know their province / state to more accurately assess
 
  the ideal timezone.
 
  So for most countries, it's a simple 1:1 translation. For the above
  countries, you'll need some extra info, and translate further based
  on that. You should be able to find the info required yourself, it
  just takes a while to collect it.
 
  Alternatively, and this is the most simple way; since you're asking
  people for their country and such, simply also ask them about their
  timezone. Don't bother automating and putting a heck of a lot of
  time into hard to realize solutions, when you can ask a very simple
  and easy-to-answer question to the browser instead. :)
 
  - Tul
 
 
 Yes, I had thought about asking the user his/her timezone, but being
 that the product will be bought by some people who may have no idea, I
 
 figured I would try and see if I can set it up myself.
 Maybe if the country has a province, i could ask the user then what
 province and get my 1:2 that way. If it is a country I can get the
 timezone for, just skip that question.
 Thanks for the thoughts!
 
 Best,
 
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com

 Don't most browsers include this information in the HTTP headers?
 --
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

RES: [PHP] Re: User Timezone

2012-10-21 Thread Samuel Lopes Grigolato
Coincidentally, TODAY I had to adjust my clock one hour forward because of DST 
(poor sleep =[). No so easy-to-solve problem, after all...

-Mensagem original-
De: Matijn Woudt [mailto:tijn...@gmail.com] 
Enviada em: domingo, 21 de outubro de 2012 10:30
Para: Maciek Sokolewicz
Cc: Karl DeSaulniers; php-general
Assunto: Re: [PHP] Re: User Timezone

On Sun, Oct 21, 2012 at 12:01 PM, Maciek Sokolewicz 
maciek.sokolew...@gmail.com wrote:
 On 21-10-2012 01:11, Karl DeSaulniers wrote:

 Thanks for the response. Yes, for the US I plan on calculating by 
 state, but this website is not geared to just the US.
 So I am looking for a solution that lets me also calculate by 
 country/region.
 Was looking on google and found geoip, but not sure if this will do 
 the job I am looking for.
 Anyone with experience on geoip that can send pointers?

 Thanks,


 Best,
 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com



 Geo IP is based on IP, and I must warn you that IP data is not 
 always accurate. Especially here in Europe, companies that are based 
 in multiple countries sometimes only register their IPs in a single 
 country, and share them between all the countries they are active in.
 This will give you wrong data from GeoIP. The time difference will 
 only be 1 hour at max, but still.



 That was what my own suspicions were leading to.
 I am familiar with the fact that ips can be spoofed.
 Thanks for the corroboration.

 Best,

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 As Bart said, IP is not ideal for this situation.

 Since you do have information about the location of that person (as in 
 country and possible state), you can find out the timezone via a 
 static database.

 The HTML5 geolocation tool is nice, and would certainly help a lot! 
 However, be aware of the fact that it only works if there is the 
 device on which the browser runs actually has the ability to find out 
 its location. Many smartphones have GPS chips, but most PCs don't. 
 Asking a PC where are you located? the PC will answer How should I know?.

 Luckily for you, the way of country and state is pretty easy. I've 
 handed you a list to find it in the USA. For most countries in the 
 world, there's a simple 1:1 mapping of timezone and country 
 (http://en.wikipedia.org/wiki/List_of_time_zones_by_country), there 
 are however 21 countries which have multiple timezones. In these 
 cases, you'll need extra information to be able to distinguish between them.

 For the USA, you already have a way.
 For (ex-)colonical islands and such (such as for France), you could 
 always add them to the country list:
 - France
 - France (Marquesas Islands)
 - France (Gambier)
 etc.
 Thus treating them as separate countries for your timezone db.

 In Russia, Canada, Australia, New Zealand, Brasil, Indonesia, 
 Kiribati, Mexico,Congo, Ecuador, Micronesia, Kazakhstan and Mongolia 
 you'll need to know their province / state to more accurately assess the 
 ideal timezone.

 So for most countries, it's a simple 1:1 translation. For the above 
 countries, you'll need some extra info, and translate further based on that.
 You should be able to find the info required yourself, it just takes a 
 while to collect it.

 Alternatively, and this is the most simple way; since you're asking 
 people for their country and such, simply also ask them about their 
 timezone. Don't bother automating and putting a heck of a lot of time 
 into hard to realize solutions, when you can ask a very simple and 
 easy-to-answer question to the browser instead. :)

 - Tul


Don't forget that some countries have DST, and some don't. And those that have 
DST, all use different dates.. So in to keep a static database you would also 
need to have DST info from all countries.

- Matijn

--
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



RES: [PHP] Re: User Timezone

2012-10-20 Thread Samuel Lopes Grigolato
Have you tried Google Timezone API?
(https://developers.google.com/maps/documentation/timezone/)

I don't know if it's free to use, probably not.

You may note that you need user's longitude/latitude to query this API. A
solution is to query Google Places API
(https://developers.google.com/places/) based on the State name, or use the
HTML5 Geolocation API (http://www.w3schools.com/html/html5_geolocation.asp,
I won't recommend as AFAIK it is not stable, others could correct me).

Hope it helps.

Cheers,
Samuel.

-Mensagem original-
De: Maciek Sokolewicz [mailto:tula...@gmail.com] Em nome de Maciek
Sokolewicz
Enviada em: sábado, 20 de outubro de 2012 09:24
Para: Karl DeSaulniers
Cc: php-general
Assunto: [PHP] Re: User Timezone

On 20-10-2012 09:39, Karl DeSaulniers wrote:
 Hello all,
 Happy weekend. Hoping you can help me with an age old question.
 I am trying to get a users timezone for a purchase online.
 I know that php is not really able to get a timzone of a user because 
 its a server side execution with the date functions.
 But I wanted to get a little help on my work around. I am hoping 
 someone can help. TIA

 I have a form that a user must fill out in order to purchase anything.
 On this form they are required to put their city, state, country and 
 zip code.
 These are all required fields.

 Now, I know there is a way to get a timezone offset if you have a 
 location to offset.
 So is there a way based on the fields provided that I can get that 
 offset for each user?

 (The users have to put a correct city, state, country and zip in order 
 to get there purchase.
 This address has to match their paypal or cc address in order to 
 purchase as well.
 So I know there will still be a margin of error with user manipulated 
 info. So that is moot point for now.)

 My thoughts are to get a timezone offset based on the country and zip 
 code, with a backup check of city state country zip.
 I just don't know where to start looking for how to get the timezone 
 or UTC location based on country and zip or city state country zip.


Hi Karl,

so basically what you're looking for is a database map between timezone and
country/state/zip.

Did you try to google such a thing?

One of the first posts I found was a StackOverflow question about this; one
of the answers mentioned just such a database on Tom Boutell's website (the
same person who created the GD library [used for image-creation in php]):
http://www.boutell.com/zipcodes/ It includes states, cities, zip codes, etc.
for the USA. Since you specifically mentioned you want to find it by
state, it means you're mainly focussing on the USA (barely any other
country even bothers with states).

Apart from the above data, I'm sure you can find more on google.

Good luck.
- Tul


--
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



RES: [PHP] foreach

2012-10-16 Thread Samuel Lopes Grigolato
There is some cases that more code (and more cycles) is a good thing. For
example, a multi-layer architecture (like presentation, business and data
access) is more cpu-intensive than a single page doing everything in an
entangled procedural style, but is far more easy to evolve!

As Steven said, you need to use the right tool for the job. If you're going
to write some cryptographic API for mission-critical applications, or a
network protocol for games with extreme bandwidth demands, every =
matters, otherwise, better to stick with readability and separation of
concerns.

Cheers,
Samuel.

-Mensagem original-
De: Steven Staples [mailto:sstap...@mnsi.net] 
Enviada em: terça-feira, 16 de outubro de 2012 10:46
Para: 'David McGlone'; 'Bastien'; 'PHP-GENERAL'
Assunto: RE: [PHP] foreach

 Here's what I ended up with after you gave me the advise:
 $result = mysql_query(SELECT * FROM items);
   $rows = array();
   while($row = mysql_fetch_array($result))
$rows[] = $row;
   foreach($rows as $row){
   $product = $row['product'];
   $price = $row['price'];
 echo $product ;
 echo $price ;
 
 
 $justright = 0;
 $toohigh = 5; //I was going to use this to check if the price was 
 too high
   just so I could use an elseif in the
exercise, but
 I realized that
   it would only work if the if() evaluated to
false,
 which would be
   impossible. Ahhh pizz on it, it was fun
anyway! :-
 )
 
 if($justright = $price){
  echo Not bad. I'll buy it.br /;
   } else
  echo Too expensive I'm going home LOL ;
 
   }
 
 It's a dumb script that makes no sense but I had a blast doing this. 
 When things start coming together like this, it gets so gratifying. 
 :-)
 
  --
 David M.


David, 

Just putting this out there, but the use of a foreach() loop here, is
redundant...
You are putting your query results into an array, and then looping through
them after with the foreach(), instead of just using the while loop to loop
through them initially... so you're doing the same thing, twice, just using
the foreach() after the while.

One thing I was always told when I was learning c++ (my teacher was anal,
and always forced us to try and be more efficient), using = uses more cpu
cycles, than  or , so when you're checking 0 = 0.1 true, false, you could
exchange your check to be 0  0.1 false, else true...

Also, setting the variable $product and $price, with the value from the
database $row['product'], would be less cycles than to just echo the
$row['product']...

That is just some $0.02...  I wouldn't personally create more code, just to
try something out... use the right function for the job, write less code
than needed (sometimes, a little more code for readability is better
though), and most importantly... have fun.

One thing I do, is my coding and bracing style is something that Tedd
Sperling doesn't like (there have been many discussions about bracing
styles),  I keep my braces all in line, and always use them in my if()s...
ie:
If($yourmom == $hot)
{
Echo MILF!;
}
Else
{
Echo Pass.;
}

And I do this for readability, so I can see if I forgot a brace somewhere,
and also, I always know that there are braces (with a 4space indentation, or
tab stops set at 4 space)

1 more point, doing multiline comments, use /*  insert comment here */  and
not just //, and with that, I use inline comments with #,  but that is just
me.

Overall though, I am glad to see you're learning, and having fun doing so...


Steve Staples.


--
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



RES: [PHP] Re: limiting

2012-10-09 Thread Samuel Lopes Grigolato
I don't know if it has any value, but here's my 2 cents:

People here expect tricky questions. Of course to be tricky is subjective and 
is based on your knowledge level. When posting, please try to write every bit 
of effort you had so far trying to solve your problem.

Besides that, please, don't feel sad or ignored or whatsoever if the answers 
you've got wasn't satisfactory or doesn't came at all. As Matijn said, this 
list isn't meant to be a hand holding professional support and it may happen 
that the ones with the knowledge simply doesn't got the time to help.

Remember that any answer is given with nothing in return, so, read carefully 
and follow the wise advices provided by the ones that learned the hard way and 
are here today softening the path for the newcomers. 

Everything should be interpreted as directions and hints, and not as yells or 
other bad things, doesn't matter how bad the words appear to be.

Good luck in your path.

-Mensagem original-
De: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Enviada em: terça-feira, 9 de outubro de 2012 17:07
Para: php-general@lists.php.net
Assunto: Re: [PHP] Re: limiting

On 10/9/2012 3:46 PM, Matijn Woudt wrote:
 On Tue, Oct 9, 2012 at 9:18 PM, David McGlone da...@dmcentral.net wrote:
 On Tuesday, October 09, 2012 12:18:06 PM Jim Giner wrote:

 Sorry to be so blunt.

 It's fine I kinda figured I'd be either ignored, or yelled at when I 
 asked and I now know that I need to be a professional to ask 
 questions here so there went my confidence.

   --
 David M.


 David,

 You really don't need to be a professional here to ask questions, but 
 you can imagine that we're not going to write code for you. Some 
 people expect professional support here (like they paid for it), and 
 that's clearly not the case. We are all volunteers with our (limited) 
 spare time. Therefore, you're expected to figure out most things out 
 yourself (reading PHP manual, google, etc), and only ask here if you 
 really can't figure things out. Then you can post what you have tried, 
 and what you think it should do. For example your previous post, you 
 could have just looked up what the 'echo' and 'return' statements do 
 in the PHP manual, and they are probably explained pretty OK in those 
 books you own too. You probably could have answered the questions you 
 posted here yourself, after reading PHP manual carefully.

 - Matijn

Matijn - well said.

--
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



RES: [PHP] Re: problem with my login script

2012-10-02 Thread Samuel Lopes Grigolato
I follow this rule of thumb: small blocks of highly understandable code. If 
this demands ternary conditionals or breaks, so be it!

-Mensagem original-
De: Tim Streater [mailto:t...@clothears.org.uk] 
Enviada em: terça-feira, 2 de outubro de 2012 08:37
Para: PHP General List
Assunto: [PHP] Re: problem with my login script

On 02 Oct 2012 at 12:07, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote:

 On 02-10-2012 11:59, Bálint Horváth wrote:
 The problem was already solved. I forgot to send a copy to the list...

 Rodrigo, break!? Ohh man, it's a crazy idea... A developer DOES NOT 
 use break at all (in a loop)... (switch is an exception)

 I personally find this statement to be utter bullshit. There is 
 nothing wrong with using break. There is a very good reason why it's 
 available in the language. In very many cases, it costs a lot less 
 code to add a break than to add additional clauses to your while-conditional.

Agree 100%.

--
Cheers  --  Tim


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



RES: [PHP] Re: {ATTENTION} Re: [PHP] base64_decode

2012-10-02 Thread Samuel Lopes Grigolato
Another way to decode and inspect such data is to use utilities like:
http://www.motobit.com/util/base64-decoder-encoder.asp 

By the way, never saw before this kind of sloppy irritating malicious
obfuscation =).

Does your server allow execution of the eval function? I consider this a
security breach especially if your apache user is not correctly sandboxed.
I wonder if there is a way to disable execution of this method on shared
servers. AFAIK there is a way, I just can't remember how to do it.

Cheers.

-Mensagem original-
De: John Taylor-Johnston [mailto:john.taylor-johns...@cegepsherbrooke.qc.ca]

Enviada em: terça-feira, 2 de outubro de 2012 14:46
Para: Rodrigo Silva dos Santos
Cc: PHP-General
Assunto: [PHP] Re: {ATTENTION} Re: [PHP] base64_decode

Interesting.
Thanks.
It was a footer.php in a webpress theme.
I was wondering if it was a portal someone was using to get onto my server.
I changted ftp passwords and begun using sftp, but phishing code is still
leaking onto my sites. My wordpress copies are up to date and DreamHost has
no real answers as to how someone is uploading and expanding *.tar.gz files.

Thanks,
john

Rodrigo Silva dos Santos wrote:


 Hello John.

 This code generates the following html:


 ? /div
 div id=footera href=*MailScanner has detected a possible fraud 
 attempt from web-hosting-click.com claiming to be* 
 http://web-hosting-click.com/; title=Web hostingWeb hosting/a
 !-- 27 queries. 0.561 seconds. --
 /div
 ?php wp_footer(); ?
 /body
 /html ?

 Appears that is nothing dangerous, only unauthorized advertising.




 Em 02-10-2012 14:27, John Taylor-Johnston escreveu:
 Without anyone infecting their machines, can someone tell me what 
 this is? I found a phishing site on my DreamHost server. DreamHost 
 has been very helpful.
 We found a file containing this code.
 What is it? What does it contain?

 ?php
 eval(base64_decode('Pz4gPC9kaXY+DQo8ZGl2IGlkPSJmb290ZXIiPjxhIGhyZWY9I
 mh0dHA6Ly93ZWItaG9zdGluZy1jbGljay5jb20vIiB0aXRsZT0iV2ViIGhvc3RpbmciPl
 dlYiBob3N0aW5nPC9hPg0KPCEtLSAyNyBxdWVyaWVzLiAwLjU2MSBzZWNvbmRzLiAtLT4
 NCjwvZGl2Pg0KPD9waHAgd3BfZm9vdGVyKCk7ID8+DQo8L2JvZHk+DQo8L2h0bWw+IDw/
 '));?



--
John Taylor-Johnston

Département de Langues modernes
Cégep de Sherbrooke, Sherbrooke, Québec
http://cegepsherbrooke.qc.ca/~languesmodernes/
http://cegepsherbrooke.qc.ca/~languesmodernes/wiki/



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



RES: [PHP] Joining a team, where no wiki or docs are available

2012-09-24 Thread Samuel Lopes Grigolato
I would recommend reading this article: 
http://www.infoq.com/articles/tips-to-developers-starting-on-large-apps

It's targeted to Java developers, but the concepts are valid to any language.

Hope it helps.

Cheers,
Samuel.

-Mensagem original-
De: AmirBehzad Eslami [mailto:behzad.esl...@gmail.com] 
Enviada em: segunda-feira, 24 de setembro de 2012 11:05
Para: PHP General Mailing List
Assunto: [PHP] Joining a team, where no wiki or docs are available

Hi,

i'm going to join a mid-size company with a few PHP-driven projects written in 
procedural PHP, million years old.

At the moment, they don't have a wiki or any documentation about their 
projects. For me, the first challenge in probation period is to understand how 
their code works.
*
Considering that there is no wiki or docs, How can I see the Big Picture?* i'm 
sure this is a common problem for programmers everywhere.

What approach do you use in a similar situation?
Is there a systematic approach for this?
Is there reverse-engineering technique to understand the design of code?

Please share your experience and thoughts.

-Thanks in advance,
Behzad


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



RES: [PHP] Re: Joining a team, where no wiki or docs are available

2012-09-24 Thread Samuel Lopes Grigolato
What about using visual code coverage instead of callstacks? I think the big 
picture is easier to digest. Maybe a combination of both, as code coverage 
won't provide the time axis of the monster.

Something like http://phpcoverage.sourceforge.net/

-Mensagem original-
De: Mihamina Rakotomandimby [mailto:miham...@rktmb.org] 
Enviada em: segunda-feira, 24 de setembro de 2012 11:58
Para: PHP General
Assunto: Re: [PHP] Re: Joining a team, where no wiki or docs are available

On 09/24/2012 05:38 PM, AmirBehzad Eslami wrote:
 #1 Start using the software as an End-User (don't care about the code) 
 to understand the business-value of the software
 #2 Take a look at the database scheme, try to understand the entities 
 and their relations
 #3 As you use the software, you'll become more curious about its 
 features and how they've implemented.
 #4 Start to see how they've implemented common problems, such as:
 Authentication, CRUD, etc. How the other interesting features are 
 implemented

#5 install xdebug + geben + emacs and have a look at the call stacks and 
bottlenecks.

--
RMA.

--
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



RES: [PHP] Day after Friday

2012-09-23 Thread Samuel Lopes Grigolato
Independent of programming language, good teaching skills will lead to 
self-taught developers with a bunch of best practices under the hood. I hope 
you are such a good teacher =). We need not PHP or Java developers, we need 
good and creative designers that can adapt to new tools.

One language is only a path among others with the same goal, software with 
quality. Remember Brooks (1986, yes, that old!), the real problem (essence of 
software engineering) is capture business requirements as specifications, and 
not translate specifications to software.

The point is, you, as a teacher, has a wider responsibility, you need to find 
and incentive creative talents, not just teach one or another native function.

Cheers.
Samuel.

-Mensagem original-
De: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Enviada em: domingo, 23 de setembro de 2012 10:55
Para: php-general@lists.php.net
Assunto: Re: [PHP] Day after Friday

On Sun, Sep 23, 2012 at 8:33 AM, Tedd Sperling t...@sperling.com wrote:
 On Sep 22, 2012, at 3:59 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Sat, Sep 22, 2012 at 01:05:51PM -0400, Tedd Sperling wrote:

 Hi gang:

 I know it's the Day after Friday, but I'm asking a off-topic question 
 anyway -- sorry.

 Normally, I teach a PHP class at the local college, but it got canceled 
 (don't ask why) -- now I'm teaching Java.

 So, can anyone recommend a Java list that is similar to this list?

 Off off topic...

 Who the hell cancels a PHP class? Do they not realize damn near the 
 whole internet runs on PHP? Wordpress, Drupal, Joomla, Facebook ad 
 nauseum, not to mention Symfony, CakePHP, Code Igniter, etc.
 Administrators! Ach!

 Paul

 Paul:

 The class was canceled by administration and they have absolutely no 
 conception of the technology and scope that PHP brings to the table. In fact, 
 they were so opposed to PHP that when I first started teaching there they had 
 PHP removed from their servers because of security concerns. So, for me to 
 teach PHP, they were forced to install PHP/MySQL.

 Now that you asked, here's the story about my PHP class.

 The college moved the entire CIT (Computer Information Technology) department 
 five miles from the downtown campus, where it has always been, to the new 
 West campus. It's a nice campus, but no Macs -- admin said Mac don't meet 
 their ROI requirement, but that's another story.

 Of course, most students don't have transportation and there is no 
 established public transportation from main campus to west campus -- that's 
 not good.

 Knowing that the students were going to have problems with transportation and 
 that would result in a reduction in class sizes, the administration agreed to 
 allow smaller than normal classes for the Fall semester. Furthermore, the 
 administration agreed to allow registration to be for a longer period than 
 normal, namely from a couple of weeks before the semester started to a week 
 after the semester started.

 Everything sounds ok, right?

 My PHP class had six students register two weeks before the class started. I 
 expected, as is custom, to pick up a couple of students after the semester 
 started thus exceeding the minimum number of student required. Furthermore, I 
 agreed to teach the class at a reduced rate if there wasn't a sufficient 
 number of students attending. BTW, administration had not made a 
 determination as to exactly what the minimum class-size should be -- keep in 
 mind, they only had two years to decide and these things take time.

 So what happened?

 Well we (the teachers) have a new contract and in that contract is a 
 provision that allows for a reduced class size IF the teacher agrees to teach 
 it at a reduced rate -- which I agreed to do. However, administration became 
 confused as to how to pay a full time teacher IF they taught an undersized 
 class. So, their solution was to cancel ALL under sized classes before the 
 semester started. That way there would be no confusion as to what to pay.

 Now, in my case I am the only teacher to teaches PHP, so there would be no 
 full time teacher that might teach it. I am also an adjunct (part time) 
 teacher and as such there is no confusion as to my pay. I am simply paid 
 hourly and a reduced class size would result in my rate being reduced. So, 
 there was absolutely no reason what-so-ever for my class to be cancelled. 
 Leaps and bounds of illogic.

 This is just another example of how administration makes decisions. It would 
 be nice if administration decisions were made with respect to what is best 
 for the student as compared to this type of nonsense.

 Cheers,

 tedd

 _
 t...@sperling.com
 http://sperling.com


Oh, Administrators!! The bane of teachers everywhere. The anti-teacher.

Maybe you could slip a little PHP in on the Java kids... :)

Unfortunately, I have no Java list resources...

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

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



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



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

RES: [PHP] Risks involved in MyISAM to Innodb

2012-09-21 Thread Samuel Lopes Grigolato
I would start trying my DBMS user list. Or maybe you're afraid of impacts on
PHP code?

Cheers.

-Mensagem original-
De: Girish Talluru [mailto:girish.dev1...@gmail.com] 
Enviada em: sexta-feira, 21 de setembro de 2012 10:04
Para: php-general@lists.php.net
Assunto: [PHP] Risks involved in MyISAM to Innodb

Hi Guys,

I have requirement to change my production database tables which are using
myISAM and now bcoz of some changes we have to move to Innodb.

Can anyone suggest how the plan should be and risks involve?

Thanks,
Girish Talluru


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



RES: [PHP] Risks involved in MyISAM to Innodb

2012-09-21 Thread Samuel Lopes Grigolato
Sure, the address you're looking for is:  http://lists.mysql.com/
http://lists.mysql.com/

 

Good hunting =)

 

De: Girish Talluru [mailto:girish.dev1...@gmail.com] 
Enviada em: sexta-feira, 21 de setembro de 2012 10:15
Para: Samuel Lopes Grigolato
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Risks involved in MyISAM to Innodb

 

Samuel, Can you please send the DBMS list address?

 

Thanks,

Girish

On Fri, Sep 21, 2012 at 6:08 AM, Samuel Lopes Grigolato
samuel.grigol...@gmail.com wrote:

I would start trying my DBMS user list. Or maybe you're afraid of impacts on
PHP code?

Cheers.

-Mensagem original-
De: Girish Talluru [mailto:girish.dev1...@gmail.com]
Enviada em: sexta-feira, 21 de setembro de 2012 10:04
Para: php-general@lists.php.net
Assunto: [PHP] Risks involved in MyISAM to Innodb


Hi Guys,

I have requirement to change my production database tables which are using
myISAM and now bcoz of some changes we have to move to Innodb.

Can anyone suggest how the plan should be and risks involve?

Thanks,
Girish Talluru



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

 



RES: [PHP] Highlight Search Results

2012-09-18 Thread Samuel Lopes Grigolato
If you're dealing with a high amount of search data, I highly advise you to
use something like SOLR. Match highlighting and a lot of other awesome
things is easy breeze with it.

-Mensagem original-
De: Floyd Resler [mailto:fres...@adex-intl.com] 
Enviada em: terça-feira, 18 de setembro de 2012 09:37
Para: PHP
Assunto: [PHP] Highlight Search Results

I want to highlight the word searched in search results.  I know I can use
str_ireplace to do a case insensitive search and replace.  However, is there
an easy way to maintain the case of the word found when I do the replace?

Thanks!
Floyd



--
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



RES: [PHP] fets() escaping some characters

2012-09-11 Thread Samuel Lopes Grigolato
This issue has to do with HTML markup. You need to properly escape
characters before sending them as text to the browser. Try to use this PHP
function to escape your string: echo htmlspecialchars($yourstringhere);

Regards,
Samuel.

-Mensagem original-
De: sunil meena [mailto:sunil.extc2...@gmail.com] 
Enviada em: terça-feira, 11 de setembro de 2012 14:49
Para: php-general@lists.php.net
Assunto: [PHP] fets() escaping some characters

Hello Everyone,

Very new to the list.

So I am trying to echo a string to the browser as follows -

$str = 0x100092000 -0x1000b7fff +com.apple.com (2.0 - 56)
BB91F4F8-3B1B-93C6-0D1A-E431E96F1BA3 /Library/PrivateFrameworks;

echo $str;

However the text between  and  i.e
BB91F4F8-3B1B-93C6-0D1A-E431E96F1BA3 doesn't get echoed instead all I get
is 0x100092000 -0x1000b7fff +com.apple.com (2.0 - 56)
/Library/PrivateFrameworks;

Anyone knows why this is happening?

This happened while I was getting a line using fgets and hence I tried
storing that string into a variable and outputting but it still doesn't show
the characters between the .

Any help is highly appreciated.

Thanks

--
Best Regards,
Sunil Meena


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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Samuel Lopes Grigolato
Maybe you have a ? inside the HTML code and your php configuration
allows short open tags? In production that setting could be disabled.

On Sun, Aug 26, 2012 at 9:20 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote:

  On 26 Aug 2012, at 03:56, Ashley Sheridan a...@ashleysheridan.co.uk
 wrote:
 
   Through the browser I get:
  
   Parse error: syntax error, unexpected $end
   in /var/www/html/siteinquestion/index.php on line 356
  
   Through the CLI I get:
  
   PHP Parse error:  syntax error, unexpected $end in index.php on line
 356
  
   Parse error: syntax error, unexpected $end in index.php on line 356
  
   Errors parsing index.php
  
   I've narrowed it down to the lines that used the breaking in and out of
   PHP style. As soon as I comment out those it runs fine, albeit without
   the content that code was intended to add.
 
 
  Let me guess, line 356 is the last line of the file? That error is only
 caused by mis-matched braces, so the code you are deleting *must* contain
 either an errant opening brace or be missing a closing brace.
 
  -Stuart
 
  --
  Stuart Dallas
  3ft9 Ltd
  http://3ft9.com/


 It is the last line of the file, but it's not caused by a mismatched
 brace. I've tested by deleting just the code in the section where it
 breaks out of PHP and it runs without errors. It's a very weird issue,
 because this is code that is currently working on another server (which
 I don't have access to to match my own setup)

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





RES: [PHP] Dynamic Content thoughts

2012-08-24 Thread Samuel Lopes Grigolato
Do you mean the  quotation marks? Have you tried to create a simple 
Notepad++ macro? I do this for things like formatting SQL from SQL Editor to 
SQL String in code, and vice versa.

Cheers.

-Mensagem original-
De: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Enviada em: sexta-feira, 24 de agosto de 2012 12:02
Para: php-general@lists.php.net
Assunto: Re: [PHP] Dynamic Content thoughts

OT Reply -- just frustrated with the way email screws up program listings. It's 
a royal pain to have to strip out code and then put it in an editor and tidy it 
up just to be able to make heads or tails out of something. There are lots of 
code pasting sites around, but that breaks up the continuity of the list 
archive. No solution, just frustrated

--
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] PHP OpenSSL - Problem with openssl_pkcs7_verify

2012-07-21 Thread Samuel Lopes Grigolato
Hello,

 

I'm having some trouble trying to put the openssl_pkcs7_verify function to
work.

 

I have a file signed with a valid certificate with this software:
http://www.signfiles.com/p7s-signer/ http://www.signfiles.com/p7s-signer/

 

What I'm trying to achieve is to extract the contents of the signed file
inside PHP. This is what I've got looking to php.net documentation:

 

$path = fullpath/filename.p7s;

 

$results = openssl_pkcs7_verify($path, 0);

//$results = openssl_pkcs7_verify($path, PKCS7_BINARY); same problem

//$results = openssl_pkcs7_verify($path, PKCS7_TEXT); same problem

 

echo Verification results:  . $results;

 

while ($msg = openssl_error_string()) {

echo \n . $msg;

}

 

When I execute this piece of script the following output is echoed:

 

Verification results: -1

error:02001003:system library:fopen:No such process

error:2006D080:BIO routines:BIO_new_file:no such file

error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

error:0B065068:x509 certificate routines:BY_FILE_CTRL:loading defaults

error:0D0D20CC:asn1 encoding routines:SMIME_read_ASN1:no content type

 

This is the php -version output:

 

PHP 5.4.5 (cli) (built: Jul 18 2012 22:25:51)

Copyright (c) 1997-2012 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

 

I'm on Windows 7 64 bits operating system, the binary is the latest stable
build available today on php.net.

 

Could someone please suggest what else can I try? Tried to google
SMIME_read_ASN1:no content type but nothing so far.

 

Regards,

Samuel.