Categories
code

CSS Print Framework

If you want to improve your layouts for printing, this mini CSS Framework will definitely assist you.

What is a CSS Framework?

“A CSS framework is a library that is meant to allow for easier, more standards-compliant styling of a webpage using the Cascading Style Sheets language. Just like programming and scripting language libraries, CSS frameworks package a number of ready-made options for designing and outlaying a webpage.” – Wikipedia

One of the cool things in this CSS you can find on line 27/28. This part will grab all links of the document and append the URL to the link-names.

[ad name=”Adsense – text only”]

The Source:

body {
width:100% !important;
margin:0 !important;
padding:0 !important;
line-height: 1.4;
word-spacing:1.1pt;
letter-spacing:0.2pt; font-family: Garamond,"Times New Roman", serif; color: #000; background: none; font-size: 12pt;
}

/*Headings */
h1,h2,h3,h4,h5,h6 { font-family: Helvetica, Arial, sans-serif; }
h1{font-size:19pt;}
h2{font-size:17pt;}
h3{font-size:15pt;}
h4,h5,h6{font-size:12pt;}

code { font: 10pt Courier, monospace; }
blockquote { margin: 1.3em; padding: 1em;  font-size: 10pt; }
hr { background-color: #ccc; }

/* Images */
img { float: left; margin: 1em 1.5em 1.5em 0; }
a img { border: none; }

/* Links */
a:link, a:visited { background: transparent; font-weight: 700; text-decoration: underline;color:#333; }
a:link[href^="http://"]:after, a[href^="http://"]:visited:after { content: " (" attr(href) ") "; font-size: 90%; }
a[href^="http://"] {color:#000; }

/* Table */
table { margin: 1px; text-align:left; }
th { border-bottom: 1px solid #333;  font-weight: bold; }
td { border-bottom: 1px solid #333; }
th,td { padding: 4px 10px 4px 0; }
tfoot { font-style: italic; }
caption { background: #fff; margin-bottom:2em; text-align:left; }
thead {display: table-header-group;}
tr {page-break-inside: avoid;}

/*hide various parts from the site

#header, #footer, #navigation, #rightSideBar, #leftSideBar
{display:none;}

*/

To use this Framework, just attach it to your header and choose “print” as media-type.

<link rel="stylesheet" href="print.css" type="text/css" media="print"/>

via hartija at Google Project Hosting.

Categories
code

The F(ucking) U(ncrackable) E(ncryption) Function in PHP

I think following function doesn’t need any more description but the inline comments.

[ad name=”Adsense – text only”]

The Function:

// f(ucking) u(ncrackable) e(ncryption) function
function fue($hash,$times){
    // Execute the encryptions as many times as the user wants
    for($i=$times;$i>0;$i--) {
        // Encode with base64...
        $hash=base64_encode($hash);
        // and md5...
        $hash=md5($hash);
        // sha1...
        $hash=sha1($hash);
        // sha256... (one more)
        $hash=hash("sha256", $hash);
        // sha512
        $hash=hash("sha512", $hash);
    }
    // Finaly, when done, return the value
    return $hash;
}

This function was first introduced by BlackHatDBL.

Categories
code

Clean Up User-Input & Convert Line-Breaks To BR-tags

A simple PHP function to clean up user input.
It does following:

  • converts & to &amp;
  • converts < to &lt;
  • converts > to &gt;
  • converts to &quot;
  • and converts line-breaks to <br />

[ad name=”Adsense – text only”]

The Function:

function clean($str) {
    $str = preg_replace('/&(?!#[0-9]+;)/s', '&amp;', $str);
    $str = str_replace(array('< ', '>', '"'), array('&lt;', '&gt;', '"'), $str);
    $str = nl2br($str);
    return $str;
}
Categories
code

Check for AJAX Request in PHP

A simple PHP function to check if the request comes from an AJAX XMLHttpRequest.
Use it if you want your page or script to behave differently when called from AJAX.

The Function:

function isAjax(){
    return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}

[ad name=”Adsense – text only”]