classmap.php

Gesponsorde koppelingen

PHP script bestanden

  1. index.php
  2. sql.sql
  3. handlemap.php
  4. classmap.php
  5. config.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php

class mapModule
{
    
    // ## Public functie's vallen hieronder

    public function mapModule($user, $pass, $host, $db)
    {
    
        $this->user = $user;
        $this->pass = $pass;
        $this->host = $host;
        $this->db   = $db;
    }

    
    public function connectMySQL()
    {

        $connectMySQL = mysql_connect( $this->host, $this->user, $this->pass );
        $connectDB    = mysql_select_db( $this->db );
        $this->connection = $connectMySQL;
        if( $connectMySQL && $connectDB ){
            return true;
        }
else{
            return "Kon geen verbinding met database maken.<br />Reden: ". mysql_error();
        }
    }
    
    
    public function createMap( $userid )
    {

        $this->userID = $userid;
        
        $cols = 30;
        $rows = 30;
        
        $mapTable = "<table cellpadding=\"0\" cellspacing=\"0\" >";
            for( $y = 1; $y < $rows; $y ++ )
            {

                $mapTable .= "<tr>";
                
                for( $x = 1; $x < $cols; $x ++ )
                {

                    // ## Park objecten binnenhalen
                    $parkObjects = $this->getMapObjects( $x, $y, $this->userID );
                    
                    // ## Er zijn objecten gevonden in deze X+Y range
                    if( $parkObjects['object'] == true ){
                          $mapTable .= "<td style=\"border-spacing: 1px;\"><img alt=\"Object\" onclick=\"getClickedPosition( ". $x .", ". $y .", ". $x . $y ." );\" style=\"background-image: url(images/grass.png);\" src=\"". $parkObjects['objectImage']."\" id=\"". $x . $y . "\" /></td>";
                    
                    // ## Gewoon simpel gras laten zien
                    }else{
                          $mapTable .= "<td style=\"border-spacing: 1px;\">
                                          <img alt=\"Gras\" onclick=\"getClickedPosition( "
. $x .", ". $y .", ". $x . $y ." );\" src=\"images/grass.png\" id=\"". $x . $y . "\"/></td>";
                    }
                }

                
                $mapTable .= "</tr>";
            }
        
        $mapTable .= "</table>";    
        
        return $mapTable;
    }

    
    public function createObjectList()
    {

    
        $queryGetList = $this->performQuery( "SELECT id, objectname, objectimage FROM objectlist" );
        
        if( $queryGetList ){
            
            $divList = "<div style=\"border: 1px solid; width: 500px;\">";
            
            while( $rowObjectlist = mysql_fetch_assoc( $queryGetList ) ){
                $divList .= "<input type=\"button\" value=\"". $rowObjectlist['objectname']."\" onclick=\"addObject(". $rowObjectlist['id'] .", ". $this->userID .");\" /> | ";
            }

            
            $divList .= "</div>";
            return $divList;
        }
else{
            return "Kon geen verbinding met database maken.<br />Reden: ". mysql_error() ."";
        }
        
    }

    
    public function createObjectEditField()
    {

        $editField = "<div id=\"editField\" style=\"border: 1px solid; width: 500px;\">";
        $editField .= "</div>";
        return $editField;
    }


    public function performQuery( $queryString )
    {

        $executeQuery = mysql_query( $queryString, $this->connection );
        
        if( $executeQuery ){
            return $executeQuery;
        }
else{
            return false;
        }
    }

    
    // ## Private functie's vallen  hieronder
    
    private function getMapObjects( $xPos, $yPos, $userid )
    {

        $queryGetObjects = $this->performQuery( "SELECT objectnaam, objectImage FROM objects WHERE userid=". mysql_real_escape_string($userid) ." AND xPos=". mysql_real_escape_string($xPos) ." AND yPos=". mysql_real_escape_string($yPos) );
        
        if( $queryGetObjects ){
            if( mysql_num_rows( $queryGetObjects ) > 0 ){
                
                $fetchObjectData = mysql_fetch_assoc( $queryGetObjects );
                
                return array( "object"             => true,
                              "objectNaam"         => $fetchObjectData['objectnaam'],
                              "objectImage"        => $fetchObjectData['objectImage']
                            );
            }
        }
else{
            return false;
        }
    }
    
}

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.