예제 #1
0
function delete_folder($folderID, $username, $path = "")
{
    include $path . 'conn.php';
    include $path . 'config.inc.php';
    $resultArr = array();
    $resultArr['message'] = "";
    $resultArr['success'] = false;
    if ($folderID != null) {
        //delete the whole subtree
        //get all the folder ids in the subtree
        $folderids = array();
        $bookids = array();
        function countfolders($folderid, $uname, &$folderids, &$bookids, $path = "")
        {
            include $path . 'conn.php';
            $Query = "select id from " . TABLE_PREFIX . "favourites where folderid='{$folderid}'";
            //echo($Query . "<br>\n");
            $dbResult = $dblink->query($Query);
            while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
                $rowid = "{$row["id"]}";
                $bookids[] = $rowid;
            }
            $Query = "select id from " . TABLE_PREFIX . "folders where pid='{$folderid}'";
            //echo($Query . "<br>\n");
            $dbResult = $dblink->query($Query);
            $nb = 0;
            while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
                $rowid = "{$row["id"]}";
                $folderids[] = $rowid;
                $nb++;
                $nb += countfolders($rowid, $uname, $folderids, $bookids, $path);
            }
            return $nb;
        }
        $nbfolders = countfolders($folderID, $username, $folderids, $bookids, $path);
        //delete all the subtree
        foreach ($folderids as $folderid) {
            $Query = "delete from " . TABLE_PREFIX . "folders where id='" . $folderid . "'";
            //echo($Query . "<br>\n");
            $AffectedRows = $dblink->exec($Query);
            if ($AffectedRows != 1) {
                $resultArr['message'] = T_("There has been a problem when deleting a folder");
            }
        }
        foreach ($bookids as $bookID) {
            if (TAGS) {
                require_once $path . 'includes/tags_functions.php';
                $public = checkIfPublic($bookID);
                if ($public) {
                    //Remove (unstore) all the tags attached to this bookmark in table tags_books
                    unstoreTags($bookID);
                }
            }
            $Query = "delete from " . TABLE_PREFIX . "favourites where id='" . $bookID . "'";
            //echo($Query . "<br>\n");
            $AffectedRows = $dblink->exec($Query);
            if ($AffectedRows != 1) {
                $resultArr['message'] = T_("There has been a problem when deleting a bookmark");
            }
        }
        //delete the folder itself when subtree deleted
        $Query = "delete from " . TABLE_PREFIX . "folders where id='" . $folderID . "'";
        //echo($Query . "<br>\n");
        $AffectedRows = $dblink->exec($Query);
        if ($AffectedRows == 1) {
            $resultArr['message'] = T_("You have successfully deleted this folder");
            $resultArr['success'] = true;
        } else {
            $resultArr['message'] = T_("There has been a problem when deleting the folder");
        }
    }
    return $resultArr;
}
예제 #2
0
            //echo($Query . "<br>\n");
            $dbResult = $dblink->query($Query);
            $found = false;
            if ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
                $title = "{$row["title"]}";
                $url = "{$row["url"]}";
                $description = "{$row["description"]}";
                $found = true;
            }
            //strip out html
            $title = filter($title);
            $description = filter($description);
            $url = filter($url);
            if (TAGS) {
                require_once 'includes/tags_functions.php';
                $public = checkIfPublic($id);
                if ($public) {
                    $checkedStr = "checked=\"checked\"";
                    //Return all tags for this bookmark
                    $strTags = returnAllTags($id);
                } else {
                    $readOnlyTags = "readonly";
                }
            }
            if ($found && $url != null) {
                $strBack = $success ? "<< " . T_("Back to Folder") . "" : "" . T_("Cancel") . "";
                ?>
	<form action="modifyfav.php" method="post">
	<input type="hidden" name="id" value="<?php 
                echo $id;
                ?>
예제 #3
0
function deleteUserAccount($uname, $massDelete = false)
{
    global $user;
    if ($uname != null) {
        include 'conn.php';
        $Query = "delete from " . TABLE_PREFIX . "session where name='{$uname}'";
        //echo($Query . "<br>\n");
        $AffectedRows = $dblink->exec($Query);
        if ($AffectedRows == 1) {
            //Delete all books/folders from user's account
            $Query = "delete from " . TABLE_PREFIX . "folders where name='" . $uname . "' AND pid != '-1'";
            //Avoid deleting group folders
            //echo($Query . "<br>\n");
            $AffectedRows = $dblink->exec($Query);
            if ($AffectedRows >= 0) {
                if (TAGS && !$massDelete) {
                    include 'tags_functions.php';
                    //Get all the bookmark ids of this user before deleting, in order to remove the entries in table tags_books
                    $Query = "select id from " . TABLE_PREFIX . "favourites where name='" . $uname . "'";
                    $dbResult = $dblink->query($Query);
                    $strTags = "";
                    while ($row =& $dbResult->fetchRow(DB_FETCHMODE_ASSOC)) {
                        $current_id = "{$row["id"]}";
                        $public = checkIfPublic($current_id);
                        if ($public) {
                            //Remove (unstore) all the tags attached to this bookmark in table tags_books
                            unstoreTags($current_id);
                        }
                    }
                }
                $Query = "delete from " . TABLE_PREFIX . "favourites where name='" . $uname . "'";
                //echo($Query . "<br>\n");
                $AffectedRows = $dblink->exec($Query);
                if ($AffectedRows >= 0) {
                    $Query = "delete from " . TABLE_PREFIX . "activation where name='{$uname}'";
                    //echo($Query . "<br>\n");
                    $AffectedRows = $dblink->exec($Query);
                    if ($AffectedRows == 1) {
                        $success = true;
                        if ($massDelete) {
                            echo "<br>\n" . $uname . " ... deleted!";
                        } else {
                            if ($user->isAdmin()) {
                                echo "<p class=\"success\">" . sprintf(T_("%s was successfully deleted") . "</p>", $uname);
                                echo "<p><a href=\"manageusers.php\"><< " . T_("Go Back") . "</a></p>";
                            } else {
                                echo "<p class=\"success\">" . T_("You have been successfully deleted") . ".</p><p>" . sprintf(T_("Thank you for using %s"), WEBSITE_NAME) . "!</p>";
                                $_SESSION = array();
                                session_destroy();
                            }
                        }
                    } else {
                        echo "<p class=\"error\">" . T_("There has been a problem when deleting your activation code") . ".</p>";
                    }
                } else {
                    echo "<p class=\"error\">" . T_("There has been a problem when deleting bookmarks") . ".</p>";
                }
            } else {
                echo "<p class=\"error\">" . T_("There has been a problem when deleting folders") . ".</p>";
            }
        } else {
            echo "<p class=\"error\">" . T_("There has been a problem") . ".</p>";
        }
    } else {
        echo "<p class=\"error\">" . T_("The form is incomplete") . ".</p>";
    }
}
예제 #4
0
파일: comment.php 프로젝트: noikiy/owaspbwa
        //Convert line breaks to <br>
        $cMessage = nl2br($cMessage);
        if (!empty($bookmarkID) && !empty($cTitle) && !empty($cMessage)) {
            $success = addComment($bookmarkID, $cTitle, $cMessage, $username, $cParentID);
        } else {
            $msgError = T_("The form is incomplete");
        }
    } else {
        $msgError = T_("You are not logged in, or your session has expired");
    }
}
$exists = false;
$public = false;
if ($bookmarkID != null) {
    $exists = b_exists($bookmarkID);
    $public = checkIfPublic($bookmarkID);
}
if ($bookmarkID != null && $exists && $public) {
    //Get bookmark title
    $bTitle = get_btitle($bookmarkID);
    //Display bookmarks
    // Strip title if too long!
    if (strlen($bTitle) > MAX_TITLE_LENGTH) {
        $bTitle = substr($bTitle, 0, MAX_TITLE_LENGTH) . "..";
    }
    $customTitle = T_("Comments on bookmark:") . " " . $bTitle;
    include 'header.php';
    echo "<h2>" . $customTitle . "</h2>";
    if ($_POST['submitted']) {
        if ($success) {
            echo "<p class=\"success\">" . T_("Your comment has been added") . ".</p>";