Flowplayer Secure Streaming "Stream not found" - security

My client wants his videos hidden and not having the possibility to be downloaded or copied (or at least to make it difficult to do).
I'm trying to use flowplayer secure streaming, but I cannot make it work!
I'm getting this error:
200, Stream not found, NetStream.Play.StreamNotFound, clip: '[Clip]
'secure/ad722768cfa6f10b51b7e317c8dd1ca4/1417957647/v.mp4"
It says the video was not found, but it's placed on secure/v.mp4 as it should (right?)
UPDATE1
I forgot to mention that I have the required apache rewrite rule inside secure folder…
secure/.htaccess
RewriteEngine on
RewriteBase /secure
RewriteRule ^(.*)/(.*)/(.*)$ video.php?h=$1&t=$2&v=$3
RewriteRule ^$ - [F]
RewriteRule ^[^/]+\.(flv|mp4)$ - [F]
UPDATE2
I did it! It was a dumb simple thing:
I was testing with easyphp webserver, and the url was localhost/v/index.html
I did a test moving all the content from /v folder to the root and it worked!
And now I learned in htaccess I need to put the full path on RewriteBase starting from the root, in my case I needed to set this:
RewriteBase /v/secure
The codes:
index.html
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="flowplayer-3.2.13.min.js"></script>
<script>
$(document).ready(function() {
$f("player", "flowplayer-3.2.18.swf", {
plugins: {
secure: {
url: "flowplayer.securestreaming-3.2.9.swf",
timestampUrl: "sectimestamp.php"
}
},
clip: {
baseUrl: "secure",
url: "v.mp4",
urlResolvers: "secure",
scaling: "fit",
}
});
});
</script>
</head>
<body>
<div id="player"></div>
</body>
sectimestamp.php
<?php
echo time();
?>
secure/video.php
<?php
$hash = $_GET['h'];
$streamname = $_GET['v'];
$timestamp = $_GET['t'];
$current = time();
$token = 'sn983pjcnhupclavsnda';
$checkhash = md5($token . '/' . $streamname . $timestamp);
if (($current - $timestamp) <= 2 && ($checkhash == $hash)) {
$fsize = filesize($streamname);
header('Content-Disposition: attachment; filename="' . $streamname . '"');
if (strrchr($streamname, '.') == '.mp4') {
header('Content-Type: video/mp4');
} else {
header('Content-Type: video/x-flv');
}
header('Content-Length: ' . $fsize);
session_cache_limiter('nocache');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
$file = fopen($streamname, 'rb');
print(fread($file, $fsize));
fclose($file);
exit;
} else {
header('Location: /secure');
}
?>
I already tried this > Flowplayer Secure Streaming with Apache but I also get the error above.
Does anyone use flowplayer secure streaming? What am I doing wrong?

I figured out what was wrong, in htaccess you need to put the full path on RewriteBase starting from the root, in my case I needed to set this:
RewriteBase /v/secure

Related

HTAccess Rewrite Rule URL from Meta Title

How can I rewrite a rule for the url
navi.php?a=815&lang=eng
and a meta title
How can I post a Video
into
/en/How-can-I-post-a-Video
Can the Meta Title be fetched somehow to add it to url?
Instead of passing the params in the url, you need to form a url with meta tag title. From the url take the arguements and match with the database and get the result data. This is how the .htaccess will work.
You can make a rewrite rule like so:
RewriteRule ^(.*)$ index.php?params=$1 [NC]
This will make your actual php file like so:
index.php?params=value&param=value
And your actual URL would be like so:
http://url.com/params/param/value/param/value
And in your PHP file you could access your params by exploding this like so:
<?php
$params = explode( "/", $_GET['params'] );
for($i = 0; $i < count($params); $i+=2) {
echo $params[$i] ." has value: ". $params[$i+1] ."<br />";
}
?>

How to get the root URL to Slim application in a subdir?

I must make a website with PHP and I choose to use Slim and Twig. But my superiors don't want me to use a virtual host. So I'm having trouble when I test the website with MAMP because the site is on a subdirectory, like http://localhost:8888/subdir.
When I try to access an asset, I can't use absolute path because it would force me to write /subpath/path/to/asset. But when we will deploy the application, there will be no subpath. How can I root the website as if there would be a virtual host?
You can see some of my code below:
index.php
<?php
require 'vendor/autoload.php';
include 'database.php';
use app\controller\ConfigController;
$app = new \Slim\Slim();
$app->get('/', function () {
echo "accueil";
})->name("root");
$app->group('/Admin', function () use ($app) {
$app->get("/", function (){
$ctrl = new ConfigController();
$ctrl->index();
})->name("indexAdmin");
});
.htaccess (in localhost:8888/subdir)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
ConfigController (called function)
public function index() {
$loader = new \Twig_Loader_Filesystem("app/view/Admin");
$twig = new \Twig_Environment($loader);
$template = $twig->loadTemplate('Index.twig');
echo $template->render(array(
'css' => "admin.css"
));
}
template called by Twig environment
<!doctype html>
<html lang="fr">
<head>
<link rel="stylesheet" type="text/css" href="/app/assets/stylesheets/{{ css }}">
</head>
<body>
[...]
When I search on Google and Stack Overflow, everyone said to make a virtual host, but I can't. Would there be another solution?
If you are using the slim/views package to integrate Twig in the application you are writing, it's possible to add the TwigExtension in that package to your Twig instance and use the siteUrl function for your assets. This way:
<link rel="stylesheet" href="{{ siteUrl('path/to/asset/style.css') }}">
If you're not using that package, you can create your own function to get the application URL. Something like this:
function siteUrl($url) {
$req = Slim::getInstance()->request();
$uri = $req->getUrl() . $req->getRootUri();
return $uri . '/' . ltrim($url, '/');
}

Opencart SEO URL for product filters

I recently got a chance to work on Opencart and I got a custom-made theme (Pav foodstore).
I am trying to implement auto-seo URLs in my project. For doing so, I downloaded a very good extension from Navneet Singh for auto-seo URLs. The problem is, it doesn't come with SEO URLs for product filters. Tried a few modifications, but I can't seem to get it working right.
Following is the VQmod xml file code :
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>CUSTOM CHANGES DONE BY NAVNEET SINGH</id>
<version>1</version>
<vqmver>1.0.0</vqmver>
<author>NAVNEET SINGH</author>
<!-- SEO URLS -->
<file error="abort" name="system/library/response.php">
<operation>
<search position="after"><![CDATA[
public function output() {
]]></search>
<add><![CDATA[
if ($this->output) {
// REPLACE URLS WITH SEO URLS
function my_repl($value) {
if( defined(ENT_COMPAT) && defined(ENT_HTML401) && defined(ENT_IGNORE) ) {
$val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT|ENT_HTML401|ENT_IGNORE,"UTF-8"),"`~!##$%^&*()-_=+\\|[{]};:'\",<.>/?"," "))));
return rawurlencode($val); }
elseif( defined(ENT_COMPAT) && defined(ENT_IGNORE) ) {
$val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT|ENT_IGNORE,"UTF-8"),"`~!##$%^&*()-_=+\\|[{]};:'\",<.>/?"," "))));
return rawurlencode($val); }
else {
$val=str_replace(" ","-",strtolower(trim(strtr(html_entity_decode(strip_tags($value),ENT_COMPAT,"UTF-8"),"`~!##$%^&*()-_=+\\|[{]};:'\",<.>/?"," "))));
return rawurlencode($val); }
}
function my_preg_replace($m1) {
if($m1[1]=='information/information') $p2 = 'i';
elseif($m1[1]=='product/category') $p2 = 'c';
elseif($m1[1]=='product/category' && $m1[2]=='filter') $p2 = 'f';
elseif($m1[1]=='product/manufacturer/info') $p2 = 'm';
elseif($m1[1]=='product/product' && $m1[2]=='product_id') $p2 = 'pp';
elseif($m1[1]=='product/product' && $m1[2]=='manufacturer_id') $p2 = 'pm';
elseif($m1[1]=='product/product' && $m1[2]=='path') $p2 = 'pc';
else return;
// IF IMG TAG, USE IMG ALT TEXT IN SEO URL; ELSE, USE ANCHOR TEXT IN SEO URL
if($p2=='i' || $p2=='c' || $p2=='m' || $p2=='pp') {
if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[4], $m2 ) )
$u1 = my_repl($m2[1]);
else
$u1 = my_repl($m1[4]);
return $p2 . trim($m1[3]) . "-" . $u1 . '">' . $m1[4] . "</a>";
}
elseif($p2=='pc') {
if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[5], $m2 ) )
$u1 = my_repl($m2[1]);
else
$u1 = my_repl($m1[5]);
return $p2 . trim($m1[4]) . "-c" . trim($m1[3]) . "-" . $u1 . '">' . $m1[5] . "</a>";
}
elseif($p2=='pm') {
if( preg_match( '#<img.*alt="([^"]*)"#iUs', $m1[5], $m2 ) )
$u1 = my_repl($m2[1]);
else
$u1 = my_repl($m1[5]);
return $p2 . trim($m1[4]) . "-m" . trim($m1[3]) . "-" . $u1 . '">' . $m1[5] . "</a>";
}
}
// PATTERNS TO SEARCH FOR SEO URL REPLACEMENT
$p1s = array(
"#index\.php\?route\=(product/category)&(path)=([0-9_]+?)\">(.*)</a>#iUs",
"#index\.php\?route\=(product/category)&(path)=([0-9_]+?)&filter=([0-9]+?)\">(.*)</a>#iUs",
"#index\.php\?route\=(product/manufacturer/info)&(manufacturer_id)=([0-9]+?)\">(.*)</a>#iUs",
"#index\.php\?route\=(information/information)&(information_id)=([0-9]+?)\">(.*)</a>#iUs",
"#index\.php\?route\=(product/product)&(product_id)=([0-9]+?)[^\"]*\">(.*)</a>#iUs",
"#index\.php\?route\=(product/product)&(path)=([0-9_]+?)&product_id=([0-9]+?)\">(.*)</a>#iUs",
"#index\.php\?route\=(product/product)&(manufacturer_id)=([0-9]+?)&product_id=([0-9]+?)\">(.*)</a>#iUs",
);
$this->output = preg_replace_callback( $p1s, "my_preg_replace", $this->output );
}
]]></add>
</operation>
</file>
And this is my .htaccess code block :
RewriteEngine On
RewriteRule ^i([0-9]+)-(.*)$ index.php?route=information/information&information_id=$1 [L]
RewriteRule ^c([0-9_]+)-(.*)$ index.php?route=product/category&path=$1 [L]
RewriteRule ^c([0-9_]+)-f([0-9_]+)-(.*)$ index.php?route=product/category&path=$2&filter=$1 [L]
RewriteRule ^m([0-9]+)-(.*)$ index.php?route=product/manufacturer/info&manufacturer_id=$1 [L]
RewriteRule ^pp([0-9]+)-(.*)$ index.php?route=product/product&product_id=$1 [L]
RewriteRule ^pm([0-9]+)-m([0-9]+)-(.*)$ index.php?route=product/product&manufacturer_id=$2&product_id=$1 [L]
RewriteRule ^pc([0-9]+)-c([0-9_]+)-(.*)$ index.php?route=product/product&path=$2&product_id=$1 [L]
Any help would be appreciated.

Masonry Infinite Scroll with Database and Anchor Tag that links to the current document

I am new to PHP, Javascript and HTML. So maybe I'm missing something obvious but, I can't for the life of me figure out what is wrong with my code. I am trying to use Paul Irish's Infinite Scroll with a PHP file that has an anchor point that links back to itself with different GET values. The problem is that Anything I do gives me this error:
Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag.
I am at my wits end and desperately need someones help because I need this done by January 20th. It's going to be a birthday gift for someone I know.
Here is my code:
index.php (Code Snippet)
<div id="content-container" class="container-fluid" style="padding:0px;overflow:hidden;">
<div class="row-fluid full">
<div class="span12 full" style="overflow:scroll;position:relative;">
<div id="media-palette">
<?php
include('content.php');
?>
</div>
</div>
</div>
</div>
script.js (Code Snippet)
$("#media-palette").infinitescroll({
navSelector:"#next",
nextSelector:"#media-palette a#next:last",
itemSelector:".media-content",
bufferPx:50,
debug: true,
}, function(newElements) {
$("#media-palette").masonry('append', newElements,true);
});
content.php
(It is worth noting that the images found in this file are for testing purposes and the final PHP file will load images from a database.)
<?php
require('dbconnect.php');
$startIndex = $_GET['start'];
$endIndex = $_GET['end'];
$nextStartIndex = $endIndex-1;
$nextEndIndex = $endIndex-10;
?>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
$files = scandir("images");
if ($files) {
$length = count($files);
static $allowedExts = array("jpg", "jpeg", "gif", "png");
for ($i = 0; $i < $length; $i++) {
$extension = end(explode(".", $files[$i]));
$extension = strtolower($extension);
if (in_array($extension,$allowedExts)) {
$rand = rand(0,10);
if (!$rand) echo "<img class='media-content medium' src='images/".$files[$i]."'/>";
else echo "<img class='media-content small' src='images/".$files[$i]."'/>";
}
}
}
echo '<a id="next" href="content.php?start='.$nextStartIndex.'&end='.$nextEndIndex.'"></a>';
?>
</body>

.htaccess redirect get to a subdomain

I want to redirect a link from
www.example.com/ex.php?name=andy
to
www.andy.example.com
Can you give me the code please
Why use .htaccess? You can do that with PHP.
<?php
$url = 'http://www.'. $_GET['name'] .'.example.com';
header('Location: '. $url);
?>
Just make sure you don't output any text before using header().
To get the name from the subdomain URL do the following.
<?php
$new_url = $_SERVER["SERVER_NAME"];
$url_parts = explode('.', $new_url);
echo 'Name is: '. $url_parts[0];
?>
james.example.com results in "Name is: james".

Resources