Exemplo n.º 1
0
function cancelInvite($userid, $clean = true)
{
    $pool = DBModel::getInstance();
    $pool->reset('Users');
    $pool->setQualifier('userid', 'eq', $userid);
    $pool->setQualifier('lastlogin', 'eq', 0);
    if ($pool->getCount() === 0) {
        return false;
    }
    $pool->unsetQualifier('lastlogin');
    $pool->setQualifier('host', 'eq', getUserId());
    if ($pool->getCount() === 0) {
        return false;
    }
    $blogidWithOwner = User::getOwnedBlogs($userid);
    foreach ($blogidWithOwner as $blogids) {
        if (deleteBlog($blogids) === false) {
            return false;
        }
    }
    $pool->reset('Privileges');
    $pool->setQualifier('userid', 'eq', $userid);
    if ($clean && !$pool->getAll()) {
        User::removePermanent($userid);
    }
    return true;
}
Exemplo n.º 2
0
function cancelInvite($userid, $clean = true)
{
    global $database;
    requireModel('blog.user');
    if (POD::queryCell("SELECT count(*) FROM {$database['prefix']}Users WHERE userid = {$userid} AND lastlogin = 0") == 0) {
        return false;
    }
    if (POD::queryCell("SELECT count(*) FROM {$database['prefix']}Users WHERE userid = {$userid} AND host = " . getUserId()) === 0) {
        return false;
    }
    $blogidWithOwner = User::getOwnedBlogs($userid);
    foreach ($blogidWithOwner as $blogids) {
        if (deleteBlog($blogids) === false) {
            return false;
        }
    }
    if ($clean && !POD::queryAll("SELECT * FROM {$database['prefix']}Privileges WHERE userid = {$userid}")) {
        User::removePermanent($userid);
    }
    return true;
}
Exemplo n.º 3
0
     $results = getAllBlogs("all");
     break;
 case "POST":
     //action is a variable (set by the function) sent along with any variables
     $action = $_REQUEST['action'];
     switch ($action) {
         case "ADD":
             addBlog($_REQUEST);
             $results = getAllBlogs("all");
             break;
         case "UPDATE":
             updateBlog($_REQUEST);
             $results = getAllBlogs("all");
             break;
         case "DELETE":
             deleteBlog($_REQUEST['code']);
             $results = getProductsDB("all");
             break;
         case "search":
             $results = getSearchDB($_REQUEST['search']);
             break;
         default:
             //if the specified action isn't recognised set meta details
             $results["meta"]["msg"] = "action not recognised, illegal action!";
             $results["meta"]["status"] = 400;
             $results["meta"]["ok"] = false;
     }
     break;
 default:
     //if the verb isn't supported or recognised set meta details
     $results["meta"]["msg"] = "Verb not recognised or is not supported!";
Exemplo n.º 4
0
        }
    }
    if ($index === 0) {
        $errors[] = 'Please select blogs to be ' . $act_name . '!';
    } else {
        $messages[] = 'Successfully ' . $act_name . ' ' . $index . ' (selected) blogs!';
    }
}
$remove = NULL;
if (isset($_GET['a']) && $_GET['a'] != '') {
    $action = trim($_GET['a']);
    $BID = isset($_GET['BID']) && is_numeric($_GET['BID']) && blogExists($_GET['BID']) ? intval(trim($_GET['BID'])) : NULL;
    if ($BID) {
        switch ($action) {
            case 'delete':
                deleteBlog($BID);
                $messages[] = 'Blog was successfully removed!';
                $remove = '&a=delete&BID=' . $BID;
                break;
            case 'suspend':
            case 'activate':
                $status = $action == 'activate' ? 1 : 0;
                $sql = "UPDATE blog SET status = '" . $status . "' WHERE BID = " . $BID . " LIMIT 1";
                $conn->execute($sql);
                if ($conn->Affected_Rows() == 1) {
                    $messages[] = 'Blog was successfully ' . $action . 'ed!';
                } else {
                    $errors[] = 'Failed to ' . $action . ' blog!';
                }
                if ($action == 'activate') {
                    $remove = '&a=activate&BID=' . $BID;
Exemplo n.º 5
0
*/
//get action var: action|''
$action = isset($_POST['action']) ? $_POST['action'] : "";
//controls what to show in the front page
switch ($action) {
    case 'addBlog':
        addBlog();
        break;
    case 'editBlog':
        editBlog();
        break;
    case 'alterBlog':
        alterBlog();
        break;
    case 'deleteBlog':
        deleteBlog();
        break;
    default:
        homepage();
}
function addBlog()
{
    $blog = new Blog();
    $blog->storeFormValues($_POST);
    $blog->insertBlog();
}
function editBlog()
{
    $results = array();
    // User has not posted the article edit form yet: display the form
    $results['blog'] = Blog::getBlogById((int) $_POST['blogId']);
Exemplo n.º 6
0
$inputs = array();
parse_str(file_get_contents("php://input"), $_PUT);
//check POST object for variables from front end
foreach ($fields as $postKey) {
    if (isset($_PUT[$postKey])) {
        $inputs[$postKey] = $_PUT[$postKey];
    }
}
//check inputs for all required fields
foreach ($requiredFields as $postKey) {
    if (!isset($inputs[$postKey]) || empty($inputs[$postKey])) {
        return errorHandler("missing {$postKey}", 503);
    }
}
//print debug statement
if ($SERVERDEBUG) {
    echo "\r\n inputs:";
    echo json_encode($inputs);
}
//setup for query
$stmt = deleteBlog($DB, $inputs['blogid']);
if (!$stmt) {
    return;
}
// getLists already send error.
if (!$stmt->execute()) {
    return errorHandler("failed to delete this page {$stmt->errno}: {$stmt->error}", 503);
}
if ($stmt->affected_rows != 1) {
    return errorHandler("Deleted {$stmt->affected_rows} rows", 503);
}