|
对于很多使用dz论坛运营的站长们,初始为了吸引人气可能会使用采集器,但论坛上全部都是几个用户在发帖回贴。于是便使用C#来批量修改发帖人和回贴人,制造论坛用户活跃的假象。代码如下,需要详细的请联系本站长。使用时需要使用MYSQL数据库连接库mysql-connector-net-6.8.3,注意MYSQL不支持OLEDB的自动更新语句,需要手工写更新代码。 - DataSet DiscuzDZDS = new DataSet();
- string DZConnectionString = "server=localhost;user id=root; password=*; database=ultrax; pooling=false;charset=utf8 ";
- string SqlText = "SELECT uid,username FROM pre_common_member order by regdate limit 100 ";// "dnt_users";
- //MySqlConnection connection = new MySqlConnection(DZConnectionString);
- //connection.Open();
- MySqlDataAdapter users_newsAdapter = new MySqlDataAdapter(SqlText, DZConnectionString);
- MySqlCommandBuilder users_newsCommandBuilder = new MySqlCommandBuilder(users_newsAdapter);
- users_newsAdapter.Fill(DiscuzDZDS, "pre_common_member");
- //List<int> ID = new List<int>();
- string topicSqlText = "SELECT * FROM pre_forum_thread where author='xycost'";// "dnt_topics";
- MySqlDataAdapter dz_topicAdapter = new MySqlDataAdapter(topicSqlText, DZConnectionString);
- //MySqlCommandBuilder dz_topicCommandBuilder = new MySqlCommandBuilder(dz_topicAdapter);
- dz_topicAdapter.Fill(DiscuzDZDS, "pre_forum_thread");
- DataRow[] PostRows = DiscuzDZDS.Tables["pre_forum_thread"].Select();
- int postnum = 0;
- for (int j = 0; j < PostRows.Length; j++)
- {
- //if (j == 1)
- // break;
- DataRow TopicsRow = PostRows[j];
- Random random = new Random();
- int UserNum = random.Next(1, DiscuzDZDS.Tables["pre_common_member"].Select().Length);
- DataRow UserRow = DiscuzDZDS.Tables["pre_common_member"].Select()[UserNum];
-
- int uid = Convert.ToInt32(UserRow["uid"]);
- string username = UserRow["username"].ToString();
- postnum++;
- //TopicsRow["author"] = username;
- //TopicsRow["authorid"] = uid;
- int tid =Convert.ToInt32( TopicsRow["tid"]);
- try
- {
- string sql = "update pre_forum_thread set author=?author,authorid=?authorid where tid=?tid";
- MySqlParameter[] parameters = new MySqlParameter[3];
- parameters[0] = new MySqlParameter("?author", MySqlDbType.VarChar, 50);
- parameters[0].Value = username ;
- parameters[1] = new MySqlParameter("?authorid", MySqlDbType.Int32);
- parameters[1].Value = uid;
-
- parameters[2] = new MySqlParameter("?tid", MySqlDbType.Int32);
- parameters[2].Value = tid;
- ExecuteNonQuery(sql, parameters,DZConnectionString);
- string postSqlText = "SELECT * FROM pre_forum_post where tid="+tid;// "dnt_topics";
- MySqlDataAdapter dz_postAdapter = new MySqlDataAdapter(postSqlText, DZConnectionString);
- //MySqlCommandBuilder dz_postCommandBuilder = new MySqlCommandBuilder(dz_postAdapter);
- if (DiscuzDZDS.Tables.Contains("pre_forum_post"))
- DiscuzDZDS.Tables["pre_forum_post"].Clear();
- dz_postAdapter.Fill(DiscuzDZDS, "pre_forum_post");
-
- foreach (DataRow postrow in DiscuzDZDS.Tables["pre_forum_post"].Select())
- {
- sql = "update pre_forum_post set author=?author,authorid=?authorid where pid=?pid";
- int pid = Convert.ToInt32(postrow["pid"]);
- if (Convert.ToInt32(postrow["first"]) == 1)
- {
- parameters = new MySqlParameter[3];
- parameters[0] = new MySqlParameter("?author", MySqlDbType.VarChar, 50);
- parameters[0].Value = username;
- parameters[1] = new MySqlParameter("?authorid", MySqlDbType.Int32);
- parameters[1].Value = uid;
- parameters[2] = new MySqlParameter("?pid", MySqlDbType.Int32);
- parameters[2].Value = pid;
- }
- else
- {
- UserNum = random.Next(1, DiscuzDZDS.Tables["pre_common_member"].Select().Length);
- UserRow = DiscuzDZDS.Tables["pre_common_member"].Select()[UserNum];
- uid = Convert.ToInt32(UserRow["uid"]);
- username = UserRow["username"].ToString();
- parameters = new MySqlParameter[3];
- parameters[0] = new MySqlParameter("?author", MySqlDbType.VarChar, 50);
- parameters[0].Value = username;
- parameters[1] = new MySqlParameter("?authorid", MySqlDbType.Int32);
- parameters[1].Value = uid;
- parameters[2] = new MySqlParameter("?pid", MySqlDbType.Int32);
- parameters[2].Value = pid;
- }
- ExecuteNonQuery(sql, parameters, DZConnectionString);
- }
- //DataTable changes = DiscuzDZDS.Tables["pre_forum_post"].GetChanges();
- //dnt_topicsAdapter.Update(changes);
- //DiscuzDZDS.Tables["pre_forum_post"].AcceptChanges();
- //dnt_topicsAdapter.Update(DiscuzDZDS, "pre_forum_post");
- }
- catch(Exception ){}
- }
-
复制代码
|
|