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

HELP needed with php codes

Reply to Message Icon

Original Message
Name: jjasm
Date: December 4, 2006 at 06:11:37 Pacific
Subject: HELP needed with php codes
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");
?>


Report Offensive Message For Removal


Response Number 1
Name: Laler
Date: December 5, 2006 at 14:49:49 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 2
Name: jjasm
Date: December 5, 2006 at 19:00:44 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 3
Name: Laler
Date: December 5, 2006 at 23:11:25 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 4
Name: Laler
Date: December 6, 2006 at 03:15:41 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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


Report Offensive Follow Up For Removal

Response Number 5
Name: jjasm
Date: December 6, 2006 at 06:14:01 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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."


Report Offensive Follow Up For Removal


Response Number 6
Name: fahimeh
Date: January 18, 2007 at 15:17:05 Pacific
Subject: HELP needed with php codes
Reply: (edit)

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


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: HELP needed with php codes

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge