how to convert php script to javascript

we have construct the one secret URL for my application.i have PHP script how to change java script any one help me to solve the issue

Below mentioned script how to change java script in c# application i have php script this to change javascript

<html>
<title>Live</title>
<head>
<script src=""></script>
<script>jwplayer.key = "ti8UU55KNdJCPX+oWrJhLJNjkZYGiX13KS7yhlM7Ok/wmU3R";</script>
</head>
<body>
<?php
function bg_gen_secure_uri($file, $directory, $secret, $expiry=0, $allowed_countries='',
$disallowed_countries='', $allowed_ip='', $allowed_useragent='',
$allowed_metros='', $disallowed_metros='',
$progressive_start='', $progressive_end='',
$extra_params='') { if ($file==''||$secret=='') { return false; } // Construct the values for the MD5 salt ... if (substr($expiry,0,1)=='=') { $timestamp=substr($expiry,1); } else if ($expiry > 0) { $now=time(); // use UTC time since the server does $timestamp=$now+$expiry; } else { $timestamp=0; } if ($allowed_countries) { $allowed_countries='&a='.$allowed_countries; } if ($disallowed_countries) { $disallowed_countries='&d='.$disallowed_countries; } if ($allowed_ip) { $allowed_ip='&i='.$allowed_ip; } if ($allowed_useragent) { $allowed_useragent='&u='.$allowed_useragent; } if ($progressive_start!='') { $progressive_start='&start='.$progressive_start; } if ($progressive_end) { $progressive_end='&end='.$progressive_end; } if ($allowed_metros) { $allowed_metros='&am='.$allowed_metros; } if ($disallowed_metros) { $disallowed_metros='&dm='.$disallowed_metros; } if ($extra_params) { $extra_params=urldecode($extra_params); } // Generate the MD5 salt ... if ($directory == '') { $salt = $secret . $file . '?e=' . $timestamp . $allowed_countries . $disallowed_countries . $allowed_metros . $disallowed_metros . $allowed_ip . $allowed_useragent . $progressive_start . $progressive_end; } else { $salt = $secret . $directory . '?e=' . $timestamp . $allowed_countries . $disallowed_countries . $allowed_metros . $disallowed_metros . $allowed_ip . $allowed_useragent . $progressive_start . $progressive_end; } // Generate the MD5 hash ... $hash_code = md5($salt); // Generate the link ... $url = $file . '?e=' . $timestamp . $allowed_countries . $disallowed_countries . $allowed_metros . $disallowed_metros . $allowed_ip . $allowed_useragent . $progressive_start . $progressive_end . '&h=' . $hash_code . $extra_params; return $url;
}
function get_secure_url($file,$directory,$secret) { $expiry=3600; $allowed_countries=''; $disallowed_countries=''; $allowed_ip=''; $allowed_useragent=''; $allowed_metros=''; $disallowed_metros=''; $progressive_start=''; $progressive_end=''; $extra_params='&bgsecuredir=1'; return bg_gen_secure_uri($file, $directory, $secret, $expiry, $allowed_countries, $disallowed_countries, $allowed_ip, $allowed_useragent, $allowed_metros, $disallowed_metros, $progressive_start, $progressive_end, $extra_params);
}
$url = '('/secure/live/tv/playlist.m3u8','/tv/secure/','kkkfdashfsdiads');
?>
<div>
<div>
<div> </div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: '<?=$url?>',
width: '100%',
aspectratio: '16:9',
stretching:'exactfit',
autostart: false,
androidhls: true,
skin: 'vapor',
primary: 'html5'
});
</script>
</div>
</div>
4

2 Answers

  • Install Composer from
  • Add the "base-reality/php-to-javascript": ">=0.0.3" to your project's composer.json file:

    "require":{ "base-reality/php-to-javascript": "0.1.16" }

    Or the latest tagged version. The dev master should only be used for development, not production.\

  • Include the Composer SPL autoload file in your project: require_once('../vendor/autoload.php');

    Call the converter:

     $phpToJavascript = new PHPToJavascript\PHPToJavascript(); $phpToJavascript->addFromFile($inputFilename); $jsOutput = $phpToJavascript->toJavascript();

    $jsOutput will now contain an auto-generated Javascript version of the PHP source file.

Hope this helps!

Thanks

3

You can convert PHP syntax to JS with

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like