Change user password through webservice

You can share your Lua Scripts with everybody here.
Post Reply
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Change user password through webservice

Post by FTP »

-- Description: Change user password through webservice
-- Here is an PHP example for calling Lua webservice
-- Author: Luke
-- Date: 2010-03-10

Code: Select all

<?php

$strUrl = "http://127.0.0.1:5466/admin_webservice.html";
$strUrlParam = "?admin=demo&pass=demo123&cmd=";
$strLuaScript = <<<EOT
	local strDomain = "mydomain"
	local strUsername = "myuser"
	local strNewPass = "12345"
	local tableUser = c_GetUser(strDomain,strUsername)

	--change all the boolean values into integer values
	for k,v in pairs(tableUser) do
		if type(v) == "boolean" then
			if v == true then
				tableUser[k] = 1
			else
				tableUser[k] = 0
			end
		end
	end

	tableUser.password = strNewPass
	AddUser(strDomain,tableUser)
EOT;

$strResult = file_get_contents($strUrl.$strUrlParam.rawurlencode($strLuaScript));
print($strResult);

?>
Post Reply