PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   PHP Grundlagen (http://www.selfphp.de/forum/forumdisplay.php?f=12)
-   -   nach if, html tags, und zwischen html tags php befehle...? (http://www.selfphp.de/forum/showthread.php?t=12745)

silent.chiller 28.02.2006 20:20:30

nach if, html tags, und zwischen html tags php befehle...?
 
Hy, wie kann ich diesen code(listet alles files in einem bestimmten ordner auf):
PHP-Code:

<?php

   $path 
$_GET["path"];
   if( !isset( 
$path ) || $path == "" )  {
     
$path "./";
   }

   print 
"";

   
# Initialise list arrays, directories and files separately and array counters for them
   
$d_arr = array(); $d 0;
   
$f_arr = array(); $f 0;

   if( 
is_dir$path ) ) {
     if( 
$handle opendir$path ) ) {
         while( 
false !== ( $file readdir$handle ) ) ) {

           if( 
$file != "." && $file != ".." && $file[0] != "." ) {
               if( 
is_dir$path "/" $file ) )

                 
$d_arr[$d++] = $file;
               else

                 
$f_arr[$f++] = $file;
           }
         }
     }
   }


   if( 
is_dir$handle ) ) closedir$handle );


   
asort$d_arr ); reset$d_arr );
   
asort$f_arr ); reset$f_arr );


   
$d_prev substr$path0, ( strrposdirname$path "/." ), "/" ) ) );
   print 
"<div align='left'><a href=\"?path=" $d_prev "\"> Parent directory </a><br>\n";


   for( 
$i=0$i count$d_arr ); $i++ ) {

     print 
"<a href=\"?path=" $path "" $d_arr[$i] . "\">" $d_arr[$i] . "</a><br>\n";
   }
   
   print 
"<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
   for( 
$i=0$i count$f_arr ); $i++ ) {

  print 
"<tr>
    <td><a href=\"" 
$path "" $f_arr[$i] . "\"> " $f_arr[$i] . "</a></div></td>
    <td width='45%' valign='bottom'><div align='right'>"
;

     if( 
filesize$path "/" $f_arr[$i] ) >= 1024 ) {

         print 
roundfilesize$path "/" $f_arr[$i] ) / 1024) . " KB";
     } elseif( 
filesize$path "/" $f_arr[$i] ) >= 1048576 ) {

         print 
roundfilesize$path "/" $f_arr[$i] ) / 1024 1024) . " MB";
     } else {

         print 
filesize$path "/" $f_arr[$i] ) . " bytes";
     }
   print 
"</div>
     </td>
  </tr>"
;
   }
   
   print 
"</table><br>\n";

?>

in diesen tun?

PHP-Code:


<?php
if (file_exists("file1")) {
echo 
"



"
;
    } else {
            echo 
"";
        }

if (
file_exists("file2")) {
print 
"

<h3>File manager</h3>
<form id='your-profile'> <!-- just required to show fieldsets -->
<fieldset>
<legend>Existing Files</legend>

<!--  Hier sollte es rein... -->

</label>
</fieldset>

<fieldset>
<legend>Infos and Upload</legend>
bla bla bla
</fieldset>

<br clear='all' />
<fieldset>
<legend>Admin messages</legend>



</fieldset>

<br clear='all' />

</form>

"
;
    } else {
            echo 
"";
        }

if (
file_exists("file3")) {
echo 
"";
    } else {
            echo 
"";
        }

?>

Ich danke für jegliche Tipps mit dem ich es realisieren kann...

MFG
silent.chiller

Usul 28.02.2006 21:56:56

AW: nach if, html tags, und zwischen html tags php befehle...?
 
Soll das bei <!-- Hier sollte es rein... --> rein?

1. Weg mit dem printf. Statt dessen schliesse und oeffne den php-tag. ja, es ist ohne weiteres moeglich innerhalb einer php-schleife oder eine php-bedingung den php tag zu schliessen und mit normalen HTML weiterzumachen.

2. ersetze <!-- Hier sollte es rein... --> durch dein skript (inklusive php-tags)

silent.chiller 01.03.2006 10:49:41

AW: nach if, html tags, und zwischen html tags php befehle...?
 
Ja es sollte bei "<!-- Hier sollte es rein... -->" rein :)
danke für die antwort.

Ich nehme mal an, du meintest das so, mit " php schliessen und mit " wieder öffnen... hab ich mal versucht:

PHP-Code:


<div class="wrap">
<h2>Own Files of <?php print($user_identity?></h2>
<?php
if (file_exists("check")) {
echo 
" ";
    } else {
            echo 
"";
        }

if (
file_exists("unlocked")) {
"
<h3>File manager</h3>
<form id='your-profile'> <!-- just required to show fieldsets -->
<fieldset>
<legend>Existing Files</legend>"

$path $_GET["path"]; #An dieser stelle gibts einen Fehler "Parse error: syntax error, unexpected T_VARIABLE in /wp-admin/ownfiles.php on line 36" Wie kann ich diesen fehler beheben?
   
if( !isset( $path ) || $path == "" )  {
     
$path "./";
   }

   print 
"";

   
$d_arr = array(); $d 0;
   
$f_arr = array(); $f 0;

   if( 
is_dir$path ) ) {
     if( 
$handle opendir$path ) ) {
         while( 
false !== ( $file readdir$handle ) ) ) {

           if( 
$file != "." && $file != ".." && $file[0] != "." ) {
               if( 
is_dir$path "/" $file ) )

                 
$d_arr[$d++] = $file;
               else

                 
$f_arr[$f++] = $file;
           }
         }
     }
   }


   if( 
is_dir$handle ) ) closedir$handle );


   
asort$d_arr ); reset$d_arr );
   
asort$f_arr ); reset$f_arr );


   
$d_prev substr$path0, ( strrposdirname$path "/." ), "/" ) ) );
   print 
"<div align='left'><a href=\"?path=" $d_prev "\"> Parent directory </a><br>\n";


   for( 
$i=0$i count$d_arr ); $i++ ) {

     print 
"<a href=\"?path=" $path "" $d_arr[$i] . "\">" $d_arr[$i] . "</a><br>\n";
   }
   
   print 
"<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
   for( 
$i=0$i count$f_arr ); $i++ ) {

  print 
"<tr>
    <td><a href=\"" 
$path "" $f_arr[$i] . "\"> " $f_arr[$i] . "</a></div></td>
    <td width='45%' valign='bottom'><div align='right'>"
;

     if( 
filesize$path "/" $f_arr[$i] ) >= 1024 ) {

         print 
roundfilesize$path "/" $f_arr[$i] ) / 1024) . " KB";
     } elseif( 
filesize$path "/" $f_arr[$i] ) >= 1048576 ) {

         print 
roundfilesize$path "/" $f_arr[$i] ) / 1024 1024) . " MB";
     } else {

         print 
filesize$path "/" $f_arr[$i] ) . " bytes";
     }
   print 
"</div>
     </td>
  </tr>"
;
   }
   
   print 
"</table><br>\n"
"
</label>
</fieldset>

<fieldset>
<legend>Infos and Upload</legend>
bla bla bla
</fieldset>

<br clear='all' />
<fieldset>
<legend>Admin messages</legend>
Hy, alle bla sind für blas zugaenglich, boe<br>
scheisse, über 20mb... $user_identity
</fieldset>

<br clear='all' />

</form>

"
;
    } else {
            echo 
"";
        }

if (
file_exists("../../members/$user_identity/locked")) {
echo 
" ";
    } else {
            echo 
"";
        }

?>

</div>

<?php include('admin-footer.php'); ?>

hmmm... Was habe ich falsch gemacht...?
Was ist gemeint mit T_VARIABLE?

mfg

mfg


Alle Zeitangaben in WEZ +2. Es ist jetzt 03:18:32 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.