Advertisement
ASP_Volume2 OLE/ COM/ DCOM/ Active-X #42887

Simple Automation Object

After struggling to learn COM for the past few days I finally started to understand it so I decided to create a brief "how to" tutorial. I choose the Temperature Conversion section from the JEDI Code Library to provide a "sort of" practical example of an Automation Object. The Automation Object example in this quick tutorial converts temperatures. (See the the QuickTutorial.txt, Tested with VB5/6 and Delphi5 Client)

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Upload
<?PHP
function SubmitSong($filename,$filename_name){
#Desination path that mp3s will be uploaded to.
$destination="/path/to/mp3/folder/";
if (ereg(".mp3",$filename_name)){
copy($filename,$destination.$filename_name);
echo "<h1>File Uploaded...</h1>";
echo "<b>$filename_name was uploaded succesfully.</b><br><br>";
echo "<a href=\"mp3.php\">Click here to go back.</a>";
}else{die("<h1>Not a Valid mp3 file...</h1>"); }
}
function main(){
###################################################################
#URL to directory containing your mp3s
$url="http://www.yoursite.com/mp3s/";
#actual location of your mp3 folder
$directory="path/to/mp3/folder/";
###################################################################
$count=0;
$handle=opendir($directory);
while (($filename = readdir($handle))!==false) { 
if ($filename != "." && $filename != ".." && ereg(".mp3",$filename)) {
$count++;
echo "<b>Song Number: $count</b>";
getTag($filename,$directory,$url);}
}
closedir($handle); 
####################################################################
#This part adds a submit form to allow people to upload mp3s to you.
#If they are on a slow connection the script will time out unless
#you change the timeout rate of your script.
?>
<form method="post" action="mp3.php" enctype="multipart/form-data">
Submit MP3: 
<input type="file" name="filename" size="20" tabindex="5">
<input type="hidden" name="action" value="SubmitSong">
<input type="submit" value="Submit" tabindex="8">
</form><?
}
####################################################################
function getTag($filename,$directory,$url){
$filetitle=$filename;
$filename= $directory.$filename;
$fp=fopen($filename,"r");
fseek($fp,filesize($filename)-128);
$checktag=fread($fp,3);
echo "<table width='100%' border='1' bgcolor='#c0c0c0'><tr><td>";
echo "<b><a href=\"$url$filetitle\">$filetitle</a></b><br></tr></td><tr><tr><tr bgcolor='#FFFFFF'><td>";
if ($checktag=="TAG") {
echo "Size: ".number_format(filesize($filename)/1000,2)." KBytes<br>";
echo "Title: ".fread($fp,30)."<br>";
echo "Author: ".fread($fp,30)."<br>";
echo "Album: ".fread($fp,30)."<br>";
echo "Copyright: ".fread($fp,4)."<br>";
echo "Comments: ".fread($fp,30)."<br>";
echo "</td></tr></table><br>";
}else{
echo "Size: ".filesize($filename)." Bytes<br>";
echo "<font color=\"red\"><b>No Tag</b></font><br>";
echo "</td></tr></table><br>";
fclose($filename);}
}
switch ($action){
	default:
	main();
	break;
	case "SubmitSong":
	if ($filename=="none") {echo("<h1>No File Selected....</h1>"); break;}
	submitsong($filename,$filename_name);
	break;
}
?>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine