diff --git a/app/controllers/CommentController.php b/app/controllers/CommentController.php index a0b9d72..68c0ee7 100755 --- a/app/controllers/CommentController.php +++ b/app/controllers/CommentController.php @@ -25,7 +25,7 @@ class CommentController extends ApplicationController { $comment = Comment::find($this->params()->id); if (current_user()->has_permission($comment)) { - $comment->updateAttributes($this->params()->comment); + $comment->updateAttributes(array_merge($this->params()->comment, ['updater_ip_addr' => $this->request()->remoteIp()])); $this->respond_to_success("Comment updated", '#index'); } else { $this->access_denied(); @@ -52,7 +52,7 @@ class CommentController extends ApplicationController } $user_id = current_user()->id; -Rails::log($this->params()->comment); + $comment = new Comment(array_merge($this->params()->comment, array('ip_addr' => $this->request()->remoteIp(), 'user_id' => $user_id))); if ($this->params()->commit == "Post without bumping") { $comment->do_not_bump_post = true; diff --git a/app/controllers/DmailController.php b/app/controllers/DmailController.php index 0d4b59a..cbdb903 100755 --- a/app/controllers/DmailController.php +++ b/app/controllers/DmailController.php @@ -36,7 +36,7 @@ class DmailController extends ApplicationController $dmail = $this->params()->dmail; if (empty($dmail['parent_id'])) $dmail['parent_id'] = null; - $this->dmail = Dmail::create(array_merge($dmail, ['from_id' => $this->current_user->id])); + $this->dmail = Dmail::create(array_merge($dmail, ['from_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()])); if ($this->dmail->errors()->none()) { $this->notice("Message sent to ".$dmail['to_name']); diff --git a/app/controllers/ForumController.php b/app/controllers/ForumController.php index e9e0f19..12d3450 100755 --- a/app/controllers/ForumController.php +++ b/app/controllers/ForumController.php @@ -65,7 +65,7 @@ class ForumController extends ApplicationController if (empty($params['parent_id']) || !ctype_digit($params['parent_id'])) $params['parent_id'] = null; - $this->forum_post = ForumPost::create(array_merge($params, ['creator_id' => $this->current_user->id])); + $this->forum_post = ForumPost::create(array_merge($params, ['creator_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()])); if ($this->forum_post->errors()->blank()) { if (!$this->params()->forum_post['parent_id']) { @@ -120,7 +120,7 @@ class ForumController extends ApplicationController return; } - $this->forum_post->assignAttributes($this->params()->forum_post); + $this->forum_post->assignAttributes(array_merge($this->params()->forum_post, ['updater_ip_addr' => $this->request()->remoteIp()]); if ($this->forum_post->save()) { $this->notice("Post updated"); diff --git a/db/migrate/20131118024736_create_advertisements.php b/db/migrate/20131118024736_create_advertisements.php index 32b24e9..cc44b58 100755 --- a/db/migrate/20131118024736_create_advertisements.php +++ b/db/migrate/20131118024736_create_advertisements.php @@ -1,7 +1,7 @@ createTable('advertisements', function($t) { $t->column('image_url', 'string', ['null' => false]); diff --git a/db/migrate/20131118173429_add_ip_addr_to_dmails.php b/db/migrate/20131118173429_add_ip_addr_to_dmails.php new file mode 100755 index 0000000..d9872be --- /dev/null +++ b/db/migrate/20131118173429_add_ip_addr_to_dmails.php @@ -0,0 +1,8 @@ +addColumn('dmails', 'ip_addr', 'string', ['length' => 46]); + } +} diff --git a/db/migrate/20131118173629_add_ip_addr_to_forum_posts.php b/db/migrate/20131118173629_add_ip_addr_to_forum_posts.php new file mode 100755 index 0000000..d485a56 --- /dev/null +++ b/db/migrate/20131118173629_add_ip_addr_to_forum_posts.php @@ -0,0 +1,9 @@ +addColumn('forum_posts', 'ip_addr', 'string', ['length' => 46]); + $this->addColumn('forum_posts', 'updater_ip_addr', 'string', ['length' => 46]); + } +} diff --git a/db/migrate/20131118173949_add_updater_ip_addr_to_comments.php b/db/migrate/20131118173949_add_updater_ip_addr_to_comments.php new file mode 100755 index 0000000..d5f4cf4 --- /dev/null +++ b/db/migrate/20131118173949_add_updater_ip_addr_to_comments.php @@ -0,0 +1,8 @@ +addColumn('comments', 'updater_ip_addr', 'string', ['limit' => 46]); + } +} diff --git a/db/seeds.php b/db/seeds.php new file mode 100755 index 0000000..a4abe2d --- /dev/null +++ b/db/seeds.php @@ -0,0 +1,2 @@ + + array ( + 'id' => + array ( + 'type' => 'int(11)', + 'default' => NULL, + ), + 'image_url' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + 'referral_url' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + 'ad_type' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + 'status' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + 'hit_count' => + array ( + 'type' => 'int(11)', + 'default' => '0', + ), + 'width' => + array ( + 'type' => 'int(11)', + 'default' => NULL, + ), + 'height' => + array ( + 'type' => 'int(11)', + 'default' => NULL, + ), + ), + 1 => + array ( + 'pri' => + array ( + 0 => 'id', + ), + ), +) +; \ No newline at end of file diff --git a/db/table_schema/production/comments.php b/db/table_schema/production/comments.php index f3528e5..65cb178 100755 --- a/db/table_schema/production/comments.php +++ b/db/table_schema/production/comments.php @@ -42,6 +42,11 @@ return array ( 'type' => 'tinyint(1)', 'default' => '0', ), + 'updater_ip_addr' => + array ( + 'type' => 'varchar(46)', + 'default' => NULL, + ), ), 1 => array ( diff --git a/db/table_schema/production/dmails.php b/db/table_schema/production/dmails.php index a2a03c4..dee7a17 100755 --- a/db/table_schema/production/dmails.php +++ b/db/table_schema/production/dmails.php @@ -42,6 +42,11 @@ return array ( 'type' => 'int(11)', 'default' => NULL, ), + 'ip_addr' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), ), 1 => array ( diff --git a/db/table_schema/production/forum_posts.php b/db/table_schema/production/forum_posts.php index 2ce9e22..deb7779 100755 --- a/db/table_schema/production/forum_posts.php +++ b/db/table_schema/production/forum_posts.php @@ -62,6 +62,16 @@ return array ( 'type' => 'text', 'default' => NULL, ), + 'ip_addr' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + 'updater_ip_addr' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), ), 1 => array ( diff --git a/db/table_schema/production/schema_migrations.php b/db/table_schema/production/schema_migrations.php new file mode 100644 index 0000000..9538984 --- /dev/null +++ b/db/table_schema/production/schema_migrations.php @@ -0,0 +1,15 @@ + + array ( + 'version' => + array ( + 'type' => 'varchar(255)', + 'default' => NULL, + ), + ), + 1 => + array ( + ), +) +; \ No newline at end of file