Ejemplo n.º 1
0
 /**
 * Documentation for this function.
 */
 function onMakeFinalPDB()
 {
     $context = getContext();
     $newModel = $_SESSION['models'][$context['newModel']];
     $oldModel = $_SESSION['models'][$newModel['parent']];
     $newPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     $oldPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb'];
     $url = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     // Put our money where our mouth is and calculate that new PDB file
     $all_changes = $context['sswingChanges'];
     $usercnit = $_REQUEST['cnit'];
     // Remove changes for residues that weren't selected
     foreach ($all_changes as $k => $v) {
         $res = substr($k, 0, 9);
         if (!isset($usercnit[$res])) {
             unset($all_changes[$k]);
         } else {
             $changed_res[$res] = $res;
         }
         // used below for the lab notebook
     }
     // Make PDB file
     pdbSwapCoords($oldPDB, $newPDB, $all_changes);
     // Make up the lab notebook entry
     $text = "The following residues were automatically refit by SSWING, creating {$newModel['pdb']} from {$oldModel['pdb']}:\n<ul>\n";
     foreach ($changed_res as $res) {
         $text .= "<li>{$res}</li>\n";
     }
     $text .= "</ul>\n";
     $text .= "<p>You can now <a href='{$url}'>download the optimized and annotated PDB file</a> (" . formatFilesize(filesize($newPDB)) . ").</p>\n";
     $entryNum = addLabbookEntry("Refit sidechains with SSWING to get {$newModel['pdb']}", $text, "{$oldModel['id']}|{$newModel['id']}", 'auto');
     $ctx = array('labbookEntry' => $entryNum);
     pageGoto("generic_done.php", $ctx);
 }
Ejemplo n.º 2
0
 public function handle($path, Application $app)
 {
     $files = array();
     $folders = array();
     $list = $this->filesystem->listContents($path);
     $ignored = array(".", "..", ".DS_Store", ".gitignore", ".htaccess");
     foreach ($list as $entry) {
         if (in_array($entry['basename'], $ignored)) {
             continue;
         }
         $fullfilename = $this->filesystem->getAdapter()->applyPathPrefix($entry['path']);
         if (!$app['filepermissions']->authorized(realpath($fullfilename))) {
             continue;
         }
         if ($entry['type'] === 'file') {
             try {
                 $url = $this->filesystem->url($entry['path']);
             } catch (\Exception $e) {
                 $url = $entry['path'];
             }
             // Ugh, for some reason the foldername for the theme is included twice. Why?
             // For now we 'fix' this with an ugly hack, replacing it. :-/
             // TODO: dig into Filesystem and figure out why this happens.
             $pathsegments = explode('/', $entry['path']);
             if (!empty($pathsegments[0])) {
                 $url = str_replace('/' . $pathsegments[0] . '/' . $pathsegments[0] . '/', '/' . $pathsegments[0] . '/', $url);
             }
             $files[$entry['path']] = array('path' => $entry['dirname'], 'filename' => $entry['basename'], 'newpath' => $entry['path'], 'relativepath' => $entry['path'], 'writable' => true, 'readable' => false, 'type' => isset($entry['extension']) ? $entry['extension'] : '', 'filesize' => formatFilesize($entry['size']), 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'permissions' => 'public', 'url' => $url);
             /***** Extra checks for files that can be resolved via PHP urlopen functions *****/
             try {
                 $files[$entry['path']]['permissions'] = $this->filesystem->getVisibility($entry['path']);
             } catch (\Exception $e) {
             }
             if (is_readable($fullfilename)) {
                 $files[$entry['path']]['readable'] = true;
                 if (!empty($entry['extension']) && in_array($entry['extension'], array('gif', 'jpg', 'png', 'jpeg'))) {
                     $size = getimagesize($fullfilename);
                     $files[$entry['path']]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
                 }
                 $files[$entry['path']]['permissions'] = \utilphp\util::full_permissions($fullfilename);
             }
         }
         if ($entry['type'] == 'dir') {
             $folders[$entry['path']] = array('path' => $entry['dirname'], 'foldername' => $entry['basename'], 'newpath' => $entry['path'], 'modified' => date("Y/m/d H:i:s", $entry['timestamp']), 'writable' => true);
             /***** Extra checks for files that can be resolved via PHP urlopen functions *****/
             if (is_readable($fullfilename)) {
                 if (!is_writable($fullfilename)) {
                     $folders[$entry['path']]['writable'] = false;
                 }
             }
         }
     }
     ksort($files);
     ksort($folders);
     return array($files, $folders);
 }
Ejemplo n.º 3
0
 function displayMap($context)
 {
     echo $this->pageHeader("Map {$context['mapName']} added");
     echo "<p>The following electron density maps are now available:\n";
     echo "<ul>\n";
     foreach ($_SESSION['edmaps'] as $map) {
         $mapPath = "{$_SESSION['dataDir']}/" . MP_DIR_EDMAPS . "/{$map}";
         echo "<li><b>{$map}</b> (" . formatFilesize(filesize($mapPath)) . ")</li>\n";
     }
     echo "</ul>\n</p>\n";
     echo "<p>" . makeEventForm("onReturn");
     echo "<input type='submit' name='cmd' value='Continue &gt;'>\n</form></p>\n";
     echo $this->pageFooter();
 }
Ejemplo n.º 4
0
 public function files($path, Silex\Application $app, Request $request)
 {
     $files = array();
     $folders = array();
     $basefolder = BOLT_WEB_DIR . "/";
     $path = stripTrailingSlash(str_replace("..", "", $path));
     $currentfolder = realpath($basefolder . $path);
     if (!$app['filepermissions']->authorized($currentfolder)) {
         $error = __("Display the file or directory '%s' is forbidden.", array('%s' => $path));
         $app->abort(403, $error);
     }
     if (is_writable($currentfolder)) {
         // Define the "Upload here" form.
         $form = $app['form.factory']->createBuilder('form')->add('FileUpload', 'file', array('label' => __("Upload a file to this folder:")))->getForm();
         // Handle the upload.
         if ($request->isMethod('POST')) {
             $form->bind($request);
             if ($form->isValid()) {
                 $files = $request->files->get($form->getName());
                 // Check if we even have an uploaded file.
                 if (isset($files['FileUpload'])) {
                     // clean up and validate filename
                     $originalFilename = $files['FileUpload']->getClientOriginalName();
                     $filename = preg_replace('/[^a-zA-Z0-9_\\.]/', '_', basename($originalFilename));
                     if ($app['filepermissions']->allowedUpload($filename)) {
                         $files['FileUpload']->move($currentfolder, $filename);
                         $app['session']->getFlashBag()->set('info', __("File '%file%' was uploaded successfully.", array('%file%' => $filename)));
                         // Add the file to our stack..
                         $app['stack']->add($path . "/" . $filename);
                     } else {
                         $extensionList = array();
                         foreach ($app['filepermissions']->getAllowedUploadExtensions() as $extension) {
                             $extensionList[] = '<code>.' . htmlspecialchars($extension, ENT_QUOTES) . '</code>';
                         }
                         $extensionList = implode(' ', $extensionList);
                         $app['session']->getFlashBag()->set('error', __("File '%file%' could not be uploaded (wrong/disallowed file type). Make sure the file extension is one of the following: ", array('%file%' => $filename)) . $extensionList);
                     }
                 }
             } else {
                 $app['session']->getFlashBag()->set('error', __("File '%file%' could not be uploaded.", array('%file%' => $filename)));
             }
             return redirect('files', array('path' => $path));
         }
         $formview = $form->createView();
     } else {
         // Folder not writable, don't show an upload.
         $formview = false;
     }
     $ignored = array(".", "..", ".DS_Store", ".gitignore", ".htaccess");
     // Get the pathsegments, so we can show the path..
     $pathsegments = array();
     $cumulative = "";
     if (!empty($path)) {
         foreach (explode("/", $path) as $segment) {
             $cumulative .= $segment . "/";
             $pathsegments[$cumulative] = $segment;
         }
     }
     if (file_exists($currentfolder)) {
         $d = dir($currentfolder);
         while (false !== ($entry = $d->read())) {
             if (in_array($entry, $ignored)) {
                 continue;
             }
             $fullfilename = $currentfolder . "/" . $entry;
             if (!$app['filepermissions']->authorized(realpath($fullfilename))) {
                 continue;
             }
             if (is_file($fullfilename)) {
                 $files[$entry] = array('path' => $path, 'filename' => $entry, 'newpath' => $path . "/" . $entry, 'writable' => is_writable($fullfilename), 'readable' => is_readable($fullfilename), 'type' => getExtension($entry), 'filesize' => formatFilesize(filesize($fullfilename)), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)), 'permissions' => \util::full_permissions($fullfilename));
                 if (in_array(getExtension($entry), array('gif', 'jpg', 'png', 'jpeg'))) {
                     $size = getimagesize($fullfilename);
                     $files[$entry]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
                 }
             }
             if (is_dir($fullfilename)) {
                 $folders[$entry] = array('path' => $path, 'foldername' => $entry, 'newpath' => $path . "/" . $entry, 'writable' => is_writable($fullfilename), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)));
             }
         }
         $d->close();
     } else {
         $app['session']->getFlashBag()->set('error', __("Folder '%s' could not be found, or is not readable.", array('%s' => $path)));
     }
     $app['twig']->addGlobal('title', __("Files in %s", array('%s' => $path)));
     // Make sure the files and folders are sorted properly.
     ksort($files);
     ksort($folders);
     // Select the correct template to render this. If we've got 'CKEditor' in the title, it's a dialog
     // from CKeditor to insert a file..
     if (!$request->query->has('CKEditor')) {
         $twig = 'files.twig';
     } else {
         $twig = 'files_ck.twig';
     }
     return $app['render']->render($twig, array('path' => $path, 'files' => $files, 'folders' => $folders, 'pathsegments' => $pathsegments, 'form' => $formview));
 }
Ejemplo n.º 5
0
	$content = serialize($data);

	viscacha_header('Content-Type: text/plain');
	viscacha_header('Content-Length: '.strlen($content));
	viscacha_header('Content-Disposition: attachment; filename="'.$data['bbcodetag'].'.bbc"');

	print($content);
}
elseif ($job == 'custombb_import') {
	echo head();
	?>
<form name="form2" method="post" enctype="multipart/form-data" action="admin.php?action=bbcodes&job=custombb_import2">
 <table class="border" cellpadding="4" cellspacing="0" border="0">
  <tr><td class="obox" colspan="2">Import a new Design</td></tr>
  <tr><td class="mbox"><em>Either</em> upload a file:<br /><span class="stext">Allowed file types: .bbc - Maximum file size: <?php echo formatFilesize(1024*250); ?></span></td>
  <td class="mbox"><input type="file" name="upload" size="40" /></td></tr>
  <tr><td class="mbox"><em>or</em> select a file from the server:<br /><span class="stext">Path starting from the Viscacha-root-directory: <?php echo $config['fpath']; ?></span></td>
  <td class="mbox"><input type="text" name="server" size="50" /></td></tr>
  <tr><td class="mbox">Delete file after import:</td>
  <td class="mbox"><input type="checkbox" name="delete" value="1" checked="checked" /></td></tr>
  <tr><td class="ubox" colspan="2" align="center"><input accesskey="s" type="submit" value="Import" /></td></tr>
 </table>
</form>
	<?php
	echo foot();
}
elseif ($job == 'custombb_import2') {

	$dir = $gpc->get('dir', int);
	$server = $gpc->get('server', none);
Ejemplo n.º 6
0
 /**
  * Gets the correct error message.
  *
  * Methoed tries to use $lang-Object. If not available, hardcoded english phrases will be used.
  *
  * @return	string		error message
  */
 function get_error()
 {
     if ($this->error == null) {
         return false;
     }
     $lang = new lang();
     $lang->group("classes");
     switch ($this->error) {
         case UPLOAD_ERR_FILE_INDEX:
             $message = $lang->phrase('upload_error_noupload');
             break;
         case UPLOAD_ERR_FILE_SIZE:
             $lang->assign('mfs', formatFilesize($this->max_filesize));
             $message = $lang->phrase('upload_error_maxfilesize');
             break;
         case UPLOAD_ERR_IMAGE_WIDTH:
         case UPLOAD_ERR_IMAGE_HEIGHT:
             $lang->assign('mih', $this->max_image_height > 0 ? numbers($this->max_image_height) : $lang->phrase('upload_unspecified'));
             $lang->assign('miw', $this->max_image_width > 0 ? numbers($this->max_image_width) : $lang->phrase('upload_unspecified'));
             $message = $lang->phrase('upload_error_maximagesize');
             break;
         case UPLOAD_ERR_FILE_TYPE:
             $lang->assign('aft', implode(', ', $this->file_types));
             $message = $lang->phrase('upload_error_wrongfiletype');
             break;
         case UPLOAD_ERR_COPY:
             $message = $lang->phrase('upload_error_noaccess');
             break;
         case UPLOAD_ERR_FILE_EXISTS:
             $message = $lang->phrase('upload_error_fileexists');
             break;
         default:
             $message = $lang->phrase('upload_error_default');
     }
     if (!empty($this->file['name'])) {
         return "{$this->file['name']}: {$message}";
     } else {
         return $message;
     }
 }
Ejemplo n.º 7
0
   <td class="mbox"><a class="button" href="admin.php?action=misc&amp;job=cache_delete_plugins"><?php 
    echo $lang->phrase('admin_misc_delete_cache');
    ?>
</a></td>
  </tr>
  <?php 
    foreach ($result as $name => $row) {
        $age = fileAge($row['age']);
        ?>
  <tr>
   <td class="mbox"><?php 
        echo $name;
        ?>
</td>
   <td class="mbox" nowrap="nowrap" align="right"><?php 
        echo iif($row['cached'], formatFilesize($row['size']), '-');
        ?>
</td>
   <td class="mbox" nowrap="nowrap"><?php 
        echo iif($row['cached'], $lang->phrase('admin_misc_approx_x'), '-');
        ?>
</td>
   <td class="mbox">
   <?php 
        if ($row['cached']) {
            ?>
   <a class="button" href="admin.php?action=misc&amp;job=cache_view&amp;file=<?php 
            echo $name;
            ?>
"><?php 
            echo $lang->phrase('admin_misc_view_contents');
Ejemplo n.º 8
0
            echo "</tr>\n";
            $color == MP_TABLE_ALT1 ? $color = MP_TABLE_ALT2 : ($color = MP_TABLE_ALT1);
        }
        $sublog = new LogIter($time_range['start'], $time_range['end']);
        $active_sessions = $sublog->uniqueSessions;
        $actions =& $sublog->actions;
        $unique_actions =& $sublog->uniqueActions;
        echo "  <tr align='right' bgcolor='{$color}'><td align='left'>{$time_range['range_text']}</td>";
        echo "<td>" . $sublog->uniqueIPs . "</td>";
        foreach ($detail_actions as $action) {
            echo "<td>" . $actions[$action];
            if ($show_action_pct && $actions[$action] && $active_sessions) {
                echo " (" . round(100.0 * $unique_actions[$action] / $active_sessions) . "%)";
            }
            echo "</td>";
        }
        echo "</tr>\n";
        $color == MP_TABLE_ALT1 ? $color = MP_TABLE_ALT2 : ($color = MP_TABLE_ALT1);
    }
    echo "</table></p>\n";
}
echo "</form>\n";
echo "<hr>\n<small><center>Time elapsed: " . (time() - $exec_time) . " sec";
if (function_exists('memory_get_usage')) {
    echo " | Memory usage: " . formatFilesize(memory_get_usage()) . " / " . ini_get('memory_limit');
}
echo "</center></small>\n";
?>
</body>
</html>
Ejemplo n.º 9
0
    echo "<table width=100%>\n";
    echo "<tr>\n";
    echo "<td><b>Session ID</b></td>\n";
    echo "<td><a href='" . basename($_SERVER['PHP_SELF']) . "?sort=last'><b>Last touched</b></a></td>\n";
    echo "<td><a href='" . basename($_SERVER['PHP_SELF']) . "?sort=ttl'><b>Time to live</b></a></td>\n";
    echo "<td><a href='" . basename($_SERVER['PHP_SELF']) . "?sort=size'><b>Size on disk</b></a></td>\n";
    echo "<td><!-- space for Debug cmd --></td>\n";
    echo "<td><!-- space for Enter cmd --></td>\n";
    echo "<td><!-- space for Destroy cmd --></td>\n";
    echo "</tr>\n";
    foreach ($sessList as $sess) {
        echo "<tr>\n";
        echo "<td>{$sess['id']}</td>\n";
        echo "<td>" . formatMinutesElapsed(time() - $sess['last']) . " ago</td>\n";
        echo "<td>" . formatHoursElapsed($sess['ttl']) . "</td>\n";
        echo "<td>" . formatFilesize($sess['size']) . "</td>\n";
        echo "<td><a href='../viewdebug.php?" . MP_SESSION_NAME . "={$sess['id']}' target='_blank'>Debug</a></td>\n";
        echo "<td><a href='../index.php?" . MP_SESSION_NAME . "={$sess['id']}'>Enter</a></td>\n";
        // We use basename() to get "index.php" instead of the full path,
        // which is subject to corruption with URL forwarding thru kinemage.
        echo "<td><a href='" . basename($_SERVER['PHP_SELF']) . "?cmd=Destroy&target={$sess['id']}'>Destroy</a></td>\n";
        echo "</tr>\n";
    }
    echo "</table>\n";
} else {
    echo "<center><i>No live sessions found on disk.</i></center>\n";
}
?>
</body>
</html>
Ejemplo n.º 10
0
runJiffiloop($pdb, $pdbPrefix, $fragfiller_args);
//reduceNoBuild($pdb, $outpath);
setProgress($tasks, 'notebook');
//$kinout = $_SESSION['dataDir'].'/'.MP_DIR_MODELS.'/'.$kinpath;
//$kinurl = $_SESSION['dataURL'].'/'.MP_DIR_MODELS.'/'.$kinpath;
// have to scan MP_DIR_MODELS directory for all outputted loop files.
$gapCount = 0;
$pdbFiles = listDir($pdbDir);
$pdbEntries = "<p>You can now use the following links to download multi-model PDB files for each filled gap.</p>\n";
foreach ($pdbFiles as $pdbName) {
    //echo "For $pdbName\n";
    if (preg_match("/" . $modelID . ".*\\.[0-9]*-[0-9]*\\.pdb/", $pdbName)) {
        //echo "Found $pdbName\n";
        $filledPdbFile = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $pdbName;
        $pdburl = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $pdbName;
        $pdbEntries .= "<p>File <a href='{$pdburl}'>{$pdbName}</a> (" . formatFilesize(filesize($filledPdbFile)) . ").</p>\n";
        $gapCount += 1;
    } else {
        if (preg_match("/.kin/", $pdbName)) {
            // because JiffiLoop puts all output files in one directory, this moves the output kin to the kin directory.
            //echo "kin file name: ".$pdbName."\n";
            $origKinFile = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $pdbName;
            $newKinFile = $kinDir . '/' . $pdbName;
            rename($origKinFile, $newKinFile);
            $jiffiKin = $pdbName;
        }
    }
}
//$pdbout = $_SESSION['dataDir'].'/'.MP_DIR_MODELS.'/'.$pdbpath;
//$pdburl = $_SESSION['dataURL'].'/'.MP_DIR_MODELS.'/'.$pdbpath;
$entry = "Jiffiloop was run on {$model['pdb']}; {$gapCount} JiffiLoop PDB files were found. If there are no files shown here, JiffiLoop likely crashed; please contact the developers.\n";
Ejemplo n.º 11
0
 function makeFileCommands($path, $url)
 {
     $s = '';
     $s .= "<td><small>" . formatFilesize(filesize($path)) . "</small></td>";
     $lcPath = strtolower($path);
     // Kinemages
     if (endsWith($lcPath, ".kin")) {
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=plain' target='_blank'>plain text</a></small></td>";
         $s .= "<td></td>";
         //$s .= "<td><small><a href='viewtext.php?$_SESSION[sessTag]&file=$path&mode=kin' target='_blank'>highlighted</a></small></td>";
         $s .= "<td><small><a href='viewking.php?{$_SESSION['sessTag']}&url={$url}' target='_blank'>in KiNG</a></small></td>";
     } elseif (endsWith($lcPath, ".kin.gz")) {
         $s .= "<td></td>";
         $s .= "<td><small><a href='viewking.php?{$_SESSION['sessTag']}&url={$url}' target='_blank'>in KiNG</a></small></td>";
         $s .= "<td></td>";
     } elseif (endsWith($path, "H.pdb")) {
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=plain' target='_blank'>plain text</a></small></td>";
         $s .= "<td><small><a href='download_trimmed.php?{$_SESSION['sessTag']}&file={$path}'>without H</a></small></td>";
         $s .= "<td><small><a href='viewpdbking.php?{$_SESSION['sessTag']}&url={$url}' target='_blank'>in KiNG</a></small></td>";
     } elseif (endsWith($path, ".pdb")) {
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=plain' target='_blank'>plain text</a></small></td>";
         $s .= "<td></td>";
         $s .= "<td><small><a href='viewpdbking.php?{$_SESSION['sessTag']}&url={$url}' target='_blank'>in KiNG</a></small></td>";
     } elseif (endsWith($lcPath, ".table")) {
         $s .= "<td></td>";
         $s .= "<td><small><a href='viewtable.php?{$_SESSION['sessTag']}&file={$path}' target='_blank'>as table</a></small></td>";
         $s .= "<td></td>";
     } elseif (endsWith($lcPath, ".html")) {
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=plain' target='_blank'>plain text</a></small></td>";
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=html' target='_blank'>as HTML</a></small></td>";
         $s .= "<td></td>";
     } elseif (endsWith($lcPath, ".pdf")) {
         $s .= "<td></td>";
         $s .= "<td></td>";
         $s .= "<td></td>";
     } elseif (endsWith($lcPath, ".gz") || endsWith($lcPath, ".tgz") || endsWith($lcPath, ".zip")) {
         $s .= "<td></td>";
         $s .= "<td></td>";
         $s .= "<td></td>";
     } else {
         $s .= "<td><small><a href='viewtext.php?{$_SESSION['sessTag']}&file={$path}&mode=plain' target='_blank'>plain text</a></small></td>";
         $s .= "<td></td>";
         $s .= "<td></td>";
     }
     $s .= "<td align='right'><small><a href='{$url}'><img src='img/download.gif'> Download</a></small></td>";
     return $s;
 }
Ejemplo n.º 12
0
 public function files($path, Silex\Application $app, Request $request)
 {
     $files = array();
     $folders = array();
     $basefolder = __DIR__ . "/../../../../";
     $path = stripTrailingSlash(str_replace("..", "", $path));
     $currentfolder = realpath($basefolder . $path);
     if (is_writable($currentfolder)) {
         // Define the "Upload here" form.
         $form = $app['form.factory']->createBuilder('form')->add('FileUpload', 'file', array('label' => __("Upload a file to this folder:")))->getForm();
         // Handle the upload.
         if ($request->isMethod('POST')) {
             $form->bind($request);
             if ($form->isValid()) {
                 $files = $request->files->get($form->getName());
                 /* Make sure that Upload Directory is properly configured and writable */
                 $filename = $files['FileUpload']->getClientOriginalName();
                 $files['FileUpload']->move($currentfolder, $filename);
                 echo "path: {$path}";
                 $app['session']->getFlashBag()->set('info', __("File '%file%' was uploaded successfully.", array('%file%' => $filename)));
                 // Add the file to our stack..
                 $app['stack']->add($path . "/" . $filename);
             } else {
                 $app['session']->getFlashBag()->set('error', __("File '%file%' could not be uploaded.", array('%file%' => $filename)));
             }
             return redirect('files', array('path' => $path));
         }
         $formview = $form->createView();
     } else {
         // Folder not writable, don't show an upload.
         $formview = false;
     }
     $ignored = array(".", "..", ".DS_Store", ".gitignore", ".htaccess");
     // Get the pathsegments, so we can show the path..
     $pathsegments = array();
     $cumulative = "";
     if (!empty($path)) {
         foreach (explode("/", $path) as $segment) {
             $cumulative .= $segment . "/";
             $pathsegments[$cumulative] = $segment;
         }
     }
     if (file_exists($currentfolder)) {
         $d = dir($currentfolder);
         while (false !== ($entry = $d->read())) {
             if (in_array($entry, $ignored)) {
                 continue;
             }
             $fullfilename = $currentfolder . "/" . $entry;
             if (is_file($fullfilename)) {
                 $files[$entry] = array('path' => $path, 'filename' => $entry, 'newpath' => $path . "/" . $entry, 'writable' => is_writable($fullfilename), 'readable' => is_readable($fullfilename), 'type' => getExtension($entry), 'filesize' => formatFilesize(filesize($fullfilename)), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)), 'permissions' => \util::full_permissions($fullfilename));
                 if (in_array(getExtension($entry), array('gif', 'jpg', 'png', 'jpeg'))) {
                     $size = getimagesize($fullfilename);
                     $files[$entry]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
                 }
             }
             if (is_dir($fullfilename)) {
                 $folders[$entry] = array('path' => $path, 'foldername' => $entry, 'newpath' => $path . "/" . $entry, 'writable' => is_writable($fullfilename), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)));
             }
         }
         $d->close();
     } else {
         $app['session']->getFlashBag()->set('error', __("Folder '%s' could not be found, or is not readable.", array('%s' => $path)));
     }
     $app['twig']->addGlobal('title', __("Files in %s", array('%s' => $path)));
     // Make sure the files and folders are sorted properly.
     ksort($files);
     ksort($folders);
     // Select the correct template to render this. If we've got 'CKEditor' in the title, it's a dialog
     // from CKeditor to insert a file..
     if (!$request->query->has('CKEditor')) {
         $twig = 'files.twig';
     } else {
         $twig = 'files_ck.twig';
     }
     return $app['render']->render($twig, array('path' => $path, 'files' => $files, 'folders' => $folders, 'pathsegments' => $pathsegments, 'form' => $formview));
 }
Ejemplo n.º 13
0
 /**
  * Ajax helper function to facilitate the selection of files from the images/
  * folder.
  *
  */
 public static function ext_fileSelector()
 {
     global $PIVOTX;
     $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
     $path = $PIVOTX['paths']['upload_base_path'];
     $url = $PIVOTX['paths']['upload_base_url'];
     if (empty($path) || empty($url)) {
         echo "Can't continue: paths not set..";
         die;
     }
     $breadcrumbs = array("<a href='#' onclick=\"fileSelectorChangefolder('')\">" . basename($path) . "</a>");
     if (!empty($_POST['folder'])) {
         $folder = fixPath($_POST['folder']) . "/";
         $path .= $folder;
         $url .= $folder;
         $incrementalpath = "";
         foreach (explode("/", $folder) as $item) {
             if (!empty($item)) {
                 $incrementalpath = $incrementalpath . $item . "/";
                 $breadcrumbs[] = sprintf("<a href='#' onclick=\"fileSelectorChangefolder('%s')\">%s</a>", $incrementalpath, $item);
             }
         }
     }
     $breadcrumbs = implode(" &raquo; ", $breadcrumbs);
     $files = array();
     $folders = array();
     $d = dir($path);
     while (false !== ($filename = $d->read())) {
         if (strpos($filename, '.thumb.') !== false || strpos($filename, '._') !== false || $filename == ".DS_Store" || $filename == "Thumbs.db" || $filename == "." || $filename == ".." || $filename == ".svn") {
             // Skip this one..
             continue;
         }
         if (is_file($path . $filename)) {
             $files[$filename]['link'] = $url . urlencode($filename);
             $files[$filename]['name'] = trimText($filename, 50);
             $ext = strtolower(getExtension($filename));
             $files[$filename]['ext'] = $ext;
             $files[$filename]['bytesize'] = filesize($path . "/" . $filename);
             $files[$filename]['size'] = formatFilesize($files[$filename]['bytesize']);
             if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png'))) {
                 $dim = getimagesize($path . "/" . $filename);
                 $files[$filename]['dimension'] = sprintf('%s &#215; %s', $dim[0], $dim[1]);
                 $files[$filename]['image_type'] = $ext;
             }
             $files[$filename]['path'] = $folder . $filename;
         }
         if (is_dir($path . $filename)) {
             $folders[$filename] = array('link' => $url . urlencode($filename), 'name' => trimText($filename, 50), 'path' => $folder . $filename);
         }
     }
     $d->close();
     ksort($folders);
     ksort($files);
     echo "<div id='fileselector'>";
     printf("<p><strong>%s:</strong> %s </p>", __("Current path"), $breadcrumbs);
     foreach ($folders as $folder) {
         printf("<div class='folder'><a href='#' onclick=\"fileSelectorChangefolder('%s'); return false;\">%s</a></div>", addslashes($folder['path']), $folder['name']);
     }
     foreach ($files as $file) {
         if ($PIVOTX['config']->get('fileselector_thumbs') && !empty($file['image_type'])) {
             $height = getDefault($PIVOTX['config']->get('fileselector_thumbs_height'), 40);
             $link_text = sprintf("<img src='%sincludes/timthumb.php?h=%s&amp;src=%s' alt='%s' title='%s'>", $PIVOTX['paths']['pivotx_url'], $height, $file['path'], $file['name'], $file['name']);
             $extra_style = "style='height: {$height}px; margin-bottom: 5px;'";
         } else {
             $link_text = $file['name'];
             $extra_style = "";
         }
         printf("<div class='file' {$extra_style}><a href='#' onclick=\"fileSelectorChoose('%s'); return false;\">%s</a> <span>(%s%s)</span></div>", addslashes($file['path']), $link_text, $file['size'], !empty($file['dimension']) ? " - " . $file['dimension'] . " px" : "");
     }
     echo "</div>";
     //echo "<pre>\n"; print_r($folders); echo "</pre>";
     //echo "<pre>\n"; print_r($files); echo "</pre>";
 }
Ejemplo n.º 14
0
    $newModel['history'] = "Derived from {$model['pdb']} by Reduce -nobuild9999 -nuclear";
}
$newModel['isUserSupplied'] = $model['isUserSupplied'];
$newModel['isReduced'] = true;
$_SESSION['models'][$newModel['id']] = $newModel;
$_SESSION['bgjob']['modelID'] = $newModel['id'];
$_SESSION['lastUsedModelID'] = $newModel['id'];
// this is now the current model
$hcount = countReduceChanges($outpath);
setProgress($tasks, 'notebook');
$pdb = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $outname;
$url = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $outname;
$entry = "Reduce was run on {$model['pdb']} to add and optimize missing hydrogens, resulting in {$newModel['pdb']}.\n";
if ($hcount) {
    $entry .= "{$hcount['found']} hydrogens were found in the original model, and {$hcount['add']} hydrogens were added.\n";
    if ($hcount['std']) {
        $entry .= "{$hcount['std']} H were repositioned to standardize bond lengths.\n";
    }
    if ($hcount['adj']) {
        $entry .= "The positions of {$hcount['adj']} hydrogens were adjusted to optimize H-bonding.\n";
    }
}
$entry .= "Asn/Gln/His flips were not optimized.\n";
$entry .= "<p>You can now <a href='{$url}'>download the annotated PDB file</a> (" . formatFilesize(filesize($pdb)) . ").</p>\n";
$_SESSION['bgjob']['labbookEntry'] = addLabbookEntry("Added H with -nobuild9999 to get {$newModel['pdb']}", $entry, "{$modelID}|{$newModel['id']}", "auto", "add_h.png");
setProgress($tasks, null);
############################################################################
// Clean up and go home
unset($_SESSION['bgjob']['processID']);
$_SESSION['bgjob']['endTime'] = time();
$_SESSION['bgjob']['isRunning'] = false;
Ejemplo n.º 15
0
 /**
  * List browse on the server, so we can insert them in the file input.
  *
  * @param $path
  * @param  Silex\Application $app
  * @param  Request           $request
  * @return mixed
  */
 public function browse($path, Silex\Application $app, Request $request)
 {
     $files = array();
     $folders = array();
     // $key is linked to the fieldname of the original field, so we can
     // Set the selected value in the proper field
     $key = $app['request']->get('key');
     $basefolder = $app['resources']->getPath('files');
     $path = stripTrailingSlash(str_replace("..", "", $path));
     if ($path == 'files') {
         $path = '';
     }
     $currentfolder = realpath($basefolder . $path);
     $ignored = array(".", "..", ".DS_Store", ".gitignore", ".htaccess");
     // Get the pathsegments, so we can show the path..
     $pathsegments = array();
     $cumulative = "";
     if (!empty($path)) {
         foreach (explode("/", $path) as $segment) {
             $cumulative .= $segment . "/";
             $pathsegments[$cumulative] = $segment;
         }
     }
     if (file_exists($currentfolder)) {
         $d = dir($currentfolder);
         while (false !== ($entry = $d->read())) {
             if (in_array($entry, $ignored)) {
                 continue;
             }
             $fullfilename = $currentfolder . "/" . $entry;
             if (is_file($fullfilename)) {
                 $relativepath = str_replace("files/", "", $path . "/" . $entry);
                 $files[$entry] = array('path' => $path, 'filename' => $entry, 'newpath' => $path . "/" . $entry, 'relativepath' => $relativepath, 'writable' => is_writable($fullfilename), 'readable' => is_readable($fullfilename), 'type' => strtolower(getExtension($entry)), 'filesize' => formatFilesize(filesize($fullfilename)), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)), 'permissions' => \util::full_permissions($fullfilename));
                 if (in_array(strtolower(getExtension($entry)), array('gif', 'jpg', 'png', 'jpeg'))) {
                     $size = getimagesize($fullfilename);
                     $files[$entry]['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
                 }
             }
             if (is_dir($fullfilename)) {
                 $folders[$entry] = array('path' => $path, 'foldername' => $entry, 'newpath' => $path . "/" . $entry, 'writable' => is_writable($fullfilename), 'modified' => date("Y/m/d H:i:s", filemtime($fullfilename)));
             }
         }
         $d->close();
     } else {
         $app['session']->getFlashBag()->set('error', __("Folder '%s' could not be found, or is not readable.", array('%s' => $path)));
     }
     $app['twig']->addGlobal('title', __("Files in %s", array('%s' => $path)));
     // Make sure the files and folders are sorted properly.
     ksort($files);
     ksort($folders);
     return $app['render']->render('files_async.twig', array('path' => $path, 'files' => $files, 'folders' => $folders, 'pathsegments' => $pathsegments, 'key' => $key));
 }
Ejemplo n.º 16
0
            $my_uploader->set_path($path);
            if ($my_uploader->upload('file')) {
                $my_uploader->save_file();
            }
            if ($my_uploader->upload_failed()) {
                $error = $my_uploader->get_error();
            }
            $image_file = $path . $my_uploader->fileinfo('filename');
            if (!file_exists($image_file)) {
                $error = $lang->phrase('admin_cms_file_does_not_exist');
            }
            $image_file = str_replace(realpath($config['fpath']) . DIRECTORY_SEPARATOR, '', $image_file);
            $image_file = str_replace(DIRECTORY_SEPARATOR, '/', $image_file);
        }
    }
    $filesize = formatFilesize(ini_maxupload());
    $htmlhead .= '<script type="text/javascript" src="templates/editor/wysiwyg-popup.js"></script>';
    echo head(' onLoad="loadImage();"');
    ?>
<form method="post" action="admin.php?action=cms&amp;job=doc_insert_image&amp;wysiwyg=<?php 
    echo $wysiwyg;
    ?>
" enctype="multipart/form-data">
<table class="border" border="0" cellspacing="0" cellpadding="4" align="center" style="width: 700px;">
	<tr>
		<td class="obox" colspan="3"><?php 
    echo $lang->phrase('admin_wysiwyg_upload_x');
    ?>
</td>
	</tr>
	<tr class="mbox">
Ejemplo n.º 17
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
    if (isset($_POST["list"]) == true) {
        $list = getSelectedEntries($_POST["list"]);
    } else {
        $list = "";
    }
    // -------------------------------------------------------------------------
    // Variables
    // -------------------------------------------------------------------------
    // Title
    $title = __("Size of selected directories and files");
    // Form name, back and forward buttons
    $formname = "CalculateSizeForm";
    $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
    // Open connection
    setStatus(2, 10, __("Connecting to the FTP server"));
    $conn_id = ftp_openconnection();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // Calculate the size
    $options = array();
    $result['size'] = 0;
    $result['skipped'] = 0;
    $result = ftp_processfiles("calculatesize", $conn_id, $net2ftp_globals["directory"], $list, $options, $result, 0);
    // Close connection
    ftp_closeconnection($conn_id);
    // Print message
    $net2ftp_output["calculatesize"][] = __("The total size taken by the selected directories and files is:") . " <b>" . formatFilesize($result['size']) . "</b> (" . $result['size'] . " Bytes)";
    if ($result['skipped'] > 0) {
        $net2ftp_output["calculatesize"][] = __("The number of files which were skipped is:") . " <b>" . $result['skipped'] . "</b>";
    }
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
}
Ejemplo n.º 18
0
function exec_query_form($query = '')
{
    global $db;
    $tables = $db->list_tables();
    ?>
<form name="form" method="post" action="admin.php?action=db&job=query2">
 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr> 
   <td class="obox" colspan="2"><b>Execute Queries</b></td>
  </tr>
  <tr> 
	<td class="mbox" width="90%">
	<span style="float: right;">semicolon-separated list</span><strong>Queries:</strong>
	<textarea name="query" id="query" rows="10" cols="90" class="texteditor" style="width: 100%; height: 200px;"><?php 
    echo iif(!empty($query), $query);
    ?>
</textarea>
	</td>
	<td class="mbox" width="10%">
	<strong>Tables:</strong>
	<div style="overflow: scroll; height: 200px; width: 150px; border: 1px solid #336699; padding: 2px;">
	<?php 
    foreach ($tables as $table) {
        ?>
	<a href="javascript:InsertTags('query', '`<?php 
        echo $table;
        ?>
`', '');"><?php 
        echo $table;
        ?>
</a><br />
	<?php 
    }
    ?>
	</div>
	</td>
  </tr>
  <tr> 
   <td class="ubox" colspan="2" align="center"><input type="submit" name="Submit" value="Submit"></td> 
  </tr>
 </table>
</form>
<br />
<?php 
    if (empty($query)) {
        ?>
<form name="form" method="post" action="admin.php?action=db&amp;job=query2&amp;type=1" enctype="multipart/form-data">
 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr> 
   <td class="obox"><b>Import SQL File</b></td>
  </tr>
  <tr>
  	<td class="mbox">
  	<input type="file" name="upload" size="80" /><br />
  	<span class="stext">Allowed file types: .sql, .zip - Maximum file size: <?php 
        echo formatFilesize(ini_maxupload());
        ?>
</span>
  	</td>
  </tr>
  <tr> 
   <td class="ubox" align="center"><input type="submit" name="Submit" value="Submit"></td> 
  </tr>
 </table>
</form>
<br />
<?php 
    }
}
Ejemplo n.º 19
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the login screen
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
    // -------------------------------------------------------------------------
    // Variables for screen 1
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["screen"] == 1) {
        // Title
        $title = __("Upload directories and files using a Java applet");
        // Next screen
        $nextscreen = 2;
        // Form name, back and forward buttons
        $formname = "JavaUploadForm";
        $back_onclick = "document.forms['" . $formname . "'].state.value='browse';document.forms['" . $formname . "'].state2.value='main';document.forms['" . $formname . "'].submit();";
        // Action URL
        $actionURL = printPHP_SELF("jupload");
        // Maxima
        $maxFileSize = $net2ftp_settings["max_filesize"];
        $maxChunkSize = $net2ftp_settings["max_filesize"];
        $maxFilesPerRequest = "100";
        $max_filesize_net2ftp = formatFilesize($net2ftp_settings["max_filesize"]);
        $max_upload_filesize_php = formatFilesize(@ini_get("upload_max_filesize"));
        $max_execution_time = @ini_get("max_execution_time");
        // Print the output
        require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/manage.template.php";
    }
    // end if
    // -------------------------------------------------------------------------
    // Variables for screen 2
    // -------------------------------------------------------------------------
    //	elseif ($net2ftp_globals["screen"] == 2) {
    // THE OUTPUT IS GENERATED HIGHER UP, IN net2ftp_module_sendHttpHeaders().
    // This is because the Applet only takes text - no HTML.
    //	} // end if
    // -------------------------------------------------------------------------
    // Print the output
    // -------------------------------------------------------------------------
    // Is done higher up, as for screen 1 a template is used, but not for screen 2.
}
Ejemplo n.º 20
0
    }
    $delobj = $scache->load('components');
    $delobj->delete();
    $db->query('UPDATE ' . $db->pre . 'component SET active = "' . $act . '" WHERE id = ' . $id, __LINE__, __FILE__);
    viscacha_header('Location: admin.php?action=cms&job=com');
} elseif ($job == 'com_add') {
    echo head();
    ?>
<form name="form" method="post" action="admin.php?action=cms&job=com_add2" enctype="multipart/form-data">
 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr> 
   <td class="obox" colspan="2">Import a new Component</td>
  </tr>
  <tr> 
   <td class="mbox" width="50%"><em>Either</em> upload a file:<br /><span class="stext">Compressed file (.zip) containing the component. Maximum file size: <?php 
    echo formatFilesize(ini_maxupload());
    ?>
. You should install only components from confidential sources!</td>
   <td class="mbox" width="50%"><input type="file" name="upload" size="40" /></td> 
  </tr>
  <tr>
   <td class="mbox"><em>or</em> select a file from the server:<br /><span class="stext">Path starting from the Viscacha-root-directory: <?php 
    echo $config['fpath'];
    ?>
</span></td>
   <td class="mbox"><input type="text" name="server" size="50" /></td>
  </tr>
  <tr>
   <td class="mbox">Delete file after import:</td>
   <td class="mbox"><input type="checkbox" name="delete" value="1" checked="checked" /></td>
  </tr>
Ejemplo n.º 21
0
  <tr>
   <td class="ubox" width="40%">Cache Name</td>
   <td class="ubox" width="10%">Size</td>
   <td class="ubox" width="10%">Age</td>
   <td class="ubox" width="40%">Options</td>
  </tr>
  <?php 
    foreach ($result as $name => $row) {
        ?>
  <tr>
   <td class="mbox" width="40%"><?php 
        echo $name;
        ?>
</td>
   <td class="mbox" width="10%" nowrap="nowrap" align="right"><?php 
        echo formatFilesize($row['size']);
        ?>
</td>
   <td class="mbox" width="10%" nowrap="nowrap">ca. <?php 
        echo fileAge($row['age']);
        ?>
</td>
   <td class="mbox" width="40%" align="right">[<a href="admin.php?action=misc&job=cache_view&file=<?php 
        echo $name;
        ?>
">View Contents</a>] [<a href="admin.php?action=misc&job=cache_refresh&file=<?php 
        echo $name;
        ?>
">Refresh Cache</a>]</td>
  </tr>
  <?php 
Ejemplo n.º 22
0
function net2ftp_module_printBody()
{
    // --------------
    // This function prints the browse screen ($state2=="main") or the directory popup screen ($state2=="popup")
    // For the browse screen ($state2=="main"), 2 template files are called
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result;
    // -------------------------------------------------------------------------
    // Check if the directory name contains \' and if it does, print an error message
    // Note: these directories cannot be browsed, but can be deleted
    // -------------------------------------------------------------------------
    //	if (strstr($directory, "\'") != false) {
    //		$errormessage = __("Directories with names containing \' cannot be displayed correctly. They can only be deleted. Please go back and select another subdirectory.");
    //		setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
    //		return false;
    //	}
    // -------------------------------------------------------------------------
    // Variables
    // With status update if $state2=="main"
    // -------------------------------------------------------------------------
    // ------------------------------------
    // Open connection
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(2, 10, __("Connecting to the FTP server"));
    }
    $conn_id = ftp_openconnection();
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Get raw list of directories and files; parse the raw list and return a nice list
    // This function may change the current $directory; a warning message is returned in that case
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(4, 10, __("Getting the list of directories and files"));
    }
    $list = ftp_getlist($conn_id, $net2ftp_globals["directory"]);
    if ($net2ftp_result["success"] == false) {
        return false;
    }
    // ------------------------------------
    // Close connection
    // ------------------------------------
    ftp_closeconnection($conn_id);
    // ------------------------------------
    // Sort the list
    // ------------------------------------
    $list_directories = sort_list($list["directories"]);
    $list_files = sort_list($list["files"]);
    $list_symlinks = sort_list($list["symlinks"]);
    $list_unrecognized = sort_list($list["unrecognized"]);
    $warning_directory = $list["stats"]["warnings"];
    $directory = $list["stats"]["newdirectory"];
    $directory_html = htmlEncode2($directory);
    $directory_url = urlEncode2($directory);
    $directory_js = javascriptEncode2($directory);
    $updirectory = upDir($directory);
    $updirectory_html = htmlEncode2($updirectory);
    $updirectory_url = urlEncode2($updirectory);
    $updirectory_js = javascriptEncode2($updirectory);
    // ------------------------------------
    // Calculate the list of HTTP URLs
    // ------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        $list_links_js = ftp2http($net2ftp_globals["directory"], $list_files, "no");
        $list_links_url = ftp2http($net2ftp_globals["directory"], $list_files, "yes");
    }
    // ------------------------------------
    // Consumption message
    // ------------------------------------
    $warning_consumption = "";
    if (checkConsumption() == false) {
        $warning_consumption .= "<b>" . __("Daily limit reached: you will not be able to transfer data") . "</b><br /><br />\n";
        $warning_consumption .= __("In order to guarantee the fair use of the web server for everyone, the data transfer volume and script execution time are limited per user, and per day. Once this limit is reached, you can still browse the FTP server but not transfer data to/from it.") . "<br /><br />\n";
        $warning_consumption .= __("If you need unlimited usage, please install net2ftp on your own web server.") . "<br />\n";
    }
    // ------------------------------------
    // Browse message
    // ------------------------------------
    if ($net2ftp_settings["message_browse"] != "" && $net2ftp_settings["message_browse"] != "Setting message_browse does not exist") {
        $warning_message = $net2ftp_settings["message_browse"];
    }
    // ------------------------------------
    // Directory tree
    // ------------------------------------
    $directory_exploded = explode("/", stripDirectory($directory));
    if ($directory != "/" && checkAuthorizedDirectory("/") == true) {
        $directory_tree = "<a href=\"javascript:submitBrowseForm('/','','browse','main');\">root</a> ";
    } else {
        $directory_tree = "root ";
    }
    $directory_goto = "";
    for ($i = 0; $i < sizeof($directory_exploded) - 1; $i++) {
        $directory_goto = glueDirectories($directory_goto, $directory_exploded[$i]);
        $directory_goto_url = urlEncode2($directory_goto);
        if (checkAuthorizedDirectory($directory_goto) == true) {
            $directory_tree .= "/<a href=\"javascript:submitBrowseForm('" . $directory_goto_url . "','','browse','main');\">" . htmlEncode2($directory_exploded[$i]) . "</a> ";
        } else {
            $directory_tree .= "/" . $directory_exploded[$i] . " ";
        }
    }
    $directory_tree .= "/" . $directory_exploded[sizeof($directory_exploded) - 1];
    // ------------------------------------
    // Language
    // ------------------------------------
    $language_onchange = "document.BrowseForm.language.value=document.forms['BrowseForm'].language2.options[document.forms['BrowseForm'].language2.selectedIndex].value; submitBrowseForm('{$directory_js}', '', 'browse', 'main');";
    // ------------------------------------
    // Skin
    // ------------------------------------
    $skin_onchange = "document.BrowseForm.skin.value=document.forms['BrowseForm'].skin2.options[document.forms['BrowseForm'].skin2.selectedIndex].value; submitBrowseForm('{$directory_js}', '', 'browse', 'main');";
    // ------------------------------------
    // $rowcounter counts the total nr of rows
    // ------------------------------------
    $rowcounter = 0;
    // ------------------------------------
    // Column spans
    // ------------------------------------
    $action_colspan = 1;
    if ($net2ftp_settings["functionuse_view"] == "yes") {
        $action_colspan++;
    }
    if ($net2ftp_settings["functionuse_edit"] == "yes") {
        $action_colspan++;
    }
    if ($net2ftp_settings["functionuse_update"] == "yes") {
        $action_colspan++;
    }
    // Total nr of columns
    $total_colspan = $action_colspan + 9;
    // ------------------------------------
    // Name, Type, Size, ...
    // Determine the sort criteria and direction (ascending/descending)
    // ------------------------------------
    $sortArray["dirfilename"]["text"] = __("Name");
    $sortArray["type"]["text"] = __("Type");
    $sortArray["size"]["text"] = __("Size");
    $sortArray["owner"]["text"] = __("Owner");
    $sortArray["group"]["text"] = __("Group");
    $sortArray["permissions"]["text"] = __("Perms");
    $sortArray["mtime"]["text"] = __("Mod Time");
    $icon_directory = $net2ftp_globals["application_rootdir_url"] . "/skins/" . $net2ftp_globals["skin"] . "/images/mime";
    // Loop over all the sort possibilities
    while (list($key, $value) = each($sortArray)) {
        // The list is sorted by the current $key
        // Print the icon representing the current sortorder
        // Print the link to sort using the other sortorder
        if ($net2ftp_globals["sort"] == $key) {
            // Ascending
            if ($net2ftp_globals["sortorder"] == "ascending") {
                $sortArray[$key]["title"] = __("Click to sort by %1\$s in descending order", $value["text"]);
                $sortArray[$key]["onclick"] = "do_sort('" . $key . "','descending');";
                $icon = "ascend.png";
                $alt = __("Ascending order");
            } else {
                $sortArray[$key]["title"] = __("Click to sort by %1\$s in ascending order", $value["text"]);
                $sortArray[$key]["onclick"] = "do_sort('" . $key . "','ascending');";
                $icon = "descend.png";
                $alt = __("Descending order");
            }
        } else {
            $sortArray[$key]["title"] = __("Click to sort by %1\$s in ascending order", $value["text"]);
            $sortArray[$key]["onclick"] = "do_sort('" . $key . "','ascending');";
            $icon = "";
            $alt = "";
        }
        // The icon to be printed is determined above
        // Now, print the full HTML depending on the browser agent, version and platform
        if ($icon != "") {
            if ($net2ftp_globals["browser_agent"] == "IE" && ($net2ftp_globals["browser_version"] == "5.5" || $net2ftp_globals["browser_version"] == "6") && $net2ftp_globals["browser_platform"] == "Win") {
                $sortArray[$key]["icon"] = "<img src=\"{$icon_directory}/spacer.gif\"   alt=\"{$alt}\" style=\"border: 0px; width: 16px; height: 16px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$icon_directory}/{$icon}', sizingMethod='scale');\" />\n";
            } else {
                $sortArray[$key]["icon"] = "<img src=\"{$icon_directory}/{$icon}\"        alt=\"{$alt}\" style=\"border: 0px; width: 16px; height: 16px;\" />\n";
            }
        } else {
            $sortArray[$key]["icon"] = "";
        }
    }
    // ------------------------------------
    // popup - FormAndFieldname
    // ------------------------------------
    if (isset($_POST["FormAndFieldName"]) == true) {
        $FormAndFieldName = validateGenericInput($_POST["FormAndFieldName"]);
    } else {
        $FormAndFieldName = "";
    }
    // ------------------------------------
    // Action URL
    // Used for Up, Subdirectories, Files (download + actions)
    // ------------------------------------
    $action_url = printPHP_SELF("actions");
    // ------------------------------------
    // Data transfer statistics
    // Print this only if the consumption statistics are available (logging must be on, using a MySQL database)
    // ------------------------------------
    if (isset($net2ftp_globals["consumption_ipaddress_datatransfer"]) == true || isset($net2ftp_globals["consumption_ftpserver_datatransfer"]) == true) {
        $print_consumption = true;
        $consumption_ipaddress_datatransfer = formatFilesize($net2ftp_globals["consumption_ipaddress_datatransfer"]);
        $consumption_ftpserver_datatransfer = formatFilesize($net2ftp_globals["consumption_ftpserver_datatransfer"]);
    } else {
        $print_consumption = false;
    }
    // ------------------------------------
    // HTTP URL
    // ------------------------------------
    $list_files_tmp[1]["dirfilename_url"] = "";
    $httplink = ftp2http($directory, $list_files_tmp, "no");
    // -------------------------------------------------------------------------
    // Print the output - part 2
    // -------------------------------------------------------------------------
    if ($net2ftp_globals["state2"] == "main") {
        setStatus(6, 10, __("Printing the list of directories and files"));
        require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/browse_main.template.php";
    } elseif ($net2ftp_globals["state2"] == "popup") {
        require_once $net2ftp_globals["application_skinsdir"] . "/" . $net2ftp_globals["skin"] . "/browse_popup.template.php";
    }
}
Ejemplo n.º 23
0
                }
            }
            viscacha_header('Location: attachments.php?type=' . $_GET['type'] . '&id=' . $_GET['id'] . SID2URL_JS_x);
        }
    } else {
        echo $tpl->parse("popup/header");
        $filetypes = implode($lang->phrase('listspacer'), explode('|', $config['tpcfiletypes']));
        $filesize = formatFilesize($config['tpcfilesize']);
        if ($_GET['type'] == 'edit' && ($my->mp[0] == 1 || $upinfo['name'] == $my->id)) {
            $result = $db->query('SELECT id, file FROM ' . $db->pre . 'uploads WHERE mid = "' . $upinfo['name'] . '" AND tid = "' . $upinfo['id'] . '"', __LINE__, __FILE__);
        } else {
            $result = $db->query('SELECT id, file FROM ' . $db->pre . 'uploads WHERE mid = "' . $my->id . '" AND topic_id = "' . $upinfo['id'] . '" AND tid = "0"', __LINE__, __FILE__);
        }
        $free = $config['tpcmaxuploads'] - $db->num_rows($result);
        if ($free < 1) {
            $free = 0;
        }
        $uploads = array();
        while ($row = $db->fetch_assoc($result)) {
            $fsize = filesize('uploads/topics/' . $row['file']);
            $fsize = formatFilesize($fsize);
            $uploads[] = array('file' => $row['file'], 'filesize' => $fsize, 'id' => $row['id']);
        }
        echo $tpl->parse("attachments");
        echo $tpl->parse("popup/footer");
    }
}
$slog->updatelogged();
$zeitmessung = t2();
$phpdoc->Out();
$db->close();
Ejemplo n.º 24
0
 /**
  * string get_error(int error_code);
  * 
  * Gets the correct error message for language set by constructor
  * 
  * @param error_code		(int) error code
  * 
  */
 function get_error($error_code = '')
 {
     global $lang;
     $error_message = array();
     $error_code = (int) $error_code;
     if (!$this->max_image_height) {
         $this->max_image_height = $lang->phrase('upload_unspecified');
     }
     if (!$this->max_image_width) {
         $this->max_image_width = $lang->phrase('upload_unspecified');
     }
     $aft = implode(", ", $this->acceptable_file_types);
     $mfs = formatFilesize($this->max_filesize);
     $pathfile = $this->path . $this->file["name"];
     if (is_object($lang)) {
         $lang->assign('this', $this);
         $lang->assign('aft', $aft);
         $lang->assign('mfs', $mfs);
         $lang->assign('pathfile', $pathfile);
         $error_message[0] = $lang->phrase('upload_error_noupload');
         $error_message[1] = $lang->phrase('upload_error_maxfilesize');
         $error_message[2] = $lang->phrase('upload_error_maximagesize');
         $error_message[3] = $lang->phrase('upload_error_wrongfiletype');
         $error_message[4] = $lang->phrase('upload_error_fileexists');
         $error_message[5] = $lang->phrase('upload_error_noaccess');
     } else {
         $error_message[0] = 'Es wurde keine Datei hochgeladen';
         $error_message[1] = 'Zugriff verweigert. Konnte Datei nicht zu &quot;{%this->path}&quot; kopieren.';
         $error_message[2] = 'Nur {$aft} Dateien d&uuml;rfen hochgeladen werden.';
         $error_message[3] = 'Maximale Dateigr&ouml;sse &uuml;berschritten. Datei darf nicht gr&ouml;sser als {$mfs} sein.';
         $error_message[4] = 'Maximale Bildgr&ouml;sse &uuml;berschritten. Bild darf nicht gr&ouml;sser als {%this->max_image_width} x {%this->max_image_height} Pixel sein.';
         $error_message[5] = 'Datei &quot;{$pathfile}&quot; existiert bereits.';
     }
     // for backward compatability:
     $this->errors[$error_code] = $error_message[$error_code];
     return $error_message[$error_code];
 }
Ejemplo n.º 25
0
    } elseif (!empty($pic) && preg_match('/^(http:\\/\\/|www.)([\\wהצ�ִײ�@\\-_\\.]+)\\:?([0-9]*)\\/(.*)$/', $pic, $url_ary)) {
        $my->pic = checkRemotePic($pic, $url_ary, $my->id);
    } else {
        removeOldImages('uploads/pics/', $my->id);
    }
    $db->query("UPDATE {$db->pre}user SET pic = '{$my->pic}' WHERE id = '{$my->id}' LIMIT 1", __LINE__, __FILE__);
    ok($lang->phrase('editprofile_pic_success'), "editprofile.php?action=pic" . SID2URL_x);
} elseif ($_GET['action'] == "pic") {
    if ($my->p['usepic'] == 0) {
        errorLogin($lang->phrase('not_allowed'), "editprofile.php");
    }
    $breadcrumb->Add($lang->phrase('editprofile_pic'));
    echo $tpl->parse("header");
    echo $tpl->parse("menu");
    $filetypes = str_replace("|", ", ", $config['avfiletypes']);
    $filesize = formatFilesize($config['avfilesize']);
    $size = '';
    if ($config['avwidth'] > 0) {
        $size .= $lang->phrase('editprofile_pic_w1');
    } else {
        $size .= $lang->phrase('editprofile_pic_w2');
    }
    if ($config['avheight'] > 0) {
        $size .= $lang->phrase('editprofile_pic_h1');
    } else {
        $size .= $lang->phrase('editprofile_pic_h2');
    }
    $mymodules->load('editprofile_pic_top');
    echo $tpl->parse("editprofile/pic");
} elseif ($_GET['action'] == "profile2") {
    $_POST['hp'] = trim($_POST['hp']);
Ejemplo n.º 26
0
 /**
  * Gets the correct error message.
  *
  * Methoed tries to use $lang-Object. If not available, hardcoded english phrases will be used.
  * 
  * @return	string		error message
  */
 function get_error()
 {
     if ($this->error == null) {
         return false;
     }
     global $lang;
     if (is_object($lang)) {
         switch ($this->error) {
             case UPLOAD_ERR_FILE_INDEX:
                 $message = $lang->phrase('upload_error_noupload');
                 break;
             case UPLOAD_ERR_FILE_SIZE:
                 $lang->assign('mfs', formatFilesize($this->max_filesize));
                 $message = $lang->phrase('upload_error_maxfilesize');
                 break;
             case UPLOAD_ERR_IMAGE_WIDTH:
             case UPLOAD_ERR_IMAGE_HEIGHT:
                 $lang->assign('mih', $this->max_image_height > 0 ? numbers($this->max_image_height) : $lang->phrase('upload_unspecified'));
                 $lang->assign('miw', $this->max_image_width > 0 ? numbers($this->max_image_width) : $lang->phrase('upload_unspecified'));
                 $message = $lang->phrase('upload_error_maximagesize');
                 break;
             case UPLOAD_ERR_FILE_TYPE:
                 $lang->assign('aft', implode($lang->phrase('listspacer'), $this->file_types));
                 $message = $lang->phrase('upload_error_wrongfiletype');
                 break;
             case UPLOAD_ERR_COPY:
                 $message = $lang->phrase('upload_error_noaccess');
                 break;
             case UPLOAD_ERR_FILE_EXISTS:
                 $message = $lang->phrase('upload_error_fileexists');
                 break;
             default:
                 $message = $lang->phrase('upload_error_default');
         }
         if (!empty($this->file['name'])) {
             return "{$this->file['name']}: {$message}";
         } else {
             return $message;
         }
     } else {
         switch ($this->error) {
             case UPLOAD_ERR_FILE_INDEX:
                 $message = 'No file has been uploaded.';
                 break;
             case UPLOAD_ERR_FILE_SIZE:
                 $message = 'Max. filesize reached. The file is not allowed to be bigger than ' . formatFilesize($this->max_filesize) . '.';
                 break;
             case UPLOAD_ERR_IMAGE_WIDTH:
             case UPLOAD_ERR_IMAGE_HEIGHT:
                 $mih = $this->max_image_height > 0 ? numbers($this->max_image_height) : 'any';
                 $miw = $this->max_image_width > 0 ? numbers($this->max_image_width) : 'any';
                 $message = "Max. imagesize reached. Image is not allowed to be greater than {$miw} x {$mih} pixels.";
                 break;
             case UPLOAD_ERR_FILE_TYPE:
                 $lang->assign('aft', implode($lang->phrase('listspacer'), $this->file_types));
                 $message = 'Only ' . implode(', ', $this->file_types) . ' files are allowed to be uploaded.';
                 break;
             case UPLOAD_ERR_COPY:
                 $message = 'Access denied. Could not copy file.';
                 break;
             case UPLOAD_ERR_FILE_EXISTS:
                 $message = 'File already exists.';
                 break;
             default:
                 $message = 'An unknown error occured while uploading.';
         }
         if (!empty($this->file['name'])) {
             return "{$this->file['name']}: {$message}";
         } else {
             return $message;
         }
     }
 }
Ejemplo n.º 27
0
function exec_query_form($query = '')
{
    global $db, $lang;
    $tables = $db->list_tables();
    $lang->assign('maxfilesize', formatFilesize(ini_maxupload()));
    ?>
<script type="text/javascript" src="templates/editor/bbcode.js"></script>
<form name="form" method="post" action="admin.php?action=db&job=query2">
 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr>
   <td class="obox" colspan="2"><?php 
    echo $lang->phrase('admin_db_execute_queries');
    ?>
</td>
  </tr>
  <tr>
	<td class="mbox" width="90%">
	<span style="float: right;"><?php 
    echo $lang->phrase('admin_db_semicolon_sep_list');
    ?>
</span><strong><?php 
    echo $lang->phrase('admin_db_queries');
    ?>
</strong>
	<textarea name="query" id="query" rows="10" cols="90" class="texteditor" style="width: 100%; height: 200px;"><?php 
    echo iif(!empty($query), $query);
    ?>
</textarea>
	</td>
	<td class="mbox" width="10%">
	<strong><?php 
    echo $lang->phrase('admin_db_tables');
    ?>
</strong>
	<div style="overflow: scroll; height: 200px; width: 150px; border: 1px solid #336699; padding: 2px;">
	<?php 
    foreach ($tables as $table) {
        ?>
	<a href="javascript:InsertTags('query', '`<?php 
        echo $table;
        ?>
`', '');"><?php 
        echo $table;
        ?>
</a><br />
	<?php 
    }
    ?>
	</div>
	</td>
  </tr>
  <tr>
   <td class="ubox" colspan="2" align="center"><input type="submit" name="Submit" value="<?php 
    echo $lang->phrase('admin_db_form_submit');
    ?>
"></td>
  </tr>
 </table>
</form>
<br />
<?php 
    if (empty($query)) {
        ?>
<form name="form" method="post" action="admin.php?action=db&amp;job=query2&amp;type=1" enctype="multipart/form-data">
 <table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
  <tr>
   <td class="obox"><b><?php 
        echo $lang->phrase('admin_db_import_sql_file');
        ?>
</b></td>
  </tr>
  <tr>
  	<td class="mbox">
  	<input type="file" name="upload" size="80" /><br />
  	<span class="stext"><?php 
        echo $lang->phrase('admin_db_allowed_filetypes_max_filesize');
        ?>
</span>
  	</td>
  </tr>
  <tr>
   <td class="ubox" align="center"><input type="submit" name="Submit" value="<?php 
        echo $lang->phrase('admin_db_form_submit');
        ?>
"></td>
  </tr>
 </table>
</form>
<br />
<?php 
    }
}
Ejemplo n.º 28
0
    $file = $gpc->get('file', str);
    ?>
<form name="form2" method="post" enctype="multipart/form-data" action="admin.php?action=bbcodes&job=custombb_import2">
 <table class="border" cellpadding="4" cellspacing="0" border="0">
  <tr><td class="obox" colspan="2"><?php 
    echo $lang->phrase('admin_bbc_import_design');
    ?>
</td></tr>
  <tr><td class="mbox"><?php 
    echo $lang->phrase('admin_bbc_either_upload');
    ?>
<br /><span class="stext"><?php 
    echo $lang->phrase('admin_bbc_design_allowed_file_types');
    ?>
 <?php 
    echo formatFilesize(1024 * 250);
    ?>
</span></td>
  <td class="mbox"><input type="file" name="upload" size="40" /></td></tr>
  <tr><td class="mbox"><?php 
    echo $lang->phrase('admin_bbc_or_select');
    ?>
<br /><span class="stext"><?php 
    echo $lang->phrase('admin_bbc_path_from_vc_root');
    ?>
 <?php 
    echo $config['fpath'];
    ?>
</span></td>
  <td class="mbox"><input type="text" name="server" value="<?php 
    echo $file;
Ejemplo n.º 29
0
function ftp_getlist($conn_id, $directory)
{
    // --------------
    // This function connects to the FTP server and returns an array with a list of directories and files.
    // One row per directory or file, with rows from index 1 to n
    //
    // Step 1: send ftp_rawlist request to the FTP server; this returns a string
    // Step 2: parse that string and get a first array ($templist)
    // Step 3: move the rows to another array, to index 1 to n ($list)
    //
    // This function is used in all functions which process directories recursively.
    // --------------
    // -------------------------------------------------------------------------
    // Global variables
    // -------------------------------------------------------------------------
    global $net2ftp_globals, $net2ftp_settings;
    // -------------------------------------------------------------------------
    // Initialization
    // -------------------------------------------------------------------------
    $warnings = "";
    // -------------------------------------------------------------------------
    // Step 1: Chdir to the directory and get the current directory
    // -------------------------------------------------------------------------
    // ----------------------------------------------
    // Step 1a - Directory is "/"
    // Chdir to the directory because otherwise the ftp_rawlist does not work on some FTP servers
    // ----------------------------------------------
    if ($directory == "/") {
        $result1a = @ftp_chdir($conn_id, $directory);
    } elseif ($directory == "") {
        $result1b = @ftp_chdir($conn_id, $directory);
        $directory = @ftp_pwd($conn_id);
    } else {
        // 1c1 - Replace \' by \\' to be able to delete directories with names containing \'
        $directory1 = str_replace("\\'", "\\\\'", $directory);
        // 1c2 - Chdir to the directory
        // This is to check if the directory exists, but also because otherwise
        // the ftp_rawlist does not work on some FTP servers.
        $result1c = @ftp_chdir($conn_id, $directory1);
        // 1c3 - If the first ftp_chdir returns false, try a second time without the leading /
        // Some Windows FTP servers do not work when you use a leading /
        if ($result1c == false) {
            $directory2 = stripDirectory($directory1);
            $result2 = @ftp_chdir($conn_id, $directory2);
            // 1c3 - If the second ftp_chdir also does not work:
            //           For the Browse screen ==> go to the user's root directory
            //           For all other screens ==> return error
            if ($result2 == false) {
                if ($net2ftp_globals["state"] == "browse") {
                    $rootdirectory = getRootdirectory();
                    // User's root directory is different from the current directory, so switch to it
                    if ($directory != $rootdirectory) {
                        $warnings .= __("The directory <b>%1\$s</b> does not exist or could not be selected, so the directory <b>%2\$s</b> is shown instead.", $directory, $rootdirectory);
                        $directory = $rootdirectory;
                        $result3 = @ftp_chdir($conn_id, $directory);
                    } else {
                        $errormessage = __("Your root directory <b>%1\$s</b> does not exist or could not be selected.", $directory);
                        setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                    }
                } else {
                    $errormessage = __("The directory <b>%1\$s</b> could not be selected - you may not have sufficient rights to view this directory, or it may not exist.", $directory);
                    setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
                }
            }
            // end if result2
        }
        // end if result1
    }
    // end if / or "" or else
    // -------------------------------------------------------------------------
    // Step 2 - Get list of directories and files
    // The -a option is used to show the hidden files as well on some FTP servers
    // Some servers do not return anything when using -a, so in that case try again without the -a option
    // -------------------------------------------------------------------------
    $rawlist = ftp_rawlist($conn_id, "-a");
    if (sizeof($rawlist) <= 1) {
        $rawlist = ftp_rawlist($conn_id, "");
    }
    // -------------------------------------------------------------------------
    // Step 3 - Parse the raw list
    // -------------------------------------------------------------------------
    // ----------------------------------------------
    // Initialize variables
    // ----------------------------------------------
    $list["directories"] = array();
    $list["files"] = array();
    $list["symlinks"] = array();
    $list["unrecognized"] = array();
    $directory_index = 1;
    $file_index = 1;
    $symlink_index = 1;
    $unrecognized_index = 1;
    $list["stats"]["directories"]["total_number"] = 0;
    $list["stats"]["directories"]["total_size"] = 0;
    $list["stats"]["directories"]["total_skipped"] = 0;
    $list["stats"]["files"]["total_number"] = 0;
    $list["stats"]["files"]["total_size"] = 0;
    $list["stats"]["files"]["total_skipped"] = 0;
    $list["stats"]["symlinks"]["total_number"] = 0;
    $list["stats"]["symlinks"]["total_size"] = 0;
    $list["stats"]["symlinks"]["total_skipped"] = 0;
    $list["stats"]["unrecognized"]["total_number"] = 0;
    $list["stats"]["unrecognized"]["total_size"] = 0;
    $list["stats"]["unrecognized"]["total_skipped"] = 0;
    // ----------------------------------------------
    // Loop over the raw list lines
    // ----------------------------------------------
    $nr_entries_banned_keyword = 0;
    $nr_entries_too_big = 0;
    for ($i = 0; $i < sizeof($rawlist); $i++) {
        // ----------------------------------------------
        // Scan each line
        // ----------------------------------------------
        $listline = ftp_scanline($directory, $rawlist[$i]);
        // If $listline is empty (e.g. if it contained ".."), continue to the next line
        if ($listline == "") {
            continue;
        }
        // Encode the name for HTML and Javascript
        if (isset($listline["dirfilename"])) {
            $listline["dirfilename_html"] = htmlEncode2($listline["dirfilename"]);
            $listline["dirfilename_url"] = urlEncode2($listline["dirfilename"]);
            $listline["dirfilename_js"] = javascriptEncode2($listline["dirfilename"]);
        }
        // Check if the filename contains a forbidden keyword
        // If it does, then this line will not be selectable on the Browse screen
        // Note: even if "selectable" is set to true here, it can still be set to false just below if the filesize is too big
        if (checkAuthorizedName($listline["dirfilename"]) == true) {
            $listline["selectable"] = "ok";
        } else {
            $listline["selectable"] = "banned_keyword";
            $nr_entries_banned_keyword++;
        }
        // Check if the filesize is bigger than the maximum authorized filesize
        if ($listline["dirorfile"] == "-" && isset($listline["size"]) && is_numeric($listline["size"])) {
            if ($listline["selectable"] == "ok" && $listline["size"] > $net2ftp_settings["max_filesize"]) {
                $listline["selectable"] = "too_big";
                $nr_entries_too_big++;
            }
        }
        // Form the new directory filename and encode it too
        if ($listline["dirorfile"] == "d") {
            $listline["newdir"] = glueDirectories($directory, $listline["dirfilename"]);
            $listline["newdir_html"] = htmlEncode2($listline["newdir"]);
            $listline["newdir_url"] = urlEncode2($listline["newdir"]);
            $listline["newdir_js"] = javascriptEncode2($listline["newdir"]);
        }
        // ----------------------------------------------
        // Depending on if the line contained a directory/file/symlink/unrecognized
        // row, store the result in different variables
        // ----------------------------------------------
        if ($listline["dirorfile"] == "d") {
            $list["directories"][$directory_index] = $listline;
            $directory_index++;
            if (isset($listline["size"]) && is_numeric($listline["size"])) {
                $list["stats"]["directories"]["total_size"] = $list["stats"]["directories"]["total_size"] + $listline["size"];
            } else {
                $list["stats"]["directories"]["total_skipped"] = $list["stats"]["directories"]["total_skipped"] + 1;
            }
        } elseif ($listline["dirorfile"] == "-") {
            $list["files"][$file_index] = $listline;
            $file_index++;
            if (isset($listline["size"]) && is_numeric($listline["size"])) {
                $list["stats"]["files"]["total_size"] = $list["stats"]["files"]["total_size"] + $listline["size"];
            } else {
                $list["stats"]["files"]["total_skipped"] = $list["stats"]["files"]["total_skipped"] + 1;
            }
        } elseif ($listline["dirorfile"] == "l") {
            $list["symlinks"][$symlink_index] = $listline;
            $symlink_index++;
        } elseif ($listline["dirorfile"] == "u") {
            $list["unrecognized"][$unrecognized_index] = $listline;
            $unrecognized_index++;
        }
        // end elseif
    }
    // end for
    // Print a warning message if some directories, files or symlinks contain a banned keyword or if a file is
    // too big to be downloaded
    if ($nr_entries_banned_keyword > 0) {
        $warnings .= __("Entries which contain banned keywords can't be managed using net2ftp. This is to avoid Paypal or Ebay scams from being uploaded through net2ftp.");
        $warnings .= "<br />\n";
    }
    if ($nr_entries_too_big > 0) {
        $warnings .= __("Files which are too big can't be downloaded, uploaded, copied, moved, searched, zipped, unzipped, viewed or edited; they can only be renamed, chmodded or deleted.");
        $warnings .= "<br />\n";
    }
    // Store the warnings and new directory in $list["stats"]
    if (isset($warnings) == true) {
        $list["stats"]["warnings"] = $warnings;
    } else {
        $list["stats"]["warnings"] = "";
    }
    $list["stats"]["newdirectory"] = $directory;
    // Store the statistics
    $list["stats"]["directories"]["total_size_formated"] = formatFilesize($list["stats"]["directories"]["total_size"]);
    $list["stats"]["files"]["total_size_formated"] = formatFilesize($list["stats"]["files"]["total_size"]);
    $list["stats"]["directories"]["total_number"] = $directory_index - 1;
    $list["stats"]["files"]["total_number"] = $file_index - 1;
    $list["stats"]["symlinks"]["total_number"] = $symlink_index - 1;
    $list["stats"]["unrecognized"]["total_number"] = $unrecognized_index - 1;
    // Put everything together in $list["all"]
    $list["all"] = $list["directories"] + $list["files"] + $list["symlinks"] + $list["unrecognized"];
    // -------------------------------------------------------------------------
    // Step 4 - Return the result
    // -------------------------------------------------------------------------
    return $list;
    // -------------------------------------------------------------------------
    // Some documentation:
    // 1 - Some FTP servers return a total on the first line
    // 2 - Some FTP servers return . and .. in their list of directories
    // ftp_scanline does not return those entries.
    // -------------------------------------------------------------------------
    // 1 - After doing some tests on different public FTP servers, it appears that
    // they reply differently to the ftp_rawlist request:
    //      - some FTP servers, like ftp.belnet.be, start with a line summarizing how
    //        many subdirectories and files there are in the current directory. The
    //        real list of subdirectories and files starts on the second line.
    //               [0] => total 15
    //               [1] => drwxr-xr-x 11 BELNET Archive 512 Feb 6 2000 BELNET
    //               [2] => drwxr-xr-x 2 BELNET Archive 512 Oct 29 2001 FVD-SFI
    //      - some other FTP servers, like ftp.redhat.com/pub, start directly with the
    //        list of subdirectories and files.
    //               [0] => drwxr-xr-x 9 ftp ftp 4096 Jan 11 06:34 contrib
    //               [1] => drwxr-xr-x 13 ftp ftp 4096 Jan 29 21:59 redhat
    //               [2] => drwxrwsr-x 6 ftp ftp 4096 Jun 05 2002 up2date
    // 2 - Some FTP servers return "." and ".." as directories. These fake entries
    // have to be eliminated!
    // They would cause infinite loops in the copy/move/delete functions.
    //               [0] => drwxr-xr-x 5 80 www 512 Apr 10 09:39 .
    //               [1] => drwxr-xr-x 16 80 www 512 Apr 9 08:51 ..
    //               [2] => -rw-r--r-- 1 80 www 5647 Apr 9 08:12 _CHANGES_v0.5
    //               [3] => -rw-r--r-- 1 80 www 1239 Apr 9 08:12 _CREDITS_v0.5
}
Ejemplo n.º 30
-1
 /**
  * Return a list with the current stacked items. Add some relevant info to each item,
  * and also check if the item is present and readable.
  *
  * @param int $count
  * @param string $typefilter
  * @return array
  */
 public function listitems($count = 100, $typefilter = "")
 {
     // Make sure typefilter is an array, if passed something like "image, document"
     if (!empty($typefilter)) {
         $typefilter = array_map("trim", explode(",", $typefilter));
     }
     // Our basepath for all uploaded files.
     $filespath = $this->app['paths']['filespath'];
     $items = $this->items;
     $list = array();
     foreach ($items as $item) {
         $extension = strtolower(getExtension($item));
         if (in_array($extension, $this->imagetypes)) {
             $type = "image";
         } elseif (in_array($extension, $this->documenttypes)) {
             $type = "document";
         } else {
             $type = "other";
         }
         // Skip this one, if it doesn't match the type.
         if (!empty($typefilter) && !in_array($type, $typefilter)) {
             continue;
         }
         // Skip it, if it isn't readable or doesn't exist.
         $fullpath = str_replace("files/files/", "files/", $filespath . "/" . $item);
         if (!is_readable($fullpath)) {
             continue;
         }
         $thisitem = array('basename' => basename($item), 'extension' => $extension, 'filepath' => str_replace("files/", "", $item), 'type' => $type, 'writable' => is_writable($fullpath), 'readable' => is_readable($fullpath), 'filesize' => formatFilesize(filesize($fullpath)), 'modified' => date("Y/m/d H:i:s", filemtime($fullpath)), 'permissions' => \util::full_permissions($fullpath));
         $thisitem['info'] = sprintf("%s: <code>%s</code><br>%s: %s<br>%s: %s<br>%s: <code>%s</code>", __('Path'), $thisitem['filepath'], __('Filesize'), $thisitem['filesize'], __('Modified'), $thisitem['modified'], __('Permissions'), $thisitem['permissions']);
         if ($type == "image") {
             $size = getimagesize($fullpath);
             $thisitem['imagesize'] = sprintf("%s × %s", $size[0], $size[1]);
             $thisitem['info'] .= sprintf("<br>%s: %s × %s px", __("Size"), $size[0], $size[1]);
         }
         //add it to our list..
         $list[] = $thisitem;
     }
     $list = array_slice($list, 0, $count);
     return $list;
 }