function fetch_web($update_id) { global $settings; deleteupdatedfile($update_id); //validate the desired link-url //rename or not?? if ($settings['rename'] == 1) { $newfilename = freshaudioname(); } else { $newfilename = extractfilename($_POST['linkurl'], true); $newfilename = tunefilename($newfilename); } $newfilepath = $GLOBALS['audiopath'] . $newfilename; //copy the file from the url to ... whatever $sourcefile = fopen($_POST['linkurl'], "rb") or die("<p class=\"msg\">Did not find url!</p>"); $destfile = fopen($newfilepath, "wb"); $eof = false; $filesize = 0; //copies the file in fragments of 1024 bytes do { $file = fread($sourcefile, 1024) or $eof = true; $filesize = $filesize + 1024; fwrite($destfile, $file) or fclose($destfile); } while ($eof == false); fclose($sourcefile); //make a valid temp-title $temptitle = stripsuffix(htmlspecialchars(extractfilename($_POST['linkurl'], false), 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, filelocal, \n audio_file, audio_type, audio_size, status)\n VALUES\n (\n '{$_SESSION['authorid']}',\n '{$temptitle}',\n '" . date('Y-m-d H:i:s') . "',\n '1',\n '{$newfilename}',\n '" . type_suffix($newfilename) . "',\n '{$filesize}',\n '1'\n );"; $result = mysql_query($dosql) or die(mysql_error()); //if the parser gets until here, all should be good echo "<p class=\"msg\">{$_POST['linkurl']} successfully copied. Fight content-stealing!</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 \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 anonim_mail($from, $to, $subject, $text, $file) { $fp = fopen($file, "rb"); while (!feof($fp)) { $attachment .= fread($fp, 4096); } $attachment = base64_encode($attachment); $subject = "sendfile (" . extractfilename($file) . ")"; $boundary = uniqid("NextPart_"); $headers = "From: {$from}\nContent-type: multipart/mixed; boundary=\"{$boundary}\""; $info = $text; $filename = extractfilename($file); $info .= "--{$boundary}\nContent-type: text/plain; charset=iso-8859-1\nContent-transfer-encoding: 8bit\n\n\n\n--{$boundary}\nContent-type: application/octet-stream; name={$filename} \nContent-disposition: inline; filename={$filename} \nContent-transfer-encoding: base64\n\n{$attachment}\n\n--{$boundary}--"; $send = mail($to, $subject, $info, $headers); fclose($fp); echo "<script language=\"javascript\">location.href=\"javascript:history.back(-1)\";\nalert('Файл {$filename} отправлен на {$to}');</script>"; die; }
function fetch_web($update_id) { global $settings; deleteupdatedfile($update_id); //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['linkurl'], "."), $settings['filename'], $result[0]['posted']); //get a fresh filename if we have a new posting } else { $newfilename = freshaudioname(strrchr($_POST['linkurl'], "."), $settings['filename']); } //if we don't rename, we will at least tune the filename } else { $newfilename = extractfilename($_POST['linkurl'], true); $newfilename = tunefilename($newfilename); } $newfilepath = $GLOBALS['audiopath'] . $newfilename; //copy the file from the url to ... whatever $sourcefile = fopen($_POST['linkurl'], "rb") or die("<p class=\"msg\">" . bla("msg_nourl") . "</p>"); $destfile = fopen($newfilepath, "wb"); $eof = false; $filesize = 0; //copies the file in fragments of 1024 bytes do { $file = fread($sourcefile, 1024) or $eof = true; $filesize = $filesize + 1024; fwrite($destfile, $file) or fclose($destfile); } while ($eof == false); fclose($sourcefile); //change the chmod chmod($newfilepath, 0777); //make a valid temp-title $temptitle = stripsuffix(htmlspecialchars(extractfilename($_POST['linkurl'], false), 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, filelocal, \n audio_file, audio_type, audio_size, status, \n countweb, countfla, countpod, countall)\n VALUES\n (\n '{$_SESSION['authorid']}',\n '{$temptitle}',\n '" . date('Y-m-d H:i:s') . "',\n '1',\n '{$newfilename}',\n '" . type_suffix($newfilename) . "',\n '{$filesize}',\n '1','0','0','0','0'\n )"; $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\">" . 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 \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}'"; $row = $GLOBALS['lbdata']->GetArray($dosql); return $row[0]['id']; }