Beispiel #1
0
 /**
  * Parses the files and put it in $uploadData
  *
  * @return string $output | Output messages
  */
 function parseFiles()
 {
     global $roster;
     if (!is_array($_FILES)) {
         return '<span class="red">Upload failed: No files present</span>' . "<br />\n";
     }
     require_once ROSTER_LIB . 'luaparser.php';
     $output = $roster->locale->act['parsing_files'] . "<br />\n<ul>";
     foreach ($_FILES as $file) {
         if (!empty($file['name']) && $this->upload_error_check($file)) {
             $filename = explode('.', $file['name']);
             $filebase = strtolower($filename[0]);
             if (in_array($filebase, $this->files)) {
                 // Get start of parse time
                 $parse_starttime = format_microtime();
                 $luahandler = new lua();
                 $data = $luahandler->luatophp($file['tmp_name'], isset($this->blinds[$filebase]) ? $this->blinds[$filebase] : array());
                 // Calculate parse time
                 $parse_totaltime = round(format_microtime() - $parse_starttime, 2);
                 if ($data) {
                     $output .= '<li>' . sprintf($roster->locale->act['parsed_time'], $filename[0], $parse_totaltime) . "</li>\n";
                     $this->uploadData[$filebase] = $data;
                 } else {
                     $output .= '<li>' . sprintf($roster->locale->act['error_parsed_time'], $filebase, $parse_totaltime) . "</li>\n";
                     $output .= $luahandler->error() != '' ? '<li>' . $luahandler->error() . "</li>\n" : '';
                 }
                 unset($luahandler);
             } else {
                 $output .= '<li>' . sprintf($roster->locale->act['upload_not_accept'], $file['name']) . "</li>\n";
             }
         } else {
             $output .= '<li>' . sprintf($roster->locale->act['error_parsed_time'], $file['name'], '0') . "</li>\n";
         }
     }
     $output .= "</ul><br />\n";
     return $output;
 }