Computing.Net > Forums > Web Development > HELP needed with php codes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

HELP needed with php codes

Reply to Message Icon

Name: jjasm
Date: December 4, 2006 at 06:11:37 Pacific
OS: xp
CPU/Ram: 512
Comment:

In the following php code to embed wmv file in a webpage, is it possible to list more than one wmv file (so that I do not have to create one php file for each very one wmv file)? Would appreciate if someone could help. Thank you.
<?php
session_start();
error_reporting(0);
$file = $_REQUEST["file"];

if ($file == "name") {
$open = 'juliet.wmv';
if(is_readable($open))
{
header("Content-type: video/x-ms-wmv");
readfile($open);
exit;
}
}
// output 404 header if file not specified or not found:
header("HTTP/1.0 404 Not Found");
?>



Sponsored Link
Ads by Google

Response Number 1
Name: Laler
Date: December 5, 2006 at 14:49:49 Pacific
Reply:

something like this:

<?php
session_start();
error_reporting(0);
$file = $_REQUEST["file"];

$myfiles = array ('juliet.wmv', 'romeo.wmv');

if (in_array ($file, $myfiles) {
$open = $file;
if(is_readable($open))
{
header("Content-type: video/x-ms-wmv");
readfile($open);
exit;
}
}
// output 404 header if file not specified or not found:
header("HTTP/1.0 404 Not Found");
?>


add all your files to $myfiles array separated by commas

upload all the wmvs to the same folder where juliet.wmv is.


then you can create list of links:

yourfile.php?file=juliet.wmw
yourfile.php?file=romeo.wmv

...and so on
---
Fubar


0

Response Number 2
Name: jjasm
Date: December 5, 2006 at 19:00:44 Pacific
Reply:

Thank you so much for your input. Would appreciate if you could assist me further with the following.

The above php code rendered the error message below:

Parse error: parse error, unexpected '{' in /home/www/domain.com/wmv.php on line 8

When I remove the '{' on line 8 and re-upload the php file, another message appeared:

Parse error: parse error, unexpected T_VARIABLE in /home/www/domain.com/wmv.php on line 9


0

Response Number 3
Name: Laler
Date: December 5, 2006 at 23:11:25 Pacific
Reply:

Hello, yes sorry didn't test it out. A small syntax error.

In line 8 it should be:

if (in_array ($file, $myfiles)) {


Will it work now?

---
Fubar


0

Response Number 4
Name: Laler
Date: December 6, 2006 at 03:15:41 Pacific
Reply:

Good evening, Laler,
Further to my earlier email, I have just noticed it is easy for other people to trace the source of the wmv file, ie www.domain.com/juliet.wmv and dowmload and save the file.

I wonder if there is anyway to go around it?

Would appreciate your advice.


Hi,

First we must remember that when something is played or viewed, whether they're images, text, music, or movies, it means those something is already downloaded and can be saved.

In other words, people may save a movie by pointing his/her handycam to the monitor :)

---

We can of course do something to make people work harder when they want to save our content. This "something" cannot be explained easily. There're so many methods, each requires different knowledge. While none of them 100% guarantees that the content cannot be saved.

A basic and simple method is probably by disallowing "direct access", so people can't just type yoursite.com/juliet.wmv to download the file. This can be done by modifying your .htaccess file

> Best method (being used by rapidshare and the like)

In theory:

Put the wmvs in a restricted directory.

Only the streamer file has access to that directory.

People get different link each time, can only be used once.

The link will use the streamer file to read the requested wmv (in the restricted directory), and stream it out.

> Implementation

I also need to read and learn alot if Im going to implement these :D

---
Fubar


0

Response Number 5
Name: jjasm
Date: December 6, 2006 at 06:14:01 Pacific
Reply:

Thank you very much for your kind input, Laler. You are excellent.

Strange, the message I posted here (as appended below )before your above message has gone missing!!
"Thank you very much for your kind assistance. It works now.
You are really brilliant."


0

Related Posts

See More



Response Number 6
Name: fahimeh
Date: January 18, 2007 at 15:17:05 Pacific
Reply:

i need some insert code for mssql.
please help.


<?
//session_start();
mssql_connect("127.0.0.1","sa","") or die("connection failed");
$conn=mssql_connect("127.0.0.1","sa","");
mssql_select_db("[e-lib]") or die("db failed");
$sql="SELECT user_id FROM login WHERE username='$_POST[us1]' and password='$_POST[pass]'";
$rs=mssql_query($sql,$conn);
$row1=mssql_fetch_array($rs);
$num = @mssql_num_rows($rs);
if ($num != 0)
{print("<h3> wellcom</h3>");
mssql_connect("127.0.0.1","sa","") or die("connection failed");
$conn=mssql_connect("127.0.0.1","sa","");
mssql_select_db("[e-lib]") or die("db failed");
$rs=mssql_query($sql,$conn);
$row2=mssql_fetch_array($rs);
echo "<h4>please log in</h4>";
print ("login");
$_SESSION['family']=$row2[0];
mssql_close($conn);
}
else
{
print("<h3>illegal</h3>");
print("<h3>olease</h3>");
print("signup");
}
?>

fafa


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: HELP needed with php codes

help need with php code on wmv www.computing.net/answers/webdevel/help-need-with-php-code-on-wmv/3015.html

help with php code! www.computing.net/answers/webdevel/help-with-php-code/3049.html

Cannot connect to MySQL DB with PHP www.computing.net/answers/webdevel/cannot-connect-to-mysql-db-with-php/4085.html