[
{ "keys": ["ctrl+shift+u"], "command": "sftp_upload_file" },
{ "keys": ["ctrl+shift+m"], "command": "sftp_browse" },
{ "keys": ["f4"], "command": "toggle_side_bar" },
]
Kiến thức là vô biên, vì vậy hãy chia sẻ nó. Trên đây là một số công cụ và source mình sưu tầm được. Mong là nó sẽ hữu ích đối với bạn !
Code Google
Thứ Năm, 23 tháng 1, 2014
Thứ Bảy, 18 tháng 1, 2014
something in sql
Boolean full-text searches have these characteristics:
- They do not use the 50% threshold.
- They do not automatically sort rows in order of decreasing relevance. You can see this from the preceding query result: The row with the highest relevance is the one that contains “MySQL” twice, but it is listed last, not first.
-
They can work even without a
FULLTEXTindex, although a search executed in this fashion would be quite slow. - The minimum and maximum word length full-text parameters apply.
- The stopword list applies.
-
+
A leading plus sign indicates that this word must be present in each row that is returned. -
-
A leading minus sign indicates that this word must not be present in any of the rows that are returned.
Note: The-operator acts only to exclude rows that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by-returns an empty result. It does not return “all rows except those containing any of the excluded terms.” -
(no operator)
By default (when neither+nor-is specified) the word is optional, but the rows that contain it are rated higher. This mimics the behavior ofMATCH() ... AGAINST()without theIN BOOLEAN MODEmodifier. -
> <
These two operators are used to change a word's contribution to the relevance value that is assigned to a row. The>operator increases the contribution and the<operator decreases it. See the example following this list. -
( )
Parentheses group words into subexpressions. Parenthesized groups can be nested. -
~
A leading tilde acts as a negation operator, causing the word's contribution to the row's relevance to be negative. This is useful for marking “noise” words. A row containing such a word is rated lower than others, but is not excluded altogether, as it would be with the-operator. -
*
The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the*operator.
If a word is specified with the truncation operator, it is not stripped from a boolean query, even if it is too short (as determined from theft_min_word_lensetting) or a stopword. This occurs because the word is not seen as too short or a stopword, but as a prefix that must be present in the document in the form of a word that begins with the prefix. Suppose thatft_min_word_len=4. Then a search for'+will likely return fewer rows than a search forword+the*''+:word+the'
-
The former query remains as is and requires both
wordandthe*(a word starting withthe) to be present in the document. -
The latter query is transformed to
+(requiring onlywordwordto be present).theis both too short and a stopword, and either condition is enough to cause it to be ignored.
-
The former query remains as is and requires both
-
"
A phrase that is enclosed within double quote (“"”) characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words and performs a search in theFULLTEXTindex for the words. Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example,"test phrase"matches"test, phrase".
If the phrase contains no words that are in the index, the result is empty. For example, if all words are either stopwords or shorter than the minimum length of indexed words, the result is empty.
-
'apple banana'
Find rows that contain at least one of the two words. -
'+apple +juice'
Find rows that contain both words. -
'+apple macintosh'
Find rows that contain the word “apple”, but rank rows higher if they also contain “macintosh”. -
'+apple -macintosh'
Find rows that contain the word “apple” but not “macintosh”. -
'+apple ~macintosh'
Find rows that contain the word “apple”, but if the row also contains the word “macintosh”, rate it lower than if row does not. This is “softer” than a search for'+apple -macintosh', for which the presence of “macintosh” causes the row not to be returned at all. -
'+apple +(>turnover <strudel)'
Find rows that contain the words “apple” and “turnover”, or “apple” and “strudel” (in any order), but rank “apple turnover” higher than “apple strudel”. -
'apple*'
Find rows that contain words such as “apple”, “apples”, “applesauce”, or “applet”. -
'"some words"'
Find rows that contain the exact phrase “some words” (for example, rows that contain “some words of wisdom” but not “some noise words”). Note that the “"” characters that enclose the phrase are operator characters that delimit the phrase. They are not the quotation marks that enclose the search string itself.
SELECT name, description, ...
FROM ...
WHERE id IN([ids, any order])
ORDER BY FIELD(id, [ids in order])
FIELD() will return the index of the first parameter that is equal to
the first parameter (other than the first parameter itself).FIELD('a', 'a', 'b', 'c')will return 1
FIELD('a', 'c', 'b', 'a')
Thứ Sáu, 17 tháng 1, 2014
class get pagerank
class PR {
public function get_google_pagerank($url) {
$query="http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".$this->CheckHash($this->HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0";
$data=file_get_contents($query);
$pos = strpos($data, "Rank_");
if($pos === false){} else{
$pagerank = substr($data, $pos + 9);
return $pagerank;
}
}
public function StrToNum($Str, $Check, $Magic)
{
$Int32Unit = 4294967296; // 2^32
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
public function HashURL($String)
{
$Check1 = $this->StrToNum($String, 0x1505, 0x21);
$Check2 = $this->StrToNum($String, 0, 0x1003F);
$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
$T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
return ($T1 | $T2);
}
public function CheckHash($Hashnum)
{
$CheckByte = 0;
$Flag = 0;
$HashStr = sprintf('%u', $Hashnum) ;
$length = strlen($HashStr);
for ($i = $length - 1; $i >= 0; $i --) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int)($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag ++;
}
$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2) ) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}
return '7'.$CheckByte.$HashStr;
}
}
Lay rank alexa
<?$url="toolspot.org";$xml = simplexml_load_file('http://data.alexa.com/data?cli=10&dat=snbamz&url='.$url);$rank=isset($xml->SD[1]->POPULARITY)?$xml->SD[1]->POPULARITY->attributes()->TEXT:0;$web=(string)$xml->SD[0]->attributes()->HOST;echo $web." has Alexa Rank ".$rank;?>Thứ Tư, 15 tháng 1, 2014
Thứ Ba, 7 tháng 1, 2014
Chủ Nhật, 5 tháng 1, 2014
tab basic using jquery
<!DOCTYPE html>
<html>
<body>
<style>
.title_tab li {
float: left;
list-style: none outside none;
}
.content_tab li {
display: none;
list-style: none outside none;
}
.title_tab ul {
height: 30px;
margin: 0;
padding: 0;
}
.title_tab li a {
background: none repeat scroll 0 0 #D7D7D7;
border-radius: 5px 5px 0 0;
border-top: 1px solid #CCCCCC;
color: #666161;
display: block;
font-family: arial;
margin-left: 10px;
padding: 5px 33px;
text-decoration: none;
}
.content_tab li {
}
.content_tab li.active {
display: block;
}
.content_tab > ul {
background: none repeat scroll 0 0 #EDEDED;
border-radius: 4px;
margin: 0;
padding: 10px;
}
.title_tab li.active a {
background: none repeat scroll 0 0 #EDEDED;
color: #060606;
font-weight: bold;
}
</style>
<div class="title_tab">
<ul class="">
<li data-class-child="1" class="active"> <a href="#">1</a></li>
<li data-class-child="2"> <a href="#">2</a></li>
<li data-class-child="3"> <a href="#">3</a></li>
</ul>
</div>
<div class="content_tab">
<ul class="">
<li class="active"> <a href="#">a</a></li>
<li> <a href="#">b</a></li>
<li> <a href="#">c</a></li>
</ul>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.title_tab li').click(function(event) {
var pos_li=$(this).attr('data-class-child');
$('.title_tab ul>li').removeClass('active');
$(this).addClass('active');
$('.content_tab ul>li').removeClass('active');
$('.content_tab ul>li:nth-child('+pos_li+')').addClass('active');
return false;
});;
});
</script>
</body>
</html>
<html>
<body>
<style>
.title_tab li {
float: left;
list-style: none outside none;
}
.content_tab li {
display: none;
list-style: none outside none;
}
.title_tab ul {
height: 30px;
margin: 0;
padding: 0;
}
.title_tab li a {
background: none repeat scroll 0 0 #D7D7D7;
border-radius: 5px 5px 0 0;
border-top: 1px solid #CCCCCC;
color: #666161;
display: block;
font-family: arial;
margin-left: 10px;
padding: 5px 33px;
text-decoration: none;
}
.content_tab li {
}
.content_tab li.active {
display: block;
}
.content_tab > ul {
background: none repeat scroll 0 0 #EDEDED;
border-radius: 4px;
margin: 0;
padding: 10px;
}
.title_tab li.active a {
background: none repeat scroll 0 0 #EDEDED;
color: #060606;
font-weight: bold;
}
</style>
<div class="title_tab">
<ul class="">
<li data-class-child="1" class="active"> <a href="#">1</a></li>
<li data-class-child="2"> <a href="#">2</a></li>
<li data-class-child="3"> <a href="#">3</a></li>
</ul>
</div>
<div class="content_tab">
<ul class="">
<li class="active"> <a href="#">a</a></li>
<li> <a href="#">b</a></li>
<li> <a href="#">c</a></li>
</ul>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.title_tab li').click(function(event) {
var pos_li=$(this).attr('data-class-child');
$('.title_tab ul>li').removeClass('active');
$(this).addClass('active');
$('.content_tab ul>li').removeClass('active');
$('.content_tab ul>li:nth-child('+pos_li+')').addClass('active');
return false;
});;
});
</script>
</body>
</html>
Thứ Tư, 25 tháng 12, 2013
Plugin sublime text : Bracket Highlighter Đánh dấu
Plugin sublime text : Bracket Highlighter Đánh dấu
Thứ Ba, 17 tháng 12, 2013
Thứ Hai, 16 tháng 12, 2013
Thứ Bảy, 14 tháng 12, 2013
jquery ajax + php
Lấy database với ajax
$(document).delegate("#json", "pageinit", function() { $(".manda").click(function(e) { $.ajax({ url : "json1.php", dataType : "json", data : '{"opc":"sim"}', success : function(data){ var html = ""; for($i=0; $i < data.length; $i++){ html += "<strong>Nome:</strong> "+data[$i].nome +" "+ data[$i].sobreNome; html += " <strong>Cidade:</strong> "+data[$i].cidade html += "<br />"; } $("#mostra").html(html); } }); return false; }); });
<?php if ($_POST['opc'] == "sim"){ $var = Array( array( "nome"=>"João", "sobreNome"=>"Silva", "cidade"=>"Maringá" ), array( "nome"=>"Ana", "sobreNome"=>"Rocha", "cidade"=>"Londrina" ), array( "nome"=>"Véra", "sobreNome"=>"Valério", "cidade"=>"Cianorte" )); echo json_encode($var); } ?>
Upload file với ajax
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form id="form" method="post" action="post.php" enctype="multipart/form-data">
<input type="file" name="img"/>
<input type="submit" value="Upload" />
</form>
<script src="jquery.js"></script>
<script src="upload.js"></script>
</body>
</html>
<?php
if($_FILES['img']['error'] > 0) die('Error ' . $_FILES['file']['error']);
if(empty($_FILES['img']['name'])) die('No file sent.');
$tmp = $_FILES['img']['tmp_name'];
if(is_uploaded_file($tmp))
{
if(!move_uploaded_file($tmp, 'img.png')) echo 'error !';
}
else echo 'Upload failed !';
?>
$(function() {
$('#form').submit(function(e) {
e.preventDefault();
data = new FormData($('#form')[0]);
console.log('Submitting');
$.ajax({
type: 'POST',
url: 'post.php',
data: data,
cache: false,
contentType: false,
processData: false
}).done(function(data) {
console.log(data);
}).fail(function(jqXHR,status, errorThrown) {
console.log(errorThrown);
console.log(jqXHR.responseText);
console.log(jqXHR.status);
});
});
});
Thứ Ba, 10 tháng 12, 2013
Button top jquery
=========== HTML ===========
<div class="button_top"></div>
=========== CSS ===========
.button_top {
background: url("../images/top_png.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
bottom: 70px;
height: 70px;
position: fixed;
right: 22px;
width: 70px;
display: none;
cursor: pointer;
}
=========== JS ===========
var offset = 220;
var duration = 500;
$(window).scroll(function() {
console.log($(window).width());
if($(window).width()<1190){
$(".button_top").remove();
}
if ($(this).scrollTop() > offset) {
$('.button_top').fadeIn(duration);
} else {
$('.button_top').fadeOut(duration);
}
});
$(".button_top").click(function(event){
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
});
<div class="button_top"></div>
=========== CSS ===========
.button_top {
background: url("../images/top_png.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
bottom: 70px;
height: 70px;
position: fixed;
right: 22px;
width: 70px;
display: none;
cursor: pointer;
}
=========== JS ===========
var offset = 220;
var duration = 500;
$(window).scroll(function() {
console.log($(window).width());
if($(window).width()<1190){
$(".button_top").remove();
}
if ($(this).scrollTop() > offset) {
$('.button_top').fadeIn(duration);
} else {
$('.button_top').fadeOut(duration);
}
});
$(".button_top").click(function(event){
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
});
Thứ Sáu, 6 tháng 12, 2013
Truyền chuỗi vào biến
$path_server="Nội dung biến";
$son="path_server";
echo ${$son};
// Output
Nội dung biến
$son="path_server";
echo ${$son};
// Output
Nội dung biến
Lấy tin từ trang web khác
/****************************
*
* Lấy tin từ trang web khác
*
*laytin_banh($url_array)
*
****************************/
function laytin_banh($url_array){
print_r($url_array);
$data=array();
$j=0;
for($i=0;$i<sizeof($url_array);$i++){
$html = $this->curl_get($url_array[$i]);
foreach ($html->find(".normal") as $link){
echo "<h1>".$j."</h2>";
$html2 = str_get_html($link->innertext);
foreach ($html2->find(".price") as $link2){
$data[$j]["price"]=$link2->innertext;
}
foreach ($html2->find(".info>a") as $link2){
$data[$j]["title"]=$link2->innertext;
}
foreach ($html2->find(".picture img") as $link2){
$data[$j]["src"]=$link2->src;
}
$html2->clear();
echo "<pre>";
print_r($data[$j]);
echo "</pre>";
$j++;
}
$html->clear();
}
file_put_contents("banhbong_lan_new.json", json_encode($data));
}
/******************************
* Lấy Html bằng phương thức cURL (Rất nhanh và hiệu quả)
*
* curl_get($url)
*
*******************************/
function curl_get($url){
$cookie = tmpfile();
$userAgent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31' ;
$ch = curl_init($url);
$options = array(
CURLOPT_CONNECTTIMEOUT => 20 ,
CURLOPT_USERAGENT => $userAgent,
CURLOPT_AUTOREFERER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIEFILE => $cookie,
CURLOPT_COOKIEJAR => $cookie ,
CURLOPT_SSL_VERIFYPEER => 0 ,
CURLOPT_SSL_VERIFYHOST => 0
);
curl_setopt_array($ch, $options);
$kl = curl_exec($ch);
curl_close($ch);
$dom=str_get_html($kl);
return $dom;
}
*
* Lấy tin từ trang web khác
*
*laytin_banh($url_array)
*
****************************/
function laytin_banh($url_array){
print_r($url_array);
$data=array();
$j=0;
for($i=0;$i<sizeof($url_array);$i++){
$html = $this->curl_get($url_array[$i]);
foreach ($html->find(".normal") as $link){
echo "<h1>".$j."</h2>";
$html2 = str_get_html($link->innertext);
foreach ($html2->find(".price") as $link2){
$data[$j]["price"]=$link2->innertext;
}
foreach ($html2->find(".info>a") as $link2){
$data[$j]["title"]=$link2->innertext;
}
foreach ($html2->find(".picture img") as $link2){
$data[$j]["src"]=$link2->src;
}
$html2->clear();
echo "<pre>";
print_r($data[$j]);
echo "</pre>";
$j++;
}
$html->clear();
}
file_put_contents("banhbong_lan_new.json", json_encode($data));
}
/******************************
* Lấy Html bằng phương thức cURL (Rất nhanh và hiệu quả)
*
* curl_get($url)
*
*******************************/
function curl_get($url){
$cookie = tmpfile();
$userAgent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31' ;
$ch = curl_init($url);
$options = array(
CURLOPT_CONNECTTIMEOUT => 20 ,
CURLOPT_USERAGENT => $userAgent,
CURLOPT_AUTOREFERER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_COOKIEFILE => $cookie,
CURLOPT_COOKIEJAR => $cookie ,
CURLOPT_SSL_VERIFYPEER => 0 ,
CURLOPT_SSL_VERIFYHOST => 0
);
curl_setopt_array($ch, $options);
$kl = curl_exec($ch);
curl_close($ch);
$dom=str_get_html($kl);
return $dom;
}
Thứ Năm, 5 tháng 12, 2013
Thứ Ba, 3 tháng 12, 2013
PHP - Function SEO - Gắn tag vào str + Nhận dạng cụm từ trong câu
function strallpos($pajar, $aguja, $offset=0, &$count=null) {
if ($offset > strlen($pajar)) trigger_error("strallpos(): Offset not contained in string.", E_USER_WARNING);
$match = array();
for ($count=0; (($pos = strpos($pajar, $aguja, $offset)) !== false); $count++) {
$match[] = $pos;
$offset = $pos + strlen($aguja);
}
return $match;
}
function phathien_str($str,$needs){
$str_posss=strallpos($str,$needs);
return $str_posss;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap CSS -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body><div class="container">
<h1 class="text-center">Hello World</h1>
<?php
$str = '
Mình thấy trên triệu đồng mạng có dòng điện thoại Samsung Galaxy Note 3 N9002 triệu đồng Dual 16 GB, nhưng không biết là sử dụng có tốt không.
Nghe nói triệu đồng là dòng điện thoại triệu đồng này dùng 2 sim mà chỉ sản xuất cho Trung Quốc thôi. Mình đang tìm hiểu tính mua con triệu đồng này, những
ai đã sử dụng qua xin tư triệu đồng vấn giúp, giá mình thấý khoảng 18,5 triệu đồng, không biết là có đắt quá không?
';
$str=str_replace("triệu đồng", "<a href='http://vus.vn'>triệu đồng</a>", $str);
echo $str;
echo "<pre>";
print_r(phathien_str($str,"triệu đồng"));
echo "</pre>";
?></div>
<!-- jQuery -->
<script src="//code.jquery.com/jquery.js"></script>
<!-- Bootstrap JavaScript -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
</body>
</html>
<?php
die ('deptrai');
PHP - function strallpos Lấy vị trí chuỗi ra mảng
function strallpos($pajar, $aguja, $offset=0, &$count=null) {
if ($offset > strlen($pajar)) trigger_error("strallpos(): Offset not contained in string.", E_USER_WARNING);
$match = array();
for ($count=0; (($pos = strpos($pajar, $aguja, $offset)) !== false); $count++) {
$match[] = $pos;
$offset = $pos + strlen($aguja);
}
return $match;
}
if ($offset > strlen($pajar)) trigger_error("strallpos(): Offset not contained in string.", E_USER_WARNING);
$match = array();
for ($count=0; (($pos = strpos($pajar, $aguja, $offset)) !== false); $count++) {
$match[] = $pos;
$offset = $pos + strlen($aguja);
}
return $match;
}
Php - Tạo xml sitemap động theo dữ liệu !
<?php
header('Content-type: application/xml');
require_once '../common/settings.php'; // database settings
require_once PROJECT_PATH . '/lib/php_adodb_v5.18/adodb.inc.php';
require_once PROJECT_PATH . '/lib/small_blog_v0.8.0/smallblog.php'; // custom blogging engine
require_once PROJECT_PATH . '/lib/utils/utils.php'; // utility functions: date_decode, now
// configuration
$url_prefix = 'http://www.pontikis.net/blog/';
$blog_timezone = 'UTC';
$timezone_offset = '+00:00';
$W3C_datetime_format_php = 'Y-m-d\Th:i:s'; // See http://www.w3.org/TR/NOTE-datetime
$null_sitemap = '<urlset><url><loc></loc></url></urlset>';
$blog = new smallblog(); // custom blogging engine
$res = $blog->db_connect($blog_db_settings);
if($res === false) {
echo $null_sitemap;
exit; // Database connection error...
} else {
// get all posts meta-data
$posts = $blog->getPosts(0, 0, '', '', '', now($blog_timezone));
if($posts === false) {
echo $null_sitemap;
exit; // Error retreiving posts...
}
$len = count($posts);
for($i = 0; $i < $len; $i++) {
// entities encode URL according http://www.sitemaps.org/protocol.html#escaping
$posts[$i]['url'] = $url_prefix . htmlspecialchars($posts[$i]['url']);
// convert dates to W3C datetime format http://www.sitemaps.org/protocol.html#xmlTagDefinitions
$posts[$i]['date_updated'] = date_decode($posts[$i]['date_updated'], $blog_timezone, $W3C_datetime_format_php) . $timezone_offset;
}
// retrieve max date
$max_date = $posts[0]['date_updated'];
}
$output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
echo $output;
?>
<url>
<loc>http://www.pontikis.net/blog/</loc>
<lastmod><?php print $max_date ?></lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://www.pontikis.net/blog/archive/</loc>
<lastmod><?php print $max_date ?></lastmod>
<changefreq>daily</changefreq>
</url>
<?php for($i = 0; $i < $len; $i++) { ?>
<url>
<loc><?php print $posts[$i]['url'] ?></loc>
<lastmod><?php print $posts[$i]['date_updated'] ?></lastmod>
</url>
<?php } ?>
</urlset>
Thứ Hai, 2 tháng 12, 2013
Class zip folder backup !
<?php
class Backup_folder{
function backup_folder_ele($folder_file_backup,$folder_want_backup){
if(!isset($folder_file_backup)) return false;
if(!isset($folder_want_backup)) return false;
if(true){
$zip = new ZipArchive;
$zip->open($folder_file_backup.'/file_'.time().'.zip', ZipArchive::CREATE);
if (false !== ($dir = opendir($folder_want_backup)))
{
while (false !== ($file = readdir($dir)))
{
if ($file != '.' && $file != '..')
{
$zip->addFile($folder_want_backup.DIRECTORY_SEPARATOR.$file);
//delete if need
//if($file!=='important.txt')
//unlink($path.DIRECTORY_SEPARATOR.$file);
}
}
}
else
{
die('Can\'t read dir');
}
$zip->close();
}
}
}
?>
Chủ Nhật, 1 tháng 12, 2013
function htmlspecialchars
function htmlspecialchars string htmlspecialchars
( string $string
[, int $flags = ENT_COMPAT | ENT_HTML401
[, string $encoding = 'UTF-8'
[, bool $double_encode = true
]]] ) <?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>?>
Thứ Bảy, 30 tháng 11, 2013
function stripslashes
Link site: http://us1.php.net/stripslashes
stripslashes
(PHP 4, PHP 5)
Descriptio
string stripslashes
( string
$str
)
Un-quotes a quoted string.
Note:
If magic_quotes_sybase is on, no backslashes are stripped off but two apostrophes are replaced by one instead.
An example use of stripslashes() is when the PHP
directive magic_quotes_gpc
is on (it was on by default before PHP 5.4), and you aren't inserting
this data into a place (such as a database) that requires escaping.
For example, if you're simply outputting data straight from an HTML form.
<?phpfunction stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}// Example$array = array("f\\'oo", "b\\'ar", array("fo\\'o", "b\\'ar"));$array = stripslashes_deep($array);// Outputprint_r($array);?>
Thứ Năm, 28 tháng 11, 2013
Placehold.it - Lấy hình theo kích thước và màu sắc
Website: www.placehold.it
Hướng dẫn:
Hướng dẫn:
Hình kích thước 500 x 300 màu xám
<img src='http://placehold.it/552x384'>
Hình kích thước 500 x 300 màu trắng
<img src='http://placehold.it/552x384/fff'>
Thứ Tư, 27 tháng 11, 2013
Nâng cấp input editor bằng tinymce
LINK DOWNLOAD: http://www.mediafire.com/?zgo2mcde34slzwl
Cau hinh tinmce
===========
tinymce.init({
convert_urls: false,
relative_urls: false,
selector: "textarea.input_text_vihan",
theme: "modern",
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor filemanager"
],
content_css: "http://vuslkasdjfl.com/vasdf.css",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'sondeptrai 2', inline: 'span', classes: 'sondeptrai2'},
{title: 'sondeptrai', inline: 'span', classes: 'sondeptrai'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent ",
toolbar2: "print preview media | forecolor backcolor emoticons | link image",
image_advtab: true,
templates: [
{title: 'Test template 1', content: 'Test 1'},
{title: 'Test template 2', content: 'Test 2'}
]
});
Cau hinh tinmce
===========
tinymce.init({
convert_urls: false,
relative_urls: false,
selector: "textarea.input_text_vihan",
theme: "modern",
plugins: [
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
"emoticons template paste textcolor filemanager"
],
content_css: "http://vuslkasdjfl.com/vasdf.css",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'sondeptrai 2', inline: 'span', classes: 'sondeptrai2'},
{title: 'sondeptrai', inline: 'span', classes: 'sondeptrai'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent ",
toolbar2: "print preview media | forecolor backcolor emoticons | link image",
image_advtab: true,
templates: [
{title: 'Test template 1', content: 'Test 1'},
{title: 'Test template 2', content: 'Test 2'}
]
});
Thứ Ba, 26 tháng 11, 2013
Chống sql injection cho php với hàm mysql_real_escape_string()
mysql_real_escape_string
SQL injection là một kỹ thuật cho phép những kẻ tấn công lợi dụng lỗ hổng của việc kiểm tra dữ liệu đầu vào trong các ứng dụng web và các thông báo lỗi của hệ quản trị cơ sở dữ liệu trả về để inject (tiêm vào) và thi hành các câu lệnh SQL bất hợp pháp, Sql injection có thể cho phép những kẻ tấn công thực hiện các thao tác, delete, insert, update,… trên cơ sỡ dữ liệu của ứng dụng, thậm chí là server mà ứng dụng đó đang chạy, lỗi này thường xãy ra trên các ứng dụng web có dữ liệu được quản lý bằng các hệ quản trị cơ sở dữ liệu như SQL Server, MySQL, Oracle, DB2, Sysbase...
Một ví dụ về SQL Injection
<?php
$query = "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";
mysql_query($query);
$_POST['username'] = 'aidan';
$_POST['password'] = "' OR ''='";
echo $query;
?>
Câu lệnh truyền lên server sẽ là :
SELECT * FROM users WHERE user='aidan' AND password='' OR ''=''
Tài liệu tham khảo:
http://kythuatlaptrinh.com/noi-dung/chong-sql-injection-cho-php-voi-ham-mysql-real-escape-string.html
http://php.net/manual/en/function.mysql-real-escape-string.php
Thứ Tư, 20 tháng 11, 2013
Lập trình hướng đối tượng trong PHP 5 ( PHP OOP )
Lập trình hướng đối tượng:
- Lấy đối tượng là nền tảng
- Tìm những đối tượng có sẵn hoặc xây dựng những đối tượng
- Sau đó kết hợp với nhau để giải quyết vấn đề
- Xây dựng những đối tượng mã lệnh có liên hệ khắn khít với đối tượng của thế giới thực
Ví dụ 3: Game bóng đá:
- Game bóng đá là một chương trình rất lớn chắc chắn nếu bạn muốn
làm nó bạn phải xây dựng nó trên mô hình hướng đối tượng. Vậy việc đầu
tiên của trước khi xây dựng game này bạn cần xác định các đối tượng
chính của game
- Những đối tượng chính của game mà bạn có thể dễ dàng nhìn thấy như:
o Câu lạc bộ
o Sân vận động
o Giải thi đấu
o Cầu thủ
o Huấn luyện viên
o Cổ động viên…
- Trong một ứng dụng lớn như game bóng đá các bạn sẽ thấy xuất hiện
rất nhiều đối tượng. Chúng ta sẽ phân tích thử một đối tượng trong game
đó là đối tượng con người.
- Con người là một lớp chính trong game từ đối tượng ‘con người’
chúng ta sẽ mở rộng ra các đối khác như cầu thủ, trọng tài, huấn luyện
viên, cổ động viên…
- Đơn giản hóa việc phát triển các chương trình
- Giúp tạo ra những chương trình có tính mềm dẻo và linh động cao (Khi sửa chữa bảo trì, nâng cấp dể dàng)
Thứ Hai, 18 tháng 11, 2013
Một em lâu la của codeignitor em ấy mang tên go cart !
Chủ Nhật, 17 tháng 11, 2013
Codeigniter Framework - Bài 1
Hôm nay rảnh rỗi nghiên cứu cái framework mới thấy cũng hay hay. vs mô hình mvc (Mẹ và Con)
Codeigniter là một framework mã nguồn mở viết bằng ngôn ngữ php với mô hình Model View Controler cấu trúc hướng đối tượng.
Model
class Page_model extends CI_Model{
public function get_page($p=null){
$query = $this->db->get('pages');
if ($query->num_rows() > 0){
return $query->result();
}
return FALSE;
}
}
Controler
class Welcome extends CI_Controller {
public function index()
{
$this->load->model('page_model');
$data["bien_truyen_view"]=$this->page_model->get_page();
$this->load->view('home',$data);
}
}
View
echo $bien_truyen_view;
Ngoài ra codeisnitor còn hỗ trợ rất nhiều phương thức tương tác với cơ sở dữ liệu thông qua active record khá tiện dụng
Ví dụ:
Muốn view một bảng ra chỉ cần
$this->db->get("user");
= với query truy vấn $this->db->query("select * from user");
Tương tự với insert, update và delete record ngoài ra còn rất nhiều phương thức khác liên quan tới database.
Xem link bên dưới
** http://ellislab.com/codeigniter/user-guide/database/active_record.html
Thư viện class của codeignitor rất phong phú được chia vào các
Class Reference
Benchmarking Class
Calendar Class
Cart Class
Config Class
Email Class
Encryption Class
File Uploading Class
Form Validation Class
FTP Class
HTML Table Class
Image Manipulation Class
Input Class
Javascript Class
Loader Class
Language Class
Migration Class
Output Class
Pagination Class
Security Class
Session Class
Trackback Class
Template Parser Class
Typography Class
Unit Testing Class
URI Class
User Agent Class
XML-RPC Class
Zip Encoding Class
Chúng ta sẽ tìm hiểu những thành phần này rõ và kỹ hơn ở những mục tiếp theo.
Codeigniter là một framework mã nguồn mở viết bằng ngôn ngữ php với mô hình Model View Controler cấu trúc hướng đối tượng.
Model
class Page_model extends CI_Model{
public function get_page($p=null){
$query = $this->db->get('pages');
if ($query->num_rows() > 0){
return $query->result();
}
return FALSE;
}
}
Controler
class Welcome extends CI_Controller {
public function index()
{
$this->load->model('page_model');
$data["bien_truyen_view"]=$this->page_model->get_page();
$this->load->view('home',$data);
}
}
View
echo $bien_truyen_view;
Ngoài ra codeisnitor còn hỗ trợ rất nhiều phương thức tương tác với cơ sở dữ liệu thông qua active record khá tiện dụng
Ví dụ:
Muốn view một bảng ra chỉ cần
$this->db->get("user");
= với query truy vấn $this->db->query("select * from user");
Tương tự với insert, update và delete record ngoài ra còn rất nhiều phương thức khác liên quan tới database.
Xem link bên dưới
** http://ellislab.com/codeigniter/user-guide/database/active_record.html
Thư viện class của codeignitor rất phong phú được chia vào các
Class Reference
Benchmarking Class
Calendar Class
Cart Class
Config Class
Email Class
Encryption Class
File Uploading Class
Form Validation Class
FTP Class
HTML Table Class
Image Manipulation Class
Input Class
Javascript Class
Loader Class
Language Class
Migration Class
Output Class
Pagination Class
Security Class
Session Class
Trackback Class
Template Parser Class
Typography Class
Unit Testing Class
URI Class
User Agent Class
XML-RPC Class
Zip Encoding Class
Chúng ta sẽ tìm hiểu những thành phần này rõ và kỹ hơn ở những mục tiếp theo.
Thứ Sáu, 15 tháng 11, 2013
Jquery - Lazy load images loader
Link homepage: http://jquery.eisbehr.de/lazy/
Link download: http://www.mediafire.com/?bsicj0brmx6ojbm
Link download: http://www.mediafire.com/?bsicj0brmx6ojbm
Đăng ký:
Nhận xét (Atom)






























