Gaber Опубликовано 22 Мая 2005 Жалоба Поделиться Опубликовано 22 Мая 2005 У меня вотнедавно появилась идейка вставить в магазин RPG Inferno виртуального продовца, но че-то у меня не клеется, сказывается то что в РНР я ничего не соображаю, ну подчти ичего.Может мне поможет кто-нибудь понимающий в этом деле. В админке продовец прописывается (записывается в БД, аватарчик его виден) там вроде как все нормально, но в магазинах(рынке) когда я нажимаю на созданый мною магаз, то картинка продовца в нужном месте не меняется. Че делать не знаю.Вот измененные мною файлы: rpg.phpНаходим function BuyItems() и меняем ее всю наfunction BuyItems(){ global $DB, $ibforums,$std; // are we offline? v2 // $DB->query("SELECT * FROM ibf_rpgoptions where id='1'"); $options=$DB->fetch_row(); if($options['itemshopon']=="Offline"){ $std->Error( array( 'LEVEL' => 1, 'MSG' => 'section_offline' ) ); } // Member Money $DB->query("SELECT * FROM ibf_members where id='".$ibforums->member['id']."'"); $Member=$DB->fetch_row(); // our inventory, yay! $this->output .= $this->html->InvenTop(); $DB->query("SELECT i.*,s.* FROM ibf_infernostock s LEFT JOIN ibf_infernoshop i ON (s.item=i.id) where s.owner='{$ibforums->member['id']}'"); while($Item=$DB->fetch_row()){ $Sell=floor($Item['cost']/3); $this->output .= $this->html->InvenRow($Item,$Sell); } $DB->query("SELECT * FROM ibf_members where id='".$ibforums->member['id']."'"); $Member=$DB->fetch_row(); if($Member['heal1']==""){}else{ $DB->query("SELECT * FROM ibf_infernocat where cid='{$Member['heal1']}'"); $Prod=$DB->fetch_row(); $Sell=floor($Prod['cost']/3); $this->output .= $this->html->InvenBottom($Member,$Prod,$Sell); } // lets display some cats - Lets upgrade some data presentation - [V3] $this->output .= $this->html->CatTop(); // select all categories $DB->query("SELECT * FROM ibf_infernocat"); while($thecat=$DB->fetch_row()){ $AllCats[$thecat[cid]]=$thecat; } // Select all items $DB->query("select i.*,m.money from ibf_infernoshop i, ibf_members m where m.id='{$ibforums->member['id']}' order by `cost`"); while($theitem=$DB->fetch_row()){ $AllItems[]=$theitem; } if($ibforums->input['shop']){ if($ibforums->input['shop']=="expandall"){ } else { $id=$ibforums->input['shop']; $shop = $AllCats[$id]; // Grab Items And Data $this->output .= $this->html->ShopTop($shop); if(is_array($AllItems)){ foreach($AllItems as $Data){ if($Data['type']==$id){ if($Member['money'] >= $Data['cost']){ $Data['BuyLink'].="<a href='?act=rpg&code=buyitem&id={$Data['id']}' style='color:green'>{$ibforums->lang['buy']}</a>"; } else if($Member['money'] < $Data['cost']){ $Data['BuyLink'].="<a href='?act=rpg&code=buyitem&id={$Data['id']}' title='Не достаточно {$ibforums->lang['money']}' style='color:red'>{$ibforums->lang['buy']}</a>"; } else {} $this->output .= $this->html->Row($Data); }}} $this->output .= $this->html->ShopBottom($Member); }} if(is_array($AllCats)){ foreach($AllCats as $TheCat){ if($TheCat['cname']==""){}else{ $TheCat['total_items']=0; $TheCat['total_sold']=0; $TheCat['total_profit']=0; if(is_array($AllItems)){ foreach($AllItems as $ItemsA){ if($ItemsA['type']==$TheCat['cid']){ $TheCat['total_items']++; $TheCat['total_sold']+=$ItemsA['sold']; $TheCat['total_profit']+=($ItemsA['cost']*$ItemsA['sold']); }}} $this->output .= $this->html->CatRow($TheCat); }}} $this->output .= $this->html->CatBottom(); $this->output .= $this->html->Copyright(); $this->page_title = "Магазин"; $this->nav = array( "Itemshop", ); } skin_rpg.php я там много че менял точно не помню, но продовцов я втыкнул в InvenBottom//=========================================================================== // InvenBottom //=========================================================================== function InvenBottom($Member="",$Data="",$Sell="") { global $ibforums; $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<<EOF <tr> <td colspan='6' class='row1'>Всего {$ibforums->lang['money']}: {$Member['money']}</td> </tr> </table> </div> <br> <div class='formsubtitle'> <table cellpadding='0' cellspacing='0' border='3'> <tr><td width='100'><div class='formsubtitle' style='font-weight:normal;font-size:140%;font-style:italic'><img src='html/Inferno/prod/{$Data['img']}' alt='{$Data['name']}'>"Welcome to my shop, how may I help you?"</div></td></tr> </table> </div><br> <table> <tr> EOF; //--endhtml--// return $IPBHTML; } И конечно же админка<?php $idx = new ad_scat(); class ad_scat { function ad_scat() { global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $ibforums->admin->page_title = "Manage Itemshop Catagories"; $ibforums->admin->page_detail = ""; switch($ibforums->input['code']){ case 'editscat': $this->edit_scats(); break; case 'deletescat': $this->delete_scat(); break; case 'dodelete': $this->do_delete(); break; case 'doedit': $this->do_edit(); break; case 'addscat': $this->add_scat(); break; case 'doadd': $this->do_add(); break; default: $this->view_scats(); break; } $ibforums->admin->output(); } function view_scats(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $ibforums->adskin->td_header[] = array( "ID" , "1%" ); $ibforums->adskin->td_header[] = array( "Продовец" , "10%" ); $ibforums->adskin->td_header[] = array( "Name" , "19%" ); $ibforums->adskin->td_header[] = array( "Description" , "30%" ); $ibforums->adskin->td_header[] = array( "Edit" , "15%" ); $ibforums->adskin->td_header[] = array( "Delete" , "15%" ); // ---------------- $ibforums->vars['html_url'] = "html"; $ibforums->html .= $ibforums->adskin->start_table( "Manage Catagories For Itemshop" ); $DB->query("SELECT * FROM ibf_infernocat"); while ($Data = $DB->fetch_row() ) { $ibforums->html .= $ibforums->adskin->add_td_row( array( "<center><b>{$Data['cid']}</b></center>", "<center><img src='{$ibforums->vars['html_url']}/Inferno/prod/{$Data['img']}'></center>", "<center>{$Data['cname']}</center>", "<center>{$Data['desc']}</center>", "<center><a href='{$ibforums->admin->base_url}&act=scat&code=editscat&cid={$Data['cid']}'>Edit</a></center>", "<center><a href='{$ibforums->admin->base_url}&act=scat&code=deletescat&cid={$Data['cid']}'>Delete</a></center>", ) ); } $ibforums->html .= $ibforums->adskin->add_td_basic("<a href='{$ibforums->admin->base_url}&act=scat&code=addscat'>Add New Itemshop Catagory</a></center>", "center", "tdrow1"); $ibforums->html .= $ibforums->adskin->end_table(); } function edit_scats(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code' , 'doedit' ), 2 => array( 'act' , 'scat' ), 3 => array( 'cid' , $ibforums->input['cid'] ), ) ); $DB->query("SELECT * FROM ibf_infernocat WHERE cid='".$ibforums->input['cid']."'"); if ( ! $Data = $DB->fetch_row() ){ $ibforums->admin->error("Unable to find the catagory inside the db"); } //+------------------------------- $ibforums->adskin->td_header[] = array( " " , "40%" ); $ibforums->adskin->td_header[] = array( " " , "60%" ); //+------------------------------- $ibforums->vars['html_url'] = "html"; $ibforums->vars['html_dir'] = "html"; $ibforums->html .= $ibforums->adskin->start_table( "Edit Catagory" ); //Grab Items $handle = opendir($ibforums->vars['html_dir'] . "/Inferno/prod/"); $icons[] = array('blank.gif', 'Select A Item Image'); while ($icon = readdir($handle)) { if(preg_match("/(.jpg|.gif|.png|.bmp)/",$icon)) { if($icon != '.' || $icon != '..') { $icons[] = array($icon, $icon); }}} $ibforums->html .= "<script> function show_icon() { document.images['showitem'].src = '{$ibforums->vars['html_url']}/Inferno/prod/' + document.theAdminForm.img.value } </script>"; $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Продовцы</b>" , $ibforums->adskin->form_dropdown('img', $icons,"","onChange='show_icon()'") . " <img src='{$ibforums->vars['html_url']}/Inferno/prod/blank.gif' name='showitem' border='0'> <script> x=document.theAdminForm.img.options for(u=0;u<x.length;u++){ if(x[u].value=='{$Data['img']}'){ x[u].selected=true; document.images['showitem'].src = '{$ibforums->vars['html_url']}/Inferno/prod/' + document.theAdminForm.img.value }} </script> ", ) ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Name</b>" , $ibforums->adskin->form_input("name", $Data['cname'] ) ) ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Description</b>" , $ibforums->adskin->form_input("desc", $Data['desc'] ) ) ); $ibforums->html .= $ibforums->adskin->end_form('Update Catagory'); $ibforums->html .= $ibforums->adskin->end_table(); } function do_edit(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $DB->query("UPDATE `ibf_infernocat` SET img='{$ibforums->input['img']}' WHERE cid='{$ibforums->input['cid']}'"); $DB->query("UPDATE `ibf_infernocat` SET cname='{$ibforums->input['name']}' WHERE cid='{$ibforums->input['cid']}'"); $DB->query("UPDATE `ibf_infernocat` SET `desc`='{$ibforums->input['desc']}' WHERE cid='{$ibforums->input['cid']}'"); $DB->query("OPTIMIZE TABLE ibf_infernocat"); $ibforums->admin->done_screen("Itemshop Catagory Updated", "Catagory Management", "act=scat" ); } function delete_scat(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $ibforums->adskin->td_header[] = array( " " , "40%" ); $ibforums->adskin->td_header[] = array( " " , "60%" ); // ------------- $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code' , 'dodelete' ), 2 => array( 'act' , 'scat' ), 3 => array( 'cid' , $ibforums->input['cid'] ), ) ); $DB->query("SELECT * FROM ibf_infernocat WHERE cid='".$ibforums->input['cid']."'"); if ( ! $mGrab = $DB->fetch_row() ){ $ibforums->admin->error("Unable to find the catagory inside the db"); } $ibforums->html .= $ibforums->adskin->start_table( "Removal Confirmation" ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Catagory to Remove</b>" , "<b>{$mGrab['cname']}</b>", ) ); $ibforums->html .= $ibforums->adskin->end_form("Remove This Catagory"); $ibforums->html .= $ibforums->adskin->end_table(); } function do_delete(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $DB->query("DELETE FROM ibf_infernocat WHERE cid='".$ibforums->input['cid']."'"); $DB->query("OPTIMIZE TABLE ibf_infernocat"); $ibforums->admin->done_screen("Itemshop Catagory Removed", "Catagory Management", "act=scat" ); } function add_scat(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code' , 'doadd' ), 2 => array( 'act' , 'scat' ), 3 => array( 'cid' , $ibforums->input['cid'] ), ) ); //+------------------------------- $ibforums->adskin->td_header[] = array( " " , "40%" ); $ibforums->adskin->td_header[] = array( " " , "60%" ); //+------------------------------- $ibforums->html .= $ibforums->adskin->start_table( "Add Catagory" ); //Grab Items $ibforums->vars['html_url'] = "html"; $ibforums->vars['html_dir'] = "html"; $handle = opendir($ibforums->vars['html_dir'] . "/Inferno/prod/"); $icons[] = array('blank.gif', 'Select A Item Image'); while ($icon = readdir($handle)) { if(preg_match("/(.jpg|.gif|.png|.bmp)/",$icon)) { if($icon != '.' || $icon != '..') { $icons[] = array($icon, $icon); }}} $ibforums->html .= "<script> function show_icon() { document.images['showitem'].src = '{$ibforums->vars['html_url']}/Inferno/prod/' + document.theAdminForm.img.value } </script>"; $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Продовцы</b>" , $ibforums->adskin->form_dropdown('img', $icons,"","onChange='show_icon()'") . " <img src='{$ibforums->vars['html_url']}/Inferno/prod/blank.gif' name='showitem' border='0'>", ) ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Catagory Name</b>" , $ibforums->adskin->form_input("cname", "" ) ) ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "<b>Catagory Description</b>" , $ibforums->adskin->form_input("desc", "" ) ) ); $ibforums->html .= $ibforums->adskin->end_form('Add Catagory'); $ibforums->html .= $ibforums->adskin->end_table(); } function do_add(){ global $ibforums, $DB, $std, $forums, $HTTP_POST_VARS; $DB->query("INSERT INTO `ibf_infernocat` VALUES ('','{$ibforums->input['img']}','{$ibforums->input['cname']}','{$ibforums->input['desc']}') "); $DB->query("OPTIMIZE TABLE ibf_infernocat"); $ibforums->admin->done_screen("Itemshop Catagory Added", "Catagory Management", "act=scat" ); } // Class end } ?> Да и чуть не забыл про БДтаблица ibf_infernocat Я добавил поле imgCREATE TABLE `ibf_infernocat` ( `cid` int(11) NOT NULL auto_increment, `img` text NOT NULL, `cname` text NOT NULL, `desc` text NOT NULL, PRIMARY KEY (`cid`) ) TYPE=MyISAM AUTO_INCREMENT=9; INSERT INTO `ibf_infernocat` VALUES (1, '01.gif', 'Броня (Фэн)', 'Поупайте и надевайте на себя'); INSERT INTO `ibf_infernocat` VALUES (2, '02.gif', 'Предметы', 'улучшают харатеристии героя'); INSERT INTO `ibf_infernocat` VALUES (3, '15.gif', 'Оружие', 'Чемто вам надо же воевать'); INSERT INTO `ibf_infernocat` VALUES (8, '14.gif', 'ffdsf', 'dfsf'); Если кто знает где ошибка подскажите... Цитата Ссылка на комментарий Поделиться на других сайтах Прочее
Рекомендуемые сообщения
Присоединиться к обсуждению
Вы можете ответить сейчас, а зарегистрироваться позже. Если у вас уже есть аккаунт, войдите, чтобы ответить от своего имени.