Quellcode der Dragonslayer-Edition
Quellcode der Dragonslayer-Edition : 0.9.7(Dragonslayer Edition V/3)


Anmerkung: Dies ist nur ein Auszug aus dem Source. Ein etwas älteres, abgespecktes Release ist für jeden Interessenten frei zum Download verfügbar. Allerdings würden wir uns über eine Anfrage freuen, in der die Serveradresse bzw. sonstiger Verwendungszweck aufgeführt sind, da wir gern wissen würden wohin unsere Version geht. Was wir uns unbedingt verbitten, ist Diebstahl unserer Arbeit ohne Nennung des Copyrights.
Falls beim Lesen des Source ein Bug entdeckt werden sollte, bitten wir um sofortige Meldung per Anfrage!


./invhandler.php

zurück
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:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
<?php
/**
 * invhandler.php: neuer Itemhandler für Drachenserver-Itemsystem
 * @author talion <t [-[at]-] ssilo.de>
 * @version DS-E V/2
*/

require_once('common.php');
require_once(
LIB_PATH.'house.lib.php');

$id = (int)$_REQUEST['id'];
$ret $_REQUEST['ret'];

$base_link 'invhandler.php?ret='.urlencode($ret).'&id='.$id;

if ( isset(
$id) ){
    
$item item_get('id='.$id);
}
else {
    
$item = array();

    if(!isset(
$_POST['ids'])) {
        
redirect($ret);
    }
}

page_header('Inventar');

$str_op $_REQUEST['op'];

switch(
$str_op) {

    
// Inventar, Benutzen
    
case 'use':

        
$item_hook_info['link'] = $base_link;
        
$item_hook_info['ret'] = $ret;

        
item_load_hook($item['use_hook'],'use',$item);

        break;

    
// Wegwerfen
    
case 'wegw':

        
// Multiselect
        
if(!empty($_POST['ids']) && is_array($_POST['ids'])) {
            
$str_ids implode(',',$_POST['ids']);
            
$res_items item_list_get(' id IN ('.addslashes(stripslashes($str_ids)).') AND owner='.$session['user']['acctid'].' AND deposit1 !='.ITEM_LOC_EQUIPPED.' AND it.throw > 0 ','',true,'name,id');

            if(
db_num_rows($res_items) == 0) {
                
redirect($ret);
            }

        }

        if(
$_GET['act'] != 'ok') {
            
$str_lnk $base_link.'&op=wegw&act=ok';

            if(isset(
$res_items)) {
                
output('`QBist du dir sicher, die folgenden Gegenstände unwiederbringlich aufgeben zu wollen?`n`n');
                
$str_lnk .= '&ids='.$str_ids;
                while (
$item db_fetch_assoc($res_items)) {
                    
output('`q'.$item['name'].'`q`n');
                }
            }
            else {
                if(empty(
$item)) {
                    
redirect($ret);
                }
                
output('`QBist du dir sicher, '.$item['name'].'`Q unwiederbringlich aufgeben zu wollen?');
            }

            
addnav('Nein, zurück!',$ret);

            
addnav('Ja, weg damit!',$str_lnk);
        }
        else {

            
// Mehrere Items?
            
if(isset($_GET['ids'])) {
                
item_delete('id IN ('.addslashes(stripslashes($_GET['ids'])).') AND owner='.$session['user']['acctid'].' AND deposit1 !='.ITEM_LOC_EQUIPPED);
                
output('`QDu schleppst all die Gegenstände in eine dunkle Seitengasse und lässt sie dort vergammeln.');
            }
            else {
                
output('`QDu schleppst '.$item['name'].'`Q in eine dunkle Seitengasse und lässt es dort liegen. Da wird sich schon jemand drum kümmern...');
                
item_delete('id='.$id);
            }

            
addnav('Zum Inventar',$ret);

        }

        break;

    
// Einlagern in Haus o. Gemach
    
case 'einl':

        
// Multiselect
        
if(!empty($_POST['ids']) && is_array($_POST['ids'])) {
            
$str_ids implode(',',$_POST['ids']);
        }

        if(
$_GET['act'] == 'house') {

            
$sql 'SELECT k.*,h.status,h.houseid,h.owner,h.housename FROM keylist k LEFT JOIN houses h ON h.houseid=k.value1 WHERE k.owner='.$session['user']['acctid'].'  AND type='.HOUSES_KEY_DEFAULT.' ORDER BY id ASC';
            
$res db_query($sql);

            while(
$k db_fetch_assoc($res)) {
                
$link $base_link.'&op=einl&act=ok&housenr='.$k['houseid'].'&ids='.urlencode($_GET['ids']);
                
output('<a href="'.$link.'">'.$k['housename'].'</a>`n',true);
                
addnav('',$link);

            }
            
addnav('Zurück',$base_link.'&op=einl&ids='.urlencode($_GET['ids']));

        }
        elseif(
$_GET['act'] == 'private') {

            
output('`QDu besitzt Schlüssel zu Privatgemächern in diesen Häusern:`n`n');

            
$sql 'SELECT he.*,h.status,h.houseid,h.owner,h.housename FROM house_extensions he
                    LEFT JOIN houses h USING(houseid)
                    WHERE he.owner='
.$session['user']['acctid'].' AND loc IS NOT NULL AND level > 0
                    ORDER BY id ASC'
;
            
$res db_query($sql);

            while(
$k db_fetch_assoc($res)) {
                
$k['name'] = '`&'.(empty($k['name']) ? $g_arr_house_extensions[$k['type']]['name'] : $k['name'].'`& ('.$g_arr_house_extensions[$k['type']]['name'].')');
                
$k['name'] .= '`0`& - '.house_get_floor($k['loc']).' in '.$k['housename'].'`0';
                
$link $base_link.'&op=einl&act=ok&housenr='.$k['houseid'].'&private='.$k['id'].'&ids='.urlencode($_GET['ids']);
                
output('`0<a href="'.$link.'">'.$k['name'].'</a>`n',true);
                
addnav('',$link);

            }
            
addnav('Zurück',$base_link.'&op=einl&ids='.urlencode($_GET['ids']));

        }
        elseif(
$_GET['act'] == 'ok') {

            
$housenr = (int)$_GET['housenr'];
            
$private = (int)$_GET['private'];

            if(!empty(
$_GET['ids'])) {
                
$res item_list_get(' owner='.$session['user']['acctid'].' AND id IN ('.addslashes(stripslashes(urldecode($_GET['ids']))).') AND deposit1=0 AND deposit2=0');
                
$arr_items db_create_list($res);

            }
            else {
                
$arr_items = array($item);
            }

            if(!
is_array($arr_items) || sizeof($arr_items) == 0) {
                
redirect($ret);
            }

            
$sql 'SELECT status FROM houses WHERE houseid='.$housenr;
            
$res db_query($sql);
            
$house db_fetch_assoc($res);

            if(
$private) {
                
$sql 'SELECT type FROM house_extensions WHERE id='.$private;
                
$res db_query($sql);
                
$room db_fetch_assoc($res);

                
// Wenn durch den Gemachtyp Vorgaben gemacht werden:
                
if(isset($g_arr_house_extensions[$room['type']]['max_furn'])) {
                    
$max_count_ges $g_arr_house_extensions[$room['type']]['max_furn'];
                }
                
// Sonst allg. Limit
                
else {
                    
$max_count_ges get_max_furniture($house['status'],true);
                }

            }
            else {
                
$max_count_ges get_max_furniture($house['status']);
            }
            
            if(
$max_count_ges == 0)
            {
                
output('`QHier ist kein Platz für Möbel!');
            }
            else 
            {
                
$count_ges item_count(' deposit1 = '.$housenr.' AND deposit2 = '.$private);
                        
                foreach (
$arr_items as $item) {
                                                    
                    if(
$count_ges >= $max_count_ges) {
                        
output('`n`QDu hast hier bereits `q'.$count_ges.'`Q Möbel deponiert. Mehr passt einfach nicht rein!');
                        break;
                    }
                                    
                    
// Check auf Gesamtzahl dieses Stücks
                    
$max_count $item['deposit'.($private '_private' '')];
                    
$count item_count' deposit1 = '.$housenr.' AND deposit2 = '.$private.' AND tpl_id="'.$item['tpl_id'].'"' );
                    
output('`n');
                    if(
$max_count == 0) {
                        
output('`QMal ehrlich, du willst '.$item['name'].'`Q doch nicht wirklich einlagern?! Nicht mal ein Erztroll würde sowas tun...');
                    }
                    elseif(
$count >= $max_count) {
                        
output('`QDu kannst von diesem edlen Stück maximal '.$max_count.' Exemplare eingelagert haben. Mehr hätte einfach keinen Stil...');
                    }
                    else {
                        
output("`QDu suchst für `q$item[name]`Q einen Ehrenplatz in deinem Haus, an dem `q$item[name]`Q von jetzt an den Staub fangen wird.");
    
                        
item_set(' id='.$item['id'] , array('deposit1'=>$housenr,'deposit2'=>$private) );
                        
$count_ges++;
                    }
                }                
            }
                        
        }
        else {

            
output('`QWohin willst du `q'.(isset($str_ids) ? 'die Gegenstände' $item['name']).'`Q bringen?');

            if(
$session['user']['house']) {addnav('Ins Haus',$base_link.'&op=einl&act=ok&housenr='.$session['user']['house'].'&ids='.urlencode($str_ids));}
            if(
db_num_rows(db_query("SELECT he.id FROM house_extensions he WHERE he.loc IS NOT NULL AND he.owner=".$session['user']['acctid']." LIMIT 1")) > 0) {
                
addnav('In Privatgemächer',$base_link.'&op=einl&act=private&ids='.urlencode($str_ids));
            }

        }

        
addnav('Zum Inventar',$ret);

        break;

    
// Auslagern aus Haus o. Gemach
    
case 'ausl':

        
// Multiselect
        
if(!empty($_POST['ids']) && is_array($_POST['ids'])) {
            
$str_ids implode(',',$_POST['ids']);
            
output('`QDu packst die Gegenstände wieder in dein Inventar.');

            
item_set('id IN ('.$str_ids.') AND owner='.$session['user']['acctid'].' AND deposit1 !='.ITEM_LOC_EQUIPPED,array('deposit1'=>0,'deposit2'=>0) );
        }
        else {
            
output('`QDu packst '.$item['name'].'`Q wieder in dein Inventar.');

            
item_set('id='.$id,array('deposit1'=>0,'deposit2'=>0) );
        }

        
addnav('Zum Inventar',$ret);

        break;

    
// Waffe, Rüstung o.ä. anlegen
    
case 'ausr':

        
// Hook
        
$item_hook_info['op'] = 'ausr';
        if(!empty(
$item['equip_hook'])) {
            
item_load_hook($item['equip_hook'],'equip',$item);
        }

        if(!
$item_hook_info['hookstop']) {

            if(
$item['equip'] == ITEM_EQUIP_WEAPON) {

                
$w_old item_set_weapon($item['name'],$item['value1'],$item['gold'],$id);

                
$old_name $w_old['name'];

                
$old_attack $session['user']['attack'] - $session['user']['weapondmg'] + $w_old['value1'];

                
output('`QDu tauschst `q'.$old_name.'`Q gegen '.$item['name'].'`Q.
                        Dein Angriff verändert sich dadurch von '
.$old_attack.' auf '.$session['user']['attack'].'!');

            }

            else if(
$item['equip'] == ITEM_EQUIP_ARMOR) {

                
$a_old item_set_armor($item['name'],$item['value1'],$item['gold'],$id);

                
$old_name $a_old['name'];

                
$old_defence $session['user']['defence'] - $session['user']['armordef'] + $a_old['value1'];

                
output('`QDu tauschst `q'.$old_name.'`Q gegen '.$item['name'].'`Q.
                        Deine Verteidigung verändert sich dadurch von '
.$old_defence.' auf '.$session['user']['defence'].'!');

            }
        }

        
addnav('Zum Inventar',$ret);

        break;

    
// Angelegtes Item ablegen und in Invent zurückpacken
    
case 'abl':

        if(
$_GET['what'] != '') {
            
$item_hook_info['what'] = $_GET['what'];
        }
        else {
            if(
$item['equip'] == ITEM_EQUIP_WEAPON) {
                
$item_hook_info['what'] = 'weapon';
            }
            else if(
$item['equip'] == ITEM_EQUIP_ARMOR) {
                
$item_hook_info['what'] = 'armor';
            }
        }

        
// Hook
        
$item_hook_info['op'] = 'abl';
        if(!empty(
$item['equip_hook'])) {
            
item_load_hook($item['equip_hook'],'equip',$item);
        }

        if(!
$item_hook_info['hookstop']) {

            if(
$item_hook_info['what'] == 'weapon') {

                
$old $session['user']['attack'];

                
// ohne Params, um Fäuste zu setzen
                
$w_old item_set_weapon();

                
$old_name $w_old['name'];

                
output('`QDu legst `q'.$old_name.'`Q ab.
                        Dein Angriff verändert sich dadurch von '
.$old.' auf '.$session['user']['attack'].'!');

            }

            else if(
$item_hook_info['what'] == 'armor') {

                
$old $session['user']['defence'];

                
// ohne Params, um Straßenkleidung zu setzen
                
$a_old item_set_armor();

                
$old_name $a_old['name'];

                
output('`QDu legst `q'.$old_name.'`Q ab.
                        Deine Verteidigung verändert sich dadurch von '
.$old.' auf '.$session['user']['defence'].'!');

            }
        }

        
addnav('Zum Inventar',$ret);

        break;


}

page_footer();
?>
0.9.7(Dragonslayer Edition V/3)