Foros del Web » Programando para Internet » PHP »

Crear instalador

Estas en el tema de Crear instalador en el foro de PHP en Foros del Web. Hola, yo modifique un upload, entonces, lo que quiero hacer es un instalador.. Para hacer funcionar el upload hay que editar una parte del index.php: ...
  #1 (permalink)  
Antiguo 03/01/2013, 14:24
 
Fecha de Ingreso: diciembre-2012
Mensajes: 7
Antigüedad: 11 años, 4 meses
Puntos: 0
Crear instalador

Hola,

yo modifique un upload, entonces, lo que quiero hacer es un instalador..

Para hacer funcionar el upload hay que editar una parte del index.php:

Código:
<?php 
// V1.5 BETA - BY DEWEYCARAPINTADA
$varrand = substr(md5(uniqid(rand())),0,10);		
$varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
$tips = array("bmp","gif","jpeg","png","jpg");
$url = "http://miweb.com/tmp/";
$varstat = "";
 
if ($_POST["action"] == "upload") {
	if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
		$varname = $_FILES["imagen"]['name'];
		$vartemp = $_FILES['imagen']['tmp_name'];
		$vartype = $_FILES['imagen']['type'];
		
		if (in_array($vartype, $varallw) && $varname != "") {
			$arrname = explode(".", $varname);
			$i = strtolower(end($arrname));
			if(in_array($i, $tips)){
			$varname = $varrand.".".$i;
			if (copy($vartemp, "tmp/".$varname)) {
				$url = $url.$varname;
				$varstat = "ok";
			} else {
				$varstat = "Error al subir el archivo";
			}
			} else { $varstat = "Archivo no valido"; }
		} else {
			$varstat = "Archivo no valido";
		}
	}
}
?>

<!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" dir="ltr" lang="es">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>imgMAKER - Upload de Imagenes</title>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
	<script>
		!window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
	</script>
	<script type="text/javascript" src="./fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
	<script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"></script>
	<link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<link href="cssupload.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript">
		$(document).ready(function() {
			/*
			*   Examples - images
			*/

			$("a#example1").fancybox();

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a#example3").fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'	
			});

			$("a#example4").fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'none'
			});

			$("a#example5").fancybox();

			$("a#example6").fancybox({
				'titlePosition'		: 'outside',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});

			$("a#example7").fancybox({
				'titlePosition'	: 'inside'
			});

			$("a#example8").fancybox({
				'titlePosition'	: 'over'
			});

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Imagen</span>';
				}
			});

			/*
			*   Examples - various
			*/

			$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

			$("#various2").fancybox();

			$("#various3").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe'
			});

			$("#various4").fancybox({
				'padding'			: 0,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
		});
	</script>
</head>
<body>

<div class="container_up" align="center">

<img src="img/logo.png">
<br />
<br />

 <form action="index.php" method="post" enctype="multipart/form-data">
      <input name="imagen" type="file" class="casilla" id="imagen" size="35" />
      <input name="enviar" type="submit" class="boton" id="enviar" value="Subir" />
	  <input name="action" type="hidden" value="upload" />	
	</form>

  <?php if ($varstat == "ok") { ?>
<br />
    <td class="textinf"><strong>¡IMPORTANTE!</strong><br>
	Tu archivo se ha subido correctamente, tienes diferentes opciones para enlazarlo y aqui en nuestro sitio te ofrecemos tres:<br>
<br />
	<strong>Codigo HTML:</strong> <br>
	<input name='txt1' type='text' value='<a href="<?php echo $url; ?>"><img src="<?php echo $url; ?>" border="0" /></a>' size='60'>
	<br>
<br />
	<strong>Codigo BBCODE:</strong> <br>
	<input name='txt1' type='text' value='[url=<?php echo $url; ?>][img]<?php echo $url; ?>[/img][/url]' size='60'>
	<br>
<br />
	<strong>Enlace Directo: </strong><br>
	<input name='txt2' type='text' value='<?php echo $url; ?>' size='60'></td>

  <?php } else { ?>
	  <?php if ($varstat != "") { ?>

		<td class="textinf"><strong>Error:</strong><br>
	    <?php echo $varstat; ?>&nbsp;</td>

	  <?php } ?>
  <?php } ?>

<br />

<?php if ($varstat == "ok") { ?>
<p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $varname; ?>' width='125' height='125' /></a></p>

<?php } ?>
<?php if ($_GET['image'] != "") { ?>

<p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $_GET['image']; ?>' width='125' height='125' /></a></p>
<?php } ?>

</div>

<div style="height:320px; width:776px; background-color:#ffffff; border: 1px solid #d5d4d0; margin:0 auto; margin-top:20px; padding:20px 20px 20px 20px;   overflow-x: hidden; overflow-y: scroll; color:black;">

<ul>
<?php
$ruta = "tmp/";
$directorio = opendir($ruta);

while($archivo=readdir($directorio)){
if ($archivo=="."){
} else {
if ($archivo==".."){
} else {

echo "<li>
<a rel='example_group' href='tmp/$path$archivo'><img alt='$path2$archivo' src='tmp/$path2$archivo' width='125' height='125' /></a>
</li>";
}
}
}
?>
</ul>

</div>

<div class="footer" align="center">
Copyright 2012 Upload - All rights reserved | powered by <a href=http://blog.unijimpe.net/>Unijimpe</a> edited by <a href=http://kekomundo.com/foro/index.php?action=profile />DeweyCaraPintada</a>
</div>

</body>
</html>
y esa parte es:

Código:
$url = "http://miweb.com/tmp/";
__

Pues entonces, lo que quiero lograr es que mediante un formulario (ubicado en un archivo .php) se edite esa parte del codigo por la que se puso en el formulario..
  #2 (permalink)  
Antiguo 04/01/2013, 12:05
 
Fecha de Ingreso: febrero-2004
Mensajes: 1.987
Antigüedad: 20 años, 2 meses
Puntos: 22
Respuesta: Crear instalador

Cita:
Iniciado por zenitrames Ver Mensaje
lo que quiero lograr es que mediante un formulario (ubicado en un archivo .php) se edite esa parte del codigo por la que se puso en el formulario..
Haz que esa parte del código sea leida/cargada del archivo config_de_user.php, y con tu programa EDITAS/GRABAS en config_de_user.php la ruta del user.
  #3 (permalink)  
Antiguo 05/01/2013, 12:45
 
Fecha de Ingreso: diciembre-2012
Mensajes: 7
Antigüedad: 11 años, 4 meses
Puntos: 0
Respuesta: Crear instalador

Cita:
Iniciado por Anarko Ver Mensaje
Haz que esa parte del código sea leida/cargada del archivo config_de_user.php, y con tu programa EDITAS/GRABAS en config_de_user.php la ruta del user.
No entendi, ¿como podia lograrlo?
  #4 (permalink)  
Antiguo 05/01/2013, 14:06
Avatar de rodrigo791  
Fecha de Ingreso: noviembre-2009
Ubicación: Uruguay
Mensajes: 1.339
Antigüedad: 14 años, 5 meses
Puntos: 168
Respuesta: Crear instalador

Pero muchacho, simplemente toma 1 form con 1 input text como decís, y luego generas creas 1 variable con todo el contenido del sistema de upload que tenes + el dato que te llega del form y todo eso lo volcas hacia 1 archivo.php el cual es ya el sistema definitivo.

Tenes el form, ingresas el dato, y luego creas 1 variable con todo este contenido a continuación y usando el dato que te llega del form, para luego crearte con fopen() un archivo.php con este sistema.
Código PHP:
Ver original
  1. <?php
  2. // V1.5 BETA - BY DEWEYCARAPINTADA
  3. $varrand = substr(md5(uniqid(rand())),0,10);       
  4. $varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image/x-png");
  5. $tips = array("bmp","gif","jpeg","png","jpg");
  6. $url = "http://miweb.com/tmp/"; //---------------ACÁ EL DATO QUE TE LLEGA POR EL FORMULARIO----------------
  7. $varstat = "";
  8.  
  9. if ($_POST["action"] == "upload") {
  10.     if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
  11.         $varname = $_FILES["imagen"]['name'];
  12.         $vartemp = $_FILES['imagen']['tmp_name'];
  13.         $vartype = $_FILES['imagen']['type'];
  14.        
  15.         if (in_array($vartype, $varallw) && $varname != "") {
  16.             $arrname = explode(".", $varname);
  17.             $i = strtolower(end($arrname));
  18.             if(in_array($i, $tips)){
  19.             $varname = $varrand.".".$i;
  20.             if (copy($vartemp, "tmp/".$varname)) {
  21.                 $url = $url.$varname;
  22.                 $varstat = "ok";
  23.             } else {
  24.                 $varstat = "Error al subir el archivo";
  25.             }
  26.             } else { $varstat = "Archivo no valido"; }
  27.         } else {
  28.             $varstat = "Archivo no valido";
  29.         }
  30.     }
  31. }
  32. ?>
  33.  
  34. <!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" dir="ltr" lang="es">
  35. <html xmlns="http://www.w3.org/1999/xhtml">
  36. <head>
  37. <title>imgMAKER - Upload de Imagenes</title>
  38.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  39.     <script>
  40.         !window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
  41.     </script>
  42.     <script type="text/javascript" src="./fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
  43.     <script type="text/javascript" src="./fancybox/jquery.fancybox-1.3.4.pack.js"></script>
  44.     <link rel="stylesheet" type="text/css" href="./fancybox/jquery.fancybox-1.3.4.css" media="screen" />
  45. <link href="cssupload.css" rel="stylesheet" type="text/css" />
  46.     <script type="text/javascript">
  47.         $(document).ready(function() {
  48.             /*
  49.             *   Examples - images
  50.             */
  51.  
  52.             $("a#example1").fancybox();
  53.  
  54.             $("a#example2").fancybox({
  55.                 'overlayShow'   : false,
  56.                 'transitionIn'  : 'elastic',
  57.                 'transitionOut' : 'elastic'
  58.             });
  59.  
  60.             $("a#example3").fancybox({
  61.                 'transitionIn'  : 'none',
  62.                 'transitionOut' : 'none'   
  63.             });
  64.  
  65.             $("a#example4").fancybox({
  66.                 'opacity'       : true,
  67.                 'overlayShow'   : false,
  68.                 'transitionIn'  : 'elastic',
  69.                 'transitionOut' : 'none'
  70.             });
  71.  
  72.             $("a#example5").fancybox();
  73.  
  74.             $("a#example6").fancybox({
  75.                 'titlePosition'     : 'outside',
  76.                 'overlayColor'      : '#000',
  77.                 'overlayOpacity'    : 0.9
  78.             });
  79.  
  80.             $("a#example7").fancybox({
  81.                 'titlePosition' : 'inside'
  82.             });
  83.  
  84.             $("a#example8").fancybox({
  85.                 'titlePosition' : 'over'
  86.             });
  87.  
  88.             $("a[rel=example_group]").fancybox({
  89.                 'transitionIn'      : 'none',
  90.                 'transitionOut'     : 'none',
  91.                 'titlePosition'     : 'over',
  92.                 'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
  93.                     return '<span id="fancybox-title-over">Imagen</span>';
  94.                 }
  95.             });
  96.  
  97.             /*
  98.             *   Examples - various
  99.             */
  100.  
  101.             $("#various1").fancybox({
  102.                 'titlePosition'     : 'inside',
  103.                 'transitionIn'      : 'none',
  104.                 'transitionOut'     : 'none'
  105.             });
  106.  
  107.             $("#various2").fancybox();
  108.  
  109.             $("#various3").fancybox({
  110.                 'width'             : '75%',
  111.                 'height'            : '75%',
  112.                 'autoScale'         : false,
  113.                 'transitionIn'      : 'none',
  114.                 'transitionOut'     : 'none',
  115.                 'type'              : 'iframe'
  116.             });
  117.  
  118.             $("#various4").fancybox({
  119.                 'padding'           : 0,
  120.                 'autoScale'         : false,
  121.                 'transitionIn'      : 'none',
  122.                 'transitionOut'     : 'none'
  123.             });
  124.         });
  125.     </script>
  126. </head>
  127. <body>
  128.  
  129. <div class="container_up" align="center">
  130.  
  131. <img src="img/logo.png">
  132. <br />
  133. <br />
  134.  
  135.  <form action="index.php" method="post" enctype="multipart/form-data">
  136.       <input name="imagen" type="file" class="casilla" id="imagen" size="35" />
  137.       <input name="enviar" type="submit" class="boton" id="enviar" value="Subir" />
  138.       <input name="action" type="hidden" value="upload" /> 
  139.     </form>
  140.  
  141.   <?php if ($varstat == "ok") { ?>
  142. <br />
  143.     <td class="textinf"><strong>¡IMPORTANTE!</strong><br>
  144.     Tu archivo se ha subido correctamente, tienes diferentes opciones para enlazarlo y aqui en nuestro sitio te ofrecemos tres:<br>
  145. <br />
  146.     <strong>Codigo HTML:</strong> <br>
  147.     <input name='txt1' type='text' value='<a href="<?php echo $url; ?>"><img src="<?php echo $url; ?>" border="0" /></a>' size='60'>
  148.     <br>
  149. <br />
  150.     <strong>Codigo BBCODE:</strong> <br>
  151.     <input name='txt1' type='text' value='[url=<?php echo $url; ?>][img]<?php echo $url; ?>[/img][/url]' size='60'>
  152.     <br>
  153. <br />
  154.     <strong>Enlace Directo: </strong><br>
  155.     <input name='txt2' type='text' value='<?php echo $url; ?>' size='60'></td>
  156.  
  157.   <?php } else { ?>
  158.       <?php if ($varstat != "") { ?>
  159.  
  160.         <td class="textinf"><strong>Error:</strong><br>
  161.         <?php echo $varstat; ?>&nbsp;</td>
  162.  
  163.       <?php } ?>
  164.   <?php } ?>
  165.  
  166. <br />
  167.  
  168. <?php if ($varstat == "ok") { ?>
  169. <p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $varname; ?>' width='125' height='125' /></a></p>
  170.  
  171. <?php } ?>
  172. <?php if ($_GET['image'] != "") { ?>
  173.  
  174. <p align="center"><a rel='example_group' href='tmp/<?php echo $varname; ?>'><img alt='img' src='tmp/<?php echo $_GET['image']; ?>' width='125' height='125' /></a></p>
  175. <?php } ?>
  176.  
  177. </div>
  178.  
  179. <div style="height:320px; width:776px; background-color:#ffffff; border: 1px solid #d5d4d0; margin:0 auto; margin-top:20px; padding:20px 20px 20px 20px;   overflow-x: hidden; overflow-y: scroll; color:black;">
  180.  
  181. <ul>
  182. <?php
  183. $ruta = "tmp/";
  184. $directorio = opendir($ruta);
  185.  
  186. while($archivo=readdir($directorio)){
  187. if ($archivo=="."){
  188. } else {
  189. if ($archivo==".."){
  190. } else {
  191.  
  192. echo "<li>
  193. <a rel='example_group' href='tmp/$path$archivo'><img alt='$path2$archivo' src='tmp/$path2$archivo' width='125' height='125' /></a>
  194. </li>";
  195. }
  196. }
  197. }
  198. ?>
  199. </ul>
  200.  
  201. </div>
  202.  
  203. <div class="footer" align="center">
  204. Copyright 2012 Upload - All rights reserved | powered by <a href=http://blog.unijimpe.net/>Unijimpe</a> edited by <a href=http://kekomundo.com/foro/index.php?action=profile />DeweyCaraPintada</a>
  205. </div>
  206.  
  207. </body>
  208. </html>

Luego como te dije todo este contenido una vez que te llego el dato del form lo guardas en 1 variable y esa variable con frwite u alguna otra función volcas su contenido para crear el archivo

Etiquetas: formulario, html, instalador
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:51.