Dynamic Guru - The Web and Technology Blog


ajax css design featured freebies google html internet javascript jquery php seo technology tools web wordpress wordpress themes xhtml
 

New theme!

If you are among the frequent visitors to my blog you will notice that i changed the blog theme today, this new theme is my own creation and the best part about it is the effects on the left sidebar, hover over a link to slide it towards right and click on a link category title to see it slide up, all thanx to the powerful jQuery.8) If you like the theme or want to point out a bug , drop a comment using the form below.

Update

I switched back to my previous Silver Theme . But this new theme is now available for download from the official wordpress theme directory.



Click here to download this theme

A problem with float and clear that drove me crazy!

Yesterday i had submitted this wordpress theme of mine to the official wordpress theme directory. I got a feedback from the guys there stating that my theme wasnt valid as it had some issues and they asked me to fix them and upload again. I was able to fix all the issues but one, ant that was : the gallery, when inserted in the post, streches out the gallery container div to around 600px! I looked at the source code of the gallery and found that the gallery was created using the dt and dl tags, and the dt containing the images was set to float to left using css and each row of dt containing images was separated out by a br styled to clear:both. This was the part of document which was causing trouble, the br tag, after clearing both side was pushing down the next row of images to at least around 600px, trying to fix this issue only had me panicking after hours of debugging,re-writing some styles and googling the solution out, but in vain :( . It was when i was almost exhausted and felt like my brain was going to give up and shutdown that i told myself to give it a last try , i just gave my content div (which was set to float to left and was the parent of the post div that was streching out) a fixed width of 740px, and hurray, to my amazement i found that the problem was solved!!! :D . I dont know what actually happened, what had the width of the parent element to do with the vertical stretchning of the gallery image rows. So if you have an explanation then please lemme know in the comments below.

Drive your php code viewers mad! Encode your php script

If you are among the ones who give away free self written php scripts to everybody but want some way to stop script kiddies and newbies just copy-pasting and modifying your script or you just dont want code newbies to know the original code then this post is probably for you. The trick is to encode your php code as a string and then parse the encoded string as php code after decoding it. This trick is very commonly usede by developers. Though this trick cannot stop code copying but can discourage the viewer to a certain extent to copy the code.
Here is how to do it:

  1. Encode your code as string using any encoding method/functions . the most commonly used is base64_encode. You can even use Dynamicguru’s Online base 64 encoder and decoder to instantly convert your code to base64 format
  2. In your script file, decode the generated string using base64_decode function and assign it to a variable
  3. Now call the function eval() passing your decoded string as argument and you are done!

Example :

Consider the following piece of code :

<?php
echo "hello world";
?>

Now suppose you want to disguise the code and make it look un-interpretable , Encode it using our Online base 64 encoder and decoder . here is what the code looks like after encoding :

PD9waHANCmVjaG8gXCJoZWxsbyB3b3JsZFwiOw0KPz4=
//Amazing isnt it?

Now call the eval() function :

eval(base64_decode("PD9waHANCmVjaG8gXCJoZWxsbyB3b3JsZFwiOw0KPz4= "));

//the above code is equal to :

<?php
echo "hello world";
?>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Note
This trick should not be used if you want to completely disguise your code, as anybody can go a step further and decode it using base64_decode function.

The eval fucntion evaluates a string as a php code and is of immense help in situations where you want a piece of code to be stored in a file / database and executed at a later time

hope you enjoyed the post and learnt something new and useful :D

Another wordpress theme

Free beautiful wordpress theme

Free beautiful wordpress theme


Here is another free beautiful wordpress theme from dynamicguru.com . This theme uses jQuery effects for a nice hover effect on the links in the sidebar.

Download this free Wordpress theme

UPDATE 17/06/09

An updated an improved version (1.3) of this theme is now available for download at the official wordpress theme directory :
http://wordpress.org/extend/themes/silver-dreams


To install wordpress theme :

  1. Download and unzip the theme file
  2. Upload the theme directory to “wp-contents/themes” directory
  3. If you do it right, the theme preview will be visible in “Themes”, Click on it to activate and enjoy!

PHP contact form script

The most common use of php on the internet is probably to make Contact Forms or mail forms . Here is a free php contact form script that takes input from 5 fields : name,email,url,subject and message. The script also validates the input and checks to see if the name , email and message fields are filled out properly and also checks if the email address provided is valid. the script then sends a mail to the administrator containing the message and the visitor info and also writes (appends) the input to a “contact.log” file . The script is quiet easy to understand and edit as it is commented and well written. Just place the following code in a “contact.php” file and change the value of $admin_mail to your email id. You can style the form to your taste using css.

<?php

error_reporting(0);
        //Replace with your email ID
        $admin_mail="mujtaba_91@yahoo.com";
       
if (isset($_POST[‘button’])) {
        $date=date(‘l dS \of F Y h:i A e’);
        $name=htmlentities($_POST[‘name’]);
        $email=htmlentities($_POST[‘email’]);
        $url=htmlentities($_POST[‘url’]);
        $subject=htmlentities($_POST[’subject’]);
        $message=htmlentities(stripslashes($_POST[‘message’]));
        //Form Validation
        $errors="";
        if(empty($name)) {
                $errors.="Please enter your name <br />";
        }
       
        if(empty($email) || !strpos($email, "@") || !strpos($email, ".")) {
                $errors.="Please enter a valid email ID <br />";
        }
       
        if(empty($message)) {
                $errors.="Please enter a message <br />";
        }
       
        if(!empty($url) && !strpos($url,"http://")) {
                $url="http://".$url;
        }
       
       
        //Building mail if the input is valid
       
        if ($errors=="") {
        $mail_subject="Message from :".$email;
         //Required for html formatted mail, do not remove
        $headers  = ‘MIME-Version: 1.0′ . "\r\n";
        //Required for html formatted mail, do not remove
        $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . "\r\n";
        $headers .= "To: Admin <".$admin_mail.">" . "\r\n";
        $headers .= "From: ".$name." <".$email.">" . "\r\n";
       
        //The mail
        $mail_message="
        <html>
        <head>
        <title> Message from "
.$name." </title>
        </head>
        <body>
        <b>Name</b> :<br /> $name <br />
        <b>Email</b> :<br /> $email <br />
        <b>URL</b> :<br /> <a href=\"$url\">$url</a> <br />
        <b>IP Address</b> : <br/>
        "
.$_SERVER[‘REMOTE_ADDR’]." <br />
        <b>Date and Time</b> : <br />
        $date <br />
        <b>Message</b> :<br/> "
.nl2br($message)."
        </body>
        </html>"
;
       
        if(mail($admin_mail,$mail_subject,$mail_message,$headers)) {
                $status="Mail Sent Successfully";
                //echo "<div class=’success’>$status</div>";
        }
        else {
                $status="Mail Failed to Send";
                //echo "<div class=’error’>$status</div>";
        }
       
        //Logging the message to a file
        $file="contact.log";
        $log_message="
        Name : $name\r\n
        Email : $email\r\n
        URL: $url\r\n
        Subject: $subject\r\n
        Time: $date\r\n
        IP Address: "
.$_SERVER[‘REMOTE_ADDR’]."\r\n
        Message:
$message\r\n
        Mailing Status: $status\r\n
        _______________________________________________________________________\r\n
        "
;
        $fh=fopen($file,"a+");
        fwrite($fh,$log_message);
        fclose($fh);
       
        echo "Thanx! i will get back to you soon";
        }
        else {
                echo $errors;
        }

       
}

else {
        echo "
        <form action=\"contact.php\" method=\"post\" id="
myform" >
        <input type=\"text\" name=\"name\" /> Name <br />
        <input type=\"text\" name=\"email\" /> Email <br />
        <input type=\"text\" name=\"url\" /> URL <br />
        <input type=\"text\" name=\"subject\" /> Subject <br />
        <textarea cols=\"30\" rows=\"20\" name=\"message\" ></textarea>
        <input type=\"submit\" name=\"button\" value=\"Submit\" />
        </form>"
;
}
?>

My first web portfolio

The web portfolio of Mujtaba Ahmed

The web portfolio of Mujtaba Ahmed

Today i’ve launched my new website and my first web portfolio.

You can check it out here: www.dynamicguru.com/mujtaba/ .

The site is one of my best works till date and is the first site of mine to use ajax and is powered by jQuery. The site uses awesome jQuery effects for page transitions. Also it has validated XHTML 1.0 Strict markup. Check it out and tell me in the comments what you think about it?

Learning jQuery

jQuery is a comprehensive free javascript library that is a must for every designer and developer. It is extremely powerfull and very easy to learn and use and saves a developer a hell lot of time. It can be used to build powerful interactive User Interfaces and sites.You can take a look at some awesome sites built using jquery at jQueryStyle.com to better understand what this little wonder library is capable of.
The library was first written by John Resig back in 2006. The current realease version at the time of writing is 1.3.2. Due to its DOM centered approach, jQuery is very easy to learn for a person who already has some css and xhtml background.
You can download your copy of jQuery from the homepage of jQuery.com
There are a number of free resources on the web which teach you jQuery right from the start, but i would recommend LearningJQuery as it is well documented and has three separate sections for beginner,intermediate and advanced levels. LearningJQuery is authored by Karl Swedberg and some other authors. it is a good place to start with for people new to jQuery. Also the jQuery Docs is good place to refer to whenever you find yourself stuck with a problem.

Why not to rely on free web hosts?

I launched Scrapground.co.cc around an year ago when Orkut enabled html scraps. The site was my first project as i had just taught my self css and php. It featured an online “scrap creating tool” which designed your scrap in 40 different html templates and all you had to do was copy and paste the code given below any template into your friends scrapbook. The site was hosted for free at www.x10hosting.com and had a free .co.cc domain. It worked fine untill i moved to India and stopped logging in into my hosting account frequently, i got suspended a couple of times for inactivity and last week i found out to my surprise that my hosting account had been terminated for inactivity!!! I lost both of my sites as i didnt have a backup of it on my local machine!!! :(

The lesson i learnt were : Never rely on free webhosts and if you cant do without a free host Take regular backup of your site so even if you are kicked off the hosting service you can still quickly switch to another free host.

There are even more reasons as to why free hosts are highly un-reliable, like:

  • Limited or low bandwidth
  • Limited or very less web space
  • Frequent server downtimes
  • No or limited customer support
  • Lack of freedom/ restrictions
  • Search Engines ignore you
© 2012 Dynamic Guru All rights reserved - About Us - WordPress themes - Mujtaba Ahmad