dokeos
[ class tree: dokeos ] [ index: dokeos ] [ all elements ]

Source for file audiopost.php

Documentation is available at audiopost.php

  1. <?php 
  2. //file_put_contents("result.txt", print_r($_POST, true));
  3. //file_put_contents("result3.txt", print_r($_FILES, true));
  4. //file_put_contents("result2.txt", print_r($_GET, true));
  5. require('../inc/global.inc.php');
  6.  
  7. // check the request comes from our red5 server
  8. $ips gethostbynamel(api_get_setting('service_visio','visio_host'));
  9. $is_our_server false;
  10.  
  11. // ignoring null file
  12. if ($_FILES["file"]["size"== 0)
  13.     exit(0);
  14.  
  15. if(is_array($ips))
  16. {
  17.     foreach($ips as $ip)
  18.     {
  19.         //get 255 range for known server address
  20.         $split split('.',$ip);
  21.         $ip_range_server $split[0].'.'.$split[1].'.'.$split[2];
  22.         //get 255 range for request source address
  23.         $split split('.',$_SERVER['REMOTE_ADDR']);
  24.         $ip_range_request $split[0].'.'.$split[1].'.'.$split[2];
  25.         if($ip_range_server == $ip_range_request){$is_our_server true;}
  26.     }
  27. }
  28. if($is_our_server)
  29. {
  30.     if(api_get_setting('service_visio','active')=='true')
  31.     {
  32.         //check encryption key
  33.         $string1 $_GET['course_code'].$_GET['user_id'].gmdate('Ymd').$_configuration['security_key'];
  34.         $string2 $_GET['course_code'].$_GET['user_id'].(gmdate('Ymd')-1).$_configuration['security_key'];
  35.         if(md5($string1== $_GET['checker'or md5($string2== $_GET['checker'])
  36.         {
  37.             $course_info api_get_course_info($_GET['course_code']);
  38.             $target api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/audio/';
  39.             $basename basename$_FILES['file']['name']);
  40.             $target $target $basename ;
  41.             if(!move_uploaded_file($_FILES['file']['tmp_name']$target))
  42.             {
  43.                 error_log(__FILE__.':'.__LINE__.': File upload to '.$target.' failed',0);
  44.             }
  45.             else
  46.             {
  47.                 require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
  48.                 $id add_document($course_info,'/audio/'.$basename,'file',filesize($target),$basename);
  49.                 if($id !== false)
  50.                 {
  51.                     $res api_item_property_update($course_info,TOOL_DOCUMENT,$id,'DocumentAdded',$_GET['user_id']);
  52.                     if($res === false)
  53.                     {
  54.                         error_log(__FILE__.':'.__LINE__.': Something went wrong with item properties update of '.$target,0);                    
  55.                     }
  56.                     else
  57.                     {//make sound invisible?
  58.                         //$res = api_item_property_update($course_info,TOOL_DOCUMENT,$id,'invisible',$_GET['user_id']);
  59.                     }
  60.                 }
  61.                 else
  62.                 {
  63.                     error_log(__FILE__.':'.__LINE__.': Could not create document record for document '.$target,0);                    
  64.                 }
  65.             }
  66.         }
  67.         else
  68.         {
  69.             error_log(__FILE__.':'.__LINE__.': Attempting to save file but hash check did not suceed (hacking attempt?)',0);
  70.         }
  71.     }
  72.     else
  73.     {
  74.         error_log(__FILE__.':'.__LINE__.': Attempting to save file but videoconf is not enabled',0);
  75.     }
  76. }
  77. else
  78. {
  79.     error_log(__FILE__.':'.__LINE__.': Attempting to save file but coming from unknown source',0);
  80. }
  81. ?>

Documentation generated on Thu, 12 Jun 2008 12:59:26 -0500 by phpDocumentor 1.4.1