Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Free Web Script > PHP > มาทำ music libraries แบบง่ายๆ



Clound SSD Virtual Server
 

มาทำ music libraries แบบง่ายๆ

  มาทำ music libraries (PHP) แบบง่ายๆ zip file แล้วใส่ใน hostเลย

Code
<strong>Please Select A Song Request</strong><br>
<br>
<?php
// Read Original PLaylist
include ("config.php");
$handle = fopen($playlist, "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);

// Begin parsing and writing
$filename = 'playlist.txt';
$newline = "\n";
$text1 = str_replace ("#EXTINF:0,", "<option>" , $contents); // removes rubbish
$text1 = str_replace (".mp3", "</option>" , $text1); // removes rubbish
$text1 = str_replace ("#EXTM3U", "" , $text1); // removes more rubbish
$f=fopen($filename, "wb");
fputs($f, $text1);
fclose($f); // and writes file
$file = file($filename); // re opens file
$fp = fopen($filename, 'w');
foreach($file as $line){
  $line = trim($line);
  if(!empty($line)){ // removes blank lines
    fwrite($fp, $line.$newline);
  }
}
fclose($fp);
$key = "\\"; // search for backslash, this will remove file path in the playlist, leaving us only with song names
$fc=file($filename);
$f=fopen($filename,"w");
foreach($fc as $line)
{
     if (!strstr($line,$key)) //look for $key in each line
           fputs($f,$line); //place $line back in file
}
fclose($f);
// Read new Text file
$handle1 = fopen("playlist.txt", "rb");
$contents1 = '';
while (!feof($handle1)) {
  $contents1 .= fread($handle1, 8192);
}
fclose($handle1);
print "<form name=\"form1\" method=\"post\" action=\"index.php\">
</select>
	 
<select name=\"select[]\" size=\"15\" multiple>";
echo $contents1;
print "</select><input type=\"submit\" name=\"Submit\" value=\"Submit\">
 <input type=\"hidden\" name=\"good\" value=\"yes\"></form>";

// Create request list

if($_POST['good']=='yes') //if the hidden field was submitted (then we know our form has been)
{
// Create The m3u file with a random name
$filename = "chosen.txt"; // put the random number and the .m3u together.
$fp = fopen($filename, 'a'); // this will create the the m3u file since it doesn't exist
chmod($filename, 0777); // chmod our m3u to 777 so we can write data to it (and later delete the file)
fwrite($fp, ""); // Again not 100% neccesary, but just shows it can be written too
fclose($fp);  // close our m3u file.
// end creation
if (is_writable($filename)) { // if we can write to the file

   if (!$handle = fopen($filename, 'a')) { // but can't open it
         echo "Cannot open file ($filename)"; // print out an error message.
         exit; // and exit.
   } // and close the if statement.

$topicArray = $_POST['select']; // Get The Array of mp3's and wma's from our selectbox.
foreach ($topicArray as $select) // and for everyone
{
 // Write The data from the selectbox to our opened file.
   if (fwrite($handle, $select) === FALSE) { // more error checking for if file cannot be written to, if it can do it.
       echo "Cannot write to file ($filename)"; // and error message if it can't.
       exit; // and exit
   } // and close the if statement
   fwrite($handle, "<br>"); // and write a new line character so that each link to the mp3 / wma goes on a new line so media player
   // can read the file.
   }}}
   // Read Original PLaylist
$handle5 = fopen("chosen.txt", "rb");
$contents5 = '';
while (!feof($handle5)) {
  $contents5 .= fread($handle5, 8192);
}
fclose($handle5);
echo "<strong>Songs To Be Played</strong><br><br>";
echo $contents5;
?>







   
Share

Bookmark.
  Score Rating :
  Create Date : 2009-03-04 09:41:43
  View : 17,989
  Download : Download  มาทำ music libraries แบบง่ายๆ
     
Sponsored Links
PHP สร้าง WebBoard กระดานถาม-ตอบ เว็บบอร์ดสำหรับเว็บ PHP กับ MySQL
บทความ php ตัวอย่าง code การสร้าง webboard ด้วย php กับ mysql แบบง่าย ๆ สามารถนำไปใช้งานจริง
Rating : Update : 2017-03-24 21:07:15
PHP สร้างระบบตะกร้าสั่งซื้อสินค้า Shopping Cart ด้วย Session และ Array (PHP กับ MySQL)
สร้างระบบตะกร้าและ shhopping cart แบบง่าย ๆ ด้วย php โดยทำงานในรูปแบบ session กับ array
Rating : Update : 2017-03-24 21:05:36
PHP Upload MySQL BLOB Image (BLOB Binary Data in a MySQL Database)
ตัวอย่าง Script PHP ในการ Upload ไฟล์ลงในฐานข้อมูล MySQL โดยเก็บไฟล์ในรูปแบบของ Binary ผ่าน BLOB
Rating : Update : 2017-03-24 21:02:00
PHP Upload Oracle BLOB (Binary Data)
ตัวอย่างการ php กับ oracle ใช้ในการ upload ไฟล์ BLOB Data Type ลงในฐานข้อมูล Oracle Database Server
Rating : Update : 2017-03-24 21:04:13
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่