Could you re-post your script please? The link appears to be broken. I'm interested in giving this a shot.
I get an error when I try to upload the file - "Cannot access attachments upload path!".
Just copy the code below into a text editor and save the file as BatchAssign.php.
<?php
$i = 0;
$con = $_POST['con'];
$userID = $_POST['userID'];
$passWord = $_POST['passWord'];
$querStr = $_POST['querStr'];
$querStr2 = $_POST['querStr2'];
$isLoggedOn = $_POST['isLoggedOn'];
$mediaSubTypeEnum = array (1 => "TV Shows",2 => "Movies",3 => "Home Videos", 4 => "Sports Events", 5 => "Music Videos", 6 => "Alternative", 7 => "Popular Music", 8 => "Classical Music");
$fileFormatEnum = array (1 => "Low Res",2 => "DVD",3 => "Standard Def", 4 => "HD 720", 5 => "HD 1080", 6 => "Low Quality", 7 => "MP3", 8 => "CD Quality", 9 => "High-def audio");
Echo "<html>";
Echo "<title>LMCE Batch Assign</title>
<LINK REL=relationship HREF='URL' REL='Banner'> ";
Echo "
<body bgcolor='Green'>
<h1> LinuxMCE: Batch Assign Cover Art & Attributes</h1>
<hr />
<br>
<form action=".$_SERVER['PHP_SELF']." method='post'>";
if (isset($_POST['logon'])) {
$isLoggedOn = 1;
}
if (!$isLoggedOn) {
Echo "
Logon Name: <input name='userID' type='text' size='10'/>
Password: <input type='password' name='passWord' type='text' size='10'/>
<input type='submit' name='logon' value='Login'>
<hr />
";
}
if ($isLoggedOn) {
$con = mysql_connect("localhost", $userID, $passWord);
if (!$con) {
$isLoggedOn = 0;
Echo "
Logon Name: <input name='userID' type='text' size='10'/>
Password: <input type='password' name='passWord' type='text' size='10'/>
<input type='submit' name='logon' value='Login'>
<hr />
";
Echo "<input type='hidden' id='isLoggedOn' name='isLoggedOn' value='".$isLoggedOn."'/>";
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pluto_media") or die(mysql_error());
}
if ($con) {
Echo "
Search For File: <input name='querStr' type='text' size='10'/>
<input type='submit' name='submit' value='Find'>
Search For Directory: <input name='querStr2' type='text' size='10'/>
<input type='submit' name='submit3' value='Find'>
<input type='hidden' id='con' name='con' value='".$con."'/>
<input type='hidden' id='userID' name='userID' value='".$userID."'/>
<input type='hidden' id='passWord' name='passWord' value='".$passWord."'/>
<input type='hidden' id='isLoggedOn' name='isLoggedOn' value='".$isLoggedOn."'/>
<hr />
";
if(isset($_POST['submit'])) {
if (strlen($querStr) > 0) {
$result = mysql_query("SELECT * FROM File WHERE Filename LIKE '%".$querStr."%'");
//<input type='checkbox' value='1' onclick='var w = document.getElementsByTagName('input'); for(var i = 0; i\"<\" w.length; i++){ if(w[i].type='checkbox'){ w[i].checked = this.checked;};};'>
Echo " <input type='submit' name='submit2' value='Add Attributes To Selected Files'>
<table border='1' bgcolor='White'>
<tr>
<th>Primary File</th>
<th>Update File</th>
<th>Filename</th>
<th>Path</th>
<th>MediaSubType</th>
<th>FileFormat</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input type='radio' name='primary[]' value=$i/></td>";
echo "<td><input type='checkbox' name='CopyFile[]' value='$i'/></td>";
echo "<td>".$row['Filename']."</td>";
echo "<td>".$row['Path']."</td>";
$FK_Media_Subtype[$i] = $row['FK_MediaSubType'];
$mediaSubtypeStr = implode(",",$FK_Media_Subtype);
echo "<td>".$mediaSubTypeEnum[$FK_Media_Subtype[$i]]."</td>";
$FK_File_Format[$i] = $row['FK_FileFormat'];
$fileFormatStr = implode(",",$FK_File_Format);
echo "<td>".$fileFormatEnum[$FK_File_Format[$i]]."</td>";
$myArray[$i++] = $row['PK_File'];
echo "</tr>";
$saveStr = implode(",",$myArray);
echo "<input type='hidden' id='arry' name='myArray' value='".$saveStr."'/>";
echo "<input type='hidden' id='arry2' name='fkmediasubtype' value='".$mediaSubtypeStr."'/>";
echo "<input type='hidden' id='arry3' name='fkfileformat' value='".$fileFormatStr."'/>";
}
echo "</table>";
}
else {
echo "Please enter a valid search string.";
}
}
if(isset($_POST['submit2'])) {
foreach($_POST['primary'] as $value) {
$value = (int) $value;
echo "the primary is".$value."\n";
}
$saveStr = $_POST['myArray'];
$myArray = explode(",",$saveStr);
$saveStr = $_POST['fkmediasubtype'];
$FK_Media_Subtype = explode(",",$saveStr);
$saveStr = $_POST['fkfileformat'];
$FK_File_Format = explode(",",$saveStr);
$primaryVal = $value;
$result = mysql_query("SELECT * FROM Picture_File Where FK_File = '".$myArray[$value]."'");
$row = mysql_fetch_array($result);
$FK_Picture = $row['FK_Picture'];
$result = mysql_query("SELECT * FROM File_Attribute Where FK_File = '".$myArray[$value]."'");
$i = 0;
while ($row = mysql_fetch_array($result)) {
$FK_File_Attribute[$i++] = $row['FK_Attribute'];
}
// echo "media type = ".$FK_File_Format[$primaryVal];
foreach($_POST['CopyFile'] as $value) {
$value = (int) $value;
mysql_query("INSERT INTO `Picture_File` VALUES ($FK_Picture,$myArray[$value],NULL,NULL,NULL,0,NULL,NULL)");
for ($i = 0; $i < count($FK_File_Attribute); $i++) {
mysql_query("INSERT INTO `File_Attribute` VALUES ($myArray[$value],$FK_File_Attribute[$i],'0','0',NULL ,NULL ,NULL ,'0',NOW(), NULL)");
}
mysql_query("UPDATE File SET FK_MediaSubType=$FK_Media_Subtype[$primaryVal] ,FK_FileFormat=$FK_File_Format[$primaryVal] WHERE PK_File=$myArray[$value]");
}
}
if(isset($_POST['submit3'])) {
if (strlen($querStr2) > 0) {
$result = mysql_query("SELECT * FROM File WHERE Path LIKE '%".$querStr2."%'");
//<input type='checkbox' value='1' onclick='var w = document.getElementsByTagName('input'); for(var i = 0; i\"<\" w.length; i++){ if(w[i].type='checkbox'){ w[i].checked = this.checked;};};'>
Echo " <input type='submit' name='submit2' value='Add Attributes To Selected Files'>
<table border='1' bgcolor='White'>
<tr>
<th>Primary File</th>
<th>Update File</th>
<th>Filename</th>
<th>Path</th>
<th>MediaSubType</th>
<th>FileFormat</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input type='radio' name='primary[]' value=$i/></td>";
echo "<td><input type='checkbox' name='CopyFile[]' value='$i'/></td>";
echo "<td>".$row['Filename']."</td>";
echo "<td>".$row['Path']."</td>";
$FK_Media_Subtype[$i] = $row['FK_MediaSubType'];
$mediaSubtypeStr = implode(",",$FK_Media_Subtype);
echo "<td>".$mediaSubTypeEnum[$FK_Media_Subtype[$i]]."</td>";
$FK_File_Format[$i] = $row['FK_FileFormat'];
$fileFormatStr = implode(",",$FK_File_Format);
echo "<td>".$fileFormatEnum[$FK_File_Format[$i]]."</td>";
$myArray[$i++] = $row['PK_File'];
echo "</tr>";
$saveStr = implode(",",$myArray);
echo "<input type='hidden' id='arry' name='myArray' value='".$saveStr."'/>";
echo "<input type='hidden' id='arry2' name='fkmediasubtype' value='".$mediaSubtypeStr."'/>";
echo "<input type='hidden' id='arry3' name='fkfileformat' value='".$fileFormatStr."'/>";
}
echo "</table>";
}
else {
echo "Please enter a valid search string.";
}
}
}
Echo "</form>";
Echo "</body>";
Echo "</html>";
?>