<?php
declare (strict_types = 1);
namespace ProxyPay\Pages;

use ProxyPay\Core\Page;
use ProxyPay\Traits\Log;

class Activity extends Page
{
	use Log;

	public function actionIndex()
	{
		$this->log($_REQUEST, 'activity');
		$uuid     = $_POST['clientId'];
		$activity = json_decode($_POST['activity'] ?? '');
		$status   = intval($activity->active);
		if ($activity->freeze) {
			$status = -1;
		}

		$url = str_replace(['http://', 'https://', '/'], "", $_POST['systemUrl'] ?? '');

		$this->db->pQuery("UPDATE clients set status=:status:, url=:url: WHERE `uuid`=:uuid:", [
			'status' => $status,
			'url'    => $url,
			'uuid'   => $uuid,
		]);

		return ['status' => true];
	}

}
