本文整理汇总了PHP中DataHandler::returnExtensionOfFile方法的典型用法代码示例。如果您正苦于以下问题:PHP DataHandler::returnExtensionOfFile方法的具体用法?PHP DataHandler::returnExtensionOfFile怎么用?PHP DataHandler::returnExtensionOfFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataHandler
的用法示例。
在下文中一共展示了DataHandler::returnExtensionOfFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createImage
/**
* Creation of the original image object.
*
* @return object of the image created.
*/
function createImage()
{
//est� conferindo o arquivo pela exten��o contando que foi conferido o tipo de arquivo ao recebe-lo
$extensao = DataHandler::returnExtensionOfFile($this->image);
// echo Debug::li(filetype($this->image));
// exit();
switch (strtolower($extensao)) {
case 'jpg':
case 'jpeg':
return imagecreatefromjpeg($this->image);
break;
case 'gif':
return imagecreatefromgif($this->image);
break;
case 'png':
return imagecreatefrompng($this->image);
break;
case 'bmp':
return imagecreatefromwbmp($this->image);
break;
default:
return imagecreatefromjpeg($this->image);
break;
}
}
示例2: __construct
function __construct($fileName)
{
// *** Open up the file
$this->image = $this->openImage($fileName);
// save the extension
$this->extension_file = strtolower(DataHandler::returnExtensionOfFile($fileName));
// *** Get width and height
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
}
示例3: insert
public function insert()
{
//inicia um retorno de ReturnResultVO
$ReturnResultVO = new ReturnResultVO();
//pega os dados baseado na infoPost
$VO = new FileVO();
if ($this->infoPost->file_info_id) {
$VO->setId($this->infoPost->file_info_id, TRUE);
}
$VO->setActive($this->infoPost->file_info_active);
$VO->setName($this->infoPost->file_info_name);
$VO->setDescription($this->infoPost->file_info_description);
$VO->setType($this->infoPost->file_info_type);
$VO->setAuthor($this->infoPost->file_info_author);
$VO->setLocale($this->infoPost->file_info_locale);
$VO->setOrder($this->infoPost->file_info_order);
//("JÁ") gera id para criar pasta onde vai ser guardado o arquivo
$ReturnResultFileVO = $VO->commit();
if ($ReturnResultFileVO->success) {
$ReturnResultFileVO->result = $VO->getId();
} else {
//erro, os motivos estão na ReturnResultVO abaixo
return $ReturnResultFileVO;
}
//pega o id da file
$FILE_ID = $VO->getId();
$ReturnResultFileVO = new ReturnResultVO();
if (isset($this->infoPost->file_data) && !$this->infoPost->file_info_id > 0) {
set_time_limit(0);
$sentFileData = $this->infoPost->file_data;
//$_FILES['Filedata'];
$name = $sentFileData['name'];
// extens�o enviada
$sentExtension = DataHandler::returnExtensionOfFile($name);
// remove caracteres escrotos
$name = DataHandler::returnFilenameWithoutExtension($name);
$name = DataHandler::removeAccent($name);
$name = DataHandler::removeSpecialCharacters($name);
$name = trim(substr($name, 0, 80));
switch ($sentFileData["type"]) {
case "text/plain":
$extension = "txt";
break;
default:
$extension = strtolower($sentExtension);
break;
}
//verifica se a pasta existe, se não existir, inventa
DataHandler::createFolderIfNotExist($this->defaultFolderForNewFiles);
// pasta de upload de files está no config.php
$tempFolder = DataHandler::removeDobleBars($this->defaultFolderForNewFiles . "/" . $FILE_ID);
DataHandler::createFolderIfNotExist($tempFolder);
$tempUrl = $tempFolder . "/" . strtolower($name . "." . $extension);
$i = 2;
while (file_exists($tempUrl)) {
$tempUrl = $tempFolder . "/" . strtolower($name . "-" . $i . "." . $extension);
$i++;
}
$VO->setUrl($tempUrl);
$ReturnResultFileVO = $VO->commit();
//Debug::li("aaa");
if ($ReturnResultFileVO->success) {
//incluir o vinculo com a linked_table e linked_table_id
//receber table
// table_id
if ($this->infoPost->table) {
$table = $this->infoPost->table;
$table_id = $this->infoPost->table_id;
include_once "library/facil3/core/dao/LinkDAO.class.php";
$LinkDAO = new LinkDAO();
//vincula a foto ao table e table_id enviado
$ReturnResultVinculoVO = $LinkDAO->insert($table, $table_id, $this->moduleName, $VO->getId(), 1);
if (!$ReturnResultVinculoVO->success) {
//deu erro ao vincular
$ReturnResultVO->success = false;
$ReturnResultVO->appendMessage($ReturnResultVinculoVO->array_messages);
return $ReturnResultVO;
}
} else {
$ReturnResultVO->addMessage(Translation::text("LibraryLanguage::WARNING_FILE_NO_LINKED_TABLE"));
}
//movendo o arquivo para sua respectiva pasta.
$localFile = $VO->getUrl();
if (!move_uploaded_file($sentFileData['tmp_name'], $localFile)) {
$ReturnResultVO->success = false;
$ReturnResultVO->addMessage(Translation::text("Arquivo não encontrado"));
return $ReturnResultVO;
} else {
$ReturnResultVO->success = TRUE;
$ReturnResultVO->result = $VO->getId();
$ReturnResultVO->addMessage(Translation::text("Arquivo gravado"));
}
} else {
return $ReturnResultFileVO;
}
return $ReturnResultVO;
} else {
$ReturnResultFileVO = new ReturnResultVO();
$ReturnResultFileVO->addMessage("Envie o Filedata");
// nao veio filedata
//.........这里部分代码省略.........
示例4: deleteDirectory
public static function deleteDirectory($urlOfDirectory)
{
$arrayExeptionFiles = array(".", "..");
try {
$result = DataHandler::listDirectory($urlOfDirectory);
foreach ($result as $item) {
$extencion = "";
if (preg_match("/\\./", $item)) {
//tem um ponto de extenção
$extencion = strtolower(DataHandler::returnExtensionOfFile($item));
}
$fileUrl = DataHandler::removeDobleBars($urlOfDirectory . "/" . $item);
if ($extencion == "") {
if (in_array($item, $arrayExeptionFiles)) {
//não fazer nada com esse
} else {
$newfolder = DataHandler::removeDobleBars($urlOfDirectory . "/" . $item);
//é um folder, vai varrer dentro do folder tb - recursivo
if (is_dir($newfolder)) {
//echo Debug::li("a pasta será varrida:".$newfolder);
self::deleteDirectory($newfolder);
} else {
unlink($newfolder);
}
}
} else {
//ve se é um arquivo a se deletar
unlink($fileUrl);
}
}
//deleta o próprio diretório enviado
rmdir($urlOfDirectory);
} catch (Exception $e) {
//mudinho
return FALSE;
}
}
示例5: foreach
break;
case "text":
$model .= "<textarea name='{$field->name}[]' id='content_{$field->name}_{$i}' cols='60' rows='10'>{$field->value}</textarea><br/>";
break;
$i++;
}
}
$model .= "</div>";
//echo "<div id='files_model' class='multi_input_model' style='display:none'>{$model}</div>";
echo "<div id='files_container'>";
$printed_fields = 0;
//Debug::print_r($HttpContentResult->arrayVariable->array_file);
$array_file = $formView->getArrayFiles();
if ($array_file) {
foreach ($array_file as $file) {
$extensao = DataHandler::returnExtensionOfFile($file->url);
//procurando o arquivo que simbolize esse icone
$filePath = Config::getRootPath("/image/get_image/url.view[,]forum[,]assets[,]img[,]file[,]file_icon[:]jpg/max_width.30/max_heigth.30");
//ve se o arquivo do icone existe
$url_ico = Config::getFolderView("assets/img/file/{$extensao}_icon.gif");
if (file_exists($url_ico)) {
$url_ico = str_replace("/", "[,]", $url_ico);
$url_ico = str_replace(".gif", "[:]gif", $url_ico);
$filePath = Config::getRootPath("/image/get_image/url.{$url_ico}/max_width.30/max_heigth.30");
}
// view/forum/assets/img/file/file_icon.jpg
// $delete_URL = Config::getRootPath("file/get_file/id.{$file->id}/max_width.150/max_heigth.150");
$data = $model;
preg_match_all("/###VALUE_([a-zA-Z_]+)###/", $model, $out);
for ($i = 0; $i < sizeof($out[0]); $i++) {
$attr = strtolower($out[1][$i]);
示例6: explode
"><?php
echo $row->id;
?>
</td>
<td>
<?php
$nome = explode("/", DataHandler::returnFilenameWithoutExtension($row->url));
$nome = $nome[count($nome) - 1];
echo $nome;
?>
</td>
<td align="center"><a href="<?php
echo $row->url;
?>
"><?php
echo strtoupper(DataHandler::returnExtensionOfFile($row->url));
?>
</a></td>
<td><?php
echo DataHandler::bytesInString(filesize($row->url));
?>
</td>
<td align="center"><?php
echo "<a href=\"" . Config::getRootPath("backend/product/delete_file/product_id." . $HttpContentResult->vo->id . "/id." . $row->id) . "\" class=\"iconlink2\"><img src=\"" . Config::getAsset('backend/assets/images/icons/small/black/close.png') . "\" alt=\"\"></a>";
?>
</td>
</tr>
<?php
}
}
?>
示例7: insert
/**
* recebe a imagem por post
* @return ReturnResultVO
*/
public function insert()
{
//inicia um retorno de ReturnResultVO
$ReturnResultVO = new ReturnResultVO();
//pega os dados baseado na infoPost
$VO = new ImageVO();
//var_dump($this->infoPost);
//exit();
if ($this->infoPost->image_info_id > 0) {
//passou o id, vai atualizar essa VO
// echo Debug::li("image_info_id >>>>>>>>>> ".$this->infoPost->image_info_id);
$VO->setId($this->infoPost->image_info_id, TRUE);
}
$VO->setActive($this->infoPost->image_info_active);
$VO->setName($this->infoPost->image_info_name);
$VO->setDescription($this->infoPost->image_info_description);
$VO->setType($this->infoPost->image_info_type);
$VO->setAuthor($this->infoPost->image_info_author);
$VO->setLocale($this->infoPost->image_info_locale);
$VO->setOrder($this->infoPost->image_info_order);
// var_dump($_FILES);
// var_dump($this->infoPost->file_data);
//comitando as infos enviadas, dados apenas
if ($VO->getId() > 0 || $this->infoPost->file_data['tmp_name']) {
//só comita a imagem se tiver ou id ou enviado o file_data, se não nem tem o que fazer
$ReturnResultImageVO = $VO->commit();
} else {
//nem enviou o id e nem o file_data, retorna
$ReturnResultVO->addMessage(Translation::text("Have nothing to commit."));
return $ReturnResultVO;
}
if ($ReturnResultImageVO->success) {
$ReturnResultImageVO->result = $VO->getId();
} else {
//erro, os motivos estão na ReturnResultVO abaixo
return $ReturnResultImageVO;
}
//pega o id da imagem
$IMAGE_ID = $VO->getId();
$ReturnResultImageVO = new ReturnResultVO();
//echo Debug::li("this->infoPost->file_data: ".$this->infoPost->file_data);
if (isset($this->infoPost->file_data) && $this->infoPost->file_data['tmp_name']) {
set_time_limit(0);
//var_dump($_FILES);
$sentFileData = $this->infoPost->file_data;
//$_FILES['Filedata'];
$name = $sentFileData['name'];
// extens�o enviada
$sentExtension = DataHandler::returnExtensionOfFile($name);
// remove caracteres escrotos
$name = DataHandler::returnFilenameWithoutExtension($name);
$name = DataHandler::removeAccent($name);
$name = DataHandler::removeSpecialCharacters($name);
$name = trim(substr($name, 0, 80));
switch ($sentFileData["type"]) {
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$extension = "jpg";
break;
case "image/gif":
$extension = "gif";
break;
case "image/png":
case "image/x-png":
$extension = "png";
break;
case "image/bmp":
$extension = "bmp";
break;
default:
$extension = strtolower($sentExtension);
break;
}
//verifica se a pasta existe, se não existir, inventa
DataHandler::createFolderIfNotExist($this->defaultFolderForNewImages);
// pasta de upload de imagens est� no config.php
$tempFolder = DataHandler::removeDobleBars($this->defaultFolderForNewImages . "/" . $IMAGE_ID);
DataHandler::createFolderIfNotExist($tempFolder);
//echo Debug::li("name: $name");
$tempUrl = $tempFolder . "/original_" . strtolower($name . "." . $extension);
//echo Debug::li("tempUrl: $tempUrl");
//exit();
$i = 2;
while (file_exists($tempUrl)) {
$tempUrl = $tempFolder . "/original_" . strtolower($name . "-" . $i . "." . $extension);
$i++;
}
$VO->setUrl($tempUrl);
$ReturnResultImageVO = $VO->commit();
//Debug::li("aaa");
//Debug::print_r($ReturnResultImageVO);
if ($ReturnResultImageVO->success) {
//incluir o vinculo com a linked_table e linked_table_id
//receber table
// table_id
//.........这里部分代码省略.........
示例8: create_watermark
/**
* @param $main_img_src src da imagem que vai ter marca dagua
* @param $watermark_img_src src do PNG da imagem que será usada como marca dagua
* @param $new_image_path src da imagem que deve resultar já com marca dagua
* @param $alpha_level transparencia da marca dagua
* @return void
*/
public static function create_watermark($main_img_src, $watermark_img_src, $new_image_path, $alpha_level = 100)
{
$main_img_obj = self::imageCreateFromX($main_img_src);
$watermark_img_obj = self::imageCreateFromX($watermark_img_src);
// gambiarra q transforma a imagem de fundo em jpg caso ela e a merca d'agua sejam .png para evitar zica
$type_main_img = DataHandler::returnExtensionOfFile($main_img_src);
$type_watermark_img = DataHandler::returnExtensionOfFile($watermark_img_src);
if ($type_main_img == "png" && $type_main_img == "png") {
$outputFile = str_replace(".jpg", ".png", $main_img_src);
// print_r($outputFile);exit;
imagejpeg($main_img_obj, $outputFile);
imagedestroy($main_img_obj);
$main_img_obj = imagecreatefromjpeg($outputFile);
}
// fim da gambiarra
$alpha_level /= 100;
# convert 0-100 (%) alpha to decimal
# calculate our images dimensions
$main_img_obj_w = imagesx($main_img_obj);
$main_img_obj_h = imagesy($main_img_obj);
$watermark_img_obj_w = imagesx($watermark_img_obj);
$watermark_img_obj_h = imagesy($watermark_img_obj);
# determine center position coordinates
$main_img_obj_min_x = floor($main_img_obj_w / 2 - $watermark_img_obj_w / 2);
$main_img_obj_max_x = ceil($main_img_obj_w / 2 + $watermark_img_obj_w / 2);
$main_img_obj_min_y = floor($main_img_obj_h / 2 - $watermark_img_obj_h / 2);
$main_img_obj_max_y = ceil($main_img_obj_h / 2 + $watermark_img_obj_h / 2);
# create new image to hold merged changes
$return_img = imagecreatetruecolor($main_img_obj_w, $main_img_obj_h);
# walk through main image
for ($y = 0; $y < $main_img_obj_h; $y++) {
for ($x = 0; $x < $main_img_obj_w; $x++) {
$return_color = NULL;
# determine the correct pixel location within our watermark
$watermark_x = $x - $main_img_obj_min_x;
$watermark_y = $y - $main_img_obj_min_y;
# fetch color information for both of our images
$main_rgb = imagecolorsforindex($main_img_obj, imagecolorat($main_img_obj, $x, $y));
# if our watermark has a non-transparent value at this pixel intersection
# and we're still within the bounds of the watermark image
if ($watermark_x >= 0 && $watermark_x < $watermark_img_obj_w && $watermark_y >= 0 && $watermark_y < $watermark_img_obj_h) {
$watermark_rbg = imagecolorsforindex($watermark_img_obj, imagecolorat($watermark_img_obj, $watermark_x, $watermark_y));
# using image alpha, and user specified alpha, calculate average
$watermark_alpha = round((127 - $watermark_rbg['alpha']) / 127, 2);
$watermark_alpha = $watermark_alpha * $alpha_level;
# calculate the color 'average' between the two - taking into account the specified alpha level
$avg_red = self::_get_ave_color($main_rgb['red'], $watermark_rbg['red'], $watermark_alpha);
$avg_green = self::_get_ave_color($main_rgb['green'], $watermark_rbg['green'], $watermark_alpha);
$avg_blue = self::_get_ave_color($main_rgb['blue'], $watermark_rbg['blue'], $watermark_alpha);
# calculate a color index value using the average RGB values we've determined
$return_color = self::_get_image_color($return_img, $avg_red, $avg_green, $avg_blue);
# if we're not dealing with an average color here, then let's just copy over the main color
} else {
$return_color = imagecolorat($main_img_obj, $x, $y);
}
# END if watermark
# draw the appropriate color onto the return image
imagesetpixel($return_img, $x, $y, $return_color);
}
# END for each X pixel
}
# END for each Y pixel
# display our watermarked image - first telling the browser that it's a JPEG,
# and that it should be displayed inline
// header( 'Content-Type: image/jpeg' );
// header( 'Content-Disposition: inline; filename=' . $_GET['src'] );
//imagejpeg( $return_img, $new_image_path, 100);
self::imageX($return_img, $new_image_path, 100);
}