cambiar script php

martial
22 de Junio del 2005
ola tengo una pagina para insertar unos datos con un editor pero es para hacer cambios a la base d datos, lo q me gustaria es k kambiara un archivo de txt se puede? yo os apso el script y m decis:

<?php require_once('../../Connections/connFlashblog.php'); ?>
<?php
// *** Restrict Access To Page: Grant or deny access to this page
$FF_authorizedUsers=" administrador,usuario";
$FF_authFailedURL="../sin_acceso.php";
$FF_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS["MM_Username"])) {
if (false || !(isset($HTTP_SESSION_VARS["MM_UserAuthorization"])) || $HTTP_SESSION_VARS["MM_UserAuthorization"]=="" || strpos($FF_authorizedUsers, $HTTP_SESSION_VARS["MM_UserAuthorization"])) {
$FF_grantAccess = 1;
}
}
if (!$FF_grantAccess) {
$FF_qsChar = "?";
if (strpos($FF_authFailedURL, "?")) $FF_qsChar = "&";
$FF_referrer = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0) $FF_referrer .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
$FF_authFailedURL = $FF_authFailedURL . $FF_qsChar . "accessdenied=" . urlencode($FF_referrer);
header("Location: $FF_authFailedURL");
exit;
}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

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;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "formulario")) {
$insertSQL = sprintf("INSERT INTO articulos (cat_id, fecha, visible, user_id, titulo, texto, texto2, comment_si_no) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['cat_id'], "text"),
GetSQLValueString($HTTP_POST_VARS['fecha'], "text"),
GetSQLValueString($HTTP_POST_VARS['visible'], "text"),
GetSQLValueString($HTTP_POST_VARS['user_id'], "text"),
GetSQLValueString($HTTP_POST_VARS['titulo'], "text"),
GetSQLValueString($HTTP_POST_VARS['texto'], "text"),
GetSQLValueString($HTTP_POST_VARS['texto2'], "text"),
GetSQLValueString($HTTP_POST_VARS['comment_si_no'], "text"));

mysql_select_db($database_connFlashblog, $connFlashblog);
$Result1 = mysql_query($insertSQL, $connFlashblog) or die(mysql_error());

$insertGoTo = "xmlArticulo.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

$colname_rsUsers = "1";
if (isset($HTTP_SESSION_VARS['MM_Username'])) {
$colname_rsUsers = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['MM_Username'] : addslashes($HTTP_SESSION_VARS['MM_Username']);
}
mysql_select_db($database_connFlashblog, $connFlashblog);
$query_rsUsers = sprintf("SELECT * FROM usuarios WHERE email = '%s'", $colname_rsUsers);
$rsUsers = mysql_query($query_rsUsers, $connFlashblog) or die(mysql_error());
$row_rsUsers = mysql_fetch_assoc($rsUsers);
$totalRows_rsUsers = mysql_num_rows($rsUsers);

mysql_select_db($database_connFlashblog, $connFlashblog);
$query_rsCategorias = "SELECT * FROM categoria ORDER BY categoria ASC";
$rsCategorias = mysql_query($query_rsCategorias, $connFlashblog) or die(mysql_error());
$row_rsCategorias = mysql_fetch_assoc($rsCategorias);
$totalRows_rsCategorias = mysql_num_rows($rsCategorias);
?>
<html>
<head>
<title>flashBlog </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "../Editor/"; // URL to htmlarea files
_editor_field = "";
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
var MyBgColor ='#FFFFFF';
var MyBgImg ='';
// --></script>
<script>
function updateAttributes(){
document.myform.bgcolor.value=MyBgColor;
document.myform.background.value=MyBgImg;
}
</script>
<script language="JavaScript" type="text/javascript">
function GP_popupConfirmMsg(msg) { //v1.0
document.MM_returnValue = confirm(msg);
}
//-->
</script>
<!-- /hoja de estilos del editor Html/ -->
<STYLE type="text/css">
.headtext { font-size:10pt;font-weight:bold; }
TD, DIV {font:9pt Verdana,Arial, Helvetica, sans-serif;}
</STYLE>

<link href="../admin.css" rel="stylesheet" type="text/css">
</head>
<?php include("../lang/lang.php"); ?>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="initDocument()" >
<div align="center"><?php include("../includes/head.php"); ?><table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="210" valign="top"><?php include("../includes/menu.php"); ?>
</td>
<td width="540" valign="top"><table width="95%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right"><span class="textos"><?php echo $lang_usuario_conectado ?> &gt;</span> <span class="titulos"><?php echo $row_rsUsers['NombreUsuario']; ?></span><br>
<img src="../imagenes/puntos.gif" width="523" height="8" align="middle"> </div></td>
</tr>
<tr>
<td valign="top"><span class="titulos"><a href="../inicio/index.php"><?php echo $lang_inicio ?></a> &gt;<?php echo $lang_nueva_entrada ?><br>
<br>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="formulario" id="formulario">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#E9E9E9">
<tr valign="baseline" bgcolor="#F4F4F4">
<td colspan="2">
<span class="titulos"><?php echo $lang_categoria ?></span><br>
<select name="cat_id">
<?php
do {
?>
<option value="<?php echo $row_rsCategorias['cat_id']?>" ><?php echo $row_rsCategorias['categoria']?></option>
<?php
} while ($row_rsCategorias = mysql_fetch_assoc($rsCategorias));
?>
</select>
</td>
<tr valign="baseline" bgcolor="#F4F4F4">
<td colspan="2"><span class="titulos"><?php echo $lang_fecha ?></span><br>
<input type="text" name="fecha" value="<?php echo date("Y-m-d H:i:s") ?>" size="25">
<span class="textos"> <?php echo $lang_any_mes_dia ?></span> </td>
</tr>
<tr valign="baseline" bgcolor="#F4F4F4">
<td colspan="2"><span class="titulos"><?php echo $lang_titulo ?></span><br>
<input type="text" name="titulo" value="" size="75">
</td></tr>
<tr valign="baseline" bgcolor="#F4F4F4">
<td colspan="2">
<span class="titulos"><br>
<?php echo $lang_cuerpo ?></span><br>
<textarea name="texto" id="texto" cols="60" rows="15"></textarea>
<script language="javascript1.2">
var config = new Object(); // create new config object

config.width = "100%";
config.height = "200px";
config.bodyStyle = 'background-color: white; font-family: "Georgia"; font-size: x-small;';
config.debug = 0;

// NOTE: You can remove any of these blocks and use the default config!

config.toolbar = [
['fontname'],
// ['fontsize'],
// ['fontstyle'],
// ['linebreak'],
['bold','italic','underline','forecolor','separator'],
// ['strikethrough','subscript','superscript','separator'],
['justifyleft','justifycenter','justifyright','separator'],
['specchar','today','print'],
['selectall','cut','copy','paste','delete','remove','undo','redo','find'],
['separator'],
['separator'],
['insertlink','unlink','InsertImage','Upload'],
['htmlmode','calculator','separator'],
['popupeditor'],
];

config.fontnames = {
"Arial": "arial, helvetica, sans-serif",
"Courier New": "courier new, courier, mono",
"Georgia": "Georgia, Times New Roman, Times, Serif",
"Tahoma": "Tahoma, Arial, Helvetica, sans-serif",
"Times New Roman": "times new roman, times, serif",
"Verdana": "Verdana, Arial, Helvetica, sans-serif",
"impact": "impact",
"WingDings": "WingDings"
};
config.fontsizes = {
"1 (8 pt)": "1",
"2 (10 pt)": "2",
"3 (12 pt)": "3",
"4 (14 pt)": "4",
"5 (18 pt)": "5",
"6 (24 pt)": "6",
"7 (36 pt)": "7"
};

//config.stylesheet = "http://www.domain.com/sample.css";

config.fontstyles = [ // make sure classNames are defined in the page the content is being display as well in or they won't work!
{ name: "headline", className: "headline", classStyle: "font-family: arial black, arial; font-size: 28px; letter-spacing: -2px;" },
{ name: "arial red", className: "headline2", classStyle: "font-family: arial black, arial; font-size: 12px; letter-spacing: -2px; color:red" },
{ name: "verdana blue", className: "headline4", classStyle: "font-family: verdana; font-size: 18px; letter-spacing: -2px; color:blue" }

// leave classStyle blank if it's defined in config.stylesheet (above), like this:
// { name: "verdana blue", className: "headline4", classStyle: "" }
];

editor_generate('texto',config);
WriteMenuItems('texto');


</script>
</td>
</tr>
<tr valign="baseline" bgcolor="#F4F4F4">
<td colspan="2">
<span class="titulos"><br>
<?php echo $lang_mas_contenido ?></span><br>
<textarea name="texto2" cols="60" rows="15" id="texto2"></textarea>
<script language="javascript1.2">
var config = new Object(); // create new config object

config.width = "100%";
config.height = "200px";
config.bodyStyle = 'background-color: white; font-family: "Georgia"; font-size: x-small;';
config.debug = 0;

// NOTE: You can remove any of these blocks and use the default config!

config.toolbar = [
['fontname'],
// ['fontsize'],
// ['fontstyle'],
// ['linebreak'],
['bold','italic','underline','forecolor','separator'],
// ['strikethrough','subscript','superscript','separator'],
['justifyleft','justifycenter','justifyright','separator'],
['specchar','today','print'],
['selectall','cut','copy','paste','delete','remove','undo','redo','find'],
['separator'],
['separator'],
['insertlink','unlink','InsertImage','Upload'],
['htmlmode','calculator','separator'],
['popupeditor'],
];

config.fontnames = {
"Arial": "arial, helvetica, sans-serif",
"Courier New": "courier new, courier, mono",
"Georgia": "Georgia, Times New Roman, Times, Serif",
"Tahoma": "Tahoma, Arial, Helvetica, sans-serif",
"Times New Roman": "times new roman, times, serif",
"Verdana": "Verdana, Arial, Helvetica, sans-serif",
"impact": "impact",
"WingDings": "WingDings"
};
config.fontsizes = {
"1 (8 pt)": "1",
"2 (10 pt)": "2",
"3 (12 pt)": "3",
"4 (14 pt)": "4",
"5 (18 pt)": "5",
"6 (24 pt)": "6",
"7 (36 pt)": "7"
};

//config.stylesheet = "http://www.domain.com/sample.css";

config.fontstyles = [ // make sure classNames are defined in the page the content is being display as well in or they won't work!
{ name: "headline", className: "headline", classStyle: "font-family: arial black, arial; font-size: 28px; letter-spacing: -2px;" },
{ name: "arial red", className: "headline2", classStyle: "font-family: arial black, arial; font-size: 12px; letter-spacing: -2px; color:red" },
{ name: "verdana blue", className: "headline4", classStyle: "font-family: verdana; font-size: 18px; letter-spacing: -2px; color:blue" }

// leave classStyle blank if it's defined in config.stylesheet (above), like this:
// { name: "verdana blue", className: "headline4", classStyle: "" }
];

editor_generate('texto2',config);
WriteMenuItems('texto2');



</script>
</td>
</tr>
<tr valign="baseline" bgcolor="#E9E9E9">
<td width="118">
<span class="titulos"><br>
<?php echo $lang_estado ?></span><br>
<select name="visible">
<option value="1" ><?php echo $lang_visible ?></option>
<option value="0"><?php echo $lang_no_visible ?></option>
</select>
</td>
<td width="393"><span class="titulos"><br>
<?php echo $lang_comentarios ?></span><br>
<select name="comment_si_no">
<option value="1" ><?php echo $lang_comentarios_si ?></option>
<option value="0" ><?php echo $lang_comentarios_no ?></option>
</select></td>
</tr>
<tr valign="middle" bgcolor="#E9E9E9">
<td height="35" colspan="2"> <div align="left">
<input name="submit" type="submit" onClick="GP_popupConfirmMsg('<?php echo $lang_mensaje_salvar ?>');return document.MM_returnValue" value="<?php echo $lang_salvar ?>">
</div></td>
</tr>
</table>
<input type="hidden" name="user_id" value="<?php echo $row_rsUsers['usuarioID']; ?>">
<input type="hidden" name="MM_insert" value="form1">
<input type="hidden" name="MM_insert" value="formulario">
</form>
<p>&nbsp;</p>
</span></td>
</tr>
</table>
<br></td>
</tr>
</table>
<?php include("../includes/bottom.php"); ?><br>
</div>
</body>
</html>
<?php
mysql_free_result($rsUsers);

mysql_free_result($rsCategorias);
?>