function cut_off_user($id) { $status = get_user_status($id); $event = new SysEvent(); $event->setUserListById($id); if ($status == 1) { set_user_status($id, 0); $event->sendCutOn(); } else { set_user_status($id, 1); $event->sendCutOff(); } }
public function updateByUids($uids = array(), $data) { if (empty($data)) { return false; } $result = Mysql::getInstance(); $result = $result->in('id', $uids); if (array_key_exists("reboot", $data)) { unset($data['reboot']); $event = new SysEvent(); $event->setUserListById($uids); $event->sendReboot(); } if (!empty($data)) { $result = $result->update('users', $data); } if (array_key_exists("status", $data)) { $event = new SysEvent(); $event->setUserListById($uids); if ($data["status"] == 0) { $event->sendCutOn(); } else { $event->sendCutOff(); } } if (!$result) { return false; } return $this->getByUids($uids); }
public function setStatus($status) { $status = intval(!$status); if ($status == $this->profile['status']) { return; } Mysql::getInstance()->update('users', array('status' => $status), array('id' => $this->id)); $event = new SysEvent(); $event->setUserListById($this->id); if ($status == 1) { $event->sendCutOff(); } else { $event->sendCutOn(); } }
private function saveUsersData(&$form, $edit = FALSE) { if (!empty($this->method) && $this->method == 'POST') { $form->handleRequest($this->request); $data = $form->getData(); $action = isset($this->user) ? 'updateUserById' : 'insertUsers'; if (array_key_exists('password', $data) && $edit && empty($data['password'])) { unset($data['password']); } if ($form->isValid()) { $stb_groups = new \StbGroup(); $member = $stb_groups->getMemberByUid(intval($data['id'])); $id = $data['id']; if (empty($member)) { $stb_groups->addMember(array('mac' => \Middleware::normalizeMac($data['mac']), 'uid' => \Middleware::getUidByMac($data['mac']), 'stb_group_id' => $data['group_id'])); } else { $stb_groups->setMember(array('stb_group_id' => $data['group_id']), $member['id']); } $curr_fields = $this->db->getTableFields('users'); $curr_fields = $this->getFieldFromArray($curr_fields, 'Field'); $curr_fields = array_flip($curr_fields); $data = array_intersect_key($data, $curr_fields); $match = array(); if (!empty($data['expire_billing_date']) && preg_match("/(0[1-9]|[12][0-9]|3[01])([- \\/\\.])(0[1-9]|1[012])[- \\/\\.](19|20)\\d\\d/im", $data['expire_billing_date'], $match)) { $data['expire_billing_date'] = implode('-', array_reverse(explode($match[2], $data['expire_billing_date']))); } else { $data['expire_billing_date'] = 0; } if ($data['reseller_id'] == '-') { $data['reseller_id'] = NULL; } if (!empty($this->user) && array_key_exists('status', $this->user) && (int) $this->user['status'] != (int) $data['status']) { $data['last_change_status'] = FALSE; $event = new \SysEvent(); $event->setUserListById($data['id']); if ((int) $data['status'] == 0) { $event->sendCutOn(); } else { $event->sendCutOff(); } } else { unset($data['last_change_status']); } unset($data['version']); $result = call_user_func_array(array($this->db, $action), array($data, $data['id'])); if (!empty($this->postData['tariff_plan_packages'])) { $this->changeUserPlanPackages($id, $this->postData['tariff_plan_packages']); } return TRUE; } } return FALSE; }
if (preg_match("/[а-я,А-Я]/", $mac)) { _log('mac "' . $mac . '", ЛС ' . $ls . ' содержит русские буквы '); } if (strpos($mac, 'ts') !== false) { $mac = str_replace('ts', '', $mac); $ch = '00203'; } $mac = Middleware::normalizeMac($mac); if (@array_key_exists($mac, $stb_id_map)) { $stb = Stb::getByMac($mac); $status = $stb['status']; if ($status == 1 && $update_status) { Mysql::getInstance()->update('users', array('status' => 0, 'last_change_status' => 'NOW()'), array('mac' => $mac)); $event = new SysEvent(); $event->setUserListByMac($mac); $event->sendCutOn(); $cut_on++; } $stb_id = $stb_id_map[$mac]; $stb_id_arr[] = $stb_id; if (array_key_exists($ch, $service_id_map)) { if (!@array_key_exists($stb_id, $result)) { $result[$stb_id] = array(); } $result[$stb_id][] = intval($service_id_map[$ch]); } else { if ($ch == '00494' || $ch == '00674' || $ch == '00675' || $ch == '00725' || $ch == '00726' || $ch == '00746' || $ch == '00747' || $ch == '00754') { $result[$stb_id] = merge_services(!empty($result[$stb_id]) ? $result[$stb_id] : null, get_all_payed_ch_discovery()); $result[$stb_id] = merge_services(!empty($result[$stb_id]) ? $result[$stb_id] : null, get_all_hd_channels()); if ($ch == '00674' || $ch == '00675' || $ch == '00725' || $ch == '00726' || $ch == '00746' || $ch == '00747') { $add_services_on[] = $stb_id;