private function Cleantalk::createMsg in Anti Spam by CleanTalk 7.4
Same name and namespace in other branches
- 7.5 src/Cleantalk.php \Cleantalk::createMsg()
- 7 cleantalk.module \Cleantalk::createMsg()
- 7.2 cleantalk.module \Cleantalk::createMsg()
Create msg for cleantalk server
Parameters
type $method:
CleantalkRequest $request:
Return value
\xmlrpcmsg
3 calls to Cleantalk::createMsg()
- Cleantalk::isAllowMessage in src/
Cleantalk.php - Function checks whether it is possible to publish the message
- Cleantalk::isAllowUser in src/
Cleantalk.php - Function checks whether it is possible to publish the message
- Cleantalk::sendFeedback in src/
Cleantalk.php - Function sends the results of manual moderation
File
- src/
Cleantalk.php, line 224
Class
- Cleantalk
- Cleantalk Base class
Code
private function createMsg($method, CleantalkRequest $request) {
switch ($method) {
case 'check_message':
// Convert strings to UTF8
$request->message = $this
->stringToUTF8($request->message, $this->data_codepage);
$request->example = $this
->stringToUTF8($request->example, $this->data_codepage);
$request->sender_email = $this
->stringToUTF8($request->sender_email, $this->data_codepage);
$request->sender_nickname = $this
->stringToUTF8($request->sender_nickname, $this->data_codepage);
$request->message = $this
->compressData($request->message);
$request->example = $this
->compressData($request->example);
break;
case 'check_newuser':
// Convert strings to UTF8
$request->sender_email = $this
->stringToUTF8($request->sender_email, $this->data_codepage);
$request->sender_nickname = $this
->stringToUTF8($request->sender_nickname, $this->data_codepage);
break;
case 'send_feedback':
if (is_array($request->feedback)) {
$request->feedback = implode(';', $request->feedback);
}
break;
}
$request->method_name = $method;
//
// Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
//
foreach ($request as $param => $value) {
if (!preg_match('//u', $value)) {
$request->{$param} = 'Nulled. Not UTF8 encoded or malformed.';
}
}
return $request;
}