krijgt hij deze error
Code: Selecteer alles
error getting store's information
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax near 'LIMIT 1' at line 1
SELECT * FROM store_list WHERE store_id = LIMIT 1
Line : 365
File : /home/virtual/site59/fst/var/www/html/forum/includes/functions_store.php
Dit is de functions_store.php
Code: Selecteer alles
<?php
/***************************************************************************
* functions_store.php
* -------------------
* begin : Thrusday July 31, 2003
* copyright : (C) 2003 wGeric
* email : eric@best-1.biz
*
* $Id: functions_store.php,v 1.1 2004/01/03 00:55:33 wgeric Exp $
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
//---------------------------------------------------------
//get_owner($id)
//gets the owner of an item or store
//
function get_owner($id)
{
global $db, $phpEx, $phpbb_root_path, $lang;
if( $id == BOARD_OWNED )
{
$owner = $lang['Store_board'];
}
else
{
$sql = "SELECT username FROM " . USERS_TABLE . " WHERE user_id = ". $id;
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get owner", "", __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$temp_url = append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $id);
$owner = '<a href="' . $temp_url . '" class="gen" target="_blank">' . $row['username'] . '</a>';
}
return $owner;
} //get_owner()
//---------------------------------------------------------
//item_list($mode = '', $id = false )
//gets the items for a user and puts them in a drop down list
//
function item_list($mode = '', $id = false)
{
global $db, $template, $userdata, $store_info, $lang, $phpEx, $phpbb_root_path;
switch ( $mode )
{
case "board_add":
$list = '<select name="item" class="post">';
$sql = "SELECT * FROM " . STORE_ITEMS . " ORDER BY item_name";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting items", "", __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
if ( $id == $row['item_id'] )
{
$status = 'selected';
}
else
{
$status = '';
}
$list .= '<option value="' . $row['item_id'] . '" ' . $status . '>' . stripslashes(htmlspecialchars(trim($row['item_name']))) . '</option>';
}
$list .= '</select>';
return $list;
break;
case 'store':
//display inventory in store
$sql = "SELECT * FROM " . STORE_INVENTORY . " WHERE inventory_store = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Error getting store's inventory", "",__LINE__,__FILE__, $sql);
}
while ( $inven = $db->sql_fetchrow($result) )
{
$inventory_id = $inven['inventory_id'];
$inventory_amount = $inven['inventory_amount'];
$inventory_price = $inven['inventory_price'];
$restock_time = $inven['restock_time'];
$restock_amount = $inven['restock_amount'];
$restock_last = $inven['restock_last'];
$current_time = time();
$temp = $current_time - $restock_last;
if ( $temp >= $restock_time && $restock_time != '' && $restock_time != 'NULL' && !$restock_time && $restock_time != '0')
{
$i = 0;
while ( $temp >= 0 )
{
$temp = $temp - $restock_time;
$i++;
}
$inventory_amount = $inventory_amount + ($restock_amount * $i);
store_restock($inventory_id, $inventory_amount, $current_time);
}
$sql2 = "SELECT item_special, item_download FROM " . STORE_ITEMS;
if ( !$result2 = $db->sql_query($sql2) )
{
message_die(GENERAL_ERROR, "Error getting item list", "",__LINE__,__FILE__, $sql);
}
$item_dlcheck = $db->sql_fetchrow($result2);
if ( $item_dlcheck['item_special'] == '2' )
{
$textbox = '<input disabled type="text" size="5" value="1" name="amount" class="post">';
$hidden = '<input type="hidden" name="download" value="' . $item_dlcheck['item_download'] . '">';
$buy_action = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=download');
}
else
{
$textbox = '<input type="text" size="5" name="amount" class="post">';
$buy_action = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=buy');
}
$inventory_item = $inven['inventory_item'];
$items = item_info($inventory_item);
$item_name = stripslashes(trim($items['item_name']));
$item_description = stripslashes(trim($items['item_description']));
if ( $userdata['user_id'] == $store_info['owner_id'] && $store_info['owner_id'] != BOARD_OWNED )
{
//edit link
$temp_url = append_sid($phpbb_root_path . 'admin/admin_store.'.$phpEx.'?mode=editinventory&id='.$inventory_id);
$edit = '<a href="' . $temp_url . '" class="gen">' . $lang['Edit'] . '</a>';
}
else
{
$edit = '';
}
$template->assign_block_vars('item_row', array(
'ID' => $inventory_id,
'ITEM' => $item_name,
'DESCRIPTION' => $item_description,
'AMOUNT' => $inventory_amount,
'PRICE' => $inventory_price,
'TEXTBOX' => $textbox,
'S_BUY_ACTION' => $buy_action,
'S_HIDDEN_VALUE' => $hidden,
'EDIT' => $edit)
);
if ( $userdata['user_id'] == $store_info['owner_id'] && $store_info['owner_id'] != BOARD_OWNED )
{
$template->assign_block_vars('item_row.switch_owner', array());
}
else
{
$template->assign_block_vars('item_row.switch_not_owner', array());
}
}
break;
case 'admin':
//display users inventory
$sql = "SELECT * FROM " . STORE_INVENTORY . " WHERE inventory_user = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Error getting user's inventory", "",__LINE__,__FILE__, $sql);
}
while ( $inven = $db->sql_fetchrow($result) )
{
$inventory_id = $inven['inventory_id'];
$inventory_amount = $inven['inventory_amount'];
$inventory_price = $inven['inventory_price'];
$inventory_item = $inven['inventory_item'];
$items = item_info($inventory_item);
$item_name = stripslashes(trim($items['item_name']));
$item_description = stripslashes(trim($items['item_description']));
//edit link
$temp_url = append_sid($phpbb_root_path . 'admin/admin_store.'.$phpEx.'?mode=edit&id='.$inventory_id);
$edit = '<a href="' . $temp_url . '" class="gen">' . $lang['Edit'] . '</a>';
$template->assign_block_vars('item_row', array(
'ID' => $inventory_id,
'ITEM' => $item_name,
'DESCRIPTION' => $item_description,
'AMOUNT' => $inventory_amount,
'PRICE' => $inventory_price,
'EDIT' => $edit)
);
}
break;
default:
//display users inventory
$sql = "SELECT * FROM " . STORE_INVENTORY . " WHERE inventory_user = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Error getting user's inventory", "",__LINE__,__FILE__, $sql);
}
while ( $inven = $db->sql_fetchrow($result) )
{
$inventory_id = $inven['inventory_id'];
$inventory_amount = $inven['inventory_amount'];
$inventory_item = $inven['inventory_item'];
$items = item_info($inventory_item);
$item_name = stripslashes(trim($items['item_name']));
$item_description = stripslashes(trim($items['item_description']));
if ( $userdata['user_id'] == $id || $userdata['user_level'] == ADMIN )
{
//delete link
$temp_url = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=deleteinventory&id='.$inventory_id);
$delete = '<a href="' . $temp_url . '" class="gen">' . $lang['Delete'] . '</a>';
//edit link
if ( $userdata['user_level'] == ADMIN )
{
$temp_url = append_sid($phpbb_root_path . 'admin/admin_store.'.$phpEx.'?id='.$inventory_id);
$edit = '<a href="' . $temp_url . '" class="gen">' . $lang['Edit'] . '</a>';
}
}
else
{
$delete = '';
}
$template->assign_block_vars('item_row', array(
'ID' => $inventory_id,
'ITEM' => $item_name,
'DESCRIPTION' => $item_description,
'AMOUNT' => $inventory_amount,
'DELETE' => $delete)
);
if ( $userdata['user_id'] == $id || $userdata['user_level'] == ADMIN )
{
$template->assign_block_vars('item_row.switch_owner', array());
if ( $userdata['user_level'] == ADMIN )
{
$template->assign_block_vars('item_row.switch_owner.switch_admin', array());
}
}
}
break;
}
return;
} //item_list()
//---------------------------------------------------------
//get_stores($mode, $block, $id = 0)
//gets stores and puts them in a block
//
function get_stores($mode, $block, $id = 0)
{
global $db, $template, $lang, $userdata, $phpEx;
switch($mode)
{
case 'owned':
$where_sql = " WHERE owner_id = $id";
break;
case 'board':
$where_sql = " WHERE owner_id = " . BOARD_OWNED;
break;
case 'user':
$where_sql = " WHERE owner_id <> " . BOARD_OWNED;
break;
} //switch
$sql = "SELECT * FROM " . STORE_LIST . $where_sql;
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting stores the user owns", "", __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$store_id = $row['store_id'];
$store_name = stripslashes(trim($row['store_name']));
$temp_url = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=store_items&id='.$store_id);
$store = '<a href="' . $temp_url . '" class="forumlink">' . $store_name . '</a>';
$owner = get_owner($row['owner_id']);
$store_description = stripslashes(trim($row['store_description']));
$cash_id = $row['cash_id'];
$sql3 = "SELECT cash_name FROM " . CASH_TABLE . " WHERE cash_id = $cash_id LIMIT 1";
if ( !$result3 = $db->sql_query($sql3) )
{
message_die(GENERAL_ERROR, "Could not get cash name", "", __LINE__, __FILE__, $sql);
}
$cash = $db->sql_fetchrow($result3);
if ( $userdata['session_logged_in'] && $userdata['user_id'] == $row['owner_id'] )
{
//delete link
$temp_url = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=delete_store&id=' . $store_id);
$delete = ' <a href="' . $temp_url . '" class="genmed">' . $lang['Delete'] . '</a> ';
//edit link
$temp_url = append_sid($phpbb_root_path . 'store.'.$phpEx.'?mode=edit_store&id=' . $store_id);
$edit = ' <a href="' . $temp_url . '" class="genmed">' . $lang['Edit'] . '</a> ';
}
else
{
$delete = '';
$edit = '';
$inventory = '';
}
//count number of items in store
$sql = "SELECT COUNT(inventory_id) AS total FROM " . STORE_INVENTORY . " WHERE inventory_store = $store_id";
if ( !$resul2 = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not get number of items", "", __LINE__, __FILE__, $sql);
}
$items = $db->sql_fetchrow($result2);
$item_number = $items['total'];
$template->assign_block_vars($block, array(
'STORE_NAME' => $store,
'STORE_DESCRIPTION' => $store_description,
'STORE_OWNER' => $owner,
'ITEMS' => $item_number,
'CASH' => $cash['cash_name'],
'DELETE' => $delete,
'EDIT' => $edit)
);
}
return array($template, $store);
} //get_stores()
//--------------------------------------------------
//store_info($id)
//gets stores information
//
function store_info($id)
{
global $db;
$sql = "SELECT * FROM " . STORE_LIST . " WHERE store_id = $id LIMIT 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting store's information", "", __LINE__, __FILE__, $sql);
}
$store_info = $db->sql_fetchrow($result);
//get cash name
$cash_id = $store_info['cash_id'];
$sql2 = "SELECT cash_dbfield, cash_name FROM " . CASH_TABLE . " WHERE cash_id = $cash_id LIMIT 1";
if ( !$result2 = $db->sql_query($sql2) )
{
message_die(GENERAL_ERROR, "Could not get cash name", "", __LINE__, __FILE__, $sql);
}
$cash = $db->sql_fetchrow($result2);
$store_info['cash_field'] = $cash['cash_dbfield'];
$store_info['cash_name'] = $cash['cash_name'];
return $store_info;
} //store_info();
//--------------------------------------------------
//item_info($id)
//gets item's information
//
function item_info($id)
{
global $db;
$sql = "SELECT * FROM " . STORE_ITEMS . " WHERE item_id = $id LIMIT 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting items's information", "", __LINE__, __FILE__, $sql);
}
$item_info = $db->sql_fetchrow($result);
return $item_info;
} //item_info();
//--------------------------------------------------
//inventory_info($id)
//gets inventory info
//
function inventory_info($id)
{
global $db;
$sql = "SELECT * FROM " . STORE_INVENTORY . " WHERE inventory_id = $id LIMIT 1";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting inventory's information", "", __LINE__, __FILE__, $sql);
}
$inventory_info = $db->sql_fetchrow($result);
return $inventory_info;
} //inventory_info();
//--------------------------------------------------
//store_restock($id, $amount,$current_time)
//restocks an inventory item if the time is right
//
function store_restock($id, $amount, $current_time)
{
global $db;
$sql = "UPDATE " . STORE_INVENTORY . " SET
inventory_amount = $amount,
restock_last = $current_time
WHERE inventory_id = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error restock item", "", __LINE__, __FILE__, $sql);
}
return;
} //store_restock()
//--------------------------------------------------
//store_update_cash($id, $cash_amount, $cash_field)
//updates user cash when buying an item occurs
//
function store_update_cash($id, $cash_amount, $cash_field)
{
global $db;
$sql = "UPDATE " . USERS_TABLE . " SET
$cash_field = $cash_amount
WHERE user_id = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error updating user's cash", "", __LINE__, __FILE__, $sql);
}
return;
} //store_update_cash()
//--------------------------------------------------
//get_user_stores($id)
//gets the user's stores and puts them in a drop down list
//
function get_user_stores($id)
{
global $db, $lang;
$sql = "SELECT store_id, store_name FROM " . STORE_LIST . " WHERE owner_id = $id";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "error getting users stores", "", __LINE__, __FILE__, $sql);
}
$store_list = '<option value="-1">' . $lang['Select_one'] . '</option>';
while ( $row = $db->sql_fetchrow($result) )
{
$store_list .= '<option value="' . $row['store_id'] . '">' . $row['store_name'] . '</option>';
}
return $store_list;
} //store_update_cash()
//////////////////////////////////
// //
// //
// //
// //
// //
// Insert PM function by wGEric //
// //
// //
// //
// //
// //
//////////////////////////////////
function insert_pm(
$to_id,
$message,
$subject,
$from_id,
$html_on = 0,
$bbcode_on = 1,
$smilies_on = 1)
{
global $db, $lang, $user_ip, $board_config, $userdata, $phpbb_root_path, $phpEx;
if ( !$from_id )
{
$from_id = $userdata['user_id'];
}
//get varibles ready
$to_id = intval($to_id);
$from_id = intval($from_id);
$msg_time = time();
$attach_sig = $userdata['user_attachsig'];
//get to users info
$sql = "SELECT user_id, user_notify_pm, user_email, user_lang, user_active
FROM " . USERS_TABLE . "
WHERE user_id = '$to_id'
AND user_id <> " . ANONYMOUS;
if ( !($result = $db->sql_query($sql)) )
{
$error = TRUE;
$error_msg = $lang['No_such_user'];
}
$to_userdata = $db->sql_fetchrow($result);
$privmsg_subject = trim(strip_tags($subject));
if ( empty($privmsg_subject) )
{
$error = TRUE;
$error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_subject'];
}
if ( !empty($message) )
{
if ( !$error )
{
if ( $bbcode_on )
{
$bbcode_uid = make_bbcode_uid();
}
$privmsg_message = prepare_message($message, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$privmsg_message = str_replace('\\\n', '\n', $privmsg_message);
}
}
else
{
$error = TRUE;
$error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Empty_message'];
}
//
// See if recipient is at their inbox limit
//
$sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time
FROM " . PRIVMSGS_TABLE . "
WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "
OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )
AND privmsgs_to_userid = " . $to_userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, $lang['No_such_user']);
}
$sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : '';
if ( $inbox_info = $db->sql_fetchrow($result) )
{
if ( $inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] )
{
$sql = "SELECT privmsgs_id FROM " . PRIVMSGS_TABLE . "
WHERE ( privmsgs_type = " . PRIVMSGS_NEW_MAIL . "
OR privmsgs_type = " . PRIVMSGS_READ_MAIL . "
OR privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )
AND privmsgs_date = " . $inbox_info['oldest_post_time'] . "
AND privmsgs_to_userid = " . $to_userdata['user_id'];
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not find oldest privmsgs (inbox)', '', __LINE__, __FILE__, $sql);
}
$old_privmsgs_id = $db->sql_fetchrow($result);
$old_privmsgs_id = $old_privmsgs_id['privmsgs_id'];
$sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
WHERE privmsgs_id = $old_privmsgs_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs (inbox)'.$sql, '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE $sql_priority FROM " . PRIVMSGS_TEXT_TABLE . "
WHERE privmsgs_text_id = $old_privmsgs_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete oldest privmsgs text (inbox)', '', __LINE__, __FILE__, $sql);
}
}
}
$sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
VALUES (" . PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $privmsg_subject) . "', " . $from_id . ", " . $to_userdata['user_id'] . ", $msg_time, '$user_ip', $html_on, $bbcode_on, $smilies_on, $attach_sig)";
if ( !($result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) )
{
message_die(GENERAL_ERROR, "Could not insert/update private message sent info.", "", __LINE__, __FILE__, $sql_info);
}
$privmsg_sent_id = $db->sql_nextid();
$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '" . str_replace("\'", "''", $privmsg_message) . "')";
if ( !$db->sql_query($sql, END_TRANSACTION) )
{
message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql);
}
//
// Add to the users new pm counter
//
$sql = "UPDATE " . USERS_TABLE . "
SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . "
WHERE user_id = " . $to_userdata['user_id'];
if ( !$status = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
}
if ( $to_userdata['user_notify_pm'] && !empty($to_userdata['user_email']) && $to_userdata['user_active'] )
{
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer($board_config['smtp_delivery']);
$emailer->from($board_config['board_email']);
$emailer->replyto($board_config['board_email']);
$emailer->use_template('privmsg_notify', $to_userdata['user_lang']);
$emailer->email_address($to_userdata['user_email']);
$emailer->set_subject($lang['Notification_subject']);
$emailer->assign_vars(array(
'USERNAME' => $to_username,
'SITENAME' => $board_config['sitename'],
'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '',
'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
);
$emailer->send();
$emailer->reset();
}
return;
$msg = $lang['Message_sent'] . '<br /><br />' . sprintf($lang['Click_return_inbox'], '<a href="' . append_sid("privmsg.$phpEx?folder=inbox") . '">', '</a> ') . '<br /><br />' . sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a>');
message_die(GENERAL_MESSAGE, $msg);
} // insert_pm()
function gethelp($topic, $page)
{
$helpfile_link = '[<a href="'.append_sid('admin_store.php?file=help&num='.$topic.'&from='.$page).'">-?-</a>]';
return $helpfile_link;
}
?>