本文整理汇总了PHP中image_format_supported函数的典型用法代码示例。如果您正苦于以下问题:PHP image_format_supported函数的具体用法?PHP image_format_supported怎么用?PHP image_format_supported使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了image_format_supported函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Account
}
$object = new Account($db);
if ($id) {
$object->fetch($id);
}
/*
* Actions
*/
// Envoi fichier
if ($_POST["sendit"] && !empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->fetch($id)) {
$upload_dir = $conf->bank->dir_output . "/" . $object->ref;
if (dol_mkdir($upload_dir) >= 0) {
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']), 0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0) {
if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) {
// Create small thumbs for image (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
}
$mesg = '<div class="ok">' . $langs->trans("FileTransferComplete") . '</div>';
} else {
$langs->load("errors");
if ($resupload < 0) {
// Unknown error
$mesg = '<div class="error">' . $langs->trans("ErrorFileNotUploaded") . '</div>';
} else {
if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
示例2: list_of_documents
//.........这里部分代码省略.........
print '<td>';
//print "XX".$file['name']; //$file['name'] must be utf8
print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
if ($forcedownload) {
print '&attachment=1';
}
if (!empty($object->entity)) {
print '&entity=' . $object->entity;
}
$filepath = $relativepath . $file['name'];
/* Restore old code: When file is at level 2+, full relative path (and not only level1) must be into url
if ($file['level1name'] <> $object->id)
$filepath=$object->id.'/'.$file['level1name'].'/'.$file['name'];
else
$filepath=$object->id.'/'.$file['name'];
*/
print '&file=' . urlencode($filepath);
print '">';
print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' ';
if ($showrelpart == 1) {
print $relativepath;
}
print dol_trunc($file['name'], $maxlength, 'middle');
print '</a>';
print "</td>\n";
print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>';
print '<td align="center">' . dol_print_date($file['date'], "dayhour", "tzuser") . '</td>';
// Preview
if (empty($useinecm)) {
$fileinfo = pathinfo($file['name']);
print '<td align="center">';
$minifile = $fileinfo['filename'] . '_mini.' . strtolower($fileinfo['extension']);
// Thumbs are created with filename in lower case
if (image_format_supported($file['name']) > 0) {
print '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath . $fileinfo['filename'] . '.' . strtolower($fileinfo['extension'])) . '" class="aphoto" target="_blank">';
print '<img border="0" height="' . $maxheightmini . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath . 'thumbs/' . $minifile) . '" title="">';
print '</a>';
} else {
print ' ';
}
print '</td>';
}
// Delete or view link
// ($param must start with &)
print '<td align="right">';
if ($useinecm) {
print '<a href="' . DOL_URL_ROOT . '/ecm/docfile.php?urlfile=' . urlencode($file['name']) . $param . '" class="editfilelink" rel="' . urlencode($file['name']) . '">' . img_view() . '</a> ';
} else {
if (image_format_supported($file['name']) > 0) {
$permtoedit = 0;
$newmodulepart = $modulepart;
if ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service') {
if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) {
$permtoedit = 1;
}
if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) {
$permtoedit = 1;
}
$newmodulepart = 'produit|service';
}
/* TODO Not yet working
if ($modulepart == 'holiday')
{
if ($user->rights->holiday->write_all) $permtoedit=1;
}
*/
示例3: dol_sanitizeFileName
$object->localtax1_assuj = $_POST["localtax1assuj_value"];
$object->localtax2_assuj = $_POST["localtax2assuj_value"];
$object->tva_intra = $_POST["tva_intra"];
$object->commercial_id = $_POST["commercial_id"];
$object->default_lang = $_POST["default_lang"];
$object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
// Gestion du logo de la société
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
if ($file_OK)
{
if (image_format_supported($_FILES['photo']['name']))
{
dol_mkdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
if (! $result > 0)
{
$errors[] = "ErrorFailedToSaveFile";
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
示例4: vignette
/**
* Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
* If file is myfile.jpg, new file may be myfile_small.jpg
*
* @param string $file Path of source file to resize
* @param int $maxWidth Largeur maximum que dois faire la miniature (-1=unchanged, 160 by default)
* @param int $maxHeight Hauteur maximum que dois faire l'image (-1=unchanged, 120 by default)
* @param string $extName Extension to differenciate thumb file name ('_small', '_mini')
* @param int $quality Quality of compression (0=worst, 100=best)
* @param string $outdir Directory where to store thumb
* @param int $targetformat New format of target (1,2,3,... or 0 to keep old format)
* @return string Full path of thumb or '' if it fails
*/
function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0)
{
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
global $conf, $langs;
dol_syslog("vignette file=" . $file . " extName=" . $extName . " maxWidth=" . $maxWidth . " maxHeight=" . $maxHeight . " quality=" . $quality . " outdir=" . $outdir . " targetformat=" . $targetformat);
// Clean parameters
$file = trim($file);
// Check parameters
if (!$file) {
// Si le fichier n'a pas ete indique
return 'ErrorBadParameters';
} elseif (!file_exists($file)) {
// Si le fichier passe en parametre n'existe pas
dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
return $langs->trans("ErrorFileNotFound", $file);
} elseif (image_format_supported($file) < 0) {
dol_syslog('This file ' . $file . ' does not seem to be an image format file name.', LOG_WARNING);
return 'ErrorBadImageFormat';
} elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) {
// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
return 'Error: Wrong value for parameter maxWidth';
} elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) {
// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
return 'Error: Wrong value for parameter maxHeight';
}
$fichier = realpath($file);
// Chemin canonique absolu de l'image
$dir = dirname($file);
// Chemin du dossier contenant l'image
$infoImg = getimagesize($fichier);
// Recuperation des infos de l'image
$imgWidth = $infoImg[0];
// Largeur de l'image
$imgHeight = $infoImg[1];
// Hauteur de l'image
if ($maxWidth == -1) {
$maxWidth = $infoImg[0];
}
// If size is -1, we keep unchanged
if ($maxHeight == -1) {
$maxHeight = $infoImg[1];
}
// If size is -1, we keep unchanged
// Si l'image est plus petite que la largeur et la hauteur max, on ne cree pas de vignette
if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight) {
// On cree toujours les vignettes
dol_syslog("File size is smaller than thumb size", LOG_DEBUG);
//return 'Le fichier '.$file.' ne necessite pas de creation de vignette';
}
$imgfonction = '';
switch ($infoImg[2]) {
case IMAGETYPE_GIF:
// 1
$imgfonction = 'imagecreatefromgif';
break;
case IMAGETYPE_JPEG:
// 2
$imgfonction = 'imagecreatefromjpeg';
break;
case IMAGETYPE_PNG:
// 3
$imgfonction = 'imagecreatefrompng';
break;
case IMAGETYPE_BMP:
// 6
// Not supported by PHP GD
break;
case IMAGETYPE_WBMP:
// 15
$imgfonction = 'imagecreatefromwbmp';
break;
}
if ($imgfonction) {
if (!function_exists($imgfonction)) {
// Fonctions de conversion non presente dans ce PHP
return 'Error: Creation of thumbs not possible. This PHP does not support GD function ' . $imgfonction;
}
}
// On cree le repertoire contenant les vignettes
$dirthumb = $dir . ($outdir ? '/' . $outdir : '');
// Chemin du dossier contenant les vignettes
dol_mkdir($dirthumb);
// Initialisation des variables selon l'extension de l'image
switch ($infoImg[2]) {
case IMAGETYPE_GIF:
//.........这里部分代码省略.........
示例5: dol_add_file_process
/**
* Get and save an upload file (for example after submitting a new file a mail form).
* All information used are in db, conf, langs, user and _FILES.
* Note: This function can be used only into a HTML page context.
*
* @param string $upload_dir Directory where to store uploaded file (note: also find in first part of dest_file)
* @param int $allowoverwrite 1=Allow overwrite existing file
* @param int $donotupdatesession 1=Do no edit _SESSION variable
* @param string $varfiles _FILES var name
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param string $link Link to add
* @return void
*/
function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null)
{
global $db, $user, $conf, $langs;
if (!empty($_FILES[$varfiles])) {
dol_syslog('dol_add_file_process upload_dir=' . $upload_dir . ' allowoverwrite=' . $allowoverwrite . ' donotupdatesession=' . $donotupdatesession . ' savingdocmask=' . $savingdocmask, LOG_DEBUG);
if (dol_mkdir($upload_dir) >= 0) {
$TFile = $_FILES[$varfiles];
if (!is_array($TFile['name'])) {
foreach ($TFile as $key => &$val) {
$val = array($val);
}
}
$nbfile = count($TFile['name']);
for ($i = 0; $i < $nbfile; $i++) {
// Define $destpath (path to file including filename) and $destfile (only filename)
$destpath = $upload_dir . "/" . $TFile['name'][$i];
$destfile = $TFile['name'][$i];
$savingdocmask = dol_sanitizeFileName($savingdocmask);
if ($savingdocmask) {
$destpath = $upload_dir . "/" . preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
$destfile = preg_replace('/__file__/', $TFile['name'][$i], $savingdocmask);
}
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destpath, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
if (is_numeric($resupload) && $resupload > 0) {
global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini;
include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
if (empty($donotupdatesession)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->add_attached_files($destpath, $destfile, $TFile['type'][$i]);
}
if (image_format_supported($destpath) == 1) {
// Create small thumbs for image (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs");
// Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs");
}
setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
} else {
$langs->load("errors");
if ($resupload < 0) {
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
} else {
if (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
} else {
setEventMessages($langs->trans($resupload), null, 'errors');
}
}
}
}
}
} elseif ($link) {
if (dol_mkdir($upload_dir) >= 0) {
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
$linkObject = new Link($db);
$linkObject->entity = $conf->entity;
$linkObject->url = $link;
$linkObject->objecttype = GETPOST('objecttype', 'alpha');
$linkObject->objectid = GETPOST('objectid', 'int');
$linkObject->label = GETPOST('label', 'alpha');
$res = $linkObject->create($user);
$langs->load('link');
if ($res > 0) {
setEventMessages($langs->trans("LinkComplete"), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors');
}
}
} else {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("File")), null, 'errors');
}
}
示例6: restrictedArea
if ($user->societe_id) {
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
$mesg = '';
$object = new Product($db);
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
$dir = !empty($conf->product->multidir_output[$object->entity]) ? $conf->product->multidir_output[$object->entity] : $conf->service->multidir_output[$object->entity];
}
/*
* Actions
*/
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST('sendit') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->id) {
if (image_format_supported($_FILES['userfile']['name']) >= 1) {
$result = $object->add_photo($dir, $_FILES['userfile']);
if ($result > 0) {
setEventMessage($langs->trans("FileUploaded"));
} else {
setEventMessage($langs->trans("FileNotUploaded"), 'errors');
}
} else {
$langs->load("errors");
setEventMessage($langs->trans("ErrorBadImageFormat"), 'errors');
}
}
}
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer)) {
$object->delete_photo($dir . "/" . $_GET["file"]);
}
示例7: image_format_supported
$isimage = image_format_supported($_GET["file"]);
// Create thumbs of logo
if ($isimage > 0) {
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($conf->mycompany->dir_output . '/logos/' . $_GET["file"], $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
$imgThumbSmall = $reg[1];
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog($imgThumbSmall);
}
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($conf->mycompany->dir_output . '/logos/' . $_GET["file"], $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
$imgThumbMini = $reg[1];
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog($imgThumbMini);
}
Header("Location: " . $_SERVER["PHP_SELF"]);
exit;
} else {
$message .= '<div class="error">' . $langs->trans("ErrorImageFormatNotSupported") . '</div>';
dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"), LOG_WARNING);
}
} else {
$message .= '<div class="error">' . $langs->trans("ErrorFileDoesNotExists", $_GET["file"]) . '</div>';
dol_syslog($langs->transnoentities("ErrorFileDoesNotExists", $_GET["file"]), LOG_WARNING);
}
示例8: list_of_documents
/**
* Show list of documents in a directory
*
* @param array $filearray Array of files loaded by dol_dir_list('files') function before calling this
* @param Object $object Object on which document is linked to
* @param string $modulepart Value for modulepart used by download or viewimage wrapper
* @param string $param Parameters on sort links
* @param int $forcedownload Force to open dialog box "Save As" when clicking on file
* @param string $relativepath Relative path of docs (autodefined if not provided)
* @param int $permtodelete Permission to delete
* @param int $useinecm Change output for use in ecm module
* @param string $textifempty Text to show if filearray is empty ('NoFileFound' if not defined)
* @param int $maxlength Maximum length of file name shown
* @param string $title Title before list
* @param string $url Full url to use for click links ('' = autodetect)
* @return int <0 if KO, nb of files shown if OK
*/
function list_of_documents($filearray, $object, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '')
{
global $user, $conf, $langs;
global $bc;
global $sortfield, $sortorder, $maxheightmini;
// Show list of existing files
if (empty($useinecm)) {
print_titre($title ? $title : $langs->trans("AttachedFiles"));
}
if (empty($url)) {
$url = $_SERVER["PHP_SELF"];
}
print '<table width="100%" class="' . ($useinecm ? 'nobordernopadding' : 'liste') . '">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Documents2"), $url, "name", "", $param, 'align="left"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Size"), $url, "size", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Date"), $url, "date", "", $param, 'align="center"', $sortfield, $sortorder);
if (empty($useinecm)) {
print_liste_field_titre('', $url, "", "", $param, 'align="center"');
}
print_liste_field_titre('', '', '');
print '</tr>';
$nboffiles = count($filearray);
if ($nboffiles > 0) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';
}
$var = true;
foreach ($filearray as $key => $file) {
if ($file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && !preg_match('/\\.meta$/i', $file['name'])) {
// Define relative path used to store the file
if (!$relativepath) {
$relativepath = dol_sanitizeFileName($object->ref) . '/';
}
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td>';
//print "XX".$file['name']; //$file['name'] must be utf8
print '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart;
if ($forcedownload) {
print '&attachment=1';
}
if (!empty($object->entity)) {
print '&entity=' . $object->entity;
}
print '&file=' . urlencode($relativepath . $file['name']) . '">';
print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' ';
print dol_trunc($file['name'], $maxlength, 'middle');
print '</a>';
print "</td>\n";
print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>';
print '<td align="center">' . dol_print_date($file['date'], "dayhour") . '</td>';
// Preview
if (empty($useinecm)) {
print '<td align="center">';
$tmp = explode('.', $file['name']);
$minifile = $tmp[0] . '_mini.' . $tmp[1];
if (image_format_supported($file['name']) > 0) {
print '<img border="0" height="' . $maxheightmini . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath . 'thumbs/' . $minifile) . '" title="">';
} else {
print ' ';
}
print '</td>';
}
// Delete or view link
print '<td align="right">';
if ($useinecm) {
print '<a href="' . DOL_URL_ROOT . '/ecm/docfile.php?urlfile=' . urlencode($file['name']) . $param . '" class="editfilelink" rel="' . urlencode($file['name']) . '">' . img_view() . '</a> ';
}
if ($permtodelete) {
print '<a href="' . ($useinecm && !empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS) ? '#' : $url . '?id=' . $object->id . '&action=delete&urlfile=' . urlencode($file['name']) . $param) . '" class="deletefilelink" rel="' . urlencode($file['name']) . '">' . img_delete() . '</a>';
} else {
print ' ';
}
print "</td>";
print "</tr>\n";
}
}
if ($nboffiles == 0) {
print '<tr ' . $bc[$var] . '><td colspan="' . (empty($useinecm) ? '5' : '4') . '">';
if (empty($textifempty)) {
print $langs->trans("NoFileFound");
} else {
print $textifempty;
//.........这里部分代码省略.........