Archive for May, 2012

PHP Headers and Popular Mime Types

1.Atom

header('Content-type: application/atom+xml');

2.CSS

header('Content-type: text/css');

3.Javascript

header('Content-type: text/javascript');

4.JPEG Image

header('Content-type: image/jpeg');

5.JSON

header('Content-type: application/json');

6.PDF

header('Content-type: application/pdf');

7.RSS

header('Content-Type: application/rss+xml; charset=ISO-8859-1');

8.Text (Plain)

header('Content-type: text/plain');

9.XML

header('Content-type: text/xml');

Get values multiselect

var selectedIdsStr = $("#selectId option:selected").map(function(){
   return $(this).val();
}).get().join(",");



URL:http://stackoverflow.com/questions/1172144/jquery-turn-array-input-values-into-a-string-optimization

Get list news from vnexpress.net

<?php
include_once(‘../../simple_html_dom.php’);
ini_set(‘user_agent’, ‘My-Application/2.5’);
$html = file_get_html(‘http://thethao.vnexpress.net/tin-tuc/bong-da-trong-nuoc/&#8217;);
$item[‘toptin’]     =$html->find(‘div.left a’,1)->innertext;
$item[‘toptin_url’] = $html->find(‘div.left a’,1)->href;
$item[‘images’]       = $html->find(‘div.left img’,0)->src;
$data[] = $item;
foreach($html->find(‘div.news_images’) as $val){
$item[‘toptin’] = $val->find(‘b’,0)->innertext;
$item[‘toptin_url’] = $val->find(‘a.txt_black_hover_blue’,0)->href;
$item[‘images’]  = $val->find(‘img’,0)->src;
$data[] = $item;
}

$n =count($data);
for($i =0;$i<$n;$i++)
{
$title =  $data[$i][‘toptin’];
$images = $data[$i][‘images’];
$url = $data[$i][‘toptin_url’];
echo”<div style=\”margin:0 auto\”>
<div style=\”padding-bottom:4px;width:400px;height:300px;border:1px solid #CC0000;padding-bottom:4px;margin-bottom:20px\”><a href=\”$url\”><img src=\”$images\” border=\”0\”></a>
<p>$title</p>
</div>
</div>”;
}

?>

How get news a link content from thanhnien.com.vn

<?php

include_once(‘../../simple_html_dom.php’);

ini_set(‘user_agent’, ‘My-Application/2.5’);
$html = file_get_html(‘http://www.thanhnien.com.vn/pages/20120530/khoi-thong-song-co-co-30-5-2012.aspx&#8217;);
$ret[‘img’]     = $html->find(‘div.article-content img’, 0)->src;
$ret[‘Title’]     = $html->find(‘div.article-content’, 0)->innertext;
$detail[‘body’] =  preg_replace(“/(src=(\”)+[^(http:|https:)])/i”, ‘src=”http://www.thanhnien.com.vn/&#8217; , $ret[‘Title’]);
echo $detail[‘body’];

?>

Modify HTTP Headers

// See related links for more status codes

// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');

// Page was not found:
header('HTTP/1.1 404 Not Found');

// Access forbidden:
header('HTTP/1.1 403 Forbidden');

// The page moved permanently should be used for
// all redrictions, because search engines know
// what's going on and can easily update their urls.
header('HTTP/1.1 301 Moved Permanently');

// Server error
header('HTTP/1.1 500 Internal Server Error');

// Redirect to a new location:
header('Location: http://www.example.org/');

// Redriect with a delay:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';

// you can also use the HTML syntax:
// <meta http-equiv="refresh" content="10;http://www.example.org/ />

// override X-Powered-By value
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');

// content language (en = English)
header('Content-language: en');

// last modified (good for caching)
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');

// set content length (good for caching):
header('Content-Length: 1234');

// Headers for an download:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"'); 
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip');

// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');

// set content type:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); // plain text file
header('Content-Type: image/jpeg'); // JPG picture
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio MPEG (MP3,...) file
header('Content-Type: application/x-shockwave-flash'); // Flash animation

// show sign in box
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';

yahoo-Chat Client Buttons

Chat Client Buttons

http://www.freejavachat.com/chat.php

/nick newname Change your the chat nick you are using
/join #newroom Create a new chat room or join a room that already exists
/action message Sends a message like mynick *jumps
/whois nick Shows you information about the nickname
/topic new topic Changes the topic (if allowed)
/list Updates the room list
/quit Leave chat and disconnect from the server

Faking a load more with jQuery (no AJAX/PHP)

<div class=”listitem”>list item 1</div>
<div class=”listitem”>list item 2</div>
<div class=”listitem”>list item 3</div>
<div class=”listitem”>list item 4</div>
<div class=”listitem”>list item 5</div>
<div class=”listitem”>list item 6</div>
<div class=”listitem”>list item 7</div>
<div class=”listitem”>list item 8</div>
<div class=”listitem”>list item 9</div>
<div class=”more”>showmore</div>

<a href="javascript://" onclick="showMore(this)">more...</a> 

<script type=”text/javascript”>
$(document).ready(function(){

$(“.listitem”).hide();
$(“.listitem”).slice(0, 2).show();
$(“.more”).click(function(){
var showing = $(“.listitem:visible”).length;
$(“.listitem”).slice(showing – 1, showing + 2).show();
});

});

function showMore(e) {        $('.hiddenMore').eq(0).show()        $(e).removeClass('hiddenMore')     } 

</script>

URL :http://stackoverflow.com/questions/6947718/faking-a-load-more-with-jquery-no-ajax-php

Universal IE 6 CSS

<!--[if !IE 6]><!--> <link rel="stylesheet" type="text/css" media="screen, projection" href="REGULAR-STYLESHEET.css" /> <!--<![endif]-->
 <!--[if gte IE 7]> <link rel="stylesheet" type="text/css" media="screen, projection" href="REGULAR-STYLESHEET.css" /> <![endif]--> 
<!--[if lte IE 6]> <link rel="stylesheet" type="text/css" media="screen, projection" href="http://universal-ie6-css.googlecode.com/files/ie6.0.3.css" /> <![endif]-->


IE-6 ONLY

* html #div { height: 300px; }

IE-7 ONLY

*+html #div { height: 300px; }

IE-8 ONLY

#div { height: 300px/; }

IE-7 & IE-8

#div { height: 300px\9; }

NON IE-7 ONLY:

#div { _height: 300px; }

Hide from IE 6 and LOWER:

#div { height/**/: 300px; }
html > body #div { height: 300px; }

How To Create an IE-Only Stylesheet

Target ALL VERSIONS of IE
<!--[if IE]> <link rel="stylesheet" type="text/css" href="all-ie-only.css" /> <![endif]-->

Target everything EXCEPT IE

<!--[if !IE]><!--> <link rel="stylesheet" type="text/css" href="not-ie.css" /> <!--<![endif]-->

Target IE 7 ONLY

<!--[if IE 7]> <link rel="stylesheet" type="text/css" href="ie7.css"> <![endif]-->

Target IE 6 ONLY

<!--[if IE 6]> <link rel="stylesheet" type="text/css" href="ie6.css" /> <![endif]-->

Target IE 5 ONLY

<!--[if IE 5]> <link rel="stylesheet" type="text/css" href="ie5.css" /> <![endif]-->

Target IE 5.5 ONLY

<!--[if IE 5.5000]> <link rel="stylesheet" type="text/css" href="ie55.css" /> <![endif]-->

Target IE 6 and LOWER

 

<!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="ie6-and-down.css" /> <![endif]-->

<!--[if lte IE 6]> <link rel="stylesheet" type="text/css" href="ie6-and-down.css" /> <![endif]-->

Target IE 7 and LOWER

 

<!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="ie7-and-down.css" /> <![endif]-->
<!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="ie7-and-down.css" /> <![endif]-->

Target IE 8 and LOWER

<!--[if lt IE 9]> <link rel="stylesheet" type="text/css" href="ie8-and-down.css" /> <![endif]-->
<!--[if lte IE 8]> <link rel="stylesheet" type="text/css" href="ie8-and-down.css" /> <![endif]-->

Target IE 6 and HIGHER

<!--[if gt IE 5.5]> <link rel="stylesheet" type="text/css" href="ie6-and-up.css" /> <![endif]-->
<!--[if gte IE 6]> <link rel="stylesheet" type="text/css" href="ie6-and-up.css" /> <![endif]-->

Target IE 7 and HIGHER

<!--[if gt IE 6]> <link rel="stylesheet" type="text/css" href="ie7-and-up.css" /> <![endif]-->
<!--[if gte IE 7]> <link rel="stylesheet" type="text/css" href="ie7-and-up.css" /> <![endif]-->

Target IE 8 and HIGHER

<!--[if gt IE 7]> <link rel="stylesheet" type="text/css" href="ie8-and-up.css" /> <![endif]-->
<!--[if gte IE 8]> <link rel="stylesheet" type="text/css" href="ie8-and-up.css" /> <![endif]-->





Hack CSS IE, Firefox, Chrome, Safari, Opera

1.IE
.className

{
padding:10px/; IE9 + IE8

}

@media all and (min-width:0) {
.className { color:pink /; }  /* IE9 */
}

.className{padding:10px\9;} /* IE8 — */

.className{padding:10px;} /* IE8 */

.className{ *padding :10px ; } /* IE7 — */

or

* + html .class{margin-left:20px;} /* IE7 */

.className{ _padding :10px ; }  /* IE6 — */

or

* html .logo{margin-left:10px;} /* IE6 */

2.Firefox

html>/**/body .className{margin-left:10px}

or

@-moz-document url-prefix() {
.className {{font-size: .6em;}}

html>/**/body .className, x:-moz-any-link, x:default {background:red;} /* Firefox 3 */

3.Chrome

body:nth-of-type(1) .className{margin:20px;}

or:

@media screen and (-webkit-min-device-pixel-ratio:0) {
.className{ margin:0 26px 0 0; }
} /* hacked cho chrome và safari */

4.Safari

@media screen and (-webkit-min-device-pixel-ratio:0)
{ .className { margin:10px; } }

5.Opera
@media all and (min-width:0px) {head~body .className {margin-left:10px;}}