RE: Item-Shop - StefanT - 19.03.2008
Ersetze '".TABLE_PREFIX."users' durch ".TABLE_PREFIX."users
RE: Item-Shop - SHViperia - 19.03.2008
Klappt leider nicht.
Kommt genau die selbe Fehlermeldung
MySQL error: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''shop3' 'shop3' VARCHAR( 120 ) NOT NULL' at line 1
Query: ALTER TABLE mybb_users CHANGE 'shop3' 'shop3' VARCHAR( 120 ) NOT NULL
RE: Item-Shop - StefanT - 20.03.2008
Nein, das Fehler ist jetzt ein anderer.
Ersetze:PHP-Code: $db->query(" ALTER TABLE '".TABLE_PREFIX."users' CHANGE '".$db->escape_string($mybb->input['old_shop'])."' '".$db->escape_string($mybb->input['shop'])."' VARCHAR( 120 ) NOT NULL");
durch:PHP-Code: $db->query(" ALTER TABLE ".TABLE_PREFIX."users CHANGE ".$db->escape_string($mybb->input['old_shop'])." ".$db->escape_string($mybb->input['shop'])." VARCHAR( 120 ) NOT NULL");
RE: Item-Shop - SHViperia - 21.03.2008
Jawoll ja! Und wiedermal klappts! ...Man sollte halt PHP dateien nicht mit nem Texteditor bearbeiten *g*
Danke vielmals! TOP!
RE: Item-Shop - SHViperia - 22.03.2008
Jetzt wollte ich bei einer IF Abfrage mehrere Bedingungen einbauen.
Kommt nun folgende Fehlermeldung:
Parse error: syntax error, unexpected '}' in /home/www/doc/16415/myonlinegame.de/www/GdO/inc/class_shop.php on line 121
PHP-Code: //check if user has enough money and gems if( $money >= intval($itemarray['price']) AND $rubin >= intval($itemarray['rubin']) AND $smaragd >= intval($itemarray['smaragd']) AND $saphir >= intval($itemarray['saphir']) ) { // User has enough, now check if they already own it. if($this->mybb->user[''.$shop.''] == $itemarray['name']) { error($this->lang->you_already_own); } else // User doesn't have this item, so make sure they're in the right shop. if($itemarray['shop'] != $shoparray['shop']) { error($this->lang->wrong_shop); } else // All check passed! Give them the item. =) }
RE: Item-Shop - StefanT - 22.03.2008
Lösche:PHP-Code: else // All check passed! Give them the item. =)
RE: Item-Shop - SHViperia - 22.03.2008
Jetzt kommt dafür diese Meldung:
Parse error: syntax error, unexpected T_ELSE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/www/doc/16415/myonlinegame.de/www/GdO/inc/class_shop.php on line 173
Hier mal die komplette datei:
PHP-Code: <?php /* * ** Inventory Shop 1.1.0 ** Copyright © Ryan Ashbrook 2006 (http://www.mybb-templates.com/) ** Special Thanks: Crakter, Christian, and Mike. ** ./inc/class_shop.php * */
class Inv_Shop { // Initialize Version Array var $version = array();
// Initialize some MyBB variables var $db = NULL; var $lang = NULL; var $templates = NULL; var $mybb = NULL;
function Inv_Shop() { global $db, $lang, $templates, $mybb; $this->db = &$db; $this->lang = &$lang; $this->templates = &$templates; $this->mybb = &$mybb; return TRUE; }
// Build Version Function function buildversion() { // Do not change any of the following unless you also change the version number in the plugin. // Please Note: Changing the version numbers in Inv Shop 1.1.0 isn't a major problem, but // doing so in the future 1.2 versions may mess up the Version Checking feature in MyBB 1.4. // Major Version Number $major = $this->version['major'] = "1"; // Minor Version Number $minor = $this->version['minor'] = "1"; // Bug Fix Version Number $bugfix = $this->version['bugfix'] = "0"; // Suffix (Alpha, Beta, Gamma, Development etc.) $suffix = $this->version['suffix'] = ""; // If there is no suffix, then print just the major, minor, and bugfix numbers, else print them all. if($suffix == "") { $version = $major . '.' . $minor . '.' . $bugfix; } else { $version = $major . '.' . $minor . '.' . $bugfix . ' ' . $suffix; } // Return the formatted version number. return $version; }
// Start the Copyright Output Function. Do not change!!! function copyright($showvernumsetting) { // Determine if the Show Version Numbers setting is on. $version = ($showvernumsetting == 'on' ? ' ' . $this->buildversion() : ''); $copyyear = date("Y"); // Do the copyright. $copy = '<br /><span class="smalltext">Inventory Shop' . $version . '<br />Copyright © 2006-2008-' . $copyyear . ' <a href="http://www.mybb-templates.com/"><strong>Ryan Ashbrook, Features by SHViperia</strong></a></span><br />'; // The copyright is to remain in English, NO MATTER WHAT!!! // Return the finished copyright. return $copy; } // Let's choose which Points System to use =) function moneysystem() { if($this->mybb->settings['moneysystem'] == 'myps') { $points_table = "myps"; } else { $points_table = "money"; } return $points_table; }
// Start the Buy Item Function function buy_item($iid) { // Fix the money. $money = str_replace($this->mybb->settings['thousandssep'], "", $this->mybb->user[''.$this->moneysystem().'']); // Grab the Items and put them in an array. $itemquery = $this->db->simple_select(TABLE_PREFIX."shop", "*", "iid='".intval($iid)."'"); $itemarray = $this->db->fetch_array($itemquery); // Grab the shops and put them in an array. $shopquery = $this->db->simple_select(TABLE_PREFIX."shops", "*", "shop='".$this->db->escape_string($itemarray['shop'])."'"); $shoparray = $this->db->fetch_array($shopquery);
//check if user has enough money and gems if( $money >= intval($itemarray['price']) AND $rubin >= intval($itemarray['rubin']) AND $smaragd >= intval($itemarray['smaragd']) AND $saphir >= intval($itemarray['saphir']) ) { // User has enough, now check if they already own it. if($this->mybb->user[''.$shop.''] == $itemarray['name']) { error($this->lang->you_already_own); } else // User doesn't have this item, so make sure they're in the right shop. if($itemarray['shop'] != $shoparray['shop']) { error($this->lang->wrong_shop); }
$this->db->query(" UPDATE ".TABLE_PREFIX."users SET ".$this->db->escape_string($itemarray['shop'])."='<img src=\"http://www.myonlinegame.de/GdO/images/".$this->db->escape_string($itemarray['pic']).".gif\"> <font color=\"".$this->db->escape_string($itemarray['color'])."\"> ".$this->db->escape_string($itemarray['name'])." </font> ' , ".$this->moneysystem()."=".$this->moneysystem()."-".intval($itemarray['price'])." WHERE uid='".intval($this->mybb->user['uid'])."' "); //Attribute updaten { $query = $this->db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='".$mybb->user['uid']."'"); $user = $this->db->fetch_array($query); } $this->db->query("UPDATE ".TABLE_PREFIX."users SET siglenght=siglenght+".intval($itemarray['siglenght']).", customtitlemaxlength=customtitlemaxlength+".intval($itemarray['customtitlemaxlength']).", maxsigimages=maxsigimages+".intval($itemarray['maxsigimages']).", maxavatardims=maxavatardims+'".$this->db->escape_string($itemarray['maxavatardims'])."', avatarsize=avatarsize+".intval($itemarray['avatarsize']).", maxattachments=maxattachments+".intval($itemarray['maxattachments']).", money_post=money_post+".intval($itemarray['money_post']).", money_thread=money_thread+".intval($itemarray['money_thread']).", smilieinsertertot=smilieinsertertot+".intval($itemarray['smilieinsertertot']).", saphir=saphir-".intval($itemarray['saphir']).", smaragd=smaragd-".intval($itemarray['smaragd']).", rubin=rubin-".intval($itemarray['rubin']).", ".$this->db->escape_string($shoparray['shop'])."_rubin=".intval($itemarray['rubin']).", ".$this->db->escape_string($shoparray['shop'])."_saphir=".intval($itemarray['saphir']).", ".$this->db->escape_string($shoparray['shop'])."_smaragd=".intval($itemarray['smaragd']).", ".$this->db->escape_string($shoparray['shop'])."_money=".intval($itemarray['price']).", ".$this->db->escape_string($shoparray['shop'])."_iid=".intval($itemarray['iid']).", ".$this->db->escape_string($shoparray['shop'])."_siglenght=".intval($itemarray['siglenght']).", ".$this->db->escape_string($shoparray['shop'])."_avatarsize=".intval($itemarray['avatarsize']).", ".$this->db->escape_string($shoparray['shop'])."_customtitlemaxlength=".intval($itemarray['customtitlemaxlength']).", ".$this->db->escape_string($shoparray['shop'])."_maxsigimages=".intval($itemarray['maxsigimages']).", ".$this->db->escape_string($shoparray['shop'])."_maxavatardims=".intval($itemarray['maxavatardims']).", ".$this->db->escape_string($shoparray['shop'])."_maxattachments=".intval($itemarray['maxattachments']).", ".$this->db->escape_string($shoparray['shop'])."_money_post=".intval($itemarray['money_post']).", ".$this->db->escape_string($shoparray['shop'])."_money_thread=".intval($itemarray['money_thread']).", ".$this->db->escape_string($shoparray['shop'])."_smilieinsertertot=".intval($itemarray['smilieinsertertot'])." WHERE uid='".intval($this->mybb->user['uid'])."' "); // Redirect and thank them for the purchase. redirect("shop.php?do=shop&sid=".$shoparray['sid']."", $this->lang->thanks_purchase); } } else { // Oops, the money check didn't clear, tell them so. error($this->lang->not_enough_money); } }
// Start the Sell Item Function function sell_item($sid) { // Grab the shops and put them in an array. $shopquery = $this->db->simple_select(TABLE_PREFIX."shops", "*", "sid='".intval($sid)."'"); $shoparray = $this->db->fetch_array($shopquery); // User has nothing to sell. if(!$this->mybb->user[$shoparray['shop']]) { error($this->lang->nothing_to_sell); } else { // User has something to sell, so find out what it is. $query = $this->db->simple_select(TABLE_PREFIX."shop", "*", "name='".$this->db->escape_string($this->mybb->user[$shoparray['shop']])."'"); $sell = $this->db->fetch_array($query); // Set them with no item for that shop and refund their money. $this->db->query(" UPDATE ".TABLE_PREFIX."users SET ".$this->db->escape_string($shoparray['shop'])."='', ".$this->moneysystem()."=".$this->moneysystem()."+".intval($sell['price'])." WHERE uid='".intval($this->mybb->user['uid'])."' ");
// Attribute updaten { $query = $this->db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='".$mybb->user['uid']."'"); $user = $this->db->fetch_array($query); $item_query = $this->db->query("SELECT * FROM ".TABLE_PREFIX."shop WHERE iid='".$mybb->user['iid']."'"); $item = $this->db->fetch_array($query); } $this->db->query("UPDATE ".TABLE_PREFIX."users SET
saphir=saphir+".$this->db->escape_string($shoparray['shop'])."_saphir, smaragd=smaragd+".$this->db->escape_string($shoparray['shop'])."_smaragd, rubin=rubin+".$this->db->escape_string($shoparray['shop'])."_rubin, money=money+".$this->db->escape_string($shoparray['shop'])."_money,
siglenght=siglenght-".$this->db->escape_string($shoparray['shop'])."_siglenght, customtitlemaxlength=customtitlemaxlength-".$this->db->escape_string($shoparray['shop'])."_customtitlemaxlength, maxsigimages=maxsigimages-".$this->db->escape_string($shoparray['shop'])."_maxsigimages, maxavatardims=maxavatardims-".$this->db->escape_string($shoparray['shop'])."_maxavatardims, avatarsize=avatarsize-".$this->db->escape_string($shoparray['shop'])."_avatarsize, maxattachments=maxattachments-".$this->db->escape_string($shoparray['shop'])."_maxattachments, money_post=money_post-".$this->db->escape_string($shoparray['shop'])."_money_post, money_thread=money_thread-".$this->db->escape_string($shoparray['shop'])."_money_thread, smilieinsertertot=smilieinsertertot-".$this->db->escape_string($shoparray['shop'])."_smilieinsertertot, ".$this->db->escape_string($shoparray['shop'])."_iid=0 WHERE uid='".intval($this->mybb->user['uid'])."' ");
// Sold! Redirect them back the shop. redirect("shop.php?do=shop&sid=".$shoparray['sid']."", $this->lang->sold); } }
// Start the Show Items Function
function show_items($item_type) {
// $sigl = $mybb->shop['siglenght'] ; if ($sigl <0 ) { $col ="red"; } else { $col ="green"; } // Initialize $item_bits $item_bits = "";
// Let's get the items. $query_options = array( 'order_by' => 'name ASC' ); $query = $this->db->simple_select(TABLE_PREFIX."shop", "*", "shop='".$item_type."'", $query_options); // Start the altbg's at trow1 $altbg = "trow1";
// Start the array. while($item = $this->db->fetch_array($query)) { // Format the prices. $price = my_number_format($item['price']);
// Format the name. $name = str_replace(' ', '_', htmlentities($item['name']));
// Output the items. eval("\$item_bits .= \"".$this->templates->get("shop_itembits")."\";");
// Alternate the row colors. $altbg = ($altbg == "trow1") ? "trow2" : "trow1"; }
// Return the items. return $item_bits; }
// Start the Show Shops Function function show_shops() { // Initialize $shop_bits $shop_bits = ""; // Let's get the shops. $query_options = array( 'order_by' => 'sid ASC' ); $query = $this->db->simple_select(TABLE_PREFIX."shops", "*", "", $query_options); // Start the altbg's at trow1 $altbg = "trow1"; // Start the array. while($shop = $this->db->fetch_array($query)) { // Output the shops. eval("\$shop_bits .= \"".$this->templates->get("shop_shopbits")."\";"); // Alternate the row colors. $altbg = ($altbg == "trow1") ? "trow2" : "trow1"; } // Return the shops. return $shop_bits; }
// Start the Donate Money Function function donate($sourceuser, $destuser, $money, $thread, $post) { // Strip The Commas from the Money. $money2 = str_replace($this->mybb->settings['thousandssep'], "", $money); // Let's load information about both users... $source = $this->db->simple_select(TABLE_PREFIX."users", "*", "uid=".$sourceuser.""); $su = $this->db->fetch_array($source); $dest = $this->db->simple_select(TABLE_PREFIX."users", "*", "uid=".$destuser.""); $du = $this->db->fetch_array($dest); // Now that we have the information about both users, let's do the Money Swap if($su[''.$this->moneysystem().''] < $money2) { // Source User doesn't have enough. error($this->lang->dont_have_that_much); } else if(!$du['uid']) { // Destination User doesn't exist. error($this->lang->user_doesnt_exist); } else if($su['uid'] == $du['uid']) { // Destination User and Source User are the same. error($this->lang->cannot_donate_to_yourself); } else if($su['uid'] != $this->mybb->user['uid']) { // Source User isn't equal to Current User. error($this->lang->cannot_steal); } else if($money2 <= 0) { error($this->lang->cannot_donate_nothing); } else { // All checks clear! Update the users. $this->db->query(" UPDATE `".TABLE_PREFIX."users` SET ".$this->moneysystem()."=".$this->moneysystem()."+".intval($money2)." WHERE uid=".$du['uid']." "); $this->db->query(" UPDATE `".TABLE_PREFIX."users` SET ".$this->moneysystem()."=".$this->moneysystem()."-".intval($money2)." WHERE uid=".$su['uid']." "); redirect('showthread.php?tid='.$thread.'&pid='.$post.'#pid'.$post.'', $this->lang->donate_complete); } } }
// Lets start this biatch... ( Mike said this :P ) $shop = new Inv_Shop();
// This may need to be changed later, cuz I kinda borrowed it from admin/plugins.php =P // Do not report this as needing to be translated. This is only used to verify that your file versions are correct. $pluginfile = './inc/plugins/inventoryshop.php'; $classfile = './inc/class_shop.php'; if(!file_exists($pluginfile)) { echo('Please Upload ' . $pluginfile); exit; } else { require_once($pluginfile); $shopinfo = "inventoryshop_info"; if(!function_exists($shopinfo)) { continue; } $shop2 = $shopinfo(); $version = $shop->buildversion(); if($shop2['version'] != $version) { echo('<p>The version defined in ' . $classfile . ' does not match the one in ' . $pluginfile . ', please verify that you\'ve uploaded all of the correct files..</p>'); echo('<p>' . $classfile . ' version defined: ' . $version . '<br />' . $pluginfile . ' version defined: ' . $shop2['version'] . '</p>'); exit; } } ?>
RE: Item-Shop - SHViperia - 22.03.2008
Habe den Fehler entdeckt.
Habe die Variablen $rubin, $saphir und $smaragd nicht definiert gehabt.
Danke trotzdem
RE: Item-Shop - SHViperia - 02.04.2008
Jetzt neues Problem.
Ich habe den Item-Shop um eine Mine erweitert.
Dort kann man für den Ausbau der Mine spenden.
Nun habe ich ne Tabelle angelegt, wo die Mitglieder die gespendet haben aufgeführt werden sollen.
Es soll so sein, dass dann dort der Username und die gesammte Spendensumme steht.
PHP-Code: case 'donate_mine': $plugins->run_hooks("donate_mine"); // Variablen für Anzeige der Mine { $query = $db->simple_select(TABLE_PREFIX."mine", "*"); $mine = $db->fetch_array($query); } { $query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS posts"); $posts = $db->fetch_field($query, "posts"); } $minelevel = $mine['level']; $gold_in = $mine['gold_in']; $gold_next = ($minelevel*1525); if ($gold_in >= $gold_next) { $db->query("UPDATE ".TABLE_PREFIX."mine SET level=level+1"); } else { $minelevel = $mine['level']; } $arbeiter_t = ($minelevel*100); if ($posts > $arbeiter_t) { $posts = $arbeiter_t ; } else { $posts = $posts; } $arbeiter_c = $posts ; $bonus = ($posts/100); $plusdiamant = round($bonus, 0); // Ende der Anzeige $source = $mybb->input['suser']; $dest = $mybb->input['gold_in']; add_breadcrumb($lang->donate, "shop.php?do=donate_mine&suser=".$source.""); eval("\$shop_mine = \"".$templates->get("shop_mine")."\";"); output_page($shop_mine); break; case 'do_donate_mine': // Hier sollen die Spenden in eine Tabelle eingetragen werden { $query = $db->simple_select(TABLE_PREFIX."spenden", "*"); $spenden = $db->fetch_array($query); } $name = $mybb->user['username']; $uid = $mybb->user['uid']; $betrag = $mybb->input['money']; $spname = $spenden['name']; if ($name <> $spname) { $db->query("INSERT INTO ".TABLE_PREFIX."spenden (name, betrag, id) VALUES ('".$name."', '".$betrag."', '".$uid."')"); } else { $db->query(" UPDATE mybb_spenden SET betrag = betrag + ".$betrag." WHERE id='".$uid."'"); } $plugins->run_hooks("do_donate_mine"); $shop->donate_mine($mybb->input['source'], $mybb->input[''.$shop->moneysystem().'']); break; default: // Index $plugins->run_hooks("inventory_shop_index"); $shop_bits = $shop->show_shops(); eval("\$shop_index = \"".$templates->get("shop_index")."\";"); output_page($shop_index); break; }
Ich wollts halt so machen, dass geprüft wird ob der $mybb->user['username'] schon in der tabelle steht.
Wenn ja ---> addiere gespendetes Gold beim jeweiligen User.
Wenn nein ---> erzeuge neuen Eintrag.
Aber irgendwie werden mehrere Einträge von selben User erzeugt.
Woran kanns liegen?
RE: Item-Shop - StefanT - 02.04.2008
Du solltest nicht mit dem Benutzernamen arbeiten. Die UID ist viel sicherer.
Dieser Code sollte funktionieren:
PHP-Code: case 'donate_mine': $plugins->run_hooks("donate_mine"); // Variablen für Anzeige der Mine { $query = $db->simple_select(TABLE_PREFIX."mine", "*"); $mine = $db->fetch_array($query); } { $query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS posts"); $posts = $db->fetch_field($query, "posts"); } $minelevel = $mine['level']; $gold_in = $mine['gold_in']; $gold_next = ($minelevel*1525); if ($gold_in >= $gold_next) { $db->query("UPDATE ".TABLE_PREFIX."mine SET level=level+1"); } else { $minelevel = $mine['level']; } $arbeiter_t = ($minelevel*100); if ($posts > $arbeiter_t) { $posts = $arbeiter_t ; } else { $posts = $posts; } $arbeiter_c = $posts ; $bonus = ($posts/100); $plusdiamant = round($bonus, 0); // Ende der Anzeige $source = $mybb->input['suser']; $dest = $mybb->input['gold_in']; add_breadcrumb($lang->donate, "shop.php?do=donate_mine&suser=".$source.""); eval("\$shop_mine = \"".$templates->get("shop_mine")."\";"); output_page($shop_mine); break; case 'do_donate_mine': // Hier sollen die Spenden in eine Tabelle eingetragen werden { } $name = $mybb->user['username']; $uid = $mybb->user['uid']; $betrag = $mybb->input['money']; $query = $db->simple_select(TABLE_PREFIX.'spenden', '*', "username='".$db->escape_string($mybb->user['username']."'"); $spenden = $db->fetch_array($query); if (!$spenden) { $db->query("INSERT INTO ".TABLE_PREFIX."spenden (name, betrag, id) VALUES ('".$name."', '".$betrag."', '".$uid."')"); } else { $db->query(" UPDATE mybb_spenden SET betrag = betrag + ".$betrag." WHERE id='".$uid."'"); } $plugins->run_hooks("do_donate_mine"); $shop->donate_mine($mybb->input['source'], $mybb->input[''.$shop->moneysystem().'']); break; default: // Index $plugins->run_hooks("inventory_shop_index"); $shop_bits = $shop->show_shops(); eval("\$shop_index = \"".$templates->get("shop_index")."\";"); output_page($shop_index); break; }
|