function streamPlay($id, $rate = 0, $stereo = "s", $user = '', $ip = '') { mp3act_connect(); // check to see if IP is in the verified IP DB for that user if (verifyIP($user, $ip)) { $query = "SELECT mp3act_artists.artist_name, \n mp3act_songs.name,\n mp3act_songs.bitrate, \n mp3act_songs.length as length, \n mp3act_songs.filename as filename, \n mp3act_songs.size as size \n FROM mp3act_songs,mp3act_artists \n WHERE mp3act_songs.song_id={$id} \n AND mp3act_artists.artist_id=mp3act_songs.artist_id"; $result = mysql_query($query); $row = mysql_fetch_array($result); updateNumPlays($id, 0, $user, 'streaming'); clearstatcache(); // flush buffer $file['name'] = basename($row['filename']); $mp3out = ''; if (getSystemSetting("lamebin") != "" && $rate != 0) { $row['size'] = ($row['length'] + 1) * $rate * 1000 / 8; $mp3out = getSystemSetting("lamebin") . " -b {$rate} -s {$stereo} --silent --nores --mp3input -h \"" . stripslashes($row['filename']) . "\" -"; } else { $mp3out = stripslashes($row['filename']); } $size = $row['size']; $mode = getSystemSetting("sample_mode"); if ($mode == 1) { $size = floor($row['size'] / 4); } header("Content-Type: audio/mpeg"); header("Content-Length: {$size}"); header("Content-Disposition: filename={$row['artist_name']} - {$row['name']}"); // Run the command, and read back the results at the bitrate size + 1K. $blocksize = $row['bitrate'] * 1024 + 1024; $totaldata = 0; if ($rate != 0 && $mode == 1) { $temp = @popen($mp3out, "r"); while (($data = @fread($temp, $blocksize)) && $totaldata <= $size) { echo $data; $totaldata += $blocksize; } pclose($temp); } elseif ($rate != 0) { $temp = @popen($mp3out, "r"); while ($data = @fread($temp, $blocksize)) { echo $data; } pclose($temp); } elseif ($mode == 1) { $temp = @fopen($mp3out, "r"); while (!feof($temp) && $totaldata <= $size) { $data = @fread($temp, $blocksize); echo $data; $totaldata += $blocksize; } fclose($temp); } else { $temp = @fopen($mp3out, "r"); while (!feof($temp)) { $data = @fread($temp, $blocksize); echo $data; } fclose($temp); } } // end IF for verify IP exit; }
function getIP(&$ip) { if (verifyIP($ip)) { return $ip; } else { $tmp_ip = @gethostbyname($ip); if (verifyIP($tmp_ip)) { return $tmp_ip; } } return FALSE; }
public function queryTelnet(array &$vars) { echo '***TELNET SETUP***' . PHP_EOL; echo 'You now have the chance to manually enter the details of the telnet server.' . PHP_EOL; echo 'Afterwards your telnet settings will be stored in ./config/telnet.ini for future use.' . PHP_EOL; // Ask if we want to use a telnet socket at all if (self::query(PHP_EOL . 'Would you like to setup the telnet server?', array('yes', 'no')) == 'no') { $vars['ip'] = ''; $vars['port'] = '0'; return; } // Ask which IP address to bind the listen socket to while (true) { $vars['ip'] = self::query('On which IP address should we listen? (blank means all)', array(), true); if ($vars['ip'] == '') { $vars['ip'] = '0.0.0.0'; } if (!verifyIP($vars['ip'])) { echo 'Invalid IPv4 address entered. Please try again.' . PHP_EOL; } else { break; } } // Ask which Port to listen on while (true) { $vars['port'] = (int) self::query('On which Port should we listen?'); if ($vars['port'] < 1 || $vars['port'] > 65535) { echo 'Invalid Port number entered. Please try again.' . PHP_EOL; } else { break; } } echo PHP_EOL; }