Wednesday, November 17, 2010

Learn to hack from Real Hacking game for those who want

If you are very new in hacking world, before going to the article, I suggest you to read Learn How To Hack With The Hacker’s Underground Handbook before reading further article.

If you are already known to the hacking world then, welcome to the virtual simulation world of hacking environment.

If you really need some easy platform to practice hacking then I think this article will be a great help for you. Yes I am talking about the real hacking game, Hack The Game.

HackTheGame is a free 1MB file game which will introduce you to the real hacking word.

The real hack able DOS environment makes you feel like that you have finally accessed to US Defense system.

The game becomes much more interesting and fun because of the addition of sounds. The sounds includes typing and several warning announcement.

The user interface of HackTheGame is very friendly and easy. Just open the program and select your language, input any ID you may like.

There are several missions of this game. You’ll get the briefing of each mission in your inbox.

The mail itself includes several hints and processes.

If you find sounds irritating then, you can go to settings menu and disable sounds. But I bet you, enabling sounds makes your game play experience very easy.

I bet you’ll love this game.

No installation is needed to run this game and it is obviously safe to use because it utilizes local files which in game play acts as a remote files. You don’t have to worry about your security. If you doubt it, then play it offline.

This game can be downloaded from here, HackTheGame.

Monday, November 15, 2010

How to create a wordpress Upcomming Events Widget- A step by step tutorial

This Wordpress tutorial is targeted to those who are struggling for being a good Wordpress developer. This tutorial will be delivered in simplest term so that a newbie can easily understand what is going on the screen. After following this step by step tutorial, you’ll able to do following things:

  1. Create a very basic Wordpress widget acceptable for even version Wordpress 3.0.1
  2. Create a basic upcoming events widget which lists the scheduled articles.

Wordpress is created in PHP. So, you must know the basic coding knowledge in PHP. Except default Wordpress widgets, you’ll need to create a separate plugin to add separate thirdparty widget to your wordpress blog.

We are going to create a basic plugin first.

Before we start the coding part, lets go to Wordpress Admin panel and explore through the plugin control panel.

To go to Plugin control panel, at the left sidebar, click on Plugins.

This is the place where you can activate/disactivate or install/remove plugins. By default Wordpress stores all the plugin files in wp-content/plugin folder.

For each plugin, you can see various definations. The basic definations needed are, plugin name, plugin URI, description, author name, version and author’s website.

These all will be defined inside the plugin php code.

Let me show you how you can set the details of plugin and start the coding for new plugin.

Open up notepad, a very simple yet powerful text editor by Microsoft.

We must begin every PHP code by

/*

Plugin Name: Comming up

Plugin URI: http://www.hackspc.com

Description: Up comming posts

Author: suraZ Kayastha

Version: 1.0

Author URI: http://youcanhack.blogspot.com

*/

These are actually PHP comments held between /* */ but wordpress fetches these section for details about the plugin.

Wordpress Plugins are all about PHP functions (the division of codes that work for specific part).

Lets see what we can do with the functions to create a plugin that will load a new widget.

/* Function that will deliver all the necessary code contents in the sidebar */

function commingup_widget() {}

/* Function that is called by wordpress when the plugin is activated. It registers new widget called Coming Up */

function init_commingup(){

register_sidebar_widget("commingup", "commingup_widget");

}

/* Tells WordPress to call init_commingup when plugin is loaded */

add_action("plugins_loaded", "init_commingup");

Confused? Let me clear you what those codes do. The first function, commingup_widget(), here is what will be displayed on the sidebar. Whatever HTML/PHP code you put here will be displayed as a sidebar widget. It can be links, texts or any other dynamic contents.

The second function, init_commingup(), is called by WordPress if the plugin is activated. It calls a WordPress function that will register a new widget which will be called “Coming Up” which will call our new widget.

Add action just tells WordPress to call the second function when the plugin is loaded.

That is done, you’ve successfully created a plugin that will deliver a new blank widget.

You may be wondering how you can place dynamic contents in your newly created widget plugin.

This is so simple to do if you know little bit PHP and HTML coding.

Now let’s forget what we’ve done above.

And let me show you the idea to get things ready for your widget.

Consider the following loop that will show the posts that are marked as scheduled posts.

status=future'); ?>

else: ?>

No future events scheduled.

The above code is just a basic posts loop that we have in your index.php page. Only the difference is, it is modified to view only title and scheduled date. Post_status=future makes is so much special. Hence all the posts except scheduled one are filtered out.

You can directly put the above code in any part of index.php. But, we are creating a widget right?

So we’ll modify that code to fit as a widget.

Here is the modified part of it:

echo '

  • Comming up

    ';

    echo '

      ';

      query_posts('showposts=10&post_status=future');

      if ( have_posts() ) : while ( have_posts() ) : the_post();

      echo '

    • '; the_title(); echo '

      ';

      echo ''; the_time('j F Y'); echo '

    • ';

      endwhile;

      else: echo '

      No future events scheduled.

      ';

      endif;

      echo '

  • ';

    We’ll place the above code in function commingup_widget().

    When we combine the description code and the functions we’ll get the following setup of code.

    /*

    Plugin Name: Comming up

    Plugin URI: http://youcanhack.blogspot.com

    Description: Up comming posts

    Author: suraZ Kayastha

    Version: 1.0

    Author URI: http://youcanhack.blogspot.com

    */

    function commingup_widget() {

    echo '

  • Comming up

    ';

    echo '

      ';

      query_posts('showposts=10&post_status=future');

      if ( have_posts() ) : while ( have_posts() ) : the_post();

      echo '

    • '; the_title(); echo '

      ';

      echo ''; the_time('j F Y'); echo '

    • ';

      endwhile;

      else: echo '

    • No future events scheduled.

      ';

      endif;

      echo '

  • ';

    }

    function init_commingup(){

    register_sidebar_widget("commingup", "commingup_widget");

    }

    add_action("plugins_loaded", "init_commingup");

    ?>

    See that? All the codes are enclosed in . Now all we need to do is save it as PHP file. Name it anything you want, I named it commingup.php.

    Upload it to wp-content/plugins/commingup.

    Go to plugin control panel in wordpress and activate it.

    Now navigate to widget control panel, Right sidebar > Appearance > Widgets.

    There you go, you’ll see the widget that you’ve just created.

    Click and drag it to the sidebar.

    Now reload your Wordpress website. If you have any scheduled post then it will list it as an upcoming event.

    If nothing is scheduled then it will print “No future events scheduled”.

    If you have any confusion, then comment us. We’ll have full support for this widget in our blog.

    Sunday, November 14, 2010

    View PSD and other image files without installing Photoshop

    Yesterday, I requested my friend to send me the snapshot of the PSD file of the Wordpress design. But he claimed that his Photoshop CS2 has expired. He thought of going to his friend and copying the snapshot and again sending back to me. Photoshop Document itself was large size, therefore I asked for the snapshot. If I was going to accept his idea, then I would have to wait whole day for just a snapshot.

    Rather I suggested him certain idea to view PSD files without the need of Photoshop. And that is what I want to share with my visitors as well.

    With IrfanView, a 1.3 MB image viewing freeware utility, you can open almost all the images without need of any high level software. Here is a list of image files that I can open.

    IrfanView is a freeware utility, licensed under End User License Agreement (EULA).

    It is not only a viewer; rather you can edit the pictures there. Basically it supports cropping, cut, paste, copy, drawing tools, eraser tools etc. IrfanView is plug-in enabled, that means they have plug-in to make it more accessible and useful.

    Click here to download IrfanView

    This is guest post from suraZ. His other interesting posts can be read on You Can Hack and Hacktutors blog.

    Saturday, November 13, 2010

    Only Retrieve First Image Of The Post In Mainpage If It Exists – Wordpress Hack

    I am going to apply a small hack to the trick suggested by wprecipes.com to display the first image from the post in a mainpage.

    Let’s summarize what they’ve done.

    First they’ve created a function that retrives the first image of the post if the image is not found, then it will show default.jpg image from the defined location.

    function catch_that_image() {

    global $post, $posts;

    $first_img = '';

    ob_start();

    ob_end_clean();

    $output = preg_match_all('/"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);

    $first_img = $matches [1] [0];

    if(empty($first_img)){ //Defines a default image

    $first_img = "/images/default.jpg";

    }

    return $first_img;

    }

    Code exactly copied from wprecipes.com

    The above code snippet is to be copied in functions.php file located at the themes root folder. If it doesn’t exists, then you can create one using notepad, and paste the above code enclosed in following format:

    Wprecipes.com’s function code goes here

    ?>

    Now to load the image anywhere in your main page or any other page just places the following code within the posts loop.

    The above PHP function code must like somewhere near to or

    Consider it in the following example loop.

    " rel="bookmark" title="Permanent Link to ">

    by

    " />

    You’ll get following type of screen in your post loop.

    The upper post contains the first image of the post. The lower content is not showing any images rather than a alternate tag. It is because we don’t have any image in the second post, by default from functions.php, functions will be redirected to no image and browser will try to load default image. If browser is unable to find /images/default.jpg, which we have specified in functions.php it will show no image but alternative title, you must upload default.jpg in the specific location to get the default image.

    But using default image might not be dynamic and useful if most of your post doesn’t contain any images. Then we’ll have to seek extra tweaks to show nothing in place of default image.

    Let me show you how can you accomplish this using extra function.

    First, we’ll create a function that will scan for presence of any image in the specific post, then we’ll define what it must do if image is there and what it must do if image is not there. It can be accomplished by using conditional tags.

    Here is the function to scan image, add this in functions.php just above, ?> (i.e. exactly above the PHP code end tag)

    function image_scan( $args = array() ) {

    if ( !$post_id )

    global $post;

    preg_match_all( '|?>|i', $post->post_content, $matches );

    if ( isset( $matches ) ) $image = $matches[1][0];

    if ( $matches[1][0] )

    return array( 'image' => $image );

    else

    return false;

    }

    Now we’ll use PHP conditional tag in index.php or any page where we want this to take effect on.

    Show image

    The final code will be like this after applying the the image_scan condition.

    " rel="bookmark" title="Permanent Link to ">

    by

    " />


    Now you’ll have only thumbnails of first images if it exists, otherwise it shows no image.

    Friday, November 12, 2010

    Transfer Your Joomla Website From One Host To Another

    Ever wanted to shift your joomla site from one host to another better host? There are lots of thirdparty joomla extensions to transfer your joomla web contents, but the layout may remain same. You can transfer the joomla with your whole layout and widgets same as in previous host.

    Backup your database

    First you’ll need to backup your database from phpmyadmin. Go to your phpmyadmin from control panel. Then at the left sidebar, select the database your joomla is based on.

    After you select the database, you’ll get list of tables.

    At the right column, select on export tab.

    In next page, under View dump (schema) of database, Export, click on select all.

    Below this, you’ll have large options of formats available to export in. Choose SQL.

    Under Save as File, give the filename and choose the compression method if you have larger size of database.

    Then at the most right corner, click on GO button.

    Then you’ll have a text format of the database.

    Select all and copy it in Notepad. Save it as “database.txt” with Unicode formatting.

    Now you have successfully backed up your data. Next you’ll be copying the core contents of the joomla site.

    Copying the files to another host.

    This is nothing harder; it is like just copying and pasting. Copy the contents from the source host and paste it to another host by using any FTP client favorable to you. You can also use windows inbuilt ftp client.

    Since you are using joomla and using different host than previous one, delete the configuration.php file from the root of the webhost. Get the installation folder of the joomla version you were using and upload it to your new host again, as you might have deleted it from your previous host for security reasons.

    Now we have the files ready.

    Preparing for transfer.

    Next, you’ll again login to phpmyadmin control panel and manually create a new database. To create a new database, in your phpmyadmin main page, type the database name exactly same that you had before.

    Click on create button.

    Installing again

    To fix the host configuration, you’ll need to re-install joomla. Reinstalling joomla will create completely new website and you haven’t created any tables yet in your new database.

    In your web browser browse to the main page and install it as usually with no sample data installed. Even though you install sample data, it doesn’t matter as you will be droping all the tables later.

    After you the installation is complete, either rename or replace or remove installation folder. You’ll have new configuration.php in your root folder where joomla is installed.

    Deleting the database

    We installed joomla again only for the configuration.php. Now we won’t need the new tables created in this database. Therefore we’ll be removing it.

    To remove all the tables, choose the database as before. In the right column at the end of the table list, click on Check All.

    Now at in with selected dropdown list, select drop.

    In next confirmation window, click on Yes button.

    There you go, you’ve successfully cleared all the contents in your database. At the moment, your website won’t work, so better not browsing it.

    Recovering your previous database

    Again choose the database you’ve just emptied, at the right column choose import tab.

    In next page, click on choose file and upload the backed up database. Before uploading make sure you’ve chosen the right format. We’ve saved database.txt in utf-8 format. Hence we must select utf-8 format in the dropdown list.

    Leave rest of the things as default and click on Go button.

    You’ll be notified if the database has been successfully uploaded.

    Now you’ve successfully completed transferring your blog. You’ll see everything similar as before.

    Note: You might have problem in administration page login if you have typed different username and password. The Username and Password that you used at the time of installation gets deleted. As you upload the backed up database, your previous administer username and password will be recovered instead. Therefore try logging in username and password as you had in your previous host.

    Thursday, November 11, 2010

    CSS Mouse Hover Tips To Beautify Your Web Templates

    Beautiful web template is what everyone expects to have in their site. Moreover making it is much more challenging. Previously websites were designed in tabled form. Later the tabled forms were replaced by Cascading Style Sheets (CSS).

    CSS is the versatile method to design website, while HTML as the platform. Today, for interactive websites, mostly flash based movie files are used. However Flash is not based on any HTML program. Plus, it needs additional plug-in and applets in browser to view the flash based website. This is the main backward feature of flash based websites.

    However with the release of new HTML 5 and CSS, it is now possible to achieve interactive websites more versatile than Flash based interactive websites.

    Today, in this post, we’ll discuss about few methods that we can apply in HTML and CSS only to achieve highly dynamic and interactive web templates.

    Using pseudo classes

    CSS pseudo-classes are used to add special effects to some selectors. For example, some popular and widely used pseudo classes are:

    :link, :visited, :hover, :active.

    Following example demonstrates the use of pseudo class in tags.

    a:link {color:#FF0000;} /* unvisited link */
    a:visited {color:#00FF00;} /* visited link */
    a:hover {color:#FF00FF;} /* mouse over link */
    a:active {color:#0000FF;} /* selected link */

    It can also be applied to lists and divisions to add more hover effects to the web page.

    For example, the following images shows how it can be applied to divisions to add content highlight effect.

    We’ used hover to one of the class for division.

    Here is the basic CSS code:

    And for the HTML part:

    Every contents located here will have mouse highlighting effect.


    Method to add image link hover effect

    Bascially, we apply background image to a:link and another background image to a:hover to have background image hover effect in CSS. It is ok with all of the browsers as most of them supports it.

    But incase you are using large size image then you’ll have a problem here. What exactly the above method does is that, whenever the link is in normal state (i.e. mouse is not over the link) the browser will in default load the background image specified in a:link CSS class, but when mouse is hovered over the link, it will load background image from a:hover class. If the image is larger in size then it will take time to load.

    Let us discuss alternative method which will load both of the images at the of page load.

    Look at the HTML code below:

    < href="link.html">

    image

    imagehover

    We have two images inside tag each of the image have specific class defined.

    We can hide one of the image when hovering with the help of CSS.


    img.nohover {

    border:0

    }

    img.hover {

    border:0;

    display:none

    }

    a:hover img.hover {

    display:inline

    }

    a:hover img.nohover {

    display:none

    }

    In above four different CSS functions, at first when no mouse is hovered over the link image, the image defined with class “nohover” will take in action, resulting only one image to be viewed. In other words, one image is set to hidden while other one is set to visible. We do this by the help of display:none;

    Now when a link image is hovered, we’ll apply display:none; to the image that must be hidden when hovered. And for the one that must be visible, we’ll apply display:inline;

    Copy and try the above codes. Play with it, you’ll learn more when you research it yourself.

    This works in all the version of browsers, so you won’t have cross browser compatibility problem.

    The rise of CSS3 have made more thing possible, the above tutorial is classified under CSS 2.1 version.

    In this way you can utilize the pseudo class hover to make your web page much more user friendly and interactive.

    Monday, November 8, 2010

    Hacking CSS For Rounded Colors In All Browsers No Images And No Javascript

    There are lots of tricks to get rounded/curved corners for our CSS websites. For example, you may want rounded corner for a box. You may easily think of using images and aligning it top left, top right, bottom left and bottom right. It sounds easy, but is way too complicated as we’ll need to create large number of blank divisions. Also another minus point can be, it is little bit harder to crop the exact pixel of the corner. Consequently, we’ll have something irregular display of corners and the plain line.

    Also we’ve another technique, border-radius, which is supported from CSS3. But CSS3 is not supported in enemy of web developers, i.e. Internet Explorer. However CSS3 is partially supported in other popular browsers like Chrome, Firefox, Safari, etc.

    The main problem here became the internet explorer. Even Internet Explorer 8 doesn’t support CSS3 rounded corners. However, it is expected in Internet Explorer 9.

    Now, instead of trying images and CSS3, we’ll focus on CSS2 as every of the browsers supports it.

    Before creating rounded corners we must technically have pixel to pixel knowledge about rounded corners.

    Rounded corners are created from pixels. Imagine a bunch of few lines combining to form a rounded corner. To get clearer, refer to following example:

    The above illustration is the illustrated microscopic view of rounded corner in raster image.

    Again when the lines come closer together, then it looks like this:

    Finally when all of the line combines then it gives a pixilated image of rounded corner.

    In normal view, a rounded corner will look like the image below:

    We are going to work on the same principle.

    Assume that you want rounded corner of about 6 pixel, then you’ll need 7 different lines of 1 pixel height with several width.

    As you can see the first line illustrated image above, the height is made constant with few gaps and the width keeps increasing by 1px or few more pixels.

    For your easy, again refer to following illustration.

    The first line is 93px long, and second line is 2px more than first one. After that the width of the line is kept increasing by 1px till it gives 99px.

    Note: For larger radius, you’ll need larger number of lines.

    Now we’ll do the CSS trick here which is applicable as CSS2.

    We’ll create 6 spans with different classes. We’ll name the class as class1, class2, class3, class 4, class5, class6. And we’ll put each line in each span class. But we are not going to place image, we’ll be instead using background color for each span.

    You might question right here, why 6 classes only when we have 7 lines in above image. Well, this is because, the last two lines have similar width and we can set the height to make it as two lines.

    Again to define the width of each span, we’ll use margin, where the actual width remains same but the background color will skip the marginal areas. And we’ll again set the height of each span.

    OK, now let me show you how this can be accomplished in CSS script.

    We will first set default values for all the classes that lies in span.

    .class1, .class2, .class3, .class4, .class5, .class6 {

    display:block;

    overflow:hidden;

    }

    This will make each span as a block instead of inline content and set the overflow hidden.

    We’ll now set the width of each line. But we are not using width CSS code as we actually will have dynamic div wrapping this. So we are doing only pixels work here not a line. Therefore, we’ll use margin.

    Here is a code for each class,

    .class1 {

    Height:1px

    Background:#ddd;

    Margin:0 6px; /* this will make the first line of the rounded corner 6px smaller than normal maximum line width */

    }

    .class2 {

    Height:1px

    Background:#ddd;

    Margin:0 4px; /* this will make the second line of the rounded corner 4px smaller than normal maximum line width */

    }

    .class3 {

    Height:1px

    Background:#ddd;

    Margin:0 3px; /* this will make the third line of the rounded corner 6px smaller than normal maximum line width */

    }

    .class4 {

    Height:1px

    Background:#ddd;

    Margin:0 2px; /* this will make the fourth line of the rounded corner 2px smaller than normal maximum line width */

    }

    .class5 {

    Height:1px

    Background:#ddd;

    Margin:0 1px; /* this will make the fifth line of the rounded corner 2px smaller than normal maximum line width */

    }

    .class6 {

    Height:2px /* this will double the line */

    Background:#ddd;

    Margin:0 0; /* this will make the last line of the rounded exactly the maximum width of the wrapper */

    }

    Now we’ll be coding for XHTML.

    span>span>

    Rounded Corner here!!

    span>span>

    The bottom rounded corner must have reversed order of span class. Like we have class1 then class 2 then class 3 then class 4 up to class 6 for the top rounded corner. We’ll need exactly reverse, class6 then class5 … for the bottom rounded corner.

    Finalized style sheet:

    Apply the above code and see the result in every browser. It is supported in every browser, as we have used nothing complicated here.