Thứ Tư, 24 tháng 12, 2014

Keymap sublime text

[
    { "keys": ["f1"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } },
    { "keys": ["f2"], "command": "insert_snippet", "args": {"contents": "<?php ${0:$SELECTION} ?>"}},
    { "keys": ["f3"], "command": "insert_snippet", "args": {"contents": "  ?> ${0:$SELECTION} <?php "}},
    { "keys": ["f4"], "command": "insert_snippet", "args": {"contents": "  // Đánh dấu phần này "}},
    { "keys": ["ctrl+m"], "command": "sftp_browse" },
    { "keys": ["ctrl+u"], "command": "sftp_upload_file" },
    { "keys": ["shift+f4"], "command": "toggle_side_bar" }
]

Thứ Hai, 15 tháng 12, 2014

Dialog jquery

                function show_dialog(mes){
                    if(!$(".dialog_jquery").width())
                        $("body").append('<div class="dialog_jquery"></div>');  
                    $(".dialog_jquery").text(mes);
                    $(".dialog_jquery").fadeIn(200).delay(1000).fadeOut(200);
                    var width_b=$(window).width()/2 - ($(".dialog_jquery").width()/2);
                    $(".dialog_jquery").css({top:"10px",left:width_b+"px"});                                                  
                }.dialog_jquery {
  background: none repeat scroll 0 0 white;
  border: 5px solid rgba(80, 78, 78, 0.58);
  border-radius: 5px;
  color: black;
  left: 0;
  padding: 18px;
  position: fixed;
  top: 0;
  z-index: 444;
}

Thứ Hai, 29 tháng 9, 2014

Thứ Sáu, 8 tháng 8, 2014

convert_time($time) mysql_format to timestamp


Convert_time($time) mysql_format to timestamp  




function convert_time($time){
        if(!$time) return false;
        $array1=explode(" ",$time);
        $array2["date"]=explode("-",$array1[0]);
        $array2["time"]=explode(":",$array1[1]);           
        $int_time=mktime($array2["time"][0],$array2["time"][1],$array2["time"][2],$array2["date"][1],$array2["date"][2],$array2["date"][0]);
        if($int_time)
            return $int_time;
        else
            return false;
    }

Thứ Ba, 29 tháng 7, 2014

Xóa dòng này !!!


Function check table có tồn tại không !

        function table_exist($nametable){
            $nametable=trim($nametable);
        if($this->sql_numrows($this->sql_query("SHOW TABLES LIKE '".$nametable."'"))==1)
            return true;
        else
            return false;
        }

Thứ Sáu, 25 tháng 7, 2014

Resize scale png transparent !!




            $source = "".$inpath."/".$inimg."";
            $source = imagecreatefrompng($source);
            $newImg=resizePng($source , 50, 50);
            imagepng($newImg, "".$inpath."/".$inimg."");
            ImageDestroy($newImg);

function resizePng($im, $dst_width, $dst_height) {
    $width = imagesx($im);
    $height = imagesy($im);
    $dst_height = $height/($width/$dst_width);
    $newImg = imagecreatetruecolor($dst_width, $dst_height);
    imagealphablending($newImg, false);
    imagesavealpha($newImg, true);
    $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
    imagefilledrectangle($newImg, 0, 0, $width, $height, $transparent);
    imagecopyresampled($newImg, $im, 0, 0, 0, 0, $dst_width, $dst_height, $width, $height);
    return $newImg;
}

Thứ Năm, 24 tháng 7, 2014

Thứ Tư, 23 tháng 7, 2014

Show tất cả biến global !!! Thật là nguy hiểm !


        echo "<pre>";
            print_r($GLOBALS);
        echo "</pre>";
        die;

Thứ Ba, 22 tháng 7, 2014

Thứ Hai, 21 tháng 7, 2014


Link github
https://github.com/vihoangson/vihanviet/blob/master/class.step_cart.php

update shopping cart


Thứ Sáu, 18 tháng 7, 2014

Mở chế độ chạy .htaccess trên Appserv

Bước 1: Vào thư mục cài đặt (thông thường C:\AppServ\Apache2.2\conf\)
Mở file httpd.conf tìm đến
#LoadModule rewrite_module modules/mod_rewrite.so
Bỏ dấu # ở phía trước, trở thành
LoadModule rewrite_module modules/mod_rewrite.so
Bước 2: Không cần thiết lắm, mục đích là để server nhận đúng tên file htaccess, vì trong windows khó đặt tên file có dấu . ở trước nên ta thêm vào x cho thuận tiện thôi.
Tìm AccessFileName.htaccess
Thay bằng: AccessFileName x.htaccess
Save all.
Bước 3. Khởi động lại Apache
Thường thì vào: C:\Appserv\Apache2.2\bin chạy file ApacheMonitor.exe click Restart Hoặc click Start>>All Programs>> … tìm trong đó. Enjoy
Sưu tầm: Al0nex’s blog

Thứ Ba, 15 tháng 7, 2014

disable get_content


Dòng 40 security.php

if (stristr($_SERV

Thứ Bảy, 12 tháng 7, 2014

regular expression css selector



Div[id^="son"]
Div[id*="son"]
Div[id$="son"]

Thứ Bảy, 21 tháng 6, 2014

Thứ Hai, 12 tháng 5, 2014

Get full url




function url_origin($s, $use_forwarded_host=false)
{
    $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
    $sp = strtolower($s['SERVER_PROTOCOL']);
    $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
    $port = $s['SERVER_PORT'];
    $port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port;
    $host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
    $host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
    return $protocol . '://' . $host;
}
function full_url($s, $use_forwarded_host=false)
{
    return url_origin($s, $use_forwarded_host) . $s['REQUEST_URI'];
}

Thứ Bảy, 10 tháng 5, 2014

Function get content Liric or dic

    
            case "loibaihat_zing":
                        ?>
                        <form  method="get" role="form">
                            <legend>Form title</legend>
                       
                            <div class="form-group">
                                <label for="">name</label>
                                <input name="word" type="text" class="form-control" id="" placeholder="">
                            </div>
                            <input type="hidden" name="name" value="Your_Account">
                            <input type="hidden" name="case" value="loibaihat_zing">
                            <input type="hidden" name="op" value="MyDomain">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </form>
                        <?php
                $lik= str_replace(" ", "+", ($_GET["word"])) ;
                $url="http://mp3.zing.vn/tim-kiem/bai-hat.html?q=".$lik;
                $html=get_page($url);
                 foreach ($html->find(".content-item h3 a._trackLink") as $value) {                    
                     if(strpos($value->href,"bai-hat")===false) {
                         continue;
                     }
                     echo "<h1>".$value->innertext."</h1>";
                    $url="http://mp3.zing.vn".$value->href."";               
                    $html2=get_page($url);
                    foreach ($html2->find("._lyricItem") as $value2) {

                        $array_of_id_or_class=array("oLyric");
                        $name = implode('|', $array_of_id_or_class);
                        $regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name .
                            ')[\'"][^>]*>.*</\\1>#isU';
                        echo (preg_replace($regex, '', $value2->innertext));

                       
                    }
                 }
                die;
            break;
   

            case "loibaihat":
                        ?>
                        <form  method="get" role="form">
                            <legend>Form title</legend>
                       
                            <div class="form-group">
                                <label for="">name</label>
                                <input name="word" type="text" class="form-control" id="" placeholder="">
                            </div>
                            <input type="hidden" name="name" value="Your_Account">
                            <input type="hidden" name="case" value="loibaihat">
                            <input type="hidden" name="op" value="MyDomain">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </form>
                        <?php
                       
                $lik= str_replace(" ", "+", unicode($_GET["word"])) ;
                $url="http://loibaihat.mobi/tim-kiem/loi-bai-hat.html?search=".$lik;
                $html=get_page($url);

                 foreach ($html->find(".item a") as $value) {
                     echo "<h1>".$value->innertext."</h1>";
                    echo "<h5>http://loibaihat.mobi".$value->href."</h5>";
                    // $url="http://loibaihat.mobi".$value->href."";
                    // $html2=get_page($url);
                    // foreach ($html2->find(".lyric") as $value2) {
                    //     echo $value2->innertext;
                    // }
                     // echo "<pre>";
                     //     print_r($value);
                     // echo "</pre>";   
                 }
                die;
            break;





            case "dict":
                        ?>
                        <form  method="get" role="form">
                            <legend>Form title</legend>
                       
                            <div class="form-group">
                                <label for="">name</label>
                                <input name="word" type="text" class="form-control" id="" placeholder="">
                            </div>
                            <input type="hidden" name="name" value="Your_Account">
                            <input type="hidden" name="case" value="dict">
                            <input type="hidden" name="op" value="MyDomain">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </form>
                        <?php
                $url="http://vdict.com/".$_GET["word"].",1,0,0.html";
                $html=get_page($url);
                 foreach ($html->find(".word_title") as $value) {
                     echo "<h1>".$value->innertext."</h1>";
                     // echo "<pre>";
                     //     print_r($value);
                     // echo "</pre>";   
                 }
               
                 foreach ($html->find(".pronounce") as $value) {
                     echo "<p>".$value->innertext."</p>";
                     // echo "<pre>";
                     //     print_r($value);
                     // echo "</pre>";   
                 }       
                 foreach ($html->find(".phanloai") as $value) {
                     echo "<h3>".$value->innertext."</h3>";
                     // echo "<pre>";
                     //     print_r($value);
                     // echo "</pre>";   
                 }       
                 foreach ($html->find(".list1") as $value) {
                     echo "<p>".$value->innertext."</p>";
                     // echo "<pre>";
                     //     print_r($value);
                     // echo "</pre>";   
                 }                                

           

                die;
            break;   

Thứ Sáu, 25 tháng 4, 2014

REgister wordpress

        if(function_exists('register_nav_menus')){
            register_nav_menus(
                array(
                    'main_nav' => 'Main Navigation Menu'
                    )
            );
            register_nav_menus(
                array(
                    'main_nav2' => 'Main Navigation Menu2'
                    )
            );      
        }
    /**
    * Creates a sidebar
    * @param string|array  Builds Sidebar based off of 'name' and 'id' values.
    */
    $args = array(
        'name'          => __( '1' ),
        'id'            => 'unique-sidebar-id',
        'description'   => '',
        'class'         => '',
        'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
        'after_widget'  => '</li>',
        'before_title'  => '<h2 class="widgettitle">',
        'after_title'   => '</h2>'
    );

    register_sidebar( $args );

    $args = array(
        'name'          => __( '2' ),
        'id'            => 's',
        'description'   => '',
        'class'         => '',
        'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
        'after_widget'  => '</li>',
        'before_title'  => '<h2 class="widgettitle">',
        'after_title'   => '</h2>'
    );

    register_sidebar( $args );


Call

dynamic_sidebar( 'sidebar-1' );
get_sidebar("1");

get_sidebar("2");

Thứ Năm, 24 tháng 4, 2014

Thứ Ba, 22 tháng 4, 2014

Cron - auto process php

Lấy thông tin script file name



Thiết lập cấu hình



Do


Thứ Hai, 14 tháng 4, 2014

Hai cái này mò cả 1 buổi ^^ Bây chừ đã xong và rất là vui !



///////////////////
$params = array('scope' => 'read_stream, friends_likes,email,user_birthday,read_stream,read_friendlists,publish_actions');
///////////////////
$response = $facebook->api(
                "/me/feed",
                "POST",
                array (
                    'message' => 'Không có gì quý hơn độc lập tự do - Tôi viết cái này trong app của facebook ^_^ '.rand(0,10000)
                )
            );
///////////////////

Thứ Sáu, 7 tháng 3, 2014

Confirm action link by jquery

$('.delete_row').click(function(){
    return confirm("Are you sure you want to delete?");
});

Thứ Tư, 5 tháng 3, 2014

Lấy biến input radio



$('input[name=sel_op_tt]:checked', '#form_naptien').val();

Thứ Ba, 25 tháng 2, 2014

Xóa tag có tên class tùy biến

                    $array_of_id_or_class=array("oLyric");
                    $name = implode('|', $array_of_id_or_class);
                    $regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name .
                        ')[\'"][^>]*>.*</\\1>#isU';
                    echo (preg_replace($regex, '', $value2->innertext));

Thứ Năm, 23 tháng 1, 2014

Shortkey sublimetext

[
    { "keys": ["ctrl+shift+u"], "command": "sftp_upload_file" },

    { "keys": ["ctrl+shift+m"], "command": "sftp_browse" },
   
    { "keys": ["f4"], "command": "toggle_side_bar" },

]

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 FULLTEXT index, 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.
The boolean full-text search capability supports the following operators:
  • +
    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 of MATCH() ... AGAINST() without the IN BOOLEAN MODE modifier.
  • > <
    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 the ft_min_word_len setting) 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 that ft_min_word_len=4. Then a search for '+word +the*' will likely return fewer rows than a search for '+word +the':
    • The former query remains as is and requires both word and the* (a word starting with the) to be present in the document.
    • The latter query is transformed to +word (requiring only word to be present). the is both too short and a stopword, and either condition is enough to cause it to be ignored.
  • "
    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 the FULLTEXT index 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.
The following examples demonstrate some search strings that use boolean full-text operators:
  • '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

Jquery book

Download: https://www.mediafire.com/folder/undefined/


Thứ Ba, 7 tháng 1, 2014

check điểm seo website

http://www.seositecheckup.com/tools/results

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>