ich möchte für ein Foren RPG die Ilch-seite so verändern, dass man die Steckbriefe der einzelnen Charactere sehen kann. Zusätzlich sollen die Nutzer den Steckbrief ihres Chars beabreiten können. Hierfür habe ich mir ein Modul geschrieben, welches ein Editier-formular bereitstellt.
Meien Frage ist nun wie stell ich sicher, dass wirklich jeder Nutzer nur sein Profil bearbeiten kann? (außer der Admin natürlich)
Wenn ich einem Nutzer das Modulrecht gebe, kann der zur Zeit alle Steckbriefe bearbeiten. In der Datenbank steht eine Zuordnung, welchem Nutzer welcher Char gehört.
Meine char.php:
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | <?php // Copyright by: Kirika defined ( 'main' ) or die ( 'no direct access' ); defined ( 'admin' ) or die ( 'only admin access' ); $um = $menu ->get(1); switch ( $um ) { default : $design = new design ( 'Admins Area' , 'Admins Area' , 2); $design ->header(); $q = '' ; if (isset( $_REQUEST [ 'q' ])) { $q = escape( $_REQUEST [ 'q' ], 'string' ); } $tpl = new tpl ( 'char/char' , 1); $tpl ->set( 'action_antispam' , get_antispam( 'adminuser_action' , 0, true)); $tpl ->set_out( 'q' , unescape( $q ), 0); $q = str_replace ( '*' , '%' , $q ); if ( strpos ( $q , '%' ) === false) { $q = $q . '%' ; } $limit = 15; // Limit $page = ( $menu ->getA(1) == 'p' ? $menu ->getE(1) : 1); $anfang = ( $page - 1) * $limit ; $class = '' ; $q = "SELECT name,id, spitzname FROM `profile` ORDER by name ASC LIMIT " . $anfang . "," . $limit ; $erg = db_query( $q ); while ( $row = db_fetch_object( $erg )) { if ( $class == 'Cmite' ) { $class = 'Cnorm' ; } else { $class = 'Cmite' ; } $ar = array ( 'name' => $row ->name, 'spitzname' => $row ->spitzname, 'id' => $row ->id, 'class' => $class , ); $tpl ->set_ar_out( $ar , 1); } $design ->footer(); break ; // details eines chars anzeigen case 1 : $design = new design ( 'Admins Area' , 'Admins Area' , 2); $design ->header(); if (isset ( $_REQUEST [ 'cID' ])) { $cid = $_REQUEST [ 'cID' ]; } else { $cid = $menu ->get(2); } $erg = db_query( "SELECT * FROM profile WHERE id = '" . $cid . "'" ); if (db_num_rows( $erg ) == 0) { die ( 'Fehler: Charname nicht gefunden <a href="?user">zurück</a>' ); } else { $row = db_fetch_assoc( $erg ); $tpl = new tpl ( 'char/details' , 1); $row [ 'sex1' ] = ( $row [ 'sex' ] == 2 ? 'checked' : '' ); $row [ 'sex2' ] = ( $row [ 'sex' ] == 1 ? 'checked' : '' ); if (@ file_exists ( $row [ 'bild' ])) { $row [ 'bild' ] = '<img src="' . $row [ 'bild' ] . '" border="0" /><br />' ; } else { $row [ 'bild' ] = '' ; } $row [ 'antispam' ] = get_antispam( 'adminuser' , 0, true); $tpl ->set_ar_out ( $row , 0); $tpl ->out(1); } $design ->footer(); break ; // details des Chars aendern case 2 : $design = new design ( 'Admins Area' , 'Admins Area' , 2); $design ->header(); $changeok = true; $cid = escape( $_POST [ 'cID' ], 'integer' ); if ( $changeok and chk_antispam( 'adminuser' , true)) { $abf = "SELECT * FROM profile WHERE id = '" . $cid . "'" ; $erg = db_query( $abf ); $row = db_fetch_object( $erg ); // avatar speichern START $avatar_sql_update = '' ; if (! empty ( $_FILES [ 'avatarfile' ][ 'name' ])) { $file_tmpe = $_FILES [ 'avatarfile' ][ 'tmp_name' ]; $rile_type = ic_mime_type ( $_FILES [ 'avatarfile' ][ 'tmp_name' ]); $file_type = $_FILES [ 'avatarfile' ][ 'type' ]; $file_size = $_FILES [ 'avatarfile' ][ 'size' ]; $fmsg = $lang [ 'avatarisnopicture' ]; $size = @ getimagesize ( $file_tmpe ); $endar = array (1 => 'gif' , 2 => 'jpg' , 3 => 'png' ); if (( $size [2] == 1 OR $size [2] == 2 OR $size [2] == 3) AND $size [0] > 10 AND $size [1] > 10 AND substr ( $file_type , 0 , 6) == 'image/' AND substr ( $rile_type , 0 , 6) == 'image/' ) { $endung = $endar [ $size [2]]; $breite = $size [0]; $hoehe = $size [1]; $neuer_name = 'include/images/profile/' . $cid . '.' . $endung ; @unlink (db_result(db_query( "SELECT bild FROM profile WHERE id = " . $cid ), 0)); move_uploaded_file ( $file_tmpe , $neuer_name ); @ chmod ( $neuer_name , 0777); $avatar_sql_update = ', bild = "' . $neuer_name . '"' ; $fmsg = $lang [ 'pictureuploaded' ]; } } elseif (isset( $_POST [ 'avatardel' ])) { $fmsg = $lang [ 'picturedelete' ]; @unlink (db_result(db_query( "SELECT bild FROM profile WHERE id = " . $cid ), 0)); $avatar_sql_update = ', bild = ""' ; } // avatar speichern ENDE $name = escape( $_POST [ 'name' ], 'string' ); $spitzname = escape( $_POST [ 'spitzname' ], 'string' ); $alter = escape( $_POST [ 'alter' ], 'string' ); $bday = escape( $_POST [ 'bday' ], 'string' ); $sex = escape( $_POST [ 'sex' ], 'string' ); $height = escape( $_POST [ 'height' ], 'string' ); $weight = escape( $_POST [ 'weight' ], 'string' ); $wesen = escape( $_POST [ 'wesen' ], 'string' ); $herkunft = escape( $_POST [ 'herkunft' ], 'string' ); $beruf = escape( $_POST [ 'beruf' ], 'string' ); $waffe = escape( $_POST [ 'waffe' ], 'string' ); $magie = escape( $_POST [ 'magie' ], 'string' ); $aussehen = escape( $_POST [ 'aussehen' ], 'string' ); $merkmale = escape( $_POST [ 'merkmale' ], 'string' ); $besonderheiten = escape( $_POST [ 'besonderheiten' ], 'string' ); $vorgeschichte = escape( $_POST [ 'vorgeschichte' ], 'string' ); $bild_comment = escape( $_POST [ 'bild_comment' ], 'string' ); db_query('UPDATE profile SET name = "' . $name . '" , spitzname = "' . $spitzname . '" , `alter` = "' . $alter . '" , bday = "' . $bday . '" , sex = "' . $sex . '" , height = "' . $height . '" , weight = "' . $weight . '" , wesen = "' . $wesen . '" , herkunft = "' . $herkunft . '" , beruf = "' . $beruf . '" , waffe = "' . $waffe . '" , magie = "' . $magie . '" , aussehen = "' . $aussehen . '" , merkmale = "' . $merkmale . '" , vorgeschichte = "' . $vorgeschichte . '" , bild_comment = "' . $bild_comment . '" ' . $avatar_sql_update . ' WHERE id = "' . $cid . '" '); } wd( 'admin.php?char-1-' . $cid , 'Das Profil wurde erfolgreich geaendert' , 2); $design ->footer(); break ; } ?> |
Meine char.htm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <table cellpadding="3" cellspacing="1" border="0" class="border"> <tr> <td class="Cmite" colspan="3"><b>Charaktere:</b></td> </tr> <tr class="Chead"> <th>Name</th> <th>Spitzname</th> <th>Edit</th> </tr> {EXPLODE} <tr class="{class}"> <td><strong>{name}</strong></td> <td>{spitzname}</td> <td> <a href="admin.php?char-1-{id}"><img src="include/images/icons/edit.gif" border="0" title="ändern" alt="ändern" /></a> </td> <td class="border"></td> </tr> {EXPLODE} </table> |
und meine detail.htm
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 | <form action="admin.php?char-2" method="POST" enctype="multipart/form-data"> <input type="hidden" name="cID" value="{id}"> {antispam} <table border="0" cellspacing="1" cellpadding="3" class="border"> <tr class="Chead"><td colspan="2"><b>Details von {name} - ID: {id}</b></td></tr> <tr> <td class="Cmite">Name</td> <td class="Cnorm"><input name='name' maxlength="100" value='{name}'></td> </tr> <tr> <td class="Cmite">Spitzname</td> <td class="Cnorm"><input name='spitzname' maxlength="100" value='{spitzname}'></td> </tr> <tr> <td class="Cmite">Alter</td> <td class="Cnorm"><input name="alter" value="{alter}" /></td> </tr> <tr> <td class="Cmite">Geburtstag</td> <td class="Cnorm"><input name="bday" value="{bday}" /></td> </tr> <tr> <td class="Cmite">Geschlecht</td> <td class="Cnorm"><input type="radio" value="1" name="sex" {sex2} /> männlich, <input type="radio" value="2" name="sex" {sex1} /> weiblich</td> </tr> <tr> <td class="Cmite">Größe</td> <td class="Cnorm"><input name="height" value="{height}" /></td> </tr> <tr> <td class="Cmite">Gewicht</td> <td class="Cnorm"><input name="weight" value="{weight}" /></td> </tr> <tr> <td class="Cmite">Wesen</td> <td class="Cnorm"><input name="wesen" value="{wesen}" /></td> </tr> <tr> <td class="Cmite">Herkunft</td> <td class="Cnorm"><input name="herkunft" value="{herkunft}" /></td> </tr> <tr> <td class="Cmite">Beruf</td> <td class="Cnorm"><input name="beruf" value="{beruf}" /></td> </tr> <tr> <td class="Cmite">Waffe</td> <td class="Cnorm"><input name="waffe" value="{waffe}" /></td> </tr> <tr> <td class="Cmite">Magie</td> <td class="Cnorm"><input name="magie" value="{magie}" /></td> </tr> <tr> <td class="Cmite">Aussehen</td> <td class="Cnorm"><textarea cols="60" rows="2" name="aussehen">{aussehen}</textarea></td> </tr> <tr> <td class="Cmite">Merkmale</td> <td class="Cnorm"><textarea cols="60" rows="2" name="merkmale">{merkmale}</textarea></td> </tr> <tr> <td class="Cmite">Besonderheiten</td> <td class="Cnorm"><textarea cols="60" rows="2" name="besonderheiten">{besonderheiten}</textarea></td> </tr> <tr> <td class="Cmite">Vorgeschichte</td> <td class="Cnorm"><textarea cols="60" rows="2" name="vorgeschichte">{vorgeschichte}</textarea></td> </tr><tr> <tr> <td class="Cmite">Avatar</td> <td class="Cnorm"><input type="checkbox" name="avatardel" value="1">Löschen ?<br /> {bild}<input type="file" name="avatarfile" /></td> </tr> <tr> <td class="Cmite">Bild Kommentar</td> <td class="Cnorm"><input name="bild_comment" value="{bild_comment}" /></td> </tr> <tr> <td class="Cdark"></td> <td class="Cdark"> <input type="submit" value="Ändern" name="submit"> <input type="button" value="zurück" onclick="javscript:history.back();" /> </td> </tr> </table> </form> |
Schonmal Danke für die Hilfe
Liebe Grüße
Red~
verwendete ilchClan Version: 1.1 N
Edit: hat sich erledigt.. Ich kann dei ID ja über die Session abfragen, nciht dran gedacht. Läuft nun alles

Zuletzt modifiziert von RedSunset am 25.01.2010 - 15:00:07