Code: Alles auswählen
<?php
/***************************************************************************
* usercars.php
* -------------------
* begin : Sunday, April 13, 2003
* copyright : (C) 2003 AWSW
* url : http://www.awsw.de
* $Id: usercars.php,v 1.0.0 2003/04/13 12:00:00 AWSW 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.
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
// SESSION MANAGEMENT START
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// SESSION MANAGEMENT END
// UPLOADDIRECTORY !!! START
$phpbb_domain_path = "http://" . $_SERVER['HTTP_HOST'] . $board_config['script_path'] . "usercars/";
$phpbb_domain_uploaddir = "usercars/";
// UPLOADDIRECTORY !!! END
// USER LOGGED IN ? START
if( !$userdata['session_logged_in'] )
{
header("Location: " . append_sid("login.$phpEx?redirect=usercars.$phpEx", true));
exit;
}
// USER LOGGED IN ? END
// DELETE ENTRY START
if ( isset($HTTP_GET_VARS['mode']) )
{
$mode = ($HTTP_GET_VARS['mode']);
if ( $mode == 'remove' )
{
if ( isset($HTTP_GET_VARS['t']))
{
$usercars_id = (intval($HTTP_GET_VARS['t']));
$user_id = ($userdata['user_id']);
// DELETE PICTURE START
$sql = "SELECT usercars_pic FROM " . $table_prefix . "usercars WHERE usercars_id = " . $usercars_id;
if ( ($result = $db->sql_query($sql)) )
{
while ( $row = $db->sql_fetchrow($result) )
{
unlink("./".$row['usercars_pic']);
}
}
// DELETE PICTURE END
$sql = "DELETE FROM " . $table_prefix . "usercars WHERE user_id = '$user_id' AND usercars_id = '$usercars_id'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['L_remove_usercars_data'], '', __LINE__, __FILE__, $sql);
}
}
if ( !(isset($HTTP_GET_VARS['t'])) )
{
message_die(GENERAL_MESSAGE, $lang['L_no_usercars_id']);
exit;
}
$header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
header($header_location . append_sid("usercars." . $phpEx, true));
exit;
}
}
else
{
define('SHOW_ONLINE', true);
$page_title = $lang['L_USERCARS'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$user_id = ($userdata['user_id']);
// DELETE ENTRY END
$template->set_filenames(array(
'body' => 'usercars_body.tpl')
);
// ADD ENTRY START
if ($submit_update)
{
// UPLOAD PICTURE START
if($_FILES["datei"]["name"] == "") {
message_die(GENERAL_MESSAGE, $lang['L_USERCARS_MOD3']);
exit;
}
if($_FILES["datei"]["tmp_name"] == "") {
message_die(GENERAL_MESSAGE, $lang['L_USERCARS_MOD4']);
exit;
}
if($_FILES["datei"]["size"] == 0) {
message_die(GENERAL_MESSAGE, $lang['L_USERCARS_MOD5']);
exit;
}
if (($_FILES["datei"]["type"] != "image/pjpeg") && ($_FILES["datei"]["type"] != "image/gif")) {
message_die(GENERAL_MESSAGE, $lang['L_USERCARS_MOD6']);
exit;
}
// RENAME FILE START
$current_user_date_time = $userdata['user_id'] . "_" . date(ymd) . "_" . time();
$_FILES["datei"]["name"] = $current_user_date_time;
// RENAME FILE END
move_uploaded_file($_FILES["datei"]["tmp_name"], $phpbb_domain_uploaddir . $_FILES["datei"]["name"]);
// UPLOAD PICTURE END
$usercars_pic = $phpbb_domain_uploaddir . $_FILES["datei"]["name"];
$user_id = ($userdata['user_id']);
$sql = "INSERT INTO " . $table_prefix . "usercars (usercars_id, user_id, usercars_pic, usercars_carname, usercars_mods, usercars_cylinders, usercars_desc, usercars_exhaust, usercars_power, usercars_topspeed) VALUES (NULL, '$user_id', '$usercars_pic', '$usercars_carname', '$usercars_mods', '$usercars_cylinders', '$usercars_desc', '$usercars_exhaust', '$usercars_power', '$usercars_topspeed')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, $lang['L_USERCARS_MOD1'], '', __LINE__, __FILE__, $sql);
}
}
// ADD ENTRY END
$template->assign_vars(array(
'U_INDEX' => append_sid("index.$phpEx"),
'L_INDEX' => $lang['Index'],
"usercars_id" => $usercars_id,
"user_id" => $user_id,
"usercars_pic" => $usercars_pic,
"usercars_carname" => $usercars_carname,
"usercars_mods" => $usercars_mods,
"usercars_cylinders" => $usercars_cylinders,
"usercars_desc" => $usercars_desc,
"usercars_exhaust" => $usercars_exhaust,
"usercars_power" => $usercars_power,
"usercars_topspeed" => $usercars_topspeed,
'L_USERCARS' => $lang['L_USERCARS'],
"L_usercars_carname" => $lang['usercars_carname'],
"L_usercars_desc" => $lang['usercars_desc'],
"L_usercars_mods" => $lang['usercars_mods'],
"L_usercars_cylinders" => $lang['usercars_cylinders'],
"L_usercars_exhaust" => $lang['usercars_exhaust'],
"L_usercars_power" => $lang['usercars_power'],
"L_usercars_topspeed" => $lang['usercars_topspeed'],
"L_usercars_pic" => $lang['L_usercars_pic'],
"L_add_entry" => $lang['L_add_entry'],
"L_SUBMIT" => $lang['Submit'],
'L_DELETE' => $lang['Delete'])
);
// SHOW ENTRY START
$sql = "SELECT * FROM " . $table_prefix . "usercars fe WHERE fe.user_id = '" . $userdata['user_id'] . "' ORDER BY usercars_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_MESSAGE, $lang['L_USERCARS_MOD2'], '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
$template->assign_block_vars("usercarsrow", array(
'usercars_id' => $row['usercars_id'],
'user_id' => $row['user_id'],
'usercars_pic' => $row['usercars_pic'],
'usercars_carname' => $row['usercars_carname'],
'usercars_mods' => $row['usercars_mods'],
'usercars_cylinders' => $row['usercars_cylinders'],
'usercars_desc' => $row['usercars_desc'],
'usercars_exhaust' => $row['usercars_exhaust'],
'usercars_power' => $row['usercars_power'],
'usercars_topspeed' => $row['usercars_topspeed'],
'L_REMOVE' => $lang['Delete'],
'U_REMOVE' => append_sid("usercars.$phpEx?mode=remove&t=" . $row['usercars_id']))
);
}
// SHOW ENTRY END
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
?>