ASPXBOY.com open source

zhaozj2021-02-16  94

1

// 2004-03-14, the Heaven (IM286.com) is three years old,

2

// Open aspxboy.com Current source code, everyone study each other.

3

// The target just started learning .NET encoding is rough, please refer to you, thank you!

4

5

//

6

//

Seduce

// Copyright: www.aspxboy.com

8

// filename: aspxboy.cs

9

// Author huobazi

10

// Createdate:

11

// UpdateHistory:

12

//

13

//

14

15

Namespace aspxboy.com

16 {

In one

Using system;

18

Using system.configuration;

19

Using system.data;

20

Using system.data.oledb;

twenty one

Using system.io;

twenty two

Using system.text;

twenty three

Using system.text.regularExpressions;

twenty four

Using system.Web;

25

Using system.Web.ui;

26

Using system.Web.ui.webcontrols;

27

Using system.Web.ui.htmlcontrols;

Twist

Using wuqi.webdiyer;

29

///

///

30

///

31

///

Create aspxboy.com Namespace

32

///

33

///

///

34

public

Class Basepage: Page

35 {

36

37

public

Static

String strconn

38 {

39GET

40 {

41StringBuilder Strresult =

New stringbuilder (configurationSettings.appsettings [

"Provider"]);

42strresult.Append (

";");

43strresult.Append (

"Data Source =");

44StrRRRRRRESULT.APpend (httpContext.current.Request.PhysicalApplicationPath);

45strresult.Append (

"//");

46strresult.Append (configurationSettings.appsettings ["Datasource"]);

47

Return strresult.toString ();

48}

49}

50

public

String strsiteURL

51 {

52GET

53 {

54

String str =

"http://www.aspxboy.com";

55

Return Str;

56}

57}

58

public

String Transstring

String Str,

INT i)

59 {

60

IF (str.length> i)

61 {

62

Return Str.Substring (0, i)

"...";

63}

64

Else

65 {

66

Return Str;

67}

68}

69

protected oledbconnection con =

New OLEDBConnection (STRCONN);

70

Protected oledbcommand cmm;

71}

72

public

Class BaseControl: UserControl

73 {

74

///

/

75

///

76

///

Create base type Basepage

77

///

78

///

/

79

80

public

String StrcopyRight

81 {

82GET

83 {

String Str;

84Str =

"CopyRight (C) 2003-";

85STR = (System.Datetime.now.Year 1) .tostring ();

86STR =

"By aspxboy.com. All rights reserved";

87

Return Str;

88}

89}

90

public

String strsiteURL

91 {

92GET

93 {

94

String str =

"http://www.aspxboy.com";

95

Return Str;

96}

97}

98

public

String strsiteTitle

99 {

100get

101 {

102

String str =

"- | .NET Boy Community | - | ASPXBOY.com | ---- | Provide a large number of .NET technical articles //.net technology discussion zone / / large amount ASP.NET//c#/vb.net// Web services // website design // flat design / / software development // tutorial // ~~~ Powered by Huo Ba Zi ---------------- ";

103

Return Str;

104}

105}

106

public

String strmailwebmaster

107 {

108GET

109 {

110

String str =

"Webmaster@aspxboy.com";

111

Return Str;

112}

113}

114

public

Static

String strconn

115 {

116GET

117 {

118StringBuilder Strresult =

New stringbuilder (configurationSettings.appsettings [

"Provider"]);

119strresult.Append (

";");

120StrRRRRRRRRRESULT.APpend ("Data Source =");

121strresult.Append (httpContext.current.Request.PhysicalApplicationPath);

122StrRRRRRESULT.APpend (

"//");

123strresult.Append (ConfigurationSettings.AppSettings "

"Datasource"]);

124

Return strresult.toString ();

125}

126

127}

128

public

String strVersion

129 {

130GET

131 {

String str =

"1.0";

132

Return Str;

133}

134}

135

public

String Transstring

String Str,

INT i)

136 {

137

IF (str.length> i)

138 {

139

Return Str.Substring (0, i)

"...";

140}

141

Else

142 {

143

Return Str;

144}

145}

146

protected oledbconnection conn =

New OLEDBConnection (STRCONN);

147

Protected oledbcommand cmd;

148}

149

150

public

Class Module: Basepage

151 {

152

///

/

153

///

154

///

Module class, realize dynamic adding Module control

155

///

156

///

157

protected htmlform myform =

New htmlform ();

158

public

String getModulename ()

159 {

160

String strm;

161

IF (Request.queryString "

"Module"] ==

null || request.querystring [

"Module"] ==

"")

162STRM =

"index";

163

Else

164STRM = Request.QueryString [

"Module"];

165

Return Strm;

166}

167

public

String getModuleskinPath (

String MoDulname)

168 {

169

String strresult =

NULL;

170stringbuilder strskinfile =

New stringbuilder (httpcontext.current.server.mappath

"."));

171strskinfile.Append (

"// module //");

172stskinfile.append (MODULNAME);

173strskinfile.Append (

"//");

174strskinfile.Append (MODULNAME);

175strskinfile.Append (

".ascx");

176

IF (! file.exists (strskinfile.toString ())))

177StrRRESULT =

"Err"; 178

Else Strresult = strskinfile.toString ();

179

Return strresult.replace (httpcontext.current.server.mappath (

"."),

".");

180

181}

182

public

Void loadingModuleskin

String strModuleskinPath)

183 {

184Control MyCtrl = loadingControl (StrmoduleskinPath);

185MYFORM.CONTROLS.ADD (MyCtrl);

186}

187

public

Void Page_Load

Object sender, Eventargs E)

188 {

189

String Modulename = getModulename ();

190

String ModulePath = getModuleskinPath (ModuLename);

191

IF (modulepath ==

"ERR")

192Response.Redirect

"./Errorpages/generalrror.htm?aspxerrorpath=default.aspx");

193

Else

194 {

195LoadModuleskin (ModulePath);

196}

197}

198}

1999

200

public

Class Article: BaseControl

201 {

202

///

/

203

///

204

///

Article class, implement article pages

205

///

206

///

207

208

Protected Repeater Repeater, Showbigclass, Showsmallclass, TOP;

209

Protected aspnetPager Pager;

210

protected htmlGenericControl Title =

New htmlGenericControl ();

211

protected

Void initbigclassshow ()

212 {

213Conn.open ();

214cmd =

New OLEDBCommand

"SELECT ID, BigclassName from rootclass", conn

215oledbdatareader myreader = cmd.executeReader ();

216showbigclass.DataSource = MyReader;

217showbigclass.DATABIND ();

218myReader.close ();

219Conn.close ();

220}

221

protected

Void initsmallclassshow ()

222 {

223

IF ((Request.QueryString "

"BigclassID"]! =

Null && (Request.QueryString "

"BigclassID"]! =

""))

224 {

225

String strsql =

"SELECT ID, TYPENAME from Type Where Bigid =";

226strsql = (Request.QueryString "

"BigclassID"]). TOSTRING ();

227conn.open ();

228cmd =

New OLEDBCommand (strsql, conn);

229oledbdataareader myreader = cmd.executeReader ();

230showsmallclass.datasource = MyReader;

231showsmallclass.DATABIND ();

232myReader.close ();

233Conn.close ();

234}

235}

236

protected

Void inittopshow ()

237 {

238

String strsql =

"SELECT TOP 10 ArticleId, Title from";

239STRSQL = where ();

240STRSQL =

"Order By Hits DESC";

241cmd =

New OLEDBCommand (strsql, conn);

242Conn.open ();

243oledbdatareader myreader = cmd.executeReader ();

244TOP.DataSource = MyReader;

245top.database ();

246myReader.Close ();

247Conn.close ();

248}

249

protected

String where ()

250 {

251

String strwhere;

252

IF (Request.queryString "

"Smallclassid"] ==

null || request.querystring [

"Smallclassid"] ==

"")

253

IF (Request.queryString "

"BigclassID"] ==

null || request.querystring [

"BigclassID"] ==

"")

254Strwhere =

"Article";

255

Else

256 {

257Strwhere =

"Article where bigid =";

258Strwhere = (Request.QueryString "

"BigclassID"]). TOSTRING ();

259}

260

Else

261 {

262Strwhere =

"Article where smallid =";

263Strwhere = (Request.QueryString "

"SmallClassID"]). TOSTRING ();

264}

265

Return strwhere;

266}

267

protected

void binddata ()

268 {

269

270

String strsql =

"SELECT ARTICLEID, TITLE, ADDDATE";

271strsql = where ();

272strsql =

"Order by ArticleID DESC";

273cmd =

New OLEDBCommand (strsql, conn);

274conn.open ();

275oledbdataadapter adapter =

New OLEDBDataAdapter (CMD);

276DataSet DS =

New dataset (); 277adapter.Fill (DS, Pager.pageSize * (Pager.currentPageIndex-1), Pager.pageSize,

"Article");

278Repeater.DataSource = DS.TABLES [

"Article"]. Defaultview;

279Repeater.DATABIND ();

280Conn.close ();

281}

282

protected

void initpaging ()

283 {

284Pager.ShowFirstlast =

True;

285Pager.ShowPRevnext =

True;

286Pager.ShowPageIndex =

True;

287

288

289

/ / Calculate total record number

290

String strsql =

"SELECT COUNT (ARTICLEID) from";

291strsql = where ();

292cmd =

New OLEDBCommand (strsql, conn);

293Conn.open ();

294Pager.Recordcount = ((((((() 294PAGER.Recordcount =

Int) cmd.executescalar () <= 0)? 1 :(

Int) cmd.executescalar ();

295Conn.close ();

296

/ / Dynamically set the user-defined text content

297Pager.custominfotext =

"Total number of articles: " Pager.Recordcount.toString ()

" ";

298Pager.custominfotext =

"Total number of pages: " Pager.pageCount.toString ()

" ";

299Pager.custominfotext =

"Current page: " Pager.currentPageIndex.tostring ()

" ";

300}

301

protected

Void change_page

Object Sender, PageChangeDeventargs E)

302 {

303Pager.currentPageIndex = E.NEWPAGEINDEX;

304binddata ();

305}

306

protected

Void Page_Load

Object sender, Eventargs E)

307 {

308

IF (! page.ispostback)

309 {

310Title.innertext = strsiteTitle;

311initbigclassshow ();

312INITSMALLCLASSHOW ();

313inittopShow ();

314initpaging ();

315binddata ();

316}

317}

318}

319

public

Class HotFile: BaseControl

320 {

321

Public Repeater HOT;

322

public

Void Page_Load (Object Sender, Eventargs E)

323 {

324

String strsql =

"SELECT TOP 15 ArticleID, Title, Hits from Article";

325strsql =

"Order By Hits DESC";

326cmd =

New OLEDBCommand (strsql, conn);

327conn.open ();

328oledbdatareader myreader = cmd.executeReader ();

329hot.datasource = MyReader;

330hot.DATABIND ();

331myReader.close ();

332conn.close ();

333}

334}

335

public

Class NewArticle: BaseControl

336 {

337

String Repeater rpnewarticle;

338

public

Void Page_Load

Object sender, Eventargs E)

339 {

340

String strsql =

"SELECT TOP 15 ArticleId, Title from Article";

341strsql =

"Order by Addddate DESC";

342cmd =

New OLEDBCommand (strsql, conn);

343conn.open ();

344oledbdatareader myreader = cmd.executeReader ();

345rpnewarticle.datasource = MyReader;

346rpnewarticle.databind ();

347myReader.close ();

348Conn.close ();

349}

350}

351

public

Class ShowArticle: Basepage

352 {

353

public

Void UpdateHits (

String ID)

354 {

355

String str =

Update Article Set Hits = Hits 1 Where Articles = ";

356STR = ID;

357cmm =

New OLEDBCommand (STR, CON);

358cmm.executenonquery ();

359}

360

public

Void Page_Load

Object sender, Eventargs E)

361 {

362

String URL, STRSQL;

363

IF (! page.ispostback)

364 {

365

IF ((Request.QueryString "

"Id"] ==

null) || (Request.QueryString "

"Id"] ==

""))

366RESPONSE.REDIRECT

"./Errorpages/generalrror.htm?aspxerrorpath=showArticle.aspx");

367

Else

368 {

369strsql =

"SELECT FileName from Article Where Articles";

370STRSQL = (Request.QueryString [

"ID"]). TOSTRING ();

371Con.Open (); 372cmm =

New OLEDBCommand (strsql, con);

373oledbdataareader DR = cmm.executeReader (commandbehavior.singlerow);

374

IF (Dr.Read ())

375 {url = strsiteURL;

376URL = DR [

"Filename"]. TOSTRING ();

377dr.close ();

378UPDATEHITS ((Request.QueryString "

"ID"]). TOSTRING ());

379}

380

Else URL =

"./Errorpages/generalarror.htm?aspxerrorpath=showArticle.aspx";

381Con.Close ();

382RESPONSE.REDIRECT (URL);

383}

384}

385}

386}

387

public

Class Admin: Module

388 {

389

protected

New

Void Page_Load

Object sender, Eventargs E)

390 {

391

392

String Modulename = getModulename ();

393

String ModulePath = getModuleskinPath (ModuLename);

394

IF (modulepath ==

"ERR")

395RESPONSE.REDIRECT

"../Errorpages/generalerror.htm?aspxerrorpath=adminCenter/default.aspx");

396

Else

397 {

398 LoadModuleskin (ModulePath);

399}

400

401

402}

403}

404

405

406

///

Article classification management /

407

public

Class ArticleClass: BaseControl

408 {

409

Protected TextBox txtbigclassadd, txtsmallclassadd, txtbigclassedit, txtsmallclassedit;

410

Protected button btnbigclassadd, btnbigclassedit, btnbigclassdelete, btnsmallclassadd, btnsmallclassedit, btnsmallclassdelete;

411

Protected Dropdownlist BigclassListedit, SmallClassListedit, BigclassListdelete, SmallClassListDelete;

412

Protected DropdownList BigclassList =

New DropDownList ();

413

protected

Void Page_Load (Object Sender, Eventargs E)

414 {

415

IF (session

"Admin"]! =

NULL)

416 {

417bigclassdropdownlistinit ();

418smallclassdropdownlistinit ();

419}

420

Else

421RESPONSE.REDIRECT

"Default.aspx? Module = login");

422}

423

protected

Void BtnbigclassAdd_Click (Object Sender, Eventargs E) 424 {

425

String strinsert =

"INSERT INTO ROOTCLASS (BigclassName) VALUES ('" txtbigclassadd.text

"')"

426conn.open ();

427oledbcommand commit =

New OLEDBCommand

"SELECT Count (*) from rootclass where bigclassname = '" txtbigclassadd.text

"'", Conn);

428

INT i =

INT.PARSE (CommTest.executescalar (). TOSTRING ());

429conn.close ();

430

IF (i> 0)

431 {

432RESPONSE.WRITE

"