예제 #1
0
 function saveAs($filename, $directory, $field, $overwrite, $mode = 0766)
 {
     if ($this->isPosted) {
         if ($this->HTTP_POST_FILES[$field]['size'] < $this->maxupload_size && $this->HTTP_POST_FILES[$field]['size'] > 0) {
             $noerrors = true;
             $tempName = $this->HTTP_POST_FILES[$field]['tmp_name'];
             $all = $directory . $filename;
             if (file_exists($all)) {
                 if ($overwrite) {
                     @unlink($all) || ($noerrors = false);
                     $this->errors = upload_translate("Erreur de téléchargement du fichier - fichier non sauvegardé.");
                     @move_uploaded_file($tempName, $all) || ($noerrors = false);
                     $this->errors .= upload_translate("Erreur de téléchargement du fichier - fichier non sauvegardé.");
                     @chmod($all, $mode);
                 }
             } else {
                 @move_uploaded_file($tempName, $all) || ($noerrors = false);
                 $this->errors = upload_translate("Erreur de téléchargement du fichier - fichier non sauvegardé.");
                 @chmod($all, $mode);
             }
             return $noerrors;
         } elseif ($this->HTTP_POST_FILES[$field]['size'] > $this->maxupload_size) {
             $this->errors = upload_translate("La taille de ce fichier excède la taille maximum autorisée") . " => " . number_format($this->maxupload_size / 1024, 2) . " Kbs";
             return false;
         } elseif ($this->HTTP_POST_FILES[$field]['size'] == 0) {
             $this->errors = upload_translate("Erreur de téléchargement du fichier - fichier non sauvegardé.");
             return false;
         }
     }
 }
예제 #2
0
function getAttachmentUrl($apli, $post_id, $att_id, $att_path, $att_type, $att_size, $att_inline = 0, $compteur, $visible = 0, $Mmod)
{
    global $icon_dir, $img_dir, $forum;
    global $mimetype_default, $mime_dspfmt, $mime_renderers;
    global $DOCUMENTROOT;
    load_mimetypes();
    $att_name = substr(strstr(basename($att_path), '.'), 1);
    $att_name = substr(strstr(basename($att_name), '.'), 1);
    $att_path = $DOCUMENTROOT . $att_path;
    if (!is_file($att_path)) {
        return '&nbsp;<span class="text-danger" style="font-size: .65rem;">' . upload_translate("Fichier non trouvÈ") . ' : ' . $att_name . '</span>';
    }
    if ($att_inline) {
        if (isset($mime_dspfmt[$att_type])) {
            $display_mode = $mime_dspfmt[$att_type];
        } else {
            $display_mode = $mime_dspfmt[$mimetype_default];
        }
    } else {
        $display_mode = ATT_DSP_LINK;
    }
    if ($Mmod) {
        global $userdata;
        $marqueurM = "&amp;Mmod=" . substr($userdata[2], 8, 6);
    } else {
        $marqueurM = "";
    }
    $att_url = "getfile.php?att_id={$att_id}&amp;apli={$apli}" . $marqueurM . "&amp;att_name=" . rawurlencode($att_name);
    if ($visible != 1) {
        $visible_wrn = '&nbsp;<span class="text-danger" style="font-size: .65rem;">' . upload_translate("Fichier non visible") . '</span>';
    }
    switch ($display_mode) {
        case ATT_DSP_IMG:
            // display as an embedded image
            $size = @getImageSize("{$att_path}");
            //         $img_size = verifsize( $size );
            $img_size = 'style="max-width: 100%; height:auto;"';
            $text = str_replace('"', '\\"', $mime_renderers[ATT_DSP_IMG]);
            eval("\$ret=stripSlashes(\"{$text}\");");
            break;
        case ATT_DSP_PLAINTEXT:
            // display as embedded text, PRE-formatted
            $att_contents = str_replace("\\", "\\\\", htmlSpecialChars(join('', file($att_path)), ENT_COMPAT | ENT_HTML401, cur_charset));
            $att_contents = word_wrap($att_contents);
            $text = str_replace('"', '\\"', $mime_renderers[ATT_DSP_PLAINTEXT]);
            eval("\$ret=\"{$text}\";");
            break;
        case ATT_DSP_HTML:
            // display as embedded HTML text
            //au choix la source ou la page
            $att_contents = word_wrap(nl2br(scr_html(join("", file($att_path)))));
            //$att_contents = removeHack (join ("", file ($att_path)));
            $text = str_replace('"', '\\"', $mime_renderers[ATT_DSP_HTML]);
            eval("\$ret=stripSlashes(\"{$text}\");");
            break;
        case ATT_DSP_SWF:
            // Embedded Macromedia Shockwave Flash
            $size = @getImageSize("{$att_path}");
            $img_size = verifsize($size);
            $text = str_replace('"', '\\"', $mime_renderers[ATT_DSP_SWF]);
            eval("\$ret=stripSlashes(\"{$text}\");");
            break;
        default:
            // display as link
            $Fichier = new FileManagement();
            // essai class PHP7
            //         $Fichier = new File("");
            //         $att_size = $Fichier->Pretty_Size($att_size);
            $att_size = $Fichier->file_size_format($att_size, 1);
            $att_icon = att_icon($att_name);
            $text = str_replace('"', '\\"', $mime_renderers[ATT_DSP_LINK]);
            eval("\$ret=stripSlashes(\"{$text}\");");
            break;
    }
    return $ret;
}
예제 #3
0
파일: minigf.php 프로젝트: npds/npds_dune
        $imgtmp = $ibid;
    } else {
        $imgtmp = "images/upload/arrow.gif";
    }
    $att_table .= '
         <tr>
            <td colspan="2" align="left"><img src="' . $imgtmp . '" border="0" alt="" align="center" /><a class="text-danger" href="#" onclick="deleteFile(document.form0); return false;">' . upload_translate("Supprimer les fichier sélectionnés") . '</a></td>
            <td align="right"><strong>' . upload_translate("Total :") . '</strong></td>
            <td align="center"><strong>' . $total_sz . '</strong></td>
            <td align="center">&nbsp;' . $att_inline_button . '</td>
            <td align="center">' . $visu_button . '</td>
         </tr>';
}
$file_upload_button = "<script type=\"text/javascript\">\n//<![CDATA[\n";
$file_upload_button .= " document.write ('<input type=\"button\" class=\"btn btn-primary btn-sm\" value=\"" . upload_translate("Joindre") . "\" onclick=\"uploadFile(this.form);\" />');\n";
$file_upload_button .= " //]]>\n</script>";
$att_upload_table = '
         <tr>
            <td colspan="6" align="left">' . upload_translate("Fichier joint :") . '&nbsp;<input type="file" class="" name="pcfile" width="260" size="30" onchange="confirmSendFile(this.form);" />&nbsp; ' . $file_upload_button . '</td>
         </tr>
      </tbody>
   </table>';
$att_form = '
         <div class="container-fluid">
            <p>' . upload_translate("Extensions autorisées") . ' : (<small>' . $bn_allowed_extensions . '</small>)</p>';
$att_form .= $att_table . $att_upload_table;
echo $att_form . '<br />' . $thanks_msg . '
         </div>
      </body>
   </html>';
ob_end_flush();
예제 #4
0
         <form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" name="formEdit">
            <input type="hidden" name="ModPath" value="' . $ModPath . '" />
            <input type="hidden" name="ModStart" value="' . $ModStart . '" />
            <input type="hidden" name="apli" value="' . $apli . '" />';
if (isset($groupe)) {
    echo '
            <input type="hidden" name="groupe" value="' . $groupe . '" />';
}
echo '
            <div class="form-group row">
               <input type="hidden" name="actiontype" value="upload" />
               <label class="form-control-label">' . upload_translate("Fichier") . '</label>
               <input class="form-control" name="pcfile" type="file" id="pcfile" value="" />
            </div>
            <div class="form-group row">
               <input type="submit" class="btn btn-primary btn-sm" name="insert" value="' . upload_translate("Joindre") . '" />
            </div>
         </form>
      </div>
   </body>
</html>';
/*****************************************************/
/* Upload du fichier                                 */
/*****************************************************/
function load_mimetypes()
{
    global $mimetypes, $mimetype_default, $mime_dspinl, $mime_dspfmt, $mime_renderers, $att_icons, $att_icon_default, $att_icon_multiple;
    if (defined('ATT_DSP_LINK')) {
        return;
    }
    if (file_exists("modules/upload/include/mimetypes.php")) {
예제 #5
0
function forum_upload()
{
    global $apli, $IdPost, $IdForum, $IdTopic, $pcfile, $pcfile_size, $pcfile_name, $pcfile_type, $att_count, $att_size, $total_att_count, $total_att_size;
    global $MAX_FILE_SIZE, $MAX_FILE_SIZE_TOTAL, $mimetypes, $mimetype_default, $upload_table, $rep_upload_forum;
    // mine......
    list($sum) = sql_fetch_row(sql_query("SELECT SUM(att_size ) FROM {$upload_table} WHERE apli = '{$apli}' && post_id = '{$IdPost}'"));
    // gestion du quota de place d'un post
    if ($MAX_FILE_SIZE_TOTAL - $sum < $MAX_FILE_SIZE) {
        $MAX_FILE_SIZE = $MAX_FILE_SIZE_TOTAL - $sum;
    }
    include "modules/upload/include/fileupload.php";
    // RÈcupÈration des valeurs de PCFILE
    global $HTTP_POST_FILES, $_FILES;
    if (!empty($HTTP_POST_FILES)) {
        $fic = $HTTP_POST_FILES;
    } else {
        $fic = $_FILES;
    }
    $pcfile_name = $fic['pcfile']['name'];
    $pcfile_type = $fic['pcfile']['type'];
    $pcfile_size = $fic['pcfile']['size'];
    $pcfile = $fic['pcfile']['tmp_name'];
    $fu = new FileUpload();
    $fu->init($rep_upload_forum, $IdForum, $apli);
    $att_count = 0;
    $att_size = 0;
    $total_att_count = 0;
    $total_att_size = 0;
    $attachments = $fu->getUploadedFiles($IdPost, $IdTopic);
    if (is_array($attachments)) {
        $att_count = $attachments['att_count'];
        $att_size = $attachments['att_size'];
        if (is_array($pcfile_name)) {
            reset($pcfile_name);
            $names = implode(', ', $pcfile_name);
            $pcfile_name = $names;
        }
        $pcfile_size = $att_size;
        $thanks_msg .= '<div class="alert alert-success" role="alert">' . str_replace('{NAME}', '<strong>' . $pcfile_name . '</strong>', str_replace('{SIZE}', $pcfile_size, upload_translate("Fichier {NAME} bien reçu ({SIZE} octets transférés)"))) . '</div>';
        $total_att_count += $att_count;
        $total_att_size += $att_size;
    }
    return $thanks_msg;
}
예제 #6
0
$mime_dspfmt[$mimetype_default] = ATT_DSP_LINK;
// display mode if displayed inline
$mime_dspfmt['image/gif'] = ATT_DSP_IMG;
$mime_dspfmt['image/bmp'] = ATT_DSP_LINK;
$mime_dspfmt['image/png'] = ATT_DSP_IMG;
$mime_dspfmt['image/x-png'] = ATT_DSP_IMG;
$mime_dspfmt['image/jpeg'] = ATT_DSP_IMG;
$mime_dspfmt['image/pjpeg'] = ATT_DSP_IMG;
$mime_dspfmt['text/html'] = ATT_DSP_HTML;
$mime_dspfmt['text/plain'] = ATT_DSP_PLAINTEXT;
$mime_dspfmt['application/x-shockwave-flash'] = ATT_DSP_SWF;
// attachement
$mime_renderers[ATT_DSP_PLAINTEXT] = "<div class=\"list-group-item\"><div align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</div><pre>\$att_contents</pre></div>";
//$mime_renderers[ATT_DSP_PLAINTEXT] = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"background-color: #000000;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr><td align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</td></tr><tr><td style=\"background-color: #ffffff;\"><pre>\$att_contents</pre></td></tr></table></td></tr></table>";
$mime_renderers[ATT_DSP_HTML] = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"background-color: #000000;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr><td align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</td></tr><tr><td style=\"background-color: #ffffff;\">\$att_contents</td></tr></table></td></tr></table>";
$mime_renderers[ATT_DSP_LINK] = "\n<a class=\"list-group-item\" href=\"\$att_url\" target=\"_blank\" >\n\$att_icon<span title=\"" . upload_translate("Télécharg.") . " \$att_name (\$att_type - \$att_size)\" data-toggle=\"tooltip\" style=\"font-size: .85rem;\"><strong>&nbsp;\$att_name</strong></span><span class=\"tag tag-default tag-pill pull-right\" style=\"font-size: .75rem;\">\$compteur &nbsp;<i class=\"fa fa-lg fa-download\"></i></span><br /><span align=\"center\">\$visible_wrn</span></a>";
$mime_renderers[ATT_DSP_IMG] = "<a class=\"list-group-item\" href=\"javascript:void(0);\" onclick=\"window.open('\$att_url','fullsizeimg','menubar=no,location=no,directories=no,status=no,copyhistory=no,height=600,width=800,toolbar=no,scrollbars=yes,resizable=yes');\"><img src=\"\$att_url\" alt=\"\$att_name\" border=\"0\" \$img_size />\$visible_wrn </a>";
$mime_renderers[ATT_DSP_SWF] = "<p align=\"center\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4\\,0\\,2\\,0\" \$img_size><param name=\"quality\" value=\"high\"><param name=\"SRC\" value=\"\$att_url\"><embed src=\"\$att_url\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" \$img_size></embed></object>\$visible_wrn</p>";
// images
$att_icons = "";
$handle = opendir("images/upload/file_types");
while (false !== ($file = readdir($handle))) {
    if ($file != "." && $file != "..") {
        $prefix = strtoLower(substr($file, 0, strpos($file, '.')));
        $att_icons[$prefix] = "<img src=\"images/upload/file_types/" . $file . "\" border=\"0\" align=\"center\" alt=\"\" />";
        $att_icons[$prefix] = '
      <span class="fa-stack">
  <i class="fa fa-file fa-stack-2x"></i>
  <span class="fa-stack-1x filetype-text">' . $prefix . '</span>
</span>';
    }
예제 #7
0
 /**
  * Get files uploaded
  * @access    public
  * @return    array
  */
 function getUploadedFiles($IdPost, $IdTopic)
 {
     global $pcfile, $pcfile_size, $pcfile_name, $pcfile_type;
     $this->errno = 0;
     $att_size = 0;
     $att_count = 0;
     if (is_string($pcfile) && !empty($pcfile) && !empty($pcfile_name)) {
         if ($pcfile == 'none') {
             $errmsg = sprintf(upload_translate("Erreur de téléchargement du fichier %s (%s) - Le fichier n'a pas été sauvé"), $pcfile_name, $pcfile_type);
             $this->errno = NO_FILE;
             $this->halt($errmsg);
         } elseif ($this->uploadFile($IdPost, $IdTopic, $pcfile_name, $pcfile_size, $pcfile_type, $pcfile, DEFAULT_INLINE)) {
             $att_size = $pcfile_size;
             $att_count = 1;
         } else {
             $errmsg = sprintf(upload_translate("Erreur de téléchargement du fichier %s (%s) - Le fichier n'a pas été sauvé"), $pcfile_name, $pcfile_type);
             $this->halt($errmsg);
         }
     } elseif (is_array($pcfile)) {
         $nfiles = count($pcfile);
         for ($i = 0; $i < $nfiles; $i++) {
             if (!empty($pcfile[$i]) && strtolower($pcfile[$i]) != 'none') {
                 if ($this->uploadFile($IdPost, $IdTopic, $pcfile_name[$i], $pcfile_size[$i], $pcfile_type[$i], $pcfile[$i], DEFAULT_INLINE)) {
                     $att_size += $pcfile_size[$i];
                     $att_count++;
                 } else {
                     $errmsg = sprintf(upload_translate("Erreur de téléchargement du fichier %s (%s) - Le fichier n'a pas été sauvé"), $pcfile_name[$i], $pcfile_type[$i]);
                     $this->halt($errmsg);
                 }
             }
         }
     } else {
         $this->errno = NO_FILE;
         return FALSE;
     }
     if ($att_size > 0) {
         $att['att_size'] = $att_size;
         $att['att_count'] = $att_count;
         return $att;
     } else {
         return false;
     }
 }