FrickenTrevor
01-10-2014, 11:04 PM
Hey there, I am writing a bunch of Php, however I am not sure how to go about writing a few of them:
Tags for easier searching
Different categories to organise uploads
Restricted 'Adult' category/ Filter by maturity rating
Commenting on pictures
Profile page with each user's uploads
Favourites list on the profile page
Map for users to tag their location
Also I wrote some code for a video upload, just need someone to check it:
<?php
$allowed_filetypes = array('.jpg','.gif','.png','.jpeg','.wmv','.avi','.mp4','.m4v','.mkv','.mov','.mpeg','.mpg','.3g2','.3gp','.swf',);
$max_filesize = 20971520; // Maximum filesize in bytes (currently 20 MB)
$upload_path = './files/';
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die("Whoops you can't upload that type of file!");
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die("That file is too big, please upload a file smaller than 20 MB.");
if(!is_writable($upload_path))
die("You cannot upload to the specified directory.");
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '">here</a>';
else
echo 'Something went wrong during the upload, please try again.';
class media_handler
{
function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;
$out=explode(".",$outfile);
$size = Width & "x" & Height;
$outfile = $out[0].".flv";
$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -ar ".$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."/".$outfile;
//$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -b 500 -r 25 -s 320×240 -hq -deinterlace -ab 56 -ar 22050 -ac 1 ".$outputpath."/".$outfile." 2>&1";
$ret = shell_exec($ffmpegcmd1);
return $ffmpegcmd1;
}
}
Tags for easier searching
Different categories to organise uploads
Restricted 'Adult' category/ Filter by maturity rating
Commenting on pictures
Profile page with each user's uploads
Favourites list on the profile page
Map for users to tag their location
Also I wrote some code for a video upload, just need someone to check it:
<?php
$allowed_filetypes = array('.jpg','.gif','.png','.jpeg','.wmv','.avi','.mp4','.m4v','.mkv','.mov','.mpeg','.mpg','.3g2','.3gp','.swf',);
$max_filesize = 20971520; // Maximum filesize in bytes (currently 20 MB)
$upload_path = './files/';
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die("Whoops you can't upload that type of file!");
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die("That file is too big, please upload a file smaller than 20 MB.");
if(!is_writable($upload_path))
die("You cannot upload to the specified directory.");
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '">here</a>';
else
echo 'Something went wrong during the upload, please try again.';
class media_handler
{
function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;
$out=explode(".",$outfile);
$size = Width & "x" & Height;
$outfile = $out[0].".flv";
$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -ar ".$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."/".$outfile;
//$ffmpegcmd1 = "/usr/local/bin/ffmpeg -i ".$inputpath."/".$filename. " -b 500 -r 25 -s 320×240 -hq -deinterlace -ab 56 -ar 22050 -ac 1 ".$outputpath."/".$outfile." 2>&1";
$ret = shell_exec($ffmpegcmd1);
return $ffmpegcmd1;
}
}