PHP Music Collection (part code) _php Tutorial

Source: Internet
Author: User
Tags fread
Set_time_limit (0);
mysql_connect ("localhost", "root", "");
mysql_select_db ("music_36g");

$ip = ' 127.0.0.1 ';

function _getip ()
{
$ip = getenv ("REMOTE_ADDR");
$ip 1 = getenv ("Http_x_forwarded_for");
$ip 2 = getenv ("Http_client_ip");
($ip 1)? $ip = $ip 1:null;
($ip 2)? $ip = $ip 2:null;
return $IP;
}
function Makepassword ($length =10)
{
$password = ";
$chars =
Array
(
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"A", "a", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F", "G", "G", "H", "H", "I", "I", "J", "J",
"K", "K", "L", "L", "M", "M", "N", "n", "O", "O", "P", "P", "Q", "Q", "R", "R", "s", "s", "T", "T",
"U", "U", "V", "V", "W", "W", "X", "X", "Y", "y", "z", "Z"
);

$count = count ($chars)-1;
Srand (Double) microtime () *1000000);

for ($i = 0; $i < $length; $i + +)
{
$password. = $chars [rand (0, $count)];
}
return ($password);
}

if (_getip ()! = $ip)
{
Exit ("Can ' t run!");
}


for ($i =2; $i <5769; $i + +)//52738
{
$url = "Http://music.36g.net/SpecialInfo/showspecial". $i. ". HTM ";

$File = @fopen ($url, ' RB ');
if ($File)
{
$makeFile = $buffer = "";
$buffer = "";
while ($buffer = Fread ($File, 4096))
{
$makeFile = $makeFile. $buffer;
}
@fclose ($File);


Preg_match ("/src=\/uppic\/(. *) width=135/", $makeFile, $pic); #图片
#下载图片
if ($pic [1]!= ' Es/nophoto.gif ')
{
$p _url = "http://music.36g.net/uppic/". $pic [1];

$File 2 = fopen ($p _url, ' RB ');
if ($File 2)
{
$Buffer 2 = $makeFile 2 = "";
while ($Buffer 2 = fread ($File 2,4096))
{
$makeFile 2 = $makeFile 2. $Buffer 2;
}
Fclose ($File 2);


$Filename 2 = './pic/'. $pic [1];
$Fp 2 = fopen ($Filename 2, ' w+ ');
Fwrite ($Fp 2, $makeFile 2);
Fclose ($Fp 2);
}
}
Else
{
$pic [1] = ";
}

Preg_match ("/album:<\/strong> (. *) <\/td>$name = Addslashes ($name [1]);

Preg_match ("/singer:<\/strong> (. *) <\/td><\/tr>/", $makeFile, $songer); #歌手名称
Preg_match ("/(. *) <\/td><\/tr>/", $songer [1], $songer _name); #歌手名称
Preg_match ("/Issuing company:<\/strong> (. *)/", $songer [1], $company); #发行公司

Preg_match ("/Release Time <\/strong>: (. *) <\/td> <\/tr>/", $makeFile, $date); #发行时间
Preg_match ("/(. *) <\/td>/", $date [1], $date 2); #发行时间
Preg_match ("/<\/strong> (. *)/", $date [1], $language); #发行语言


Preg_match ("/album Introduction:<\/strong><\/td>(. *) <\/td><\/tr><\/table>
/", $makeFile, $descript); #专辑简介


$songer _name = addslashes ($songer _name[1]);
$company = Addslashes ($company [1]);

$descript = Addslashes ($descript [1]);

#取得歌曲ID
Preg_match_all ("/download1\.asp\?id= (\d+) &which=bakdownurl1/", $makeFile, $id 2); #歌曲ID

$num = count ($id 2[1]);
for ($jj =0; $jj < $num; $JJ + +)
{
$sql = "INSERT into Tx_music set musicid= '". $id 2[1][$JJ]. "', specialid= ' $i ', specialname= ' $name ', songername= ' $songer _ Name ', orderbyid= '. $id 2[1][$jj]. "' ";
echo $id 2[1][$JJ]. "
";
mysql_query ($sql);
}

echo $descript. "

";

$sql = "INSERT into tx_special set orderbyid= ' $i ', specialid= ' $i ', specialname= ' $name ', songername= ' $songer _name ', Company= ' $company ', date= ' $date 2[1] ', language= ' $language [1] ', picture= ' $pic [1] ', musicnum= ' $num ', createdate= ' ". Time (). "', description= ' $descript '";
Echo $sql;
mysql_query ($sql);

}
}
?>

http://www.bkjia.com/PHPjc/317740.html www.bkjia.com true http://www.bkjia.com/PHPjc/317740.html techarticle ? PHP set_time_limit (0); mysql_connect ("localhost", "root", ""); mysql_select_db ("music_36g"); $ip = ' 127.0.0.1 '; Function_getip () {$ip =getenv ("REMOTE_ADDR"), $ip 1=getenv ("Http_x_forwar ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.