do_html_header('Adding bookmarks');
check_valid_user();
if (!filled_out($HTTP_POST_VARS)) {
    echo 'You have not filled out the form completely.
          Please try again.';
    display_user_menu();
    do_html_footer();
    exit;
} else {
    // check URL format
    if (strstr($new_url, 'http://') === false) {
        $new_url = 'http://' . $new_url;
    }
    // check URL is valid
    if (@fopen($new_url, 'r')) {
        // try to add bm
        if (add_bm($new_url)) {
            echo 'Bookmark added.';
        } else {
            echo 'Could not add bookmark.';
        }
    } else {
        echo 'Not a valid URL.';
    }
}
// get the bookmarks this user has saved
if ($url_array = get_user_urls($HTTP_SESSION_VARS['valid_user'])) {
}
display_user_urls($url_array);
display_user_menu();
do_html_footer();
Ejemplo n.º 2
0
require_once 'bookmark_fns.php';
session_start();
//create short variable name
$new_url = $_POST['new_url'];
do_html_header('Adding bookmarks');
try {
    check_valid_user();
    if (!filled_out($_POST)) {
        throw new Exception('Form not completely filled out.');
    }
    // check URL format
    if (strstr($new_url, 'http://') === false) {
        $new_url = 'http://' . $new_url;
    }
    // check URL is valid
    if (!@fopen($new_url, 'r')) {
        throw new Exception('Not a valid URL.');
    }
    // try to add bm
    add_bm($new_url);
    echo 'Bookmark added.';
    // get the bookmarks this user has saved
    if ($url_array = get_user_urls($_SESSION['valid_user'])) {
        display_user_urls($url_array);
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
display_user_menu();
do_html_footer();
Ejemplo n.º 3
0
session_start();
$username = $_SESSION["valid_user"];
$bookmark = $_POST["newbm"];
do_html_header("Adding bookmarks");
//use try catch when you think the whole process is a little risky and heaps of possible errors
try {
    check_valid_user();
    //cant forget this right?
    if (!filled_out($_POST)) {
        throw new Exception("Form not completely filled out.");
    }
    //check URL format
    if (strstr($bookmark, "http://") === false) {
        $bookmark = "http://" . $bookmark;
    }
    //check URL is valid
    if (!@fopen($bookmark, "r")) {
        throw new Exception("Not a valid URL");
    }
    //try to add BM
    add_bm($bookmark);
    echo "Bookmark added";
    //get the bookmarks this user has saved
    if ($url_array = get_user_urls($_SESSION["valid_user"])) {
        display_user_urls($url_array);
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
display_user_menu();
do_html_footer();