Beispiel #1
0
 /**
  *function get_steam_connector:
  *
  */
 public function get_steam_connector()
 {
     return steam_connector::get_instance($this->steam_connectorID);
 }
Beispiel #2
0
 /**
  * function decode_data
  *
  * @param $command
  *
  * @return
  */
 function decode_data(&$command)
 {
     //echo "decode_data<br>";
     $typ = $command[0];
     switch ($typ) {
         case CMD_TYPE_INT:
             $newdata = $this->mybin2dec(substr($command, 1, 4));
             $command = substr($command, 5);
             break;
         case CMD_TYPE_FLOAT:
             $tmp = unpack("f*", strrev(substr($command, 1, 4)));
             $newdata = $tmp[1];
             $command = substr($command, 5);
             //echo $newdata . "<br />";
             break;
         case CMD_TYPE_STRING:
             $length = (string) hexdec(bin2hex(substr($command, 1, 4)));
             $newdata = substr($command, 5, $length);
             $command = substr($command, 5 + $length);
             break;
         case CMD_TYPE_OBJECT:
             $newdata = steam_factory::get_object($this->steam_connectorID, hexdec(bin2hex(substr($command, 1, 4))), hexdec(bin2hex(substr($command, 5, 4))));
             $command = substr($command, 9);
             break;
         case CMD_TYPE_ARRAY:
             $count = hexdec(bin2hex(substr($command, 1, 2)));
             $command = substr($command, 3);
             if ($count <= 0) {
                 $newdata = array();
             } else {
                 for ($i = 0; $i < $count; $i++) {
                     $value = $this->decode_data($command);
                     $newdata[$i] = $value;
                 }
             }
             //for($i = 0; $i < $count; $i++)
             break;
         case CMD_TYPE_MAPPING:
             $count = hexdec(bin2hex(substr($command, 1, 2)));
             $command = substr($command, 3);
             if ($count <= 0) {
                 $newdata = array();
             } else {
                 for ($i = 0; $i < $count; $i++) {
                     $key = $this->decode_data($command);
                     $value = $this->decode_data($command);
                     if (is_object($key)) {
                         $newdata[$key->get_id()] = $value;
                     } else {
                         if (is_array($key)) {
                             $newdata[] = $value;
                         } else {
                             $newdata[$key] = $value;
                         }
                     }
                 }
             }
             //for($i = 0; $i < $count; $i++)
             break;
         case CMD_TYPE_PROGRAM:
             $newdata = "type program not yet implemented";
             break;
         case CMD_TYPE_TIME:
             $newdata = (int) hexdec(bin2hex(substr($command, 1, 4)));
             $command = substr($command, 5);
             break;
         case CMD_TYPE_FUNCTION:
             $length = hexdec(bin2hex(substr($command, 1, 4)));
             $fname = substr($command, 13, $length - 8);
             $newdata = new steam_function($fname);
             $command = substr($command, 5 + $length);
             break;
         default:
             throw new steam_exception(steam_connector::get_instance($this->steam_connectorID)->get_login_user_name(), "COAL support in PHP not yet implemented for object type=" . $typ . " command=" . $command, 120);
             $newdata = "COAL support in PHP not yet implemented for object type=" . $typ . " command=" . $command;
             break;
     }
     //switch ($typ)
     return $newdata;
 }
Beispiel #3
0
 /**
  * function create_user:
  *
  * Creates a new user and returns its activation code
  *
  * Please keep in mind, that you will need extended rights
  * to execute this function, that means a steam_connector
  * with an administrator login.
  *
  * Suggestion: Divide the registration and activation
  * process, if you want to be sure about the existence
  * of the user's e-mail-address; send the activation-code
  * via e-mail...
  *
  * Example for registration and activation:
  * <code>
  * $activation_code = steam_factory::create_user(
  *		$steam_con,
  *		"nbates",
  *		"mother",
  *		"*****@*****.**",
  *		"Norman",
  *		"Bates",
  *		"english"
  * 		);
  * if ( $activation_code )
  * {
  *	$new_user = steam_factory::username_to_object( "nbates" );
  *	$new_user->set_attributes(
  *		array(
  *			"country" => "United States",
  *			"occupation" => "motel keeper"
  *		)
  *	);
  *	if ( $new_user->activate( $activation_code ) )
  *	{
  *		print( "Bates, you can login now!" );
  *	}
  * }
  * else
  * {
  *	print( "Login name exists. Choose another one." );
  * }
  * </code>
  *
  * @see steam_user->activate()
  * @param steam_connector $pSteamConnector connection to sTeam-server, for creating new users you will need extended rights
  * @param string $pLogin user's login name
  * @param string $pPassword user's password
  * @param string $pEMail user's email
  * @param string $pFullname user's surname
  * @param string $pFirstname user's firstname
  * @param string $pLanguage user's prefered language (optional)
  * @return string activation code; needed to activate this login
  */
 public static function create_user($pSteamConnectorID, $pLogin, $pPassword, $pEMail, $pFullname, $pFirstname, $pLanguage = "english")
 {
     if (!is_string($pSteamConnectorID)) {
         throw new ParameterException("pSteamConnectorID", "string");
     }
     $new_user = steam_factory::create_object($pSteamConnectorID, $pLogin, CLASS_USER, FALSE, array("name" => (string) $pLogin, "pw" => (string) $pPassword, "email" => (string) $pEMail, "fullname" => (string) $pFullname, "firstname" => (string) $pFirstname, "language" => (string) $pLanguage));
     if ($new_user) {
         $factories = steam_connector::get_instance($pSteamConnectorID)->get_login_data()->get_arguments();
         $user_factory = $factories[9][CLASS_USER];
         $activation_code = steam_connector::get_instance($pSteamConnectorID)->predefined_command($user_factory, "get_activation", array(), 0);
         return $activation_code;
     } else {
         return FALSE;
     }
 }
Beispiel #4
0
 /**
  *function set_name:
  *
  *@param $pName
  *@param $pBuffer
  *
  *@return
  */
 public function set_name($pName, $pBuffer = FALSE)
 {
     $myConnector = steam_connector::get_instance($this->steam_connectorID);
     return $this->steam_command($myConnector->get_factory(CLASS_GROUP), "rename_group", array($this, $pName), $pBuffer);
 }