Voltar para Paste Lymas | pasteLog v. 2.0-alpha

Visualizando código



Postado por LUIZ CREMEPE em 10/03/2010 20:18:08.
http://paste.lymas.com.br/1116

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


Colando um novo código


Seu Apelido:
Guardar o apelido em um cookie?

Linguagem:


Código: