Voltar para Paste Lymas | pasteLog v. 2.0-alpha

Visualizando código



Postado por LUIZ CREMEPE em 10/03/2010 20:40:32.
http://paste.lymas.com.br/1117

Clique AQUI para fazer download do código. Esconder número da linha

  1. <?php require_once('../Connections/connBaseAntiga.php'); ?>
  2. <?php
  3.     session_start();
  4.     require("sessao.php");
  5. ?>
  6. <?php
  7. if (!function_exists("GetSQLValueString")) {
  8. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  9. {
  10.   if (PHP_VERSION < 6) {
  11.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  12.   }
  13.  
  14.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  15.  
  16.   switch ($theType) {
  17.     case "text":
  18.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  19.       break;    
  20.     case "long":
  21.     case "int":
  22.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  23.       break;
  24.     case "double":
  25.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  26.       break;
  27.     case "date":
  28.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  29.       break;
  30.     case "defined":
  31.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  32.       break;
  33.   }
  34.   return $theValue;
  35. }
  36. }
  37.  
  38. // ** Logout the current user. **
  39. $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
  40. if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  41.   $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
  42. }
  43.  
  44. if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  45.   //to fully log out a visitor we need to clear the session varialbles
  46.   $_SESSION['MM_Username'] = NULL;
  47.   $_SESSION['MM_UserGroup'] = NULL;
  48.   $_SESSION['PrevUrl'] = NULL;
  49.   unset($_SESSION['MM_Username']);
  50.   unset($_SESSION['MM_UserGroup']);
  51.   unset($_SESSION['PrevUrl']);
  52.    
  53.   $logoutGoTo = "index.php";
  54.   if ($logoutGoTo) {
  55.     header("Location: $logoutGoTo");
  56.     exit;
  57.   }
  58. }
  59. ?>
  60. <?php
  61. $editFormAction = $_SERVER['PHP_SELF'];
  62. if (isset($_SERVER['QUERY_STRING'])) {
  63.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  64. }
  65. ?>
  66. <?php
  67. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frm_not")) {
  68.        
  69.         if(is_uploaded_file($_FILES['not_imagem']['tmp_name'])){
  70.         // variáveis criadas para o funcionamento do upload //
  71.         $imagem_type = $_FILES['type'];
  72.         $arquivo = $_FILES['not_imagem'];
  73.         $vetFile = explode('.',$_FILES[$id_arquivo]['name']);
  74.         $extensao = $vetFile[count($vetFile)-1];
  75.         //gera nome da foto da noticia atraves do titulo da noticia
  76.         $arquivo_nome = 'not'.'_'.date('d_m_Y').'_'.md5(rand(1,9182930495).date('ymdhsi')).$extensao;
  77.        
  78.         //$arquivo_nome = 'not'.'_'.date('d_m_Y').'_'.md5(rand(1,9182930495).date('ymdhsi'));
  79.  
  80.         //diretorio aonde salvara as imagens
  81.         $caminho_imagem = "imgs_not/".$arquivo_nome;
  82.  
  83.          if( $imagem_type <> 'image/gif' AND
  84.              $imagem_type <> 'image/pjpeg' AND
  85.              $imagem_type <> 'image/jpeg' AND
  86.              $imagem_type <> 'image/png') {
  87.           /*verifica o tipo da imagem*/
  88.           $erros=1;
  89.           $Mensagem = "Tipo de arquivo inválido";
  90.         }      
  91.     }
  92.    
  93.     // variáveis upLoad //
  94.     $insertSQL = sprintf("INSERT INTO tb_noticia (sinopse_noticia,
  95.                                                   titulo_noticia,
  96.                                                   texto_noticia,
  97.                                                   imagem_not,
  98.                                                   login_usuario,
  99.                                                   dt_cadastro,
  100.                                                   id_destaque,
  101.                                                   id_status,
  102.                                                   cd_secao)
  103.                          VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
  104.                        GetSQLValueString($_POST['not_sinopse'], "text"),
  105.                        GetSQLValueString($_POST['not_titulo'], "text"),
  106.                        GetSQLValueString($_POST['not_texto'], "text"),
  107.                        GetSQLValueString($arquivo_nome, "text"),
  108.                        GetSQLValueString($_POST['usuario'], "text"),
  109.                        GetSQLValueString(date('Y-m-d'), "text"),
  110.                        GetSQLValueString($_POST['not_destaque'], "text"),
  111.                        GetSQLValueString($_POST['not_status'], "text"),
  112.                        GetSQLValueString('1', "text"));
  113.  
  114.   //código Upload //  
  115.   $diretorio = "imgs_not";
  116.   $id_arquivo = "not_imagem";
  117.  // $nome_arquivo = $_FILES[$id_arquivo]['name'];
  118.   $arquivo_temporario = $_FILES[$id_arquivo]["tmp_name"];
  119.   move_uploaded_file($arquivo_temporario, "$diretorio/arquivo_nome");
  120.   //fim código Upload //
  121.    
  122.     /*
  123.   $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)",
  124.                        GetSQLValueString($_POST['not_titulo'], "text"),
  125.                        GetSQLValueString($_POST['not_sinopse'], "text"),
  126.                        GetSQLValueString($_POST['not_texto'], "text"),
  127.                        GetSQLValueString($_POST['not_imagem'], "text"),
  128.                        GetSQLValueString($_POST['not_login_usuario'], "text"),
  129.                        GetSQLValueString($_POST['not_destaque'], "date"),
  130.                        GetSQLValueString($_POST['not_destaque'], "text"),
  131.                        GetSQLValueString($_POST['not_status'], "text"),
  132.                        GetSQLValueString($_POST['not_status'], "int"));*/
  133.  
  134.   mysql_select_db($database_connBaseAntiga, $connBaseAntiga);
  135.   $Result1 = mysql_query($insertSQL, $connBaseAntiga) or die(mysql_error());
  136. }
  137. ?>
  138. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  139. <html xmlns="http://www.w3.org/1999/xhtml">
  140. <head>
  141. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  142. <title>Projeto: Portal de Not&iacute;cias [ &Aacute;rea Administrativa ]</title>
  143. <script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
  144. <script type="text/javascript">
  145.     tinyMCE.init({
  146.         // General options
  147.         mode : "textareas",
  148.         theme : "advanced",
  149.         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",
  150.  
  151.         // Theme options
  152.         theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
  153.         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",
  154.         theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
  155.         theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
  156.         theme_advanced_toolbar_location : "top",
  157.         theme_advanced_toolbar_align : "left",
  158.         theme_advanced_statusbar_location : "bottom",
  159.         theme_advanced_resizing : false,
  160.  
  161.         // Example content CSS (should be your site CSS)
  162.         content_css : "css/content.css",
  163.  
  164.         // Drop lists for link/image/media/template dialogs
  165.         template_external_list_url : "lists/template_list.js",
  166.         external_link_list_url : "lists/link_list.js",
  167.         external_image_list_url : "lists/image_list.js",
  168.         media_external_list_url : "lists/media_list.js",
  169.  
  170.         // Replace values for the template plugin
  171.         template_replace_values : {
  172.             username : "Some User",
  173.             staffid : "991234"
  174.         }
  175.     });
  176. </script>
  177. <link href="css/style_portal_admin.css" rel="stylesheet" type="text/css" />
  178. </head>
  179. <body>
  180. <div id="global">
  181. <div id="topo">
  182.         <h1>G.NEWS</h1>
  183.     </div>
  184.     <!-- / Head -->
  185.    
  186.     <div id="menu">
  187.         <ul>
  188.     <li><a href="indexNews.php" class="bts_Menu_Horiz">Listar Not&iacute;cias</a></li>
  189.     <li><a href="noticia_inserir.php" class="bts_Menu_Horiz">Cadastrar Notícia</a></li>
  190.     <li><a href="indexClipping.php" class="bts_Menu_Horiz">Listar Clipping</a></li>
  191.     <li><a href="clipping_inserir.php" class="bts_Menu_Horiz">Cadastrar Clipping</a></li>
  192.     <li id="bemvindo">Bem vindo(a),<strong><?php echo $_SESSION['usuario']; ?></strong>.</li>
  193.     <li><a href="<?php echo $logoutAction ?>" class="bts_Menu_Horiz">Sair</a></li>
  194.       </ul>
  195.   </div>
  196.     <!-- / Menu -->
  197.        
  198.   <div id="conteudo_admin">
  199.   <div id="box_Titulos2"> <h1>Cadastrar Notícia</h1></div>
  200.   <div id="box_centraliza_forms">
  201.    
  202.           <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="frm_not" id="frm_not"  onsubmit="return submitForm();">
  203. <table align="center" width="695px">
  204.                 <tr valign="baseline">
  205.                   <td colspan="2" nowrap><strong>Chape&uacute;:</strong></td>
  206.         </tr>
  207.                 <tr valign="baseline">
  208.                   <td colspan="2" nowrap><input name="not_sinopse" type="text" id="not_sinopse" value="" size="60%" /></td>
  209.               </tr>
  210.                 <tr valign="baseline">
  211.                   <td colspan="2" nowrap>&nbsp;</td>
  212.           </tr>
  213.                 <tr valign="baseline">
  214.                   <td colspan="2" nowrap><strong>T&iacute;tulo:</strong></td>
  215.         </tr>
  216.                 <tr valign="baseline">
  217.                     <td colspan="2" nowrap><input type="text" name="not_titulo" value="" size="60%"></td>
  218.         </tr>
  219.                 <tr valign="baseline">
  220.                   <td colspan="2" valign="top" nowrap>&nbsp;</td>
  221.           </tr>
  222.                 <tr valign="baseline">
  223.                   <td colspan="2" valign="top" nowrap><strong>Mat&eacute;ria:</strong></td>
  224.         </tr>
  225.                 <tr valign="baseline">
  226.                     <td colspan="2" valign="top" nowrap><textarea name="not_texto" rows="25" id="not_texto"></textarea></td>
  227.                     </tr>
  228.                 <tr valign="baseline">
  229.                   <td colspan="2" nowrap>&nbsp;</td>
  230.         </tr>
  231.                 <tr valign="baseline">
  232.                   <td width="63" nowrap><strong>Imagem:</strong></td>
  233.                   <td width="556" nowrap><input type="file" name="not_imagem" id="not_imagem" /></td>
  234.         </tr>
  235.                 <tr valign="baseline">
  236.                   <td colspan="2" nowrap>&nbsp;</td>
  237.         </tr>
  238.                 <tr valign="baseline">
  239.                   <td nowrap><strong>Destaque:</strong></td>
  240.                   <td nowrap><select name="not_destaque">
  241.                     <option value="M">Ativo</option>
  242.                     <option value="D" selected="selected">Inativo</option>
  243.                   </select></td>
  244.         </tr>
  245.                 <tr valign="baseline">
  246.                   <td colspan="2" nowrap>&nbsp;</td>
  247.         </tr>
  248.                 <tr valign="baseline">
  249.                     <td nowrap><strong>Status:</strong></td>
  250.                     <td nowrap><select name="not_status">
  251.                       <option value="A">Ativo</option>
  252.                       <option value="I" selected="selected">Inativo</option>
  253.                     </select></td>
  254.                     </tr>
  255.                 <tr valign="baseline">
  256.                   <td colspan="2" nowrap>&nbsp;</td>
  257.         </tr>
  258.                 <tr valign="baseline">
  259.                     <td colspan="2" align="center" nowrap><div id="box"><input type="submit" class="bts" value="Cadastrar Notícia" /></div></td>
  260.                   </tr>
  261.                 </table>
  262. <input type="hidden" name="not_usuario_id" />
  263. <input type="hidden" name="MM_insert" value="frm_not" />
  264.       <input name="usuario" type="hidden" value="<?php echo $_SESSION['login']; ?>" />
  265.       </form></div>
  266.     </div>
  267.     <!-- / Conteudo Admin -->
  268.        
  269. <div id="rodape">
  270.         <h4>Rodapé</h4>
  271.     </div>
  272.     <!-- / Rodapé -->
  273.    
  274. </div>
  275. <!-- / Global -->
  276.  
  277.  
  278. </body>
  279. </html>


Colando um novo código


Seu Apelido:
Guardar o apelido em um cookie?

Linguagem:


Código: