include("../includes/common.htm");
$badphoto=0;
if ($job==2) { $myid="dbid"; } else { $myid="id"; }
if ($fid) {
$qry="select PageName,avatar from $table[$job] where $sid[$job]='$fid'";
$rec=SelectQry($qry);
$avatar=$rec[0]['avatar'];
if ($avatar=='') { $avatarstatus="Please choose an avatar!"; }
//else { $avatarstatus="Edit Headshot"; }
/*
if ($job==0) { $profile=$homepage . "/" . "portfolio.html"; }
else if ($job==1) { $profile=$homepage . "/" . "portfolio-photographer.html"; }
else if ($job==2) { $profile=$homepage . "/" . "portfolio-designer.html"; }
else if ($job==4) { $profile=$homepage . "/" . "mypicture.html"; }
*/
$profile="$homepage/portfolio.html?id=$fid&pid=$job";
/* delete photo */
if ($did!='') {
$pqry="select filename,status from $phototable[$job] where id='$did' and pid='$fid'";
$prec=SelectQry($pqry);
$aqry="select avatar from $table[$job] where avatar like '%".$prec[0]['filename']."%' and $myid='$fid'";
//if ($admin) print "$aqry
";
$arec=SelectQry($aqry);
if ($arec[0]['avatar']!='') {
$updatestatus="update $table[$job] set avatar='' where $myid='$fid'";
//if ($admin) print "$updatestatus
";
$updatestatusrec = mysql_query("$updatestatus");
}
$frame=$jobdir[$job] . $rec[0]['PageName'] . "/frame_" . $prec[0]['filename'];
$thumb=$jobdir[$job] . $rec[0]['PageName'] . "/thumb_" . $prec[0]['filename'];
$large=$jobdir[$job] . $rec[0]['PageName'] . "/large_" . $prec[0]['filename'];
$file=$jobdir[$job] . $rec[0]['PageName'] . "/" . $prec[0]['filename'];
if (is_file($frame)) { unlink($frame); }
if (is_file($thumb)) { unlink($thumb); }
if (is_file($large)) { unlink($large); }
if (is_file($file)) { unlink($file); }
$delete="delete from $phototable[$job] where id='$did' and pid='$fid'";
$updaterec = mysql_query("$delete") or $msg="Unable to remove photo, contact admin.
";
if ($debug!='') { print "$delete
$file
$frame
$thumb
"; }
}
$pqry="select id,filename,filesize,filedate,status from $phototable[$job] where filename!='' and pid='$fid' and (status!='bad') $extra order by filedate desc";
//if ($admin) echo $pqry;
$prec=SelectQry($pqry);
$bqry="select id,filename,filesize,filedate,status from $phototable[$job] where filename!='' and pid='$fid' and status='bad'";
$brec=SelectQry($bqry);
}
$ilimit=10000;
$totalimg=0;
$peralbum=$ilimit;
$dir=$jobdir[$job] . $rec[0]['PageName'];
$url=$oldhomepage . "/" . $jobpath[$job] . "/" . $rec[0]['PageName'];
$thumbarr=array();
$framearr=array();
$filearr=array();
$iarr=array();
$photostatus=array();
$totalimg=0;
/* IF image exist in database */
if (count($prec)>0) {
for($f=0;$f";
$avatarfile="avatar_" . $prec[$f]['filename'];
if ($avatarfile=="$avatar") {
$avatarpath=$url . "/" . $pagename . $avatarfile;
//print "avatar: $avatarfile ($f)
";
$photostatus[$f]="avatar";
//if ($prec[$f]['status']=='Inactive') $avatarstatus="Edit Headshot";
}
if (($prec[$f]['status']=='main') && ($photostatus[$f]!='avatar')) $photostatus[$f]="main";
if (($prec[$f]['status']=='Inactive') && ($photostatus[$f]!='avatar')) $photostatus[$f]="hidden";
array_push($thumbarr,$thumb);
array_push($framearr,$frame);
array_push($filearr,$prec[$f]['filename']);
array_push($iarr,$prec[$f]['id']);
$totalimg++;
} else {
/* bad photo */
/*
$frame=$jobdir[$job] . $rec[0]['PageName'] . "/frame_" . $prec[0]['filename'];
$thumb=$jobdir[$job] . $rec[0]['PageName'] . "/thumb_" . $prec[0]['filename'];
$large=$jobdir[$job] . $rec[0]['PageName'] . "/large_" . $prec[0]['filename'];
$file=$jobdir[$job] . $rec[0]['PageName'] . "/" . $prec[0]['filename'];
if (is_file($frame)) { unlink($frame); }
if (is_file($thumb)) { unlink($thumb); }
if (is_file($large)) { unlink($large); }
if (is_file($file)) { unlink($file); }
*/
$badphoto++;
/*
$updatebadphoto="update $phototable[$job] set status='bad' where id='".$prec[$f]['id']."'";
if ($admin) { print "$updatebadphoto
"; }
$updatebadrec = mysql_query("$updatebadphoto");
if ($debug!='') { print "$updatebadphoto
$file
$frame
$thumb
"; }
*/
}
}
/* ELSE read image directly from local directory */
}
/*
else if ($handle = opendir("$dir")) {
while (false !== ($file = readdir($handle))) {
$forExt = explode('.',$file);
$dirpath=$dir . "/" . $file;
if (($totalimg<=$ilimit) && (eregi("frame_",$file))) {
$thumbfile=ereg_replace("frame_","thumb_",$file);
$thumb=$url . "/" . $thumbfile;
$framefile=$file;
$frame=$url . "/" . $framefile;
array_push($thumbarr,$thumb);
array_push($framearr,$frame);
array_push($filearr,$file);
$totalimg++;
}
}
closedir($handle);
}
*/
$numofalbum=ceil($totalimg/$peralbum);
//print "$dir
total pic: $totalimg
pic per album: $peralbum
number of album: $numofalbum";
$numofalbum=1;
?>
if ($admin) { ?>
Bad Photos
} ?>
if (count($thumbarr)==0) { print "No Image available
"; exit; }
?>
// print "Total pic: $totalimg
Pic per album: $peralbum
Number of album: $numofalbum";
if ($badphoto>0) {
if ($badphoto>1) {
print "Note: There may be $badphoto bad photos in your album.
Bad photo are photo that are either unreadable by our system or is corrupted.
";
} else { print "There is $badphoto bad photo in your album.
Bad photo are photo that are either unreadable by our system or is corrupted.
"; }
}
if (($badphoto==0) && (count($brec)>0)) {
if (count($brec)>1) {
print "There may be " . count($brec) . " bad photos in your album.
Bad photo are photo that are either unreadable by our system or is corrupted.
";
} else { print "There is " . count($brec) . " bad photo in your album.
Bad photo are photo that are either unreadable by our system or is corrupted.
";
}
}
?>