Tuesday, April 8, 2014

Friday, March 28, 2014

ofx2n3.py - OFX data to N3

#!/usr/bin/python
"""
USAGE with Python 2.6
  python ofx2n3.py --n3 < foo.ofx > foo.rdf
"""
__version__ = "$Id: ofx2n3.py Exp $"

# from swap.myStore import load, Namespace
# from swap.diag import chatty_flag, progress

import sys, re, os


def main(argv):
    filenames = []
    for arg in argv[1:]:  # skip script name
        if arg[0] != "-": # Not an option
            filenames.append(arg)
    if filenames == []:
        fyi("Reading OFX document")
        doc = sys.stdin.read()
        fyi("Parsing STDIN OFX document")
        contentLines(doc, argv)
    else:
        for fn in filenames:
            f = open(fn, "r")
            doc=f.read()
            fyi("Parsing STDIN OFX document %s" % fn)
            contentLines(doc, argv, fn)

def fyi(s):
    pass
#    sys.stderr.write(s+"\n")
  
CR = chr(13)
LF = chr(10)
CRLF = CR + LF
SPACE = chr(32)
TAB = chr(9)


# See qfx2n3.sed
# Date time maps to \1-\2-\3T\4:\5:\6
dt1 = [re.compile(r'([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])'),  "%s-%s-%sT%s:%s:%s"]

# Date maps to \1-\2-\3
dt2 = [re.compile(r'([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])'), "%s-%s-%s"]

# Date with Timezone  -- maps to \1-\2-\3T\4:\5:\6\70\800
# Like 20100317075059[-7:PDT]
dt3 = [re.compile('([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])\[([-+])([0-9]):[A-Z]*\]'), "%s-%s-%sT%s:%s:%s%s0%s00"]

# Like 20100317075059.000[-7:PDT]
#dt4 = [re.compile('([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).[0-9][0-9][0-9]\[([-+])([0-9]):[A-Z]*\]'), "%s-%s-%sT%s:%s:%s%s0%s00"]
dt4 = [re.compile('([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).000\[([-+])([0-9]):[A-Z]*\]'), "%s-%s-%sT%s:%s:%s%s0%s00"]

# Most complex first
dtcases = [dt4, dt3, dt2, dt1]

def sanitize(tag):
    str = ""
    for ch in tag:
        if ch in ".-": str+= "_"
        else: str += ch
    return str
  
def de_escapeXML(st0):
    return st0.replace('&amp;','&').replace('&lt;', '<').replace('&gt;', '>');

def contentLines(doc, argv, fn=None):
    "Process the content as a single buffer"

    n3 = "--n3" in argv
    makeName = "--rename" in argv
  
    version = "$Id: ofx2n3.py,v 1.6 2013-10-14 Exp $"[1:-1]
    if n3:
        print """# Generated by %s""" % version
        print """@prefix ofx: <http://www.w3.org/2000/10/swap/pim/ofx#>.
@prefix ofxh: <http://www.w3.org/2000/10/swap/pim/ofx-headers#>.

<> ofxh:headers [
"""

    for ch in doc:
    if ch in CRLF: break  # Find delimiter used in the file
    if ch == CR and LF in doc: ch = CRLF
    lines = doc.split(ch)
    header = {}
    stack = []
    filenamebits = {}
    ln = 0
    while 1:
    ln = ln + 1
    line = lines[ln]
    colon = line.find(":")
    if colon < 0:
        if line == "": break #
            if "<OFX>" in line:  # NatWest OFX error - missing gap line
                ln = ln - 1  # Back up and do it again
                break;
        raise SyntaxError("No colon in header line, line %i: %s" % (
                        ln, line))
    hname, value = line[:colon], line[colon+1:]
    while " " in hname:
        i = hname.find(" ")
        hname = hname[:i] + hname[i+1:]
#    fyi("Header line %s:%s" % (hname, value))
    if n3: print "  ofxh:%s \"%s\";" % (hname, value)  #@@ do n3 escaping
    header[hname] = value
    if n3: print "];\n"
  
    assert header["ENCODING"] == "USASCII"  # Our assumption
  
    while ln+1 < len(lines):
    ln = ln + 1
    line = lines[ln]
        while line != "" and line[0] in " \t": line = line[1:] # Strip leading space
        while line != "" and line[-1:] in " \t\r": line = line[:-1] # and trailing returns
    if line == "": continue # Possible on last line
    if line[0] != "<": raise SyntaxError("No < on line %i: %s" %(
                ln, line))
    i = line.find(">")
    if i < 0: raise SyntaxError("No > on line %i: %s" %(
                ln, line))
    tag = sanitize(line[1:i])

    if line[1] == "/": # End tag
        tag = tag[1:]
        tag2 = stack.pop()
        if tag != tag2: raise SyntaxError(
        "Found </%s> when </%s> expected.\nStack: %s" %
        (tag, tag2, stack))
        if n3: print "%s];  # %s" % ("  "*len(stack), tag)
    elif line[i+1:] == "":  # Start tag
        if n3: print "%s ofx:%s [" %("  "*len(stack), tag)
        stack.append(tag)
    else:  #  Data tag
            e = line.find('</')
            if e > 0:
                line = line[:e]  # If so strip off
            value = de_escapeXML(line[i+1:]);
            if tag[:2] == "DT": # Datetimes
                for re_fmt in dtcases:
                    m = re_fmt[0].search(value)
                    if m:
                        value = re_fmt[1] % m.groups()
                        break
                else:
                    raise SyntaxError("Unexpected date format on line %i: %s" %(
                ln, line))
              
        if n3: print  "%s ofx:%s \"%s\";" % ("  "*len(stack), tag, value)
            if tag in [ "ACCTID", "DTSTART", "DTEND", "ACCTTYPE"]:
                filenamebits[tag] = value;
              
    if stack: raise SyntaxError("Unclosed tags: %s" % stack)
    if n3: print "."

    if makeName:
         # Not always present but on old BBoA a/c needed top differentiate between
         # checking and savings accounts of SAME ACCOUNT NUMBER!
        at = filenamebits.get("ACCTTYPE", 'ac').lower()
        name = filenamebits["DTSTART"][:10]+"-on-" + at + "-" + filenamebits["ACCTID"][-4:]+".ofx"
        if name == fn:
            print "Name is already as suggested. Not renamed: %s"%fn
        else:
            print "mv %s %s" % (fn, name)
            if "--no" not in sys.argv[1:]: os.rename(fn, name)
  

def _test():
    import sys
    from pprint import pprint
    import doctest, fromOFX
    doctest.testmod(fromOFX)

    lines = contentLines(open(sys.argv[1]))
    #print lines
    c, lines = findComponents(lines)
    assert lines == []
    pprint(c)
    #unittest.main()

if __name__ == '__main__':
    import sys
    if "--help" in sys.argv[1:] or "-help" in sys.argv[1:]:
        print __doc__
    elif sys.argv[1:2] == ['--test']:
        del sys.argv[1]
        _test()
    else:
        main(sys.argv)


Sunday, February 9, 2014

How to Save Skype Video Messages

How to Save Your Skype Video Messages

http://www.petri.co.il/save-skype-video-messages.htm

Windows XP

Go to Windows Start and in the Search/Run box type %appdata%\skype and then press Enter or click the OK button. The Windows File Explorer will pop up. There locate a folder named as your Skype name. You will find the main.db file in this folder.

Keep Your Own Copies

It turns out that these video messages are (theoretically) stored on Skype's servers for an indefinite period of time. ("Forever" comes to an end very often sooner than you may realize. I remember many "free for life" services I once used – which aren't free anymore.) We, as end-users of a service that is currently free, have no control over Skype's (actually Microsoft's) storage policy. What works today may be broken tomorrow, what is free today may cost money tomorrow, and what seems like a lifetime endless storage space may be gone without a trace in an eye blink. What if these messages will be deleted sometime in the future?
So how do you actually download those priceless video messages? The logic behind downloading these important videos is that you take control and responsibility of keeping them on your end. Even if Skype (or Microsoft) decides to close this service in the future, or if something goes really bad and causes a catastrophic data loss (which will probably get you nothing more than an official apology, saying that they're so sorry for this and that they will study the incident to make sure that it won't happen again - but nothing else), you'll still have your local copy of this data.
As it turns out, you can save those video files. Here are some methods to help you do that. Some are easier than others, so pick the one that's right for you and your Skype version.
So let's assume we have a video message that you can view in your chat history and that you want to save.
Save Skype Video Messages

Save Skype Video Messages: Versions Prior to 6.5

In previous versions of Skype, when you get a video message you also receive a link to view the video message on your browser. You also get a code which you must enter when you replay the video message.
Save Skype Video Messages
One of the easiest methods to save these video messages is by using the Chrome browser and an extension called FVD Video Downloader.
Save Skype Video Messages: fvd video downloader
Once you open the video message in Chrome you can download the message, and then play the downloaded file with VLC media player. However, this method may not work anymore if you're using a newer version of Skype.
Note: One workaround may be to remove the current version of Skype and install the old beta version for 6.5.
In addition, make sure you disable Skype's automatic updates feature under Tools > Options >Advanced > Turn off automatic updates.

Save Skype Video Messages: Versions 6.5 and above

On the latest Skype versions (6.5 and above) you are no longer provided with links to video messages. Therefore, if you use a Skype version higher than 6.5 the previous method will no longer work for you. According to Skype's community forum, "You should be able to watch these Video messages in your Skype for the next 10 years. The only what you need to ensure is that the chat database file (main.db) is still intact and that you don’t delete any chat messages."
The main.db file is located in the following location:
C:\Users\<Windows user name>\AppData\Roaming\Skype\<Skype user name>\main.db
  • In order to be able to read the main.db database file you need to get an SQLite database browser.
  • On the SQLite browser, click on File, then click Open Database.
  • Browse to the location of the main.db file (see path above).
Save Skype Video Messages: SQLite Database browser
  • In the Browse Data tab, use the Table drop-down list and select VideoMessages.
Save Skype Video Messages: SQLite Database browser
  • Scroll till you see the column called "vod path." Each voice message has such a path. Double-click on the corresponding vod path text for the video message you want to view.
Note: Do not use the link from the "public link" column even if there is one.
Save Skype Video Messages: SQLite Database browser vod path
  • Copy the URL text.
Save Skype Video Messages: SQLite Database browser URL text
  • Open a browser window and paste in the URL. You should be able to play the video message.
  • To save the video message, open Windows Media Player and click File, then click Open URL. Paste the URL in the text box and click OK.
Save Skype Video Messages: Windows Media Player
  • Once the video starts playing, click File, then Save As.
Save Skype Video Messages: Windows Media Player
  • Give the file a descriptive name, select a saving location, and click Save.
Save Skype Video Messages: Windows Media Player
You can repeat this for all the video messages you want to keep.

Save Your Sent Skype Video Messages

This is another trick that works for video messages that YOU send with Skype.
There are two places where your message is saved. Prior to sending it, it will be saved in the Temp folder on your computer (located at C:\Users\<Windows user name>\AppData\Local\Temp) with a name that looks like this: vidmxxxxxxxxxx.mp4.
Save Skype Video Messages: temp folder
This file is deleted the moment you send it to the other person.
After you hit Send and the message is sent to your chat partner, the message is temporary saved in the “media” folder of your user profile at this location:
C:\Users\<Windows user name>\AppData\Roaming\Skype\<Skype user name>\media
File names will be different that the one you saw in the Temp folder.
Save Skype Video Messages: media folder
  • Copy this file to another location on your computer.
  • Next, add an extension .avi or .mp4 to it. You can now play the file in Windows Media Player or VLC media player.
Save Skype Video Messages: media folder
Note: However, there are two issues with this method. First, it only works for messages that YOU send, and not for the ones you receive. Second, these files get deleted the moment you quit Skype. So if you want to keep your own messages, you need to remember to copy them before you quit Skype.

Monday, January 6, 2014

How To Fix A Hacked Joomla Website

Do you know what is a webmaster's biggest nightmare? You're right. It's the hackers. Every now and then, website administrators get to deal with hackers. It's not possible to make your website 100% hack-proof. A small security hole in your entire website's coding can give an experienced hacker access to the backend of your website. And if they manage to crack it down, you may have a hard time figuring out what to do if you didn't have a backup. However, if you do have a backup, you can restore the site. But what's the guarantee that it won't be hacked again? How do you exactly what security hole gave the hacker access to your server in the first place?

There is one tool that can do the job of finding out what's the security hole and what other weak points there are on your website. The tool is called Audit My Joomla. If you remember, we faced the same hacking experience a while ago at ThemeXperts. This was the tool that made our website's security stronger and protected. But before we talk about how to audit your website with this tool, let's first look at some of the basic features the site comes with.

Features

  • Audit My Joomla scans your entire website in just a few moments. You have to first sign up with them and you will be provided with a downloadable extension that you need to upload and install on your Joomla site. The tool then scans for all potentially harmful contents in your website.
  • During a hack, a hacker may leave a backdoor on any of your website's core files so that they can gain access later. Audit My Joomla will instantly scan and recognize those changes in the file that are suspicious.
  • If you're using too many extensions and your site is very large, you might be wondering which files are untouched and which files are affected. With Audit My Joomla, you can easily revert the core files to their distributed state making sure everything is at their default.
  • Like I already said, you will never know where the security holes are. Audit My Joomla can look them up for you and you can make very technical changes in your Joomla quite easily with the tool.
  • You can also get suggestions for best practices by using this tool. For example, if you are using root username to connect the database, you're at risk. The tool Audit My Joomla will suggest you to change that username to something more complex so that hackers can never guess what it is.

What to do after a Joomla site is hacked

You can use the tool to secure and fix your Joomla website and NOT to backup or restore the content. Audit My Joomla offers two types of auditing. The easiest way is to let them do the job. But if you're a little familiar with Joomla administration interface and how these things work, you can do the audit by yourself. You need to register with a username and add your website before you can audit it. Just so you know, the first audit is totally free of charge. From second audit onwards, however, you will have to pay which is worth the service.
So, let's fix and secure your Joomla site for free!

Install and Activate

After you add your first website, you'll see a screen idential to the one below. You must click the Generate new connector for the extension to be ready.
generating-ready.png
Within moments, the download button will show up and you can download and install the extension to your Joomla website the usual way.
download-install.png
As you can see, you can also use the button on Step 2 go to go the Joomla administration panel on your website directly.
upload-install.png
Once the plugin has been installed, you'll see a message saying that there isn't anything more you can do from your Joomla administration. You need to go to the first tab and continue with the following.
The buttons to test endpoint are self-explanatory. Click accordingly.
test-endpoint.png
If connection was established, you will see the word “endpoint” upon clicking the button. Remember to click the right button. If you are using Joomla 1.5.x, use the 1st button. If Joomla 2.5+ is running on your site, use the second button.
Now, click the Connection Test button to make sure that the connection has been established. If connection is established, you'll briefly see the success message.
connection-success.png
You will then be redirected to start audit page. You will have to confirm that you want to start auditing now. The page here will look identical to the one below:
start-new-audit.png
As soon as you click the start button, Audit My Joomla will start its magic. You will see a live screen of what the plugin is doing on the next screen. Be patient, though; this may take a while if you have a very large website.
audit-progress.png
As the audit finishes, you'll see a screen with all the details of audit results. From there, you can what problem the plugin found on your website. If it has found any problem, there will be blue button that reads “next steps” next to the configuration name.
joomla-audit-next-step-1.png
audit-result-analysis.png
If you click the next steps button, you'll see all the details of what the problem was and what the tool recommends you to fix the issue.

If you scroll through the audit results, you might be a little bit overwhelmed. The tools developer writes,
Remember, the object is NOT just to get green OK for each item, the aim is to understand more about your site and its integrity at this moment in time. In fact its impossible to resolve all items in this list as some checks have knock on effects to others.

If you've got enough time or a dedicated developer, you can have them check the entire result and take action to better protect your website from hacking attempts. If you'd rather leave it to the tool's developer, you can always pay and get their service right over to you. Fees for the service can be found here: https://manage.myjoomla.com/faq/fees
As you might have already realized, the service is really amazing. The tool takes deeper-than-any-human-can-do look into your Joomla's core files and comes up with an incredibly detailed result and possible fixes within minutes. This is some serious stuff that every serious web developers and administrators should have on their Joomla website.
Just as a reminder, the first audit is free. But you cannot audit your website again without paying the charges.

Your Turn

What security measures have you taken to protect your Joomla powered website? How do you find out after your site has been hacked where the problem or security hole lies? Let us know if you have come across any other tool that does better job than Audit My Joomla!

http://www.themexpert.com/blog/how-to-fix-a-hacked-joomla-website

https://manage.myjoomla.com/

Thursday, January 2, 2014

Jooma - Upgrade 1.7 to 2.5 to 3.0

Upgrade

http://docs.joomla.org/J2.5:Upgrading_from_an_existing_version
 
If you are updating to an x.x.0 release (for example, from 1.7.3 to 2.5.0), this will normally be a file like Joomla_2.5.0-Stable-Update_Package.zip. If you are updating within the same release series (for example, 2.5.0 to 2.5.1), then the file will be named something like Joomla_2.5.0_to_2.5.1-Stable-Patch_Package.zip. 
http://joomlacode.org/gf/project/joomla/frs/?action=FrsReleaseBrowse&frs_package_id=6257

At this point, you have three options:
  1. Install from URL
  2. Install from Directory
  3. Upload Package File

Database Errors When Upgrading to 2.5.0

http://docs.joomla.org/Database_Errors_When_Upgrading_to_2.5.0
When upgrading from an earlier, compatible version, to 2.5.0, you may experience a database error such as the following
JInstaller: :Install: Error SQL DB function failed with error number 1060 Duplicate column name 'ordering' SQL=ALTER TABLE `j17_languages` ADD COLUMN `ordering` int(11) NOT NULL default 0 AFTER `published`; SQL = ALTER TABLE `#__languages` ADD COLUMN `ordering` int(11) NOT NULL default 0 AFTER `published`; Files Update: SQL error file DB function failed with error number 1060 Duplicate column name 'ordering' SQL=ALTER TABLE `j17_languages` ADD COLUMN `ordering` int(11) NOT NULL default 0 AFTER `published`; SQL = ALTER TABLE `#__languages` ADD COLUMN `ordering` int(11) NOT NULL default 0 AFTER `published`;"
To fix this issues, go to Extension Manager -> Database then click the fix button. This will attempt to fix any database issues caused by changes in the database structure that occurred between versions.

Should I update from Joomla! 2.5 to 3.x?

http://docs.joomla.org/Joomla_3_FAQ
In most cases, probably not. Joomla 2.5 will continue be supported until December 31st of 2014 and you can update directly to Joomla 3 once it’s tried-and-tested thoroughly by other users. You can even wait until Joomla 3.5 with release scheduled for Spring 2014 and still get a direct upgrade. The only reason you should update is if you need Joomla 3’s features or want to be on the leading edge.