Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

660 lines
19 KiB

  1. //
  2. //
  3. //
  4. var mdb_ContentOwners = [];
  5. var mdb_Taxonomy = [];
  6. var mdb_Topics = [];
  7. var mdb_Keywords = [];
  8. var edb_ContentOwners = [];
  9. var edb_Taxonomy = [];
  10. var edb_Topics = [];
  11. var edb_Topics_LOOKUP = [];
  12. var edb_Keywords = [];
  13. var edb_Owner = null;
  14. ////////////////////////////////////////////////////////////////////////////////
  15. var hhkList = [];
  16. hhkList[ "98update.chm" ] = "/98update.hhk";
  17. hhkList[ "access.chm" ] = "/access.hhk";
  18. hhkList[ "accessib.chm" ] = "/accessib.hhk";
  19. hhkList[ "camera.chm" ] = "/camera.hhk";
  20. hhkList[ "common.chm" ] = "/common.hhk";
  21. hhkList[ "cpanel.chm" ] = "/cpanel.hhk";
  22. hhkList[ "find.chm" ] = "/find.hhk";
  23. hhkList[ "Folderop.chm" ] = "/Folderop.hhk";
  24. hhkList[ "ieeula.chm" ] = "/ieeula.hhk";
  25. hhkList[ "iesupp.chm" ] = "/iesupp.hhk";
  26. hhkList[ "iexplore.chm" ] = "/iexplore.hhk";
  27. hhkList[ "infrared.chm" ] = "/infrared.hhk";
  28. hhkList[ "license.chm" ] = "/license.hhk";
  29. hhkList[ "mouse.chm" ] = "/mouse.hhk";
  30. hhkList[ "mstask.chm" ] = "/mstask.hhk";
  31. hhkList[ "mtshelp.chm" ] = "/mtshelp.hhk";
  32. hhkList[ "ndsnp.chm" ] = "/ndsnp.hhk";
  33. hhkList[ "network.chm" ] = "/network.hhk";
  34. hhkList[ "ratings.chm" ] = "/ratings.hhk";
  35. hhkList[ "rnaapp.chm" ] = "/rnaapp.hhk";
  36. hhkList[ "users.chm" ] = "/users.hhk";
  37. hhkList[ "vpn.chm" ] = "/vpn.hhk";
  38. hhkList[ "whatnew.chm" ] = "/whatnew.hhk";
  39. hhkList[ "windows.chm" ] = "/windows.hhk";
  40. hhkList[ "Compfldr.chm" ] = "/Compfldr.hhk";
  41. hhkList[ "OSK.chm" ] = "/OSK.hhk";
  42. hhkList[ "Brief.chm" ] = "/Brief.hhk";
  43. hhkList[ "Webfoldr.chm" ] = "/Webfoldr.hhk";
  44. hhkList[ "icwdial.chm" ] = "/icwdial.hhk";
  45. ////////////////////////////////////////////////////////////////////////////////
  46. var ftsList = [];
  47. ftsList[ "windows.chm" ] = "windows.chq";
  48. ////////////////////////////////////////////////////////////////////////////////
  49. var stopwords = "a,able,about,also,an,another,any,are,aren't,arent,as,at,be,beat,because,being,both,but,by,came,can,can't,cannot,cant,come,could,couldnt,couldn't,did,didnt,didn't,do,does,doesn't,doesnt,don't,dont,each,effort,for,from,get,give,gives,giving,got,had,has,have,havent,haven't,having,how,however,howto,if,i,im,i'm,in,into,is,isnt,isn't,it,i've,know,like,mainly,make,makes,making,many,may,me,might,more,most,mostly,much,must,my,need,needing,needs,never,now,of,on,only,onto,other,our,over,please,propose,proposes,proposing,same,see,should,shouldnt,shouldn't,since,so,some,still,such,suppose,supposedly,take,takes,taking,that,the,these,this,those,though,through,to,too,tries,try,trying,trys,unless,until,useless,up,use,uses,using,very,want,wanting,wants,was,way,ways,were,werent,weren't,what,whatever,what's,where,whereas,which,whichever,while,whilst,will,with,won't,wont,work,working,works,would,you,you've,your,new,feature,features,old,prepare,prepares,preparing,choose,chooses,choosing,pick,picks,picking,chose,usage,useful"
  50. var dbparamList = [];
  51. dbparamList[ "SET_STOPSIGNS" ] = ",?;";
  52. dbparamList[ "SET_STOPSIGNS_ATENDOFWORD" ] = ".!";
  53. dbparamList[ "SET_STOPWORDS" ] = stopwords;
  54. dbparamList[ "SET_OPERATOR_NOT" ] = "not";
  55. dbparamList[ "SET_OPERATOR_AND" ] = "and";
  56. dbparamList[ "SET_OPERATOR_OR" ] = "or";
  57. dbparamList[ "DB_SKU" ] = "Server";
  58. dbparamList[ "DB_LANGUAGE" ] = "English";
  59. dbparamList[ "DB_VERSION" ] = "1.0.0.0";
  60. dbparamList[ "HELP_LOCATION" ] = "%WINDIR%\\Help";
  61. ////////////////////////////////////////////////////////////////////////////////
  62. var args = WScript.Arguments;
  63. if(args.length != 2)
  64. {
  65. WScript.Echo( "Usage: CopySchema.js <EDB database file> <MDB database file>" );
  66. WScript.Quit( 10 );
  67. }
  68. //try
  69. {
  70. var fso = new ActiveXObject( "Scripting.FileSystemObject" );
  71. var connObj = new ActiveXObject( "ADODB.Connection" );
  72. connObj.Open( "provider=Microsoft.Jet.OLEDB.4.0;data source=" + fso.GetAbsolutePathName( args(1) ) + ";" );
  73. LoadContentOwners( connObj );
  74. LoadTaxonomy ( connObj );
  75. LoadTopics ( connObj );
  76. LoadKeywords ( connObj );
  77. var sess = new ActiveXObject( "PCH.DBSession" );
  78. var db = sess.AttachDatabase( fso.GetAbsolutePathName( args(0) ) );
  79. ////////////////////////////////////////
  80. sess.BeginTransaction ( );
  81. GenerateDBParameters ( sess );
  82. sess.CommitTransaction( );
  83. sess.BeginTransaction ( );
  84. GenerateContentOwner ( sess, db );
  85. sess.CommitTransaction( );
  86. sess.BeginTransaction ( );
  87. GenerateIndexFiles ( sess );
  88. sess.CommitTransaction( );
  89. sess.BeginTransaction ( );
  90. GenerateFullTextSearch( sess );
  91. sess.CommitTransaction( );
  92. ////////////////////////////////////////
  93. sess.BeginTransaction ( );
  94. GenerateTaxonomy ( sess, db );
  95. sess.CommitTransaction( );
  96. sess.BeginTransaction ( );
  97. GenerateTopics ( sess, db );
  98. sess.CommitTransaction( );
  99. sess.BeginTransaction ( );
  100. GenerateKeywords ( sess, db );
  101. sess.CommitTransaction( );
  102. sess.BeginTransaction ( );
  103. GenerateMatches ( sess, db );
  104. sess.CommitTransaction( );
  105. }
  106. //catch(e)
  107. //{
  108. // WScript.Echo( "Error: " + hex( e.number ) + " - " + e.description );
  109. //
  110. // if(sess) sess.RollbackTransaction();
  111. //}
  112. ////////////////////////////////////////////////////////////////////////////////
  113. function LoadContentOwners( connObj )
  114. {
  115. var cmdObj = new ActiveXObject( "ADODB.Command" );
  116. var rs;
  117. WScript.Echo( "Loading Content Owners..." );
  118. cmdObj.ActiveConnection = connObj;
  119. cmdObj.CommandText = "select * from ContentOwners";
  120. cmdObj.CommandType = 1; // adCmdText
  121. rs = cmdObj.Execute();
  122. while(rs.EOF == false)
  123. {
  124. var obj = new Object();
  125. var fl = rs.Fields;
  126. obj.OWID = fl.Item("OWID").Value;
  127. obj.DN = fl.Item("DN" ).Value;
  128. rs.MoveNext();
  129. if(obj.DN == "This row is not used") continue; // Hack...
  130. mdb_ContentOwners[ obj.DN ] = obj;
  131. }
  132. rs = null;
  133. cmdObj = null;
  134. }
  135. function LoadTaxonomy( connObj )
  136. {
  137. var cmdObj = new ActiveXObject( "ADODB.Command" );
  138. var rs;
  139. WScript.Echo( "Loading Taxonomy..." );
  140. cmdObj.ActiveConnection = connObj;
  141. cmdObj.CommandText = "select * from Topics where Entry <> \"\" order by Category";
  142. cmdObj.CommandType = 1; // adCmdText
  143. rs = cmdObj.Execute();
  144. while(rs.EOF == false)
  145. {
  146. var obj = new Object();
  147. var fl = rs.Fields;
  148. obj.OID = fl.Item("OID" ).Value;
  149. obj.Category = fl.Item("Category" ).Value;
  150. obj.Entry = fl.Item("Entry" ).Value;
  151. obj.Title = fl.Item("Title" ).Value;
  152. obj.Description = fl.Item("Description").Value;
  153. obj.OWID = fl.Item("OWID" ).Value;
  154. mdb_Taxonomy[ obj.Category + "/" + obj.Entry ] = obj;
  155. rs.MoveNext();
  156. }
  157. rs = null;
  158. cmdObj = null;
  159. }
  160. function LoadTopics( connObj )
  161. {
  162. var cmdObj = new ActiveXObject( "ADODB.Command" );
  163. var rs;
  164. WScript.Echo( "Loading Topics..." );
  165. cmdObj.ActiveConnection = connObj;
  166. cmdObj.CommandText = "select * from Topics where URI <> \"\"";
  167. cmdObj.CommandType = 1; // adCmdText
  168. rs = cmdObj.Execute();
  169. while(rs.EOF == false)
  170. {
  171. var obj = new Object();
  172. var fl = rs.Fields;
  173. obj.OID = fl.Item("OID" ).Value;
  174. obj.Category = fl.Item("Category" ).Value;
  175. obj.URI = AdjustURL( fl.Item("URI" ).Value );
  176. obj.Title = fl.Item("Title" ).Value; if(obj.Title == null) obj.Title = "";
  177. obj.Description = fl.Item("Description").Value;
  178. obj.Type = fl.Item("Type" ).Value; if(obj.Type == null) obj.Type = 1;
  179. obj.OWID = fl.Item("OWID" ).Value;
  180. mdb_Topics[ obj.OID ] = obj;
  181. rs.MoveNext();
  182. }
  183. rs = null;
  184. cmdObj = null;
  185. }
  186. function LoadKeywords( connObj )
  187. {
  188. var cmdObj = new ActiveXObject( "ADODB.Command" );
  189. var rs;
  190. WScript.Echo( "Loading Keywords..." );
  191. cmdObj.ActiveConnection = connObj;
  192. cmdObj.CommandText = "SELECT Topics.OID, SuperKeywords.Keyword FROM Topics, Matches, SuperKeywords where Topics.OID = Matches.OID AND Matches.KID = SuperKeywords.KID";
  193. cmdObj.CommandType = 1; // adCmdText
  194. var num=0;
  195. rs = cmdObj.Execute();
  196. while(rs.EOF == false)
  197. {
  198. var fl = rs.Fields;
  199. var keyword;
  200. var arr;
  201. keyword = fl.Item("Keyword" ).Value;
  202. arr = mdb_Keywords[ keyword ];
  203. if(!arr)
  204. {
  205. mdb_Keywords[ keyword ] = [];
  206. arr = mdb_Keywords[ keyword ];
  207. }
  208. arr[fl.Item("OID").Value] = 1;
  209. num++;
  210. rs.MoveNext();
  211. }
  212. rs = null;
  213. cmdObj = null;
  214. }
  215. ////////////////////////////////////////////////////////////////////////////////
  216. function GenerateDBParameters( sess )
  217. {
  218. var tbl = db.AttachTable( "DbParameters" );
  219. var colENUM = tbl.Columns;
  220. var col_Name = colENUM( "Name" );
  221. var col_Value = colENUM( "Value" );
  222. WScript.Echo( "Generating DBParameters..." );
  223. CleanTable( tbl );
  224. for(i in dbparamList)
  225. {
  226. tbl.PrepareInsert();
  227. col_Name .Value = i;
  228. col_Value.Value = dbparamList[i];
  229. tbl.UpdateRecord();
  230. }
  231. }
  232. function GenerateIndexFiles( sess )
  233. {
  234. var tbl = db.AttachTable( "IndexFiles" );
  235. var colENUM = tbl.Columns;
  236. var col_ID_owner = colENUM( "ID_owner" );
  237. var col_Storage = colENUM( "Storage" );
  238. var col_File = colENUM( "File" );
  239. WScript.Echo( "Generating IndexFiles..." );
  240. CleanTable( tbl );
  241. for(i in hhkList)
  242. {
  243. tbl.PrepareInsert();
  244. col_ID_owner.Value = edb_Owner.ID_owner;
  245. col_Storage .Value = i;
  246. col_File .Value = hhkList[i];
  247. tbl.UpdateRecord();
  248. }
  249. }
  250. function GenerateFullTextSearch( sess )
  251. {
  252. var tbl = db.AttachTable( "FullTextSearch" );
  253. var colENUM = tbl.Columns;
  254. var col_ID_owner = colENUM( "ID_owner" );
  255. var col_CHM = colENUM( "CHM" );
  256. var col_CHQ = colENUM( "CHQ" );
  257. WScript.Echo( "Generating FullTextSearch..." );
  258. CleanTable( tbl );
  259. for(i in ftsList)
  260. {
  261. tbl.PrepareInsert();
  262. col_ID_owner.Value = edb_Owner.ID_owner;
  263. col_CHM .Value = i;
  264. col_CHQ .Value = ftsList[i];
  265. tbl.UpdateRecord();
  266. }
  267. }
  268. ////////////////////////////////////////////////////////////////////////////////
  269. function GenerateContentOwner( sess, db )
  270. {
  271. var tbl = db.AttachTable( "ContentOwners" );
  272. var colENUM = tbl.Columns;
  273. var col_DN = colENUM( "DN" );
  274. var col_ID_owner = colENUM( "ID_owner" );
  275. var col_IsOEM = colENUM( "IsOEM" );
  276. WScript.Echo( "Generating Content Owners..." );
  277. CleanTable( tbl );
  278. for(i in mdb_ContentOwners)
  279. {
  280. var obj = mdb_ContentOwners[i];
  281. var obj2 = new Object();
  282. tbl.PrepareInsert();
  283. col_DN .Value = obj.DN;
  284. debugger;
  285. col_IsOEM.Value = true;
  286. tbl.UpdateRecord();
  287. obj2.DN = col_DN .Value;
  288. obj2.ID_owner = col_ID_owner.Value;
  289. obj2.IsOEM = col_IsOEM .Value;
  290. if(edb_Owner == null) edb_Owner = obj2;
  291. edb_ContentOwners[obj2.DN] = obj2;
  292. }
  293. }
  294. function GenerateTaxonomy( sess, db )
  295. {
  296. var tbl = db.AttachTable( "Taxonomy" );
  297. var colENUM = tbl.Columns;
  298. var col_ID_node = colENUM( "ID_node" );
  299. var col_Pos = colENUM( "Pos" );
  300. var col_ID_parent = colENUM( "ID_parent" );
  301. var col_ID_owner = colENUM( "ID_owner" );
  302. var col_Entry = colENUM( "Entry" );
  303. var col_Title = colENUM( "Title" );
  304. var col_Description = colENUM( "Description" );
  305. WScript.Echo( "Generating Taxonomy..." );
  306. CleanTable( tbl );
  307. tbl.PrepareInsert();
  308. col_Entry .Value = "<ROOT>";
  309. col_ID_owner.Value = edb_Owner.ID_owner;
  310. col_Pos .Value = 0;
  311. tbl.UpdateRecord();
  312. var obj2 = new Object();
  313. obj2.ID_node = col_ID_node .Value;
  314. obj2.Pos = col_Pos .Value;
  315. obj2.ID_parent = col_ID_parent .Value;
  316. obj2.ID_owner = col_ID_owner .Value;
  317. obj2.Entry = col_Entry .Value;
  318. obj2.Title = col_Title .Value;
  319. obj2.Description = col_Description.Value;
  320. edb_Taxonomy[obj2.Entry] = obj2;
  321. while(1)
  322. {
  323. var done = true;
  324. var got = false;
  325. for(i in mdb_Taxonomy)
  326. {
  327. var obj = mdb_Taxonomy[i]; if(obj.done) continue;
  328. var pathParent = (obj.Category != "" ? "<ROOT>/" : "<ROOT>") + obj.Category;
  329. if(obj2 = edb_Taxonomy[pathParent])
  330. {
  331. got = true;
  332. // WScript.Echo( "Mapped taxonomy node: " + pathParent + " -- " + obj.Category + " -- " + obj.Entry );
  333. obj.done = true;
  334. tbl.PrepareInsert();
  335. col_Entry .Value = obj .Entry;
  336. col_ID_owner .Value = edb_Owner.ID_owner;
  337. col_ID_parent .Value = obj2 .ID_node;
  338. col_Pos .Value = obj .OID;
  339. col_Title .Value = obj .Title;
  340. col_Description.Value = obj .Description;
  341. tbl.UpdateRecord();
  342. var obj2 = new Object();
  343. obj2.ID_node = col_ID_node .Value;
  344. obj2.Pos = col_Pos .Value;
  345. obj2.ID_parent = col_ID_parent .Value;
  346. obj2.ID_owner = col_ID_owner .Value;
  347. obj2.Entry = col_Entry .Value;
  348. obj2.Title = col_Title .Value;
  349. obj2.Description = col_Description.Value;
  350. edb_Taxonomy[ pathParent + "/" + obj2.Entry] = obj2;
  351. }
  352. else
  353. {
  354. done = false;
  355. }
  356. }
  357. if(done) break;
  358. if(got == false)
  359. {
  360. for(i in mdb_Taxonomy)
  361. {
  362. var obj = mdb_Taxonomy[i]; if(obj.done) continue;
  363. WScript.Echo( "Unmapped taxonomy node: " + obj.Category + " -- " + obj.Entry );
  364. }
  365. break;
  366. }
  367. // {
  368. // var e = new Object();
  369. //
  370. // e.number = 0x80004005;
  371. // e.description = "Unmapped taxonomy nodes!";
  372. //
  373. // throw e;
  374. // }
  375. }
  376. }
  377. function GenerateTopics( sess, db )
  378. {
  379. var tbl = db.AttachTable( "Topics" );
  380. var colENUM = tbl.Columns;
  381. var col_ID_topic = colENUM( "ID_topic" );
  382. var col_ID_node = colENUM( "ID_node" );
  383. var col_ID_owner = colENUM( "ID_owner" );
  384. var col_Pos = colENUM( "Pos" );
  385. var col_Title = colENUM( "Title" );
  386. var col_URI = colENUM( "URI" );
  387. var col_Description = colENUM( "Description" );
  388. var col_Type = colENUM( "Type" );
  389. WScript.Echo( "Generating Topics... (this will take some time)" );
  390. CleanTable( tbl );
  391. for(i in mdb_Topics)
  392. {
  393. var obj = mdb_Topics[i];
  394. var obj2 = edb_Taxonomy[ "<ROOT>/" + obj.Category];
  395. if(obj2 == null)
  396. {
  397. WScript.Echo( "Unmapped topic: " + obj.Category + " -- " + obj.Title );
  398. continue;
  399. }
  400. tbl.PrepareInsert();
  401. col_ID_node .Value = obj2 .ID_node;
  402. col_ID_owner .Value = edb_Owner.ID_owner;
  403. col_Pos .Value = obj .OID;
  404. col_Title .Value = obj .Title;
  405. col_URI .Value = obj .URI;
  406. col_Description.Value = obj .Description;
  407. col_Type .Value = obj .Type;
  408. tbl.UpdateRecord();
  409. var obj3 = new Object();
  410. obj3.ID_topic = col_ID_topic .Value;
  411. obj3.ID_node = col_ID_node .Value;
  412. obj3.ID_owner = col_ID_owner .Value;
  413. obj3.Pos = col_Pos .Value;
  414. obj3.Title = col_Title .Value;
  415. obj3.URI = col_URI .Value;
  416. obj3.Description = col_Description.Value;
  417. obj3.Type = col_Type .Value;
  418. edb_Topics [obj3.ID_topic] = obj3;
  419. edb_Topics_LOOKUP[obj .OID ] = obj3;
  420. }
  421. }
  422. function GenerateKeywords( sess, db )
  423. {
  424. var tbl = db.AttachTable( "Keywords" );
  425. var colENUM = tbl.Columns;
  426. var col_Keyword = colENUM( "Keyword" );
  427. var col_ID_keyword = colENUM( "ID_keyword" );
  428. WScript.Echo( "Generating Keywords..." );
  429. CleanTable( tbl );
  430. for(i in mdb_Keywords)
  431. {
  432. tbl.PrepareInsert();
  433. col_Keyword.Value = i;
  434. tbl.UpdateRecord();
  435. var obj2 = new Object();
  436. obj2.Keyword = col_Keyword .Value;
  437. obj2.ID_keyword = col_ID_keyword.Value;
  438. edb_Keywords[obj2.Keyword] = obj2;
  439. }
  440. }
  441. function GenerateMatches( sess, db )
  442. {
  443. var tbl = db.AttachTable( "Matches" );
  444. var colENUM = tbl.Columns;
  445. var col_ID_topic = colENUM( "ID_topic" );
  446. var col_ID_keyword = colENUM( "ID_keyword" );
  447. var col_HHK = colENUM( "HHK" );
  448. WScript.Echo( "Generating Matches... (this will take some time)" );
  449. CleanTable( tbl );
  450. for(i in mdb_Keywords)
  451. {
  452. var arr = mdb_Keywords[i];
  453. var obj = edb_Keywords[i];
  454. for(j in arr)
  455. {
  456. var obj2 = edb_Topics_LOOKUP[j];
  457. if(obj2) // == null in case it's a match to a taxonomy node (NOT SUPPORTED).
  458. {
  459. tbl.PrepareInsert();
  460. col_ID_topic .Value = obj2.ID_topic;
  461. col_ID_keyword.Value = obj .ID_keyword;
  462. col_HHK .Value = true;
  463. tbl.UpdateRecord();
  464. }
  465. }
  466. }
  467. }
  468. function CleanTable( tbl )
  469. {
  470. try
  471. {
  472. tbl.Move( 0, -2147483648 /* JET_MoveFirst */ );
  473. while(1)
  474. {
  475. tbl.DeleteRecord();
  476. tbl.Move( 0, 1 );
  477. }
  478. }
  479. catch(e)
  480. {
  481. if(e.number != -1576994371 /*0xA200F9BD*/) throw e;
  482. }
  483. }
  484. ////////////////////////////////////////////////////////////////////////////////
  485. function hex( num )
  486. {
  487. var i;
  488. var res = "";
  489. for(i=0;i<8;i++)
  490. {
  491. var mod = num & 0xF;
  492. switch(mod)
  493. {
  494. case 10: mod = "A"; break;
  495. case 11: mod = "B"; break;
  496. case 12: mod = "C"; break;
  497. case 13: mod = "D"; break;
  498. case 14: mod = "E"; break;
  499. case 15: mod = "F"; break;
  500. }
  501. res = mod + res;
  502. num = num >> 4;
  503. }
  504. return res;
  505. }
  506. function AdjustURL( url )
  507. {
  508. return url.replace( /%WINDIR%\\Help/i, "%HELP_LOCATION%" );
  509. }