voxforge.org
VoxForge Dev

Changeset 2309

Show
Ignore:
Timestamp:
10/03/07 14:31:09 (1 year ago)
Author:
kmaclean
Message:

updates to server-side scripts for Speech Submission app

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/SpeechSubmission/VFSpeechSubmission/server/SubmitSpeechServer.php

    r2307 r2309  
    11<?php 
    22/* 
    3 The following file enables the uploading of each image from the java applet. 
    43 
    5 PLEASE NOTE, THIS FILES IN ITS PRESENT FORM IS A MASSIVE SECURITY RISK, AND 
    6 SHOULD NOT BE USED WITHOUT DOING EITHER OF THE FOLLOWING: 
     4PHP functions for integrating JSpeex-based voice tools into Moodle. 
     5(c) 2006 Dan Stowell. Released under the GNU Public Licence (GPL). 
    76 
    8 - PROTECTING THE ACCESS OF THE FILE BY THE USE OF SESSION VARIABLES (DO NOT 
    9   PROTECT IT BY USING HTTP PASSWORDS) 
    10 - ENSURING THAT UPLOADED FILES ARE NOT ACCESSIBLE TO THE WEB (UPLOAD FILES 
    11   TO A DIRECTORY ABOVE THE DOCUMENT ROOT) 
     7The Java part of this library uses code from other authors - 
     8see the copyrights.txt for more details. 
     9 
    1210*/ 
    1311 
    14 /* 
    15 AS OF POSTLET 0.11, POSTLET READS THE MESSAGES SENT BACK TO IT, AND NOW 
    16 IS AWARE OF WHETHER OR NOT AN UPLOAD HAS BEEN SUCCESSFUL. MORE INFORMATION 
    17 ABOUT THE FORMAT OF REPLY MESSAGES CAN BE FOUND ON THE POSTLET WEBSITE  
    18 http://www.postlet.com/install/ 
    19 */ 
    2012 
    21 // Configuration --------------------------------------------------------------- 
    22 // Change the below path to the folder where you would like files uploading. 
    23 // e.g. "/home/yourname/myuploads/" 
    24 // or "c:\php\uploads\" 
    25 // Note, this MUST have the trailing slash. 
    26 //$uploaddir = 'public/'; 
    27 $uploaddir = '../public/speechsubmissions/'; 
    28 // Whether or not to allow the upload of specific files 
    29 $allow_or_deny = true; 
    30 // If the above is true, then this states whether the array of files is a list of 
    31 // extensions to ALLOW, or DENY 
    32 $allow_or_deny_method = "allow"; // "allow" or "deny" 
    33 $file_extension_list = array("zip"); 
    34 // ----------------------------------------------------------------------------- 
    35 if ($allow_or_deny){ 
    36         if (($allow_or_deny_method == "allow" && !in_array(strtolower(array_pop(explode('.', $_FILES['userfile']['name']))), $file_extension_list)) 
    37                 || ($allow_or_deny_method == "deny" && in_array(strtolower(array_pop(explode('.', $_FILES['userfile']['name']))), $file_extension_list))){               
    38                 // Atempt to upload a file with a specific extension when NOT allowed. 
    39                 // 403 error 
    40                 header("HTTP/1.1 403 Forbidden"); 
    41                 echo "POSTLET REPLY\r\n"; 
    42                 echo "POSTLET:NO\r\n"; 
    43                 echo "POSTLET:FILE TYPE NOT ALLOWED\r\n"; 
    44                 echo "POSTLET:ABORT THIS\r\n"; // Postlet should NOT send this file again. 
    45                 echo "END POSTLET REPLY\r\n"; 
    46                 exit; 
    47         } 
     13function speex_postlet_applet($destination, $endpage,  $codebase, 
     14                $subject='', $filefieldname='userfile', $compressionmode=1, $compressionmodes='1,2,3'){ 
     15  global $CFG; 
     16  $cookie = htmlspecialchars($_SERVER['HTTP_COOKIE']); 
     17  $code =  <<<ENDHTMLFRAGMENT 
     18<applet name="Speexuploader" width ="800" height ="800" mayscript="mayscript" 
     19      code="moodlespeex/MoodleSpeexRecorderApplet.class" style="border: 1px solid rgb(153,153,153);"> 
     20 <param name="codebase"  value="$codebase"/> 
     21 <param name="archive"  value="moodlespeex.jar"/> 
     22 <param name="type"  value="application/x-java-applet;version=1.4"/> 
     23 <param name="scriptable"  value="true"/> 
     24ENDHTMLFRAGMENT; 
     25 if($isforumpost) { 
     26   $code .= '<param name="subject"  value="'.htmlspecialchars($subject).'"/>'; 
     27 } 
     28  $code .=  <<<ENDHTMLFRAGMENT 
     29 <param name="destination" value="$destination"/> 
     30 <param name="filefieldname"  value=" 
     31ENDHTMLFRAGMENT; 
     32  $code .= htmlspecialchars($filefieldname); 
     33  $code .=  <<<ENDHTMLFRAGMENT 
     34"/> 
     35 <param name="endpage"  value="$endpage"/> 
     36 <param name="cookie"  value="$cookie"/> 
     37 <param name="compressionmode"  value="$compressionmode"/> 
     38 <param name="compressionmodes"  value="$compressionmodes"/> 
     39 The VoxForge audio recorder applet should appear here. Please check that you have Java enabled in your web browser - this is 
     40 required in order to use the audio recorder. 
     41 </applet> 
     42ENDHTMLFRAGMENT; 
     43  return $code; 
    4844} 
    49 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir .$_FILES['userfile']['name'])) 
    50 
    51         // All replies MUST start with "POSTLET REPLY", if they don't, then Postlet will 
    52         // not read the reply and will assume the file uploaded successfully. 
    53         echo "POSTLET REPLY\r\n"; 
    54         // "YES" tells Postlet that this file was successfully uploaded. 
    55     echo "POSTLET:YES\r\n"; 
    56         // End the Postlet reply 
    57         echo "END POSTLET REPLY\r\n"; 
    58         exit; 
    59 }  
    60 else 
    61 
    62         // If the file can not be uploaded (most likely due to size), then output the 
    63         // correct error code 
    64         // If $_FILES is EMPTY, or $_FILES['userfile']['error']==1 then TOO LARGE 
    65         if (count($_FILES)==0 || $_FILES['userfile']['error']==1){ 
    66                 // All replies MUST start with "POSTLET REPLY", if they don't, then Postlet will 
    67                 // not read the reply and will assume the file uploaded successfully. 
    68                 header("HTTP/1.1 413 Request Entity Too Large"); 
    69                 echo "POSTLET REPLY\r\n"; 
    70                 echo "POSTLET:NO\r\n"; 
    71                 echo "POSTLET:TOO LARGE\r\n"; 
    72                 echo "POSTLET:ABORT THIS\r\n"; // Postlet should NOT send this file again. 
    73                 echo "END POSTLET REPLY\r\n"; 
    74                 exit; 
    75         } 
    76         // Unable to write the file to the server ALL WILL FAIL 
    77         else if ($_FILES['userfile']['error']==6 || $_FILES['userfile']['error']==7){ 
    78                 // All replies MUST start with "POSTLET REPLY", if they don't, then Postlet will 
    79                 // not read the reply and will assume the file uploaded successfully. 
    80                 header("HTTP/1.1 500 Internal Server Error"); 
    81                 echo "POSTLET REPLY\r\n"; 
    82                 echo "POSTLET:NO\r\n"; 
    83                 echo "POSTLET:SERVER ERROR\r\n"; 
    84                 echo "POSTLET:ABORT ALL\r\n"; // Postlet should NOT send any more files 
    85                 echo "END POSTLET REPLY\r\n"; 
    86                 exit; 
    87         } 
    88         // Unsure of the error here (leaves 2,3,4, which means try again) 
    89         else { 
    90                 // All replies MUST start with "POSTLET REPLY", if they don't, then Postlet will 
    91                 // not read the reply and will assume the file uploaded successfully. 
    92                 header("HTTP/1.1 500 Internal Server Error"); 
    93                 echo "POSTLET REPLY\r\n"; 
    94                 echo "POSTLET:NO\r\n"; 
    95                 echo "POSTLET:UNKNOWN ERROR\r\n"; 
    96                 echo "POSTLET:RETRY\r\n"; 
    97                 print_r($_REQUEST); // Possible usefull for debugging 
    98                 echo "END POSTLET REPLY\r\n"; 
    99                 exit; 
    100         } 
    101 
     45 
     46 
     47 
     48 
    10249?> 
  • Trunk/SpeechSubmission/VFSpeechSubmission/server/SubmitSpeechStart.php

    r2307 r2309  
    11<html> 
    22 
    3 <head> 
    4         <title>VoxForge Speech Submission Application</title> 
    5 </head> 
     3<title>VoxForge Repository</title> 
     4 
     5        <style type="text/css"> 
     6        .siteFunctions { 
     7                text-align: right; 
     8        } 
     9        .copyright { 
     10                test-align: left; 
     11                color: #2E3436; 
     12                font-family: sans-serif; 
     13                font-size: small; 
     14        } 
     15 
     16        body { 
     17                font-family: "DejaVu Sans", "Lucida Sans Unicode", sans-serif; 
     18                font-weight:    normal; 
     19                word-spacing:   normal; 
     20                letter-spacing: normal;  
     21                text-transform: none; 
     22                font-size: medium; 
     23                text-align: justify; 
     24        } 
     25        h2 { 
     26                font-size:      1.5em; 
     27                font-weight:    700; 
     28                margin-top:1em; 
     29                margin-bottom:0.8em; 
     30        } 
     31        h3 { 
     32                font-size:      1.1em; 
     33                font-weight:    600; 
     34                margin-top:1em; 
     35                margin-bottom:0.4em; 
     36        } 
     37        p, ol, ul { 
     38                font-size:      1em; 
     39                margin-top:0.4em; 
     40                margin-bottom:0.4em; 
     41        }        
     42        .heading { 
     43                background-color: #555753; 
     44                color: #D3D7CF; 
     45                font-size: 40px; 
     46                vertical-align: bottom; 
     47        } 
     48        .logo { 
     49                width: 100px;  
     50                float: left; 
     51                text-align: left; 
     52        } 
     53        .logo img { 
     54                border: 0px; 
     55        } 
     56        img { 
     57                border: 0px; 
     58        } 
     59        .clickableicons { 
     60        } 
     61        .endFloat { 
     62                clear: both; 
    663         
     64        } 
     65        .padding { 
     66                padding: 10px; 
     67        } 
     68        .bodyContent { 
     69                background-color: #ffffff; 
     70                color: #2E3436; 
     71                text-align: justify; 
     72        } 
     73        .menu { 
     74                color: #D3D7CF; 
     75                background-color: #555753; 
     76                text-align: left; 
     77        } 
     78 
     79        .menu2 { 
     80                color: #D3D7CF; 
     81                background-color: #555753; 
     82                text-align: center; 
     83                 
     84        } 
     85        a { 
     86                color: #f57900; 
     87                text-decoration:none; 
     88        } 
     89        a:visited { 
     90                color: #ce5c00; 
     91        } 
     92        a:hover { 
     93                text-decoration:underline; 
     94        } 
     95        .menu a { 
     96                color: #D3D7CF; 
     97                font-weight: bold;  
     98        } 
     99        .menu a:hover { 
     100                color: #eeeeec; 
     101                text-decoration:none; 
     102        } 
     103 
     104        </style> 
     105</head><body> 
     106 
     107 
     108 
     109<div class="heading"> 
     110<div class="padding"> 
     111<div class="logo"><a href="http://www.voxforge.org"><img src="http://www.voxforge.org/uploads/CQ/vE/CQvEzFYe85HH5hkI705eXQ/voxforge-logo.jpg" alt="VoxForge Repository"> </a></div>  
     112 
     113<div class="endFloat"></div> 
     114 
     115</div> 
     116</div> 
     117 
     118<div class="menu"> 
     119        <div class="padding">            
     120                 
     121                 
     122<span class="horizontalMenu"> 
     123 
     124<a class="horizontalMenu" href="http://www.voxforge.org/home">Home</a> 
     125    &middot;  
     126 
     127<a class="horizontalMenu" href="http://www.voxforge.org/home/read">Read</a> 
     128    &middot;  
     129 
     130<a class="horizontalMenu" href="http://www.voxforge.org/home/listen">Listen</a> 
     131    &middot;  
     132 
     133<a class="horizontalMenu" href="http://www.voxforge.org/home/audiobooks">AudioBooks</a> 
     134    &middot;  
     135 
     136<a class="horizontalMenu" href="http://www.voxforge.org/home/forums">Forums</a> 
     137    &middot;  
     138 
     139<a class="horizontalMenu" href="http://www.voxforge.org/home/dev">Dev</a> 
     140 
     141    &middot;  
     142 
     143<a class="horizontalMenu" href="http://www.voxforge.org/home/downloads">Downloads</a> 
     144    &middot;  
     145 
     146<a class="horizontalMenu" href="http://www.voxforge.org/home/about">About</a> 
     147  
     148 
     149   
     150 
     151</span></div> 
     152 
     153</div> 
     154 
     155 
     156 
     157</div> 
     158 
    7159<body> 
    8160 
    9161<?php 
    10 require_once('NewSubmitSpeechServer.php'); 
     162require_once('SubmitSpeechServer.php'); 
    11163 
    12164echo speex_postlet_applet( 
     165'http://www.repository.voxforge1.org/SubmitSpeech/javaUploadServer.php',  
     166'http://www.repository.voxforge1.org/SubmitSpeech/endpage.php', 
     167'http://www.repository.voxforge1.org/SubmitSpeech' 
     168     ); 
     169 
     170?> 
     171 
     172 
     173<br><br> 
     174<div class="copyright">&#169; 2005-2007 VoxForge; Legal: <a href="http://www.voxforge.org/home/about/legal">Terms and Conditions</a></div> 
     175</body> 
     176 
     177<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> 
     178</script> 
     179<script type="text/javascript"> 
     180_uacct = "UA-1183615-5"; 
     181urchinTracker(); 
     182</script> 
     183</html> 
     184 
     185 
     186let( 
    13187'http://www.repository.voxforge1.org/SubmitSpeech/javaUploadServer.php',  
    14188'http://www.repository.voxforge1.org/SubmitSpeech/endpage.php',