Example #1
0
         $content->parse("BLOCK_TAKE");
     }
     if ($can_write) {
         $content->setCurrentBlock("BLOCK_EDIT");
         $content->setVariable("LINK_EDIT_OBJECT", $edit_link);
         $content->setVariable("LABEL_EDIT_OBJECT", gettext("edit"));
         $content->setVariable("ICONPATH_EDIT_OBJECT", PATH_STYLE . "images/edit.png");
         $content->parse("BLOCK_EDIT");
         $content->setCurrentBlock("BLOCK_DELETE");
         $content->setVariable("LINK_DELETE_OBJECT", $delete_link);
         $content->setVariable("LABEL_DELETE_OBJECT", gettext("delete"));
         $content->setVariable("ICONPATH_DELETE_OBJECT", PATH_STYLE . "images/delete.png");
         $content->parse("BLOCK_DELETE");
     }
     //$content->setVariable( "NAME_ITEM", h( $attributes[OBJ_NAME] ) );
     $content->setVariable("NAME_ITEM", format_length(h($attributes[OBJ_NAME]), 25));
     $item_desc = $attributes[OBJ_DESC];
     if (is_string($item_desc) && strlen($item_desc) > 0) {
         $content->setCurrentBlock("BLOCK_DESCRIPTION");
         $content->setVariable("OBJ_DESC", h($item_desc));
         $content->parse("BLOCK_DESCRIPTION");
         $content->setVariable("ITEM_STYLE", "style=\"margin-top: 3px;\"");
     } else {
         $content->setVariable("ITEM_STYLE", "style=\"margin-top: 8px;\"");
     }
     $content->setVariable("BOXES", "boxes_" . $i);
     $content->parse("BLOCK_ITEM");
     $item_ids[] = (string) $item->get_id();
     $i++;
 }
 $content->parse("BLOCK_INVENTORY");
Example #2
0
		<h2>Liste des t&eacute;l&eacute;chargements :</h2>
		<p>
			Tant que le t&eacute;l&eacute;chargement d'un torrent n'est pas fini, vous ne pouvez supprimer aucun de ses fichiers.
			Vous pouvez voir la progression du t&eacute;l&eacute;chargement &agrave; c&ocirc;t&eacute; de la taille (quand la progression dispara&icirc;t, le t&eacute;l&eacute;chargement est termin&eacute;).
			Il est possible que le t&eacute;l&eacute;chargement arrive &agrave; 100% et y reste pendant quelques temps.
			Si vous trouvez que cela dure trop longtemps, vous pouvez <a href="mailto:<?php 
echo ADMIN_MAIL;
?>
">contacter l'administrateur</a> pour avoir plus d'informations.
		</p>
		<p>
			Vous utilisez actuellement <?php 
echo format_length(getSize(DOWNLOADS_DIR));
?>
 (<?php 
echo format_length(disk_free_space(DOWNLOADS_DIR));
?>
 restant).
		</p>
		<?php 
echo getDirectoryDescription(TORRENTS_DIR);
?>
		
		<p>
			En cas de soucis ou pour toute question, vous pouvez toujours contacter l'administrateur &agrave; cette adresse e-mail :
			<a href="mailto:<?php 
echo ADMIN_MAIL;
?>
"><?php 
echo ADMIN_MAIL;
?>
Example #3
0
            $size = $doc instanceof steam_document ? $doc->get_attribute("DOC_SIZE") : 0;
            $content->setVariable("SIZE_ITEM", get_formatted_filesize($size));
            $last_modified = $doc->get_attribute("DOC_LAST_MODIFIED");
            if ($last_modified == 0) {
                $last_modified = $doc->get_attribute("OBJ_CREATION_TIME");
            }
            if ($last_modified != 0) {
                $autorname = $data_result[$data_tnr[$doc->get_id()]["authorname"]];
                $autorstring = "<a href=\"" . PATH_URL . "user/" . $autorname . "/\">" . $autorname . "</a>";
                $modifiedstring = $autorstring . ",<br />" . "<small>" . strftime("%x", $last_modified) . strftime(", %R", $last_modified) . "</small>";
                $content->setVariable("MODIFIED_ITEM", $modifiedstring);
            }
            $content->setVariable("VALUE_VIEWS", str_replace("%NO_VIEWS", count($data_result[$data_tnr[$doc->get_id()]["readers"]]), gettext("%NO_VIEWS views")));
            $content->setVariable("VALUE_COMMENTS", str_replace("%NO_COMMENTS", count($data_result[$data_tnr[$doc->get_id()]["annotations"]]), gettext("%NO_COMMENTS comments")));
            $content->setVariable("LINK_COMMENTS", PATH_URL . "doc/" . $doc->get_id() . "/");
            $content->setVariable("NAME_ITEM", format_length(h($doc->get_name()), 70));
            $content->setVariable("OBJ_DESC", h($doc->get_attribute("OBJ_DESC")));
            $content->parse("BLOCK_ITEM");
        }
    }
    $content->parse("BLOCK_INVENTORY");
} else {
    $content->setVariable("LABEL_NO_DOCUMENTS_FOUND", gettext("No documents found."));
}
////////////////////////////////////////////////
// Learners
$cache = get_cache_function($tutorial->get_id(), CACHE_LIFETIME_STATIC);
$members = $cache->call("lms_steam::group_get_members", $tutorial->get_id());
$no_members = count($members);
if ($no_members > 0) {
    //$start = $portal->set_paginator( $content, 10, $no_members, "(" . str_replace( "%NAME", h($tutorial->get_name()), gettext( "%TOTAL members in %NAME" ) ) . ")" );
Example #4
0
function getDirectoryDescription($dirPath)
{
    if (!is_dir($dirPath)) {
        debug_print_backtrace();
        die("L'emplacement de t&eacute;l&eacute;chargement renseign&eacute; n'est pas un dossier : " . $dirPath);
    }
    //get the files of the directory
    $files = array();
    foreach (getContentOf($dirPath) as $file) {
        $files[$file]['file'] = $dirPath . DIRECTORY_SEPARATOR . $file;
        $files[$file]['torrent'] = null;
    }
    if ($dirPath == TORRENTS_DIR) {
        //recognize files as torrents
        $temp = array();
        foreach ($files as $name => $fileDescription) {
            $path = $fileDescription['file'];
            $torrent = new Torrent($path);
            $temp[$torrent->name()]['torrent'] = $torrent;
            $temp[$torrent->name()]['file'] = null;
        }
        $files = $temp;
        unset($temp);
        //look for the downloaded files
        foreach (getContentOf(DOWNLOADS_DIR) as $file) {
            $downloadPath = DOWNLOADS_DIR . DIRECTORY_SEPARATOR . $file;
            $files[$file]['file'] = $downloadPath;
            if (!isset($files[$file]['torrent'])) {
                $files[$file]['torrent'] = null;
            }
        }
        //natural sorting on the downloaded file names
        uksort($files, 'strnatcasecmp');
    } else {
        if (strpos($dirPath, DOWNLOADS_DIR) === 0) {
            //look for the file or root directory downloaded by torrent
            $downloadName = "";
            $parentDir = $dirPath;
            while ($parentDir != DOWNLOADS_DIR) {
                $downloadName = basename($parentDir);
                $parentDir = dirname($parentDir);
            }
            //look if there is a torrent for this download
            foreach (getContentOf(TORRENTS_DIR) as $file) {
                $torrentPath = TORRENTS_DIR . DIRECTORY_SEPARATOR . $file;
                $torrent = new Torrent($torrentPath);
                if ($torrent->name() == $downloadName) {
                    foreach ($files as $name => $fileDescription) {
                        $files[$name]['torrent'] = $torrent;
                    }
                    break;
                }
            }
        }
    }
    $description = "<p>\n\t\t\t\t\t\t\t<span class='warning'>ATTENTION :</span>\n\t\t\t\t\t\t\tCertains fichiers peuvent appara&icirc;tre &agrave; 100% alors qu'ils sont en cours de t&eacute;l&eacute;chargement (et donc incomplets).\n\t\t\t\t\t\t\tSi cela arrive, attendez simplement que la progression disparaisse, cela garantit que plus rien n'est en cours.\n\t\t\t\t\t\t\tEn cas de doute, n'h&eacute;sitez pas &agrave; <a href='mailto:" . ADMIN_MAIL . "'>contacter l'administrateur</a>.\n\t\t\t\t\t\t</p>";
    if (count($files) > 0) {
        //open table
        $description .= "<form method='post'>";
        $description .= "<table>";
        $description .= "<tr class='header'>\n\t\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t\t<td>Fichier</td>\n\t\t\t\t\t\t\t\t<td>Taille</td>\n\t\t\t\t\t\t\t\t<td>Actions</td>\n\t\t\t\t\t\t\t</tr>";
        //start filling
        clearstatcache();
        $total = count($files);
        $index = 0;
        foreach ($files as $fileName => $fileDescription) {
            $filePath = $fileDescription['file'];
            $torrent = $fileDescription['torrent'];
            $index++;
            $increment = 0;
            $checkboxIndex = $increment++ * $total + $index;
            $linkIndex = $increment++ * $total + $index;
            $visualizeIndex = $increment++ * $total + $index;
            $compressIndex = $increment++ * $total + $index;
            $extractIndex = $increment++ * $total + $index;
            $downloadIndex = $increment++ * $total + $index;
            $renameIndex = $increment++ * $total + $index;
            $moveIndex = $increment++ * $total + $index;
            $deleteIndex = $increment++ * $total + $index;
            //generate data
            $hasTorrent = $torrent != null;
            $hasDownload = $filePath != null;
            $isRootDownload = $hasDownload && dirname($filePath) == DOWNLOADS_DIR;
            $isDir = $hasDownload && is_dir($filePath);
            $isCompressed = $filePath != null && isCompressedArchive($filePath);
            $isImage = $hasDownload && is_image($filePath);
            $MD5 = $filePath != null ? getMD5ChainForPath($filePath, DOWNLOADS_DIR) : null;
            $MD5Arg = $MD5 != null ? "md5=" . $MD5 : "";
            //format data for columns
            $fileCol = $fileName;
            if ($isDir) {
                $fileCol = "<a tabindex='" . $linkIndex . "' href='" . PAGE_EXPLORE . "?" . $MD5Arg . "'>" . ICON_EXPLORE . $fileCol . "</a>";
            }
            $sizeCol = "";
            $isCompleted = false;
            $realSize = getSize($filePath);
            if ($hasTorrent) {
                $relativePath = substr($filePath, strpos($filePath, $torrent->name()));
                $calculatedSize = 0;
                foreach ($torrent->content() as $fileRelativePath => $fileLength) {
                    if (strpos($fileRelativePath, $relativePath) === 0) {
                        $calculatedSize += $fileLength;
                    }
                }
                if ($calculatedSize < $realSize) {
                    $percent = "?";
                } else {
                    $percent = !$hasDownload ? 0 : floor(100 * $realSize / $calculatedSize);
                }
                $sizeCol = format_length($calculatedSize) . " (" . $percent . "%)";
                $isCompleted = $percent == 100;
            } else {
                $sizeCol = format_length($realSize);
                $isCompleted = true;
            }
            $actionCol = "";
            if ($isDir) {
                $actionCol .= " <a tabindex='" . $compressIndex . "' href='" . PAGE_ZIP . "?" . $MD5Arg . "' title='Compresser' onclick='return(confirm(\"Compresser " . $fileName . " et tout sont contenu ?\"));'>" . ICON_ZIP . "</a>";
            } else {
                if ($isImage && $isCompleted) {
                    $url = new Url();
                    $url->setQueryVar('md5', $MD5);
                    $url->setQueryVar('show');
                    $actionCol .= " <a tabindex='" . $visualizeIndex . "' href='" . $url . "' title='Afficher'>" . ICON_VISUALIZE . "</a>";
                } else {
                    if ($isCompressed && $isCompleted) {
                        $actionCol .= " <a tabindex='" . $extractIndex . "' href='" . PAGE_UNZIP . "?" . $MD5Arg . "' title='D&eacute;compresser' onclick='return(confirm(\"D&eacute;compresser " . $fileName . " ?\"));'>" . ICON_UNZIP . "</a>";
                    }
                }
            }
            if ($hasDownload && !$isDir && $realSize > 0) {
                $actionCol .= " <a tabindex='" . $downloadIndex . "' href='" . PAGE_DOWNLOAD . "?" . $MD5Arg . "' title='T&eacute;l&eacute;charger' " . ($isCompleted ? "" : "onclick='return(confirm(\"Le fichier est incomplet, voulez-vous quand m&ecirc;me le t&eacute;l&eacute;charger ?\"));'") . ">" . ICON_DOWNLOAD . "</a>";
            }
            if (!$hasTorrent) {
                $id = "ren" . $MD5;
                $actionCol .= " <a tabindex='" . $renameIndex . "' href='" . PAGE_RENAME . "?" . $MD5Arg . "' title='Renommer' id='" . $id . "' onclick='" . "oldName = \"" . htmlentities($fileName, ENT_QUOTES | ENT_IGNORE, 'UTF-8') . "\";" . "newName = prompt(\"Nouveau nom :\", oldName);" . "if (newName != oldName && newName != null && newName != \"\") {" . "document.getElementById(\"" . $id . "\").href = document.getElementById(\"" . $id . "\").href + \"&name=\" + encodeURIComponent(newName);" . "return(true);" . "} else {" . "return(false);" . "}" . "'>" . ICON_RENAME . "</a>";
                $actionCol .= " <a tabindex='" . $moveIndex . "' href='" . PAGE_MOVE . "?" . $MD5Arg . "' title='D&eacute;placer'>" . ICON_MOVE . "</a>";
                $actionCol .= " <a tabindex='" . $deleteIndex . "' href='" . PAGE_DELETE . "?" . $MD5Arg . "' title='Supprimer'>" . ICON_DELETE . "</a>";
            }
            $selectCol = $hasTorrent ? "" : "<input tabindex='" . $checkboxIndex . "' type='checkbox' name='selection[]' value='" . $MD5 . "'>";
            //place data in the table
            $description .= "<tr class='row" . ($hasTorrent ? $isCompleted ? "-complete" : "-incomplete" : "") . "'>";
            $description .= "<td>" . $selectCol . "</td>";
            $description .= "<td>" . $fileCol . "</td>";
            $description .= "<td>" . $sizeCol . "</td>";
            $description .= "<td><center>" . $actionCol . "</center></td>";
            $description .= "</tr>";
        }
        //place group actions as the last line
        $actionCol = "";
        $actionCol .= " <input type='image' class='icon' formaction='" . PAGE_ZIP . "?grouped' title='Compresser' onclick='return(confirm(\"Compresser la sélection ?\"));' src='" . SUBMIT_ZIP . "' />";
        $actionCol .= " <input type='image' class='icon' formaction='" . PAGE_MOVE . "?grouped' title='D&eacute;placer' src='" . SUBMIT_MOVE . "' />";
        $actionCol .= " <input type='image' class='icon' formaction='" . PAGE_DELETE . "?grouped' title='Supprimer' src='" . SUBMIT_DELETE . "' />";
        $description .= "<script type='text/javascript'>\n\t\t\t\t\t\t\tfunction switchAll(x) {\n\t\t\t\t\t\t\t\tfor(var i = 0, l = x.form.length ; i < l ; i++) {\n\t\t\t\t\t\t\t\t\tif(x.form[i].type == 'checkbox' && x.form[i].name != 'sAll') {\n\t\t\t\t\t\t\t\t\t\tx.form[i].checked = x.checked;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t// not a checkbox nor one we should care about\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t</script>";
        $description .= "<tr class='row'>";
        $description .= "<td><input type='checkbox' name='sAll' onclick='switchAll(this)' /></td>";
        $description .= "<td colspan='3'>" . $actionCol . "</td>";
        $description .= "</tr>";
        //close table
        $description .= "</table>";
        $description .= "</form>";
    } else {
        $description .= "<p><i>Aucun fichier, ajoutez de nouveaux torrents ci-dessus pour qu'ils soient t&eacute;l&eacute;charg&eacute;s.</i></p>";
    }
    unset($files);
    return $description;
}