Skip to content

Commit

Permalink
Too few arguments to function KunenaControllerUser::report()
Browse files Browse the repository at this point in the history
  • Loading branch information
810 committed Mar 4, 2019
1 parent f72ab45 commit 05c88e4
Showing 1 changed file with 43 additions and 42 deletions.
85 changes: 43 additions & 42 deletions src/components/com_kunena/controllers/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
class KunenaControllerUser extends KunenaController
{
/**
* @param bool $cachable cachable
* @param bool $urlparams urlparams
* @param bool $cachable cachable
* @param bool $urlparams urlparams
*
* @return \Joomla\CMS\MVC\Controller\BaseController|void
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function display($cachable = false, $urlparams = false)
Expand Down Expand Up @@ -102,7 +102,7 @@ public function search()
{
$model = $this->getModel('user');

$uri = new \Joomla\CMS\Uri\Uri('index.php?option=com_kunena&view=user&layout=list');
$uri = new Joomla\CMS\Uri\Uri('index.php?option=com_kunena&view=user&layout=list');

$state = $model->getState();
$search = $state->get('list.search');
Expand All @@ -122,8 +122,8 @@ public function search()
}

/**
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function change()
Expand Down Expand Up @@ -163,8 +163,8 @@ public function karmadown()

/**
* @return array|null
* @throws Exception
* @since Kunena
* @throws Exception
*/
public function save()
{
Expand Down Expand Up @@ -270,8 +270,8 @@ public function save()
}

/**
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function ban()
Expand Down Expand Up @@ -319,7 +319,7 @@ public function ban()
$success = $ban->save();

// Send report to stopforumspam
$this->report($user);
$this->report($user, $reason_public);
}
else
{
Expand Down Expand Up @@ -520,8 +520,8 @@ public function cancel()
}

/**
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function login()
Expand Down Expand Up @@ -560,8 +560,8 @@ public function login()
}

/**
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function logout()
Expand Down Expand Up @@ -599,8 +599,8 @@ public function logout()
* Save online status for user
*
* @return void
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function status()
Expand Down Expand Up @@ -638,8 +638,8 @@ public function status()
* Set online status text for user
*
* @return void
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
public function statusText()
Expand Down Expand Up @@ -678,8 +678,8 @@ public function statusText()
/**
* @param $karmaDelta
*
* @throws Exception
* @since Kunena
* @throws Exception
* @throws null
*/
protected function karma($karmaDelta)
Expand Down Expand Up @@ -778,8 +778,8 @@ protected function karma($karmaDelta)
/**
* @return boolean
*
* @throws Exception
* @since Kunena
* @throws Exception
*/
protected function saveUser()
{
Expand Down Expand Up @@ -945,7 +945,7 @@ protected function saveUser()
}

$username = $this->user->get('username');
$user = new \Joomla\CMS\User\User($this->user->id);
$user = new Joomla\CMS\User\User($this->user->id);

// Bind the form fields to the user table and save.
try
Expand Down Expand Up @@ -1048,8 +1048,8 @@ protected function saveProfile()
* Delete previoulsy uplaoded avatars from filesystem
*
* @return void
* @throws Exception
* @since Kunena
* @throws Exception
*/
protected function deleteOldAvatars()
{
Expand Down Expand Up @@ -1081,8 +1081,8 @@ protected function deleteOldAvatars()
/**
* Upload avatar with AJAX.
*
* @throws null
* @since 5.1
* @throws null
*/
public function upload()
{
Expand Down Expand Up @@ -1212,8 +1212,8 @@ public function removeAvatar()
* Get avatar attached to a profile with AJAX.
*
* @return void
* @throws Exception
* @since 5.1
* @throws Exception
*/
public function loadAvatar()
{
Expand Down Expand Up @@ -1342,8 +1342,8 @@ public function delfile()
/**
* Reports a user to stopforumspam.com
*
* @param $user
* @param $evidence
* @param mixed $user user
* @param string $evidence evidence
*
* @return boolean
* @since Kunena
Expand All @@ -1364,39 +1364,40 @@ protected function report($user, string $evidence)

if (!empty($ip))
{
$options = new \Joomla\Registry\Registry;
$options = new Joomla\Registry\Registry;

$transport = new \Joomla\CMS\Http\Transport\StreamTransport($options);
$transport = new Joomla\CMS\Http\Transport\StreamTransport($options);

// Create a 'stream' transport.
$http = new \Joomla\CMS\Http\Http($options, $transport);
// Create a 'stream' transport.
$http = new Joomla\CMS\Http\Http($options, $transport);

$data = 'username=' . $spammer->username . '&ip_addr=' . $ip . '&email=' . $spammer->email . '&api_key=' . $this->config->stopforumspam_key . '&evidence=' . $evidence;
$data = 'username=' . $spammer->username . '&ip_addr=' . $ip . '&email=' . $spammer->email . '&api_key=' .
$this->config->stopforumspam_key . '&evidence=' . $evidence;

$response = $http->post('https://www.stopforumspam.com/add', $data);
$response = $http->post('https://www.stopforumspam.com/add', $data);

if ($response->code == '200')
{
// Report accepted. There is no need to display the reason
$this->app->enqueueMessage(Text::_('COM_KUNENA_STOPFORUMSPAM_REPORT_SUCCESS'));
if ($response->code == '200')
{
// Report accepted. There is no need to display the reason
$this->app->enqueueMessage(Text::_('COM_KUNENA_STOPFORUMSPAM_REPORT_SUCCESS'));

return true;
}
else
{
// Report failed or refused
$reasons = array();
preg_match('/<p>.*<\/p>/', $response->body, $reasons);
return true;
}
else
{
// Report failed or refused
$reasons = array();
preg_match('/<p>.*<\/p>/', $response->body, $reasons);

// Stopforumspam returns only one reason, which is reasons[0], but we need to strip out the html tags before using it
$this->app->enqueueMessage(Text::sprintf('COM_KUNENA_STOPFORUMSPAM_REPORT_FAILED', strip_tags($reasons[0])), 'error');
// Stopforumspam returns only one reason, which is reasons[0], but we need to strip out the html tags before using it
$this->app->enqueueMessage(Text::sprintf('COM_KUNENA_STOPFORUMSPAM_REPORT_FAILED', strip_tags($reasons[0])), 'error');

return false;
}
return false;
}
}
else
{
$this->app->enqueueMessage(Text::_('COM_KUNENA_STOPFORUMSPAM_REPORT_NO_IP_GIVEN'), 'error');
$this->app->enqueueMessage(Text::_('COM_KUNENA_STOPFORUMSPAM_REPORT_NO_IP_GIVEN'), 'error');
}
}
}

0 comments on commit 05c88e4

Please sign in to comment.