本文整理汇总了PHP中formatFilesize函数的典型用法代码示例。如果您正苦于以下问题:PHP formatFilesize函数的具体用法?PHP formatFilesize怎么用?PHP formatFilesize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatFilesize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: onMakeFinalPDB
/**
* 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);
}
开发者ID:smlewis,项目名称:MolProbity,代码行数:37,代码来源:sswing_choose.php
示例2: handle
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);
}
开发者ID:ArdKuijpers,项目名称:bolt,代码行数:56,代码来源:BrowsePlugin.php
示例3: displayMap
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 >'>\n</form></p>\n";
echo $this->pageFooter();
}
开发者ID:smlewis,项目名称:MolProbity,代码行数:14,代码来源:upload_other_done.php
示例4: str_replace
$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&job=doc_insert_image&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">
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:cms.php
示例5: exec_query_form
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&job=query2&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
}
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:69,代码来源:db.php
示例6: viscacha_header
}
$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>
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:31,代码来源:cms.php
示例7: net2ftp_module_printBody
//.........这里部分代码省略.........
// ------------------------------------
$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";
}
}
开发者ID:NN-Dev-Team,项目名称:Nordic-Network,代码行数:101,代码来源:browse.inc.php
示例8: get_error
/**
* 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 "{%this->path}" kopieren.';
$error_message[2] = 'Nur {$aft} Dateien dürfen hochgeladen werden.';
$error_message[3] = 'Maximale Dateigrösse überschritten. Datei darf nicht grösser als {$mfs} sein.';
$error_message[4] = 'Maximale Bildgrösse überschritten. Bild darf nicht grösser als {%this->max_image_width} x {%this->max_image_height} Pixel sein.';
$error_message[5] = 'Datei "{$pathfile}" existiert bereits.';
}
// for backward compatability:
$this->errors[$error_code] = $error_message[$error_code];
return $error_message[$error_code];
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:45,代码来源:class.upload.php
示例9: exec_query_form
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&job=query2&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
}
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:92,代码来源:db.php
示例10: basename
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>
开发者ID:smlewis,项目名称:MolProbity,代码行数:30,代码来源:show_sessions.php
示例11: runJiffiloop
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";
开发者ID:smlewis,项目名称:MolProbity,代码行数:31,代码来源:fillfragments.php
示例12: makeFileCommands
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;
}
开发者ID:smlewis,项目名称:MolProbity,代码行数:47,代码来源:file_browser.php
示例13: files
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));
}
开发者ID:nirolph,项目名称:bolt,代码行数:77,代码来源:Backend.php
示例14: ext_fileSelector
/**
* 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(" » ", $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 × %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&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>";
}
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:78,代码来源:ajaxhelper.php
示例15: countReduceChanges
$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;
开发者ID:smlewis,项目名称:MolProbity,代码行数:31,
|
请发表评论