function send_bits($File_Name, $MIME) { $File_Size = filesize($File_Name); $File = fopen($File_Name, "rb"); $File_Ranges = null; if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_SERVER['HTTP_RANGE']) && ($File_Range = stristr(trim($_SERVER['HTTP_RANGE']), 'bytes='))) { $File_Range = substr($File_Range, 6); $Boundary = 'sdfjasjbc3hd84hr9ajdh20d'; $File_Ranges = explode(',', $File_Range); } if ($File_Ranges && count($File_Ranges)) { header("HTTP/1.1 206 Partial content"); header("Accept-Ranges: bytes"); if (count($File_Ranges) > 1) { $content_length = 0; foreach ($File_Ranges as $File_Range) { set_index($File_Range, $File_Size, $Index_First, $Index_Last); $content_length += strlen("\r\n--{$Boundary}\r\n"); $content_length += strlen("Content-type: {$MIME}\r\n"); $content_length += strlen("Content-range: bytes {$Index_First}-{$Index_Last}/{$File_Size}\r\n\r\n"); $content_length += $Index_Last - $Index_First + 1; } $content_length += strlen("\r\n--{$boundary}--\r\n"); header("Content-Length: {$content_length}"); header("Content-Type: multipart/x-byteranges; boundary={$boundary}"); foreach ($File_Ranges as $File_Range) { set_index($File_Range, $File_Size, $Index_First, $Index_Last); echo "\r\n--{$boundary}\r\n"; echo "Content-type: {$MIME}\r\n"; echo "Content-range: bytes {$Index_First}-{$Index_Last}/{$File_Size}\r\n\r\n"; fseek($File, $Index_First); buffered_read($File, $Index_Last - $Index_First + 1); } echo "\r\n--{$boundary}--\r\n"; } else { $File_Range = $File_Ranges[0]; set_index($File_Range, $File_Size, $Index_First, $Index_Last); header("Content-Length: " . ($Index_Last - $Index_First + 1)); header("Content-Range: bytes {$Index_First}-{$Index_Last}/{$File_Size}"); header("Content-Type: {$MIME}"); fseek($File, $Index_First); buffered_read($File, $Index_Last - $Index_First + 1); } } else { header("Accept-Ranges: bytes"); header("Content-Length: {$File_Size}"); header("Content-Type: {$MIME}"); readfile($File_Name); } fclose($File); }
foreach ($words_arr as $row) { if ($row["term"] != $prev_row["term"]) { $temp_index[$row["term"]] = array("hits" => 1, "docs" => array($row["id"])); } else { if ($row["id"] != $prev_row["id"]) { $temp_index[$row["term"]]["docs"][] = $row["id"]; $temp_index[$row["term"]]["hits"]++; } } $prev_row = $row; } //insert to the index foreach ($temp_index as $term => $docs) { $index = save_term_to_index($term, $docs["hits"], $docs["docs"], $index); } set_index($index); //update the database //delete files from source folder $fp = opendir('source/'); while (false !== ($file = readdir($fp))) { if (is_file('source/' . $file)) { unlink('source/' . $file); } } ?> <h1> Added </h1> <h3><a href="index.php" role="button" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> Start Searching</a></h3> <h3><a href="admin.php" role="button" class="btn btn-primary"><span class="glyphicon glyphicon-user"></span> Back To Admin</a></h3> </div>