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;
 }
 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;
 }
Пример #3
0
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();
    }
}
Пример #4
0
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $error = sprintf(_('%s events %s sended, %s errors'), count($user_list), $_POST['event'], $error_counter) . "<br>\n" . $error;
     $event->setUserListById($user_list);
 } elseif (@$_POST['user_list_type'] == 'by_group') {
     if (intval($_POST['group_id']) > 0) {
         $stb_groups = new StbGroup();
         $user_list = $stb_groups->getAllMemberUidsByGroupId($_POST['group_id']);
     } else {
         $user_list = array();
     }
     $error = sprintf(_('%s events %s sended, %s errors'), count($user_list), $_POST['event'], $error_counter) . "<br>\n" . $error;
     $event->setUserListById($user_list);
 } elseif (@$_POST['user_list_type'] == 'by_user_list') {
     if (@$_FILES['user_list']) {
         if (is_uploaded_file($_FILES['user_list']['tmp_name'])) {
             $f_cont = file($_FILES['user_list']['tmp_name']);
             if (is_array($f_cont) && isset($f_cont[0]) && substr($f_cont[0], 0, 3) == "") {
                 $f_cont[0] = substr($f_cont[0], 3);
Пример #5
0
$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']);
    }
Пример #6
0
 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);
 }
Пример #7
0
 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;
 }
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);
    }
}
Пример #9
0
 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();
     }
 }
Пример #10
0
 $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())";
         }
         Mysql::getInstance()->query($sql);
Пример #11
0
<?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);
 /**
  * @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;
 }
<?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();
}