<?php
/*
* SAINTX » Müzik Uygulaması
*
* @author: Ogün KARAKUŞ
* @web: http://saintx.net
* @email: im@saintx.net
* @createdAt: 04.10.2013
* @lastUpdate: 05.12.2013
*/
$user_agent = (isset($_SERVER["HTTP_USER_AGENT"])) ? getenv("HTTP_USER_AGENT") : null;
if(!is_null($user_agent)) {
if(PHP_VERSION >= "4.0.4pl1" && (strstr($user_agent, "compatible") || strstr($user_agent, "Gecko"))) {
if(extension_loaded("zlib")) {
$do_gzip_compress = false;
ob_start("ob_gzhandler");
} else {
$do_gzip_compress = false;
}
} else if(PHP_VERSION > "4.0") {
if(strstr(getenv("HTTP_ACCEPT_ENCODING"), "gzip")) {
if(extension_loaded("zlib")) {
$do_gzip_compress = true;
ob_start();
ob_implicit_flush(0);
header("Content-Encoding: gzip, deflate");
} else {
$do_gzip_compress = false;
}
}
} else {
$do_gzip_compress = false;
}
}
session_name("SAINTX");
session_set_cookie_params((60 * 60 * 6));
session_start();
@ error_reporting(E_ALL);
@ set_time_limit(0);
@ ini_set("html_errors", false);
define("SAINTX", true);
define("TURKISH_CHARS_HEX_VALS", "{\"\u00d6\":\"Ö\",\"\u00c7\":\"Ç\",\"\u015e\":\"Ş\",\"\u0130\":\"İ\",\"\u011e\":\"Ğ\",\"\u00f6\":\"ö\",\"\u00e7\":\"ç\",\"\u015f\":\"ş\",\"\u0131\":\"ı\",\"\u00fc\":\"ü\",\"\u011f\":\"ğ\"}");
function str_encode($string) {
$replace_char_list = json_decode(TURKISH_CHARS_HEX_VALS, true);
return str_replace(
array_keys($replace_char_list),
array_values($replace_char_list),
str_replace(" ", " ", htmlentities($string, ENT_COMPAT, "UTF-8", true))
);
}
function str_decode($string) {
$replace_char_list = json_decode(TURKISH_CHARS_HEX_VALS, true);
return str_replace(
array_values($replace_char_list),
array_keys($replace_char_list),
str_replace(" ", " ", html_entity_decode($string, ENT_COMPAT, "UTF-8"))
);
}
function is_ssl() {
if(isset($_SERVER["HTTPS"]))
if("on" == strtolower(getenv("HTTPS")))
return true;
if("1" == getenv("HTTPS"))
return true;
else if(isset($_SERVER["SERVER_PORT"]) && ("443" == getenv("SERVER_PORT")))
return true;
else
return false;
}
function get_current_url() {
$scheme = (is_ssl()) ? "https" : "http";
$host = getenv("HTTP_HOST");
$base_path = str_replace("\\", "/", getenv("SCRIPT_NAME"));
return sprintf("%s", sprintf("%s://%s%s", $scheme, $host, $base_path));
}
function write_jplayer_css() {
$base = "http://jplayer.org/latest/skin/pink.flag/";
$URL = "http://jplayer.org/latest/skin/pink.flag/jplayer.pink.flag.css";
$content = file_get_contents($URL);
$content = str_replace("url(\"", "url(\"" . $base, $content);
return $content;
}
function get_random_m4a_file() {
$m4a_directory = ""; # dosyaların bulunduğu klasör
$full_url = dirname(get_current_url());
$m4a_http_url = $full_url . "/" . trim($m4a_directory, "/") . "/";
$files = scandir(dirname(__FILE__).trim($m4a_directory, "/") . "/");
$ignore_items = array(".", "..");
$items = array();
foreach($files as $file)
if(!in_array($file, $ignore_items))
$items[] = $file;
$random_key = rand(0, (count($items) - 1));
return array("url", $m4a_http_url . $items[$random_key]);
}
if(array_key_exists("action", $_POST)) {
if($_POST["action"] == "endEvent") {
header("Content-Type: application/json; charset=UTF-8");
$output = get_random_m4a_file();
exit(json_encode($output));
}
}
header("Content-Type: text/html; charset=UTF-8");
?><!DOCTYPE html>
<!--[if lt IE 7]>
<html class="no-js lt-ie9 lt-ie8 lt-ie7" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<![endif]-->
<!--[if IE 7]>
<html class="no-js lt-ie9 lt-ie8" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<![endif]-->
<!--[if IE 8]>
<html class="no-js lt-ie9" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1" />
<![endif]-->
<title><?=str_encode("Müzik Uygulaması");?></title>
<meta name="author" content="<?=str_encode("Ogün KARAKUŞ");?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
<div "player-container">
<div id="jp_container_1" class="jp-audio">
<div class="jp-type-single">
<div class="jp-gui jp-interface">
<ul class="jp-controls">
<li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
<li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
<li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
<li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
</ul>
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<ul class="jp-toggles">
<li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
<li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
</ul>
</div>
<div class="jp-no-solution">
<span>Update Required</span>
<?=str_encode("To play the media you will need to either update your browser to a recent version or update your ");?><a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
</div>
</div>
</div>
</div>
<script type="text/javascript">window.onerror=function(a,b,c){console.log({url:b,line:c,message:a})}</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jplayer/2.5.0/jquery.jplayer.min.js"></script>
<script type="text/javascript">
$(function() {
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
m4a: "http://127.0.0.1:1923/calisma.alani/player/panpa.m4a"
}).jPlayer("play");
},
volume: "1",
supplied: "m4a, oga",
wmode: "window",
keyEnabled: true
});
$("#jquery_jplayer_1").bind($.jPlayer.event.ended, function(event) {
$.ajax({
url: "<?=get_current_url();?>",
type: "POST",
dataType: "json",
data: {
action: "endEvent"
},
async: true,
cache: false
}).done(function(response) {
$("#next-url").data("next-url", response.url);
});
$("#jquery_jplayer_1").jPlayer("setMedia", {
m4a: $("#next-url").data("next-url")
}).jPlayer("play");
});
});
</script>
<div id="next-url" data-next-url="" style="display:none"></div>
<link rel="stylesheet" type="text/css" href="http://jplayer.org/css/jPlayer.css" />
<style type="text/css"><?=write_jplayer_css();?></style>
<style type="text/css">body{padding:1em}#jp_container_1{margin:0 auto}#player-container{width:80%}</style>
</body>
</html><?php
if($do_gzip_compress) {
$gzip_contents = ob_get_contents();
ob_end_clean();
$gzip_size = strlen($gzip_contents);
$gzip_crc32 = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, (strlen($gzip_contents) - 4));
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $gzip_contents . pack("V", $gzip_crc) . pack("V", $gzip_size);
}