Category Archives: Chỉ dẫn lập trình

PHP lấy link nhạc nhaccuatui

<?php
    $url = “http://www.nhaccuatui.com/M/” . $_GET[“nct”];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//don’t print source
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    //curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    //curl_setopt($ch, CURLOPT_POST, TRUE);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, $FIELDS);
    curl_exec($ch);
    //$info = curl_getinfo($ch);
    //echo $info[“url”];
    $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    //echo $url;
    $a = explode(“=”, $url, 2);
    $asx = $a[1];
    //echo $asx;
    curl_setopt($ch, CURLOPT_URL, $asx);
    $source = curl_exec($ch);
    //echo htmlspecialchars($source);
    $ok = preg_match(“@<creator>(.*?)<\\/creator><location>(http://media.*?)<\\/location>@si”, $source, $m);
    $mp3 = $m[2];
//    echo $m[1] .  ” – ” . $m[2];
    curl_close($ch);
?>

Truyền data từ cửa sổ popup về cửa sổ cha

Web và Javascript
Minh họa ứng dụng: Khi gửi thư, cho phép chọn người cần liên hệ từ sổ địa chỉ (phân trang, phân nhóm) từ một cửa sổ pop-up
Code:
– Trang chính (cha): sử dụng window.open để mở trang con
– Trang con: giao tiếp với trang cha thông qua biến window.opener
// xử lý người dùng chọn (checkbox) thu danh sách vào biến strList
window.opener.getElementById(“contact_list”) = strList;

Javascript Drag and Drop

Copy đoạn code dưới đây về, tạo file text, paste vào và lưu với đuôi .htm
<style>
<!–
.dragme{position:relative;}
–>
</style>
<script>
<!–

var ie=document.all;
var nn6=document.getElementById&&!document.all;

var isdrag=false;
var x,y;
var dobj;

function movemouse(e)
{
  if (isdrag)
  {
    dobj.style.left = nn6 ? tx + e.clientX – x : tx + event.clientX – x;
    dobj.style.top  = nn6 ? ty + e.clientY – y : ty + event.clientY – y;
    return false;
  }
}

function selectmouse(e)
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? “HTML” : “BODY”;

  while (fobj.tagName != topelement && fobj.className != “dragme”)
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }

  if (fobj.className==”dragme”)
  {
    isdrag = true;
    dobj = fobj;
    tx = parseInt(dobj.style.left+0);
    ty = parseInt(dobj.style.top+0);
    x = nn6 ? e.clientX : event.clientX;
    y = nn6 ? e.clientY : event.clientY;
    document.onmousemove=movemouse;
    return false;
  }
}

document.onmousedown=selectmouse;
document.onmouseup=new Function(“isdrag=false”);

//–>
</script>

<img src=”http://elouai.com/images/AIM_smiley.gif” class=”dragme”>