Jump to content

Smarty upload wont work...???


Andy-H

Recommended Posts

Basically I have purchased FFMpeg hosting for a youtube clone site I wanted to test and the upload.php script wont work, this is a 3rd partys script (I had sent to me) which is advanced PHP which I do not understand as I am self taught (3 years experience). Here are the upload.php and upload.tpl scripts:

 

<?php
include("include/config.php");
session_start();
include("include/function.php");
chk_member_login();
isMailVerified();
if($config['enable_package']=="yes")
{
        check_subscriber(100);
}


if($_REQUEST[action_upload]!="")
{
        if($_REQUEST[field_myvideo_title]==""){
		$err="Upload: Please Provide a video title.";
	}
        elseif($_REQUEST[field_myvideo_descr]==""){
		$err="Upload: Please Provide a video description.";
	}
        elseif($_REQUEST[field_myvideo_keywords]==""){
		$err="Upload: Please provide tag/s.";
	}
        elseif(count($_REQUEST[chlist])<1 || count($_REQUEST[chlist])>3){
		$err="Upload: Please check (1 to 3) channel/s.";
	}

        if($err==""){
		$page = "second";
		STemplate::assign('secondpage',"second");
		$listch=implode("|",$_REQUEST[chlist]);
		STemplate::assign('listch',$listch);
		$var = "<script language=javascript>
				var field_myvideo_title = $_REQUEST[field_myvideo_title];
				var field_myvideo_descr = $_REQUEST[field_myvideo_descr];
				var field_myvideo_keywords = $_REQUEST[field_myvideo_keywords];
				var listch = $listch;
				</script>";
		STemplate::assign("var", $var);
        }
}
if($_POST[upload_final]!="")
{
        if($_FILES['field_uploadfile']['tmp_name']=="") $err="Please provide the video location.";
        if($err=="" && $_FILES['field_uploadfile']['tmp_name']!="")
                {
                $p=$_FILES['field_uploadfile']['name'];
                $pos=strrpos($p,".");
                $ph=strtolower(substr($p,$pos+1,strlen($p)-$pos));
                /* Space in Megabytes (MB) */
                $space = round($_FILES['field_uploadfile']['size']/(1024*1024));
                if($config['enable_package']=="yes")
                {
                        check_subscriber($space);
                }
                
                if(($ph!="mpg" && $ph!="avi" && $ph!="mpeg" && $ph!="wmv" && $ph!="rm" && $ph!="dat") || $space>$config[max_video_size])
                $err="Invalid Video Format.";
                }

        if($err=="")
        {
                $sql="insert into video set
                        UID=$_SESSION[uID],
                        title='$_REQUEST[field_myvideo_title]',
                        description='$_REQUEST[field_myvideo_descr]',
                        keyword='$_REQUEST[field_myvideo_keywords]',
                        channel='0|$_REQUEST[listch]|0',
                        space = '$_REQUEST[space]',
                        addtime='".time()."',
                        adddate='".date("Y-m-d")."',
                        vkey='".mt_rand()."',
                        type='$_REQUEST[field_privacy]',
                        filehome='$_REQUEST[p]'";
                $conn->execute($sql);
                $vid=mysql_insert_id();
                $vdoname=$vid.".".$ph;
             
                    if(isset($_FILES['field_uploadfile']['tmp_name']) && is_uploaded_file($_FILES['field_uploadfile']['tmp_name']))
                    {
					$ff = $config[vdodir]."/".$vdoname;
					if(move_uploaded_file($_FILES['field_uploadfile']['tmp_name'], $ff))
					{	$mov = new ffmpeg_movie($ff);
						video_to_frame($ff,$vid,&$mov,$listch[0]);
						$duration=$mov->getDuration();
						exec("$config[ffmpeg] -i $config[vdodir]/$vdoname -acodec mp3 -ar 22050 -ab 32 -f flv $config[flvdodir]/".$vid.".flv");
					}
                       
                    }
                //END

                $key=substr(md5($vid),11,20);
                $sql="update video set
                        vdoname='$vdoname',
                        flvdoname='".$vid.".flv',
                        duration='$duration',
                        vkey='$key' WHERE VID=$vid";
                $conn->execute($sql);
        
                if($config['enable_package']=="yes")
                {
                        $sql = "update subscriber set used_space=used_space+$space, used_bw=used_bw+$space, total_video=total_video+1 where UID=$_SESSION[uID]";
                        $conn->execute($sql);
                }
        
                header("Location:$config[baseurl]/upload_success.php?viewkey=$key&upload=yes&vid=$vid");
        }
}


STemplate::assign('err',$err);
STemplate::assign('msg',$msg);
STemplate::assign('head_bottom',"blank.tpl");
STemplate::display('head1.tpl');
STemplate::display('err_msg.tpl');
STemplate::display('upload.tpl');
STemplate::display('footer.tpl');
?>

 



{if $secondpage ne "second" and $smarty.request.upload_final eq ""}
<table>
<tr>
<td height="24" valign=top align=center><table width="760"  border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="5" height="24" background="images/nv_2_l.jpg" valign=top><img src="images/nv_2_l.jpg" width="5" height="24" alt=""></td>
                                    <th background="images/nv_2_bg.jpg" align=left width=760><span class="white_bold" valign=top align=left>Video Upload (Step 1 of 2)</span></th>
                                    <td width="5" background="images/nv_2_r.jpg"><img src="images/nv_2_r.jpg" width="5" height="24" alt=""></td>
                                  </tr>
                              </table></td>

</tr></table>

<FORM id=theForm name=theForm action="{$baseurl}/upload.php" method=post encType=multipart/form-data>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0><TBODY>
<TR>
<TD align=right width=200><SPAN class=label><NOBR>Title:</NOBR></SPAN></TD>
<TD><INPUT maxLength=60 size=40 name="field_myvideo_title" value="{$smarty.request.field_myvideo_title}"></TD>
</TR>
<TR>
<TD vAlign=top align=right><SPAN class=label><NOBR>Description:</NOBR> </SPAN></TD>
<TD><TEXTAREA name="field_myvideo_descr" rows=4 cols=50>{$smarty.request.field_myvideo_descr}</TEXTAREA></TD>
</TR>
<TR vAlign=top>
<TD align=right><SPAN class=label><NOBR>Tags:</NOBR> </SPAN></TD>
<TD><INPUT maxLength=120 size=40 name="field_myvideo_keywords" value="{$smarty.request.field_myvideo_keywords}">
<DIV class=formFieldInfo><STRONG>Enter one or more tags, separated
by spaces.</STRONG> <BR>Tags are simply keywords used to describe
your video so they are easily searched and organized. For example,
if you have a surfing video, you might tag it: surfing beach
waves.<BR></DIV></TD>
</TR>
<TR vAlign=top>
<TD align=right><SPAN class=label><NOBR>Video Channels:</NOBR></SPAN></TD>
<TD>
        <TABLE><TBODY><TR><TD vAlign=top>
        {insert name=list_channel assign=chinfo vid=$VID}
        {section name=i loop=$chinfo}
        <INPUT type=checkbox name=chlist[] value={$chinfo[i].id}>{$chinfo[i].ch}<BR>
        {/section}
        </TD></TR></TBODY></TABLE>

<DIV class=formFieldInfo><STRONG>Select between one to three
channels that best describe your video.</STRONG><BR>It helps to use
relevant channels so that others can find your video!</DIV>
</TD>
</TR>
<TR>
<TD align=right> </TD>
<TD><INPUT type=submit value="Continue ->" name=action_upload></TD></TR>
</TBODY></TABLE>
</FORM>

{else}
<table>
<tr>
<td height="24" valign=top align=center><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="5" height="24" background="images/nv_2_l.jpg" valign=top><img src="images/nv_2_l.jpg" width="5" height="24" alt=""></td>
                                    <th background="images/nv_2_bg.jpg" align=left width=760><span class="white_bold" valign=top align=left>Video Upload (Step 2 of 2)</span></th>
                                    <td width="5" background="images/nv_2_r.jpg"><img src="images/nv_2_r.jpg" width="5" height="24" alt=""></td>
                                  </tr>
                              </table></td>

</tr></table>



<FORM id=theForm name=theForm action="{$baseurl}/upload.php" method=post encType=multipart/form-data>
<table width="100%" cellpadding="5" cellspacing="0" border="0">
<tr valign="top">
        <td width="200" align="right"><span class="label">File:</span></td>
        <td><div class="formHighlight"><input type="hidden" name="MAX_FILE_SIZE" value="104857600">
        <input type="file" name="field_uploadfile" size="30">
        <div class="formHighlightText"><strong>Max file size: 100 MB. No copyrighted or obscene material.</strong>
        <br>After uploading, you can edit or remove this video at anytime under the "My Videos" link on the top of the page.</div></div></td>
</tr>
<tr>
        <td align="right"><span class="label">Broadcast:</span></td>
        <td>
        <table cellpadding="1" cellspacing="0" border="0">
        <tr>
                <td><input name="field_privacy" type="radio" value="public" checked></td>
                <td><span class="bold">Public:</span> Share your video with the world! (Recommended)</td>
                </tr>
        </table>
        </td>
        </tr>
        <tr>
        <td align="right"><span class="label"> </span></td>
        <td>
                <table cellpadding="1" cellspacing="0" border="0">
                <tr>
                <td><input name="field_privacy" type="radio" value="private"></td>
                <td><span class="bold">Private:</span> Only viewable by you and those you share the video with.</td>
                </tr>
                </table>
        </td>
        </tr>
        <tr>
                <td colspan="2"> </td>
        </tr>
        <tr>
        <td align="right"> </td>
        <td>
        <span class="bold">PLEASE BE PATIENT, THIS MAY TAKE SEVERAL MINUTES.
                <br>ONCE COMPLETED, YOU WILL SEE A CONFIRMATION MESSAGE.<br><br></span>
                <input type="hidden" name="field_myvideo_keywords" value="{$smarty.request.field_myvideo_keywords}">
                <input type="hidden" name="field_myvideo_title" value="{$smarty.request.field_myvideo_title}">
                <input type="hidden" name="field_myvideo_descr" value="{$smarty.request.field_myvideo_descr}">
                <input type="hidden" name="listch" value="{$listch}">
                <input name="upload_final" type="submit" value="Upload Video" ><!-- onclick='this.disabled = true;' -->
                <span id="hide_stuff" style="display:none;" class="bold">
                <table><tr>
                <td valign=middle> <img  src="{$imgurl}/LoadingGraphic.gif"></img></td><td valign=middle><font size=4>Uploading..</font></td>
                </tr></table>
                </span> </td></tr></table>
</FORM>
{/if}

 

Any help appreciated TY :)

Link to comment
Share on other sites

Define: "wont work". That could laterally mean 32 different things.

 

Unless you tell us what actions you took (browsed to form, filled in information, submitted form...), at what point it appeared to be working and when it did not (does the form display, does the submit button do anything...), and what exactly you see in front of you when you try this (do you get the form, any program produced content and exactly what part of it is there, any php produced error messages, blank screens, content that is in the "view source" in the browser but does not get rendered...), we cannot help you.

 

I guess it must be said - People if you want someone to help you, you must provide them with information you have about what you have done and what you have seen in front of you at each step when you did it.

Link to comment
Share on other sites

Well I simply filled in the first form, submited it, filles in the second form (including the upload part with a flv format file, then submitted page two; it then skipped back to page1 of upload.tpl with no PHP error messages and no page errors...

 

http://itchy.cirtexhosting.com/~nymorcom/index.php

 

login: admin

Pass: admin

 

click upload...

 

TY for any help

Link to comment
Share on other sites

BTW DarkWater TY for making me look like a T**T lol I am self taught and when I say 3 years I mean spending most of my time wagging school to smoke sputnit and getting pissed most nights, in other words, about 6 months actually learning programming (practical not theory) learning from reading, copying, then writing the worst (mafia game) codes ever.

 

P.S. Any writing mistakes are due to the fact I am pissed and stonned now...

Link to comment
Share on other sites

1) I don't care if you're stoned and shitfaced, that's great for you.  Have a blast with your cirrhosis and lung cancer dude.

 

2) $_REQUEST is not secure because it takes a combination of GET, POST, and COOKIES, in that order from highest to least level of order.  So basically you don't know where data is coming from.  You want to use the correct superglobal, $_REQUEST is for lazy programmers.

 

3) You should use ' ' around all keys of an array because it speeds up the application and is guaranteed to work in the future.

Link to comment
Share on other sites

1) I don't care if you're stoned and shitfaced, that's great for you.  Have a blast with your cirrhosis and lung cancer dude.

 

2) $_REQUEST is not secure because it takes a combination of GET, POST, and COOKIES, in that order from highest to least level of order.  So basically you don't know where data is coming from.  You want to use the correct superglobal, $_REQUEST is for lazy programmers.

 

3) You should use ' ' around all keys of an array because it speeds up the application and is guaranteed to work in the future.

 

TY I do that anyway, didn't know why tho TBH; was just what I copied from codes. BTW what is cirrhosis? Like Multiple cirrhosis???

Link to comment
Share on other sites

Cirrhosis is scarring of the liver due to alcoholism or a lot of alcohol intake.  It's also known as "beer belly" because your liver expands as it scars.  You were thinking of Multiple Sclerosis (MS) which is a autoimmune disease that destroys myelin around the axons of neurons.

 

(I'm going into medicine when I grow up. =P)

Link to comment
Share on other sites

Lol, by the sounds of it you could do any job when your older, my dad drinks 1 700cl bottle of whisky a day (since cutting down from 2) and his doctor said he would be dead in 5 years (10 years ago) so how I follow by example and enjoy what I remember of lil while it lasts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.