Jump to content

upload movies


Ph0enix

Recommended Posts

Hi can someone make me a script please.
I would like people to be able upload there flash movie, and enter there name and the title of the movie.
Then there is a page that has a list of the movies title and who it was submitted by. (6 per page). Then a link to the next page.
Then when they click on the title of the movie they can veiw the flash movie in a new window.
I am willing to pay for this script. (a reasonable amount)
Or could someone give me a link so i can download one please.
Add me on msn or email me at [email protected]
Thanks
Max
Link to comment
https://forums.phpfreaks.com/topic/13985-upload-movies/
Share on other sites

  • 2 weeks later...
ill gives this to you in parts so it's easier to handle..

Ini functions (do not edit, just use :) put in "inifunc.inc") :
[code]
<?php
// write_key($section, $key, $value, $file_name)
// write_section($section, $keys, $file_name)
// delete_key($section, $key, $file_name)
// delete_section($section, $file_name)
// read_key($section, $key, $default, $file_name)
// read_section($section, $default, $file_name)
$empty = "";
function write_key($section, $key, $value, $file_name)
{
if (!file_exists($file_name))
{
$content = "[$section]\r\n";
$content .= "$key=$value";
}
else
{
$content = read_ini($file_name);
$currentsection = find_section($content, $section, FALSE);
if (!isset($currentsection))
{
$content .= "\r\n\r\n[$section]\r\n";
$content .= "$key=$value";
}
else
{
    $currentkey = find_key($currentsection, $key, FALSE);
    if (!isset($currentkey))
{
$newsection = $currentsection."\r\n$key=$value";
$content = str_replace($currentsection, $newsection, $content);
}
    else
    {
$newsection = str_replace($currentkey, "$key=$value", $currentsection);
$content = str_replace($currentsection, $newsection, $content);    
}
}
}
write_ini ($content, $file_name);
}

function write_section($section, $keys, $file_name)
{
if (!file_exists($file_name))
{
$content = "[$section]\r\n";
foreach ($keys as $key=>$value)
$content .="$key=$value\r\n";
}
else
{
$content = read_ini($file_name);
$currentsection = find_section($content, $section, FALSE);
if (!isset($currentsection))
{
$content .= "\r\n\r\n[$section]\r\n";
foreach ($keys as $key=>$value)
$content .="$key=$value\r\n";
}
else
{
$newsection = $currentsection;
foreach ($keys as $key=>$value)
{
$currentkey = find_key($currentsection, $key, FALSE);
    if (!isset($currentkey))
{
$newsection .= "\r\n$key=$value";
}
    else
    {
$newsection = str_replace($currentkey, "$key=$value", $newsection);
}
}
$content = str_replace($currentsection, $newsection, $content);
}
}
write_ini ($content, $file_name);
}

function delete_key($section, $key, $file_name)
{
if (!file_exists($file_name))
return (FALSE);
$content = read_ini($file_name);
$currentsection = find_section($content, $section, FALSE);
if (!isset($currentsection))
return (FALSE);
$currentkey = find_key($currentsection, $key, FALSE);
if (!isset($currentkey))
return (FALSE);
$newsection = str_replace("\r\n".$currentkey, "", $currentsection);
$content = str_replace($currentsection, $newsection, $content);
write_ini ($content, $file_name);
return (TRUE);
}
function delete_section($section, $file_name)
{
if (!file_exists($file_name))
return (FALSE);
$content = read_ini($file_name);
$currentsection = find_section($content, $section, FALSE);
if (!isset($currentsection))
return (FALSE);
$content = str_replace($currentsection, "", $content);
write_ini ($content, $file_name);
return (TRUE);
}
function read_key($section, $key, $default, $file_name)
{
if (!file_exists($file_name))
return($default);
$content = read_ini($file_name);
$currentsection = find_section($content, $section, TRUE);
if (!isset($currentsection))
return($default);
    $value = find_key($currentsection, $key, TRUE);
    if (!isset($value))
return($default);
    return ($value);
}
function read_section($section, $default, $file_name)
{
if (!file_exists($file_name))
return($default);
$content = read_ini($file_name);
$currentsection = find_section($content, $section, TRUE);
if (!isset($currentsection))
return($default);
    $lines = explode("\r\n" , $currentsection);
foreach ($lines as $line)
{
list($key,$value)=explode('=',$line);
$keys[$key]=$value;
}
    return ($keys);
}
function read_ini ($file_name)
{
clearstatcache();
$file = fopen($file_name, "r");
flock($file, LOCK_SH);
$content = trim(fread($file, filesize($file_name)));
flock($file, LOCK_UN);
fclose ($file);
return ($content);
}

function write_ini ($content, $file_name)
{
$file = fopen($file_name, "w");
flock($file, LOCK_EX);
fwrite($file, $content);
flock($file, LOCK_UN);
fclose ($file);
}

function find_section ($content, $section, $just_keys)
{
$section = "[$section]\r\n";
$currentsection = strstr($content, $section);
if (!$currentsection)
return($empty);
$endpos = strpos($currentsection, "\r\n\r\n");
if (!$endpos)
$endpos = strpos($currentsection, "\r\n[");
if (!$endpos)
$endpos = strlen($currentsection);
if ($just_keys)
$currentsection = trim(substr($currentsection, strlen($section), $endpos-strlen($section)));
else
$currentsection = trim(substr($currentsection, 0, $endpos));
return ($currentsection);
}

function find_key ($currentsection, $key, $just_value)
{
    $key .= "=";
    $currentkey = strstr($currentsection, $key);
    if (!$currentkey)
return($empty);
    $endpos = strpos($currentkey, "\r\n");
    if (!$endpos)
$endpos = strlen($currentkey);
if ($just_value)
$currentkey = trim(substr($currentkey, strlen($key), $endpos-strlen($key)));
else
$currentkey = trim(substr($currentkey, 0, $endpos));

return ($currentkey);
}
?>
[/code]
the first few lines (commented ones) explain how to use it, if u dont understand, pm me..

functions ("func.inc"):
[code]
<?php
function enumUploads() {
$num = 0;
while(read_key("Files", $num, "", "files.ini") != "") {
$num++;
}
return $num;
}
function clearUploads() {
$num2 = 0;
while(read_key("Files", $num2, "", "files.ini") != "") {
                          unlink(read_key("Files", $num2, "", "files.ini"));
                          unlink("$num2.txt");
                          write_key("Files", $num2, "", "files.ini");
$num2++;
}
return echo "all uploads deleted!";
}
function deleteUpload($num4) {
$num3 = 0;
             $num5 = $num4;
             unlink(read_key("Files", $num5, "", "files.ini"));
             unlink("$num5.txt");
while(read_key("Files", $num, "", "files.ini") != "") {
$num3++;
}
             while($num4<=$num3) {
                          write_key("Files", $num4, read_key("Files",$num4+1, "", "files.ini"), "files.ini");
                          $num4++;
             }
             return echo "deleted upload $num5";
}
?>
[/code]

whew, wrote that on the spot :o, u may wanna give it some testing ;)

next for the upload script, upload.html:

[code]
<?php
if(file_exists("links.html")) {
echo "<a href=links.html>links</a>";
}
?>
<hr>
<form method=POST action=ul.php enctype=multipart/form-data>
<p>File to upload:<br>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td colspan=2><input type=file name=img size=20></td>
</tr><tr>
<td><textarea name="comment" cols=15 rows=5></textarea></td><td>File Comments</td>
</tr><tr>
<td><input type="submit" name="submit" value="Upload"></td><td><input type=reset value=Clear></td>
</tr></table>
</form>
<hr>
</body>
</html>
[/code]

ul.php:

[code]
<?php
include("inifunc.inc");
include("func.inc");
$log = "";
$abpath = "./";
$moo = enumUploads();
if(@copy($img, "$abpath/" . $img_name)) {
if (file_exists($img_name)) {
$log .= "File was uploaded<br><input type='button' value='back' onclick='history.go(-1)'>";
$fp = fopen($moo . ".txt", "a");
$cmnt = $_POST["comment"];
$cmnt = str_replace("\\", "", $cmnt);
fwrite($fp, $cmnt);
fclose($fp);
write_key("Files", $moo, $img_name, "files.ini");
}
}
else {
$log .= "Error uploading file";
}
echo $log;
?>
[/code]

again, written on the spot, test it first, if there is errors then pm me and ill give it another once-over

and finally, linking to the uploaded files, dunno where ur putting it but here it is, we'll say links.html:

[code]
<?php
include("inifunc.inc");
include("func.inc");
$moo = enumUploads();
$num = 0;
$moo--;
$links = "<p>
";
while($num!=$moo) {
$links .= "<li><a href=" . read_key("Files", $num, "404.html", "files.ini") . ">" . read_key("Files", $num, "404.html", "files.ini") . "</a><br><i>" . include("$num.txt") . "</i>
";
$num++;
}
$links .= "
</p>";
echo $links;     //--- this goes where you want it.
?>
[/code]

change "404.html" to whatever your error404 page is (if read_key fails somehow it will link them there instead of crashing the script ^.^)

that should do ya ;) (thats about $150 of my time, yours free, be happy :) )
Link to comment
https://forums.phpfreaks.com/topic/13985-upload-movies/#findComment-59162
Share on other sites

  • 2 weeks later...
Since I'm not sure where $img and $img_name are coming from (and a bugfix), change this:

[code]
$abpath = "./";
$moo = enumUploads();
if(@copy($img, "$abpath/" . $img_name)) {
[/code]

To this:

[code]
$abpath = "./";
$img = $_FILES['img']['tmp_name'];
$img_name = $_FILES['img']['name'];
$moo = enumUploads();
if(@copy($img, $abpath . $img_name)) {
[/code]
Link to comment
https://forums.phpfreaks.com/topic/13985-upload-movies/#findComment-64148
Share on other sites

Ok the script is working now thanks!
The videos are uploaded and i can click on them to view them but i get this warning above the video's name..

Warning: include(0.txt</i> ) [function.include]: failed to open stream: Invalid argument in C:\wamp\www\scripts\links.php on line 11

Warning: include() [function.include]: Failed opening '0.txt</i> ' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\scripts\links.php on line 11
Link to comment
https://forums.phpfreaks.com/topic/13985-upload-movies/#findComment-64298
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.