Hallo,
Ik zit met een vreemd probleempje, ik krijg de volgende meldingen terwijl die bij zowat identieke functies (aan het begin van de class) niet voorkomen:
Notice: Undefined variable: thumb in portfolio.class.php on line 77
Notice: Undefined variable: image in portfolio.class.php on line 96
Notice: Undefined variable: description in portfolio.class.php on line 115
Het gekke is dat als ik binnen de while loop de variabele echo dan bestaat ie, maar zodra ik het return bestaat ie ineens niet meer.....
<?php
class portfolio{
/* setup for the thumbs and images, depending on the var $dir, for example: playground/thumbs or playground/gallery */
public function index($dir){
/* read directory and put the files in an array */
$x=0;
$handle = opendir('public/content/' . $dir);
/* walk through directory and put the filenames in an array */
while (false != ($file = readdir($handle))) {
if($file!="."&&$file!=".."){
$arrimages[$x]=$dir.$file;
$x++;
}
}
$numimages=$x;
closedir($handle);
/* if the given directory is empty it's propably under construction, else the array has to be ordered by alfabet */
if($numimages==0){
echo'Currently under construction.';
}else{
/* sort by alphabet */
sort($arrimages);reset($arrimages);
}
return $arrimages;
}
/* get the descriptions from the database, each description owns a timestamp referring to the filenames */
public function descriptions($value){
$y=0;
$connection=new shared();
$connection->connect();
$descriptions=new mysql($value);
$query=$descriptions->select('','');
while($myDescriptions=$descriptions->FetchArray($query)){
extract($myDescriptions);
$arrdescr['id'][$y]=$id;
$arrdescr['descr'][$y]=$description;
$y++;
}
return $arrdescr;
}
// if a page is requested to edit a project- or playgrounditem the following functions are used
public function getthumb($source, $timestamp){
$handle = opendir('public/content/' . $source . '/thumbs/');
/* walk through directory till a file, depending on the timestamp, is found. */
while (false != ($file = readdir($handle))) {
if($file=="thumb_".$timestamp.".png" || $file=="thumb_".$timestamp.".jpeg" || $file=="thumb_".$timestamp.".jpg" || $file=="thumb_".$timestamp.".gif" || $file=="thumb_".$timestamp.".swf"){
$thumb['file']=$source.'/thumbs/'.$file;
$thumb['edit']=$file;
$thumb['source']=$source;
}
}
closedir($handle);
return $thumb;
}
public function getimage($source, $timestamp){
$handle = opendir('public/content/' . $source . '/gallery/');
/* walk through directory till a file, depending on the timestamp, is found. */
while (false != ($file = readdir($handle))) {
if($file==$timestamp.".png" || $file==$timestamp.".jpeg" || $file==$timestamp.".jpg" || $file==$timestamp.".gif" || $file==$timestamp.".swf"){
$image['edit']=$file;
$image['file']=$source.'/gallery/'.$file;
/* to determine which file has to be removed and replaced.... */
/* ... and in which directory */
$image['source']=$source;
}
}
closedir($handle);
return $image;
}
public function getdescription($source, $timestamp){
$connection=new shared();
$connection->connect();
$descr=new mysql($source);
$query=$descr->select($timestamp, 'id');
while($myDescription=$descr->FetchArray($query)){
extract($myDescription);
if(!empty($id)){
$description['timestamp']=$id;
$description['descr']=$description;
}
}
return $description;
}
public function deletefiles($source, $timestamp){
#########
//new
#########
/* walk through directory till a file, depending on the timestamp, is found. */
$directory='public/content/' . $source . '/thumbs/';
$handle = opendir($directory);
while (false != ($file = readdir($handle))) {
if($file=="thumb_".$timestamp.".png" || $file=="thumb_".$timestamp.".jpeg" || $file=="thumb_".$timestamp.".jpg" || $file=="thumb_".$timestamp.".gif" || $file=="thumb_".$timestamp.".swf"){
if(!unlink($directory.$file)){
echo"Error deleting thumb, it can't be found. You are being redirected about 3 seconds...<br />";
echo"<meta http-equiv=\"refresh\" content=\"3; URL=".__ROOT.$_SESSION['back']."\" \>";
}
}
}
closedir($handle);
$directory='public/content/' . $source . '/gallery/';
$handle = opendir($directory);
/* walk through directory till a file, depending on the timestamp, is found. */
while (false != ($file = readdir($handle))) {
if($file==$timestamp.".png" || $file==$timestamp.".jpeg" || $file==$timestamp.".jpg" || $file==$timestamp.".gif" || $file==$timestamp.".swf"){
if(!unlink($directory.$file)){
echo"Error deleting image, it can't be found. You are being redirected about 3 seconds...<br />";
echo"<meta http-equiv=\"refresh\" content=\"3; URL=".__ROOT.$_SESSION['back']."\" \>";
}
}
}
closedir($handle);
return $source;
echo"<meta http-equiv=\"refresh\" content=\"0; URL=".__ROOT.$_SESSION['back']."\" \>";
}
}
?>
1.157 views