function photos_upload() { require MODELS . "photo.php"; require MODELS . "users.php"; $cur_user = users_getCurrentUser(); if ($cur_user['id'] > 0) { if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($_FILES['file']['error'] == 0) { $name = $_POST['name']; $album = $_POST['album']; $filename = generate_filename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], ROOT . "files/{$filename}")) { photos_insert($name, '', $filename, $cur_user['id'], $album); header('location: ' . WEB); exit; } } } else { require MODELS . "albums.php"; $albums = albums_getByUser($cur_user); if (isset($_GET['albumId'])) { $album_id = $_GET['albumId']; } else { $album_id = -100500; } require VIEWS . "upload.php"; } } else { header('location:' . WEB . '/login'); } }
function albums_showByUser($id) { require MODELS . 'users.php'; require MODELS . 'albums.php'; $cur_user = users_getById($id); if ($cur_user === false) { header('location:' . WEB); } else { $albums = albums_getByUser($cur_user); require VIEWS . 'show_albums.php'; } }