Example #1
0
    function delete()
    {
        $translator = new Translator();
        $request = new Request();
        try {
            $id = array_shift($this->param);
            $request->delete($id, $data);
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->Request_deleted}</h1>
      </div>
   <p class="lead">{$translator->Request_deleted_Desc}</p>
      <p >{$translator->Error_Backrequests}</p>
</div>
<script type="text/javascript">
window.location.href='/admin_requests';
</script>

EOF;
        } catch (Exception $e) {
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->Request_error}</h1>
      </div>
   <p class="lead">{$translator->Request_error_Desc}</p>
      <p >{$translator->Error_Backrequests}</p>
</div>

EOF;
        }
    }
Example #2
0
 /**
  * remove indexed node
  *
  * @throws \Neo4j\Exception\HttpException
  *
  * @param \Neo4j\Node $node
  * @param string $key
  * @param string $value
  *
  * @return void
  */
 public function remove(Node $node, $key, $value)
 {
     $this->_uri = $this->_db->getBaseUri() . 'index/node/' . $key . '/' . $value . '/' . $node->getId();
     list($response, $http_code) = Request::delete($this->_uri);
     if ($http_code != 204) {
         throw new \Neo4j\Exception\HttpException($http_code);
     }
 }
Example #3
0
 /**
  * delete current node
  *
  * @throws \Neo4j\Exception\HttpException
  * @return void
  */
 public function delete()
 {
     if (!$this->_is_new) {
         list($response, $http_code) = Request::delete($this->getUri());
         if ($http_code != 204) {
             throw new \Neo4j\Exception\HttpException("http code: " . $http_code . ", response: " . print_r($response, true));
         }
         $this->_id = null;
         $this->_id_new = true;
     }
 }
Example #4
0
 /**
  * @transaction
  *
  * @param int $userId ユーザID
  *
  * @return Logics_Result
  */
 public function destroy($userId)
 {
     $result = new Logics_Result();
     $aUser = new User($userId);
     if ($aUser->isSelected()) {
         $or = new Sabel_Db_Condition_Or();
         $or->add(C::create(C::EQUAL, "user_id", $aUser->id));
         $or->add(C::create(C::EQUAL, "request_id", $aUser->id));
         $request = new Request();
         $request->delete($or);
         $or = new Sabel_Db_Condition_Or();
         $or->add(C::create(C::EQUAL, "user_id", $aUser->id));
         $or->add(C::create(C::EQUAL, "follow_id", $aUser->id));
         $follower = new Follower();
         $follower->delete($or);
         $status = new Status();
         $status->delete("user_id", $userId);
         $aUser->save(array("delete_flag" => true));
     }
     return $result;
 }
                Session::flash('alerts', array('info' => array('type' => 'success', 'title' => 'Request Accepted'), 'alerts' => array("You are now friends with {$friendName}.")));
            } catch (Exception $e) {
                die($e->getMessage());
            }
        }
        //}
    } else {
        if (isset($_POST['delete_friend_request'])) {
            //if(Token::check(Input::get('token'))) {
            $friend = new User($_POST['friend']);
            $fid = $friend->data()->id;
            $friendName = $friend->data()->firstName . ' ' . $friend->data()->middleName . ' ' . $friend->data()->lastName;
            if (!$user->isFriend($fid) && $user->getFriendRequests($fid)) {
                try {
                    $request = new Request();
                    $request->delete('friend', array('uid' => $user->data()->id, 'fid' => $fid));
                    Session::flash('alerts', array('info' => array('type' => 'success', 'title' => 'Request Deleted'), 'alerts' => array("You deleted {$friendName}'s friend request.")));
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
            //}
        }
    }
}
?>

<!DOCTYPE html>
<html>
	<head>
		<title>Friend Requests</title>
Example #6
0
 public static function delete($id)
 {
     return Request::delete("beers/" . $id);
 }
Example #7
0
 /**
  * @param int $userId      リクエストされたユーザのID
  * @param int $requestorId リクエストしたユーザのID
  *
  * @return Logics_Result
  */
 public function deny($userId, $requestorId)
 {
     $result = new Logics_Result();
     $aUser = new User($userId);
     $requestor = new User($requestorId);
     if ($aUser->isActive() && $requestor->isActive()) {
         $request = new Request();
         $request->setCondition("user_id", $requestor->id);
         $request->setCondition("request_id", $aUser->id);
         $request->delete();
     } else {
         $result->failure();
     }
     return $result;
 }
Example #8
0
 private function _executeDelete($resource, $requiresToken = true)
 {
     if ($requiresToken) {
         $this->requiresToken();
     }
     $request = new Request($this->_url, $this->getToken());
     $content = $request->delete($resource);
     return $this->_jsonDecode($content);
 }
Example #9
0
 public function addFriend($fid)
 {
     $uid = $this->data()->id;
     $request = new Request();
     $requestInfo = array('uid' => $uid, 'fid' => $fid);
     if ($request->delete('friend', $requestInfo)) {
         $timestamp = date('Y-m-d H:i:s');
         $fields = array('uid' => $uid, 'fid' => $fid, 'timestamp' => $timestamp);
         if (!$this->_db->insert('friends', $fields)) {
             throw new Exception('There was a problem adding friend');
         }
         $id = $this->_db->get('friends', "uid = '{$uid}' AND fid = '{$fid}'")->first()->id;
         $fields2 = array('uid' => $fid, 'fid' => $uid, 'timestamp' => $timestamp);
         if (!$this->_db->insert('friends', $fields2)) {
             $this->_db->delete('friends', "id = '{$id}'");
             throw new Exception('There was a problem adding friend');
         }
         $notification = new Notification();
         $notification->set(array('uid' => $uid, 'fid' => $fid, 'type' => 'friend_added', 'timestamp' => $timestamp));
         $notification->set(array('uid' => $fid, 'fid' => $uid, 'type' => 'friend_added', 'timestamp' => $timestamp));
         return true;
     }
     return false;
 }
 public function logout()
 {
     Request::delete('cookie', 'connection_user');
     Request::delete('cookie', 'connection_token');
 }
Example #11
0
 function logout()
 {
     Request::delete('cookie', 'auth');
     return true;
 }
Example #12
0
<?php

session_start();
if (!isset($_SESSION['admin_user_id']) || !$_SESSION['admin_user_id'] || !isset($_SESSION['admin_username'])) {
    exit;
}
if (!isset($_POST['request_id']) || !$_POST['request_id']) {
    exit;
}
require_once "../../vars.php";
require_once "../../includes/request.class.php";
$request = new Request();
$request->delete($_POST['request_id']);
Example #13
0
function testSendDelete()
{
    $response = Request::delete(TEST_URL)->expects(Mime::JSON)->sendIt();
    assert(Http::DELETE === $response->body->requestMethod);
}
Example #14
0
 public static function delete($id)
 {
     return Request::delete("breweries/" . $id);
 }
Example #15
0
 // Start Transaction so if the daemon errors we can rollback changes
 ORM::get_db()->beginTransaction();
 $node = ORM::forTable('nodes')->findOne($core->server->getData('node'));
 $ports = json_decode($node->ports, true);
 $ips = json_decode($node->ips, true);
 $ports[$core->server->getData('server_ip')][$core->server->getData('server_port')]++;
 $ips[$core->server->getData('server_ip')]['ports_free']++;
 $node->ips = json_encode($ips);
 $node->ports = json_encode($ports);
 $node->save();
 ORM::forTable('subusers')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('permissions')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('downloads')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('servers')->where('id', $core->server->getData('id'))->deleteMany();
 try {
     $unirest = Request::delete("https://" . $core->server->nodeData('fqdn') . ":" . $core->server->nodeData('daemon_listen') . "/server", array('X-Access-Token' => $core->server->nodeData('daemon_secret'), 'X-Access-Server' => $core->server->getData('hash')));
     if ($unirest->code !== 204) {
         throw new Exception('<div class="alert alert-danger">Scales returned an error when trying to process your request. Scales said: ' . $unirest->raw_body . ' [HTTP/1.1 ' . $unirest->code . ']</div>');
     }
     ORM::get_db()->commit();
     $service->flash('<div class="alert alert-success">The requested server has been deleted from PufferPanel.</div>');
     $response->redirect('/admin/server')->send();
 } catch (Exception $e) {
     Debugger::log($e);
     if ($request->param('force') && $request->param('force') === "force") {
         ORM::get_db()->commit();
         $service->flash('<div class="alert alert-danger">An error was encountered with the daemon while trying to delete this server from the system. <strong>Because you requested a force delete this server has been removed from the panel regardless of the reason for the error. This server and its data may still exist on the Scales instance.</strong></div>');
         $response->redirect('/admin/server')->send();
         return;
     }
     ORM::get_db()->rollBack();
Example #16
0
/**
 * Sends an HTTP DELETE request.
 *
 * Uses HTTP DELETE request to get contents a $url
 * @param string $url The URL that should be opnened.
 * @param bool $authbool If true then send sessioninformation in header.
 * @param string $message The Response Message e.g. 404. Argument is optional.
 * @param bool $sessiondelete If true then send a new timestamp. Only necessary
 * if $authbool true.
 */
function http_delete($url, $authbool, &$message = 0, $sessiondelete = false)
{
    $answer = Request::delete($url, array(), '', $authbool);
    if (isset($answer['status'])) {
        $message = $answer['status'];
    }
    if ($message == "401" && $sessiondelete == false) {
        Authentication::logoutUser();
    }
    return isset($answer['content']) ? $answer['content'] : '';
}