• 05-06-2009, 17:55:12
    #1
    merhaba arkadaşlar,
    php ile dosya listeleme işlemi yapacagım ama hata veriyor boolean hatası php net te baktım boolen ile ilgili bişi yok.

    <?php
    function dosyalistele($yol) {
    $dizinac = opendir($yol);
    while ( gettype ($dosya = readdir($dizinac) ) != boolean ) {
    if ( is_file("$yol/$dosya") ) {
    echo (ucwords($dosya)."<br>");
    }
    }
    closedir ($dizinac);
    }
    
    dosyalistele("dosyalar");
    ?>

    Verdigi hata:

    Alıntı
    Notice: Use of undefined constant boolean - assumed 'boolean' in C:\wamp\www\dosya\klasor\dosyalistele.php on line 4
  • 05-06-2009, 18:21:54
    #2
    Üyeliği durduruldu
    boolean sabiti yok diyor.
    ($dosya = readdir($dizinac) ) !== false kullanın

    veya define('
    boolean',false) ekleyin (hiç gerek yok buna)
  • 05-06-2009, 18:42:25
    #3
    Sonsuz döngüye giriyor bu yüzden time limite girip php çalışmasını sonlandırıyor
  • 06-06-2009, 03:49:26
    #4
    gettype kullanmana gerek yok. o satırı birde şöyle dener misin

    while(
    ($dosya = readdir($dizinac)) != false) {


    yine bi hata verirse(sanmıyorum) operatörü !== ile değişin
  • 06-06-2009, 09:42:41
    #5
    Üyeliği durduruldu
    <?
    $host=$_SERVER['HTTP_HOST'];

    $startdir = '.';
    $showthumbnails = false;
    $showdirs = true;
    $forcedownloads = false;
    $hide = array(
    'dlf',
    'httpdocs',
    'index.php',
    'Thumbs',
    '.htaccess',
    '.htpasswd'
    );
    $displayindex = false;
    $allowuploads = false;
    $overwrite = false;

    $indexfiles = array (
    'index.html',
    'index.htm',
    'default.htm',
    'default.html'
    );

    $filetypes = array (
    'png' => 'jpg.gif',
    'jpeg' => 'jpg.gif',
    'bmp' => 'jpg.gif',
    'jpg' => 'jpg.gif',
    'gif' => 'gif.gif',
    'zip' => 'archive.png',
    'rar' => 'archive.png',
    'exe' => 'exe.gif',
    'setup' => 'setup.gif',
    'txt' => 'text.png',
    'htm' => 'html.gif',
    'html' => 'html.gif',
    'php' => 'php.gif',
    'fla' => 'fla.gif',
    'swf' => 'swf.gif',
    'xls' => 'xls.gif',
    'doc' => 'doc.gif',
    'sig' => 'sig.gif',
    'fh10' => 'fh10.gif',
    'pdf' => 'pdf.gif',
    'psd' => 'psd.gif',
    'rm' => 'real.gif',
    'mpg' => 'video.gif',
    'mpeg' => 'video.gif',
    'mov' => 'video2.gif',
    'avi' => 'video.gif',
    'eps' => 'eps.gif',
    'gz' => 'archive.png',
    'asc' => 'sig.gif',
    );

    error_reporting(0);
    if(!function_exists('imagecreatetruecolor')) $showthumbnails = false;
    $leadon = $startdir;
    if($leadon=='.') $leadon = '';
    if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
    $startdir = $leadon;

    if($_GET['dir']) {
    //check this is okay.

    if(substr($_GET['dir'], -1, 1)!='/') {
    $_GET['dir'] = $_GET['dir'] . '/';
    }

    $dirok = true;
    $dirnames = split('/', $_GET['dir']);
    for($di=0; $di<sizeof($dirnames); $di++) {

    if($di<(sizeof($dirnames)-2)) {
    $dotdotdir = $dotdotdir . $dirnames[$di] . '/';
    }

    if($dirnames[$di] == '..') {
    $dirok = false;
    }
    }

    if(substr($_GET['dir'], 0, 1)=='/') {
    $dirok = false;
    }

    if($dirok) {
    $leadon = $leadon . $_GET['dir'];
    }
    }



    $opendir = $leadon;
    if(!$leadon) $opendir = '.';
    if(!file_exists($opendir)) {
    $opendir = '.';
    $leadon = $startdir;
    }

    clearstatcache();
    if ($handle = opendir($opendir)) {
    while (false !== ($file = readdir($handle))) {
    //first see if this file is required in the listing
    if ($file == "." || $file == "..") continue;
    $discard = false;
    for($hi=0;$hi<sizeof($hide);$hi++) {
    if(strpos($file, $hide[$hi])!==false) {
    $discard = true;
    }
    }

    if($discard) continue;
    if (@filetype($leadon.$file) == "dir") {
    if(!$showdirs) continue;

    $n++;
    if($_GET['sort']=="date") {
    $key = @filemtime($leadon.$file) . ".$n";
    }
    else {
    $key = $n;
    }
    $dirs[$key] = $file . "/";
    }
    else {
    $n++;
    if($_GET['sort']=="date") {
    $key = @filemtime($leadon.$file) . ".$n";
    }
    elseif($_GET['sort']=="size") {
    $key = @filesize($leadon.$file) . ".$n";
    }
    else {
    $key = $n;
    }
    $files[$key] = $file;

    if($displayindex) {
    if(in_array(strtolower($file), $indexfiles)) {
    header("Location: $file");
    die();
    }
    }
    }
    }
    closedir($handle);
    }

    //sort our files
    if($_GET['sort']=="date") {
    @ksort($dirs, SORT_NUMERIC);
    @ksort($files, SORT_NUMERIC);
    }
    elseif($_GET['sort']=="size") {
    @natcasesort($dirs);
    @ksort($files, SORT_NUMERIC);
    }
    else {
    @natcasesort($dirs);
    @natcasesort($files);
    }

    //order correctly
    if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);}
    if($_GET['order']=="desc") {$files = @array_reverse($files);}
    $dirs = @array_values($dirs); $files = @array_values($files);


    ?>
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
    <title>Welcome to <? print $host; ?></title>
    <link rel="stylesheet" type="text/css" href="http://www.000webhost.com/images/index/styles.css" />
    </head>
    <body>
    <div id="container">
    <h1>Ftp dizini </h1>
    <div id="breadcrumbs">Website <strong><? print $host; ?></strong> has been successfully installed on
    server.<br />
    Please delete file &quot;<strong>default.php</strong>&quot; from <strong>httpdocs</strong> folder and upload your website
    by using FTP or web based File Manager.<br />
    <br />
    Below you can see your current files in <strong>httpdocs </strong>folder.</div>
    <div id="listingcontainer">
    <div id="listingheader">
    <div id="headerfile">Dosya &amp; Dizin Adı </div>
    <div id="headersize">Boyut</div>
    <div id="headermodified">Son G&uuml;ncelleme </div>
    </div>
    <div id="listing">
    <?
    $class = 'b';
    if($dirok) {
    ?>
    <div><a href="<?=$dotdotdir;?>" class="<?=$class;?>"><img src="http://www.000webhost.com/images/index/dirup.png" alt="Folder" /><strong>..</strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($dotdotdir));?></a></div>
    <?
    if($class=='b') $class='w';
    else $class = 'b';
    }
    $arsize = sizeof($dirs);
    for($i=0;$i<$arsize;$i++) {
    ?>
    <div><a href="<?=$leadon.$dirs[$i];?>" class="<?=$class;?>"><img src="http://www.000webhost.com/images/index/folder.png" alt="<?=$dirs[$i];?>" /><strong><?=$dirs[$i];?></strong> <em>-</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$dirs[$i]));?></a></div>
    <?
    if($class=='b') $class='w';
    else $class = 'b';
    }

    $arsize = sizeof($files);
    for($i=0;$i<$arsize;$i++) {
    $icon = 'unknown.png';
    $ext = strtolower(substr($files[$i], strrpos($files[$i], '.')+1));
    $supportedimages = array('gif', 'png', 'jpeg', 'jpg');
    $thumb = '';

    if($filetypes[$ext]) {
    $icon = $filetypes[$ext];
    }

    $filename = $files[$i];
    if(strlen($filename)>43) {
    $filename = substr($files[$i], 0, 40) . '...';
    }

    $fileurl = $leadon . $files[$i];
    ?>
    <div><a href="<?=$fileurl;?>" class="<?=$class;?>"<?=$thumb2;?>><img src="http://www.000webhost.com/images/index/<?=$icon;?>" alt="<?=$files[$i];?>" /><strong><?=$filename;?></strong> <em><?=round(filesize($leadon.$files[$i])/1024);?>KB</em> <?=date ("M d Y h:i:s A", filemtime($leadon.$files[$i]));?><?=$thumb;?></a></div>
    <?
    if($class=='b') $class='w';
    else $class = 'b';
    }
    ?></div>
    </div>
    </div>
    <div id="copy">Free Web Hosting by <a href="http://www.delphp.in/">Delphi & Php</a></div>
    </body>
    </html>
  • 06-06-2009, 14:03:19
    #6
    while(($dosya = readdir($dizinac)) !== false) {

    Bunu ekleyince çalıştı teşekkurler

    Sil kısmını yaptım ama boşlukları göstermiyor sizce neden olabilir?

    echo (ucwords($dosya))."<a href=?sil=".(ucwords($dosya)).">Sil</a><br>";
    silme kısmındaki ?sil= den sonraki kısmında dosyanın sadece boşluga kadar olan kısmı cıkıyor.

    Yani ali ayse.jpg olursa bunun sadece ali kısmı cıkıyor ayse.jpg kısmı cıkmıyor. yani ?sil=ali ayse.jpg şeklinde cıkması gerekirken ?sil=ali şeklinde cıkıyor.
  • 06-06-2009, 17:52:30
    #7
    Üyeliği durduruldu
    xmtml standartlarında yazmadighinizdan kaynaklaniyor

    <?php echo (ucwords($dosya));?><a href=?sil="<?php echo (ucwords($dosya));?>">Sil</a><br>
  • 06-06-2009, 18:21:12
    #8
    sdemirkeser adlı üyeden alıntı: mesajı görüntüle
    xmtml standartlarında yazmadighinizdan kaynaklaniyor

    <?php echo (ucwords($dosya));?><a href=?sil="<?php echo (ucwords($dosya));?>">Sil</a><br>
    o nasıl bir kullanımdır ya bende ilk href="link" gibi düzelticen sandım..
  • 06-06-2009, 21:34:17
    #9
    böyle olması gerekmiyor mu ?
    <?php echo (ucwords($dosya));?><a href="?sil=<?php echo (ucwords($dosya)); ?>">Sil</a><br />