Skip to content

Commit

Permalink
Methods MACadd, MACdel, MAClist changed
Browse files Browse the repository at this point in the history
  • Loading branch information
fswitch committed Dec 15, 2017
1 parent b945134 commit 0de133a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
29 changes: 21 additions & 8 deletions trinity.class.5.3.php
Expand Up @@ -76,6 +76,7 @@ public static function UserUpdate($localid=0,$lastname='',$firstname='',$middlen
{
// GET /partners/user/updateuser?requestid={requestid}&partnerid={partnerid}&localid={localid}firstname={partnerid}&lastname={lastname}&middlename={middlename}&address={address}&hash={hash}
// hash = md5(requestid+partnerid+localid+firstname+lastname+middlename+address+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
return array('error'=>1,'msg'=>'No local user ID entered');
}
Expand Down Expand Up @@ -205,7 +206,8 @@ public static function SubscriptionInfo($localid=0)
*/
public static function MACadd($localid=0,$mac='')
{
// GET /partners/user/autorizemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// old (till 2017.12.15) GET /partners/user/autorizemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// GET /partners/user/autorizedevice?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&uuid={uuid}&hash={hash}
// hash = md5(requestid+partnerid+localid+mac+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -225,7 +227,8 @@ public static function MACadd($localid=0,$mac='')

$int = TrinityTV::GenInt();
$hash = md5($int.TrinityTV::PARTNERID.$localid.$mac.TrinityTV::SALT);
$uri = TRINITY_HOST.'/partners/user/autorizemac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/autorizemac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/autorizedevice?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$res = TrinityTV::_get_uri($uri);

$js = json_decode($res);
Expand Down Expand Up @@ -256,7 +259,8 @@ public static function MACadd($localid=0,$mac='')
*/
public static function MACdel($localid=0,$mac='')
{
// GET /partners/user/deletemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// old (till 2017.12.15) GET /partners/user/deletemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// GET /partners/user/deletedevice?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&uuid={uuid}&hash={hash}
// hash = md5(requestid+partnerid+localid+mac+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -276,7 +280,8 @@ public static function MACdel($localid=0,$mac='')

$int = TrinityTV::GenInt();
$hash = md5($int.TrinityTV::PARTNERID.$localid.$mac.TrinityTV::SALT);
$uri = TRINITY_HOST.'/partners/user/deletemac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/deletemac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/deletedevice?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$res = TrinityTV::_get_uri($uri);

$js = json_decode($res);
Expand Down Expand Up @@ -357,7 +362,8 @@ public static function MACcode($localid=0,$code='')
*/
public static function MAClist($localid=0)
{
// GET /partners/user/listmac?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// old (till 2017.12.15) GET /partners/user/listmac?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// GET/partners/user/devicelist?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// hash = md5(requestid+partnerid+localid+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -366,15 +372,22 @@ public static function MAClist($localid=0)

$int = TrinityTV::GenInt();
$hash = md5($int.TrinityTV::PARTNERID.$localid.TrinityTV::SALT);
$uri = TRINITY_HOST.'/partners/user/listmac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/listmac?requestid='.$int.'&partnerid='.TrinityTV::PARTNERID.'&localid='.$localid.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/devicelist?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&hash='.$hash;
$res = TrinityTV::_get_uri($uri);

$js = json_decode($res);

if (isset($js->requestid) && $js->requestid == $int && $js->result == 'success'){
if (isset($js->requestid) && $js->requestid == $int && $js->result == 'success')
{
$macs = array();
foreach ((array)$js->devices as $d){
if (!empty($d['mac'])) $macs[] = $d['mac'];
}
return array(
'error' => 0,
'macs' => (array)$js->maclist,
// 'macs' => (array)$js->maclist,
'macs' => $macs,
'msg' => ''
);
}
Expand Down
29 changes: 21 additions & 8 deletions trinity.class.php
Expand Up @@ -72,6 +72,7 @@ public static function UserUpdate($localid=0,$lastname='',$firstname='',$middlen
{
// GET /partners/user/updateuser?requestid={requestid}&partnerid={partnerid}&localid={localid}firstname={partnerid}&lastname={lastname}&middlename={middlename}&address={address}&hash={hash}
// hash = md5(requestid+partnerid+localid+firstname+lastname+middlename+address+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
return array('error'=>1,'msg'=>'No local user ID entered');
}
Expand Down Expand Up @@ -199,7 +200,8 @@ public static function SubscriptionInfo($localid=0)
*/
public static function MACadd($localid=0,$mac='')
{
// GET /partners/user/autorizemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// old (till 2017.12.15) GET /partners/user/autorizemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// GET /partners/user/autorizedevice?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&uuid={uuid}&hash={hash}
// hash = md5(requestid+partnerid+localid+mac+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -219,7 +221,8 @@ public static function MACadd($localid=0,$mac='')

$int = self::GenInt();
$hash = md5($int.self::PARTNERID.$localid.$mac.self::SALT);
$uri = TRINITY_HOST.'/partners/user/autorizemac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/autorizemac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/autorizedevice?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$res = self::_get_uri($uri);

$js = json_decode($res);
Expand Down Expand Up @@ -250,7 +253,8 @@ public static function MACadd($localid=0,$mac='')
*/
public static function MACdel($localid=0,$mac='')
{
// GET /partners/user/deletemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// old (till 2017.12.15) GET /partners/user/deletemac?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&hash={hash}
// GET /partners/user/deletedevice?requestid={requestid}&partnerid={partnerid}&localid={localid}&mac={mac}&uuid={uuid}&hash={hash}
// hash = md5(requestid+partnerid+localid+mac+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -270,7 +274,8 @@ public static function MACdel($localid=0,$mac='')

$int = self::GenInt();
$hash = md5($int.self::PARTNERID.$localid.$mac.self::SALT);
$uri = TRINITY_HOST.'/partners/user/deletemac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/deletemac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/deletedevice?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&mac='.$mac.'&hash='.$hash;
$res = self::_get_uri($uri);

$js = json_decode($res);
Expand Down Expand Up @@ -351,7 +356,8 @@ public static function MACcode($localid=0,$code='')
*/
public static function MAClist($localid=0)
{
// GET /partners/user/listmac?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// old (till 2017.12.15) GET /partners/user/listmac?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// GET/partners/user/devicelist?requestid={requestid}&partnerid={partnerid}&localid={localid}&hash={hash}
// hash = md5(requestid+partnerid+localid+salt)

if ($localid == 0 || empty($localid) || !is_numeric($localid) || (int)($localid)<1){
Expand All @@ -360,15 +366,22 @@ public static function MAClist($localid=0)

$int = self::GenInt();
$hash = md5($int.self::PARTNERID.$localid.self::SALT);
$uri = TRINITY_HOST.'/partners/user/listmac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&hash='.$hash;
// $uri = TRINITY_HOST.'/partners/user/listmac?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&hash='.$hash;
$uri = TRINITY_HOST.'/partners/user/devicelist?requestid='.$int.'&partnerid='.Self::PARTNERID.'&localid='.$localid.'&hash='.$hash;
$res = self::_get_uri($uri);

$js = json_decode($res);

if (isset($js->requestid) && $js->requestid == $int && $js->result == 'success'){
if (isset($js->requestid) && $js->requestid == $int && $js->result == 'success')
{
$macs = array();
foreach ((array)$js->devices as $d){
if (!empty($d['mac'])) $macs[] = $d['mac'];
}
return array(
'error' => 0,
'macs' => (array)$js->maclist,
// 'macs' => (array)$js->maclist,
'macs' => $macs,
'msg' => ''
);
}
Expand Down

0 comments on commit 0de133a

Please sign in to comment.