WarpConduit Computing

  • Quick Tips
  • Web Design & Development
  • Graphic Design
  • Home
  • WordPress Plugins
  • Password Generator
  • About
  • Contact

mailto: Email Link Obfuscation (Hiding)

April 1, 2010 by Josh Hartman

After searching for a good email link obfuscation script that allows the address to be seen as normal text i came upon a webpage that had a good solution, so i did a little reverse engineering and created this PHP script to output the same code, enjoy!

$v){
            $domain_array[$k] = strToHex($v,'%');
        }
        $domain = "'".implode("','",$domain_array);
        $domain .= "'";
        $output = $var1."=['".$user."',[".$domain."].reverse().join('.')].join('@');".$var2."=unescape(".$var1.");document.write(".$var2.".link('mai'+'lto:'+".$var1."));";
        $output = "";
        echo $output;
    }else{
        return false; //email address is not valid
    }
}

mailto_link('username@domain.com'); //use this function wherever you want an email link
?>

Filed Under: Web Design & Development Tagged With: email, link, mailto, obfuscation, php

Simple Standalone PHP Web Counter

December 3, 2009 by Josh Hartman

In my search for a simple PHP web counter it was difficult to find one that wasn’t somehow connected to an external host and didn’t write IP addresses to a file and then use resources to search the file later.  With all the NAT firewalls out there counting visitors based on IP address just doesn’t seem like a modern thing to do. I took a script by Eric Sizemore and modified it to create my own version.  What it does is add to the visitor count (stored in a txt file on the server) if they don’t have a cookie showing that they have visited before, then i set that cookie to expire after 60 days, after that if the visitor comes again they will be counted again.  It’s not the most accurate, but gives a good idea of how many people are visiting and i wanted to reduce server file operations.

The Code

  Simple Standalone PHP Web Counter (9.6 KiB, 901 hits)

Installation & Usage

  1. Unzip the code into your website’s root folder
  2. Change permissions on the counter log txt file so that it is writable (chmod 666).
  3. Add the following PHP code at the top of each root page you would like to display the counter on:
  4. Add the following PHP code where you want to have the counter display:
  5. Test the page you’ve included counter.php on and have show_counter() displayed.

Filed Under: Web Design & Development Tagged With: counter, php

Dynamically Load CSS and JS files using PHP

May 12, 2009 by Josh Hartman

I’ve been working more and more with jQuery and plugins that go with it and it can be a pain to keep going back to the code and adding another <script> tag for each of these and then removing it again when you find out it isn’t quite what you needed.  I came up with a solution to look in a “js” folder and create the correct tags for loading the files.  Then i extended this to do CSS files as well.  All you need to do is drop js/css files into “js” and “css” directories and the page you have placed the PHP code onto will load those files.  To disable a file, just delete it or move it into a subfolder. Oh, you are worried about loading order you say?  Since readdir() lists the files in alphabetical order you can rename your files using numbers (01-jquery.js, 02-jquery-plugin.js, 03-global.js, etc.) to adjust the loading order.  If you find any issues leave a comment to help others figure it out.  Hope you find it useful in some application.

Directory Structure

css

01-style.css
02-morestyles.css
03-custom.css

js

01-jquery.min.js
02-jquery.plugin.min.js
03-custom.js

index.php

Code

Place the following code just before your document’s closing </head> tag.

' . "\n";
        }
    }
    closedir($handle);
    echo $js;
}
 
// FOR CSS FILES
$css = '';
$handle = '';
$file = '';
// open the "css" directory
if ($handle = opendir('css')) {
    // list directory contents
    while (false !== ($file = readdir($handle))) {
        // only grab file names
        if (is_file('css/' . $file)) {
            // insert HTML code for loading Javascript files
            $css .= '' . "\n";
        }
    }
    closedir($handle);
    echo $css;
}
?>

Result





Dynamically Load CSS and JS files using PHP










Hello World!

Notes

This code will not search subdirectories for files to load.  This code also doesn’t help when you are using a WYSIWYG editor such as Adobe Dreamweaver that will look for JS/CSS links in the HTML header and load the files.  These programs don’t run the PHP code and therefore don’t know what JS/CSS files are suppose to be loaded. You may need to adjust the path to the “js” and “css” directories based on the location of the page you enter the code onto.

Filed Under: Web Design & Development Tagged With: css, javascript, php

  • « Previous Page
  • 1
  • …
  • 3
  • 4
  • 5

Connect

  • Facebook
  • GitHub
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • Extremely Useful Applications for Web Development and IT Tasks
  • Installing BookStack Wiki on cPanel Shared Hosting
  • Media (MIME) Type Reference List

Tags

automatic benchmark cbc cipher class comparisons cpanel credit memo css decrypt encrypt font gzip htaccess html image increment javascript jquery list magento mcrypt mysql number old opencart order php profiling random redirect repository rijndael shipment software strict ubuntu url wincachegrind windows windows 7 wordpress xampp xdebug xss

Blogroll

  • CodeIgniter
  • Fusion Forward
  • jQuery
  • Nettuts+
  • Smashing Magazine

© 2023 WarpConduit Computing. All Rights Reserved.