Skip to content
This repository was archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Fix errors.
Browse files Browse the repository at this point in the history
Security fix.
Add PHPDoc blocks.
  • Loading branch information
ostiwe committed Feb 15, 2020
1 parent 9bb21df commit 9d4c5e5
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
"type": "vcs",
"url": "https://github.com/ostiwe/vksaver.git"
}
]
}
],
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*"
}
}
31 changes: 30 additions & 1 deletion src/ostiwe-saver/Client/UserClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,44 @@

class UserClient
{
/**
* Access user token
* @var string $userToken
*/
private $userToken = null;

/**
* User ID
* @var string|int $userId
* */
private $userId = null;

/**
* Array of arrays whose keys are group IDs
* @var array $groups
* */
private $groups = null;

/**
* ID of the community
* @var string|int $currentPubId
* */
private $currentPubId = null;

/**
* @var VKApiClient $vk
* */
private $vk = null;

/**
* @var Photos $utilsPhoto
* */
private $utilsPhoto = null;

/**
* Patch to custom handlers for communities
* @var string $handlersPatch
* */
private $handlersPatch = null;

/**
Expand Down Expand Up @@ -87,7 +115,7 @@ public function callbackHandler($callbackObj = [])
throw new Exception ('Empty message.');
}

if ($callbackObj['message']['from_id'] !== $this->userId) {
if ($callbackObj['object']['message']['from_id'] != $this->userId) {
echo 'ok';
return;
}
Expand All @@ -98,6 +126,7 @@ public function callbackHandler($callbackObj = [])
if (!isset($callbackObj['secret']) || empty($callbackObj['secret'])) {
throw new Exception ('Param "secret" is required.');
}

$groupId = $callbackObj['group_id'];
$this->currentPubId = $groupId;
if (($this->groups[$groupId]['secret'] !== $callbackObj['secret']) && $callbackObj['type'] !== 'browser_plugin') {
Expand Down
26 changes: 26 additions & 0 deletions src/ostiwe-saver/Handlers/PubHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,39 @@

class PubHandler
{
/**
* Access user token
* @var string $userToken
* */
public $userToken = null;

/**
* User ID
* @var string|int $userId
* */
public $userId = null;

/**
* A community token allows working with API on behalf of a group, event or public page
* @var string $pubToken
* */
public $pubToken = null;

/**
* Pub ID
* @var string|int $pubId
* */
public $pubId = null;


/**
* @var VKApiClient $vk
* */
public $vk = null;

/**
* @var Wall $utilsWall
* */
public $utilsWall = null;

/**
Expand Down
14 changes: 12 additions & 2 deletions src/ostiwe-saver/Utils/Photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
class Photos
{
/**
* @var VKApiClient|null
* @var VKApiClient|null $vk
*/
private $vk = null;

/**
* User ID
* @var string|int $userId
* */
private $userId = null;

/**
Expand All @@ -42,7 +47,12 @@ public function __construct($userId)
*
* @param string $userToken Access user token
* @param array $photoIds An array consisting of identifiers that represent the IDs of the users who posted the photos,
* and the IDs of the photos themselves, going through the underscore (example: [1_129207899,6492_135055734] )
* and the IDs of the photos themselves, going through the underscore, example:
*
* <code>
* $photoIds = [1_129207899,6492_135055734]
* </code>
*
* @return array Array containing paths to images
* @throws Exception
*/
Expand Down
3 changes: 3 additions & 0 deletions src/ostiwe-saver/Utils/Wall.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

class Wall
{
/**
* @var VKApiClient $vk
* */
private $vk = null;

/**
Expand Down

0 comments on commit 9d4c5e5

Please sign in to comment.