예제 #1
0
function Newnews(&$smarty, &$form)
{
    $news = new Noticias($smarty, $form);
    if (isset($form['page'])) {
        if (is_array($_FILES)) {
            ## se há arquivos enviados.
            foreach ($_FILES as $nome => $file) {
                $arquivo = new Arquivo();
                $arquivo->SetOrigem($file['tmp_name']);
                $arquivo->SetDestino(NOTICIAS_DIR_IMG);
                $arquivo->SetPropriedades($file);
                if ($arquivo->error) {
                    return $smarty->getFinishError($arquivo->error);
                }
                if ($arquivo->SetMimetype($arquivo->prop['filename'], array('jpg', 'jepg', 'gif', 'png'), $file['type']) == true) {
                    return $smarty->getFinishError('ERROR_017');
                }
                if ($arquivo->UploadFile() == true) {
                    return $smarty->getFinishError('ERROR_021');
                }
                $thb[$nome] = $arquivo->Thumbnail(NOTICIAS_THB_SIZE);
                $arquivo->FileLogs($nome);
                $form[$nome] = $arquivo->filelog[$nome]['filename'];
                $form[$nome . '_thb'] = $thb[$nome]['thb_name'];
            }
        }
        return $news->NewNoticias($smarty, $form);
    }
}
예제 #2
0
 function EditNews(&$smarty, $idde, $form)
 {
     unset($form[idde]);
     $tabela = $smarty->cfg['prefix'] . 'news';
     $form = Check::RegForm($form);
     if (is_numeric($idde)) {
         if (is_array($_FILES)) {
             foreach ($_FILES as $nome => $file) {
                 if ($file['tmp_name'] == '') {
                     continue;
                 }
                 $result = $this->SqlSelect("SELECT {$nome},{$nome}_thb FROM {$tabela} WHERE ID_NEWS = '{$idde}'");
                 $item = mysql_fetch_array($result, MYSQL_ASSOC);
                 unlink(realpath(NOTICIAS_DIR_IMG . '/' . $item[$nome]));
                 unlink(realpath(NOTICIAS_DIR_IMG . THUMBNAIL_DIR_IMG . '/' . $item[$nome . '_thb']));
                 $arquivo = new Arquivo();
                 $arquivo->SetOrigem($file['tmp_name']);
                 $arquivo->SetDestino(NOTICIAS_DIR_IMG);
                 $arquivo->SetPropriedades($file);
                 if ($arquivo->error) {
                     return $smarty->getFinishError($arquivo->error);
                 }
                 if ($arquivo->SetMimetype($arquivo->prop['filename'], array('jpg', 'jepg', 'gif', 'png'), $file['type']) == true) {
                     return $smarty->getFinishError('ERROR_017');
                 }
                 if ($arquivo->UploadFile() == true) {
                     return $smarty->getFinishError('ERROR_021');
                 }
                 $thb[$nome] = $arquivo->Thumbnail(NOTICIAS_THB_SIZE);
                 $arquivo->FileLogs($nome);
                 $form[$nome] = $arquivo->filelog[$nome]['filename'];
                 $form[$nome . '_thb'] = $thb[$nome]['thb_name'];
             }
         }
         $sql = $this->SqlUpdate($tabela, $form, "ID_NEWS = '{$idde}'");
         $request = $this->SqlSelect($sql);
         if ($request != 1) {
             return $request;
         }
     }
 }