Plugin Directory

Changeset 1779004


Ignore:
Timestamp:
11/30/2017 08:36:39 PM (8 years ago)
Author:
viewup
Message:

add utils functions to encode and decode data

Location:
up-user-datakeeper/trunk/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • up-user-datakeeper/trunk/class/api.php

    r1778970 r1779004  
    2626    }
    2727
     28    public static function encode($data){
     29        return Utils::encode($data);
     30    }
    2831
    29 
     32    public static function decode($data){
     33        return Utils::decode($data);
     34    }
    3035}
    3136
  • up-user-datakeeper/trunk/class/utils.php

    r1778970 r1779004  
    44class Utils{
    55
    6     public function sendSuccess($obj){
     6    public static function sendSuccess($obj){
    77        return [
    88            'success' => true,
     
    1111    }
    1212
    13     public function sendError($obj){
     13    public static function sendError($obj){
    1414        return [
    1515            'success' => false,
     
    1717        ];
    1818    }
     19
     20    public static function encode($data){
     21        return base64_encode( serialize($obj) );
     22    }
     23
     24    public static function decode($data){
     25        return unserialize( base64_decode($data) );
     26    }
    1927}
    2028
Note: See TracChangeset for help on using the changeset viewer.