require_once("../../include/headers.inc.php");
global $id, $persoonres, $rating;
headers();
processPost();
drawPage();
/**
* Behandelt de data verstuurd door forms
*/
function processPost() {
if ( isset($_GET['action']) && $_GET['action']== 'delete_photo' && hasPrivilege("bpersoonfoto"))
{
$sql = "SELECT * FROM adm_foto WHERE id=" . $_GET['fid'];
$result = mysql_query($sql) or die(mysql_error());
$line = mysql_fetch_array($result);
global $data_root_path;
$dir = $data_root_path . "upload/foto/persoon/" . $_GET['id'];
if (unlink($dir . "/orig/" . $line['foto']) && unlink($dir . "/thumb/" . $line['foto']))
{
$sql = "DELETE FROM adm_foto WHERE id=" . $_GET['fid'];
mysql_query($sql);
}
}
if ( isset($_FILES['fotofile']) && hasPrivilege("bpersoonfoto") )
{
global $data_root_path;
$dir = $data_root_path . "upload/foto/persoon/" . $_GET['id'];
//Voeg foto in
if (! ( file_exists($dir) && is_dir($dir) ) )
{
//Directory bestaat nog niet, maak deze aan
FtpMkDir( "upload/foto/persoon/", $_GET['id'] );
FtpMkDir( "upload/foto/persoon/" . $_GET['id'] . "/", "thumb");
FtpMkDir( "upload/foto/persoon/" . $_GET['id'] . "/", "orig");
}
$originalpicname = $dir . "/orig/" . $_FILES['fotofile']['name'];
move_uploaded_file($_FILES['fotofile']['tmp_name'], $originalpicname);
//Ga foto nu bewerken!
$original = imagecreatefromjpeg($originalpicname);
$maxthumbside = 200;
$thumbx = imagesx($original);
$thumby = imagesy($original);
if ( $thumbx > $maxthumbside) {
$thumby = $thumby * ($maxthumbside / $thumbx);
$thumbx = $maxthumbside;
}
if ( $thumby > $maxthumbside) {
$thumbx = $thumbx * ($maxthumbside / $thumby);
$thumby = $maxthumbside;
}
$thumb = imagecreatetruecolor($thumbx,$thumby);
imagecopyresampled($thumb, $original, 0, 0, 0, 0, $thumbx, $thumby, imagesx($original), imagesy($original));
imagejpeg($thumb, $dir . "/thumb/" . $_FILES['fotofile']['name'], 80);
imagedestroy($thumb);
imagedestroy($original);
//Sla op in DataBase
$sql = "INSERT INTO adm_foto
(onderwerp, foto, type) VALUES ('" . $_GET['id'] . "', '" . $_FILES['fotofile']['name'] . "', '1')";
$result = mysql_query($sql);
if (!$result) echo(mysql_error());
}
}
/**
* Tekent de pagina
* Verwacht via $_GET['id'] de persoonid te krijgen
*/
function drawPage(){
global $persoonres,$rating, $id;
cm_render_left();
?>
if (!isset($_GET['id'])) {
$msg = "Deze pagina verwacht een referentie naar de persoon '?id=..'";
layoutBlueDrawBoxParam('Melding','melding',$msg);
} else {
$id = $_GET['id'];
$persoonres = mysql_fetch_object(mysql_query("SELECT * FROM adm_persoon WHERE id={$id}"));
layoutBlueDrawBox(str_persoonnaam($persoonres->achternaam,$persoonres->tussenvoegsel,$persoonres->voorletters,$persoonres->voornaam) . ' (' . $persoonres->knsbnummer . ')','persoon');
}
?>
footers();
}
/**
* Callback functie voor div met melding
*/
function melding($msg) {
echo $msg;
}
/**
* Callback functie voor div met persooninformatie
*/
function persoon() {
global $id, $persoonres, $rating, $cm_wedstrijd, $cm_klasse, $cm_ronde, $cm_team, $cm_persoon, $photo_path;
$rating = getRating($id);
$seizoen = getSeizoen();
$teamsql =
"SELECT s.id AS sid, s.naam AS snaam, k.id AS kid, k.naam AS knaam, t.id AS tid, " .
" t.naam AS tnaam, ti.bord AS bord, c.id AS cid, c.naam AS cnaam " .
"FROM cm_teamindeling AS ti " .
"LEFT JOIN cm_team AS t ON ti.team=t.id " .
"LEFT JOIN cm_klasse AS k ON t.klasse=k.id " .
"LEFT JOIN cm_seizoen AS s ON k.seizoen=s.id " .
"LEFT JOIN adm_club AS c ON t.club=c.id " .
"WHERE ti.persoon={$id} " .
"ORDER BY s.begin DESC, k.prioriteit ASC, bord ASC";
$partijsql =
"SELECT w.datum AS datum, team1.id AS teamid1, team2.id AS teamid2, team1.naam AS teamnaam1, " .
" team2.naam AS teamnaam2, p1.bord AS bord, p.id AS pid, p.achternaam AS achternaam, " .
" p.voornaam AS voornaam, p.tussenvoegsel AS tussenvoegsel, p.voorletters AS voorletters, " .
" p1.wit AS kleur, psc.score AS score, pscr.score AS reglementair, k.id AS kid, w.id AS wid, k.naam AS knaam, " .
" r.id AS rid, r.omschrijving AS rnaam, r.nr AS rnr " .
"FROM cm_partij AS p1 " .
"LEFT JOIN cm_teamresultaat AS t1 ON p1.teamresultaat=t1.id " .
"LEFT JOIN cm_teamresultaat AS t2 ON t2.wedstrijd=t1.wedstrijd AND t1.id<>t2.id " .
"LEFT JOIN cm_partij AS p2 ON p2.teamresultaat=t2.id AND p1.bord=p2.bord " .
"LEFT JOIN cm_partijscore AS psc ON p1.score=psc.id " .
"LEFT JOIN cm_partijscore AS pscr ON p1.reglementair=pscr.id " .
"LEFT JOIN cm_team AS team1 ON t1.team=team1.id " .
"LEFT JOIN cm_team AS team2 ON t2.team=team2.id " .
"LEFT JOIN cm_wedstrijd AS w ON t1.wedstrijd=w.id " .
"LEFT JOIN adm_persoon AS p ON p2.speler=p.id " .
"LEFT JOIN cm_ronde AS r ON w.ronde=r.id " .
"LEFT JOIN cm_klasse AS k ON team1.klasse=k.id " .
"WHERE p1.speler={$id} AND k.seizoen={$seizoen}";
$ratingres = mysql_query("SELECT r.*, rs.naam AS naam FROM adm_rating AS r, adm_ratingsoort AS rs WHERE r.soort=rs.id AND r.persoon={$id} ORDER BY r.soort, r.datum DESC");
$lidmaatschapres = mysql_query("SELECT l.*, c.id AS cid, c.naam AS cnaam FROM adm_club AS c, adm_lidmaatschap AS l WHERE l.persoon={$id} AND l.club=c.id ORDER BY c.naam ASC, l.start ASC");
$teamres = mysql_query($teamsql);
$partijres = mysql_query($partijsql);
$photores = mysql_query("SELECT *, f.onderwerp AS pid, f.id AS fid FROM adm_foto AS f, adm_fototype AS ft WHERE f.type=ft.id AND ft.naam='persoon' AND f.onderwerp={$id}");
// Persoonlijke informatie
?>
if (cm_show_photo())
{
echo photo_persoon($persoonres->id,'left',120);
}
?>
| Naam: |
|