Adresa do rootu
Adresa do rootu
Nie som skuseny php programator. Potrebujem napisat adresu do jedneho scriptu (ktory je v priecinku), aby includoval subor z priecinka /fotky/kategoria/foto.php.
Pouzivam SEF - mod_rewrite a preto potrebujem tuto cestu napisat tak, aby ju script bral od rootu. Dakujem
Pouzivam SEF - mod_rewrite a preto potrebujem tuto cestu napisat tak, aby ju script bral od rootu. Dakujem
-
audiotrack
VIP
- Príspevky: 25958
- Registrovaný: 09 sep 2005, 18:39
- Kontaktovať používateľa:
a je to tvoj server (a vieš teda presnú adresárovú štruktúru) alebo platený resp. freehosting (a musíš ju zistiť)? Ak to druhé (čo je pravdepodobnejšie, lebo v prvom prípade by si ju vedel) tak si sprav v /fotky/kategoria/foto.php neajkú syntaktickú chybu, spusti a v chybe uvidíš presnú cestu k súboru kde chyba nastala
Neviem či som to spravne napisal.
Urobil som stranku na jednom serveri. Script vyzeral asi takto:
Hoci domena.tld je tiez tam kde ten subor v ktorom je ten script, neriesil som tu root adresu ale takto mi to fungovalo.
Ale potom som to prehodil na iny server (hosting), kde som zistil, ze je problem. Ma ochranu proti tejto funkcii (ak je spustana cez http.)
A teraz mi vyhadzuje tento error:
Ďakujem
//autoeditácia príspevku ( 25 Jan 2009, 14:10 )
Upravil som to takto:
Avšak teraz mi už neincludne spustený php script, ale vypíše časť scriptu.
Ďakujem za pomoc
Urobil som stranku na jednom serveri. Script vyzeral asi takto:
Kód: Vybrať všetko
<?php
$url = fopen("http://domena.tld/fotky/kategoria/foto.php",r);
fpassthru($url);
?><Ale potom som to prehodil na iny server (hosting), kde som zistil, ze je problem. Ma ochranu proti tejto funkcii (ak je spustana cez http.)
A teraz mi vyhadzuje tento error:
Kód: Vybrať všetko
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /domains1/do6xxx00/public/www_root/subor.php on line 9
Warning: fopen(http://domena.tld/fotky/kategoria/foto.php) [function.fopen]: failed to open stream: no suitable wrapper could be found in /domains1/do6xxx00/public/www_root/subor.php on line 9
Warning: fpassthru(): supplied argument is not a valid stream resource in /domains1/do6xxx00/public/www_root/subor.php on line 10
//autoeditácia príspevku ( 25 Jan 2009, 14:10 )
Upravil som to takto:
Kód: Vybrať všetko
<?php
$url = fopen("./fotky/kategoria/foto.php",r);
fpassthru($url);
?>Ďakujem za pomoc
Lebo to foto.php je script na to, aby vypisal fotky z daneho priecika /kategorie/. Ked to hodim cez include tak vypisuje vsetky mozne obrazky od rootu.
Tu j ten script na fotky:
foto.php
get_image.php
Ten script je tak urobeny, ze berie fotky z tamadial, kde sa to .php nachaza. Mohol by mi to niekto upravit, ze sa na tvrdo nastavi priecinok?
Dakujem
Tu j ten script na fotky:
foto.php
Kód: Vybrať všetko
<?php
$directory = getcwd();
$directories = array();
getListOfDirectories( $directories, $directory );
// Max width of image thumbnail
$max_width = 180;
// Max height of image thumbnail
$max_height = 150;
// Max number of images per row of the table
$images_per_row = 2;
$directories = array_flip($directories);
foreach( $directories as $directory => $foo){
$directories[ $directory ] = array();
$directory_reader = dir($directory);
// Get a list of images
while (false !== ($filename = $directory_reader->read())) {
if( preg_match( "~.*\.(gif|jpg|jpeg|png)~Ui", $filename, $matches ) ){
$directories[ $directory ][] = $filename;
}
}
$directory_reader->close();
}
function getListOfDirectories( &$directories, $current_directory ){
$directories[] = $current_directory;
$directory_reader = dir($current_directory);
while (false !== ($filename = $directory_reader->read())) {
if( is_dir( $current_directory . '/' . $filename ) && $filename[0] != '.'){
getListOfDirectories( $directories, $current_directory . '/' . $filename );
}
}
}
?>
<table>
<?php
// Render the images in their rows
foreach( $directories as $directory => $images ){
$directory = substr( $directory, strlen( getcwd() ) + 1 );
echo (
str_replace
(
array(
'[[images_per_row]]',
'[[directory_name]]',
),
array(
$images_per_row,
($directory)?$directory:'[[current]]'
),
''
)
);
$rows = ceil(count($images)/$images_per_row);
for( $y = 0; $y < $rows; $y++ ){
echo( '<tr>' );
for( $x = 0; $x < $images_per_row; $x++ ){
$index = $x + ( $y * $images_per_row );
if( $index < count( $images ) ){
echo
(
str_replace
(
array(
'[[path]]',
'[[image_name]]',
'[[width]]',
'[[height]]'
),
array(
(($directory)?$directory.'/':''),
$images[ $index ],
$max_width,
$max_height
),
'<td align="center"><a href="[[path]][[image_name]]" rel="lightbox[roadtrip]"><img border="0" src="get_image.php?image_name=[[path]][[image_name]]&width=[[width]]&height=[[height]]" alt="[[image_name]]"></a></td>'
)
);
}
}
echo( '</tr>' );
}
}
?>
</table>
Kód: Vybrať všetko
<?php
$image_name = './' . $_GET[ 'image_name' ];
$output_width = $_GET[ 'width' ];
$output_height = $_GET[ 'height' ];
$types = array(
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
);
if( preg_match( "~.*\.(gif|jpg|jpeg|png)~Ui", $image_name, $matches ) ){
$format = $matches[ 1 ];
if( $format == 'jpg' ){
$format = 'jpeg';
}
switch( $format ){
case 'gif':{
$image = imagecreatefromgif( $image_name );
break;
}
case 'jpeg':{
$image = imagecreatefromjpeg( $image_name );
break;
}
case 'png':{
$image = imagecreatefrompng( $image_name );
break;
}
}
// obtain source image dimensions
list( $width, $height, $type ) = getimagesize( $image_name );
// By default, w/h are the same as the requested output size
$new_height = $output_height;
$new_width = $output_width;
// Do we have to shrink it horizontally or vertically?
$ratio_current = $width / $height;
$ratio_output = $output_width / $output_height;
if( $ratio_current > $ratio_output ){
// New ratio is wider/shorter than old
$new_height = $height / ( $width / $output_width );
} elseif ( $ratio_current < $ratio_output ) {
// New ratio is taller/thinner than old
$new_width = $width / ( $height / $output_height );
}
// Create a blank image
$target = imagecreatetruecolor
(
$new_width,
$new_height
);
// Copy resized image into blank image
imagecopyresampled( $target, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
// Clean up in-memory objects
imagedestroy( $image );
header("Content-Type: " . $types[ $format ]);
imagejpeg($target);
}
?>Dakujem
Zmeň riadokNamiesto tej funkcie getcwd(); tam daj ten adresár, ktorý tam chceš mať.
Kód: Vybrať všetko
$directory = getcwd();Oh, dakujem. Velkde vdaka!
//autoeditácia príspevku ( 26 Jan 2009, 12:24 )
Ešte by som sa chcel spýtať, či by niekto nevedel ten script upraviť tak, aby vygeneroval a uložil thumbnail do nejakeho priečinka, napr, /thumb/, lebo keď ten sa stale spusta, stale generuje nove thumby, a server je dost zatazeny.
Dakujem
//autoeditácia príspevku ( 26 Jan 2009, 12:24 )
Ešte by som sa chcel spýtať, či by niekto nevedel ten script upraviť tak, aby vygeneroval a uložil thumbnail do nejakeho priečinka, napr, /thumb/, lebo keď ten sa stale spusta, stale generuje nove thumby, a server je dost zatazeny.
Dakujem
-
programator
Medium Star
- Príspevky: 475
- Registrovaný: 18 apr 2005, 8:31
- Bydlisko: Papua new Guinea
- Kontaktovať používateľa:
Používam tento script, fotky nahadzujem cez ftp.
//autoeditácia príspevku ( 26 Jan 2009, 17:06 )
Popripade mozete mi tu poslat pdoobny script na podobnom principe ako je tento, ale s thumb.
dik
//autoeditácia príspevku ( 27 Jan 2009, 17:25 )
Našeil som novú galériu, ktorá už ukladá thumbnails. Vedel by niekto vybrať túto funkciu, pridať ju do pôvodneho scriptu? Ďakujem veľmi pekne.
//autoeditácia príspevku ( 26 Jan 2009, 17:06 )
Popripade mozete mi tu poslat pdoobny script na podobnom principe ako je tento, ale s thumb.
dik
//autoeditácia príspevku ( 27 Jan 2009, 17:25 )
Našeil som novú galériu, ktorá už ukladá thumbnails. Vedel by niekto vybrať túto funkciu, pridať ju do pôvodneho scriptu? Ďakujem veľmi pekne.