|
Visualizando código
Postado por LUIZ CREMEPE em 10/03/2010 20:40:32.
http://paste.lymas.com.br/1117
<?php require_once('../Connections/connBaseAntiga.php'); ?>
<?php
require("sessao.php");
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
}
}
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
?>
<?php
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frm_not")) {
// variáveis criadas para o funcionamento do upload //
$imagem_type = $_FILES['type'];
$arquivo = $_FILES['not_imagem'];
$vetFile = explode('.',$_FILES[$id_arquivo]['name']);
$extensao = $vetFile[count($vetFile)-1];
//gera nome da foto da noticia atraves do titulo da noticia
$arquivo_nome = 'not'.'_'.date('d_m_Y').'_'.md5(rand(1,9182930495).date('ymdhsi')).$extensao;
//$arquivo_nome = 'not'.'_'.date('d_m_Y').'_'.md5(rand(1,9182930495).date('ymdhsi'));
//diretorio aonde salvara as imagens
$caminho_imagem = "imgs_not/".$arquivo_nome;
if( $imagem_type <> 'image/gif' AND
$imagem_type <> 'image/pjpeg' AND
$imagem_type <> 'image/jpeg' AND
$imagem_type <> 'image/png') {
/*verifica o tipo da imagem*/
$erros=1;
$Mensagem = "Tipo de arquivo inválido";
}
}
// variáveis upLoad //
$insertSQL = sprintf("INSERT INTO tb_noticia (sinopse_noticia,
titulo_noticia,
texto_noticia,
imagem_not,
login_usuario,
dt_cadastro,
id_destaque,
id_status,
cd_secao)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['not_sinopse'], "text"),
GetSQLValueString($_POST['not_titulo'], "text"),
GetSQLValueString($_POST['not_texto'], "text"),
GetSQLValueString($arquivo_nome, "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString (date('Y-m-d'), "text"),
GetSQLValueString($_POST['not_destaque'], "text"),
GetSQLValueString($_POST['not_status'], "text"),
GetSQLValueString('1', "text"));
//código Upload //
$diretorio = "imgs_not";
$id_arquivo = "not_imagem";
// $nome_arquivo = $_FILES[$id_arquivo]['name'];
$arquivo_temporario = $_FILES[$id_arquivo]["tmp_name"];
//fim código Upload //
/*
$insertSQL = sprintf("INSERT INTO tb_noticia (titulo_noticia, sinopse_noticia, texto_noticia, imagem_not, login_usuario, dt_cadastro, id_destaque, id_status, cd_secao) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['not_titulo'], "text"),
GetSQLValueString($_POST['not_sinopse'], "text"),
GetSQLValueString($_POST['not_texto'], "text"),
GetSQLValueString($_POST['not_imagem'], "text"),
GetSQLValueString($_POST['not_login_usuario'], "text"),
GetSQLValueString($_POST['not_destaque'], "date"),
GetSQLValueString($_POST['not_destaque'], "text"),
GetSQLValueString($_POST['not_status'], "text"),
GetSQLValueString($_POST['not_status'], "int"));*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Projeto: Portal de Notícias [ Área Administrativa ]</title>
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<link href="css/style_portal_admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="global">
<div id="topo">
<h1>G.NEWS</h1>
</div>
<!-- / Head -->
<div id="menu">
<ul>
<li><a href="indexNews.php" class="bts_Menu_Horiz">Listar Notícias</a></li>
<li><a href="noticia_inserir.php" class="bts_Menu_Horiz">Cadastrar Notícia</a></li>
<li><a href="indexClipping.php" class="bts_Menu_Horiz">Listar Clipping</a></li>
<li><a href="clipping_inserir.php" class="bts_Menu_Horiz">Cadastrar Clipping</a></li>
<li id="bemvindo">Bem vindo(a),<strong> <?php echo $_SESSION['usuario']; ?></strong>.</li>
<li><a href=" <?php echo $logoutAction ?>" class="bts_Menu_Horiz">Sair</a></li>
</ul>
</div>
<!-- / Menu -->
<div id="conteudo_admin">
<div id="box_Titulos2"> <h1>Cadastrar Notícia</h1></div>
<div id="box_centraliza_forms">
<form action=" <?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="frm_not" id="frm_not" onsubmit="return submitForm();">
<table align="center" width="695px">
<tr valign="baseline">
<td colspan="2" nowrap><strong>Chapeú:</strong></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap><input name="not_sinopse" type="text" id="not_sinopse" value="" size="60%" /></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap> </td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap><strong>Título:</strong></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap><input type="text" name="not_titulo" value="" size="60%"></td>
</tr>
<tr valign="baseline">
<td colspan="2" valign="top" nowrap> </td>
</tr>
<tr valign="baseline">
<td colspan="2" valign="top" nowrap><strong>Matéria:</strong></td>
</tr>
<tr valign="baseline">
<td colspan="2" valign="top" nowrap><textarea name="not_texto" rows="25" id="not_texto"></textarea></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap> </td>
</tr>
<tr valign="baseline">
<td width="63" nowrap><strong>Imagem:</strong></td>
<td width="556" nowrap><input type="file" name="not_imagem" id="not_imagem" /></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap> </td>
</tr>
<tr valign="baseline">
<td nowrap><strong>Destaque:</strong></td>
<td nowrap><select name="not_destaque">
<option value="M">Ativo</option>
<option value="D" selected="selected">Inativo</option>
</select></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap> </td>
</tr>
<tr valign="baseline">
<td nowrap><strong>Status:</strong></td>
<td nowrap><select name="not_status">
<option value="A">Ativo</option>
<option value="I" selected="selected">Inativo</option>
</select></td>
</tr>
<tr valign="baseline">
<td colspan="2" nowrap> </td>
</tr>
<tr valign="baseline">
<td colspan="2" align="center" nowrap><div id="box"><input type="submit" class="bts" value="Cadastrar Notícia" /></div></td>
</tr>
</table>
<input type="hidden" name="not_usuario_id" />
<input type="hidden" name="MM_insert" value="frm_not" />
<input name="usuario" type="hidden" value=" <?php echo $_SESSION['login']; ?>" />
</form></div>
</div>
<!-- / Conteudo Admin -->
<div id="rodape">
<h4>Rodapé</h4>
</div>
<!-- / Rodapé -->
</div>
<!-- / Global -->
</body>
</html>
Colando um novo código
|