コード例 #1
0
ファイル: configure.php プロジェクト: MarcelvC/phplist3
    }
    print '>';
    print $GLOBALS['I18N']->get('Yes');
    print '  </option>';
    print '<option value="false" ';
    if ($value === false || $value == 'false' || $value == 0) {
        print 'selected="selected"';
    }
    print '>';
    print $GLOBALS['I18N']->get('No');
    print '  </option>';
    print '</select>';
} elseif ($configItem['type'] == 'image') {
    print '<br/><p>' . s('Please upload an image file, PNG or JPG.') . '</p>';
    include 'class.image.inc';
    $image = new imageUpload();
    printf('<input type="hidden" name="values[%s]" value="%s" />', $id, $value);
    ## to trigger the saving of the value
    print $image->showInput($id, $value, 0);
} else {
    print s('Don\'t know how to handle type ' . $configItem['type']);
}
if (isset($_GET['ret']) && $_GET['ret'] == 'catlists') {
    print '<input type="hidden" name="ret" value="catlists" />';
}
print '<input type="hidden" name="save" value="item_' . $id . '" />
<button class="submit" type="submit" name="savebutton">' . s('save changes') . '</button>';
## for cancellation, we use a reset button, but that will reset all values in the entire page
## https://mantis.phplist.org/view.php?id=16924
## UX wise, it would be good to close the editing DIV again.
print '<button class="dontsavebutton" id="dontsaveitem_' . $id . '" type="reset">' . s('undo') . '</button>';
コード例 #2
0
ファイル: template.php プロジェクト: narareddy/phplist3
 ## ##17419 don't prompt for remote images that exist
 $missingImages = array();
 while (list($key, $val) = each($images)) {
     $key = trim($key);
     if (preg_match('~^https?://~i', $key)) {
         $imageFound = testUrl($key);
         if (!$imageFound) {
             $missingImages[$key] = $val;
         }
     } else {
         $missingImages[$key] = $val;
     }
 }
 if (sizeof($missingImages) && empty($_POST['sendtest'])) {
     include dirname(__FILE__) . "/class.image.inc";
     $image = new imageUpload();
     print "<h3>" . $GLOBALS['I18N']->get('Images') . '</h3><p class="information">' . $GLOBALS['I18N']->get('Below is the list of images used in your template. If an image is currently unavailable, please upload it to the database.') . "</p>";
     print '<p class="information">' . $GLOBALS['I18N']->get('This includes all images, also fully referenced ones, so you may choose not to upload some. If you upload images, they will be included in the campaigns that use this template.') . "</p>";
     print formStart('enctype="multipart/form-data" class="template1" ');
     print '<input type="hidden" name="id" value="' . $id . '" />';
     ksort($images);
     reset($images);
     while (list($key, $val) = each($images)) {
         $key = trim($key);
         if (preg_match('~^https?://~i', $key)) {
             $missingImage = true;
             $imageFound = testUrl($key);
             if ($imageFound != 200) {
                 printf($GLOBALS['I18N']->get('Image name:') . ' <b>%s</b> (' . $GLOBALS['I18N']->get('%d times used') . ')<br/>', $key, $val);
                 print $image->showInput($key, $val, $id);
             }
コード例 #3
0
ファイル: connect.php プロジェクト: gillima/phplist3
function SaveConfig($item, $value, $editable = 1, $ignore_errors = 0)
{
    global $tables;
    ## in case DB hasn't been initialised
    if (empty($_SESSION['hasconf'])) {
        $_SESSION['hasconf'] = Sql_Table_Exists($tables['config']);
    }
    if (empty($_SESSION['hasconf'])) {
        return;
    }
    if (isset($GLOBALS['default_config'][$item])) {
        $configInfo = $GLOBALS['default_config'][$item];
    } else {
        $configInfo = array('type' => 'unknown', 'allowempty' => true, 'value' => '');
    }
    ## to validate we need the actual values
    $value = str_ireplace('[domain]', $GLOBALS['domain'], $value);
    $value = str_ireplace('[website]', $GLOBALS['website'], $value);
    switch ($configInfo['type']) {
        case 'boolean':
            if ($value == 'false' || $value == 'no') {
                $value = 0;
            } elseif ($value == 'true' || $value == 'yes') {
                $value = 1;
            }
            break;
        case 'integer':
            $value = sprintf('%d', $value);
            if ($value < $configInfo['min']) {
                $value = $configInfo['min'];
            }
            if ($value > $configInfo['max']) {
                $value = $configInfo['max'];
            }
            break;
        case 'email':
            if (!empty($value) && !is_email($value)) {
                ## hmm, this is displayed only later
                # $_SESSION['action_result'] = s('Invalid value for email address');
                return $configInfo['description'] . ': ' . s('Invalid value for email address');
                $value = '';
            }
            break;
        case 'emaillist':
            $valid = array();
            $hasError = false;
            $emails = explode(',', $value);
            foreach ($emails as $email) {
                if (is_email($email)) {
                    $valid[] = $email;
                } else {
                    $hasError = true;
                }
            }
            $value = implode(',', $valid);
            /*
             * hmm, not sure this is good or bad for UX
             *
             */
            if ($hasError) {
                return $configInfo['description'] . ': ' . s('Invalid value for email address');
            }
            break;
        case 'image':
            include 'class.image.inc';
            $image = new imageUpload();
            $imageId = $image->uploadImage($item, 0);
            if ($imageId) {
                $value = $imageId;
            }
            ## we only use the image type for the logo
            flushLogoCache();
    }
    ## reset to default if not set, and required
    if (empty($configInfo['allowempty']) && empty($value)) {
        $value = $configInfo['value'];
    }
    if (!empty($configInfo['hidden'])) {
        $editable = 0;
    }
    ## force reloading config values in session
    unset($_SESSION['config']);
    ## and refresh the config immediately https://mantis.phplist.com/view.php?id=16693
    unset($GLOBALS['config']);
    Sql_Query(sprintf('replace into %s set item = "%s", value = "%s", editable = %d', $tables['config'], sql_escape($item), sql_escape($value), $editable));
    return false;
    ## true indicates error, and which one
}
コード例 #4
0
ファイル: CFileManager.php プロジェクト: habibu/YiiCommerce
 /**
  * Salva um arquivo dentro da pasta específica
  * @param $file
  * @param $file_name
  * @param $directory
  * @return boolean
  */
 public function upload(CUploadedFile $file, $file_name = NULL, $directory = NULL)
 {
     /**
      * Para cada item do array de configuração de corte
      * o método tratará a imagem como configurado
      */
     try {
         Yii::log("CApiFileManager ::: INICIANDO O ARMAZENAMENTO DO ARQUIVO ");
         if (!is_dir($this->upload_path)) {
             $const_path = ABSOLUTE_PATH_UPLOAD;
             throw new CHttpException(500, "O diretório de upload de arquivo é inválido {$const_path} | {$this->upload_path}");
         }
         $caminho = $this->upload_path;
         if (!is_null($directory)) {
             // $array_directory= explode('/', $directory);
             // @todo Testar código abaixo para garantir integridade das pastas
             /**
              * foreach($array_directory as $dir_name)
              * 		$dir_name= normalize($dir_name)
              * 
              * $directory= implode('/', $array_directory);
              */
             /*
              * Verificar se o diretório não existe: Caso não exista, criar este diretório
              */
             if (!is_dir("{$caminho}/{$directory}/")) {
                 $novo_caminho = @mkdir("{$caminho}/{$directory}/", 0777, true);
                 if (!$novo_caminho) {
                     throw new Exception("Falha ao criar diretorio {$caminho}/{$directory}/");
                 }
                 $caminho = "{$caminho}/{$directory}/";
             } else {
                 $caminho = "{$caminho}/{$directory}/";
             }
         }
         // Atualizar a variavel com o novo caminho de upload
         $this->upload_path = $caminho;
         if (is_null($file_name)) {
             $nome_do_arquivo = $this->getNewFileName($file);
         } else {
             $nome_do_arquivo = $this->normalize($file_name);
         }
         $caminho_para_salvar_arquivo = "{$caminho}/{$nome_do_arquivo}";
         if (!$file->saveAs($caminho_para_salvar_arquivo)) {
             throw new Exception("Falha ao salvar arquivo como {$caminho}/{$nome_do_arquivo}");
         }
         // A rotina abaixo deve ser realizada somente em casos de imagem
         if (in_array($file->getType(), array("image/gif", "image/png", "image/bmp", "image/jpeg", "image/tiff"))) {
             Yii::import("application.components.SystemService.lib.*");
             foreach ($this->image_crop_configuration as $crop_configuration) {
                 $thumb = new imageUpload("{$caminho}/{$nome_do_arquivo}");
                 if (array_key_exists("width", $crop_configuration)) {
                     $thumb->size_auto($crop_configuration["width"]);
                 }
                 $thumb->jpeg_quality($crop_configuration["quality"]);
                 $thumb->save("{$caminho}/{$crop_configuration['prefix']}{$nome_do_arquivo}");
                 Yii::log("CApiFileManager ::: O arquivo {$crop_configuration['prefix']}{$nome_do_arquivo} foi mantido no disco");
             }
             if (!$this->keep_original_image_file) {
                 // A imagem original deve ser removida após os cortes serem executados
                 $this->delete($nome_do_arquivo, $directory);
             }
         } else {
             Yii::log("CApiFileManager ::: O arquivo nao possui um tipo permitido");
         }
     } catch (Exception $e) {
         Yii::log("CApiFileManager ::: {$e->getMessage()} ");
         return false;
     }
     $this->file_name = $nome_do_arquivo;
     return true;
 }
コード例 #5
0
ファイル: 14.1_upload.php プロジェクト: yasoon/yasoon
require_once 'image_lib/upload_class.php';
// *** Step 1 of 2) Set up the variables
$formInputName = 'img-upload';
# This is the name given to the form's file input
$savePath = 'output3';
# The folder to save the image
$saveName = 'test';
# Without ext
$allowedExtArray = array('.jpg', '.png', '.gif', '.bmp');
# Set allowed file types
$imageQuality = 100;
// *** If the form has been submitted...
if (isset($_POST['submit'])) {
    $error = '';
    // *** Create object
    $uploadObj = new imageUpload($formInputName, $savePath, $saveName, $allowedExtArray);
    // *** If everything is swell, continue...
    if ($uploadObj->getIsSuccessful()) {
        #=------------------------------------------------------------------
        // *** Step 2 of 2) Add your image processing code here.
        $uploadObj->resizeImage(100, 100, 'crop');
        $uploadObj->greyScaleDramatic();
        #=------------------------------------------------------------------
        $uploadObj->saveImage($uploadObj->getTargetPath(), $imageQuality);
    } else {
        // *** If there was an error, save it.
        $error = $uploadObj->getError();
    }
}
?>
<!DOCTYPE html>
コード例 #6
0
ファイル: avatar.php プロジェクト: LukeXF/vision
<?php

if (isset($_GET['pic'])) {
    // load classes
    require_once '../../lib/config.php';
    require_once '../../classes/siteFunctions.php';
    require_once '../../classes/ImageUpload.php';
    // initialize classes
    $siteFunctions = new siteFunctions();
    $imageUpload = new imageUpload();
    $pic = $imageUpload->getUsersAvatar($_GET['pic']);
    if ($pic == false) {
        $pic = imagecreatefromjpeg('avatars_backend/logo.jpg');
        // $size = getimagesize($pic);
        header('Content-Type: image/jpeg');
        imagejpeg($pic);
        imagedestroy($pic);
    } else {
        $pic = 'avatars_backend/' . $imageUpload->thumb_image_prefix . $pic;
        $size = getimagesize($pic);
        header('Content-Type: ' . $size['mime']);
    }
    // $siteFunctions->debug($size);
    //Read the image and send it directly to the output.
    readfile($pic);
}