} } } } } } } } if ($error) { $smarty->assign('registration_error', $error); $smarty->display('index.tpl.html'); exit; } $db = new SQLite($SQLITE_DB_PATH); $user_count_query = "SELECT COUNT(*) FROM users WHERE username = '******'username']}'"; $user_count = $db->fetchRowQuerySingle($user_count_query); if ($db->isError()) { $error = "Registration failed! There was a database error: " . $db->getError(); $smarty->assign('registration_error', $error); $smarty->assign('register_username', $_POST['username']); $smarty->display('index.tpl.html'); exit; } if ($user_count) { $error = "Username '{$_POST['username']}' already exists!\n" . "Please choose a different one!"; $smarty->assign('registration_error', $error); $smarty->assign('register_username', $_POST['username']); $smarty->display('index.tpl.html'); exit; } $current_time = time();
# The requested item was not found # $smarty->assign('tpl_content', 'content-error.tpl.html'); $smarty->assign('error', "Item '" . htmlentities($HandlerMatches[1]) . "' does not exist!"); $smarty->display('index.tpl.html'); exit; } if ($add_comment) { $escaped_comment = $db->escape($_POST['comment']); $user_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0; $anonymous_name = isset($_POST['name']) ? $db->escape($_POST['name']) : ''; $time_now = time(); # Let's check if the cowboy is not posting too fast # $check_query = "SELECT date_added FROM comments " . "WHERE item_id = {$item['id']} AND " . "user_id = {$user_id} AND " . "ip_address = '{$_SERVER['REMOTE_ADDR']}' " . "ORDER BY date_added DESC"; $date_added = $db->fetchRowQuerySingle($check_query); if ($db->isError()) { $comment_error = "There was a database error while adding your comment: " . $db->getError() . "! Sorry..."; $smarty->assign('comment_error', $comment_error); $smarty->assign('existing_comment', isset($_POST['comment']) ? $_POST['comment'] : ''); } if ($date_added && $time_now - $date_added < 20) { $comment_error = "Please wait at least 20 seconds between posting comments! Thank you :)"; $smarty->assign('comment_error', $comment_error); $smarty->assign('existing_comment', isset($_POST['comment']) ? $_POST['comment'] : ''); } if (!$comment_error) { $add_comment_query = "INSERT INTO comments (comment, item_id, user_id, anonymous_name, date_added, ip_address) VALUES " . "('{$escaped_comment}', {$item['id']}, {$user_id}, '{$anonymous_name}', {$time_now}, '{$_SERVER['REMOTE_ADDR']}')"; if (!$db->query($add_comment_query)) { $comment_error = "There was a database error while adding your comment: " . $db->getError() . "! Sorry..."; $smarty->assign('comment_error', $comment_error);
} else { if (!isset($_SESSION['user_id'])) { header("Location: {$SITE_URL}"); exit; } } require_once 'mysmarty.php'; require_once 'system/db.sqlite.php'; $smarty = new MySmarty(); $db = new SQLite($SQLITE_DB_PATH); $smarty->assign('tpl_content', 'content-my-profile.tpl.html'); $smarty->assign('page_style', 'style-my-profile.css'); # Get the current information # $data_query = "SELECT data FROM users WHERE id = {$_SESSION['user_id']}"; $data_ser = $db->fetchRowQuerySingle($data_query); if ($db->isError()) { $smarty->assign('tpl_content', 'content-error.tpl.html'); $smarty->assign('error', 'There was a database error while getting your profile information: ' . $db->getError()); $smarty->display('index.tpl.html'); exit; } $data = array(); if ($data_ser) { $data = unserialize($data_ser); } $smarty->assign('email', isset($data['email']) ? $data['email'] : ''); $smarty->assign('website', isset($data['website']) ? $data['website'] : ''); # UGLINESS if (isset($_POST['action'])) { if ($_POST['action'] == "profile") {
$smarty->assign('error', 'Database error has occured: ' . $db->getError()); $smarty->display('index.tpl.html'); exit; } if (!$site) { # The requested site was not found # $smarty->assign('tpl_content', 'content-error.tpl.html'); $smarty->assign('error', "Pictures from '" . htmlentities($HandlerMatches[1]) . "' are not being collected!"); $smarty->display('index.tpl.html'); exit; } # Prepare data for navigation through pages [<prev] [1], [2], [3], etc, [next>] # $total_items_query = "SELECT COUNT(*) FROM items WHERE site_id = {$site['id']}"; $total_items = $db->fetchRowQuerySingle($total_items_query); if ($db->isError()) { $smarty->assign('tpl_content', 'content-error.tpl.html'); $smarty->assign('error', 'Database error has occured: ' . $db->getError()); $smarty->display('index.tpl.html'); exit; } $total_pages = ceil($total_items / $ITEMS_PER_SITE_PAGE); $current_page = isset($HandlerMatches[2]) ? $HandlerMatches[2] : 1; if ($current_page > $total_pages) { $current_page = 1; } # Fetch ITEMS_PER_INDEX_PAGE for each site # $item_offset = $ITEMS_PER_SITE_PAGE * ($current_page - 1); $item_query = "SELECT " . join(',', $ITEM_FIELDS) . " FROM items " . "WHERE site_id = {$site['id']} AND visible = 1 " . "ORDER BY date_added DESC, id DESC LIMIT {$item_offset}, {$ITEMS_PER_SITE_PAGE}";
$years = ceil($time_diff / 3600 / 24 / 30 / 12); $human_diff = "{$years} year" . ($years != 1 ? 's' : ''); } } } } return 'aprox. ' . $human_diff; } $smarty = new MySmarty(); $db = new SQLite($SQLITE_DB_PATH); $smarty->assign('tpl_content', 'content-my-comments.tpl.html'); $smarty->assign('page_style', 'style-my-comments.css'); # Prepare data for navigation through pages [<prev] [1], [2], [3], etc, [next>] # $total_comments_query = "SELECT COUNT(*) FROM comments WHERE user_id = {$_SESSION['user_id']}"; $total_comments = $db->fetchRowQuerySingle($total_comments_query); if ($db->isError()) { $smarty->assign('tpl_content', 'content-error.tpl.html'); $smarty->assign('error', 'Database error has occured: ' . $db->getError()); $smarty->display('index.tpl.html'); exit; } $total_pages = ceil($total_comments / $COMMENTS_PER_MY_COMMENTS); $current_page = isset($HandlerMatches[1]) ? $HandlerMatches[1] : 1; if ($current_page > $total_pages) { $current_page = 1; } # Fetch COMMENTS_PER_MY_COMMENTS comments for the current user # $comment_offset = $COMMENTS_PER_MY_COMMENTS * ($current_page - 1); $comment_query = <<<EOL