function copy_ftp($update_id) { global $settings; deleteupdatedfile($update_id); //no file in upload-folder? error! if ($_POST['filename'] == "") { die("<p class=\"msg\">No file defined!</p>"); } $oldfilename = $_POST['filename']; //rename or not?? if ($settings['rename'] == 1) { $newfilename = freshaudioname(); } else { $newfilename = tunefilename(urldecode($oldfilename)); } //copy the file and delete the old one $oldpath = $GLOBALS['uploadpath'] . urldecode($oldfilename); $newfilepath = $GLOBALS['audiopath'] . $newfilename; copy($oldpath, $newfilepath); unlink($oldpath); $filesize = filesize($newfilepath); //make a valid temp-title $temptitle = stripsuffix(htmlspecialchars(urldecode($oldfilename), ENT_QUOTES)); //big question: are we just updating or creating a new file? if (!$update_id) { //insert a new row to the database and fill it with some nice data $dosql = "INSERT INTO {$GLOBALS['prefix']}lb_postings\n (author_id, title, posted, \n filelocal, audio_file, audio_type, audio_size, status)\n VALUES\n ('{$_SESSION['authorid']}', '{$temptitle}', '" . date('Y-m-d H:i:s') . "',\n '1', '{$newfilename}', '" . type_suffix($newfilename) . "', \n '{$filesize}', '1');"; $result = mysql_query($dosql) or die(mysql_error()); //if the parser gets until here, all should be good echo "<p class=\"msg\">{$newfilename} - Copying was successful.</p>"; } else { //update an existing row in the database $dosql = "UPDATE {$GLOBALS['prefix']}lb_postings SET\n\n author_id = '{$_SESSION['authorid']}',\n posted = '" . date('Y-m-d H:i:s') . "',\n filelocal = '1', \n audio_file= '{$newfilename}',\n audio_type= '" . type_suffix($newfilename) . "',\n audio_length= '',\n audio_size= '{$filesize}' \n WHERE id = '{$update_id}';"; $result = mysql_query($dosql) or die(mysql_error()); } //get id for editing data after finishing this function $dosql = "SELECT id FROM {$GLOBALS['prefix']}lb_postings \n WHERE audio_file='{$newfilename}';"; $result = mysql_query($dosql) or die(mysql_error()); $row = mysql_fetch_assoc($result); return $row['id']; }
function copy_ftp($update_id) { global $settings; deleteupdatedfile($update_id); //no file in upload-folder? error! if ($_POST['filename'] == "") { die("<p class=\"msg\">" . bla("msg_noaudio") . "</p>"); } $oldfilename = $_POST['filename']; //do we rename the audio file? if ($settings['rename'] == 1) { //generate filename from posting date, if we update the file if ($update_id) { $dosql = "SELECT posted FROM " . $GLOBALS['prefix'] . "lb_postings WHERE id = '" . $update_id . "'"; $result = $GLOBALS['lbdata']->GetArray($dosql); $newfilename = buildaudioname(strrchr($_POST['filename'], "."), $settings['filename'], $result[0]['posted']); //get a fresh filename if we have a new posting } else { $newfilename = freshaudioname(strrchr($_POST['filename'], "."), $settings['filename']); } //if we don't rename, we will at least tune the filename } else { $newfilename = tunefilename(urldecode($oldfilename)); } //copy the file and delete the old one $oldpath = $GLOBALS['uploadpath'] . urldecode($oldfilename); $newfilepath = $GLOBALS['audiopath'] . $newfilename; copy($oldpath, $newfilepath); unlink($oldpath); //change the chmod chmod($newfilepath, 0777); $filesize = filesize($newfilepath); //make a valid temp-title $temptitle = stripsuffix(htmlspecialchars(urldecode($oldfilename), ENT_QUOTES)); //big question: are we just updating or creating a new file? if (!$update_id) { //insert a new row to the database and fill it with some nice data $dosql = "INSERT INTO {$GLOBALS['prefix']}lb_postings\n (author_id, title, posted, \n filelocal, audio_file, audio_type, audio_size, status, \n countweb, countfla, countpod, countall)\n VALUES\n ('{$_SESSION['authorid']}', '{$temptitle}', '" . date('Y-m-d H:i:s') . "',\n '1', '{$newfilename}', '" . type_suffix($newfilename) . "', \n '{$filesize}', '1','0','0','0','0')"; $GLOBALS['lbdata']->Execute($dosql); //add default id3 tags, if needed defaultid3tags($GLOBALS['audiopath'] . $newfilename, $temptitle); //if the parser gets until here, all should be good echo "<p class=\"msg\">" . $newfilename . " - " . bla("msg_copysuccess") . "</p>"; } else { //update an existing row in the database $dosql = "UPDATE {$GLOBALS['prefix']}lb_postings SET\n\n author_id = '{$_SESSION['authorid']}',\n filelocal = '1', \n audio_file= '{$newfilename}',\n audio_type= '" . type_suffix($newfilename) . "',\n audio_length= '',\n audio_size= '{$filesize}' \n WHERE id = '{$update_id}'"; $GLOBALS['lbdata']->Execute($dosql); //add default id3 tags, if needed defaultid3tags($GLOBALS['audiopath'] . $newfilename, gettitlefromid($update_id)); } //get id for editing data after finishing this function $dosql = "SELECT id FROM {$GLOBALS['prefix']}lb_postings \n WHERE audio_file='{$newfilename}'"; $result = $GLOBALS['lbdata']->GetArray($dosql); return $result[0]['id']; }