Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    On my 'localhost' I have a directory called 'tools' which contains a bunch of PHP scripts I've put together to perform a bunch of basic actions. Actions such as converting a string to MD5 or SHA1, encoding/decoding base64, password generators, hash generators, un/serialize, time, etc.

    Basically a bunch of 'snippets' that make developing easier.

    This thread is to be used to share your tools with others. As/when I make tools, I'll add them here. Feel free to improve on them and post them back!

  2.  

  3. #2
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    MD5 Generator

    This script is a simple textbox. Simply enter the string you wish to convert and hit the button. You are presented with a MD5 hash from your string.

    The Code:

    PHP Code:
    <?php

    if(isset($_POST['submit']))
    {
        
    $md5 md5($_POST['md5']);
        echo 
    $md5;
    }
    ?>
    <form action="" method="post">
        <input type="text" name="md5" /> <input type="submit" value="Gen MD5" name="submit" />
    </form>

  4. #3
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    SHA1 Generator

    (Note: Almost identical to the MD5 generator. You could even put the two together with 2 submit buttons - one for MD5 or one for SHA1)

    This script is a simple textbox. Simply enter the string you wish to convert and hit the button. You are presented with a MD5 hash from your string.

    The Code:

    PHP Code:
    <?php

    if(isset($_POST['submit']))
    {
        
    $sha1 sha1($_POST['sha1']);
        echo 
    $sha1;
    }
    ?>
    <form action="" method="post">
        <input type="text" name="sha1" /> <input type="submit" value="Gen SHA1" name="submit" />
    </form>

  5. #4
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    Base64 Encoder/Decoder

    This script allows you to encode and decode base_64 strings.

    The Code:

    PHP Code:
    <?php 
    // Setting str just to stop an undefined error
    $str=null;

    if(isset(
    $_POST['decode'])) 
    {
        
    $str base64_decode($_POST['data']);
    }
    elseif(isset(
    $_POST['encode'])) 
    {
        
    $str base64_encode($_POST['data']);
    }
    ?>
    <form action="" method="post">
    <textarea rows="15" cols="80" name="data"><?php echo $str?></textarea>
    <br />
    <input type="submit" name="decode" value="Base64 Decode" /> | <input type="submit" name="encode" value="Base64 Encode" />
    </form>

  6. #5
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    Current Unix Timestamp

    A pretty simple one Just shows the current unix timestamp.

    The Code:

    PHP Code:
    <?php echo time(); ?>

  7. #6
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    Domain to IP

    Works out and returns the IP address of a domain name.

    The Code:

    PHP Code:
    <?php

    if($_POST['getdomainip_submit']) 
    {
        
    $domain htmlentities(addslashes($_POST['getdomainip_string']));
        
    $domainip gethostbyname($domain);
        echo
    'The IP Address for the domain "'.$domain.'" is <input type="text" value="'.$domainip.'" />';
    }
    else 
    {
    ?>
    <form action="" method="post">
        <input type="text" name="getdomainip_string" /> <input type="submit" name="getdomainip_submit" value="Fetch Domain's IP" />
    </form>
    <?php ?>

  8. #7
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    Random String Generator

    Generates a long random string based on a list of characters. This first runs a bunch of random encryptions on a big, unique number then uses whirlpool hashing to create a long string.

    Note: You can change the encryption from whirlpool to something else supported by php's hash() function.

    The Code:

    PHP Code:
    <?php
    $str 
    = (time()*rand(515))*(time()*rand(515))+(time()*rand(515)*time());

    $str md5(sha1($str));
    $str hash('whirlpool'$str);

    echo 
    $str;
    ?>

  9. #8
    WDF Staff RickM's Avatar
    Join Date
    Jun 2010
    Posts
    593
    Member #
    2
    Liked
    14 times
    Email Form

    NOTE: This is designed for LOCAL use only (mainly to test if your mail server works) - This is not secure enough to use in a production environment! -- You have been warned! Please also note that this is old - its in a simple table - not designed to look pretty!

    This email form allows you to send an email to any address, from any address. Designed mainly to test if a localhost can send emails.

    The Code:

    PHP Code:
    <?php
    if(isset($_POST['submit'])) 
    {

        
    $subject htmlentities($_POST['subject']);
        
    $message htmlentities($_POST['detail']);
        
    $mail_from htmlentities($_POST['customer_mail']);
        
    $header="from: ".htmlentities($_POST['from'])." <".htmlentities($_POST['from']).">";
        
    $to htmlentities($_POST['to']);
        
    $send_contact=mail($to,$subject,$message,$header);

        if(
    $send_contact)
        {
            echo 
    "Message Sent!";
        }
        else 
        {
            echo 
    "Houston, we have a problem!";
        }
    }

    ?>
    <table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
        <tr>
            <td><strong>Contact Form </strong></td>
        </tr>
    </table>

    <table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr>
            <td>
                <form name="form1" method="post">
                    <table width="100%" border="0" cellspacing="1" cellpadding="3">
                        <tr>
                            <td width="16%">Subject</td>
                            <td width="2%">:</td>
                            <td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
                        </tr>
                        <tr>
                            <td>Detail</td>
                            <td>:</td>
                            <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
                        </tr>
                        <tr>
                            <td>Name</td>
                            <td>:</td>
                            <td><input name="name" type="text" id="name" size="50"></td>
                        </tr>
                        <tr>
                            <td>From Email</td>
                            <td>:</td>
                            <td><input name="from" type="text" id="from" size="50"></td>
                        </tr>
                        <tr>
                            <td>To Email</td>
                            <td>:</td>
                            <td><input name="to" type="text" id="to" size="50"></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td><input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"></td>
                        </tr>
                    </table>
                </form>
            </td>
        </tr>
    </table>

  10. #9
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Member #
    25357
    nice tutorial.

  11. #10
    Senior Member Dorky's Avatar
    Join Date
    Jun 2009
    Location
    Destin Florida
    Posts
    1,430
    Member #
    19103
    Liked
    4 times
    Image Resizing

    This is upload only and requires you have the gd-lib installed.
    set the $size_to to the size(du) and $target to the target path. you only need to set the path up to the file name, the extension is taken care of by $extension.
    PHP Code:
    $size_to =100;
    $imagename $_FILES['new_image']['name'];
    $source $_FILES['new_image']['tmp_name'];
    $imgtype $_FILES['new_image']['type'];
    $extensionfind strpos($imgtype"/" );
    $extensionlock = ($extensionfind );
    $extension strtolower(substr("$imgtype"$extensionlock ));
    $target "path/to/file.$extension";
    move_uploaded_file($source$target);
    $file "$target"
    $save "$target";
    list(
    $width$height) = getimagesize($file) ; 
    if (
    $extension == "jpg" || $extension == "jpeg" || $extension == "png" || $extension == "gif")
    {
    $img_data_size $_FILES['new_image']['size'];
    if (
    $img_data_size 8388608)
    {
    if (
    $width $size_to)

    $modwidth $size_to
    }
    else
    {
    $modwidth $width ;
    }
    $diff $width $modwidth;
    $modheight $height $diff
    $tn imagecreatetruecolor($modwidth$modheight) ; 
    if( 
    $extension == "jpg" || $extension == "jpeg" ) { $image imagecreatefromjpeg ($file); }
    if( 
    $extension == "gif" ) { $image imagecreatefromgif ($file);  }
    if( 
    $extension == "png" ) { $image imagecreatefrompng ($file);  } 
    imagecopyresampled($tn$image0000$modwidth$modheight$width$height) ; 
    if( 
    $extension == "jpg" || $extension == "jpeg" ) { imagejpeg($tn$save100) ;  }
    if( 
    $extension == "gif" ) { imagegif($tn$save100) ;  }
    if( 
    $extension == "png" ) { imagepng($tn$save9) ;  }
    }
    else
    {
    $image_upload_error ="Images must be under: 8MB";
    }
    }
    else
    {
    $image_upload_error ="Image was not an accepted format. Accepted types are jpg - jpeg - gif - png";

    PHP Code:
    if (isset($image_upload_error)){ echo "$image_upload_error"; } 

    while($get_it !== true){ continue; }


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:58 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com