![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Przyjaciele php.pl Postów: 1 467 Pomógł: 13 Dołączył: 22.02.2003 Ostrzeżenie: (0%) ![]() ![]() |
Mam taki skrypt:[php:1:27cda00d7c]<pre><?php
function insertdir( &$db, $path, $parent ) { $dir = opendir( $path ); while( ( $child = readdir( $dir ) ) !== false ) { if( ( $child != '.' ) AND ( $child != '..' ) ) { if( is_dir( $path.'/'.$child ) ) { $result = $db->Execute( 'SELECT mkdir(''. $child.'', '.$parent');' ); if( $result->fields[0] == 't' ) { print $path.'/'.$child.'/'; $result->Close(); $id = $db->pg_insert_id( 'categories', 'id' ); if( !insertdir( $db, $path.'/'.$child, $id ) { $db->RollbackTrans(); return false; } } else { $result->RollbackTrans(); $result->Close(); return false; } } else { $result = $db->Execute( 'SELECT mk(''.$child.'', '.$parent.', 'testowy plik');' ); if( $result->fields[0] == 't' ) { print $path.'/'.$child; $result->Close(); } else { $result->Close(); $db->RollbackTrans(); return false; } } } closedir( $dir ); } return true; } error_reporting( 'E_ALL' ); set_time_limit( 0 ); include( '/usr/local/htdocs/adodb/adodb.inc.php' ); $db = NewAdodbConnection('postgres7') or die('Cannot open ADOdb'); $db->Connect('localhost', 'php_pl', 'o kurka...', 'postgres') or die('Cannot Connect'); $db->BeginTrans(); if( insertdir( $db, '/usr', 1 ) ) { $db->CommitTrans(); } else { print $db->ErrorMsg(); } $db->Close(); $dir = opendir( './' ); while( ( $child = readdir( $dir ) ) !== false ) { print $child; } closedir( $dir ); ?></pre> [/php:1:27cda00d7c]Teraz caly problem polega na tym, ze skrypt pokazuje taki output Cytat <html><body></body></html> zamiast czegokolwiek innego. Nie wiem czemu sie tak dzieje ![]() Ps. Mam apache 2.0.47 i php5 (--with-apxs2 przy instalacji) na linuxie slackware. Ps2. Jutro wyjezdzam na troche wiec nie bede odpowiadal na posty wyslane pozniej niz dzisiaj |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Przyjaciele php.pl Postów: 1 467 Pomógł: 13 Dołączył: 22.02.2003 Ostrzeżenie: (0%) ![]() ![]() |
no tak... ba jak mam display_error ustawione na Off...
|
|
|
![]()
Post
#3
|
|
![]() Grupa: Przyjaciele php.pl Postów: 1 467 Pomógł: 13 Dołączył: 22.02.2003 Ostrzeżenie: (0%) ![]() ![]() |
[php:1:ecc762d1ec]<?php
header( 'Content-type: text/plain' ); function insertdir( &$db, $path, $parent ) { print $path."n"; $dir = opendir( $path ); get_resource_type( $dir )."n"; if( ! is_resource( $dir ) ) { die( 'problemy z katalogiem' ); } rewinddir( $dir ); while( ( $child = readdir( $dir ) ) !== false ) { if( ( $child != '.' ) AND ( $child != '..' ) ) { if( is_dir( $path.'/'.$child ) ) { if( ! ( $result = $db->Execute( 'SELECT mkdir(''. $child.'', '.$parent.');' ) ) ) { return false; } elseif( $result->fields[0] == 't' ) { print $path.'/'.$child.'/'."n"; $result->Close(); $id = $db->Insert_ID( 'categories', 'id' ); if( !insertdir( $db, $path.'/'.$child, $id ) ) { $db->RollbackTrans(); return false; } } else { $db->RollbackTrans(); $result->Close(); return false; } } else { $result = $db->Execute( 'SELECT mk(''.$child.'', '.$parent.', 'testowy plik');' ); if( $result->fields[0] == 't' ) { print $path.'/'.$child."n"; $result->Close(); } else { $result->Close(); $db->RollbackTrans(); return false; } } } closedir( $dir ); } return true; } error_reporting( E_ALL ); set_time_limit( 0 ); include( '/usr/local/htdocs/adodb/adodb.inc.php' ); $db = ADONewConnection('postgres7') or die("Cannot Connect"); $db->Connect('host=localhost user=php_pl password=private dbname=postgres') or die("Cannot Connect"); $db->BeginTrans(); if( insertdir( $db, '/usr/local/htdocs', 1 ) ) { $db->RollbackTrans(); } else { print $db->ErrorMsg(); } $db->Close(); ?>[/php:1:ecc762d1ec]ale ten kod robi cos czego calkiem nie rozumiem, a mianowicie daje taki error Cytat /usr/local/htdocs
to mnie troche dobija. Jakbyscie doszli czemu to napiszcie a sprawdze jak wroce (za 2 tyg)
<br /> <b>Warning</b>: readdir(): 9 is not a valid Directory resource in <b>/usr/local/htdocs/insert.php</b> on line <b>14</b><br /> Ps. zauwazcie, ze przy rewinddir ani przy innych sie nie skarzy Ps 2. Po srodowisko dla tego skryptu zapraszam tutaj (link na samym dole i przeczytajcie Ps'y). |
|
|
![]() ![]() |
![]() |
Aktualny czas: 20.08.2025 - 05:13 |