Re: [PHP] htaccess to make html act as php suffixed files

2013-06-11 Thread Rodrigo Silva dos Santos

Em Ter 11 Jun 2013 15:08:59 BRT, Matijn Woudt escreveu:

On Tue, Jun 11, 2013 at 7:17 PM, Stuart Dallas stu...@3ft9.com wrote:


On 11 Jun 2013, at 18:16, Tedd Sperling t...@sperling.com wrote:


Hi gang:

To get html pages to use php scripts, I've used:

RewriteEngine on
# handler for phpsuexec. -- this makes these prefixes considered for php
FilesMatch \.(htm|html)$
SetHandler application/x-httpd-php
/FilesMatch

In a .htaccess file.

However, it works on one site, but not on another -- any ideas as to why?


At a rough guess there's an AllowOverride line in the main Apache config
that's restricting what you can do in the .htaccess file.



Or the .htaccess usage is not enabled at all in that site.



ALSO, you have to be sure this site is using apache. Otherwise, 
.htaccess are not available.


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



Re: [PHP] Unexpected behavior of max() function

2012-12-11 Thread Rodrigo Silva dos Santos
A solution to it is, if you can, enter the array itens without the 
commas, just array(100,110.453351020813,9);


Em 11-12-2012 05:05, Andreas Perstinger escreveu:

On 11.12.2012 07:48, Рогулин С.В. wrote:

I encountered with unexpected behavior of max() function. When i pass a
parameter ['100', '110,453351020813', '9'], this function gives 
answer '9'


var_dump(
max(array('100', '110,453351020813', '9'))
);

// will output:
// string(1) 9


As the output tells you, you are comparing strings and the character 
'9' is greater than the character '1' (at the beginning of the two 
other strings).


Bye, Andreas





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



Re: [PHP] problem with my login script

2012-10-02 Thread Rodrigo Silva dos Santos
Hello Thomas.

The if are being evaluated in all iterations of the while, the problem is you 
didn't stop the loop when it finds what it's searching for. Try putting a break 
in the end of the if, them, when the condition match, the while will stop.

And hey! You're using a lot of legacy code for one that is learning php. If you 
want, I can give you some tips to modernize your script ;)

Regards, Rodrigo Silva dos Santos.




Enviado por Samsung Mobile

Thomas Conrad koopasfore...@gmail.com escreveu:

I'm currently learning php and as a challenge, I'm creating a login
script using text files to store the information (until I learn how to
handle databases with php).
The problem I'm having is the if statement in my while loop is only
evaluated on the last iteration of the while loop, so its only
comparing the last username in the file and no others.

Heres the code:

?php
session_start();

$users = file(../inc/users.inc.php);

if($_POST['username']  $_POST['password']){

if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$, $_POST['username'])){


while(list($id ,$username) = each($users)){
if($_POST['username'] == $username){
$_SESSION['logged_in'] = 1;
$_SESSION['username'] = $username;

}
}
if($_SESSION['logged_in'] != 1){
$error = 2;
}
}else{
$error = 4;
}
}else{
$error = 3;
}

if($error){
header(Location: http://koopasforever.com/scripts/login.php?error=$error;);
}else{
header(Location: http://koopasforever.com/;);
}


?

I have checked all my variables and they all contain the proper information

Some help would be greatly appriciated, Thanks

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



Re: [PHP] problem with my login script

2012-10-02 Thread Rodrigo Silva dos Santos
Better solution than mine (that don't even make a code)

As a Oo developer, a run away from using switch, so I should never use break 
too... Good to know. By the way, what's the problem with it?


Enviado por Samsung Mobile

Bálint Horváth hbal...@gmail.com escreveu:

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)

In the other hand Thomas, you should use while and count the lines and u
need to test if username found...

Yeah, this script is near to the good solution:
?php

session_start();

$users = file(users.inc.php);

if (!empty($_POST['username'])  !empty($_POST['password'])) {
    if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) {
    $ui = 0;
    while ($ui  count($users)  $error != 0) {
    $user = explode(' ', trim($users[$ui]));
    if ($_POST['username'] == $user[1]) {
    $_SESSION['logged_in'] = 1;
    $_SESSION['username'] = $user[1];
    $error = 0;
    } else{
    $error = 2;
    }
    $ui++;
    }
    } else {
    $error = 4;
    }
} else {
    $error = 3;
}

if ($error == 0) {
    print(redirecting);
} else {
    print(error:  . $error);
}

?

On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.comwrote:

 I'm currently learning php and as a challenge, I'm creating a login
 script using text files to store the information (until I learn how to
 handle databases with php).
 The problem I'm having is the if statement in my while loop is only
 evaluated on the last iteration of the while loop, so its only
 comparing the last username in the file and no others.

 Heres the code:

 ?php
 session_start();

 $users = file(../inc/users.inc.php);

 if($_POST['username']  $_POST['password']){

 if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$,
 $_POST['username'])){


 while(list($id ,$username) = each($users)){
 if($_POST['username'] ==
 $username){
 $_SESSION['logged_in'] = 1;
 $_SESSION['username'] =
 $username;

 }
 }
 if($_SESSION['logged_in'] != 1){
 $error = 2;
 }
 }else{
 $error = 4;
 }
 }else{
 $error = 3;
 }

 if($error){
 header(Location:
 http://koopasforever.com/scripts/login.php?error=$error;);
 }else{
 header(Location: http://koopasforever.com/;);
 }


 ?

 I have checked all my variables and they all contain the proper information

 Some help would be greatly appriciated, Thanks

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




Re: [PHP] problem with my login script

2012-10-02 Thread Rodrigo Silva dos Santos
Make sense, I haven't ever realizad how old the code appears like when it haves 
a break. Fell like C. Livin' n' learnin'. Thanks!


Enviado por Samsung Mobile

Bálint Horváth hbal...@gmail.com escreveu:

As a Oo developer, a run away from using switch - I don't understand this: 
OOP and switch could be good together and I also prefer switch eg. at action or 
page selection...

break is an old stuff and not a nice solution (like goto)... killing a 
procedure!? -means wrong planning of an app! (and jumping in the code with goto 
also like this)


On Tue, Oct 2, 2012 at 12:11 PM, Rodrigo Silva dos Santos 
rodrigos.santo...@gmail.com wrote:
Better solution than mine (that don't even make a code)

As a Oo developer, a run away from using switch, so I should never use break 
too... Good to know. By the way, what's the problem with it?


Enviado por Samsung Mobile



Bálint Horváth hbal...@gmail.com escreveu:



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)

In the other hand Thomas, you should use while and count the lines and u
need to test if username found...

Yeah, this script is near to the good solution:
?php

session_start();

$users = file(users.inc.php);

if (!empty($_POST['username'])  !empty($_POST['password'])) {
    if (filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) {
    $ui = 0;
    while ($ui  count($users)  $error != 0) {
    $user = explode(' ', trim($users[$ui]));
    if ($_POST['username'] == $user[1]) {
    $_SESSION['logged_in'] = 1;
    $_SESSION['username'] = $user[1];
    $error = 0;
    } else{
    $error = 2;
    }
    $ui++;
    }
    } else {
    $error = 4;
    }
} else {
    $error = 3;
}

if ($error == 0) {
    print(redirecting);
} else {
    print(error:  . $error);
}

?

On Tue, Oct 2, 2012 at 8:52 AM, Thomas Conrad koopasfore...@gmail.comwrote:

 I'm currently learning php and as a challenge, I'm creating a login
 script using text files to store the information (until I learn how to
 handle databases with php).
 The problem I'm having is the if statement in my while loop is only
 evaluated on the last iteration of the while loop, so its only
 comparing the last username in the file and no others.

 Heres the code:

 ?php
 session_start();

 $users = file(../inc/users.inc.php);

 if($_POST['username']  $_POST['password']){

 if(ereg(^[^@ ]+@[^@ ]+\.[^@ \.]+$,
 $_POST['username'])){


 while(list($id ,$username) = each($users)){
 if($_POST['username'] ==
 $username){
 $_SESSION['logged_in'] = 1;
 $_SESSION['username'] =
 $username;

 }
 }
 if($_SESSION['logged_in'] != 1){
 $error = 2;
 }
 }else{
 $error = 4;
 }
 }else{
 $error = 3;
 }

 if($error){
 header(Location:
 http://koopasforever.com/scripts/login.php?error=$error;);
 }else{
 header(Location: http://koopasforever.com/;);
 }


 ?

 I have checked all my variables and they all contain the proper information

 Some help would be greatly appriciated, Thanks

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





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

2012-10-02 Thread Rodrigo Silva dos Santos



To break or not to break? that's the question...

All that fight makes me (and, I think that Thomas too) learn a bit more 
about all of this. And for finish with all of it. I think that if 
something is not deprecated, is because it's is a good idea to use it 
somewhere. If the Language developers think that way, i will not discord.


Regards.

Em 02-10-2012 10:35, Thomas Conrad escreveu:

My problem was solved no need to argue. I don't see why use a while
loop with a count variable when it produces the same result as a
foreach loop. As for using a break in the loop, I could add it but the
loop is gonna stop anyway as soon as it hits the end of the array. I
also didn't see the point in using the explode() function as long as I
remove the (in my opinion) useless index numbers from the text file
containing the username. The following code works as I expect it to:

?php
session_start();

$users = file(../inc/users.inc.php);

if(!empty($_POST['username'])  !empty($_POST['password'])){

if(filter_var($_POST['username'], 
FILTER_VALIDATE_EMAIL)){


foreach($users as $row){
$row = trim($row);
if($_POST['username'] == $row){
$_SESSION['logged_in'] = 1;
$_SESSION['username'] = $row;

}
}
if($_SESSION['logged_in'] != 1){
$error = 2;
}
}else{
$error = 4;
}
}else{
$error = 3;
}

if($error){
header(Location:);
}else{
header(Location:);
}


?

users.inc.php:

m...@email1.com
m...@email2.com





Re: [PHP] base64_decode

2012-10-02 Thread Rodrigo Silva dos Santos


Hello John.

This code generates the following html:


? /div
div id=footera href=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+DQo8ZGl2IGlkPSJmb290ZXIiPjxhIGhyZWY9Imh0dHA6Ly93ZWItaG9zdGluZy1jbGljay5jb20vIiB0aXRsZT0iV2ViIGhvc3RpbmciPldlYiBob3N0aW5nPC9hPg0KPCEtLSAyNyBxdWVyaWVzLiAwLjU2MSBzZWNvbmRzLiAtLT4NCjwvZGl2Pg0KPD9waHAgd3BfZm9vdGVyKCk7ID8+DQo8L2JvZHk+DQo8L2h0bWw+IDw/'));?