Пример #1
0
 public static function decryptId($int, $class = '')
 {
     $parts = explode('*', plxEncrypt::base64url_decode($int));
     if (sizeof($parts) != 2) {
         return 0;
     }
     return substr(sha1($class . $parts[0] . ENCRYPTION_KEY), 0, 6) === $parts[1] ? $parts[0] : 0;
 }
Пример #2
0
 /**
  * Méthode qui lance le téléchargement d'un document
  *
  * @param	cible	cible de téléchargement cryptée
  * @return	booleen
  * @author	Stephane F. et Florent MONTHEL
  **/
 public function sendTelechargement($cible)
 {
     # On décrypte le nom du fichier
     $file = PLX_ROOT . $this->aConf['documents'] . plxEncrypt::decryptId($cible);
     # Hook plugins
     if (eval($this->plxPlugins->callHook('plxMotorSendDownload'))) {
         return;
     }
     # On lance le téléchargement et on check le répertoire documents
     if (file_exists($file) and preg_match('#^' . str_replace('\\', '/', realpath(PLX_ROOT . $this->aConf['documents']) . '#'), str_replace('\\', '/', realpath($file)))) {
         header('Content-Description: File Transfer');
         header('Content-Type: application/download');
         header('Content-Disposition: attachment; filename=' . basename($file));
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: no-cache');
         header('Content-Length: ' . filesize($file));
         readfile($file);
         exit;
     } else {
         # On retourne false
         return false;
     }
 }
Пример #3
0
/**
 * Méthode qui affiche les documents du dossier en cours
 *
 * @return	stdout
 * @author	Stephane F.
 **/
function displayDocuments($dir, $plxMedias, $view)
{
    if (!empty($plxMedias->aContent['files'])) {
        echo '<table class="table">';
        echo '<thead>';
        echo '<tr>';
        echo '<th style="width:75%">Nom du fichier</th>';
        echo '<th style="width:25%">Action</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';
        # Initialisation variable de boucles
        $i = 1;
        foreach ($plxMedias->aContent['files'] as $k => $v) {
            $i++;
            echo '<tr class="line-' . $i % 2 . '">';
            echo '<td class="tc1">&nbsp;' . plxUtils::strCut($v['name'], 100) . '</td>';
            echo '<td class="tc1">&nbsp;';
            if ($view != '') {
                # Icone pour lien crypté
                echo '<a href="javascript:void(0)" title="Ajouter le lien pour t&eacute;l&eacute;charger le fichier" onclick="opener.insDoc(\'' . $view . '\', \'' . str_replace('../', '', plxEncrypt::encryptId($plxMedias->path . $dir . $v['name'])) . '\', \'' . $v['name'] . '\', \'1\')">';
                echo '<img src="img/lock_go.png" alt="Ajouter fichier" /></a>&nbsp;';
                # Icone pour lien en clair
                echo '<a href="javascript:void(0)" title="Ajouter le lien du fichier" onclick="opener.insDoc(\'' . $view . '\', \'' . str_replace('../', '', $plxMedias->path . $dir . $v['name']) . '\', \'' . $v['name'] . '\', \'0\')">';
                echo '<img src="img/square.png" alt="Ajouter fichier" /></a>&nbsp;';
            }
            echo "\n" . '<select name="files[' . $dir . $v['name'] . ']">' . $plxMedias->getDirs($dir) . '</select>&nbsp;';
            echo '<a href="medias.php?delfile=' . $dir . $v['name'] . '&amp;dir=' . urlencode($dir) . '&amp;hash=' . $_SESSION['hash'] . ($view != '' ? '&amp;v=' . $view : '') . '" title="Supprimer le fichier" onclick="Check=confirm(\'Supprimer ce fichier ?\');if(Check==false) return false;"><img src="img/delete.gif" alt="Supprimer" /></a>';
            echo '</td>';
            echo '</tr>';
        }
        echo '</tbody>';
        echo '</table>';
    } else {
        echo '<p style="padding:10px;">Aucun fichier</p>';
    }
}