javascript in wordpress

When you want to add javascript in wordpress posts, it won’t display. There is a simple solution for this. I got this problem when I wanted to add a bol.com advertisement in an blog post in wordpress. WordPress converts several tags in your WYSIWYG editor. This is the reason it won’t display correct. There is a simple solution for thi, the pureHTML plugin for wordpress. You can find is in the pluggin page (search for pureHTML). Use the plugin like this: [pureHTML] javascript code [/pureHTML].

It will display correct now.

Posted in WordPress | Tagged , , | Leave a comment

Create strong passwords that you can remember

The key is to find a formula which you always remember. I found this a couple of years ago, it might be useful for someone.

Lets use the domain name of a site (because you alway’s have that when logging in), in this case blog.davidsz.nl and translate it into a password like; $%d@v1Dsz&*

Seems difficult? It isn’t. Here is how it works;

First 2 characters are fixed special, so every password you create starts with these ($%), choose your own and never tell it to somebody.

Than the domain name comes, some characters are transformed;

  • a = @
  • e = 3
  • i = 1
  • o = 0

The fifth character is uppercase (D)

And then 2 extra fixed characters are added (&*), again choose your own and don’t ever tell it to anyone.

What if the 5th character is for example a i? Just place 1 and take the next character to transform.

When you do this for a few websites, It will grow naturally on you. Lets try an other one;

www.microsoft.nl => $%m1cr0S0ft&*

Easy huh?

Experiment with this until you find the right combination

Posted in No category | Tagged | 1 Comment

KeePass and Dropbox on Iphone or Ipad

While surfing on the net, you probably have many passwords. For security reasons, it’s good not to use the same password for all of the websites. But how do you remember all of them?
I use a simple free program that is called KeePass (http://keepass.info/). It created a small encrypted database where you can store your passwords and other data.

The combination with dropbox is ideal because when you place the database file into your dropbox, you can access the database file everywhere and it updates no mather where you are.
In this case I also use it on my iPad/IPhone (you can find KeePass also on the App-store).

Make sure you place the database file in the public folder of your dropbox. When right-clicking you can now select the URL option. This is the weblink to your file.

In Keepass on your Ipad/Iphone you can select [download from www]. Here is where you fill in the URL.

Now you can use the file, it automaticly updates as well.

Although KeePass can generate passwords for you, I’ll post a blog about creating strong passwords -which you can remember- soon.

Update: click here for the post

Posted in No category | Tagged , , , , | Leave a comment

ASP.NET Popup Dialog – Confirm Delete – Javascript

Although most of the time it is actually annoying, adding a confirmation pop-up before deleting something is a must for professional websites. Simple [Ctrl][z] doesn’t work when a user clicks on the wrong button.

Integration between javascript and ASP.net is very simple, just add the attribute OnClick in your code behind, like this (the buttons ID is btnDelete);

 

protected override void OnInit(EventArgs e)
{
   base.OnInit(e);
   btnDelete.Attributes.Add("onclick", "return confirm_delete();");
}

When using a button in a repeater you put the attribute when the item is created;

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        rptForTable.ItemCreated += new RepeaterItemEventHandler(rptForTable_ItemCreated);
    }

    void rptForTable_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Button _mbtn = (Button)e.Item.FindControl("btnDelete");
            _btn.Attributes.Add("onclick", "return confirm_delete();");
        }

    }

 

Posted in ASP.net | Tagged , , , | Leave a comment

Using Captcha on your website

Once you start creating forms for users to fill in. You might cross a problem; a spam bot. These bot scan you website and fill for example your guestbook. Using Captcha to check if the form fields are beeing filled by I human user is a good way to prevent this.

You have probably seen it before, a simple picture and a Textbox next to it. I found a nice one that is very easy to implement and look very good, reCaptcha;

reCaptcha

 

 

Download the latest dll file and place it in your BIN directory of your project.

Register at reCaptcha to get the public and private key’s
https://www.google.com/recaptcha/admin/create

Than add the following line at the top of your .aspx page;

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

Then insert the reCAPTCHA control inside of the <form runat=”server”> tag:

<recaptcha:RecaptchaControl ID="recaptcha" runat="server"
    PublicKey="your_public_key"
    PrivateKey="your_private_key" />

Alter the data to match your key’s.

After that you’re finished! The codebehind is very simple, just check the Page.IsValid;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Contact : BasePage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        btnSubmit.Click += new EventHandler(btnSubmit_Click);
    }

    void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            lbMessage.Text = "Well done!";
        }
        else lbMessage.Text = "incorrect value for captcha!";
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Note: lbMessage is a label in your .aspx file place it like this;

<asp:Label ID="lbMessage" runat="server" forecolor="RED" />
Posted in ASP.net | Tagged , , | Leave a comment

Export your Linkedin contact’s

When you build up a great network on linkedin, sometimes you want to do something with that data. Lucky for us, they build in a standard feature to export your complete contact list to a comma separated file.

When you are logged in into Linkedin follow this link: http://www.linkedin.com/addressBookExport

The link will get you to your own contact list en export options. (You can also click on contacts and then bottom-right you’ll find export contacts).

linkedin-export-contacts

Select Microsoft Outlook csv file. I download this file and open it in Excel.
Then select the first column (A). Than Text to Column, and voila you have a excel “database” with your own contact’s. Now you can use this list in other applications as well.

Posted in Linkedin | Tagged , , , | Leave a comment

Hash passwords for you website

When you are writing an aplication and you store passwords, You don’t want to store them as plain text, like;

Login: Jeffrey
Password: SomeThingNice

What you extualy would like to store is something like this;

Login: Jeffrey
Password: $LMAYBZcwt7cql80KFF9uSeGlkdqnYdMM.o0veWQALw7

The advantage of a password is that you only need to check if your user filled in the right password. What the password actualy is, doesn’t matter. Here is where Hashing comes in place. Hashing is unlike encryption a one-way encoder.

Hashing is a one way transformation that is very hard to reverse. So to store passwords, a site would simply hash them before saving them to a database. Then when a user logs in, the password they supply is also hashed and compared to the hashed value in the database. If they typed in the same password the hashes will match and the authentication passes.

Of course when the user forgets his password you need to reset the password, because there’s no way to crack it.

Or is there?

There are various hashing algorithms out there, and many of them are wonderfully optimised and very fast. A typical example is SHA. An optimal hasher sounds great doesn’t it?

… well it isn’t. In fact it’s a weakness with the power of modern cpu’s and cloud computing resources. It means that its very possible and remarkably cheap to brute force SHA with a dictionary attack, simply because it is so fast.

This is where BCrypt.Net comes in. It is intentionally slow, so should someone try to brute force it, its simply not viable. Whereas a hacker can generate 100s of millions of SHA hashes a second, they can’t with BCrypt, and as technology marches on, you can just increase the work factor on BCrypt to keep ahead of processors.

Here is the version I’m using:

http://bcrypt.codeplex.com/releases/view/57687

Just put the files in your BIN directory en use the code like this;

// Set work factor for hash algorithem
private static readonly int BCRYPT_WORK_FACTOR = 10;

// Hash the value that your user filled
string hashedPassword = BCrypt.Net.BCrypt.HashPassword(txtUserPassword.Text, BCRYPT_WORK_FACTOR);

To check/validate if the entered password is correct;

// password is the user's password, hashedpassword is the stored one
bool matched = BCrypt.Net.BCrypt.Verify(password, hashedpassword);

Ok, have fun and if there are any questions let me know!

Posted in ASP.net | Tagged , , , , , | Leave a comment

Auto SyntaxHighlighter

I’m gonna post allot of code here. Developers would like to read (and copy and pate of course) the code they need. There is a good plugin for that which I’m using:

Auto SystaxtHighlighter. Just go to the plugin part of your dashboard and install it. Then when activated, there is a extra button on your add new post toolbar (looks like a pen). Select which language you are typing in, and check the result on your post when finished.

Posted in WordPress | Leave a comment

What is Ping Back on WordPress?

A pingback is a special type of WordPress comment that is automatically created whenever somebody links to one of your posts from their own blog. These comments include a short excerpt of the post that linked to yours as well as a direct link to it; what you do with the pingback depends on where the post came from.

Legitimate Pingbacks
Legitimate pingbacks occur when the author of a blog feels that your post is worth commenting on and sharing with his readers. These pingbacks are a form of reciprocal linking and add value to both blogs, allowing them to share readers and potentially increase their audience. Unless you completely disagree with the contents of the blog that linked to you — and you would never want your readers to visit it — you can approve legitimate pingbacks through the WordPress interface and allow them to be displayed in the comments section of your posts.

Spam Pingbacks
Some blogs are simply lengthy advertisements for products or services, with little in the way of actual content and a large amount of outbound links aimed at increasing their inbound clicks through pingback comments. When you receive a pingback from a site that looks suspicious, you should flag it as spam through the WordPress interface; you should also report the offending blog to the WordPress staff using the “Report Spam” form, found at http://en.wordpress.com/report-spam/.

Self Pingbacks
By default, WordPress automatically sends a pingback to your own old posts when you link to them in a newer post. On one hand, these pingbacks can be helpful in offering additional content on the same subject to readers who find one of your old posts; on the other hand, tags and categories can serve the same purpose, and too many self pingbacks can make the comment area of old posts look cluttered. Whether you allow these pingbacks to display on your weblog or delete them is entirely up to you.

Pingback Settings
You can turn off the ability for a specific post to receive any pingbacks from within the post’s edit page; if the option to disable receiving pingbacks is not present, click on the “Screen Options” button in the upper right corner of the page, tick the check box labeled “Discussion” and click on the “Screen Options” button a second time. If you do not want to receive pingbacks for any of your blog posts, click on the “Discussion” option in the menu on the left of your dashboard, untick the checkbox labeled “Allow link notifications from other blogs” and click on the “Save Changes” button found at the bottom of the page.

Posted in WordPress | Leave a comment

Create a custom toolbar for CKEditor

Normaly when installing CKEditor is has (for me) to many options. CKEditor has a simple option for you to choose which button to show on the toolbar and which not to show.
(need help on the installation of CKEditor?)

Simply go to config.js in the root of the ckeditor directory add some lines like this:

CKEDITOR.editorConfig = function( config )
{
    config.toolbar = 'cms_toolbar';

    config.toolbar_cms_toolbar =
    [
        ['Source','-','Preview','-','Templates'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
        ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
        ['NumberedList','BulletedList','-','Outdent','Indent'],
        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
        ['Link','Unlink','Anchor'],
        ['Image','Table','HorizontalRule','Smiley','SpecialChar'],
        '/',
        ['Styles','Format','Font','FontSize'],
        ['TextColor','BGColor'],
        ['Maximize', 'ShowBlocks','-']
    ];
};

Of course here’s the place where you can add/change your own options. Then after that, let the editor know you want to use this toolbar:

        <asp:TextBox ID="txtPageContent" TextMode="MultiLine" runat="server">
</asp:TextBox>
        <script type="text/javascript">
            CKEDITOR.replace('siteContentHolder_txtPageContent',{toolbar:'cms_toolbar'});
         </script>

That’s it, if you have any questions just leave a comment!

Posted in ASP.net | Tagged , | 1 Comment