public function set_current_theme() { if (!$this->isAjax || $this->method != 'POST' || empty($this->postData['themename'])) { $this->app->abort(404, 'Page not found...'); } if ($no_auth = $this->checkAuth()) { return $no_auth; } $data = array(); $data['action'] = 'manageTheme'; $error = $this->setlocalization('There is no such skin'); $data['name'] = $data['title'] = $data['preview'] = ''; $themes = \Middleware::getThemes(); if (!empty($themes) && in_array($this->postData['themename'], $themes)) { $this->db->setCurrentTheme($this->postData['themename']); $error = ''; $event = new \SysEvent(); $event->setUserListByMac('online'); $event->sendReboot(); $data['name'] = $this->postData['themename']; $data['title'] = ucwords(str_replace('_', ' ', $this->postData['themename'])); $data['preview'] = $this->theme_path . $this->postData['themename'] . "/preview.png"; } $response = $this->generateAjaxResponse($data, $error); return new Response(json_encode($response), empty($error) ? 200 : 500); }
/** * Update EPG from all EPG setting records. * * @param bool $force * @return string */ public function updateEpg($force = false) { $this->settings = $this->getSettings(); $result = ''; foreach ($this->settings as $setting) { $result .= $this->updateEpgBySetting($setting, $force); $result .= "\n"; } $event = new SysEvent(); $event->setUserListByMac('online'); $event->sendUpdateEpg(); return $result; }
public function create(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); if (empty($stb_list)) { throw new RESTCommandException('Empty stb list'); } $msg = $request->getData("msg"); if (empty($msg)) { throw new RESTCommandException('Empty msg'); } $event = new SysEvent(); $ttl = (int) $request->getData("ttl"); if (!empty($ttl)) { $event->setTtl($ttl); } $auto_hide_timeout = (int) $request->getData('auto_hide_timeout'); if ($auto_hide_timeout) { $event->setAutoHideTimeout($auto_hide_timeout); } $event->setUserListById($stb_list); $event->sendMsg($msg); return true; }
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; }
<?php include "./common.php"; if (Config::getSafe('enable_internal_billing', false) && Config::getSafe('number_of_days_to_send_message', false) !== FALSE) { $locales = array(); $allowed_locales = Config::get("allowed_locales"); $default_locale = Config::get("default_locale"); bindtextdomain('stb', PROJECT_PATH . '/locale'); textdomain('stb'); bind_textdomain_codeset('stb', 'UTF-8'); $end_billing_interval = Config::getSafe('number_of_days_to_send_message', false); $users = Mysql::getInstance()->select(array('id', '(TO_DAYS(`expire_billing_date`) - TO_DAYS(NOW())) as `end_billing_days`', 'locale'))->from("`users`")->where(array("(TO_DAYS(`expire_billing_date`) - TO_DAYS(NOW())) <= {$end_billing_interval} AND CAST(`expire_billing_date` AS CHAR) <> '0000-00-00 00:00:00' AND 1=" => 1, 'status' => 0))->get()->all(); $event = new SysEvent(); $event->setTtl(86340); $msg_more = 'Dear Subscriber! Your payment term will expire in "%s" days. Please refill a personal account in order to avoid tripping of services.'; $msg_today = "Dear Subscriber! Your payment term will expire today. Please refill a personal account in order to avoid tripping of services."; $msg = ''; $locale = $default_locale; foreach ($users as $user) { $current_local = setlocale(LC_MESSAGES, 0); $event->setUserListById($user['id']); if (in_array($user['locale'], $allowed_locales)) { $locale = $user['locale']; } else { $locale = $default_locale; } putenv("LC_MESSAGES={$locale}"); putenv("LANGUAGE={$locale}"); setlocale(LC_MESSAGES, $locale); $msg = $user['end_billing_days'] > 0 ? sprintf(_($msg_more), $user['end_billing_days']) : _($msg_today); $event->sendMsg($msg);
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(); } }
$sub = array_unique($sub); $sub_str = base64_encode(serialize($sub)); /*if (count($sub) == 18){ $bonus = array_unique(array_merge($bonus, $all_ch_bonus)); }*/ //var_dump($sub); exit; $bonus_str = base64_encode(serialize($bonus)); if (array_key_exists($uid, $subscription_map)) { $sql = "update itv_subscription set sub_ch='{$sub_str}', bonus_ch='{$bonus_str}', addtime=NOW() where uid={$uid}"; } else { $sql = "insert into itv_subscription (uid, sub_ch, bonus_ch, addtime) value ({$uid}, '{$sub_str}', '{$bonus_str}', NOW())"; } $event = new SysEvent(); $event->setUserListById($uid); $event->sendUpdateSubscription(); $event = new SysEvent(); $event->setUserListById($uid); $event->sendMsg('Каналы обновлены согласно подписке.'); $result = Mysql::getInstance()->query($sql)->result(); if ($result) { $updated++; if ((bool) Config::get('enable_subscription') && $update_fav) { $fav_channels = array_unique(array_merge($sub, $bonus, $base_channels)); //$fav_channels = array(); $data_str = base64_encode(serialize($fav_channels)); $id = Mysql::getInstance()->from('fav_itv')->where(array('uid' => $uid))->get()->first('id'); if ($id) { $sql = "update fav_itv set fav_ch='" . $data_str . "', addtime=NOW() where uid='" . $uid . "'"; } else { $sql = "insert into fav_itv (uid, fav_ch, addtime) values ('" . $uid . "', '" . $data_str . "', NOW())"; }
<?php include "./common.php"; if (Config::getSafe('enable_internal_billing', false)) { $ids = Mysql::getInstance()->from("`users`")->where(array("(TO_DAYS(`expire_billing_date`) - TO_DAYS(NOW()) - 1) < 0 AND CAST(`expire_billing_date` AS CHAR) <> '0000-00-00 00:00:00' AND 1=" => 1, 'status' => 0))->get()->all('id'); Mysql::getInstance()->update("`users`", array('status' => 1, 'last_change_status' => 'NOW()'), array(" `id` IN ('" . implode("', '", $ids) . "') AND 1=" => 1, 'status' => 0)); $online = Middleware::getOnlineUsersId(); $event = new SysEvent(); $event->setUserListById(array_intersect($ids, $online)); $event->sendCutOff(); }
$error_counter = 0; if (@$_GET['del'] == 1) { Admin::checkAccess(AdminAccess::ACCESS_DELETE); $uid = Middleware::getUidByMac(@$_GET['mac']); Mysql::getInstance()->delete('events', array('uid' => $uid)); header("Location: events.php?mac=" . @$_GET['mac']); exit; } if (!empty($_POST['user_list_type']) && !empty($_POST['event'])) { Admin::checkAccess(AdminAccess::ACCESS_CREATE); if (@$_POST['need_reboot']) { $reboot_after_ok = 1; } else { $reboot_after_ok = 0; } $event = new SysEvent(); $event->setTtl($_POST['ttl']); if (@$_POST['user_list_type'] == 'to_all') { if ($_POST['event'] == 'send_msg' || $_POST['event'] == 'send_msg_with_video') { $event->setUserListByMac('all'); $user_list = Middleware::getOnlineUsersId(); } else { $event->setUserListByMac('online'); $user_list = Middleware::getAllUsersId(); } } elseif (@$_POST['user_list_type'] == 'to_single') { $event->setUserListByMac(@$_POST['mac']); $user_list = Middleware::getUidByMac(@$_POST['mac']); $user_list = array($user_list); } elseif (@$_POST['user_list_type'] == 'by_pattern') { if (@$_POST['pattern'] == 'mag100') {
public function __construct($postData = array()) { parent::__construct(); $this->postData = $postData; }
<?php include "../common.php"; $all_channels = Mysql::getInstance()->from('itv')->where(array('status' => 1))->get()->all('id'); $all_channels = System::base64_encode(serialize($all_channels)); $result = Mysql::getInstance()->query("insert into itv_subscription (uid, sub_ch, addtime) (select id, '" . $all_channels . "' as sub_ch, now() from users) on duplicate key update sub_ch=VALUES(sub_ch)")->result(); if ($result) { $event = new SysEvent(); $event->setUserListByMac('all'); $event->sendUpdateSubscription(); }
public function add_event() { if (!$this->isAjax || $this->method != 'POST' || empty($this->postData['user_list_type']) || empty($this->postData['event'])) { $this->app->abort(404, $this->setLocalization('Page not found')); } if ($no_auth = $this->checkAuth()) { return $no_auth; } $data = array(); $data['action'] = 'addEvent'; $data['msg'] = $this->setlocalization('Added') . ' ' . $this->setlocalization('for') . ' '; $error = $this->setlocalization('Error. Event has not been added.'); $_SERVER['TARGET'] = 'ADM'; $event = new \SysEvent(); $event->setTtl($this->postData['ttl']); $get_list_func_name = 'get_userlist_' . str_replace('to_', '', $this->postData['user_list_type']); $set_event_func_name = 'set_event_' . str_replace('to_', '', $this->postData['event']); $user_list = array_intersect($this->{$get_list_func_name}($event), $this->getFieldFromArray($this->db->getUser(array(), 'ALL'), 'id')); $event->setUserListById($user_list); if ($this->{$set_event_func_name}($event, $user_list)) { $data['msg'] .= count($user_list) . ' ' . $this->setlocalization('users'); $error = ''; } $response = $this->generateAjaxResponse($data, $error); return new Response(json_encode($response), empty($error) ? 200 : 500); }
public function create(RESTRequest $request) { $stb_list = $request->getConvertedIdentifiers(); $identifiers = $request->getIdentifiers(); if (empty($stb_list) && !empty($identifiers)) { throw new RESTCommandException('STB not found'); } $event = new SysEvent(); if (empty($identifiers)) { $event->setUserListByMac('all'); } else { $event->setUserListById($stb_list); } if ($request->getData('ttl')) { $event->setTtl($request->getData('ttl')); } switch ($request->getData('event')) { case 'send_msg': if ($request->getData('need_reboot')) { $event->sendMsgAndReboot($request->getData('msg')); } else { $event->sendMsg($request->getData('msg')); } if ($request->getData('auto_hide_timeout')) { $event->setAutoHideTimeout($request->getData('auto_hide_timeout')); } break; case 'send_msg_with_video': $event->sendMsgWithVideo($request->getData('msg'), $request->getData('video')); break; case 'reboot': $event->sendReboot(); break; case 'reload_portal': $event->sendReloadPortal(); break; case 'update_channels': $event->sendUpdateChannels(); break; case 'play_channel': $event->sendPlayChannel($request->getData('channel')); break; case 'play_radio_channel': $event->sendPlayRadioChannel($request->getData('channel')); break; case 'update_image': $event->sendUpdateImage(); break; case 'cut_off': $event->sendCutOff(); break; case 'show_menu': $event->sendShowMenu(); break; default: return false; } return true; }
/** * @deprecated * @param $user_rec_id * @return bool */ public function stopAndUsrMsg($user_rec_id) { $stopped = $this->stop($user_rec_id); if ($stopped) { $user_record = Mysql::getInstance()->from('users_rec')->where(array('id' => $user_rec_id))->get()->first(); $channel = Itv::getChannelById($user_record['ch_id']); $event = new SysEvent(); $event->setUserListById($user_record['uid']); $user = User::getInstance((int) $user_record['uid']); $event->sendMsg($user->getLocalizedText('Stopped recording') . ' — ' . $user_record['program'] . ' ' . $user->getLocalizedText('on channel') . ' ' . $channel['name']); } return $stopped; }
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); }
include "./common.php"; $error = ''; Admin::checkAuth(); Admin::checkAccess(AdminAccess::ACCESS_VIEW); //echo '<pre>'; //print_r($_FILES); //print_r($_SESSION); //print_r($_POST); //echo '</pre>'; $search = @$_GET['search']; $letter = @$_GET['letter']; if (!empty($_POST['change_tariff_plan'])) { Admin::checkAccess(AdminAccess::ACCESS_EDIT); Mysql::getInstance()->update('users', array('tariff_plan_id' => intval($_POST['tariff_plan_id'])), array('id' => intval($_GET['id']))); if (Config::get('enable_tariff_plans')) { $event = new SysEvent(); $event->setUserListById(array(intval($_GET['id']))); $user = User::getInstance((int) $_GET['id']); $event->sendMsgAndReboot($user->getLocalizedText('Tariff plan is changed, please restart your STB')); } header("Location: profile.php?id=" . @$_GET['id']); exit; } if (@$_POST['save']) { Admin::checkAccess(AdminAccess::ACCESS_EDIT); $stb_groups = new StbGroup(); $member = $stb_groups->getMemberByUid(intval($_GET['id'])); if (empty($member)) { $stb_groups->addMember(array('mac' => Middleware::normalizeMac($_POST['mac']), 'uid' => Middleware::getUidByMac($_POST['mac']), 'stb_group_id' => $_POST['group_id'])); } else { $stb_groups->setMember(array('stb_group_id' => $_POST['group_id']), $member['id']);
<?php /* */ error_reporting(E_ALL); include "./common.php"; $uid_arr = Mysql::getInstance()->from('vclub_paused')->where(array('UNIX_TIMESTAMP(pause_time)<' => time() - 86400))->get()->all('uid'); if (count($uid_arr) > 0) { Mysql::getInstance()->query("delete from vclub_paused where uid in (" . implode(', ', $uid_arr) . ")"); $event = new SysEvent(); $event->setUserListById($uid_arr); $event->sendResetPaused(); } echo count($uid_arr);
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(); } }
$sub_str = base64_encode(serialize($sub)); /*if (!is_array($bonus)){ $bonus = array(); }*/ $bonus_str = base64_encode(serialize($bonus)); $itv_subscription = Mysql::getInstance()->from('itv_subscription')->where(array('uid' => $uid))->get()->first(); if (!empty($itv_subscription)) { $result = Mysql::getInstance()->update('itv_subscription', array('sub_ch' => $sub_str, 'bonus_ch' => $bonus_str, 'addtime' => 'NOW()'), array('uid' => $uid))->result(); } else { $result = Mysql::getInstance()->insert('itv_subscription', array('uid' => $uid, 'sub_ch' => $sub_str, 'bonus_ch' => $bonus_str, 'addtime' => 'NOW()'))->insert_id(); } if ($result) { $event = new SysEvent(); $event->setUserListById($uid); $event->sendUpdateSubscription(); $event = new SysEvent(); $event->setUserListById($uid); $event->sendMsg(_('Updated according to the subscription channels.')); js_redirect('profile.php?id=' . $uid, _('Subscription saved')); } else { echo _('error'); } exit; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> body {