Archive for May, 2012

PHP Headers and Popular Mime Types


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


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


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

4.JPEG Image

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


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


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


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

8.Text (Plain)

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


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

Get values multiselect

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


Get list news from

ini_set(‘user_agent’, ‘My-Application/2.5’);
$html = file_get_html(‘;);
$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>


How get news a link content from



ini_set(‘user_agent’, ‘My-Application/2.5’);
$html = file_get_html(‘;);
$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=”; , $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:

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

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

// 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=""'); 
header('Content-Transfer-Encoding: binary');
// load the file to send:

// 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

/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”>

$(“.listitem”).slice(0, 2).show();
var showing = $(“.listitem:visible”).length;
$(“.listitem”).slice(showing – 1, showing + 2).show();


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