Archive for April, 2007

Microsoft releases Windows Media Player 11 plugin for Firefox

Posted on April 18th, 2007 in Firefox, Windows | 1 Comment »

Now Firefox users can use Windows Media Player within Firefox in a plugin designed by the WMP team. According to Hank Janssen, who posted the plugin on Microsoft’s open-source website, Port 25, it is “designed to support” all varieties of Windows XP and Vista. However, he also mentions that it’s backwards-compatible with WMP versions as far back as 6.4, which seems to imply that it might also work on Windows systems as old as Windows 95. That’s just speculation, though.

In any event, you can download the files from Port 25’s website. You can also find this link from the Firefox Add-ons page.

Decrypting a Dreamweaver site definition password

Posted on April 18th, 2007 in Code, PHP | 5 Comments »

I don’t use Dreamweaver, but everyone I work with does. It so happens that whenever I need server connection information, they send it to me in the form of a Dreamweaver site definition (.ste). Naturally, this isn’t terribly useful for someone like me who connects via SSH or SCP most of the time. In the end, I have to waste time asking around to see if anyone actually remembers the password.

So today I finally took a few minutes out of my day and wrote a simple PHP class to parse site definitions. It reads the bare essentials of the connection information and decrypts the password. Because Dreamweaver site definitions are just XML files, if (for some bizarre reason) someone wanted to extend this, it wouldn’t be hard at all.

/**
 * A Dreamweaver site definition (.ste) reader.
 */
class SteReader
{
    /** @var SimpleXMLElement SimpleXML object */
    protected $_xml = null;

    /**
     * Constructor.
     *
     * Parses a site definition file into its SimpleXML equivalent.
     *
     * @param string $file Fully-qualified file path
     */
    public function __construct($file)
    {
        if (!is_file($file)) {
            throw new Exception('File does not exist');
        }

        $contents = file($file);
        foreach ($contents as $i => $line) {
            // This element is unnecessary, and often contains duplicate
            // attributes that prevent the file from loading correctly
            if (substr($line, 0, 14) == '<appserverinfo') {
                unset($contents[$i]);
            }
        }
        $contents = implode('', $contents);
        try {
            $xml = new SimpleXMLElement($contents, LIBXML_NOWARNING | LIBXML_NOERROR);
        } catch (Exception $e) {
            throw new Exception("File is not a valid Dreamweaver site definition");
        }
        $this->_xml = $xml;
    }

    /**
     * @return string Site name
     */
    public function getSiteName()
    {
        return (string) $this->_xml->localinfo['sitename'];
    }

    /**
     * @return string Host address
     */
    public function getHost()
    {
        return (string) $this->_xml->remoteinfo['host'];
    }

    /**
     * @return string Remote root directory
     */
    public function getRemoteRoot()
    {
        return (string) $this->_xml->remoteinfo['remoteroot'];
    }

    /**
     * @return string Username
     */
    public function getUsername()
    {
        return (string) $this->_xml->remoteinfo['user'];
    }

    /**
     * @return string Password
     */
    public function getPassword()
    {
        if (!isset($this->_xml->remoteinfo['pw'])) {
            return false;
        }

        $encoded  = (string) $this->_xml->remoteinfo['pw'];
        $literals = explode(' ', wordwrap($encoded, 2, ' ', 2));
        $password = '';
        for ($i = 0; $i < count($literals); $i++) {
            $password .= chr(hexdec($literals[$i]) - $i);
        }

        return $password;
    }
}

Thanks to Bart Grantham for his Dreamweaver site definition password decryption algorithm!