Jump to content

boolean - text read error.


lanana

Recommended Posts

Hi this is my code...

 

<?php

 

$username = "user"; 

$wordlist = "password.txt"; 

foreach( file( $wordlist ) as $password ) 


 

$json_url = "http://www.mypage.com/security?j_username=$username&j_password=$password";

$json = file_get_contents($json_url);

$data = json_decode($json, TRUE);

var_dump($data);

echo $password, '<br>';

flush();

ob_flush();

sleep(1);

}

 

if($data["success"]== "1")

{

echo "Password is: <h4>$password</h4>";

}

else {

echo "false";


 

?>

 

 

the explanation is when i go to the page i receive and read json file with the "success" as boolean({"success":true}), if i get the true, print me the password im searching for, the problem is in my text file, when ordered at the beginning for example

 

password

test1

test2

 

the boolean always return in false, but if i ordered at the least

 

test1

test2

password

 

the boolean becomes true, what I want is that the script can find the password in any location, the password is always the same on the test.

 

thaks for help !

Link to comment
Share on other sites

  • 2 weeks later...

your condition is outside of and comes after your foreach loop, so it's only testing against the last iteration of your foreach loop. It *seems* like what you want to do is move your condition to inside your foreach loop (and then also break from the loop when found if you want it to stop going through the list when found)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.