/**
  * Return the defined server list
  * @param string $localserverlisttext='' List of local server in text
  * @return array of servers
  */
 static function get_server_list($localserverlisttext)
 {
     global $CFG;
     $plugincfg = get_config('mod_vpl');
     $nl_local = vpl_detect_newline($localserverlisttext);
     $nl_global = vpl_detect_newline($plugincfg->jail_servers);
     $tempserverlist = array_merge(explode($nl_local, $localserverlisttext), explode($nl_global, $plugincfg->jail_servers));
     $serverlist = array();
     //Clean temp server list and search for 'end_of_jails'
     foreach ($tempserverlist as $server) {
         $server = trim($server);
         if ($server > '' && $server[0] != '#') {
             if (strtolower($server) == 'end_of_jails') {
                 break;
             } else {
                 $serverlist[] = $server;
             }
         }
     }
     return $serverlist;
 }
예제 #2
0
 function get_detail()
 {
     $ret = '';
     $subf = $this->get_submitted_fgm();
     $filelist = $subf->getFileList();
     foreach ($filelist as $filename) {
         $data = $subf->getFileData($filename);
         if ($ret > '') {
             $ret .= ', ';
         }
         //TODO too slow calculus
         $nl = vpl_detect_newline($data);
         $ret .= $filename . ' ' . strlen($data) . 'b ' . count(explode($nl, $data)) . 'l';
     }
     return $ret;
 }
예제 #3
0
 static function show($filename1, $data1, $HTMLheader1, $filename2, $data2, $HTMLheader2)
 {
     //Get file lines
     $nl = vpl_detect_newline($data1);
     $lines1 = explode($nl, $data1);
     $nl = vpl_detect_newline($data2);
     $lines2 = explode($nl, $data2);
     //Get dif as an array of info
     $diff = self::calculateDiff($lines1, $lines2);
     if ($diff === false) {
         return;
     }
     $separator = array('<' => ' <<< ', '>' => ' >>> ', '=' => ' === ', '#' => ' ### ');
     $emptyline = "&nbsp;\n";
     $data1 = '';
     $data2 = '';
     $datal1 = '';
     $datal2 = '';
     $diffl = '';
     $lines1[-1] = '';
     $lines2[-1] = '';
     foreach ($diff as $line) {
         $diffl .= $separator[$line->type] . "\n";
         if ($line->ln1) {
             $datal1 .= $line->ln1 . " \n";
             $data1 .= $lines1[$line->ln1 - 1] . "\n";
         } else {
             $data1 .= " \n";
             $datal1 .= $emptyline;
         }
         if ($line->ln2) {
             $datal2 .= $line->ln2 . " \n";
             $data2 .= $lines2[$line->ln2 - 1] . "\n";
         } else {
             $data2 .= " \n";
             $datal2 .= $emptyline;
         }
     }
     echo '<div style="width: 100%;min-width: 950px; overflow: auto">';
     //Header
     echo '<div style="float:left; width: 445px">';
     echo $HTMLheader1;
     echo '</div>';
     echo '<div style="float:left; width: 445px">';
     echo $HTMLheader2;
     echo '</div>';
     echo '<div style="clear:both;"></div>';
     //Files
     echo '<div style="float:left; text-align: right">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $datal1;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; width: 390px; overflow:auto">';
     $shower = vpl_sh_factory::get_sh($filename1);
     $shower->print_file($filename1, $data1, false);
     echo '</div>';
     echo '<div style="float:left">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $diffl;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; text-align: right;">';
     echo '<pre class="' . vpl_sh_base::c_general . '">';
     echo $datal2;
     echo '</pre>';
     echo '</div>';
     echo '<div style="float:left; width: 390px; overflow:auto">';
     $shower = vpl_sh_factory::get_sh($filename2);
     $shower->print_file($filename2, $data2, false);
     echo '</div>';
     echo '</div>';
     echo '<div style="clear:both;"></div>';
 }
예제 #4
0
 /**
  * Add watermark to the end of data
  * @param string $data file content
  * @param userid of wm
  * @return string $data with water mark
  */
 static function addwm_generic(&$data, $userid)
 {
     //Check if need water mark
     if (self::getwm($data) == false) {
         $wm = self::genwm($userid);
         $nl = vpl_detect_newline($data);
         $data .= $wm . $nl;
     }
 }