This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- source: http://www.apphp.com/index.php?snippet=css-alternating-table-color-rows --> | |
<style type="text/css"> | |
/* technique 1 */ | |
tbody tr:nth-child(odd){ background-color:#ccc; } | |
/* technique 2 */ | |
TBODY TR.odd { background-color:#78a5d1; } | |
</style> | |
<table> | |
<tbody> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- source: http://www.apphp.com/index.php?snippet=javascript-specify-referring-page --> | |
<script type="text/javascript"> | |
var allowed_referrer = "http://www.yourdomain.com/referring_page_name.html"; | |
if(document.referrer.indexOf(allowed_referrer) == -1){ | |
alert("You can access this page only from " + allowed_referrer); | |
window.location = allowed_referrer; | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// source: http://www.apphp.com/index.php?snippet=php-post-request-by-socket-connection | |
// submit these variables to the server | |
$post_data = array("test"=>"yes", "passed"=>"yes", "id"=>"3"); | |
// send a request to specified server | |
$result = do_post_request("http://www.example.com/", $post_data); | |
if($result["status"] == "ok"){ | |
// headers | |
echo $result["header"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// source: http://www.apphp.com/index.php?snippet=php-using-gravatars-in-your-script | |
function show_my_gravatar($email, $size, $default, $rating) | |
{ | |
$params = '?gravatar_id='.md5($email).'&default='.$default.'&size='.$size.'&rating='.$rating; | |
$output = '<img src="http://www.gravatar.com/avatar.php'.$params.'" width="'.$size.'px" height="'.$size.'px" />'; | |
echo $output; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// source: http://www.apphp.com/index.php?snippet=php-compress-multiple-css-files | |
header('Content-type: text/css'); | |
ob_start('compress_css'); | |
function compress_css($buffer) { | |
/* remove comments in css file */ | |
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer); | |
/* also remove tabs, spaces, newlines, etc. */ | |
$buffer = str_replace(array("\r", "\n", "\r\n", "\t", ' ', ' ', ' '), '', $buffer); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
/* Source: hhttp://www.apphp.com/index.php?snippet=html-meta-tag-refresh */ | |
<meta http-equiv="refresh" content="5;url=http://yourdomain.com/" /> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
/* Source: http://www.apphp.com/index.php?snippet=html-meta-tag-refresh#null */ | |
<meta http-equiv="refresh" content="5;url=http://yourdomain.com/" /> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/* Source: http://www.apphp.com/index.php?snippet=css-background-gradient */ | |
.grad{ | |
background: -webkit-gradient(linear, left top, left bottom, from(#84c8d7), to(#327fbd)); | |
background: -moz-linear-gradient(top, #84c8d7, #327fbd); | |
filter: | |
progid:DXImageTransform.Microsoft.gradient(startColorstr="#84c8d7", endColorstr="#327fbd"); | |
} | |
</style> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type="text/css"> | |
/* Source: http://www.apphp.com/index.php?snippet=css-box-shadow */ | |
.shadow { | |
-moz-box-shadow: 4px 5px 5px 1px #777; | |
-webkit-box-shadow: 4px 5px 5px 1px #777; | |
box-shadow: 4px 5px 5px 1px #777; | |
} | |
.shadowIE { | |
background-color:#f5f5f5; /* need for IE*/ |