Wednesday, August 25, 2010

PHP Big Bummer!

When a string is set to empty String "":
--------------
$myvar = "";
echo is_null($myvar) ? "is null" : "not null";
//return not null
echo $myvar==null ? "is null" : "not null";
//return IS NULL
//whattttt????
=========
When a array is set to empty String "":
$myvar = array("myname" => "");
echo is_null($myvar["myname"]) ? "is null" : "not null";
//return not null
echo isset($myvar["myname"]) ? "is set" : "not Set";
//return NOT SET!
//whatttttt????
echo $myvar["myname"] == null ? "is null" : "not null";
//return IS NULL!
//what??????????

Thursday, August 19, 2010

Modx 1.04 Event Sequence

List of events in sequence
- OnBeforeManagerPageInit (DocumentParser::getSettings), if is manager
- OnWebPageInit (DocumentParser::executeParser)
- OnLogPageHit (DocumentParser::executeParser), if track_visitors is on
- OnLoadWebPageCache (DocumentParser::prepareResponse)
- OnLoadWebDocument (DocumentParser::prepareResponse)
- OnParseDocument (DocumentParser::parseDocumentSource)
- OnWebPagePrerender (DocumentParser::outputContent)

Wednesday, August 18, 2010

Double action (GET & POST) posted! Modx Manager

When you encounter this type of error, its due to the specification of
query-string and post form with "a" parameter

Monday, August 2, 2010

Modx ChangePwd Chunk sample

<div id="divChangePassword" style="position: relative; display: none;">
<form method="POST" name="changepwdfrm" action="[+action+]">
<input type="hidden" name="cmdwebchngpwd" value="1" />
<input type="hidden" name="passwordgenmethod" value="spec" />
<input type="hidden" name="passwordnotifymethod" value="e" />
<div><label for="oldpassword">Existing Password</label><input type="password" name="oldpassword" /></div>
<div><label for="specifiedpassword">New Password</label><input type="password" name="specifiedpassword" /></div>
<div><label for="confirmpassword">Retype Password</label><input type="password" name="confirmpassword" /></div>
<input type="submit" value="Save" />
</form>
</div>

Some useful way to get ip and computer name via php

To get the user’s IP use the following script:
phpGetHostByName($REMOTE_ADDR);

To get the user’s computer name use the following script:

phpgethostbyaddr($_SERVER['REMOTE_ADDR']);

Sources: