ShallerConnector implemented; Users migration implemented

main
Inga 🏳‍🌈 15 years ago
parent ff5fe8481e
commit 469242c4a6
  1. 2
      Builder/IISMainHandler/build.txt
  2. 10
      Builder/IISMainHandler/product.wxs
  3. 1
      Common/Common.csproj
  4. 6
      Common/Config.cs
  5. 1
      Common/actions/ChangeSet.cs
  6. 117
      Common/dataobjects/Account.cs
  7. 29
      Common/dataobjects/User.cs
  8. 26
      Core/Util.cs
  9. 8
      FLocal.sln
  10. 17
      IISMainHandler/HandlersFactory.cs
  11. 8
      IISMainHandler/IISMainHandler.csproj
  12. 31
      IISMainHandler/handlers/request/AbstractPostHandler.cs
  13. 37
      IISMainHandler/handlers/request/MigrateAccountHandler.cs
  14. 2
      IISMainHandler/handlers/response/BoardAsThread.cs
  15. 24
      IISMainHandler/handlers/response/LoginHandler.cs
  16. 43
      IISMainHandler/handlers/response/MigrateAccountHandler.cs
  17. 62
      Importer/Importer.csproj
  18. 36
      Importer/Properties/AssemblyInfo.cs
  19. 48
      Importer/ShallerConnector.cs
  20. 14
      Importer/ShallerGateway.cs
  21. BIN
      Importer/bin/Release/Importer.dll
  22. BIN
      Importer/bin/Release/Importer.pdb
  23. 5
      Importer/obj/Release/Importer.csproj.FileListAbsolute.txt
  24. BIN
      Importer/obj/Release/Importer.dll
  25. BIN
      Importer/obj/Release/Importer.pdb
  26. 65
      templates/Full/Login.xslt
  27. 44
      templates/Full/MigrateAccount.xslt
  28. 2
      templates/Full/Post.xslt
  29. 3
      templates/Full/elems/Header.xslt
  30. 25
      templates/Full/result/MigrateAccount.xslt

@ -49,6 +49,12 @@
<Component Id="IISMainHandler.pdb" Guid="4F5F1280-8EC8-4C56-80F4-8C810F0C839F"> <Component Id="IISMainHandler.pdb" Guid="4F5F1280-8EC8-4C56-80F4-8C810F0C839F">
<File Id="IISMainHandler.pdb" Source="..\..\IISMainHandler\bin\Release\IISMainHandler.pdb" KeyPath="yes" Checksum="yes"/> <File Id="IISMainHandler.pdb" Source="..\..\IISMainHandler\bin\Release\IISMainHandler.pdb" KeyPath="yes" Checksum="yes"/>
</Component> </Component>
<Component Id="Importer.dll" Guid="F25304A3-2705-4E97-B0E9-1DF04C277AD8">
<File Id="Importer.dll" Source="..\..\Importer\bin\Release\Importer.dll" KeyPath="yes" Checksum="yes"/>
</Component>
<Component Id="Importer.pdb" Guid="6AE31E67-EFC6-471B-BB55-0DF628399D35">
<File Id="Importer.pdb" Source="..\..\Importer\bin\Release\Importer.pdb" KeyPath="yes" Checksum="yes"/>
</Component>
<!--Component Id="MySql.Data.dll" Guid="90646729-6B21-4BEE-94C3-F39F5288EFB3"> <!--Component Id="MySql.Data.dll" Guid="90646729-6B21-4BEE-94C3-F39F5288EFB3">
<File Id="MySql.Data.dll" Source="..\..\ThirdParty\mysql-connector-net-6.2.3\MySql.Data\Provider\bin\Release\MySql.Data.dll" KeyPath="yes" Checksum="yes"/> <File Id="MySql.Data.dll" Source="..\..\ThirdParty\mysql-connector-net-6.2.3\MySql.Data\Provider\bin\Release\MySql.Data.dll" KeyPath="yes" Checksum="yes"/>
</Component> </Component>
@ -71,6 +77,10 @@
<ComponentRef Id='IISMainHandler.dll' /> <ComponentRef Id='IISMainHandler.dll' />
<ComponentRef Id='IISMainHandler.pdb' /> <ComponentRef Id='IISMainHandler.pdb' />
</Feature> </Feature>
<Feature Id='Importer' Title='Importer' Level='1'>
<ComponentRef Id='Importer.dll' />
<ComponentRef Id='Importer.pdb' />
</Feature>
<Feature Id='Core' Title='Core library' Level='1'> <Feature Id='Core' Title='Core library' Level='1'>
<ComponentRef Id='Core.dll' /> <ComponentRef Id='Core.dll' />
<ComponentRef Id='Core.pdb' /> <ComponentRef Id='Core.pdb' />

@ -55,6 +55,7 @@
<Compile Include="actions\ScalarFieldValue.cs" /> <Compile Include="actions\ScalarFieldValue.cs" />
<Compile Include="actions\UpdateChange.cs" /> <Compile Include="actions\UpdateChange.cs" />
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="dataobjects\Account.cs" />
<Compile Include="dataobjects\Board.cs" /> <Compile Include="dataobjects\Board.cs" />
<Compile Include="dataobjects\Category.cs" /> <Compile Include="dataobjects\Category.cs" />
<Compile Include="dataobjects\IUserSettings.cs" /> <Compile Include="dataobjects\IUserSettings.cs" />

@ -16,11 +16,17 @@ namespace FLocal.Common {
public readonly string DirSeparator; public readonly string DirSeparator;
public readonly string SaltMigration;
public readonly string SaltPasswords;
protected Config(NameValueCollection data) : base(data) { protected Config(NameValueCollection data) : base(data) {
this.InitTime = DateTime.Now.ToLongTimeString(); this.InitTime = DateTime.Now.ToLongTimeString();
this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance);
this.dataDir = data["DataDir"]; this.dataDir = data["DataDir"];
this.DirSeparator = System.IO.Path.DirectorySeparatorChar.ToString(); this.DirSeparator = System.IO.Path.DirectorySeparatorChar.ToString();
this.SaltMigration = data["SaltMigration"];
this.SaltPasswords = data["SaltPasswords"];
} }
public static void Init(NameValueCollection data) { public static void Init(NameValueCollection data) {

@ -19,6 +19,7 @@ namespace FLocal.Common.actions {
return Cache<IEnumerable<string>>.instance.get( return Cache<IEnumerable<string>>.instance.get(
tablesLockOrder_locker, tablesLockOrder_locker,
() => new List<string>() { () => new List<string>() {
"Accounts",
"Boards", "Boards",
"Threads", "Threads",
"Posts", "Posts",

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
using FLocal.Common.actions;
namespace FLocal.Common.dataobjects {
public class Account : SqlObject<Account> {
public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "Accounts";
public const string FIELD_ID = "Id";
public const string FIELD_USERID = "UserId";
public const string FIELD_PASSWORD = "Password";
public const string FIELD_NEEDSMIGRATION = "NeedsMigration";
public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } }
public void refreshSqlObject(int id) { Refresh(id); }
}
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
private int _userId;
public int userId {
get {
this.LoadIfNotLoaded();
return this._userId;
}
}
public User user {
get {
return User.LoadById(this.userId);
}
}
private string _password;
private string password {
get {
this.LoadIfNotLoaded();
return this._password;
}
}
private bool _needsMigration;
public bool needsMigration {
get {
this.LoadIfNotLoaded();
return this._needsMigration;
}
}
protected override void doFromHash(Dictionary<string, string> data) {
this._userId = int.Parse(data[TableSpec.FIELD_USERID]);
this._password = data[TableSpec.FIELD_PASSWORD];
this._needsMigration = Util.string2bool(data[TableSpec.FIELD_NEEDSMIGRATION]);
}
private static Dictionary<int, int> userid2id = new Dictionary<int, int>();
public static Account LoadByUser(User user) {
if(!userid2id.ContainsKey(user.id)) {
lock(userid2id) {
if(!userid2id.ContainsKey(user.id)) {
List<string> ids = Config.instance.mainConnection.LoadIdsByConditions(
TableSpec.instance,
new ComparisonCondition(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_USERID),
ComparisonType.EQUAL,
user.id.ToString()
),
Diapasone.unlimited,
new JoinSpec[0]
);
if(ids.Count > 1) {
throw new CriticalException("not unique");
} else if(ids.Count == 1) {
userid2id[user.id] = int.Parse(ids[0]);
} else {
throw new NotFoundInDBException();
}
}
}
}
return Account.LoadById(userid2id[user.id]);
}
public void updatePassword(string newPassword) {
using(ChangeSet changeSet = new ChangeSet()) {
changeSet.Add(
new UpdateChange(
TableSpec.instance,
new Dictionary<string, AbstractFieldValue>() {
{
TableSpec.FIELD_PASSWORD,
new ScalarFieldValue(Util.md5(newPassword + " " + Config.instance.SaltMigration + " " + this.id))
},
{
TableSpec.FIELD_NEEDSMIGRATION,
new ScalarFieldValue("0")
},
},
this.id
)
);
using(Transaction transaction = Config.instance.mainConnection.beginTransaction()) {
changeSet.Apply(transaction);
transaction.Commit();
}
}
}
}
}

@ -5,6 +5,7 @@ using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using FLocal.Core; using FLocal.Core;
using FLocal.Core.DB; using FLocal.Core.DB;
using FLocal.Core.DB.conditions;
namespace FLocal.Common.dataobjects { namespace FLocal.Common.dataobjects {
public class User : SqlObject<User> { public class User : SqlObject<User> {
@ -92,6 +93,34 @@ namespace FLocal.Common.dataobjects {
} }
} }
private static Dictionary<string, int> id2user = new Dictionary<string,int>();
public static User LoadByName(string name) {
if(!id2user.ContainsKey(name)) {
lock(id2user) {
if(!id2user.ContainsKey(name)) {
List<string> ids = Config.instance.mainConnection.LoadIdsByConditions(
TableSpec.instance,
new ComparisonCondition(
TableSpec.instance.getColumnSpec(TableSpec.FIELD_NAME),
ComparisonType.EQUAL,
name
),
Diapasone.unlimited,
new JoinSpec[0]
);
if(ids.Count > 1) {
throw new CriticalException("not unique");
} else if(ids.Count == 1) {
id2user[name] = int.Parse(ids[0]);
} else {
throw new NotFoundInDBException();
}
}
}
}
return User.LoadById(id2user[name]);
}
protected override void doFromHash(Dictionary<string, string> data) { protected override void doFromHash(Dictionary<string, string> data) {
this._regDate = new DateTime(long.Parse(data[TableSpec.FIELD_REGDATE])); this._regDate = new DateTime(long.Parse(data[TableSpec.FIELD_REGDATE]));
this._totalPosts = int.Parse(data[TableSpec.FIELD_TOTALPOSTS]); this._totalPosts = int.Parse(data[TableSpec.FIELD_TOTALPOSTS]);

@ -139,6 +139,32 @@ namespace FLocal.Core {
} }
} }
/// <summary>
/// Code sample from http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string md5(string input) {
System.Security.Cryptography.HashAlgorithm md5Hasher = System.Security.Cryptography.MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
// Return the hexadecimal string.
return sBuilder.ToString();
}
} }
} }

@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Builder", "Builder\Builder.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tmp", "tmp\tmp.csproj", "{BDC42785-41F7-4C32-880E-A6C43A448054}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tmp", "tmp\tmp.csproj", "{BDC42785-41F7-4C32-880E-A6C43A448054}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Importer", "Importer\Importer.csproj", "{E2ECF86C-C0BA-4782-A485-E267BB213BB2}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -57,6 +59,12 @@ Global
{BDC42785-41F7-4C32-880E-A6C43A448054}.Release|Any CPU.ActiveCfg = Release|Any CPU {BDC42785-41F7-4C32-880E-A6C43A448054}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDC42785-41F7-4C32-880E-A6C43A448054}.Release|Any CPU.Build.0 = Release|Any CPU {BDC42785-41F7-4C32-880E-A6C43A448054}.Release|Any CPU.Build.0 = Release|Any CPU
{BDC42785-41F7-4C32-880E-A6C43A448054}.Release|x86.ActiveCfg = Release|Any CPU {BDC42785-41F7-4C32-880E-A6C43A448054}.Release|x86.ActiveCfg = Release|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Debug|x86.ActiveCfg = Debug|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Release|Any CPU.Build.0 = Release|Any CPU
{E2ECF86C-C0BA-4782-A485-E267BB213BB2}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -20,13 +20,28 @@ namespace FLocal.IISHandler {
case "board": case "board":
return new handlers.BoardHandler(); return new handlers.BoardHandler();
case "boardasthread": case "boardasthread":
return new handlers.BoardAsThreadHandler(); return new handlers.response.BoardAsThreadHandler();
case "thread": case "thread":
return new handlers.ThreadHandler(); return new handlers.ThreadHandler();
case "post": case "post":
return new handlers.PostHandler(); return new handlers.PostHandler();
case "login":
return new handlers.response.LoginHandler();
case "migrateaccount":
return new handlers.response.MigrateAccountHandler();
case "static": case "static":
return new handlers.StaticHandler(context.requestParts); return new handlers.StaticHandler(context.requestParts);
case "do":
if(context.requestParts.Length < 2) {
return new handlers.WrongUrlHandler();
} else {
switch(context.requestParts[1].ToLower()) {
case "migrateaccount":
return new handlers.request.MigrateAccountHandler();
default:
return new handlers.WrongUrlHandler();
}
}
default: default:
return new handlers.DebugHandler(context.requestParts[0]); return new handlers.DebugHandler(context.requestParts[0]);
} }

@ -57,7 +57,11 @@
<Compile Include="handlers\BoardsHandler.cs" /> <Compile Include="handlers\BoardsHandler.cs" />
<Compile Include="handlers\DebugHandler.cs" /> <Compile Include="handlers\DebugHandler.cs" />
<Compile Include="handlers\PostHandler.cs" /> <Compile Include="handlers\PostHandler.cs" />
<Compile Include="handlers\request\AbstractPostHandler.cs" />
<Compile Include="handlers\request\MigrateAccountHandler.cs" />
<Compile Include="handlers\response\BoardAsThread.cs" /> <Compile Include="handlers\response\BoardAsThread.cs" />
<Compile Include="handlers\response\LoginHandler.cs" />
<Compile Include="handlers\response\MigrateAccountHandler.cs" />
<Compile Include="handlers\RootHandler.cs" /> <Compile Include="handlers\RootHandler.cs" />
<Compile Include="handlers\StaticHandler.cs" /> <Compile Include="handlers\StaticHandler.cs" />
<Compile Include="handlers\ThreadHandler.cs" /> <Compile Include="handlers\ThreadHandler.cs" />
@ -81,6 +85,10 @@
<Project>{6F532626-E9F8-498E-9683-1538E7CD62CB}</Project> <Project>{6F532626-E9F8-498E-9683-1538E7CD62CB}</Project>
<Name>Core</Name> <Name>Core</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Importer\Importer.csproj">
<Project>{E2ECF86C-C0BA-4782-A485-E267BB213BB2}</Project>
<Name>Importer</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Common;
namespace FLocal.IISHandler.handlers.request {
abstract class AbstractPostHandler : ISpecificHandler {
abstract protected string templateName {
get;
}
abstract protected XElement[] Do(WebContext context);
private XDocument getData(WebContext context) {
return new XDocument(
new XElement("root",
new XElement("title", Config.instance.AppInfo),
this.Do(context)
)
);
}
public void Handle(WebContext context) {
context.httpresponse.Write(context.Transform(this.templateName, this.getData(context)));
}
}
}

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Common.dataobjects;
using FLocal.Importer;
using System.Text.RegularExpressions;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.actions;
namespace FLocal.IISHandler.handlers.request {
class MigrateAccountHandler : AbstractPostHandler {
protected override string templateName {
get {
return "result/MigrateAccount.xslt";
}
}
protected override XElement[] Do(WebContext context) {
Account account = Account.LoadById(int.Parse(context.httprequest.Form["accountId"]));
if(!account.needsMigration) throw new FLocalException("Already migrated");
string userInfo = ShallerGateway.getUserInfo(account.user.name);
Regex regex = new Regex("\\(fhn\\:([a-z0-9]+)\\)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match match = regex.Match(userInfo);
if(!match.Success) throw new FLocalException("not found");
string check = Util.md5(match.Groups[1].Value + " " + Config.instance.SaltMigration + " " + account.id);
if(check != context.httprequest["check"]) throw new FLocalException("Wrong key '" + match.Groups[1].Value + "'");
if(context.httprequest.Form["password"] != context.httprequest.Form["password2"]) throw new FLocalException("Passwords mismatch");
account.updatePassword(context.httprequest.Form["password2"]);
return new XElement[0];
}
}
}

@ -8,7 +8,7 @@ using FLocal.Common;
using FLocal.Common.dataobjects; using FLocal.Common.dataobjects;
using FLocal.Core.DB; using FLocal.Core.DB;
namespace FLocal.IISHandler.handlers { namespace FLocal.IISHandler.handlers.response {
class BoardAsThreadHandler : AbstractGetHandler { class BoardAsThreadHandler : AbstractGetHandler {

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLocal.Core;
using FLocal.Common;
using System.Xml.Linq;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class LoginHandler : AbstractGetHandler {
protected override string templateName {
get {
return "Login.xslt";
}
}
protected override System.Xml.Linq.XElement[] getSpecificData(WebContext context) {
return new XElement[0];
}
}
}

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FLocal.Core;
using FLocal.Common;
using System.Xml.Linq;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class MigrateAccountHandler : AbstractGetHandler {
protected override string templateName {
get {
return "MigrateAccount.xslt";
}
}
protected override System.Xml.Linq.XElement[] getSpecificData(WebContext context) {
string username;
if(context.httprequest.Form["username"] != "") {
username = context.httprequest.Form["username"];
} else {
if(context.requestParts.Length != 2) {
throw new CriticalException("Username is not specified");
}
username = context.requestParts[1];
}
User user = User.LoadByName(username);
Account account = Account.LoadByUser(user);
if(!account.needsMigration) throw new FLocalException("Already migrated");
string key = Util.RandomString(8, Util.RandomSource.LETTERS_DIGITS);
return new XElement[] {
new XElement("migrationInfo",
new XElement("accountId", account.id),
new XElement("key", key),
new XElement("check", Util.md5(key + " " + Config.instance.SaltMigration + " " + account.id))
),
};
}
}
}

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E2ECF86C-C0BA-4782-A485-E267BB213BB2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FLocal.Importer</RootNamespace>
<AssemblyName>Importer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShallerConnector.cs" />
<Compile Include="ShallerGateway.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Importer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Importer")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a89bd8e-95bf-4085-ad06-768a3fde2335")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Net;
using System.Configuration;
using System.IO;
namespace FLocal.Importer {
class ShallerConnector {
public static string getPageContent(string requestUrl, Dictionary<string, string> postData, CookieContainer cookies) {
string baseUrl = ConfigurationManager.AppSettings["Importer_BaseUrl"];
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseUrl + requestUrl);
request.KeepAlive = true;
request.CookieContainer = cookies;
if(postData.Count < 1) {
request.Method = "GET";
} else {
StringBuilder postBuilder = new StringBuilder();
foreach(KeyValuePair<string, string> kvp in postData) {
postBuilder.Append(HttpUtility.UrlEncode(kvp.Key));
postBuilder.Append('=');
postBuilder.Append(HttpUtility.UrlEncode(kvp.Value));
}
byte[] postBytes = Encoding.ASCII.GetBytes(postBuilder.ToString());
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
}
request.UserAgent = "ShallerConnector v0.1";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
cookies.Add(response.Cookies);
using(StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1251))) {
return reader.ReadToEnd();
}
}
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLocal.Importer {
public class ShallerGateway {
public static string getUserInfo(string userName) {
return ShallerConnector.getPageContent("showprofile.php?User=" + userName + "&What=login&showlite=l", new Dictionary<string,string>(), new System.Net.CookieContainer());
}
}
}

Binary file not shown.

Binary file not shown.

@ -0,0 +1,5 @@
D:\penartur\Documents\Visual Studio 2008\Projects\FLocal\trunk\Importer\obj\Release\ResolveAssemblyReference.cache
D:\penartur\Documents\Visual Studio 2008\Projects\FLocal\trunk\Importer\bin\Release\Importer.dll
D:\penartur\Documents\Visual Studio 2008\Projects\FLocal\trunk\Importer\bin\Release\Importer.pdb
D:\penartur\Documents\Visual Studio 2008\Projects\FLocal\trunk\Importer\obj\Release\Importer.dll
D:\penartur\Documents\Visual Studio 2008\Projects\FLocal\trunk\Importer\obj\Release\Importer.pdb

Binary file not shown.

Binary file not shown.

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="elems\Main.xslt"/>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Âõîä</xsl:text>
</td>
</tr>
<tr class="darktable">
<td>
<xsl:text>Ââåäèòå âàøå èìÿ ïîëüçîâàòåëÿ è ïàðîëü äëÿ ðåãèñòðàöèè â ôîðóìå. </xsl:text>
<xsl:text>Åñëè âû åù¸ íå ïîëüçîâàëèñü ýòèì ôîðóìîì, íî ïðèøëè ñî ñòàðîãî ôîðóì.ëîêàëà &#150; âû ìîæåòå ñîçäàòü ïàðîëü â ôîðìå ìèãðàöèè.</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<form method="post" action="/do/Login/">
<xsl:text>Ëîãèí</xsl:text><br />
<input type="text" name="username" class="formboxes" /><br/>
<xsl:text>Ïàðîëü</xsl:text><br/>
<input type="password" name="password" class="formboxes" /><br/>
<input type="submit" name="buttlogin" value="Âîéòè!" class="buttons" />
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ìèãðàöèÿ</xsl:text>
</td>
</tr>
<tr class="darktable">
<td>
<xsl:text>Åñëè âû ïðèøëè ñî ñòàðîãî ôîðóì.ëîêàëà &#150; ââåäèòå ñâîé ëîãèí.</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<form method="post" action="/MigrateAccount/">
<xsl:text>Ëîãèí</xsl:text><br />
<input type="text" name="username" class="formboxes" /><br/>
<input type="submit" name="buttlogin" value="Äàëåå" class="buttons" />
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="elems\Main.xslt"/>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ìèãðàöèÿ ïîëüçîâàòåëÿ</xsl:text>
</td>
</tr>
<tr class="darktable">
<td>
<xsl:text>Ââåäèòå ñòðîêó </xsl:text>
<b>(fhn:<xsl:value-of select="migrationInfo/key"/>)</b>
<xsl:text> (âìåñòå ñî ñêîáêàìè) â ïîëå áèîãðàôèè â ñâî¸ì ïðîôàéëå íà ñòàðîì ôîðóìå.</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<form method="post" action="/do/MigrateAccount/">
<input type="hidden" name="accountId">
<xsl:attribute name="value"><xsl:value-of select="migrationInfo/accountId"/></xsl:attribute>
</input>
<input type="hidden" name="check">
<xsl:attribute name="value"><xsl:value-of select="migrationInfo/check"/></xsl:attribute>
</input>
<xsl:text>Íîâûé ïàðîëü</xsl:text><br />
<input type="password" name="password" class="formboxes" /><br/>
<xsl:text>Ïîâòîðèòå ïàðîëü</xsl:text><br/>
<input type="password" name="password2" class="formboxes" /><br/>
<input type="submit" name="buttlogin" value="Ìèãðèðîâàòü!" class="buttons" />
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -53,7 +53,7 @@
</td> </td>
<td class="navigation" nowrap="nowrap"> <td class="navigation" nowrap="nowrap">
<a> <a>
<xsl:attribute name="href">/Thread/<xsl:value-of select="currentLocation/post/parent/thread/id"/>/p<xsl:value-of select="currentLocation/post/id"/>/</xsl:attribute> <xsl:attribute name="href">/Thread/<xsl:value-of select="currentLocation/post/parent/thread/id"/>/p<xsl:value-of select="currentLocation/post/id"/></xsl:attribute>
<img alt="*" src="/static/images/flat.gif" style="vertical-align: text-bottom" /> <img alt="*" src="/static/images/flat.gif" style="vertical-align: text-bottom" />
<xsl:text>Ïëîñêèé</xsl:text> <xsl:text>Ïëîñêèé</xsl:text>
</a> </a>

@ -38,7 +38,8 @@
<xsl:text> | </xsl:text> <xsl:text> | </xsl:text>
<a target="_top">Ďîčńę</a> <a target="_top">Ďîčńę</a>
<xsl:text> | </xsl:text> <xsl:text> | </xsl:text>
<a target="_top">My Home</a> <!--a target="_top">My Home</a-->
<a href="/Login/" target="_top">Âõîä</a>
<xsl:text> | </xsl:text> <xsl:text> | </xsl:text>
<a target="_top">Ęňî â îíëŕéíĺ</a> <a target="_top">Ęňî â îíëŕéíĺ</a>
<xsl:text> | </xsl:text> <xsl:text> | </xsl:text>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="..\elems\Main.xslt"/>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Ìèãðàöèÿ ïîëüçîâàòåëÿ</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<xsl:text>Ìèãðàöèÿ óñïåøíî çàâåðøåíà, òåïåðü âû ìîæåòå âîéòè â ôîðóì, èñïîëüçóÿ ñâîé ëîãèí è íîâûé ïàðîëü.</xsl:text>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Loading…
Cancel
Save