[BlackBox项目]Plog用户操作分析

1、添加Plog用户
===============
Step 1: 检查用户是否存在

Step 2: 添加用户
$query = "INSERT INTO ".$this->getPrefix()."users(user,password,email,about) VALUES ('".Db::qstr($userName)."','".md5($password)."','".Db::qstr($email)."','');";


2、添加Blog
===============
Step 1: 检查用户是否存在

Step 2: 添加Blog
$query = "INSERT INTO ".$this->getPrefix()."blogs (blog,owner_id,about,settings) "."VALUES ('".Db::qstr($name)."',$ownerId,'', '".serialize($blogSettings)."');";

Step 3: 添加bayesian过滤器
$query = "INSERT INTO ".$this->getPrefix()."bayesian_filter_info (blog_id, total_spam, total_nonspam) VALUES ('$blogId', '0', '0');";

Step 4: 创建默认分类和文章

3、删除Plog用户
===============
Step 1: 收回权限
$query = "DELETE FROM ".$this->getPrefix()."users_permissions WHERE user_id = $userId";

Step 2: 删除用户
$query = "DELETE FROM ".$this->getPrefix()."users WHERE id = $userId;";


4、删除Blog
===============
Step 1: 删除文章
删除文章内容
$query = "DELETE FROM ".$this->getPrefix()."articles WHERE id = ".$artId." AND user_id = ".$userId." AND blog_id = ".$blogId.";";
逐个删除评论
$query = "DELETE FROM ".$this->getPrefix()."articles_comments WHERE id = ".$commentid." AND article_id = ".$artid.";";
$query = "UPDATE ".$this->getPrefix()."articles_comments SET parent_id = 0 WHERE parent_id = ".$commentid." AND article_id = ".$artid.";";
逐个删除Trackbacks
$query = "DELETE FROM ".$this->getPrefix()."trackbacks WHERE article_id = $artId";

Step 2: 删除文章分类
$query = "DELETE FROM ".$this->getPrefix()."articles_categories WHERE blog_id = $blogId";

Step 3: 删除连接和连接分类
删除连接
$query = "DELETE FROM ".$this->getPrefix()."mylinks WHERE blog_id = $blogId";
删除连接分类
$query = "DELETE FROM ".$this->getPrefix()."mylinks_categories WHERE blog_id = $blogId";

Step 4: 收回权限
$query = "DELETE FROM ".$this->getPrefix()."users_permissions WHERE blog_id = $blogId";

Step 5: 删除Blog
$query = "DELETE FROM ".$this->getPrefix()."blogs WHERE id = $blogId";

你可能感兴趣的:([BlackBox项目]Plog用户操作分析)