2021-10-30 19:02:07 +02:00
|
|
|
<?php
|
|
|
|
class Log_model extends MO_Model
|
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
public function delete_combat_log($id, $villageid)
|
|
|
|
{
|
|
|
|
$sql = "SELECT * FROM combat_logs WHERE id='$id'";
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$q = $this->db->query($sql);
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$q->num_rows()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$res = $q->row_array();
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if ($res['villageid'] != $villageid) {
|
|
|
|
return;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$sql = "DELETE FROM combat_logs WHERE id='$id'";
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$this->db->query($sql);
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
public function get_combat_log($id, $villageid)
|
|
|
|
{
|
|
|
|
$sql = "SELECT * FROM combat_logs WHERE id='$id'";
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$q = $this->db->query($sql);
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$q->num_rows()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$res = $q->row_array();
|
|
|
|
|
|
|
|
if ($res['villageid'] != $villageid) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if ($res['new']) {
|
|
|
|
$sql = "UPDATE combat_logs SET new='0' WHERE id='$id'";
|
|
|
|
$this->db->query($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
2021-11-14 11:02:22 +01:00
|
|
|
|
|
|
|
public function get_combat_logs($villageid)
|
|
|
|
{
|
|
|
|
$sql = "SELECT * FROM combat_logs WHERE villageid='$villageid' ORDER BY time DESC";
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$q = $this->db->query($sql);
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$q->num_rows()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$res = $q->result_array();
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$new = false;
|
|
|
|
foreach ($res as $row) {
|
|
|
|
if ($row['new']) {
|
|
|
|
$new = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if (!$new) {
|
|
|
|
$sql = "UPDATE villages SET new_log='0' WHERE id='$villageid'";
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$this->db->query($sql);
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
return $res;
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-14 11:02:22 +01:00
|
|
|
//nowhitesp
|