2024-07-05 11:51:14 +03:00
|
|
|
<?php
|
|
|
|
|
2024-07-06 09:57:51 +03:00
|
|
|
namespace App\Controllers\Api\Images\Comments;
|
2024-07-05 11:51:14 +03:00
|
|
|
|
|
|
|
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, Files, Shell};
|
|
|
|
use App\Models\Notification;
|
|
|
|
|
2024-07-06 09:57:51 +03:00
|
|
|
class Create
|
2024-07-05 11:51:14 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static function create($content, $id)
|
|
|
|
{
|
2024-10-08 21:42:55 +03:00
|
|
|
DB::query('INSERT INTO photos_comments VALUES (\'0\', :userid, :postid, :postbody, :time, :content)', array('postid' => $_POST['id'], ':postbody' => $_POST['wtext'], ':userid' => Auth::userid(), ':time' => time(), ':content'=>''));
|
2024-07-05 11:51:14 +03:00
|
|
|
}
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$id = $_POST['id'];
|
|
|
|
$postbody = $_POST['wtext'];
|
|
|
|
if ((int)$id === DB::query('SELECT id FROM photos WHERE id=:id', array(':id' => $id))[0]['id']) {
|
|
|
|
|
|
|
|
|
|
|
|
$content = Json::return(
|
|
|
|
array(
|
|
|
|
'type' => 'none',
|
|
|
|
'by' => 'user'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (strlen($postbody) < 4096 || strlen($postbody) > 1) {
|
|
|
|
if (trim($postbody) != '') {
|
|
|
|
$postbody = ltrim($postbody);
|
|
|
|
echo json_encode(
|
|
|
|
array(
|
|
|
|
'errorcode' => '0',
|
|
|
|
'error' => 0
|
|
|
|
)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
die(json_encode(
|
|
|
|
array(
|
|
|
|
'errorcode' => '1',
|
|
|
|
'error' => 1
|
|
|
|
)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
die(json_encode(
|
|
|
|
array(
|
|
|
|
'errorcode' => '1',
|
|
|
|
'error' => 1
|
|
|
|
)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
self::create($content, $id);
|
|
|
|
} else {
|
|
|
|
die(json_encode(
|
|
|
|
array(
|
|
|
|
'errorcode' => '1',
|
|
|
|
'error' => 1
|
|
|
|
)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|