Ver Mensaje Individual
  #9 (permalink)  
Antiguo 05/03/2008, 17:58
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Sonrisa Re: APORTE: Crea tu foro con php

Hola,
Ise un parche ( se instala automaticamente ) para el foro que postee anterior mente.
Lo que hace el parche es distinguir los usuarios normales de los administradores.
Empezemos:
install2_parch.php
Código PHP:
<title>Parchador</title><style type="text/css">
<!--
body {
    background-color: #E2E2E2;
}
.style1 {
    color: #999999;
    font-weight: bold;
}
-->
</style>
<table width="560" border="2" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#FFFFFF">
  <!--DWLayoutTable-->
  <tr>
    <td width="560" height="25"><div align="center"><strong>Parche de administrador </strong></div></td>
  </tr>
  <tr>
    <td height="43"><?
if(!file_exists("usuarios/adm.ini.dat")){
  
$jiw "adm.ini.dat";
 @
$aqw fopen($jiw"a+"); 
  
$sssw "pato12"
 @
$ghjw fwrite($aqw$sssw); 
  
fclose($aqw);
if(!
$aqw){
  echo 
"<font color='#FF0000'> <strong>Error al crear el archivo.</strong></font><br>";
   }
 else
 {
 echo 
"<strong><font color='#00FF00'>El archivo fue creado correctamente.</font></strong><br>";
 
$key='si';
 } 
if(!
$ghjw){
 echo 
"<font color='#FF0000'> <strong>Error al escribir el archivo</strong></font><br>";
 }
 else
 {
 echo 
"<strong><font color='#00FF00'> El archivo se escribio correctamente.</font></strong>";
 
$key='si';
 }
 }
if(
$key == 'si'){
  
$file=$_POST['file'];
  
$sep=explode('index.php',$file);
  
$archivo=$sep[0]."creat_adm_nuevo.php";
  
$abre fopen($archivo"a+"); 
  
$totala "<?
  \$usu=\$_POST['usu'];
  if(empty(\$usu)) \$key='no';
if(\$key != 'no'){
  \$jiw = 'adm.ini.dat';
 \$aqw = fopen(\$jiw, 'a+'); 
  \$sssw = \";\$usu\"; 
 \$ghjw = fwrite(\$aqw, \$sssw); 
  fclose(\$aqw);
if(!\$aqw){
  echo '<font color=\'#FF0000\'> <strong>Error al leer el archivo, asegurate que no lo esten usando.</strong></font><br>';
   }
 else
 {
 echo '<strong><font color=\'#00FF00\'>El archivo se leyo correctamente.</font></strong><br>';
 } 
if(!\$ghjw){
 echo '<font color=\'#FF0000\'> <strong>Error al escribir el archivo</strong></font><br>';
 }
 else
 {
 echo '<strong><font color=\'#00FF00\'> El archivo se escribio correctamente.</font></strong>';
 }
 }
 else
 {
 echo 'El campo esta facio.';
 }
?>"
;
  
$grabar fwrite($abre$totala); 
  
fclose($abre);



  
$archivo=$sep[0]."ad_nuevo_form.html";
  
$abre fopen($archivo"a+"); 
  
$totala '<style type="text/css">
<!--
body {
    background-color: #E2E2E2;
}
-->
</style>
<table width="476" border="2" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#FFFFFF">
  <!--DWLayoutTable-->
  <tr>
    <td width="476" height="25"><div align="center"><strong>Nuevo administrador </strong></div></td>
  </tr>
  <tr>
    <td height="25"><form name="form1" method="post" action="creat_adm_nuevo.php">
      <p>
        <label>
        Usuario:<br>
        <input name="usu" type="text" id="usu">
        </label>
      <br>
      <label>
      <input type="submit" name="Submit" value="Crear">
      </label>
      </p>
      </form>
    </td>
  </tr>
</table>'
;
 @ 
$grabar2 fwrite($abre$totala); 
  
fclose($abre);
  include(
'parch2.php');
}
if(!
$grabar2){
 echo 
"<font color='#FF0000'> <strong>Error al escribir el archivo ad_nuevo_from.html</strong></font><br>";
 }
 else
 {
 echo 
"<strong><font color='#00FF00'>El archivo ad_nuevo_from.html se escribio correctamente.</font></strong>";
 
$error2='no';
 }

if(!
$grabar){
 echo 
"<font color='#FF0000'> <strong>Error al escribir el archivo creat_adm_nuevo.php</strong></font><br>";
 }
 else
 {
 echo 
"<strong><font color='#00FF00'>El archivo creat_adm_nuevo.php se escribio correctamente.</font></strong>";
 
$error='no';
 }
 if(
$error == 'no' and $error2 =='no') echo "<br>El parche salio exitosamente.";
?><br>
<a href="install_parch2.php">Siguiente&gt;</a></td>
  </tr>
</table>
install_parch2.php
Código PHP:
<style type="text/css">
<!--
body {
    
background-color#E2E2E2;
}
.
style1 {
    
color#999999;
    
font-weightbold;
}
-->
</
style>
<
table width="560" border="2" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#FFFFFF">
  <!--
DWLayoutTable-->
  <
tr>
    <
td width="560" height="25"><div align="center"><strong>Parche de administrador </strong></div></td>
  </
tr>
  <
tr>
    <
td height="165"><fieldset><legend>Rellene los siguientes datos</legend>
        <
form name="form1" method="post" action="creat_adm_nuevo">
          <
strong>Nombre del administrador:</strong><br>
          <
label>
          <
input name="usu" type="text" id="usu">
          </
label>
                <
br>
                <
label>
                <
input type="submit" name="Submit" value="Crear">
                </
label>
      </
form>
        </
fieldset>
      <
p><br>
      </
p></td>
  </
tr>
</
table
parch2.php
Código PHP:
<?
  $archivo
=$sep[0]."post.html";
  
$abre fopen($archivo"w"); 
  
$totala '<table width="90%" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000">
  <tr bgcolor="<?=$color?>"> 
    <td width="25%" valign="top" bgcolor="#999999"> <b><a name="<?=$id?>">
      <?=$autor?></a>
      </b><br><?
session_start(); // abrimos la session
  $archivo ="adm.ini.dat"; 
  $abre = fopen($archivo, "a+"); 
 @$total = fread($abre, filesize($archivo));
  fclose($abre);
  $adm=explode(";",$total);
  $partes=count($sep);
  for($i=0;$i<=$partes;$i++){
  $adm[$i];
  }
/////////////// - NO EDITAR -//////////////
$flag = false;
foreach( $adm as $user ) {
     if( $user == $autor ) {
           echo "[ ADMINISTRADOR ]";
           $flag = true;
           break;
     }
}

if( !$flag ) {
       echo "[ USUARIO ]";
}  
?>
<br>
      <font size="-2">Enviado el : <?=$enviado?></font>    </td>
    <td bgcolor="#999999"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#999999"><strong><font size="-1">
            <?=$titulo?>
            </font></strong> </td>
          <td width="10%" align="right">
          <?
          if(isset($_SESSION["s_username"])){
          ?>[ <a href="respuesta.php?id=<?=$id?>&citar=1">CITAR</a> 
            ]
            <?
            }
            ?></td>
        </tr>
      </table>
      <hr align="center" width="100%" size="2">
    <?=$mensaje?></td>
  </tr>
  <tr> 
    <td colspan="2" height="5"></td>
  </tr>
</table>'
;
 @ 
$grabar2 fwrite($abre$totala); 
  
fclose($abre);
?>
install_parch.html
Código HTML:
<style type="text/css">
<!--
body {
	background-color: #E2E2E2;
}
.style1 {
	color: #999999;
	font-weight: bold;
}
-->
</style>
<table width="560" border="2" align="center" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#FFFFFF">
  <!--DWLayoutTable-->
  <tr>
    <td width="560" height="25"><div align="center"><strong>Parche de administrador </strong></div></td>
  </tr>
  <tr>
    <td height="165"><fieldset><legend>Rellene los siguientes datos</legend><ul>
        <li><strong>Este parche te ayuda a distinguir los usuarios de los administradores </strong></li>
    </ul><br>
    <form action="install2_parch.php" method="post" enctype="multipart/form-data" name="form1">
      <label></label>
      <span class="style1">Deve llevar el parhceador a la carpeta donde esta el foro </span><br>
            <label>
            <input type="submit" name="Submit" value="Parchear">
            </label><br>
    </form>
    </fieldset></td>
  </tr>
</table> 
Hay que ejecutar install_parch.html.
El aprche hay que ponerlo en la carpeta donde esta el foro o te saldra un error.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com