芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/status.pulsehost.co.uk/app/controllers/Broadcast.php
where('broadcast_id', $parameters['broadcast_id'])->getOne('broadcasts')) { redirect(); } if(!in_array($broadcast->status, ['sent', 'processing'])) { redirect(); } $broadcast->users_ids = json_decode($broadcast->users_ids); if(!$user_id = db()->where('user_id', $parameters['user_id'])->getValue('users', 'user_id')) { redirect(); } /* Make sure the user is included in the broadcast */ if(!in_array($user_id, $broadcast->users_ids)) { redirect(); } /* Prepare for database insertion */ $type = $url ? 'click' : 'view'; $target = $url ?? null; /* Make sure the log was not already created */ $broadcast_statistic = db() ->where('broadcast_id', $parameters['broadcast_id']) ->where('user_id', $parameters['user_id']) ->where('type', $type) ->where('target', $target) ->getValue('broadcasts_statistics', 'id'); if($broadcast_statistic && $type == 'view') { return_image(); } if($broadcast_statistic && $type == 'click') { header('Location: ' . $url); die(); } if($type == 'click' && !str_contains($broadcast->content, $url)) { redirect(); } /* Insert log and update stats */ db()->insert('broadcasts_statistics', [ 'broadcast_id' => $parameters['broadcast_id'], 'user_id' => $parameters['user_id'], 'type' => $type, 'target' => $target, 'datetime' => get_date(), ]); switch($type) { case 'view': db()->where('broadcast_id', $parameters['broadcast_id'])->update('broadcasts', [ 'views' => db()->inc() ]); return_image(); break; case 'click': db()->where('broadcast_id', $parameters['broadcast_id'])->update('broadcasts', [ 'clicks' => db()->inc() ]); header('Location: ' . $url); break; } die(); } }