Jump to content


Photo

upload movies


  • Please log in to reply
10 replies to this topic

#1 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 07 July 2006 - 10:10 PM

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 xphoenixx@hotmail.com
Thanks
Max
[url=http://www.slimphoenix.com][/url]

#2 True`Logic

True`Logic
  • Members
  • PipPipPip
  • Advanced Member
  • 59 posts

Posted 17 July 2006 - 04:30 AM

ill gives this to you in parts so it's easier to handle..

Ini functions (do not edit, just use :) put in "inifunc.inc") :
<?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);
}
?>
the first few lines (commented ones) explain how to use it, if u dont understand, pm me..

functions ("func.inc"):
<?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";
}
?>

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

next for the upload script, upload.html:

<?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>

ul.php:

<?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;
?>

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:

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

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 :) )

#3 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 26 July 2006 - 01:29 AM

Hey thanks man, iv only just seen the post xD
I havent tested it but i will and get back to ya!
[url=http://www.slimphoenix.com][/url]

#4 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 26 July 2006 - 01:38 AM

I tested it and i get an error on the upload saying:
Parse error: parse error, unexpected T_ECHO in C:\wamp\www\scripts\func.inc on line 17

and line 17 is
return echo "all uploads deleted!";

Can you help me please?
[url=http://www.slimphoenix.com][/url]

#5 stickman

stickman
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 26 July 2006 - 03:08 AM

I dont think you can return an echo (I dont know for sure), so change it to:

return "all uploads deleted!";

..:: FREE NINTENDO WII OR $250 CASH ::..
..:: Click here for more information ::..


#6 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 26 July 2006 - 10:22 AM

Ok i did that on line 17 and line 31, but not i just get an error saying "Error uploading file"  :-\
Can you help again? please
[url=http://www.slimphoenix.com][/url]

#7 stickman

stickman
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 26 July 2006 - 04:33 PM

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

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

To this:

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

..:: FREE NINTENDO WII OR $250 CASH ::..
..:: Click here for more information ::..


#8 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 26 July 2006 - 04:57 PM

i'm moving this to PHP Help, since it's no longer a freelancing inquiry so much as a help topic about the script tidbits true logic gave.

#9 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 26 July 2006 - 08:13 PM

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
[url=http://www.slimphoenix.com][/url]

#10 stickman

stickman
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 26 July 2006 - 09:30 PM

I'm not sure how to fix that one. I'm not too familiar with the script that True Logic made. The only thing I could think of is that 0.txt wasnt created when the video was uploaded. We'll have to wait and see what True Logic says though.

..:: FREE NINTENDO WII OR $250 CASH ::..
..:: Click here for more information ::..


#11 Ph0enix

Ph0enix
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 26 July 2006 - 11:43 PM

Ok then. Thanks for your help Stickman :)
[url=http://www.slimphoenix.com][/url]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users