Answer the question
In order to leave comments, you need to log in
Authorization on Joomla?
I'm trying to authorize the joomla post admin panel with a request using the xNet library. but the result is nothing. who knows how to do it right?
here is the code
using (var request = new HttpRequest())
{
var get = request.Get("http://mysit.ru/administrator/index.php").ToString();
var newReg = new Regex("type=\"hidden\" name=\"(.*?)\" value=\"1\"");
var matches = newReg.Matches(get);
var token = matches.Count > 0 ? matches[0].Value : string.Empty;
if (token.Length > 0)
{
var startToken = token.IndexOf("name=\"", 0, token.Length, StringComparison.Ordinal);
var endToken = token.IndexOf("\" value", 0, token.Length, StringComparison.Ordinal);
token = token.Substring(startToken + "name=\"".Length,
token.Length - (startToken + "name=\"".Length + (token.Length - endToken)));
}
newReg = new Regex("type=\"hidden\" name=\"return\" value=\"(.*?)\"");
matches = newReg.Matches(get);
var _return = matches.Count > 0 ? matches[0].Value : string.Empty;
if (_return.Length > 0)
{
var startReturn = _return.IndexOf("value=\"", 0, _return.Length, StringComparison.Ordinal);
_return = _return.Substring(startReturn + "value=\"".Length,
_return.Length - (startReturn + "value=\"".Length + 1));
}
var reqParams = new RequestParams();
reqParams["username"] = userName;
reqParams["passwd"] = password;
reqParams["option"] = "com_login";
reqParams["task"] = "login";
reqParams["return"] = _return;
reqParams[token] = "1";
request.AllowAutoRedirect = false;
request.UserAgent = Http.FirefoxUserAgent();
var response = request.Post(@"http://mysit.ru/administrator/index.php", reqParams);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question