温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:NETCMSv1.5(Build0509)完整源码版
当前文件路径:NetCMSv15/NetCMS.Content/Common/createJs.cs

1//====================================================== 2
//== (c)2008 aspxcms inc by NeTCMS v1.0 == 3
//== Forum:bbs.aspxcms.com == 4
//== Website:www.aspxcms.com == 5
//====================================================== 6
using System; 7
using System.Data; 8
using System.IO; 9
10
/// <summary> 11
/// createJs 的摘要说明 12
/// </summary> 13
public class createJs 14
{ 15
private static string str_SessionID= NetCMS.Global.Current.SiteID; 16
private static string str_dirMana = NetCMS.Config.UIConfig.dirDumm; 17
private static string str_rootpath= NetCMS.Common.ServerInfo.GetRootPath(); 18
/// <summary> 19
/// 获取当前站点域名 20
/// </summary> 21
/// <param name="SiteID">SessinonID</param> 22
/// <returns>返回域名字符串</returns> 23
/// 编写时间2007-04-11 Code By DengXi 24
25
public static string GetDomain(string SiteID) 26
{ 27
string str_Domain = ""; 28
if (str_dirMana != "" && str_dirMana != null && str_dirMana != string.Empty) 29
str_dirMana = "//" + str_dirMana; 30
31
NetCMS.Content.Ads.Ads ac = new NetCMS.Content.Ads.Ads(); 32
DataTable dt = ac.getAdsDomain(); 33
34
if (SiteID == "0") 35
{ 36
if (dt != null) 37
{ 38
if (dt.Rows.Count > 0) 39
str_Domain = "http://" + dt.Rows[0][0].ToString() + str_dirMana; 40
dt.Clear();dt.Dispose(); 41
} 42
} 43
else 44
{ 45
if (dt != null) 46
{ 47
if (dt.Rows.Count > 0) 48
{ 49
if (dt.Rows[0][0].ToString() == "" || dt.Rows[0][0].ToString() == null || dt.Rows[0][0].ToString()==string.Empty) 50
str_Domain = GetDomain("0"); 51
else 52
str_Domain = "http://" + dt.Rows[0][0].ToString() + str_dirMana; 53
} 54
dt.Clear();dt.Dispose(); 55
} 56
} 57
return str_Domain; 58
} 59
60
/// <summary> 61
/// (生成JS文件公共部份)获取左图片 62
/// </summary> 63
/// <param name="adsID">广告编号</param> 64
/// <returns>返回左图片字符串</returns> 65
/// 编写时间2007-04-11 Code By DengXi 66
67
public static string GetAdsLeftStr(string adsID) 68
{ 69
string str_Temp = ""; 70
NetCMS.Content.Ads.Ads ac = new NetCMS.Content.Ads.Ads(); 71
DataTable dt = ac.getAdsPicInfo("leftPic,leftSize", "ads", adsID); 72
if (dt != null) 73
{ 74
if (dt.Rows.Count > 0) 75
{ 76
string str_leftPic = ReplaceDirfile(dt.Rows[0][0].ToString()); 77
string str_leftSize = dt.Rows[0][1].ToString(); 78
79
str_leftPic = str_leftPic.ToLower(); 80
string[] arr_LeftSize = str_leftSize.Split('|'); 81
if (str_leftPic.IndexOf(".swf") != -1) 82
{ 83
if (str_leftPic.IndexOf("http://") != -1) 84
str_Temp = "<embed src=\"" + str_leftPic + "\" quality=\"high\" width=\"" + arr_LeftSize[0].ToString() + "\"" + 85
" height=\"" + arr_LeftSize[1].ToString() + "\" type=\"application/x-shockwave-flash\" " + 86
" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>"; 87
else 88
str_Temp = "<embed src=\"" + GetDomain(str_SessionID) + str_leftPic + "\" quality=\"high\" " + 89
" width=\"" + arr_LeftSize[0].ToString() + "\" height=\"" + arr_LeftSize[1].ToString() + "\" " + 90
" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>"; 91
} 92
else 93
{ 94
if (str_leftPic.IndexOf("http://") == -1) 95
str_Temp = "<a href=\"" + GetDomain(str_SessionID) + "/jsfiles/ads/adsclick.aspx?adsID=" + adsID + "\" " + 96
" target=_blank><img src=\"" + str_leftPic + "\" border=\"0\" width=\"" + arr_LeftSize[0].ToString() + "\" " + 97
" height=\"" + arr_LeftSize[1].ToString() + "\" align=\"top\"></a>"; 98
else 99
str_Temp = "<a href=\"" + GetDomain(str_SessionID) + "/jsfiles/ads/adsclick.aspx?adsID=" + adsID + "\" "+ 100
" target=_blank><img src=\"" + GetDomain(str_SessionID) + str_leftPic + "\" border=\"0\" "+ 101
"width=\"" + arr_LeftSize[0].ToString() + "\" height=\"" + arr_LeftSize[1].ToString() + "\" align=\"top\"></a>"; 102
} 103
} 104
dt.Clear();dt.Dispose(); 105
} 106
return str_Temp; 107
} 108
109
/// <summary> 110
/// (生成JS文件公共部份)获取右图片 111
/// </summary> 112
/// <param name="adsID">广告编号</param> 113
/// <returns>返回右图片字符串</returns> 114
/// 编写时间2007-04-11 Code By DengXi 115
116
public static string GetAdsRightStr(string adsID) 117
{ 118
NetCMS.Content.Ads.Ads ac = new NetCMS.Content.Ads.Ads(); 119
DataTable dt = ac.getAdsPicInfo("rightPic,rightSize", "ads", adsID); 120
121
string str_Temp = ""; 122
if (dt != null) 123
{ 124
if (dt.Rows.Count > 0) 125
{ 126
string str_rightPic = ReplaceDirfile(dt.Rows[0][0].ToString()); 127
string str_rightSize = dt.Rows[0][1].ToString(); 128
129
str_rightPic = str_rightPic.ToLower(); 130
string[] arr_rightSize = str_rightSize.Split('|'); 131
if (str_rightPic.IndexOf(".swf") != -1) 132
{ 133
if (str_rightPic.IndexOf("http://") != -1) 134
str_Temp = "<embed src=\"" + str_rightPic + "\" quality=\"high\" width=\"" + arr_rightSize[0].ToString() + "\" " + 135
" height=\"" + arr_rightSize[1].ToString() + "\" type=\"application/x-shockwave-flash\" " + 136
" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>"; 137
else 138
str_Temp = "<embed src=\"" + GetDomain(str_SessionID) + str_rightPic + "\" quality=\"high\" " + 139
"width=\"" + arr_rightSize[0].ToString() + "\" height=\"" + arr_rightSize[1].ToString() + "\"" + 140
"type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>"; 141
} 142
else 143
{ 144
if (str_rightPic.IndexOf("http://") != -1) 145
str_Temp = "<a href=\"" + GetDomain(str_SessionID) + "/jsfiles/ads/adsclick.aspx?adsID=" + adsID + "\" target=_blank>" + 146
"<img src=\"" + str_rightPic + "\" border=\"0\" width=\"" + arr_rightSize[0].ToString() + "\" " + 147
" height=\"" + arr_rightSize[1].ToString() + "\" align=\"top\"></a>"; 148
else 149
str_Temp = "<a href=\"" + GetDomain(str_SessionID) + "/jsfiles/ads/adsclick.aspx?adsID=" + adsID + "\" " + 150
" target=_blank><img src=\"" + GetDomain(str_SessionID) + str_rightPic + "\" border=\"0\" " + 151
"width=\"" + arr_rightSize[0].ToString() + "\" height=\"" + arr_rightSize[1].ToString() + "\" align=\"top\"></a>"; 152
} 153
} 154
dt.Clear(); dt.Dispose(); 155
} 156
return str_Temp; 157
} 158
159
/// <summary> 160
/// 生成JS文件 161
/// </summary> 162
/// <param name="adsID">广告编号</param> 163
/// <param name="adsClassID">广告栏目编号</param> 164
/// <param name="adsContent">广告内容</param> 165
/// <returns>生成JS文件</returns> 166
/// 编写时间2007-04-11 Code By DengXi 167
168
public static void CreateJsFile(string adsID, string adsClassID, string adsContent) 169
{ 170
if (str_dirMana != "" && str_dirMana != null && str_dirMana != string.Empty) 171
str_dirMana = "\\" + str_dirMana; 172
string str_jsdir = str_rootpath + str_dirMana + "\\jsfiles\\ads\\" + adsClassID; 173
string str_jspath = str_rootpath + str_dirMana + "\\jsfiles\\ads\\" + adsClassID + "\\" + adsID + ".js"; 174
if (Directory.Exists(str_jsdir) == false) 175
{ 176
try 177
{ 178
Directory.CreateDirectory(str_jsdir); 179
} 180
catch (Exception ex) 181
{ 182
throw new Exception (ex.ToString()); 183
} 184
} 185
if (File.Exists(str_jspath) == true) 186
{ 187
try 188
{ 189
File.Delete(str_jspath); 190
} 191
catch (Exception ex1) 192
{ 193
throw new Exception(ex1.ToString()); 194
} 195
} 196
try 197
{ 198
File.AppendAllText(str_jspath, adsContent); 199
} 200
catch (Exception ex2) 201
{ 202
throw new Exception(ex2.ToString()); 203
} 204
} 205
206
/// <summary> 207
/// 检测广告是否锁定与过期 208
/// </summary> 209
/// <param name="adsID">广告编号</param> 210
/// <returns>返回true或false</returns> 211
/// 编写时间2007-04-11 Code By DengXi 212
public static bool checkJs(string adsID) 213
{ 214
bool tf = false; 215
NetCMS.Content.Ads.Ads ac = new NetCMS.Content.Ads.Ads(); 216
DataTable dt = ac.getAdsPicInfo("CondiTF,maxShowClick,TimeOutDay,maxClick,isLock,ClickNum,ShowNum", "ads", adsID); 217
if (dt != null) 218
{ 219
if (dt.Rows.Count > 0) 220
{ 221
if (dt.Rows[0]["isLock"].ToString() == "1") 222
tf = true; 223
else 224
{ 225
if (dt.Rows[0]["CondiTF"].ToString() == "1") 226
{ 227
int int_maxShowClick = int.Parse(dt.Rows[0]["maxShowClick"].ToString()); 228
int int_maxClick = int.Parse(dt.Rows[0]["maxClick"].ToString()); 229
int int_ClickNum = int.Parse(dt.Rows[0][&quo






