Пример #1
0
 public static function check_owner_sub_units()
 {
     global $language;
     $clients = self::$_cid;
     $cid = self::$_cid;
     $max_request_len = 1024;
     //最大每次请求长度(受mysql单指令长度限制)
     //注:可能会超过,需要保守使用
     $query_head = 'select a.cid,a.name,b.alias,c.module from ' . self::$_mysql_ini['prefix'] . 'online_clients as a left join ' . self::$_mysql_ini['prefix'] . 'dummy as b on b.dummy=a.dummy left join ' . self::$_mysql_ini['prefix'] . 'online_module as c on c.cid=a.cid and c.module=\'' . self::$_mid . '\'' . ' where a.status=1' . ' and (';
     $query_tail = ') limit ';
     $max_request_len -= strlen($query_head) + strlen($query_tail);
     while (!empty($cid)) {
         $units = 0;
         $remain = $cid;
         $c_len = $max_request_len;
         $query = $query_head;
         $c_units = array();
         foreach ($remain as $a) {
             $q = 'a.cid=' . $a . ' or ';
             $b = strlen($q);
             if ($c_len > $b) {
                 $c_len -= $b;
                 $query .= $q;
                 $c_units[$a] = $a;
                 unset($cid[$a]);
                 $units++;
             } else {
                 break;
             }
         }
         $query = substr($query, 0, strlen($query) - 4);
         $query .= $query_tail . $units;
         $result = self::$_db->query($query);
         $i = mysqli_num_rows($result);
         if ($i) {
             for (; $i > 0; $i--) {
                 $tmp = $result->fetch_assoc();
                 unset($clients[$tmp['cid']]);
                 self::$_result[$tmp['cid']]['cid'] = $tmp['cid'];
                 self::$_result[$tmp['cid']]['mid'] = self::$_mid;
                 if (!empty($tmp['alias'])) {
                     self::$_result[$tmp['cid']]['name'] = GlobalFunc::clip_str_width($tmp['alias']);
                 } else {
                     self::$_result[$tmp['cid']]['name'] = GlobalFunc::clip_str_width($tmp['name']);
                 }
                 if (!GlobalFunc::is_sys_module_id(self::$_mid) and !$tmp['module']) {
                     self::$_result[$tmp['cid']]['lasterror'] = $language['no_mid_client'] . self::$_mid;
                     //$language['no_mid_client'];
                 }
             }
         }
     }
     foreach ($clients as $a) {
         //var_dump ($query);
         self::$_result[$a]['lasterror'] = $language['client_off_line'];
     }
     if (false === self::$_result) {
         return false;
     } else {
         return true;
     }
 }
Пример #2
0
$mac_num = count($mac);
if (!preg_match('/^[a-zA-Z0-9]{32}$/', $token) or !$mac_num or (!is_numeric($flag) or $flag <= 0 or $flag > 2147483647)) {
    repond_breath(1);
}
foreach ($mac as $a) {
    if (!preg_match('/^[a-fA-F0-9]{12}$/', $a)) {
        repond_breath(1);
    }
}
$module_num = 0;
$tmp = $module;
foreach ($tmp as $a) {
    if (!preg_match('/^[a-fA-F0-9]{32}$/', $a)) {
        repond_breath(1);
    } else {
        if (GlobalFunc::is_sys_module_id($a)) {
            unset($module[$a]);
            continue;
        }
    }
    $module_num++;
}
if (!$module_num) {
    repond_breath(1);
}
$query = 'select tid from ' . $mysql_ini['prefix'] . 'token where token = \'' . $token . '\' limit 1';
$result = $db->query($query);
if (1 === mysqli_num_rows($result)) {
    $result = $result->fetch_assoc();
    $tid = $result['tid'];
} else {