Ejemplo n.º 1
0
 function valida_campos($requeridos)
 {
     $erros = array();
     // Se tem o parâmetro captcha, e for "true", valida o captcha
     if (isset($this->dados['recaptcha_response_field'])) {
         if (!$this->my_captcha->validar()) {
             $erros[] = 'Preencha o corretamente o Captcha.';
         }
     }
     // Valida os campos
     $requeridos = (array) explode(',', $requeridos);
     foreach ($requeridos as $k => $campo) {
         $requeridos[$k] = MY_Utils::removeSpecialChars(strtolower($campo));
     }
     foreach ($this->dados as $campo => $valor) {
         $valor_do_campo = MY_Utils::removeSpecialChars(strtolower(trim($valor)), true);
         if (strlen($valor_do_campo) == 0 || $valor_do_campo == $campo) {
             if (in_array($campo, $requeridos)) {
                 $label = ucfirst(str_replace('_', ' ', $campo));
                 $erros[] = 'O campo ' . $label . ' é de preenchimento obrigatório.';
             } elseif (MY_Utils::removeSpecialChars(strtolower($campo)) == 'email') {
                 vdie($email);
             } else {
                 $this->dados[$campo] = '';
             }
         }
     }
     return $erros;
 }
Ejemplo n.º 2
0
 /**
  * Função para redimensionar imagens
  * @param ($_FILE) $tmp_file - Arquivo que veio no post do form
  * @param (string) $dest_img - Destino da imagem
  * @param (int) $maxW - Largura máxima
  * @param (int) $maxH - Altura máxima
  * @return (bool) - Sucesso
  */
 public static function redimensionar_imagem($tmp_file, $dest_img, $maxW, $maxH, $keepRatio = true)
 {
     if (!is_file($tmp_file['tmp_name'])) {
         vdie($tmp_file['tmp_name'] . ' não existe.');
     }
     if ($keepRatio) {
         // Dimensões originais
         list($width, $height) = getimagesize($tmp_file['tmp_name']);
         // Limites
         $max_width = $maxW > 0 ? $maxW : $width;
         $max_height = $maxH > 0 ? $maxH : $height;
         // Novas dimensões
         list($new_height, $new_width) = MY_Utils::calcular_novas_dimensoes($height, $width, $max_height, $max_width);
         $new_width = $maxW > 0 ? $maxW : $max_width;
         $new_height = $maxH > 0 ? $maxH : $max_heigth;
     } else {
         // Dimensões originais
         list($width, $height) = getimagesize($tmp_file['tmp_name']);
         // Limites
         $max_width = $maxW > 0 ? $maxW : $width;
         $max_height = $maxH > 0 ? $maxH : $height;
         // Novas dimensões
         list($new_height, $new_width) = MY_Utils::calcular_novas_dimensoes_2($height, $width, $max_height, $max_width);
     }
     // Converte/redimensiona
     $tmp_img = $tmp_file['tmp_name'];
     if (copy($tmp_img, $dest_img) && is_file($tmp_img)) {
         // Chama o arquivo com a classe WideImage
         require_once 'WideImage/lib/WideImage.php';
         // Carrega a imagem a ser manipulada
         $image = WideImage::load($tmp_img);
         // Redimensiona a imagem
         $image = $image->resize($new_width, $new_height);
         if (!$keepRatio) {
             // Corta a imagem
             $image = $image->crop(0, 0, $maxW, $maxH);
         }
         // JPG to progressive
         if (array_pop(explode('.', $dest_img)) == 'jpg') {
             imageinterlace($image->getHandle(), true);
         }
         // Salva a imagem em um arquivo (novo ou não)
         $image->saveToFile($dest_img);
     } else {
         vdie('Não foi possível gravar a imagem no servidor.');
     }
     // Se ok
     $ok = is_file($dest_img);
     if (!$ok) {
         vdie('Não foi possível receber a imagem no servidor.');
     }
     return $ok;
 }
Ejemplo n.º 3
0
    vdie('Unknown vendor', $pretty);
}
if (!preg_match('/^[a-z0-9\\-\\.]+$/Di', $module)) {
    vdie('Unknown module', $pretty);
}
if (!preg_match('/^[0-9\\.(\\-rc|\\-svn|)]+$/Di', $version)) {
    vdie('Unknown version for ' . $vendor . '/' . $module, $pretty);
}
$recent = array();
$recent = getLatestFroxlorVersion($vendor, $module, $version);
updateStats($vendor, $module, $version);
if (isset($recent['error']) && $recent['error'] == true) {
    if (isset($recent['message'])) {
        vdie($recent['message'], $pretty);
    } else {
        vdie(null, $pretty);
    }
} else {
    $out = '';
    if ($recent['has_latest']) {
        if ($pretty) {
            $out .= '<ul>
				<li>Your version: <strong>' . $version . '</strong></li>
				<li>Latest version: <strong>' . trim($recent['version']) . '</strong></li>
				<li>&nbsp;</li>';
            if ($recent['is_testing']) {
                $out .= '<li><strong>You already have the latest testing version of Froxlor installed.</strong></li>';
            } else {
                $out .= '<li><strong>You already have the latest version of Froxlor installed.</strong></li>';
            }
            $out .= '</ul>';