¿Cómo puedo incluir un archivo de texto con php

  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 7th, 2010, 8:32 pm

quiero todo el contenido de mi sitio en los documentos de texto. Quiero usar un php incluir en mi página de inicio donde se carga el archivo de texto correcto por el que se hace clic en enlace. im no es real seguro de cómo se hace esto. su año pasado desde ive hecho ningún diseño y mi memoria es bastante oxidado. quiero los enlaces a este aspecto. index.php? = contenido. im seguro de que alguien aquí me puede ayudar
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Mayo 7th, 2010, 8:32 pm

  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 8th, 2010, 12:52 pm

se puede todavía sin respuestas. déjame hacer esto un poco más claro. Sé que hay algunos webmasters muy cualificados que utilizan este sitio todos los días. Quiero crear una página de índice que se utilizará como el diseño y definir todo lo demás a continuación, el contenido que se muestra. Quiero escribir todo el contenido en archivos de texto por separado sino que tendrá la llamada a la función incluyen en el archivo de texto adecuado por el que se hace clic en enlace. por lo tanto los vínculos tendría un aspecto similar a este index.php? = textfilename
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13458
  • Loc: Florida
  • Status: Offline

Nota Mayo 8th, 2010, 4:42 pm

Suponiendo que la dirección http://www.domain.com/?page=mypage

El siguiente código buscará un archivo llamado "mypage.txt" en un directorio en relación con el script llamado "páginas".

PHP Código: [ Select ]
<?php
 
if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./pages/{$_GET['page']}.txt"))
{
   include("./pages/{$_GET['page']}.txt");
}
 
?>
  1. <?php
  2.  
  3. if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./pages/{$_GET['page']}.txt"))
  4. {
  5.    include("./pages/{$_GET['page']}.txt");
  6. }
  7.  
  8. ?>


La convocatoria habrá strcspn en libertad bajo fianza en cualquier valor enviado a través de la página se variable que contiene nada más que minúsculas az
Strong with this one, the sudo is.
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 8th, 2010, 11:47 pm

gracias por la respuesta joebert. Ahora tengo que poner este script en su propio archivo php o puedo incluir en un lugar donde quiero el archivo de texto a la carga en el index.php. tengo un esquema diseñado, pero no quiero que incluya el diseño de cada página. por lo que el contenido debe estar en archivos separados que se cargan en función de lo que se hace clic en enlace de la dirección donde se index.php? page = mipágina. es esto lo que hace el script de arriba?
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13458
  • Loc: Florida
  • Status: Offline

Nota Mayo 9th, 2010, 11:07 am

Asumiendo que su index.php tiene una combinación de HTML y PHP en él ya, que pondría el código anterior en el lugar en ese archivo index.php en la que desea que el contenido del archivo de texto que se mostrará.

PHP Código: [ Select ]
<!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" xml:lang="en" lang="en">
<head>
   <meta http-equiv="content-type" content="text/html;charset=utf-8" />
   <title>My Site</title>
</head>
<body>
 
<div id="content">
<?php
   if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./pages/{$_GET['page']}.txt"))
   {
      include("./pages/{$_GET['page']}.txt");
   }
?>
</div>
 
<div id="sidebar"> ... </div>
 
</body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  5.    <title>My Site</title>
  6. </head>
  7. <body>
  8.  
  9. <div id="content">
  10. <?php
  11.    if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./pages/{$_GET['page']}.txt"))
  12.    {
  13.       include("./pages/{$_GET['page']}.txt");
  14.    }
  15. ?>
  16. </div>
  17.  
  18. <div id="sidebar"> ... </div>
  19.  
  20. </body>
  21. </html>


Habría un directorio llamado "páginas" a lo largo del lado de su archivo index.php y ese directorio se llenaba con los archivos txt.

Attachments:
folder.jpg


Heres un ejemplo adjunto, hay un htaccess dentro de la carpeta ejemplos páginas que impide a las personas el acceso a cualquiera de los archivos txt directamente desde su navegador.
Attachments:
example.zip

(1.18 KiB) 274 veces

Strong with this one, the sudo is.
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 9th, 2010, 12:15 pm

gracias joebert. malos probar esto. parece ser exactamente lo que necesitan im.
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 12th, 2010, 1:08 pm

lo que me mostró las grandes obras. Sin embargo, ¿cómo tengo la carga de una página php de forma predeterminada cuando el sitio es visitado, como la página principal. donde automáticamente pantalla home.txt
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Registrado: Feb 10, 2004
  • Mensajes: 13458
  • Loc: Florida
  • Status: Offline

Nota Mayo 12th, 2010, 3:24 pm

Después de que el SI se puede usar un ELSE.

PHP Código: [ Select ]
else
{
    include("./pages/home.txt");
}
  1. else
  2. {
  3.     include("./pages/home.txt");
  4. }
Strong with this one, the sudo is.
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 15th, 2010, 8:04 pm

el im teniendo problema ahora es que el fondo no se repita lo que el contenido sólo arroyos derecho que pasado. im no muy seguro cómo puedo conseguir el fondo para repetir indefinidamente. tal vez usted me puede ayudar joebert. para ver lo que im hablando puedes ir aquí:

http://www.blockworkmusic.com/index.php?page=services
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 15th, 2010, 9:01 pm

Corregí el DOCTYPE y solucionado el problema de la ópera, pero IE sigue mostrando una brecha en el fondo. alguien me ayude! Heres el código de mi archivo index.php.

Código: [ Select ]
<!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.0 ">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Blockwork Music Recording Studio</title>
<style type="text/css">
body,td,th {
    color: #FFF;
}
body {
    background-image: url(Images/bg1.jpg);
    background-repeat: repeat-y;
    background-position: center;
    margin-top: 0px;
    padding-top: 0px;
    width: 100%;
    height:100%;
    position:absolute;
    
}

html {
    background-image:url(Images/bg.jpg);
    background-repeat: inherit;
    margin-bottom:0px;
    padding-bottom:0px;
    width:100%;
    height:100%;
}

.center {
  text-align: center;
    margin-top: 0px;

}
.bottom {
    background-image:url(Images/bg1.jpg);
    background-position: center;
    background-repeat:repeat-y;
  position:fixed;
  bottom: 0;
    margin-bottom:1px;
    padding-bottom:0;
    width: 100%;
    height: 20px;
    text-align:center;
}
</style>
</head>

<body link="#c2edfd" alink="#c2edfd" vlink="#c2edfd">
<p class="center"><img src="Images/header.jpg" width="1011" height="298" border="0" usemap="#Map"/>
 <map name="Map" id="Map">
  <area shape="rect" coords="102,267,188,297" href="index.php?page=home" />
  <area shape="rect" coords="227,269,366,306" href="index.php?page=services" />
  <area shape="rect" coords="406,266,540,299" href="index.php?page=contact" />
  <area shape="rect" coords="575,266,717,301" href="index.php?page=portfolio" />
  <area shape="rect" coords="749,268,840,300" href="index.php?page=links" />
 </map>
</p>
<table width="900" border="0" cellspacing="0" cellpadding="0" align="center">
 <tr>
  <td><p class="center"><img src="Images/banner.jpg" /></p><br /><?php

if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./content/{$_GET['page']}.txt"))
{
  include("./content/{$_GET['page']}.txt");
}

else
{
  include("./content/home.txt");
}

?></td>
 </tr>
</table></p><br />
<p class="bottom"><font size="2">&copy 2010 Blockwork Music. All Rights Reserved.</font></p>
</body>
</html>
  1. <!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.0 ">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Blockwork Music Recording Studio</title>
  6. <style type="text/css">
  7. body,td,th {
  8.     color: #FFF;
  9. }
  10. body {
  11.     background-image: url(Images/bg1.jpg);
  12.     background-repeat: repeat-y;
  13.     background-position: center;
  14.     margin-top: 0px;
  15.     padding-top: 0px;
  16.     width: 100%;
  17.     height:100%;
  18.     position:absolute;
  19.     
  20. }
  21. html {
  22.     background-image:url(Images/bg.jpg);
  23.     background-repeat: inherit;
  24.     margin-bottom:0px;
  25.     padding-bottom:0px;
  26.     width:100%;
  27.     height:100%;
  28. }
  29. .center {
  30.   text-align: center;
  31.     margin-top: 0px;
  32. }
  33. .bottom {
  34.     background-image:url(Images/bg1.jpg);
  35.     background-position: center;
  36.     background-repeat:repeat-y;
  37.   position:fixed;
  38.   bottom: 0;
  39.     margin-bottom:1px;
  40.     padding-bottom:0;
  41.     width: 100%;
  42.     height: 20px;
  43.     text-align:center;
  44. }
  45. </style>
  46. </head>
  47. <body link="#c2edfd" alink="#c2edfd" vlink="#c2edfd">
  48. <p class="center"><img src="Images/header.jpg" width="1011" height="298" border="0" usemap="#Map"/>
  49.  <map name="Map" id="Map">
  50.   <area shape="rect" coords="102,267,188,297" href="index.php?page=home" />
  51.   <area shape="rect" coords="227,269,366,306" href="index.php?page=services" />
  52.   <area shape="rect" coords="406,266,540,299" href="index.php?page=contact" />
  53.   <area shape="rect" coords="575,266,717,301" href="index.php?page=portfolio" />
  54.   <area shape="rect" coords="749,268,840,300" href="index.php?page=links" />
  55.  </map>
  56. </p>
  57. <table width="900" border="0" cellspacing="0" cellpadding="0" align="center">
  58.  <tr>
  59.   <td><p class="center"><img src="Images/banner.jpg" /></p><br /><?php
  60. if( ! empty($_GET['page']) && ! (bool)strcspn($_GET['page'], 'abcdefghijklmnopqrstuvwxyz') && file_exists("./content/{$_GET['page']}.txt"))
  61. {
  62.   include("./content/{$_GET['page']}.txt");
  63. }
  64. else
  65. {
  66.   include("./content/home.txt");
  67. }
  68. ?></td>
  69.  </tr>
  70. </table></p><br />
  71. <p class="bottom"><font size="2">&copy 2010 Blockwork Music. All Rights Reserved.</font></p>
  72. </body>
  73. </html>
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 16th, 2010, 12:51 am

¿Alguien puede echarme una mano aquí?
  • xlgfx
  • Graduate
  • Graduate
  • No Avatar
  • Registrado: Sep 03, 2006
  • Mensajes: 232
  • Loc: saint joseph, missouri
  • Status: Offline

Nota Mayo 16th, 2010, 2:14 am

para nadie más que nunca tiene este problema una solución a su sencilla. todo funciona bien ahora, tanto en Opera e Internet Explorer.
He añadido este fragmento de código:
Código: [ Select ]
html>body {
min-height:100%;
height:auto;
}
  1. html>body {
  2. min-height:100%;
  3. height:auto;
  4. }

solucionado el problema

Publicar Información

  • Total de mensajes en este tema: 12 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 109 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC