We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Interesting way to trouble shoot or follow execution. | Forum

dave Leader
dave May 16 '13

Just thought I would share this with you all.  Wether you are a coder or not, there are many times it is just nearly impossble to fix something unless you can view the data being pocessed.  Which is why the firefox web developer  tools are a god send.  Among other tools of the trade, many are free to use.

 

One way we programmers have to view data is by using some the php commands available to us such as echo, print, an print_r.    print_r allows you to view arrays.

 

But what about if you are in a situation such as in a called (remote) function and you cant do any output to the page using those methods..  What do you do then?

 

Every script is different  but with oxwall you can simply in many cases use what is already provided for you in the function.   I am speaking of the error message output. 

 

Here is a classic example:

 

objective:  look to see if the actual input password is being encoded properly according to research that shows it should be a certain result at this point in the process.

 

i went to ow_system_plugins/base/classes/standard_auth.php and at this point the password should be ready for comparison so all i need to do is view the raw data. 

 

Down near the bottom you will see this code.

 

if ( $user->getPassword() !== BOL_UserService::getInstance()->hashPassword($this->password) )
        {
            return new OW_AuthResult(OW_AuthResult::FAILURE_PASSWORD_INVALID, null, array($language->text('base', 'auth_invlid_password_error_message')));
        }


        return new OW_AuthResult(OW_AuthResult::SUCCESS, $user->getId(), array($language->text('base', 'auth_success_message')));
    }

 

what it is saying is that if the  pw does not equal the hash version then show a invalid pw message, otherwise show sucess..

 

So what i did was i just used that output to test my data value to make sure it was correct at this point.  I commented out the original code just temporary for the test and i used this instead.

 

like this.

 

 

//added to test only

             $testpass = BOL_UserService::getInstance()->hashPassword($this->password);

          
             return new OW_AuthResult(OW_AuthResult::FAILURE_PASSWORD_INVALID, null, array($testpass));

 

So all i did was replace the value of the array with the value of the pw so i could see it when the message appeared on the page.

 

so what happened is that when i entered the pw now, it shows it to me on the page inside the nicely formated message format that would normally show an error or success message now it shows my encrypted pw. 

 

everything looked great so i removed my test and put the original code back.

 

The point here is that many functions have some kind of error default output, so use that if  you need to, to view your data values during execution.

 

Just a quick tip..

The Forum post is edited by dave May 16 '13
HIGH Quality Backlinks
That definitely possibly an amazing organize i always in truth definitely relished checking out. It's not necessarily specifically frequent i always add some choice to identify a selected matter. cellucare
HIGH Quality Backlinks
This web site seems to get a sizable ammount of visitors. How do you obtain visitors to this? It provides a good person twist on issues. I guess having something authentic or considerable to give information on is the most important element. Vitamin Dee