phpBB SEO
Boards
Directory  
SEO  
Downloads
  phpBB SEO : Search Engine Optimization, Directory, Forums  
Index
Forums
Annuaire
Référencement
Télécharger
 
  Search Rechercher
    Register
Username :  Password :  Log me on automatically each visit  
S'enregistrer  
 
   
Error when sell item with Shop MOD. Help.

 
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB3 mod Rewrite  » Advanced SEO URL
::  
Author Message
Autinhyeu



Joined: 09 Aug 2008
Posts: 36

Error when sell item with Shop MOD. Help.Posted: Mon Aug 11, 2008 9:41 am    Post subject: Error when sell item with Shop MOD. Help.

Shop MOD: http://www.phpbb.com/community/viewtopic.php?f=70&t=575761&st=0&sk=t&sd=a
When i sell item to shop, error on header:
Code:
2
Warning: Cannot modify header information - headers already sent by (output started at G:\HNSV_FTP\ForumAutinhyeu\includes\functions_shop.php:89) in G:\HNSV_FTP\ForumAutinhyeu\includes\functions.php on line 3834

Warning: Cannot modify header information - headers already sent by (output started at G:\HNSV_FTP\ForumAutinhyeu\includes\functions_shop.php:89) in G:\HNSV_FTP\ForumAutinhyeu\includes\functions.php on line 3836

Warning: Cannot modify header information - headers already sent by (output started at G:\HNSV_FTP\ForumAutinhyeu\includes\functions_shop.php:89) in G:\HNSV_FTP\ForumAutinhyeu\includes\functions.php on line 3837

Warning: Cannot modify header information - headers already sent by (output started at G:\HNSV_FTP\ForumAutinhyeu\includes\functions_shop.php:89) in G:\HNSV_FTP\ForumAutinhyeu\includes\functions.php on line 3838


code line 3832-3842:
Code:
   // application/xhtml+xml not used because of IE
   header('Content-type: text/html; charset=UTF-8');

   header('Cache-Control: private, no-cache="set-cookie"');
   header('Expires: 0');
   header('Pragma: no-cache');

   return;
}


and file functions_shop.php:
Code:
<?php
/**
*
* @package phpBB3
* @version $Id: $
* @copyright (c) 2008 Francis W. Fisher (Phantom) http://radoncube.com/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
define('SHOP_VERSION', '0.4.0');

class item
{
   var $data;   //holds everything taken from phpbb_items (eg name, description, price, quantity)
   var $notrash = false; //set to true by buy function when instant_used so it isn't removed from inventory
   
   function item($db_info)
   {
      $this->data         = $db_info;
      //here, we load custom config values
      $this->init();
   }

   function init()
   {
      //blank by default
   }
   
   function get_actions()
   {
      //'name'   => isset($user->lang['ITEM_USE']) ? $user->lang['ITEM_USE'] : 'blah'
      global $user, $shop, $db, $config;

      $actions = array();
      if ($this->data['can_sellback'])
      {
         $actions['sellback'] = array(
               'name'      => sprintf($user->lang['ITEM_SELLBACK'], $shop->cash->format_cash_string($this->data['sell_price'])),
               'confirm'   => sprintf($user->lang['ITEM_CONFIRM_SELL'], $this->data['name'], $shop->cash->format_cash_string($this->data['sell_price'])),
               'function'   => 'sellback'

         );
      }
      if ($this->data['can_trash'])
      {
         $actions['trash'] = array(
            'name'      => $user->lang['ITEM_TRASH'],
            'confirm'   => sprintf($user->lang['ITEM_CONFIRM_TRASH'], $this->data['name']),
            'function'   => 'trash'
         );
      }
      if ($this->data['can_display'] and $config['shop_shelf_size_sig'] != 0)
      {
         //find out how many items are currently on the shelf
         $sql = 'SELECT * FROM ' . SHOP_ITEMS_USER_TABLE . ' WHERE user=' . (int) $user->data['user_id'] . ' AND shelf_display=true';
         $db->sql_query($sql);
         if ($this->data['shelf_display'])
         {
            $actions['display'] = array(
               'name'      => $user->lang['ITEM_DISPLAY_REMOVE'],
               'confirm'   => false,
               'function'   => 'display',
            );
         }
         elseif ($db->sql_affectedrows() == $config['shop_shelf_size_sig'])
         {
            $actions['display'] = array(
               'name'      => $user->lang['ITEM_DISPLAY_FULL'],
               'confirm'   => false,
               'function'   => 'none',
            );
         }
         else
         {
            $actions['display'] = array(
               'name'      => $user->lang['ITEM_DISPLAY'],
               'confirm'   => false,
               'function'   => 'display',
            );
         }
      }
      return $actions;
   }

   //this removes one instance of an item from the user's inventory.
   function remove_item()
   {
      global $db, $user, $shop, $phpbb_root_path, $phpEx;
      echo $this->data['user'];
      if ($this->notrash)
      {
         return false;
      }
      $sql = 'UPDATE ' . SHOP_ITEMS_USER_TABLE . ' SET quantity_user = quantity_user - 1 WHERE item=' . (int) $this->data['item'] . ' AND user=' . (int) $user->data['user_id'];   
      $db->sql_query($sql);
      $sql = 'DELETE FROM ' . SHOP_ITEMS_USER_TABLE . ' WHERE quantity_user = 0';
      $db->sql_query($sql);
   }

   function action_handler($action, $confirm = true)
   {
      $actions = $this->get_actions();
      if (!isset($actions[$action]))
      {
         return false;
      }
      if (!$confirm or !$actions[$action]['confirm'] or confirm_box(true))
      {
         if ($actions[$action]['function'] == 'none')
         {
            return;
         }
         else
         {
            return $this->$actions[$action]['function'](); //greatest single line of code I've ever written
         }
      }
      else
      {
         $s_hidden_fields = build_hidden_fields(array(
            'submit'   => true,
            )
         );
         confirm_box(false, $actions[$action]['confirm'], $s_hidden_fields);
         return false;
      }

   }

   function display()
   {
      global $db, $user;
      if($this->data['shelf_display'] == 1)
      {
         $this->data['shelf_display'] = 0;
      }
      else
      {
         $this->data['shelf_display'] = 1;
      }
      $sql = 'UPDATE ' . SHOP_ITEMS_USER_TABLE . ' SET shelf_display=' . $this->data['shelf_display'] . ' WHERE item=' . (int) $this->data['item'] . ' AND user=' . (int) $user->data['user_id'];   
      $db->sql_query($sql);
      return sprintf(($this->data['shelf_display'] == 1)?$user->lang['ITEM_SHELF_ADDED']:$user->lang['ITEM_SHELF_REMOVED'], $this->data['name']);
   }

   function trash()
   {
      global $db, $user, $shop, $phpbb_root_path, $phpEx;
      $this->remove_item();
      return sprintf($user->lang['ITEM_TRASHED'], $this->data['name']);
   }

   function sellback()
   {
      global $db, $user, $shop, $phpbb_root_path, $phpEx;
      //this part is exactly like throwing the item out
      $this->remove_item();
      //but then, they get MONEY!!!
      $shop->cash->deposit_user($this->data['sell_price']);
      //and put it back in the shop
      $sql = 'UPDATE ' . SHOP_ITEMS_TABLE . ' SET quantity = quantity + 1 WHERE item=' . (int) $this->data['item'];
      $db->sql_query($sql);
      return sprintf($user->lang['ITEM_SOLD'], $this->data['name']);
   }

   //this function sees if the user is able to buy and item and charges the user if so
   //it doesn't move the item from the shop to the user's inventory
   //if item can't be bought, it won't return
   function prebuy()
   {
      global $user, $shop, $db, $phpEx, $phpbb_root_path;
      //eventually, we'll have an auth check here too.  for now, all registered users can use the shop
      if (!$user->data['is_registered'])
      {
         $db->sql_transaction('rollback');
         trigger_error('SHOP_NOT_PERMITTED');
      }
      if (!$this->data['quantity'])
      {
         $db->sql_transaction('rollback');
         $meta_info = append_sid("{$phpbb_root_path}shop.$phpEx");
         meta_refresh(3, $meta_info);
         $message = $user->lang['SHOP_SOLD_OUT'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $meta_info . '">', '</a>');
         trigger_error($message);
      }

      //decrease the quantity in the shop
      $sql = 'UPDATE ' . SHOP_ITEMS_TABLE . ' SET quantity = quantity - 1 WHERE item=\'' . (int) $this->data['item'] . '\'';   
      $db->sql_query($sql);

      //charge the user
      if (!$shop->cash->charge_user($this->data['price']))
      {
         $db->sql_transaction('rollback');
         $meta_info = append_sid("{$phpbb_root_path}shop.$phpEx");
         meta_refresh(3, $meta_info);
         $message = $user->lang['SHOP_INSUFFICIENT_FUNDS'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $meta_info . '">', '</a>');
         trigger_error($message);
      }
   }

   function use_item()
   {
      //we only define this function so the program doesn't crash
      //if somebody decides to make an item that doesn't have a use action set
      //an instant use item
      return false;
   }
   function buy()
   {
      global $user, $shop, $db, $phpEx, $phpbb_root_path, $config;
      $db->sql_transaction('begin');
      $this->prebuy(); //returns if purchase is allowed, user was charged, and quantity was decreased
      //see if there is already an entry for the object and user in question
      if ($this->data['instant_use'])
      {
         $this->notrash = true;
         //this way, if it returns false, we still buy the item like normal
         if ($message = $this->use_item())
         {
            $meta_info = append_sid("{$phpbb_root_path}shop.$phpEx");
            meta_refresh(3, $meta_info);
            $message = $message . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $meta_info . '">', '</a>');
            trigger_error($message);
         }
      }
      $sql = 'UPDATE ' . SHOP_ITEMS_USER_TABLE . ' SET quantity_user = quantity_user + 1 WHERE item=' . (int) $this->data['item'] . ' AND user=' . (int) $user->data['user_id'];   
      $db->sql_query($sql);
      if ($db->sql_affectedrows() != 1)
      {
         $sql = 'INSERT INTO ' . SHOP_ITEMS_USER_TABLE . ' ' . $db->sql_build_array('INSERT', array('item' => $this->data['item'], 'user' => $user->data['user_id'], 'quantity_user' => 1));
         $db->sql_query($sql);
      }
      $db->sql_transaction('commit');

      if ($config['shop_pm_on_buy'])
      {
         require($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
         $my_subject = utf8_normalize_nfc($user->lang['ITEM_PM_SUBJECT']);
         $my_text = utf8_normalize_nfc(sprintf($user->lang['ITEM_PM_MESSAGE'], $user->data['username'], $this->data['name'], $shop->cash->format_cash_string($this->data['price'])));
         $poll = $uid = $bitfield = $options = '';
         generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
         generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

         $data = array(
         'address_list' => array ('u' => array(2 => 'to')),
         'from_user_id' => 2,
         'icon_id' => 0,
         'from_user_ip' => $user->data['user_ip'],

         'enable_bbcode' => true,
         'enable_smilies' => true,
         'enable_urls' => true,
         'enable_sig' => true,

         'message' => $my_text,
         'bbcode_bitfield' => $bitfield,
         'bbcode_uid' => $uid,
         );

         submit_pm('post', $my_subject, $data, false);
      }

      //everything worked, send a success message
      $meta_info = append_sid("{$phpbb_root_path}shop.$phpEx");
      meta_refresh(3, $meta_info);
      $message = sprintf($user->lang['ITEM_BOUGHT'], $this->data['name']) . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $meta_info . '">', '</a>');
      trigger_error($message);
   }
}

class shop
{
   var $cash;
   //constructor
   function shop()
   {
      global $config;
      //select the correct money system
      if($config['shop_money_system'] == 'cashmod')
      {
         if (version_compare($config['cash_version'], '1.0.0', '>='))
         {
            $this->cash = new cash_mod;
         }
         else
         {
            $this->cash = new cash_mod_beta;
         }
      }
      elseif($config['shop_money_system'] == 'simplepoints')
      {
         $this->cash = new simple_points;
      }
      else
      {
         $this->cash = new cash;
      }
   }
   function get_item_by_row($row)
   {
      global $phpbb_root_path, $phpEx;
      include_once($phpbb_root_path . 'includes/items/' . $row['backend'] . '.' . $phpEx);
      return new $row['backend']($row);
   }
   function get_item($item_id, $condition = false)
   {
      global $db;
      $condition = $condition?' AND ' . $condition:'';
      $sql = 'SELECT * FROM ' . SHOP_ITEMS_TABLE . ' WHERE item=' . (int) $item_id . $condition;
      $result = $db->sql_query($sql);
      if ($db->sql_affectedrows() != 1)
      {
         return false;
      }
      return $this->get_item_by_row($db->sql_fetchrow($result));
   }

   function get_item_list($condition = false)
   {
      global $db;
      $condition = $condition?' WHERE ' . $condition:'';
      $sql = 'SELECT * FROM ' . SHOP_ITEMS_TABLE . $condition . ' ORDER BY item_order';
      $result = $db->sql_query($sql);
      $i = 0;
      if ($db->sql_affectedrows() != 0)
      {
         while($item_row = $db->sql_fetchrow($result))
         {
            $items[$i] = $this->get_item_by_row($item_row);
            $i++;
         }
         return $items;
      }
      else
      {
         return false;
      }
   }

   function get_item_user($item_id, $user_id = NULL,  $condition = false)
   {
      global $db, $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      $condition = $condition?' AND ' . $condition:'';
      $sql = 'SELECT * FROM ( ' . SHOP_ITEMS_TABLE . ' INNER JOIN ' . SHOP_ITEMS_USER_TABLE . ' ON ' . SHOP_ITEMS_USER_TABLE . '.item = ' . SHOP_ITEMS_TABLE . '.item) WHERE user = ' . (int) $user_id . ' AND ' . SHOP_ITEMS_TABLE . '.item=' . (int) $item_id . $condition;
      $result = $db->sql_query($sql);
      if ($db->sql_affectedrows() != 1)
      {
         return false;
      }
      return $this->get_item_by_row($db->sql_fetchrow($result));
   }

   function get_item_list_user($user_id = NULL, $condition = false)
   {
      global $db, $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      $condition = $condition?' AND ' . $condition:'';
      $sql = 'SELECT * FROM ( ' . SHOP_ITEMS_TABLE . ' INNER JOIN ' . SHOP_ITEMS_USER_TABLE . ' ON ' . SHOP_ITEMS_USER_TABLE . '.item = ' . SHOP_ITEMS_TABLE . '.item) WHERE user = ' . (int) $user_id . $condition . ' ORDER BY item_order';
      $result = $db->sql_query($sql);
      $i = 0;
      if ($db->sql_affectedrows() != 0)
      {
         while($item_row = $db->sql_fetchrow($result))
         {
            $items[$i] = $this->get_item_by_row($item_row);
            $i++;
         }
         return $items;
      }
      else
      {
         return false;
      }
   }
}

//classes for the various cash systems
class cash
{
   var $money_on = false;
   function deposit_user($amount, $user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return false;
   }
   function charge_user($amount, $user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return false;
   }
   function user_get_cash_amount($user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return 0;
   }
   function format_cash_string($amount = NULL)
   {
      $amount = is_null($amount) ? $this->user_get_cash_amount() : $amount;
      return number_format($amount, 0, '.', ' ');
   }
}

class simple_points extends cash
{
   //constructor
   function simple_points()
   {
      global $phpbb_root_path, $phpEx;
      require_once($phpbb_root_path . 'includes/mods/functions_points.' . $phpEx);
      $this->money_on = true;
   }
   function deposit_user($amount, $user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      add_points($user_id, $amount);
      return true;
   }
   function charge_user($amount, $user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      if ($amount > $user->data['user_points'])
      {
         return false;
      }
      substract_points($user_id, $amount);
      return true;
   }
   function user_get_cash_amount($user_id = NULL)
   {
      global $user;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return $user->data['user_points'];
   }
}

class cash_mod extends cash
{
   //constructor
   function cash_mod()
   {
      global $phpbb_root_path, $phpEx;
      require_once($phpbb_root_path . 'includes/mods/cash/cash_class.' . $phpEx);
      $this->money_on = true;
      $this->cash = $cash;
      $this->shop_cash = $config['cash_id'];
   }
   function deposit_user($amount, $user_id = NULL)
   {
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return $this->cash->give_cash($user_id, $amount, $this->shop_cash);
   }
   function charge_user($amount, $user_id = NULL)
   {
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      return $this->cash->take_cash($user_id, $amount, $this->shop_cash);
   }
   function user_get_cash_amount($user_id = NULL)
   {
      $cashrow = $this->cash->get_user_cash($user_id, false);
      return $cashrow[$this->shop_cash];
   }
   function format_cash_string($amount)
   {
      $amount = is_null($amount) ? $this->user_get_cash_amount() : $amount;
      return $this->cash->format_currency($amount, $this->shop_cash);
   }
}

class cash_mod_beta extends cash
{
   //constructor
   function cash_mod_beta()
   {
      global $phpbb_root_path, $phpEx;
      require_once($phpbb_root_path . 'includes/mods/functions_cash.' . $phpEx);
      $this->money_on = true;
   }
   function deposit_user($amount, $user_id = NULL)
   {
      global $user, $db, $config;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      $sql = 'UPDATE ' . CASH_AMT_TABLE . "
         SET cash_amt = cash_amt + $amount
         WHERE user_id = '$user_id'
         AND cash_id = {$config['cash_id']}";
      $db->sql_query($sql);
      if ($db->sql_affectedrows() < 1)
      {
         $cash_ary = array(
            'user_id'   => $user_id,
            'cash_id'   => $config['cash_id'],
            'cash_amt'   => $amount,
         );
         $sql = 'INSERT INTO ' . CASH_AMT_TABLE . ' ' . $db->sql_build_array('INSERT', $cash_ary);
         $db->sql_query($sql);
      }
      return true;
   }
   function charge_user($amount, $user_id = NULL)
   {
      global $user, $db, $config;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      if ($amount > $this->user_get_cash_amount($user_id))
      {
         return false;
      }
      $sql = 'UPDATE ' . CASH_AMT_TABLE . "
         SET cash_amt = cash_amt - $amount
         WHERE user_id = '$user_id'
         AND cash_id = {$config['cash_id']}";
      $result = $db->sql_query($sql);
      if ($db->sql_affectedrows($result) < 1)
      {
         return false;
      }
      return true;
   }
   function user_get_cash_amount($user_id = NULL)
   {
      global $user, $db, $config;
      $user_id = is_null($user_id) ? $user->data['user_id'] : $user_id;
      $sql = 'SELECT c.*, ca.cash_amt
         FROM ' . CASH_TABLE . ' c
         LEFT JOIN ' . CASH_AMT_TABLE . " ca ON (ca.cash_id = c.cash_id)
         WHERE ca.user_id = $user_id
         AND ca.cash_id = {$config['cash_id']}";
      $result = $db->sql_query($sql);
      //this should be ==, not >=, but cash mod is being weird
      if ($db->sql_affectedrows() >= 1)
      {
         $row = $db->sql_fetchrow($result);
         return $row['cash_amt'];
      }
      else
      {
         return 0;
      }
   }
}
?>


Please help me!!!
Thanks
Back to top
dcz
Administrateur - Site Admin
Administrateur - Site Admin


Joined: 28 Apr 2006
Posts: 15242

Error when sell item with Shop MOD. Help.Posted: Wed Aug 13, 2008 10:16 am    Post subject: Re: Error when sell item with Shop MOD. Help.

Looks like it comes from this line (line 89) :
Code:
      echo $this->data['user'];

The mod is here sending content before it should, and it does look like a typo from the author, try to replace this line with :

Code:
      //echo $this->data['user'];


Should work, but you'd better report this one in the mod's release thread too Wink

++

_________________
Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche
Back to top
Visit poster's website
Autinhyeu



Joined: 09 Aug 2008
Posts: 36

Error when sell item with Shop MOD. Help.Posted: Wed Aug 13, 2008 10:46 am    Post subject: Re: Error when sell item with Shop MOD. Help.

Thanks you very much. Work fine now Laughing
i love phpbb-seo ^^!
thx again Smile
Back to top
Display posts from previous:   
Post new topic   Reply to topic    phpBB SEO » SEO Forum  » phpBB3 mod Rewrite  » Advanced SEO URL
Page 1 of 1

Navigation Similar Topics

Jump to: